@veltdev/react 1.0.50 → 1.0.51

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 (34) hide show
  1. package/cjs/index.js +423 -3
  2. package/cjs/index.js.map +1 -1
  3. package/cjs/types/components/SnippylyUserInviteTool/SnippylyUserInviteTool.d.ts +1 -0
  4. package/cjs/types/constants.d.ts +1 -1
  5. package/cjs/types/hooks/Client.d.ts +19 -7
  6. package/cjs/types/hooks/CommentElement.d.ts +24 -7
  7. package/cjs/types/hooks/CursorElement.d.ts +8 -2
  8. package/cjs/types/hooks/HuddleElement.d.ts +4 -0
  9. package/cjs/types/hooks/LiveStateSyncElement.d.ts +16 -3
  10. package/cjs/types/hooks/PresenceElement.d.ts +8 -2
  11. package/cjs/types/hooks/RecorderElement.d.ts +8 -2
  12. package/cjs/types/hooks/RewriterElement.d.ts +4 -1
  13. package/cjs/types/hooks/SelectionElement.d.ts +4 -1
  14. package/cjs/types/hooks/TagElement.d.ts +8 -2
  15. package/cjs/types/hooks/index.d.ts +10 -9
  16. package/cjs/types/index.d.ts +1 -0
  17. package/esm/index.js +398 -4
  18. package/esm/index.js.map +1 -1
  19. package/esm/types/components/SnippylyUserInviteTool/SnippylyUserInviteTool.d.ts +1 -0
  20. package/esm/types/constants.d.ts +1 -1
  21. package/esm/types/hooks/Client.d.ts +19 -7
  22. package/esm/types/hooks/CommentElement.d.ts +24 -7
  23. package/esm/types/hooks/CursorElement.d.ts +8 -2
  24. package/esm/types/hooks/HuddleElement.d.ts +4 -0
  25. package/esm/types/hooks/LiveStateSyncElement.d.ts +16 -3
  26. package/esm/types/hooks/PresenceElement.d.ts +8 -2
  27. package/esm/types/hooks/RecorderElement.d.ts +8 -2
  28. package/esm/types/hooks/RewriterElement.d.ts +4 -1
  29. package/esm/types/hooks/SelectionElement.d.ts +4 -1
  30. package/esm/types/hooks/TagElement.d.ts +8 -2
  31. package/esm/types/hooks/index.d.ts +10 -9
  32. package/esm/types/index.d.ts +1 -0
  33. package/index.d.ts +117 -2
  34. package/package.json +1 -1
package/cjs/index.js CHANGED
@@ -94,7 +94,7 @@ var loadVelt = function (callback, version, staging) {
94
94
  }
95
95
  };
96
96
 
97
- var VELT_SDK_VERSION = '1.0.57';
97
+ var VELT_SDK_VERSION = '1.0.60';
98
98
 
