@cas-smartdesign/token-selector 0.16.1 → 0.17.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.
@@ -1,7 +1,7 @@
1
1
  import { LitElement, TemplateResult, CSSResult, PropertyValues } from "lit";
2
2
  import "@cas-smartdesign/lit-input";
3
3
  import { ValidationLevel } from "@cas-smartdesign/field-validation-message";
4
- import { ItemGenerator } from "@cas-smartdesign/list";
4
+ import { ItemGenerator } from "@cas-smartdesign/virtual-list";
5
5
  import { Filter } from "./token-suggest-popover";
6
6
  import Token, { TokenData } from "./token";
7
7
  export type { Filter as InMemoryFilter } from "./token-suggest-popover";
@@ -1,30 +1,40 @@
1
- import { LitElement as b, unsafeCSS as T, html as v, nothing as w } from "lit";
1
+ import { LitElement as x, unsafeCSS as T, html as m, nothing as I } from "lit";
2
2
  import { property as a } from "lit/decorators/property.js";
3
3
  import "@cas-smartdesign/lit-input";
4
- import E from "@cas-smartdesign/field-validation-message";
5
- import { generator as S } from "@cas-smartdesign/list-item";
6
- import _ from "@cas-smartdesign/popover";
7
- import I from "@cas-smartdesign/list";
8
- import { KeyDownDelegator as C } from "@cas-smartdesign/element-utils";
4
+ import S from "@cas-smartdesign/field-validation-message";
5
+ import { generator as _ } from "@cas-smartdesign/list-item";
6
+ import C from "@cas-smartdesign/popover";
7
+ import y from "@cas-smartdesign/virtual-list";
8
+ import { KeyDownDelegator as L } from "@cas-smartdesign/element-utils";
9
9
  import { ifDefined as A } from "lit/directives/if-defined.js";
10
10
  import { unsafeSVG as P } from "lit/directives/unsafe-svg.js";
