@patternfly/pfe-core 3.0.0 → 4.0.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 (102) hide show
  1. package/controllers/activedescendant-controller.d.ts +99 -0
  2. package/controllers/activedescendant-controller.js +230 -0
  3. package/controllers/activedescendant-controller.js.map +1 -0
  4. package/controllers/at-focus-controller.d.ts +56 -0
  5. package/controllers/at-focus-controller.js +168 -0
  6. package/controllers/at-focus-controller.js.map +1 -0
  7. package/controllers/cascade-controller.d.ts +7 -2
  8. package/controllers/cascade-controller.js +6 -1
  9. package/controllers/cascade-controller.js.map +1 -1
  10. package/controllers/combobox-controller.d.ts +117 -0
  11. package/controllers/combobox-controller.js +611 -0
  12. package/controllers/combobox-controller.js.map +1 -0
  13. package/controllers/css-variable-controller.js +1 -1
  14. package/controllers/css-variable-controller.js.map +1 -1
  15. package/controllers/floating-dom-controller.d.ts +8 -1
  16. package/controllers/floating-dom-controller.js +12 -5
  17. package/controllers/floating-dom-controller.js.map +1 -1
  18. package/controllers/internals-controller.d.ts +26 -9
  19. package/controllers/internals-controller.js +45 -13
  20. package/controllers/internals-controller.js.map +1 -1
  21. package/controllers/light-dom-controller.js +2 -2
  22. package/controllers/light-dom-controller.js.map +1 -1
  23. package/controllers/listbox-controller.d.ts +118 -33
  24. package/controllers/listbox-controller.js +347 -154
  25. package/controllers/listbox-controller.js.map +1 -1
  26. package/controllers/logger.d.ts +13 -10
  27. package/controllers/logger.js +15 -11
  28. package/controllers/logger.js.map +1 -1
  29. package/controllers/overflow-controller.js +10 -6
  30. package/controllers/overflow-controller.js.map +1 -1
  31. package/controllers/perf-controller.js.map +1 -1
  32. package/controllers/property-observer-controller.d.ts +13 -16
  33. package/controllers/property-observer-controller.js +54 -25
  34. package/controllers/property-observer-controller.js.map +1 -1
  35. package/controllers/roving-tabindex-controller.d.ts +12 -61
  36. package/controllers/roving-tabindex-controller.js +57 -203
  37. package/controllers/roving-tabindex-controller.js.map +1 -1
  38. package/controllers/scroll-spy-controller.d.ts +4 -1
  39. package/controllers/scroll-spy-controller.js +9 -6
  40. package/controllers/scroll-spy-controller.js.map +1 -1
  41. package/controllers/slot-controller.d.ts +12 -16
  42. package/controllers/slot-controller.js +17 -20
  43. package/controllers/slot-controller.js.map +1 -1
  44. package/controllers/style-controller.js +3 -1
  45. package/controllers/style-controller.js.map +1 -1
  46. package/controllers/tabs-aria-controller.d.ts +2 -0
  47. package/controllers/tabs-aria-controller.js +2 -0
  48. package/controllers/tabs-aria-controller.js.map +1 -1
  49. package/controllers/test/combobox-controller.spec.d.ts +1 -0
  50. package/controllers/test/combobox-controller.spec.js +282 -0
  51. package/controllers/test/combobox-controller.spec.js.map +1 -0
  52. package/controllers/timestamp-controller.js +7 -2
  53. package/controllers/timestamp-controller.js.map +1 -1
  54. package/core.d.ts +0 -23
  55. package/core.js +1 -38
  56. package/core.js.map +1 -1
  57. package/custom-elements.json +3862 -1369
  58. package/decorators/bound.d.ts +3 -1
  59. package/decorators/bound.js +3 -1
  60. package/decorators/bound.js.map +1 -1
  61. package/decorators/cascades.d.ts +2 -1
  62. package/decorators/cascades.js +2 -1
  63. package/decorators/cascades.js.map +1 -1
  64. package/decorators/deprecation.d.ts +6 -5
  65. package/decorators/deprecation.js +6 -5
  66. package/decorators/deprecation.js.map +1 -1
  67. package/decorators/initializer.js.map +1 -1
  68. package/decorators/listen.d.ts +8 -0
  69. package/decorators/listen.js +22 -0
  70. package/decorators/listen.js.map +1 -0
  71. package/decorators/observed.d.ts +12 -16
  72. package/decorators/observed.js +39 -44
  73. package/decorators/observed.js.map +1 -1
  74. package/decorators/observes.d.ts +15 -0
  75. package/decorators/observes.js +30 -0
  76. package/decorators/observes.js.map +1 -0
  77. package/decorators/time.d.ts +1 -0
  78. package/decorators/time.js +6 -9
  79. package/decorators/time.js.map +1 -1
  80. package/decorators/trace.d.ts +4 -1
  81. package/decorators/trace.js +4 -1
  82. package/decorators/trace.js.map +1 -1
  83. package/decorators.d.ts +2 -0
  84. package/decorators.js +2 -0
  85. package/decorators.js.map +1 -1
  86. package/functions/arraysAreEquivalent.d.ts +9 -0
  87. package/functions/arraysAreEquivalent.js +28 -0
  88. package/functions/arraysAreEquivalent.js.map +1 -0
  89. package/functions/containsDeep.d.ts +2 -0
  90. package/functions/containsDeep.js +2 -0
  91. package/functions/containsDeep.js.map +1 -1
  92. package/functions/context.d.ts +3 -4
  93. package/functions/context.js +6 -2
  94. package/functions/context.js.map +1 -1
  95. package/functions/debounce.js.map +1 -1
  96. package/functions/isElementInView.d.ts +4 -6
  97. package/functions/isElementInView.js +9 -11
  98. package/functions/isElementInView.js.map +1 -1
  99. package/package.json +12 -4
  100. package/ssr-shims.d.ts +17 -0
  101. package/ssr-shims.js +55 -0
  102. package/ssr-shims.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"listbox-controller.js","sourceRoot":"","sources":["listbox-controller.ts"],"names":[],"mappings":";;AAwBA,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAGrB,MAAM,CAAC,EAAE,CACd,IAA4B,EAC5B,OAAmC;QAEnC,mBAAmB,GAAG,IAAI,CAAC;QAC3B,MAAM,QAAQ,GACZ,iBAAiB,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,iBAAiB,CAAO,IAAI,EAAE,OAAO,CAAC,CAAC;QACtF,mBAAmB,GAAG,KAAK,CAAC;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,YACS,IAA4B;IACnC,wFAAwF;IACxF,+EAA+E;IAC/E,sDAAsD;IAC9C,QAAoC;;QAJrC,SAAI,GAAJ,IAAI,CAAwB;QAI3B,aAAQ,GAAR,QAAQ,CAA4B;QAkB9C,0DAA0D;QAC1D,+CAAkC,IAAI,EAAC;QAEvC,sDAAsD;QACtD,mCAAiB,EAAE,EAAC;QAEpB,uCAAa,KAAK,EAAC;QAEnB,kC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sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\nexport interface ListboxAccessibilityController<Item extends HTMLElement> extends ReactiveController {\n items: Item[];\n activeItem?: Item;\n nextItem?: Item;\n prevItem?: Item;\n firstItem?: Item;\n lastItem?: Item;\n updateItems(items: Item[]): void;\n setActiveItem(item: Item): void;\n}\n\n/**\n * Filtering, multiselect, and orientation options for listbox\n */\nexport interface ListboxConfigOptions<T extends HTMLElement> {\n multi?: boolean;\n a11yController: ListboxAccessibilityController<T>;\n getHTMLElement(): HTMLElement | null;\n requestSelect(option: T, force?: boolean): boolean;\n isSelected(option: T): boolean;\n}\n\nlet constructingAllowed = false;\n\n/**\n * Implements listbox semantics and accesibility. As there are two recognized\n * patterns for implementing keyboard interactions with listbox patterns,\n * provide a secondary controller (either RovingTabindexController or\n * ActiveDescendantController) to complete the implementation.\n */\nexport class ListboxController<Item extends HTMLElement> implements ReactiveController {\n private static instances = new WeakMap<ReactiveControllerHost, ListboxController<any>>();\n\n public static of<Item extends HTMLElement>(\n host: ReactiveControllerHost,\n options: ListboxConfigOptions<Item>,\n ): ListboxController<Item> {\n constructingAllowed = true;\n const instance: ListboxController<Item> =\n ListboxController.instances.get(host) ?? new ListboxController<Item>(host, options);\n constructingAllowed = false;\n return instance;\n }\n\n private constructor(\n public host: ReactiveControllerHost,\n // this should ideally be ecma #private, but tsc/esbuild tooling isn't up to scratch yet\n // so for now we rely on the underscore convention to avoid compile-time errors\n // try refactoring after updating tooling dependencies\n private _options: ListboxConfigOptions<Item>,\n ) {\n if (!constructingAllowed) {\n throw new Error('ListboxController must be constructed with `ListboxController.of()`');\n }\n if (!(host instanceof HTMLElement) && typeof _options.getHTMLElement !== 'function') {\n throw new Error('ListboxController requires the host to be an HTMLElement, or for the initializer to include a `getHTMLElement()` function');\n }\n if (!_options.a11yController) {\n throw new Error('ListboxController requires an additional keyboard accessibility controller. Provide either a RovingTabindexController or an ActiveDescendantController');\n }\n ListboxController.instances.set(host, this);\n this.host.addController(this);\n if (this.element?.isConnected) {\n this.hostConnected();\n }\n }\n\n /** Current active descendant when shift key is pressed */\n #shiftStartingItem: Item | null = null;\n\n /** All options that will not be hidden by a filter */\n #items: Item[] = [];\n\n #listening = false;\n\n /** Whether listbox is disabled */\n disabled = false;\n\n /** Current active descendant in listbox */\n get activeItem() {\n return this.options.find(option =>\n option === this._options.a11yController.activeItem) || this._options.a11yController.firstItem;\n }\n\n get nextItem() {\n return this._options.a11yController.nextItem;\n }\n\n get options() {\n return this.#items;\n }\n\n /**\n * array of options which are selected\n */\n get selectedOptions() {\n return this.options.filter(option => this._options.isSelected(option));\n }\n\n get value() {\n const [firstItem] = this.selectedOptions;\n return this._options.multi ? this.selectedOptions : firstItem;\n }\n\n private get element() {\n return this._options.getHTMLElement();\n }\n\n async hostConnected() {\n if (!this.#listening) {\n await this.host.updateComplete;\n this.element?.addEventListener('click', this.#onClick);\n this.element?.addEventListener('focus', this.#onFocus);\n this.element?.addEventListener('keydown', this.#onKeydown);\n this.element?.addEventListener('keyup', this.#onKeyup);\n this.#listening = true;\n }\n }\n\n hostUpdated() {\n this.element?.setAttribute('role', 'listbox');\n this.element?.setAttribute('aria-disabled', String(!!this.disabled));\n this.element?.setAttribute('aria-multi-selectable', String(!!this._options.multi));\n for (const option of this._options.a11yController.items) {\n if (this._options.a11yController.activeItem === option) {\n option.setAttribute('aria-selected', 'true');\n } else {\n option.removeAttribute('aria-selected');\n }\n }\n }\n\n hostDisconnected() {\n this.element?.removeEventListener('click', this.#onClick);\n this.element?.removeEventListener('focus', this.#onFocus);\n this.element?.removeEventListener('keydown', this.#onKeydown);\n this.element?.removeEventListener('keyup', this.#onKeyup);\n this.#listening = false;\n }\n\n #getEnabledOptions(options = this.options) {\n return options.filter(option => !option.ariaDisabled && !option.closest('[disabled]'));\n }\n\n #getEventOption(event: Event): Item | undefined {\n return event.composedPath().find(node => this.#items.includes(node as Item)) as Item | undefined;\n }\n\n\n /**\n * handles focusing on an option:\n * updates roving tabindex and active descendant\n */\n #onFocus = (event: FocusEvent) => {\n const target = this.#getEventOption(event);\n if (target && target !== this._options.a11yController.activeItem) {\n this._options.a11yController.setActiveItem(target);\n }\n };\n\n /**\n * handles clicking on a listbox option:\n * which selects an item by default\n * or toggles selection if multiselectable\n */\n #onClick = (event: MouseEvent) => {\n const target = this.#getEventOption(event);\n if (target) {\n const oldValue = this.value;\n if (this._options.multi) {\n if (!event.shiftKey) {\n this._options.requestSelect(target, !this._options.isSelected(target));\n } else if (this.#shiftStartingItem && target) {\n this.#updateMultiselect(target, this.#shiftStartingItem);\n }\n } else {\n // select target and deselect all other options\n this.options.forEach(option => this._options.requestSelect(option, option === target));\n }\n if (target !== this._options.a11yController.activeItem) {\n this._options.a11yController.setActiveItem(target);\n }\n if (oldValue !== this.value) {\n this.host.requestUpdate();\n }\n }\n };\n\n /**\n * handles keyup:\n * track whether shift key is being used for multiselectable listbox\n */\n #onKeyup = (event: KeyboardEvent) => {\n const target = this.#getEventOption(event);\n if (target && event.shiftKey && this._options.multi) {\n if (this.#shiftStartingItem && target) {\n this.#updateMultiselect(target, this.#shiftStartingItem);\n }\n if (event.key === 'Shift') {\n this.#shiftStartingItem = null;\n }\n }\n };\n\n /**\n * handles keydown:\n * filters listbox by keyboard event when slotted option has focus,\n * or by external element such as a text field\n */\n #onKeydown = (event: KeyboardEvent) => {\n const target = this.#getEventOption(event);\n\n if (!target || event.altKey || event.metaKey || !this.options.includes(target)) {\n return;\n }\n\n const first = this._options.a11yController.firstItem;\n const last = this._options.a11yController.lastItem;\n\n // need to set for keyboard support of multiselect\n if (event.key === 'Shift' && this._options.multi) {\n this.#shiftStartingItem = this.activeItem ?? null;\n }\n\n switch (event.key) {\n case 'a':\n case 'A':\n if (event.ctrlKey) {\n // ctrl+A selects all options\n this.#updateMultiselect(first, last, true);\n event.preventDefault();\n }\n break;\n case 'Enter':\n case ' ':\n // enter and space are only applicable if a listbox option is clicked\n // an external text input should not trigger multiselect\n if (this._options.multi) {\n if (event.shiftKey) {\n this.#updateMultiselect(target);\n } else if (!this.disabled) {\n this._options.requestSelect(target, !this._options.isSelected(target));\n }\n } else {\n this.#updateSingleselect();\n }\n event.preventDefault();\n break;\n default:\n break;\n }\n };\n\n /**\n * handles change to options given previous options array\n */\n #optionsChanged(oldOptions: Item[]) {\n const setSize = this.#items.length;\n if (setSize !== oldOptions.length || !oldOptions.every((element, index) => element === this.#items[index])) {\n this._options.a11yController.updateItems(this.options);\n }\n }\n\n /**\n * updates option selections for single select listbox\n */\n #updateSingleselect() {\n if (!this._options.multi && !this.disabled) {\n this.#getEnabledOptions()\n .forEach(option => this._options.requestSelect(option, option === this._options.a11yController.activeItem));\n }\n }\n\n /**\n * updates option selections for multiselectable listbox:\n * toggles all options between active descendant and target\n */\n #updateMultiselect(\n currentItem?: Item,\n referenceItem = this.activeItem,\n ctrlA = false,\n ) {\n if (referenceItem && this._options.multi && !this.disabled && currentItem) {\n // select all options between active descendant and target\n const [start, end] = [this.options.indexOf(referenceItem), this.options.indexOf(currentItem)].sort();\n const options = [...this.options].slice(start, end + 1);\n\n // by default CTRL+A will select all options\n // if all options are selected, CTRL+A will deselect all options\n const allSelected = this.#getEnabledOptions(options).filter(option => !this._options.isSelected(option))?.length === 0;\n\n // whether options will be selected (true) or deselected (false)\n const selected = ctrlA ? !allSelected : this._options.isSelected(referenceItem);\n this.#getEnabledOptions(options).forEach(option =>\n this._options.requestSelect(option, selected));\n\n // update starting item for other multiselect\n this.#shiftStartingItem = currentItem;\n }\n }\n\n /**\n * sets the listbox value based on selected options\n */\n setValue(value: Item | Item[]) {\n const selected = Array.isArray(value) ? value : [value];\n const [firstItem = null] = selected;\n for (const option of this.options) {\n this._options.requestSelect(option, (\n !!this._options.multi && Array.isArray(value) ? value?.includes(option)\n : firstItem === option\n ));\n }\n }\n\n /**\n * register's the host's Item elements as listbox controller items\n */\n setOptions(options: Item[]) {\n const oldOptions = [...this.#items];\n this.#items = options;\n this.#optionsChanged(oldOptions);\n }\n}\n"]}
