maxi-stencil-library-react 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/react-component-lib/createComponent.js +65 -0
- package/dist/react-component-lib/createComponent.js.map +1 -0
- package/dist/react-component-lib/createOverlayComponent.js +86 -0
- package/dist/react-component-lib/createOverlayComponent.js.map +1 -0
- package/dist/react-component-lib/index.js +3 -0
- package/dist/react-component-lib/index.js.map +1 -0
- package/dist/react-component-lib/interfaces.js +1 -0
- package/dist/react-component-lib/interfaces.js.map +1 -0
- package/dist/react-component-lib/utils/attachProps.js +108 -0
- package/dist/react-component-lib/utils/attachProps.js.map +1 -0
- package/dist/react-component-lib/utils/case.js +7 -0
- package/dist/react-component-lib/utils/case.js.map +1 -0
- package/dist/react-component-lib/utils/dev.js +13 -0
- package/dist/react-component-lib/utils/dev.js.map +1 -0
- package/dist/react-component-lib/utils/index.js +32 -0
- package/dist/react-component-lib/utils/index.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/react-component-lib/createComponent.d.ts +10 -0
- package/dist/types/react-component-lib/createOverlayComponent.d.ts +20 -0
- package/dist/types/react-component-lib/index.d.ts +2 -0
- package/dist/types/react-component-lib/interfaces.d.ts +29 -0
- package/dist/types/react-component-lib/utils/attachProps.d.ts +16 -0
- package/dist/types/react-component-lib/utils/case.d.ts +2 -0
- package/dist/types/react-component-lib/utils/dev.d.ts +2 -0
- package/dist/types/react-component-lib/utils/index.d.ts +10 -0
- package/package.json +60 -0
package/dist/index.js
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
/* tslint:disable */
|
3
|
+
/* auto-generated react proxies */
|
4
|
+
import { createReactComponent } from './react-component-lib';
|
5
|
+
import { defineCustomElements } from 'maxi-stencil-library/loader';
|
6
|
+
defineCustomElements();
|
7
|
+
export const MyComponent = /*@__PURE__*/ createReactComponent('my-component');
|
8
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/components/stencil-generated/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,oBAAoB;AACpB,kCAAkC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,oBAAoB,EAAE,CAAC;AACvB,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAA,oBAAoB,CAA0C,cAAc,CAAC,CAAC","sourcesContent":["/* eslint-disable */\n/* tslint:disable */\n/* auto-generated react proxies */\nimport { createReactComponent } from './react-component-lib';\n\nimport type { JSX } from 'maxi-stencil-library';\n\nimport { defineCustomElements } from 'maxi-stencil-library/loader';\n\ndefineCustomElements();\nexport const MyComponent = /*@__PURE__*/createReactComponent<JSX.MyComponent, HTMLMyComponentElement>('my-component');\n"]}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { __rest } from "tslib";
|
2
|
+
import React, { createElement } from 'react';
|
3
|
+
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
|
4
|
+
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
5
|
+
if (defineCustomElement !== undefined) {
|
6
|
+
defineCustomElement();
|
7
|
+
}
|
8
|
+
const displayName = dashToPascalCase(tagName);
|
9
|
+
const ReactComponent = class extends React.Component {
|
10
|
+
constructor(props) {
|
11
|
+
super(props);
|
12
|
+
this.setComponentElRef = (element) => {
|
13
|
+
this.componentEl = element;
|
14
|
+
};
|
15
|
+
}
|
16
|
+
componentDidMount() {
|
17
|
+
this.componentDidUpdate(this.props);
|
18
|
+
}
|
19
|
+
componentDidUpdate(prevProps) {
|
20
|
+
attachProps(this.componentEl, this.props, prevProps);
|
21
|
+
}
|
22
|
+
render() {
|
23
|
+
const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
|
24
|
+
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
25
|
+
const value = cProps[name];
|
26
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
27
|
+
const eventName = name.substring(2).toLowerCase();
|
28
|
+
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
29
|
+
acc[name] = value;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
// we should only render strings, booleans, and numbers as attrs in html.
|
34
|
+
// objects, functions, arrays etc get synced via properties on mount.
|
35
|
+
const type = typeof value;
|
36
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
37
|
+
acc[camelToDashCase(name)] = value;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return acc;
|
41
|
+
}, {});
|
42
|
+
if (manipulatePropsFunction) {
|
43
|
+
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
44
|
+
}
|
45
|
+
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style });
|
46
|
+
/**
|
47
|
+
* We use createElement here instead of
|
48
|
+
* React.createElement to work around a
|
49
|
+
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
50
|
+
* React.createElement causes all elements to be rendered
|
51
|
+
* as <tagname> instead of the actual Web Component.
|
52
|
+
*/
|
53
|
+
return createElement(tagName, newProps, children);
|
54
|
+
}
|
55
|
+
static get displayName() {
|
56
|
+
return displayName;
|
57
|
+
}
|
58
|
+
};
|
59
|
+
// If context was passed to createReactComponent then conditionally add it to the Component Class
|
60
|
+
if (ReactComponentContext) {
|
61
|
+
ReactComponent.contextType = ReactComponentContext;
|
62
|
+
}
|
63
|
+
return createForwardRef(ReactComponent, displayName);
|
64
|
+
};
|
65
|
+
//# sourceMappingURL=createComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createComponent.js","sourceRoot":"","sources":["../../src/components/stencil-generated/react-component-lib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sourcesContent":["import React, { createElement } from 'react';\n\nimport { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';\n\nexport interface HTMLStencilElement extends HTMLElement {\n componentOnReady(): Promise<this>;\n}\n\ninterface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<ElementType> {\n forwardedRef: React.RefObject<ElementType>;\n ref?: React.Ref<any>;\n}\n\nexport const createReactComponent = <\n PropType,\n ElementType extends HTMLStencilElement,\n ContextStateType = {},\n ExpandedPropsTypes = {}\n>(\n tagName: string,\n ReactComponentContext?: React.Context<ContextStateType>,\n manipulatePropsFunction?: (\n originalProps: StencilReactInternalProps<ElementType>,\n propsToPass: any\n ) => ExpandedPropsTypes,\n defineCustomElement?: () => void\n) => {\n if (defineCustomElement !== undefined) {\n defineCustomElement();\n }\n\n const displayName = dashToPascalCase(tagName);\n const ReactComponent = class extends React.Component<StencilReactInternalProps<ElementType>> {\n componentEl!: ElementType;\n\n setComponentElRef = (element: ElementType) => {\n this.componentEl = element;\n };\n\n constructor(props: StencilReactInternalProps<ElementType>) {\n super(props);\n }\n\n componentDidMount() {\n this.componentDidUpdate(this.props);\n }\n\n componentDidUpdate(prevProps: StencilReactInternalProps<ElementType>) {\n attachProps(this.componentEl, this.props, prevProps);\n }\n\n render() {\n const { children, forwardedRef, style, className, ref, ...cProps } = this.props;\n\n let propsToPass = Object.keys(cProps).reduce((acc: any, name) => {\n const value = (cProps as any)[name];\n\n if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {\n const eventName = name.substring(2).toLowerCase();\n if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {\n acc[name] = value;\n }\n } else {\n // we should only render strings, booleans, and numbers as attrs in html.\n // objects, functions, arrays etc get synced via properties on mount.\n const type = typeof value;\n\n if (type === 'string' || type === 'boolean' || type === 'number') {\n acc[camelToDashCase(name)] = value;\n }\n }\n return acc;\n }, {} as ExpandedPropsTypes);\n\n if (manipulatePropsFunction) {\n propsToPass = manipulatePropsFunction(this.props, propsToPass);\n }\n\n const newProps: Omit<StencilReactInternalProps<ElementType>, 'forwardedRef'> = {\n ...propsToPass,\n ref: mergeRefs(forwardedRef, this.setComponentElRef),\n style,\n };\n\n /**\n * We use createElement here instead of\n * React.createElement to work around a\n * bug in Vite (https://github.com/vitejs/vite/issues/6104).\n * React.createElement causes all elements to be rendered\n * as <tagname> instead of the actual Web Component.\n */\n return createElement(tagName, newProps, children);\n }\n\n static get displayName() {\n return displayName;\n }\n };\n\n // If context was passed to createReactComponent then conditionally add it to the Component Class\n if (ReactComponentContext) {\n ReactComponent.contextType = ReactComponentContext;\n }\n\n return createForwardRef<PropType, ElementType>(ReactComponent, displayName);\n};\n"]}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import { __rest } from "tslib";
|
2
|
+
import React from 'react';
|
3
|
+
import ReactDOM from 'react-dom';
|
4
|
+
import { attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
|
5
|
+
export const createOverlayComponent = (tagName, controller, customElement) => {
|
6
|
+
defineCustomElement(tagName, customElement);
|
7
|
+
const displayName = dashToPascalCase(tagName);
|
8
|
+
const didDismissEventName = `on${displayName}DidDismiss`;
|
9
|
+
const didPresentEventName = `on${displayName}DidPresent`;
|
10
|
+
const willDismissEventName = `on${displayName}WillDismiss`;
|
11
|
+
const willPresentEventName = `on${displayName}WillPresent`;
|
12
|
+
let isDismissing = false;
|
13
|
+
class Overlay extends React.Component {
|
14
|
+
constructor(props) {
|
15
|
+
super(props);
|
16
|
+
if (typeof document !== 'undefined') {
|
17
|
+
this.el = document.createElement('div');
|
18
|
+
}
|
19
|
+
this.handleDismiss = this.handleDismiss.bind(this);
|
20
|
+
}
|
21
|
+
static get displayName() {
|
22
|
+
return displayName;
|
23
|
+
}
|
24
|
+
componentDidMount() {
|
25
|
+
if (this.props.isOpen) {
|
26
|
+
this.present();
|
27
|
+
}
|
28
|
+
}
|
29
|
+
componentWillUnmount() {
|
30
|
+
if (this.overlay) {
|
31
|
+
this.overlay.dismiss();
|
32
|
+
}
|
33
|
+
}
|
34
|
+
handleDismiss(event) {
|
35
|
+
if (this.props.onDidDismiss) {
|
36
|
+
this.props.onDidDismiss(event);
|
37
|
+
}
|
38
|
+
setRef(this.props.forwardedRef, null);
|
39
|
+
}
|
40
|
+
shouldComponentUpdate(nextProps) {
|
41
|
+
// Check if the overlay component is about to dismiss
|
42
|
+
if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
|
43
|
+
isDismissing = true;
|
44
|
+
}
|
45
|
+
return true;
|
46
|
+
}
|
47
|
+
async componentDidUpdate(prevProps) {
|
48
|
+
if (this.overlay) {
|
49
|
+
attachProps(this.overlay, this.props, prevProps);
|
50
|
+
}
|
51
|
+
if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
|
52
|
+
this.present(prevProps);
|
53
|
+
}
|
54
|
+
if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
|
55
|
+
await this.overlay.dismiss();
|
56
|
+
isDismissing = false;
|
57
|
+
/**
|
58
|
+
* Now that the overlay is dismissed
|
59
|
+
* we need to render again so that any
|
60
|
+
* inner components will be unmounted
|
61
|
+
*/
|
62
|
+
this.forceUpdate();
|
63
|
+
}
|
64
|
+
}
|
65
|
+
async present(prevProps) {
|
66
|
+
const _a = this.props, { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent } = _a, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
|
67
|
+
const elementProps = Object.assign(Object.assign({}, cProps), { ref: this.props.forwardedRef, [didDismissEventName]: this.handleDismiss, [didPresentEventName]: (e) => this.props.onDidPresent && this.props.onDidPresent(e), [willDismissEventName]: (e) => this.props.onWillDismiss && this.props.onWillDismiss(e), [willPresentEventName]: (e) => this.props.onWillPresent && this.props.onWillPresent(e) });
|
68
|
+
this.overlay = await controller.create(Object.assign(Object.assign({}, elementProps), { component: this.el, componentProps: {} }));
|
69
|
+
setRef(this.props.forwardedRef, this.overlay);
|
70
|
+
attachProps(this.overlay, elementProps, prevProps);
|
71
|
+
await this.overlay.present();
|
72
|
+
}
|
73
|
+
render() {
|
74
|
+
/**
|
75
|
+
* Continue to render the component even when
|
76
|
+
* overlay is dismissing otherwise component
|
77
|
+
* will be hidden before animation is done.
|
78
|
+
*/
|
79
|
+
return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return React.forwardRef((props, ref) => {
|
83
|
+
return React.createElement(Overlay, Object.assign({}, props, { forwardedRef: ref }));
|
84
|
+
});
|
85
|
+
};
|
86
|
+
//# sourceMappingURL=createOverlayComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createOverlayComponent.js","sourceRoot":"","sources":["../../src/components/stencil-generated/react-component-lib/createOverlayComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,WAAW,CAAC;AAGjC,OAAO,EAA4B,WAAW,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAgB/G,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAe,EACf,UAA8D,EAC9D,aAAmB,EACnB,EAAE;IACF,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE5C,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,mBAAmB,GAAG,KAAK,WAAW,YAAY,CAAC;IACzD,MAAM,mBAAmB,GAAG,KAAK,WAAW,YAAY,CAAC;IACzD,MAAM,oBAAoB,GAAG,KAAK,WAAW,aAAa,CAAC;IAC3D,MAAM,oBAAoB,GAAG,KAAK,WAAW,aAAa,CAAC;IAO3D,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,MAAM,OAAQ,SAAQ,KAAK,CAAC,SA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EF,IAAI,CAAC,OAAO,GAAG,MAAM,UAAU,CAAC,MAAM,iCACjC,YAAY,KACf,SAAS,EAAE,IAAI,CAAC,EAAE,EAClB,cAAc,EAAE,EAAE,IAClB,CAAC;YAEH,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9C,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;YAEnD,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;QAED,MAAM;YACJ;;;;eAIG;YACH,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxG,CAAC;KACF;IAED,OAAO,KAAK,CAAC,UAAU,CAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACzD,OAAO,oBAAC,OAAO,oBAAK,KAAK,IAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { OverlayEventDetail } from './interfaces';\nimport { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';\n\ninterface OverlayElement extends HTMLElement {\n present: () => Promise<void>;\n dismiss: (data?: any, role?: string | undefined) => Promise<boolean>;\n}\n\nexport interface ReactOverlayProps {\n children?: React.ReactNode;\n isOpen: boolean;\n onDidDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;\n onDidPresent?: (event: CustomEvent<OverlayEventDetail>) => void;\n onWillDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;\n onWillPresent?: (event: CustomEvent<OverlayEventDetail>) => void;\n}\n\nexport const createOverlayComponent = <OverlayComponent extends object, OverlayType extends OverlayElement>(\n tagName: string,\n controller: { create: (options: any) => Promise<OverlayType> },\n customElement?: any\n) => {\n defineCustomElement(tagName, customElement);\n\n const displayName = dashToPascalCase(tagName);\n const didDismissEventName = `on${displayName}DidDismiss`;\n const didPresentEventName = `on${displayName}DidPresent`;\n const willDismissEventName = `on${displayName}WillDismiss`;\n const willPresentEventName = `on${displayName}WillPresent`;\n\n type Props = OverlayComponent &\n ReactOverlayProps & {\n forwardedRef?: StencilReactForwardedRef<OverlayType>;\n };\n\n let isDismissing = false;\n\n class Overlay extends React.Component<Props> {\n overlay?: OverlayType;\n el!: HTMLDivElement;\n\n constructor(props: Props) {\n super(props);\n if (typeof document !== 'undefined') {\n this.el = document.createElement('div');\n }\n this.handleDismiss = this.handleDismiss.bind(this);\n }\n\n static get displayName() {\n return displayName;\n }\n\n componentDidMount() {\n if (this.props.isOpen) {\n this.present();\n }\n }\n\n componentWillUnmount() {\n if (this.overlay) {\n this.overlay.dismiss();\n }\n }\n\n handleDismiss(event: CustomEvent<OverlayEventDetail<any>>) {\n if (this.props.onDidDismiss) {\n this.props.onDidDismiss(event);\n }\n setRef(this.props.forwardedRef, null);\n }\n\n shouldComponentUpdate(nextProps: Props) {\n // Check if the overlay component is about to dismiss\n if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {\n isDismissing = true;\n }\n\n return true;\n }\n\n async componentDidUpdate(prevProps: Props) {\n if (this.overlay) {\n attachProps(this.overlay, this.props, prevProps);\n }\n\n if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {\n this.present(prevProps);\n }\n if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {\n await this.overlay.dismiss();\n isDismissing = false;\n\n /**\n * Now that the overlay is dismissed\n * we need to render again so that any\n * inner components will be unmounted\n */\n this.forceUpdate();\n }\n }\n\n async present(prevProps?: Props) {\n const { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent, ...cProps } = this.props;\n const elementProps = {\n ...cProps,\n ref: this.props.forwardedRef,\n [didDismissEventName]: this.handleDismiss,\n [didPresentEventName]: (e: CustomEvent) => this.props.onDidPresent && this.props.onDidPresent(e),\n [willDismissEventName]: (e: CustomEvent) => this.props.onWillDismiss && this.props.onWillDismiss(e),\n [willPresentEventName]: (e: CustomEvent) => this.props.onWillPresent && this.props.onWillPresent(e),\n };\n\n this.overlay = await controller.create({\n ...elementProps,\n component: this.el,\n componentProps: {},\n });\n\n setRef(this.props.forwardedRef, this.overlay);\n attachProps(this.overlay, elementProps, prevProps);\n\n await this.overlay.present();\n }\n\n render() {\n /**\n * Continue to render the component even when\n * overlay is dismissing otherwise component\n * will be hidden before animation is done.\n */\n return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);\n }\n }\n\n return React.forwardRef<OverlayType, Props>((props, ref) => {\n return <Overlay {...props} forwardedRef={ref} />;\n });\n};\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/stencil-generated/react-component-lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { createReactComponent } from './createComponent';\nexport { createOverlayComponent } from './createOverlayComponent';\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=interfaces.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/components/stencil-generated/react-component-lib/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// General types important to applications using stencil built components\nexport interface EventEmitter<T = any> {\n emit: (data?: T) => CustomEvent<T>;\n}\n\nexport interface StyleReactProps {\n class?: string;\n className?: string;\n style?: { [key: string]: any };\n}\n\nexport interface OverlayEventDetail<T = any> {\n data?: T;\n role?: string;\n}\n\nexport interface OverlayInterface {\n el: HTMLElement;\n animated: boolean;\n keyboardClose: boolean;\n overlayIndex: number;\n presented: boolean;\n\n enterAnimation?: any;\n leaveAnimation?: any;\n\n didPresent: EventEmitter<void>;\n willPresent: EventEmitter<void>;\n willDismiss: EventEmitter<OverlayEventDetail>;\n didDismiss: EventEmitter<OverlayEventDetail>;\n\n present(): Promise<void>;\n dismiss(data?: any, role?: string): Promise<boolean>;\n}\n"]}
|
@@ -0,0 +1,108 @@
|
|
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
|
+
};
|
108
|
+
//# sourceMappingURL=attachProps.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"attachProps.js","sourceRoot":"","sources":["../../../src/components/stencil-generated/react-component-lib/utils/attachProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAE,QAAa,EAAE,WAAgB,EAAE,EAAE,EAAE;IAClF,6GAA6G;IAC7G,IAAI,IAAI,YAAY,OAAO,EAAE;QAC3B,iDAAiD;QACjD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnE,IAAI,SAAS,KAAK,EAAE,EAAE;YACpB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;SAC5B;QAED,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrC,IACE,IAAI,KAAK,UAAU;gBACnB,IAAI,KAAK,OAAO;gBAChB,IAAI,KAAK,KAAK;gB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CAAC;AACb,CAAC,CAAC","sourcesContent":["import { camelToDashCase } from './case';\n\nexport const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => {\n // some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first\n if (node instanceof Element) {\n // add any classes in className to the class list\n const className = getClassName(node.classList, newProps, oldProps);\n if (className !== '') {\n node.className = className;\n }\n\n Object.keys(newProps).forEach((name) => {\n if (\n name === 'children' ||\n name === 'style' ||\n name === 'ref' ||\n name === 'class' ||\n name === 'className' ||\n name === 'forwardedRef'\n ) {\n return;\n }\n if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {\n const eventName = name.substring(2);\n const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);\n\n if (!isCoveredByReact(eventNameLc)) {\n syncEvent(node, eventNameLc, newProps[name]);\n }\n } else {\n (node as any)[name] = newProps[name];\n const propType = typeof newProps[name];\n if (propType === 'string') {\n node.setAttribute(camelToDashCase(name), newProps[name]);\n }\n }\n });\n }\n};\n\nexport const getClassName = (classList: DOMTokenList, newProps: any, oldProps: any) => {\n const newClassProp: string = newProps.className || newProps.class;\n const oldClassProp: string = oldProps.className || oldProps.class;\n // map the classes to Maps for performance\n const currentClasses = arrayToMap(classList);\n const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);\n const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);\n const finalClassNames: string[] = [];\n // loop through each of the current classes on the component\n // to see if it should be a part of the classNames added\n currentClasses.forEach((currentClass) => {\n if (incomingPropClasses.has(currentClass)) {\n // add it as its already included in classnames coming in from newProps\n finalClassNames.push(currentClass);\n incomingPropClasses.delete(currentClass);\n } else if (!oldPropClasses.has(currentClass)) {\n // add it as it has NOT been removed by user\n finalClassNames.push(currentClass);\n }\n });\n incomingPropClasses.forEach((s) => finalClassNames.push(s));\n return finalClassNames.join(' ');\n};\n\n/**\n * Transforms a React event name to a browser event name.\n */\nexport const transformReactEventName = (eventNameSuffix: string) => {\n switch (eventNameSuffix) {\n case 'doubleclick':\n return 'dblclick';\n }\n return eventNameSuffix;\n};\n\n/**\n * Checks if an event is supported in the current execution environment.\n * @license Modernizr 3.0.0pre (Custom Build) | MIT\n */\nexport const isCoveredByReact = (eventNameSuffix: string) => {\n if (typeof document === 'undefined') {\n return true;\n } else {\n const eventName = 'on' + transformReactEventName(eventNameSuffix);\n let isSupported = eventName in document;\n\n if (!isSupported) {\n const element = document.createElement('div');\n element.setAttribute(eventName, 'return;');\n isSupported = typeof (element as any)[eventName] === 'function';\n }\n\n return isSupported;\n }\n};\n\nexport const syncEvent = (\n node: Element & { __events?: { [key: string]: ((e: Event) => any) | undefined } },\n eventName: string,\n newEventHandler?: (e: Event) => any\n) => {\n const eventStore = node.__events || (node.__events = {});\n const oldEventHandler = eventStore[eventName];\n\n // Remove old listener so they don't double up.\n if (oldEventHandler) {\n node.removeEventListener(eventName, oldEventHandler);\n }\n\n // Bind new listener.\n node.addEventListener(\n eventName,\n (eventStore[eventName] = function handler(e: Event) {\n if (newEventHandler) {\n newEventHandler.call(this, e);\n }\n })\n );\n};\n\nconst arrayToMap = (arr: string[] | DOMTokenList) => {\n const map = new Map<string, string>();\n (arr as string[]).forEach((s: string) => map.set(s, s));\n return map;\n};\n"]}
|
@@ -0,0 +1,7 @@
|
|
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()}`);
|
7
|
+
//# sourceMappingURL=case.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"case.js","sourceRoot":"","sources":["../../../src/components/stencil-generated/react-component-lib/utils/case.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,EAAE,CAC9C,GAAG;KACA,WAAW,EAAE;KACb,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACpE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC","sourcesContent":["export const dashToPascalCase = (str: string) =>\n str\n .toLowerCase()\n .split('-')\n .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n .join('');\nexport const camelToDashCase = (str: string) => str.replace(/([A-Z])/g, (m: string) => `-${m[0].toLowerCase()}`);\n"]}
|
@@ -0,0 +1,13 @@
|
|
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
|
+
};
|
13
|
+
//# sourceMappingURL=dev.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/components/stencil-generated/react-component-lib/utils/dev.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,OAAO,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,QAAQ,GAA+B,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,OAAe,EAAE,EAAE;IACjE,IAAI,SAAS,EAAE,EAAE;QACf,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;SACtB;KACF;AACH,CAAC,CAAC","sourcesContent":["export const isDevMode = () => {\n return process && process.env && process.env.NODE_ENV === 'development';\n};\n\nconst warnings: { [key: string]: boolean } = {};\n\nexport const deprecationWarning = (key: string, message: string) => {\n if (isDevMode()) {\n if (!warnings[key]) {\n console.warn(message);\n warnings[key] = true;\n }\n }\n};\n"]}
|
@@ -0,0 +1,32 @@
|
|
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, Object.assign({}, 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';
|
32
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/stencil-generated/react-component-lib/utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAA+D,EAAE,KAAU,EAAE,EAAE;IACpG,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;QAC7B,GAAG,CAAC,KAAK,CAAC,CAAC;KACZ;SAAM,IAAI,GAAG,IAAI,IAAI,EAAE;QACtB,gDAAgD;QAC/C,GAAmC,CAAC,OAAO,GAAG,KAAK,CAAC;KACtD;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAAG,IAAoE,EAC/C,EAAE;IAC1B,OAAO,CAAC,KAAU,EAAE,EAAE;QACpB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAwB,cAAmB,EAAE,WAAmB,EAAE,EAAE;IAClG,MAAM,UAAU,GAAG,CACjB,KAAuD,EACvD,GAA0C,EAC1C,EAAE;QACF,OAAO,oBAAC,cAAc,oBAAK,KAAK,IAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC1D,CAAC,CAAC;IACF,UAAU,CAAC,WAAW,GAAG,WAAW,CAAC;IAErC,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,aAAkB,EAAE,EAAE;IACzE,IAAI,aAAa,KAAK,SAAS,IAAI,OAAO,cAAc,KAAK,WAAW,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QACxG,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;KAC/C;AACH,CAAC,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC","sourcesContent":["import React from 'react';\n\nimport type { StyleReactProps } from '../interfaces';\n\nexport type StencilReactExternalProps<PropType, ElementType> = PropType &\n Omit<React.HTMLAttributes<ElementType>, 'style'> &\n StyleReactProps;\n\n// This will be replaced with React.ForwardedRef when react-output-target is upgraded to React v17\nexport type StencilReactForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;\n\nexport const setRef = (ref: StencilReactForwardedRef<any> | React.Ref<any> | undefined, value: any) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n // Cast as a MutableRef so we can assign current\n (ref as React.MutableRefObject<any>).current = value;\n }\n};\n\nexport const mergeRefs = (\n ...refs: (StencilReactForwardedRef<any> | React.Ref<any> | undefined)[]\n): React.RefCallback<any> => {\n return (value: any) => {\n refs.forEach((ref) => {\n setRef(ref, value);\n });\n };\n};\n\nexport const createForwardRef = <PropType, ElementType>(ReactComponent: any, displayName: string) => {\n const forwardRef = (\n props: StencilReactExternalProps<PropType, ElementType>,\n ref: StencilReactForwardedRef<ElementType>\n ) => {\n return <ReactComponent {...props} forwardedRef={ref} />;\n };\n forwardRef.displayName = displayName;\n\n return React.forwardRef(forwardRef);\n};\n\nexport const defineCustomElement = (tagName: string, customElement: any) => {\n if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {\n customElements.define(tagName, customElement);\n }\n};\n\nexport * from './attachProps';\nexport * from './case';\n"]}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import type { JSX } from 'maxi-stencil-library';
|
2
|
+
export declare const MyComponent: import("react").ForwardRefExoticComponent<JSX.MyComponent & Pick<import("react").HTMLAttributes<HTMLMyComponentElement>, "dir" | "slot" | "title" | "children" | "className" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLMyComponentElement>>;
|
@@ -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) | undefined) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
10
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { OverlayEventDetail } from './interfaces';
|
3
|
+
interface OverlayElement extends HTMLElement {
|
4
|
+
present: () => Promise<void>;
|
5
|
+
dismiss: (data?: any, role?: string | undefined) => Promise<boolean>;
|
6
|
+
}
|
7
|
+
export interface ReactOverlayProps {
|
8
|
+
children?: React.ReactNode;
|
9
|
+
isOpen: boolean;
|
10
|
+
onDidDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
|
11
|
+
onDidPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
|
12
|
+
onWillDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
|
13
|
+
onWillPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
|
14
|
+
}
|
15
|
+
export declare const createOverlayComponent: <OverlayComponent extends object, OverlayType extends OverlayElement>(tagName: string, controller: {
|
16
|
+
create: (options: any) => Promise<OverlayType>;
|
17
|
+
}, customElement?: any) => React.ForwardRefExoticComponent<React.PropsWithoutRef<OverlayComponent & ReactOverlayProps & {
|
18
|
+
forwardedRef?: React.MutableRefObject<OverlayType | null> | ((instance: OverlayType | null) => void) | null | undefined;
|
19
|
+
}> & React.RefAttributes<OverlayType>>;
|
20
|
+
export {};
|
@@ -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,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,10 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { StyleReactProps } from '../interfaces';
|
3
|
+
export declare type StencilReactExternalProps<PropType, ElementType> = PropType & Omit<React.HTMLAttributes<ElementType>, 'style'> & StyleReactProps;
|
4
|
+
export declare 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';
|
package/package.json
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
{
|
2
|
+
"name": "maxi-stencil-library-react",
|
3
|
+
"sideEffects": false,
|
4
|
+
"version": "0.0.1",
|
5
|
+
"description": "Integration for React apps",
|
6
|
+
"license": "MIT",
|
7
|
+
"keywords": [
|
8
|
+
"webapp"
|
9
|
+
],
|
10
|
+
"repository": {
|
11
|
+
"type": "git",
|
12
|
+
"url": "https://github.com/adaleks/anywhere-ui.git"
|
13
|
+
},
|
14
|
+
"bugs": {
|
15
|
+
"url": "https://github.com/adaleks/anywhere-ui/issues"
|
16
|
+
},
|
17
|
+
"homepage": "https://github.com/adaleks/anywhere-ui/tree/main/packages/react#readme",
|
18
|
+
"scripts": {
|
19
|
+
"build": "npm run clean && npm run compile && npm publish",
|
20
|
+
"clean:all" : "rimraf src dist node_modules package-lock.json",
|
21
|
+
"clean": "rimraf dist",
|
22
|
+
"compile": "npm run tsc",
|
23
|
+
"tsc": "tsc -p . --outDir ./dist",
|
24
|
+
"rollup": "rollup -c"
|
25
|
+
},
|
26
|
+
"main": "./dist/index.js",
|
27
|
+
"module": "./dist/index.js",
|
28
|
+
"types": "./dist/index.d.ts",
|
29
|
+
"files": [
|
30
|
+
"dist"
|
31
|
+
],
|
32
|
+
"devDependencies": {
|
33
|
+
"@types/jest": "23.3.9",
|
34
|
+
"@types/node": "^15.12.2",
|
35
|
+
"@types/react": "^17.0.34",
|
36
|
+
"@types/react-dom": "^17.0.11",
|
37
|
+
"jest": "^23.0.0",
|
38
|
+
"jest-dom": "^3.0.2",
|
39
|
+
"np": "^3.1.0",
|
40
|
+
"react": "^17.0.2",
|
41
|
+
"react-dom": "^17.0.2",
|
42
|
+
"rimraf": "^3.0.2",
|
43
|
+
"typescript": "^3.3.4000"
|
44
|
+
},
|
45
|
+
"peerDependencies": {
|
46
|
+
"react": "^17.0.2",
|
47
|
+
"react-dom": "^17.0.2"
|
48
|
+
},
|
49
|
+
"jest": {
|
50
|
+
"preset": "ts-jest",
|
51
|
+
"setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js",
|
52
|
+
"testPathIgnorePatterns": [
|
53
|
+
"node_modules",
|
54
|
+
"dist"
|
55
|
+
]
|
56
|
+
},
|
57
|
+
"dependencies": {
|
58
|
+
"maxi-stencil-library": "^0.0.1"
|
59
|
+
}
|
60
|
+
}
|