@lit-labs/react
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
const t=new Set(["children","localName","ref","style","className"]),e=new WeakMap,n=(t,n,s,o,i)=>{const l=null==i?void 0:i[n];void 0!==l?s!==o&&((t,n,s)=>{let o=e.get(t);void 0===o&&e.set(t,o=new Map);let i=o.get(n);void 0!==s?void 0===i?(o.set(n,i={handleEvent:s}),t.addEventListener(n,i)):i.handleEvent=s:void 0!==i&&(o.delete(n),t.removeEventListener(n,i))})(t,l,s):t[n]=s},s=(e,s,o,i,l)=>{const c=e.Component,r=e.createElement,d=new Set(Object.keys(null!=i?i:{}));for(const e in o.prototype)e in HTMLElement.prototype||(t.has(e)?console.warn(`${s} contains property ${e} which is a React reserved property. It will be used by React and not set on the element.`):d.add(e));class h extends c{constructor(){super(...arguments),this.o=null}t(t){if(null!==this.o)for(const e in this.i)n(this.o,e,this.props[e],t?t[e]:void 0,i)}componentDidMount(){this.t()}componentDidUpdate(t){this.t(t)}render(){const t=this.props._$Gl;void 0!==this.h&&this.u===t||(this.h=e=>{null===this.o&&(this.o=e),null!==t&&((t,e)=>{"function"==typeof t?t(e):t.current=e})(t,e),this.u=t});const e={ref:this.h};this.i={};for(const[t,n]of Object.entries(this.props))"__forwardedRef"!==t&&(d.has(t)?this.i[t]=n:e["className"===t?"class":t]=n);return r(s,e)}}h.displayName=null!=l?l:o.name;const a=e.forwardRef(((t,e)=>r(h,{...t,_$Gl:e},null==t?void 0:t.children)));return a.displayName=h.displayName,a};export{s as createComponent}; | ||
const t=new Set(["children","localName","ref","style","className"]),e=new WeakMap,n=(t,n,s,i,o)=>{const l=null==o?void 0:o[n];void 0!==l?s!==i&&((t,n,s)=>{let i=e.get(t);void 0===i&&e.set(t,i=new Map);let o=i.get(n);void 0!==s?void 0===o?(i.set(n,o={handleEvent:s}),t.addEventListener(n,o)):o.handleEvent=s:void 0!==o&&(i.delete(n),t.removeEventListener(n,o))})(t,l,s):t[n]=s},s=(e,s,i,o,l)=>{const d=e.Component,c=e.createElement,h=new Set(Object.keys(null!=o?o:{}));class r extends d{constructor(){super(...arguments),this.o=null}t(t){if(null!==this.o)for(const e in this.i)n(this.o,e,this.props[e],t?t[e]:void 0,o)}componentDidMount(){this.t()}componentDidUpdate(t){this.t(t)}render(){const e=this.props._$Gl;void 0!==this.h&&this.u===e||(this.h=t=>{null===this.o&&(this.o=t),null!==e&&((t,e)=>{"function"==typeof t?t(e):t.current=e})(e,t),this.u=e});const n={ref:this.h};this.i={};for(const[e,s]of Object.entries(this.props))"__forwardedRef"!==e&&(h.has(e)||!t.has(e)&&!(e in HTMLElement.prototype)&&e in i.prototype?this.i[e]=s:n["className"===e?"class":e]=s);return c(s,n)}}r.displayName=null!=l?l:i.name;const a=e.forwardRef(((t,e)=>c(r,{...t,_$Gl:e},null==t?void 0:t.children)));return a.displayName=r.displayName,a};export{s as createComponent}; | ||
//# sourceMappingURL=create-component.js.map |
@@ -94,22 +94,3 @@ /** | ||
const createElement = React.createElement; | ||
// Set of properties/events which should be specially handled by the wrapper | ||
// and not handled directly by React. | ||
const elementClassProps = new Set(Object.keys(events !== null && events !== void 0 ? events : {})); | ||
for (const p in elementClass.prototype) { | ||
if (!(p in HTMLElement.prototype)) { | ||
if (reservedReactProperties.has(p)) { | ||
// Note, this effectively warns only for `ref` since the other | ||
// reserved props are on HTMLElement.prototype. To address this | ||
// would require crawling down the prototype, which doesn't feel worth | ||
// it since implementing these properties on an element is extremely | ||
// rare. | ||
console.warn(`${tagName} contains property ${p} which is a React ` + | ||
`reserved property. It will be used by React and not set on ` + | ||
`the element.`); | ||
} | ||
else { | ||
elementClassProps.add(p); | ||
} | ||
} | ||
} | ||
const eventProps = new Set(Object.keys(events !== null && events !== void 0 ? events : {})); | ||
class ReactComponent extends Component { | ||
@@ -181,3 +162,6 @@ constructor() { | ||
continue; | ||
if (elementClassProps.has(k)) { | ||
if (eventProps.has(k) || | ||
(!reservedReactProperties.has(k) && | ||
!(k in HTMLElement.prototype) && | ||
k in elementClass.prototype)) { | ||
this._elementProps[k] = v; | ||
@@ -184,0 +168,0 @@ } |
{ | ||
"name": "@lit-labs/react", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "A React component wrapper for web components.", | ||
@@ -140,3 +140,3 @@ "license": "BSD-3-Clause", | ||
"devDependencies": { | ||
"@lit/reactive-element": "^1.0.0", | ||
"@lit/reactive-element": "^1.4.0", | ||
"@types/react": "^17.0.0", | ||
@@ -143,0 +143,0 @@ "@types/react-dom": "^17.0.0", |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
const t=Promise.resolve();class s{constructor(t,s){this.v=[],this.p=!0,this._=!1,this.m=t,this.C=s,this.j=new Promise(((t,s)=>{this.O=t}))}addController(t){this.v.push(t)}removeController(t){var s;null===(s=this.v)||void 0===s||s.splice(this.v.indexOf(t)>>>0,1)}requestUpdate(){this.p||(this.p=!0,t.then((()=>this.C(++this.m))))}get updateComplete(){return this.j}M(){this._=!0,this.v.forEach((t=>{var s;return null===(s=t.hostConnected)||void 0===s?void 0:s.call(t)}))}R(){this._=!1,this.v.forEach((t=>{var s;return null===(s=t.hostDisconnected)||void 0===s?void 0:s.call(t)}))}N(){this.v.forEach((t=>{var s;return null===(s=t.hostUpdate)||void 0===s?void 0:s.call(t)}))}P(){this.p=!1;const t=this.O;this.j=new Promise(((t,s)=>{this.O=t})),this.v.forEach((t=>{var s;return null===(s=t.hostUpdated)||void 0===s?void 0:s.call(t)})),t(this.p)}}const i=(i,e)=>{const{useState:r,useLayoutEffect:o}=i,[n,h]=r(0);let u=!1;const[d]=r((()=>{const i=new s(n,h),r=e(i);return i.S=r,i.M(),u=!0,t.then((()=>{u&&i.R()})),i}));return d.p=!0,o((()=>(u=!1,d._||d.M(),()=>d.R())),[]),o((()=>d.P())),d.N(),d.S};export{i as useController}; | ||
const t=Promise.resolve();class s{constructor(t,s){this.v=[],this._=!0,this.p=!1,this.m=t,this.C=s,this.j=new Promise(((t,s)=>{this.O=t}))}addController(t){this.v.push(t)}removeController(t){var s;null===(s=this.v)||void 0===s||s.splice(this.v.indexOf(t)>>>0,1)}requestUpdate(){this._||(this._=!0,t.then((()=>this.C(++this.m))))}get updateComplete(){return this.j}M(){this.p=!0,this.v.forEach((t=>{var s;return null===(s=t.hostConnected)||void 0===s?void 0:s.call(t)}))}N(){this.p=!1,this.v.forEach((t=>{var s;return null===(s=t.hostDisconnected)||void 0===s?void 0:s.call(t)}))}P(){this.v.forEach((t=>{var s;return null===(s=t.hostUpdate)||void 0===s?void 0:s.call(t)}))}S(){this._=!1;const t=this.O;this.j=new Promise(((t,s)=>{this.O=t})),this.v.forEach((t=>{var s;return null===(s=t.hostUpdated)||void 0===s?void 0:s.call(t)})),t(this._)}}const i=(i,e)=>{const{useState:r,useLayoutEffect:o}=i,[n,h]=r(0);let u=!1;const[d]=r((()=>{const i=new s(n,h),r=e(i);return i.D=r,i.M(),u=!0,t.then((()=>{u&&i.N()})),i}));return d._=!0,o((()=>(u=!1,d.p||d.M(),()=>d.N())),[]),o((()=>d.S())),d.P(),d.D};export{i as useController}; | ||
//# sourceMappingURL=use-controller.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98521
568