@penn-libraries/web 1.2.1-dev.0 → 1.2.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.
@@ -16,6 +16,6 @@ var patchBrowser = () => {
16
16
 
17
17
  patchBrowser().then(async (options) => {
18
18
  await globalScripts();
19
- return bootstrapLazy([["p-906263a3",[[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"]}]]],["p-37644cf5",[[258,"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]}]]],["p-1c0dd1ec",[[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"]]]]],["p-e1947e84",[[257,"pennlibs-banner"]]],["p-badb334a",[[257,"pennlibs-chat",{"href":[32]}]]],["p-d392e98a",[[257,"pennlibs-hero",{"heroPictureElement":[32],"heroHeadingElement":[32],"heroParagraphElement":[32],"heroSrc":[32]}]]],["p-51bc70b8",[[257,"pennlibs-fallback-img"]]]], options);
19
+ return bootstrapLazy([["p-906263a3",[[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"]}]]],["p-5c02b8da",[[258,"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]}]]],["p-1c0dd1ec",[[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"]]]]],["p-e1947e84",[[257,"pennlibs-banner"]]],["p-badb334a",[[257,"pennlibs-chat",{"href":[32]}]]],["p-d392e98a",[[257,"pennlibs-hero",{"heroPictureElement":[32],"heroHeadingElement":[32],"heroParagraphElement":[32],"heroSrc":[32]}]]],["p-51bc70b8",[[257,"pennlibs-fallback-img"]]]], options);
20
20
  });
21
21
  //# sourceMappingURL=web.esm.js.map
package/hydrate/index.js CHANGED
@@ -4235,9 +4235,8 @@ class NoImage {
4235
4235
  }; }
4236
4236
  }
4237
4237
 
4238
- const pennlibsFeedbackCss = ".feedback__container.sc-pennlibs-feedback{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{.sc-pennlibs-feedback-h{display:none}}*.sc-pennlibs-feedback,*.sc-pennlibs-feedback::before,*.sc-pennlibs-feedback::after{box-sizing:border-box}.viewport-margins.sc-pennlibs-feedback{max-width:var(--pl-viewport-margins-max-width);margin:0 auto;padding:0 var(--pl-viewport-margins-gutter, 1em)}.feedback__content.sc-pennlibs-feedback{display:flex;justify-content:space-between;gap:var(--pl-space-s);flex-wrap:wrap}.feedback__inline-question.sc-pennlibs-feedback{display:flex;flex-wrap:wrap;gap:0.5em;align-items:center}h2.sc-pennlibs-feedback{display:inline-block;margin:0;font-family:var(--pl-font-sans-serif);font-size:1em;font-weight:400}p.sc-pennlibs-feedback{margin:0;padding:calc(0.5em + 1px) 0}strong.sc-pennlibs-feedback{font-weight:600}a.sc-pennlibs-feedback{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.sc-pennlibs-feedback{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.sc-pennlibs-feedback:hover{cursor:pointer}button.sc-pennlibs-feedback:hover span.sc-pennlibs-feedback{text-decoration:underline}button.selected.sc-pennlibs-feedback{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.sc-pennlibs-feedback+.feedback__share-feedback.sc-pennlibs-feedback,p.sc-pennlibs-feedback{animation:none}.feedback__content.sc-pennlibs-feedback>p.sc-pennlibs-feedback{animation:fadeIn 300ms ease-in}@keyframes fadeIn{from{opacity:0}to{opacity:1}}*.sc-pennlibs-feedback: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.sc-pennlibs-feedback: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.sc-pennlibs-feedback{display:block;width:100%;text-align:center}}.help-us.sc-pennlibs-feedback{display:flex;flex-direction:column;gap:0.5em}.visually-hidden.sc-pennlibs-feedback{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}.visually-hidden.sc-pennlibs-feedback:focus,.visually-hidden.sc-pennlibs-feedback:active{clip:auto;clip-path:none;height:auto;overflow:visible;position:static;white-space:normal;width:auto}";
4238
+ const pennlibsFeedbackCss = ".feedback__container.sc-pennlibs-feedback{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{.sc-pennlibs-feedback-h{display:none}}*.sc-pennlibs-feedback,*.sc-pennlibs-feedback::before,*.sc-pennlibs-feedback::after{box-sizing:border-box}.viewport-margins.sc-pennlibs-feedback{max-width:var(--pl-viewport-margins-max-width);margin:0 auto;padding:0 var(--pl-viewport-margins-gutter, 1em)}.feedback__content.sc-pennlibs-feedback{display:flex;justify-content:space-between;gap:var(--pl-space-s);flex-wrap:wrap}.feedback__inline-question.sc-pennlibs-feedback{display:flex;flex-wrap:wrap;gap:0.5em;align-items:center}h2.sc-pennlibs-feedback{display:inline-block;margin:0;font-family:var(--pl-font-sans-serif);font-size:1em;font-weight:400}p.sc-pennlibs-feedback{margin:0;padding:calc(0.5em + 1px) 0}a.sc-pennlibs-feedback{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.sc-pennlibs-feedback{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.sc-pennlibs-feedback:hover{cursor:pointer}button.sc-pennlibs-feedback:hover span.sc-pennlibs-feedback{text-decoration:underline}button.selected.sc-pennlibs-feedback{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.sc-pennlibs-feedback+.feedback__share-feedback.sc-pennlibs-feedback,p.sc-pennlibs-feedback{animation:none}.feedback__content.sc-pennlibs-feedback>p.sc-pennlibs-feedback{animation:fadeIn 300ms ease-in}@keyframes fadeIn{from{opacity:0}to{opacity:1}}*.sc-pennlibs-feedback:focus{outline:0;box-shadow:0 0 0 2px var(--pl-color-bg-attention),\n 0 0 0 3px var(--pl-color-bg-emphasis)}@media (max-width: 26em){h2.sc-pennlibs-feedback{display:block;width:100%}}.visually-hidden.sc-pennlibs-feedback{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}";
4239
4239
 
4240
- const FEEDBACK_STORAGE_KEY = `pennlibs-feedback-${window.location.pathname}`;
4241
4240
  const FEEDBACK_TTL = 5 * 60 * 1000; // 5 minutes
4242
4241
  const FEEDBACK_QUESTION = 'Did you find what you need?';
4243
4242
  /**
@@ -4261,21 +4260,50 @@ class PennlibsFeedback {
4261
4260
  this.hideQuestion = false;
4262
4261
  this.answer = undefined;
4263
4262
  this.selected = undefined;
4263
+ this.currentUrl = '';
4264
+ this.onNavigate = (event) => {
4265
+ try {
4266
+ const destinationUrl = new URL(event.destination.url).href;
4267
+ if (destinationUrl !== this.currentUrl) {
4268
+ this.currentUrl = destinationUrl;
4269
+ this.selected = undefined;
4270
+ this.answer = undefined;
4271
+ this.loadStoredAnswer();
4272
+ }
4273
+ }
4274
+ catch (_a) {
4275
+ this.selected = undefined;
4276
+ this.answer = undefined;
4277
+ }
4278
+ };
4279
+ }
4280
+ get storageKey() {
4281
+ return `pennlibs-feedback-${this.currentUrl}`;
4282
+ }
4283
+ connectedCallback() {
4284
+ this.currentUrl = window.location.href;
4285
+ window.navigation.addEventListener('navigate', this.onNavigate);
4286
+ }
4287
+ disconnectedCallback() {
4288
+ window.navigation.removeEventListener('navigate', this.onNavigate);
4264
4289
  }
4265
4290
  componentWillLoad() {
4266
- const stored = sessionStorage.getItem(FEEDBACK_STORAGE_KEY);
4291
+ this.loadStoredAnswer();
4292
+ }
4293
+ loadStoredAnswer() {
4294
+ const stored = sessionStorage.getItem(this.storageKey);
4267
4295
  if (stored) {
4268
4296
  try {
4269
4297
  const { answer, timestamp } = JSON.parse(stored);
4270
4298
  if (Date.now() - timestamp > FEEDBACK_TTL) {
4271
- sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);
4299
+ sessionStorage.removeItem(this.storageKey);
4272
4300
  }
4273
4301
  else {
4274
4302
  this.answer = answer;
4275
4303
  }
4276
4304
  }
4277
4305
  catch (_a) {
4278
- sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);
4306
+ sessionStorage.removeItem(this.storageKey);
4279
4307
  }
4280
4308
  }
4281
4309
  }
@@ -4284,7 +4312,7 @@ class PennlibsFeedback {
4284
4312
  event.preventDefault();
4285
4313
  const answer = event.submitter.value;
4286
4314
  this.selected = answer;
4287
- sessionStorage.setItem(FEEDBACK_STORAGE_KEY, JSON.stringify({ answer, timestamp: Date.now() }));
4315
+ sessionStorage.setItem(this.storageKey, JSON.stringify({ answer, timestamp: Date.now() }));
4288
4316
  this.feedbackEvent.emit({
4289
4317
  question: FEEDBACK_QUESTION,
4290
4318
  answer: answer,
@@ -4297,7 +4325,7 @@ class PennlibsFeedback {
4297
4325
  }, 600);
4298
4326
  }
4299
4327
  render() {
4300
- return (hAsync("div", { key: '013c3b140f249641d412bd0c19108a6c51d2f12e', class: "feedback__container" }, hAsync("div", { key: 'ef51ab5c419dfdd8679b027882a59171480ea039', class: "viewport-margins" }, hAsync("div", { key: '2c61b86b1e69037d7d63ecde5288bfcc0e1dad75', class: "feedback__content" }, !this.hideQuestion && (this.answer === 'yes' ? (hAsync("p", null, "Thank you for letting us know.")) : this.answer === 'no' ? (hAsync("p", null, "We'd like to help. ", hAsync("a", { href: "https://www.library.upenn.edu/contact-us" }, "Contact us"), " and let us know what you're looking for.")) : (hAsync("form", { class: "feedback__inline-question", onSubmit: (e) => this.handleSubmit(e) }, hAsync("h2", null, "Did you find what you need?"), hAsync("button", { type: "submit", name: "answer", value: "yes", class: { 'selected': this.selected === 'yes' }, disabled: !!this.selected }, hAsync("span", null, "Yes"), hAsync("span", { class: "visually-hidden" }, ", I found what I needed.")), hAsync("button", { type: "submit", name: "answer", value: "no", class: { 'selected': this.selected === 'no' }, disabled: !!this.selected }, hAsync("span", null, "No"), hAsync("span", { class: "visually-hidden" }, ", I did not find what I needed."))))), hAsync("div", { key: '90ccdacc682229570f83867f8d8f587a3e0c16aa', class: "feedback__share-feedback" }, hAsync("p", { key: 'edd15c793ac6af5d31bd98863cd76fce27aed69a' }, "To help us improve, ", hAsync("a", { key: '25f5c322d0fb717b8618b40625af978d57f805bd', href: `https://upenn.co1.qualtrics.com/jfe/form/SV_3xVrP7EKWS92zfE?reporting_from_url=${encodeURIComponent(window.location.href)}` }, "share your feedback"), "."))))));
4328
+ return (hAsync("div", { key: '12bdec6f975166a4c5d451fc1834f70fbce3b424', class: "feedback__container" }, hAsync("div", { key: '4c607ceef5f10760d540d2549a2b186a871714c7', class: "viewport-margins" }, hAsync("div", { key: 'a967498163e05ce60a12bf230d303caa31373c8d', class: "feedback__content" }, !this.hideQuestion && (this.answer === 'yes' ? (hAsync("p", null, "Thank you for letting us know.")) : this.answer === 'no' ? (hAsync("p", null, "We'd like to help. ", hAsync("a", { href: "https://www.library.upenn.edu/contact-us" }, "Contact us"), " and let us know what you're looking for.")) : (hAsync("form", { class: "feedback__inline-question", onSubmit: (e) => this.handleSubmit(e) }, hAsync("h2", null, "Did you find what you need?"), hAsync("button", { type: "submit", name: "answer", value: "yes", class: { 'selected': this.selected === 'yes' }, disabled: !!this.selected }, hAsync("span", null, "Yes"), hAsync("span", { class: "visually-hidden" }, ", I found what I needed.")), hAsync("button", { type: "submit", name: "answer", value: "no", class: { 'selected': this.selected === 'no' }, disabled: !!this.selected }, hAsync("span", null, "No"), hAsync("span", { class: "visually-hidden" }, ", I did not find what I needed."))))), hAsync("div", { key: 'f918da2833ae0c64e67a9e95551edaeb78e2ba05', class: "feedback__share-feedback" }, hAsync("p", { key: '12928af116ffadf669cbc694160ee6ca3458528b' }, "To help us improve, ", hAsync("a", { key: '7281b7423677b104fb622a7fdcf8e768517ea84e', href: `https://upenn.co1.qualtrics.com/jfe/form/SV_3xVrP7EKWS92zfE?reporting_from_url=${encodeURIComponent(window.location.href)}` }, "share your feedback"), "."))))));
4301
4329
  }
4302
4330
  static get style() { return pennlibsFeedbackCss; }
4303
4331
  static get cmpMeta() { return {
package/hydrate/index.mjs CHANGED
@@ -4233,9 +4233,8 @@ class NoImage {
4233
4233
  }; }
4234
4234
  }
4235
4235
 
4236
- const pennlibsFeedbackCss = ".feedback__container.sc-pennlibs-feedback{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{.sc-pennlibs-feedback-h{display:none}}*.sc-pennlibs-feedback,*.sc-pennlibs-feedback::before,*.sc-pennlibs-feedback::after{box-sizing:border-box}.viewport-margins.sc-pennlibs-feedback{max-width:var(--pl-viewport-margins-max-width);margin:0 auto;padding:0 var(--pl-viewport-margins-gutter, 1em)}.feedback__content.sc-pennlibs-feedback{display:flex;justify-content:space-between;gap:var(--pl-space-s);flex-wrap:wrap}.feedback__inline-question.sc-pennlibs-feedback{display:flex;flex-wrap:wrap;gap:0.5em;align-items:center}h2.sc-pennlibs-feedback{display:inline-block;margin:0;font-family:var(--pl-font-sans-serif);font-size:1em;font-weight:400}p.sc-pennlibs-feedback{margin:0;padding:calc(0.5em + 1px) 0}strong.sc-pennlibs-feedback{font-weight:600}a.sc-pennlibs-feedback{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.sc-pennlibs-feedback{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.sc-pennlibs-feedback:hover{cursor:pointer}button.sc-pennlibs-feedback:hover span.sc-pennlibs-feedback{text-decoration:underline}button.selected.sc-pennlibs-feedback{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.sc-pennlibs-feedback+.feedback__share-feedback.sc-pennlibs-feedback,p.sc-pennlibs-feedback{animation:none}.feedback__content.sc-pennlibs-feedback>p.sc-pennlibs-feedback{animation:fadeIn 300ms ease-in}@keyframes fadeIn{from{opacity:0}to{opacity:1}}*.sc-pennlibs-feedback: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.sc-pennlibs-feedback: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.sc-pennlibs-feedback{display:block;width:100%;text-align:center}}.help-us.sc-pennlibs-feedback{display:flex;flex-direction:column;gap:0.5em}.visually-hidden.sc-pennlibs-feedback{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}.visually-hidden.sc-pennlibs-feedback:focus,.visually-hidden.sc-pennlibs-feedback:active{clip:auto;clip-path:none;height:auto;overflow:visible;position:static;white-space:normal;width:auto}";
4236
+ const pennlibsFeedbackCss = ".feedback__container.sc-pennlibs-feedback{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{.sc-pennlibs-feedback-h{display:none}}*.sc-pennlibs-feedback,*.sc-pennlibs-feedback::before,*.sc-pennlibs-feedback::after{box-sizing:border-box}.viewport-margins.sc-pennlibs-feedback{max-width:var(--pl-viewport-margins-max-width);margin:0 auto;padding:0 var(--pl-viewport-margins-gutter, 1em)}.feedback__content.sc-pennlibs-feedback{display:flex;justify-content:space-between;gap:var(--pl-space-s);flex-wrap:wrap}.feedback__inline-question.sc-pennlibs-feedback{display:flex;flex-wrap:wrap;gap:0.5em;align-items:center}h2.sc-pennlibs-feedback{display:inline-block;margin:0;font-family:var(--pl-font-sans-serif);font-size:1em;font-weight:400}p.sc-pennlibs-feedback{margin:0;padding:calc(0.5em + 1px) 0}a.sc-pennlibs-feedback{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.sc-pennlibs-feedback{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.sc-pennlibs-feedback:hover{cursor:pointer}button.sc-pennlibs-feedback:hover span.sc-pennlibs-feedback{text-decoration:underline}button.selected.sc-pennlibs-feedback{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.sc-pennlibs-feedback+.feedback__share-feedback.sc-pennlibs-feedback,p.sc-pennlibs-feedback{animation:none}.feedback__content.sc-pennlibs-feedback>p.sc-pennlibs-feedback{animation:fadeIn 300ms ease-in}@keyframes fadeIn{from{opacity:0}to{opacity:1}}*.sc-pennlibs-feedback:focus{outline:0;box-shadow:0 0 0 2px var(--pl-color-bg-attention),\n 0 0 0 3px var(--pl-color-bg-emphasis)}@media (max-width: 26em){h2.sc-pennlibs-feedback{display:block;width:100%}}.visually-hidden.sc-pennlibs-feedback{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}";
4237
4237
 
4238
- const FEEDBACK_STORAGE_KEY = `pennlibs-feedback-${window.location.pathname}`;
4239
4238
  const FEEDBACK_TTL = 5 * 60 * 1000; // 5 minutes
4240
4239
  const FEEDBACK_QUESTION = 'Did you find what you need?';
4241
4240
  /**
@@ -4259,21 +4258,50 @@ class PennlibsFeedback {
4259
4258
  this.hideQuestion = false;
4260
4259
  this.answer = undefined;
4261
4260
  this.selected = undefined;
4261
+ this.currentUrl = '';
4262
+ this.onNavigate = (event) => {
4263
+ try {
4264
+ const destinationUrl = new URL(event.destination.url).href;
4265
+ if (destinationUrl !== this.currentUrl) {
4266
+ this.currentUrl = destinationUrl;
4267
+ this.selected = undefined;
4268
+ this.answer = undefined;
4269
+ this.loadStoredAnswer();
4270
+ }
4271
+ }
4272
+ catch (_a) {
4273
+ this.selected = undefined;
4274
+ this.answer = undefined;
4275
+ }
4276
+ };
4277
+ }
4278
+ get storageKey() {
4279
+ return `pennlibs-feedback-${this.currentUrl}`;
4280
+ }
4281
+ connectedCallback() {
4282
+ this.currentUrl = window.location.href;
4283
+ window.navigation.addEventListener('navigate', this.onNavigate);
4284
+ }
4285
+ disconnectedCallback() {
4286
+ window.navigation.removeEventListener('navigate', this.onNavigate);
4262
4287
  }
4263
4288
  componentWillLoad() {
4264
- const stored = sessionStorage.getItem(FEEDBACK_STORAGE_KEY);
4289
+ this.loadStoredAnswer();
4290
+ }
4291
+ loadStoredAnswer() {
4292
+ const stored = sessionStorage.getItem(this.storageKey);
4265
4293
  if (stored) {
4266
4294
  try {
4267
4295
  const { answer, timestamp } = JSON.parse(stored);
4268
4296
  if (Date.now() - timestamp > FEEDBACK_TTL) {
4269
- sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);
4297
+ sessionStorage.removeItem(this.storageKey);
4270
4298
  }
4271
4299
  else {
4272
4300
  this.answer = answer;
4273
4301
  }
4274
4302
  }
4275
4303
  catch (_a) {
4276
- sessionStorage.removeItem(FEEDBACK_STORAGE_KEY);
4304
+ sessionStorage.removeItem(this.storageKey);
4277
4305
  }
4278
4306
  }
4279
4307
  }
@@ -4282,7 +4310,7 @@ class PennlibsFeedback {
4282
4310
  event.preventDefault();
4283
4311
  const answer = event.submitter.value;
4284
4312
  this.selected = answer;
4285
- sessionStorage.setItem(FEEDBACK_STORAGE_KEY, JSON.stringify({ answer, timestamp: Date.now() }));
4313
+ sessionStorage.setItem(this.storageKey, JSON.stringify({ answer, timestamp: Date.now() }));
4286
4314
  this.feedbackEvent.emit({
4287
4315
  question: FEEDBACK_QUESTION,
4288
4316
  answer: answer,
@@ -4295,7 +4323,7 @@ class PennlibsFeedback {
4295
4323
  }, 600);
4296
4324
  }
4297
4325
  render() {
4298
- return (hAsync("div", { key: '013c3b140f249641d412bd0c19108a6c51d2f12e', class: "feedback__container" }, hAsync("div", { key: 'ef51ab5c419dfdd8679b027882a59171480ea039', class: "viewport-margins" }, hAsync("div", { key: '2c61b86b1e69037d7d63ecde5288bfcc0e1dad75', class: "feedback__content" }, !this.hideQuestion && (this.answer === 'yes' ? (hAsync("p", null, "Thank you for letting us know.")) : this.answer === 'no' ? (hAsync("p", null, "We'd like to help. ", hAsync("a", { href: "https://www.library.upenn.edu/contact-us" }, "Contact us"), " and let us know what you're looking for.")) : (hAsync("form", { class: "feedback__inline-question", onSubmit: (e) => this.handleSubmit(e) }, hAsync("h2", null, "Did you find what you need?"), hAsync("button", { type: "submit", name: "answer", value: "yes", class: { 'selected': this.selected === 'yes' }, disabled: !!this.selected }, hAsync("span", null, "Yes"), hAsync("span", { class: "visually-hidden" }, ", I found what I needed.")), hAsync("button", { type: "submit", name: "answer", value: "no", class: { 'selected': this.selected === 'no' }, disabled: !!this.selected }, hAsync("span", null, "No"), hAsync("span", { class: "visually-hidden" }, ", I did not find what I needed."))))), hAsync("div", { key: '90ccdacc682229570f83867f8d8f587a3e0c16aa', class: "feedback__share-feedback" }, hAsync("p", { key: 'edd15c793ac6af5d31bd98863cd76fce27aed69a' }, "To help us improve, ", hAsync("a", { key: '25f5c322d0fb717b8618b40625af978d57f805bd', href: `https://upenn.co1.qualtrics.com/jfe/form/SV_3xVrP7EKWS92zfE?reporting_from_url=${encodeURIComponent(window.location.href)}` }, "share your feedback"), "."))))));
4326
+ return (hAsync("div", { key: '12bdec6f975166a4c5d451fc1834f70fbce3b424', class: "feedback__container" }, hAsync("div", { key: '4c607ceef5f10760d540d2549a2b186a871714c7', class: "viewport-margins" }, hAsync("div", { key: 'a967498163e05ce60a12bf230d303caa31373c8d', class: "feedback__content" }, !this.hideQuestion && (this.answer === 'yes' ? (hAsync("p", null, "Thank you for letting us know.")) : this.answer === 'no' ? (hAsync("p", null, "We'd like to help. ", hAsync("a", { href: "https://www.library.upenn.edu/contact-us" }, "Contact us"), " and let us know what you're looking for.")) : (hAsync("form", { class: "feedback__inline-question", onSubmit: (e) => this.handleSubmit(e) }, hAsync("h2", null, "Did you find what you need?"), hAsync("button", { type: "submit", name: "answer", value: "yes", class: { 'selected': this.selected === 'yes' }, disabled: !!this.selected }, hAsync("span", null, "Yes"), hAsync("span", { class: "visually-hidden" }, ", I found what I needed.")), hAsync("button", { type: "submit", name: "answer", value: "no", class: { 'selected': this.selected === 'no' }, disabled: !!this.selected }, hAsync("span", null, "No"), hAsync("span", { class: "visually-hidden" }, ", I did not find what I needed."))))), hAsync("div", { key: 'f918da2833ae0c64e67a9e95551edaeb78e2ba05', class: "feedback__share-feedback" }, hAsync("p", { key: '12928af116ffadf669cbc694160ee6ca3458528b' }, "To help us improve, ", hAsync("a", { key: '7281b7423677b104fb622a7fdcf8e768517ea84e', href: `https://upenn.co1.qualtrics.com/jfe/form/SV_3xVrP7EKWS92zfE?reporting_from_url=${encodeURIComponent(window.location.href)}` }, "share your feedback"), "."))))));
4299
4327
  }
4300
4328
  static get style() { return pennlibsFeedbackCss; }
4301
4329
  static get cmpMeta() { return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@penn-libraries/web",
3
- "version": "1.2.1-dev.0",
3
+ "version": "1.2.1",
4
4
  "description": "Reusable web designs for University of Pennsylvania Libraries websites. This package contains our code for shared Web Components and Cascading Style Sheets (CSS).",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",