1
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AAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;AACH,CAAC;AA7Zc,2BAAS,GAAG,IAAI,OAAO,EAA0D,AAAxE,CAAyE","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport type { RequireProps } from '../core.ts';\n\nimport { isServer } from 'lit';\nimport { arraysAreEquivalent } from '../functions/arraysAreEquivalent.js';\n\n/**\n * Options for listbox controller\n */\nexport interface ListboxControllerOptions<Item extends HTMLElement> {\n /**\n * Whether the listbox supports multiple selections.\n */\n multi?: boolean;\n /**\n * Optional callback to control the selection behavior of items. By default, ListboxController\n * will set the `aria-selected` attribute. When overriding this option, it will call it on your\n * element with the selected state.\n * Callers **must** ensure that the correct ARIA state is set.\n */\n setItemSelected?(item: Item, selected: boolean): void;\n /**\n * Optional predicate to ascertain whether a custom element item is disabled or not\n * By default, if the item matches any of these conditions, it is considered disabled:\n * 1. it's `disabled` DOM property is `true`\n * 1. it has the `aria-disabled=\"true\"` attribute\n * 2. it has the `disabled` attribute present\n * 3. it matches the `:disabled` pseudo selector\n */\n isItemDisabled?(item: Item): boolean;\n /**\n * Predicate which determines if a given element is in fact an item\n * instead of e.g a presentational divider. By default, elements must meet the following criteria\n * 1. element a child of a listbox role,\n * 2. element does not have role=\"presentation\"\n * 2. element is not an `<hr>`\n * **NB**: When overriding, you must avoid outside references. This predicate must\n * only consider the element itself, without reference to the host element's items array.\n * @example ```js\n * isItem: (item) => item instanceof MyCustomItem\n * ```\n */\n isItem?(item: EventTarget | null): item is Item;\n /**\n * Function returning the item which currently has assistive technology focus.\n * In most cases, this should be the `atFocusedItem` of an ATFocusController\n * i.e. RovingTabindexController or ActivedescendantController.\n *\n */\n getATFocusedItem(): Item | null;\n /**\n * Function returning the DOM node which is the direct parent of the item elements\n * Defaults to the controller host.\n * If the controller host is not an HTMLElement, this *must* be set\n */\n getItemsContainer?(): HTMLElement | null;\n /**\n * Optional function returning an additional DOM node which controls the listbox, e.g.\n * a combobox input.\n */\n getControlsElements?(): HTMLElement[];\n}\n\n/**\n * This is the default method for setting the selected state on an item element\n * @param item the item\n * @param selected is this item selected\n */\nfunction setItemSelected<Item extends HTMLElement>(item: Item, selected: boolean) {\n if (selected) {\n item.setAttribute('aria-selected', 'true');\n } else {\n item.removeAttribute('aria-selected');\n }\n}\n\n/**\n * @param item possible disabled item\n * @package do not import this outside of `@patternfly/pfe-core`, it is subject to change at any time\n */\nexport function isItem<Item extends HTMLElement>(item: EventTarget | null): item is Item {\n return item instanceof Element\n && item?.parentElement?.role === 'listbox'\n && item?.role !== 'presentation'\n && item?.localName !== 'hr';\n}\n\n/**\n * This is a fib. aria-disabled might not be present on an element that uses internals,\n * and the `disabled` attribute may not accurately represent the disabled state.\n * short of patching the `attachInternals` constructor, it may not be possible at\n * runtime to know with certainty that an arbitrary custom element is disabled or not.\n * @param item possibly disabled item\n * @package do not import this outside of `@patternfly/pfe-core`, it is subject to change at any time\n */\nexport function isItemDisabled<Item extends HTMLElement>(item: Item): boolean {\n return ('disabled' in item && typeof item.disabled === 'boolean' && item.disabled)\n || item.getAttribute('aria-disabled') === 'true'\n || item.hasAttribute('disabled')\n || item.hasAttribute('inert')\n || item.matches(':disabled');\n}\n\nlet constructingAllowed = false;\n\n/**\n * Implements listbox semantics and accesibility. As there are two recognized\n * patterns for implementing keyboard interactions with listbox patterns,\n * provide a secondary controller (either RovingTabindexController or\n * ActiveDescendantController) to complete the implementation.\n *\n * @see https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_focus_vs_selection\n *\n * > Occasionally, it may appear as if two elements on the page have focus at the same time.\n * > For example, in a multi-select list box, when an option is selected it may be greyed.\n * > Yet, the focus indicator can still be moved to other options, which may also be selected.\n * > Similarly, when a user activates a tab in a tablist, the selected state is set on the tab\n * > and its visual appearance changes. However, the user can still navigate, moving the focus\n * > indicator elsewhere on the page while the tab retains its selected appearance and state.\n * >\n * > Focus and selection are quite different. From the keyboard user's perspective,\n * > focus is a pointer, like a mouse pointer; it tracks the path of navigation.\n * > There is only one point of focus at any time and all operations take place at the\n * > point of focus. On the other hand, selection is an operation that can be performed in\n * > some widgets, such as list boxes, trees, and tablists. If a widget supports only single\n * > selection, then only one item can be selected and very often the selected state will simply\n * > follow the focus when focus is moved inside of the widget.\n * > That is, in some widgets, moving focus may also perform the select operation.\n * > However, if the widget supports multiple selection, then more than one item can be in a\n * > selected state, and keys for moving focus do not perform selection. Some multi-select widgets\n * > do support key commands that both move focus and change selection, but those keys are\n * > different from the normal navigation keys. Finally, when focus leaves a widget that includes\n * > a selected element, the selected state persists.\n * >\n * > From the developer's perspective, the difference is simple -- the focused element is the\n * > active element (document.activeElement). Selected elements are elements that have\n * > aria-selected=\"true\".\n * >\n * > With respect to focus and the selected state, the most important considerations for designers\n * > and developers are:\n * >\n * > - The visual focus indicator must always be visible.\n * > - The selected state must be visually distinct from the focus indicator.\n */\nexport class ListboxController<Item extends HTMLElement> implements ReactiveController {\n private static instances = new WeakMap<ReactiveControllerHost, ListboxController<HTMLElement>>();\n\n public static of<Item extends HTMLElement>(\n host: ReactiveControllerHost,\n options: ListboxControllerOptions<Item>,\n ): ListboxController<Item> {\n constructingAllowed = true;\n const instance = new ListboxController<Item>(host, options);\n constructingAllowed = false;\n return instance as ListboxController<Item>;\n }\n\n /** Current active descendant when shift key is pressed */\n #shiftStartingItem: Item | null = null;\n\n #options: RequireProps<ListboxControllerOptions<Item>,\n | 'setItemSelected'\n | 'isItemDisabled'\n | 'isItem'\n >;\n\n /** All items */\n #items: Item[] = [];\n\n #selectedItems = new Set<Item>;\n\n #listening = false;\n\n /** Whether listbox is disabled */\n disabled = false;\n\n get container(): HTMLElement {\n return this.#options.getItemsContainer?.() ?? this.host as unknown as HTMLElement;\n }\n\n get multi(): boolean {\n return !!this.#options.multi;\n }\n\n set multi(v: boolean) {\n this.#options.multi = v;\n this.host.requestUpdate();\n }\n\n get items(): Item[] {\n return this.#items;\n }\n\n /**\n * register's the host's Item elements as listbox controller items\n * sets aria-setsize and aria-posinset on items\n * @param items items\n */\n set items(items: Item[]) {\n this.#items = items;\n this.#items.forEach((item, index, _items) => {\n item.ariaSetSize = _items.length.toString();\n item.ariaPosInSet = (index + 1).toString();\n });\n }\n\n /**\n * sets the listbox value based on selected options\n * @param selected item or items\n */\n set selected(selected: Item[]) {\n if (!arraysAreEquivalent(selected, Array.from(this.#selectedItems))) {\n this.#selectedItems = new Set(selected);\n for (const item of this.items) {\n this.#options.setItemSelected(item, this.#selectedItems.has(item));\n }\n this.host.requestUpdate();\n }\n }\n\n /**\n * array of options which are selected\n */\n get selected(): Item[] {\n return [...this.#selectedItems];\n }\n\n private constructor(\n public host: ReactiveControllerHost,\n options: ListboxControllerOptions<Item>,\n ) {\n this.#options = { setItemSelected, isItemDisabled, isItem, ...options };\n if (!constructingAllowed) {\n throw new Error('ListboxController must be constructed with `ListboxController.of()`');\n }\n if (!isServer\n && !(host instanceof HTMLElement)\n && typeof options.getItemsContainer !== 'function') {\n throw new Error([\n 'ListboxController requires the host to be an HTMLElement',\n 'or for the initializer to include a getItemsContainer() function',\n ].join(' '));\n }\n const instance = ListboxController.instances.get(host) as unknown as ListboxController<Item>;\n if (instance) {\n return instance as ListboxController<Item>;\n }\n ListboxController.instances.set(host, this as unknown as ListboxController<HTMLElement>);\n this.host.addController(this);\n this.multi = this.#options.multi ?? false;\n if (this.container?.isConnected) {\n this.hostConnected();\n }\n }\n\n async hostConnected(): Promise<void> {\n await this.host.updateComplete;\n this.hostUpdate();\n this.hostUpdated();\n }\n\n #controlsElements: HTMLElement[] = [];\n\n #removeControlsListeners(els = this.#controlsElements) {\n for (const el of els) {\n el.removeEventListener('keydown', this.#onKeydown);\n el.removeEventListener('keyup', this.#onKeyup);\n }\n }\n\n hostUpdate(): void {\n const last = this.#controlsElements;\n this.#controlsElements = this.#options.getControlsElements?.() ?? [];\n if (!arraysAreEquivalent(last, this.#controlsElements)) {\n this.#removeControlsListeners(last);\n for (const el of this.#controlsElements) {\n el.addEventListener('keydown', this.#onKeydown);\n el.addEventListener('keyup', this.#onKeyup);\n }\n }\n }\n\n hostUpdated(): void {\n if (!this.#listening) {\n this.container?.addEventListener('click', this.#onClick);\n this.container?.addEventListener('keydown', this.#onKeydown);\n this.container?.addEventListener('keyup', this.#onKeyup);\n this.#listening = true;\n }\n this.container?.setAttribute('role', 'listbox');\n this.container?.setAttribute('aria-disabled', String(!!this.disabled));\n this.container?.setAttribute('aria-multiselectable', String(!!this.#options.multi));\n }\n\n hostDisconnected(): void {\n this.container?.removeEventListener('click', this.#onClick);\n this.container?.removeEventListener('keydown', this.#onKeydown);\n this.container?.removeEventListener('keyup', this.#onKeyup);\n this.#removeControlsListeners();\n this.#listening = false;\n }\n\n public isSelected(item: Item): boolean {\n return this.#selectedItems.has(item);\n }\n\n get #isExpanded() {\n return !this.#controlsElements.length ? true\n : this.#controlsElements.every(x => x.ariaExpanded === 'true');\n }\n\n /**\n * In the case where aria IDL attributes are not supported,\n * we need to correlate the item in the event path (i.e. the shadow dom clone)\n * with the item in listbox controller's root (i.e. the hidden light dom original)\n * XXX: as long as there is no DOM preceeding the shadow root clones, this will work\n * @param event click or keyboard event\n */\n #getItemFromEvent(event: Event): Item | null {\n // NOTE(bennypowers): I am aware that this function *sucks*\n // you're more than welcome to improve it.\n // make sure there are unit tests first\n const path = event.composedPath();\n const tabindexed = this.items.some(x => x.hasAttribute('tabindex'));\n if (tabindexed) {\n const item = path.find(this.#options.isItem);\n if (item) {\n return item;\n }\n } else if (this.#options.isItem(event.target)\n && event.target.getRootNode() !== this.container.getRootNode()\n && 'ariaActiveDescendantElement' in HTMLElement.prototype) {\n return event.target;\n } else if (event.target instanceof HTMLElement && event.target.ariaActiveDescendantElement) {\n return event.target.ariaActiveDescendantElement as Item;\n } else if (event.type === 'click'\n && this.#options.isItem(event.target)\n && event.target.id) {\n const element = event.target;\n const root = element.getRootNode();\n if (root instanceof ShadowRoot && this.container.getRootNode() === root) {\n const shadowRootListboxElement = this.container;\n const shadowRootItem = element;\n if (shadowRootItem && shadowRootListboxElement) {\n if (this.items.includes(shadowRootItem)) {\n return shadowRootItem;\n } else {\n const index =\n Array.from(shadowRootListboxElement?.children ?? [])\n .filter(this.#options.isItem)\n .filter(x => !x.hidden)\n .indexOf(shadowRootItem);\n return this.#items.filter(x => !x.hidden)[index];\n }\n }\n }\n } else {\n // otherwise, query the root (e.g. shadow root) for the associated element\n const element = event.target as HTMLElement;\n\n const root = element.getRootNode() as ShadowRoot | Document;\n\n const controlsId = element?.getAttribute('aria-controls');\n const shadowRootListboxElement =\n this.#options.isItem(element) ? this.container\n : controlsId ? root.getElementById(controlsId)\n : null;\n\n const shadowRootHasActiveDescendantElement =\n root.querySelector(`[aria-controls=\"${shadowRootListboxElement?.id}\"][aria-activedescendant]`);\n\n const shadowRootItemId =\n shadowRootHasActiveDescendantElement?.getAttribute('aria-activedescendant');\n\n const shadowRootItem =\n shadowRootItemId && root.getElementById(shadowRootItemId) as Item | null;\n\n if (shadowRootItem && shadowRootListboxElement) {\n if (this.items.includes(shadowRootItem)) {\n return shadowRootItem;\n } else {\n const index =\n Array.from(shadowRootListboxElement?.children ?? [])\n .filter(this.#options.isItem)\n .filter(x => !x.hidden)\n .indexOf(shadowRootItem);\n return this.#items.filter(x => !x.hidden)[index];\n }\n }\n\n const itemFromEventContainer =\n shadowRootListboxElement ? shadowRootListboxElement\n : path.find(x =>\n x instanceof HTMLElement && x.role === 'listbox') as HTMLElement;\n\n if (itemFromEventContainer) {\n const possiblyShadowRootContainerItems = Array.from(itemFromEventContainer.children)\n .filter(this.#options.isItem);\n\n const index = possiblyShadowRootContainerItems\n .findIndex(node => path.includes(node));\n\n if (index >= 0) {\n return this.items[index] ?? null;\n }\n }\n }\n\n return null;\n }\n\n /**\n * handles clicking on a listbox option:\n * which selects an item by default\n * or toggles selection if multiselectable\n * @param event click event\n */\n #onClick = (event: MouseEvent) => {\n const item = this.#getItemFromEvent(event);\n this.#shiftStartingItem ??= this.#getItemFromEvent(event);\n if (item && !this.#options.isItemDisabled(item)) {\n // Case: single select?\n // just reset the selected list.\n if (!this.multi) {\n // select target and deselect all other options\n this.selected = [item];\n // Case: multi select, but no shift key\n // toggle target, keep all other previously selected\n } else if (!event.shiftKey) {\n this.selected = this.items.filter(possiblySelectedItem =>\n this.#selectedItems.has(possiblySelectedItem) ? possiblySelectedItem !== item\n : possiblySelectedItem === item);\n // Case: multi select, with shift key\n // find all items between previously selected and target,\n // and select them (if reference item is selected) or deselect them (if reference item is deselected)\n // Do not wrap around from end to start, rather, only select withing the range of 0-end\n } else {\n const startingItem = this.#shiftStartingItem!;\n // whether options will be selected (true) or deselected (false)\n const selecting = this.#selectedItems.has(startingItem);\n const [start, end] = [this.items.indexOf(startingItem), this.items.indexOf(item)].sort();\n // de/select all options between active descendant and target\n this.selected = this.items.filter((item, i) => {\n if (i >= start && i <= end) {\n return selecting;\n } else {\n return this.#selectedItems.has(item);\n }\n });\n }\n }\n this.#shiftStartingItem = item;\n this.host.requestUpdate();\n };\n\n /**\n * track whether shift key is being used for multiselectable listbox\n * @param event keyup event\n */\n #onKeyup = (event: KeyboardEvent) => {\n if (event.key === 'Shift') {\n this.#shiftStartingItem = null;\n }\n };\n\n /**\n * filters listbox by keyboard event when slotted option has focus,\n * or by external element such as a text field\n * @param event keydown event\n */\n #onKeydown = (event: KeyboardEvent) => {\n const item = this.#getItemFromEvent(event);\n\n if (this.disabled\n || event.altKey\n || event.metaKey\n || !this.#isExpanded) {\n return;\n }\n\n // need to set for keyboard support of multiselect\n if (event.key === 'Shift' && this.multi) {\n this.#shiftStartingItem ??= this.#options.getATFocusedItem() ?? null;\n }\n\n switch (event.key) {\n // ctrl+A de/selects all options\n case 'a':\n case 'A':\n if (event.ctrlKey\n && (event.target === this.container\n || this.#options.isItem(event.target))) {\n const selectableItems = this.items.filter(item => !this.#options.isItemDisabled(item));\n if (arraysAreEquivalent(this.selected, selectableItems)) {\n this.selected = [];\n } else {\n this.selected = selectableItems;\n }\n event.preventDefault();\n }\n break;\n case 'Enter':\n // enter and space are only applicable if a listbox option is clicked\n // an external text input should not trigger multiselect\n if (item && !event.shiftKey) {\n const focused = item;\n this.#selectItem(focused, event.shiftKey);\n event.preventDefault();\n }\n break;\n case 'ArrowUp':\n if (this.multi && event.shiftKey && this.#options.isItem(event.target)) {\n const item = event.target;\n this.selected = this.items.filter((x, i) =>\n this.#selectedItems.has(x)\n || i === this.items.indexOf(item) - 1)\n .filter(x => !this.#options.isItemDisabled(x));\n }\n break;\n case 'ArrowDown':\n if (this.multi && event.shiftKey && this.#options.isItem(event.target)) {\n const item = event.target;\n this.selected = this.items.filter((x, i) =>\n this.#selectedItems.has(x)\n || i === this.items.indexOf(item) + 1)\n .filter(x => !this.#options.isItemDisabled(x));\n }\n break;\n case ' ':\n // enter and space are only applicable if a listbox option is clicked\n // an external text input should not trigger multiselect\n if (item && event.target === this.container) {\n this.#selectItem(item, event.shiftKey);\n event.preventDefault();\n } else if (this.#options.isItem(event.target)) {\n this.#selectItem(event.target, event.shiftKey);\n event.preventDefault();\n }\n break;\n default:\n break;\n }\n this.host.requestUpdate();\n };\n\n #selectItem(item: Item, shiftDown = false) {\n if (this.#options.isItemDisabled(item)) {\n return;\n } else if (this.multi && shiftDown) {\n // update starting item for other multiselect\n this.selected = [...this.selected, item];\n } else if (this.multi && this.#selectedItems.has(item)) {\n this.selected = this.selected.filter(x => x !== item);\n } else if (this.multi) {\n this.selected = this.selected.concat(item);\n } else {\n this.selected = [item];\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { ReactiveController, ReactiveControllerHost } from 'lit';
1
+ import { type ReactiveController, type ReactiveControllerHost } from 'lit';
2
2
  export declare class Logger implements ReactiveController {
3
3
  private host;
4
4
  private static logDebug;
@@ -8,67 +8,70 @@ export declare class Logger implements ReactiveController {
8
8
  * A boolean value that indicates if the logging should be printed to the console; used for debugging.
9
9
  * For use in a JS file or script tag; can also be added in the constructor of a component during development.
10
10
  * @example Logger.debugLog(true);
11
- * @tags debug
11
+ * @param [preference=null]
12
12
  */
13
13
  static debugLog(preference?: null): boolean;
14
14
  /**
15
15
  * A logging wrapper which checks the debugLog boolean and prints to the console if true.
16
- *
17
16
  * @example Logger.debug("Hello");
17
+ * @param msgs console.log params
18
18
  */
19
19
  static debug(...msgs: unknown[]): void;
20
20
  /**
21
21
  * A logging wrapper which checks the debugLog boolean and prints to the console if true.
22
- *
23
22
  * @example Logger.info("Hello");
23
+ * @param msgs console.log params
24
24
  */
25
25
  static info(...msgs: unknown[]): void;
26
26
  /**
27
27
  * A logging wrapper which checks the debugLog boolean and prints to the console if true.
28
- *
29
- * @example Logger.log("Hello");
28
+ * @example Logger.log("Hello");
29
+ * @param msgs console.log params
30
30
  */
31
31
  static log(...msgs: unknown[]): void;
32
32
  /**
33
33
  * A console warning wrapper which formats your output with useful debugging information.
34
- *
35
34
  * @example Logger.warn("Hello");
35
+ * @param msgs console.log params
36
36
  */
37
37
  static warn(...msgs: unknown[]): void;
38
38
  /**
39
39
  * A console error wrapper which formats your output with useful debugging information.
40
40
  * For use inside a component's function.
41
41
  * @example Logger.error("Hello");
42
+ * @param msgs console.log params
42
43
  */
43
44
  static error(...msgs: unknown[]): void;
44
45
  /**
45
46
  * Debug logging that outputs the tag name as a prefix automatically
46
- *
47
47
  * @example this.logger.log("Hello");
48
+ * @param msgs console.log params
48
49
  */
49
50
  debug(...msgs: unknown[]): void;
50
51
  /**
51
52
  * Info logging that outputs the tag name as a prefix automatically
52
- *
53
53
  * @example this.logger.log("Hello");
54
+ * @param msgs console.log params
54
55
  */
55
56
  info(...msgs: unknown[]): void;
56
57
  /**
57
58
  * Local logging that outputs the tag name as a prefix automatically
58
- *
59
59
  * @example this.logger.log("Hello");
60
+ * @param msgs console.log params
60
61
  */
61
62
  log(...msgs: unknown[]): void;
62
63
  /**
63
64
  * Local warning wrapper that outputs the tag name as a prefix automatically.
64
65
  * For use inside a component's function.
65
66
  * @example this.logger.warn("Hello");
67
+ * @param msgs console.log params
66
68
  */
67
69
  warn(...msgs: unknown[]): void;
68
70
  /**
69
71
  * Local error wrapper that outputs the tag name as a prefix automatically.
70
72
  * For use inside a component's function.
71
73
  * @example this.logger.error("Hello");
74
+ * @param msgs console.log params
72
75
  */
73
76
  error(...msgs: unknown[]): void;
74
77
  constructor(host: ReactiveControllerHost);
@@ -1,6 +1,7 @@
1
+ import { isServer } from 'lit';
1
2
  export class Logger {
2
3
  get prefix() {
3
- if (this.host instanceof HTMLElement) {
4
+ if (!isServer && this.host instanceof HTMLElement) {
4
5
  return `[${this.host.localName}${this.host.id ? `#${this.host.id}` : ''}]`;
5
6
  }
6
7
  else {
@@ -11,7 +12,7 @@ export class Logger {
11
12
  * A boolean value that indicates if the logging should be printed to the console; used for debugging.
12
13
  * For use in a JS file or script tag; can also be added in the constructor of a component during development.
13
14
  * @example Logger.debugLog(true);
14
- * @tags debug
15
+ * @param [preference=null]
15
16
  */
16
17
  static debugLog(preference = null) {
17
18
  // wrap localStorage references in a try/catch; merely referencing it can
@@ -23,15 +24,15 @@ export class Logger {
23
24
  }
24
25
  return localStorage.pfeLog === 'true';
25
26
  }
26
- catch (e) {
27
+ catch {
27
28
  return Logger.logDebug;
28
29
  }
29
30
  }
30
31
  /* eslint-disable no-console */
31
32
  /**
32
33
  * A logging wrapper which checks the debugLog boolean and prints to the console if true.
33
- *
34
34
  * @example Logger.debug("Hello");
35
+ * @param msgs console.log params
35
36
  */
36
37
  static debug(...msgs) {
37
38
  if (Logger.debugLog()) {
@@ -40,8 +41,8 @@ export class Logger {
40
41
  }
41
42
  /**
42
43
  * A logging wrapper which checks the debugLog boolean and prints to the console if true.
43
- *
44
44
  * @example Logger.info("Hello");
45
+ * @param msgs console.log params
45
46
  */
46
47
  static info(...msgs) {
47
48
  if (Logger.debugLog()) {
@@ -50,8 +51,8 @@ export class Logger {
50
51
  }
51
52
  /**
52
53
  * A logging wrapper which checks the debugLog boolean and prints to the console if true.
53
- *
54
- * @example Logger.log("Hello");
54
+ * @example Logger.log("Hello");
55
+ * @param msgs console.log params
55
56
  */
56
57
  static log(...msgs) {
57
58
  if (Logger.debugLog()) {
@@ -60,8 +61,8 @@ export class Logger {
60
61
  }
61
62
  /**
62
63
  * A console warning wrapper which formats your output with useful debugging information.
63
- *
64
64
  * @example Logger.warn("Hello");
65
+ * @param msgs console.log params
65
66
  */
66
67
  static warn(...msgs) {
67
68
  console.warn(...msgs);
@@ -70,6 +71,7 @@ export class Logger {
70
71
  * A console error wrapper which formats your output with useful debugging information.
71
72
  * For use inside a component's function.
72
73
  * @example Logger.error("Hello");
74
+ * @param msgs console.log params
73
75
  */
74
76
  static error(...msgs) {
75
77
  console.error([...msgs].join(' '));
@@ -77,24 +79,24 @@ export class Logger {
77
79
  /* eslint-enable no-console */
78
80
  /**
79
81
  * Debug logging that outputs the tag name as a prefix automatically
80
- *
81
82
  * @example this.logger.log("Hello");
83
+ * @param msgs console.log params
82
84
  */
83
85
  debug(...msgs) {
84
86
  Logger.debug(this.prefix, ...msgs);
85
87
  }
86
88
  /**
87
89
  * Info logging that outputs the tag name as a prefix automatically
88
- *
89
90
  * @example this.logger.log("Hello");
91
+ * @param msgs console.log params
90
92
  */
91
93
  info(...msgs) {
92
94
  Logger.info(this.prefix, ...msgs);
93
95
  }
94
96
  /**
95
97
  * Local logging that outputs the tag name as a prefix automatically
96
- *
97
98
  * @example this.logger.log("Hello");
99
+ * @param msgs console.log params
98
100
  */
99
101
  log(...msgs) {
100
102
  Logger.log(this.prefix, ...msgs);
@@ -103,6 +105,7 @@ export class Logger {
103
105
  * Local warning wrapper that outputs the tag name as a prefix automatically.
104
106
  * For use inside a component's function.
105
107
  * @example this.logger.warn("Hello");
108
+ * @param msgs console.log params
106
109
  */
107
110
  warn(...msgs) {
108
111
  Logger.warn(this.prefix, ...msgs);
@@ -111,6 +114,7 @@ export class Logger {
111
114
  * Local error wrapper that outputs the tag name as a prefix automatically.
112
115
  * For use inside a component's function.
113
116
  * @example this.logger.error("Hello");
117
+ * @param msgs console.log params
114
118
  */
115
119
  error(...msgs) {
116
120
  Logger.error(this.prefix, ...msgs);
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,MAAM;IAKjB,IAAY,MAAM;QAChB,IAAI,IAAI,CAAC,IAAI,YAAY,WAAW,EAAE,CAAC;YACrC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,IAAI;QAC/B,yEAAyE;QACzE,gDAAgD;QAChD,IAAI,CAAC;YACH,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;gBACxB,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC;gBAC/B,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,UAAU,CAAC;YACrC,CAAC;YACD,OAAO,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC;QACxC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,MAAM,CAAC,QAAQ,CAAC;QACzB,CAAC;IACH,CAAC;IAED,+BAA+B;IAE/B;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,IAAe;QAC7B,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,GA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AC;IACpC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,IAAe;QACtB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,YAAoB,IAA4B;QAA5B,SAAI,GAAJ,IAAI,CAAwB;QAC9C,4CAA4C;QAC5C,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAW,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,aAAa;QACX,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1B,CAAC;;AA7Ic,gBAAS,GAA4C,IAAI,OAAO,EAAE,CAAC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\nexport class Logger implements ReactiveController {\n private static logDebug: boolean;\n\n private static instances: WeakMap<ReactiveControllerHost, Logger> = new WeakMap();\n\n private get prefix() {\n if (this.host instanceof HTMLElement) {\n return `[${this.host.localName}${this.host.id ? `#${this.host.id}` : ''}]`;\n } else {\n return `[${this.host.constructor.name}]`;\n }\n }\n\n /**\n * A boolean value that indicates if the logging should be printed to the console; used for debugging.\n * For use in a JS file or script tag; can also be added in the constructor of a component during development.\n * @example Logger.debugLog(true);\n * @tags debug\n */\n static debugLog(preference = null) {\n // wrap localStorage references in a try/catch; merely referencing it can\n // throw errors in some locked down environments\n try {\n if (preference !== null) {\n Logger.logDebug = !!preference;\n localStorage.pfeLog = !!preference;\n }\n return localStorage.pfeLog === 'true';\n } catch (e) {\n return Logger.logDebug;\n }\n }\n\n /* eslint-disable no-console */\n\n /**\n * A logging wrapper which checks the debugLog boolean and prints to the console if true.\n *\n * @example Logger.debug(\"Hello\");\n */\n static debug(...msgs: unknown[]) {\n if (Logger.debugLog()) {\n console.debug(...msgs);\n }\n }\n\n /**\n * A logging wrapper which checks the debugLog boolean and prints to the console if true.\n *\n * @example Logger.info(\"Hello\");\n */\n static info(...msgs: unknown[]) {\n if (Logger.debugLog()) {\n console.info(...msgs);\n }\n }\n\n /**\n * A logging wrapper which checks the debugLog boolean and prints to the console if true.\n *\n * @example Logger.log(\"Hello\");\n */\n static log(...msgs: unknown[]) {\n if (Logger.debugLog()) {\n console.log(...msgs);\n }\n }\n\n /**\n * A console warning wrapper which formats your output with useful debugging information.\n *\n * @example Logger.warn(\"Hello\");\n */\n static warn(...msgs: unknown[]) {\n console.warn(...msgs);\n }\n\n /**\n * A console error wrapper which formats your output with useful debugging information.\n * For use inside a component's function.\n * @example Logger.error(\"Hello\");\n */\n static error(...msgs: unknown[]) {\n console.error([...msgs].join(' '));\n }\n\n /* eslint-enable no-console */\n\n /**\n * Debug logging that outputs the tag name as a prefix automatically\n *\n * @example this.logger.log(\"Hello\");\n */\n debug(...msgs: unknown[]) {\n Logger.debug(this.prefix, ...msgs);\n }\n\n /**\n * Info logging that outputs the tag name as a prefix automatically\n *\n * @example this.logger.log(\"Hello\");\n */\n info(...msgs: unknown[]) {\n Logger.info(this.prefix, ...msgs);\n }\n\n /**\n * Local logging that outputs the tag name as a prefix automatically\n *\n * @example this.logger.log(\"Hello\");\n */\n log(...msgs: unknown[]) {\n Logger.log(this.prefix, ...msgs);\n }\n\n /**\n * Local warning wrapper that outputs the tag name as a prefix automatically.\n * For use inside a component's function.\n * @example this.logger.warn(\"Hello\");\n */\n warn(...msgs: unknown[]) {\n Logger.warn(this.prefix, ...msgs);\n }\n\n /**\n * Local error wrapper that outputs the tag name as a prefix automatically.\n * For use inside a component's function.\n * @example this.logger.error(\"Hello\");\n */\n error(...msgs: unknown[]) {\n Logger.error(this.prefix, ...msgs);\n }\n\n constructor(private host: ReactiveControllerHost) {\n // We only need one logger instance per host\n if (Logger.instances.get(host)) {\n return Logger.instances.get(host) as Logger;\n }\n host.addController(this);\n Logger.instances.set(host, this);\n }\n\n hostConnected() {\n this.debug('connected');\n }\n}\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwD,MAAM,KAAK,CAAC;AAErF,MAAM,OAAO,MAAM;IAKjB,IAAY,MAAM;QAChB,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,YAAY,WAAW,EAAE,CAAC;YAClD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,IAAI;QAC/B,yEAAyE;QACzE,gDAAgD;QAChD,IAAI,CAAC;YACH,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;gBACxB,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC;gBAC/B,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,UAAU,CAAC;YACrC,CAAC;YACD,OAAO,YAAY,CAAC,MAAM,KAAK,MAAM,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,MAAM,CAAC,QAAQ,CAAC;QACzB,CAAC;IACH,CAAC;IAED,+BAA+B;IAE/B;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,IAAe;QAC7B,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC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ED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,IAAe;QACtB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,YAAoB,IAA4B;QAA5B,SAAI,GAAJ,IAAI,CAAwB;QAC9C,4CAA4C;QAC5C,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAW,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,aAAa;QACX,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC1B,CAAC;;AAhJc,gBAAS,GAAG,IAAI,OAAO,EAAkC,CAAC","sourcesContent":["import { isServer, type ReactiveController, type ReactiveControllerHost } from 'lit';\n\nexport class Logger implements ReactiveController {\n private static logDebug: boolean;\n\n private static instances = new WeakMap<ReactiveControllerHost, Logger>();\n\n private get prefix() {\n if (!isServer && this.host instanceof HTMLElement) {\n return `[${this.host.localName}${this.host.id ? `#${this.host.id}` : ''}]`;\n } else {\n return `[${this.host.constructor.name}]`;\n }\n }\n\n /**\n * A boolean value that indicates if the logging should be printed to the console; used for debugging.\n * For use in a JS file or script tag; can also be added in the constructor of a component during development.\n * @example Logger.debugLog(true);\n * @param [preference=null]\n */\n static debugLog(preference = null): boolean {\n // wrap localStorage references in a try/catch; merely referencing it can\n // throw errors in some locked down environments\n try {\n if (preference !== null) {\n Logger.logDebug = !!preference;\n localStorage.pfeLog = !!preference;\n }\n return localStorage.pfeLog === 'true';\n } catch {\n return Logger.logDebug;\n }\n }\n\n /* eslint-disable no-console */\n\n /**\n * A logging wrapper which checks the debugLog boolean and prints to the console if true.\n * @example Logger.debug(\"Hello\");\n * @param msgs console.log params\n */\n static debug(...msgs: unknown[]): void {\n if (Logger.debugLog()) {\n console.debug(...msgs);\n }\n }\n\n /**\n * A logging wrapper which checks the debugLog boolean and prints to the console if true.\n * @example Logger.info(\"Hello\");\n * @param msgs console.log params\n */\n static info(...msgs: unknown[]): void {\n if (Logger.debugLog()) {\n console.info(...msgs);\n }\n }\n\n /**\n * A logging wrapper which checks the debugLog boolean and prints to the console if true.\n * @example Logger.log(\"Hello\");\n * @param msgs console.log params\n */\n static log(...msgs: unknown[]): void {\n if (Logger.debugLog()) {\n console.log(...msgs);\n }\n }\n\n /**\n * A console warning wrapper which formats your output with useful debugging information.\n * @example Logger.warn(\"Hello\");\n * @param msgs console.log params\n */\n static warn(...msgs: unknown[]): void {\n console.warn(...msgs);\n }\n\n /**\n * A console error wrapper which formats your output with useful debugging information.\n * For use inside a component's function.\n * @example Logger.error(\"Hello\");\n * @param msgs console.log params\n */\n static error(...msgs: unknown[]): void {\n console.error([...msgs].join(' '));\n }\n\n /* eslint-enable no-console */\n\n /**\n * Debug logging that outputs the tag name as a prefix automatically\n * @example this.logger.log(\"Hello\");\n * @param msgs console.log params\n */\n debug(...msgs: unknown[]): void {\n Logger.debug(this.prefix, ...msgs);\n }\n\n /**\n * Info logging that outputs the tag name as a prefix automatically\n * @example this.logger.log(\"Hello\");\n * @param msgs console.log params\n */\n info(...msgs: unknown[]): void {\n Logger.info(this.prefix, ...msgs);\n }\n\n /**\n * Local logging that outputs the tag name as a prefix automatically\n * @example this.logger.log(\"Hello\");\n * @param msgs console.log params\n */\n log(...msgs: unknown[]): void {\n Logger.log(this.prefix, ...msgs);\n }\n\n /**\n * Local warning wrapper that outputs the tag name as a prefix automatically.\n * For use inside a component's function.\n * @example this.logger.warn(\"Hello\");\n * @param msgs console.log params\n */\n warn(...msgs: unknown[]): void {\n Logger.warn(this.prefix, ...msgs);\n }\n\n /**\n * Local error wrapper that outputs the tag name as a prefix automatically.\n * For use inside a component's function.\n * @example this.logger.error(\"Hello\");\n * @param msgs console.log params\n */\n error(...msgs: unknown[]): void {\n Logger.error(this.prefix, ...msgs);\n }\n\n constructor(private host: ReactiveControllerHost) {\n // We only need one logger instance per host\n if (Logger.instances.get(host)) {\n return Logger.instances.get(host) as Logger;\n }\n host.addController(this);\n Logger.instances.set(host, this);\n }\n\n hostConnected(): void {\n this.debug('connected');\n }\n}\n"]}
@@ -86,14 +86,18 @@ _a = OverflowController, _OverflowController_container = new WeakMap(), _Overflo
86
86
  }
87
87
  const prevLeft = this.overflowLeft;
88
88
  const prevRight = this.overflowRight;
89
- this.overflowLeft = !__classPrivateFieldGet(this, _OverflowController_hideOverflowButtons, "f") && !isElementInView(__classPrivateFieldGet(this, _OverflowController_container, "f"), this.firstItem);
90
- this.overflowRight = !__classPrivateFieldGet(this, _OverflowController_hideOverflowButtons, "f") && !isElementInView(__classPrivateFieldGet(this, _OverflowController_container, "f"), this.lastItem);
89
+ this.overflowLeft = !__classPrivateFieldGet(this, _OverflowController_hideOverflowButtons, "f")
90
+ && !isElementInView(__classPrivateFieldGet(this, _OverflowController_container, "f"), this.firstItem);
91
+ this.overflowRight = !__classPrivateFieldGet(this, _OverflowController_hideOverflowButtons, "f")
92
+ && !isElementInView(__classPrivateFieldGet(this, _OverflowController_container, "f"), this.lastItem);
91
93
  let scrollButtonsWidth = 0;
92
94
  if (this.overflowLeft || this.overflowRight) {
93
- scrollButtonsWidth = (__classPrivateFieldGet(this, _OverflowController_container, "f").parentElement?.querySelector('button')?.getBoundingClientRect().width || 0) * 2;
95
+ scrollButtonsWidth =
96
+ (__classPrivateFieldGet(this, _OverflowController_container, "f").parentElement?.querySelector('button')?.getBoundingClientRect().width || 0)
97
+ * 2;
94
98
  }
95
- this.showScrollButtons = !__classPrivateFieldGet(this, _OverflowController_hideOverflowButtons, "f") &&
96
- __classPrivateFieldGet(this, _OverflowController_container, "f").scrollWidth > (__classPrivateFieldGet(this, _OverflowController_container, "f").clientWidth + scrollButtonsWidth);
99
+ this.showScrollButtons = !__classPrivateFieldGet(this, _OverflowController_hideOverflowButtons, "f")
100
+ && __classPrivateFieldGet(this, _OverflowController_container, "f").scrollWidth > (__classPrivateFieldGet(this, _OverflowController_container, "f").clientWidth + scrollButtonsWidth);
97
101
  // only request update if there has been a change
98
102
  if ((prevLeft !== this.overflowLeft) || (prevRight !== this.overflowRight)) {
99
103
  this.host.requestUpdate();
@@ -102,7 +106,7 @@ _a = OverflowController, _OverflowController_container = new WeakMap(), _Overflo
102
106
  _OverflowController_instances_1 = { value: new Set() };
103
107
  (() => {
104
108
  // on resize check for overflows to add or remove scroll buttons
105
- window.addEventListener('resize', () => {
109
+ globalThis.addEventListener?.('resize', () => {
106
110
  for (const instance of __classPrivateFieldGet(_a, _a, "f", _OverflowController_instances_1)) {
107
111
  instance.onScroll();
108
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"overflow-controller.js","sourceRoot":"","sources":["overflow-controller.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AAapF,MAAM,OAAO,kBAAkB;IAuC7B,IAAI,SAAS;QACX,OAAO,uBAAA,IAAI,iCAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,uBAAA,IAAI,iCAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;IACE,kDAAkD;IAC3C,IAAqB,EACpB,OAAiB;;QADlB,SAAI,GAAJ,IAAI,CAAiB;QACpB,YAAO,GAAP,OAAO,CAAU;QAtC3B,yBAAyB;QACzB,gDAAyB;QACzB,iCAAiC;QACjC,oCAAwB,EAAE,EAAC;QAE3B,yDAA4B;QAC5B,oDAA+C;QAE/C,oBAAoB;QACpB,0DAA8B;QAE9B,iCAAM,IAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE;YACrC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,IAAI,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,CAAC,QAAQ,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACxC,CAAC,GAAA,CAAA","sourcesContent":["import type { ReactiveController, ReactiveElement } from 'lit';\n\nimport { isElementInView } from '@patternfly/pfe-core/functions/isElementInView.js';\n\nexport interface Options {\n /**\n * Force hide the scroll buttons regardless of overflow\n */\n hideOverflowButtons?: boolean;\n /**\n * Delay in ms to wait before checking for overflow\n */\n scrollTimeoutDelay?: number;\n}\n\nexport class OverflowController implements ReactiveController {\n static #instances = new Set<OverflowController>();\n\n static {\n // on resize check for overflows to add or remove scroll buttons\n window.addEventListener('resize', () => {\n for (const instance of this.#instances) {\n instance.onScroll();\n }\n }, { capture: false, passive: true });\n }\n\n /** Overflow container */\n #container?: HTMLElement;\n /** Children that can overflow */\n #items: HTMLElement[] = [];\n\n #scrollTimeoutDelay: number;\n #scrollTimeout?: ReturnType<typeof setTimeout>;\n\n /** Default state */\n #hideOverflowButtons: boolean;\n\n #mo = new MutationObserver(mutations => {\n for (const mutation of mutations) {\n if (mutation.type === 'childList') {\n this.#setOverflowState();\n }\n }\n });\n\n #ro = new ResizeObserver(() => {\n this.#setOverflowState();\n });\n\n showScrollButtons = false;\n overflowLeft = false;\n overflowRight = false;\n\n get firstItem(): HTMLElement | undefined {\n return this.#items.at(0);\n }\n\n get lastItem(): HTMLElement | undefined {\n return this.#items.at(-1);\n }\n\n constructor(\n // TODO: widen this type to ReactiveControllerHost\n public host: ReactiveElement,\n private options?: Options,\n ) {\n this.#hideOverflowButtons = options?.hideOverflowButtons ?? false;\n this.#scrollTimeoutDelay = options?.scrollTimeoutDelay ?? 0;\n if (host.isConnected) {\n OverflowController.#instances.add(this);\n }\n host.addController(this);\n if (host.isConnected) {\n this.hostConnected();\n }\n }\n\n #setOverflowState(): void {\n if (!this.firstItem || !this.lastItem || !this.#container) {\n return;\n }\n const prevLeft = this.overflowLeft;\n const prevRight = this.overflowRight;\n\n this.overflowLeft = !this.#hideOverflowButtons && !isElementInView(this.#container, this.firstItem);\n this.overflowRight = !this.#hideOverflowButtons && !isElementInView(this.#container, this.lastItem);\n let scrollButtonsWidth = 0;\n if (this.overflowLeft || this.overflowRight) {\n scrollButtonsWidth = (this.#container.parentElement?.querySelector('button')?.getBoundingClientRect().width || 0) * 2;\n }\n this.showScrollButtons = !this.#hideOverflowButtons &&\n this.#container.scrollWidth > (this.#container.clientWidth + scrollButtonsWidth);\n\n // only request update if there has been a change\n if ((prevLeft !== this.overflowLeft) || (prevRight !== this.overflowRight)) {\n this.host.requestUpdate();\n }\n }\n\n init(container: HTMLElement, items: HTMLElement[]) {\n this.#container = container;\n // convert HTMLCollection to HTMLElement[]\n this.#items = items;\n }\n\n onScroll = () => {\n clearTimeout(this.#scrollTimeout);\n this.#scrollTimeout = setTimeout(() => this.#setOverflowState(), this.#scrollTimeoutDelay);\n };\n\n scrollLeft() {\n if (!this.#container) {\n return;\n }\n const leftScroll = this.#container.scrollLeft - this.#container.clientWidth;\n this.#container.scroll({ left: leftScroll, behavior: 'smooth' });\n this.#setOverflowState();\n }\n\n scrollRight() {\n if (!this.#container) {\n return;\n }\n const leftScroll = this.#container.scrollLeft + this.#container.clientWidth;\n this.#container.scroll({ left: leftScroll, behavior: 'smooth' });\n this.#setOverflowState();\n }\n\n update() {\n this.#setOverflowState();\n }\n\n hostConnected(): void {\n this.#mo.observe(this.host, { attributes: false, childList: true, subtree: true });\n this.#ro.observe(this.host);\n this.onScroll();\n this.#setOverflowState();\n }\n}\n"]}
1
+ {"version":3,"file":"overflow-controller.js","sourceRoot":"","sources":["overflow-controller.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AAapF,MAAM,OAAO,kBAAkB;IAuC7B,IAAI,SAAS;QACX,OAAO,uBAAA,IAAI,iCAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,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,CAAC,WAAW,GAAG,CAAC,uBAAA,IAAI,qCAAW,CAAC,WAAW,GAAG,kBAAkB,CAAC,CAAC;IAEpF,iDAAiD;IACjD,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QAC3E,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC;AAtFM,2CAAa,IAAI,GAAG,EAAsB,EAAhC,CAAiC;AAElD;IACE,gEAAgE;IAChE,UAAU,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QAC3C,KAAK,MAAM,QAAQ,IAAI,oEAAe,EAAE,CAAC;YACvC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACxC,CAAC,GAAA,CAAA","sourcesContent":["import type { ReactiveController, ReactiveElement } from 'lit';\n\nimport { isElementInView } from '@patternfly/pfe-core/functions/isElementInView.js';\n\nexport interface Options {\n /**\n * Force hide the scroll buttons regardless of overflow\n */\n hideOverflowButtons?: boolean;\n /**\n * Delay in ms to wait before checking for overflow\n */\n scrollTimeoutDelay?: number;\n}\n\nexport class OverflowController implements ReactiveController {\n static #instances = new Set<OverflowController>();\n\n static {\n // on resize check for overflows to add or remove scroll buttons\n globalThis.addEventListener?.('resize', () => {\n for (const instance of this.#instances) {\n instance.onScroll();\n }\n }, { capture: false, passive: true });\n }\n\n /** Overflow container */\n #container?: HTMLElement;\n /** Children that can overflow */\n #items: HTMLElement[] = [];\n\n #scrollTimeoutDelay: number;\n #scrollTimeout?: ReturnType<typeof setTimeout>;\n\n /** Default state */\n #hideOverflowButtons: boolean;\n\n #mo = new MutationObserver(mutations => {\n for (const mutation of mutations) {\n if (mutation.type === 'childList') {\n this.#setOverflowState();\n }\n }\n });\n\n #ro = new ResizeObserver(() => {\n this.#setOverflowState();\n });\n\n showScrollButtons = false;\n overflowLeft = false;\n overflowRight = false;\n\n get firstItem(): HTMLElement | undefined {\n return this.#items.at(0);\n }\n\n get lastItem(): HTMLElement | undefined {\n return this.#items.at(-1);\n }\n\n constructor(\n // TODO: widen this type to ReactiveControllerHost\n public host: ReactiveElement,\n private options?: Options | undefined,\n ) {\n this.#hideOverflowButtons = options?.hideOverflowButtons ?? false;\n this.#scrollTimeoutDelay = options?.scrollTimeoutDelay ?? 0;\n if (host.isConnected) {\n OverflowController.#instances.add(this);\n }\n host.addController(this);\n if (host.isConnected) {\n this.hostConnected();\n }\n }\n\n #setOverflowState(): void {\n if (!this.firstItem || !this.lastItem || !this.#container) {\n return;\n }\n const prevLeft = this.overflowLeft;\n const prevRight = this.overflowRight;\n\n this.overflowLeft = !this.#hideOverflowButtons\n && !isElementInView(this.#container, this.firstItem);\n this.overflowRight = !this.#hideOverflowButtons\n && !isElementInView(this.#container, this.lastItem);\n let scrollButtonsWidth = 0;\n if (this.overflowLeft || this.overflowRight) {\n scrollButtonsWidth =\n (this.#container.parentElement?.querySelector('button')?.getBoundingClientRect().width || 0)\n * 2;\n }\n this.showScrollButtons = !this.#hideOverflowButtons\n && this.#container.scrollWidth > (this.#container.clientWidth + scrollButtonsWidth);\n\n // only request update if there has been a change\n if ((prevLeft !== this.overflowLeft) || (prevRight !== this.overflowRight)) {\n this.host.requestUpdate();\n }\n }\n\n init(container: HTMLElement, items: HTMLElement[]): void {\n this.#container = container;\n // convert HTMLCollection to HTMLElement[]\n this.#items = items;\n }\n\n onScroll = (): void => {\n clearTimeout(this.#scrollTimeout);\n this.#scrollTimeout = setTimeout(() => this.#setOverflowState(), this.#scrollTimeoutDelay);\n };\n\n scrollLeft(): void {\n if (!this.#container) {\n return;\n }\n const leftScroll = this.#container.scrollLeft - this.#container.clientWidth;\n this.#container.scroll({ left: leftScroll, behavior: 'smooth' });\n this.#setOverflowState();\n }\n\n scrollRight(): void {\n if (!this.#container) {\n return;\n }\n const leftScroll = this.#container.scrollLeft + this.#container.clientWidth;\n this.#container.scroll({ left: leftScroll, behavior: 'smooth' });\n this.#setOverflowState();\n }\n\n update(): void {\n this.#setOverflowState();\n }\n\n hostConnected(): void {\n this.#mo.observe(this.host, { attributes: false, childList: true, subtree: true });\n this.#ro.observe(this.host);\n this.onScroll();\n this.#setOverflowState();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"perf-controller.js","sourceRoot":"","sources":["perf-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,OAAO,cAAc;IAKzB,YAAoB,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;QAJzC,gBAAW,GAAG,KAAK,CAAC;QAKlB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAEzB,oEAAoE;QACpE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;aAAM,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QAC/C,CAAC;QAED,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,WAAW,CAAC,CAAC;QAE5C,yFAAyF;QACzF,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,kCAAkC,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,WAAW,CAAC,CAAC;QAE5G,6DAA6D;QAC7D,WAAW,CAAC,OAAO,CACjB,GAAG,IAAI,CAAC,MAAM,+BAA+B,EAC7C,GAAG,IAAI,CAAC,MAAM,UAAU,EACxB,GAAG,IAAI,CAAC,MAAM,WAAW,CAC1B,CAAC;QAEF,wEAAwE;QACxE,yCAAyC;QACzC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF","sourcesContent":["import type { ReactiveController, ReactiveElement } from 'lit';\n\nimport { getRandomId } from '../functions/random.js';\n\nexport class PerfController implements ReactiveController {\n hasMeasured = false;\n\n markId: string;\n\n constructor(private host: ReactiveElement) {\n host.addController(this);\n\n // Set up the mark ID based on existing ID on component if it exists\n if (!host.id) {\n this.markId = getRandomId(host.localName);\n } else if (host.id.startsWith('pf-') && !host.id.startsWith(host.localName)) {\n this.markId = host.id.replace('pf', host.localName);\n } else {\n this.markId = `${host.localName}-${host.id}`;\n }\n\n performance.mark(`${this.markId}-defined`);\n }\n\n hostUpdate() {\n if (!this.hasMeasured) {\n this.measure();\n }\n }\n\n measure() {\n this.hasMeasured = true;\n\n performance.mark(`${this.markId}-rendered`);\n\n // Navigation start, i.e., the browser first sees that the user has navigated to the page\n performance.measure(`${this.markId}-from-navigation-to-first-render`, undefined, `${this.markId}-rendered`);\n\n // Render is run before connection unless delayRender is used\n performance.measure(\n `${this.markId}-from-defined-to-first-render`,\n `${this.markId}-defined`,\n `${this.markId}-rendered`\n );\n\n // Once we've measured time to render, we no longer need the controller,\n // so we allow it to be garbage-collected\n this.host.removeController(this);\n }\n}\n"]}
1
+ {"version":3,"file":"perf-controller.js","sourceRoot":"","sources":["perf-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,OAAO,cAAc;IAKzB,YAAoB,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;QAJzC,gBAAW,GAAG,KAAK,CAAC;QAKlB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAEzB,oEAAoE;QACpE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;aAAM,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QAC/C,CAAC;QAED,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,WAAW,CAAC,CAAC;QAE5C,yFAAyF;QACzF,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,kCAAkC,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,WAAW,CAAC,CAAC;QAE5G,6DAA6D;QAC7D,WAAW,CAAC,OAAO,CACjB,GAAG,IAAI,CAAC,MAAM,+BAA+B,EAC7C,GAAG,IAAI,CAAC,MAAM,UAAU,EACxB,GAAG,IAAI,CAAC,MAAM,WAAW,CAC1B,CAAC;QAEF,wEAAwE;QACxE,yCAAyC;QACzC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF","sourcesContent":["import type { ReactiveController, ReactiveElement } from 'lit';\n\nimport { getRandomId } from '../functions/random.js';\n\nexport class PerfController implements ReactiveController {\n hasMeasured = false;\n\n markId: string;\n\n constructor(private host: ReactiveElement) {\n host.addController(this);\n\n // Set up the mark ID based on existing ID on component if it exists\n if (!host.id) {\n this.markId = getRandomId(host.localName);\n } else if (host.id.startsWith('pf-') && !host.id.startsWith(host.localName)) {\n this.markId = host.id.replace('pf', host.localName);\n } else {\n this.markId = `${host.localName}-${host.id}`;\n }\n\n performance.mark(`${this.markId}-defined`);\n }\n\n hostUpdate(): void {\n if (!this.hasMeasured) {\n this.measure();\n }\n }\n\n measure(): void {\n this.hasMeasured = true;\n\n performance.mark(`${this.markId}-rendered`);\n\n // Navigation start, i.e., the browser first sees that the user has navigated to the page\n performance.measure(`${this.markId}-from-navigation-to-first-render`, undefined, `${this.markId}-rendered`);\n\n // Render is run before connection unless delayRender is used\n performance.measure(\n `${this.markId}-from-defined-to-first-render`,\n `${this.markId}-defined`,\n `${this.markId}-rendered`\n );\n\n // Once we've measured time to render, we no longer need the controller,\n // so we allow it to be garbage-collected\n this.host.removeController(this);\n }\n}\n"]}
@@ -1,20 +1,17 @@
1
1
  import type { ReactiveController, ReactiveElement } from 'lit';
2
- export declare const observedController: unique symbol;
3
- export type ChangeCallback<T = ReactiveElement> = (this: T, old?: T[keyof T], newV?: T[keyof T]) => void;
4
- export type ChangeCallbackName = `_${string}Changed`;
5
- export type PropertyObserverHost<T> = T & Record<ChangeCallbackName, ChangeCallback<T>> & {
6
- [observedController]: PropertyObserverController;
7
- };
8
- /** This controller holds a cache of observed property values which were set before the element updated */
9
- export declare class PropertyObserverController implements ReactiveController {
2
+ export type ChangeCallback<T extends ReactiveElement, V = T[keyof T]> = (this: T, old?: V, newV?: V) => void;
3
+ export interface PropertyObserverOptions<T extends ReactiveElement> {
4
+ propertyName: string & keyof T;
5
+ callback: ChangeCallback<T>;
6
+ waitFor?: 'connected' | 'updated' | 'firstUpdated';
7
+ }
8
+ export declare class PropertyObserverController<T extends ReactiveElement> implements ReactiveController {
9
+ #private;
10
10
  private host;
11
- private static hosts;
12
- private values;
13
- private delete;
14
- constructor(host: ReactiveElement);
11
+ private options;
12
+ private oldVal;
13
+ constructor(host: T, options: PropertyObserverOptions<T>);
14
+ hostConnected(): void;
15
15
  /** Set any cached valued accumulated between constructor and connectedCallback */
16
- hostUpdate(): void;
17
- /** Once the element has updated, we no longer need this controller, so we remove it */
18
- hostUpdated(): void;
19
- cache(key: string, methodName: string, ...vals: [unknown, unknown]): void;
16
+ hostUpdate(): Promise<void>;
20
17
  }
@@ -1,33 +1,62 @@
1
- export const observedController = Symbol('observed properties controller');
2
- /** This controller holds a cache of observed property values which were set before the element updated */
1
+ var _PropertyObserverController_instances, _PropertyObserverController_neverRan, _PropertyObserverController_init;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { notEqual } from 'lit';
4
+ const UNINITIALIZED = Symbol('uninitialized');
3
5
  export class PropertyObserverController {
4
- delete(key) {
5
- this.values.delete(key);
6
- }
7
- constructor(host) {
6
+ constructor(host, options) {
7
+ _PropertyObserverController_instances.add(this);
8
8
  this.host = host;
9
- this.values = new Map();
10
- if (PropertyObserverController.hosts.get(host)) {
11
- return PropertyObserverController.hosts.get(host);
12
- }
13
- host.addController(this);
14
- host[observedController] = this;
9
+ this.options = options;
10
+ this.oldVal = UNINITIALIZED;
11
+ _PropertyObserverController_neverRan.set(this, true);
12
+ }
13
+ hostConnected() {
14
+ __classPrivateFieldGet(this, _PropertyObserverController_instances, "m", _PropertyObserverController_init).call(this);
15
15
  }
16
16
  /** Set any cached valued accumulated between constructor and connectedCallback */
17
- hostUpdate() {
18
- for (const [key, [methodName, [oldVal, newVal]]] of this.values) {
19
- // @ts-expect-error: be cool, typescript
20
- this.host[methodName]?.(oldVal, newVal);
21
- this.delete(key);
17
+ async hostUpdate() {
18
+ __classPrivateFieldGet(this, _PropertyObserverController_instances, "m", _PropertyObserverController_init).call(this);
19
+ const { oldVal, options: { waitFor, propertyName, callback } } = this;
20
+ if (!callback) {
21
+ throw new Error(`no callback for ${propertyName}`);
22
+ }
23
+ const newVal = this.host[propertyName];
24
+ this.oldVal = newVal;
25
+ if (newVal !== oldVal) {
26
+ switch (waitFor) {
27
+ case 'connected':
28
+ if (!this.host.isConnected) {
29
+ const origConnected = this.host.connectedCallback;
30
+ await new Promise(resolve => {
31
+ this.host.connectedCallback = function () {
32
+ resolve(origConnected?.call(this));
33
+ };
34
+ });
35
+ }
36
+ break;
37
+ case 'firstUpdated':
38
+ if (!this.host.hasUpdated) {
39
+ await this.host.updateComplete;
40
+ }
41
+ break;
42
+ case 'updated':
43
+ await this.host.updateComplete;
44
+ break;
45
+ }
46
+ }
47
+ const Class = this.host.constructor;
48
+ const hasChanged = Class
49
+ .getPropertyOptions(this.options.propertyName)
50
+ .hasChanged ?? notEqual;
51
+ if (__classPrivateFieldGet(this, _PropertyObserverController_neverRan, "f") || hasChanged(oldVal, newVal)) {
52
+ callback.call(this.host, oldVal, newVal);
53
+ __classPrivateFieldSet(this, _PropertyObserverController_neverRan, false, "f");
22
54
  }
23
- }
24
- /** Once the element has updated, we no longer need this controller, so we remove it */
25
- hostUpdated() {
26
- this.host.removeController(this);
27
- }
28
- cache(key, methodName, ...vals) {
29
- this.values.set(key, [methodName, vals]);
30
55
  }
31
56
  }
32
- PropertyObserverController.hosts = new WeakMap();
57
+ _PropertyObserverController_neverRan = new WeakMap(), _PropertyObserverController_instances = new WeakSet(), _PropertyObserverController_init = function _PropertyObserverController_init() {
58
+ if (this.oldVal === UNINITIALIZED) {
59
+ this.oldVal = this.host[this.options.propertyName];
60
+ }
61
+ };
33
62
  //# sourceMappingURL=property-observer-controller.js.map