@azure/communication-react 1.5.1-alpha-202303170014 → 1.5.1-alpha-202303220012

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 (37) hide show
  1. package/dist/dist-cjs/communication-react/index.js +325 -268
  2. package/dist/dist-cjs/communication-react/index.js.map +1 -1
  3. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
  4. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
  5. package/dist/dist-esm/react-components/src/components/HorizontalGallery.d.ts +4 -0
  6. package/dist/dist-esm/react-components/src/components/HorizontalGallery.js +19 -10
  7. package/dist/dist-esm/react-components/src/components/HorizontalGallery.js.map +1 -1
  8. package/dist/dist-esm/react-components/src/components/ResponsiveHorizontalGallery.d.ts +2 -1
  9. package/dist/dist-esm/react-components/src/components/ResponsiveHorizontalGallery.js +4 -40
  10. package/dist/dist-esm/react-components/src/components/ResponsiveHorizontalGallery.js.map +1 -1
  11. package/dist/dist-esm/react-components/src/components/ResponsiveVerticalGallery.d.ts +2 -0
  12. package/dist/dist-esm/react-components/src/components/ResponsiveVerticalGallery.js +4 -53
  13. package/dist/dist-esm/react-components/src/components/ResponsiveVerticalGallery.js.map +1 -1
  14. package/dist/dist-esm/react-components/src/components/VerticalGallery.d.ts +2 -0
  15. package/dist/dist-esm/react-components/src/components/VerticalGallery.js +15 -6
  16. package/dist/dist-esm/react-components/src/components/VerticalGallery.js.map +1 -1
  17. package/dist/dist-esm/react-components/src/components/VideoGallery/DefaultLayout.js +15 -4
  18. package/dist/dist-esm/react-components/src/components/VideoGallery/DefaultLayout.js.map +1 -1
  19. package/dist/dist-esm/react-components/src/components/VideoGallery/FloatingLocalVideoLayout.js +22 -9
  20. package/dist/dist-esm/react-components/src/components/VideoGallery/FloatingLocalVideoLayout.js.map +1 -1
  21. package/dist/dist-esm/react-components/src/components/VideoGallery/Layout.d.ts +1 -1
  22. package/dist/dist-esm/react-components/src/components/VideoGallery/Layout.js.map +1 -1
  23. package/dist/dist-esm/react-components/src/components/VideoGallery/OverflowGallery.d.ts +8 -7
  24. package/dist/dist-esm/react-components/src/components/VideoGallery/OverflowGallery.js +4 -4
  25. package/dist/dist-esm/react-components/src/components/VideoGallery/OverflowGallery.js.map +1 -1
  26. package/dist/dist-esm/react-components/src/components/VideoGallery/ScrollableHorizontalGallery.d.ts +2 -1
  27. package/dist/dist-esm/react-components/src/components/VideoGallery/ScrollableHorizontalGallery.js +8 -2
  28. package/dist/dist-esm/react-components/src/components/VideoGallery/ScrollableHorizontalGallery.js.map +1 -1
  29. package/dist/dist-esm/react-components/src/components/VideoGallery/styles/VideoGalleryResponsiveVerticalGallery.styles.d.ts +2 -0
  30. package/dist/dist-esm/react-components/src/components/VideoGallery/styles/VideoGalleryResponsiveVerticalGallery.styles.js +5 -3
  31. package/dist/dist-esm/react-components/src/components/VideoGallery/styles/VideoGalleryResponsiveVerticalGallery.styles.js.map +1 -1
  32. package/dist/dist-esm/react-components/src/components/VideoGallery/utils/OverflowGalleryUtils.d.ts +26 -0
  33. package/dist/dist-esm/react-components/src/components/VideoGallery/utils/OverflowGalleryUtils.js +93 -0
  34. package/dist/dist-esm/react-components/src/components/VideoGallery/utils/OverflowGalleryUtils.js.map +1 -0
  35. package/dist/dist-esm/react-components/src/components/VideoGallery.js +2 -1
  36. package/dist/dist-esm/react-components/src/components/VideoGallery.js.map +1 -1
  37. package/package.json +8 -8
