@patternfly/pfe-core 2.0.0-next.8 → 2.0.0-rc.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.
Files changed (77) hide show
  1. package/README.md +2 -2
  2. package/controllers/cascade-controller.js +136 -2
  3. package/controllers/cascade-controller.js.map +1 -7
  4. package/controllers/css-variable-controller.js +13 -2
  5. package/controllers/css-variable-controller.js.map +1 -7
  6. package/controllers/floating-dom-controller.d.ts +35 -14
  7. package/controllers/floating-dom-controller.js +115 -2
  8. package/controllers/floating-dom-controller.js.map +1 -7
  9. package/controllers/internals-controller.d.ts +52 -0
  10. package/controllers/internals-controller.js +52 -0
  11. package/controllers/internals-controller.js.map +1 -0
  12. package/controllers/light-dom-controller.js +38 -2
  13. package/controllers/light-dom-controller.js.map +1 -7
  14. package/controllers/logger.js +90 -2
  15. package/controllers/logger.js.map +1 -7
  16. package/controllers/perf-controller.js +36 -2
  17. package/controllers/perf-controller.js.map +1 -7
  18. package/controllers/property-observer-controller.d.ts +3 -3
  19. package/controllers/property-observer-controller.js +33 -2
  20. package/controllers/property-observer-controller.js.map +1 -7
  21. package/controllers/roving-tabindex-controller.d.ts +48 -0
  22. package/controllers/roving-tabindex-controller.js +166 -0
  23. package/controllers/roving-tabindex-controller.js.map +1 -0
  24. package/controllers/scroll-spy-controller.d.ts +37 -0
  25. package/controllers/scroll-spy-controller.js +120 -0
  26. package/controllers/scroll-spy-controller.js.map +1 -0
  27. package/controllers/slot-controller.d.ts +3 -3
  28. package/controllers/slot-controller.js +148 -2
  29. package/controllers/slot-controller.js.map +1 -7
  30. package/controllers/style-controller.js +42 -2
  31. package/controllers/style-controller.js.map +1 -7
  32. package/core.d.ts +1 -1
  33. package/core.js +68 -2
  34. package/core.js.map +1 -7
  35. package/custom-elements.json +6315 -1
  36. package/decorators/bound.js +27 -2
  37. package/decorators/bound.js.map +1 -7
  38. package/decorators/cascades.js +18 -2
  39. package/decorators/cascades.js.map +1 -7
  40. package/decorators/deprecation.d.ts +1 -1
  41. package/decorators/deprecation.js +44 -2
  42. package/decorators/deprecation.js.map +1 -7
  43. package/decorators/initializer.js +21 -2
  44. package/decorators/initializer.js.map +1 -7
  45. package/decorators/observed.d.ts +1 -1
  46. package/decorators/observed.js +52 -2
  47. package/decorators/observed.js.map +1 -7
  48. package/decorators/time.js +36 -2
  49. package/decorators/time.js.map +1 -7
  50. package/decorators/trace.js +21 -2
  51. package/decorators/trace.js.map +1 -7
  52. package/decorators.d.ts +0 -2
  53. package/decorators.js +8 -2
  54. package/decorators.js.map +1 -7
  55. package/functions/debounce.js +28 -2
  56. package/functions/debounce.js.map +1 -7
  57. package/functions/deprecatedCustomEvent.js +12 -2
  58. package/functions/deprecatedCustomEvent.js.map +1 -7
  59. package/functions/isElementInView.d.ts +12 -0
  60. package/functions/isElementInView.js +31 -0
  61. package/functions/isElementInView.js.map +1 -0
  62. package/functions/random.js +9 -2
  63. package/functions/random.js.map +1 -7
  64. package/package.json +13 -24
  65. package/context.d.ts +0 -53
  66. package/context.js +0 -2
  67. package/context.js.map +0 -7
  68. package/controllers/color-context.d.ts +0 -114
  69. package/controllers/color-context.js +0 -2
  70. package/controllers/color-context.js.map +0 -7
  71. package/controllers/color-context.scss +0 -84
  72. package/decorators/color-context.d.ts +0 -4
  73. package/decorators/color-context.js +0 -2
  74. package/decorators/color-context.js.map +0 -7
  75. package/decorators/pfelement.d.ts +0 -10
  76. package/decorators/pfelement.js +0 -2
  77. package/decorators/pfelement.js.map +0 -7
package/README.md CHANGED
@@ -19,8 +19,8 @@ Utilities for building PatternFly elements.
19
19
  - `@cascades` - cascades the decorated property to configured light and shadow child elements
20
20
  - `@initializer` - executes a decorated method when the element upgrades and on DOM mutations (opt-out)
21
21
  - `@observed` - runs a callback when the decorated property changes
