@penn-libraries/web 1.2.0-dev.1 → 1.2.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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pennlibs-autocomplete.cjs.entry.js +281 -0
- package/dist/cjs/pennlibs-autocomplete.entry.cjs.js.map +1 -0
- package/dist/cjs/pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.cjs.js.map +1 -0
- package/dist/cjs/{pennlibs-autocomplete_4.cjs.entry.js → pennlibs-feedback_3.cjs.entry.js} +33 -301
- package/dist/cjs/web.cjs.js +1 -1
- package/dist/collection/components/pennlibs-feedback/pennlibs-feedback.css +22 -1
- package/dist/collection/components/pennlibs-feedback/pennlibs-feedback.js +25 -21
- package/dist/collection/components/pennlibs-feedback/pennlibs-feedback.js.map +1 -1
- package/dist/collection/components/pennlibs-footer/pennlibs-footer.css +12 -3
- package/dist/collection/components/pennlibs-footer/pennlibs-footer.js +33 -3
- package/dist/collection/components/pennlibs-footer/pennlibs-footer.js.map +1 -1
- package/dist/components/pennlibs-feedback.js +26 -22
- package/dist/components/pennlibs-feedback.js.map +1 -1
- package/dist/components/pennlibs-footer.js +9 -4
- package/dist/components/pennlibs-footer.js.map +1 -1
- package/dist/docs.json +32 -2
- package/dist/esm/{index-CNQ9-Wwh.js → index-mkVX9lU0.js} +3 -3
- package/dist/esm/{index-CNQ9-Wwh.js.map → index-mkVX9lU0.js.map} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/pennlibs-autocomplete.entry.js +279 -0
- package/dist/esm/pennlibs-autocomplete.entry.js.map +1 -0
- package/dist/esm/pennlibs-banner.entry.js +1 -1
- package/dist/esm/pennlibs-chat.entry.js +1 -1
- package/dist/esm/pennlibs-fallback-img.entry.js +1 -1
- package/dist/esm/pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.js.map +1 -0
- package/dist/esm/{pennlibs-autocomplete_4.entry.js → pennlibs-feedback_3.entry.js} +35 -302
- package/dist/esm/pennlibs-hero.entry.js +1 -1
- package/dist/esm/pennlibs-iiif-img.entry.js +1 -1
- package/dist/esm/web.js +3 -3
- package/dist/types/components/pennlibs-feedback/pennlibs-feedback.d.ts +1 -1
- package/dist/types/components/pennlibs-footer/pennlibs-footer.d.ts +4 -0
- package/dist/types/components.d.ts +10 -0
- package/dist/web/index.esm.js +1 -1
- package/dist/web/{p-a34e1e3e.entry.js → p-0c1113f4.entry.js} +1 -1
- package/dist/web/{p-b9538aed.entry.js → p-10931f0a.entry.js} +35 -302
- package/dist/web/{p-b6e686d1.entry.js → p-154851d1.entry.js} +1 -1
- package/dist/web/{p-c96a3643.entry.js → p-190f0293.entry.js} +1 -1
- package/dist/web/{p-eb633f4d.entry.js → p-4fb3e5a4.entry.js} +1 -1
- package/dist/web/p-7c6382d0.entry.js +279 -0
- package/dist/web/{p-662e4125.entry.js → p-e426fb61.entry.js} +1 -1
- package/dist/web/{p-CNQ9-Wwh.js → p-mkVX9lU0.js} +3 -3
- package/dist/web/{p-CNQ9-Wwh.js.map → p-mkVX9lU0.js.map} +1 -1
- package/dist/web/pennlibs-autocomplete.entry.esm.js.map +1 -0
- package/dist/web/pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.esm.js.map +1 -0
- package/dist/web/web.esm.js +3 -3
- package/hydrate/index.js +35 -26
- package/hydrate/index.mjs +35 -26
- package/package.json +1 -1
- package/dist/cjs/pennlibs-autocomplete.pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.cjs.js.map +0 -1
- package/dist/esm/pennlibs-autocomplete.pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.js.map +0 -1
- package/dist/web/pennlibs-autocomplete.pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.esm.js.map +0 -1
|
@@ -2,288 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index-Ag6DtE87.js');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const pennlibsFeedbackCss = ":host{display:block;background:#eeeff4;font-family:var(--pl-font-family);font-size:var(--pl-font-size);color:var(--pl-color-fg-default);line-height:1.4;box-sizing:border-box;padding:0.75em 0}@media print{:host{display:none}}*,*::before,*::after{box-sizing:border-box}.viewport-margins{max-width:var(--pl-viewport-margins-max-width);margin:0 auto;padding:0 var(--pl-viewport-margins-gutter, 1em)}.feedback__content{display:flex;justify-content:space-between;gap:var(--pl-space-s);flex-wrap:wrap}.feedback__inline-question{display:flex;flex-wrap:wrap;gap:0.5em;align-items:center}h2{display:inline-block;margin:0;font-family:var(--pl-font-sans-serif);font-size:1em;font-weight:400}p{margin:0;padding:calc(0.5em + 1px) 0}strong{font-weight:600}a{color:var(--pl-color-fg-accent);text-decoration:underline;text-underline-offset:var(--pl-link-text-underline-offset);text-decoration-thickness:var(--pl-link-hover-text-decoration-thickness)}button{all:unset;display:flex;align-items:center;gap:0.5em;padding:0.25em 1.25em;font-family:var(--pl-font-family);font-weight:500;line-height:1.4;color:var(--pl-color-fg-default);background:var(--pl-color-bg-default);border:solid 1px var(--pl-color-fg-subtle);border-radius:1em;box-sizing:border-box}button:hover{cursor:pointer}button:hover span{text-decoration:underline}button.selected{background:var(--pl-color-bg-accent-emphasis);color:var(--pl-color-fg-on-emphasis);border-color:var(--pl-color-bg-accent-emphasis)}.feedback__inline-question+.feedback__share-feedback,p{animation:none}.feedback__content>p{animation:fadeIn 300ms ease-in}@keyframes fadeIn{from{opacity:0}to{opacity:1}}*:focus{outline:0;box-shadow:0 0 0 2px var(--pl-color-bg-attention),\n 0 0 0 3px var(--pl-color-bg-emphasis)}p:focus{outline:none;box-shadow:0 0 0 2px var(--pl-color-bg-attention), 0 0 0 3px var(--pl-color-bg-emphasis)}@media (max-width: 26em){h2{display:block;width:100%;text-align:center}}.help-us{display:flex;flex-direction:column;gap:0.5em}.visually-hidden{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}.visually-hidden:focus,.visually-hidden:active{clip:auto;clip-path:none;height:auto;overflow:visible;position:static;white-space:normal;width:auto}";
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
constructor(hostRef) {
|
|
9
|
-
index.registerInstance(this, hostRef);
|
|
10
|
-
this.activated = index.createEvent(this, "pl:activated");
|
|
11
|
-
this.showSuggestions = false;
|
|
12
|
-
this.currentIndex = -1;
|
|
13
|
-
this.originalValue = '';
|
|
14
|
-
this.options = [];
|
|
15
|
-
this.keyHandlerMap = {
|
|
16
|
-
'Escape': () => this.handleEscape(),
|
|
17
|
-
'ArrowDown': () => this.handleArrowDown(),
|
|
18
|
-
'ArrowUp': () => this.handleArrowUp(),
|
|
19
|
-
'Enter': () => this.handleEnter()
|
|
20
|
-
};
|
|
21
|
-
this.handleOptionClick = (index) => {
|
|
22
|
-
this.currentIndex = index;
|
|
23
|
-
this.selectCurrent();
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
componentWillLoad() {
|
|
27
|
-
this.options = this.parseOptionsFromDOM();
|
|
28
|
-
}
|
|
29
|
-
componentDidLoad() {
|
|
30
|
-
this.setupInput();
|
|
31
|
-
this.setupMutationObserver();
|
|
32
|
-
}
|
|
33
|
-
disconnectedCallback() {
|
|
34
|
-
if (this.blurTimeout)
|
|
35
|
-
clearTimeout(this.blurTimeout);
|
|
36
|
-
if (this.mutationObserver)
|
|
37
|
-
this.mutationObserver.disconnect();
|
|
38
|
-
}
|
|
39
|
-
setupMutationObserver() {
|
|
40
|
-
this.mutationObserver = new MutationObserver(() => {
|
|
41
|
-
this.options = this.parseOptionsFromDOM();
|
|
42
|
-
});
|
|
43
|
-
this.mutationObserver.observe(this.el, {
|
|
44
|
-
childList: true,
|
|
45
|
-
subtree: true,
|
|
46
|
-
characterData: true
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
parseOptionsFromDOM() {
|
|
50
|
-
const listbox = this.findListbox();
|
|
51
|
-
if (!listbox)
|
|
52
|
-
return [];
|
|
53
|
-
const elements = Array.from(listbox.querySelectorAll('[role="option"]'));
|
|
54
|
-
return elements.map((el, i) => this.createOption(el, i));
|
|
55
|
-
}
|
|
56
|
-
findListbox() {
|
|
57
|
-
return Array.from(this.el.children).find(child => child.matches('ol[role="listbox"]'));
|
|
58
|
-
}
|
|
59
|
-
createOption(element, index) {
|
|
60
|
-
var _a;
|
|
61
|
-
return {
|
|
62
|
-
id: element.id || `option-${index}`,
|
|
63
|
-
html: element.innerHTML,
|
|
64
|
-
value: element.getAttribute('data-pl-value') || ((_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || ''
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
getInput() {
|
|
68
|
-
var _a;
|
|
69
|
-
if (!this.for)
|
|
70
|
-
return null;
|
|
71
|
-
const slot = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot[name="start"]');
|
|
72
|
-
if (!slot)
|
|
73
|
-
return null;
|
|
74
|
-
const assignedElements = slot.assignedElements();
|
|
75
|
-
if (assignedElements.length === 0)
|
|
76
|
-
return null;
|
|
77
|
-
const input = assignedElements[0].querySelector(`input#${this.for}`);
|
|
78
|
-
return input || null;
|
|
79
|
-
}
|
|
80
|
-
isInputFocused() {
|
|
81
|
-
return this.getInput() === document.activeElement;
|
|
82
|
-
}
|
|
83
|
-
isTrackedInput(input) {
|
|
84
|
-
return (input === null || input === void 0 ? void 0 : input.getAttribute('data-pl-autocomplete-connected')) === 'true' &&
|
|
85
|
-
this.el.contains(input);
|
|
86
|
-
}
|
|
87
|
-
setupInput() {
|
|
88
|
-
if (!this.for) {
|
|
89
|
-
console.warn('<pennlibs-autocomplete> Missing "for" attribute. Please add for="input-id" to specify which input to attach to.');
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const input = this.getInput();
|
|
93
|
-
if (!input) {
|
|
94
|
-
console.warn(`<pennlibs-autocomplete> No input element found with id="${this.for}". Ensure an input with this id exists.`);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
this.setComboboxAttributes(input);
|
|
98
|
-
input.setAttribute('data-pl-autocomplete-connected', 'true');
|
|
99
|
-
}
|
|
100
|
-
setComboboxAttributes(input) {
|
|
101
|
-
input.setAttribute('role', 'combobox');
|
|
102
|
-
input.setAttribute('aria-autocomplete', 'list');
|
|
103
|
-
input.setAttribute('aria-expanded', 'false');
|
|
104
|
-
input.setAttribute('aria-controls', 'listbox');
|
|
105
|
-
}
|
|
106
|
-
handleSlotChange() {
|
|
107
|
-
this.options = this.parseOptionsFromDOM();
|
|
108
|
-
this.setupInput();
|
|
109
|
-
}
|
|
110
|
-
handleInputEvent(event) {
|
|
111
|
-
const input = event.target;
|
|
112
|
-
if (this.isTrackedInput(input)) {
|
|
113
|
-
this.currentIndex = -1;
|
|
114
|
-
this.openSuggestions();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
handleFocusEvent(event) {
|
|
118
|
-
const input = event.target;
|
|
119
|
-
if (this.isTrackedInput(input))
|
|
120
|
-
this.showSuggestionsPanel();
|
|
121
|
-
}
|
|
122
|
-
handleBlurEvent(event) {
|
|
123
|
-
const input = event.target;
|
|
124
|
-
if (this.isTrackedInput(input))
|
|
125
|
-
this.deferCloseSuggestions();
|
|
126
|
-
}
|
|
127
|
-
handleFocusOut(event) {
|
|
128
|
-
if (this.isFocusLeavingComponent(event))
|
|
129
|
-
this.closeSuggestions();
|
|
130
|
-
}
|
|
131
|
-
handleKeyDown(event) {
|
|
132
|
-
if (!this.isInputFocused())
|
|
133
|
-
return;
|
|
134
|
-
if (event.metaKey || event.ctrlKey)
|
|
135
|
-
return; // Ignore keyboard shortcuts
|
|
136
|
-
const handler = this.keyHandlerMap[event.key];
|
|
137
|
-
if (handler) {
|
|
138
|
-
// Don't prevent default for Enter - allow form submission
|
|
139
|
-
if (event.key !== 'Enter') {
|
|
140
|
-
event.preventDefault();
|
|
141
|
-
}
|
|
142
|
-
handler();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
handleEscape() {
|
|
146
|
-
this.reset();
|
|
147
|
-
this.syncAll();
|
|
148
|
-
}
|
|
149
|
-
handleArrowDown() {
|
|
150
|
-
if (!this.showSuggestions)
|
|
151
|
-
return;
|
|
152
|
-
this.moveNext();
|
|
153
|
-
this.syncAll();
|
|
154
|
-
}
|
|
155
|
-
handleArrowUp() {
|
|
156
|
-
if (!this.showSuggestions)
|
|
157
|
-
return;
|
|
158
|
-
this.movePrevious();
|
|
159
|
-
this.syncAll();
|
|
160
|
-
}
|
|
161
|
-
handleEnter() {
|
|
162
|
-
if (this.canSelect())
|
|
163
|
-
this.selectCurrent();
|
|
164
|
-
}
|
|
165
|
-
// Navigation
|
|
166
|
-
moveNext() {
|
|
167
|
-
const lastIndex = this.options.length - 1;
|
|
168
|
-
this.currentIndex = this.currentIndex < lastIndex ? this.currentIndex + 1 : -1;
|
|
169
|
-
}
|
|
170
|
-
movePrevious() {
|
|
171
|
-
const lastIndex = this.options.length - 1;
|
|
172
|
-
this.currentIndex = this.currentIndex > -1 ? this.currentIndex - 1 : lastIndex;
|
|
173
|
-
}
|
|
174
|
-
canSelect() {
|
|
175
|
-
return this.showSuggestions && this.currentIndex >= 0;
|
|
176
|
-
}
|
|
177
|
-
selectCurrent() {
|
|
178
|
-
if (this.currentIndex < 0)
|
|
179
|
-
return;
|
|
180
|
-
const selectedOption = this.options[this.currentIndex];
|
|
181
|
-
this.applySelection(selectedOption);
|
|
182
|
-
this.emitActivation(selectedOption);
|
|
183
|
-
this.closeSuggestions();
|
|
184
|
-
}
|
|
185
|
-
applySelection(option) {
|
|
186
|
-
const input = this.getInput();
|
|
187
|
-
if (!input)
|
|
188
|
-
return;
|
|
189
|
-
input.value = option.value;
|
|
190
|
-
this.originalValue = option.value;
|
|
191
|
-
}
|
|
192
|
-
emitActivation(option) {
|
|
193
|
-
this.activated.emit({
|
|
194
|
-
index: this.currentIndex,
|
|
195
|
-
value: option.value
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
openSuggestions() {
|
|
199
|
-
if (!this.isInputFocused())
|
|
200
|
-
return;
|
|
201
|
-
const input = this.getInput();
|
|
202
|
-
if (input)
|
|
203
|
-
this.originalValue = input.value;
|
|
204
|
-
this.showSuggestionsPanel();
|
|
205
|
-
}
|
|
206
|
-
showSuggestionsPanel() {
|
|
207
|
-
this.showSuggestions = true;
|
|
208
|
-
this.syncAriaAttributes();
|
|
209
|
-
}
|
|
210
|
-
closeSuggestions() {
|
|
211
|
-
this.reset();
|
|
212
|
-
this.syncAll();
|
|
213
|
-
}
|
|
214
|
-
deferCloseSuggestions() {
|
|
215
|
-
if (this.blurTimeout)
|
|
216
|
-
clearTimeout(this.blurTimeout);
|
|
217
|
-
this.blurTimeout = setTimeout(() => {
|
|
218
|
-
if (this.isFocusOutsideComponent())
|
|
219
|
-
this.closeSuggestions();
|
|
220
|
-
}, 150);
|
|
221
|
-
}
|
|
222
|
-
reset() {
|
|
223
|
-
this.showSuggestions = false;
|
|
224
|
-
this.currentIndex = -1;
|
|
225
|
-
}
|
|
226
|
-
isFocusLeavingComponent(event) {
|
|
227
|
-
var _a;
|
|
228
|
-
const target = event.relatedTarget;
|
|
229
|
-
return !target ||
|
|
230
|
-
(!this.el.contains(target) && !((_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.contains(target)));
|
|
231
|
-
}
|
|
232
|
-
isFocusOutsideComponent() {
|
|
233
|
-
var _a;
|
|
234
|
-
const active = document.activeElement;
|
|
235
|
-
return !((_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.contains(active)) && active !== this.getInput();
|
|
236
|
-
}
|
|
237
|
-
syncAriaAttributes() {
|
|
238
|
-
const input = this.getInput();
|
|
239
|
-
if (!input)
|
|
240
|
-
return;
|
|
241
|
-
this.updateAriaExpanded(input);
|
|
242
|
-
this.updateAriaActiveDescendant(input);
|
|
243
|
-
}
|
|
244
|
-
syncInputValueToSelection() {
|
|
245
|
-
const input = this.getInput();
|
|
246
|
-
if (!input)
|
|
247
|
-
return;
|
|
248
|
-
input.value = this.currentIndex >= 0 && this.currentIndex < this.options.length
|
|
249
|
-
? this.options[this.currentIndex].value
|
|
250
|
-
: this.originalValue;
|
|
251
|
-
}
|
|
252
|
-
syncAll() {
|
|
253
|
-
this.syncAriaAttributes();
|
|
254
|
-
this.syncInputValueToSelection();
|
|
255
|
-
}
|
|
256
|
-
updateAriaExpanded(input) {
|
|
257
|
-
input.setAttribute('aria-expanded', this.showSuggestions.toString());
|
|
258
|
-
}
|
|
259
|
-
updateAriaActiveDescendant(input) {
|
|
260
|
-
const hasSelection = this.showSuggestions &&
|
|
261
|
-
this.currentIndex >= 0 &&
|
|
262
|
-
this.currentIndex < this.options.length;
|
|
263
|
-
if (hasSelection) {
|
|
264
|
-
input.setAttribute('aria-activedescendant', this.options[this.currentIndex].id);
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
input.removeAttribute('aria-activedescendant');
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
shouldShowListbox() {
|
|
271
|
-
return this.showSuggestions && this.options.length > 0 && this.isInputFocused();
|
|
272
|
-
}
|
|
273
|
-
render() {
|
|
274
|
-
return (index.h("div", { key: 'ee4ead1b5bec44a561901a29d3d5e119da0d09f8' }, index.h("slot", { key: '7d7128ab7968544ab25125d30a648136f8d8a566', name: "start" }), this.shouldShowListbox() && (index.h("ol", { key: '95d45d524847f83b646853a8d919bc88f471f150', 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 })))))));
|
|
275
|
-
}
|
|
276
|
-
get el() { return index.getElement(this); }
|
|
277
|
-
};
|
|
278
|
-
Autocomplete.style = pennlibsAutocompleteCss;
|
|
279
|
-
|
|
280
|
-
const pennlibsFeedbackCss = ":host{display:block;background:#eeeff4;font-family:var(--pl-font-family);font-size:var(--pl-font-size);color:var(--pl-color-fg-default);line-height:1.4;box-sizing:border-box;padding:0.75em 0}@media print{:host{display:none}}*,*::before,*::after{box-sizing:border-box}.viewport-margins{max-width:var(--pl-viewport-margins-max-width);margin:0 auto;padding:0 var(--pl-viewport-margins-gutter, 1em)}.feedback__content{display:flex;justify-content:space-between;gap:var(--pl-space-s);flex-wrap:wrap}.feedback__inline-question{display:flex;flex-wrap:wrap;gap:0.5em;align-items:center}h2{display:inline-block;margin:0;font-family:var(--pl-font-sans-serif);font-size:1em;font-weight:600}p{margin:0;padding:calc(0.5em + 1px) 0}strong{font-weight:600}a{color:var(--pl-color-fg-accent);text-decoration:underline;text-underline-offset:var(--pl-link-text-underline-offset);text-decoration-thickness:var(--pl-link-hover-text-decoration-thickness)}button{all:unset;display:flex;align-items:center;gap:0.5em;padding:0.25em 1.25em;font-family:var(--pl-font-family);font-weight:500;line-height:1.4;color:var(--pl-color-fg-default);background:var(--pl-color-bg-default);border:solid 1px var(--pl-color-fg-subtle);border-radius:1em;box-sizing:border-box}button:hover{cursor:pointer}button:hover span{text-decoration:underline}*:focus{outline:0;box-shadow:0 0 0 2px var(--pl-color-bg-attention),\n 0 0 0 3px var(--pl-color-bg-emphasis)}p:focus{outline:none;box-shadow:0 0 0 2px var(--pl-color-bg-attention), 0 0 0 3px var(--pl-color-bg-emphasis)}@media (max-width: 26em){h2{display:block;width:100%;text-align:center}}.help-us{display:flex;flex-direction:column;gap:0.5em}.visually-hidden{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}.visually-hidden:focus,.visually-hidden:active{clip:auto;clip-path:none;height:auto;overflow:visible;position:static;white-space:normal;width:auto}";
|
|
281
|
-
|
|
282
|
-
const FEEDBACK_STORAGE_KEY = 'pennlibs-feedback-answer';
|
|
283
|
-
const FEEDBACK_TIMESTAMP_KEY = 'pennlibs-feedback-timestamp';
|
|
7
|
+
const FEEDBACK_STORAGE_KEY = `pennlibs-feedback-${window.location.pathname}`;
|
|
284
8
|
const FEEDBACK_TTL = 5 * 60 * 1000; // 5 minutes
|
|
285
|
-
const FEEDBACK_QUESTION = '
|
|
286
|
-
const FEEDBACK_ERROR_STORAGE_KEY = 'pennlibs-feedback-error';
|
|
9
|
+
const FEEDBACK_QUESTION = 'Did you find what you need?';
|
|
287
10
|
const PennlibsFeedback = class {
|
|
288
11
|
constructor(hostRef) {
|
|
289
12
|
index.registerInstance(this, hostRef);
|
|
@@ -292,27 +15,30 @@ const PennlibsFeedback = class {
|
|
|
292
15
|
* When true, hides the yes/no question and only shows the "share your feedback" link.
|
|
293
16
|
*/
|
|
294
17
|
this.hideQuestion = false;
|
|
295
|
-
this.error = false;
|
|
296
18
|
this.answer = undefined;
|
|
19
|
+
this.selected = undefined;
|
|
297
20
|
}
|
|
298
21
|
componentWillLoad() {
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
22
|
+
const stored = sessionStorage.getItem(FEEDBACK_STORAGE_KEY);
|
|
23
|
+
if (stored) {
|
|
24
|
+
try {
|
|
25
|
+
const { answer, timestamp } = JSON.parse(stored);
|
|
26
|
+
if (Date.now() - timestamp > FEEDBACK_TTL) {
|
|
27
|
+
sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.answer = answer;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (_a) {
|
|
34
|
+
sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);
|
|
35
|
+
}
|
|
309
36
|
}
|
|
310
37
|
}
|
|
311
38
|
handleFeedback(answer) {
|
|
312
39
|
var _a;
|
|
313
|
-
this.
|
|
314
|
-
sessionStorage.setItem(FEEDBACK_STORAGE_KEY, answer);
|
|
315
|
-
sessionStorage.setItem(FEEDBACK_TIMESTAMP_KEY, String(Date.now()));
|
|
40
|
+
this.selected = answer;
|
|
41
|
+
sessionStorage.setItem(FEEDBACK_STORAGE_KEY, JSON.stringify({ answer, timestamp: Date.now() }));
|
|
316
42
|
this.feedbackEvent.emit({
|
|
317
43
|
question: FEEDBACK_QUESTION,
|
|
318
44
|
answer: answer,
|
|
@@ -320,18 +46,25 @@ const PennlibsFeedback = class {
|
|
|
320
46
|
pageHeading: ((_a = document.querySelector('h1')) === null || _a === void 0 ? void 0 : _a.textContent) || undefined,
|
|
321
47
|
pageTitle: document.title || undefined
|
|
322
48
|
});
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
this.answer = answer;
|
|
51
|
+
}, 600);
|
|
323
52
|
}
|
|
324
53
|
render() {
|
|
325
|
-
return (index.h("div", { key: '
|
|
54
|
+
return (index.h("div", { key: 'e470cb9ce96fecddda37c8a557c6670b581d8414', class: "feedback__container" }, index.h("div", { key: '0f3729d63102379f7219fd9a65c370f05c3f271c', class: "viewport-margins" }, index.h("div", { key: '3eaa8419d9b5fed5d7cf33de60ab93dd911afa34', class: "feedback__content" }, !this.hideQuestion && (this.answer === 'yes' ? (index.h("p", null, "Thank you for letting us know.")) : this.answer === 'no' ? (index.h("p", null, "We'd like to help. ", index.h("a", { href: "https://www.library.upenn.edu/contact-us" }, "Contact us"), " and let us know what you're looking for.")) : (index.h("div", { class: "feedback__inline-question" }, index.h("h2", null, "Did you find what you need?"), index.h("button", { class: { 'selected': this.selected === 'yes' }, disabled: !!this.selected, onClick: () => this.handleFeedback('yes') }, index.h("span", null, "Yes"), index.h("span", { class: "visually-hidden" }, ", I found what I needed.")), index.h("button", { class: { 'selected': this.selected === 'no' }, disabled: !!this.selected, onClick: () => this.handleFeedback('no') }, index.h("span", null, "No"), index.h("span", { class: "visually-hidden" }, ", I did not find what I needed."))))), index.h("div", { key: '50da9c1f23d14feeb6a2c408b0461a439331fcd9', class: "feedback__share-feedback" }, index.h("p", { key: '3580e25ecd7b463bb46103a6aee54a710e88c0ff' }, "To help us improve, ", index.h("a", { key: '276e226f4487ce94b9de30ae40f964e63f0d045b', href: `https://upenn.co1.qualtrics.com/jfe/form/SV_3xVrP7EKWS92zfE?reporting_from_url=${encodeURIComponent(window.location.href)}` }, "share your feedback"), "."))))));
|
|
326
55
|
}
|
|
327
56
|
};
|
|
328
57
|
PennlibsFeedback.style = pennlibsFeedbackCss;
|
|
329
58
|
|
|
330
|
-
const pennlibsFooterCss = ":host {\n font-family: var(--pl-font-family);\n font-size: var(--pl-font-size);\n --padding-bottom: 3em;\n}\n\n@media print {\n :host {\n display: none;\n }\n}\n\n*, *::before, *::after {\n box-sizing: border-box;\n}\n\n.website-footer-wrapper {\n background: var(--pl-color-penn-blue);\n padding-bottom: var(--padding-bottom);\n}\n\n.viewport-margins {\n max-width: var(--pl-viewport-margins-max-width);\n margin: 0 auto;\n padding: 0 var(--pl-viewport-margins-gutter, 1em);\n}\n\n.website-footer {\n background-size: cover;\n color: var(--pl-color-fg-subtle-on-emphasis);\n}\n\n.website-footer a {\n color: var(--pl-color-fg-subtle-on-emphasis);\n}\n\n.built-with,\n.built-with a {\n color: var(--pl-color-
|
|
59
|
+
const pennlibsFooterCss = ":host {\n font-family: var(--pl-font-family);\n font-size: var(--pl-font-size);\n --padding-bottom: 3em;\n}\n\n@media print {\n :host {\n display: none;\n }\n}\n\n*, *::before, *::after {\n box-sizing: border-box;\n}\n\n.website-footer-wrapper {\n background: var(--pl-color-penn-blue);\n padding-bottom: var(--padding-bottom);\n}\n\n.viewport-margins {\n max-width: var(--pl-viewport-margins-max-width);\n margin: 0 auto;\n padding: 0 var(--pl-viewport-margins-gutter, 1em);\n}\n\n.website-footer {\n background-size: cover;\n color: var(--pl-color-fg-subtle-on-emphasis);\n}\n\n.website-footer a {\n color: var(--pl-color-fg-subtle-on-emphasis);\n}\n\n.built-with,\n.built-with a {\n color: var(--pl-color-fg-subtle-on-emphasis);\n}\n\n.built-with a {\n font-weight: 500;\n text-underline-offset: var(--pl-link-text-underline-offset);\n\n &:hover {\n text-decoration-thickness: var(--pl-link-hover-text-decoration-thickness);\n }\n}\n\n.built-with {\n opacity: 0.875;\n margin: 0; \n padding: 1.5em 0;\n font-size: 0.875em;\n}\n\n.website-footer__content {\n padding: 4em 0;\n}\n\n.website-footer__links-container {\n gap: 4em 2em;\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(12em, 1fr));\n}\n\n.website-footer__heading {\n font-size: 0.8em;\n text-transform: uppercase;\n letter-spacing: 0.075em;\n margin-bottom: 1em;\n opacity: 0.75;\n}\n\n.website-footer__links {\n margin: 0;\n padding: 0;\n list-style: none;\n display: flex;\n flex-direction: column;\n gap: 0.75em;\n}\n\n.website-footer__links a {\n text-decoration: none;\n}\n\n.website-footer__links a:hover {\n text-decoration: underline;\n text-underline-offset: var(--pl-link-text-underline-offset);\n}\n\n.website-footer__footer {\n padding: 1em 0;\n background: rgba(1, 31, 91, 0.65);\n}\n\n.website-footer__links--footer {\n display: flex;\n flex-wrap: wrap;\n gap: 0;\n flex-direction: row;\n margin-left: -0.75em;\n\n @media (max-width: 1080px) {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(16em, 1fr));\n }\n}\n\n.website-footer__links--footer a {\n display: inline-block;\n padding: 0.5em 0.75em;\n font-size: 0.875em;\n opacity: 0.875;\n font-weight: 500;\n}\n\n.website-footer__links--footer a:hover {\n text-decoration: underline;\n text-underline-offset: var(--pl-link-text-underline-offset);\n}";
|
|
331
60
|
|
|
332
61
|
const Footer = class {
|
|
333
62
|
constructor(hostRef) {
|
|
334
63
|
index.registerInstance(this, hostRef);
|
|
64
|
+
/**
|
|
65
|
+
* When true, shows a "Built with the Penn Libraries Design System" line below the footer.
|
|
66
|
+
*/
|
|
67
|
+
this.showBuiltWith = false;
|
|
335
68
|
}
|
|
336
69
|
componentWillLoad() {
|
|
337
70
|
this.setNavigationByChildren();
|
|
@@ -356,12 +89,12 @@ const Footer = class {
|
|
|
356
89
|
}
|
|
357
90
|
render() {
|
|
358
91
|
const footerBackgroundSrc = index.getAssetPath('./assets/footer-bg.webp');
|
|
359
|
-
return (index.h("footer", { key: '
|
|
92
|
+
return (index.h("footer", { key: '39b1bc7336fe2aa28e8c6093d13b8dfb3dd70d3e', class: "website-footer-wrapper" }, index.h("div", { key: '7902cf7cde3a468dec8ea71c2a139addafa5af79', class: "website-footer", style: {
|
|
360
93
|
background: `var(--pl-color-penn-blue) url(${footerBackgroundSrc}) no-repeat 50% 50%`,
|
|
361
94
|
backgroundSize: 'cover',
|
|
362
|
-
} }, index.h("div", { key: '
|
|
95
|
+
} }, index.h("div", { key: '804f9cd3f101997ee2d15d4a4749945ef553a118', class: "viewport-margins" }, index.h("div", { key: '3a09637400e74e729641666eb8142c0cf77d66b3', class: "website-footer__content" }, index.h("div", { key: 'cdb9270db298aa7781859a80c799949cb4c35787', class: "website-footer__links-container" }, index.h("section", { key: '20d953d2b85178798d2298aa8aaa9fb8e47d7af4' }, index.h("h2", { key: '79b1fe7f4fc2dff03134c7d4e96e9fd657131fc8', class: "website-footer__heading" }, "Penn Libraries"), index.h("ul", { key: 'ba8002b17457f979f9817c45a89f332064f0b5bb', class: "website-footer__links" }, index.h("li", { key: 'cb65fc4ad6432ef447a4b98a8dfdc0323bf37ccc' }, index.h("a", { key: '0b61506da9a1c18919f77410fa39d3937f7485df', href: "https://maps.google.com/?q=Van Pelt Library 3420 Walnut Street, Philadelphia, PA 19104-6206" }, "3420 Walnut Street", index.h("br", { key: 'ebd3def13a3107d1b301c0932d421b054e2bb338' }), "Philadelphia, PA 19104-6206")), index.h("li", { key: '3f26ebab3b90a33ba2d17cd3cfd8a485f1c7e74f' }, index.h("a", { key: 'c2dcf7a3d936eb5376b2568e677bb8a7dc7ab445', href: "tel:(215) 898-7555" }, "(215) 898-7555")), index.h("li", { key: '8c9374110f2d386c7275fad9522ea2565daf6c06' }, index.h("a", { key: 'd40a2fd7490f1b233e4839e38faf29d9bb04f519', href: "https://www.library.upenn.edu/contact-us" }, "Contact us")), index.h("li", { key: 'ab3016b1cfcc8827af060ec383d8556e8346713a' }, index.h("a", { key: '76a8d246128fb76606c1cdf24640198c23c9d317', href: "https://www.library.upenn.edu/about/hours", target: "_blank" }, "Locations and hours")))), index.h("section", { key: 'fd0abacbc35ffaafbb2016064c7a6194616ee2dc' }, index.h("h2", { key: 'a812d7d26e21a1808ce6bd115ec620e1b033a8bf', class: "website-footer__heading" }, "Stay in touch"), index.h("ul", { key: 'fe158ff1336379e1236a88c4a3d0f5e1efd9cdb8', class: "website-footer__links" }, index.h("li", { key: '32396df360b39190ff587400fabe405ee319a507' }, index.h("a", { key: '07ac56362dde7a2807e86c2a22564689ed9de90c', href: "https://www.alumni.upenn.edu/libsignup" }, "Newsletter")), index.h("li", { key: '95abd2bf0f6a79c0597c1e57e878f986002adde2' }, index.h("a", { key: '374044fae62fd82c9369cfba8b7c6223ded48d5a', href: "https://www.instagram.com/upennlib/" }, "Instagram")), index.h("li", { key: '86cc74d4ec21dfb51a072cfad87ed395e961f26f' }, index.h("a", { key: 'fda9e8c73918252b91e40dc23d289613a3fe5802', href: "https://www.facebook.com/PennLibraries/" }, "Facebook")), index.h("li", { key: 'b1ce60d7aa5ac8a2aa8bd4f826c11cc753b1488c' }, index.h("a", { key: 'ccfef8131fc7f9edd44936f1c212d31c08c61682', href: "https://www.linkedin.com/company/penn-libraries" }, "LinkedIn")))), this.navigationByChildren && [
|
|
363
96
|
this.navigationByChildren.map(section => (index.h("section", null, index.h("h2", { class: "website-footer__heading" }, section.heading), index.h("ul", { class: "website-footer__links" }, section.links.map(link => (index.h("li", null, index.h("a", { href: link.href }, link.label))))))))
|
|
364
|
-
]))), index.h("div", { key: '
|
|
97
|
+
]))), index.h("div", { key: '4430d39b9b8943d9336020d5ed04cdb80a3b91af', class: "website-footer__footer" }, index.h("div", { key: '437f0b8894b63c3857f8871eaaaf3d28277738ad', class: "viewport-margins" }, index.h("ul", { key: '8c4ac37a89006d543a66c8c1ba6bc9d7acc0d6db', class: "website-footer__links website-footer__links--footer" }, index.h("li", { key: 'ac1db31f3c5331a26c0aee171974c10f22d5da08' }, index.h("a", { key: 'ad8a6251cca9b0c904ccecff96a8800b22ed5568', href: "https://www.upenn.edu/" }, "UPenn")), index.h("li", { key: '1189f7119ec768d34ea9435f9ff85df2764abe61' }, index.h("a", { key: 'eb53d4f15fe49d32899d435670a34369a4e7e190', href: "https://www.upenn.edu/about/privacy-policy" }, "Privacy Policy")), index.h("li", { key: 'd2a155f7f91a31cca41df9d0c9d37f151bded247' }, index.h("a", { key: '8e329a895a25bd139867063dd7eed9c0aa7c0060', href: "https://accessibility.web-resources.upenn.edu/get-help" }, "Report Accessibility Issues and Get Help")), index.h("li", { key: '0b65f3da18b54b91158515d7966e010e4e0d64ac' }, index.h("a", { key: 'f8615c438f94216372fdb8afa26ae7150bbef816', href: "https://www.upenn.edu/about/disclaimer" }, "Disclaimer")), index.h("li", { key: 'cbf5febfb926a1b569e73d4a57e7ca8315f6d876' }, index.h("a", { key: '1116c792623c0fa819ce0189e105ee54c69ba73e', href: "https://www.publicsafety.upenn.edu/contact/" }, "Emergency Services")), index.h("li", { key: '385a84f264b263a9738d38d66ac917e3a6055db4' }, index.h("a", { key: 'dcd8517fb32ae46b983cb4802adb86e33e29bd71', href: "https://www.upenn.edu/about/report-copyright-infringement" }, "Report Copyright Infringement")))))), this.showBuiltWith && (index.h("div", { key: 'd3bca43144b06b50091b54dee5c8734de4f80d60', class: "viewport-margins" }, index.h("p", { key: 'a3d974ea56f521406bffc2a8eaf6b6e6c57bb595', class: "built-with" }, "Built with the ", index.h("a", { key: '7aa9fc3901510e0ad7d2b0ca4abf4f8c6f92d735', href: "https://designsystem.library.upenn.edu/" }, "Penn Libraries Design System"), ".")))));
|
|
365
98
|
}
|
|
366
99
|
static get assetsDirs() { return ["assets"]; }
|
|
367
100
|
get hostElement() { return index.getElement(this); }
|
|
@@ -426,8 +159,7 @@ const Header = class {
|
|
|
426
159
|
};
|
|
427
160
|
Header.style = pennlibsHeaderCss;
|
|
428
161
|
|
|
429
|
-
exports.pennlibs_autocomplete = Autocomplete;
|
|
430
162
|
exports.pennlibs_feedback = PennlibsFeedback;
|
|
431
163
|
exports.pennlibs_footer = Footer;
|
|
432
164
|
exports.pennlibs_header = Header;
|
|
433
|
-
//# sourceMappingURL=pennlibs-
|
|
165
|
+
//# sourceMappingURL=pennlibs-feedback.pennlibs-footer.pennlibs-header.entry.cjs.js.map
|
package/dist/cjs/web.cjs.js
CHANGED
|
@@ -18,7 +18,7 @@ var patchBrowser = () => {
|
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(async (options) => {
|
|
20
20
|
await index.globalScripts();
|
|
21
|
-
return index.bootstrapLazy([["pennlibs-iiif-img.cjs",[[257,"pennlibs-iiif-img",{"uuid":[1],"alt":[1],"region":[513],"rotation":[1],"quality":[1],"loading":[1],"showFallback":[4,"show-fallback"],"isLoaded":[32],"hasError":[32],"imageDimensions":[32],"observedWidth":[32]},null,{"region":["handleRegionChange"]}]]],["pennlibs-
|
|
21
|
+
return index.bootstrapLazy([["pennlibs-iiif-img.cjs",[[257,"pennlibs-iiif-img",{"uuid":[1],"alt":[1],"region":[513],"rotation":[1],"quality":[1],"loading":[1],"showFallback":[4,"show-fallback"],"isLoaded":[32],"hasError":[32],"imageDimensions":[32],"observedWidth":[32]},null,{"region":["handleRegionChange"]}]]],["pennlibs-feedback_3.cjs",[[257,"pennlibs-feedback",{"hideQuestion":[4,"hide-question"],"answer":[32],"selected":[32]}],[257,"pennlibs-footer",{"showBuiltWith":[4,"show-built-with"],"navigationByChildren":[32]}],[257,"pennlibs-header",{"serviceName":[1,"service-name"],"serviceLede":[1,"service-lede"],"serviceHref":[1,"service-href"],"theme":[1],"isMenuOpen":[32],"navigation":[32]}]]],["pennlibs-autocomplete.cjs",[[257,"pennlibs-autocomplete",{"for":[1],"showSuggestions":[32],"currentIndex":[32],"originalValue":[32],"options":[32]},[[0,"slotchange","handleSlotChange"],[16,"input","handleInputEvent"],[16,"focus","handleFocusEvent"],[16,"blur","handleBlurEvent"],[0,"focusout","handleFocusOut"],[4,"keydown","handleKeyDown"]]]]],["pennlibs-banner.cjs",[[257,"pennlibs-banner"]]],["pennlibs-chat.cjs",[[257,"pennlibs-chat",{"href":[32]}]]],["pennlibs-hero.cjs",[[257,"pennlibs-hero",{"heroPictureElement":[32],"heroHeadingElement":[32],"heroParagraphElement":[32],"heroSrc":[32]}]]],["pennlibs-fallback-img.cjs",[[257,"pennlibs-fallback-img"]]]], options);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
exports.setNonce = index.setNonce;
|
|
@@ -50,7 +50,7 @@ h2 {
|
|
|
50
50
|
margin: 0;
|
|
51
51
|
font-family: var(--pl-font-sans-serif);
|
|
52
52
|
font-size: 1em;
|
|
53
|
-
font-weight:
|
|
53
|
+
font-weight: 400;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
p {
|
|
@@ -97,6 +97,27 @@ button:hover span {
|
|
|
97
97
|
text-decoration: underline;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
button.selected {
|
|
101
|
+
background: var(--pl-color-bg-accent-emphasis);
|
|
102
|
+
color: var(--pl-color-fg-on-emphasis);
|
|
103
|
+
border-color: var(--pl-color-bg-accent-emphasis);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Thank you message fade-in */
|
|
107
|
+
.feedback__inline-question + .feedback__share-feedback,
|
|
108
|
+
p {
|
|
109
|
+
animation: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.feedback__content > p {
|
|
113
|
+
animation: fadeIn 300ms ease-in;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@keyframes fadeIn {
|
|
117
|
+
from { opacity: 0; }
|
|
118
|
+
to { opacity: 1; }
|
|
119
|
+
}
|
|
120
|
+
|
|
100
121
|
/* Focus States
|
|
101
122
|
---------------------------------------- */
|
|
102
123
|
*:focus {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
|
-
const FEEDBACK_STORAGE_KEY =
|
|
3
|
-
const FEEDBACK_TIMESTAMP_KEY = 'pennlibs-feedback-timestamp';
|
|
2
|
+
const FEEDBACK_STORAGE_KEY = `pennlibs-feedback-${window.location.pathname}`;
|
|
4
3
|
const FEEDBACK_TTL = 5 * 60 * 1000; // 5 minutes
|
|
5
|
-
const FEEDBACK_QUESTION = '
|
|
6
|
-
const FEEDBACK_ERROR_STORAGE_KEY = 'pennlibs-feedback-error';
|
|
4
|
+
const FEEDBACK_QUESTION = 'Did you find what you need?';
|
|
7
5
|
/**
|
|
8
6
|
* A feedback component that asks visitors "Did you find what you need?" and
|
|
9
7
|
* links to a feedback form. The answer is stored in sessionStorage for 5 minutes
|
|
@@ -21,27 +19,30 @@ export class PennlibsFeedback {
|
|
|
21
19
|
* When true, hides the yes/no question and only shows the "share your feedback" link.
|
|
22
20
|
*/
|
|
23
21
|
this.hideQuestion = false;
|
|
24
|
-
this.error = false;
|
|
25
22
|
this.answer = undefined;
|
|
23
|
+
this.selected = undefined;
|
|
26
24
|
}
|
|
27
25
|
componentWillLoad() {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
const stored = sessionStorage.getItem(FEEDBACK_STORAGE_KEY);
|
|
27
|
+
if (stored) {
|
|
28
|
+
try {
|
|
29
|
+
const { answer, timestamp } = JSON.parse(stored);
|
|
30
|
+
if (Date.now() - timestamp > FEEDBACK_TTL) {
|
|
31
|
+
sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.answer = answer;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (_a) {
|
|
38
|
+
sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
handleFeedback(answer) {
|
|
41
43
|
var _a;
|
|
42
|
-
this.
|
|
43
|
-
sessionStorage.setItem(FEEDBACK_STORAGE_KEY, answer);
|
|
44
|
-
sessionStorage.setItem(FEEDBACK_TIMESTAMP_KEY, String(Date.now()));
|
|
44
|
+
this.selected = answer;
|
|
45
|
+
sessionStorage.setItem(FEEDBACK_STORAGE_KEY, JSON.stringify({ answer, timestamp: Date.now() }));
|
|
45
46
|
this.feedbackEvent.emit({
|
|
46
47
|
question: FEEDBACK_QUESTION,
|
|
47
48
|
answer: answer,
|
|
@@ -49,9 +50,12 @@ export class PennlibsFeedback {
|
|
|
49
50
|
pageHeading: ((_a = document.querySelector('h1')) === null || _a === void 0 ? void 0 : _a.textContent) || undefined,
|
|
50
51
|
pageTitle: document.title || undefined
|
|
51
52
|
});
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
this.answer = answer;
|
|
55
|
+
}, 600);
|
|
52
56
|
}
|
|
53
57
|
render() {
|
|
54
|
-
return (h("div", { key: '
|
|
58
|
+
return (h("div", { key: 'e470cb9ce96fecddda37c8a557c6670b581d8414', class: "feedback__container" }, h("div", { key: '0f3729d63102379f7219fd9a65c370f05c3f271c', class: "viewport-margins" }, h("div", { key: '3eaa8419d9b5fed5d7cf33de60ab93dd911afa34', class: "feedback__content" }, !this.hideQuestion && (this.answer === 'yes' ? (h("p", null, "Thank you for letting us know.")) : this.answer === 'no' ? (h("p", null, "We'd like to help. ", h("a", { href: "https://www.library.upenn.edu/contact-us" }, "Contact us"), " and let us know what you're looking for.")) : (h("div", { class: "feedback__inline-question" }, h("h2", null, "Did you find what you need?"), h("button", { class: { 'selected': this.selected === 'yes' }, disabled: !!this.selected, onClick: () => this.handleFeedback('yes') }, h("span", null, "Yes"), h("span", { class: "visually-hidden" }, ", I found what I needed.")), h("button", { class: { 'selected': this.selected === 'no' }, disabled: !!this.selected, onClick: () => this.handleFeedback('no') }, h("span", null, "No"), h("span", { class: "visually-hidden" }, ", I did not find what I needed."))))), h("div", { key: '50da9c1f23d14feeb6a2c408b0461a439331fcd9', class: "feedback__share-feedback" }, h("p", { key: '3580e25ecd7b463bb46103a6aee54a710e88c0ff' }, "To help us improve, ", h("a", { key: '276e226f4487ce94b9de30ae40f964e63f0d045b', href: `https://upenn.co1.qualtrics.com/jfe/form/SV_3xVrP7EKWS92zfE?reporting_from_url=${encodeURIComponent(window.location.href)}` }, "share your feedback"), "."))))));
|
|
55
59
|
}
|
|
56
60
|
static get is() { return "pennlibs-feedback"; }
|
|
57
61
|
static get encapsulation() { return "shadow"; }
|
|
@@ -91,8 +95,8 @@ export class PennlibsFeedback {
|
|
|
91
95
|
}
|
|
92
96
|
static get states() {
|
|
93
97
|
return {
|
|
94
|
-
"
|
|
95
|
-
"
|
|
98
|
+
"answer": {},
|
|
99
|
+
"selected": {}
|
|
96
100
|
};
|
|
97
101
|
}
|
|
98
102
|
static get events() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pennlibs-feedback.js","sourceRoot":"","sources":["../../../src/components/pennlibs-feedback/pennlibs-feedback.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAE/E,MAAM,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"pennlibs-feedback.js","sourceRoot":"","sources":["../../../src/components/pennlibs-feedback/pennlibs-feedback.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAE/E,MAAM,oBAAoB,GAAG,qBAAqB,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;AAC7E,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAChD,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AAGxD;;;;;;;;;;GAUG;AAMH,MAAM,OAAO,gBAAgB;IAL7B;QAME;;WAEG;QACK,iBAAY,GAAY,KAAK,CAAC;QAE7B,WAAM,GAAuB,SAAS,CAAC;QACvC,aAAQ,GAAuB,SAAS,CAAC;KAgFnD;IA7DC,iBAAiB;QACf,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC5D,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC;gBACH,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBACjD,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,YAAY,EAAE,CAAC;oBAC1C,cAAc,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAClD,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;gBACvB,CAAC;YACH,CAAC;YAAC,WAAM,CAAC;gBACP,cAAc,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED,cAAc,CAAC,MAAc;;QAC3B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;QACvB,cAAc,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;QAEhG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACtB,QAAQ,EAAE,iBAAiB;YAC3B,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;YACzB,WAAW,EAAE,CAAA,MAAA,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,0CAAE,WAAW,KAAI,SAAS;YACnE,SAAS,EAAE,QAAQ,CAAC,KAAK,IAAI,SAAS;SACvC,CAAC,CAAC;QAEH,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC;IAED,MAAM;QACJ,OAAO,CACL,4DAAK,KAAK,EAAC,qBAAqB;YAC9B,4DAAK,KAAK,EAAC,kBAAkB;gBAC3B,4DAAK,KAAK,EAAC,mBAAmB;oBAC3B,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,CAC9C,8CAAqC,CACtC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CACzB;;wBAAsB,SAAG,IAAI,EAAC,0CAA0C,iBAAe;oEAA6C,CACrI,CAAC,CAAC,CAAC,CACF,WAAK,KAAK,EAAC,2BAA2B;wBACpC,4CAAoC;wBACpC,cAAQ,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;4BAC1H,sBAAgB;4BAAA,YAAM,KAAK,EAAC,iBAAiB,+BAAgC,CACtE;wBACT,cAAQ,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;4BACxH,qBAAe;4BAAA,YAAM,KAAK,EAAC,iBAAiB,sCAAuC,CAC5E,CACL,CACP,CAAC;oBACF,4DAAK,KAAK,EAAC,0BAA0B;wBACnC;;4BAAuB,0DAAG,IAAI,EAAE,kFAAkF,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,0BAAyB;gCAAK,CACtL,CACF,CACF,CACF,CACP,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, State, Event, EventEmitter } from '@stencil/core';\n\nconst FEEDBACK_STORAGE_KEY = `pennlibs-feedback-${window.location.pathname}`;\nconst FEEDBACK_TTL = 5 * 60 * 1000; // 5 minutes\nconst FEEDBACK_QUESTION = 'Did you find what you need?';\n\n\n/**\n * A feedback component that asks visitors \"Did you find what you need?\" and\n * links to a feedback form. The answer is stored in sessionStorage for 5 minutes\n * to avoid re-prompting during a browsing session.\n *\n * @example\n * <pennlibs-feedback></pennlibs-feedback>\n *\n * @example\n * <pennlibs-feedback hide-question></pennlibs-feedback>\n */\n@Component({\n tag: 'pennlibs-feedback',\n styleUrl: 'pennlibs-feedback.css',\n shadow: true,\n})\nexport class PennlibsFeedback {\n /**\n * When true, hides the yes/no question and only shows the \"share your feedback\" link.\n */\n @Prop() hideQuestion: boolean = false;\n\n @State() answer: string | undefined = undefined;\n @State() selected: string | undefined = undefined;\n\n /**\n * Emitted when a visitor answers the feedback question. Includes the question,\n * answer, current URL, and page heading/title for context.\n */\n @Event({\n eventName: 'pennlibs-feedback',\n composed: true,\n cancelable: true,\n bubbles: true,\n }) feedbackEvent!: EventEmitter<{\n question: string;\n answer: string;\n url: string;\n pageHeading?: string;\n pageTitle?: string;\n }>;\n\n componentWillLoad() {\n const stored = sessionStorage.getItem(FEEDBACK_STORAGE_KEY);\n if (stored) {\n try {\n const { answer, timestamp } = JSON.parse(stored);\n if (Date.now() - timestamp > FEEDBACK_TTL) {\n sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);\n } else {\n this.answer = answer;\n }\n } catch {\n sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);\n }\n }\n }\n\n handleFeedback(answer: string) {\n this.selected = answer;\n sessionStorage.setItem(FEEDBACK_STORAGE_KEY, JSON.stringify({ answer, timestamp: Date.now() }));\n\n this.feedbackEvent.emit({\n question: FEEDBACK_QUESTION,\n answer: answer,\n url: window.location.href,\n pageHeading: document.querySelector('h1')?.textContent || undefined,\n pageTitle: document.title || undefined\n });\n\n setTimeout(() => {\n this.answer = answer;\n }, 600);\n }\n \n render() {\n return (\n <div class=\"feedback__container\">\n <div class=\"viewport-margins\">\n <div class=\"feedback__content\">\n {!this.hideQuestion && (this.answer === 'yes' ? (\n <p>Thank you for letting us know.</p>\n ) : this.answer === 'no' ? (\n <p>We'd like to help. <a href=\"https://www.library.upenn.edu/contact-us\">Contact us</a> and let us know what you're looking for.</p>\n ) : (\n <div class=\"feedback__inline-question\">\n <h2>Did you find what you need?</h2>\n <button class={{ 'selected': this.selected === 'yes' }} disabled={!!this.selected} onClick={() => this.handleFeedback('yes')}>\n <span>Yes</span><span class=\"visually-hidden\">, I found what I needed.</span>\n </button>\n <button class={{ 'selected': this.selected === 'no' }} disabled={!!this.selected} onClick={() => this.handleFeedback('no')}>\n <span>No</span><span class=\"visually-hidden\">, I did not find what I needed.</span>\n </button>\n </div>\n ))}\n <div class=\"feedback__share-feedback\">\n <p>To help us improve, <a href={`https://upenn.co1.qualtrics.com/jfe/form/SV_3xVrP7EKWS92zfE?reporting_from_url=${encodeURIComponent(window.location.href)}`}>share your feedback</a>.</p>\n </div>\n </div>\n </div>\n </div>\n )\n }\n}\n\n"]}
|