@watermarkinsights/ripple-react 4.9.0 → 4.11.0

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 (29) hide show
  1. package/dist/components/index.d.ts +1 -1
  2. package/dist/components/index.js +1 -1
  3. package/dist/components/stencil-generated/index.d.ts +1 -1
  4. package/dist/components/stencil-generated/index.js +28 -28
  5. package/dist/components.d.ts +41 -41
  6. package/dist/components.js +43 -43
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +3 -3
  9. package/dist/react-component-lib/ReactProps.d.ts +3 -3
  10. package/dist/react-component-lib/createComponent.d.ts +10 -10
  11. package/dist/react-component-lib/createComponent.js +105 -105
  12. package/dist/react-component-lib/createControllerComponent.d.ts +43 -43
  13. package/dist/react-component-lib/createControllerComponent.js +145 -145
  14. package/dist/react-component-lib/createOverlayComponent.d.ts +21 -21
  15. package/dist/react-component-lib/createOverlayComponent.js +188 -188
  16. package/dist/react-component-lib/index.d.ts +2 -2
  17. package/dist/react-component-lib/index.js +2 -2
  18. package/dist/react-component-lib/interfaces.d.ts +29 -29
  19. package/dist/react-component-lib/utils/attachEventProps.d.ts +8 -8
  20. package/dist/react-component-lib/utils/attachEventProps.js +78 -78
  21. package/dist/react-component-lib/utils/attachProps.d.ts +16 -16
  22. package/dist/react-component-lib/utils/attachProps.js +108 -108
  23. package/dist/react-component-lib/utils/case.d.ts +2 -2
  24. package/dist/react-component-lib/utils/case.js +8 -8
  25. package/dist/react-component-lib/utils/dev.d.ts +2 -2
  26. package/dist/react-component-lib/utils/dev.js +12 -12
  27. package/dist/react-component-lib/utils/index.d.ts +10 -10
  28. package/dist/react-component-lib/utils/index.js +46 -46
  29. package/package.json +2 -2
