UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

11 lines (8 loc) 1.58 kB
'use strict'; /** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ 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?null==s&&n in HTMLElement.prototype?t.removeAttribute(n):t[n]=s:((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);},s=(t,e)=>{"function"==typeof t?t(e):t.current=e;};function i(e=window.React,i,o,l,d){let a,c,r;if(void 0===i){const t=e;(({tagName:c,elementClass:r,events:l,displayName:d}=t)),a=t.react;}else a=e,r=o,c=i;const h=a.Component,u=a.createElement,f=new Set(Object.keys(null!=l?l:{}));class v extends h{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,l);}componentDidMount(){var t;this.t(),null===(t=this.o)||void 0===t||t.removeAttribute("defer-hydration");}componentDidUpdate(t){this.t(t);}render(){const{_$Gl:e,...n}=this.props;this.h!==e&&(this.u=t=>{null!==e&&s(e,t),this.o=t,this.h=e;}),this.i={};const i={ref:this.u};for(const[e,s]of Object.entries(n))t.has(e)?i["className"===e?"class":e]=s:f.has(e)||e in r.prototype?this.i[e]=s:i[e]=s;return i.suppressHydrationWarning=!0,u(c,i)}}v.displayName=null!=d?d:r.name;const m=a.forwardRef(((t,e)=>u(v,{...t,_$Gl:e},null==t?void 0:t.children)));return m.displayName=v.displayName,m} exports.createComponent = i;