99
99
  var SnippylyProvider = function (props) {
100
100
  var apiKey = props.apiKey, user = props.user, config = props.config, documentId = props.documentId, language = props.language, translations = props.translations, autoTranslation = props.autoTranslation, onClientLoad = props.onClientLoad, children = props.children;
@@ -401,8 +401,8 @@ var SnippylyArrowTool = function (props) {
401
401
  };
402
402
 
403
403
  var SnippylyUserInviteTool = function (props) {
404
- var type = props.type, source = props.source, title = props.title, placeholder = props.placeholder, accessControlDropdown = props.accessControlDropdown;
405
- return (React__default["default"].createElement("velt-user-invite-tool", { type: type, source: source, title: title, placeholder: placeholder, "access-control-dropdown": [true, false].includes(accessControlDropdown) ? accessControlDropdown : undefined }));
404
+ var type = props.type, source = props.source, title = props.title, placeholder = props.placeholder, accessControlDropdown = props.accessControlDropdown, documentUserAccessList = props.documentUserAccessList;
405
+ return (React__default["default"].createElement("velt-user-invite-tool", { type: type, source: source, title: title, placeholder: placeholder, "access-control-dropdown": [true, false].includes(accessControlDropdown) ? accessControlDropdown : undefined, "document-user-access-list": [true, false].includes(documentUserAccessList) ? documentUserAccessList : undefined }));
406
406
  };
407
407
 
408
408
  var SnippylyUserRequestTool = function (props) {
@@ -431,6 +431,400 @@ var VeltVideoPlayer = function (props) {
431
431
  return (React__default["default"].createElement("velt-video-player", { src: src, "dark-mode": [true, false].includes(darkMode) ? (darkMode ? 'true' : 'false') : undefined, sync: [true, false].includes(sync) ? (sync ? 'true' : 'false') : undefined }));
432
432
  };
433
433
 
434
+ /**
435
+ * @beta This hook is in beta
436
+ */
437
+ function useClient() {
438
+ var client = useVeltClient().client;
439
+ var _a = React__default["default"].useState(), veltClient = _a[0], setVeltClient = _a[1];
440
+ React__default["default"].useEffect(function () {
441
+ if (!client || veltClient)
442
+ return;
443
+ setVeltClient(client);
444
+ }, [client, setVeltClient, veltClient]);
445
+ return veltClient;
446
+ }
447
+ /**
448
+ * @beta This hook is in beta
449
+ */
450
+ function useIdentify(user, userOptions) {
451
+ var client = useVeltClient().client;
452
+ React__default["default"].useEffect(function () {
453
+ client && client.identify(user, userOptions);
454
+ }, [client]);
455
+ }
456
+ /**
457
+ * @beta This hook is in beta
458
+ */
459
+ function useSetDocumentId(documentId) {
460
+ var client = useVeltClient().client;
461
+ React__default["default"].useEffect(function () {
462
+ client && client.setDocumentId(documentId);
463
+ }, [client]);
464
+ }
465
+ /**
466
+ * @beta This hook is in beta
467
+ */
468
+ function useSetLocation(location) {
469
+ var client = useVeltClient().client;
470
+ React__default["default"].useEffect(function () {
471
+ client && client.setLocation(location);
472
+ }, [client]);
473
+ }
474
+ /**
475
+ * @beta This hook is in beta
476
+ */
477
+ function useAddLocation(location) {
478
+ var client = useVeltClient().client;
479
+ React__default["default"].useEffect(function () {
480
+ client && client.addLocation(location);
481
+ }, [client]);
482
+ }
483
+
484
+ /**
485
+ * @beta This hook is in beta
486
+ */
487
+ function useCommentUtils() {
488
+ var _a = React__default["default"].useState(), commentElement = _a[0], setCommentElement = _a[1];
489
+ var client = useVeltClient().client;
490
+ React__default["default"].useEffect(function () {
491
+ if (!client || commentElement)
492
+ return;
493
+ var loadedCommentElement = client.getCommentElement();
494
+ setCommentElement(loadedCommentElement);
495
+ }, [client, setCommentElement, commentElement]);
496
+ return commentElement;
497
+ }
498
+ /**
499
+ * @beta This hook is in beta
500
+ */
501
+ function useCommentAnnotations(documentId, location) {
502
+ var commentElement = useCommentUtils();
503
+ var _a = React__default["default"].useState([]), data = _a[0], setData = _a[1];
504
+ React.useEffect(function () {
505
+ if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.getAllCommentAnnotations))
506
+ return;
507
+ var subscription = commentElement.getAllCommentAnnotations(documentId, location).subscribe(function (res) {
508
+ setData(res);
509
+ });
510
+ return function () {
511
+ subscription.unsubscribe();
512
+ };
513
+ }, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.getAllCommentAnnotations]);
514
+ return data;
515
+ }
516
+ /**
517
+ * @beta This hook is in beta
518
+ */
519
+ function useCommentModeState() {
520
+ var commentElement = useCommentUtils();
521
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
522
+ React.useEffect(function () {
523
+ if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.onCommentModeChange))
524
+ return;
525
+ var subscription = commentElement.onCommentModeChange().subscribe(function (res) {
526
+ setData(res);
527
+ });
528
+ return function () {
529
+ subscription.unsubscribe();
530
+ };
531
+ }, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.onCommentModeChange]);
532
+ return data;
533
+ }
534
+ /**
535
+ * @beta This hook is in beta
536
+ */
537
+ function useCommentAddHandler() {
538
+ var commentElement = useCommentUtils();
539
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
540
+ React.useEffect(function () {
541
+ if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.onCommentAdd))
542
+ return;
543
+ var subscription = commentElement.onCommentAdd().subscribe(function (res) {
544
+ setData(res);
545
+ });
546
+ return function () {
547
+ subscription.unsubscribe();
548
+ };
549
+ }, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.onCommentAdd]);
550
+ return data;
551
+ }
552
+ /**
553
+ * @beta This hook is in beta
554
+ */
555
+ function useCommentUpdateHandler() {
556
+ var commentElement = useCommentUtils();
557
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
558
+ React.useEffect(function () {
559
+ if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.onCommentUpdate))
560
+ return;
561
+ var subscription = commentElement.onCommentUpdate().subscribe(function (res) {
562
+ setData(res);
563
+ });
564
+ return function () {
565
+ subscription.unsubscribe();
566
+ };
567
+ }, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.onCommentUpdate]);
568
+ return data;
569
+ }
570
+ /**
571
+ * @beta This hook is in beta
572
+ */
573
+ function useCommentDialogSidebarClickHandler() {
574
+ var commentElement = useCommentUtils();
575
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
576
+ React.useEffect(function () {
577
+ if (!(commentElement === null || commentElement === void 0 ? void 0 : commentElement.onSidebarButtonOnCommentDialogClick))
578
+ return;
579
+ var subscription = commentElement.onSidebarButtonOnCommentDialogClick().subscribe(function (res) {
580
+ setData(res === undefined ? new Date().getTime() : res);
581
+ });
582
+ return function () {
583
+ subscription.unsubscribe();
584
+ };
585
+ }, [commentElement === null || commentElement === void 0 ? void 0 : commentElement.onSidebarButtonOnCommentDialogClick]);
586
+ return data;
587
+ }
588
+
589
+ /**
590
+ * @beta This hook is in beta
591
+ */
592
+ function useCursorUtils() {
593
+ var _a = React__default["default"].useState(), cursorElement = _a[0], setCursorElement = _a[1];
594
+ var client = useVeltClient().client;
595
+ React__default["default"].useEffect(function () {
596
+ if (!client || cursorElement)
597
+ return;
598
+ var loadedCursorElement = client.getCursorElement();
599
+ setCursorElement(loadedCursorElement);
600
+ }, [client, setCursorElement, cursorElement]);
601
+ return cursorElement;
602
+ }
603
+ /**
604
+ * @beta This hook is in beta
605
+ */
606
+ function useCursorUsers() {
607
+ var cursorElement = useCursorUtils();
608
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
609
+ React.useEffect(function () {
610
+ if (!cursorElement)
611
+ return;
612
+ var subscription = cursorElement.getOnlineUsersOnCurrentDocument().subscribe(function (res) {
613
+ setData(res);
614
+ });
615
+ return function () {
616
+ subscription.unsubscribe();
617
+ };
618
+ }, [cursorElement]);
619
+ return data;
620
+ }
621
+
622
+ /**
623
+ * @beta This hook is in beta
624
+ */
625
+ function useHuddleUtils() {
626
+ var _a = React__default["default"].useState(), huddleElement = _a[0], setHuddleElement = _a[1];
627
+ var client = useVeltClient().client;
628
+ React__default["default"].useEffect(function () {
629
+ if (!client || huddleElement)
630
+ return;
631
+ var loadedHuddleElement = client.getHuddleElement();
632
+ setHuddleElement(loadedHuddleElement);
633
+ }, [client, setHuddleElement, huddleElement]);
634
+ return huddleElement;
635
+ }
636
+
637
+ /**
638
+ * @beta This hook is in beta
639
+ */
640
+ function useLiveStateSyncUtils() {
641
+ var _a = React__default["default"].useState(), liveStateSyncElement = _a[0], setLiveStateSyncElement = _a[1];
642
+ var client = useVeltClient().client;
643
+ React__default["default"].useEffect(function () {
644
+ if (!client || liveStateSyncElement)
645
+ return;
646
+ var loadedLiveStateSyncElement = client.getLiveStateSyncElement();
647
+ setLiveStateSyncElement(loadedLiveStateSyncElement);
648
+ }, [client, setLiveStateSyncElement, liveStateSyncElement]);
649
+ return liveStateSyncElement;
650
+ }
651
+ /**
652
+ * @beta This hook is in beta
653
+ */
654
+ function useLiveStateData(liveStateDataId) {
655
+ var liveStateSyncElement = useLiveStateSyncUtils();
656
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
657
+ React.useEffect(function () {
658
+ if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData))
659
+ return;
660
+ var subscription = liveStateSyncElement.getLiveStateData(liveStateDataId).subscribe(function (res) {
661
+ setData(res);
662
+ });
663
+ return function () {
664
+ subscription.unsubscribe();
665
+ };
666
+ }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.getLiveStateData]);
667
+ return data;
668
+ }
669
+ /**
670
+ * @beta This hook is in beta
671
+ */
672
+ function useSetLiveStateData(liveStateDataId, liveStateData) {
673
+ var liveStateSyncElement = useLiveStateSyncUtils();
674
+ React__default["default"].useEffect(function () {
675
+ if (liveStateSyncElement && liveStateDataId && liveStateData) {
676
+ liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData(liveStateDataId, liveStateData);
677
+ }
678
+ }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.setLiveStateData]);
679
+ }
680
+ /**
681
+ * @beta This hook is in beta
682
+ */
683
+ function useUserEditorState() {
684
+ var liveStateSyncElement = useLiveStateSyncUtils();
685
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
686
+ React.useEffect(function () {
687
+ if (!(liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.isUserEditor))
688
+ return;
689
+ var subscription = liveStateSyncElement.isUserEditor().subscribe(function (res) {
690
+ setData(res);
691
+ });
692
+ return function () {
693
+ subscription.unsubscribe();
694
+ };
695
+ }, [liveStateSyncElement === null || liveStateSyncElement === void 0 ? void 0 : liveStateSyncElement.isUserEditor]);
696
+ return data;
697
+ }
698
+
699
+ /**
700
+ * @beta This hook is in beta
701
+ */
702
+ function usePresenceUtils() {
703
+ var _a = React__default["default"].useState(), presenceElement = _a[0], setPresenceElement = _a[1];
704
+ var client = useVeltClient().client;
705
+ React__default["default"].useEffect(function () {
706
+ if (!client || presenceElement)
707
+ return;
708
+ var loadedPresenceElement = client.getPresenceElement();
709
+ setPresenceElement(loadedPresenceElement);
710
+ }, [client, setPresenceElement, presenceElement]);
711
+ return presenceElement;
712
+ }
713
+ /**
714
+ * @beta This hook is in beta
715
+ */
716
+ function usePresenceUsers() {
717
+ var presenceElement = usePresenceUtils();
718
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
719
+ React.useEffect(function () {
720
+ if (!presenceElement)
721
+ return;
722
+ var subscription = presenceElement.getOnlineUsersOnCurrentDocument().subscribe(function (res) {
723
+ setData(res);
724
+ });
725
+ return function () {
726
+ subscription.unsubscribe();
727
+ };
728
+ }, [presenceElement]);
729
+ return data;
730
+ }
731
+
732
+ /**
733
+ * @beta This hook is in beta
734
+ */
735
+ function useRecorderUtils() {
736
+ var _a = React__default["default"].useState(), recorderElement = _a[0], setRecorderElement = _a[1];
737
+ var client = useVeltClient().client;
738
+ React__default["default"].useEffect(function () {
739
+ if (!client || recorderElement)
740
+ return;
741
+ var loadedRecorderElement = client.getRecorderElement();
742
+ setRecorderElement(loadedRecorderElement);
743
+ }, [client, setRecorderElement, recorderElement]);
744
+ return recorderElement;
745
+ }
746
+ /**
747
+ * @beta This hook is in beta
748
+ */
749
+ function useRecorderAddHandler() {
750
+ var recorderElement = useRecorderUtils();
751
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
752
+ React.useEffect(function () {
753
+ if (!recorderElement)
754
+ return;
755
+ var subscription = recorderElement.onRecordedData().subscribe(function (res) {
756
+ setData(res);
757
+ });
758
+ return function () {
759
+ subscription.unsubscribe();
760
+ };
761
+ }, [recorderElement]);
762
+ return data;
763
+ }
764
+
765
+ /**
766
+ * @beta This hook is in beta
767
+ */
768
+ function useAIRewriterUtils() {
769
+ var _a = React__default["default"].useState(), rewriterElement = _a[0], setRewriterElement = _a[1];
770
+ var client = useVeltClient().client;
771
+ React__default["default"].useEffect(function () {
772
+ if (!client || rewriterElement)
773
+ return;
774
+ var loadedRewriterElement = client.getRewriterElement();
775
+ setRewriterElement(loadedRewriterElement);
776
+ }, [client, setRewriterElement, rewriterElement]);
777
+ return rewriterElement;
778
+ }
779
+
780
+ /**
781
+ * @beta This hook is in beta
782
+ */
783
+ function useLiveSelectionUtils() {
784
+ var _a = React__default["default"].useState(), selectionElement = _a[0], setSelectionElement = _a[1];
785
+ var client = useVeltClient().client;
786
+ React__default["default"].useEffect(function () {
787
+ if (!client || selectionElement)
788
+ return;
789
+ var loadedSelectionElement = client.getSelectionElement();
790
+ setSelectionElement(loadedSelectionElement);
791
+ }, [client, setSelectionElement, selectionElement]);
792
+ return selectionElement;
793
+ }
794
+
795
+ /**
796
+ * @beta This hook is in beta
797
+ */
798
+ function useTagUtils() {
799
+ var _a = React__default["default"].useState(), tagElement = _a[0], setTagElement = _a[1];
800
+ var client = useVeltClient().client;
801
+ React__default["default"].useEffect(function () {
802
+ if (!client || tagElement)
803
+ return;
804
+ var loadedTagElement = client.getTagElement();
805
+ setTagElement(loadedTagElement);
806
+ }, [client, setTagElement, tagElement]);
807
+ return tagElement;
808
+ }
809
+ /**
810
+ * @beta This hook is in beta
811
+ */
812
+ function useTagAnnotations(documentId, location) {
813
+ var tagElement = useTagUtils();
814
+ var _a = React__default["default"].useState(), data = _a[0], setData = _a[1];
815
+ React.useEffect(function () {
816
+ if (!tagElement)
817
+ return;
818
+ var subscription = tagElement.getAllTagAnnotations(documentId, location).subscribe(function (res) {
819
+ setData(res);
820
+ });
821
+ return function () {
822
+ subscription.unsubscribe();
823
+ };
824
+ }, [tagElement]);
825
+ return data;
826
+ }
827
+
434
828
  exports.VeltArrowTool = SnippylyArrowTool;
