@wcstack/resize 4.24.0 → 4.24.2
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.
- package/dist/auto.min.js +1 -1
- package/dist/index.esm.js +1 -1
- package/package.json +1 -1
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tagNames:{resize:"wcs-resize"}};var t="@wcstack/resize",n="4.24.
|
|
1
|
+
const e={tagNames:{resize:"wcs-resize"}};var t="@wcstack/resize",n="4.24.2";class s extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"entry",event:"wcs-resize:change",semantics:"state"},{name:"width",event:"wcs-resize:change",semantics:"state",getter:e=>e.detail.width},{name:"height",event:"wcs-resize:change",semantics:"state",getter:e=>e.detail.height},{name:"observing",event:"wcs-resize:observing-changed",semantics:"state"}],commands:[{name:"observe"},{name:"unobserve"},{name:"disconnect"}]};_target;_observer=null;_observed=null;_options={};_effectiveBox="content-box";_entry=null;_observing=!1;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}observe(e,t={}){return e&&this._observeElement(e,t),this._ready}dispose(){this.disconnect()}get entry(){return this._entry}get width(){return this._entry?this._entry.width:0}get height(){return this._entry?this._entry.height:0}get observing(){return this._observing}_setEntry(e){this._entry=e,this._target.dispatchEvent(new CustomEvent("wcs-resize:change",{detail:e,bubbles:!0}))}_setObserving(e){this._observing!==e&&(this._observing=e,this._target.dispatchEvent(new CustomEvent("wcs-resize:observing-changed",{detail:e,bubbles:!0})))}_observeElement(e,t={}){if(this._observer&&this._observed===e&&this._optionsEqual(this._options,t))return;this._teardownObserver();const n=this._createObserver();if(!n)return void this._setObserving(!1);const s=this._beginObserve(n,e,t.box);if(null===s)return n.disconnect(),void this._setObserving(!1);this._observer=n,this._observed=e,this._options={box:t.box,round:t.round},this._effectiveBox=s,this._setObserving(!0)}unobserve(e){this._observed===e&&(this._teardownObserver(),this._setObserving(!1))}disconnect(){this._teardownObserver(),this._setObserving(!1)}_teardownObserver(){this._observer&&(this._observer.disconnect(),this._observer=null),this._observed=null}_createObserver(){return"undefined"==typeof ResizeObserver?null:new ResizeObserver(this._onResize)}_beginObserve(e,t,n){const s=n??"content-box";try{return e.observe(t,{box:s}),s}catch{if("content-box"===s)return null;try{return e.observe(t,{box:"content-box"}),"content-box"}catch{return null}}}_onResize=e=>{for(const t of e)this._setEntry(this._normalizeEntry(t))};_normalizeEntry(e){const t=this._normalizeRect(e.contentRect),n=this._firstBoxSize(e.contentBoxSize),s=this._firstBoxSize(e.borderBoxSize),r=this._firstBoxSize(e.devicePixelContentBoxSize),{width:i,height:o}=this._headlineSize(n,s,r,t);return{width:i,height:o,contentRect:t,contentBoxSize:n,borderBoxSize:s,devicePixelContentBoxSize:r,target:e.target}}_headlineSize(e,t,n,s){const r=this._effectiveBox;let i,o,c;return i="border-box"===r?t:"device-pixel-content-box"===r?n:e,i?(o=i.inlineSize,c=i.blockSize):(o=s.width,c=s.height),this._options.round&&(o=Math.round(o),c=Math.round(c)),{width:o,height:c}}_firstBoxSize(e){if(!e||0===e.length)return null;const t=e[0];return{inlineSize:t.inlineSize,blockSize:t.blockSize}}_normalizeRect(e){return{x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left}}_optionsEqual(e,t){return(e.box??"content-box")===(t.box??"content-box")&&(e.round??!1)===(t.round??!1)}}function r(e,t){let n=Object.getPrototypeOf(e);for(;null!==n;){const e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;n=Object.getPrototypeOf(n)}return!1}const i=new WeakSet;function o(e,t,n){if(i.has(e))return;i.add(e);const s=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${s}> has the attribute ${t}="${n}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const c=new WeakMap;function a(e,t){let n=c.get(e);return void 0===n&&(n=new Map,c.set(e,n)),n.has(t)||n.set(t,e.getAttribute(t)),n.get(t)}function h(e,t,n){null===n?e.removeAttribute(t):e.setAttribute(t,n)}function l(e,t,n){const s=a(e,t);h(e,t,void 0===n?s:null===n?null:String(n))}function u(e,t,n){const s=a(e,t);h(e,t,void 0===n?s:n?"":null)}const b=["content-box","border-box","device-pixel-content-box"];class d extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["target","box","round"];static wcBindable={...s.wcBindable,properties:[...s.wcBindable.properties,{name:"trigger",event:"wcs-resize:trigger-changed",semantics:"state"}],inputs:[{name:"target",attribute:"target"},{name:"box",attribute:"box"},{name:"round",attribute:"round"},{name:"once",attribute:"once"},{name:"manual",attribute:"manual"},{name:"trigger"}],commands:s.wcBindable.commands};_core;_trigger=!1;_connectedCallbackPromise=Promise.resolve();_internals=null;_observePending=!1;constructor(){super(),this._core=new s(this),this._internals=this._initInternals(),this._wireStates({"wcs-resize:observing-changed":e=>({observing:!0===e})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[n,s]of Object.entries(e))this.addEventListener(n,e=>{const n=this.hasAttribute("debug-states");for(const[r,i]of Object.entries(s(e.detail))){try{i?t.add(r):t.delete(r)}catch{}n&&this.toggleAttribute(`data-wcs-state-${r}`,i)}})}get target(){return this.getAttribute("target")??""}set target(e){l(this,"target",e)}get box(){return this.getAttribute("box")??""}set box(e){l(this,"box",e)}get round(){return this.hasAttribute("round")}set round(e){u(this,"round",e)}get once(){return this.hasAttribute("once")}set once(e){u(this,"once",e)}get manual(){return this.hasAttribute("manual")}set manual(e){u(this,"manual",e)}get entry(){return this._core.entry}get width(){return this._core.width}get height(){return this._core.height}get observing(){return this._core.observing}get trigger(){return this._trigger}set trigger(e){if(!!e){this._trigger=!0;try{this.observe()}finally{this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-resize:trigger-changed",{detail:!1,bubbles:!0}))}}}observe(){const{element:e,display:t}=this._resolveTarget();this.style.display=t,e?this._core.observe(e,this._options()):this._core.disconnect()}unobserve(){this._observePending=!1,this._core.disconnect()}disconnect(){this._observePending=!1,this._core.disconnect()}_resolveTarget(){const e=this.target;if("self"===e)return{element:this,display:"block"};if(""!==e){const t=this.getRootNode();return{element:this._safeQuery(t,e),display:"none"}}const t=this.firstElementChild;return t?{element:t,display:"contents"}:{element:this,display:"block"}}_safeQuery(e,t){try{return e.querySelector(t)}catch{return null}}_parseBox(){const e=this.box.trim();return b.includes(e)?e:"content-box"}_options(){return{box:this._parseBox(),round:this.round}}_onChange=e=>{e.target===this&&this.once&&this._core.disconnect()};_scheduleObserve(){this._observePending||(this._observePending=!0,queueMicrotask(()=>{this._observePending&&(this._observePending=!1,this.isConnected&&!this.manual&&this.observe())}))}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,n=t?.inputs;if(void 0===n)return;const s=e.getAttribute;for(const t of n){const n=t.name,i="function"==typeof s?s.call(e,n.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&o(e,n,i),!Object.prototype.hasOwnProperty.call(e,n))continue;if(!r(e,n))continue;const c=e,a=c[n];delete c[n],c[n]=a}}(this),this.addEventListener("wcs-resize:change",this._onChange),this._scheduleObserve(),this._connectedCallbackPromise=this._core.observe()}disconnectedCallback(){this.removeEventListener("wcs-resize:change",this._onChange),this._core.dispose()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&!this.manual&&this._scheduleObserve()}}const g=Symbol.for("wcstack.package"),_=new WeakSet;function v(e,t){Object.defineProperty(e,g,{value:t,configurable:!0})}function f(e,t,n,s,r){if(void 0!==s&&(n===s||n.prototype instanceof s))return;const i=n[g];if(i===r||_.has(e))return;_.add(e);const o=r.slice(0,r.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${t}> is already defined by ${i??`another copy of ${o} that does not name its version`}; this copy, ${r}, does nothing. Load each package once.`)}function m(s=customElements){!function(e,t,n){for(const[s,r]of n){const n=e.get(s);void 0===n?(v(r,t),e.define(s,r)):f(e,s,n,r,t)}}(s,`${t}@${n}`,[[e.tagNames.resize,d]])}var p;m(p);
|
|
2
2
|
//# sourceMappingURL=auto.min.js.map
|
package/dist/index.esm.js
CHANGED
|
@@ -58,7 +58,7 @@ function setConfig(partialConfig) {
|
|
|
58
58
|
frozenConfig = null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
var pkg = {"name":"@wcstack/resize","version":"4.24.
|
|
61
|
+
var pkg = {"name":"@wcstack/resize","version":"4.24.2"};
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Headless element-size primitive. A thin, framework-agnostic wrapper around the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/resize",
|
|
3
|
-
"version": "4.24.
|
|
3
|
+
"version": "4.24.2",
|
|
4
4
|
"description": "Declarative ResizeObserver component for Web Components. Framework-agnostic element-size primitive via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|