@@ -1,189 +1,189 @@
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- extendStatics(d, b);
10
- function __() { this.constructor = d; }
11
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
- };
13
- })();
14
- var __assign = (this && this.__assign) || function () {
15
- __assign = Object.assign || function(t) {
16
- for (var s, i = 1, n = arguments.length; i < n; i++) {
17
- s = arguments[i];
18
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
- t[p] = s[p];
20
- }
21
- return t;
22
- };
23
- return __assign.apply(this, arguments);
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (_) try {
41
- 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;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
- var __rest = (this && this.__rest) || function (s, e) {
62
- var t = {};
63
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
64
- t[p] = s[p];
65
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
66
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
67
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
68
- t[p[i]] = s[p[i]];
69
- }
70
- return t;
71
- };
72
- import React from 'react';
73
- import ReactDOM from 'react-dom';
74
- import { attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
75
- export var createOverlayComponent = function (tagName, controller, customElement) {
76
- defineCustomElement(tagName, customElement);
77
- var displayName = dashToPascalCase(tagName);
78
- var didDismissEventName = "on" + displayName + "DidDismiss";
79
- var didPresentEventName = "on" + displayName + "DidPresent";
80
- var willDismissEventName = "on" + displayName + "WillDismiss";
81
- var willPresentEventName = "on" + displayName + "WillPresent";
82
- var isDismissing = false;
83
- var Overlay = /** @class */ (function (_super) {
84
- __extends(Overlay, _super);
85
- function Overlay(props) {
86
- var _this = _super.call(this, props) || this;
87
- if (typeof document !== 'undefined') {
88
- _this.el = document.createElement('div');
89
- }
90
- _this.handleDismiss = _this.handleDismiss.bind(_this);
91
- return _this;
92
- }
93
- Object.defineProperty(Overlay, "displayName", {
94
- get: function () {
95
- return displayName;
96
- },
97
- enumerable: false,
98
- configurable: true
99
- });
100
- Overlay.prototype.componentDidMount = function () {
101
- if (this.props.isOpen) {
102
- this.present();
103
- }
104
- };
105
- Overlay.prototype.componentWillUnmount = function () {
106
- if (this.overlay) {
107
- this.overlay.dismiss();
108
- }
109
- };
110
- Overlay.prototype.handleDismiss = function (event) {
111
- if (this.props.onDidDismiss) {
112
- this.props.onDidDismiss(event);
113
- }
114
- setRef(this.props.forwardedRef, null);
115
- };
116
- Overlay.prototype.shouldComponentUpdate = function (nextProps) {
117
- // Check if the overlay component is about to dismiss
118
- if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
119
- isDismissing = true;
120
- }
121
- return true;
122
- };
123
- Overlay.prototype.componentDidUpdate = function (prevProps) {
124
- return __awaiter(this, void 0, void 0, function () {
125
- return __generator(this, function (_a) {
126
- switch (_a.label) {
127
- case 0:
128
- if (this.overlay) {
129
- attachProps(this.overlay, this.props, prevProps);
130
- }
131
- if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
132
- this.present(prevProps);
133
- }
134
- if (!(this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false)) return [3 /*break*/, 2];
135
- return [4 /*yield*/, this.overlay.dismiss()];
136
- case 1:
137
- _a.sent();
138
- isDismissing = false;
139
- /**
140
- * Now that the overlay is dismissed
141
- * we need to render again so that any
142
- * inner components will be unmounted
143
- */
144
- this.forceUpdate();
145
- _a.label = 2;
146
- case 2: return [2 /*return*/];
147
- }
148
- });
149
- });
150
- };
151
- Overlay.prototype.present = function (prevProps) {
152
- return __awaiter(this, void 0, void 0, function () {
153
- var _a, children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent, cProps, elementProps, _b;
154
- var _c;
155
- var _this = this;
156
- return __generator(this, function (_d) {
157
- switch (_d.label) {
158
- case 0:
159
- _a = this.props, children = _a.children, isOpen = _a.isOpen, onDidDismiss = _a.onDidDismiss, onDidPresent = _a.onDidPresent, onWillDismiss = _a.onWillDismiss, onWillPresent = _a.onWillPresent, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
160
- elementProps = __assign(__assign({}, cProps), (_c = { ref: this.props.forwardedRef }, _c[didDismissEventName] = this.handleDismiss, _c[didPresentEventName] = function (e) { return _this.props.onDidPresent && _this.props.onDidPresent(e); }, _c[willDismissEventName] = function (e) { return _this.props.onWillDismiss && _this.props.onWillDismiss(e); }, _c[willPresentEventName] = function (e) { return _this.props.onWillPresent && _this.props.onWillPresent(e); }, _c));
161
- _b = this;
162
- return [4 /*yield*/, controller.create(__assign(__assign({}, elementProps), { component: this.el, componentProps: {} }))];
163
- case 1:
164
- _b.overlay = _d.sent();
165
- setRef(this.props.forwardedRef, this.overlay);
166
- attachProps(this.overlay, elementProps, prevProps);
167
- return [4 /*yield*/, this.overlay.present()];
168
- case 2:
169
- _d.sent();
170
- return [2 /*return*/];
171
- }
172
- });
173
- });
174
- };
175
- Overlay.prototype.render = function () {
176
- /**
177
- * Continue to render the component even when
178
- * overlay is dismissing otherwise component
179
- * will be hidden before animation is done.
180
- */
181
- return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
182
- };
183
- return Overlay;
184
- }(React.Component));
185
- return React.forwardRef(function (props, ref) {
186
- return React.createElement(Overlay, __assign({}, props, { forwardedRef: ref }));
187
- });
188
- };
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __assign = (this && this.__assign) || function () {
15
+ __assign = Object.assign || function(t) {
16
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
17
+ s = arguments[i];
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
+ t[p] = s[p];
20
+ }
21
+ return t;
22
+ };
23
+ return __assign.apply(this, arguments);
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (_) try {
41
+ 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;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ var __rest = (this && this.__rest) || function (s, e) {
62
+ var t = {};
63
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
64
+ t[p] = s[p];
65
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
66
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
67
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
68
+ t[p[i]] = s[p[i]];
69
+ }
70
+ return t;
71
+ };
72
+ import React from 'react';
73
+ import ReactDOM from 'react-dom';
74
+ import { attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
75
+ export var createOverlayComponent = function (tagName, controller, customElement) {
76
+ defineCustomElement(tagName, customElement);
77
+ var displayName = dashToPascalCase(tagName);
78
+ var didDismissEventName = "on" + displayName + "DidDismiss";
79
+ var didPresentEventName = "on" + displayName + "DidPresent";
80
+ var willDismissEventName = "on" + displayName + "WillDismiss";
81
+ var willPresentEventName = "on" + displayName + "WillPresent";
82
+ var isDismissing = false;
83
+ var Overlay = /** @class */ (function (_super) {
84
+ __extends(Overlay, _super);
85
+ function Overlay(props) {
86
+ var _this = _super.call(this, props) || this;
87
+ if (typeof document !== 'undefined') {
88
+ _this.el = document.createElement('div');
89
+ }
90
+ _this.handleDismiss = _this.handleDismiss.bind(_this);
91
+ return _this;
92
+ }
93
+ Object.defineProperty(Overlay, "displayName", {
94
+ get: function () {
95
+ return displayName;
96
+ },
97
+ enumerable: false,
98
+ configurable: true
99
+ });
100
+ Overlay.prototype.componentDidMount = function () {
101
+ if (this.props.isOpen) {
102
+ this.present();
103
+ }
104
+ };
105
+ Overlay.prototype.componentWillUnmount = function () {
106
+ if (this.overlay) {
107
+ this.overlay.dismiss();
108
+ }
109
+ };
110
+ Overlay.prototype.handleDismiss = function (event) {
111
+ if (this.props.onDidDismiss) {
112
+ this.props.onDidDismiss(event);
113
+ }
114
+ setRef(this.props.forwardedRef, null);
115
+ };
116
+ Overlay.prototype.shouldComponentUpdate = function (nextProps) {
117
+ // Check if the overlay component is about to dismiss
118
+ if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
119
+ isDismissing = true;
120
+ }
121
+ return true;
122
+ };
123
+ Overlay.prototype.componentDidUpdate = function (prevProps) {
124
+ return __awaiter(this, void 0, void 0, function () {
125
+ return __generator(this, function (_a) {
126
+ switch (_a.label) {
127
+ case 0:
128
+ if (this.overlay) {
129
+ attachProps(this.overlay, this.props, prevProps);
130
+ }
131
+ if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
132
+ this.present(prevProps);
133
+ }
134
+ if (!(this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false)) return [3 /*break*/, 2];
135
+ return [4 /*yield*/, this.overlay.dismiss()];
136
+ case 1:
137
+ _a.sent();
138
+ isDismissing = false;
139
+ /**
140
+ * Now that the overlay is dismissed
141
+ * we need to render again so that any
142
+ * inner components will be unmounted
143
+ */
144
+ this.forceUpdate();
145
+ _a.label = 2;
146
+ case 2: return [2 /*return*/];
147
+ }
148
+ });
149
+ });
150
+ };
151
+ Overlay.prototype.present = function (prevProps) {
152
+ return __awaiter(this, void 0, void 0, function () {
153
+ var _a, children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent, cProps, elementProps, _b;
154
+ var _c;
155
+ var _this = this;
156
+ return __generator(this, function (_d) {
157
+ switch (_d.label) {
158
+ case 0:
159
+ _a = this.props, children = _a.children, isOpen = _a.isOpen, onDidDismiss = _a.onDidDismiss, onDidPresent = _a.onDidPresent, onWillDismiss = _a.onWillDismiss, onWillPresent = _a.onWillPresent, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
160
+ elementProps = __assign(__assign({}, cProps), (_c = { ref: this.props.forwardedRef }, _c[didDismissEventName] = this.handleDismiss, _c[didPresentEventName] = function (e) { return _this.props.onDidPresent && _this.props.onDidPresent(e); }, _c[willDismissEventName] = function (e) { return _this.props.onWillDismiss && _this.props.onWillDismiss(e); }, _c[willPresentEventName] = function (e) { return _this.props.onWillPresent && _this.props.onWillPresent(e); }, _c));
161
+ _b = this;
162
+ return [4 /*yield*/, controller.create(__assign(__assign({}, elementProps), { component: this.el, componentProps: {} }))];
163
+ case 1:
164
+ _b.overlay = _d.sent();
165
+ setRef(this.props.forwardedRef, this.overlay);
166
+ attachProps(this.overlay, elementProps, prevProps);
167
+ return [4 /*yield*/, this.overlay.present()];
168
+ case 2:
169
+ _d.sent();
170
+ return [2 /*return*/];
171
+ }
172
+ });
173
+ });
174
+ };
175
+ Overlay.prototype.render = function () {
176
+ /**
177
+ * Continue to render the component even when
178
+ * overlay is dismissing otherwise component
179
+ * will be hidden before animation is done.
180
+ */
181
+ return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
182
+ };
183
+ return Overlay;
184
+ }(React.Component));
185
+ return React.forwardRef(function (props, ref) {
186
+ return React.createElement(Overlay, __assign({}, props, { forwardedRef: ref }));
187
+ });
188
+ };
189
189
  //# sourceMappingURL=createOverlayComponent.js.map
