|
177 | 177 | super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev(); |
178 | 178 | } |
179 | 179 | _$Ev() { |
180 | | - this._$Eg = new Promise((t4) => this.enableUpdating = t4), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((t4) => t4(this)); |
| 180 | + this._$Eg = new Promise((t4) => this.enableUpdating = t4), this._$AL = /* @__PURE__ */ new Map(), this._$ES(), this.requestUpdate(), this.constructor.l?.forEach((t4) => t4(this)); |
181 | 181 | } |
182 | 182 | addController(t4) { |
183 | | - (this._$ES ??= []).push(t4), void 0 !== this.renderRoot && this.isConnected && t4.hostConnected?.(); |
| 183 | + (this._$E_ ??= /* @__PURE__ */ new Set()).add(t4), void 0 !== this.renderRoot && this.isConnected && t4.hostConnected?.(); |
184 | 184 | } |
185 | 185 | removeController(t4) { |
186 | | - this._$ES?.splice(this._$ES.indexOf(t4) >>> 0, 1); |
| 186 | + this._$E_?.delete(t4); |
187 | 187 | } |
188 | | - _$E_() { |
| 188 | + _$ES() { |
189 | 189 | const t4 = /* @__PURE__ */ new Map(), s4 = this.constructor.elementProperties; |
190 | 190 | for (const i4 of s4.keys()) |
191 | 191 | this.hasOwnProperty(i4) && (t4.set(i4, this[i4]), delete this[i4]); |
|
196 | 196 | return S(t4, this.constructor.elementStyles), t4; |
197 | 197 | } |
198 | 198 | connectedCallback() { |
199 | | - this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$ES?.forEach((t4) => t4.hostConnected?.()); |
| 199 | + this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$E_?.forEach((t4) => t4.hostConnected?.()); |
200 | 200 | } |
201 | 201 | enableUpdating(t4) { |
202 | 202 | } |
203 | 203 | disconnectedCallback() { |
204 | | - this._$ES?.forEach((t4) => t4.hostDisconnected?.()); |
| 204 | + this._$E_?.forEach((t4) => t4.hostDisconnected?.()); |
205 | 205 | } |
206 | 206 | attributeChangedCallback(t4, s4, i4) { |
207 | 207 | this._$AK(t4, i4); |
|
248 | 248 | if (!this.isUpdatePending) |
249 | 249 | return; |
250 | 250 | if (!this.hasUpdated) { |
251 | | - if (this._$Ep) { |
| 251 | + if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) { |
252 | 252 | for (const [t6, s5] of this._$Ep) |
253 | 253 | this[t6] = s5; |
254 | 254 | this._$Ep = void 0; |
|
261 | 261 | let t4 = false; |
262 | 262 | const s4 = this._$AL; |
263 | 263 | try { |
264 | | - t4 = this.shouldUpdate(s4), t4 ? (this.willUpdate(s4), this._$ES?.forEach((t5) => t5.hostUpdate?.()), this.update(s4)) : this._$ET(); |
| 264 | + t4 = this.shouldUpdate(s4), t4 ? (this.willUpdate(s4), this._$E_?.forEach((t5) => t5.hostUpdate?.()), this.update(s4)) : this._$ET(); |
265 | 265 | } catch (s5) { |
266 | 266 | throw t4 = false, this._$ET(), s5; |
267 | 267 | } |
|
270 | 270 | willUpdate(t4) { |
271 | 271 | } |
272 | 272 | _$AE(t4) { |
273 | | - this._$ES?.forEach((t5) => t5.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t4)), this.updated(t4); |
| 273 | + this._$E_?.forEach((t5) => t5.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t4)), this.updated(t4); |
274 | 274 | } |
275 | 275 | _$ET() { |
276 | 276 | this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; |
|
292 | 292 | firstUpdated(t4) { |
293 | 293 | } |
294 | 294 | }; |
295 | | - b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[d("elementProperties")] = /* @__PURE__ */ new Map(), b[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: b }), (a.reactiveElementVersions ??= []).push("2.0.1"); |
| 295 | + b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[d("elementProperties")] = /* @__PURE__ */ new Map(), b[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: b }), (a.reactiveElementVersions ??= []).push("2.0.2"); |
296 | 296 |
|
297 | 297 | // node_modules/lit-html/lit-html.js |
298 | 298 | var t2 = globalThis; |
|
551 | 551 | } |
552 | 552 | }; |
553 | 553 | var Z = t2.litHtmlPolyfillSupport; |
554 | | - Z?.(V, M), (t2.litHtmlVersions ??= []).push("3.0.2"); |
| 554 | + Z?.(V, M), (t2.litHtmlVersions ??= []).push("3.1.0"); |
555 | 555 | var j = (t4, i4, s4) => { |
556 | 556 | const e5 = s4?.renderBefore ?? i4; |
557 | 557 | let h3 = e5._$litPart$; |
|
588 | 588 | s3._$litElement$ = true, s3["finalized", "finalized"] = true, globalThis.litElementHydrateSupport?.({ LitElement: s3 }); |
589 | 589 | var r4 = globalThis.litElementPolyfillSupport; |
590 | 590 | r4?.({ LitElement: s3 }); |
591 | | - (globalThis.litElementVersions ??= []).push("4.0.1"); |
| 591 | + (globalThis.litElementVersions ??= []).push("4.0.2"); |
592 | 592 |
|
593 | 593 | // node_modules/@lit/reactive-element/decorators/custom-element.js |
594 | 594 | var t3 = (t4) => (e5, o5) => { |
|
627 | 627 | })(t4, e5, o5); |
628 | 628 | } |
629 | 629 |
|
| 630 | + // node_modules/@posit-dev/shiny-bindings-core/dist/OptionalShiny.js |
| 631 | + var Shiny = window.Shiny; |
| 632 | + |
| 633 | + // node_modules/@posit-dev/shiny-bindings-core/dist/makeInputBinding.js |
| 634 | + function makeInputBinding(tagName, { type = null } = {}) { |
| 635 | + if (!Shiny) { |
| 636 | + return; |
| 637 | + } |
| 638 | + class NewCustomBinding extends Shiny["InputBinding"] { |
| 639 | + constructor() { |
| 640 | + super(); |
| 641 | + } |
| 642 | + find(scope) { |
| 643 | + return $(scope).find(tagName); |
| 644 | + } |
| 645 | + getValue(el) { |
| 646 | + return el.value; |
| 647 | + } |
| 648 | + getType(_2) { |
| 649 | + return type; |
| 650 | + } |
| 651 | + subscribe(el, callback) { |
| 652 | + el.notifyBindingOfChange = (ad) => callback(ad ?? false); |
| 653 | + } |
| 654 | + unsubscribe(el) { |
| 655 | + el.notifyBindingOfChange = (_2) => { |
| 656 | + }; |
| 657 | + } |
| 658 | + } |
| 659 | + Shiny.inputBindings.register(new NewCustomBinding(), `${tagName}-Binding`); |
| 660 | + } |
| 661 | + |
630 | 662 | // srcts/index.ts |
631 | | - var customInputTag = "shiny-custom-input"; |
632 | | - var ShinyCustomInput = class extends s3 { |
| 663 | + var customInputTag = "custom-component"; |
| 664 | + var CustomComponentEl = class extends s3 { |
633 | 665 | constructor() { |
634 | 666 | super(...arguments); |
635 | 667 | this.value = 0; |
|
638 | 670 | * This alerts Shiny that the value has changed and it should check for the |
639 | 671 | * latest value. This is set by the input binding. |
640 | 672 | */ |
641 | | - this.onChangeCallback = null; |
| 673 | + this.notifyBindingOfChange = () => { |
| 674 | + }; |
642 | 675 | } |
643 | 676 | /** |
644 | 677 | * Function to run when the increment button is clicked. |
645 | 678 | */ |
646 | 679 | onIncrement() { |
647 | 680 | this.value++; |
648 | | - this.onChangeCallback?.(true); |
| 681 | + this.notifyBindingOfChange(true); |
649 | 682 | } |
650 | 683 | render() { |
651 | 684 | return x` |
|
655 | 688 | `; |
656 | 689 | } |
657 | 690 | }; |
658 | | - ShinyCustomInput.styles = i` |
| 691 | + CustomComponentEl.styles = i` |
659 | 692 | :host { |
660 | 693 | display: block; |
661 | 694 | border: solid 1px gray; |
|
666 | 699 | `; |
667 | 700 | __decorateClass([ |
668 | 701 | n4({ type: Number }) |
669 | | - ], ShinyCustomInput.prototype, "value", 2); |
670 | | - ShinyCustomInput = __decorateClass([ |
| 702 | + ], CustomComponentEl.prototype, "value", 2); |
| 703 | + CustomComponentEl = __decorateClass([ |
671 | 704 | t3(customInputTag) |
672 | | - ], ShinyCustomInput); |
673 | | - var CustomInputBinding = class extends Shiny.InputBinding { |
674 | | - constructor() { |
675 | | - super(); |
676 | | - } |
677 | | - find(scope) { |
678 | | - return $(scope).find(customInputTag); |
679 | | - } |
680 | | - getValue(el) { |
681 | | - return el.value; |
682 | | - } |
683 | | - subscribe(el, callback) { |
684 | | - el.onChangeCallback = callback; |
685 | | - } |
686 | | - }; |
687 | | - Shiny.inputBindings.register(new CustomInputBinding(), customInputTag); |
| 705 | + ], CustomComponentEl); |
| 706 | + makeInputBinding(customInputTag); |
688 | 707 | })(); |
689 | 708 | /*! Bundled license information: |
690 | 709 |
|
|
0 commit comments