@arcgis/charts-components-react 4.29.1 → 4.29.3

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/components.d.ts +11 -0
  3. package/dist/components.js +13 -0
  4. package/dist/index.js +1 -0
  5. package/dist/react-component-lib/createComponent.d.ts +10 -0
  6. package/dist/react-component-lib/createComponent.js +67 -0
  7. package/dist/react-component-lib/createOverlayComponent.d.ts +21 -0
  8. package/dist/react-component-lib/createOverlayComponent.js +95 -0
  9. package/dist/react-component-lib/index.js +2 -0
  10. package/dist/react-component-lib/interfaces.d.ts +29 -0
  11. package/dist/react-component-lib/interfaces.js +1 -0
  12. package/dist/react-component-lib/utils/attachProps.d.ts +16 -0
  13. package/dist/react-component-lib/utils/attachProps.js +107 -0
  14. package/dist/react-component-lib/utils/case.d.ts +2 -0
  15. package/dist/react-component-lib/utils/case.js +6 -0
  16. package/dist/react-component-lib/utils/dev.d.ts +2 -0
  17. package/dist/react-component-lib/utils/dev.js +12 -0
  18. package/dist/react-component-lib/utils/index.d.ts +10 -0
  19. package/dist/react-component-lib/utils/index.js +31 -0
  20. package/package.json +18 -6
  21. package/src/components.ts +0 -26
  22. package/src/public-api.ts +0 -7
  23. package/src/react-component-lib/createComponent.tsx +0 -106
  24. package/src/react-component-lib/createOverlayComponent.tsx +0 -142
  25. package/src/react-component-lib/interfaces.ts +0 -34
  26. package/src/react-component-lib/utils/attachProps.ts +0 -125
  27. package/src/react-component-lib/utils/case.ts +0 -7
  28. package/src/react-component-lib/utils/dev.ts +0 -14
  29. package/src/react-component-lib/utils/index.tsx +0 -50
  30. /package/{src/index.ts → dist/index.d.ts} +0 -0
  31. /package/{src/react-component-lib/index.ts → dist/react-component-lib/index.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.29.3](https://devtopia.esri.com/WebGIS/arcgis-charts/compare/v4.29.2...v4.29.3) (2024-02-29)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * react component wrapper package build fix ([808e54b](https://devtopia.esri.com/WebGIS/arcgis-charts/commits/808e54b71006e5773f868cfd45f199af3628be94))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.29.2](https://devtopia.esri.com/WebGIS/arcgis-charts/compare/v4.29.1...v4.29.2) (2024-02-26)
18
+
19
+ **Note:** Version bump only for package @arcgis/charts-components-react
20
+
21
+
22
+
23
+
24
+
6
25
  ## [4.29.1](https://devtopia.esri.com/WebGIS/arcgis-charts/compare/v4.30.0...v4.29.1) (2024-02-26)
7
26
 
8
27
 
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import type { JSX } from "@arcgis/charts-components/dist/types/components";
3
+ export declare const ArcgisChartsActionBar: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsActionBar & Omit<import("react").HTMLAttributes<HTMLArcgisChartsActionBarElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsActionBarElement>>;
4
+ export declare const ArcgisChartsBarChart: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsBarChart & Omit<import("react").HTMLAttributes<HTMLArcgisChartsBarChartElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsBarChartElement>>;
5
+ export declare const ArcgisChartsBarLineChart: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsBarLineChart & Omit<import("react").HTMLAttributes<HTMLArcgisChartsBarLineChartElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsBarLineChartElement>>;
6
+ export declare const ArcgisChartsBoxPlot: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsBoxPlot & Omit<import("react").HTMLAttributes<HTMLArcgisChartsBoxPlotElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsBoxPlotElement>>;
7
+ export declare const ArcgisChartsGauge: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsGauge & Omit<import("react").HTMLAttributes<HTMLArcgisChartsGaugeElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsGaugeElement>>;
8
+ export declare const ArcgisChartsHistogram: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsHistogram & Omit<import("react").HTMLAttributes<HTMLArcgisChartsHistogramElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsHistogramElement>>;
9
+ export declare const ArcgisChartsLineChart: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsLineChart & Omit<import("react").HTMLAttributes<HTMLArcgisChartsLineChartElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsLineChartElement>>;
10
+ export declare const ArcgisChartsPieChart: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsPieChart & Omit<import("react").HTMLAttributes<HTMLArcgisChartsPieChartElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsPieChartElement>>;
11
+ export declare const ArcgisChartsScatterPlot: import("react").ForwardRefExoticComponent<JSX.ArcgisChartsScatterPlot & Omit<import("react").HTMLAttributes<HTMLArcgisChartsScatterPlotElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLArcgisChartsScatterPlotElement>>;
@@ -0,0 +1,13 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /* auto-generated react proxies */
4
+ import { createReactComponent } from './react-component-lib';
5
+ export const ArcgisChartsActionBar = /*@__PURE__*/ createReactComponent('arcgis-charts-action-bar');
6
+ export const ArcgisChartsBarChart = /*@__PURE__*/ createReactComponent('arcgis-charts-bar-chart');
7
+ export const ArcgisChartsBarLineChart = /*@__PURE__*/ createReactComponent('arcgis-charts-bar-line-chart');
8
+ export const ArcgisChartsBoxPlot = /*@__PURE__*/ createReactComponent('arcgis-charts-box-plot');
9
+ export const ArcgisChartsGauge = /*@__PURE__*/ createReactComponent('arcgis-charts-gauge');
10
+ export const ArcgisChartsHistogram = /*@__PURE__*/ createReactComponent('arcgis-charts-histogram');
11
+ export const ArcgisChartsLineChart = /*@__PURE__*/ createReactComponent('arcgis-charts-line-chart');
12
+ export const ArcgisChartsPieChart = /*@__PURE__*/ createReactComponent('arcgis-charts-pie-chart');
13
+ export const ArcgisChartsScatterPlot = /*@__PURE__*/ createReactComponent('arcgis-charts-scatter-plot');
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./components";
@@ -0,0 +1,10 @@
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> | undefined, manipulatePropsFunction?: ((originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes) | undefined, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
10
+ export {};
@@ -0,0 +1,67 @@
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
+ };
@@ -0,0 +1,21 @@
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> | undefined;
20
+ }> & React.RefAttributes<OverlayType>>;
21
+ export {};
@@ -0,0 +1,95 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ export { createReactComponent } from './createComponent';
2
+ export { createOverlayComponent } from './createOverlayComponent';
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
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
+ } | undefined;
16
+ }, eventName: string, newEventHandler?: ((e: Event) => any) | undefined) => void;
@@ -0,0 +1,107 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ export declare const dashToPascalCase: (str: string) => string;
2
+ export declare const camelToDashCase: (str: string) => string;
@@ -0,0 +1,6 @@
1
+ export const dashToPascalCase = (str) => str
2
+ .toLowerCase()
3
+ .split('-')
4
+ .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
5
+ .join('');
6
+ export const camelToDashCase = (str) => str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
@@ -0,0 +1,2 @@
1
+ export declare const isDevMode: () => boolean;
2
+ export declare const deprecationWarning: (key: string, message: string) => void;
@@ -0,0 +1,12 @@
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
+ };
@@ -0,0 +1,10 @@
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';
@@ -0,0 +1,31 @@
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';
package/package.json CHANGED
@@ -2,8 +2,14 @@
2
2
  "name": "@arcgis/charts-components-react",
