@optifye/dashboard-core 6.0.8 → 6.0.9

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.
package/dist/index.js CHANGED
@@ -18666,7 +18666,9 @@ var VideoGridView = React19__namespace.default.memo(({
18666
18666
  const containerRef = React19.useRef(null);
18667
18667
  const observerRef = React19.useRef(null);
18668
18668
  const [gridCols, setGridCols] = React19.useState(4);
18669
+ const [gridRows, setGridRows] = React19.useState(1);
18669
18670
  const [visibleWorkspaces, setVisibleWorkspaces] = React19.useState(/* @__PURE__ */ new Set());
18671
+ const [cardDimensions, setCardDimensions] = React19.useState({ width: 0, height: 0 });
18670
18672
  const videoConfig = useVideoConfig();
18671
18673
  const { cropping, canvasConfig, hlsUrls } = videoConfig;
18672
18674
  const mergedVideoSources = {
@@ -18727,35 +18729,51 @@ var VideoGridView = React19__namespace.default.memo(({
18727
18729
  setGridCols(1);
18728
18730
  return;
18729
18731
  }
18730
- let bestCols = 1;
18731
- let bestScore = 0;
18732
+ const optimalLayouts = {
18733
+ 1: 1,
18734
+ 2: 2,
18735
+ 3: 3,
18736
+ 4: 2,
18737
+ 5: 3,
18738
+ 6: 3,
18739
+ 7: 4,
18740
+ 8: 4,
18741
+ 9: 3,
18742
+ 10: 5,
18743
+ 11: 4,
18744
+ 12: 4,
18745
+ 13: 5,
18746
+ 14: 5,
18747
+ 15: 5,
18748
+ 16: 4,
18749
+ 17: 6,
18750
+ 18: 6,
18751
+ 19: 5,
18752
+ 20: 5,
18753
+ 21: 7,
18754
+ 22: 6,
18755
+ 23: 6,
18756
+ 24: 6
18757
+ };
18758
+ let bestCols = optimalLayouts[count] || Math.ceil(Math.sqrt(count));
18759
+ const containerAspectRatio = containerWidth / containerHeight;
18732
18760
  const targetAspectRatio = 16 / 9;
18733
18761
  const gap = 8;
18734
- const maxCols = Math.min(count, selectedLine ? 6 : 12);
18735
- for (let cols = 1; cols <= maxCols; cols++) {
18736
- const rows = Math.ceil(count / cols);
18737
- const availableWidth = containerWidth - gap * (cols - 1);
18738
- const availableHeight = containerHeight - gap * (rows - 1);
18739
- const cellWidth = availableWidth / cols;
18740
- const cellHeight = availableHeight / rows;
18741
- const minCellWidth = selectedLine ? containerWidth < 800 ? 120 : 150 : containerWidth < 800 ? 80 : 100;
18742
- const minCellHeight = selectedLine ? containerHeight < 600 ? 80 : 100 : containerHeight < 600 ? 60 : 80;
18743
- if (cellWidth < minCellWidth || cellHeight < minCellHeight) continue;
18744
- const totalUsedArea = cellWidth * cellHeight * count;
18745
- const totalAvailableArea = containerWidth * containerHeight;
18746
- const spaceUtilization = totalUsedArea / totalAvailableArea;
18747
- const actualAspectRatio = cellWidth / cellHeight;
18748
- const aspectRatioScore = 1 / (1 + Math.abs(actualAspectRatio - targetAspectRatio) * 0.3);
18749
- const score = spaceUtilization * 0.9 + aspectRatioScore * 0.1;
18750
- if (score > bestScore) {
18751
- bestScore = score;
18752
- bestCols = cols;
18753
- }
18754
- }
18755
- if (bestScore === 0) {
18756
- bestCols = Math.ceil(Math.sqrt(count));
18762
+ if (containerAspectRatio > targetAspectRatio * 1.5 && count > 6) {
18763
+ bestCols = Math.min(bestCols + 1, Math.ceil(count / 2));
18764
+ }
18765
+ const minCellWidth = selectedLine ? 150 : 100;
18766
+ const availableWidth = containerWidth - gap * (bestCols - 1);
18767
+ const cellWidth = availableWidth / bestCols;
18768
+ if (cellWidth < minCellWidth && bestCols > 1) {
18769
+ bestCols = Math.floor((containerWidth + gap) / (minCellWidth + gap));
18757
18770
  }
18771
+ const rows = Math.ceil(count / bestCols);
18758
18772
  setGridCols(bestCols);
18773
+ setGridRows(rows);
18774
+ const cardWidth = (containerWidth - gap * (bestCols - 1)) / bestCols;
18775
+ const cardHeight = (containerHeight - gap * (rows - 1)) / rows;
18776
+ setCardDimensions({ width: Math.floor(cardWidth), height: Math.floor(cardHeight) });
18759
18777
  }, [filteredWorkspaces.length, selectedLine]);
18760
18778
  React19.useEffect(() => {
18761
18779
  calculateOptimalGrid();
@@ -18811,8 +18829,8 @@ var VideoGridView = React19__namespace.default.memo(({
18811
18829
  className: "grid h-full w-full gap-2",
18812
18830
  style: {
18813
18831
  gridTemplateColumns: `repeat(${gridCols}, 1fr)`,
18814
- gridTemplateRows: `repeat(${Math.ceil(filteredWorkspaces.length / gridCols)}, 1fr)`,
18815
- minHeight: "100%"
18832
+ gridTemplateRows: `repeat(${gridRows}, 1fr)`,
18833
+ gridAutoFlow: "row"
18816
18834
  },
18817
18835
  children: filteredWorkspaces.sort((a, b) => {
18818
18836
  if (a.line_id !== b.line_id) {
@@ -18835,9 +18853,8 @@ var VideoGridView = React19__namespace.default.memo(({
18835
18853
  "div",
18836
18854
  {
18837
18855
  "data-workspace-id": workspaceId,
18838
- className: "workspace-card relative min-h-0 min-w-0",
18839
- style: { width: "100%", height: "100%" },
18840
- children: /* @__PURE__ */ jsxRuntime.jsx(
18856
+ className: "workspace-card relative w-full h-full",
18857
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0", children: /* @__PURE__ */ jsxRuntime.jsx(
18841
18858
  VideoCard,
18842
18859
  {
18843
18860
  workspace,
@@ -18851,7 +18868,7 @@ var VideoGridView = React19__namespace.default.memo(({
18851
18868
  useRAF: canvasConfig?.useRAF,
18852
18869
  compact: !selectedLine
18853
18870
  }
18854
- )
18871
+ ) })
18855
18872
  },
18856
18873
  workspaceId
18857
18874
  );
package/dist/index.mjs CHANGED
@@ -18637,7 +18637,9 @@ var VideoGridView = React19__default.memo(({
18637
18637
  const containerRef = useRef(null);
18638
18638
  const observerRef = useRef(null);
18639
18639
  const [gridCols, setGridCols] = useState(4);
18640
+ const [gridRows, setGridRows] = useState(1);
18640
18641
  const [visibleWorkspaces, setVisibleWorkspaces] = useState(/* @__PURE__ */ new Set());
18642
+ const [cardDimensions, setCardDimensions] = useState({ width: 0, height: 0 });
18641
18643
  const videoConfig = useVideoConfig();
18642
18644
  const { cropping, canvasConfig, hlsUrls } = videoConfig;
18643
18645
  const mergedVideoSources = {
@@ -18698,35 +18700,51 @@ var VideoGridView = React19__default.memo(({
18698
18700
  setGridCols(1);
18699
18701
  return;
18700
18702
  }
18701
- let bestCols = 1;
18702
- let bestScore = 0;
18703
+ const optimalLayouts = {
18704
+ 1: 1,
18705
+ 2: 2,
18706
+ 3: 3,
18707
+ 4: 2,
18708
+ 5: 3,
18709
+ 6: 3,
18710
+ 7: 4,
18711
+ 8: 4,
18712
+ 9: 3,
18713
+ 10: 5,
18714
+ 11: 4,
18715
+ 12: 4,
18716
+ 13: 5,
18717
+ 14: 5,
18718
+ 15: 5,
18719
+ 16: 4,
18720
+ 17: 6,
18721
+ 18: 6,
18722
+ 19: 5,
18723
+ 20: 5,
18724
+ 21: 7,
18725
+ 22: 6,
18726
+ 23: 6,
18727
+ 24: 6
18728
+ };
18729
+ let bestCols = optimalLayouts[count] || Math.ceil(Math.sqrt(count));
18730
+ const containerAspectRatio = containerWidth / containerHeight;
18703
18731
  const targetAspectRatio = 16 / 9;
18704
18732
  const gap = 8;
18705
- const maxCols = Math.min(count, selectedLine ? 6 : 12);
18706
- for (let cols = 1; cols <= maxCols; cols++) {
18707
- const rows = Math.ceil(count / cols);
18708
- const availableWidth = containerWidth - gap * (cols - 1);
18709
- const availableHeight = containerHeight - gap * (rows - 1);
18710
- const cellWidth = availableWidth / cols;
18711
- const cellHeight = availableHeight / rows;
18712
- const minCellWidth = selectedLine ? containerWidth < 800 ? 120 : 150 : containerWidth < 800 ? 80 : 100;
18713
- const minCellHeight = selectedLine ? containerHeight < 600 ? 80 : 100 : containerHeight < 600 ? 60 : 80;
18714
- if (cellWidth < minCellWidth || cellHeight < minCellHeight) continue;
18715
- const totalUsedArea = cellWidth * cellHeight * count;
18716
- const totalAvailableArea = containerWidth * containerHeight;
18717
- const spaceUtilization = totalUsedArea / totalAvailableArea;
18718
- const actualAspectRatio = cellWidth / cellHeight;
18719
- const aspectRatioScore = 1 / (1 + Math.abs(actualAspectRatio - targetAspectRatio) * 0.3);
18720
- const score = spaceUtilization * 0.9 + aspectRatioScore * 0.1;
18721
- if (score > bestScore) {
18722
- bestScore = score;
18723
- bestCols = cols;
18724
- }
18725
- }
18726
- if (bestScore === 0) {
18727
- bestCols = Math.ceil(Math.sqrt(count));
18733
+ if (containerAspectRatio > targetAspectRatio * 1.5 && count > 6) {
18734
+ bestCols = Math.min(bestCols + 1, Math.ceil(count / 2));
18735
+ }
18736
+ const minCellWidth = selectedLine ? 150 : 100;
18737
+ const availableWidth = containerWidth - gap * (bestCols - 1);
18738
+ const cellWidth = availableWidth / bestCols;
18739
+ if (cellWidth < minCellWidth && bestCols > 1) {
18740
+ bestCols = Math.floor((containerWidth + gap) / (minCellWidth + gap));
18728
18741
  }
18742
+ const rows = Math.ceil(count / bestCols);
18729
18743
  setGridCols(bestCols);
18744
+ setGridRows(rows);
18745
+ const cardWidth = (containerWidth - gap * (bestCols - 1)) / bestCols;
18746
+ const cardHeight = (containerHeight - gap * (rows - 1)) / rows;
18747
+ setCardDimensions({ width: Math.floor(cardWidth), height: Math.floor(cardHeight) });
18730
18748
  }, [filteredWorkspaces.length, selectedLine]);
18731
18749
  useEffect(() => {
18732
18750
  calculateOptimalGrid();
@@ -18782,8 +18800,8 @@ var VideoGridView = React19__default.memo(({
18782
18800
  className: "grid h-full w-full gap-2",
18783
18801
  style: {
18784
18802
  gridTemplateColumns: `repeat(${gridCols}, 1fr)`,
18785
- gridTemplateRows: `repeat(${Math.ceil(filteredWorkspaces.length / gridCols)}, 1fr)`,
18786
- minHeight: "100%"
18803
+ gridTemplateRows: `repeat(${gridRows}, 1fr)`,
18804
+ gridAutoFlow: "row"
18787
18805
  },
18788
18806
  children: filteredWorkspaces.sort((a, b) => {
18789
18807
  if (a.line_id !== b.line_id) {
@@ -18806,9 +18824,8 @@ var VideoGridView = React19__default.memo(({
18806
18824
  "div",
18807
18825
  {
18808
18826
  "data-workspace-id": workspaceId,
18809
- className: "workspace-card relative min-h-0 min-w-0",
18810
- style: { width: "100%", height: "100%" },
18811
- children: /* @__PURE__ */ jsx(
18827
+ className: "workspace-card relative w-full h-full",
18828
+ children: /* @__PURE__ */ jsx("div", { className: "absolute inset-0", children: /* @__PURE__ */ jsx(
18812
18829
  VideoCard,
18813
18830
  {
18814
18831
  workspace,
@@ -18822,7 +18839,7 @@ var VideoGridView = React19__default.memo(({
18822
18839
  useRAF: canvasConfig?.useRAF,
18823
18840
  compact: !selectedLine
18824
18841
  }
18825
- )
18842
+ ) })
18826
18843
  },
18827
18844
  workspaceId
18828
18845
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.0.8",
3
+ "version": "6.0.9",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",