@arcgis/charts-components-react 4.33.0-next.16 → 4.33.0-next.160
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.
- package/README.md +40 -4
- package/dist/components.d.ts +25 -3
- package/dist/components.js +24 -6
- package/package.json +7 -6
- package/dist/react-component-lib/createComponent.d.ts +0 -10
- package/dist/react-component-lib/createComponent.js +0 -67
- package/dist/react-component-lib/createOverlayComponent.d.ts +0 -21
- package/dist/react-component-lib/createOverlayComponent.js +0 -95
- package/dist/react-component-lib/index.d.ts +0 -2
- package/dist/react-component-lib/index.js +0 -2
- package/dist/react-component-lib/interfaces.d.ts +0 -29
- package/dist/react-component-lib/interfaces.js +0 -1
- package/dist/react-component-lib/utils/attachProps.d.ts +0 -16
- package/dist/react-component-lib/utils/attachProps.js +0 -107
- package/dist/react-component-lib/utils/case.d.ts +0 -2
- package/dist/react-component-lib/utils/case.js +0 -6
- package/dist/react-component-lib/utils/dev.d.ts +0 -2
- package/dist/react-component-lib/utils/dev.js +0 -12
- package/dist/react-component-lib/utils/index.d.ts +0 -10
- package/dist/react-component-lib/utils/index.js +0 -31
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# ArcGIS Maps SDK for JavaScript - React
|
|
1
|
+
# ArcGIS Maps SDK for JavaScript - React wrapper for Charts Components (beta)
|
|
2
2
|
|
|
3
3
|
**No Esri Technical Support during beta.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> Note: `@arcgis/charts-components-react` was developed for use in React 18. Consider updating to React 19 where the React wrapper is no longer necessary. Check out the [documentation](https://developers.arcgis.com/javascript/latest/get-started-react/) to get started with `@arcgis/charts-components` in React 19.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The ArcGIS Maps SDK for JavaScript provides a suite of ready-to-use UI components that simplify the process of creating GIS web applications. This package offers a series of charting components that can be used to build custom applications.
|
|
8
8
|
|
|
9
9
|
## Documentation
|
|
10
10
|
|
|
@@ -22,11 +22,47 @@ Samples for how to use this package are available on github in the [jsapi-resour
|
|
|
22
22
|
- [Licensing](https://developers.arcgis.com/javascript/latest/licensing/)
|
|
23
23
|
- [Working with `next` versions](https://github.com/Esri/feedback-js-api-next/blob/main/README.md)
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## Support
|
|
26
26
|
|
|
27
27
|
- General questions about using this package or the ArcGIS Maps SDK for JavaScript? See the [Esri developer community](https://community.esri.com/t5/arcgis-api-for-javascript/ct-p/arcgis-api-for-javascript).
|
|
28
28
|
- [Technical support](https://support.esri.com/).
|
|
29
29
|
|
|
30
|
+
## Quick start guide
|
|
31
|
+
|
|
32
|
+
- Get started by using the [react 18 sample](https://developers.arcgis.com/javascript/latest/get-started-react/#download-project).
|
|
33
|
+
- Install the required packages: `@arcgis/charts-components-react`, `@arcgis/core`, `@esri/calcite-components-react`.
|
|
34
|
+
- Import the necessary CSS files in your project and ensure CSS is configured for the charts components:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
@import 'https://js.arcgis.com/4.33/@arcgis/core/assets/esri/themes/dark/main.css';
|
|
38
|
+
@import url("https://js.arcgis.com/calcite-components/3.2.0/calcite.css");
|
|
39
|
+
|
|
40
|
+
#root,
|
|
41
|
+
html,
|
|
42
|
+
body {
|
|
43
|
+
margin: 0;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- Add chart component: In your main file (e.g., index.tsx), add the `ArcgisChart` component and configure it with either an existing chart model from a feature layer, or by creating a new model with `createModel()`.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import React from "react";
|
|
51
|
+
import ReactDOM from "react-dom/client";
|
|
52
|
+
import "@arcgis/charts-components/components/arcgis-chart";
|
|
53
|
+
import "@arcgis/charts-components/components/arcgis-charts-action-bar";
|
|
54
|
+
import { ArcgisChart, ArcgisChartsActionBar } from "@arcgis/charts-components-react";
|
|
55
|
+
|
|
56
|
+
const root = ReactDOM.createRoot(document.getElementById("root"));
|
|
57
|
+
root.render(
|
|
58
|
+
<React.StrictMode>
|
|
59
|
+
<ArcgisChart>
|
|
60
|
+
<ArcgisChartsActionBar slot="action-bar"></ArcgisChartsActionBar>
|
|
61
|
+
</ArcgisChart>
|
|
62
|
+
</React.StrictMode>,
|
|
63
|
+
);
|
|
64
|
+
```
|
|
65
|
+
|
|
30
66
|
## License
|
|
31
67
|
|
|
32
68
|
COPYRIGHT © 2025 Esri
|
package/dist/components.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
/// <reference types="@arcgis/charts-components" preserve="true" />
|
|
2
|
+
import type { EventName } from "@lit/react";
|
|
3
|
+
export declare const ArcgisChart: import("@lit/react").ReactWebComponent<HTMLArcgisChartElement & {
|
|
4
|
+
class?: string;
|
|
5
|
+
}, {
|
|
6
|
+
onArcgisAxesMinMaxChange: EventName<HTMLArcgisChartElement["arcgisAxesMinMaxChange"]>;
|
|
7
|
+
onArcgisBadDataWarningRaise: EventName<HTMLArcgisChartElement["arcgisBadDataWarningRaise"]>;
|
|
8
|
+
onArcgisConfigChange: EventName<HTMLArcgisChartElement["arcgisConfigChange"]>;
|
|
9
|
+
onArcgisDataFetchComplete: EventName<HTMLArcgisChartElement["arcgisDataFetchComplete"]>;
|
|
10
|
+
onArcgisDataProcessComplete: EventName<HTMLArcgisChartElement["arcgisDataProcessComplete"]>;
|
|
11
|
+
onArcgisDataProcessError: EventName<HTMLArcgisChartElement["arcgisDataProcessError"]>;
|
|
12
|
+
onArcgisLegendItemVisibilityChange: EventName<HTMLArcgisChartElement["arcgisLegendItemVisibilityChange"]>;
|
|
13
|
+
onArcgisNoRenderPropChange: EventName<HTMLArcgisChartElement["arcgisNoRenderPropChange"]>;
|
|
14
|
+
onArcgisRuntimeError: EventName<HTMLArcgisChartElement["arcgisRuntimeError"]>;
|
|
15
|
+
onArcgisSelectionComplete: EventName<HTMLArcgisChartElement["arcgisSelectionComplete"]>;
|
|
16
|
+
onArcgisSeriesColorChange: EventName<HTMLArcgisChartElement["arcgisSeriesColorChange"]>;
|
|
17
|
+
onArcgisSeriesOrder: EventName<HTMLArcgisChartElement["arcgisSeriesOrder"]>;
|
|
18
|
+
onArcgisUpdateComplete: EventName<HTMLArcgisChartElement["arcgisUpdateComplete"]>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const ArcgisChartsActionBar: import("@lit/react").ReactWebComponent<HTMLArcgisChartsActionBarElement & {
|
|
21
|
+
class?: string;
|
|
22
|
+
}, {
|
|
23
|
+
onArcgisActionBarToggle: EventName<HTMLArcgisChartsActionBarElement["arcgisActionBarToggle"]>;
|
|
24
|
+
onArcgisDefaultActionSelect: EventName<HTMLArcgisChartsActionBarElement["arcgisDefaultActionSelect"]>;
|
|
25
|
+
}>;
|
package/dist/components.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export const
|
|
1
|
+
/// <reference types="@arcgis/charts-components" preserve="true" />
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { createComponent } from "@lit/react";
|
|
4
|
+
import { makeReactWrapperFactory, getReactWrapperOptions } from "@arcgis/lumina";
|
|
5
|
+
const createWrapper = /*@__PURE__*/ makeReactWrapperFactory(React, createComponent);
|
|
6
|
+
export const ArcgisChart = /*@__PURE__*/ createWrapper(getReactWrapperOptions("arcgis-chart", {
|
|
7
|
+
onArcgisAxesMinMaxChange: "arcgisAxesMinMaxChange",
|
|
8
|
+
onArcgisBadDataWarningRaise: "arcgisBadDataWarningRaise",
|
|
9
|
+
onArcgisConfigChange: "arcgisConfigChange",
|
|
10
|
+
onArcgisDataFetchComplete: "arcgisDataFetchComplete",
|
|
11
|
+
onArcgisDataProcessComplete: "arcgisDataProcessComplete",
|
|
12
|
+
onArcgisDataProcessError: "arcgisDataProcessError",
|
|
13
|
+
onArcgisLegendItemVisibilityChange: "arcgisLegendItemVisibilityChange",
|
|
14
|
+
onArcgisNoRenderPropChange: "arcgisNoRenderPropChange",
|
|
15
|
+
onArcgisRuntimeError: "arcgisRuntimeError",
|
|
16
|
+
onArcgisSelectionComplete: "arcgisSelectionComplete",
|
|
17
|
+
onArcgisSeriesColorChange: "arcgisSeriesColorChange",
|
|
18
|
+
onArcgisSeriesOrder: "arcgisSeriesOrder",
|
|
19
|
+
onArcgisUpdateComplete: "arcgisUpdateComplete",
|
|
20
|
+
}));
|
|
21
|
+
export const ArcgisChartsActionBar = /*@__PURE__*/ createWrapper(getReactWrapperOptions("arcgis-charts-action-bar", {
|
|
22
|
+
onArcgisActionBarToggle: "arcgisActionBarToggle",
|
|
23
|
+
onArcgisDefaultActionSelect: "arcgisDefaultActionSelect",
|
|
24
|
+
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/charts-components-react",
|
|
3
|
-
"version": "4.33.0-next.
|
|
3
|
+
"version": "4.33.0-next.160",
|
|
4
4
|
"description": "A set of React components that wrap ArcGIS charts components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ArcGIS",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"homepage": "https://developers.arcgis.com/javascript/latest/",
|
|
20
20
|
"sideEffects": false,
|
|
21
|
+
"type": "module",
|
|
21
22
|
"main": "dist/index.js",
|
|
22
23
|
"module": "dist/index.js",
|
|
23
24
|
"types": "dist/index.d.ts",
|
|
@@ -26,13 +27,13 @@
|
|
|
26
27
|
],
|
|
27
28
|
"license": "SEE LICENSE.md",
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@arcgis/charts-components": "4.33.0-next.
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
30
|
+
"@arcgis/charts-components": "4.33.0-next.160",
|
|
31
|
+
"@lit/react": "^1.0.7",
|
|
32
|
+
"tslib": "^2.8.1"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
35
|
"@arcgis/core": ">=4.33.0-next <4.34",
|
|
35
|
-
"react": ">=18.0.0 <
|
|
36
|
-
"react-dom": ">=18.0.0 <
|
|
36
|
+
"react": ">=18.0.0 <20.0.0",
|
|
37
|
+
"react-dom": ">=18.0.0 <20.0.0"
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface HTMLStencilElement extends HTMLElement {
|
|
3
|
-
componentOnReady(): Promise<this>;
|
|
4
|
-
}
|
|
5
|
-
interface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<ElementType> {
|
|
6
|
-
forwardedRef: React.RefObject<ElementType>;
|
|
7
|
-
ref?: React.Ref<any>;
|
|
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, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
|
10
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React, { createElement } from 'react';
|
|
2
|
-
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
|
|
3
|
-
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
|
4
|
-
if (defineCustomElement !== undefined) {
|
|
5
|
-
defineCustomElement();
|
|
6
|
-
}
|
|
7
|
-
const displayName = dashToPascalCase(tagName);
|
|
8
|
-
const ReactComponent = class extends React.Component {
|
|
9
|
-
constructor(props) {
|
|
10
|
-
super(props);
|
|
11
|
-
this.setComponentElRef = (element) => {
|
|
12
|
-
this.componentEl = element;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
componentDidMount() {
|
|
16
|
-
this.componentDidUpdate(this.props);
|
|
17
|
-
}
|
|
18
|
-
componentDidUpdate(prevProps) {
|
|
19
|
-
attachProps(this.componentEl, this.props, prevProps);
|
|
20
|
-
}
|
|
21
|
-
render() {
|
|
22
|
-
const { children, forwardedRef, style, className, ref, ...cProps } = this.props;
|
|
23
|
-
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
24
|
-
const value = cProps[name];
|
|
25
|
-
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
26
|
-
const eventName = name.substring(2).toLowerCase();
|
|
27
|
-
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
|
28
|
-
acc[name] = value;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
// we should only render strings, booleans, and numbers as attrs in html.
|
|
33
|
-
// objects, functions, arrays etc get synced via properties on mount.
|
|
34
|
-
const type = typeof value;
|
|
35
|
-
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
36
|
-
acc[camelToDashCase(name)] = value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return acc;
|
|
40
|
-
}, {});
|
|
41
|
-
if (manipulatePropsFunction) {
|
|
42
|
-
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
43
|
-
}
|
|
44
|
-
const newProps = {
|
|
45
|
-
...propsToPass,
|
|
46
|
-
ref: mergeRefs(forwardedRef, this.setComponentElRef),
|
|
47
|
-
style,
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* We use createElement here instead of
|
|
51
|
-
* React.createElement to work around a
|
|
52
|
-
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
53
|
-
* React.createElement causes all elements to be rendered
|
|
54
|
-
* as <tagname> instead of the actual Web Component.
|
|
55
|
-
*/
|
|
56
|
-
return createElement(tagName, newProps, children);
|
|
57
|
-
}
|
|
58
|
-
static get displayName() {
|
|
59
|
-
return displayName;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
// If context was passed to createReactComponent then conditionally add it to the Component Class
|
|
63
|
-
if (ReactComponentContext) {
|
|
64
|
-
ReactComponent.contextType = ReactComponentContext;
|
|
65
|
-
}
|
|
66
|
-
return createForwardRef(ReactComponent, displayName);
|
|
67
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { OverlayEventDetail } from './interfaces';
|
|
3
|
-
import { StencilReactForwardedRef } from './utils';
|
|
4
|
-
interface OverlayElement extends HTMLElement {
|
|
5
|
-
present: () => Promise<void>;
|
|
6
|
-
dismiss: (data?: any, role?: string | undefined) => Promise<boolean>;
|
|
7
|
-
}
|
|
8
|
-
export interface ReactOverlayProps {
|
|
9
|
-
children?: React.ReactNode;
|
|
10
|
-
isOpen: boolean;
|
|
11
|
-
onDidDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
12
|
-
onDidPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
13
|
-
onWillDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
14
|
-
onWillPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
15
|
-
}
|
|
16
|
-
export declare const createOverlayComponent: <OverlayComponent extends object, OverlayType extends OverlayElement>(tagName: string, controller: {
|
|
17
|
-
create: (options: any) => Promise<OverlayType>;
|
|
18
|
-
}, customElement?: any) => React.ForwardRefExoticComponent<React.PropsWithoutRef<OverlayComponent & ReactOverlayProps & {
|
|
19
|
-
forwardedRef?: StencilReactForwardedRef<OverlayType>;
|
|
20
|
-
}> & React.RefAttributes<OverlayType>>;
|
|
21
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
|
|
4
|
-
export const createOverlayComponent = (tagName, controller, customElement) => {
|
|
5
|
-
defineCustomElement(tagName, customElement);
|
|
6
|
-
const displayName = dashToPascalCase(tagName);
|
|
7
|
-
const didDismissEventName = `on${displayName}DidDismiss`;
|
|
8
|
-
const didPresentEventName = `on${displayName}DidPresent`;
|
|
9
|
-
const willDismissEventName = `on${displayName}WillDismiss`;
|
|
10
|
-
const willPresentEventName = `on${displayName}WillPresent`;
|
|
11
|
-
let isDismissing = false;
|
|
12
|
-
class Overlay extends React.Component {
|
|
13
|
-
constructor(props) {
|
|
14
|
-
super(props);
|
|
15
|
-
if (typeof document !== 'undefined') {
|
|
16
|
-
this.el = document.createElement('div');
|
|
17
|
-
}
|
|
18
|
-
this.handleDismiss = this.handleDismiss.bind(this);
|
|
19
|
-
}
|
|
20
|
-
static get displayName() {
|
|
21
|
-
return displayName;
|
|
22
|
-
}
|
|
23
|
-
componentDidMount() {
|
|
24
|
-
if (this.props.isOpen) {
|
|
25
|
-
this.present();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
componentWillUnmount() {
|
|
29
|
-
if (this.overlay) {
|
|
30
|
-
this.overlay.dismiss();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
handleDismiss(event) {
|
|
34
|
-
if (this.props.onDidDismiss) {
|
|
35
|
-
this.props.onDidDismiss(event);
|
|
36
|
-
}
|
|
37
|
-
setRef(this.props.forwardedRef, null);
|
|
38
|
-
}
|
|
39
|
-
shouldComponentUpdate(nextProps) {
|
|
40
|
-
// Check if the overlay component is about to dismiss
|
|
41
|
-
if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
|
|
42
|
-
isDismissing = true;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
async componentDidUpdate(prevProps) {
|
|
47
|
-
if (this.overlay) {
|
|
48
|
-
attachProps(this.overlay, this.props, prevProps);
|
|
49
|
-
}
|
|
50
|
-
if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
|
|
51
|
-
this.present(prevProps);
|
|
52
|
-
}
|
|
53
|
-
if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
|
|
54
|
-
await this.overlay.dismiss();
|
|
55
|
-
isDismissing = false;
|
|
56
|
-
/**
|
|
57
|
-
* Now that the overlay is dismissed
|
|
58
|
-
* we need to render again so that any
|
|
59
|
-
* inner components will be unmounted
|
|
60
|
-
*/
|
|
61
|
-
this.forceUpdate();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async present(prevProps) {
|
|
65
|
-
const { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent, ...cProps } = this.props;
|
|
66
|
-
const elementProps = {
|
|
67
|
-
...cProps,
|
|
68
|
-
ref: this.props.forwardedRef,
|
|
69
|
-
[didDismissEventName]: this.handleDismiss,
|
|
70
|
-
[didPresentEventName]: (e) => this.props.onDidPresent && this.props.onDidPresent(e),
|
|
71
|
-
[willDismissEventName]: (e) => this.props.onWillDismiss && this.props.onWillDismiss(e),
|
|
72
|
-
[willPresentEventName]: (e) => this.props.onWillPresent && this.props.onWillPresent(e),
|
|
73
|
-
};
|
|
74
|
-
this.overlay = await controller.create({
|
|
75
|
-
...elementProps,
|
|
76
|
-
component: this.el,
|
|
77
|
-
componentProps: {},
|
|
78
|
-
});
|
|
79
|
-
setRef(this.props.forwardedRef, this.overlay);
|
|
80
|
-
attachProps(this.overlay, elementProps, prevProps);
|
|
81
|
-
await this.overlay.present();
|
|
82
|
-
}
|
|
83
|
-
render() {
|
|
84
|
-
/**
|
|
85
|
-
* Continue to render the component even when
|
|
86
|
-
* overlay is dismissing otherwise component
|
|
87
|
-
* will be hidden before animation is done.
|
|
88
|
-
*/
|
|
89
|
-
return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return React.forwardRef((props, ref) => {
|
|
93
|
-
return React.createElement(Overlay, { ...props, forwardedRef: ref });
|
|
94
|
-
});
|
|
95
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface EventEmitter<T = any> {
|
|
2
|
-
emit: (data?: T) => CustomEvent<T>;
|
|
3
|
-
}
|
|
4
|
-
export interface StyleReactProps {
|
|
5
|
-
class?: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export interface OverlayEventDetail<T = any> {
|
|
12
|
-
data?: T;
|
|
13
|
-
role?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface OverlayInterface {
|
|
16
|
-
el: HTMLElement;
|
|
17
|
-
animated: boolean;
|
|
18
|
-
keyboardClose: boolean;
|
|
19
|
-
overlayIndex: number;
|
|
20
|
-
presented: boolean;
|
|
21
|
-
enterAnimation?: any;
|
|
22
|
-
leaveAnimation?: any;
|
|
23
|
-
didPresent: EventEmitter<void>;
|
|
24
|
-
willPresent: EventEmitter<void>;
|
|
25
|
-
willDismiss: EventEmitter<OverlayEventDetail>;
|
|
26
|
-
didDismiss: EventEmitter<OverlayEventDetail>;
|
|
27
|
-
present(): Promise<void>;
|
|
28
|
-
dismiss(data?: any, role?: string): Promise<boolean>;
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const attachProps: (node: HTMLElement, newProps: any, oldProps?: any) => void;
|
|
2
|
-
export declare const getClassName: (classList: DOMTokenList, newProps: any, oldProps: any) => string;
|
|
3
|
-
/**
|
|
4
|
-
* Transforms a React event name to a browser event name.
|
|
5
|
-
*/
|
|
6
|
-
export declare const transformReactEventName: (eventNameSuffix: string) => string;
|
|
7
|
-
/**
|
|
8
|
-
* Checks if an event is supported in the current execution environment.
|
|
9
|
-
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
10
|
-
*/
|
|
11
|
-
export declare const isCoveredByReact: (eventNameSuffix: string) => boolean;
|
|
12
|
-
export declare const syncEvent: (node: Element & {
|
|
13
|
-
__events?: {
|
|
14
|
-
[key: string]: ((e: Event) => any) | undefined;
|
|
15
|
-
};
|
|
16
|
-
}, eventName: string, newEventHandler?: (e: Event) => any) => void;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { camelToDashCase } from './case';
|
|
2
|
-
export const attachProps = (node, newProps, oldProps = {}) => {
|
|
3
|
-
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
|
|
4
|
-
if (node instanceof Element) {
|
|
5
|
-
// add any classes in className to the class list
|
|
6
|
-
const className = getClassName(node.classList, newProps, oldProps);
|
|
7
|
-
if (className !== '') {
|
|
8
|
-
node.className = className;
|
|
9
|
-
}
|
|
10
|
-
Object.keys(newProps).forEach((name) => {
|
|
11
|
-
if (name === 'children' ||
|
|
12
|
-
name === 'style' ||
|
|
13
|
-
name === 'ref' ||
|
|
14
|
-
name === 'class' ||
|
|
15
|
-
name === 'className' ||
|
|
16
|
-
name === 'forwardedRef') {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
20
|
-
const eventName = name.substring(2);
|
|
21
|
-
const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
|
|
22
|
-
if (!isCoveredByReact(eventNameLc)) {
|
|
23
|
-
syncEvent(node, eventNameLc, newProps[name]);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
node[name] = newProps[name];
|
|
28
|
-
const propType = typeof newProps[name];
|
|
29
|
-
if (propType === 'string') {
|
|
30
|
-
node.setAttribute(camelToDashCase(name), newProps[name]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
export const getClassName = (classList, newProps, oldProps) => {
|
|
37
|
-
const newClassProp = newProps.className || newProps.class;
|
|
38
|
-
const oldClassProp = oldProps.className || oldProps.class;
|
|
39
|
-
// map the classes to Maps for performance
|
|
40
|
-
const currentClasses = arrayToMap(classList);
|
|
41
|
-
const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
|
|
42
|
-
const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
|
|
43
|
-
const finalClassNames = [];
|
|
44
|
-
// loop through each of the current classes on the component
|
|
45
|
-
// to see if it should be a part of the classNames added
|
|
46
|
-
currentClasses.forEach((currentClass) => {
|
|
47
|
-
if (incomingPropClasses.has(currentClass)) {
|
|
48
|
-
// add it as its already included in classnames coming in from newProps
|
|
49
|
-
finalClassNames.push(currentClass);
|
|
50
|
-
incomingPropClasses.delete(currentClass);
|
|
51
|
-
}
|
|
52
|
-
else if (!oldPropClasses.has(currentClass)) {
|
|
53
|
-
// add it as it has NOT been removed by user
|
|
54
|
-
finalClassNames.push(currentClass);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
incomingPropClasses.forEach((s) => finalClassNames.push(s));
|
|
58
|
-
return finalClassNames.join(' ');
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Transforms a React event name to a browser event name.
|
|
62
|
-
*/
|
|
63
|
-
export const transformReactEventName = (eventNameSuffix) => {
|
|
64
|
-
switch (eventNameSuffix) {
|
|
65
|
-
case 'doubleclick':
|
|
66
|
-
return 'dblclick';
|
|
67
|
-
}
|
|
68
|
-
return eventNameSuffix;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Checks if an event is supported in the current execution environment.
|
|
72
|
-
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
73
|
-
*/
|
|
74
|
-
export const isCoveredByReact = (eventNameSuffix) => {
|
|
75
|
-
if (typeof document === 'undefined') {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
const eventName = 'on' + transformReactEventName(eventNameSuffix);
|
|
80
|
-
let isSupported = eventName in document;
|
|
81
|
-
if (!isSupported) {
|
|
82
|
-
const element = document.createElement('div');
|
|
83
|
-
element.setAttribute(eventName, 'return;');
|
|
84
|
-
isSupported = typeof element[eventName] === 'function';
|
|
85
|
-
}
|
|
86
|
-
return isSupported;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
export const syncEvent = (node, eventName, newEventHandler) => {
|
|
90
|
-
const eventStore = node.__events || (node.__events = {});
|
|
91
|
-
const oldEventHandler = eventStore[eventName];
|
|
92
|
-
// Remove old listener so they don't double up.
|
|
93
|
-
if (oldEventHandler) {
|
|
94
|
-
node.removeEventListener(eventName, oldEventHandler);
|
|
95
|
-
}
|
|
96
|
-
// Bind new listener.
|
|
97
|
-
node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
|
|
98
|
-
if (newEventHandler) {
|
|
99
|
-
newEventHandler.call(this, e);
|
|
100
|
-
}
|
|
101
|
-
}));
|
|
102
|
-
};
|
|
103
|
-
const arrayToMap = (arr) => {
|
|
104
|
-
const map = new Map();
|
|
105
|
-
arr.forEach((s) => map.set(s, s));
|
|
106
|
-
return map;
|
|
107
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const isDevMode = () => {
|
|
2
|
-
return process && process.env && process.env.NODE_ENV === 'development';
|
|
3
|
-
};
|
|
4
|
-
const warnings = {};
|
|
5
|
-
export const deprecationWarning = (key, message) => {
|
|
6
|
-
if (isDevMode()) {
|
|
7
|
-
if (!warnings[key]) {
|
|
8
|
-
console.warn(message);
|
|
9
|
-
warnings[key] = true;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { StyleReactProps } from '../interfaces';
|
|
3
|
-
export type StencilReactExternalProps<PropType, ElementType> = PropType & Omit<React.HTMLAttributes<ElementType>, 'style'> & StyleReactProps;
|
|
4
|
-
export type StencilReactForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;
|
|
5
|
-
export declare const setRef: (ref: StencilReactForwardedRef<any> | React.Ref<any> | undefined, value: any) => void;
|
|
6
|
-
export declare const mergeRefs: (...refs: (StencilReactForwardedRef<any> | React.Ref<any> | undefined)[]) => React.RefCallback<any>;
|
|
7
|
-
export declare const createForwardRef: <PropType, ElementType>(ReactComponent: any, displayName: string) => React.ForwardRefExoticComponent<React.PropsWithoutRef<StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
|
8
|
-
export declare const defineCustomElement: (tagName: string, customElement: any) => void;
|
|
9
|
-
export * from './attachProps';
|
|
10
|
-
export * from './case';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export const setRef = (ref, value) => {
|
|
3
|
-
if (typeof ref === 'function') {
|
|
4
|
-
ref(value);
|
|
5
|
-
}
|
|
6
|
-
else if (ref != null) {
|
|
7
|
-
// Cast as a MutableRef so we can assign current
|
|
8
|
-
ref.current = value;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export const mergeRefs = (...refs) => {
|
|
12
|
-
return (value) => {
|
|
13
|
-
refs.forEach((ref) => {
|
|
14
|
-
setRef(ref, value);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export const createForwardRef = (ReactComponent, displayName) => {
|
|
19
|
-
const forwardRef = (props, ref) => {
|
|
20
|
-
return React.createElement(ReactComponent, { ...props, forwardedRef: ref });
|
|
21
|
-
};
|
|
22
|
-
forwardRef.displayName = displayName;
|
|
23
|
-
return React.forwardRef(forwardRef);
|
|
24
|
-
};
|
|
25
|
-
export const defineCustomElement = (tagName, customElement) => {
|
|
26
|
-
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
|
|
27
|
-
customElements.define(tagName, customElement);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export * from './attachProps';
|
|
31
|
-
export * from './case';
|