11
- import L from "@cas-smartdesign/image-tools";
12
- class D {
13
- constructor(e, t, i, s) {
14
- this.inputElement = e, this.notSelectedTokensProvider = t, this.initializeCallback = s, this.filter = (n, r) => n ? r.filter((l) => l.disabled || l.deactivated ? !1 : l.caption && l.caption.toLowerCase().includes(n)) : r, I.ensureDefined(), this._tokenList = new I(), this._tokenList.style.minWidth = "250px", this._tokenList.addEventListener("selection", (n) => {
15
- const r = n.detail.index, l = this._suggestItems[r];
16
- i(l), this.hide();
17
- }), new C(this._tokenList, (n, r, l) => {
18
- this._tokenList.dispatchEvent(new KeyboardEvent(n.type, n)), !l && !this.isOpened && this.show();
11
+ import D from "@cas-smartdesign/image-tools";
12
+ class O {
13
+ constructor(e, t, i, n) {
14
+ this.inputElement = e, this.notSelectedTokensProvider = t, this.initializeCallback = n, this.filter = (s, o) => s ? o.filter((d) => d.disabled || d.deactivated ? !1 : d.caption && d.caption.toLowerCase().includes(s)) : o, y.ensureDefined(), this._tokenList = new y(), this._tokenList.style.minWidth = "250px", this._tokenList.style.maxHeight = "49vh", this._tokenList.itemHeight = 50, this._tokenList.addEventListener("selection", (s) => {
15
+ const o = s.detail.index, d = this._suggestItems[o];
16
+ i(d), this.hide();
17
+ }), this._tokenList.addEventListener("data-request", (s) => {
18
+ this.lastRequestedStartIndex = s.detail.startIndex, this.lastRequestedStopIndex = s.detail.stopIndex, this._tokenList.items = this._suggestItems.slice(
19
+ this.lastRequestedStartIndex,
20
+ this.lastRequestedStopIndex + 1
21
+ );
22
+ }), new L(this._tokenList, (s, o, d) => {
23
+ this._tokenList.dispatchEvent(new KeyboardEvent(s.type, s)), !d && !this.isOpened && this.show();
19
24
  }).connect(e);
20
25
  }
21
26
  show() {
22
- this.inputElement.effectiveDisabled || (this.popover, this._suggestItems = this.filterItems((this.inputElement.value || "").toLowerCase()), this._suggestItems.length == 0 ? this.hide() : (this._tokenList.items = this._suggestItems.map((e) => ({ ...e, contentMode: "text" })), this._tokenList.focusIndex = -1, Object.assign(this._tokenList.style, {
27
+ this.inputElement.effectiveDisabled || (this.popover, this._suggestItems = this.filterItems((this.inputElement.value || "").toLowerCase()), this._suggestItems.length == 0 ? this.hide() : (this._tokenList.itemCount = this._suggestItems.length, this._tokenList.focusIndex = -1, requestAnimationFrame(() => {
28
+ this.lastRequestedStartIndex != null && (this._tokenList.items = this._suggestItems.slice(
29
+ this.lastRequestedStartIndex,
30
+ this.lastRequestedStopIndex + 1
31
+ ));
32
+ }), Object.assign(this._tokenList.style, {
23
33
  minWidth: `${Math.max(this.popover.targetElement.offsetWidth, 250)}px`
24
34
  }), this.popover.show()));
25
35
  }
26
36
  refreshItems() {
27
- this.isOpened && (this._suggestItems = this.filterItems((this.inputElement.value || "").toLowerCase()), this._suggestItems.length == 0 ? this.hide() : this._tokenList.items = this._suggestItems.map((e) => ({ ...e, contentMode: "text" })));
37
+ this.isOpened && (this._suggestItems = this.filterItems((this.inputElement.value || "").toLowerCase()), this._suggestItems.length == 0 ? this.hide() : (this._tokenList.itemCount = this._suggestItems.length, this._tokenList.items = []));
28
38
  }
29
39
  filterItems(e) {
30
40
  const t = this.notSelectedTokensProvider();
@@ -32,7 +42,7 @@ class D {
32
42
  }
33
43
  hide() {
34
44
  var e;
35
- this._suggestItems = [], this._tokenList.items = [], (e = this._popover) == null || e.hide();
45
+ this._suggestItems = [], this._tokenList.itemCount = 0, this._tokenList.items = [], (e = this._popover) == null || e.hide();
36
46
  }
37
47
  get list() {
38
48
  return this._tokenList;
@@ -41,7 +51,7 @@ class D {
41
51
  return this._popover || (this._popover = this.createPopover(), this.initializeCallback(this)), this._popover;
42
52
  }
43
53
  createPopover() {
44
- const e = new _();
54
+ const e = new C();
45
55
  return e.setAttribute("trigger-type", "manual"), e.setAttribute("placement", "bottom-start"), e.setAttribute("modal", ""), e.setAttribute("popover-for", "token-autosuggest-popover"), e.setAttribute("offset", "-2"), e.targetElement = this.inputElement, e.appendChild(this._tokenList), e;
46
56
  }
47
57
  get isOpened() {
@@ -51,25 +61,25 @@ class D {
51
61
  return this._suggestItems[this._tokenList.focusIndex];
52
62
  }
53
63
  }
54
- const O = ":host{flex-shrink:0;max-width:100%}.container{display:flex;height:28px;background-color:var(--token-background-color, #f3f3f3);border:var(--token-border);box-sizing:border-box}.container .icon-wrapper{display:flex;flex-shrink:0;justify-content:center;align-items:center;width:28px;height:100%;overflow:hidden;background-color:var(--token-icon-background-color, transparent)}.container .icon-wrapper .icon{height:100%;width:100%;object-fit:contain;background-size:cover;background-repeat:no-repeat;background-position:center}.container .value{display:inline-block;align-self:center;padding:0 8px;font-family:Segoe UI,Lucida Sans,Arial,sans-serif;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.container .delete-button-wrapper{display:flex;align-self:center;height:16px;width:16px;padding-right:8px;opacity:.5}.container .delete-button-wrapper:hover{cursor:pointer;filter:brightness(10%);opacity:1}", M = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\r
64
+ const q = ":host{flex-shrink:0;max-width:100%}.container{display:flex;height:28px;background-color:var(--token-background-color, #f3f3f3);border:var(--token-border);box-sizing:border-box}.container .icon-wrapper{display:flex;flex-shrink:0;justify-content:center;align-items:center;width:28px;height:100%;overflow:hidden;background-color:var(--token-icon-background-color, transparent)}.container .icon-wrapper .icon{height:100%;width:100%;object-fit:contain;background-size:cover;background-repeat:no-repeat;background-position:center}.container .value{display:inline-block;align-self:center;padding:0 8px;font-family:Segoe UI,Lucida Sans,Arial,sans-serif;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.container .delete-button-wrapper{display:flex;align-self:center;height:16px;width:16px;padding-right:8px;opacity:.5}.container .delete-button-wrapper:hover{cursor:pointer;filter:brightness(10%);opacity:1}", M = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\r
55
65
  <path d="m3.5 12.5 9-9m-9 0 9 9" style="fill:none;stroke:#333;stroke-linecap:square;stroke-width:1.1px"/>\r
56
66
  </svg>`;
57
- var $ = Object.defineProperty, q = Object.getOwnPropertyDescriptor, g = (o, e, t, i) => {
58
- for (var s = i > 1 ? void 0 : i ? q(e, t) : e, n = o.length - 1, r; n >= 0; n--)
59
- (r = o[n]) && (s = (i ? r(e, t, s) : r(s)) || s);
60
- return i && s && $(e, t, s), s;
67
+ var $ = Object.defineProperty, R = Object.getOwnPropertyDescriptor, g = (r, e, t, i) => {
68
+ for (var n = i > 1 ? void 0 : i ? R(e, t) : e, s = r.length - 1, o; s >= 0; s--)
69
+ (o = r[s]) && (n = (i ? o(e, t, n) : o(n)) || n);
70
+ return i && n && $(e, t, n), n;
61
71
  };
62
- const x = {
63
- fromAttribute: (o) => o == "true",
64
- toAttribute: (o) => o
72
+ const w = {
73
+ fromAttribute: (r) => r == "true",
74
+ toAttribute: (r) => r
65
75
  };
66
76
  var u;
67
- const p = (u = class extends b {
77
+ const p = (u = class extends x {
68
78
  constructor() {
69
79
  super(...arguments), this.value = "", this.type = "", this.icon = "", this.iconPlaceholder = "", this.iconBackgroundColor = "", this._checked = !1;
70
80
  }
71
81
  static get styles() {
72
- return T(O);
82
+ return T(q);
73
83
  }
74
84
  set checked(e) {
75
85
  const t = this._checked;
@@ -88,29 +98,29 @@ const p = (u = class extends b {
88
98
  });
89
99
  }
90
100
  render() {
91
- return v`
101
+ return m`
92
102
  <div class="container">
93
103
  <slot name="before-icon"></slot>
94
104
  ${this.renderIcon()}
95
105
  <slot name="after-icon"></slot>
96
106
  <div class="value">${this.value}</div>
97
- ${this.disabled ? w : v` <div class="delete-button-wrapper">${P(M)}</div> `}
107
+ ${this.disabled ? I : m` <div class="delete-button-wrapper">${P(M)}</div> `}
98
108
  </div>
99
109
  `;
100
110
  }
101
111
  renderIcon() {
102
112
  if (this.icon || this.iconPlaceholder) {
103
113
  const e = this.iconBackgroundColor != null ? `--token-icon-background-color: ${this.iconBackgroundColor}` : void 0;
104
- return v`
114
+ return m`
105
115
  <div class="icon-wrapper" style="${A(e)}" role="img">
106
116
  <div class="icon"></div>
107
117
  </div>
108
118
  `;
109
119
  }
110
- return w;
120
+ return I;
111
121
  }
112
122
  updated(e) {
113
- super.updated(e), (e.has("icon") || e.has("iconPlaceholder")) && (this.icon || this.iconPlaceholder) && L.showImage(this.shadowRoot.querySelector(".icon"), this.icon, this.iconPlaceholder), e.has("disabled") && !this.disabled && this.checked && (this.checked = !1);
123
+ super.updated(e), (e.has("icon") || e.has("iconPlaceholder")) && (this.icon || this.iconPlaceholder) && D.showImage(this.shadowRoot.querySelector(".icon"), this.icon, this.iconPlaceholder), e.has("disabled") && !this.disabled && this.checked && (this.checked = !1);
114
124
  }
115
125
  setClickHandler(e) {
116
126
  this._tokenClickHandler = e;
@@ -137,21 +147,21 @@ g([
137
147
  a({ type: String })
138
148
  ], p.prototype, "iconBackgroundColor", 2);
139
149
  g([
140
- a({ converter: x, reflect: !0, attribute: "aria-disabled" })
150
+ a({ converter: w, reflect: !0, attribute: "aria-disabled" })
141
151
  ], p.prototype, "disabled", 2);
142
152
  g([
143
- a({ converter: x, reflect: !0, attribute: "aria-current" })
153
+ a({ converter: w, reflect: !0, attribute: "aria-current" })
144
154
  ], p.prototype, "current", 2);
145
155
  g([
146
- a({ converter: x, reflect: !0, attribute: "aria-checked" })
156
+ a({ converter: w, reflect: !0, attribute: "aria-checked" })
147
157
  ], p.prototype, "checked", 1);
148
- let k = p;
149
- const G = (o, e) => {
150
- const t = document.createElement(k.ID);
151
- return o && (t.value = o.caption, t.type = o.type, t.icon = o.icon, t.iconPlaceholder = o.iconPlaceholder, t.iconBackgroundColor = o.iconBackgroundColor, t.disabled = o.disabled, t.index = e), t;
158
+ let b = p;
159
+ const G = (r, e) => {
160
+ const t = document.createElement(b.ID);
161
+ return r && (t.value = r.caption, t.type = r.type, t.icon = r.icon, t.iconPlaceholder = r.iconPlaceholder, t.iconBackgroundColor = r.iconBackgroundColor, t.disabled = r.disabled, t.index = e), t;
152
162
  };
153
- k.ensureDefined();
154
- const m = "web application/json";
163
+ b.ensureDefined();
164
+ const k = "web application/json";
155
165
  class B {
156
166
  constructor(e, t, i) {
157
167
  navigator.clipboard && (e.addEventListener("copy", () => {
@@ -165,16 +175,16 @@ class B {
165
175
  writeToClipboard(e) {
166
176
  const t = e.querySelectorAll("[slot='items'][aria-checked='true']"), i = [];
167
177
  if (t.length > 0)
168
- t.forEach((s) => i.push(s.index));
178
+ t.forEach((n) => i.push(n.index));
169
179
  else if (e.activeTokenIndex != -1) {
170
- const s = e.activeTokenElement;
171
- s && i.push(s.index);
180
+ const n = e.activeTokenElement;
181
+ n && i.push(n.index);
172
182
  }
173
183
  if (i.length > 0) {
174
- const s = JSON.stringify(i.map((r) => e.items[r])), n = new Blob([s], { type: m });
184
+ const n = JSON.stringify(i.map((o) => e.items[o])), s = new Blob([n], { type: k });
175
185
  navigator.clipboard.write([
176
186
  new ClipboardItem({
177
- [m]: n
187
+ [k]: s
178
188
  })
179
189
  ]);
180
190
  }
@@ -182,9 +192,9 @@ class B {
182
192
  async readFromClipboard(e) {
183
193
  const t = await navigator.clipboard.read();
184
194
  for (const i of t)
185
- if (i.types.includes(m)) {
186
- const n = await (await i.getType(m)).text(), r = JSON.parse(n);
187
- Array.isArray(r) && e(r);
195
+ if (i.types.includes(k)) {
196
+ const s = await (await i.getType(k)).text(), o = JSON.parse(s);
197
+ Array.isArray(o) && e(o);
188
198
  }
189
199
  }
190
200
  }
@@ -192,44 +202,47 @@ const F = ":host{display:flex;contain:layout style}:host .additonal-content::slo
192
202
  class H {
193
203
  constructor(e, t) {
194
204
  this.tokenSelector = e;
195
- let i = [];
196
- const s = (n) => {
197
- const r = n.target;
198
- e.contains(r) || e.removeTokens(i), i = [];
205
+ const i = /* @__PURE__ */ new Map(), n = (s) => {
206
+ const o = s.target;
207
+ if (!e.contains(o)) {
208
+ const d = s.addedIndexes;
209
+ d && e.removeTokens(d.map((v) => i.get(v)));
210
+ }
211
+ i.clear();
199
212
  };
200
- e.addEventListener("dragstart", (n) => {
201
- const r = n.target;
202
- if (r instanceof k) {
203
- if (r.disabled) {
204
- n.preventDefault();
213
+ e.addEventListener("dragstart", (s) => {
214
+ const o = s.target;
215
+ if (o instanceof b) {
216
+ if (o.disabled) {
217
+ s.preventDefault();
205
218
  return;
206
219
  }
207
- r.setAttribute("aria-checked", "true");
208
- const l = e.querySelectorAll("[slot='items'][aria-checked='true']");
209
- if (l.length > 0) {
210
- const y = Array.from(l).filter((f) => !f.disabled).map((f) => (i.push(f.index), e.items[f.index]));
211
- if (n.dataTransfer.setData("text/plain", JSON.stringify(y)), n.dataTransfer.dropEffect = "move", n.dataTransfer.effectAllowed = "move", l.length > 1) {
212
- const f = this.createCustomDragImage(r, y.length);
213
- n.dataTransfer.setDragImage(f, -14, -14);
220
+ o.setAttribute("aria-checked", "true");
221
+ const d = e.querySelectorAll("[slot='items'][aria-checked='true']");
222
+ if (d.length > 0) {
223
+ const v = Array.from(d).filter((f) => !f.disabled).map((f, E) => (i.set(E, f.index), e.items[f.index]));
224
+ if (s.dataTransfer.setData("text/sd-token-selector", JSON.stringify(v)), s.dataTransfer.dropEffect = "move", s.dataTransfer.effectAllowed = "move", d.length > 1) {
225
+ const f = this.createCustomDragImage(o, v.length);
226
+ s.dataTransfer.setDragImage(f, -14, -14);
214
227
  }
215
- window.addEventListener("drop", s, { capture: !0, once: !0 });
228
+ window.addEventListener("drop", n, { once: !0 });
216
229
  }
217
230
  }
218
- }), e.addEventListener("dragenter", (n) => {
219
- e.setAttribute("drop", ""), n.preventDefault();
220
- }), e.addEventListener("dragover", (n) => n.preventDefault()), e.addEventListener("dragleave", (n) => {
221
- n.target == e && e.removeAttribute("drop");
222
- }), e.addEventListener("drop", (n) => {
231
+ }), e.addEventListener("dragenter", (s) => {
232
+ e.setAttribute("drop", ""), s.preventDefault();
233
+ }), e.addEventListener("dragover", (s) => s.preventDefault()), e.addEventListener("dragleave", (s) => {
234
+ s.target == e && e.removeAttribute("drop");
235
+ }), e.addEventListener("drop", (s) => {
223
236
  e.removeAttribute("drop");
224
- const r = n.dataTransfer.getData("text/plain");
225
- if (r)
237
+ const o = s.dataTransfer.getData("text/sd-token-selector");
238
+ if (o)
226
239
  try {
227
- const l = JSON.parse(r);
228
- Array.isArray(l) && (t(l), n.preventDefault());
240
+ const d = JSON.parse(o);
241
+ Array.isArray(d) && (s.addedIndexes = t(d), s.preventDefault());
229
242
  } catch {
230
243
  }
231
244
  }), e.addEventListener("dragend", () => {
232
- window.removeEventListener("drop", s), i = [];
245
+ window.removeEventListener("drop", n), i.clear();
233
246
  });
234
247
  }
235
248
  createCustomDragImage(e, t) {
@@ -237,14 +250,14 @@ class H {
237
250
  if (i.setAttribute("aria-disabled", "true"), this.tokenSelector.tokenType)
238
251
  i.value = t + " " + this.tokenSelector.tokenType;
239
252
  else {
240
- const s = document.createElement("div");
241
- s.innerText = "+" + (t - 1), Object.assign(s.style, {
253
+ const n = document.createElement("div");
254
+ n.innerText = "+" + (t - 1), Object.assign(n.style, {
242
255
  position: "absolute",
243
256
  left: "90%",
244
257
  top: "75%"
245
258
  });
246
- const n = document.createElement("div");
247
- n.appendChild(i), n.appendChild(s), i = n;
259
+ const s = document.createElement("div");
260
+ s.appendChild(i), s.appendChild(n), i = s;
248
261
  }
249
262
  return Object.assign(i.style, {
250
263
  height: e.offsetHeight,
@@ -258,21 +271,21 @@ class H {
258
271
  }), i.slot = "items", this.tokenSelector.appendChild(i), requestAnimationFrame(() => i.remove()), i;
259
272
  }
260
273
  }
261
- var N = Object.defineProperty, j = Object.getOwnPropertyDescriptor, c = (o, e, t, i) => {
262
- for (var s = i > 1 ? void 0 : i ? j(e, t) : e, n = o.length - 1, r; n >= 0; n--)
263
- (r = o[n]) && (s = (i ? r(e, t, s) : r(s)) || s);
264
- return i && s && N(e, t, s), s;
274
+ var N = Object.defineProperty, j = Object.getOwnPropertyDescriptor, h = (r, e, t, i) => {
275
+ for (var n = i > 1 ? void 0 : i ? j(e, t) : e, s = r.length - 1, o; s >= 0; s--)
276
+ (o = r[s]) && (n = (i ? o(e, t, n) : o(n)) || n);
277
+ return i && n && N(e, t, n), n;
265
278
  };
266
- function K(o, e) {
279
+ function K(r, e) {
267
280
  let t;
268
281
  return function(...i) {
269
- t != null && clearTimeout(t), t = window.setTimeout(() => o(...i), e);
282
+ t != null && clearTimeout(t), t = window.setTimeout(() => r(...i), e);
270
283
  };
271
284
  }
272
- var R = /* @__PURE__ */ ((o) => (o.RemoveOnly = "remove-only", o.Multi = "multi", o))(R || {}), h;
273
- const d = (h = class extends b {
285
+ var V = /* @__PURE__ */ ((r) => (r.RemoveOnly = "remove-only", r.Multi = "multi", r))(V || {}), c;
286
+ const l = (c = class extends x {
274
287
  constructor() {
275
- super(...arguments), this.selectionMode = "multi", this.items = [], this.selectedIndexes = [], this._tokenGenerator = G, this._autoSuggestItemGenerator = S, this.additionalTokenCommittingKeys = [], this._activeTokenIndex = -1, this.handleInputKeyDown = (e, t) => {
288
+ super(...arguments), this.selectionMode = "multi", this.items = [], this.selectedIndexes = [], this._tokenGenerator = G, this._autoSuggestItemGenerator = _, this.additionalTokenCommittingKeys = [], this._activeTokenIndex = -1, this.handleInputKeyDown = (e, t) => {
276
289
  if ((e.key === "Enter" || this.additionalTokenCommittingKeys.includes(e.key)) && t.value) {
277
290
  e.preventDefault(), e.stopPropagation(), this.commitTokenValue(t.value);
278
291
  return;
@@ -324,8 +337,8 @@ const d = (h = class extends b {
324
337
  const t = this.inputElement;
325
338
  if (!t || !t.value)
326
339
  return;
327
- e.composedPath().some((s) => {
328
- if (s instanceof HTMLElement && (e.composedPath().indexOf(t) > -1 || s.getAttribute("popover-for") === "token-autosuggest-popover"))
340
+ e.composedPath().some((n) => {
341
+ if (n instanceof HTMLElement && (e.composedPath().indexOf(t) > -1 || n.getAttribute("popover-for") === "token-autosuggest-popover"))
329
342
  return !0;
330
343
  }) || this.commitTokenValue(t.value);
331
344
  }, this.debouncedShowTokenSuggestPopover = K(this.showFilteredTokenSuggestions.bind(this), 200);
@@ -355,14 +368,14 @@ const d = (h = class extends b {
355
368
  this.inputElement ? this.inputElement.focus() : this.shadowRoot.querySelector(".container").focus();
356
369
  }
357
370
  render() {
358
- return this.selectionMode == "remove-only" ? v`<div class="container" tabindex="0">
371
+ return this.selectionMode == "remove-only" ? m`<div class="container" tabindex="0">
359
372
  <slot name="items"
360
- >${this.placeholder ? v`<span part="remove-only-placeholder" class="placeholder"
373
+ >${this.placeholder ? m`<span part="remove-only-placeholder" class="placeholder"
361
374
  >${this.placeholder}</span
362
- >` : w}</slot
375
+ >` : I}</slot
363
376
  >
364
377
  </div>
365
- <slot class="additonal-content" name="additional-content"></slot>` : v`
378
+ <slot class="additonal-content" name="additional-content"></slot>` : m`
366
379
  <sd-lit-input
367
380
  class="input"
368
381
  .extendedPrefix=${!0}
@@ -383,7 +396,7 @@ const d = (h = class extends b {
383
396
  super.firstUpdated(e), this.setAttribute("role", "listbox"), this.setAttribute("aria-multiselectable", "true"), this.hasAttribute("tabIndex") || (this.tabIndex = 0), this.addEventListener("focusout", (t) => {
384
397
  const i = t.relatedTarget;
385
398
  !this.contains(i) && !this.shadowRoot.contains(i) && this.querySelectorAll("[slot='items'][aria-checked='true']").forEach(
386
- (s) => s.checked = !1
399
+ (n) => n.checked = !1
387
400
  );
388
401
  }), new B(
389
402
  this,
@@ -395,11 +408,11 @@ const d = (h = class extends b {
395
408
  ), new H(this, (t) => this.addMatchingItems(t));
396
409
  }
397
410
  addMatchingItems(e) {
398
- const t = e.map((i) => {
399
- const s = i.caption == null ? -1 : this.findIndex(i);
400
- return s != -1 && !this.items[s].disabled && !this.selectedIndexes.includes(s) ? s : -1;
401
- }).filter((i) => i != -1);
402
- t.length > 0 && this.handleTokenSelection(t);
411
+ const t = [], i = e.map((n, s) => {
412
+ const o = n.caption == null ? -1 : this.findIndex(n);
413
+ return o != -1 && !this.items[o].disabled && !this.selectedIndexes.includes(o) ? (t.push(s), o) : -1;
414
+ }).filter((n) => n != -1);
415
+ return i.length > 0 && this.handleTokenSelection(i), t;
403
416
  }
404
417
  removeSelectionOrActiveToken() {
405
418
  if (!this.disabled) {
@@ -424,8 +437,8 @@ const d = (h = class extends b {
424
437
  const i = this.tokenSuggestPopover.focusedSuggestToken;
425
438
  if (i) {
426
439
  if (!i.disabled) {
427
- const s = this.findIndex(i);
428
- this.handleTokenSelection([s]), this.tokenSuggestPopover.hide();
440
+ const n = this.findIndex(i);
441
+ this.handleTokenSelection([n]), this.tokenSuggestPopover.hide();
429
442
  }
430
443
  return;
431
444
  }
@@ -457,7 +470,7 @@ const d = (h = class extends b {
457
470
  return !this.selectedIndexes.includes(e);
458
471
  }
459
472
  get tokenSuggestPopover() {
460
- return !this._tokenSuggestPopover && this.inputElement && (this._tokenSuggestPopover = new D(
473
+ return !this._tokenSuggestPopover && this.inputElement && (this._tokenSuggestPopover = new O(
461
474
  this.inputElement,
462
475
  () => this.items.filter((e, t) => !e.disabled && this.isTokenNotSelected(t)),
463
476
  (e) => {
@@ -475,18 +488,18 @@ const d = (h = class extends b {
475
488
  if (!this.isConnected || !this.items)
476
489
  return;
477
490
  const e = this.inputElement;
478
- e && (!this._tokenSuggestPopover || !this._tokenSuggestPopover.isOpened) && (e.value = ""), this.querySelectorAll("[slot='items']").forEach((s) => {
479
- this.removeChild(s);
491
+ e && (!this._tokenSuggestPopover || !this._tokenSuggestPopover.isOpened) && (e.value = ""), this.querySelectorAll("[slot='items']").forEach((n) => {
492
+ this.removeChild(n);
480
493
  });
481
494
  const t = document.createDocumentFragment();
482
495
  let i = [];
483
- this.selectionMode == "remove-only" ? i = this.items.map((s) => this.disableIfNeeded(s)) : this.selectedIndexes.forEach((s) => {
484
- i.push(this.disableIfNeeded(this.items[s]));
485
- }), i.forEach((s) => {
486
- const n = this.tokenGenerator(s, this.findIndex(s));
487
- n.slot = "items", t.appendChild(n), n.id || (n.id = window.crypto.getRandomValues(new Uint32Array(1))[0].toString(16)), n.setClickHandler(() => this.onTokenClick(n, !0)), n.addEventListener("click", () => {
496
+ this.selectionMode == "remove-only" ? i = this.items.map((n) => this.disableIfNeeded(n)) : this.selectedIndexes.forEach((n) => {
497
+ i.push(this.disableIfNeeded(this.items[n]));
498
+ }), i.forEach((n) => {
499
+ const s = this.tokenGenerator(n, this.findIndex(n));
500
+ s.slot = "items", t.appendChild(s), s.id || (s.id = window.crypto.getRandomValues(new Uint32Array(1))[0].toString(16)), s.setClickHandler(() => this.onTokenClick(s, !0)), s.addEventListener("click", () => {
488
501
  document.activeElement != this && this.focus();
489
- }), n.setDeleteHandler((r) => this.removeTokens([r]));
502
+ }), s.setDeleteHandler((o) => this.removeTokens([o]));
490
503
  }), this.appendChild(t), this._tokenSuggestPopover && this._tokenSuggestPopover.refreshItems();
491
504
  }
492
505
  removeTokens(e) {
@@ -507,8 +520,8 @@ const d = (h = class extends b {
507
520
  }
508
521
  onTokenClick(e, t) {
509
522
  let i;
510
- this.querySelectorAll("[slot='items']").forEach((s, n) => {
511
- e == s ? i = n : s.setAttribute("aria-checked", "false");
523
+ this.querySelectorAll("[slot='items']").forEach((n, s) => {
524
+ e == n ? i = s : n.setAttribute("aria-checked", "false");
512
525
  }), this.activeTokenIndex = i, this.setAttribute("aria-activedescendant", this.activeTokenElement.id), this._tokenSuggestPopover && this._tokenSuggestPopover.isOpened && this._tokenSuggestPopover.hide(), this.dispatchEvent(
513
526
  new CustomEvent("token-clicked", {
514
527
  detail: {
@@ -572,59 +585,59 @@ const d = (h = class extends b {
572
585
  var e;
573
586
  return !!((e = this.inputElement) != null && e.value);
574
587
  }
575
- }, h.ID = "sd-token-selector", h.ensureDefined = () => {
576
- k.ensureDefined(), customElements.get(h.ID) || customElements.define(h.ID, h);
577
- }, h.shadowRootOptions = {
578
- ...b.shadowRootOptions,
588
+ }, c.ID = "sd-token-selector", c.ensureDefined = () => {
589
+ b.ensureDefined(), customElements.get(c.ID) || customElements.define(c.ID, c);
590
+ }, c.shadowRootOptions = {
591
+ ...x.shadowRootOptions,
579
592
  delegatesFocus: !0
580
- }, h);
581
- c([
593
+ }, c);
594
+ h([
582
595
  a({ type: String, attribute: "selection-mode", reflect: !0 })
583
- ], d.prototype, "selectionMode", 2);
584
- c([
596
+ ], l.prototype, "selectionMode", 2);
597
+ h([
585
598
  a({ type: Array, attribute: !1 })
586
- ], d.prototype, "items", 2);
587
- c([
599
+ ], l.prototype, "items", 2);
600
+ h([
588
601
  a({ type: Array, attribute: !1 })
589
- ], d.prototype, "selectedIndexes", 2);
590
- c([
602
+ ], l.prototype, "selectedIndexes", 2);
603
+ h([
591
604
  a({ type: String, reflect: !0 })
592
- ], d.prototype, "placeholder", 2);
593
- c([
605
+ ], l.prototype, "placeholder", 2);
606
+ h([
594
607
  a({ type: String, reflect: !0, attribute: "suggest-list-class" })
595
- ], d.prototype, "suggestListClass", 2);
596
- c([
608
+ ], l.prototype, "suggestListClass", 2);
609
+ h([
597
610
  a({ type: String, reflect: !0, attribute: "input-label" })
598
- ], d.prototype, "inputLabel", 2);
599
- c([
611
+ ], l.prototype, "inputLabel", 2);
612
+ h([
600
613
  a({
601
614
  converter: {
602
- fromAttribute: (o) => o == "true",
603
- toAttribute: (o) => o
615
+ fromAttribute: (r) => r == "true",
616
+ toAttribute: (r) => r
604
617
  },
605
618
  reflect: !0,
606
619
  attribute: "aria-disabled"
607
620
  })
608
- ], d.prototype, "disabled", 2);
609
- c([
621
+ ], l.prototype, "disabled", 2);
622
+ h([
610
623
  a({ type: String, attribute: !0 })
611
- ], d.prototype, "validationMessage", 2);
612
- c([
624
+ ], l.prototype, "validationMessage", 2);
625
+ h([
613
626
  a({ type: String, attribute: !0 })
614
- ], d.prototype, "validationIconSrc", 2);
615
- c([
616
- a({ converter: E.levelConverter, attribute: !0, reflect: !0 })
617
- ], d.prototype, "validationLevel", 2);
618
- c([
627
+ ], l.prototype, "validationIconSrc", 2);
628
+ h([
629
+ a({ converter: S.levelConverter, attribute: !0, reflect: !0 })
630
+ ], l.prototype, "validationLevel", 2);
631
+ h([
619
632
  a({ type: String, reflect: !0, attribute: "token-type" })
620
- ], d.prototype, "tokenType", 2);
621
- c([
633
+ ], l.prototype, "tokenType", 2);
634
+ h([
622
635
  a({ type: Boolean, reflect: !0, attribute: "case-sensitive" })
623
- ], d.prototype, "caseSensitive", 2);
624
- let ie = d;
636
+ ], l.prototype, "caseSensitive", 2);
637
+ let se = l;
625
638
  export {
626
- R as SelectionMode,
627
- ie as default,
639
+ V as SelectionMode,
640
+ se as default,
628
641
  G as generator
629
642
  };
630
643
  //# sourceMappingURL=token-selector.mjs.map