22
- - `@pfelement` - enabled body auto-reveal as well as colour context and other PFE features
23
- - `@time` - tracks the time a method takes to complete using the [performance API](https://developer.mozilla.org/en-US/docs/Web/API/Performance)
22
+ - `@time` - tracks the time a method takes to complete using the [performance
23
+ API](https://developer.mozilla.org/en-US/docs/Web/API/Performance)
24
24
  - `@trace` - debug decorator which logs the name and result of a class method whenever it runs
25
25
 
26
26
  ## Directives
@@ -1,2 +1,136 @@
1
- var p=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var h=(a,t,e,s)=>{for(var i=s>1?void 0:s?l(t,e):t,o=a.length-1,r;o>=0;o--)(r=a[o])&&(i=(s?r(t,e,i):r(i))||i);return s&&i&&p(t,e,i),i};import{bound as f}from"../decorators/bound.js";import{debounce as d}from"../functions/debounce.js";import{Logger as g}from"./logger.js";var n=class{constructor(t,e){this.host=t;this.options=e;this.mo=new MutationObserver(this.parse);this.cache=new Map;this.class=t.constructor,this.logger=new g(this.host),n.instances.set(t,this);let s=this.options?.properties??{};for(let[i,o]of Object.entries(s))this.initProp(i,o);t.addController(this),this.cascadeProperties=d(this.cascadeProperties,1)}hostUpdated(){this.cascadeProperties()}hostConnected(){this.mo.observe(this.host,{attributes:!0,childList:!0}),this.cascadeProperties()}hostDisconnected(){this.mo.disconnect()}cascadeProperties(t=this.host.children){if(this.host.isConnected){let e=this.cache.keys();if(!t)return this._cascadeAttributes(e,this.cache);for(let s of t)if(s instanceof Element){for(let i of e)if(s.matches(i)){let o=this.cache.get(i);for(let r of o??[])this._copyAttribute(r,s)}}}}initProp(t,e){for(let s of[e].flat(1/0).filter(Boolean)){let{attribute:i}=this.class.getPropertyOptions(t),o=typeof i=="string"?i:t.toLowerCase();this.cache.get(s)?this.cache.get(s)?.push(o):this.cache.set(s,[o])}}parse(t){for(let e of t??[])e.type==="childList"&&e.addedNodes.length?this.cascadeProperties(e.addedNodes):e.type==="attributes"&&this._cascadeAttributes(this.cache.keys(),this.cache)}async _copyAttribute(t,e){this.logger.log(`copying ${t} to ${e}`);let s=this.host.getAttribute(t);e.isConnected&&(s==null?e.removeAttribute(t):e.setAttribute(t,s))}_cascadeAttributes(t,e){for(let s of t)for(let i of e.get(s)??[])this._cascadeAttribute(i,s)}_cascadeAttribute(t,e){let s=[...this.host.querySelectorAll(e),...this.host.shadowRoot?.querySelectorAll(e)??[]];for(let i of s)this._copyAttribute(t,i)}},c=n;c.instances=new WeakMap,h([f],c.prototype,"parse",1);export{c as CascadeController};
2
- //# sourceMappingURL=cascade-controller.js.map
1
+ import { __decorate } from "tslib";
2
+ import { bound } from '../decorators/bound.js';
3
+ import { debounce } from '../functions/debounce.js';
4
+ import { Logger } from './logger.js';
5
+ export class CascadeController {
6
+ constructor(host, options) {
7
+ this.host = host;
8
+ this.options = options;
9
+ this.mo = new MutationObserver(this.parse);
10
+ this.cache = new Map();
11
+ this.class = host.constructor;
12
+ this.logger = new Logger(this.host);
13
+ CascadeController.instances.set(host, this);
14
+ const properties = this.options?.properties ?? {};
15
+ for (const [propName, cascade] of Object.entries(properties)) {
16
+ this.initProp(propName, cascade);
17
+ }
18
+ host.addController(this);
19
+ this.cascadeProperties = debounce(this.cascadeProperties, 1);
20
+ }
21
+ hostUpdated() {
22
+ this.cascadeProperties();
23
+ }
24
+ hostConnected() {
25
+ this.mo.observe(this.host, { attributes: true, childList: true });
26
+ this.cascadeProperties();
27
+ }
28
+ hostDisconnected() {
29
+ this.mo.disconnect();
30
+ }
31
+ /**
32
+ * Handles the cascading of properties to nested components when new elements are added
33
+ * Attribute updates/additions are handled by the attribute callback
34
+ */
35
+ cascadeProperties(nodeList = this.host.children) {
36
+ if (this.host.isConnected) {
37
+ const selectors = this.cache.keys();
38
+ // Find out if anything in the nodeList matches any of the observed selectors for cacading properties
39
+ if (!nodeList) {
40
+ return this._cascadeAttributes(selectors, this.cache);
41
+ }
42
+ for (const node of nodeList) {
43
+ // if this node has a match function (i.e., it's an HTMLElement, not a text node),
44
+ if (node instanceof Element) {
45
+ // see if it matches one of the selectors, otherwise drop it (like it's hot).
46
+ for (const selector of selectors) {
47
+ // console.log('_copyAttribute', name, value, el.getAttribute(name));
48
+ if (node.matches(selector)) {
49
+ const attrNames = this.cache.get(selector);
50
+ // each selector can match multiple properties/attributes, so
51
+ // copy each of them
52
+ for (const attrName of attrNames ?? []) {
53
+ this._copyAttribute(attrName, node);
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ /**
62
+ * Gets the configured attribute name for the decorated property,
63
+ * falling back to the lowercased property name, and caches the attribute name
64
+ * with it's designated child selectors for value-propagation on change
65
+ */
66
+ initProp(propName, cascade) {
67
+ for (const nodeItem of [cascade].flat(Infinity).filter(Boolean)) {
68
+ const { attribute } = this.class.getPropertyOptions(propName);
69
+ const attr = typeof attribute === 'string' ? attribute
70
+ : propName.toLowerCase();
71
+ // Create an object with the node as the key and an array of attributes
72
+ // that are to be cascaded down to it
73
+ if (!this.cache.get(nodeItem)) {
74
+ this.cache.set(nodeItem, [attr]);
75
+ }
76
+ else {
77
+ this.cache.get(nodeItem)?.push(attr);
78
+ }
79
+ }
80
+ }
81
+ parse(mutations) {
82
+ // Iterate over the mutation list, look for cascade updates
83
+ for (const mutation of mutations ?? []) {
84
+ // If a new node is added, attempt to cascade attributes to it
85
+ if (mutation.type === 'childList' && mutation.addedNodes.length) {
86
+ this.cascadeProperties(mutation.addedNodes);
87
+ }
88
+ else if (mutation.type === 'attributes') {
89
+ this._cascadeAttributes(this.cache.keys(), this.cache);
90
+ }
91
+ }
92
+ }
93
+ /**
94
+ * Copy the named attribute to a target element.
95
+ */
96
+ async _copyAttribute(name, el) {
97
+ this.logger.log(`copying ${name} to ${el}`);
98
+ const value = this.host.getAttribute(name);
99
+ if (el.isConnected) {
100
+ if (value == null) {
101
+ el.removeAttribute(name);
102
+ }
103
+ else {
104
+ el.setAttribute(name, value);
105
+ }
106
+ }
107
+ }
108
+ _cascadeAttributes(selectors, set) {
109
+ for (const selector of selectors) {
110
+ for (const attr of set.get(selector) ?? []) {
111
+ this._cascadeAttribute(attr, selector);
112
+ }
113
+ }
114
+ }
115
+ /**
116
+ * Trigger a cascade of the named attribute to any child elements that match
117
+ * the `to` selector. The selector can match elements in the light DOM and
118
+ * shadow DOM.
119
+ * @param name The name of the attribute to cascade (not necessarily the same as the property name).
120
+ * @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.
121
+ */
122
+ _cascadeAttribute(name, to) {
123
+ const recipients = [
124
+ ...this.host.querySelectorAll(to),
125
+ ...this.host.shadowRoot?.querySelectorAll(to) ?? [],
126
+ ];
127
+ for (const node of recipients) {
128
+ this._copyAttribute(name, node);
129
+ }
130
+ }
131
+ }
132
+ CascadeController.instances = new WeakMap();
133
+ __decorate([
134
+ bound
135
+ ], CascadeController.prototype, "parse", null);
136
+ //# sourceMappingURL=cascade-controller.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["cascade-controller.ts"],
4
- "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\nexport interface Options<E extends ReactiveElement> {\n properties: Partial<Record<keyof E, string|string[]>>;\n prefix?: string;\n}\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"],
5
- "mappings": "wMAEA,OAAS,SAAAA,MAAa,yBACtB,OAAS,YAAAC,MAAgB,2BACzB,OAAS,UAAAC,MAAc,cAOhB,IAAMC,EAAN,KAAiF,CAWtF,YAAmBC,EAAgBC,EAAsB,CAAtC,UAAAD,EAAgB,aAAAC,EAJnC,QAAK,IAAI,iBAAiB,KAAK,KAAK,EAEpC,WAAQ,IAAI,IAGV,KAAK,MAAQD,EAAK,YAClB,KAAK,OAAS,IAAIE,EAAO,KAAK,IAAI,EAClCH,EAAkB,UAAU,IAAIC,EAAM,IAAI,EAC1C,IAAMG,EAAa,KAAK,SAAS,YAAc,CAAC,EAChD,OAAW,CAACC,EAAUC,CAAO,IAAK,OAAO,QAAQF,CAAU,EACzD,KAAK,SAASC,EAAUC,CAAO,EAEjCL,EAAK,cAAc,IAAI,EACvB,KAAK,kBAAoBM,EAAS,KAAK,kBAAmB,CAAC,CAC7D,CAEA,aAAc,CACZ,KAAK,kBAAkB,CACzB,CAEA,eAAgB,CACd,KAAK,GAAG,QAAQ,KAAK,KAAM,CAAE,WAAY,GAAM,UAAW,EAAK,CAAC,EAChE,KAAK,kBAAkB,CACzB,CAEA,kBAAmB,CACjB,KAAK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mBAAmBZ,EAAqCa,EAAoB,CAClF,QAAWX,KAAYF,EACrB,QAAWO,KAAQM,EAAI,IAAIX,CAAQ,GAAK,CAAC,EACvC,KAAK,kBAAkBK,EAAML,CAAQ,CAG3C,CASQ,kBAAkBQ,EAAcI,EAAY,CAClD,IAAMC,EAAa,CACjB,GAAG,KAAK,KAAK,iBAAiBD,CAAE,EAChC,GAAG,KAAK,KAAK,YAAY,iBAAiBA,CAAE,GAAK,CAAC,CACpD,EAEA,QAAWb,KAAQc,EACjB,KAAK,eAAeL,EAAMT,CAAI,CAElC,CACF,EAjJae,EAANzB,EAAMyB,EAKJ,UAA0E,IAAI,QAwFtEC,EAAA,CAAfC,GA7FWF,EA6FI",
6
- "names": ["bound", "debounce", "Logger", "_CascadeController", "host", "options", "Logger", "properties", "propName", "cascade", "debounce", "nodeList", "selectors", "node", "selector", "attrNames", "attrName", "nodeItem", "attribute", "attr", "mutations", "mutation", "name", "el", "value", "set", "to", "recipients", "CascadeController", "__decorateClass", "bound"]
7
- }
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;AAOrC,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,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AAI,EAAE;SACpD,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE;YAC7B,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACjC;IACH,CAAC;;AA3IM,2BAAS,GAAiE,IAAI,OAAO,EAAE,CAAC;AAwFxF;IAAN,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\nexport interface Options<E extends ReactiveElement> {\n properties: Partial<Record<keyof E, string|string[]>>;\n prefix?: string;\n}\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,2 +1,13 @@
1
- var e=class{constructor(t){this.host=t;this.style=window.getComputedStyle(t)}parseProperty(t){return t.substr(0,2)!=="--"?`--${t}`:t}getVariable(t){return this.style.getPropertyValue(this.parseProperty(t)).trim()||null}};export{e as CssVariableController};
2
- //# sourceMappingURL=css-variable-controller.js.map
1
+ export class CssVariableController {
2
+ constructor(host) {
3
+ this.host = host;
4
+ this.style = window.getComputedStyle(host);
5
+ }
6
+ parseProperty(name) {
7
+ return name.substr(0, 2) !== '--' ? `--${name}` : name;
8
+ }
9
+ getVariable(name) {
10
+ return this.style.getPropertyValue(this.parseProperty(name)).trim() || null;
11
+ }
12
+ }
13
+ //# sourceMappingURL=css-variable-controller.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["css-variable-controller.ts"],
4
- "sourcesContent": ["import type { ReactiveElement, ReactiveController } from 'lit';\n\nexport class CssVariableController implements ReactiveController {\n style: CSSStyleDeclaration;\n\n constructor(public host: ReactiveElement) {\n this.style = window.getComputedStyle(host);\n }\n\n private parseProperty(name: string) {\n return name.substr(0, 2) !== '--' ? `--${name}` : name;\n }\n\n getVariable(name: string) {\n return this.style.getPropertyValue(this.parseProperty(name)).trim() || null;\n }\n\n hostConnected?(): void\n}\n"],
5
- "mappings": "AAEO,IAAMA,EAAN,KAA0D,CAG/D,YAAmBC,EAAuB,CAAvB,UAAAA,EACjB,KAAK,MAAQ,OAAO,iBAAiBA,CAAI,CAC3C,CAEQ,cAAcC,EAAc,CAClC,OAAOA,EAAK,OAAO,EAAG,CAAC,IAAM,KAAO,KAAKA,IAASA,CACpD,CAEA,YAAYA,EAAc,CACxB,OAAO,KAAK,MAAM,iBAAiB,KAAK,cAAcA,CAAI,CAAC,EAAE,KAAK,GAAK,IACzE,CAGF",
6
- "names": ["CssVariableController", "host", "name"]
7
- }
1
+ {"version":3,"file":"css-variable-controller.js","sourceRoot":"","sources":["css-variable-controller.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,qBAAqB;IAGhC,YAAmB,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;QACtC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,aAAa,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC;IAC9E,CAAC;CAGF","sourcesContent":["import type { ReactiveElement, ReactiveController } from 'lit';\n\nexport class CssVariableController implements ReactiveController {\n style: CSSStyleDeclaration;\n\n constructor(public host: ReactiveElement) {\n this.style = window.getComputedStyle(host);\n }\n\n private parseProperty(name: string) {\n return name.substr(0, 2) !== '--' ? `--${name}` : name;\n }\n\n getVariable(name: string) {\n return this.style.getPropertyValue(this.parseProperty(name)).trim() || null;\n }\n\n hostConnected?(): void\n}\n"]}
@@ -1,28 +1,49 @@
1
+ import type { Placement } from '@floating-ui/dom';
1
2
  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}`;
3
+ import type { StyleInfo } from 'lit/directives/style-map.js';
4
+ import type { Options as Offset } from '@floating-ui/core/src/middleware/offset';
5
+ export { Placement };
6
+ type Lazy<T> = T | (() => T | null | undefined);
7
+ interface FloatingDOMControllerOptions {
8
+ content: Lazy<HTMLElement>;
9
+ invoker?: Lazy<HTMLElement>;
10
+ arrow?: boolean;
11
+ flip?: boolean;
12
+ shift?: boolean;
13
+ padding?: number;
14
+ }
15
+ interface ShowOptions {
16
+ offset?: Offset;
17
+ placement?: Placement;
18
+ }
19
+ export type Anchor = '' | 'top' | 'left' | 'bottom' | 'right';
20
+ export type Alignment = 'center' | 'start' | 'end';
8
21
  /**
9
22
  * Controls floating DOM within a web component, e.g. tooltips and popovers
10
23
  */
11
24
  export declare class FloatingDOMController implements ReactiveController {
12
25
  #private;
13
26
  private host;
27
+ /** The crosswise alignment of the invoker on which to display the floating DOM */
28
+ get alignment(): Alignment;
29
+ /** The side of the invoker on which to display the floating DOM */
30
+ get anchor(): Anchor;
14
31
  /**
15
32
  * When true, the floating DOM is visible
16
33
  */
17
34
  get open(): boolean;
18
- set open(value: boolean);
19
- constructor(host: ReactiveElement);
20
- hostConnected?(): void;
35
+ /** The computed placement of the floating DOM */
36
+ get placement(): Placement;
37
+ /**
38
+ * Styles to apply to your element's container
39
+ *
40
+ * - `--_floating-content-translate`: translate to apply to floating content.
41
+ */
42
+ get styles(): StyleInfo;
43
+ constructor(host: ReactiveElement, options: FloatingDOMControllerOptions);
44
+ hostDisconnected(): void;
21
45
  /** Show the floating DOM */
22
- show(): void;
46
+ show({ offset, placement }?: ShowOptions): Promise<void>;
23
47
  /** Hide the floating DOM */
24
- hide(): void;
25
- /** Initialize the floating DOM */
26
- create(invoker: Element, content: HTMLElement, placement: Placement, offset?: number[]): void;
48
+ hide(): Promise<void>;
27
49
  }
28
- export {};
@@ -1,2 +1,115 @@
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
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_update;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { autoUpdate, computePosition, offset as offsetMiddleware, shift as shiftMiddleware, flip as flipMiddleware, } from '@floating-ui/dom';
4
+ /**
5
+ * Controls floating DOM within a web component, e.g. tooltips and popovers
6
+ */
7
+ export class FloatingDOMController {
8
+ /** The crosswise alignment of the invoker on which to display the floating DOM */
9
+ get alignment() {
10
+ return __classPrivateFieldGet(this, _FloatingDOMController_alignment, "f") ?? 'center';
11
+ }
12
+ /** The side of the invoker on which to display the floating DOM */
13
+ get anchor() {
14
+ return __classPrivateFieldGet(this, _FloatingDOMController_anchor, "f") ?? '';
15
+ }
16
+ /**
17
+ * When true, the floating DOM is visible
18
+ */
19
+ get open() {
20
+ return __classPrivateFieldGet(this, _FloatingDOMController_open, "f");
21
+ }
22
+ /** The computed placement of the floating DOM */
23
+ get placement() {
24
+ return __classPrivateFieldGet(this, _FloatingDOMController_placement, "f") ?? 'top';
25
+ }
26
+ /**
27
+ * Styles to apply to your element's container
28
+ *
29
+ * - `--_floating-content-translate`: translate to apply to floating content.
30
+ */
31
+ get styles() {
32
+ return __classPrivateFieldGet(this, _FloatingDOMController_styles, "f") ?? {};
33
+ }
34
+ constructor(host, options) {
35
+ var _a, _b, _c, _d;
36
+ this.host = host;
37
+ _FloatingDOMController_instances.add(this);
38
+ _FloatingDOMController_open.set(this, false);
39
+ _FloatingDOMController_opening.set(this, false);
40
+ _FloatingDOMController_cleanup.set(this, void 0);
41
+ _FloatingDOMController_anchor.set(this, void 0);
42
+ _FloatingDOMController_alignment.set(this, void 0);
43
+ _FloatingDOMController_styles.set(this, void 0);
44
+ _FloatingDOMController_placement.set(this, void 0);
45
+ _FloatingDOMController_options.set(this, void 0);
46
+ host.addController(this);
47
+ __classPrivateFieldSet(this, _FloatingDOMController_options, options, "f");
48
+ (_a = __classPrivateFieldGet(this, _FloatingDOMController_options, "f")).invoker ?? (_a.invoker = host);
49
+ (_b = __classPrivateFieldGet(this, _FloatingDOMController_options, "f")).arrow ?? (_b.arrow = false);
50
+ (_c = __classPrivateFieldGet(this, _FloatingDOMController_options, "f")).flip ?? (_c.flip = true);
51
+ (_d = __classPrivateFieldGet(this, _FloatingDOMController_options, "f")).shift ?? (_d.shift = true);
52
+ }
53
+ hostDisconnected() {
54
+ __classPrivateFieldGet(this, _FloatingDOMController_cleanup, "f")?.call(this);
55
+ }
56
+ /** Show the floating DOM */
57
+ async show({ offset, placement } = {}) {
58
+ const invoker = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_invoker_get);
59
+ const content = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_content_get);
60
+ if (!invoker || !content) {
61
+ return;
62
+ }
63
+ if (!__classPrivateFieldGet(this, _FloatingDOMController_opening, "f")) {
64
+ __classPrivateFieldSet(this, _FloatingDOMController_opening, true, "f");
65
+ const p = __classPrivateFieldGet(this, _FloatingDOMController_instances, "m", _FloatingDOMController_update).call(this, placement, offset);
66
+ __classPrivateFieldSet(this, _FloatingDOMController_cleanup, __classPrivateFieldGet(this, _FloatingDOMController_cleanup, "f") ?? autoUpdate(invoker, content, () => __classPrivateFieldGet(this, _FloatingDOMController_instances, "m", _FloatingDOMController_update).call(this, placement, offset)), "f");
67
+ await p;
68
+ __classPrivateFieldSet(this, _FloatingDOMController_opening, false, "f");
69
+ }
70
+ __classPrivateFieldSet(this, _FloatingDOMController_open, true, "f");
71
+ this.host.requestUpdate();
72
+ }
73
+ /** Hide the floating DOM */
74
+ async hide() {
75
+ await this.host.updateComplete;
76
+ while (__classPrivateFieldGet(this, _FloatingDOMController_opening, "f") && !this.open) {
77
+ await new Promise(requestAnimationFrame);
78
+ }
79
+ __classPrivateFieldSet(this, _FloatingDOMController_open, false, "f");
80
+ __classPrivateFieldGet(this, _FloatingDOMController_cleanup, "f")?.call(this);
81
+ this.host.requestUpdate();
82
+ await this.host.updateComplete;
83
+ }
84
+ }
85
+ _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() {
86
+ const { invoker } = __classPrivateFieldGet(this, _FloatingDOMController_options, "f");
87
+ return typeof invoker === 'function' ? invoker() : invoker;
88
+ }, _FloatingDOMController_content_get = function _FloatingDOMController_content_get() {
89
+ const { content } = __classPrivateFieldGet(this, _FloatingDOMController_options, "f");
90
+ return typeof content === 'function' ? content() : content;
91
+ }, _FloatingDOMController_update = async function _FloatingDOMController_update(placement = 'top', offset) {
92
+ var _a, _b;
93
+ const { flip, padding, shift } = __classPrivateFieldGet(this, _FloatingDOMController_options, "f");
94
+ const invoker = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_invoker_get);
95
+ const content = __classPrivateFieldGet(this, _FloatingDOMController_instances, "a", _FloatingDOMController_content_get);
96
+ if (!invoker || !content) {
97
+ return;
98
+ }
99
+ const { x, y, placement: _placement } = await computePosition(invoker, content, {
100
+ strategy: 'absolute',
101
+ placement,
102
+ middleware: [
103
+ offsetMiddleware(offset),
104
+ shift && shiftMiddleware({ padding }),
105
+ flip && flipMiddleware({ padding }),
106
+ ].filter(Boolean)
107
+ });
108
+ __classPrivateFieldSet(this, _FloatingDOMController_placement, _placement, "f");
109
+ _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('-') ?? []);
110
+ __classPrivateFieldSet(this, _FloatingDOMController_styles, {
111
+ '--_floating-content-translate': `${x}px ${y}px`,
112
+ }, "f");
113
+ this.host.requestUpdate();
114
+ };
115
+ //# sourceMappingURL=floating-dom-controller.js.map
@@ -1,7 +1 @@
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,OACE,eAAAA,EACA,SAAAC,EACA,iBAAAC,EACA,kBAAAC,EACA,QAAAC,EACA,QAAAC,EACA,UAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,mBAAAC,MACK,iBAiBP,IAAMC,EAAeC,EAAgB,CACnC,iBAAkB,CAChBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,CACF,CACF,CAAC,EA3CDC,EAAAC,EAgDaC,EAAN,KAA0D,CAoB/D,YAAoBC,EAAuB,CAAvB,UAAAA,EAnBpBC,EAAA,KAAAJ,EAAQ,IAiBRI,EAAA,KAAAH,EAAA,QAGEE,EAAK,cAAc,IAAI,CACzB,CAhBA,IAAI,MAAO,CACT,OAAOE,EAAA,KAAKL,EACd,CAEA,IAAI,KAAKM,EAAgB,CACvBC,EAAA,KAAKP,EAAQM,GACTA,GACFD,EAAA,KAAKJ,IAAS,OAAO,EAEvB,KAAK,KAAK,cAAc,CAC1B,CAWA,MAAa,CACX,KAAK,KAAO,EACd,CAGA,MAAa,CACX,KAAK,KAAO,EACd,CAGA,OAAOO,EAAkBC,EAAsBC,EAAsBf,EAAyB,CAC5FY,EAAA,KAAKN,EAAUZ,EAAamB,EAASC,EAAS,CAC5C,UAAAC,EACA,UAAW,CACT,CACE,KAAM,SACN,QAAS,CACP,OAAAf,CACF,CACF,EACA,CACE,KAAM,OACN,QAAS,CACP,mBAAoB,CAAC,MAAO,QAAS,OAAQ,QAAQ,CACvD,CACF,CACF,CACF,CAAC,EACH,CACF,EAvDEK,EAAA,YAiBAC,EAAA",
6
- "names": ["applyStyles", "arrow", "computeStyles", "eventListeners", "flip", "hide", "offset", "popperGenerator", "popperOffsets", "preventOverflow", "createPopper", "popperGenerator", "eventListeners", "popperOffsets", "computeStyles", "applyStyles", "offset", "flip", "preventOverflow", "arrow", "hide", "_open", "_popper", "FloatingDOMController", "host", "__privateAdd", "__privateGet", "value", "__privateSet", "invoker", "content", "placement"]
7
- }
1
+ {"version":3,"file":"floating-dom-controller.js","sourceRoot":"","sources":["floating-dom-controller.ts"],"names":[],"mappings":";;AAQA,OAAO,EACL,UAAU,EACV,eAAe,EACf,MAAM,IAAI,gBAAgB,EAC1B,KAAK,IAAI,eAAe,EACxB,IAAI,IAAI,cAAc,GACvB,MAAM,kBAAkB,CAAC;AAqB1B;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAoBhC,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,iDAA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;;IACzD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,uBAAA,IAAI,sCAAS,CAAC;IAE/C,MAAM,OAAO,GAAG,uBAAA,IAAI,4EAAS,CAAC;IAC9B,MAAM,OAAO,GAAG,uBAAA,IAAI,4EAAS,CAAC;IAC9B,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE;QACxB,OAAO;KACR;IACD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE;QAC9E,QAAQ,EAAE,UAAU;QACpB,SAAS;QACT,UAAU,EAAE;YACV,gBAAgB,CAAC,MAAM,CAAC;YACxB,KAAK,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC;YACrC,IAAI,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC;SACpC,CAAC,MAAM,CAAC,OAAO,CAAC;KAClB,CAAC,CAAC;IAEH,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, ReactiveElement } from 'lit';\nimport type { StyleInfo } from 'lit/directives/style-map.js';\nimport type { Options as Offset } from '@floating-ui/core/src/middleware/offset';\n\n\nexport { Placement };\n\nimport {\n autoUpdate,\n computePosition,\n offset as offsetMiddleware,\n shift as shiftMiddleware,\n flip as flipMiddleware,\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?: boolean;\n flip?: boolean;\n shift?: boolean;\n padding?: number;\n}\n\ninterface ShowOptions {\n offset?: Offset;\n placement?: 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: Required<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 /** 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: ReactiveElement,\n options: FloatingDOMControllerOptions\n ) {\n host.addController(this);\n this.#options = options as Required<FloatingDOMControllerOptions>;\n this.#options.invoker ??= host;\n this.#options.arrow ??= false;\n this.#options.flip ??= true;\n this.#options.shift ??= true;\n }\n\n hostDisconnected() {\n this.#cleanup?.();\n }\n\n async #update(placement: Placement = 'top', offset?: Offset) {\n const { flip, padding, shift } = this.#options;\n\n const invoker = this.#invoker;\n const content = this.#content;\n if (!invoker || !content) {\n return;\n }\n const { x, y, placement: _placement } = await computePosition(invoker, content, {\n strategy: 'absolute',\n placement,\n middleware: [\n offsetMiddleware(offset),\n shift && shiftMiddleware({ padding }),\n flip && flipMiddleware({ padding }),\n ].filter(Boolean)\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 }: 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);\n this.#cleanup ??= autoUpdate(invoker, content, () =>\n this.#update(placement, offset));\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"]}
@@ -0,0 +1,52 @@
1
+ import type { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ export declare class InternalsController implements ReactiveController, ARIAMixin {
3
+ #private;
4
+ host: ReactiveControllerHost & HTMLElement;
5
+ role: ARIAMixin['role'];
6
+ ariaAtomic: ARIAMixin['ariaAtomic'];
7
+ ariaAutoComplete: ARIAMixin['ariaAutoComplete'];
8
+ ariaBusy: ARIAMixin['ariaBusy'];
9
+ ariaChecked: ARIAMixin['ariaChecked'];
10
+ ariaColCount: ARIAMixin['ariaColCount'];
11
+ ariaColIndex: ARIAMixin['ariaColIndex'];
12
+ ariaColIndexText: ARIAMixin['ariaColIndexText'];
13
+ ariaColSpan: ARIAMixin['ariaColSpan'];
14
+ ariaCurrent: ARIAMixin['ariaCurrent'];
15
+ ariaDisabled: ARIAMixin['ariaDisabled'];
16
+ ariaExpanded: ARIAMixin['ariaExpanded'];
17
+ ariaHasPopup: ARIAMixin['ariaHasPopup'];
18
+ ariaHidden: ARIAMixin['ariaHidden'];
19
+ ariaInvalid: ARIAMixin['ariaInvalid'];
20
+ ariaKeyShortcuts: ARIAMixin['ariaKeyShortcuts'];
21
+ ariaLabel: ARIAMixin['ariaLabel'];
22
+ ariaLevel: ARIAMixin['ariaLevel'];
23
+ ariaLive: ARIAMixin['ariaLive'];
24
+ ariaModal: ARIAMixin['ariaModal'];
25
+ ariaMultiLine: ARIAMixin['ariaMultiLine'];
26
+ ariaMultiSelectable: ARIAMixin['ariaMultiSelectable'];
27
+ ariaOrientation: ARIAMixin['ariaOrientation'];
28
+ ariaPlaceholder: ARIAMixin['ariaPlaceholder'];
29
+ ariaPosInSet: ARIAMixin['ariaPosInSet'];
30
+ ariaPressed: ARIAMixin['ariaPressed'];
31
+ ariaReadOnly: ARIAMixin['ariaReadOnly'];
32
+ ariaRequired: ARIAMixin['ariaRequired'];
33
+ ariaRoleDescription: ARIAMixin['ariaRoleDescription'];
34
+ ariaRowCount: ARIAMixin['ariaRowCount'];
35
+ ariaRowIndex: ARIAMixin['ariaRowIndex'];
36
+ ariaRowIndexText: ARIAMixin['ariaRowIndexText'];
37
+ ariaRowSpan: ARIAMixin['ariaRowSpan'];
38
+ ariaSelected: ARIAMixin['ariaSelected'];
39
+ ariaSetSize: ARIAMixin['ariaSetSize'];
40
+ ariaSort: ARIAMixin['ariaSort'];
41
+ ariaValueMax: ARIAMixin['ariaValueMax'];
42
+ ariaValueMin: ARIAMixin['ariaValueMin'];
43
+ ariaValueNow: ARIAMixin['ariaValueNow'];
44
+ ariaValueText: ARIAMixin['ariaValueText'];
45
+ /** True when the control is disabled via it's containing fieldset element */
46
+ get formDisabled(): boolean;
47
+ static protos: WeakMap<object, any>;
48
+ constructor(host: ReactiveControllerHost & HTMLElement, options?: Partial<ARIAMixin>);
49
+ hostConnected?(): void;
50
+ submit(): void;
51
+ reset(): void;
52
+ }
@@ -0,0 +1,52 @@
1
+ var _InternalsController_internals, _InternalsController_formDisabled;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ function isARIAMixinProp(key) {
4
+ return key === 'role' || key.startsWith('aria');
5
+ }
6
+ export class InternalsController {
7
+ /** True when the control is disabled via it's containing fieldset element */
8
+ get formDisabled() {
9
+ return this.host.matches(':disabled') || __classPrivateFieldGet(this, _InternalsController_formDisabled, "f");
10
+ }
11
+ constructor(host, options) {
12
+ this.host = host;
13
+ _InternalsController_internals.set(this, void 0);
14
+ _InternalsController_formDisabled.set(this, false);
15
+ __classPrivateFieldSet(this, _InternalsController_internals, host.attachInternals(), "f");
16
+ // We need to polyfill :disabled
17
+ // see https://github.com/calebdwilliams/element-internals-polyfill/issues/88
18
+ const orig = host.formDisabledCallback;
19
+ host.formDisabledCallback = disabled => {
20
+ __classPrivateFieldSet(this, _InternalsController_formDisabled, disabled, "f");
21
+ orig?.call(host, disabled);
22
+ };
23
+ // proxy the internals object's aria prototype
24
+ for (const key of Object.keys(Object.getPrototypeOf(__classPrivateFieldGet(this, _InternalsController_internals, "f")))) {
25
+ if (isARIAMixinProp(key)) {
26
+ Object.defineProperty(this, key, {
27
+ get() {
28
+ return __classPrivateFieldGet(this, _InternalsController_internals, "f")[key];
29
+ },
30
+ set(value) {
31
+ __classPrivateFieldGet(this, _InternalsController_internals, "f")[key] = value;
32
+ this.host.requestUpdate();
33
+ }
34
+ });
35
+ }
36
+ }
37
+ for (const [key, val] of Object.entries(options ?? {})) {
38
+ if (isARIAMixinProp(key)) {
39
+ this[key] = val;
40
+ }
41
+ }
42
+ }
43
+ submit() {
44
+ __classPrivateFieldGet(this, _InternalsController_internals, "f").form?.requestSubmit();
45
+ }
46
+ reset() {
47
+ __classPrivateFieldGet(this, _InternalsController_internals, "f").form?.reset();
48
+ }
49
+ }
50
+ _InternalsController_internals = new WeakMap(), _InternalsController_formDisabled = new WeakMap();
51
+ InternalsController.protos = new WeakMap();
52
+ //# sourceMappingURL=internals-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internals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AC;iBACF,CAAC,CAAC;aACJ;SACF;QAED,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;YACtD,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE;gBACxB,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;aACjB;SACF;IACH,CAAC;IAID,MAAM;QACJ,uBAAA,IAAI,sCAAW,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC;IACxC,CAAC;IAED,KAAK;QACH,uBAAA,IAAI,sCAAW,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;IAChC,CAAC;;;AA5CM,0BAAM,GAAG,IAAI,OAAO,EAAE,CAAC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\nfunction isARIAMixinProp(key: string): key is keyof ARIAMixin {\n return key === 'role' || key.startsWith('aria');\n}\n\nexport class InternalsController implements ReactiveController, ARIAMixin {\n declare role: ARIAMixin['role'];\n declare ariaAtomic: ARIAMixin['ariaAtomic'];\n declare ariaAutoComplete: ARIAMixin['ariaAutoComplete'];\n declare ariaBusy: ARIAMixin['ariaBusy'];\n declare ariaChecked: ARIAMixin['ariaChecked'];\n declare ariaColCount: ARIAMixin['ariaColCount'];\n declare ariaColIndex: ARIAMixin['ariaColIndex'];\n declare ariaColIndexText: ARIAMixin['ariaColIndexText'];\n declare ariaColSpan: ARIAMixin['ariaColSpan'];\n declare ariaCurrent: ARIAMixin['ariaCurrent'];\n declare ariaDisabled: ARIAMixin['ariaDisabled'];\n declare ariaExpanded: ARIAMixin['ariaExpanded'];\n declare ariaHasPopup: ARIAMixin['ariaHasPopup'];\n declare ariaHidden: ARIAMixin['ariaHidden'];\n declare ariaInvalid: ARIAMixin['ariaInvalid'];\n declare ariaKeyShortcuts: ARIAMixin['ariaKeyShortcuts'];\n declare ariaLabel: ARIAMixin['ariaLabel'];\n declare ariaLevel: ARIAMixin['ariaLevel'];\n declare ariaLive: ARIAMixin['ariaLive'];\n declare ariaModal: ARIAMixin['ariaModal'];\n declare ariaMultiLine: ARIAMixin['ariaMultiLine'];\n declare ariaMultiSelectable: ARIAMixin['ariaMultiSelectable'];\n declare ariaOrientation: ARIAMixin['ariaOrientation'];\n declare ariaPlaceholder: ARIAMixin['ariaPlaceholder'];\n declare ariaPosInSet: ARIAMixin['ariaPosInSet'];\n declare ariaPressed: ARIAMixin['ariaPressed'];\n declare ariaReadOnly: ARIAMixin['ariaReadOnly'];\n declare ariaRequired: ARIAMixin['ariaRequired'];\n declare ariaRoleDescription: ARIAMixin['ariaRoleDescription'];\n declare ariaRowCount: ARIAMixin['ariaRowCount'];\n declare ariaRowIndex: ARIAMixin['ariaRowIndex'];\n declare ariaRowIndexText: ARIAMixin['ariaRowIndexText'];\n declare ariaRowSpan: ARIAMixin['ariaRowSpan'];\n declare ariaSelected: ARIAMixin['ariaSelected'];\n declare ariaSetSize: ARIAMixin['ariaSetSize'];\n declare ariaSort: ARIAMixin['ariaSort'];\n declare ariaValueMax: ARIAMixin['ariaValueMax'];\n declare ariaValueMin: ARIAMixin['ariaValueMin'];\n declare ariaValueNow: ARIAMixin['ariaValueNow'];\n declare ariaValueText: ARIAMixin['ariaValueText'];\n\n #internals: ElementInternals;\n\n #formDisabled = false;\n\n /** True when the control is disabled via it's containing fieldset element */\n get formDisabled() {\n return this.host.matches(':disabled') || this.#formDisabled;\n }\n\n static protos = new WeakMap();\n\n constructor(\n public host: ReactiveControllerHost & HTMLElement,\n options?: Partial<ARIAMixin>\n ) {\n this.#internals = host.attachInternals();\n // We need to polyfill :disabled\n // see https://github.com/calebdwilliams/element-internals-polyfill/issues/88\n const orig = (host as HTMLElement & { formDisabledCallback?(disabled: boolean): void }).formDisabledCallback;\n (host as HTMLElement & { formDisabledCallback?(disabled: boolean): void }).formDisabledCallback = disabled => {\n this.#formDisabled = disabled;\n orig?.call(host, disabled);\n };\n // proxy the internals object's aria prototype\n for (const key of Object.keys(Object.getPrototypeOf(this.#internals))) {\n if (isARIAMixinProp(key)) {\n Object.defineProperty(this, key, {\n get() {\n return this.#internals[key];\n },\n set(value) {\n this.#internals[key] = value;\n this.host.requestUpdate();\n }\n });\n }\n }\n\n for (const [key, val] of Object.entries(options ?? {})) {\n if (isARIAMixinProp(key)) {\n this[key] = val;\n }\n }\n }\n\n hostConnected?(): void\n\n submit() {\n this.#internals.form?.requestSubmit();\n }\n\n reset() {\n this.#internals.form?.reset();\n }\n}\n"]}
@@ -1,2 +1,38 @@
1
- import{Logger as o}from"./logger.js";var i=class{constructor(t,e,s){this.host=t;this.options=s;this.initializer=e.bind(t),this.mo=new MutationObserver(this.initializer),this.logger=new o(this.host),t.addController(this)}hostConnected(){this.hasLightDOM()?this.initializer():this.options?.emptyWarning&&this.logger.warn(this.options?.emptyWarning),this.initObserver()}hostDisconnected(){this.mo.disconnect()}initObserver(){(this.options?.observe??!0)&&this.mo.observe(this.host,typeof this.options?.observe!="object"?{childList:!0}:this.options?.observe)}hasLightDOM(){return this.host.children.length>0||(this.host.textContent??"").trim().length>0}};export{i as LightDOMController};
2
- //# sourceMappingURL=light-dom-controller.js.map
1
+ import { Logger } from './logger.js';
2
+ export class LightDOMController {
3
+ constructor(host, initializer, options) {
4
+ this.host = host;
5
+ this.options = options;
6
+ this.initializer = initializer.bind(host);
7
+ this.mo = new MutationObserver(this.initializer);
8
+ this.logger = new Logger(this.host);
9
+ host.addController(this);
10
+ }
11
+ hostConnected() {
12
+ if (this.hasLightDOM()) {
13
+ this.initializer();
14
+ }
15
+ else if (this.options?.emptyWarning) {
16
+ this.logger.warn(this.options?.emptyWarning);
17
+ }
18
+ this.initObserver();
19
+ }
20
+ hostDisconnected() {
21
+ this.mo.disconnect();
22
+ }
23
+ initObserver() {
24
+ if (this.options?.observe ?? true) {
25
+ // Use the provided options, or their defaults
26
+ this.mo.observe(this.host, typeof this.options?.observe !== 'object' ? { childList: true }
27
+ : this.options?.observe);
28
+ }
29
+ }
30
+ /**
31
+ * Returns a boolean statement of whether or not this component contains any light DOM.
32
+ */
33
+ hasLightDOM() {
34
+ return !!(this.host.children.length > 0 ||
35
+ (this.host.textContent ?? '').trim().length > 0);
36
+ }
37
+ }
38
+ //# sourceMappingURL=light-dom-controller.js.map