Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/356383 #256

Merged
merged 29 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e376c5a
Upgrade jss-react-native packages
illiakovalenko Sep 9, 2019
28dbb35
fix types
illiakovalenko Sep 9, 2019
0f355a1
Upgrade jss-proxy packages
illiakovalenko Sep 9, 2019
7e72231
Upgrade jss-dev-tools packages
illiakovalenko Sep 9, 2019
382edd4
Upgrade jss-angular-schematics packages
illiakovalenko Sep 9, 2019
329e0ea
Upgrade jss-angular packages
illiakovalenko Sep 9, 2019
4bf2d4b
Upgrade jss-manifest packages
illiakovalenko Sep 9, 2019
a2e41e1
Upgrade jss-react packages
illiakovalenko Sep 9, 2019
6ea176d
Upgrade sitecore-jss packages
illiakovalenko Sep 9, 2019
f9f2341
Upgrade jss-cli packages
illiakovalenko Sep 9, 2019
e26ce3a
Upgrade jss-forms packages
illiakovalenko Sep 9, 2019
3f67151
Upgrade jss-rendering-host packages
illiakovalenko Sep 9, 2019
82cf8eb
Upgrade jss-tracking packages
illiakovalenko Sep 9, 2019
d3cd9d6
Upgrade jss-updage-package packages
illiakovalenko Sep 9, 2019
a4232c1
Upgrade jss-vue packages
illiakovalenko Sep 9, 2019
688352a
Upgrade sitecore-pipelines packages
illiakovalenko Sep 9, 2019
62e5600
Upgrade packages
illiakovalenko Sep 10, 2019
58ca235
Upgrade react sample packages
illiakovalenko Sep 10, 2019
b16619f
Upgrade react-native sample packages
illiakovalenko Sep 10, 2019
557fd39
Upgrade embedded-jss-app sample packages
illiakovalenko Sep 10, 2019
92c6b6f
Upgrade javascript-renderings sample packages
illiakovalenko Sep 10, 2019
4f85d93
Upgrade vue sample packages
illiakovalenko Sep 10, 2019
bf5dcb0
Upgrade node-headless-ssr-proxy sample packages
illiakovalenko Sep 10, 2019
1b51eb9
Upgrade angular sample packages
illiakovalenko Sep 10, 2019
ebf17a9
Upgrade docs packages
illiakovalenko Sep 10, 2019
114987d
Upgrade dependencies and fix ts errors
illiakovalenko Sep 12, 2019
8c22908
merge
illiakovalenko Sep 12, 2019
2b234e1
add package-lock
illiakovalenko Sep 12, 2019
44343df
Merge branch 'dev' of https://github.com/Sitecore/jss into feature/35…
illiakovalenko Sep 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,804 changes: 1,745 additions & 1,059 deletions packages/sitecore-jss-react/package-lock.json

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions packages/sitecore-jss-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,39 @@
"url": "https://github.com/sitecore/jss/issues"
},
"devDependencies": {
"@types/chai": "^4.1.5",
"@types/chai-string": "^1.4.1",
"@types/enzyme": "^3.1.14",
"@types/enzyme-adapter-react-16": "^1.0.3",
"@types/mocha": "^5.2.5",
"@types/node": "*",
"@types/prop-types": "^15.5.5",
"@types/react": "16.4.7",
"@types/react-dom": "^16.0.7",
"@types/url-parse": "^1.1.0",
"chai": "^4.1.2",
"@types/chai": "^4.2.2",
"@types/chai-string": "^1.4.2",
"@types/enzyme": "^3.10.3",
"@types/enzyme-adapter-react-16": "^1.0.5",
"@types/mocha": "^5.2.7",
"@types/node": "12.7.5",
"@types/prop-types": "^15.7.2",
"@types/react": "16.9.2",
"@types/react-dom": "^16.9.0",
"@types/url-parse": "^1.4.3",
"chai": "^4.2.0",
"chai-string": "^1.5.0",
"del-cli": "^1.1.0",
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
"jsdom": "^12.0.0",
"mocha": "^5.2.0",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-test-renderer": "^16.5.2",
"sinon": "^6.3.4",
"ts-node": "^7.0.1",
"tslint-react": "^3.6.0",
"typescript": "^3.0.3",
"url-parse": "^1.4.3"
"del-cli": "^3.0.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"jsdom": "^15.1.1",
"mocha": "^6.2.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-test-renderer": "^16.9.0",
"sinon": "^7.4.2",
"ts-node": "^8.3.0",
"tslint-react": "^4.0.0",
"typescript": "^3.6.3",
"url-parse": "^1.4.7"
},
"peerDependencies": {
"react": "^16.3.0",
"react-dom": "^16.3.0"
"react": "^16.9.0",
"react-dom": "^16.9.0"
},
"dependencies": {
"@sitecore-jss/sitecore-jss": "^12.0.0",
"prop-types": "^15.6.1",
"prop-types": "^15.7.2",
"style-attr": "^1.3.0"
},
"description": "",
Expand Down
8 changes: 5 additions & 3 deletions packages/sitecore-jss-react/src/components/Date.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import PropTypes, { InferProps } from 'prop-types';