@@ -162,7 +162,7 @@ const _toCommunicationIdentifier = (id) => {
162
162
  // Copyright (c) Microsoft Corporation.
163
163
  // Licensed under the MIT license.
164
164
  // GENERATED FILE. DO NOT EDIT MANUALLY.
165
- var telemetryVersion = '1.5.1-alpha-202303170014';
165
+ var telemetryVersion = '1.5.1-alpha-202303220012';
166
166
 
167
167
  // Copyright (c) Microsoft Corporation.
168
168
  /**
@@ -9443,24 +9443,33 @@ const DEFAULT_CHILDREN_PER_PAGE = 5;
9443
9443
  */
9444
9444
  const HorizontalGallery = (props) => {
9445
9445
  var _a, _b;
9446
- const { children, childrenPerPage = DEFAULT_CHILDREN_PER_PAGE, styles } = props;
9446
+ const { children, childrenPerPage = DEFAULT_CHILDREN_PER_PAGE, styles, onFetchTilesToRender } = props;
9447
9447
  const ids = useIdentifiers();
9448
9448
  const [page, setPage] = React.useState(0);
9449
9449
  const numberOfChildren = React__default['default'].Children.count(children);
9450
9450
  const lastPage = Math.ceil(numberOfChildren / childrenPerPage) - 1;
9451
- const paginatedChildren = React.useMemo(() => {
9452
- return bucketize(React__default['default'].Children.toArray(children), childrenPerPage);
9453
- }, [children, childrenPerPage]);
9454
- // If children per page is 0 or less return empty element
9455
- if (childrenPerPage <= 0) {
9456
- return React__default['default'].createElement(React__default['default'].Fragment, null);
9457
- }
9451
+ const indexesArray = React.useMemo(() => {
9452
+ return bucketize([...Array(numberOfChildren).keys()], childrenPerPage);
9453
+ }, [numberOfChildren, childrenPerPage]);
9454
+ React.useEffect(() => {
9455
+ if (onFetchTilesToRender && indexesArray) {
9456
+ onFetchTilesToRender(indexesArray[page]);
9457
+ }
9458
+ }, [indexesArray, onFetchTilesToRender, page]);
9458
9459
  const firstIndexOfCurrentPage = page * childrenPerPage;
9459
9460
  const clippedPage = firstIndexOfCurrentPage < numberOfChildren - 1 ? page : lastPage;
9460
- const childrenOnCurrentPage = paginatedChildren[clippedPage];
9461
+ const childrenOnCurrentPage = React.useMemo(() => {
9462
+ return indexesArray[clippedPage].map((index) => {
9463
+ return React__default['default'].Children.toArray(children)[index];
9464
+ });
9465
+ }, [indexesArray, clippedPage, children]);
9461
9466
  const showButtons = numberOfChildren > childrenPerPage;
9462
9467
  const disablePreviousButton = page === 0;
9463
9468
  const disableNextButton = page === lastPage;
9469
+ // If children per page is 0 or less return empty element
9470
+ if (childrenPerPage <= 0) {
9471
+ return React__default['default'].createElement(React__default['default'].Fragment, null);
9472
+ }
9464
9473
  return (React__default['default'].createElement(react.Stack, { horizontal: true, className: react.mergeStyles(rootStyle$1, (_a = props.styles) === null || _a === void 0 ? void 0 : _a.root) },
9465
9474
  showButtons && (React__default['default'].createElement(HorizontalGalleryNavigationButton, { key: "previous-nav-button", icon: React__default['default'].createElement(react.Icon, { iconName: "HorizontalGalleryLeftButton" }), styles: styles === null || styles === void 0 ? void 0 : styles.previousButton, onClick: () => setPage(Math.max(0, Math.min(lastPage, page - 1))), disabled: disablePreviousButton, identifier: ids.overflowGalleryLeftNavButton })),
9466
9475
  React__default['default'].createElement(react.Stack, { horizontal: true, className: react.mergeStyles(childrenContainerStyle$1, { '> *': (_b = props.styles) === null || _b === void 0 ? void 0 : _b.children }) }, childrenOnCurrentPage),
@@ -9471,224 +9480,6 @@ const HorizontalGalleryNavigationButton = (props) => {
9471
9480
  return (React__default['default'].createElement(react.DefaultButton, { className: react.mergeStyles(leftRightButtonStyles$1(theme), props.styles), onClick: props.onClick, disabled: props.disabled, "data-ui-id": props.identifier }, props.icon));
9472
9481
  };
9473
9482
 
9474
- // Copyright (c) Microsoft Corporation.
9475
- /**
9476
- * Wrapped HorizontalGallery that adjusts the number of items per page based on the
9477
- * available width obtained from a ResizeObserver, width per child, gap width, and button width
9478
- */
9479
- const ResponsiveHorizontalGallery = (props) => {
9480
- const { childWidthRem, gapWidthRem, buttonWidthRem = 0 } = props;
9481
- const containerRef = React.useRef(null);
9482
- const containerWidth = _useContainerWidth(containerRef);
9483
- const leftPadding = containerRef.current ? parseFloat(getComputedStyle(containerRef.current).paddingLeft) : 0;
9484
- const rightPadding = containerRef.current ? parseFloat(getComputedStyle(containerRef.current).paddingRight) : 0;
9485
- const childrenPerPage = calculateChildrenPerPage$1({
9486
- numberOfChildren: React__default['default'].Children.count(props.children),
9487
- containerWidth: (containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0) - leftPadding - rightPadding,
9488
- childWidthRem,
9489
- gapWidthRem,
9490
- buttonWidthRem
9491
- });
9492
- return (React__default['default'].createElement("div", { "data-ui-id": "responsive-horizontal-gallery", ref: containerRef, className: react.mergeStyles(props.containerStyles) },
9493
- React__default['default'].createElement(HorizontalGallery, { childrenPerPage: childrenPerPage, styles: props.horizontalGalleryStyles }, props.children)));
9494
- };
9495
- /**
9496
- * Helper function to calculate children per page for HorizontalGallery based on width of container, child, buttons, and
9497
- * gaps in between
9498
- */
9499
- const calculateChildrenPerPage$1 = (args) => {
9500
- const { numberOfChildren, containerWidth, buttonWidthRem, childWidthRem, gapWidthRem } = args;
9501
- const childWidth = _convertRemToPx(childWidthRem);
9502
- const gapWidth = _convertRemToPx(gapWidthRem);
9503
- /** First check how many children can fit in containerWidth.
9504
- * __________________________________
9505
- * | || |
9506
- * | || |
9507
- * |________________||________________|
9508
- * <-----------containerWidth--------->
9509
- * containerWidth = n * childWidth + (n - 1) * gapWidth. Isolate n and take the floor.
9510
- */
9511
- const numberOfChildrenInContainer = Math.floor((containerWidth + gapWidth) / (childWidth + gapWidth));
9512
- // If all children fit then return numberOfChildrenInContainer
9513
- if (numberOfChildren <= numberOfChildrenInContainer) {
9514
- return numberOfChildrenInContainer;
9515
- }
9516
- const buttonWidth = _convertRemToPx(buttonWidthRem);
9517
- /** We know we need to paginate. So we need to subtract the buttonWidth twice and gapWidth twice from
9518
- * containerWidth to compute childrenSpace
9519
- * <-----------containerWidth--------->
9520
- * __________________________________
9521
- * | || || || |
9522
- * |<|| || ||>|
9523
- * |_||_____________||_____________||_|
9524
- * <-------childrenSpace------>
9525
- */
9526
- const childrenSpace = containerWidth - 2 * buttonWidth - 2 * gapWidth;
9527
- // Now that we have childrenSpace width we can figure out how many children can fit in childrenSpace.
9528
- // childrenSpace = n * childWidth + (n - 1) * gapWidth. Isolate n and take the floor.
9529
- return Math.floor((childrenSpace + gapWidth) / (childWidth + gapWidth));
9530
- };
9531
-
9532
- // Copyright (c) Microsoft Corporation.
9533
- // Licensed under the MIT license.
9534
- /**
9535
- * Vertical Gallery gap size in rem between tiles and buttons
9536
- *
9537
- * @private
9538
- */
9539
- const VERTICAL_GALLERY_GAP = 0.5;
9540
- /**
9541
- * @private
9542
- */
9543
- const childrenContainerStyle = (pageControlBarHeight) => {
9544
- return {
9545
- width: '100%',
9546
- height: `calc(100% - ${pageControlBarHeight + VERTICAL_GALLERY_GAP}rem)`,
9547
- gap: `${VERTICAL_GALLERY_GAP}rem`
9548
- };
9549
- };
9550
- /**
9551
- * @private
9552
- */
9553
- const rootStyle = {
9554
- height: '100%',
9555
- width: '100%',
9556
- gap: `${VERTICAL_GALLERY_GAP}rem`,
9557
- position: 'relative'
9558
- };
9559
- /**
9560
- * @private
9561
- */
9562
- const pageNavigationControlBarContainerStyle = {
9563
- height: '2rem',
9564
- width: '100%',
9565
- position: 'absolute',
9566
- bottom: '0'
9567
- };
9568
- /**
9569
- * @private
9570
- */
9571
- const leftRightButtonStyles = (theme) => {
9572
- return {
9573
- background: 'none',
9574
- padding: 0,
9575
- height: 'auto',
9576
- borderRadius: theme.effects.roundedCorner4,
9577
- border: 'none',
9578
- minWidth: '2rem'
9579
- };
9580
- };
9581
- /**
9582
- * @private
9583
- */
9584
- const participantPageCounter = {
9585
- lineHeight: '2rem',
9586
- width: '100%',
9587
- textAlign: 'center'
9588
- };
9589
- /**
9590
- * @private
9591
- */
9592
- const navIconStyles = {
9593
- root: {
9594
- lineHeight: '0'
9595
- }
9596
- };
9597
-
9598
- // Copyright (c) Microsoft Corporation.
9599
- /**
9600
- * VerticalGallery is a overflow gallery for participants in the {@link VideoGallery} component. Stacks
9601
- * participants on the Y-axis of the VideoGallery for better use of horizontal space.
9602
- *
9603
- * @beta
9604
- */
9605
- const VerticalGallery = (props) => {
9606
- const { children, styles, childrenPerPage } = props;
9607
- const [page, setPage] = React.useState(1);
9608
- const [buttonState, setButtonState] = React.useState({ previous: true, next: true });
9609
- /* @conditional-compile-remove(vertical-gallery) */
9610
- const ids = useIdentifiers();
9611
- const numberOfChildren = React__default['default'].Children.count(children);
9612
- const lastPage = Math.ceil(numberOfChildren / childrenPerPage);
9613
- const paginatedChildren = React.useMemo(() => {
9614
- return bucketize(React__default['default'].Children.toArray(children), childrenPerPage);
9615
- }, [children, childrenPerPage]);
9616
- const firstIndexOfCurrentPage = (page - 1) * childrenPerPage;
9617
- const clippedPage = firstIndexOfCurrentPage < numberOfChildren - 1 ? page : lastPage;
9618
- const childrenOnCurrentPage = paginatedChildren[clippedPage - 1];
9619
- const showButtons = numberOfChildren > childrenPerPage;
9620
- const onPreviousButtonClick = () => {
9621
- setPage(page - 1);
9622
- };
9623
- const onNextButtonClick = () => {
9624
- setPage(page + 1);
9625
- };
9626
- if (page > lastPage && lastPage > 0) {
9627
- setPage(lastPage);
9628
- }
9629
- React.useEffect(() => {
9630
- if (page > 1 && page < lastPage && showButtons) {
9631
- // we are somewhere in between first and last pages.
9632
- setButtonState({ previous: false, next: false });
9633
- }
9634
- else if (page === 1 && showButtons) {
9635
- // we are on the first page.
9636
- setButtonState({ previous: true, next: false });
9637
- }
9638
- else if (page === lastPage && showButtons) {
9639
- // we are on the last page.
9640
- setButtonState({ previous: false, next: true });
9641
- }
9642
- }, [page, numberOfChildren, lastPage, showButtons]);
9643
- const childContainerStyle = React.useMemo(() => {
9644
- return { root: childrenContainerStyle(2) };
9645
- }, []);
9646
- const childrenStyles = React.useMemo(() => {
9647
- return { root: styles === null || styles === void 0 ? void 0 : styles.children };
9648
- }, [styles === null || styles === void 0 ? void 0 : styles.children]);
9649
- if (childrenPerPage <= 0) {
9650
- return React__default['default'].createElement(React__default['default'].Fragment, null);
9651
- }
9652
- return (React__default['default'].createElement(react.Stack, { className: react.mergeStyles(rootStyle, styles === null || styles === void 0 ? void 0 : styles.root) },
9653
- React__default['default'].createElement(react.Stack, { styles: childContainerStyle }, childrenOnCurrentPage.map((child, i) => {
9654
- return (React__default['default'].createElement(react.Stack.Item, { key: i, styles: childrenStyles, "data-ui-id": ids.verticalGalleryVideoTile }, child));
9655
- })),
9656
- showButtons && (React__default['default'].createElement(VerticalGalleryControlBar, { buttonsDisabled: buttonState, onPreviousButtonClick: onPreviousButtonClick, onNextButtonClick: onNextButtonClick, totalPages: lastPage, currentPage: page }))));
9657
- };
9658
- const VerticalGalleryControlBar = (props) => {
9659
- const { onNextButtonClick, onPreviousButtonClick, buttonsDisabled, currentPage, totalPages, styles } = props;
9660
- const theme = useTheme();
9661
- /* @conditional-compile-remove(vertical-gallery) */
9662
- const ids = useIdentifiers();
9663
- /* @conditional-compile-remove(vertical-gallery) */
9664
- const strings = useLocale$1().strings.VerticalGallery;
9665
- const pageCounterContainerStyles = React.useMemo(() => {
9666
- return react.mergeStyles(pageNavigationControlBarContainerStyle, styles === null || styles === void 0 ? void 0 : styles.root);
9667
- }, [styles === null || styles === void 0 ? void 0 : styles.root]);
9668
- const previousButtonSyles = React.useMemo(() => {
9669
- return react.mergeStyles(leftRightButtonStyles(theme), styles === null || styles === void 0 ? void 0 : styles.previousButton);
9670
- }, [styles === null || styles === void 0 ? void 0 : styles.previousButton, theme]);
9671
- const pageCounterStyles = React.useMemo(() => {
9672
- return react.mergeStyles(participantPageCounter, styles === null || styles === void 0 ? void 0 : styles.counter);
9673
- }, [styles === null || styles === void 0 ? void 0 : styles.counter]);
9674
- const nextButtonsStyles = React.useMemo(() => {
9675
- return react.mergeStyles(leftRightButtonStyles(theme), styles === null || styles === void 0 ? void 0 : styles.nextButton);
9676
- }, [styles === null || styles === void 0 ? void 0 : styles.nextButton, theme]);
9677
- const controlBarSpacing = { childrenGap: '0.5rem' };
9678
- return (React__default['default'].createElement(react.Stack, { horizontalAlign: "center", tokens: controlBarSpacing, horizontal: true, className: pageCounterContainerStyles },
9679
- React__default['default'].createElement(react.DefaultButton, { className: previousButtonSyles, onClick: onPreviousButtonClick, disabled: buttonsDisabled === null || buttonsDisabled === void 0 ? void 0 : buttonsDisabled.previous,
9680
- /* @conditional-compile-remove(vertical-gallery) */
9681
- ariaLabel: strings.leftNavButtonAriaLabel, "data-ui-id": ids.overflowGalleryLeftNavButton },
9682
- React__default['default'].createElement(react.Icon, { iconName: "VerticalGalleryLeftButton", styles: navIconStyles })),
9683
- React__default['default'].createElement(react.Text
9684
- /* @conditional-compile-remove(vertical-gallery) */
9685
- , { "data-ui-id": ids.verticalGalleryPageCounter, className: pageCounterStyles }, `${currentPage} / ${totalPages}`),
9686
- React__default['default'].createElement(react.DefaultButton, { className: nextButtonsStyles, onClick: onNextButtonClick, disabled: buttonsDisabled === null || buttonsDisabled === void 0 ? void 0 : buttonsDisabled.next,
9687
- /* @conditional-compile-remove(vertical-gallery) */
9688
- ariaLabel: strings.rightNavButtonAriaLabel, "data-ui-id": ids.overflowGalleryRightNavButton },
9689
- React__default['default'].createElement(react.Icon, { iconName: "VerticalGalleryRightButton", styles: navIconStyles }))));
9690
- };
9691
-
9692
9483
  // Copyright (c) Microsoft Corporation.
9693
9484
  /**
9694
9485
  * @private
@@ -9807,26 +9598,28 @@ const VERTICAL_GALLERY_TILE_SIZE_REM = { minHeight: 6.75, maxHeight: 11, width:
9807
9598
  *
9808
9599
  * width is being increased by 1rem to account for the gap width desired for the VerticalGallery.
9809
9600
  *
9601
+ * Add 1.5 rem on width to account for horizontal padding
9602
+ *
9810
9603
  * @param shouldFloatLocalVideo whether rendered in floating layout or not
9811
9604
  * @returns Style set for VerticalGallery container.
9812
9605
  */
9813
9606
  const verticalGalleryContainerStyle = (shouldFloatLocalVideo, isNarrow, isShort) => {
9814
9607
  return isNarrow && isShort
9815
9608
  ? {
9816
- width: `${SHORT_VERTICAL_GALLERY_TILE_SIZE_REM.width}rem`,
9609
+ width: `${SHORT_VERTICAL_GALLERY_TILE_SIZE_REM.width + 1.5}rem`,
9817
9610
  height: shouldFloatLocalVideo ? `calc(100% - ${_pxToRem(SMALL_FLOATING_MODAL_SIZE_PX.height)})` : '100%',
9818
9611
  paddingBottom: '0.5rem'
9819
9612
  }
9820
9613
  : !isNarrow && isShort
9821
9614
  ? {
9822
- width: `${SHORT_VERTICAL_GALLERY_TILE_SIZE_REM.width}rem`,
9615
+ width: `${SHORT_VERTICAL_GALLERY_TILE_SIZE_REM.width + 1.5}rem`,
9823
9616
  height: shouldFloatLocalVideo
9824
9617
  ? `calc(100% - ${_pxToRem(SHORT_VERTICAL_GALLERY_FLOATING_MODAL_SIZE_PX.height)})`
9825
9618
  : '100%',
9826
9619
  paddingBottom: '0.5rem'
9827
9620
  }
9828
9621
  : {
9829
- width: `${VERTICAL_GALLERY_TILE_SIZE_REM.width}rem`,
9622
+ width: `${VERTICAL_GALLERY_TILE_SIZE_REM.width + 1.5}rem`,
9830
9623
  height: shouldFloatLocalVideo
9831
9624
  ? `calc(100% - ${_pxToRem(VERTICAL_GALLERY_FLOATING_MODAL_SIZE_PX.height)})`
9832
9625
  : '100%',
@@ -9864,32 +9657,49 @@ const verticalGalleryStyle = (isShort) => {
9864
9657
 
9865
9658
  // Copyright (c) Microsoft Corporation.
9866
9659
  /**
9867
- * Responsive container for the VerticalGallery Component. Performs calculations for number of children
9868
- * for the VerticalGallery
9869
- * @param props
9660
+ * Helper function to calculate children per page for HorizontalGallery based on width of container, child, buttons, and
9661
+ * gaps in between
9870
9662
  *
9871
- * @beta
9663
+ * @private
9872
9664
  */
9873
- const ResponsiveVerticalGallery = (props) => {
9874
- const { children, containerStyles, verticalGalleryStyles, gapHeightRem, controlBarHeightRem, isShort } = props;
9875
- const containerRef = React.useRef(null);
9876
- const containerHeight = _useContainerHeight(containerRef);
9877
- const topPadding = containerRef.current ? parseFloat(getComputedStyle(containerRef.current).paddingTop) : 0;
9878
- const bottomPadding = containerRef.current ? parseFloat(getComputedStyle(containerRef.current).paddingBottom) : 0;
9879
- const childrenPerPage = calculateChildrenPerPage({
9880
- numberOfChildren: React__default['default'].Children.count(children),
9881
- containerHeight: (containerHeight !== null && containerHeight !== void 0 ? containerHeight : 0) - topPadding - bottomPadding,
9882
- gapHeightRem,
9883
- controlBarHeight: controlBarHeightRem !== null && controlBarHeightRem !== void 0 ? controlBarHeightRem : 2,
9884
- isShort: isShort !== null && isShort !== void 0 ? isShort : false
9885
- });
9886
- return (React__default['default'].createElement("div", { "data-ui-id": "responsive-vertical-gallery", ref: containerRef, className: react.mergeStyles(containerStyles) },
9887
- React__default['default'].createElement(VerticalGallery, { childrenPerPage: childrenPerPage, styles: verticalGalleryStyles }, children)));
9665
+ const calculateHorizontalChildrenPerPage = (args) => {
9666
+ const { numberOfChildren, containerWidth, buttonWidthRem, childWidthRem, gapWidthRem } = args;
9667
+ const childWidth = _convertRemToPx(childWidthRem);
9668
+ const gapWidth = _convertRemToPx(gapWidthRem);
9669
+ /** First check how many children can fit in containerWidth.
9670
+ * __________________________________
9671
+ * | || |
9672
+ * | || |
9673
+ * |________________||________________|
9674
+ * <-----------containerWidth--------->
9675
+ * containerWidth = n * childWidth + (n - 1) * gapWidth. Isolate n and take the floor.
9676
+ */
9677
+ const numberOfChildrenInContainer = Math.floor((containerWidth + gapWidth) / (childWidth + gapWidth));
9678
+ // If all children fit then return numberOfChildrenInContainer
9679
+ if (numberOfChildren <= numberOfChildrenInContainer) {
9680
+ return numberOfChildrenInContainer;
9681
+ }
9682
+ const buttonWidth = _convertRemToPx(buttonWidthRem);
9683
+ /** We know we need to paginate. So we need to subtract the buttonWidth twice and gapWidth twice from
9684
+ * containerWidth to compute childrenSpace
9685
+ * <-----------containerWidth--------->
9686
+ * __________________________________
9687
+ * | || || || |
9688
+ * |<|| || ||>|
9689
+ * |_||_____________||_____________||_|
9690
+ * <-------childrenSpace------>
9691
+ */
9692
+ const childrenSpace = containerWidth - 2 * buttonWidth - 2 * gapWidth;
9693
+ // Now that we have childrenSpace width we can figure out how many children can fit in childrenSpace.
9694
+ // childrenSpace = n * childWidth + (n - 1) * gapWidth. Isolate n and take the floor.
9695
+ return Math.max(Math.floor((childrenSpace + gapWidth) / (childWidth + gapWidth)), 1);
9888
9696
  };
9889
9697
  /**
9890
9698
  * Helper function to find the number of children for the VerticalGallery on each page.
9699
+ *
9700
+ * @private
9891
9701
  */
9892
- const calculateChildrenPerPage = (args) => {
9702
+ const calculateVerticalChildrenPerPage = (args) => {
9893
9703
  const { numberOfChildren, containerHeight, gapHeightRem, controlBarHeight, isShort } = args;
9894
9704
  const childMinHeightPx = _convertRemToPx(isShort ? SHORT_VERTICAL_GALLERY_TILE_SIZE_REM.minHeight : VERTICAL_GALLERY_TILE_SIZE_REM.minHeight);
9895
9705
  const gapHeightPx = _convertRemToPx(gapHeightRem);
@@ -9935,6 +9745,222 @@ const calculateChildrenPerPage = (args) => {
9935
9745
  return Math.max(Math.floor((childSpace + gapHeightPx) / (childMinHeightPx + gapHeightPx)), 1);
9936
9746
  };
9937
9747
 
9748
+ // Copyright (c) Microsoft Corporation.
9749
+ /**
9750
+ * Wrapped HorizontalGallery that adjusts the number of items per page based on the
9751
+ * available width obtained from a ResizeObserver, width per child, gap width, and button width
9752
+ */
9753
+ const ResponsiveHorizontalGallery = (props) => {
9754
+ const { childWidthRem, gapWidthRem, buttonWidthRem = 0, onFetchTilesToRender } = props;
9755
+ const containerRef = React.useRef(null);
9756
+ const containerWidth = _useContainerWidth(containerRef);
9757
+ const leftPadding = containerRef.current ? parseFloat(getComputedStyle(containerRef.current).paddingLeft) : 0;
9758
+ const rightPadding = containerRef.current ? parseFloat(getComputedStyle(containerRef.current).paddingRight) : 0;
9759
+ const childrenPerPage = calculateHorizontalChildrenPerPage({
9760
+ numberOfChildren: React__default['default'].Children.count(props.children),
9761
+ containerWidth: (containerWidth !== null && containerWidth !== void 0 ? containerWidth : 0) - leftPadding - rightPadding,
9762
+ childWidthRem,
9763
+ gapWidthRem,
9764
+ buttonWidthRem
9765
+ });
9766
+ return (React__default['default'].createElement("div", { "data-ui-id": "responsive-horizontal-gallery", ref: containerRef, className: react.mergeStyles(props.containerStyles) },
9767
+ React__default['default'].createElement(HorizontalGallery, { childrenPerPage: childrenPerPage, styles: props.horizontalGalleryStyles, onFetchTilesToRender: onFetchTilesToRender }, props.children)));
9768
+ };
9769
+
9770
+ // Copyright (c) Microsoft Corporation.
9771
+ // Licensed under the MIT license.
9772
+ /**
9773
+ * Vertical Gallery gap size in rem between tiles and buttons
9774
+ *
9775
+ * @private
9776
+ */
9777
+ const VERTICAL_GALLERY_GAP = 0.5;
9778
+ /**
9779
+ * @private
9780
+ */
9781
+ const childrenContainerStyle = (pageControlBarHeight) => {
9782
+ return {
9783
+ width: '100%',
9784
+ height: `calc(100% - ${pageControlBarHeight + VERTICAL_GALLERY_GAP}rem)`,
9785
+ gap: `${VERTICAL_GALLERY_GAP}rem`
9786
+ };
9787
+ };
9788
+ /**
9789
+ * @private
9790
+ */
9791
+ const rootStyle = {
9792
+ height: '100%',
9793
+ width: '100%',
9794
+ gap: `${VERTICAL_GALLERY_GAP}rem`,
9795
+ position: 'relative'
9796
+ };
9797
+ /**
9798
+ * @private
9799
+ */
9800
+ const pageNavigationControlBarContainerStyle = {
9801
+ height: '2rem',
9802
+ width: '100%',
9803
+ position: 'absolute',
9804
+ bottom: '0'
9805
+ };
9806
+ /**
9807
+ * @private
9808
+ */
9809
+ const leftRightButtonStyles = (theme) => {
9810
+ return {
9811
+ background: 'none',
9812
+ padding: 0,
9813
+ height: 'auto',
9814
+ borderRadius: theme.effects.roundedCorner4,
9815
+ border: 'none',
9816
+ minWidth: '2rem'
9817
+ };
9818
+ };
9819
+ /**
9820
+ * @private
9821
+ */
9822
+ const participantPageCounter = {
9823
+ lineHeight: '2rem',
9824
+ width: '100%',
9825
+ textAlign: 'center'
9826
+ };
9827
+ /**
9828
+ * @private
9829
+ */
9830
+ const navIconStyles = {
9831
+ root: {
9832
+ lineHeight: '0'
9833
+ }
9834
+ };
9835
+
9836
+ // Copyright (c) Microsoft Corporation.
9837
+ /**
9838
+ * VerticalGallery is a overflow gallery for participants in the {@link VideoGallery} component. Stacks
9839
+ * participants on the Y-axis of the VideoGallery for better use of horizontal space.
9840
+ *
9841
+ * @beta
9842
+ */
9843
+ const VerticalGallery = (props) => {
9844
+ const { children, styles, childrenPerPage, onFetchTilesToRender } = props;
9845
+ const [page, setPage] = React.useState(1);
9846
+ const [buttonState, setButtonState] = React.useState({ previous: true, next: true });
9847
+ /* @conditional-compile-remove(vertical-gallery) */
9848
+ const ids = useIdentifiers();
9849
+ const numberOfChildren = React__default['default'].Children.count(children);
9850
+ const lastPage = Math.ceil(numberOfChildren / childrenPerPage);
9851
+ const indexesArray = React.useMemo(() => {
9852
+ return bucketize([...Array(numberOfChildren).keys()], childrenPerPage);
9853
+ }, [numberOfChildren, childrenPerPage]);
9854
+ React.useEffect(() => {
9855
+ if (onFetchTilesToRender && indexesArray) {
9856
+ onFetchTilesToRender(indexesArray[page - 1]);
9857
+ }
9858
+ }, [indexesArray, onFetchTilesToRender, page]);
9859
+ const firstIndexOfCurrentPage = (page - 1) * childrenPerPage;
9860
+ const clippedPage = firstIndexOfCurrentPage < numberOfChildren - 1 ? page : lastPage;
9861
+ const childrenOnCurrentPage = React.useMemo(() => {
9862
+ return indexesArray[clippedPage - 1].map((index) => {
9863
+ return React__default['default'].Children.toArray(children)[index];
9864
+ });
9865
+ }, [indexesArray, clippedPage, children]);
9866
+ const showButtons = numberOfChildren > childrenPerPage;
9867
+ const onPreviousButtonClick = () => {
9868
+ setPage(page - 1);
9869
+ };
9870
+ const onNextButtonClick = () => {
9871
+ setPage(page + 1);
9872
+ };
9873
+ if (page > lastPage && lastPage > 0) {
9874
+ setPage(lastPage);
9875
+ }
9876
+ React.useEffect(() => {
9877
+ if (page > 1 && page < lastPage && showButtons) {
9878
+ // we are somewhere in between first and last pages.
9879
+ setButtonState({ previous: false, next: false });
9880
+ }
9881
+ else if (page === 1 && showButtons) {
9882
+ // we are on the first page.
9883
+ setButtonState({ previous: true, next: false });
9884
+ }
9885
+ else if (page === lastPage && showButtons) {
9886
+ // we are on the last page.
9887
+ setButtonState({ previous: false, next: true });
9888
+ }
9889
+ }, [page, numberOfChildren, lastPage, showButtons]);
9890
+ const childContainerStyle = React.useMemo(() => {
9891
+ return { root: childrenContainerStyle(2) };
9892
+ }, []);
9893
+ const childrenStyles = React.useMemo(() => {
9894
+ return { root: styles === null || styles === void 0 ? void 0 : styles.children };
9895
+ }, [styles === null || styles === void 0 ? void 0 : styles.children]);
9896
+ if (childrenPerPage <= 0) {
9897
+ return React__default['default'].createElement(React__default['default'].Fragment, null);
9898
+ }
9899
+ return (React__default['default'].createElement(react.Stack, { className: react.mergeStyles(rootStyle, styles === null || styles === void 0 ? void 0 : styles.root) },
9900
+ React__default['default'].createElement(react.Stack, { styles: childContainerStyle }, childrenOnCurrentPage === null || childrenOnCurrentPage === void 0 ? void 0 : childrenOnCurrentPage.map((child, i) => {
9901
+ return (React__default['default'].createElement(react.Stack.Item, { key: i, styles: childrenStyles, "data-ui-id": ids.verticalGalleryVideoTile }, child));
9902
+ })),
9903
+ showButtons && (React__default['default'].createElement(VerticalGalleryControlBar, { buttonsDisabled: buttonState, onPreviousButtonClick: onPreviousButtonClick, onNextButtonClick: onNextButtonClick, totalPages: lastPage, currentPage: page }))));
9904
+ };
9905
+ const VerticalGalleryControlBar = (props) => {
9906
+ const { onNextButtonClick, onPreviousButtonClick, buttonsDisabled, currentPage, totalPages, styles } = props;
9907
+ const theme = useTheme();
9908
+ /* @conditional-compile-remove(vertical-gallery) */
9909
+ const ids = useIdentifiers();
9910
+ /* @conditional-compile-remove(vertical-gallery) */
9911
+ const strings = useLocale$1().strings.VerticalGallery;
9912
+ const pageCounterContainerStyles = React.useMemo(() => {
9913
+ return react.mergeStyles(pageNavigationControlBarContainerStyle, styles === null || styles === void 0 ? void 0 : styles.root);
9914
+ }, [styles === null || styles === void 0 ? void 0 : styles.root]);
9915
+ const previousButtonSyles = React.useMemo(() => {
9916
+ return react.mergeStyles(leftRightButtonStyles(theme), styles === null || styles === void 0 ? void 0 : styles.previousButton);
9917
+ }, [styles === null || styles === void 0 ? void 0 : styles.previousButton, theme]);
9918
+ const pageCounterStyles = React.useMemo(() => {
9919
+ return react.mergeStyles(participantPageCounter, styles === null || styles === void 0 ? void 0 : styles.counter);
9920
+ }, [styles === null || styles === void 0 ? void 0 : styles.counter]);
9921
+ const nextButtonsStyles = React.useMemo(() => {
9922
+ return react.mergeStyles(leftRightButtonStyles(theme), styles === null || styles === void 0 ? void 0 : styles.nextButton);
9923
+ }, [styles === null || styles === void 0 ? void 0 : styles.nextButton, theme]);
9924
+ const controlBarSpacing = { childrenGap: '0.5rem' };
9925
+ return (React__default['default'].createElement(react.Stack, { horizontalAlign: "center", tokens: controlBarSpacing, horizontal: true, className: pageCounterContainerStyles },
9926
+ React__default['default'].createElement(react.DefaultButton, { className: previousButtonSyles, onClick: onPreviousButtonClick, disabled: buttonsDisabled === null || buttonsDisabled === void 0 ? void 0 : buttonsDisabled.previous,
9927
+ /* @conditional-compile-remove(vertical-gallery) */
9928
+ ariaLabel: strings.leftNavButtonAriaLabel, "data-ui-id": ids.overflowGalleryLeftNavButton },
9929
+ React__default['default'].createElement(react.Icon, { iconName: "VerticalGalleryLeftButton", styles: navIconStyles })),
9930
+ React__default['default'].createElement(react.Text
9931
+ /* @conditional-compile-remove(vertical-gallery) */
9932
+ , { "data-ui-id": ids.verticalGalleryPageCounter, className: pageCounterStyles }, `${currentPage} / ${totalPages}`),
9933
+ React__default['default'].createElement(react.DefaultButton, { className: nextButtonsStyles, onClick: onNextButtonClick, disabled: buttonsDisabled === null || buttonsDisabled === void 0 ? void 0 : buttonsDisabled.next,
9934
+ /* @conditional-compile-remove(vertical-gallery) */
9935
+ ariaLabel: strings.rightNavButtonAriaLabel, "data-ui-id": ids.overflowGalleryRightNavButton },
9936
+ React__default['default'].createElement(react.Icon, { iconName: "VerticalGalleryRightButton", styles: navIconStyles }))));
9937
+ };
9938
+
9939
+ // Copyright (c) Microsoft Corporation.
9940
+ /**
9941
+ * Responsive container for the VerticalGallery Component. Performs calculations for number of children
9942
+ * for the VerticalGallery
9943
+ * @param props
9944
+ *
9945
+ * @beta
9946
+ */
9947
+ const ResponsiveVerticalGallery = (props) => {
9948
+ const { children, containerStyles, verticalGalleryStyles, gapHeightRem, controlBarHeightRem, isShort, onFetchTilesToRender } = props;
9949
+ const containerRef = React.useRef(null);
9950
+ const containerHeight = _useContainerHeight(containerRef);
9951
+ const topPadding = containerRef.current ? parseFloat(getComputedStyle(containerRef.current).paddingTop) : 0;
9952
+ const bottomPadding = containerRef.current ? parseFloat(getComputedStyle(containerRef.current).paddingBottom) : 0;
9953
+ const childrenPerPage = calculateVerticalChildrenPerPage({
9954
+ numberOfChildren: React__default['default'].Children.count(children),
9955
+ containerHeight: (containerHeight !== null && containerHeight !== void 0 ? containerHeight : 0) - topPadding - bottomPadding,
9956
+ gapHeightRem,
9957
+ controlBarHeight: controlBarHeightRem !== null && controlBarHeightRem !== void 0 ? controlBarHeightRem : 2,
9958
+ isShort: isShort !== null && isShort !== void 0 ? isShort : false
9959
+ });
9960
+ return (React__default['default'].createElement("div", { "data-ui-id": "responsive-vertical-gallery", ref: containerRef, className: react.mergeStyles(containerStyles) },
9961
+ React__default['default'].createElement(VerticalGallery, { childrenPerPage: childrenPerPage, styles: verticalGalleryStyles, onFetchTilesToRender: onFetchTilesToRender }, children)));
9962
+ };
9963
+
9938
9964
  // Copyright (c) Microsoft Corporation.
9939
9965
  /**
9940
9966
  * @private
@@ -10020,7 +10046,13 @@ const scrollableHorizontalGalleryContainerStyles = react.mergeStyles({
10020
10046
  * @private
10021
10047
  */
10022
10048
  const ScrollableHorizontalGallery = (props) => {
10023
- const { horizontalGalleryElements } = props;
10049
+ const { horizontalGalleryElements, onFetchTilesToRender } = props;
10050
+ React.useEffect(() => {
10051
+ const indexesArray = [...Array(horizontalGalleryElements === null || horizontalGalleryElements === void 0 ? void 0 : horizontalGalleryElements.length).keys()];
10052
+ if (onFetchTilesToRender && indexesArray) {
10053
+ onFetchTilesToRender(indexesArray);
10054
+ }
10055
+ }, [onFetchTilesToRender, horizontalGalleryElements === null || horizontalGalleryElements === void 0 ? void 0 : horizontalGalleryElements.length]);
10024
10056
  const ref = React.useRef();
10025
10057
  const { events: dragabbleEvents } = reactUseDraggableScroll.useDraggable(ref);
10026
10058
  return (React__default['default'].createElement("div", Object.assign({ ref: ref }, dragabbleEvents, { className: scrollableHorizontalGalleryContainerStyles }),
@@ -10034,7 +10066,7 @@ const ScrollableHorizontalGallery = (props) => {
10034
10066
  * @private
10035
10067
  */
10036
10068
  const OverflowGallery = (props) => {
10037
- const { shouldFloatLocalVideo = false, isNarrow = false,
10069
+ const { shouldFloatLocalVideo = false, onFetchTilesToRender, isNarrow = false,
10038
10070
  /* @conditional-compile-remove(vertical-gallery) */
10039
10071
  isShort = false, overflowGalleryElements, horizontalGalleryStyles,
10040
10072
  /* @conditional-compile-remove(vertical-gallery) */ overflowGalleryLayout = 'HorizontalBottom',
@@ -10066,13 +10098,13 @@ const OverflowGallery = (props) => {
10066
10098
  ]);
10067
10099
  /* @conditional-compile-remove(vertical-gallery) */
10068
10100
  if (overflowGalleryLayout === 'VerticalRight') {
10069
- return (React__default['default'].createElement(ResponsiveVerticalGallery, { key: "responsive-vertical-gallery", containerStyles: containerStyles, verticalGalleryStyles: galleryStyles, controlBarHeightRem: HORIZONTAL_GALLERY_BUTTON_WIDTH, gapHeightRem: HORIZONTAL_GALLERY_GAP, isShort: isShort }, overflowGalleryElements));
10101
+ return (React__default['default'].createElement(ResponsiveVerticalGallery, { key: "responsive-vertical-gallery", containerStyles: containerStyles, verticalGalleryStyles: galleryStyles, controlBarHeightRem: HORIZONTAL_GALLERY_BUTTON_WIDTH, gapHeightRem: HORIZONTAL_GALLERY_GAP, isShort: isShort, onFetchTilesToRender: onFetchTilesToRender }, overflowGalleryElements));
10070
10102
  }
10071
10103
  /* @conditional-compile-remove(pinned-participants) */
10072
10104
  if (isNarrow) {
10073
- return (React__default['default'].createElement(ScrollableHorizontalGallery, { key: "scrollable-horizontal-gallery", horizontalGalleryElements: overflowGalleryElements }));
10105
+ return (React__default['default'].createElement(ScrollableHorizontalGallery, { horizontalGalleryElements: overflowGalleryElements, onFetchTilesToRender: onFetchTilesToRender, key: "scrollable-horizontal-gallery" }));
10074
10106
  }
10075
- return (React__default['default'].createElement(ResponsiveHorizontalGallery, { key: "responsive-horizontal-gallery", containerStyles: containerStyles, horizontalGalleryStyles: galleryStyles, childWidthRem: isNarrow ? SMALL_HORIZONTAL_GALLERY_TILE_SIZE_REM.width : LARGE_HORIZONTAL_GALLERY_TILE_SIZE_REM.width, buttonWidthRem: HORIZONTAL_GALLERY_BUTTON_WIDTH, gapWidthRem: HORIZONTAL_GALLERY_GAP }, overflowGalleryElements));
10107
+ return (React__default['default'].createElement(ResponsiveHorizontalGallery, { key: "responsive-horizontal-gallery", containerStyles: containerStyles, onFetchTilesToRender: onFetchTilesToRender, horizontalGalleryStyles: galleryStyles, childWidthRem: isNarrow ? SMALL_HORIZONTAL_GALLERY_TILE_SIZE_REM.width : LARGE_HORIZONTAL_GALLERY_TILE_SIZE_REM.width, buttonWidthRem: HORIZONTAL_GALLERY_BUTTON_WIDTH, gapWidthRem: HORIZONTAL_GALLERY_GAP }, overflowGalleryElements));
10076
10108
  };
10077
10109
 
10078
10110
  // Copyright (c) Microsoft Corporation.
@@ -10105,10 +10137,20 @@ const DefaultLayout = (props) => {
10105
10137
  ? ((_a = p.videoStream) === null || _a === void 0 ? void 0 : _a.isAvailable) && activeVideoStreams++ < maxRemoteVideoStreams
10106
10138
  : (_b = p.videoStream) === null || _b === void 0 ? void 0 : _b.isAvailable);
10107
10139
  });
10108
- const horizontalGalleryTiles = horizontalGalleryParticipants.map((p) => {
10140
+ /**
10141
+ * instantiate indexes available to render with indexes available that would be on first page
10142
+ *
10143
+ * For some components which do not strictly follow the order of the array, we might
10144
+ * re-render the initial tiles -> dispose them -> create new tiles, we need to take care of
10145
+ * this case when those components are here
10146
+ */
10147
+ const [indexesToRender, setIndexesToRender] = React.useState([
10148
+ ...Array(maxRemoteVideoStreams - activeVideoStreams).keys()
10149
+ ]);
10150
+ const horizontalGalleryTiles = horizontalGalleryParticipants.map((p, i) => {
10109
10151
  var _a, _b;
10110
10152
  return onRenderRemoteParticipant(p, maxRemoteVideoStreams && maxRemoteVideoStreams >= 0
10111
- ? ((_a = p.videoStream) === null || _a === void 0 ? void 0 : _a.isAvailable) && activeVideoStreams++ < maxRemoteVideoStreams
10153
+ ? ((_a = p.videoStream) === null || _a === void 0 ? void 0 : _a.isAvailable) && indexesToRender.includes(i) && activeVideoStreams++ < maxRemoteVideoStreams
10112
10154
  : (_b = p.videoStream) === null || _b === void 0 ? void 0 : _b.isAvailable);
10113
10155
  });
10114
10156
  if (localVideoComponent) {
@@ -10124,12 +10166,13 @@ const DefaultLayout = (props) => {
10124
10166
  /* @conditional-compile-remove(vertical-gallery) */
10125
10167
  veritcalGalleryStyles: styles === null || styles === void 0 ? void 0 : styles.verticalGallery,
10126
10168
  /* @conditional-compile-remove(pinned-participants) */
10127
- overflowGalleryLayout: overflowGalleryLayout }));
10169
+ overflowGalleryLayout: overflowGalleryLayout, onFetchTilesToRender: setIndexesToRender }));
10128
10170
  }, [
10129
10171
  isNarrow,
10130
10172
  /* @conditional-compile-remove(vertical-gallery) */ isShort,
10131
10173
  horizontalGalleryTiles,
10132
10174
  styles === null || styles === void 0 ? void 0 : styles.horizontalGallery,
10175
+ setIndexesToRender,
10133
10176
  /* @conditional-compile-remove(vertical-gallery) */ overflowGalleryLayout,
10134
10177
  /* @conditional-compile-remove(vertical-gallery) */ styles === null || styles === void 0 ? void 0 : styles.verticalGallery
10135
10178
  ]);
@@ -10904,14 +10947,24 @@ const FloatingLocalVideoLayout = (props) => {
10904
10947
  ? ((_a = p.videoStream) === null || _a === void 0 ? void 0 : _a.isAvailable) && activeVideoStreams++ < maxRemoteVideoStreams
10905
10948
  : (_b = p.videoStream) === null || _b === void 0 ? void 0 : _b.isAvailable);
10906
10949
  });
10907
- const shouldFloatLocalVideo = remoteParticipants.length > 0;
10950
+ const shouldFloatLocalVideo = remoteParticipants.length > 0 || !!screenShareComponent;
10908
10951
  if (!shouldFloatLocalVideo && localVideoComponent) {
10909
10952
  gridTiles.push(localVideoComponent);
10910
10953
  }
10911
- const horizontalGalleryTiles = horizontalGalleryParticipants.map((p) => {
10954
+ /**
10955
+ * instantiate indexes available to render with indexes available that would be on first page
10956
+ *
10957
+ * For some components which do not strictly follow the order of the array, we might
10958
+ * re-render the initial tiles -> dispose them -> create new tiles, we need to take care of
10959
+ * this case when those components are here
10960
+ */
10961
+ const [indexesToRender, setIndexesToRender] = React.useState([
10962
+ ...Array(maxRemoteVideoStreams - activeVideoStreams).keys()
10963
+ ]);
10964
+ const horizontalGalleryTiles = horizontalGalleryParticipants.map((p, i) => {
10912
10965
  var _a, _b;
10913
10966
  return onRenderRemoteParticipant(p, maxRemoteVideoStreams && maxRemoteVideoStreams >= 0
10914
- ? ((_a = p.videoStream) === null || _a === void 0 ? void 0 : _a.isAvailable) && activeVideoStreams++ < maxRemoteVideoStreams
10967
+ ? ((_a = p.videoStream) === null || _a === void 0 ? void 0 : _a.isAvailable) && indexesToRender.includes(i) && activeVideoStreams++ < maxRemoteVideoStreams
10915
10968
  : (_b = p.videoStream) === null || _b === void 0 ? void 0 : _b.isAvailable);
10916
10969
  });
10917
10970
  const layerHostId = reactHooks.useId('layerhost');
@@ -10920,7 +10973,7 @@ const FloatingLocalVideoLayout = (props) => {
10920
10973
  return SMALL_FLOATING_MODAL_SIZE_PX;
10921
10974
  }
10922
10975
  /* @conditional-compile-remove(vertical-gallery) */
10923
- if (horizontalGalleryTiles.length > 0 && overflowGalleryLayout === 'VerticalRight') {
10976
+ if ((horizontalGalleryTiles.length > 0 || !!screenShareComponent) && overflowGalleryLayout === 'VerticalRight') {
10924
10977
  return isNarrow
10925
10978
  ? SMALL_FLOATING_MODAL_SIZE_PX
10926
10979
  : isShort
@@ -10932,23 +10985,24 @@ const FloatingLocalVideoLayout = (props) => {
10932
10985
  horizontalGalleryTiles.length,
10933
10986
  isNarrow,
10934
10987
  /* @conditional-compile-remove(vertical-gallery) */ isShort,
10935
- /* @conditional-compile-remove(vertical-gallery) */ overflowGalleryLayout
10988
+ /* @conditional-compile-remove(vertical-gallery) */ overflowGalleryLayout,
10989
+ /* @conditional-compile-remove(vertical-gallery) */ screenShareComponent
10936
10990
  ]);
10937
10991
  const wrappedLocalVideoComponent = localVideoComponent && shouldFloatLocalVideo ? (
10938
10992
  // When we use showCameraSwitcherInLocalPreview it disables dragging to allow keyboard navigation.
10939
10993
  showCameraSwitcherInLocalPreview ? (React__default['default'].createElement(react.Stack, { className: react.mergeStyles(localVideoTileWithControlsContainerStyle(theme, localVideoSize), {
10940
10994
  boxShadow: theme.effects.elevation8,
10941
10995
  zIndex: LOCAL_VIDEO_TILE_ZINDEX
10942
- }) }, localVideoComponent)) : horizontalGalleryTiles.length > 0 ? (React__default['default'].createElement(react.Stack, { className: react.mergeStyles(localVideoTileContainerStyle(theme, localVideoSize)) }, localVideoComponent)) : (React__default['default'].createElement(FloatingLocalVideo, { localVideoComponent: localVideoComponent, layerHostId: layerHostId, localVideoSize: localVideoSize, parentWidth: parentWidth, parentHeight: parentHeight }))) : undefined;
10996
+ }) }, localVideoComponent)) : horizontalGalleryTiles.length > 0 || !!screenShareComponent ? (React__default['default'].createElement(react.Stack, { className: react.mergeStyles(localVideoTileContainerStyle(theme, localVideoSize)) }, localVideoComponent)) : (React__default['default'].createElement(FloatingLocalVideo, { localVideoComponent: localVideoComponent, layerHostId: layerHostId, localVideoSize: localVideoSize, parentWidth: parentWidth, parentHeight: parentHeight }))) : undefined;
10943
10997
  const overflowGallery = React.useMemo(() => {
10944
- if (horizontalGalleryTiles.length === 0) {
10998
+ if (horizontalGalleryTiles.length === 0 && !screenShareComponent) {
10945
10999
  return null;
10946
11000
  }
10947
11001
  return (React__default['default'].createElement(OverflowGallery
10948
11002
  /* @conditional-compile-remove(vertical-gallery) */
10949
11003
  , {
10950
11004
  /* @conditional-compile-remove(vertical-gallery) */
10951
- isShort: isShort, isNarrow: isNarrow, shouldFloatLocalVideo: true, overflowGalleryElements: horizontalGalleryTiles, horizontalGalleryStyles: styles === null || styles === void 0 ? void 0 : styles.horizontalGallery,
11005
+ isShort: isShort, onFetchTilesToRender: setIndexesToRender, isNarrow: isNarrow, shouldFloatLocalVideo: true, overflowGalleryElements: horizontalGalleryTiles, horizontalGalleryStyles: styles === null || styles === void 0 ? void 0 : styles.horizontalGallery,
10952
11006
  /* @conditional-compile-remove(vertical-gallery) */
10953
11007
  veritcalGalleryStyles: styles === null || styles === void 0 ? void 0 : styles.verticalGallery,
10954
11008
  /* @conditional-compile-remove(vertical-gallery) */
@@ -10958,6 +11012,8 @@ const FloatingLocalVideoLayout = (props) => {
10958
11012
  /* @conditional-compile-remove(vertical-gallery) */ isShort,
10959
11013
  horizontalGalleryTiles,
10960
11014
  styles === null || styles === void 0 ? void 0 : styles.horizontalGallery,
11015
+ setIndexesToRender,
11016
+ screenShareComponent,
10961
11017
  /* @conditional-compile-remove(vertical-gallery) */ overflowGalleryLayout,
10962
11018
  /* @conditional-compile-remove(vertical-gallery) */ styles === null || styles === void 0 ? void 0 : styles.verticalGallery
10963
11019
  ]);
@@ -11030,7 +11086,8 @@ const VideoGallery = (props) => {
11030
11086
  : undefined;
11031
11087
  /* @conditional-compile-remove(pinned-participants) */
11032
11088
  const drawerMenuHostId = reactHooks.useId('drawerMenuHost', drawerMenuHostIdFromProp);
11033
- const shouldFloatLocalVideo = !!(layout === 'floatingLocalVideo' && remoteParticipants.length > 0);
11089
+ const shouldFloatLocalVideo = !!((layout === 'floatingLocalVideo' && remoteParticipants.length > 0) ||
11090
+ localParticipant.isScreenSharingOn);
11034
11091
  const containerRef = React.useRef(null);
11035
11092
  const containerWidth = _useContainerWidth(containerRef);
11036
11093
  const containerHeight = _useContainerHeight(containerRef);