@sitecore/byoc
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -131,4 +131,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
const schema = (_a = getComponent(id)) === null || _a === void 0 ? void 0 : _a.schema; | ||
const givenProps = Object.assign(Object.assign({}, contextProperties), props); | ||
return schema ? getSchemaProperties(schema, givenProps) : givenProps; | ||
return schema ? getSchemaProperties(schema, props) : props; | ||
} | ||
@@ -223,3 +222,4 @@ export function getComponentConfigurablePropertyNames(id) { | ||
} | ||
export const serializedContextProperties = ['sitecoreEdgeUrl', 'sitecoreEdgeContextId']; | ||
BYOCRegistration.register('byoc-registration'); | ||
//# sourceMappingURL=api.js.map |
@@ -13,4 +13,4 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import React from 'react'; | ||
import { getComponent, getComponentProperties, isWebComponent, registered } from '@sitecore/byoc'; | ||
import { objectKeysToKebabCase, toKebabCase } from '@sitecore/byoc'; | ||
import { getComponent, getComponentProperties, isWebComponent, registered, serializedContextProperties } from '@sitecore/byoc'; | ||
import { objectKeysToKebabCase, toKebabCase, contextProperties } from '@sitecore/byoc'; | ||
export * from '@sitecore/byoc'; | ||
@@ -86,8 +86,11 @@ var NextClientsideRenderer = null; | ||
export function RegularComponent(props) { | ||
const { componentName, className, clientFallback, fallback, suppressHydrationWarning, _dynamic } = props, attributes = __rest(props, ["componentName", "className", "clientFallback", "fallback", "suppressHydrationWarning", "_dynamic"]); | ||
const { componentName, className, clientFallback, fallback, suppressHydrationWarning, _dynamic, datasources } = props, attributes = __rest(props, ["componentName", "className", "clientFallback", "fallback", "suppressHydrationWarning", "_dynamic", "datasources"]); | ||
const definition = getComponent(componentName); | ||
const Component = definition === null || definition === void 0 ? void 0 : definition.component; | ||
const parsed = getComponentProperties(componentName, attributes); | ||
const parsedWithoutSDK = { parsed }; | ||
const componentProperties = Object.assign(Object.assign({ 'data-external-id': componentName }, objectKeysToKebabCase(parsed)), { suppressHydrationWarning: true, class: className }); | ||
const dataProperties = Object.values(datasources || {}).find((v) => v && !Array.isArray(v)); | ||
const componentProperties = Object.assign(Object.assign(Object.assign({ 'data-external-id': componentName }, objectKeysToKebabCase(dataProperties)), objectKeysToKebabCase(parsed)), { datasources, suppressHydrationWarning: true, class: className }); | ||
serializedContextProperties.forEach((key) => { | ||
Object.assign(componentProperties, { [toKebabCase(key)]: contextProperties[key] }); | ||
}); | ||
// serialize json properties | ||
@@ -104,3 +107,3 @@ Object.keys(componentProperties).forEach((key) => { | ||
} | ||
if (key == 'sdks' || typeof value == 'function' || value == null) { | ||
if (typeof value == 'function' || value == null) { | ||
delete componentProperties[key]; | ||
@@ -119,3 +122,3 @@ } | ||
var _a; | ||
(_a = el.sitecoreContextCallback) === null || _a === void 0 ? void 0 : _a.call(el, parsed); | ||
(_a = el.sitecoreContextCallback) === null || _a === void 0 ? void 0 : _a.call(el, Object.assign(Object.assign({}, contextProperties), parsed)); | ||
}); | ||
@@ -122,0 +125,0 @@ } |
@@ -1,2 +0,2 @@ | ||
var M=(e={})=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[d(r)]:e[r]}),{}),U=(e={})=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[b(r)]:e[r]}),{});function d(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return b(e).replace(t,function(r){return"-"+r.toLowerCase()})}function b(e){return e=e.replace(/[-_ ]+/g," "),e=e.charAt(0).toLowerCase()+e.slice(1),e.split(/\s+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}function h(e,t={}){let r=e.properties||{};return Object.assign(Object.assign({type:"object"},e),{properties:Object.keys(r).reduce((n,o)=>Object.assign(n,{[o]:Object.assign(Object.assign({},r[o]),{default:t.hasOwnProperty(o)?t[o]:r[o].default,title:r[o].title||d(o).split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join(" ")})}),{})})}var j=(e,t)=>{let r=Object.assign({},e);return Object.keys(t).filter(o=>/(integer|number)/.test(t[o].type)).forEach(o=>{var s;!((s=r[o])===null||s===void 0)&&s["ui:widget"]||(r[o]=Object.assign(Object.assign({},r[o]),{"ui:widget":"updown"}))}),r};function O(e,t){switch(t){case"string":return e;case"object":try{return typeof e=="object"&&e!=null?e:JSON.parse(e)}catch(r){return null}case"array":try{return Array.isArray(e)?e:JSON.parse(e)}catch(r){return null}case"number":return parseFloat(e);case"integer":return parseInt(e);case"boolean":return e=="true"||e=="1";default:return e}}function P(e,t){return Object.keys(t).reduce((r,n)=>{let o=t[n],s=b(n),i=e==null?void 0:e.properties[s],c=i==null?void 0:i.type,a=O(o,c);return a!=null&&!n.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(n)?Object.assign(Object.assign({},r),{[s]:a}):r},{})}function v(e,t){return Object.assign(Object.assign({},A(e)),P(e,t))}function A(e){return Object.keys(e.properties).reduce((t,r)=>{var n,o;return((n=e.properties[r])===null||n===void 0?void 0:n.default)!=null?Object.assign(Object.assign({},t),{[r]:(o=e.properties[r])===null||o===void 0?void 0:o.default}):t},{})}var D=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r};function J(e,t,r){let{thumbnail:n="https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg",name:o,id:s=e.name,group:i=null,ui:c,isHidden:a=!1,uiSchema:u,schema:g}=e,l=D(e,["thumbnail","name","id","group","ui","isHidden","uiSchema","schema"]),S=g||l||{},E=u||c||{},p=h(Object.assign(Object.assign({description:"External component"},S),{type:"object"}),r),_=j(E,p.properties||{});return{component:t,name:o,schema:p,uiSchema:_,thumbnail:n,group:i,isHidden:a,id:s,title:(p==null?void 0:p.title)||(l==null?void 0:l.title)||o}}var y,K=typeof HTMLElement!="undefined"?HTMLElement:typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{setAttribute(){}},f=typeof window!="undefined"?window.BYOCComponents||(window.BYOCComponents={}):{};function T(e,t,r={}){if(!(t!=null&&t.name))throw new Error("Could not register external component. Please make sure you provide a name in the options"+JSON.stringify(t));let n=J(t,e,r);f[n.id]=n,L(e)&&m.register("byoc-"+d(t.name),void 0,e),x()}function L(e){return e&&"prototype"in e&&"setAttribute"in e.prototype}function W(e,t={}){var r;let n=(r=w(e))===null||r===void 0?void 0:r.schema,o=Object.assign(Object.assign({},C),t);return n?v(n,o):o}function z(e){let t=w(e);return Object.keys((t==null?void 0:t.schema.properties)||{}).filter(r=>{var n,o;return((o=(n=t==null?void 0:t.uiSchema)===null||n===void 0?void 0:n[r])===null||o===void 0?void 0:o["ui:widget"])!="hidden"})}function w(e){if(typeof e!="string"){if(e&&"schema"in e)return e;throw new Error(`Component name should be a string, got ${typeof e}`)}let[t,r]=e.split("?");var n=f[t];if(r){let o=f[e];if(!o&&!n)return null;o&&(n=Object.assign(Object.assign(Object.assign({},n),o),{component:o.component||(n==null?void 0:n.component)})),r.split(/\&/g).forEach(s=>{var i,c,a;let[u,g]=s.split("="),l=((i=n.schema.properties)===null||i===void 0?void 0:i[u])||{type:"string"};n=Object.assign(Object.assign({},n),{schema:Object.assign(Object.assign({},n.schema),{properties:Object.assign(Object.assign({},n.schema.properties),{[u]:Object.assign(Object.assign({},l),{default:O(decodeURIComponent(g),l.type)})})}),uiSchema:Object.assign(Object.assign({},n.uiSchema),{[u]:Object.assign(Object.assign({},n.uiSchema[u]),{"ui:widget":(a=(c=n.uiSchema[u])===null||c===void 0?void 0:c["ui:widget"])!==null&&a!==void 0?a:"hidden"})})})})}return n}function x(){clearTimeout(y),y=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-components",data:Object.values(f)}),"*"))},30)}x();var m=class extends K{connectedCallback(){try{JSON.parse(String(this.getAttribute("components"))).forEach(t=>{T(null,t)})}catch(t){}}static register(t,r,n=this){r==null&&(r=typeof window!="undefined"?window:void 0),r&&!r.customElements.get(t)&&r.customElements.define(t,class extends n{})}},C={};function R(e){C=e}m.register("byoc-registration");export{m as BYOCRegistration,K as WebComponent,C as contextProperties,w as getComponent,z as getComponentConfigurablePropertyNames,W as getComponentProperties,A as getSchemaDefaults,v as getSchemaProperties,L as isWebComponent,J as normalizeOptions,U as objectKeysToCamelCase,M as objectKeysToKebabCase,P as parseSchemaProperties,O as parseValue,T as registerComponent,f as registered,R as setContextProperties,x as setRegistrationCallback,b as toCamelCase,d as toKebabCase,h as transformSchema,j as transformUiSchema}; | ||
var L=(e={})=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[d(r)]:e[r]}),{}),M=(e={})=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[b(r)]:e[r]}),{});function d(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return b(e).replace(t,function(r){return"-"+r.toLowerCase()})}function b(e){return e=e.replace(/[-_ ]+/g," "),e=e.charAt(0).toLowerCase()+e.slice(1),e.split(/\s+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}function h(e,t={}){let r=e.properties||{};return Object.assign(Object.assign({type:"object"},e),{properties:Object.keys(r).reduce((n,o)=>Object.assign(n,{[o]:Object.assign(Object.assign({},r[o]),{default:t.hasOwnProperty(o)?t[o]:r[o].default,title:r[o].title||d(o).split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join(" ")})}),{})})}var j=(e,t)=>{let r=Object.assign({},e);return Object.keys(t).filter(o=>/(integer|number)/.test(t[o].type)).forEach(o=>{var i;!((i=r[o])===null||i===void 0)&&i["ui:widget"]||(r[o]=Object.assign(Object.assign({},r[o]),{"ui:widget":"updown"}))}),r};function O(e,t){switch(t){case"string":return e;case"object":try{return typeof e=="object"&&e!=null?e:JSON.parse(e)}catch(r){return null}case"array":try{return Array.isArray(e)?e:JSON.parse(e)}catch(r){return null}case"number":return parseFloat(e);case"integer":return parseInt(e);case"boolean":return e=="true"||e=="1";default:return e}}function _(e,t){return Object.keys(t).reduce((r,n)=>{let o=t[n],i=b(n),s=e==null?void 0:e.properties[i],c=s==null?void 0:s.type,a=O(o,c);return a!=null&&!n.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(n)?Object.assign(Object.assign({},r),{[i]:a}):r},{})}function y(e,t){return Object.assign(Object.assign({},P(e)),_(e,t))}function P(e){return Object.keys(e.properties).reduce((t,r)=>{var n,o;return((n=e.properties[r])===null||n===void 0?void 0:n.default)!=null?Object.assign(Object.assign({},t),{[r]:(o=e.properties[r])===null||o===void 0?void 0:o.default}):t},{})}var A=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r};function D(e,t,r){let{thumbnail:n="https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg",name:o,id:i=e.name,group:s=null,ui:c,isHidden:a=!1,uiSchema:u,schema:g}=e,l=A(e,["thumbnail","name","id","group","ui","isHidden","uiSchema","schema"]),C=g||l||{},S=u||c||{},p=h(Object.assign(Object.assign({description:"External component"},C),{type:"object"}),r),E=j(S,p.properties||{});return{component:t,name:o,schema:p,uiSchema:E,thumbnail:n,group:s,isHidden:a,id:i,title:(p==null?void 0:p.title)||(l==null?void 0:l.title)||o}}var v,J=typeof HTMLElement!="undefined"?HTMLElement:typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{setAttribute(){}},f=typeof window!="undefined"?window.BYOCComponents||(window.BYOCComponents={}):{};function K(e,t,r={}){if(!(t!=null&&t.name))throw new Error("Could not register external component. Please make sure you provide a name in the options"+JSON.stringify(t));let n=D(t,e,r);f[n.id]=n,T(e)&&m.register("byoc-"+d(t.name),void 0,e),w()}function T(e){return e&&"prototype"in e&&"setAttribute"in e.prototype}function N(e,t={}){var r;let n=(r=x(e))===null||r===void 0?void 0:r.schema;return n?y(n,t):t}function W(e){let t=x(e);return Object.keys((t==null?void 0:t.schema.properties)||{}).filter(r=>{var n,o;return((o=(n=t==null?void 0:t.uiSchema)===null||n===void 0?void 0:n[r])===null||o===void 0?void 0:o["ui:widget"])!="hidden"})}function x(e){if(typeof e!="string"){if(e&&"schema"in e)return e;throw new Error(`Component name should be a string, got ${typeof e}`)}let[t,r]=e.split("?");var n=f[t];if(r){let o=f[e];if(!o&&!n)return null;o&&(n=Object.assign(Object.assign(Object.assign({},n),o),{component:o.component||(n==null?void 0:n.component)})),r.split(/\&/g).forEach(i=>{var s,c,a;let[u,g]=i.split("="),l=((s=n.schema.properties)===null||s===void 0?void 0:s[u])||{type:"string"};n=Object.assign(Object.assign({},n),{schema:Object.assign(Object.assign({},n.schema),{properties:Object.assign(Object.assign({},n.schema.properties),{[u]:Object.assign(Object.assign({},l),{default:O(decodeURIComponent(g),l.type)})})}),uiSchema:Object.assign(Object.assign({},n.uiSchema),{[u]:Object.assign(Object.assign({},n.uiSchema[u]),{"ui:widget":(a=(c=n.uiSchema[u])===null||c===void 0?void 0:c["ui:widget"])!==null&&a!==void 0?a:"hidden"})})})})}return n}function w(){clearTimeout(v),v=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-components",data:Object.values(f)}),"*"))},30)}w();var m=class extends J{connectedCallback(){try{JSON.parse(String(this.getAttribute("components"))).forEach(t=>{K(null,t)})}catch(t){}}static register(t,r,n=this){r==null&&(r=typeof window!="undefined"?window:void 0),r&&!r.customElements.get(t)&&r.customElements.define(t,class extends n{})}},U={};function R(e){U=e}var V=["sitecoreEdgeUrl","sitecoreEdgeContextId"];m.register("byoc-registration");export{m as BYOCRegistration,J as WebComponent,U as contextProperties,x as getComponent,W as getComponentConfigurablePropertyNames,N as getComponentProperties,P as getSchemaDefaults,y as getSchemaProperties,T as isWebComponent,D as normalizeOptions,M as objectKeysToCamelCase,L as objectKeysToKebabCase,_ as parseSchemaProperties,O as parseValue,K as registerComponent,f as registered,V as serializedContextProperties,R as setContextProperties,w as setRegistrationCallback,b as toCamelCase,d as toKebabCase,h as transformSchema,j as transformUiSchema}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import t from"react";import{getComponent as j,getComponentProperties as E,isWebComponent as C,registered as N}from"@sitecore/byoc";import{objectKeysToKebabCase as h,toKebabCase as _}from"@sitecore/byoc";export*from"@sitecore/byoc";var y=function(e,n){var c={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(c[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(e);r<a.length;r++)n.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(c[a[r]]=e[a[r]]);return c},g=null,b=null;function w(e){var n;let{componentName:c,clientFallback:a}=e,r=y(e,["componentName","clientFallback"]),d=(n=j(c))===null||n===void 0?void 0:n.component,O=t.useMemo(()=>b(()=>Promise.resolve(g),{ssr:!1,loading:()=>t.createElement(v,Object.assign({},r,{componentName:c}))}),[]);return t.createElement(O,Object.assign({},e,{fallback:d?t.createElement(d,Object.assign({},e)):a?t.createElement(b(()=>Promise.resolve(()=>a),{ssr:!1})):e.fallback}))}function S(e,n){return b=e,g=n,n}function H(e){return Object.keys(e).length==0?t.createElement(t.Fragment,null):b&&!e._dynamic?w(Object.assign({_dynamic:!0},e)):v(e)}function K(){return t.createElement(t.Fragment,null,t.createElement("byoc-registration",{components:JSON.stringify(Object.values(N)),suppressHydrationWarning:!0}),t.createElement(g,null))}function v(e){let{componentName:n,className:c,clientFallback:a,fallback:r,suppressHydrationWarning:d,_dynamic:O}=e,x=y(e,["componentName","className","clientFallback","fallback","suppressHydrationWarning","_dynamic"]),m=j(n),s=m==null?void 0:m.component,u=E(n,x),F={parsed:u},i=Object.assign(Object.assign({"data-external-id":n},h(u)),{suppressHydrationWarning:!0,class:c});if(Object.keys(i).forEach(o=>{let l=i[o];if(l&&typeof l=="object"&&o!="class"&&o!="children")try{Object.assign(i,{[o]:JSON.stringify(l)})}catch(f){delete i[o]}(o=="sdks"||typeof l=="function"||l==null)&&delete i[o]}),!s&&r||!n)return t.createElement("feaas-external",Object.assign({},i,{hydrate:"false"}),r);if(s&&C(s)){let o="byoc-"+_(m.id);return t.createElement(o,Object.assign(Object.assign({},i),{ref:l=>{var f;l&&typeof window!="undefined"&&((f=window.customElements)===null||f===void 0||f.whenDefined(o).then(()=>{var p;(p=l.sitecoreContextCallback)===null||p===void 0||p.call(l,u)}))}}))}return t.createElement(t.Fragment,null,t.createElement("feaas-external",Object.assign({},i,{hydrate:"false"}),s==null?null:t.createElement(s,Object.assign({},u))))}export{K as Bundle,H as Component,w as NextComponent,v as RegularComponent,S as enableNextClientsideComponents}; | ||
import t from"react";import{getComponent as C,getComponentProperties as P,isWebComponent as w,registered as F,serializedContextProperties as k}from"@sitecore/byoc";import{objectKeysToKebabCase as j,toKebabCase as v,contextProperties as x}from"@sitecore/byoc";export*from"@sitecore/byoc";var E=function(e,a){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&a.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)a.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(i[r[o]]=e[r[o]]);return i},g=null,b=null;function W(e){var a;let{componentName:i,clientFallback:r}=e,o=E(e,["componentName","clientFallback"]),f=(a=C(i))===null||a===void 0?void 0:a.component,O=t.useMemo(()=>b(()=>Promise.resolve(g),{ssr:!1,loading:()=>t.createElement(N,Object.assign({},o,{componentName:i}))}),[]);return t.createElement(O,Object.assign({},e,{fallback:f?t.createElement(f,Object.assign({},e)):r?t.createElement(b(()=>Promise.resolve(()=>r),{ssr:!1})):e.fallback}))}function R(e,a){return b=e,g=a,a}function A(e){return Object.keys(e).length==0?t.createElement(t.Fragment,null):b&&!e._dynamic?W(Object.assign({_dynamic:!0},e)):N(e)}function D(){return t.createElement(t.Fragment,null,t.createElement("byoc-registration",{components:JSON.stringify(Object.values(F)),suppressHydrationWarning:!0}),t.createElement(g,null))}function N(e){let{componentName:a,className:i,clientFallback:r,fallback:o,suppressHydrationWarning:f,_dynamic:O,datasources:y}=e,h=E(e,["componentName","className","clientFallback","fallback","suppressHydrationWarning","_dynamic","datasources"]),m=C(a),l=m==null?void 0:m.component,d=P(a,h),_=Object.values(y||{}).find(n=>n&&!Array.isArray(n)),c=Object.assign(Object.assign(Object.assign({"data-external-id":a},j(_)),j(d)),{datasources:y,suppressHydrationWarning:!0,class:i});if(k.forEach(n=>{Object.assign(c,{[v(n)]:x[n]})}),Object.keys(c).forEach(n=>{let s=c[n];if(s&&typeof s=="object"&&n!="class"&&n!="children")try{Object.assign(c,{[n]:JSON.stringify(s)})}catch(u){delete c[n]}(typeof s=="function"||s==null)&&delete c[n]}),!l&&o||!a)return t.createElement("feaas-external",Object.assign({},c,{hydrate:"false"}),o);if(l&&w(l)){let n="byoc-"+v(m.id);return t.createElement(n,Object.assign(Object.assign({},c),{ref:s=>{var u;s&&typeof window!="undefined"&&((u=window.customElements)===null||u===void 0||u.whenDefined(n).then(()=>{var p;(p=s.sitecoreContextCallback)===null||p===void 0||p.call(s,Object.assign(Object.assign({},x),d))}))}}))}return t.createElement(t.Fragment,null,t.createElement("feaas-external",Object.assign({},c,{hydrate:"false"}),l==null?null:t.createElement(l,Object.assign({},d))))}export{D as Bundle,A as Component,W as NextComponent,N as RegularComponent,R as enableNextClientsideComponents}; | ||
//# sourceMappingURL=react.esm.js.map |
@@ -1,2 +0,2 @@ | ||
var M=(e={})=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[d(r)]:e[r]}),{}),U=(e={})=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[b(r)]:e[r]}),{});function d(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return b(e).replace(t,function(r){return"-"+r.toLowerCase()})}function b(e){return e=e.replace(/[-_ ]+/g," "),e=e.charAt(0).toLowerCase()+e.slice(1),e.split(/\s+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}function h(e,t={}){let r=e.properties||{};return Object.assign(Object.assign({type:"object"},e),{properties:Object.keys(r).reduce((n,o)=>Object.assign(n,{[o]:Object.assign(Object.assign({},r[o]),{default:t.hasOwnProperty(o)?t[o]:r[o].default,title:r[o].title||d(o).split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join(" ")})}),{})})}var j=(e,t)=>{let r=Object.assign({},e);return Object.keys(t).filter(o=>/(integer|number)/.test(t[o].type)).forEach(o=>{var s;!((s=r[o])===null||s===void 0)&&s["ui:widget"]||(r[o]=Object.assign(Object.assign({},r[o]),{"ui:widget":"updown"}))}),r};function O(e,t){switch(t){case"string":return e;case"object":try{return typeof e=="object"&&e!=null?e:JSON.parse(e)}catch(r){return null}case"array":try{return Array.isArray(e)?e:JSON.parse(e)}catch(r){return null}case"number":return parseFloat(e);case"integer":return parseInt(e);case"boolean":return e=="true"||e=="1";default:return e}}function P(e,t){return Object.keys(t).reduce((r,n)=>{let o=t[n],s=b(n),i=e==null?void 0:e.properties[s],c=i==null?void 0:i.type,a=O(o,c);return a!=null&&!n.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(n)?Object.assign(Object.assign({},r),{[s]:a}):r},{})}function v(e,t){return Object.assign(Object.assign({},A(e)),P(e,t))}function A(e){return Object.keys(e.properties).reduce((t,r)=>{var n,o;return((n=e.properties[r])===null||n===void 0?void 0:n.default)!=null?Object.assign(Object.assign({},t),{[r]:(o=e.properties[r])===null||o===void 0?void 0:o.default}):t},{})}var D=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r};function J(e,t,r){let{thumbnail:n="https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg",name:o,id:s=e.name,group:i=null,ui:c,isHidden:a=!1,uiSchema:u,schema:g}=e,l=D(e,["thumbnail","name","id","group","ui","isHidden","uiSchema","schema"]),S=g||l||{},E=u||c||{},p=h(Object.assign(Object.assign({description:"External component"},S),{type:"object"}),r),_=j(E,p.properties||{});return{component:t,name:o,schema:p,uiSchema:_,thumbnail:n,group:i,isHidden:a,id:s,title:(p==null?void 0:p.title)||(l==null?void 0:l.title)||o}}var y,K=typeof HTMLElement!="undefined"?HTMLElement:typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{setAttribute(){}},f=typeof window!="undefined"?window.BYOCComponents||(window.BYOCComponents={}):{};function T(e,t,r={}){if(!(t!=null&&t.name))throw new Error("Could not register external component. Please make sure you provide a name in the options"+JSON.stringify(t));let n=J(t,e,r);f[n.id]=n,L(e)&&m.register("byoc-"+d(t.name),void 0,e),x()}function L(e){return e&&"prototype"in e&&"setAttribute"in e.prototype}function W(e,t={}){var r;let n=(r=w(e))===null||r===void 0?void 0:r.schema,o=Object.assign(Object.assign({},C),t);return n?v(n,o):o}function z(e){let t=w(e);return Object.keys((t==null?void 0:t.schema.properties)||{}).filter(r=>{var n,o;return((o=(n=t==null?void 0:t.uiSchema)===null||n===void 0?void 0:n[r])===null||o===void 0?void 0:o["ui:widget"])!="hidden"})}function w(e){if(typeof e!="string"){if(e&&"schema"in e)return e;throw new Error(`Component name should be a string, got ${typeof e}`)}let[t,r]=e.split("?");var n=f[t];if(r){let o=f[e];if(!o&&!n)return null;o&&(n=Object.assign(Object.assign(Object.assign({},n),o),{component:o.component||(n==null?void 0:n.component)})),r.split(/\&/g).forEach(s=>{var i,c,a;let[u,g]=s.split("="),l=((i=n.schema.properties)===null||i===void 0?void 0:i[u])||{type:"string"};n=Object.assign(Object.assign({},n),{schema:Object.assign(Object.assign({},n.schema),{properties:Object.assign(Object.assign({},n.schema.properties),{[u]:Object.assign(Object.assign({},l),{default:O(decodeURIComponent(g),l.type)})})}),uiSchema:Object.assign(Object.assign({},n.uiSchema),{[u]:Object.assign(Object.assign({},n.uiSchema[u]),{"ui:widget":(a=(c=n.uiSchema[u])===null||c===void 0?void 0:c["ui:widget"])!==null&&a!==void 0?a:"hidden"})})})})}return n}function x(){clearTimeout(y),y=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-components",data:Object.values(f)}),"*"))},30)}x();var m=class extends K{connectedCallback(){try{JSON.parse(String(this.getAttribute("components"))).forEach(t=>{T(null,t)})}catch(t){}}static register(t,r,n=this){r==null&&(r=typeof window!="undefined"?window:void 0),r&&!r.customElements.get(t)&&r.customElements.define(t,class extends n{})}},C={};function R(e){C=e}m.register("byoc-registration");export{m as BYOCRegistration,K as WebComponent,C as contextProperties,w as getComponent,z as getComponentConfigurablePropertyNames,W as getComponentProperties,A as getSchemaDefaults,v as getSchemaProperties,L as isWebComponent,J as normalizeOptions,U as objectKeysToCamelCase,M as objectKeysToKebabCase,P as parseSchemaProperties,O as parseValue,T as registerComponent,f as registered,R as setContextProperties,x as setRegistrationCallback,b as toCamelCase,d as toKebabCase,h as transformSchema,j as transformUiSchema}; | ||
var L=(e={})=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[d(r)]:e[r]}),{}),M=(e={})=>Object.keys(e).reduce((t,r)=>Object.assign(t,{[b(r)]:e[r]}),{});function d(e){let t=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;return b(e).replace(t,function(r){return"-"+r.toLowerCase()})}function b(e){return e=e.replace(/[-_ ]+/g," "),e=e.charAt(0).toLowerCase()+e.slice(1),e.split(/\s+/).map((t,r)=>r===0?t:t.charAt(0).toUpperCase()+t.slice(1)).join("")}function h(e,t={}){let r=e.properties||{};return Object.assign(Object.assign({type:"object"},e),{properties:Object.keys(r).reduce((n,o)=>Object.assign(n,{[o]:Object.assign(Object.assign({},r[o]),{default:t.hasOwnProperty(o)?t[o]:r[o].default,title:r[o].title||d(o).split("-").map(i=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join(" ")})}),{})})}var j=(e,t)=>{let r=Object.assign({},e);return Object.keys(t).filter(o=>/(integer|number)/.test(t[o].type)).forEach(o=>{var i;!((i=r[o])===null||i===void 0)&&i["ui:widget"]||(r[o]=Object.assign(Object.assign({},r[o]),{"ui:widget":"updown"}))}),r};function O(e,t){switch(t){case"string":return e;case"object":try{return typeof e=="object"&&e!=null?e:JSON.parse(e)}catch(r){return null}case"array":try{return Array.isArray(e)?e:JSON.parse(e)}catch(r){return null}case"number":return parseFloat(e);case"integer":return parseInt(e);case"boolean":return e=="true"||e=="1";default:return e}}function _(e,t){return Object.keys(t).reduce((r,n)=>{let o=t[n],i=b(n),s=e==null?void 0:e.properties[i],c=s==null?void 0:s.type,a=O(o,c);return a!=null&&!n.startsWith("data-attribute")&&!["class","id","contenteditable"].includes(n)?Object.assign(Object.assign({},r),{[i]:a}):r},{})}function y(e,t){return Object.assign(Object.assign({},P(e)),_(e,t))}function P(e){return Object.keys(e.properties).reduce((t,r)=>{var n,o;return((n=e.properties[r])===null||n===void 0?void 0:n.default)!=null?Object.assign(Object.assign({},t),{[r]:(o=e.properties[r])===null||o===void 0?void 0:o.default}):t},{})}var A=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r};function D(e,t,r){let{thumbnail:n="https://feaasstatic.blob.core.windows.net/assets/thumbnails/byoc.svg",name:o,id:i=e.name,group:s=null,ui:c,isHidden:a=!1,uiSchema:u,schema:g}=e,l=A(e,["thumbnail","name","id","group","ui","isHidden","uiSchema","schema"]),C=g||l||{},S=u||c||{},p=h(Object.assign(Object.assign({description:"External component"},C),{type:"object"}),r),E=j(S,p.properties||{});return{component:t,name:o,schema:p,uiSchema:E,thumbnail:n,group:s,isHidden:a,id:i,title:(p==null?void 0:p.title)||(l==null?void 0:l.title)||o}}var v,J=typeof HTMLElement!="undefined"?HTMLElement:typeof windowJSDOM!="undefined"?windowJSDOM.HTMLElement:class{setAttribute(){}},f=typeof window!="undefined"?window.BYOCComponents||(window.BYOCComponents={}):{};function K(e,t,r={}){if(!(t!=null&&t.name))throw new Error("Could not register external component. Please make sure you provide a name in the options"+JSON.stringify(t));let n=D(t,e,r);f[n.id]=n,T(e)&&m.register("byoc-"+d(t.name),void 0,e),w()}function T(e){return e&&"prototype"in e&&"setAttribute"in e.prototype}function N(e,t={}){var r;let n=(r=x(e))===null||r===void 0?void 0:r.schema;return n?y(n,t):t}function W(e){let t=x(e);return Object.keys((t==null?void 0:t.schema.properties)||{}).filter(r=>{var n,o;return((o=(n=t==null?void 0:t.uiSchema)===null||n===void 0?void 0:n[r])===null||o===void 0?void 0:o["ui:widget"])!="hidden"})}function x(e){if(typeof e!="string"){if(e&&"schema"in e)return e;throw new Error(`Component name should be a string, got ${typeof e}`)}let[t,r]=e.split("?");var n=f[t];if(r){let o=f[e];if(!o&&!n)return null;o&&(n=Object.assign(Object.assign(Object.assign({},n),o),{component:o.component||(n==null?void 0:n.component)})),r.split(/\&/g).forEach(i=>{var s,c,a;let[u,g]=i.split("="),l=((s=n.schema.properties)===null||s===void 0?void 0:s[u])||{type:"string"};n=Object.assign(Object.assign({},n),{schema:Object.assign(Object.assign({},n.schema),{properties:Object.assign(Object.assign({},n.schema.properties),{[u]:Object.assign(Object.assign({},l),{default:O(decodeURIComponent(g),l.type)})})}),uiSchema:Object.assign(Object.assign({},n.uiSchema),{[u]:Object.assign(Object.assign({},n.uiSchema[u]),{"ui:widget":(a=(c=n.uiSchema[u])===null||c===void 0?void 0:c["ui:widget"])!==null&&a!==void 0?a:"hidden"})})})})}return n}function w(){clearTimeout(v),v=setTimeout(()=>{var e;typeof window!="undefined"&&window.parent!==window&&((e=window.parent)===null||e===void 0||e.postMessage(JSON.stringify({action:"register-components",data:Object.values(f)}),"*"))},30)}w();var m=class extends J{connectedCallback(){try{JSON.parse(String(this.getAttribute("components"))).forEach(t=>{K(null,t)})}catch(t){}}static register(t,r,n=this){r==null&&(r=typeof window!="undefined"?window:void 0),r&&!r.customElements.get(t)&&r.customElements.define(t,class extends n{})}},U={};function R(e){U=e}var V=["sitecoreEdgeUrl","sitecoreEdgeContextId"];m.register("byoc-registration");export{m as BYOCRegistration,J as WebComponent,U as contextProperties,x as getComponent,W as getComponentConfigurablePropertyNames,N as getComponentProperties,P as getSchemaDefaults,y as getSchemaProperties,T as isWebComponent,D as normalizeOptions,M as objectKeysToCamelCase,L as objectKeysToKebabCase,_ as parseSchemaProperties,O as parseValue,K as registerComponent,f as registered,V as serializedContextProperties,R as setContextProperties,w as setRegistrationCallback,b as toCamelCase,d as toKebabCase,h as transformSchema,j as transformUiSchema}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import t from"react";import{getComponent as j,getComponentProperties as E,isWebComponent as C,registered as N}from"@sitecore/byoc";import{objectKeysToKebabCase as h,toKebabCase as _}from"@sitecore/byoc";export*from"@sitecore/byoc";var y=function(e,n){var c={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(c[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(e);r<a.length;r++)n.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(c[a[r]]=e[a[r]]);return c},g=null,b=null;function w(e){var n;let{componentName:c,clientFallback:a}=e,r=y(e,["componentName","clientFallback"]),d=(n=j(c))===null||n===void 0?void 0:n.component,O=t.useMemo(()=>b(()=>Promise.resolve(g),{ssr:!1,loading:()=>t.createElement(v,Object.assign({},r,{componentName:c}))}),[]);return t.createElement(O,Object.assign({},e,{fallback:d?t.createElement(d,Object.assign({},e)):a?t.createElement(b(()=>Promise.resolve(()=>a),{ssr:!1})):e.fallback}))}function S(e,n){return b=e,g=n,n}function H(e){return Object.keys(e).length==0?t.createElement(t.Fragment,null):b&&!e._dynamic?w(Object.assign({_dynamic:!0},e)):v(e)}function K(){return t.createElement(t.Fragment,null,t.createElement("byoc-registration",{components:JSON.stringify(Object.values(N)),suppressHydrationWarning:!0}),t.createElement(g,null))}function v(e){let{componentName:n,className:c,clientFallback:a,fallback:r,suppressHydrationWarning:d,_dynamic:O}=e,x=y(e,["componentName","className","clientFallback","fallback","suppressHydrationWarning","_dynamic"]),m=j(n),s=m==null?void 0:m.component,u=E(n,x),F={parsed:u},i=Object.assign(Object.assign({"data-external-id":n},h(u)),{suppressHydrationWarning:!0,class:c});if(Object.keys(i).forEach(o=>{let l=i[o];if(l&&typeof l=="object"&&o!="class"&&o!="children")try{Object.assign(i,{[o]:JSON.stringify(l)})}catch(f){delete i[o]}(o=="sdks"||typeof l=="function"||l==null)&&delete i[o]}),!s&&r||!n)return t.createElement("feaas-external",Object.assign({},i,{hydrate:"false"}),r);if(s&&C(s)){let o="byoc-"+_(m.id);return t.createElement(o,Object.assign(Object.assign({},i),{ref:l=>{var f;l&&typeof window!="undefined"&&((f=window.customElements)===null||f===void 0||f.whenDefined(o).then(()=>{var p;(p=l.sitecoreContextCallback)===null||p===void 0||p.call(l,u)}))}}))}return t.createElement(t.Fragment,null,t.createElement("feaas-external",Object.assign({},i,{hydrate:"false"}),s==null?null:t.createElement(s,Object.assign({},u))))}export{K as Bundle,H as Component,w as NextComponent,v as RegularComponent,S as enableNextClientsideComponents}; | ||
import t from"react";import{getComponent as C,getComponentProperties as P,isWebComponent as w,registered as F,serializedContextProperties as k}from"@sitecore/byoc";import{objectKeysToKebabCase as j,toKebabCase as v,contextProperties as x}from"@sitecore/byoc";export*from"@sitecore/byoc";var E=function(e,a){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&a.indexOf(r)<0&&(i[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)a.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(i[r[o]]=e[r[o]]);return i},g=null,b=null;function W(e){var a;let{componentName:i,clientFallback:r}=e,o=E(e,["componentName","clientFallback"]),f=(a=C(i))===null||a===void 0?void 0:a.component,O=t.useMemo(()=>b(()=>Promise.resolve(g),{ssr:!1,loading:()=>t.createElement(N,Object.assign({},o,{componentName:i}))}),[]);return t.createElement(O,Object.assign({},e,{fallback:f?t.createElement(f,Object.assign({},e)):r?t.createElement(b(()=>Promise.resolve(()=>r),{ssr:!1})):e.fallback}))}function R(e,a){return b=e,g=a,a}function A(e){return Object.keys(e).length==0?t.createElement(t.Fragment,null):b&&!e._dynamic?W(Object.assign({_dynamic:!0},e)):N(e)}function D(){return t.createElement(t.Fragment,null,t.createElement("byoc-registration",{components:JSON.stringify(Object.values(F)),suppressHydrationWarning:!0}),t.createElement(g,null))}function N(e){let{componentName:a,className:i,clientFallback:r,fallback:o,suppressHydrationWarning:f,_dynamic:O,datasources:y}=e,h=E(e,["componentName","className","clientFallback","fallback","suppressHydrationWarning","_dynamic","datasources"]),m=C(a),l=m==null?void 0:m.component,d=P(a,h),_=Object.values(y||{}).find(n=>n&&!Array.isArray(n)),c=Object.assign(Object.assign(Object.assign({"data-external-id":a},j(_)),j(d)),{datasources:y,suppressHydrationWarning:!0,class:i});if(k.forEach(n=>{Object.assign(c,{[v(n)]:x[n]})}),Object.keys(c).forEach(n=>{let s=c[n];if(s&&typeof s=="object"&&n!="class"&&n!="children")try{Object.assign(c,{[n]:JSON.stringify(s)})}catch(u){delete c[n]}(typeof s=="function"||s==null)&&delete c[n]}),!l&&o||!a)return t.createElement("feaas-external",Object.assign({},c,{hydrate:"false"}),o);if(l&&w(l)){let n="byoc-"+v(m.id);return t.createElement(n,Object.assign(Object.assign({},c),{ref:s=>{var u;s&&typeof window!="undefined"&&((u=window.customElements)===null||u===void 0||u.whenDefined(n).then(()=>{var p;(p=s.sitecoreContextCallback)===null||p===void 0||p.call(s,Object.assign(Object.assign({},x),d))}))}}))}return t.createElement(t.Fragment,null,t.createElement("feaas-external",Object.assign({},c,{hydrate:"false"}),l==null?null:t.createElement(l,Object.assign({},d))))}export{D as Bundle,A as Component,W as NextComponent,N as RegularComponent,R as enableNextClientsideComponents}; | ||
//# sourceMappingURL=react.esm.js.map |
@@ -5,3 +5,3 @@ { | ||
"description": "Bring-Your-Own-Components runtime to register and retrieve react components", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "test": "npx vitest", |
@@ -1,2 +0,2 @@ | ||
"use strict";var F=Object.create;var O=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of k(t))!S.call(e,o)&&o!==n&&O(e,o,{get:()=>t[o],enumerable:!(r=P(t,o))||r.enumerable});return e},c=(e,t,n)=>(g(e,t,"default"),n&&g(n,t,"default")),K=(e,t,n)=>(n=e!=null?F(W(e)):{},g(t||!e||!e.__esModule?O(n,"default",{value:e,enumerable:!0}):n,e)),D=e=>g(O({},"__esModule",{value:!0}),e);var l={};H(l,{Bundle:()=>B,Component:()=>J,NextComponent:()=>_,RegularComponent:()=>C,enableNextClientsideComponents:()=>R});module.exports=D(l);var a=K(require("react"),1),m=require("@sitecore/byoc"),j=require("@sitecore/byoc");c(l,require("@sitecore/byoc"),module.exports);var h=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n},E=null,y=null;function _(e){var t;let{componentName:n,clientFallback:r}=e,o=h(e,["componentName","clientFallback"]),v=(t=(0,m.getComponent)(n))===null||t===void 0?void 0:t.component,N=a.default.useMemo(()=>y(()=>Promise.resolve(E),{ssr:!1,loading:()=>a.default.createElement(C,Object.assign({},o,{componentName:n}))}),[]);return a.default.createElement(N,Object.assign({},e,{fallback:v?a.default.createElement(v,Object.assign({},e)):r?a.default.createElement(y(()=>Promise.resolve(()=>r),{ssr:!1})):e.fallback}))}function R(e,t){return y=e,E=t,t}function J(e){return Object.keys(e).length==0?a.default.createElement(a.default.Fragment,null):y&&!e._dynamic?_(Object.assign({_dynamic:!0},e)):C(e)}function B(){return a.default.createElement(a.default.Fragment,null,a.default.createElement("byoc-registration",{components:JSON.stringify(Object.values(m.registered)),suppressHydrationWarning:!0}),a.default.createElement(E,null))}function C(e){let{componentName:t,className:n,clientFallback:r,fallback:o,suppressHydrationWarning:v,_dynamic:N}=e,w=h(e,["componentName","className","clientFallback","fallback","suppressHydrationWarning","_dynamic"]),b=(0,m.getComponent)(t),f=b==null?void 0:b.component,d=(0,m.getComponentProperties)(t,w),I={parsed:d},u=Object.assign(Object.assign({"data-external-id":t},(0,j.objectKeysToKebabCase)(d)),{suppressHydrationWarning:!0,class:n});if(Object.keys(u).forEach(i=>{let s=u[i];if(s&&typeof s=="object"&&i!="class"&&i!="children")try{Object.assign(u,{[i]:JSON.stringify(s)})}catch(p){delete u[i]}(i=="sdks"||typeof s=="function"||s==null)&&delete u[i]}),!f&&o||!t)return a.default.createElement("feaas-external",Object.assign({},u,{hydrate:"false"}),o);if(f&&(0,m.isWebComponent)(f)){let i="byoc-"+(0,j.toKebabCase)(b.id);return a.default.createElement(i,Object.assign(Object.assign({},u),{ref:s=>{var p;s&&typeof window!="undefined"&&((p=window.customElements)===null||p===void 0||p.whenDefined(i).then(()=>{var x;(x=s.sitecoreContextCallback)===null||x===void 0||x.call(s,d)}))}}))}return a.default.createElement(a.default.Fragment,null,a.default.createElement("feaas-external",Object.assign({},u,{hydrate:"false"}),f==null?null:a.default.createElement(f,Object.assign({},d))))} | ||
"use strict";var k=Object.create;var O=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of H(t))!K.call(e,o)&&o!==n&&O(e,o,{get:()=>t[o],enumerable:!(r=W(t,o))||r.enumerable});return e},i=(e,t,n)=>(g(e,t,"default"),n&&g(n,t,"default")),A=(e,t,n)=>(n=e!=null?k(S(e)):{},g(t||!e||!e.__esModule?O(n,"default",{value:e,enumerable:!0}):n,e)),D=e=>g(O({},"__esModule",{value:!0}),e);var s={};R(s,{Bundle:()=>B,Component:()=>z,NextComponent:()=>P,RegularComponent:()=>C,enableNextClientsideComponents:()=>J});module.exports=D(s);var a=A(require("react"),1),l=require("@sitecore/byoc"),b=require("@sitecore/byoc");i(s,require("@sitecore/byoc"),module.exports);var _=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n},E=null,y=null;function P(e){var t;let{componentName:n,clientFallback:r}=e,o=_(e,["componentName","clientFallback"]),j=(t=(0,l.getComponent)(n))===null||t===void 0?void 0:t.component,N=a.default.useMemo(()=>y(()=>Promise.resolve(E),{ssr:!1,loading:()=>a.default.createElement(C,Object.assign({},o,{componentName:n}))}),[]);return a.default.createElement(N,Object.assign({},e,{fallback:j?a.default.createElement(j,Object.assign({},e)):r?a.default.createElement(y(()=>Promise.resolve(()=>r),{ssr:!1})):e.fallback}))}function J(e,t){return y=e,E=t,t}function z(e){return Object.keys(e).length==0?a.default.createElement(a.default.Fragment,null):y&&!e._dynamic?P(Object.assign({_dynamic:!0},e)):C(e)}function B(){return a.default.createElement(a.default.Fragment,null,a.default.createElement("byoc-registration",{components:JSON.stringify(Object.values(l.registered)),suppressHydrationWarning:!0}),a.default.createElement(E,null))}function C(e){let{componentName:t,className:n,clientFallback:r,fallback:o,suppressHydrationWarning:j,_dynamic:N,datasources:h}=e,w=_(e,["componentName","className","clientFallback","fallback","suppressHydrationWarning","_dynamic","datasources"]),d=(0,l.getComponent)(t),f=d==null?void 0:d.component,v=(0,l.getComponentProperties)(t,w),F=Object.values(h||{}).find(c=>c&&!Array.isArray(c)),m=Object.assign(Object.assign(Object.assign({"data-external-id":t},(0,b.objectKeysToKebabCase)(F)),(0,b.objectKeysToKebabCase)(v)),{datasources:h,suppressHydrationWarning:!0,class:n});if(l.serializedContextProperties.forEach(c=>{Object.assign(m,{[(0,b.toKebabCase)(c)]:b.contextProperties[c]})}),Object.keys(m).forEach(c=>{let u=m[c];if(u&&typeof u=="object"&&c!="class"&&c!="children")try{Object.assign(m,{[c]:JSON.stringify(u)})}catch(p){delete m[c]}(typeof u=="function"||u==null)&&delete m[c]}),!f&&o||!t)return a.default.createElement("feaas-external",Object.assign({},m,{hydrate:"false"}),o);if(f&&(0,l.isWebComponent)(f)){let c="byoc-"+(0,b.toKebabCase)(d.id);return a.default.createElement(c,Object.assign(Object.assign({},m),{ref:u=>{var p;u&&typeof window!="undefined"&&((p=window.customElements)===null||p===void 0||p.whenDefined(c).then(()=>{var x;(x=u.sitecoreContextCallback)===null||x===void 0||x.call(u,Object.assign(Object.assign({},b.contextProperties),v))}))}}))}return a.default.createElement(a.default.Fragment,null,a.default.createElement("feaas-external",Object.assign({},m,{hydrate:"false"}),f==null?null:a.default.createElement(f,Object.assign({},v))))} | ||
//# sourceMappingURL=react.js.map |
@@ -266,8 +266,4 @@ import { | ||
export function getComponentProperties(id: string | ExternalComponent, props: Record<string, any> = {}): Record<string, any> { | ||
const schema = getComponent(id)?.schema | ||
const givenProps = { | ||
...contextProperties, | ||
...props | ||
} | ||
return schema ? getSchemaProperties(schema, givenProps) : givenProps; | ||
const schema = getComponent(id)?.schema | ||
return schema ? getSchemaProperties(schema, props) : props; | ||
} | ||
@@ -380,2 +376,4 @@ | ||
export const serializedContextProperties = ['sitecoreEdgeUrl', 'sitecoreEdgeContextId']; | ||
BYOCRegistration.register('byoc-registration') | ||
@@ -382,0 +380,0 @@ |
@@ -193,2 +193,3 @@ /// <reference types="@types/react" /> | ||
export declare function setContextProperties(props: ContextProperties): void; | ||
export declare const serializedContextProperties: string[]; | ||
declare global { | ||
@@ -195,0 +196,0 @@ namespace JSX { |
@@ -8,2 +8,3 @@ /// <reference types="@types/react" /> | ||
clientFallback?: any; | ||
datasources?: Record<string, any>; | ||
[prop: string]: any; | ||
@@ -10,0 +11,0 @@ } |
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
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
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
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
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
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
390019
1920