435
829
  exports.VeltArrows = SnippylyArrows;
436
830
  exports.VeltCommentBubble = SnippylyCommentBubble;
@@ -453,5 +847,31 @@ exports.VeltTags = SnippylyTags;
453
847
  exports.VeltUserInviteTool = SnippylyUserInviteTool;
454
848
  exports.VeltUserRequestTool = SnippylyUserRequestTool;
455
849
  exports.VeltVideoPlayer = VeltVideoPlayer;
850
+ exports.useAIRewriterUtils = useAIRewriterUtils;
851
+ exports.useAddLocation = useAddLocation;
852
+ exports.useClient = useClient;
853
+ exports.useCommentAddHandler = useCommentAddHandler;
854
+ exports.useCommentAnnotations = useCommentAnnotations;
855
+ exports.useCommentDialogSidebarClickHandler = useCommentDialogSidebarClickHandler;
856
+ exports.useCommentModeState = useCommentModeState;
857
+ exports.useCommentUpdateHandler = useCommentUpdateHandler;
858
+ exports.useCommentUtils = useCommentUtils;
859
+ exports.useCursorUsers = useCursorUsers;
860
+ exports.useCursorUtils = useCursorUtils;
861
+ exports.useHuddleUtils = useHuddleUtils;
862
+ exports.useIdentify = useIdentify;
863
+ exports.useLiveSelectionUtils = useLiveSelectionUtils;
864
+ exports.useLiveStateData = useLiveStateData;
865
+ exports.useLiveStateSyncUtils = useLiveStateSyncUtils;
866
+ exports.usePresenceUsers = usePresenceUsers;
867
+ exports.usePresenceUtils = usePresenceUtils;
868
+ exports.useRecorderAddHandler = useRecorderAddHandler;
869
+ exports.useRecorderUtils = useRecorderUtils;
870
+ exports.useSetDocumentId = useSetDocumentId;
871
+ exports.useSetLiveStateData = useSetLiveStateData;
872
+ exports.useSetLocation = useSetLocation;
873
+ exports.useTagAnnotations = useTagAnnotations;
874
+ exports.useTagUtils = useTagUtils;
875
+ exports.useUserEditorState = useUserEditorState;
456
876
  exports.useVeltClient = useVeltClient;
457
877
  //# sourceMappingURL=index.js.map