@penn-libraries/web 1.1.0-dev.4 → 1.1.0-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/pennlibs-autocomplete.pennlibs-footer.pennlibs-header.entry.cjs.js.map +1 -1
- package/dist/cjs/pennlibs-autocomplete_3.cjs.entry.js +15 -4
- package/dist/cjs/pennlibs-autocomplete_3.cjs.entry.js.map +1 -1
- package/dist/collection/components/pennlibs-autocomplete/pennlibs-autocomplete.css +2 -1
- package/dist/collection/components/pennlibs-autocomplete/pennlibs-autocomplete.js +16 -5
- package/dist/collection/components/pennlibs-autocomplete/pennlibs-autocomplete.js.map +1 -1
- package/dist/components/pennlibs-autocomplete.js +15 -4
- package/dist/components/pennlibs-autocomplete.js.map +1 -1
- package/dist/docs.json +3 -3
- package/dist/esm/pennlibs-autocomplete.pennlibs-footer.pennlibs-header.entry.js.map +1 -1
- package/dist/esm/pennlibs-autocomplete_3.entry.js +15 -4
- package/dist/esm/pennlibs-autocomplete_3.entry.js.map +1 -1
- package/dist/types/components/pennlibs-autocomplete/pennlibs-autocomplete.d.ts +2 -6
- package/dist/types/components.d.ts +0 -9
- package/dist/web/{p-40119068.entry.js → p-909144f6.entry.js} +16 -5
- package/dist/web/{p-40119068.entry.js.map → p-909144f6.entry.js.map} +1 -1
- package/dist/web/pennlibs-autocomplete.pennlibs-footer.pennlibs-header.entry.esm.js.map +1 -1
- package/dist/web/web.esm.js +1 -1
- package/hydrate/index.js +15 -4
- package/hydrate/index.mjs +15 -4
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index-C0A2bnrZ.js');
|
|
4
4
|
|
|
5
|
-
const pennlibsAutocompleteCss = ":host {\n display: block;\n width: 100%;\n border-radius: 1.25rem;\n padding: 0;\n border-top: 0;\n position: relative;\n}\n\n[role=listbox] {\n position: absolute;\n margin-top: var(--pl-space-xs);\n background: var(--pl-color-bg-default);\n border-radius: 1.25rem;\n box-shadow: rgba(140, 149, 159, 0.3) 0px 8px 24px 0px;\n width: 100%;\n overflow: hidden;\n z-index: 1;\n\n display: flex;\n flex-direction: column;\n}\n\np {\n margin: 0;\n font-size: var(--pl-font-size-s);\n color: var(--pl-color-fg-subtle);\n padding: var(--pl-space-xs) calc(var(--pl-space-m) + var(--pl-space-2xs));\n font-size: var(--pl-font-size-s);\n order: 2;\n font-weight: 500;\n background: var(--pl-color-bg-subtle);\n border-radius: 0 0 1.25rem 1.25rem;\n\n display: flex;\n gap: var(--pl-space-s) var(--pl-space-l);\n flex-wrap: wrap;\n}\n\nol {\n list-style: none;\n margin: 0;\n padding: var(--pl-space-xs) 0;\n order: 1;\n}\n\n[role=option] {\n color: var(--pl-color-fg-default);\n padding: var(--pl-space-s) calc(var(--pl-space-m) + var(--pl-space-2xs));\n text-decoration: none;\n font-weight: 700; \n\n &:hover {\n cursor: pointer;\n }\n\n &:hover,\n &:focus {\n text-decoration-thickness: 2px;\n text-underline-offset: 2px;\n text-decoration: underline;\n }\n}\n\n[aria-selected=true] {\n text-decoration-thickness: 2px;\n text-underline-offset: 2px;\n text-decoration: underline;\n}\n\nmark {\n background: none;\n font-weight: 400;\n}\n\n.suggestion--border {\n border-bottom: solid 1px rgb(from var(--pl-color-fg-default) r g b / 0.2);\n padding-bottom: calc(var(--pl-space-2xs) + var(--pl-space-s));\n margin-bottom: var(--pl-space-2xs);\n}";
|
|
5
|
+
const pennlibsAutocompleteCss = ":host {\n display: block;\n width: 100%;\n border-radius: 1.25rem;\n padding: 0;\n border-top: 0;\n position: relative;\n}\n\n[role=listbox] {\n position: absolute;\n margin-top: var(--pl-space-xs);\n background: var(--pl-color-bg-default);\n border-radius: 1.25rem;\n box-shadow: rgba(140, 149, 159, 0.3) 0px 8px 24px 0px;\n width: 100%;\n overflow: hidden;\n z-index: 1;\n\n display: flex;\n flex-direction: column;\n}\n\np {\n margin: 0;\n font-size: var(--pl-font-size-s);\n color: var(--pl-color-fg-subtle);\n padding: var(--pl-space-xs) calc(var(--pl-space-m) + var(--pl-space-2xs));\n font-size: var(--pl-font-size-s);\n order: 2;\n font-weight: 500;\n background: var(--pl-color-bg-subtle);\n border-radius: 0 0 1.25rem 1.25rem;\n\n display: flex;\n gap: var(--pl-space-s) var(--pl-space-l);\n flex-wrap: wrap;\n}\n\nol {\n list-style: none;\n margin: 0;\n padding: var(--pl-space-xs) 0;\n order: 1;\n}\n\n[role=option] {\n color: var(--pl-color-fg-default);\n padding: var(--pl-space-s) calc(var(--pl-space-m) + var(--pl-space-2xs));\n text-decoration: none;\n font-weight: 700; \n\n &:hover {\n cursor: pointer;\n }\n\n &:hover,\n &:focus {\n text-decoration-thickness: 2px;\n text-underline-offset: 2px;\n text-decoration: underline;\n }\n}\n\n[aria-selected=true] {\n text-decoration-thickness: 2px;\n text-underline-offset: 2px;\n text-decoration: underline;\n}\n\nmark,\nb {\n background: none;\n font-weight: 400;\n}\n\n.suggestion--border {\n border-bottom: solid 1px rgb(from var(--pl-color-fg-default) r g b / 0.2);\n padding-bottom: calc(var(--pl-space-2xs) + var(--pl-space-s));\n margin-bottom: var(--pl-space-2xs);\n}";
|
|
6
6
|
|
|
7
7
|
const Autocomplete = class {
|
|
8
8
|
constructor(hostRef) {
|
|
@@ -22,10 +22,23 @@ const Autocomplete = class {
|
|
|
22
22
|
}
|
|
23
23
|
componentDidLoad() {
|
|
24
24
|
this.setupInput();
|
|
25
|
+
this.setupMutationObserver();
|
|
25
26
|
}
|
|
26
27
|
disconnectedCallback() {
|
|
27
28
|
if (this.blurTimeout)
|
|
28
29
|
clearTimeout(this.blurTimeout);
|
|
30
|
+
if (this.mutationObserver)
|
|
31
|
+
this.mutationObserver.disconnect();
|
|
32
|
+
}
|
|
33
|
+
setupMutationObserver() {
|
|
34
|
+
this.mutationObserver = new MutationObserver(() => {
|
|
35
|
+
this.options = this.parseOptionsFromDOM();
|
|
36
|
+
});
|
|
37
|
+
this.mutationObserver.observe(this.el, {
|
|
38
|
+
childList: true,
|
|
39
|
+
subtree: true,
|
|
40
|
+
characterData: true
|
|
41
|
+
});
|
|
29
42
|
}
|
|
30
43
|
parseOptionsFromDOM() {
|
|
31
44
|
const listbox = this.findListbox();
|
|
@@ -86,7 +99,6 @@ const Autocomplete = class {
|
|
|
86
99
|
handleInputEvent(event) {
|
|
87
100
|
const input = event.target;
|
|
88
101
|
if (this.isTrackedInput(input)) {
|
|
89
|
-
// Reset active option when user manually changes input
|
|
90
102
|
this.currentIndex = -1;
|
|
91
103
|
this.openSuggestions();
|
|
92
104
|
}
|
|
@@ -209,7 +221,6 @@ const Autocomplete = class {
|
|
|
209
221
|
const active = document.activeElement;
|
|
210
222
|
return !((_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.contains(active)) && active !== this.getInput();
|
|
211
223
|
}
|
|
212
|
-
// Input State Sync
|
|
213
224
|
syncInputState() {
|
|
214
225
|
const input = this.getInput();
|
|
215
226
|
if (!input)
|
|
@@ -239,7 +250,7 @@ const Autocomplete = class {
|
|
|
239
250
|
return this.showSuggestions && this.options.length > 0 && this.isInputFocused();
|
|
240
251
|
}
|
|
241
252
|
render() {
|
|
242
|
-
return (index.h("div", { key: '
|
|
253
|
+
return (index.h("div", { key: '71422b55533372a9d8697e648e49f87fe223f4e0' }, index.h("slot", { key: '951511fd2090b9816c2e6c1a5a40169ea08e72fd', name: "start" }), this.shouldShowListbox() && (index.h("ol", { key: 'e3f6f14686bc99b6e25d34d8e053f01174f23438', role: "listbox", id: "listbox" }, this.options.map((option, index$1) => (index.h("li", { role: "option", id: option.id, "aria-selected": this.currentIndex === index$1 ? 'true' : 'false', tabindex: "-1", onClick: () => this.handleOptionClick(index$1), innerHTML: option.html })))))));
|
|
243
254
|
}
|
|
244
255
|
get el() { return index.getElement(this); }
|
|
245
256
|
};
|