@telperion/elements 3.0.3 → 4.1.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 (78) hide show
  1. package/.build-manifest.json +12 -1
  2. package/README.md +45 -0
  3. package/_chunks/signal-watcher-lit-element-B9xodkLt.d.cts +29 -0
  4. package/_chunks/signal-watcher-lit-element-B9xodkLt.d.ts +29 -0
  5. package/drag-drop/drag-handle-element.cjs +1 -1
  6. package/drag-drop/drag-handle-element.js +1 -1
  7. package/fesm/elements.mjs +610 -30
  8. package/fesm/elements.mjs.map +1 -1
  9. package/iife/elements.js +192 -21
  10. package/iife/elements.js.map +1 -1
  11. package/iife/popover/index.js +44 -6
  12. package/iife/popover/index.js.map +1 -1
  13. package/iife/router/index.js.map +1 -1
  14. package/iife/select/index.js +278 -0
  15. package/iife/select/index.js.map +1 -0
  16. package/index.cjs +17 -0
  17. package/index.cjs.map +1 -1
  18. package/index.d.cts +2 -0
  19. package/index.d.ts +2 -0
  20. package/index.js +4 -0
  21. package/index.js.map +1 -1
  22. package/package.json +32 -5
  23. package/popover/index.d.cts +1 -1
  24. package/popover/index.d.ts +1 -1
  25. package/popover/popover-element.cjs +28 -18
  26. package/popover/popover-element.cjs.map +1 -1
  27. package/popover/popover-element.js +29 -19
  28. package/popover/popover-element.js.map +1 -1
  29. package/router/index.d.cts +2 -26
  30. package/router/index.d.ts +2 -26
  31. package/router/tha-router-config.cjs +2 -2
  32. package/router/tha-router-config.cjs.map +1 -1
  33. package/router/tha-router-config.js +2 -2
  34. package/router/tha-router-config.js.map +1 -1
  35. package/router/tha-router-link.cjs +1 -1
  36. package/router/tha-router-link.js +1 -1
  37. package/router/tha-router-outlet.cjs +1 -1
  38. package/router/tha-router-outlet.js +1 -1
  39. package/router/tha-router-param.cjs +1 -1
  40. package/router/tha-router-param.js +1 -1
  41. package/router/tha-router.cjs +1 -1
  42. package/router/tha-router.js +1 -1
  43. package/select/index.cjs +23 -0
  44. package/select/index.cjs.map +1 -0
  45. package/select/index.d.cts +284 -0
  46. package/select/index.d.ts +284 -0
  47. package/select/index.js +5 -0
  48. package/select/index.js.map +1 -0
  49. package/select/internal-props.cjs +10 -0
  50. package/select/internal-props.cjs.map +1 -0
  51. package/select/internal-props.js +6 -0
  52. package/select/internal-props.js.map +1 -0
  53. package/select/option.element.cjs +88 -0
  54. package/select/option.element.cjs.map +1 -0
  55. package/select/option.element.js +88 -0
  56. package/select/option.element.js.map +1 -0
  57. package/select/select-change-event.cjs +30 -0
  58. package/select/select-change-event.cjs.map +1 -0
  59. package/select/select-change-event.js +28 -0
  60. package/select/select-change-event.js.map +1 -0
  61. package/select/select-context.cjs +14 -0
  62. package/select/select-context.cjs.map +1 -0
  63. package/select/select-context.js +12 -0
  64. package/select/select-context.js.map +1 -0
  65. package/select/select.element.cjs +414 -0
  66. package/select/select.element.cjs.map +1 -0
  67. package/select/select.element.js +414 -0
  68. package/select/select.element.js.map +1 -0
  69. package/select/selected-content.element.cjs +65 -0
  70. package/select/selected-content.element.cjs.map +1 -0
  71. package/select/selected-content.element.js +65 -0
  72. package/select/selected-content.element.js.map +1 -0
  73. package/utils/signal-watcher-lit-element.cjs.map +1 -0
  74. package/utils/signal-watcher-lit-element.js.map +1 -0
  75. package/router/signal-watcher-lit-element.cjs.map +0 -1
  76. package/router/signal-watcher-lit-element.js.map +0 -1
  77. /package/{router → utils}/signal-watcher-lit-element.cjs +0 -0
  78. /package/{router → utils}/signal-watcher-lit-element.js +0 -0
