@xplortech/apollo-react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/dist/components.d.ts +4 -0
- package/dist/components.js +9 -0
- package/dist/components.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/react-component-lib/createComponent.d.ts +10 -0
- package/dist/react-component-lib/createComponent.js +59 -0
- package/dist/react-component-lib/createComponent.js.map +1 -0
- package/dist/react-component-lib/createOverlayComponent.d.ts +20 -0
- package/dist/react-component-lib/createOverlayComponent.js +89 -0
- package/dist/react-component-lib/createOverlayComponent.js.map +1 -0
- package/dist/react-component-lib/index.d.ts +2 -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.d.ts +29 -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.d.ts +12 -0
- package/dist/react-component-lib/utils/attachProps.js +96 -0
- package/dist/react-component-lib/utils/attachProps.js.map +1 -0
- package/dist/react-component-lib/utils/case.d.ts +2 -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.d.ts +2 -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.d.ts +7 -0
- package/dist/react-component-lib/utils/index.js +21 -0
- package/dist/react-component-lib/utils/index.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Getting Started with Create React App
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
4
|
+
|
|
5
|
+
## Available Scripts
|
|
6
|
+
|
|
7
|
+
In the project directory, you can run:
|
|
8
|
+
|
|
9
|
+
### `yarn start`
|
|
10
|
+
|
|
11
|
+
Runs the app in the development mode.\
|
|
12
|
+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
|
13
|
+
|
|
14
|
+
The page will reload if you make edits.\
|
|
15
|
+
You will also see any lint errors in the console.
|
|
16
|
+
|
|
17
|
+
### `yarn test`
|
|
18
|
+
|
|
19
|
+
Launches the test runner in the interactive watch mode.\
|
|
20
|
+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
21
|
+
|
|
22
|
+
### `yarn build`
|
|
23
|
+
|
|
24
|
+
Builds the app for production to the `build` folder.\
|
|
25
|
+
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
26
|
+
|
|
27
|
+
The build is minified and the filenames include the hashes.\
|
|
28
|
+
Your app is ready to be deployed!
|
|
29
|
+
|
|
30
|
+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
31
|
+
|
|
32
|
+
### `yarn eject`
|
|
33
|
+
|
|
34
|
+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
|
35
|
+
|
|
36
|
+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
37
|
+
|
|
38
|
+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
|
39
|
+
|
|
40
|
+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
|
41
|
+
|
|
42
|
+
## Learn More
|
|
43
|
+
|
|
44
|
+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
45
|
+
|
|
46
|
+
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
47
|
+
|
|
48
|
+
### Code Splitting
|
|
49
|
+
|
|
50
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
51
|
+
|
|
52
|
+
### Analyzing the Bundle Size
|
|
53
|
+
|
|
54
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
55
|
+
|
|
56
|
+
### Making a Progressive Web App
|
|
57
|
+
|
|
58
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
59
|
+
|
|
60
|
+
### Advanced Configuration
|
|
61
|
+
|
|
62
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
63
|
+
|
|
64
|
+
### Deployment
|
|
65
|
+
|
|
66
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
67
|
+
|
|
68
|
+
### `yarn build` fails to minify
|
|
69
|
+
|
|
70
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { JSX } from '@xplortech/apollo-core';
|
|
3
|
+
export declare const XplPagination: import("react").ForwardRefExoticComponent<JSX.XplPagination & Pick<import("react").HTMLAttributes<HTMLXplPaginationElement>, "hidden" | "dir" | "slot" | "title" | "color" | "children" | "className" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "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" | "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" | "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<HTMLXplPaginationElement>>;
|
|
4
|
+
export declare const XplTable: import("react").ForwardRefExoticComponent<JSX.XplTable & Pick<import("react").HTMLAttributes<HTMLXplTableElement>, "hidden" | "dir" | "slot" | "title" | "color" | "children" | "className" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "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" | "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" | "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<HTMLXplTableElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* auto-generated react proxies */
|
|
4
|
+
import { createReactComponent } from './react-component-lib';
|
|
5
|
+
import { defineCustomElements } from '@xplortech/apollo-core/dist/loader';
|
|
6
|
+
defineCustomElements();
|
|
7
|
+
export const XplPagination = /*@__PURE__*/ createReactComponent('xpl-pagination');
|
|
8
|
+
export const XplTable = /*@__PURE__*/ createReactComponent('xpl-table');
|
|
9
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,oBAAoB;AACpB,kCAAkC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,oBAAoB,EAAE,CAAC;AACvB,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAA,oBAAoB,CAA8C,gBAAgB,CAAC,CAAC;AAC9H,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAA,oBAAoB,CAAoC,WAAW,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -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>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { attachProps, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs, } from './utils';
|
|
14
|
+
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction) => {
|
|
15
|
+
const displayName = dashToPascalCase(tagName);
|
|
16
|
+
const ReactComponent = class extends React.Component {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
this.setComponentElRef = (element) => {
|
|
20
|
+
this.componentEl = element;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
componentDidMount() {
|
|
24
|
+
this.componentDidUpdate(this.props);
|
|
25
|
+
}
|
|
26
|
+
componentDidUpdate(prevProps) {
|
|
27
|
+
attachProps(this.componentEl, this.props, prevProps);
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
|
|
31
|
+
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
32
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
33
|
+
const eventName = name.substring(2).toLowerCase();
|
|
34
|
+
if (typeof document !== 'undefined' && isCoveredByReact(eventName, document)) {
|
|
35
|
+
acc[name] = cProps[name];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
acc[name] = cProps[name];
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
if (manipulatePropsFunction) {
|
|
44
|
+
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
45
|
+
}
|
|
46
|
+
let newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style });
|
|
47
|
+
return React.createElement(tagName, newProps, children);
|
|
48
|
+
}
|
|
49
|
+
static get displayName() {
|
|
50
|
+
return displayName;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
// If context was passed to createReactComponent then conditionally add it to the Component Class
|
|
54
|
+
if (ReactComponentContext) {
|
|
55
|
+
ReactComponent.contextType = ReactComponentContext;
|
|
56
|
+
}
|
|
57
|
+
return createForwardRef(ReactComponent, displayName);
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=createComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createComponent.js","sourceRoot":"","sources":["../../src/react-component-lib/createComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,GACV,MAAM,SAAS,CAAC;AAWjB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAMlC,OAAe,EACf,qBAAuD,EACvD,uBAGuB,EACvB,EAAE;IACF,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE9C,MAAM,cAAc,GAAG,KAAM,SAAQ,KAAK,CAAC,SAAiD;QAO1F,YAAY,KAA6C;YACvD,KAAK,CAAC,KAAK,CAAC,CAAC;YALf,sBAAiB,GAAG,CAAC,OAAoB,EAAE,EAAE;gBAC3C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;YAC7B,CAAC,CAAC;QAIF,CAAC;QAED,iBAAiB;YACf,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,kBAAkB,CAAC,SAAiD;YAClE,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACvD,CAAC;QAED,MAAM;YACJ,MAAM,KA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E;QACzB,cAAc,CAAC,WAAW,GAAG,qBAAqB,CAAC;KACpD;IAED,OAAO,gBAAgB,CAAwB,cAAc,EAAE,WAAW,CAAC,CAAC;AAC9E,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OverlayEventDetail } from './interfaces';
|
|
2
|
+
import React from 'react';
|
|
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>(displayName: string, controller: {
|
|
16
|
+
create: (options: any) => Promise<OverlayType>;
|
|
17
|
+
}) => React.ForwardRefExoticComponent<React.PropsWithoutRef<OverlayComponent & ReactOverlayProps & {
|
|
18
|
+
forwardedRef?: React.RefObject<OverlayType>;
|
|
19
|
+
}> & React.RefAttributes<OverlayType>>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import ReactDOM from 'react-dom';
|
|
23
|
+
import { attachProps } from './utils';
|
|
24
|
+
export const createOverlayComponent = (displayName, controller) => {
|
|
25
|
+
const didDismissEventName = `on${displayName}DidDismiss`;
|
|
26
|
+
const didPresentEventName = `on${displayName}DidPresent`;
|
|
27
|
+
const willDismissEventName = `on${displayName}WillDismiss`;
|
|
28
|
+
const willPresentEventName = `on${displayName}WillPresent`;
|
|
29
|
+
class Overlay extends React.Component {
|
|
30
|
+
constructor(props) {
|
|
31
|
+
super(props);
|
|
32
|
+
this.el = document.createElement('div');
|
|
33
|
+
this.handleDismiss = this.handleDismiss.bind(this);
|
|
34
|
+
}
|
|
35
|
+
static get displayName() {
|
|
36
|
+
return displayName;
|
|
37
|
+
}
|
|
38
|
+
componentDidMount() {
|
|
39
|
+
if (this.props.isOpen) {
|
|
40
|
+
this.present();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
componentWillUnmount() {
|
|
44
|
+
if (this.overlay) {
|
|
45
|
+
this.overlay.dismiss();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
handleDismiss(event) {
|
|
49
|
+
if (this.props.onDidDismiss) {
|
|
50
|
+
this.props.onDidDismiss(event);
|
|
51
|
+
}
|
|
52
|
+
if (this.props.forwardedRef) {
|
|
53
|
+
this.props.forwardedRef.current = undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
componentDidUpdate(prevProps) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
if (this.overlay) {
|
|
59
|
+
attachProps(this.overlay, this.props, prevProps);
|
|
60
|
+
}
|
|
61
|
+
if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
|
|
62
|
+
this.present(prevProps);
|
|
63
|
+
}
|
|
64
|
+
if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
|
|
65
|
+
yield this.overlay.dismiss();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
present(prevProps) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const _a = this.props, { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent } = _a, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
|
|
72
|
+
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) });
|
|
73
|
+
this.overlay = yield controller.create(Object.assign(Object.assign({}, elementProps), { component: this.el, componentProps: {} }));
|
|
74
|
+
if (this.props.forwardedRef) {
|
|
75
|
+
this.props.forwardedRef.current = this.overlay;
|
|
76
|
+
}
|
|
77
|
+
attachProps(this.overlay, elementProps, prevProps);
|
|
78
|
+
yield this.overlay.present();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
render() {
|
|
82
|
+
return ReactDOM.createPortal(this.props.isOpen ? this.props.children : null, this.el);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return React.forwardRef((props, ref) => {
|
|
86
|
+
return React.createElement(Overlay, Object.assign({}, props, { forwardedRef: ref }));
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=createOverlayComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOverlayComponent.js","sourceRoot":"","sources":["../../src/react-component-lib/createOverlayComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAgBtC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAIpC,WAAmB,EACnB,UAA8D,EAC9D,EAAE;IACF,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,MAAM,OAAQ,SAAQ,KAAK,CAAC,SAAgB;QAI1C,YAAY,KAAY;YACtB,KAAK,CAAC,KAAK,CAAC,CAAC;YACb,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACxC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,KAAK,WAAW;YACpB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,iBAAiB;YACf,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;gBACrB,IAAI,CAAC,OAAO,EAAE,CAAC;aAChB;QACH,CA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YAAY,EAAE,GAAG,IAAI,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react-component-lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -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
|
+
//# sourceMappingURL=interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/react-component-lib/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
* Checks if an event is supported in the current execution environment.
|
|
5
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
6
|
+
*/
|
|
7
|
+
export declare const isCoveredByReact: (eventNameSuffix: string, doc: Document) => boolean;
|
|
8
|
+
export declare const syncEvent: (node: Element & {
|
|
9
|
+
__events?: {
|
|
10
|
+
[key: string]: (e: Event) => any;
|
|
11
|
+
};
|
|
12
|
+
}, eventName: string, newEventHandler?: (e: Event) => any) => void;
|
|
@@ -0,0 +1,96 @@
|
|
|
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 (typeof document !== 'undefined' && !isCoveredByReact(eventNameLc, document)) {
|
|
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
|
+
else {
|
|
33
|
+
node[name] = newProps[name];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const getClassName = (classList, newProps, oldProps) => {
|
|
40
|
+
const newClassProp = newProps.className || newProps.class;
|
|
41
|
+
const oldClassProp = oldProps.className || oldProps.class;
|
|
42
|
+
// map the classes to Maps for performance
|
|
43
|
+
const currentClasses = arrayToMap(classList);
|
|
44
|
+
const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
|
|
45
|
+
const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
|
|
46
|
+
const finalClassNames = [];
|
|
47
|
+
// loop through each of the current classes on the component
|
|
48
|
+
// to see if it should be a part of the classNames added
|
|
49
|
+
currentClasses.forEach((currentClass) => {
|
|
50
|
+
if (incomingPropClasses.has(currentClass)) {
|
|
51
|
+
// add it as its already included in classnames coming in from newProps
|
|
52
|
+
finalClassNames.push(currentClass);
|
|
53
|
+
incomingPropClasses.delete(currentClass);
|
|
54
|
+
}
|
|
55
|
+
else if (!oldPropClasses.has(currentClass)) {
|
|
56
|
+
// add it as it has NOT been removed by user
|
|
57
|
+
finalClassNames.push(currentClass);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
incomingPropClasses.forEach((s) => finalClassNames.push(s));
|
|
61
|
+
return finalClassNames.join(' ');
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Checks if an event is supported in the current execution environment.
|
|
65
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
66
|
+
*/
|
|
67
|
+
export const isCoveredByReact = (eventNameSuffix, doc) => {
|
|
68
|
+
const eventName = 'on' + eventNameSuffix;
|
|
69
|
+
let isSupported = eventName in doc;
|
|
70
|
+
if (!isSupported) {
|
|
71
|
+
const element = doc.createElement('div');
|
|
72
|
+
element.setAttribute(eventName, 'return;');
|
|
73
|
+
isSupported = typeof element[eventName] === 'function';
|
|
74
|
+
}
|
|
75
|
+
return isSupported;
|
|
76
|
+
};
|
|
77
|
+
export const syncEvent = (node, eventName, newEventHandler) => {
|
|
78
|
+
const eventStore = node.__events || (node.__events = {});
|
|
79
|
+
const oldEventHandler = eventStore[eventName];
|
|
80
|
+
// Remove old listener so they don't double up.
|
|
81
|
+
if (oldEventHandler) {
|
|
82
|
+
node.removeEventListener(eventName, oldEventHandler);
|
|
83
|
+
}
|
|
84
|
+
// Bind new listener.
|
|
85
|
+
node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
|
|
86
|
+
if (newEventHandler) {
|
|
87
|
+
newEventHandler.call(this, e);
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
const arrayToMap = (arr) => {
|
|
92
|
+
const map = new Map();
|
|
93
|
+
arr.forEach((s) => map.set(s, s));
|
|
94
|
+
return map;
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=attachProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachProps.js","sourceRoot":"","sources":["../../../src/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;SAC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D,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -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/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,CAC7C,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -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/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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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 const mergeRefs: <ElementType>(...refs: React.Ref<ElementType>[]) => (value: ElementType) => void;
|
|
5
|
+
export declare const createForwardRef: <PropType, ElementType>(ReactComponent: any, displayName: string) => React.ForwardRefExoticComponent<React.PropsWithoutRef<StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
|
6
|
+
export * from './attachProps';
|
|
7
|
+
export * from './case';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// The comma in the type is to trick typescript because it things a single generic in a tsx file is jsx
|
|
3
|
+
export const mergeRefs = (...refs) => (value) => refs.forEach((ref) => {
|
|
4
|
+
if (typeof ref === 'function') {
|
|
5
|
+
ref(value);
|
|
6
|
+
}
|
|
7
|
+
else if (ref != null) {
|
|
8
|
+
// This is typed as readonly so we need to allow for override
|
|
9
|
+
ref.current = value;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export const createForwardRef = (ReactComponent, displayName) => {
|
|
13
|
+
const forwardRef = (props, ref) => {
|
|
14
|
+
return React.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
|
|
15
|
+
};
|
|
16
|
+
forwardRef.displayName = displayName;
|
|
17
|
+
return React.forwardRef(forwardRef);
|
|
18
|
+
};
|
|
19
|
+
export * from './attachProps';
|
|
20
|
+
export * from './case';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react-component-lib/utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,uGAAuG;AACvG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAe,GAAG,IAA8B,EAAE,EAAE,CAAC,CAC5E,KAAkB,EAClB,EAAE,CACF,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;QAC7B,GAAG,CAAC,KAAK,CAAC,CAAC;KACZ;SAAM,IAAI,GAAG,IAAI,IAAI,EAAE;QACtB,6DAA6D;QAC5D,GAA6C,CAAC,OAAO,GAAG,KAAK,CAAC;KAChE;AACH,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,cAAmB,EACnB,WAAmB,EACnB,EAAE;IACF,MAAM,UAAU,GAAG,CACjB,KAAuD,EACvD,GAA2B,EAC3B,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,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xplortech/apollo-react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "npm run clean && npm run compile",
|
|
12
|
+
"clean": "rm -rf dist",
|
|
13
|
+
"compile": "npm run tsc",
|
|
14
|
+
"tsc": "tsc -p .",
|
|
15
|
+
"rollup": "rollup -c"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/jest": "23.3.9",
|
|
19
|
+
"@types/node": "^15.12.2",
|
|
20
|
+
"@types/react": "16.7.6",
|
|
21
|
+
"@types/react-dom": "16.0.9",
|
|
22
|
+
"jest": "^23.0.0",
|
|
23
|
+
"np": "^3.1.0",
|
|
24
|
+
"react": "^16.7.0",
|
|
25
|
+
"react-dom": "^16.7.0",
|
|
26
|
+
"typescript": "^3.3.4000"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@xplortech/apollo-core": "0.0.1"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^16.7.0",
|
|
33
|
+
"react-dom": "^16.7.0"
|
|
34
|
+
},
|
|
35
|
+
"jest": {
|
|
36
|
+
"preset": "ts-jest",
|
|
37
|
+
"setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js",
|
|
38
|
+
"testPathIgnorePatterns": [
|
|
39
|
+
"node_modules",
|
|
40
|
+
"dist"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|