@patternfly/pfe-core 2.4.1 → 4.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.
Files changed (104) hide show
  1. package/README.md +0 -1
  2. package/controllers/activedescendant-controller.d.ts +99 -0
  3. package/controllers/activedescendant-controller.js +230 -0
  4. package/controllers/activedescendant-controller.js.map +1 -0
  5. package/controllers/at-focus-controller.d.ts +56 -0
  6. package/controllers/at-focus-controller.js +168 -0
  7. package/controllers/at-focus-controller.js.map +1 -0
  8. package/controllers/cascade-controller.d.ts +11 -0
  9. package/controllers/cascade-controller.js +10 -3
  10. package/controllers/cascade-controller.js.map +1 -1
  11. package/controllers/combobox-controller.d.ts +117 -0
  12. package/controllers/combobox-controller.js +611 -0
  13. package/controllers/combobox-controller.js.map +1 -0
  14. package/controllers/css-variable-controller.js +1 -1
  15. package/controllers/css-variable-controller.js.map +1 -1
  16. package/controllers/floating-dom-controller.d.ts +10 -3
  17. package/controllers/floating-dom-controller.js +93 -83
  18. package/controllers/floating-dom-controller.js.map +1 -1
  19. package/controllers/internals-controller.d.ts +104 -42
  20. package/controllers/internals-controller.js +354 -36
  21. package/controllers/internals-controller.js.map +1 -1
  22. package/controllers/light-dom-controller.js +2 -2
  23. package/controllers/light-dom-controller.js.map +1 -1
  24. package/controllers/listbox-controller.d.ts +143 -0
  25. package/controllers/listbox-controller.js +443 -0
  26. package/controllers/listbox-controller.js.map +1 -0
  27. package/controllers/logger.d.ts +33 -6
  28. package/controllers/logger.js +58 -13
  29. package/controllers/logger.js.map +1 -1
  30. package/controllers/overflow-controller.d.ts +10 -3
  31. package/controllers/overflow-controller.js +79 -44
  32. package/controllers/overflow-controller.js.map +1 -1
  33. package/controllers/perf-controller.js.map +1 -1
  34. package/controllers/property-observer-controller.d.ts +13 -16
  35. package/controllers/property-observer-controller.js +55 -27
  36. package/controllers/property-observer-controller.js.map +1 -1
  37. package/controllers/roving-tabindex-controller.d.ts +19 -50
  38. package/controllers/roving-tabindex-controller.js +64 -183
  39. package/controllers/roving-tabindex-controller.js.map +1 -1
  40. package/controllers/scroll-spy-controller.d.ts +4 -1
  41. package/controllers/scroll-spy-controller.js +94 -93
  42. package/controllers/scroll-spy-controller.js.map +1 -1
  43. package/controllers/slot-controller.d.ts +26 -19
  44. package/controllers/slot-controller.js +94 -83
  45. package/controllers/slot-controller.js.map +1 -1
  46. package/controllers/style-controller.js +3 -1
  47. package/controllers/style-controller.js.map +1 -1
  48. package/controllers/tabs-aria-controller.d.ts +31 -0
  49. package/controllers/tabs-aria-controller.js +97 -0
  50. package/controllers/tabs-aria-controller.js.map +1 -0
  51. package/controllers/test/combobox-controller.spec.d.ts +1 -0
  52. package/controllers/test/combobox-controller.spec.js +282 -0
  53. package/controllers/test/combobox-controller.spec.js.map +1 -0
  54. package/controllers/timestamp-controller.js +73 -70
  55. package/controllers/timestamp-controller.js.map +1 -1
  56. package/core.d.ts +3 -23
  57. package/core.js +1 -38
  58. package/core.js.map +1 -1
  59. package/custom-elements.json +7302 -2817
  60. package/decorators/bound.d.ts +3 -1
  61. package/decorators/bound.js +3 -1
  62. package/decorators/bound.js.map +1 -1
  63. package/decorators/cascades.d.ts +2 -0
  64. package/decorators/cascades.js +2 -0
  65. package/decorators/cascades.js.map +1 -1
  66. package/decorators/deprecation.d.ts +6 -5
  67. package/decorators/deprecation.js +6 -5
  68. package/decorators/deprecation.js.map +1 -1
  69. package/decorators/initializer.js.map +1 -1
  70. package/decorators/listen.d.ts +8 -0
  71. package/decorators/listen.js +22 -0
  72. package/decorators/listen.js.map +1 -0
  73. package/decorators/observed.d.ts +12 -16
  74. package/decorators/observed.js +39 -44
  75. package/decorators/observed.js.map +1 -1
  76. package/decorators/observes.d.ts +15 -0
  77. package/decorators/observes.js +30 -0
  78. package/decorators/observes.js.map +1 -0
  79. package/decorators/time.d.ts +1 -0
  80. package/decorators/time.js +6 -9
  81. package/decorators/time.js.map +1 -1
  82. package/decorators/trace.d.ts +4 -1
  83. package/decorators/trace.js +4 -1
  84. package/decorators/trace.js.map +1 -1
  85. package/decorators.d.ts +2 -0
  86. package/decorators.js +2 -0
  87. package/decorators.js.map +1 -1
  88. package/functions/arraysAreEquivalent.d.ts +9 -0
  89. package/functions/arraysAreEquivalent.js +28 -0
  90. package/functions/arraysAreEquivalent.js.map +1 -0
  91. package/functions/containsDeep.d.ts +8 -0
  92. package/functions/containsDeep.js +23 -0
  93. package/functions/containsDeep.js.map +1 -0
  94. package/functions/context.d.ts +8 -0
  95. package/functions/context.js +21 -0
  96. package/functions/context.js.map +1 -0
  97. package/functions/debounce.js.map +1 -1
  98. package/functions/isElementInView.d.ts +4 -6
  99. package/functions/isElementInView.js +9 -11
  100. package/functions/isElementInView.js.map +1 -1
  101. package/package.json +10 -4
  102. package/functions/deprecatedCustomEvent.d.ts +0 -5
  103. package/functions/deprecatedCustomEvent.js +0 -12
  104. package/functions/deprecatedCustomEvent.js.map +0 -1
