@cloudflare/realtimekit-react-ui 0.0.0 → 1.0.0-staging.11
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 +85 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +17 -0
- package/dist/components/stencil-generated/index.d.ts +139 -0
- package/dist/components/stencil-generated/index.js +149 -0
- package/dist/components/stencil-generated/react-component-lib/createComponent.d.ts +10 -0
- package/dist/components/stencil-generated/react-component-lib/createComponent.js +111 -0
- package/dist/components/stencil-generated/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/dist/components/stencil-generated/react-component-lib/createOverlayComponent.js +115 -0
- package/dist/components/stencil-generated/react-component-lib/index.d.ts +2 -0
- package/dist/components/stencil-generated/react-component-lib/index.js +7 -0
- package/dist/components/stencil-generated/react-component-lib/interfaces.d.ts +29 -0
- package/dist/components/stencil-generated/react-component-lib/interfaces.js +2 -0
- package/dist/components/stencil-generated/react-component-lib/utils/attachProps.d.ts +16 -0
- package/dist/components/stencil-generated/react-component-lib/utils/attachProps.js +115 -0
- package/dist/components/stencil-generated/react-component-lib/utils/case.d.ts +2 -0
- package/dist/components/stencil-generated/react-component-lib/utils/case.js +11 -0
- package/dist/components/stencil-generated/react-component-lib/utils/dev.d.ts +2 -0
- package/dist/components/stencil-generated/react-component-lib/utils/dev.js +17 -0
- package/dist/components/stencil-generated/react-component-lib/utils/index.d.ts +10 -0
- package/dist/components/stencil-generated/react-component-lib/utils/index.js +55 -0
- package/dist/es/components/index.d.ts +1 -0
- package/dist/es/components/index.js +1 -0
- package/dist/es/components/stencil-generated/index.d.ts +139 -0
- package/dist/es/components/stencil-generated/index.js +144 -0
- package/dist/es/components/stencil-generated/react-component-lib/createComponent.d.ts +10 -0
- package/dist/es/components/stencil-generated/react-component-lib/createComponent.js +74 -0
- package/dist/es/components/stencil-generated/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/dist/es/components/stencil-generated/react-component-lib/createOverlayComponent.js +108 -0
- package/dist/es/components/stencil-generated/react-component-lib/index.d.ts +2 -0
- package/dist/es/components/stencil-generated/react-component-lib/index.js +2 -0
- package/dist/es/components/stencil-generated/react-component-lib/interfaces.d.ts +29 -0
- package/dist/es/components/stencil-generated/react-component-lib/interfaces.js +1 -0
- package/dist/es/components/stencil-generated/react-component-lib/utils/attachProps.d.ts +16 -0
- package/dist/es/components/stencil-generated/react-component-lib/utils/attachProps.js +107 -0
- package/dist/es/components/stencil-generated/react-component-lib/utils/case.d.ts +2 -0
- package/dist/es/components/stencil-generated/react-component-lib/utils/case.js +6 -0
- package/dist/es/components/stencil-generated/react-component-lib/utils/dev.d.ts +2 -0
- package/dist/es/components/stencil-generated/react-component-lib/utils/dev.js +12 -0
- package/dist/es/components/stencil-generated/react-component-lib/utils/index.d.ts +10 -0
- package/dist/es/components/stencil-generated/react-component-lib/utils/index.js +31 -0
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/package.json +37 -3
|
@@ -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>;
|
|
20
|
+
}> & React.RefAttributes<OverlayType>>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.createOverlayComponent = void 0;
|
|
27
|
+
const react_1 = __importDefault(require("react"));
|
|
28
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
29
|
+
const utils_1 = require("./utils");
|
|
30
|
+
const createOverlayComponent = (tagName, controller, customElement) => {
|
|
31
|
+
(0, utils_1.defineCustomElement)(tagName, customElement);
|
|
32
|
+
const displayName = (0, utils_1.dashToPascalCase)(tagName);
|
|
33
|
+
const didDismissEventName = `on${displayName}DidDismiss`;
|
|
34
|
+
const didPresentEventName = `on${displayName}DidPresent`;
|
|
35
|
+
const willDismissEventName = `on${displayName}WillDismiss`;
|
|
36
|
+
const willPresentEventName = `on${displayName}WillPresent`;
|
|
37
|
+
let isDismissing = false;
|
|
38
|
+
class Overlay extends react_1.default.Component {
|
|
39
|
+
constructor(props) {
|
|
40
|
+
super(props);
|
|
41
|
+
if (typeof document !== 'undefined') {
|
|
42
|
+
this.el = document.createElement('div');
|
|
43
|
+
}
|
|
44
|
+
this.handleDismiss = this.handleDismiss.bind(this);
|
|
45
|
+
}
|
|
46
|
+
static get displayName() {
|
|
47
|
+
return displayName;
|
|
48
|
+
}
|
|
49
|
+
componentDidMount() {
|
|
50
|
+
if (this.props.isOpen) {
|
|
51
|
+
this.present();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
componentWillUnmount() {
|
|
55
|
+
if (this.overlay) {
|
|
56
|
+
this.overlay.dismiss();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
handleDismiss(event) {
|
|
60
|
+
if (this.props.onDidDismiss) {
|
|
61
|
+
this.props.onDidDismiss(event);
|
|
62
|
+
}
|
|
63
|
+
(0, utils_1.setRef)(this.props.forwardedRef, null);
|
|
64
|
+
}
|
|
65
|
+
shouldComponentUpdate(nextProps) {
|
|
66
|
+
// Check if the overlay component is about to dismiss
|
|
67
|
+
if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
|
|
68
|
+
isDismissing = true;
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
componentDidUpdate(prevProps) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
if (this.overlay) {
|
|
75
|
+
(0, utils_1.attachProps)(this.overlay, this.props, prevProps);
|
|
76
|
+
}
|
|
77
|
+
if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
|
|
78
|
+
this.present(prevProps);
|
|
79
|
+
}
|
|
80
|
+
if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
|
|
81
|
+
yield this.overlay.dismiss();
|
|
82
|
+
isDismissing = false;
|
|
83
|
+
/**
|
|
84
|
+
* Now that the overlay is dismissed
|
|
85
|
+
* we need to render again so that any
|
|
86
|
+
* inner components will be unmounted
|
|
87
|
+
*/
|
|
88
|
+
this.forceUpdate();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
present(prevProps) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const _a = this.props, { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent } = _a, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
|
|
95
|
+
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) });
|
|
96
|
+
this.overlay = yield controller.create(Object.assign(Object.assign({}, elementProps), { component: this.el, componentProps: {} }));
|
|
97
|
+
(0, utils_1.setRef)(this.props.forwardedRef, this.overlay);
|
|
98
|
+
(0, utils_1.attachProps)(this.overlay, elementProps, prevProps);
|
|
99
|
+
yield this.overlay.present();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
render() {
|
|
103
|
+
/**
|
|
104
|
+
* Continue to render the component even when
|
|
105
|
+
* overlay is dismissing otherwise component
|
|
106
|
+
* will be hidden before animation is done.
|
|
107
|
+
*/
|
|
108
|
+
return react_dom_1.default.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return react_1.default.forwardRef((props, ref) => {
|
|
112
|
+
return react_1.default.createElement(Overlay, Object.assign({}, props, { forwardedRef: ref }));
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
exports.createOverlayComponent = createOverlayComponent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOverlayComponent = exports.createReactComponent = void 0;
|
|
4
|
+
var createComponent_1 = require("./createComponent");
|
|
5
|
+
Object.defineProperty(exports, "createReactComponent", { enumerable: true, get: function () { return createComponent_1.createReactComponent; } });
|
|
6
|
+
var createOverlayComponent_1 = require("./createOverlayComponent");
|
|
7
|
+
Object.defineProperty(exports, "createOverlayComponent", { enumerable: true, get: function () { return createOverlayComponent_1.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,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
|
+
};
|
|
16
|
+
}, eventName: string, newEventHandler?: (e: Event) => any) => void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncEvent = exports.isCoveredByReact = exports.transformReactEventName = exports.getClassName = exports.attachProps = void 0;
|
|
4
|
+
const case_1 = require("./case");
|
|
5
|
+
const attachProps = (node, newProps, oldProps = {}) => {
|
|
6
|
+
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
|
|
7
|
+
if (node instanceof Element) {
|
|
8
|
+
// add any classes in className to the class list
|
|
9
|
+
const className = (0, exports.getClassName)(node.classList, newProps, oldProps);
|
|
10
|
+
if (className !== '') {
|
|
11
|
+
node.className = className;
|
|
12
|
+
}
|
|
13
|
+
Object.keys(newProps).forEach((name) => {
|
|
14
|
+
if (name === 'children' ||
|
|
15
|
+
name === 'style' ||
|
|
16
|
+
name === 'ref' ||
|
|
17
|
+
name === 'class' ||
|
|
18
|
+
name === 'className' ||
|
|
19
|
+
name === 'forwardedRef') {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
23
|
+
const eventName = name.substring(2);
|
|
24
|
+
const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
|
|
25
|
+
if (!(0, exports.isCoveredByReact)(eventNameLc)) {
|
|
26
|
+
(0, exports.syncEvent)(node, eventNameLc, newProps[name]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
node[name] = newProps[name];
|
|
31
|
+
const propType = typeof newProps[name];
|
|
32
|
+
if (propType === 'string') {
|
|
33
|
+
node.setAttribute((0, case_1.camelToDashCase)(name), newProps[name]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.attachProps = attachProps;
|
|
40
|
+
const getClassName = (classList, newProps, oldProps) => {
|
|
41
|
+
const newClassProp = newProps.className || newProps.class;
|
|
42
|
+
const oldClassProp = oldProps.className || oldProps.class;
|
|
43
|
+
// map the classes to Maps for performance
|
|
44
|
+
const currentClasses = arrayToMap(classList);
|
|
45
|
+
const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
|
|
46
|
+
const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
|
|
47
|
+
const finalClassNames = [];
|
|
48
|
+
// loop through each of the current classes on the component
|
|
49
|
+
// to see if it should be a part of the classNames added
|
|
50
|
+
currentClasses.forEach((currentClass) => {
|
|
51
|
+
if (incomingPropClasses.has(currentClass)) {
|
|
52
|
+
// add it as its already included in classnames coming in from newProps
|
|
53
|
+
finalClassNames.push(currentClass);
|
|
54
|
+
incomingPropClasses.delete(currentClass);
|
|
55
|
+
}
|
|
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
|
+
exports.getClassName = getClassName;
|
|
65
|
+
/**
|
|
66
|
+
* Transforms a React event name to a browser event name.
|
|
67
|
+
*/
|
|
68
|
+
const transformReactEventName = (eventNameSuffix) => {
|
|
69
|
+
switch (eventNameSuffix) {
|
|
70
|
+
case 'doubleclick':
|
|
71
|
+
return 'dblclick';
|
|
72
|
+
}
|
|
73
|
+
return eventNameSuffix;
|
|
74
|
+
};
|
|
75
|
+
exports.transformReactEventName = transformReactEventName;
|
|
76
|
+
/**
|
|
77
|
+
* Checks if an event is supported in the current execution environment.
|
|
78
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
79
|
+
*/
|
|
80
|
+
const isCoveredByReact = (eventNameSuffix) => {
|
|
81
|
+
if (typeof document === 'undefined') {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const eventName = 'on' + (0, exports.transformReactEventName)(eventNameSuffix);
|
|
86
|
+
let isSupported = eventName in document;
|
|
87
|
+
if (!isSupported) {
|
|
88
|
+
const element = document.createElement('div');
|
|
89
|
+
element.setAttribute(eventName, 'return;');
|
|
90
|
+
isSupported = typeof element[eventName] === 'function';
|
|
91
|
+
}
|
|
92
|
+
return isSupported;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.isCoveredByReact = isCoveredByReact;
|
|
96
|
+
const syncEvent = (node, eventName, newEventHandler) => {
|
|
97
|
+
const eventStore = node.__events || (node.__events = {});
|
|
98
|
+
const oldEventHandler = eventStore[eventName];
|
|
99
|
+
// Remove old listener so they don't double up.
|
|
100
|
+
if (oldEventHandler) {
|
|
101
|
+
node.removeEventListener(eventName, oldEventHandler);
|
|
102
|
+
}
|
|
103
|
+
// Bind new listener.
|
|
104
|
+
node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
|
|
105
|
+
if (newEventHandler) {
|
|
106
|
+
newEventHandler.call(this, e);
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
};
|
|
110
|
+
exports.syncEvent = syncEvent;
|
|
111
|
+
const arrayToMap = (arr) => {
|
|
112
|
+
const map = new Map();
|
|
113
|
+
arr.forEach((s) => map.set(s, s));
|
|
114
|
+
return map;
|
|
115
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.camelToDashCase = exports.dashToPascalCase = void 0;
|
|
4
|
+
const dashToPascalCase = (str) => str
|
|
5
|
+
.toLowerCase()
|
|
6
|
+
.split('-')
|
|
7
|
+
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
8
|
+
.join('');
|
|
9
|
+
exports.dashToPascalCase = dashToPascalCase;
|
|
10
|
+
const camelToDashCase = (str) => str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
|
|
11
|
+
exports.camelToDashCase = camelToDashCase;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deprecationWarning = exports.isDevMode = void 0;
|
|
4
|
+
const isDevMode = () => {
|
|
5
|
+
return process && process.env && process.env.NODE_ENV === 'development';
|
|
6
|
+
};
|
|
7
|
+
exports.isDevMode = isDevMode;
|
|
8
|
+
const warnings = {};
|
|
9
|
+
const deprecationWarning = (key, message) => {
|
|
10
|
+
if ((0, exports.isDevMode)()) {
|
|
11
|
+
if (!warnings[key]) {
|
|
12
|
+
console.warn(message);
|
|
13
|
+
warnings[key] = true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.deprecationWarning = deprecationWarning;
|
|
@@ -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<PropType & Omit<React.HTMLAttributes<ElementType>, "style"> & StyleReactProps> & React.RefAttributes<ElementType>>;
|
|
8
|
+
export declare const defineCustomElement: (tagName: string, customElement: any) => void;
|
|
9
|
+
export * from './attachProps';
|
|
10
|
+
export * from './case';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.defineCustomElement = exports.createForwardRef = exports.mergeRefs = exports.setRef = void 0;
|
|
21
|
+
const react_1 = __importDefault(require("react"));
|
|
22
|
+
const setRef = (ref, value) => {
|
|
23
|
+
if (typeof ref === 'function') {
|
|
24
|
+
ref(value);
|
|
25
|
+
}
|
|
26
|
+
else if (ref != null) {
|
|
27
|
+
// Cast as a MutableRef so we can assign current
|
|
28
|
+
ref.current = value;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.setRef = setRef;
|
|
32
|
+
const mergeRefs = (...refs) => {
|
|
33
|
+
return (value) => {
|
|
34
|
+
refs.forEach((ref) => {
|
|
35
|
+
(0, exports.setRef)(ref, value);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.mergeRefs = mergeRefs;
|
|
40
|
+
const createForwardRef = (ReactComponent, displayName) => {
|
|
41
|
+
const forwardRef = (props, ref) => {
|
|
42
|
+
return react_1.default.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
|
|
43
|
+
};
|
|
44
|
+
forwardRef.displayName = displayName;
|
|
45
|
+
return react_1.default.forwardRef(forwardRef);
|
|
46
|
+
};
|
|
47
|
+
exports.createForwardRef = createForwardRef;
|
|
48
|
+
const defineCustomElement = (tagName, customElement) => {
|
|
49
|
+
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
|
|
50
|
+
customElements.define(tagName, customElement);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.defineCustomElement = defineCustomElement;
|
|
54
|
+
__exportStar(require("./attachProps"), exports);
|
|
55
|
+
__exportStar(require("./case"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stencil-generated/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stencil-generated/index';
|