@penn-libraries/web 1.1.0-dev.1 → 1.1.0-dev.2

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 (25) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/pennlibs-allow-tracking.pennlibs-autocomplete.pennlibs-footer.pennlibs-header.entry.cjs.js.map +1 -1
  3. package/dist/cjs/pennlibs-allow-tracking_4.cjs.entry.js +14 -10
  4. package/dist/cjs/pennlibs-allow-tracking_4.cjs.entry.js.map +1 -1
  5. package/dist/cjs/web.cjs.js +1 -1
  6. package/dist/collection/components/pennlibs-autocomplete/pennlibs-autocomplete.js +37 -10
  7. package/dist/collection/components/pennlibs-autocomplete/pennlibs-autocomplete.js.map +1 -1
  8. package/dist/components/pennlibs-autocomplete.js +15 -10
  9. package/dist/components/pennlibs-autocomplete.js.map +1 -1
  10. package/dist/docs.json +26 -2
  11. package/dist/esm/loader.js +1 -1
  12. package/dist/esm/pennlibs-allow-tracking.pennlibs-autocomplete.pennlibs-footer.pennlibs-header.entry.js.map +1 -1
  13. package/dist/esm/pennlibs-allow-tracking_4.entry.js +14 -10
  14. package/dist/esm/pennlibs-allow-tracking_4.entry.js.map +1 -1
  15. package/dist/esm/web.js +1 -1
  16. package/dist/types/components/pennlibs-autocomplete/pennlibs-autocomplete.d.ts +4 -0
  17. package/dist/types/components.d.ts +8 -0
  18. package/dist/web/{p-36195ae1.entry.js → p-270fd846.entry.js} +15 -11
  19. package/dist/web/p-270fd846.entry.js.map +1 -0
  20. package/dist/web/pennlibs-allow-tracking.pennlibs-autocomplete.pennlibs-footer.pennlibs-header.entry.esm.js.map +1 -1
  21. package/dist/web/web.esm.js +1 -1
  22. package/hydrate/index.js +15 -10
  23. package/hydrate/index.mjs +15 -10
  24. package/package.json +1 -1
  25. package/dist/web/p-36195ae1.entry.js.map +0 -1
@@ -92,32 +92,36 @@ const Autocomplete = class {
92
92
  return {
93
93
  id: element.id || `option-${index}`,
94
94
  html: element.innerHTML,
95
- value: element.getAttribute('data-value') || ((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || ''
95
+ value: element.getAttribute('data-pl-value') || ((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || ''
96
96
  };
97
97
  }
98
98
  getInput() {
99
- var _a, _b;
99
+ var _a;
100
+ if (!this.for)
101
+ return null;
100
102
  const slot = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot[name="start"]');
101
- return ((_b = slot === null || slot === void 0 ? void 0 : slot.assignedElements()[0]) === null || _b === void 0 ? void 0 : _b.querySelector('input')) || null;
103
+ const input = slot.assignedElements()[0].querySelector(`input#${this.for}`);
104
+ return input || null;
102
105
  }
103
106
  isInputFocused() {
104
107
  return this.getInput() === document.activeElement;
105
108
  }
106
109
  isTrackedInput(input) {
107
- return (input === null || input === void 0 ? void 0 : input.getAttribute('data-pl-autocomplete-input')) === 'true' &&
110
+ return (input === null || input === void 0 ? void 0 : input.getAttribute('data-pl-autocomplete-connected')) === 'true' &&
108
111
  this.el.contains(input);
109
112
  }
110
113
  setupInput() {
114
+ if (!this.for) {
115
+ console.warn('<pennlibs-autocomplete> Missing "for" attribute. Please add for="input-id" to specify which input to attach to.');
116
+ return;
117
+ }
111
118
  const input = this.getInput();
112
119
  if (!input) {
113
- console.warn('<pennlibs-autocomplete> No input element found. Ensure your input has the data-pl-autocomplete-input attribute.');
120
+ console.warn(`<pennlibs-autocomplete> No input element found with id="${this.for}". Ensure an input with this id exists.`);
114
121
  return;
115
122
  }
116
- if (!input.hasAttribute('data-pl-autocomplete-input')) {
117
- console.warn('<pennlibs-autocomplete> Input element is missing the data-pl-autocomplete-input attribute. Please add it to your input element.');
118
- }
119
123
  this.setComboboxAttributes(input);
120
- input.setAttribute('data-pl-autocomplete-input', 'true');
124
+ input.setAttribute('data-pl-autocomplete-connected', 'true');
121
125
  }
122
126
  setComboboxAttributes(input) {
123
127
  input.setAttribute('role', 'combobox');
@@ -281,7 +285,7 @@ const Autocomplete = class {
281
285
  return this.showSuggestions && this.options.length > 0 && this.isInputFocused();
282
286
  }
283
287
  render() {
284
- return (h("div", { key: '64bcd2b815b654072ea9b515307d21542168496e' }, h("slot", { key: '56eb649dfbbb6677533b968bb6530651ceb645c7', name: "start" }), this.shouldShowListbox() && (h("ol", { key: '1f7de6b579ac890907c43f2e96b41078d6ad1278', role: "listbox", id: "listbox" }, this.options.map((option, index) => (h("li", { role: "option", id: option.id, "aria-selected": this.currentIndex === index ? 'true' : 'false', tabindex: "-1", onClick: () => this.handleOptionClick(index), innerHTML: option.html })))))));
288
+ return (h("div", { key: '2091f8acacac10714c4d607e294248f3bd7e5fd7' }, h("slot", { key: '628a216ce90ee693a354a74f91bcce2fe61b74a5', name: "start" }), this.shouldShowListbox() && (h("ol", { key: '916eba0f4b2148616fac4cc96cac4c7506a9bd0e', role: "listbox", id: "listbox" }, this.options.map((option, index) => (h("li", { role: "option", id: option.id, "aria-selected": this.currentIndex === index ? 'true' : 'false', tabindex: "-1", onClick: () => this.handleOptionClick(index), innerHTML: option.html })))))));
285
289
  }
286
290
  get el() { return getElement(this); }
287
291
  };