3
3
  "description": "A set of React components that wrap ArcGIS charts components",
4
4
  "homepage": "https://developers.arcgis.com/javascript/latest/",
5
- "version": "4.29.1",
5
+ "version": "4.29.3",
6
6
  "sideEffects": false,
7
+ "module": "dist/index.js",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist/"
12
+ ],
7
13
  "license": "SEE LICENSE.md",
8
14
  "publishConfig": {
9
15
  "registry": "https://registry.npmjs.org/",
@@ -12,20 +18,26 @@
12
18
  "scripts": {
13
19
  "clean": "rimraf dist node_modules .turbo",
14
20
  "compile": "yarn tsc",
15
- "pre": "rimraf dist",
21
+ "pre": "rimraf dist && yarn awc patch-jsx-imports",
22
+ "build": "yarn pre && yarn compile",
23
+ "build:production": "yarn build",
16
24
  "tsc": "tsc"
17
25
  },
18
26
  "dependencies": {
19
- "@arcgis/charts-components": "4.29.1",
20
- "react": ">=18.0.0 <19.0.0",
21
- "react-dom": ">=18.0.0 <19.0.0"
27
+ "@arcgis/charts-components": "4.29.3"
22
28
  },
23
29
  "devDependencies": {
24
- "@arcgis/components-plugins": "^4.29.0-beta.1",
30
+ "@arcgis/components-plugins": "^4.29.5",
25
31
  "@arcgis/core": ">=4.29.0-next <4.30",
32
+ "@arcgis/typescript-config": "^4.29.2",
26
33
  "@types/node": "^20.2.5",
27
34
  "@types/react-dom": "^18.2.0",
28
35
  "rimraf": "^5.0.0",
29
36
  "typescript": "~5.3.0"
37
+ },
38
+ "peerDependencies": {
39
+ "@arcgis/core": "~4.29.0",
40
+ "react": ">=18.0.0 <19.0.0",
41
+ "react-dom": ">=18.0.0 <19.0.0"
30
42
  }
31
43
  }