@@ -0,0 +1,414 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { PopoverElement } from '../popover/popover-element.js';
3
+ import { provide } from '@lit/context';
4
+ import { signal, computed } from '@lit-labs/signals';
5
+ import { css, html } from 'lit';
6
+ import { property, customElement } from 'lit/decorators.js';
7
+ import { sliceBefore } from '@telperion/js-utils/array/slice-before';
8
+ import { selectContext } from './select-context.js';
9
+ import { SelectedContentElement } from './selected-content.element.js';
10
+ import { OptionElement } from './option.element.js';
11
+ import { REGISTER_OPTION, UNREGISTER_OPTION } from './internal-props.js';
12
+ import { SelectChangeEvent } from './select-change-event.js';
13
+ import { defer } from '@telperion/js-utils/function/defer';
14
+ import { SignalWatcherLitElement } from '../utils/signal-watcher-lit-element.js';
15
+
16
+ var SelectElement_1;
17
+ let SelectElement = class SelectElement extends SignalWatcherLitElement {
18
+ static { SelectElement_1 = this; }
19
+ static { this.formAssociated = true; }
20
+ static { this.ALLOWED_OPTION_ELEMENTS = [OptionElement]; }
21
+ static { this.styles = css `
22
+ :host {
23
+ position: relative;
24
+ display: inline-flex;
25
+ height: fit-content;
26
+
27
+ --tp-select-option-color: white;
28
+ --tp-select-selection-color: #0078d4;
29
+ --tp-select-highlight-percent: 20%;
30
+ --tp-select-selection-contrast-color: white;
31
+ }
32
+
33
+ :host([disabled]) {
34
+ pointer-events: none;
35
+ opacity: 0.6;
36
+ }
37
+
38
+ :host([open]) {
39
+ [pseudo="indicator"] {
40
+ transform: rotateX(180deg);
41
+ }
42
+ }
43
+
44
+ [pseudo="button"] {
45
+ background: white;
46
+ cursor: pointer;
47
+ display: inline-flex;
48
+ align-items: center;
49
+ padding: 0.25em 0.5em;
50
+
51
+ tp-selected-content {
52
+ margin-inline-end: 0.5em;
53
+ }
54
+ }
55
+
56
+ [pseudo="indicator"] {
57
+ margin-inline-start: auto;
58
+ }
59
+
60
+ tp-popover {
61
+ border: none;
62
+ padding: 0;
63
+ }
64
+ `; }
65
+ #options;
66
+ #value;
67
+ get value() {
68
+ return this.#value.get();
69
+ }
70
+ set value(next) {
71
+ defer(() => {
72
+ const values = next.split(",").map((s) => s.trim());
73
+ const options = Array.from(this.#options);
74
+ this.selectedOptions.set(values
75
+ .map((value) => options.find((option) => option.value === value))
76
+ .filter(Boolean)
77
+ .map((option) => new WeakRef(option)));
78
+ });
79
+ }
80
+ #placeholder;
81
+ get placeholder() {
82
+ return this.#placeholder.get();
83
+ }
84
+ set placeholder(next) {
85
+ this.#signalSetter(this.#placeholder, "placeholder", next);
86
+ }
87
+ #internals;
88
+ /** Initial `value` captured at construction so `formResetCallback` can restore it. */
89
+ #initialValue;
90
+ /**
91
+ * Last `value` for which a `change` event was emitted (or considered for
92
+ * emission). `null` means "no sync has happened yet" — used to suppress
93
+ * the very first `willUpdate` so we don't emit a phantom change on mount.
94
+ */
95
+ #lastEmittedValue;
96
+ constructor() {
97
+ super();
98
+ this.#options = new Set();
99
+ /**
100
+ * Provides this `<tp-select>` instance to descendants via `@lit/context`,
101
+ * so consumers (e.g. `<tp-selected-content>`) can find it across any
102
+ * number of shadow DOM boundaries — not just light-DOM ancestors.
103
+ */
104
+ this.self = this;
105
+ this.selectedOptions = signal([]);
106
+ this.#value = computed(() => this.selectedOptions
107
+ .get()
108
+ .map((ref) => ref.deref()?.value ?? "")
109
+ .filter(Boolean)
110
+ .join(","));
111
+ this.#placeholder = signal("Select an option");
112
+ /**
113
+ * Maximum number of options that can be selected at once.
114
+ *
115
+ * Defaults to `1` (single-select). Any positive integer enables
116
+ * multi-select up to that many entries. Use the literal string
117
+ * `"infinite"` in HTML to allow an unbounded
118
+ * selection — the converter normalises it to `Number.POSITIVE_INFINITY`.
119
+ *
120
+ * When the limit is reached and a new option is selected, the oldest
121
+ * entry in `selectedOptions` is dropped (FIFO) so the new selection can
122
+ * fit. Setting `max` to a smaller number trims the current selection
123
+ * down to size from the end.
124
+ */
125
+ this.max = 1;
126
+ /** Form field name. Submitted with the owning `<form>`. */
127
+ this.name = null;
128
+ /** When true, the element is non-interactive and excluded from form submission. */
129
+ this.disabled = false;
130
+ /** When true, an empty selection makes the element invalid (`valueMissing`). */
131
+ this.required = false;
132
+ this.open = false;
133
+ /** Initial `value` captured at construction so `formResetCallback` can restore it. */
134
+ this.#initialValue = "";
135
+ /**
136
+ * Last `value` for which a `change` event was emitted (or considered for
137
+ * emission). `null` means "no sync has happened yet" — used to suppress
138
+ * the very first `willUpdate` so we don't emit a phantom change on mount.
139
+ */
140
+ this.#lastEmittedValue = null;
141
+ this.#internals = this.attachInternals();
142
+ }
143
+ /** Live `ElementInternals` (validity, form, labels, etc.). */
144
+ get internals() {
145
+ return this.#internals;
146
+ }
147
+ /** Owning `<form>` element, or `null` when not associated. */
148
+ get form() {
149
+ return this.#internals.form;
150
+ }
151
+ /** Native validity state of this control. */
152
+ get validity() {
153
+ return this.#internals.validity;
154
+ }
155
+ get validationMessage() {
156
+ return this.#internals.validationMessage;
157
+ }
158
+ get willValidate() {
159
+ return this.#internals.willValidate;
160
+ }
161
+ checkValidity() {
162
+ return this.#internals.checkValidity();
163
+ }
164
+ reportValidity() {
165
+ return this.#internals.reportValidity();
166
+ }
167
+ createRenderRoot() {
168
+ const root = super.createRenderRoot();
169
+ root.adoptedStyleSheets = [
170
+ ...root.adoptedStyleSheets,
171
+ PopoverElement.styles.styleSheet,
172
+ SelectedContentElement.styles.styleSheet,
173
+ OptionElement.styles.styleSheet,
174
+ ];
175
+ return root;
176
+ }
177
+ connectedCallback() {
178
+ super.connectedCallback();
179
+ this.#initialValue = this.value;
180
+ }
181
+ disconnectedCallback() {
182
+ super.disconnectedCallback();
183
+ }
184
+ render() {
185
+ return html `
186
+ <div pseudo="button" part="button">
187
+ <slot name="button">
188
+ <tp-selected-content part="selected-content"></tp-selected-content>
189
+ <slot name="indicator">
190
+ <span part="indicator" pseudo="indicator">▾</span>
191
+ </slot>
192
+ </slot>
193
+ </div>
194
+ <tp-popover
195
+ position="start to start / bottom"
196
+ target="[pseudo=button]"
197
+ @click=${this.#handlePopoverClick}
198
+ @toggle=${this.#handlePopoverToggle}
199
+ part="popover">
200
+ <slot name="popover">
201
+ <slot></slot>
202
+ </slot>
203
+ </tp-popover>
204
+ `;
205
+ }
206
+ updated(changed) {
207
+ super.updated(changed);
208
+ if (changed.has("max") && Number.isFinite(this.max)) {
209
+ const current = this.selectedOptions.get();
210
+ if (current.length > this.max) {
211
+ this.selectedOptions.set(current.slice(current.length - this.max));
212
+ }
213
+ }
214
+ }
215
+ /**
216
+ * Keep `ElementInternals` in sync with the current value and validity.
217
+ * Reading `this.value` here transitively reads `selectedOptions`, so the
218
+ * `SignalWatcher` base auto-tracks it and re-runs `willUpdate` whenever
219
+ * the selection changes — no `updateEffect` (and no microtask race) needed.
220
+ */
221
+ willUpdate(_changed) {
222
+ this.#syncForm();
223
+ this.#dispatchChange();
224
+ }
225
+ // -- Form-associated callbacks ------------------------------------------
226
+ formResetCallback() {
227
+ this.value = this.#initialValue;
228
+ }
229
+ formDisabledCallback(disabled) {
230
+ this.disabled = disabled;
231
+ }
232
+ formStateRestoreCallback(state) {
233
+ if (state == null) {
234
+ this.value = "";
235
+ return;
236
+ }
237
+ if (typeof state === "string") {
238
+ this.value = state;
239
+ return;
240
+ }
241
+ if (state instanceof FormData) {
242
+ const values = [];
243
+ state.forEach((v) => {
244
+ if (typeof v === "string")
245
+ values.push(v);
246
+ });
247
+ this.value = values.join(",");
248
+ }
249
+ }
250
+ /**
251
+ * Push the current selection into `ElementInternals`. Single-select forms
252
+ * report a string; multi-select forms report a `FormData` with one entry
253
+ * per selected value (so the form serialises the same way as a native
254
+ * `<select multiple>`). Also updates validity for `required`.
255
+ */
256
+ #syncForm() {
257
+ const values = this.value === "" ? [] : this.value.split(",");
258
+ if (this.max === 1) {
259
+ this.#internals.setFormValue(values[0] ?? "");
260
+ }
261
+ else {
262
+ const fd = new FormData();
263
+ const fieldName = this.name ?? "";
264
+ for (const v of values)
265
+ fd.append(fieldName, v);
266
+ this.#internals.setFormValue(fd);
267
+ }
268
+ if (this.required && values.length === 0) {
269
+ this.#internals.setValidity({ valueMissing: true }, "Please select an option.");
270
+ }
271
+ else {
272
+ this.#internals.setValidity({});
273
+ }
274
+ }
275
+ /**
276
+ * Dispatch a `SelectChangeEvent` when the joined value has actually
277
+ * changed. Suppresses the very first sync so consumers don't see a
278
+ * phantom `change` on mount (matches native `<select>` behavior).
279
+ */
280
+ #dispatchChange() {
281
+ const current = this.value;
282
+ if (current === this.#lastEmittedValue)
283
+ return;
284
+ const isInitialSync = this.#lastEmittedValue === null;
285
+ this.#lastEmittedValue = current;
286
+ if (isInitialSync)
287
+ return;
288
+ const selectedOptions = this.selectedOptions
289
+ .get()
290
+ .map(ref => ref.deref())
291
+ .filter(Boolean);
292
+ this.dispatchEvent(new SelectChangeEvent({ value: current, selectedOptions }));
293
+ }
294
+ selectOption(option) {
295
+ const current = this.selectedOptions.get();
296
+ if (current.find(ref => ref.deref() === option))
297
+ return;
298
+ const next = [...current, new WeakRef(option)];
299
+ const trimmed = next.length > this.max
300
+ ? next.slice(next.length - this.max)
301
+ : next;
302
+ this.selectedOptions.set(trimmed);
303
+ }
304
+ deselectOption(option) {
305
+ const optionRef = this.selectedOptions.get().find(ref => ref.deref() === option);
306
+ if (!optionRef)
307
+ return;
308
+ this.selectedOptions.set(this.selectedOptions.get().filter(ref => ref !== optionRef));
309
+ }
310
+ toggleOption(option) {
311
+ const ref = this.selectedOptions.get().find(ref => ref.deref() === option);
312
+ if (ref) {
313
+ this.deselectOption(option);
314
+ }
315
+ else {
316
+ this.selectOption(option);
317
+ }
318
+ }
319
+ [REGISTER_OPTION](option) {
320
+ this.#options.add(option);
321
+ }
322
+ [UNREGISTER_OPTION](option) {
323
+ this.#options.delete(option);
324
+ const selectedOptions = this.selectedOptions.get();
325
+ const optionRef = selectedOptions.find(ref => ref.deref() === option);
326
+ if (!optionRef)
327
+ return;
328
+ this.selectedOptions.set(selectedOptions.filter(ref => ref !== optionRef));
329
+ }
330
+ #handlePopoverClick(e) {
331
+ if (this.disabled)
332
+ return;
333
+ const option = sliceBefore(e.composedPath(), this)
334
+ .find(el => SelectElement_1.ALLOWED_OPTION_ELEMENTS.some(allowed => el instanceof allowed));
335
+ if (!option)
336
+ return;
337
+ this.toggleOption(option);
338
+ const count = this.selectedOptions.get().length;
339
+ // Close the popover when a new selection just filled the quota.
340
+ if (count >= this.max) {
341
+ const popover = this.shadowRoot?.querySelector("tp-popover");
342
+ popover?.hidePopover();
343
+ }
344
+ }
345
+ #handlePopoverToggle(e) {
346
+ this.open = e.newState === "open";
347
+ }
348
+ #signalSetter(signal, propName, newValue) {
349
+ const previous = signal.get();
350
+ if (previous === newValue)
351
+ return;
352
+ signal.set(newValue);
353
+ this.requestUpdate(propName, previous);
354
+ }
355
+ };
356
+ __decorate([
357
+ provide({ context: selectContext }),
358
+ __metadata("design:type", SelectElement)
359
+ ], SelectElement.prototype, "self", void 0);
360
+ __decorate([
361
+ property({ type: String, reflect: true, noAccessor: true }),
362
+ __metadata("design:type", String),
363
+ __metadata("design:paramtypes", [String])
364
+ ], SelectElement.prototype, "value", null);
365
+ __decorate([
366
+ property({ type: String, reflect: true, noAccessor: true }),
367
+ __metadata("design:type", String),
368
+ __metadata("design:paramtypes", [String])
369
+ ], SelectElement.prototype, "placeholder", null);
370
+ __decorate([
371
+ property({
372
+ reflect: true,
373
+ converter: {
374
+ fromAttribute: (value) => {
375
+ if (value === null || value === undefined || value === "")
376
+ return 1;
377
+ const trimmed = String(value).trim().toLowerCase();
378
+ if (trimmed === "infinite")
379
+ return Number.POSITIVE_INFINITY;
380
+ const parsed = Number(trimmed);
381
+ return Number.isFinite(parsed) && parsed >= 1 ? Math.floor(parsed) : 1;
382
+ },
383
+ toAttribute: (value) => {
384
+ if (!Number.isFinite(value))
385
+ return "infinite";
386
+ return String(value);
387
+ },
388
+ },
389
+ }),
390
+ __metadata("design:type", Number)
391
+ ], SelectElement.prototype, "max", void 0);
392
+ __decorate([
393
+ property({ type: String, reflect: true }),
394
+ __metadata("design:type", Object)
395
+ ], SelectElement.prototype, "name", void 0);
396
+ __decorate([
397
+ property({ type: Boolean, reflect: true }),
398
+ __metadata("design:type", Object)
399
+ ], SelectElement.prototype, "disabled", void 0);
400
+ __decorate([
401
+ property({ type: Boolean, reflect: true }),
402
+ __metadata("design:type", Object)
403
+ ], SelectElement.prototype, "required", void 0);
404
+ __decorate([
405
+ property({ type: Boolean, reflect: true }),
406
+ __metadata("design:type", Object)
407
+ ], SelectElement.prototype, "open", void 0);
408
+ SelectElement = SelectElement_1 = __decorate([
409
+ customElement("tp-select"),
410
+ __metadata("design:paramtypes", [])
411
+ ], SelectElement);
412
+
413
+ export { SelectElement };
414
+ //# sourceMappingURL=select.element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.element.js","sources":["../../../../libs/elements/src/select/select.element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;AAyGO,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,uBAAuB,CAAA;;aACjD,IAAA,CAAA,cAAc,GAAG,IAAH,CAAQ;AAEd,IAAA,SAAA,IAAA,CAAA,uBAAuB,GAAG,CAAC,aAAa,CAAC,CAAC;aAClD,IAAA,CAAA,MAAM,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2ClB,EAAA,CA3CY,CA2CX;AAEF,IAAA,QAAQ;AAaC,IAAA,MAAM;AAOf,IAAA,IACI,KAAK,GAAA;AACP,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;IAC1B;IACA,IAAI,KAAK,CAAC,IAAY,EAAA;QACpB,KAAK,CAAC,MAAK;YACT,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;YACnD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AAEzC,YAAA,IAAI,CAAC,eAAe,CAAC,GAAG,CACtB;iBACG,GAAG,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC;iBAC/D,MAAM,CAAC,OAAO;AACd,iBAAA,GAAG,CAAC,CAAC,MAAM,KAAK,IAAI,OAAO,CAAC,MAAO,CAAC,CAAC,CACzC;AACH,QAAA,CAAC,CAAC;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AAA,EAAA,MAAA,EAAA,MAAA,CAAA;AA/IF,aAAa,GAAA,eAAA,GAAA,UAAA,CAAA;IADzB,aAAa,CAAC,WAAW,CAAC;;AACd,CAAA,EAAA,aAAa,CAiZzB;;;;"}
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var context = require('@lit/context');
5
+ var lit = require('lit');
6
+ var decorators_js = require('lit/decorators.js');
7
+ var domUtils = require('@telperion/dom-utils');
8
+ var signalWatcherLitElement = require('../utils/signal-watcher-lit-element.cjs');
9
+ var selectContext = require('./select-context.cjs');
10
+ var internalProps = require('./internal-props.cjs');
11
+
12
+ exports.SelectedContentElement = class SelectedContentElement extends signalWatcherLitElement.SignalWatcherLitElement {
13
+ static { this.styles = (() => {
14
+ const style = lit.css `
15
+ tp-selected-content {
16
+ display: inline-block;
17
+
18
+ tp-option {
19
+ display: inline-block;
20
+
21
+ &:not(:last-of-type)::after {
22
+ content: ",";
23
+ white-space: pre;
24
+ margin-right: 0.25em;
25
+ }
26
+ }
27
+ }
28
+ `;
29
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, style.styleSheet];
30
+ return style;
31
+ })(); }
32
+ #cloneCache = new WeakMap();
33
+ createRenderRoot() {
34
+ return this;
35
+ }
36
+ render() {
37
+ const placeholder = this.select?.placeholder ?? "";
38
+ const selectedOptions = this.select?.selectedOptions.get().map(ref => ref.deref()).filter(Boolean) ?? [];
39
+ const clones = this.#getOptionClones(selectedOptions);
40
+ return !selectedOptions.length
41
+ ? lit.html `<span part="placeholder">${placeholder}</span>`
42
+ : clones.map(clone => lit.html `${clone}`);
43
+ }
44
+ #getOptionClones(options) {
45
+ return options.map(option => {
46
+ let mirror = this.#cloneCache.get(option);
47
+ if (!mirror) {
48
+ mirror = new domUtils.DomClone(option);
49
+ this.#cloneCache.set(option, mirror);
50
+ mirror.clone.setAttribute("part", "selected-content-option");
51
+ mirror.clone[internalProps.SHOULD_REGISTER_TO_SELECT] = false;
52
+ }
53
+ return mirror.clone;
54
+ });
55
+ }
56
+ };
57
+ tslib.__decorate([
58
+ context.consume({ context: selectContext.selectContext, subscribe: true }),
59
+ decorators_js.state(),
60
+ tslib.__metadata("design:type", Function)
61
+ ], exports.SelectedContentElement.prototype, "select", void 0);
62
+ exports.SelectedContentElement = tslib.__decorate([
63
+ decorators_js.customElement("tp-selected-content")
64
+ ], exports.SelectedContentElement);
65
+ //# sourceMappingURL=selected-content.element.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selected-content.element.cjs","sources":["../../../../libs/elements/src/select/selected-content.element.ts"],"sourcesContent":[null],"names":["SelectedContentElement","SignalWatcherLitElement","css","html","DomClone","SHOULD_REGISTER_TO_SELECT","__decorate","consume","selectContext","state","customElement"],"mappings":";;;;;;;;;;;AAkDaA,8BAAsB,GAA5B,MAAM,sBAAuB,SAAQC,+CAAuB,CAAA;aAC1D,IAAA,CAAA,MAAM,GAAG,CAAC,MAAK;QACpB,MAAM,KAAK,GAAGC,OAAG,CAAA,CAAA;;;;;;;;;;;;;;KAchB;AAED,QAAA,QAAQ,CAAC,kBAAkB,GAAG,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,UAAW,CAAC;AAEjF,QAAA,OAAO,KAAK;IACd,CAAC,GApBY,CAoBR;AAEL,IAAA,WAAW,GAAG,IAAI,OAAO,EAA0C;IAMhD,gBAAgB,GAAA;AACjC,QAAA,OAAO,IAAI;IACb;IAEmB,MAAM,GAAA;QACvB,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,WAAW,IAAI,EAAE;AAClD,QAAA,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,EAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QACzG,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC;QAErD,OAAO,CAAC,eAAe,CAAC;AACtB,cAAEC,QAAI,CAAA,CAAA,yBAAA,EAA4B,WAAW,CAAA,OAAA;AAC7C,cAAE,MAAM,CAAC,GAAG,CAAC,KAAK,IAAIA,QAAI,CAAA,CAAA,EAAG,KAAK,CAAA,CAAE,CAAC;IACzC;AAEA,IAAA,gBAAgB,CAAC,OAAwB,EAAA;AACvC,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,IAAG;YAC1B,IAAI,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;YAEzC,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,MAAM,GAAG,IAAIC,iBAAQ,CAAC,MAAM,CAAC;gBAC7B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;gBACpC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,yBAAyB,CAAC;AAC5D,gBAAA,MAAM,CAAC,KAAK,CAACC,uCAAyB,CAAC,GAAG,KAAK;YACjD;YAEA,OAAO,MAAM,CAAC,KAAK;AACrB,QAAA,CAAC,CAAC;IACJ;;AA7BQC,gBAAA,CAAA;IAFPC,eAAO,CAAC,EAAE,OAAO,EAAEC,2BAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACpD,IAAAC,mBAAK,EAAE;;AACuB,CAAA,EAAAT,8BAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AA3BpBA,8BAAsB,GAAAM,gBAAA,CAAA;IADlCI,2BAAa,CAAC,qBAAqB;AACvB,CAAA,EAAAV,8BAAsB,CAyDlC;;"}
@@ -0,0 +1,65 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { consume } from '@lit/context';
3
+ import { css, html } from 'lit';
4
+ import { state, customElement } from 'lit/decorators.js';
5
+ import { DomClone } from '@telperion/dom-utils';
6
+ import { SignalWatcherLitElement } from '../utils/signal-watcher-lit-element.js';
7
+ import { selectContext } from './select-context.js';
8
+ import { SHOULD_REGISTER_TO_SELECT } from './internal-props.js';
9
+
10
+ let SelectedContentElement = class SelectedContentElement extends SignalWatcherLitElement {
11
+ static { this.styles = (() => {
12
+ const style = css `
13
+ tp-selected-content {
14
+ display: inline-block;
15
+
16
+ tp-option {
17
+ display: inline-block;
18
+
19
+ &:not(:last-of-type)::after {
20
+ content: ",";
21
+ white-space: pre;
22
+ margin-right: 0.25em;
23
+ }
24
+ }
25
+ }
26
+ `;
27
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, style.styleSheet];
28
+ return style;
29
+ })(); }
30
+ #cloneCache = new WeakMap();
31
+ createRenderRoot() {
32
+ return this;
33
+ }
34
+ render() {
35
+ const placeholder = this.select?.placeholder ?? "";
36
+ const selectedOptions = this.select?.selectedOptions.get().map(ref => ref.deref()).filter(Boolean) ?? [];
37
+ const clones = this.#getOptionClones(selectedOptions);
38
+ return !selectedOptions.length
39
+ ? html `<span part="placeholder">${placeholder}</span>`
40
+ : clones.map(clone => html `${clone}`);
41
+ }
42
+ #getOptionClones(options) {
43
+ return options.map(option => {
44
+ let mirror = this.#cloneCache.get(option);
45
+ if (!mirror) {
46
+ mirror = new DomClone(option);
47
+ this.#cloneCache.set(option, mirror);
48
+ mirror.clone.setAttribute("part", "selected-content-option");
49
+ mirror.clone[SHOULD_REGISTER_TO_SELECT] = false;
50
+ }
51
+ return mirror.clone;
52
+ });
53
+ }
54
+ };
55
+ __decorate([
56
+ consume({ context: selectContext, subscribe: true }),
57
+ state(),
58
+ __metadata("design:type", Function)
59
+ ], SelectedContentElement.prototype, "select", void 0);
60
+ SelectedContentElement = __decorate([
61
+ customElement("tp-selected-content")
62
+ ], SelectedContentElement);
63
+
64
+ export { SelectedContentElement };
65
+ //# sourceMappingURL=selected-content.element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selected-content.element.js","sources":["../../../../libs/elements/src/select/selected-content.element.ts"],"sourcesContent":[null],"names":[],"mappings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W,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;gBACpC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,yBAAyB,CAAC;AAC5D,gBAAA,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,GAAG,KAAK;YACjD;YAEA,OAAO,MAAM,CAAC,KAAK;AACrB,QAAA,CAAC,CAAC;IACJ;;AA7BQ,UAAA,CAAA;IAFP,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACpD,IAAA,KAAK,EAAE;;AACuB,CAAA,EAAA,sBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AA3BpB,sBAAsB,GAAA,UAAA,CAAA;IADlC,aAAa,CAAC,qBAAqB;AACvB,CAAA,EAAA,sBAAsB,CAyDlC;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-watcher-lit-element.cjs","sources":["../../../../libs/elements/src/utils/signal-watcher-lit-element.ts"],"sourcesContent":[null],"names":["SignalWatcher","LitElement"],"mappings":";;;;;AAkBA;;;;AAIG;MACU,uBAAuB,GAAGA,qBAAa,CAACC,cAAU;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-watcher-lit-element.js","sources":["../../../../libs/elements/src/utils/signal-watcher-lit-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAkBA;;;;AAIG;MACU,uBAAuB,GAAG,aAAa,CAAC,UAAU;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"signal-watcher-lit-element.cjs","sources":["../../../../libs/elements/src/router/signal-watcher-lit-element.ts"],"sourcesContent":[null],"names":["SignalWatcher","LitElement"],"mappings":";;;;;AAkBA;;;;AAIG;MACU,uBAAuB,GAAGA,qBAAa,CAACC,cAAU;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"signal-watcher-lit-element.js","sources":["../../../../libs/elements/src/router/signal-watcher-lit-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAkBA;;;;AAIG;MACU,uBAAuB,GAAG,aAAa,CAAC,UAAU;;;;"}
File without changes