@@ -1,2 +1,2 @@
1
- export { createReactComponent } from './createComponent';
2
- export { createOverlayComponent } from './createOverlayComponent';
1
+ export { createReactComponent } from './createComponent';
2
+ export { createOverlayComponent } from './createOverlayComponent';
@@ -1,3 +1,3 @@
1
- export { createReactComponent } from './createComponent';
2
- export { createOverlayComponent } from './createOverlayComponent';
1
+ export { createReactComponent } from './createComponent';
2
+ export { createOverlayComponent } from './createOverlayComponent';
3
3
  //# sourceMappingURL=index.js.map
@@ -1,29 +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
- }
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
+ }
@@ -1,8 +1,8 @@
1
- export declare function attachEventProps(node: HTMLElement, newProps: any, oldProps?: any): void;
2
- export declare function 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 function isCoveredByReact(eventNameSuffix: string, doc?: Document): boolean;
8
- export declare function syncEvent(node: Element, eventName: string, newEventHandler: (e: Event) => any): void;
1
+ export declare function attachEventProps(node: HTMLElement, newProps: any, oldProps?: any): void;
2
+ export declare function 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 function isCoveredByReact(eventNameSuffix: string, doc?: Document): boolean;
8
+ export declare function syncEvent(node: Element, eventName: string, newEventHandler: (e: Event) => any): void;
@@ -1,79 +1,79 @@
1
- export function attachEventProps(node, newProps, oldProps) {
2
- if (oldProps === void 0) { oldProps = {}; }
3
- var className = getClassName(node.classList, newProps, oldProps);
4
- if (className) {
5
- node.className = className;
6
- }
7
- Object.keys(newProps).forEach(function (name) {
8
- if (name === 'children' || name === 'style' || name === 'ref' || name === 'className') {
9
- return;
10
- }
11
- if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
12
- var eventName = name.substring(2);
13
- var eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
14
- if (!isCoveredByReact(eventNameLc)) {
15
- syncEvent(node, eventNameLc, newProps[name]);
16
- }
17
- }
18
- else {
19
- node[name] = newProps[name];
20
- }
21
- });
22
- }
23
- export function getClassName(classList, newProps, oldProps) {
24
- // map the classes to Maps for performance
25
- var currentClasses = arrayToMap(classList);
26
- var incomingPropClasses = arrayToMap(newProps.className ? newProps.className.split(' ') : []);
27
- var oldPropClasses = arrayToMap(oldProps.className ? oldProps.className.split(' ') : []);
28
- var finalClassNames = [];
29
- // loop through each of the current classes on the component
30
- // to see if it should be a part of the classNames added
31
- currentClasses.forEach(function (currentClass) {
32
- if (incomingPropClasses.has(currentClass)) {
33
- // add it as its already included in classnames coming in from newProps
34
- finalClassNames.push(currentClass);
35
- incomingPropClasses.delete(currentClass);
36
- }
37
- else if (!oldPropClasses.has(currentClass)) {
38
- // add it as it has NOT been removed by user
39
- finalClassNames.push(currentClass);
40
- }
41
- });
42
- incomingPropClasses.forEach(function (s) { return finalClassNames.push(s); });
43
- return finalClassNames.join(' ');
44
- }
45
- /**
46
- * Checks if an event is supported in the current execution environment.
47
- * @license Modernizr 3.0.0pre (Custom Build) | MIT
48
- */
49
- export function isCoveredByReact(eventNameSuffix, doc) {
50
- if (doc === void 0) { doc = document; }
51
- var eventName = 'on' + eventNameSuffix;
52
- var isSupported = eventName in doc;
53
- if (!isSupported) {
54
- var element = doc.createElement('div');
55
- element.setAttribute(eventName, 'return;');
56
- isSupported = typeof element[eventName] === 'function';
57
- }
58
- return isSupported;
59
- }
60
- export function syncEvent(node, eventName, newEventHandler) {
61
- var eventStore = node.__events || (node.__events = {});
62
- var oldEventHandler = eventStore[eventName];
63
- // Remove old listener so they don't double up.
64
- if (oldEventHandler) {
65
- node.removeEventListener(eventName, oldEventHandler);
66
- }
67
- if (newEventHandler != null) {
68
- // Bind new listener.
69
- node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
70
- newEventHandler.call(this, e);
71
- }));
72
- }
73
- }
74
- function arrayToMap(arr) {
75
- var map = new Map();
76
- arr.forEach(function (s) { return map.set(s, s); });
77
- return map;
78
- }
1
+ export function attachEventProps(node, newProps, oldProps) {
2
+ if (oldProps === void 0) { oldProps = {}; }
3
+ var className = getClassName(node.classList, newProps, oldProps);
4
+ if (className) {
5
+ node.className = className;
6
+ }
7
+ Object.keys(newProps).forEach(function (name) {
8
+ if (name === 'children' || name === 'style' || name === 'ref' || name === 'className') {
9
+ return;
10
+ }
11
+ if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
12
+ var eventName = name.substring(2);
13
+ var eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
14
+ if (!isCoveredByReact(eventNameLc)) {
15
+ syncEvent(node, eventNameLc, newProps[name]);
16
+ }
17
+ }
18
+ else {
19
+ node[name] = newProps[name];
20
+ }
21
+ });
22
+ }
23
+ export function getClassName(classList, newProps, oldProps) {
24
+ // map the classes to Maps for performance
25
+ var currentClasses = arrayToMap(classList);
26
+ var incomingPropClasses = arrayToMap(newProps.className ? newProps.className.split(' ') : []);
27
+ var oldPropClasses = arrayToMap(oldProps.className ? oldProps.className.split(' ') : []);
28
+ var finalClassNames = [];
29
+ // loop through each of the current classes on the component
30
+ // to see if it should be a part of the classNames added
31
+ currentClasses.forEach(function (currentClass) {
32
+ if (incomingPropClasses.has(currentClass)) {
33
+ // add it as its already included in classnames coming in from newProps
34
+ finalClassNames.push(currentClass);
35
+ incomingPropClasses.delete(currentClass);
36
+ }
37
+ else if (!oldPropClasses.has(currentClass)) {
38
+ // add it as it has NOT been removed by user
39
+ finalClassNames.push(currentClass);
40
+ }
41
+ });
42
+ incomingPropClasses.forEach(function (s) { return finalClassNames.push(s); });
43
+ return finalClassNames.join(' ');
44
+ }
45
+ /**
46
+ * Checks if an event is supported in the current execution environment.
47
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
48
+ */
49
+ export function isCoveredByReact(eventNameSuffix, doc) {
50
+ if (doc === void 0) { doc = document; }
51
+ var eventName = 'on' + eventNameSuffix;
52
+ var isSupported = eventName in doc;
53
+ if (!isSupported) {
54
+ var element = doc.createElement('div');
55
+ element.setAttribute(eventName, 'return;');
56
+ isSupported = typeof element[eventName] === 'function';
57
+ }
58
+ return isSupported;
59
+ }
60
+ export function syncEvent(node, eventName, newEventHandler) {
61
+ var eventStore = node.__events || (node.__events = {});
62
+ var oldEventHandler = eventStore[eventName];
63
+ // Remove old listener so they don't double up.
64
+ if (oldEventHandler) {
65
+ node.removeEventListener(eventName, oldEventHandler);
66
+ }
67
+ if (newEventHandler != null) {
68
+ // Bind new listener.
69
+ node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
70
+ newEventHandler.call(this, e);
71
+ }));
72
+ }
73
+ }
74
+ function arrayToMap(arr) {
75
+ var map = new Map();
76
+ arr.forEach(function (s) { return map.set(s, s); });
77
+ return map;
78
+ }
79
79
  //# sourceMappingURL=attachEventProps.js.map