chunk.YMJR4BPF.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {
  2. event
  3. } from "./chunk.XX234VRK.js";
  4. import {
  5. T,
  6. h,
  7. n,
  8. r
  9. } from "./chunk.5PIDMFOE.js";
  10. import {
  11. __decorateClass
  12. } from "./chunk.IHGPZX35.js";
  13. // _uyihdawu1:/Users/claviska/Projects/shoelace/src/components/resize-observer/resize-observer.scss
  14. var resize_observer_default = ":host {\n position: relative;\n box-sizing: border-box;\n}\n:host *, :host *:before, :host *:after {\n box-sizing: inherit;\n}\n\n[hidden] {\n display: none !important;\n}\n\n:host {\n display: contents;\n}";
  15. // src/components/resize-observer/resize-observer.ts
  16. var SlResizeObserver = class extends h {
  17. constructor() {
  18. super(...arguments);
  19. this.observedElements = [];
  20. }
  21. connectedCallback() {
  22. super.connectedCallback();
  23. this.resizeObserver = new ResizeObserver((entries) => {
  24. this.slResize.emit({ detail: { entries } });
  25. });
  26. }
  27. disconnectedCallback() {
  28. super.disconnectedCallback();
  29. this.resizeObserver.disconnect();
  30. }
  31. handleSlotChange() {
  32. const slot = this.shadowRoot.querySelector("slot");
  33. const elements = slot.assignedElements({ flatten: true });
  34. this.observedElements.map((el) => this.resizeObserver.unobserve(el));
  35. this.observedElements = [];
  36. elements.map((el) => {
  37. this.resizeObserver.observe(el);
  38. this.observedElements.push(el);
  39. });
  40. }
  41. render() {
  42. return T` <slot @slotchange=${this.handleSlotChange}></slot> `;
  43. }
  44. };
  45. SlResizeObserver.styles = r(resize_observer_default);
  46. __decorateClass([
  47. event("sl-resize")
  48. ], SlResizeObserver.prototype, "slResize", 2);
  49. SlResizeObserver = __decorateClass([
  50. n("sl-resize-observer")
  51. ], SlResizeObserver);
  52. var resize_observer_default2 = SlResizeObserver;
  53. export {
  54. resize_observer_default2 as resize_observer_default
  55. };