@watermarkinsights/ripple-react 5.13.1-alpha.4 → 5.14.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +1 -0
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/components/index.js +2 -0
  4. package/dist/components/index.js.map +1 -0
  5. package/dist/components/stencil-generated/index.d.ts +1 -0
  6. package/dist/components/stencil-generated/index.js +29 -0
  7. package/dist/components/stencil-generated/index.js.map +1 -0
  8. package/dist/components.d.ts +49 -0
  9. package/dist/components.js +51 -484
  10. package/dist/components.js.map +1 -1
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.js +3 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/react-component-lib/ReactProps.d.ts +3 -0
  15. package/dist/react-component-lib/ReactProps.js +2 -0
  16. package/dist/react-component-lib/ReactProps.js.map +1 -0
  17. package/dist/react-component-lib/attachProps.d.ts +16 -0
  18. package/dist/react-component-lib/attachProps.js +109 -0
  19. package/dist/react-component-lib/attachProps.js.map +1 -0
  20. package/dist/react-component-lib/case.d.ts +2 -0
  21. package/dist/react-component-lib/case.js +9 -0
  22. package/dist/react-component-lib/case.js.map +1 -0
  23. package/dist/react-component-lib/createComponent.d.ts +10 -0
  24. package/dist/react-component-lib/createComponent.js +108 -0
  25. package/dist/react-component-lib/createComponent.js.map +1 -0
  26. package/dist/react-component-lib/createControllerComponent.d.ts +43 -0
  27. package/dist/react-component-lib/createControllerComponent.js +148 -0
  28. package/dist/react-component-lib/createControllerComponent.js.map +1 -0
  29. package/dist/react-component-lib/createOverlayComponent.d.ts +21 -0
  30. package/dist/react-component-lib/createOverlayComponent.js +191 -0
  31. package/dist/react-component-lib/createOverlayComponent.js.map +1 -0
  32. package/dist/react-component-lib/dev.d.ts +2 -0
  33. package/dist/react-component-lib/dev.js +13 -0
  34. package/dist/react-component-lib/dev.js.map +1 -0
  35. package/dist/react-component-lib/index.d.ts +2 -0
  36. package/dist/react-component-lib/index.js +3 -0
  37. package/dist/react-component-lib/index.js.map +1 -0
  38. package/dist/react-component-lib/interfaces.d.ts +29 -0
  39. package/dist/react-component-lib/interfaces.js +2 -0
  40. package/dist/react-component-lib/interfaces.js.map +1 -0
  41. package/dist/react-component-lib/utils/attachEventProps.d.ts +8 -0
  42. package/dist/react-component-lib/utils/attachEventProps.js +79 -0
  43. package/dist/react-component-lib/utils/attachEventProps.js.map +1 -0
  44. package/dist/react-component-lib/utils/attachProps.d.ts +16 -0
  45. package/dist/react-component-lib/utils/attachProps.js +109 -0
  46. package/dist/react-component-lib/utils/attachProps.js.map +1 -0
  47. package/dist/react-component-lib/utils/case.d.ts +2 -0
  48. package/dist/react-component-lib/utils/case.js +9 -0
  49. package/dist/react-component-lib/utils/case.js.map +1 -0
  50. package/dist/react-component-lib/utils/dev.d.ts +2 -0
  51. package/dist/react-component-lib/utils/dev.js +13 -0
  52. package/dist/react-component-lib/utils/dev.js.map +1 -0
  53. package/dist/react-component-lib/utils/index.d.ts +10 -0
  54. package/dist/react-component-lib/utils/index.js +47 -0
  55. package/dist/react-component-lib/utils/index.js.map +1 -0
  56. package/package.json +34 -15
  57. package/dist/components/stencil-generated/components.js +0 -485
  58. package/dist/components/stencil-generated/components.js.map +0 -1
  59. package/dist/stencil-generated/components.js +0 -485
  60. package/dist/stencil-generated/components.js.map +0 -1
  61. package/dist/types/components/stencil-generated/components.d.ts +0 -319
  62. package/dist/types/components.d.ts +0 -319
  63. package/dist/types/index.d.ts +0 -1
  64. package/dist/types/stencil-generated/components.d.ts +0 -319
  65. package/src/components/stencil-generated/components.ts +0 -795
  66. package/src/index.ts +0 -1
