@bloomreach/react-sdk
Advanced tools
Comparing version 14.1.1 to 14.2.0
@@ -6,3 +6,3 @@ import React from 'react'; | ||
/** | ||
* The related menu component. | ||
* The related menu model. | ||
*/ | ||
@@ -9,0 +9,0 @@ menu: Menu; |
@@ -6,4 +6,4 @@ (function(global, factory) { | ||
"use strict"; | ||
React = React && React.hasOwnProperty("default") ? React["default"] : React; | ||
ReactDOM = ReactDOM && ReactDOM.hasOwnProperty("default") ? ReactDOM["default"] : ReactDOM; | ||
React = React && Object.prototype.hasOwnProperty.call(React, "default") ? React["default"] : React; | ||
ReactDOM = ReactDOM && Object.prototype.hasOwnProperty.call(ReactDOM, "default") ? ReactDOM["default"] : ReactDOM; | ||
/** | ||
@@ -15,34 +15,22 @@ * The React Context holding the current brXM Component. | ||
super(...arguments); | ||
this.comments = []; | ||
this.tailRef = React.createRef(); | ||
} | ||
componentDidMount() { | ||
this.head = ReactDOM.findDOMNode(this); | ||
this.renderMeta(); | ||
} | ||
componentDidUpdate() { | ||
this.head = ReactDOM.findDOMNode(this); | ||
this.removeMeta(); | ||
componentDidUpdate(prevProps) { | ||
prevProps.meta.clear(); | ||
this.renderMeta(); | ||
} | ||
componentWillUnmount() { | ||
this.removeMeta(); | ||
this.props.meta.clear(); | ||
} | ||
removeMeta() { | ||
this.comments.splice(0).forEach(comment => comment.remove()); | ||
} | ||
renderMeta() { | ||
this.props.meta.filter(meta => spaSdk.isMetaComment(meta) && meta.getPosition() === spaSdk.META_POSITION_BEGIN).forEach(this.renderMetaComment.bind(this)); | ||
this.props.meta.filter(meta => spaSdk.isMetaComment(meta) && meta.getPosition() === spaSdk.META_POSITION_END).reverse().forEach(this.renderMetaComment.bind(this)); | ||
} | ||
renderMetaComment(meta) { | ||
const comment = this.head.ownerDocument.createComment(meta.getData()); | ||
this.comments.push(comment); | ||
if (meta.getPosition() === spaSdk.META_POSITION_BEGIN) { | ||
return void this.head.parentNode.insertBefore(comment, this.head); | ||
var _a; | ||
const head = ReactDOM.findDOMNode(this); | ||
const tail = (_a = this.tailRef) === null || _a === void 0 ? void 0 : _a.current; | ||
if (!head || !tail) { | ||
return; | ||
} | ||
if (!this.tailRef.current.nextSibling) { | ||
return void this.tailRef.current.parentNode.appendChild(comment); | ||
} | ||
this.tailRef.current.parentNode.insertBefore(comment, this.tailRef.current.nextSibling); | ||
this.props.meta.render(head, tail); | ||
} | ||
@@ -117,3 +105,4 @@ render() { | ||
render() { | ||
if (!this.context || !this.context.isPreview()) { | ||
var _a; | ||
if (!((_a = this.context) === null || _a === void 0 ? void 0 : _a.isPreview())) { | ||
return null; | ||
@@ -131,3 +120,4 @@ } | ||
render() { | ||
if (!this.context || !this.context.isPreview() || !this.props.menu._meta) { | ||
var _a; | ||
if (!((_a = this.context) === null || _a === void 0 ? void 0 : _a.isPreview()) || !this.props.menu._meta) { | ||
return null; | ||
@@ -211,3 +201,4 @@ } | ||
renderChildren() { | ||
return this.props.children || this.props.component.getChildren().map((child, index) => React.createElement(BrNode, { | ||
var _a; | ||
return (_a = this.props.children) !== null && _a !== void 0 ? _a : this.props.component.getChildren().map((child, index) => React.createElement(BrNode, { | ||
key: index, | ||
@@ -251,2 +242,7 @@ component: child | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { | ||
return value instanceof P ? value : new P((function(resolve) { | ||
resolve(value); | ||
})); | ||
} | ||
return new (P || (P = Promise))((function(resolve, reject) { | ||
@@ -268,5 +264,3 @@ function fulfilled(value) { | ||
function step(result) { | ||
result.done ? resolve(result.value) : new P((function(resolve) { | ||
resolve(result.value); | ||
})).then(fulfilled, rejected); | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
@@ -302,3 +296,6 @@ step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
if (this.state.page !== prevState.page) { | ||
this.forceUpdate(() => this.state.page && this.state.page.sync()); | ||
this.forceUpdate(() => { | ||
var _a; | ||
return (_a = this.state.page) === null || _a === void 0 ? void 0 : _a.sync(); | ||
}); | ||
} | ||
@@ -305,0 +302,0 @@ } |
import React from 'react'; | ||
import { Meta } from '@bloomreach/spa-sdk'; | ||
import { MetaCollection } from '@bloomreach/spa-sdk'; | ||
interface BrMetaProps { | ||
meta: Meta[]; | ||
meta: MetaCollection; | ||
} | ||
export declare class BrMeta extends React.Component<BrMetaProps> { | ||
private comments; | ||
private head?; | ||
private tailRef; | ||
componentDidMount(): void; | ||
componentDidUpdate(): void; | ||
componentDidUpdate(prevProps: BrMetaProps): void; | ||
componentWillUnmount(): void; | ||
private removeMeta; | ||
private renderMeta; | ||
private renderMetaComment; | ||
render(): JSX.Element; | ||
} | ||
export {}; |
{ | ||
"name": "@bloomreach/react-sdk", | ||
"version": "14.1.1", | ||
"version": "14.2.0", | ||
"description": "Bloomreach SPA SDK for React", | ||
@@ -31,24 +31,31 @@ "keywords": [ | ||
"lint": "tslint --project .", | ||
"prepare": "$npm_execpath run build", | ||
"test": "jest --coverage" | ||
}, | ||
"browserslist": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version", | ||
"last 1 edge version" | ||
], | ||
"dependencies": { | ||
"@bloomreach/spa-sdk": "^14.1" | ||
"@bloomreach/spa-sdk": "^14.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.10", | ||
"react-dom": "^16.10" | ||
"react": "^16.13", | ||
"react-dom": "^16.13" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.7", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.7", | ||
"@babel/preset-env": "^7.7", | ||
"@babel/preset-react": "^7.7", | ||
"@babel/core": "^7.9", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.9", | ||
"@babel/preset-env": "^7.9", | ||
"@babel/preset-react": "^7.9", | ||
"@types/enzyme": "^3.10", | ||
"@types/jest": "^24.0", | ||
"@types/jest": "^25.1", | ||
"@types/react": "^16.9", | ||
"@types/react-dom": "^16.9", | ||
"babel-plugin-transform-async-to-promises": "^0.8", | ||
"enzyme": "^3.10", | ||
"enzyme": "^3.11", | ||
"enzyme-adapter-react-16": "^1.15", | ||
"jest": "^24.9", | ||
"jest": "^25.2", | ||
"jest-environment-enzyme": "^7.1", | ||
@@ -58,11 +65,11 @@ "jest-enzyme": "^7.1", | ||
"react-dom": "^16.12", | ||
"rollup": "^1.27", | ||
"rollup-plugin-babel": "^4.3", | ||
"rollup-plugin-terser": "^5.1", | ||
"rollup-plugin-typescript2": "^0.25", | ||
"ts-jest": "^24.2", | ||
"tslint": "^5.20", | ||
"rollup": "^2.3", | ||
"rollup-plugin-babel": "^4.4", | ||
"rollup-plugin-terser": "^5.3", | ||
"rollup-plugin-typescript2": "^0.27", | ||
"ts-jest": "^25.3", | ||
"tslint": "^6.1", | ||
"tslint-config-airbnb": "^5.11", | ||
"tslint-react": "^4.1", | ||
"typescript": "^3.7" | ||
"tslint-react": "^4.2", | ||
"typescript": "^3.8" | ||
}, | ||
@@ -69,0 +76,0 @@ "jest": { |
@@ -158,3 +158,3 @@ # Bloomreach React SDK | ||
The React SDK is using [Bloomreach SPA SDK](https://www.npmjs.com/package/@bloomreach/spa-sdk#reference) to interact with the brXM. | ||
The complete reference of the exposed JavaScript objects can be found [here](https://javadoc.onehippo.org/14.0/bloomreach-spa-sdk/). | ||
The complete reference of the exposed JavaScript objects can be found [here](https://javadoc.onehippo.org/14.2/bloomreach-spa-sdk/). | ||
@@ -169,3 +169,3 @@ #### BrPage | ||
`configuration` | _yes_ | The [configuration](#configuration) of the SPA SDK. | ||
`mapping` | _yes_ | The brXM and React components [mapping](#inline-mapping). | ||
`mapping` | _yes_ | The brXM and React components [mapping](#mapping). | ||
`page` | _no_ | Preinitialized page instance or prefetched page model. Mostly that should be used to transfer state from the server-side to the client-side. | ||
@@ -186,3 +186,3 @@ | ||
--- | :---: | --- | ||
content | _yes_ | The content entity to open for editing. | ||
`content` | _yes_ | The content entity to open for editing. | ||
@@ -195,3 +195,3 @@ #### BrManageMenuButton | ||
--- | :---: | --- | ||
content | _yes_ | The related menu component. | ||
`menu` | _yes_ | The related menu model. | ||
@@ -198,0 +198,0 @@ #### BrComponentContext |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
63405
1234
Updated@bloomreach/spa-sdk@^14.2