@watermarkinsights/ripple 5.32.0-alpha.8 → 5.32.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.
Files changed (37) hide show
  1. package/dist/cjs/{app-globals-646e78bf.js → app-globals-5a9e2484.js} +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/ripple.cjs.js +1 -1
  4. package/dist/cjs/wm-action-menu_2.cjs.entry.js +5 -4
  5. package/dist/cjs/wm-button.cjs.entry.js +1 -1
  6. package/dist/cjs/wm-option_2.cjs.entry.js +1 -1
  7. package/dist/cjs/wm-tag-input.cjs.entry.js +46 -22
  8. package/dist/cjs/wm-uploader.cjs.entry.js +1 -1
  9. package/dist/collection/components/selects/wm-select/wm-select.js +1 -1
  10. package/dist/collection/components/wm-action-menu/wm-action-menu.css +1 -1
  11. package/dist/collection/components/wm-action-menu/wm-action-menu.js +4 -3
  12. package/dist/collection/components/wm-button/wm-button.css +1 -1
  13. package/dist/collection/components/wm-tag-input/wm-tag-input.js +47 -23
  14. package/dist/collection/components/wm-uploader/wm-uploader.css +1 -1
  15. package/dist/docs/docs.json +1 -1
  16. package/dist/esm/{app-globals-7697f951.js → app-globals-e9a97ede.js} +1 -1
  17. package/dist/esm/loader.js +1 -1
  18. package/dist/esm/ripple.js +1 -1
  19. package/dist/esm/wm-action-menu_2.entry.js +5 -4
  20. package/dist/esm/wm-button.entry.js +1 -1
  21. package/dist/esm/wm-option_2.entry.js +1 -1
  22. package/dist/esm/wm-tag-input.entry.js +47 -23
  23. package/dist/esm/wm-uploader.entry.js +1 -1
  24. package/dist/ripple/{p-54ff1220.entry.js → p-5c2fc42a.entry.js} +1 -1
  25. package/dist/ripple/p-7799953c.entry.js +1 -0
  26. package/dist/ripple/p-87ef0cfa.entry.js +1 -0
  27. package/dist/ripple/p-d7a1be0b.entry.js +1 -0
  28. package/dist/ripple/p-f6f92d2a.js +1 -0
  29. package/dist/ripple/p-fc843bb8.entry.js +1 -0
  30. package/dist/ripple/ripple.esm.js +1 -1
  31. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +5 -2
  32. package/package.json +2 -2
  33. package/dist/ripple/p-2e78fa0f.entry.js +0 -1
  34. package/dist/ripple/p-82c94653.js +0 -1
  35. package/dist/ripple/p-a82ad01f.entry.js +0 -1
  36. package/dist/ripple/p-afee4371.entry.js +0 -1
  37. package/dist/ripple/p-ea02567a.entry.js +0 -1
@@ -109,6 +109,14 @@ const TagInput = class {
109
109
  });
110
110
  return list;
111
111
  }
112
+ // internal representations (dropdown li or table tr) of the options matching the user query.
113
+ // An option has no such element until the render that follows its insertion, so the list can be
114
+ // shorter than filteredOptionEls.
115
+ get filteredOptionRowEls() {
116
+ return this.filteredOptionEls
117
+ .map((o) => this.elFromTagOption(o))
118
+ .filter((el) => !!el);
119
+ }
112
120
  // the ones that should be rendered as tags
113
121
  get taggedOptions() {
114
122
  return this.optionEls.filter((o) => o.selected || o.locked);
@@ -122,18 +130,23 @@ const TagInput = class {
122
130
  return this._tagEls[this.focusedTagIndex];
123
131
  }
124
132
  }
133
+ // an empty id would make querySelector throw on the "#" selector
134
+ optionById(id) {
135
+ return id ? this.el.querySelector("#" + id) : undefined;
136
+ }
125
137
  // get the wm-tag-option, given the internal representation (dropdown li or table tr)
126
138
  tagOptionFromEl(el) {
127
- return el.id === "add-new-btn" ? undefined : this.el.querySelector("#" + el.id);
139
+ return el.id === "add-new-btn" ? undefined : this.optionById(el.id);
128
140
  }
129
141
  // get the wm-tag-option, given the internal representation of a tag
130
142
  tagOptionFromTag(el) {
131
- const id = el.id.replace("tag-", "");
132
- return this.el.querySelector("#" + id);
143
+ return this.optionById(el.id.replace("tag-", ""));
133
144
  }
