@esri/calcite-components-react 0.19.0 → 0.22.0
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.
|
@@ -6,5 +6,5 @@ interface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<El
|
|
|
6
6
|
forwardedRef: React.RefObject<ElementType>;
|
|
7
7
|
ref?: React.Ref<any>;
|
|
8
8
|
}
|
|
9
|
-
export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes,
|
|
9
|
+
export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
|
10
10
|
export {};
|
|
@@ -9,10 +9,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import { attachProps, createForwardRef, dashToPascalCase,
|
|
14
|
-
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction,
|
|
15
|
-
defineCustomElement
|
|
12
|
+
import React, { createElement } from 'react';
|
|
13
|
+
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs, } from './utils';
|
|
14
|
+
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
|
15
|
+
if (defineCustomElement !== undefined) {
|
|
16
|
+
defineCustomElement();
|
|
17
|
+
}
|
|
16
18
|
const displayName = dashToPascalCase(tagName);
|
|
17
19
|
const ReactComponent = class extends React.Component {
|
|
18
20
|
constructor(props) {
|
|
@@ -30,14 +32,20 @@ export const createReactComponent = (tagName, ReactComponentContext, manipulateP
|
|
|
30
32
|
render() {
|
|
31
33
|
const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
|
|
32
34
|
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
35
|
+
const value = cProps[name];
|
|
33
36
|
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
34
37
|
const eventName = name.substring(2).toLowerCase();
|
|
35
38
|
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
|
36
|
-
acc[name] =
|
|
39
|
+
acc[name] = value;
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
else {
|
|
40
|
-
|
|
43
|
+
// we should only render strings, booleans, and numbers as attrs in html.
|
|
44
|
+
// objects, functions, arrays etc get synced via properties on mount.
|
|
45
|
+
const type = typeof value;
|
|
46
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
47
|
+
acc[camelToDashCase(name)] = value;
|
|
48
|
+
}
|
|
41
49
|
}
|
|
42
50
|
return acc;
|
|
43
51
|
}, {});
|
|
@@ -45,7 +53,14 @@ export const createReactComponent = (tagName, ReactComponentContext, manipulateP
|
|
|
45
53
|
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
46
54
|
}
|
|
47
55
|
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style });
|
|
48
|
-
|
|
56
|
+
/**
|
|
57
|
+
* We use createElement here instead of
|
|
58
|
+
* React.createElement to work around a
|
|
59
|
+
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
60
|
+
* React.createElement causes all elements to be rendered
|
|
61
|
+
* as <tagname> instead of the actual Web Component.
|
|
62
|
+
*/
|
|
63
|
+
return createElement(tagName, newProps, children);
|
|
49
64
|
}
|
|
50
65
|
static get displayName() {
|
|
51
66
|
return displayName;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/calcite-components-react",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.22.0",
|
|
5
5
|
"description": "A set of React components that wrap calcite components",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
"scripts": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"typescript": "^3.3.4000"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@esri/calcite-components": "1.0.0-beta.
|
|
29
|
+
"@esri/calcite-components": "1.0.0-beta.81"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"react": "
|
|
33
|
-
"react-dom": "
|
|
32
|
+
"react": ">=16.7 <18",
|
|
33
|
+
"react-dom": ">=16.7 <18"
|
|
34
34
|
}
|
|
35
35
|
}
|