Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bloomreach/react-sdk

Package Overview
Dependencies
Maintainers
35
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bloomreach/react-sdk - npm Package Compare versions

Comparing version 15.0.1-0 to 15.1.0

2

dist/index.d.ts

@@ -23,3 +23,3 @@ import * as _bloomreach_spa_sdk from '@bloomreach/spa-sdk';

declare class BrComponent$1 extends React.Component<BrComponentProps> {
static contextType: React.Context<_bloomreach_spa_sdk.Component | undefined>;
static contextType: React.Context<Component | undefined>;
context: React.ContextType<typeof BrComponentContext>;

@@ -26,0 +26,0 @@ private getComponents;

@@ -16,3 +16,3 @@ import React, { useRef, useEffect } from "react";

if (!((_a = head.current) === null || _a === void 0 ? void 0 : _a.nextSibling) || !tail.current) {
return;
return undefined;
}

@@ -55,7 +55,7 @@ return meta.render(head.current.nextSibling, tail.current);

function BrContainerBox(props) {
function BrContainerBox({page, children}) {
return React.createElement("div", {
className: props.page.isPreview() ? "hst-container" : undefined
}, React.Children.map(props.children, (child => React.createElement("div", {
className: props.page.isPreview() ? "hst-container-item" : undefined
className: page.isPreview() ? "hst-container" : undefined
}, React.Children.map(children, (child => React.createElement("div", {
className: page.isPreview() ? "hst-container-item" : undefined
}, child))));

@@ -65,31 +65,32 @@ }

function BrContainerInline(props) {
const {page, children} = props;
return React.createElement("div", {
className: props.page.isPreview() ? "hst-container" : undefined
}, React.Children.map(props.children, (child => React.createElement("span", {
className: props.page.isPreview() ? "hst-container-item" : undefined
className: page.isPreview() ? "hst-container" : undefined
}, React.Children.map(children, (child => React.createElement("span", {
className: page.isPreview() ? "hst-container-item" : undefined
}, child))));
}
function BrContainerNoMarkup(props) {
return React.createElement(React.Fragment, null, props.children);
function BrContainerNoMarkup({children}) {
return React.createElement(React.Fragment, null, children);
}
function BrContainerOrderedList(props) {
function BrContainerOrderedList({page, children}) {
return React.createElement("ol", {
className: props.page.isPreview() ? "hst-container" : undefined
}, React.Children.map(props.children, (child => React.createElement("li", {
className: props.page.isPreview() ? "hst-container-item" : undefined
className: page.isPreview() ? "hst-container" : undefined
}, React.Children.map(children, (child => React.createElement("li", {
className: page.isPreview() ? "hst-container-item" : undefined
}, child))));
}
function BrContainerUnorderedList(props) {
function BrContainerUnorderedList({page, children}) {
return React.createElement("ul", {
className: props.page.isPreview() ? "hst-container" : undefined
}, React.Children.map(props.children, (child => React.createElement("li", {
className: props.page.isPreview() ? "hst-container-item" : undefined
className: page.isPreview() ? "hst-container" : undefined
}, React.Children.map(children, (child => React.createElement("li", {
className: page.isPreview() ? "hst-container-item" : undefined
}, child))));
}
function BrContainerItemUndefined(props) {
return React.createElement("div", null, `Component "${props.component.getType()}" is not defined.`);
function BrContainerItemUndefined({component}) {
return React.createElement("div", null, `Component "${component.getType()}" is not defined.`);
}

@@ -101,5 +102,5 @@

render() {
var _a;
return ((_a = this.context) === null || _a === void 0 ? void 0 : _a.isPreview()) ? React.createElement(BrMeta, {
meta: this.context.getButton(TYPE_MANAGE_CONTENT_BUTTON, this.props)
const {context} = this;
return (context === null || context === void 0 ? void 0 : context.isPreview()) ? React.createElement(BrMeta, {
meta: context.getButton(TYPE_MANAGE_CONTENT_BUTTON, this.props)
}) : null;

@@ -115,5 +116,5 @@ }

render() {
var _a;
return ((_a = this.context) === null || _a === void 0 ? void 0 : _a.isPreview()) ? React.createElement(BrMeta, {
meta: this.context.getButton(TYPE_MANAGE_MENU_BUTTON, this.props.menu)
const {context, props: {menu}} = this;
return (context === null || context === void 0 ? void 0 : context.isPreview()) ? React.createElement(BrMeta, {
meta: context.getButton(TYPE_MANAGE_MENU_BUTTON, menu)
}) : null;

@@ -182,31 +183,33 @@ }

renderNode() {
if (React.Children.count(this.props.children)) {
return this.props.children;
const {children, component} = this.props;
if (React.Children.count(children)) {
return children;
}
const children = this.props.component.getChildren().map(((child, index) => React.createElement(BrNode, {
const childrenList = component.getChildren().map(((child, index) => React.createElement(BrNode, {
key: index,
component: child
})));
if (isContainer(this.props.component)) {
if (isContainer(component)) {
return React.createElement(BrNodeContainer, {
component: this.props.component,
component,
page: this.context
}, children);
}, childrenList);
}
if (isContainerItem(this.props.component)) {
if (isContainerItem(component)) {
return React.createElement(BrNodeContainerItem, {
component: this.props.component,
component,
page: this.context
}, children);
}, childrenList);
}
return React.createElement(BrNodeComponent, {
component: this.props.component,
component,
page: this.context
}, children);
}, childrenList);
}
render() {
const {component} = this.props;
return React.createElement(BrComponentContext.Provider, {
value: this.props.component
value: component
}, React.createElement(BrMeta, {
meta: this.props.component.getMeta()
meta: component.getMeta()
}, this.renderNode()));

@@ -222,16 +225,18 @@ }

getComponents() {
if (!this.context) {
const {context, props: {path}} = this;
if (!context) {
return [];
}
if (!this.props.path) {
return this.context.getChildren();
if (!path) {
return context.getChildren();
}
const component = this.context.getComponent(...this.props.path.split("/"));
const component = context.getComponent(...path.split("/"));
return component ? [ component ] : [];
}
renderComponents() {
const {children} = this.props;
return this.getComponents().map(((component, index) => React.createElement(BrNode, {
key: index,
component
}, this.props.children)));
}, children)));
}

@@ -293,18 +298,18 @@ render() {

componentDidMount() {
var _a;
if (!this.props.page) {
const {page} = this.props;
if (!page) {
this.initialize();
}
(_a = this.state.page) === null || _a === void 0 ? void 0 : _a.sync();
const {page: pageInState} = this.state;
pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync();
}
componentDidUpdate(prevProps, prevState) {
if (this.props.configuration !== prevProps.configuration || this.props.page !== prevProps.page) {
const {configuration, page} = this.props;
if (configuration !== prevProps.configuration || page !== prevProps.page) {
this.destroy();
this.initialize(this.props.page === prevProps.page);
this.initialize(page === prevProps.page);
}
if (this.state.page !== prevState.page) {
this.forceUpdate((() => {
var _a;
return (_a = this.state.page) === null || _a === void 0 ? void 0 : _a.sync();
}));
const {page: pageInState} = this.state;
if (pageInState !== prevState.page) {
this.forceUpdate((() => pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync()));
}

@@ -317,6 +322,7 @@ }

return __awaiter(this, void 0, void 0, (function*() {
const model = force ? undefined : this.props.page;
const {page, configuration} = this.props;
const model = force ? undefined : page;
try {
this.setState({
page: model ? initialize(this.props.configuration, model) : yield initialize(this.props.configuration)
page: model ? initialize(configuration, model) : yield initialize(configuration)
});

@@ -331,18 +337,21 @@ } catch (error) {

destroy() {
if (!this.state.page) {
const {page} = this.state;
if (!page) {
return;
}
destroy(this.state.page);
destroy(page);
}
render() {
if (!this.state.page) {
const {page} = this.state;
if (!page) {
return null;
}
const {mapping, children} = this.props;
return React.createElement(BrPageContext.Provider, {
value: this.state.page
value: page
}, React.createElement(BrMappingContext.Provider, {
value: this.props.mapping
value: mapping
}, React.createElement(BrNode, {
component: this.state.page.getComponent()
}, this.props.children)));
component: page.getComponent()
}, children)));
}

@@ -349,0 +358,0 @@ }

@@ -22,3 +22,3 @@ (function(global, factory) {

if (!((_a = head.current) === null || _a === void 0 ? void 0 : _a.nextSibling) || !tail.current) {
return;
return undefined;
}

@@ -56,35 +56,36 @@ return meta.render(head.current.nextSibling, tail.current);

BrNodeComponent.contextType = BrMappingContext;
function BrContainerBox(props) {
function BrContainerBox({page, children}) {
return React__default["default"].createElement("div", {
className: props.page.isPreview() ? "hst-container" : undefined
}, React__default["default"].Children.map(props.children, (child => React__default["default"].createElement("div", {
className: props.page.isPreview() ? "hst-container-item" : undefined
className: page.isPreview() ? "hst-container" : undefined
}, React__default["default"].Children.map(children, (child => React__default["default"].createElement("div", {
className: page.isPreview() ? "hst-container-item" : undefined
}, child))));
}
function BrContainerInline(props) {
const {page, children} = props;
return React__default["default"].createElement("div", {
className: props.page.isPreview() ? "hst-container" : undefined
}, React__default["default"].Children.map(props.children, (child => React__default["default"].createElement("span", {
className: props.page.isPreview() ? "hst-container-item" : undefined
className: page.isPreview() ? "hst-container" : undefined
}, React__default["default"].Children.map(children, (child => React__default["default"].createElement("span", {
className: page.isPreview() ? "hst-container-item" : undefined
}, child))));
}
function BrContainerNoMarkup(props) {
return React__default["default"].createElement(React__default["default"].Fragment, null, props.children);
function BrContainerNoMarkup({children}) {
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
}
function BrContainerOrderedList(props) {
function BrContainerOrderedList({page, children}) {
return React__default["default"].createElement("ol", {
className: props.page.isPreview() ? "hst-container" : undefined
}, React__default["default"].Children.map(props.children, (child => React__default["default"].createElement("li", {
className: props.page.isPreview() ? "hst-container-item" : undefined
className: page.isPreview() ? "hst-container" : undefined
}, React__default["default"].Children.map(children, (child => React__default["default"].createElement("li", {
className: page.isPreview() ? "hst-container-item" : undefined
}, child))));
}
function BrContainerUnorderedList(props) {
function BrContainerUnorderedList({page, children}) {
return React__default["default"].createElement("ul", {
className: props.page.isPreview() ? "hst-container" : undefined
}, React__default["default"].Children.map(props.children, (child => React__default["default"].createElement("li", {
className: props.page.isPreview() ? "hst-container-item" : undefined
className: page.isPreview() ? "hst-container" : undefined
}, React__default["default"].Children.map(children, (child => React__default["default"].createElement("li", {
className: page.isPreview() ? "hst-container-item" : undefined
}, child))));
}
function BrContainerItemUndefined(props) {
return React__default["default"].createElement("div", null, `Component "${props.component.getType()}" is not defined.`);
function BrContainerItemUndefined({component}) {
return React__default["default"].createElement("div", null, `Component "${component.getType()}" is not defined.`);
}

@@ -95,5 +96,5 @@ /**

render() {
var _a;
return ((_a = this.context) === null || _a === void 0 ? void 0 : _a.isPreview()) ? React__default["default"].createElement(BrMeta, {
meta: this.context.getButton(spaSdk.TYPE_MANAGE_CONTENT_BUTTON, this.props)
const {context} = this;
return (context === null || context === void 0 ? void 0 : context.isPreview()) ? React__default["default"].createElement(BrMeta, {
meta: context.getButton(spaSdk.TYPE_MANAGE_CONTENT_BUTTON, this.props)
}) : null;

@@ -107,5 +108,5 @@ }

render() {
var _a;
return ((_a = this.context) === null || _a === void 0 ? void 0 : _a.isPreview()) ? React__default["default"].createElement(BrMeta, {
meta: this.context.getButton(spaSdk.TYPE_MANAGE_MENU_BUTTON, this.props.menu)
const {context, props: {menu}} = this;
return (context === null || context === void 0 ? void 0 : context.isPreview()) ? React__default["default"].createElement(BrMeta, {
meta: context.getButton(spaSdk.TYPE_MANAGE_MENU_BUTTON, menu)
}) : null;

@@ -170,31 +171,33 @@ }

renderNode() {
if (React__default["default"].Children.count(this.props.children)) {
return this.props.children;
const {children, component} = this.props;
if (React__default["default"].Children.count(children)) {
return children;
}
const children = this.props.component.getChildren().map(((child, index) => React__default["default"].createElement(BrNode, {
const childrenList = component.getChildren().map(((child, index) => React__default["default"].createElement(BrNode, {
key: index,
component: child
})));
if (spaSdk.isContainer(this.props.component)) {
if (spaSdk.isContainer(component)) {
return React__default["default"].createElement(BrNodeContainer, {
component: this.props.component,
component,
page: this.context
}, children);
}, childrenList);
}
if (spaSdk.isContainerItem(this.props.component)) {
if (spaSdk.isContainerItem(component)) {
return React__default["default"].createElement(BrNodeContainerItem, {
component: this.props.component,
component,
page: this.context
}, children);
}, childrenList);
}
return React__default["default"].createElement(BrNodeComponent, {
component: this.props.component,
component,
page: this.context
}, children);
}, childrenList);
}
render() {
const {component} = this.props;
return React__default["default"].createElement(BrComponentContext.Provider, {
value: this.props.component
value: component
}, React__default["default"].createElement(BrMeta, {
meta: this.props.component.getMeta()
meta: component.getMeta()
}, this.renderNode()));

@@ -208,16 +211,18 @@ }

getComponents() {
if (!this.context) {
const {context, props: {path}} = this;
if (!context) {
return [];
}
if (!this.props.path) {
return this.context.getChildren();
if (!path) {
return context.getChildren();
}
const component = this.context.getComponent(...this.props.path.split("/"));
const component = context.getComponent(...path.split("/"));
return component ? [ component ] : [];
}
renderComponents() {
const {children} = this.props;
return this.getComponents().map(((component, index) => React__default["default"].createElement(BrNode, {
key: index,
component
}, this.props.children)));
}, children)));
}

@@ -276,18 +281,18 @@ render() {

componentDidMount() {
var _a;
if (!this.props.page) {
const {page} = this.props;
if (!page) {
this.initialize();
}
(_a = this.state.page) === null || _a === void 0 ? void 0 : _a.sync();
const {page: pageInState} = this.state;
pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync();
}
componentDidUpdate(prevProps, prevState) {
if (this.props.configuration !== prevProps.configuration || this.props.page !== prevProps.page) {
const {configuration, page} = this.props;
if (configuration !== prevProps.configuration || page !== prevProps.page) {
this.destroy();
this.initialize(this.props.page === prevProps.page);
this.initialize(page === prevProps.page);
}
if (this.state.page !== prevState.page) {
this.forceUpdate((() => {
var _a;
return (_a = this.state.page) === null || _a === void 0 ? void 0 : _a.sync();
}));
const {page: pageInState} = this.state;
if (pageInState !== prevState.page) {
this.forceUpdate((() => pageInState === null || pageInState === void 0 ? void 0 : pageInState.sync()));
}

@@ -300,6 +305,7 @@ }

return __awaiter(this, void 0, void 0, (function*() {
const model = force ? undefined : this.props.page;
const {page, configuration} = this.props;
const model = force ? undefined : page;
try {
this.setState({
page: model ? spaSdk.initialize(this.props.configuration, model) : yield spaSdk.initialize(this.props.configuration)
page: model ? spaSdk.initialize(configuration, model) : yield spaSdk.initialize(configuration)
});

@@ -314,18 +320,21 @@ } catch (error) {

destroy() {
if (!this.state.page) {
const {page} = this.state;
if (!page) {
return;
}
spaSdk.destroy(this.state.page);
spaSdk.destroy(page);
}
render() {
if (!this.state.page) {
const {page} = this.state;
if (!page) {
return null;
}
const {mapping, children} = this.props;
return React__default["default"].createElement(BrPageContext.Provider, {
value: this.state.page
value: page
}, React__default["default"].createElement(BrMappingContext.Provider, {
value: this.props.mapping
value: mapping
}, React__default["default"].createElement(BrNode, {
component: this.state.page.getComponent()
}, this.props.children)));
component: page.getComponent()
}, children)));
}

@@ -332,0 +341,0 @@ }

{
"name": "@bloomreach/react-sdk",
"version": "15.0.1-0",
"version": "15.1.0",
"description": "Bloomreach SPA SDK for React",

@@ -31,3 +31,3 @@ "keywords": [

"build": "rollup -c rollup.config.js",
"lint": "tslint --project .",
"lint": "eslint --ext js,ts,tsx src",
"prepare": "$npm_execpath run build",

@@ -43,3 +43,3 @@ "test": "jest --coverage"

"dependencies": {
"@bloomreach/spa-sdk": "15.0.1-0"
"@bloomreach/spa-sdk": "15.1.0"
},

@@ -54,2 +54,3 @@ "peerDependencies": {

"@babel/preset-react": "7.14.5",
"@bloomreach/eslint-config-react": "1.0.2",
"@rollup/plugin-babel": "5.3.0",

@@ -63,4 +64,5 @@ "@types/enzyme": "3.10.9",

"enzyme-adapter-react-16": "1.15.6",
"eslint": "7.32.0",
"eslint-import-resolver-typescript": "2.4.0",
"jest": "26.6.3",
"jest-environment-enzyme": "7.1.2",
"jest-enzyme": "7.1.2",

@@ -75,7 +77,19 @@ "jest-junit": "12.2.0",

"ts-jest": "26.5.6",
"tslint": "6.1.3",
"tslint-config-airbnb": "5.11.2",
"tslint-react": "5.0.0",
"typescript": "4.1.6"
},
"eslintConfig": {
"extends": "@bloomreach/eslint-config-react",
"overrides": [
{
"files": "*.spec.tsx",
"rules": {
"react/jsx-props-no-spreading": "off",
"jsx-a11y/anchor-has-content": "off",
"jsx-a11y/anchor-is-valid": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
]
},
"jest": {

@@ -88,3 +102,3 @@ "preset": "ts-jest",

"setupFilesAfterEnv": [
"jest-enzyme"
"./setupTests"
],

@@ -96,4 +110,3 @@ "testEnvironment": "enzyme"

"outputName": "TEST-react-sdk.xml"
},
"stableVersion": "15.0.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc