@febv/react-island-components 0.1.0-alpha.0 → 0.1.0-alpha.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.
|
@@ -23642,7 +23642,9 @@ function nM({ label: o, disabled: c, onClick: p }) {
|
|
|
23642
23642
|
{
|
|
23643
23643
|
type: "button",
|
|
23644
23644
|
className: "ri-button",
|
|
23645
|
-
onClick: () =>
|
|
23645
|
+
onClick: () => {
|
|
23646
|
+
p == null || p({ label: o }), console.log("onClick", p);
|
|
23647
|
+
},
|
|
23646
23648
|
disabled: c,
|
|
23647
23649
|
children: o
|
|
23648
23650
|
}
|
|
@@ -257,4 +257,4 @@ Check the top-level render call using <`+ve+">.")}return X}}function wu(x,X){{if
|
|
|
257
257
|
<%s {...props} />
|
|
258
258
|
React keys must be passed directly to JSX without using spread:
|
|
259
259
|
let props = %s;
|
|
260
|
-
<%s key={someKey} {...props} />`,ut,ti,ni,ti),Mr[ti+ut]=!0}}return x===g?Lr(cn):po(cn),cn}}function Si(x,X,ve){return sr(x,X,ve,!0)}function Ja(x,X,ve){return sr(x,X,ve,!1)}var Ei=Ja,Ci=Si;Ed.Fragment=g,Ed.jsx=Ei,Ed.jsxs=Ci}()),Ed}var vC;function wx(){return vC||(vC=1,process.env.NODE_ENV==="production"?Zv.exports=_x():Zv.exports=Rx()),Zv.exports}var Yi=wx();function hC({label:o,disabled:c,onClick:p}){return Yi.jsx("div",{className:"ri-root",children:Yi.jsx("button",{type:"button",className:"ri-button",onClick:()=>p==null
|
|
260
|
+
<%s key={someKey} {...props} />`,ut,ti,ni,ti),Mr[ti+ut]=!0}}return x===g?Lr(cn):po(cn),cn}}function Si(x,X,ve){return sr(x,X,ve,!0)}function Ja(x,X,ve){return sr(x,X,ve,!1)}var Ei=Ja,Ci=Si;Ed.Fragment=g,Ed.jsx=Ei,Ed.jsxs=Ci}()),Ed}var vC;function wx(){return vC||(vC=1,process.env.NODE_ENV==="production"?Zv.exports=_x():Zv.exports=Rx()),Zv.exports}var Yi=wx();function hC({label:o,disabled:c,onClick:p}){return Yi.jsx("div",{className:"ri-root",children:Yi.jsx("button",{type:"button",className:"ri-button",onClick:()=>{p==null||p({label:o}),console.log("onClick",p)},disabled:c,children:o})})}function mC({title:o,description:c,onAction:p}){return Yi.jsxs("div",{className:"ri-root ri-card",children:[Yi.jsx("h3",{className:"ri-card-title",children:o}),c?Yi.jsx("p",{children:c}):null,Yi.jsx("button",{type:"button",className:"ri-button",onClick:()=>p==null?void 0:p({title:o}),children:"Open"})]})}function yC({title:o,open:c=!1,body:p,onClose:g}){return c?Yi.jsx("div",{className:"ri-root ri-modal-overlay",onClick:()=>g==null?void 0:g({reason:"overlay"}),role:"presentation",children:Yi.jsxs("div",{className:"ri-modal-panel",onClick:R=>R.stopPropagation(),children:[Yi.jsx("h3",{className:"ri-card-title",children:o}),p?Yi.jsx("p",{children:p}):null,Yi.jsx("button",{type:"button",className:"ri-button",onClick:()=>g==null?void 0:g({reason:"close-button"}),children:"Close"})]})}):null}const Xy={Button:{tagName:"ri-button",observedAttributes:["label","disabled","event-key"],useShadowDom:!0,component:hC,contract:{version:"1.0.0",propsSchema:Gy({label:gd(),disabled:iC().optional(),onClick:qy().optional()}),events:["click"]},eventBindings:{click:"onClick"}},Card:{tagName:"ri-card",observedAttributes:["title","description","event-key"],useShadowDom:!0,component:mC,contract:{version:"1.0.0",propsSchema:Gy({title:gd(),description:gd().optional(),onAction:qy().optional()}),events:["action"]},eventBindings:{action:"onAction"}},Modal:{tagName:"ri-modal",observedAttributes:["title","body","open","event-key"],useShadowDom:!0,component:yC,contract:{version:"1.0.0",propsSchema:Gy({title:gd(),body:gd().optional(),open:iC().optional(),onClose:qy().optional()}),events:["close"]},eventBindings:{close:"onClose"}}},gC=Object.fromEntries(Object.entries(Xy).map(([o,c])=>[o,{component:c.component,contract:c.contract,eventBindings:c.eventBindings}])),SC=Object.entries(Xy).map(([o,c])=>({componentName:o,tagName:c.tagName,observedAttributes:c.observedAttributes,useShadowDom:c.useShadowDom})),Yv=ST({registry:gC,eventNamespace:"react-island"});function EC(o,c,p={},g){return Yv.mount(o,c,p,g)}function CC(o,c){return Yv.update(o,c)}function _C(o){return Yv.unmount(o)}const Tx=':host{--ri-color-text: #0f172a;--ri-color-surface: #ffffff;--ri-color-border: #cbd5e1;--ri-color-primary: #0f172a;--ri-color-primary-contrast: #ffffff;--ri-radius-sm: 6px;--ri-radius-md: 10px;--ri-spacing-sm: 8px;--ri-spacing-md: 12px;--ri-font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif}.ri-root{box-sizing:border-box;color:var(--ri-color-text);font-family:var(--ri-font-family)}.ri-button{border:1px solid var(--ri-color-primary);background:var(--ri-color-primary);color:var(--ri-color-primary-contrast);padding:var(--ri-spacing-sm) var(--ri-spacing-md);border-radius:var(--ri-radius-sm);cursor:pointer}.ri-button:disabled{opacity:.6;cursor:not-allowed}.ri-card{border:1px solid var(--ri-color-border);border-radius:var(--ri-radius-md);padding:var(--ri-spacing-md);background:var(--ri-color-surface)}.ri-card-title{margin:0 0 var(--ri-spacing-sm);font-size:14px;font-weight:600}.ri-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#02061773;display:flex;align-items:center;justify-content:center}.ri-modal-panel{width:min(560px,calc(100vw - 32px));background:var(--ri-color-surface);border-radius:var(--ri-radius-md);border:1px solid var(--ri-color-border);padding:16px}',bx="react-island-host";function kx(o,c){if(c!==null){if(c==="true")return!0;if(c==="false")return!1;if(c.trim()!==""&&!Number.isNaN(Number(c)))return Number(c);try{return JSON.parse(c)}catch{return c}}}function xx(o){return o.replace(/-([a-z])/g,(c,p)=>p.toUpperCase())}function Dx(){const o=document.createElement("style");return o.textContent=Tx,o}function RC(o,c){o.ok||console.error(`[react-island-components] ${c}: ${o.error.message}`,o.error)}function wC(o){if(customElements.get(o.tagName))return;class c extends HTMLElement{constructor(){super(...arguments),this.state={props:{}},this.mountContainer=null}static get observedAttributes(){return o.observedAttributes??[]}get props(){return this.state.props}set props(g){this.state.props={...this.state.props,...g},this.render()}connectedCallback(){if(!this.mountContainer){const g=o.useShadowDom!==!1,R=g?this.attachShadow({mode:"open"}):this;g&&R.appendChild(Dx());const k=document.createElement("div");k.className=bx,R.appendChild(k),this.mountContainer=k}this.render(!0)}disconnectedCallback(){if(!this.mountContainer)return;const g=_C(this.mountContainer);RC(g,`Failed to unmount ${o.componentName}`)}attributeChangedCallback(g,R,k){const S=o.parseAttribute??kx;this.state.props[xx(g)]=S(g,k),this.render()}render(g=!1){if(this.mountContainer){if(g){const R=EC(o.componentName,this.mountContainer,this.state.props,{eventKey:this.getAttribute("event-key")??void 0});if(!R.ok){console.error(`[react-island-components] Failed to mount ${o.componentName}`,R.error);return}return}RC(CC(this.mountContainer,this.state.props),`Failed to update ${o.componentName}`)}}}customElements.define(o.tagName,c)}function Ox(o=SC){o.forEach(c=>{wC(c)})}wr.Button=hC,wr.Card=mC,wr.Modal=yC,wr.componentDefinitions=Xy,wr.createIslandElement=wC,wr.getScopedEventName=$y,wr.islandPlatform=Yv,wr.mountComponent=EC,wr.registerReactIslandElements=Ox,wr.registry=gC,wr.unmountComponent=_C,wr.updateComponent=CC,wr.webComponentDefinitions=SC,Object.defineProperty(wr,Symbol.toStringTag,{value:"Module"})});
|