export interface DateFieldProps {
/** The date field data. */
Expand All @@ -21,7 +21,7 @@ export interface DateFieldProps {
[htmlAttributes: string]: any;
}

export const DateField: React.SFC<DateFieldProps> = ({ field, tag, editable, render, ...otherProps }) => {
export const DateField: React.SFC<DateFieldProps> = ({ field, tag, editable, render, ...otherProps }: DateFieldPropTypes) => {
if (!field || (!field.editable && !field.value)) {
return null;
}
Expand Down Expand Up @@ -49,7 +49,7 @@ export const DateField: React.SFC<DateFieldProps> = ({ field, tag, editable, ren
}
};

DateField.propTypes = {
const dateFieldPropTypes = {
field: PropTypes.shape({
value: PropTypes.any,
editable: PropTypes.string,
Expand All @@ -59,6 +59,8 @@ DateField.propTypes = {
render: PropTypes.func,
};

type DateFieldPropTypes = InferProps<typeof dateFieldPropTypes>;

DateField.defaultProps = {
editable: true,
};
Expand Down
9 changes: 6 additions & 3 deletions packages/sitecore-jss-react/src/components/File.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PropTypes from 'prop-types';
import PropTypes, { InferProps } from 'prop-types';
import React from 'react';

export interface FileFieldValue {
Expand All @@ -19,7 +19,7 @@ export interface FileProps {
[attributeName: string]: any;
}

export const File: React.SFC<FileProps> = ({ field, children, ...otherProps }) => {
export const File: React.SFC<FileProps> = ({ field, children, ...otherProps }: FilePropTypes) => {
/*
File fields cannot be managed via the EE. We never output "editable."
*/
Expand All @@ -43,7 +43,7 @@ export const File: React.SFC<FileProps> = ({ field, children, ...otherProps }) =
return React.createElement('a', { ...anchorAttrs, ...otherProps }, linkText, children);
};

File.propTypes = {
const filePropTypes = {
field: PropTypes.oneOfType([
PropTypes.shape({
src: PropTypes.string,
Expand All @@ -52,6 +52,9 @@ File.propTypes = {
value: PropTypes.object,
}),
]),
children: PropTypes.node
};

type FilePropTypes = InferProps<typeof filePropTypes>;

File.displayName = 'File';
9 changes: 6 additions & 3 deletions packages/sitecore-jss-react/src/components/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mediaApi } from '@sitecore-jss/sitecore-jss';
import PropTypes from 'prop-types';
import PropTypes, { InferProps } from 'prop-types';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import { convertAttributesToReactProps } from '../utils';
Expand Down Expand Up @@ -109,7 +109,7 @@ export const Image: React.SFC<ImageProps> = ({
imageParams,
field,
...otherProps
}) => {
}: ImagePropTypes) => {
// allows the mistake of using 'field' prop instead of 'media' (consistent with other helpers)
if (field && !media) {
media = field;
Expand Down Expand Up @@ -155,7 +155,7 @@ export const Image: React.SFC<ImageProps> = ({
return null; // we can't handle the truth
};

Image.propTypes = {
const imagePropTypes = {
media: PropTypes.oneOfType([
PropTypes.shape({
src: PropTypes.string,
Expand All @@ -167,8 +167,11 @@ Image.propTypes = {
]),
editable: PropTypes.bool,
imageParams: PropTypes.object,
field: PropTypes.any
};

type ImagePropTypes = InferProps<typeof imagePropTypes>;

Image.defaultProps = {
editable: true,
};
Expand Down
10 changes: 7 additions & 3 deletions packages/sitecore-jss-react/src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ReactElement } from 'react';
import PropTypes from 'prop-types';
import PropTypes, { InferProps } from 'prop-types';

export interface LinkFieldValue {
href?: string;
Expand Down Expand Up @@ -32,7 +32,7 @@ export type LinkProps = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLA
showLinkTextWithChildrenPresent?: boolean;
};

export const Link: React.SFC<LinkProps> = ({ field, editable, children, showLinkTextWithChildrenPresent, ...otherProps }) => {
export const Link: React.SFC<LinkProps> = ({ field, editable, children, showLinkTextWithChildrenPresent, ...otherProps }: LinkPropTypes) => {
const dynamicField: any = field;

if (!field || (!dynamicField.editableFirstPart && !dynamicField.value && !dynamicField.href)) {
Expand Down Expand Up @@ -93,7 +93,7 @@ export const Link: React.SFC<LinkProps> = ({ field, editable, children, showLink
return <React.Fragment>{resultTags}</React.Fragment>;
};

Link.propTypes = {
const linkPropTypes = {
field: PropTypes.oneOfType([
PropTypes.shape({
href: PropTypes.string,
Expand All @@ -105,8 +105,12 @@ Link.propTypes = {
}),
]),
editable: PropTypes.bool,
showLinkTextWithChildrenPresent: PropTypes.bool,
children: PropTypes.node
};

type LinkPropTypes = InferProps<typeof linkPropTypes>;

Link.defaultProps = {
editable: true,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('<Placeholder />', () => {
const renderedComponent = mount(
<Placeholder name={phKey} rendering={route} componentFactory={componentFactory} />
);
expect(renderedComponent.html()).to.be.null;
expect(renderedComponent.html()).to.be.empty;
});
});

Expand Down
7 changes: 3 additions & 4 deletions packages/sitecore-jss-react/src/components/Placeholder.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { PlaceholderCommon, PlaceholderProps } from './PlaceholderCommon';
import { PlaceholderCommon, PlaceholderProps, PlaceholderCommonPropTypes } from './PlaceholderCommon';
import { withComponentFactory } from '../enhancers/withComponentFactory';
import { ComponentRendering, HtmlElementRendering } from '@sitecore-jss/sitecore-jss';

Expand All @@ -22,9 +22,8 @@ function isRawRendering(rendering: HtmlElementRendering | ComponentRendering): r
}

class PlaceholderComponent extends PlaceholderCommon {
static propTypes = PlaceholderCommon.propTypes;

constructor(props: PlaceholderComponentProps) {
constructor(props: PlaceholderCommonPropTypes) {
super(props);
}

Expand Down Expand Up @@ -68,4 +67,4 @@ class PlaceholderComponent extends PlaceholderCommon {
}
}

export const Placeholder = withComponentFactory(PlaceholderComponent);
export const Placeholder = withComponentFactory<PlaceholderProps>(PlaceholderComponent);
27 changes: 16 additions & 11 deletions packages/sitecore-jss-react/src/components/PlaceholderCommon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import PropTypes, { Requireable, InferProps } from 'prop-types';
import { MissingComponent } from '../components/MissingComponent';
import { ComponentFactory } from '../components/sharedTypes';
import { ComponentRendering, RouteData, Field, Item, HtmlElementRendering } from '@sitecore-jss/sitecore-jss';
Expand Down Expand Up @@ -49,15 +49,20 @@ export interface PlaceholderProps {
[key: string]: any;
}

export class PlaceholderCommon extends React.Component<PlaceholderProps> {
static propTypes = {
rendering: PropTypes.object,
fields: PropTypes.object,
params: PropTypes.object,
missingComponentComponent: PropTypes.node,
errorComponent: PropTypes.node,
};
const placeholderCommonPropTypes = {
name: PropTypes.string.isRequired,
rendering: PropTypes.oneOfType(
[PropTypes.object, PropTypes.object] as [Requireable<RouteData>, Requireable<ComponentRendering>]
).isRequired,
fields: PropTypes.object,
params: PropTypes.object,
missingComponentComponent: PropTypes.node,
errorComponent: PropTypes.node,
};

export type PlaceholderCommonPropTypes = InferProps<typeof placeholderCommonPropTypes>;

export class PlaceholderCommon extends React.Component<PlaceholderProps> {
nodeRefs: any[];
state: Readonly<{ error?: Error }>;

Expand All @@ -81,7 +86,7 @@ export class PlaceholderCommon extends React.Component<PlaceholderProps> {
return result;
}

constructor(props: PlaceholderProps) {
constructor(props: PlaceholderCommonPropTypes) {
super(props);
this.nodeRefs = [];
this.state = {};
Expand Down Expand Up @@ -170,7 +175,7 @@ export class PlaceholderCommon extends React.Component<PlaceholderProps> {
);
return null;
}
const attributes = convertAttributesToReactProps(elem.attributes);
const attributes: any = convertAttributesToReactProps(elem.attributes);

const props: any = {
...baseProps,
Expand Down
8 changes: 5 additions & 3 deletions packages/sitecore-jss-react/src/components/RichText.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import PropTypes, { InferProps } from 'prop-types';

export interface RichTextProps {
/** The rich text field data. */
Expand All @@ -21,7 +21,7 @@ export interface RichTextProps {
[htmlAttributes: string]: any;
}

export const RichText: React.SFC<RichTextProps> = ({ field, tag, editable, ...otherProps }) => {
export const RichText: React.SFC<RichTextProps> = ({ field, tag, editable, ...otherProps }: RichTextPropTypes) => {
if (!field || (!field.editable && !field.value)) {
return null;
}
Expand All @@ -36,7 +36,7 @@ export const RichText: React.SFC<RichTextProps> = ({ field, tag, editable, ...ot
return React.createElement(tag || 'div', htmlProps);
};

RichText.propTypes = {
const richTextPropTypes = {
field: PropTypes.shape({
value: PropTypes.string,
editable: PropTypes.string,
Expand All @@ -45,6 +45,8 @@ RichText.propTypes = {
editable: PropTypes.bool,
};

type RichTextPropTypes = InferProps<typeof richTextPropTypes>;

RichText.defaultProps = {
tag: 'div',
editable: true,
Expand Down
8 changes: 5 additions & 3 deletions packages/sitecore-jss-react/src/components/Text.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import PropTypes, { InferProps } from 'prop-types';

export interface TextProps {
/** The text field data. */
Expand All @@ -24,7 +24,7 @@ export interface TextProps {
[htmlAttributes: string]: any;
}

export const Text: React.SFC<TextProps> = ({ field, tag, editable, encode, ...otherProps }) => {
export const Text: React.SFC<TextProps> = ({ field, tag, editable, encode, ...otherProps }: TextPropTypes) => {
if (!field || (!field.editable && !field.value)) {
return null;
}
Expand Down Expand Up @@ -58,7 +58,7 @@ export const Text: React.SFC<TextProps> = ({ field, tag, editable, encode, ...ot
}
};

Text.propTypes = {
const textPropTypes = {
field: PropTypes.shape({
value: PropTypes.any,
editable: PropTypes.string,
Expand All @@ -68,6 +68,8 @@ Text.propTypes = {
encode: PropTypes.bool,
};

type TextPropTypes = InferProps<typeof textPropTypes>;

Text.defaultProps = {
editable: true,
encode: true,
Expand Down
Loading