@@ -0,0 +1,109 @@
1
+ import { camelToDashCase } from './case';
2
+ export var attachProps = function (node, newProps, oldProps) {
3
+ if (oldProps === void 0) { oldProps = {}; }
4
+ // some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
5
+ if (node instanceof Element) {
6
+ // add any classes in className to the class list
7
+ var className = getClassName(node.classList, newProps, oldProps);
8
+ if (className !== '') {
9
+ node.className = className;
10
+ }
11
+ Object.keys(newProps).forEach(function (name) {
12
+ if (name === 'children' ||
13
+ name === 'style' ||
14
+ name === 'ref' ||
15
+ name === 'class' ||
16
+ name === 'className' ||
17
+ name === 'forwardedRef') {
18
+ return;
19
+ }
20
+ if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
21
+ var eventName = name.substring(2);
22
+ var eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
23
+ if (!isCoveredByReact(eventNameLc)) {
24
+ syncEvent(node, eventNameLc, newProps[name]);
25
+ }
26
+ }
27
+ else {
28
+ node[name] = newProps[name];
29
+ var propType = typeof newProps[name];
30
+ if (propType === 'string') {
31
+ node.setAttribute(camelToDashCase(name), newProps[name]);
32
+ }
33
+ }
34
+ });
35
+ }
36
+ };
37
+ export var getClassName = function (classList, newProps, oldProps) {
38
+ var newClassProp = newProps.className || newProps.class;
39
+ var oldClassProp = oldProps.className || oldProps.class;
40
+ // map the classes to Maps for performance
41
+ var currentClasses = arrayToMap(classList);
42
+ var incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
43
+ var oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
44
+ var finalClassNames = [];
45
+ // loop through each of the current classes on the component
46
+ // to see if it should be a part of the classNames added
47
+ currentClasses.forEach(function (currentClass) {
48
+ if (incomingPropClasses.has(currentClass)) {
49
+ // add it as its already included in classnames coming in from newProps
50
+ finalClassNames.push(currentClass);
51
+ incomingPropClasses.delete(currentClass);
52
+ }
53
+ else if (!oldPropClasses.has(currentClass)) {
54
+ // add it as it has NOT been removed by user
55
+ finalClassNames.push(currentClass);
56
+ }
57
+ });
58
+ incomingPropClasses.forEach(function (s) { return finalClassNames.push(s); });
59
+ return finalClassNames.join(' ');
60
+ };
61
+ /**
62
+ * Transforms a React event name to a browser event name.
63
+ */
64
+ export var transformReactEventName = function (eventNameSuffix) {
65
+ switch (eventNameSuffix) {
66
+ case 'doubleclick':
67
+ return 'dblclick';
68
+ }
69
+ return eventNameSuffix;
70
+ };
71
+ /**
72
+ * Checks if an event is supported in the current execution environment.
73
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
74
+ */
75
+ export var isCoveredByReact = function (eventNameSuffix) {
76
+ if (typeof document === 'undefined') {
77
+ return true;
78
+ }
79
+ else {
80
+ var eventName = 'on' + transformReactEventName(eventNameSuffix);
81
+ var isSupported = eventName in document;
82
+ if (!isSupported) {
83
+ var element = document.createElement('div');
84
+ element.setAttribute(eventName, 'return;');
85
+ isSupported = typeof element[eventName] === 'function';
86
+ }
87
+ return isSupported;
88
+ }
89
+ };
90
+ export var syncEvent = function (node, eventName, newEventHandler) {
91
+ var eventStore = node.__events || (node.__events = {});
92
+ var oldEventHandler = eventStore[eventName];
93
+ // Remove old listener so they don't double up.
94
+ if (oldEventHandler) {
95
+ node.removeEventListener(eventName, oldEventHandler);
96
+ }
97
+ // Bind new listener.
98
+ node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
99
+ if (newEventHandler) {
100
+ newEventHandler.call(this, e);
101
+ }
102
+ }));
103
+ };
104
+ var arrayToMap = function (arr) {
105
+ var map = new Map();
106
+ arr.forEach(function (s) { return map.set(s, s); });
107
+ return map;
108
+ };
109
+ //# sourceMappingURL=attachProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachProps.js","sourceRoot":"","sources":["../../src/react-component-lib/attachProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,IAAiB,EAAE,QAAa,EAAE,QAAkB;IAAlB,yBAAA,EAAA,aAAkB;IAC9E,6GAA6G;IAC7G,IAAI,IAAI,YAAY,OAAO,EAAE;QAC3B,iDAAiD;QACjD,IAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,Q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GAA4B;IAC9C,IAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACrC,GAAgB,CAAC,OAAO,CAAC,UAAC,CAAS,IAAK,OAAA,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAb,CAAa,CAAC,CAAC;IACxD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const dashToPascalCase: (str: string) => string;
2
+ export declare const camelToDashCase: (str: string) => string;
@@ -0,0 +1,9 @@
1
+ export var dashToPascalCase = function (str) {
2
+ return str
3
+ .toLowerCase()
4
+ .split('-')
5
+ .map(function (segment) { return segment.charAt(0).toUpperCase() + segment.slice(1); })
6
+ .join('');
7
+ };
8
+ export var camelToDashCase = function (str) { return str.replace(/([A-Z])/g, function (m) { return "-".concat(m[0].toLowerCase()); }); };
9
+ //# sourceMappingURL=case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"case.js","sourceRoot":"","sources":["../../src/react-component-lib/case.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,GAAW;IAC1C,OAAA,GAAG;SACA,WAAW,EAAE;SACb,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,UAAC,OAAO,IAAK,OAAA,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAlD,CAAkD,CAAC;SACpE,IAAI,CAAC,EAAE,CAAC;AAJX,CAIW,CAAC;AACd,MAAM,CAAC,IAAM,eAAe,GAAG,UAAC,GAAW,IAAK,OAAA,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,UAAC,CAAS,IAAK,OAAA,WAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAE,EAAxB,CAAwB,CAAC,EAAhE,CAAgE,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, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<PropType & Omit<React.HTMLAttributes<ElementType>, "style"> & import("./interfaces").StyleReactProps> & React.RefAttributes<ElementType>>;
10
+ export {};
@@ -0,0 +1,108 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __rest = (this && this.__rest) || function (s, e) {
28
+ var t = {};
29
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
+ t[p] = s[p];
31
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
+ t[p[i]] = s[p[i]];
35
+ }
36
+ return t;
37
+ };
38
+ import React, { createElement } from 'react';
39
+ import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
40
+ export var createReactComponent = function (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) {
41
+ if (defineCustomElement !== undefined) {
42
+ defineCustomElement();
43
+ }
44
+ var displayName = dashToPascalCase(tagName);
45
+ var ReactComponent = /** @class */ (function (_super) {
46
+ __extends(class_1, _super);
47
+ function class_1(props) {
48
+ var _this = _super.call(this, props) || this;
49
+ _this.setComponentElRef = function (element) {
50
+ _this.componentEl = element;
51
+ };
52
+ return _this;
53
+ }
54
+ class_1.prototype.componentDidMount = function () {
55
+ this.componentDidUpdate(this.props);
56
+ };
57
+ class_1.prototype.componentDidUpdate = function (prevProps) {
58
+ attachProps(this.componentEl, this.props, prevProps);
59
+ };
60
+ class_1.prototype.render = function () {
61
+ var _a = this.props, children = _a.children, forwardedRef = _a.forwardedRef, style = _a.style, className = _a.className, ref = _a.ref, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
62
+ var propsToPass = Object.keys(cProps).reduce(function (acc, name) {
63
+ var value = cProps[name];
64
+ if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
65
+ var eventName = name.substring(2).toLowerCase();
66
+ if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
67
+ acc[name] = value;
68
+ }
69
+ }
70
+ else {
71
+ // we should only render strings, booleans, and numbers as attrs in html.
72
+ // objects, functions, arrays etc get synced via properties on mount.
73
+ var type = typeof value;
74
+ if (type === 'string' || type === 'boolean' || type === 'number') {
75
+ acc[camelToDashCase(name)] = value;
76
+ }
77
+ }
78
+ return acc;
79
+ }, {});
80
+ if (manipulatePropsFunction) {
81
+ propsToPass = manipulatePropsFunction(this.props, propsToPass);
82
+ }
83
+ var newProps = __assign(__assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style: style });
84
+ /**
85
+ * We use createElement here instead of
86
+ * React.createElement to work around a
87
+ * bug in Vite (https://github.com/vitejs/vite/issues/6104).
88
+ * React.createElement causes all elements to be rendered
89
+ * as <tagname> instead of the actual Web Component.
90
+ */
91
+ return createElement(tagName, newProps, children);
92
+ };
93
+ Object.defineProperty(class_1, "displayName", {
94
+ get: function () {
95
+ return displayName;
96
+ },
97
+ enumerable: false,
98
+ configurable: true
99
+ });
100
+ return class_1;
101
+ }(React.Component));
102
+ // If context was passed to createReactComponent then conditionally add it to the Component Class
103
+ if (ReactComponentContext) {
104
+ ReactComponent.contextType = ReactComponentContext;
105
+ }
106
+ return createForwardRef(ReactComponent, displayName);
107
+ };
108
+ //# 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,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAWxH,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAMlC,OAAe,EACf,qBAAuD,EACvD,uBAGuB,EACvB,mBAAgC;IAEhC,IAAI,mBAAmB,KAAK,SAAS,EAAE;QACrC,mBAAmB,EAAE,CAAC;KACvB;IAED,IAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAM,cAAc;QAAiB,2BAAuD;QAO1F,iBAAY,KAA6C;YAAzD,YACE,kB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QAAQ,EAAE;wBAChE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;qBACpC;iBACF;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAAwB,CAAC,CAAC;YAE7B,IAAI,uBAAuB,EAAE;gBAC3B,WAAW,GAAG,uBAAuB,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;aAChE;YAED,IAAM,QAAQ,yBACT,WAAW,KACd,GAAG,EAAE,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,EACpD,KAAK,OAAA,GACN,CAAC;YAEF;;;;;;eAMG;YACH,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;QAED,sBAAW,sBAAW;iBAAtB;gBACE,OAAO,WAAW,CAAC;YACrB,CAAC;;;WAAA;QACH,cAAC;IAAD,CAAC,AAjEsB,CAAc,KAAK,CAAC,SAAS,EAiEnD,CAAC;IAEF,iGAAiG;IACjG,IAAI,qBAAqB,EAAE;QACzB,cAAc,CAAC,WAAW,GAAG,qBAAqB,CAAC;KACpD;IAED,OAAO,gBAAgB,CAAwB,cAAc,EAAE,WAAW,CAAC,CAAC;AAC9E,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ interface LoadingElement {
3
+ present: () => any;
4
+ dismiss: () => any;
5
+ }
6
+ interface ReactControllerProps<E> {
7
+ isOpen: boolean;
8
+ onDidDismiss: (event: CustomEvent<E>) => void;
9
+ }
10
+ export declare function createControllerComponent<OptionsType extends object, LoadingElementType extends LoadingElement, OverlayEventDetail>(displayName: string, controller: {
11
+ create: (options: any) => Promise<LoadingElementType>;
12
+ }): {
13
+ new (props: OptionsType & ReactControllerProps<OverlayEventDetail>): {
14
+ controller?: LoadingElementType;
15
+ componentDidMount(): Promise<void>;
16
+ componentDidUpdate(prevProps: OptionsType & ReactControllerProps<OverlayEventDetail>): Promise<void>;
17
+ present(prevProps?: OptionsType & ReactControllerProps<OverlayEventDetail>): Promise<void>;
18
+ render(): null;
19
+ context: any;
20
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<OptionsType & ReactControllerProps<OverlayEventDetail>>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
21
+ forceUpdate(callback?: () => void): void;
22
+ readonly props: Readonly<OptionsType & ReactControllerProps<OverlayEventDetail>> & Readonly<{
23
+ children?: React.ReactNode;
24
+ }>;
25
+ state: Readonly<{}>;
26
+ refs: {
27
+ [key: string]: React.ReactInstance;
28
+ };
29
+ shouldComponentUpdate?(nextProps: Readonly<OptionsType & ReactControllerProps<OverlayEventDetail>>, nextState: Readonly<{}>, nextContext: any): boolean;
30
+ componentWillUnmount?(): void;
31
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
32
+ getSnapshotBeforeUpdate?(prevProps: Readonly<OptionsType & ReactControllerProps<OverlayEventDetail>>, prevState: Readonly<{}>): any;
33
+ componentWillMount?(): void;
34
+ UNSAFE_componentWillMount?(): void;
35
+ componentWillReceiveProps?(nextProps: Readonly<OptionsType & ReactControllerProps<OverlayEventDetail>>, nextContext: any): void;
36
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<OptionsType & ReactControllerProps<OverlayEventDetail>>, nextContext: any): void;
37
+ componentWillUpdate?(nextProps: Readonly<OptionsType & ReactControllerProps<OverlayEventDetail>>, nextState: Readonly<{}>, nextContext: any): void;
38
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<OptionsType & ReactControllerProps<OverlayEventDetail>>, nextState: Readonly<{}>, nextContext: any): void;
39
+ };
40
+ readonly displayName: string;
41
+ contextType?: React.Context<any>;
42
+ };
43
+ export {};
@@ -0,0 +1,148 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ var __generator = (this && this.__generator) || function (thisArg, body) {
37
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
+ function verb(n) { return function (v) { return step([n, v]); }; }
40
+ function step(op) {
41
+ if (f) throw new TypeError("Generator is already executing.");
42
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
43
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44
+ if (y = 0, t) op = [op[0] & 2, t.value];
45
+ switch (op[0]) {
46
+ case 0: case 1: t = op; break;
47
+ case 4: _.label++; return { value: op[1], done: false };
48
+ case 5: _.label++; y = op[1]; op = [0]; continue;
49
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
+ default:
51
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
+ if (t[2]) _.ops.pop();
56
+ _.trys.pop(); continue;
57
+ }
58
+ op = body.call(thisArg, _);
59
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
+ }
62
+ };
63
+ var __rest = (this && this.__rest) || function (s, e) {
64
+ var t = {};
65
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
66
+ t[p] = s[p];
67
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
68
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
69
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
70
+ t[p[i]] = s[p[i]];
71
+ }
72
+ return t;
73
+ };
74
+ import React from 'react';
75
+ import { attachEventProps } from './utils/attachEventProps';
76
+ export function createControllerComponent(displayName, controller) {
77
+ var dismissEventName = "on".concat(displayName, "DidDismiss");
78
+ return /** @class */ (function (_super) {
79
+ __extends(ReactControllerComponent, _super);
80
+ function ReactControllerComponent(props) {
81
+ return _super.call(this, props) || this;
82
+ }
83
+ Object.defineProperty(ReactControllerComponent, "displayName", {
84
+ get: function () {
85
+ return displayName;
86
+ },
87
+ enumerable: false,
88
+ configurable: true
89
+ });
90
+ ReactControllerComponent.prototype.componentDidMount = function () {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var isOpen;
93
+ return __generator(this, function (_a) {
94
+ isOpen = this.props.isOpen;
95
+ if (isOpen) {
96
+ this.present();
97
+ }
98
+ return [2 /*return*/];
99
+ });
100
+ });
101
+ };
102
+ ReactControllerComponent.prototype.componentDidUpdate = function (prevProps) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0:
107
+ if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
108
+ this.present(prevProps);
109
+ }
110
+ if (!(this.controller &&
111
+ prevProps.isOpen !== this.props.isOpen &&
112
+ this.props.isOpen === false)) return [3 /*break*/, 2];
113
+ return [4 /*yield*/, this.controller.dismiss()];
114
+ case 1:
115
+ _a.sent();
116
+ _a.label = 2;
117
+ case 2: return [2 /*return*/];
118
+ }
119
+ });
120
+ });
121
+ };
122
+ ReactControllerComponent.prototype.present = function (prevProps) {
123
+ return __awaiter(this, void 0, void 0, function () {
124
+ var _a, isOpen, onDidDismiss, cProps, elementProps, _b;
125
+ var _c;
126
+ return __generator(this, function (_d) {
127
+ switch (_d.label) {
128
+ case 0:
129
+ _a = this.props, isOpen = _a.isOpen, onDidDismiss = _a.onDidDismiss, cProps = __rest(_a, ["isOpen", "onDidDismiss"]);
130
+ elementProps = __assign(__assign({}, cProps), (_c = {}, _c[dismissEventName] = onDidDismiss, _c));
131
+ _b = this;
132
+ return [4 /*yield*/, controller.create(__assign({}, elementProps))];
133
+ case 1:
134
+ _b.controller = _d.sent();
135
+ attachEventProps(this.controller, elementProps, prevProps);
136
+ this.controller.present();
137
+ return [2 /*return*/];
138
+ }
139
+ });
140
+ });
141
+ };
142
+ ReactControllerComponent.prototype.render = function () {
143
+ return null;
144
+ };
145
+ return ReactControllerComponent;
146
+ }(React.Component));
147
+ }
148
+ //# sourceMappingURL=createControllerComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createControllerComponent.js","sourceRoot":"","sources":["../../src/react-component-lib/createControllerComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAY5D,MAAM,UAAU,yBAAyB,CAIvC,WAAmB,EAAE,UAAqE;IAC1F,IAAM,gBAAgB,GAAG,YAAK,WAAW,eAAY,CAAC;IAItD;QAA8C,4CAAsB;QAGlE,kCAAY,KAAY;mBACtB,kBAAM,KAAK,CAAC;QACd,CAAC;QAED,sBAAW,uCAAW;iBAAtB;gBACE,OAAO,WAAW,CAAC;YACrB,CAAC;;;WAAA;QAEK,oDAAiB,GAAvB;;;;oBACU,MAAM,GAAK,IAAI,CAAC,KAAK,OAAf,CAAgB;oBAC9B,IAAI,MAAM,EAAE;wBACV,IAAI,CAAC,OAAO,EAAE,CAAC;qBAChB;;;;SACF;QAEK,qDAAkB,GAAxB,UAAyB,SAAgB;;;;;4BACvC,IAAI,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,IAAI,EAAE;gCACxE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;6BACzB;iCAEC,CAAA,IAAI,CAAC,UAAU;gCACf,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM;gCACtC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,KAAK,CAAA,EAF3B,wBAE2B;4BAE3B,qBAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAA;;4BAA/B,SAA+B,CAAC;;;;;;SAEnC;QAEK,0CAAO,GAAb,UAAc,SAAiB;;;;;;;4BACvB,KAAsC,IAAI,CAAC,KAAK,EAA9C,MAAM,YAAA,EAAE,YAAY,kBAAA,EAAK,MAAM,cAAjC,0BAAmC,CAAF,CAAgB;4BACjD,YAAY,yBACb,MAAM,gBACR,gBAAgB,IAAG,YAAY,MACjC,CAAC;4BACF,KAAA,IAAI,CAAA;4BAAc,qBAAM,UAAU,CAAC,MAAM,cACpC,YAAY,EACf,EAAA;;4BAFF,GAAK,UAAU,GAAG,SAEhB,CAAC;4BACH,gBAAgB,CAAC,IAAI,CAAC,UAAiB,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;4BAClE,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;;;;;SAC3B;QAED,yCAAM,GAAN;YACE,OAAO,IAAI,CAAC;QACd,CAAC;QACH,+BAAC;IAAD,CAAC,AA/CM,CAAuC,KAAK,CAAC,SAAS,GA+C3D;AACJ,CAAC"}
@@ -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 {};