@@ -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;
@@ -18,17 +24,22 @@ export declare class CascadeController<E extends ReactiveElement> implements Rea
18
24
  /**
19
25
  * Handles the cascading of properties to nested components when new elements are added
20
26
  * Attribute updates/additions are handled by the attribute callback
27
+ * @param [nodeList=this.host.children]
21
28
  */
22
29
  cascadeProperties(nodeList?: HTMLCollection | NodeList): void;
23
30
  /**
24
31
  * Gets the configured attribute name for the decorated property,
25
32
  * falling back to the lowercased property name, and caches the attribute name
26
33
  * with it's designated child selectors for value-propagation on change
34
+ * @param propName
35
+ * @param cascade
27
36
  */
28
37
  initProp(propName: string, cascade: string | string[]): void;
29
38
  private parse;
30
39
  /**
31
40
  * Copy the named attribute to a target element.
41
+ * @param name attr name
42
+ * @param el element
32
43
  */
33
44
  private _copyAttribute;
34
45
  private _cascadeAttributes;
@@ -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
- class CascadeController {
6
- static { this.instances = new WeakMap(); }
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;
@@ -32,6 +34,7 @@ class CascadeController {
32
34
  /**
33
35
  * Handles the cascading of properties to nested components when new elements are added
34
36
  * Attribute updates/additions are handled by the attribute callback
37
+ * @param [nodeList=this.host.children]
35
38
  */
36
39
  cascadeProperties(nodeList = this.host.children) {
37
40
  if (this.host.isConnected) {
@@ -63,6 +66,8 @@ class CascadeController {
63
66
  * Gets the configured attribute name for the decorated property,
64
67
  * falling back to the lowercased property name, and caches the attribute name
65
68
  * with it's designated child selectors for value-propagation on change
69
+ * @param propName
70
+ * @param cascade
66
71
  */
67
72
  initProp(propName, cascade) {
68
73
  for (const nodeItem of [cascade].flat(Infinity).filter(Boolean)) {
@@ -93,6 +98,8 @@ class CascadeController {
93
98
  }
94
99
  /**
95
100
  * Copy the named attribute to a target element.
101
+ * @param name attr name
102
+ * @param el element
96
103
  */
97
104
  async _copyAttribute(name, el) {
98
105
  this.logger.log(`copying ${name} to ${el}`);
@@ -130,8 +137,8 @@ class CascadeController {
130
137
  }
131
138
  }
132
139
  }
140
+ CascadeController.instances = new WeakMap();
133
141
  __decorate([
134
142
  bound
135
143
  ], CascadeController.prototype, "parse", null);
136
- export { CascadeController };
137
144
  //# sourceMappingURL=cascade-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"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IAAI,EAAE;gBACjB,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;aAC1B;iBAAM;gBACL,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aAC9B;SACF;IACH,CAAC;IAEO,kBAAkB,CAAC,SAAmC,EAAE,GAAkB;QAChF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;YAChC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE;gBAC1C,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;aACxC;SACF;IACH,CAAC;IAED;;;;;;OAMG;IACK,iBAAiB,CAAC,IAAY,EAAE,EAAU;QAChD,MAAM,UAAU,GAAG;YACjB,GAAG,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;YAC7B,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACjC;IACH,CAAC;;AAnDc;IAAd,KAAK;8CAUL;SAvGU,iBAAiB","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
+ {"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;IAY5B,YAAmB,IAAO,EAAS,OAAgC;QAAhD,SAAI,GAAJ,IAAI,CAAG;QAAS,YAAO,GAAP,OAAO,CAAyB;QAJnE,OAAE,GAAqB,IAAI,gBAAgB,CAAC,IA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AK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC3C,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACK,iBAAiB,CAAC,IAAY,EAAE,EAAU;QAChD,MAAM,UAAU,GAAG;YACjB,GAAG,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;;AAjJM,2BAAS,GACd,IAAI,OAAO,EAAuD,AADpD,CACqD;AA2FtD;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>> =\n new WeakMap<ReactiveElement, CascadeController<ReactiveElement>>();\n\n mo: MutationObserver = new MutationObserver(this.parse);\n\n cache: Map<string, string[]> = new Map<string, string[]>();\n\n constructor(public host: E, public options?: Options<E> | undefined) {\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(): void {\n this.cascadeProperties();\n }\n\n hostConnected(): void {\n this.mo.observe(this.host, { attributes: true, childList: true });\n this.cascadeProperties();\n }\n\n hostDisconnected(): void {\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 * @param [nodeList=this.host.children]\n */\n cascadeProperties(nodeList: HTMLCollection | NodeList = this.host.children): void {\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 * @param propName\n * @param cascade\n */\n initProp(propName: string, cascade: string | string[]): void {\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 * @param name attr name\n * @param el 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"]}
@@ -0,0 +1,117 @@
1
+ import { nothing, type ReactiveController, type ReactiveControllerHost } from 'lit';
2
+ import type { ActivedescendantControllerOptions } from './activedescendant-controller.js';
3
+ import type { RovingTabindexControllerOptions } from './roving-tabindex-controller.js';
4
+ import type { ListboxControllerOptions } from './listbox-controller.js';
5
+ type AllOptions<Item extends HTMLElement> = ActivedescendantControllerOptions<Item> & ListboxControllerOptions<Item> & RovingTabindexControllerOptions<Item>;
6
+ export interface ComboboxControllerOptions<Item extends HTMLElement> extends Omit<AllOptions<Item>, 'getATFocusedItem' | 'getControlsElements' | 'getActiveDescendantContainer' | 'getItemsContainer'> {
7
+ /**
8
+ * Predicate which establishes whether the listbox is expanded
9
+ * e.g. `isExpanded: () => this.expanded`, if the host's `expanded` property
10
+ * should correspond to the listbox expanded state.
11
+ */
12
+ isExpanded(): boolean;
13
+ /**
14
+ * Callback which the host must implement to change the expanded state to true.
15
+ * Return or resolve false to prevent the change.
16
+ */
17
+ requestShowListbox(): void | boolean | Promise<boolean> | Promise<void>;
18
+ /**
19
+ * Callback which the host must implement to change the expanded to false.
20
+ * Return or resolve false to prevent the default.
21
+ */
22
+ requestHideListbox(): void | boolean | Promise<boolean> | Promise<void>;
23
+ /**
24
+ * Returns the listbox container element
25
+ */
26
+ getListboxElement(): HTMLElement | null;
27
+ /**
28
+ * Returns the toggle button, if it exists
29
+ */
30
+ getToggleButton(): HTMLElement | null;
31
+ /**
32
+ * Returns the combobox input, if it exists
33
+ */
34
+ getComboboxInput(): HTMLElement | null;
35
+ /**
36
+ * Returns the label for the toggle button, combobox input, and listbox.
37
+ * when `ariaLabelledByElements` is supported, the label elements associated with
38
+ * the host element are used instead, and this value is ignored.
39
+ */
40
+ getFallbackLabel(): string;
41
+ /**
42
+ * Called on an item to retrieve it's value string. By default, returns the `value` property
43
+ * of the item, as if it implemented the `<option>` element's interface.
44
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement
45
+ */
46
+ getItemValue?(item: Item): string;
47
+ /**
48
+ * Optional callback, called on the combobox input element to set its value.
49
+ * by default, returns the element's `value` DOM property.
50
+ */
51
+ getComboboxValue?(combobox: HTMLElement): string;
52
+ /**
53
+ * Optional callback, called on the combobox input element to set its value.
54
+ * by default, sets the element's `value` DOM property.
55
+ */
56
+ setComboboxValue?(item: HTMLElement, value: string): void;
57
+ /**
58
+ * Called on each item, with the combobox input, to determine if the item should be shown in the
59
+ * listbox or filtered out. Return false to hide the item. By default, checks whether the item's
60
+ * value starts with the input value (when both are lowercased).
61
+ */
62
+ isItemFiltered?(item: Item, value: string): boolean;
63
+ /**
64
+ * Called on each item when the filter changes.
65
+ * By default, toggles the `hidden` attribute on the item
66
+ */
67
+ setItemHidden?(item: Item, hidden: boolean): void;
68
+ }
69
+ /**
70
+ * @summary Implements the WAI-ARIA pattern [Editable Combobox with Both List and Inline Autocomplete].
71
+ *
72
+ * Combobox with keyboard and pointer navigation, using the aria-activedescendant pattern.
73
+ *
74
+ * WARNING: Safari VoiceOver does not support aria-activedescendant, so Safari users
75
+ * rely on the combobox input value being announced when navigating the listbox with the keyboard.
76
+ * We have erred on the side that it may be less-broken to avoid announcing disabled items in that
77
+ * case, rather than announcing the disabled items value without indicating that it is disabled.
78
+ * @see (https://bugs.webkit.org/show_bug.cgi?id=269026)
79
+ *
80
+ * [pattern]: https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-both/
81
+ */
82
+ export declare class ComboboxController<Item extends HTMLElement> implements ReactiveController {
83
+ #private;
84
+ host: ReactiveControllerHost;
85
+ static of<T extends HTMLElement>(host: ReactiveControllerHost, options: ComboboxControllerOptions<T>): ComboboxController<T>;
86
+ /**
87
+ * Whether the `ariaActiveDescendantElement` IDL attribute is supported for cross-root ARIA.
88
+ */
89
+ static get supportsCrossRootActiveDescendant(): boolean;
90
+ private static langs;
91
+ private static langsRE;
92
+ private options;
93
+ /** All items */
94
+ get items(): Item[];
95
+ set items(value: Item[]);
96
+ /** Whether the combobox is disabled */
97
+ get disabled(): boolean;
98
+ set disabled(value: boolean);
99
+ /** Whether multiselect is enabled */
100
+ get multi(): boolean;
101
+ set multi(value: boolean);
102
+ /** The current selection: a list of items */
103
+ get selected(): Item[];
104
+ set selected(value: Item[]);
105
+ private constructor();
106
+ hostConnected(): Promise<void>;
107
+ hostUpdated(): void;
108
+ hostDisconnected(): void;
109
+ /**
110
+ * For Browsers which do not support `ariaActiveDescendantElement`, we must clone
111
+ * the listbox items into the same root as the combobox input
112
+ * Call this method to return either an array of (cloned) list box items, to be placed in your
113
+ * shadow template, or nothing in the case the browser supports cross-root aria.
114
+ */
115
+ renderItemsToShadowRoot(): Node[] | typeof nothing;
116
+ }
117
+ export {};