UNPKG

27.5 kBJavaScriptView Raw
1import React from 'react';
2
3function _classCallCheck(instance, Constructor) {
4 if (!(instance instanceof Constructor)) {
5 throw new TypeError("Cannot call a class as a function");
6 }
7}
8
9function _defineProperties(target, props) {
10 for (var i = 0; i < props.length; i++) {
11 var descriptor = props[i];
12 descriptor.enumerable = descriptor.enumerable || false;
13 descriptor.configurable = true;
14 if ("value" in descriptor) descriptor.writable = true;
15 Object.defineProperty(target, descriptor.key, descriptor);
16 }
17}
18
19function _createClass(Constructor, protoProps, staticProps) {
20 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
21 if (staticProps) _defineProperties(Constructor, staticProps);
22 return Constructor;
23}
24
25function _defineProperty(obj, key, value) {
26 if (key in obj) {
27 Object.defineProperty(obj, key, {
28 value: value,
29 enumerable: true,
30 configurable: true,
31 writable: true
32 });
33 } else {
34 obj[key] = value;
35 }
36
37 return obj;
38}
39
40function _objectSpread(target) {
41 for (var i = 1; i < arguments.length; i++) {
42 var source = arguments[i] != null ? arguments[i] : {};
43 var ownKeys = Object.keys(source);
44
45 if (typeof Object.getOwnPropertySymbols === 'function') {
46 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
47 return Object.getOwnPropertyDescriptor(source, sym).enumerable;
48 }));
49 }
50
51 ownKeys.forEach(function (key) {
52 _defineProperty(target, key, source[key]);
53 });
54 }
55
56 return target;
57}
58
59function _inherits(subClass, superClass) {
60 if (typeof superClass !== "function" && superClass !== null) {
61 throw new TypeError("Super expression must either be null or a function");
62 }
63
64 subClass.prototype = Object.create(superClass && superClass.prototype, {
65 constructor: {
66 value: subClass,
67 writable: true,
68 configurable: true
69 }
70 });
71 if (superClass) _setPrototypeOf(subClass, superClass);
72}
73
74function _getPrototypeOf(o) {
75 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
76 return o.__proto__ || Object.getPrototypeOf(o);
77 };
78 return _getPrototypeOf(o);
79}
80
81function _setPrototypeOf(o, p) {
82 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
83 o.__proto__ = p;
84 return o;
85 };
86
87 return _setPrototypeOf(o, p);
88}
89
90function _assertThisInitialized(self) {
91 if (self === void 0) {
92 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
93 }
94
95 return self;
96}
97
98function _possibleConstructorReturn(self, call) {
99 if (call && (typeof call === "object" || typeof call === "function")) {
100 return call;
101 }
102
103 return _assertThisInitialized(self);
104}
105
106var VKContext = React.createContext();
107
108/* global document, window */
109var VKApi =
110/*#__PURE__*/
111function () {
112 function VKApi(apiId) {
113 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
114
115 _classCallCheck(this, VKApi);
116
117 this.apiId = apiId;
118 this.options = options;
119 this.promise = null;
120 this.init();
121 }
122
123 _createClass(VKApi, [{
124 key: "init",
125 value: function init() {
126 var apiId = this.apiId,
127 _this$options = this.options,
128 version = _this$options.version,
129 onlyWidgets = _this$options.onlyWidgets;
130 if (this.promise) return this.promise;
131 this.promise = new Promise(function (resolve) {
132 var baseUrl = "https://vk.com/js/api/openapi.js?".concat(version);
133
134 window.vkAsyncInit = function () {
135 if (apiId) {
136 window.VK.init({
137 apiId: apiId,
138 onlyWidgets: onlyWidgets
139 });
140 }
141
142 resolve(window.VK);
143 };
144
145 if (document.getElementById("vk-openapi")) {
146 return;
147 }
148
149 var script = document.createElement("script");
150 script.type = "text/javascript";
151 script.id = "vk-openapi";
152 script.src = baseUrl;
153 script.async = true;
154 document.head.appendChild(script);
155 });
156 return this.promise;
157 }
158 }]);
159
160 return VKApi;
161}();
162
163var VKInstance = null;
164
165var VK =
166/*#__PURE__*/
167function (_React$Component) {
168 _inherits(VK, _React$Component);
169
170 function VK() {
171 var _getPrototypeOf2;
172
173 var _this;
174
175 _classCallCheck(this, VK);
176
177 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
178 args[_key] = arguments[_key];
179 }
180
181 _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(VK)).call.apply(_getPrototypeOf2, [this].concat(args)));
182
183 _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_mounted", true);
184
185 _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
186 vk: null
187 });
188
189 return _this;
190 }
191
192 _createClass(VK, [{
193 key: "componentDidMount",
194 value: function componentDidMount() {
195 var _this2 = this;
196
197 var _this$props = this.props,
198 onApiAvailable = _this$props.onApiAvailable,
199 apiId = _this$props.apiId;
200
201 if (typeof window !== "undefined" && window.document && window.document.createElement) {
202 this.VKinit().then(function (vk) {
203 onApiAvailable(vk);
204
205 if (apiId) {
206 vk.init({
207 apiId: apiId
208 });
209 }
210
211 if (_this2._mounted) _this2.setState({
212 vk: vk
213 });
214 });
215 }
216 }
217 }, {
218 key: "componentWillUnmount",
219 value: function componentWillUnmount() {
220 this._mounted = false;
221 }
222 }, {
223 key: "VKinit",
224 value: function VKinit() {
225 var _this$props2 = this.props,
226 apiId = _this$props2.apiId,
227 options = _this$props2.options;
228
229 if (!this.vk) {
230 this.vk = VKInstance || new VKApi(apiId, options);
231 VKInstance = this.vk;
232 }
233
234 return this.vk.init();
235 }
236 }, {
237 key: "render",
238 value: function render() {
239 var vk = this.state.vk;
240 var children = this.props.children;
241 return vk ? React.createElement(VKContext.Provider, {
242 value: {
243 vk: vk
244 }
245 }, children) : null;
246 }
247 }]);
248
249 return VK;
250}(React.Component);
251
252_defineProperty(VK, "defaultProps", {
253 apiId: null,
254 options: {
255 version: 160,
256 onlyWidgets: true
257 },
258 onApiAvailable: function onApiAvailable() {}
259});
260
261var AllowMessagesFromCommunity =
262/*#__PURE__*/
263function (_React$Component) {
264 _inherits(AllowMessagesFromCommunity, _React$Component);
265
266 function AllowMessagesFromCommunity() {
267 _classCallCheck(this, AllowMessagesFromCommunity);
268
269 return _possibleConstructorReturn(this, _getPrototypeOf(AllowMessagesFromCommunity).apply(this, arguments));
270 }
271
272 _createClass(AllowMessagesFromCommunity, [{
273 key: "componentDidMount",
274 value: function componentDidMount() {
275 this.mount();
276 }
277 }, {
278 key: "componentWillUnmount",
279 value: function componentWillUnmount() {
280 var vk = this.context.vk;
281 vk.Observer.unsubscribe("widgets.allowMessagesFromCommunity.allowed");
282 }
283 }, {
284 key: "mount",
285 value: function mount() {
286 var vk = this.context.vk;
287 var _this$props = this.props,
288 elementId = _this$props.elementId,
289 options = _this$props.options,
290 groupId = _this$props.groupId,
291 onAllow = _this$props.onAllow,
292 onDeny = _this$props.onDeny;
293 vk.Widgets.AllowMessagesFromCommunity(elementId, options, groupId);
294 vk.Observer.subscribe("widgets.allowMessagesFromCommunity.allowed", function (userId) {
295 return onAllow(userId);
296 });
297 vk.Observer.subscribe("widgets.allowMessagesFromCommunity.denied", function (userId) {
298 return onDeny(userId);
299 });
300 }
301 }, {
302 key: "render",
303 value: function render() {
304 var elementId = this.props.elementId;
305 return React.createElement("div", {
306 id: elementId
307 });
308 }
309 }]);
310
311 return AllowMessagesFromCommunity;
312}(React.Component);
313
314_defineProperty(AllowMessagesFromCommunity, "contextType", VKContext);
315
316_defineProperty(AllowMessagesFromCommunity, "defaultProps", {
317 elementId: "vk_send_message",
318 options: {
319 height: 24
320 },
321 onAllow: function onAllow() {},
322 onDeny: function onDeny() {}
323});
324
325var Application =
326/*#__PURE__*/
327function (_React$Component) {
328 _inherits(Application, _React$Component);
329
330 function Application() {
331 _classCallCheck(this, Application);
332
333 return _possibleConstructorReturn(this, _getPrototypeOf(Application).apply(this, arguments));
334 }
335
336 _createClass(Application, [{
337 key: "componentDidMount",
338 value: function componentDidMount() {
339 this.mount();
340 }
341 }, {
342 key: "mount",
343 value: function mount() {
344 var vk = this.context.vk;
345 var _this$props = this.props,
346 elementId = _this$props.elementId,
347 appId = _this$props.appId,
348 options = _this$props.options;
349 vk.Widgets.App(elementId, appId, options);
350 }
351 }, {
352 key: "render",
353 value: function render() {
354 var elementId = this.props.elementId;
355 return React.createElement("div", {
356 id: elementId
357 });
358 }
359 }]);
360
361 return Application;
362}(React.Component);
363
364_defineProperty(Application, "contextType", VKContext);
365
366_defineProperty(Application, "defaultProps", {
367 elementId: "vk_app",
368 options: {
369 mode: 1
370 }
371});
372
373var Auth =
374/*#__PURE__*/
375function (_React$Component) {
376 _inherits(Auth, _React$Component);
377
378 function Auth() {
379 _classCallCheck(this, Auth);
380
381 return _possibleConstructorReturn(this, _getPrototypeOf(Auth).apply(this, arguments));
382 }
383
384 _createClass(Auth, [{
385 key: "componentDidMount",
386 value: function componentDidMount() {
387 this.mount();
388 }
389 }, {
390 key: "mount",
391 value: function mount() {
392 var vk = this.context.vk;
393 var _this$props = this.props,
394 elementId = _this$props.elementId,
395 options = _this$props.options;
396
397 var copy = _objectSpread({}, options);
398
399 copy.onAuth = function (uid, first_name, last_name, photo, photo_rec, hash) {
400 return options.onAuth(uid, first_name, last_name, photo, photo_rec, hash);
401 };
402
403 vk.Widgets.Auth(elementId, copy);
404 }
405 }, {
406 key: "render",
407 value: function render() {
408 var elementId = this.props.elementId;
409 return React.createElement("div", {
410 id: elementId
411 });
412 }
413 }]);
414
415 return Auth;
416}(React.Component);
417
418_defineProperty(Auth, "contextType", VKContext);
419
420_defineProperty(Auth, "defaultProps", {
421 elementId: "vk_auth",
422 options: {
423 width: 300,
424 onAuth: function onAuth() {}
425 }
426});
427
428var Comments =
429/*#__PURE__*/
430function (_React$Component) {
431 _inherits(Comments, _React$Component);
432
433 function Comments() {
434 _classCallCheck(this, Comments);
435
436 return _possibleConstructorReturn(this, _getPrototypeOf(Comments).apply(this, arguments));
437 }
438
439 _createClass(Comments, [{
440 key: "componentDidMount",
441 value: function componentDidMount() {
442 this.mount();
443 }
444 }, {
445 key: "componentWillUnmount",
446 value: function componentWillUnmount() {
447 var vk = this.context.vk;
448 vk.Observer.unsubscribe("widgets.comments.new_comment");
449 vk.Observer.unsubscribe("widgets.comments.delete_comment");
450 }
451 }, {
452 key: "mount",
453 value: function mount() {
454 var vk = this.context.vk;
455 var _this$props = this.props,
456 elementId = _this$props.elementId,
457 options = _this$props.options,
458 pageId = _this$props.pageId,
459 onNewComment = _this$props.onNewComment,
460 onDeleteComment = _this$props.onDeleteComment;
461 vk.Widgets.Comments(elementId, options, pageId);
462 vk.Observer.subscribe("widgets.comments.new_comment", function (num, last_comment, date, sign) {
463 return onNewComment(num, last_comment, date, sign);
464 });
465 vk.Observer.subscribe("widgets.comments.delete_comment", onDeleteComment);
466 }
467 }, {
468 key: "render",
469 value: function render() {
470 var elementId = this.props.elementId;
471 return React.createElement("div", {
472 id: elementId
473 });
474 }
475 }]);
476
477 return Comments;
478}(React.Component);
479
480_defineProperty(Comments, "contextType", VKContext);
481
482_defineProperty(Comments, "defaultProps", {
483 elementId: "vk_comments",
484 options: {
485 height: 0,
486 limit: 10,
487 attach: "*",
488 autoPublish: 0,
489 mini: "auto",
490 norealtime: 0
491 },
492 pageId: null,
493 onNewComment: function onNewComment() {},
494 onDeleteComment: function onDeleteComment() {}
495});
496
497var CommentsBrowse =
498/*#__PURE__*/
499function (_React$Component) {
500 _inherits(CommentsBrowse, _React$Component);
501
502 function CommentsBrowse() {
503 _classCallCheck(this, CommentsBrowse);
504
505 return _possibleConstructorReturn(this, _getPrototypeOf(CommentsBrowse).apply(this, arguments));
506 }
507
508 _createClass(CommentsBrowse, [{
509 key: "componentDidMount",
510 value: function componentDidMount() {
511 this.mount();
512 }
513 }, {
514 key: "mount",
515 value: function mount() {
516 var vk = this.context.vk;
517 var _this$props = this.props,
518 elementId = _this$props.elementId,
519 options = _this$props.options;
520 vk.Widgets.CommentsBrowse(elementId, options);
521 }
522 }, {
523 key: "render",
524 value: function render() {
525 var elementId = this.props.elementId;
526 return React.createElement("div", {
527 id: elementId
528 });
529 }
530 }]);
531
532 return CommentsBrowse;
533}(React.Component);
534
535_defineProperty(CommentsBrowse, "contextType", VKContext);
536
537_defineProperty(CommentsBrowse, "defaultProps", {
538 elementId: "vk_comments_browse",
539 options: {
540 height: 0,
541 limit: 10,
542 mini: "auto",
543 norealtime: 0
544 }
545});
546
547var CommunityMessages =
548/*#__PURE__*/
549function (_React$Component) {
550 _inherits(CommunityMessages, _React$Component);
551
552 function CommunityMessages() {
553 _classCallCheck(this, CommunityMessages);
554
555 return _possibleConstructorReturn(this, _getPrototypeOf(CommunityMessages).apply(this, arguments));
556 }
557
558 _createClass(CommunityMessages, [{
559 key: "componentDidMount",
560 value: function componentDidMount() {
561 var vk = this.context.vk;
562 var _this$props = this.props,
563 elementId = _this$props.elementId,
564 groupId = _this$props.groupId,
565 options = _this$props.options,
566 onMount = _this$props.onMount;
567 var widget = vk.Widgets.CommunityMessages(elementId, groupId, options);
568 onMount(widget, elementId);
569 }
570 }, {
571 key: "render",
572 value: function render() {
573 var elementId = this.props.elementId;
574 return React.createElement("div", {
575 id: elementId
576 });
577 }
578 }]);
579
580 return CommunityMessages;
581}(React.Component);
582
583_defineProperty(CommunityMessages, "contextType", VKContext);
584
585_defineProperty(CommunityMessages, "defaultProps", {
586 elementId: "vk_community_messages",
587 options: {
588 onCanNotWrite: function onCanNotWrite() {},
589 welcomeScreen: 1,
590 expandTimeout: 0,
591 expanded: 0,
592 widgetPosition: "right",
593 buttonType: "blue_circle",
594 disableButtonTooltip: 0
595 },
596 onMount: function onMount() {}
597});
598
599var ContactUs =
600/*#__PURE__*/
601function (_React$Component) {
602 _inherits(ContactUs, _React$Component);
603
604 function ContactUs() {
605 _classCallCheck(this, ContactUs);
606
607 return _possibleConstructorReturn(this, _getPrototypeOf(ContactUs).apply(this, arguments));
608 }
609
610 _createClass(ContactUs, [{
611 key: "componentDidMount",
612 value: function componentDidMount() {
613 this.mount();
614 }
615 }, {
616 key: "mount",
617 value: function mount() {
618 var vk = this.context.vk;
619 var _this$props = this.props,
620 elementId = _this$props.elementId,
621 options = _this$props.options,
622 ownerId = _this$props.ownerId;
623 vk.Widgets.ContactUs(elementId, options, -ownerId);
624 }
625 }, {
626 key: "render",
627 value: function render() {
628 var elementId = this.props.elementId;
629 return React.createElement("div", {
630 id: elementId
631 });
632 }
633 }]);
634
635 return ContactUs;
636}(React.Component);
637
638_defineProperty(ContactUs, "contextType", VKContext);
639
640_defineProperty(ContactUs, "defaultProps", {
641 elementId: "vk_contact_us",
642 options: {
643 height: 24
644 }
645});
646
647var Group =
648/*#__PURE__*/
649function (_React$Component) {
650 _inherits(Group, _React$Component);
651
652 function Group() {
653 _classCallCheck(this, Group);
654
655 return _possibleConstructorReturn(this, _getPrototypeOf(Group).apply(this, arguments));
656 }
657
658 _createClass(Group, [{
659 key: "componentDidMount",
660 value: function componentDidMount() {
661 this.mount();
662 }
663 }, {
664 key: "componentWillUnmount",
665 value: function componentWillUnmount() {
666 var vk = this.context.vk;
667 vk.Observer.unsubscribe("widgets.groups.joined");
668 vk.Observer.unsubscribe("widgets.groups.leaved");
669 }
670 }, {
671 key: "mount",
672 value: function mount() {
673 var vk = this.context.vk;
674 var _this$props = this.props,
675 elementId = _this$props.elementId,
676 options = _this$props.options,
677 groupId = _this$props.groupId,
678 onJoin = _this$props.onJoin,
679 onLeave = _this$props.onLeave;
680 vk.Widgets.Group(elementId, options, groupId);
681 vk.Observer.subscribe("widgets.groups.joined", onJoin);
682 vk.Observer.subscribe("widgets.groups.leaved", onLeave);
683 }
684 }, {
685 key: "render",
686 value: function render() {
687 var elementId = this.props.elementId;
688 return React.createElement("div", {
689 id: elementId
690 });
691 }
692 }]);
693
694 return Group;
695}(React.Component);
696
697_defineProperty(Group, "contextType", VKContext);
698
699_defineProperty(Group, "defaultProps", {
700 elementId: "vk_groups",
701 options: {
702 width: "auto",
703 mode: 3,
704 no_cover: 1,
705 wide: 1
706 },
707 onJoin: function onJoin() {},
708 onLeave: function onLeave() {}
709});
710
711var Like =
712/*#__PURE__*/
713function (_React$Component) {
714 _inherits(Like, _React$Component);
715
716 function Like() {
717 _classCallCheck(this, Like);
718
719 return _possibleConstructorReturn(this, _getPrototypeOf(Like).apply(this, arguments));
720 }
721
722 _createClass(Like, [{
723 key: "componentDidMount",
724 value: function componentDidMount() {
725 this.mount();
726 }
727 }, {
728 key: "componentWillUnmount",
729 value: function componentWillUnmount() {
730 var vk = this.context.vk;
731 vk.Observer.unsubscribe("widgets.like.liked");
732 vk.Observer.unsubscribe("widgets.like.unliked");
733 vk.Observer.unsubscribe("widgets.like.shared");
734 vk.Observer.unsubscribe("widgets.like.unshared");
735 }
736 }, {
737 key: "mount",
738 value: function mount() {
739 var vk = this.context.vk;
740 var _this$props = this.props,
741 elementId = _this$props.elementId,
742 options = _this$props.options,
743 pageId = _this$props.pageId,
744 onLike = _this$props.onLike,
745 onUnlike = _this$props.onUnlike,
746 onShare = _this$props.onShare,
747 onUnshare = _this$props.onUnshare;
748
749 if (pageId) {
750 vk.Widgets.Like(elementId, options, pageId);
751 } else {
752 vk.Widgets.Like(elementId, options);
753 }
754
755 vk.Observer.subscribe("widgets.like.liked", function (quantity) {
756 return onLike(quantity);
757 });
758 vk.Observer.subscribe("widgets.like.unliked", function (quantity) {
759 return onUnlike(quantity);
760 });
761 vk.Observer.subscribe("widgets.like.shared", function (quantity) {
762 return onShare(quantity);
763 });
764 vk.Observer.subscribe("widgets.like.unshared", function (quantity) {
765 return onUnshare(quantity);
766 });
767 }
768 }, {
769 key: "render",
770 value: function render() {
771 var elementId = this.props.elementId;
772 return React.createElement("div", {
773 id: elementId
774 });
775 }
776 }]);
777
778 return Like;
779}(React.Component);
780
781_defineProperty(Like, "contextType", VKContext);
782
783_defineProperty(Like, "defaultProps", {
784 elementId: "vk_like",
785 options: {
786 type: "full",
787 width: 350,
788 height: 22,
789 verb: 0
790 },
791 pageId: null,
792 onLike: function onLike() {},
793 onUnlike: function onUnlike() {},
794 onShare: function onShare() {},
795 onUnshare: function onUnshare() {}
796});
797
798var Playlist =
799/*#__PURE__*/
800function (_React$Component) {
801 _inherits(Playlist, _React$Component);
802
803 function Playlist() {
804 _classCallCheck(this, Playlist);
805
806 return _possibleConstructorReturn(this, _getPrototypeOf(Playlist).apply(this, arguments));
807 }
808
809 _createClass(Playlist, [{
810 key: "componentDidMount",
811 value: function componentDidMount() {
812 this.mount();
813 }
814 }, {
815 key: "mount",
816 value: function mount() {
817 var vk = this.context.vk;
818 var _this$props = this.props,
819 elementId = _this$props.elementId,
820 ownerId = _this$props.ownerId,
821 playlistId = _this$props.playlistId,
822 hash = _this$props.hash,
823 options = _this$props.options;
824 vk.Widgets.Playlist(elementId, -ownerId, playlistId, hash, options);
825 }
826 }, {
827 key: "render",
828 value: function render() {
829 var elementId = this.props.elementId;
830 return React.createElement("div", {
831 id: elementId
832 });
833 }
834 }]);
835
836 return Playlist;
837}(React.Component);
838
839_defineProperty(Playlist, "contextType", VKContext);
840
841_defineProperty(Playlist, "defaultProps", {
842 elementId: "vk_playlist",
843 options: {}
844});
845
846var Poll =
847/*#__PURE__*/
848function (_React$Component) {
849 _inherits(Poll, _React$Component);
850
851 function Poll() {
852 _classCallCheck(this, Poll);
853
854 return _possibleConstructorReturn(this, _getPrototypeOf(Poll).apply(this, arguments));
855 }
856
857 _createClass(Poll, [{
858 key: "componentDidMount",
859 value: function componentDidMount() {
860 this.mount();
861 }
862 }, {
863 key: "mount",
864 value: function mount() {
865 var vk = this.context.vk;
866 var _this$props = this.props,
867 elementId = _this$props.elementId,
868 options = _this$props.options,
869 pollId = _this$props.pollId;
870 vk.Widgets.Poll(elementId, options, pollId);
871 }
872 }, {
873 key: "render",
874 value: function render() {
875 var elementId = this.props.elementId;
876 return React.createElement("div", {
877 id: elementId
878 });
879 }
880 }]);
881
882 return Poll;
883}(React.Component);
884
885_defineProperty(Poll, "contextType", VKContext);
886
887_defineProperty(Poll, "defaultProps", {
888 elementId: "vk_poll",
889 options: {
890 height: 24
891 }
892});
893
894var Post =
895/*#__PURE__*/
896function (_React$Component) {
897 _inherits(Post, _React$Component);
898
899 function Post() {
900 _classCallCheck(this, Post);
901
902 return _possibleConstructorReturn(this, _getPrototypeOf(Post).apply(this, arguments));
903 }
904
905 _createClass(Post, [{
906 key: "componentDidMount",
907 value: function componentDidMount() {
908 this.mount();
909 }
910 }, {
911 key: "mount",
912 value: function mount() {
913 var vk = this.context.vk;
914 var _this$props = this.props,
915 elementId = _this$props.elementId,
916 ownerId = _this$props.ownerId,
917 postId = _this$props.postId,
918 hash = _this$props.hash,
919 options = _this$props.options;
920 vk.Widgets.Post(elementId, ownerId, postId, hash, options);
921 }
922 }, {
923 key: "render",
924 value: function render() {
925 var elementId = this.props.elementId;
926 return React.createElement("div", {
927 id: elementId
928 });
929 }
930 }]);
931
932 return Post;
933}(React.Component);
934
935_defineProperty(Post, "contextType", VKContext);
936
937_defineProperty(Post, "defaultProps", {
938 elementId: "vk_post",
939 options: {}
940});
941
942var Recommended =
943/*#__PURE__*/
944function (_React$Component) {
945 _inherits(Recommended, _React$Component);
946
947 function Recommended() {
948 _classCallCheck(this, Recommended);
949
950 return _possibleConstructorReturn(this, _getPrototypeOf(Recommended).apply(this, arguments));
951 }
952
953 _createClass(Recommended, [{
954 key: "componentDidMount",
955 value: function componentDidMount() {
956 this.mount();
957 }
958 }, {
959 key: "mount",
960 value: function mount() {
961 var vk = this.context.vk;
962 var _this$props = this.props,
963 elementId = _this$props.elementId,
964 options = _this$props.options;
965 vk.Widgets.Recommended(elementId, options);
966 }
967 }, {
968 key: "render",
969 value: function render() {
970 var elementId = this.props.elementId;
971 return React.createElement("div", {
972 id: elementId
973 });
974 }
975 }]);
976
977 return Recommended;
978}(React.Component);
979
980_defineProperty(Recommended, "contextType", VKContext);
981
982_defineProperty(Recommended, "defaultProps", {
983 elementId: "vk_recommend",
984 options: {
985 limit: 5,
986 max: 20,
987 period: "week",
988 sort: "friend_like",
989 target: "parent"
990 }
991});
992
993var Subscribe =
994/*#__PURE__*/
995function (_React$Component) {
996 _inherits(Subscribe, _React$Component);
997
998 function Subscribe() {
999 _classCallCheck(this, Subscribe);
1000
1001 return _possibleConstructorReturn(this, _getPrototypeOf(Subscribe).apply(this, arguments));
1002 }
1003
1004 _createClass(Subscribe, [{
1005 key: "componentDidMount",
1006 value: function componentDidMount() {
1007 this.mount();
1008 }
1009 }, {
1010 key: "componentWillUnmount",
1011 value: function componentWillUnmount() {
1012 var vk = this.context.vk;
1013 vk.Observer.unsubscribe("widgets.subscribed");
1014 vk.Observer.unsubscribe("widgets.unsubscribed");
1015 }
1016 }, {
1017 key: "mount",
1018 value: function mount() {
1019 var vk = this.context.vk;
1020 var _this$props = this.props,
1021 elementId = _this$props.elementId,
1022 options = _this$props.options,
1023 ownerId = _this$props.ownerId,
1024 onSubscribe = _this$props.onSubscribe,
1025 onUnsubscribe = _this$props.onUnsubscribe;
1026 vk.Widgets.Subscribe(elementId, options, ownerId);
1027 vk.Observer.subscribe("widgets.subscribed", onSubscribe);
1028 vk.Observer.subscribe("widgets.unsubscribed", onUnsubscribe);
1029 }
1030 }, {
1031 key: "render",
1032 value: function render() {
1033 var elementId = this.props.elementId;
1034 return React.createElement("div", {
1035 id: elementId
1036 });
1037 }
1038 }]);
1039
1040 return Subscribe;
1041}(React.Component);
1042
1043_defineProperty(Subscribe, "contextType", VKContext);
1044
1045_defineProperty(Subscribe, "defaultProps", {
1046 elementId: "vk_subscribe",
1047 options: {
1048 mode: 0,
1049 soft: 0
1050 },
1051 onSubscribe: function onSubscribe() {},
1052 onUnsubscribe: function onUnsubscribe() {}
1053});
1054
1055var Post$1 =
1056/*#__PURE__*/
1057function (_React$Component) {
1058 _inherits(Post, _React$Component);
1059
1060 function Post() {
1061 _classCallCheck(this, Post);
1062
1063 return _possibleConstructorReturn(this, _getPrototypeOf(Post).apply(this, arguments));
1064 }
1065
1066 _createClass(Post, [{
1067 key: "componentDidMount",
1068 value: function componentDidMount() {
1069 this.mount();
1070 }
1071 }, {
1072 key: "mount",
1073 value: function mount() {
1074 var vk = this.context.vk;
1075 var _this$props = this.props,
1076 elementId = _this$props.elementId,
1077 articleUrl = _this$props.articleUrl;
1078 vk.Widgets.Article(elementId, articleUrl);
1079 }
1080 }, {
1081 key: "render",
1082 value: function render() {
1083 var elementId = this.props.elementId;
1084 return React.createElement("div", {
1085 id: elementId
1086 });
1087 }
1088 }]);
1089
1090 return Post;
1091}(React.Component);
1092
1093_defineProperty(Post$1, "contextType", VKContext);
1094
1095_defineProperty(Post$1, "defaultProps", {
1096 elementId: "vk_article"
1097});
1098
1099export default VK;
1100export { AllowMessagesFromCommunity, Application, Auth, Comments, CommentsBrowse, CommunityMessages, ContactUs, Group, Like, Playlist, Poll, Post, Recommended, Subscribe, Post$1 as Article };