package/src/components.ts DELETED
@@ -1,26 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- /* auto-generated react proxies */
4
- import { createReactComponent } from './react-component-lib';
5
-
6
- import type { JSX } from '@arcgis/charts-components/dist/components';
7
-
8
- import { defineCustomElement as defineArcgisChartsActionBar } from '@arcgis/charts-components/dist/components/arcgis-charts-action-bar.js';
9
- import { defineCustomElement as defineArcgisChartsBarChart } from '@arcgis/charts-components/dist/components/arcgis-charts-bar-chart.js';
10
- import { defineCustomElement as defineArcgisChartsBarLineChart } from '@arcgis/charts-components/dist/components/arcgis-charts-bar-line-chart.js';
11
- import { defineCustomElement as defineArcgisChartsBoxPlot } from '@arcgis/charts-components/dist/components/arcgis-charts-box-plot.js';
12
- import { defineCustomElement as defineArcgisChartsGauge } from '@arcgis/charts-components/dist/components/arcgis-charts-gauge.js';
13
- import { defineCustomElement as defineArcgisChartsHistogram } from '@arcgis/charts-components/dist/components/arcgis-charts-histogram.js';
14
- import { defineCustomElement as defineArcgisChartsLineChart } from '@arcgis/charts-components/dist/components/arcgis-charts-line-chart.js';
15
- import { defineCustomElement as defineArcgisChartsPieChart } from '@arcgis/charts-components/dist/components/arcgis-charts-pie-chart.js';
16
- import { defineCustomElement as defineArcgisChartsScatterPlot } from '@arcgis/charts-components/dist/components/arcgis-charts-scatter-plot.js';
17
-
18
- export const ArcgisChartsActionBar = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsActionBar, HTMLArcgisChartsActionBarElement>('arcgis-charts-action-bar', undefined, undefined, defineArcgisChartsActionBar);
19
- export const ArcgisChartsBarChart = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsBarChart, HTMLArcgisChartsBarChartElement>('arcgis-charts-bar-chart', undefined, undefined, defineArcgisChartsBarChart);
20
- export const ArcgisChartsBarLineChart = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsBarLineChart, HTMLArcgisChartsBarLineChartElement>('arcgis-charts-bar-line-chart', undefined, undefined, defineArcgisChartsBarLineChart);
21
- export const ArcgisChartsBoxPlot = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsBoxPlot, HTMLArcgisChartsBoxPlotElement>('arcgis-charts-box-plot', undefined, undefined, defineArcgisChartsBoxPlot);
22
- export const ArcgisChartsGauge = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsGauge, HTMLArcgisChartsGaugeElement>('arcgis-charts-gauge', undefined, undefined, defineArcgisChartsGauge);
23
- export const ArcgisChartsHistogram = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsHistogram, HTMLArcgisChartsHistogramElement>('arcgis-charts-histogram', undefined, undefined, defineArcgisChartsHistogram);
24
- export const ArcgisChartsLineChart = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsLineChart, HTMLArcgisChartsLineChartElement>('arcgis-charts-line-chart', undefined, undefined, defineArcgisChartsLineChart);
25
- export const ArcgisChartsPieChart = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsPieChart, HTMLArcgisChartsPieChartElement>('arcgis-charts-pie-chart', undefined, undefined, defineArcgisChartsPieChart);
26
- export const ArcgisChartsScatterPlot = /*@__PURE__*/createReactComponent<JSX.ArcgisChartsScatterPlot, HTMLArcgisChartsScatterPlotElement>('arcgis-charts-scatter-plot', undefined, undefined, defineArcgisChartsScatterPlot);
package/src/public-api.ts DELETED
@@ -1,7 +0,0 @@
1
- /*
2
- * Public API Surface of map-components-angular
3
- */
4
-
5
- export * from "./lib/map-components-angular.module";
6
- export { DIRECTIVES } from "./lib/stencil-generated";
7
- export * from "./lib/stencil-generated/components";
@@ -1,106 +0,0 @@
1
- import React, { createElement } from 'react';
2
-
3
- import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
4
-
5
- export interface HTMLStencilElement extends HTMLElement {
6
- componentOnReady(): Promise<this>;
7
- }
8
-
9
- interface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<ElementType> {
10
- forwardedRef: React.RefObject<ElementType>;
11
- ref?: React.Ref<any>;
12
- }
13
-
14
- export const createReactComponent = <
15
- PropType,
16
- ElementType extends HTMLStencilElement,
17
- ContextStateType = {},
18
- ExpandedPropsTypes = {}
19
- >(
20
- tagName: string,
21
- ReactComponentContext?: React.Context<ContextStateType>,
22
- manipulatePropsFunction?: (
23
- originalProps: StencilReactInternalProps<ElementType>,
24
- propsToPass: any
25
- ) => ExpandedPropsTypes,
26
- defineCustomElement?: () => void
27
- ) => {
28
- if (defineCustomElement !== undefined) {
29
- defineCustomElement();
30
- }
31
-
32
- const displayName = dashToPascalCase(tagName);
33
- const ReactComponent = class extends React.Component<StencilReactInternalProps<ElementType>> {
34
- componentEl!: ElementType;
35
-
36
- setComponentElRef = (element: ElementType) => {
37
- this.componentEl = element;
38
- };
39
-
40
- constructor(props: StencilReactInternalProps<ElementType>) {
41
- super(props);
42
- }
43
-
44
- componentDidMount() {
45
- this.componentDidUpdate(this.props);
46
- }
47
-
48
- componentDidUpdate(prevProps: StencilReactInternalProps<ElementType>) {
49
- attachProps(this.componentEl, this.props, prevProps);
50
- }
51
-
52
- render() {
53
- const { children, forwardedRef, style, className, ref, ...cProps } = this.props;
54
-
55
- let propsToPass = Object.keys(cProps).reduce((acc: any, name) => {
56
- const value = (cProps as any)[name];
57
-
58
- if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
59
- const eventName = name.substring(2).toLowerCase();
60
- if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
61
- acc[name] = value;
62
- }
63
- } else {
64
- // we should only render strings, booleans, and numbers as attrs in html.
65
- // objects, functions, arrays etc get synced via properties on mount.
66
- const type = typeof value;
67
-
68
- if (type === 'string' || type === 'boolean' || type === 'number') {
69
- acc[camelToDashCase(name)] = value;
70
- }
71
- }
72
- return acc;
73
- }, {} as ExpandedPropsTypes);
74
-
75
- if (manipulatePropsFunction) {
76
- propsToPass = manipulatePropsFunction(this.props, propsToPass);
77
- }
78
-
79
- const newProps: Omit<StencilReactInternalProps<ElementType>, 'forwardedRef'> = {
80
- ...propsToPass,
81
- ref: mergeRefs(forwardedRef, this.setComponentElRef),
82
- style,
83
- };
84
-
85
- /**
86
- * We use createElement here instead of
87
- * React.createElement to work around a
88
- * bug in Vite (https://github.com/vitejs/vite/issues/6104).
89
- * React.createElement causes all elements to be rendered
90
- * as <tagname> instead of the actual Web Component.
91
- */
92
- return createElement(tagName, newProps, children);
93
- }
94
-
95
- static get displayName() {
96
- return displayName;
97
- }
98
- };
99
-
100
- // If context was passed to createReactComponent then conditionally add it to the Component Class
101
- if (ReactComponentContext) {
102
- ReactComponent.contextType = ReactComponentContext;
103
- }
104
-
105
- return createForwardRef<PropType, ElementType>(ReactComponent, displayName);
106
- };
@@ -1,142 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
-
4
- import { OverlayEventDetail } from './interfaces';
5
- import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
6
-
7
- interface OverlayElement extends HTMLElement {
8
- present: () => Promise<void>;
9
- dismiss: (data?: any, role?: string | undefined) => Promise<boolean>;
10
- }
11
-
12
- export interface ReactOverlayProps {
13
- children?: React.ReactNode;
14
- isOpen: boolean;
15
- onDidDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
16
- onDidPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
17
- onWillDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
18
- onWillPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
19
- }
20
-
21
- export const createOverlayComponent = <OverlayComponent extends object, OverlayType extends OverlayElement>(
22
- tagName: string,
23
- controller: { create: (options: any) => Promise<OverlayType> },
24
- customElement?: any
25
- ) => {
26
- defineCustomElement(tagName, customElement);
27
-
28
- const displayName = dashToPascalCase(tagName);
29
- const didDismissEventName = `on${displayName}DidDismiss`;
30
- const didPresentEventName = `on${displayName}DidPresent`;
31
- const willDismissEventName = `on${displayName}WillDismiss`;
32
- const willPresentEventName = `on${displayName}WillPresent`;
33
-
34
- type Props = OverlayComponent &
35
- ReactOverlayProps & {
36
- forwardedRef?: StencilReactForwardedRef<OverlayType>;
37
- };
38
-
39
- let isDismissing = false;
40
-
41
- class Overlay extends React.Component<Props> {
42
- overlay?: OverlayType;
43
- el!: HTMLDivElement;
44
-
45
- constructor(props: Props) {
46
- super(props);
47
- if (typeof document !== 'undefined') {
48
- this.el = document.createElement('div');
49
- }
50
- this.handleDismiss = this.handleDismiss.bind(this);
51
- }
52
-
53
- static get displayName() {
54
- return displayName;
55
- }
56
-
57
- componentDidMount() {
58
- if (this.props.isOpen) {
59
- this.present();
60
- }
61
- }
62
-
63
- componentWillUnmount() {
64
- if (this.overlay) {
65
- this.overlay.dismiss();
66
- }
67
- }
68
-
69
- handleDismiss(event: CustomEvent<OverlayEventDetail<any>>) {
70
- if (this.props.onDidDismiss) {
71
- this.props.onDidDismiss(event);
72
- }
73
- setRef(this.props.forwardedRef, null);
74
- }
75
-
76
- shouldComponentUpdate(nextProps: Props) {
77
- // Check if the overlay component is about to dismiss
78
- if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
79
- isDismissing = true;
80
- }
81
-
82
- return true;
83
- }
84
-
85
- async componentDidUpdate(prevProps: Props) {
86
- if (this.overlay) {
87
- attachProps(this.overlay, this.props, prevProps);
88
- }
89
-
90
- if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
91
- this.present(prevProps);
92
- }
93
- if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
94
- await this.overlay.dismiss();
95
- isDismissing = false;
96
-
97
- /**
98
- * Now that the overlay is dismissed
99
- * we need to render again so that any
100
- * inner components will be unmounted
101
- */
102
- this.forceUpdate();
103
- }
104
- }
105
-
106
- async present(prevProps?: Props) {
107
- const { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent, ...cProps } = this.props;
108
- const elementProps = {
109
- ...cProps,
110
- ref: this.props.forwardedRef,
111
- [didDismissEventName]: this.handleDismiss,
112
- [didPresentEventName]: (e: CustomEvent) => this.props.onDidPresent && this.props.onDidPresent(e),
113
- [willDismissEventName]: (e: CustomEvent) => this.props.onWillDismiss && this.props.onWillDismiss(e),
114
- [willPresentEventName]: (e: CustomEvent) => this.props.onWillPresent && this.props.onWillPresent(e),
115
- };
116
-
117
- this.overlay = await controller.create({
118
- ...elementProps,
119
- component: this.el,
120
- componentProps: {},
121
- });
122
-
123
- setRef(this.props.forwardedRef, this.overlay);
124
- attachProps(this.overlay, elementProps, prevProps);
125
-
126
- await this.overlay.present();
127
- }
128
-
129
- render() {
130
- /**
131
- * Continue to render the component even when
132
- * overlay is dismissing otherwise component
133
- * will be hidden before animation is done.
134
- */
135
- return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
136
- }
137
- }
138
-
139
- return React.forwardRef<OverlayType, Props>((props, ref) => {
140
- return <Overlay {...props} forwardedRef={ref} />;
141
- });
142
- };
@@ -1,34 +0,0 @@
1
- // General types important to applications using stencil built components
2
- export interface EventEmitter<T = any> {
3
- emit: (data?: T) => CustomEvent<T>;
4
- }
5
-
6
- export interface StyleReactProps {
7
- class?: string;
8
- className?: string;
9
- style?: { [key: string]: any };
10
- }
11
-
12
- export interface OverlayEventDetail<T = any> {
13
- data?: T;
14
- role?: string;
15
- }
16
-
17
- export interface OverlayInterface {
18
- el: HTMLElement;
19
- animated: boolean;
20
- keyboardClose: boolean;
21
- overlayIndex: number;
22
- presented: boolean;
23
-
24
- enterAnimation?: any;
25
- leaveAnimation?: any;
26
-
27
- didPresent: EventEmitter<void>;
28
- willPresent: EventEmitter<void>;
29
- willDismiss: EventEmitter<OverlayEventDetail>;
30
- didDismiss: EventEmitter<OverlayEventDetail>;
31
-
32
- present(): Promise<void>;
33
- dismiss(data?: any, role?: string): Promise<boolean>;
34
- }
@@ -1,125 +0,0 @@
1
- import { camelToDashCase } from './case';
2
-
3
- export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => {
4
- // some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
5
- if (node instanceof Element) {
6
- // add any classes in className to the class list
7
- const className = getClassName(node.classList, newProps, oldProps);
8
- if (className !== '') {
9
- node.className = className;
10
- }
11
-
12
- Object.keys(newProps).forEach((name) => {
13
- if (
14
- name === 'children' ||
15
- name === 'style' ||
16
- name === 'ref' ||
17
- name === 'class' ||
18
- name === 'className' ||
19
- name === 'forwardedRef'
20
- ) {
21
- return;
22
- }
23
- if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
24
- const eventName = name.substring(2);
25
- const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
26
-
27
- if (!isCoveredByReact(eventNameLc)) {
28
- syncEvent(node, eventNameLc, newProps[name]);
29
- }
30
- } else {
31
- (node as any)[name] = newProps[name];
32
- const propType = typeof newProps[name];
33
- if (propType === 'string') {
34
- node.setAttribute(camelToDashCase(name), newProps[name]);
35
- }
36
- }
37
- });
38
- }
39
- };
40
-
41
- export const getClassName = (classList: DOMTokenList, newProps: any, oldProps: any) => {
42
- const newClassProp: string = newProps.className || newProps.class;
43
- const oldClassProp: string = oldProps.className || oldProps.class;
44
- // map the classes to Maps for performance
45
- const currentClasses = arrayToMap(classList);
46
- const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
47
- const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
48
- const finalClassNames: string[] = [];
49
- // loop through each of the current classes on the component
50
- // to see if it should be a part of the classNames added
51
- currentClasses.forEach((currentClass) => {
52
- if (incomingPropClasses.has(currentClass)) {
53
- // add it as its already included in classnames coming in from newProps
54
- finalClassNames.push(currentClass);
55
- incomingPropClasses.delete(currentClass);
56
- } else if (!oldPropClasses.has(currentClass)) {
57
- // add it as it has NOT been removed by user
58
- finalClassNames.push(currentClass);
59
- }
60
- });
61
- incomingPropClasses.forEach((s) => finalClassNames.push(s));
62
- return finalClassNames.join(' ');
63
- };
64
-
65
- /**
66
- * Transforms a React event name to a browser event name.
67
- */
68
- export const transformReactEventName = (eventNameSuffix: string) => {
69
- switch (eventNameSuffix) {
70
- case 'doubleclick':
71
- return 'dblclick';
72
- }
73
- return eventNameSuffix;
74
- };
75
-
76
- /**
77
- * Checks if an event is supported in the current execution environment.
78
- * @license Modernizr 3.0.0pre (Custom Build) | MIT
79
- */
80
- export const isCoveredByReact = (eventNameSuffix: string) => {
81
- if (typeof document === 'undefined') {
82
- return true;
83
- } else {
84
- const eventName = 'on' + transformReactEventName(eventNameSuffix);
85
- let isSupported = eventName in document;
86
-
87
- if (!isSupported) {
88
- const element = document.createElement('div');
89
- element.setAttribute(eventName, 'return;');
90
- isSupported = typeof (element as any)[eventName] === 'function';
91
- }
92
-
93
- return isSupported;
94
- }
95
- };
96
-
97
- export const syncEvent = (
98
- node: Element & { __events?: { [key: string]: ((e: Event) => any) | undefined } },
99
- eventName: string,
100
- newEventHandler?: (e: Event) => any
101
- ) => {
102
- const eventStore = node.__events || (node.__events = {});
103
- const oldEventHandler = eventStore[eventName];
104
-
105
- // Remove old listener so they don't double up.
106
- if (oldEventHandler) {
107
- node.removeEventListener(eventName, oldEventHandler);
108
- }
109
-
110
- // Bind new listener.
111
- node.addEventListener(
112
- eventName,
113
- (eventStore[eventName] = function handler(e: Event) {
114
- if (newEventHandler) {
115
- newEventHandler.call(this, e);
116
- }
117
- })
118
- );
119
- };
120
-
121
- const arrayToMap = (arr: string[] | DOMTokenList) => {
122
- const map = new Map<string, string>();
123
- (arr as string[]).forEach((s: string) => map.set(s, s));
124
- return map;
125
- };
@@ -1,7 +0,0 @@
1
- export const dashToPascalCase = (str: string) =>
2
- str
3
- .toLowerCase()
4
- .split('-')
5
- .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
6
- .join('');
7
- export const camelToDashCase = (str: string) => str.replace(/([A-Z])/g, (m: string) => `-${m[0].toLowerCase()}`);
@@ -1,14 +0,0 @@
1
- export const isDevMode = () => {
2
- return process && process.env && process.env.NODE_ENV === 'development';
3
- };
4
-
5
- const warnings: { [key: string]: boolean } = {};
6
-
7
- export const deprecationWarning = (key: string, message: string) => {
8
- if (isDevMode()) {
9
- if (!warnings[key]) {
10
- console.warn(message);
11
- warnings[key] = true;
12
- }
13
- }
14
- };
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
-
3
- import type { StyleReactProps } from '../interfaces';
4
-
5
- export type StencilReactExternalProps<PropType, ElementType> = PropType &
6
- Omit<React.HTMLAttributes<ElementType>, 'style'> &
7
- StyleReactProps;
8
-
9
- // This will be replaced with React.ForwardedRef when react-output-target is upgraded to React v17
10
- export type StencilReactForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;
11
-
12
- export const setRef = (ref: StencilReactForwardedRef<any> | React.Ref<any> | undefined, value: any) => {
13
- if (typeof ref === 'function') {
14
- ref(value);
15
- } else if (ref != null) {
16
- // Cast as a MutableRef so we can assign current
17
- (ref as React.MutableRefObject<any>).current = value;
18
- }
19
- };
20
-
21
- export const mergeRefs = (
22
- ...refs: (StencilReactForwardedRef<any> | React.Ref<any> | undefined)[]
23
- ): React.RefCallback<any> => {
24
- return (value: any) => {
25
- refs.forEach((ref) => {
26
- setRef(ref, value);
27
- });
28
- };
29
- };
30
-
31
- export const createForwardRef = <PropType, ElementType>(ReactComponent: any, displayName: string) => {
32
- const forwardRef = (
33
- props: StencilReactExternalProps<PropType, ElementType>,
34
- ref: StencilReactForwardedRef<ElementType>
35
- ) => {
36
- return <ReactComponent {...props} forwardedRef={ref} />;
37
- };
38
- forwardRef.displayName = displayName;
39
-
40
- return React.forwardRef(forwardRef);
41
- };
42
-
43
- export const defineCustomElement = (tagName: string, customElement: any) => {
44
- if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
45
- customElements.define(tagName, customElement);
46
- }
47
- };
48
-
49
- export * from './attachProps';
50
- export * from './case';
File without changes