134
145
  // get the internal representation of a wm-tag-option
135
146
  elFromTagOption(el) {
136
- return this.el.shadowRoot.querySelector("#" + el.id);
147
+ return el.id
148
+ ? this.el.shadowRoot.querySelector("#" + el.id)
149
+ : undefined;
137
150
  }
138
151
  // focusedOption state refers to the wm-tag-option. This gets the corresponding element in the shadow DOM, or the "Add New" button.
139
152
  get _focusedOption() {
@@ -222,7 +235,18 @@ const TagInput = class {
222
235
  isElOrChild(el) {
223
236
  return el === this.el || this.el.shadowRoot.contains(el) || this.el.contains(el);
224
237
  }
238
+ // Rows and tags are rendered with the id of their wm-tag-option, and that id is the only link
239
+ // back from a row or a tag to its option. wm-tag-option assigns its own id when it loads, which
240
+ // happens after this component renders, so any missing id is assigned here instead.
241
+ assignOptionIds() {
242
+ this.optionEls.forEach((o) => {
243
+ if (!o.id) {
244
+ o.id = functions.generateId();
245
+ }
246
+ });
247
+ }
225
248
  componentWillLoad() {
249
+ this.assignOptionIds();
226
250
  if (!this.placeholder) {
227
251
  this.placeholder = this.createPlaceholderDefault(this.addNew, this.optionEls.length > 0);
228
252
  }
@@ -254,7 +278,6 @@ const TagInput = class {
254
278
  this.tagsList = [...lockedTags, ...regularTags];
255
279
  }
256
280
  componentDidLoad() {
257
- this.handleLayoutChange();
258
281
  // Set up observer to announce changes in selected tags, or removed user-added tags
259
282
  const observerAnnouncer = new MutationObserver((optionListMutations) => optionListMutations.forEach((mutationRecord) => this.handleChangeAnnouncement(mutationRecord)));
260
283
  observerAnnouncer.observe(this.el, {
@@ -305,6 +328,7 @@ const TagInput = class {
305
328
  handleOptionListChange(record) {
306
329
  const addedNodes = Array.from(record.addedNodes);
307
330
  if (addedNodes.length > 0) {
331
+ this.assignOptionIds();
308
332
  addedNodes.forEach((n) => !this.tagsList.includes(n) && this.tagsList.push(n));
309
333
  }
310
334
  const removedNodes = Array.from(record.removedNodes);
@@ -360,8 +384,7 @@ const TagInput = class {
360
384
  const leftBound = textEl.getBoundingClientRect().left;
361
385
  // the numbers represent spacing values for padding, margin, and delete icon
362
386
  const rightBound = wrapper.getBoundingClientRect().right - 10 - 8 - 28;
363
- const id = tag.id.replace("tag-", "");
364
- const optionEl = id && this.el.querySelector("#" + id);
387
+ const optionEl = this.tagOptionFromTag(tag);
365
388
  if (optionEl) {
366
389
  // tag text for table variant is first column text
367
390
  textEl.textContent = functions.truncateText(textEl, this.getTagName(optionEl), rightBound - leftBound, 5);
@@ -413,12 +436,15 @@ const TagInput = class {
413
436
  this.resetInput();
414
437
  let option;
415
438
  if (this.isTable) {
416
- option = ev.target;
417
- option = this.tagOptionFromEl(option.closest("tr"));
439
+ const target = ev.target;
440
+ option = this.tagOptionFromEl(target.closest("tr"));
418
441
  }
419
442
  else {
420
443
  option = this.tagOptionFromEl(ev.target);
421
444
  }
445
+ if (!option) {
446
+ return;
447
+ }
422
448
  // if someone wants to attach a click event listener on wm-tag-option
423
449
  option.click();
424
450
  if (option.locked) {
@@ -539,15 +565,13 @@ const TagInput = class {
539
565
  if (this.addNewButton && this.addNewButton.id === "add-new-btn") {
540
566
  items.push(this.addNewButton);
541
567
  }
542
- this.filteredOptionEls.forEach((o) => {
543
- items.push(this.elFromTagOption(o));
544
- });
568
+ items.push(...this.filteredOptionRowEls);
545
569
  const next = functions.findNext(items, this._focusedOption, true);
546
570
  this.focusOption(next);
547
571
  }
548
572
  }
549
573
  else {
550
- const items = this.filteredOptionEls.map((o) => this.elFromTagOption(o));
574
+ const items = this.filteredOptionRowEls;
551
575
  const next = functions.findNext(items, this._focusedOption, true);
552
576
  this.focusOption(next);
553
577
  }
@@ -562,15 +586,13 @@ const TagInput = class {
562
586
  if (this.addNewButton) {
563
587
  items.push(this.addNewButton);
564
588
  }
565
- this.filteredOptionEls.forEach((o) => {
566
- items.push(this.elFromTagOption(o));
567
- });
589
+ items.push(...this.filteredOptionRowEls);
568
590
  const prev = functions.findPrev(items, this._focusedOption, true);
569
591
  this.focusOption(prev);
570
592
  }
571
593
  }
572
594
  else {
573
- const items = this.filteredOptionEls.map((o) => this.elFromTagOption(o));
595
+ const items = this.filteredOptionRowEls;
574
596
  const prev = functions.findPrev(items, this._focusedOption, true);
575
597
  this.focusOption(prev);
576
598
  }
@@ -608,6 +630,9 @@ const TagInput = class {
608
630
  case "Delete":
609
631
  if (this.focusedTag) {
610
632
  const option = this.tagOptionFromTag(this.focusedTag);
633
+ if (!option) {
634
+ break;
635
+ }
611
636
  if (option.locked) {
612
637
  this.announce(this.tagLockedMessage(this.getTagName(option)));
613
638
  }
@@ -748,9 +773,8 @@ const TagInput = class {
748
773
  }
749
774
  showTooltipIfTruncated(el) {
750
775
  const displayedText = el.querySelector(".tag-text").textContent;
751
- const id = el.id.replace("tag-", "");
752
- if (id) {
753
- const tagEl = this.el.querySelector("#" + id);
776
+ const tagEl = this.tagOptionFromTag(el);
777
+ if (tagEl) {
754
778
  const fullText = this.getTagName(tagEl);
755
779
  if (displayedText !== fullText && displayedText.includes("...")) {
756
780
  functions.showTooltip("bottom", el, fullText);
@@ -944,10 +968,10 @@ const TagInput = class {
944
968
  }
945
969
  }
946
970
  render() {
947
- return (index.h("div", { key: '98021c788751a158eaf7c9719f5a6cdbce179e5f', class: `wrapper label-${this.labelPosition} ${this.errorMessage ? "invalid" : ""}` }, index.h("div", { key: '5be1c5b7258830ba9f4ed48aac32c0cf08b7191a', class: "label-wrapper" }, index.h("label", { key: 'bcd2f7c977c282e4347671531cd91963469ea243', class: "label", htmlFor: "input", onMouseEnter: (ev) => this.handleLabelMouseEnter(ev), onMouseLeave: () => functions.hideTooltip() }, this.label), this.labelPosition !== "none" && this.requiredField && (index.h("div", { key: '987909d0fda0916c7ad77a5b6b2fbe364918fdf7', class: "required", "aria-hidden": "true" }, "*"))), index.h("div", { key: '74d2d1eb3cffb3084c575a07d9784592e3c83b0b', class: `field-wrapper ${this.el.shadowRoot.activeElement === this.inputEl ? "focused" : ""} ${this.errorMessage ? "invalid" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, index.h("div", { key: '7859920825578196f0d5680106b96be1f5f34ed2', class: "upper-row" }, index.h("div", { key: '117dc1c1083a00856b321011eb3b50839213f836', class: "svg-icon svg-search" }), index.h("div", { key: '461bba7d72ada741ee7fd0be8de693d2b7f0de35', class: `tags-and-input-wrapper` }, index.h("ul", { key: 'd8ca1a36892f5af26a6916aa328ec237626961d7', ref: (el) => (this.tagAreaEl = el), class: `tag-area ${this.taggedOptions.length === 0 && "empty"} ${this.isKeying ? "user-is-keying" : ""}`, role: "listbox", "aria-activedescendant": this.focusedTag ? this.focusedTag.id : null, "aria-orientation": "horizontal", "aria-labelledby": "sr-instructions", tabindex: this._tagEls.length > 0 ? 0 : -1, "aria-describedby": `info max-tags`, onFocus: (ev) => this.handleTagAreaFocus(ev), onBlur: (ev) => {
971
+ return (index.h("div", { key: '3320626934db9d58503b2964530e0bac1126775e', class: `wrapper label-${this.labelPosition} ${this.errorMessage ? "invalid" : ""}` }, index.h("div", { key: '9342d3b7db294e8c6c791bb0b4debfa537ab4029', class: "label-wrapper" }, index.h("label", { key: '48f8454c94c26ee09d69221d5985d9bc6d14ad90', class: "label", htmlFor: "input", onMouseEnter: (ev) => this.handleLabelMouseEnter(ev), onMouseLeave: () => functions.hideTooltip() }, this.label), this.labelPosition !== "none" && this.requiredField && (index.h("div", { key: '533458abd912ff8608419c53560baf6ff3e8ecb2', class: "required", "aria-hidden": "true" }, "*"))), index.h("div", { key: '8581fb8e727570200a2a024db5b3c767d79fb433', class: `field-wrapper ${this.el.shadowRoot.activeElement === this.inputEl ? "focused" : ""} ${this.errorMessage ? "invalid" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, index.h("div", { key: 'dc8aa608d413c1ccf2ce686d78ac14944f200421', class: "upper-row" }, index.h("div", { key: '8c076d96f42b6ce47d6ca49068fae2e51bbba705', class: "svg-icon svg-search" }), index.h("div", { key: '7dba4a97ab9435c4cd2f930e91922247349f0269', class: `tags-and-input-wrapper` }, index.h("ul", { key: '96f539b009fdc8cf9b267b8b7d9f9d110c00a24b', ref: (el) => (this.tagAreaEl = el), class: `tag-area ${this.taggedOptions.length === 0 && "empty"} ${this.isKeying ? "user-is-keying" : ""}`, role: "listbox", "aria-activedescendant": this.focusedTag ? this.focusedTag.id : null, "aria-orientation": "horizontal", "aria-labelledby": "sr-instructions", tabindex: this._tagEls.length > 0 ? 0 : -1, "aria-describedby": `info max-tags`, onFocus: (ev) => this.handleTagAreaFocus(ev), onBlur: (ev) => {
948
972
  this.focusedTagIndex = undefined;
949
973
  this.handleBlur(ev);
950
- }, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags()), index.h("div", { key: 'c7da0972ff25cc19d03e6e1fb1b9097439f1f723', class: "sr-only", id: "sr-instructions" }, this.label, ". ", this.tagAreaInstructions), this.isDropdown && this.renderDropdownInput(), this.isTable && this.renderTableInput()), this.isDropdown && (index.h("div", { key: '9d8ee83e7ff75dece20f57e96f987187f8ea4379', class: "character-count" }, this.charCount, "/", this.characterLimit))), this.renderTagCounter(), this.isDropdown && this.renderDropdown()), this.info && (index.h("div", { key: '61485889ea39dd305b051fc76a38726dea4ecba4', id: "info", class: "info-text" }, this.info)), index.h("div", { key: 'd6d2837acc24ff0334231bbc94ddaf482b4eb058', id: "error" }, this.errorMessage), index.h("div", { key: 'b1d420a77815803987916019cf32744eb3b54191', class: "sr-only", "aria-live": "polite", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage), this.isTable && this.renderTable()));
974
+ }, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags()), index.h("div", { key: '85c5677a7c97baf49906f90d0a2e20af3853b3d7', class: "sr-only", id: "sr-instructions" }, this.label, ". ", this.tagAreaInstructions), this.isDropdown && this.renderDropdownInput(), this.isTable && this.renderTableInput()), this.isDropdown && (index.h("div", { key: 'a60ae5ab37b6a973127ef0dbc73fdd25defa2b00', class: "character-count" }, this.charCount, "/", this.characterLimit))), this.renderTagCounter(), this.isDropdown && this.renderDropdown()), this.info && (index.h("div", { key: 'f66a9b7ab8687707e271dc606c54486e799a2dcc', id: "info", class: "info-text" }, this.info)), index.h("div", { key: '0e644fd0b06345ff5bb459e2dc46f7f6601bc92d', id: "error" }, this.errorMessage), index.h("div", { key: '94bea1eb5b48bd5a669d0f8a4ae98cc1ddde7692', class: "sr-only", "aria-live": "polite", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage), this.isTable && this.renderTable()));
951
975
  }
952
976
  static get delegatesFocus() { return true; }
953
977
  get el() { return index.getElement(this); }