@wistia/ui 0.13.8 → 0.13.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.d.mts CHANGED
@@ -1972,6 +1972,11 @@ type GridProps = ComponentPropsWithoutRef<'div'> & {
1972
1972
  * Controls the spacing between grid items.
1973
1973
  */
1974
1974
  gap?: Gap | ResponsiveGap | Spacings;
1975
+ /**
1976
+ * Controls whether grid items expand to fill available space when there are fewer items than columns.
1977
+ * When true, items grow to fill space. When false, the grid will auto fill the additional space with empty tracks.
1978
+ */
1979
+ expandItems?: boolean;
1975
1980
  renderAs?: ElementType;
1976
1981
  };
1977
1982
  declare const Grid: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, GridProps>) => react.ReactElement | null) & UnknownRecord;
package/dist/index.d.ts CHANGED
@@ -1972,6 +1972,11 @@ type GridProps = ComponentPropsWithoutRef<'div'> & {
1972
1972
  * Controls the spacing between grid items.
1973
1973
  */
1974
1974
  gap?: Gap | ResponsiveGap | Spacings;
1975
+ /**
1976
+ * Controls whether grid items expand to fill available space when there are fewer items than columns.
1977
+ * When true, items grow to fill space. When false, the grid will auto fill the additional space with empty tracks.
1978
+ */
1979
+ expandItems?: boolean;
1975
1980
  renderAs?: ElementType;
1976
1981
  };
1977
1982
  declare const Grid: (<C extends ElementType = "div">(props: PolymorphicComponentProps<C, GridProps>) => react.ReactElement | null) & UnknownRecord;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * @license @wistia/ui v0.13.8
3
+ * @license @wistia/ui v0.13.9
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -12906,49 +12906,52 @@ import styled57, { css as css32 } from "styled-components";
12906
12906
  import { isRecord as isRecord5 } from "@wistia/type-guards";
12907
12907
  import { jsx as jsx262 } from "react/jsx-runtime";
12908
12908
  var DEFAULT_ELEMENT5 = "div";
12909
+ var getGridTemplateColumns = (maxColumns, minChildWidth, expandItems) => {
12910
+ if (minChildWidth === "auto" && maxColumns === "auto") {
12911
+ return css32`
12912
+ grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
12913
+ `;
12914
+ }
12915
+ const gridMode = expandItems ? "auto-fit" : "auto-fill";
12916
+ const minChildWidthValue = minChildWidth === "auto" ? 0 : minChildWidth;
12917
+ if (maxColumns === "auto") {
12918
+ return css32`
12919
+ grid-template-columns: repeat(${gridMode}, minmax(${minChildWidthValue}px, 1fr));
12920
+ `;
12921
+ }
12922
+ return css32`
12923
+ /* Adapted from https://9elements.com/blog/building-a-rock-solid-auto-grid/ */
12924
+ --wui-grid-total-column-gap-width: calc(${maxColumns - 1} * var(--wui-grid-column-gap));
12925
+ --wui-grid-max-column-width: calc(
12926
+ (100% - var(--wui-grid-total-column-gap-width)) / ${maxColumns}
12927
+ );
12928
+
12929
+ grid-template-columns: repeat(
12930
+ ${gridMode},
12931
+ minmax(max(${minChildWidthValue}px, var(--wui-grid-max-column-width)), 1fr)
12932
+ );
12933
+ `;
12934
+ };
12909
12935
  var StyledGrid = styled57.div`
12910
12936
  --wui-grid-column-gap: ${({ $columnGap }) => `var(--wui-${$columnGap})`};
12911
12937
  --wui-grid-row-gap: ${({ $rowGap }) => `var(--wui-${$rowGap})`};
12912
- --wui-grid-min-column-size: ${({ $minChildWidth }) => $minChildWidth === "auto" ? "0" : `${$minChildWidth}px`};
12913
- --wui-grid-max-columns: ${({ $maxColumns }) => $maxColumns === "auto" ? "infinity" : $maxColumns};
12914
- --wui-grid-column-gap-count: calc(var(--wui-grid-max-columns) - 1);
12915
- --wui-grid-total-column-gap-width: calc(
12916
- var(--wui-grid-column-gap-count) * var(--wui-grid-column-gap)
12917
- );
12918
- --wui-grid-max-column-width: calc(
12919
- (100% - var(--wui-grid-total-column-gap-width)) / var(--wui-grid-max-columns)
12920
- );
12921
12938
 
12922
12939
  display: grid;
12923
12940
  gap: var(--wui-grid-column-gap) var(--wui-grid-row-gap);
12924
12941
  width: 100%;
12925
12942
 
12926
- ${({ $maxColumns, $minChildWidth }) => {
12927
- if ($maxColumns === "auto" && $minChildWidth === "auto") {
12928
- return css32`
12929
- grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
12930
- `;
12931
- }
12932
- if ($maxColumns !== "auto" && $minChildWidth === "auto") {
12933
- return css32`
12934
- grid-template-columns: repeat(${$maxColumns}, minmax(0, 1fr));
12935
- `;
12936
- }
12937
- if ($maxColumns === "auto" && $minChildWidth !== "auto") {
12938
- return css32`
12939
- grid-template-columns: repeat(auto-fit, minmax(${$minChildWidth}px, 1fr));
12940
- `;
12941
- }
12942
- return css32`
12943
- grid-template-columns: repeat(
12944
- auto-fit,
12945
- minmax(max(var(--wui-grid-min-column-size), var(--wui-grid-max-column-width)), 1fr)
12946
- );
12947
- `;
12948
- }}
12943
+ ${({ $maxColumns, $minChildWidth, $expandItems }) => getGridTemplateColumns($maxColumns, $minChildWidth, $expandItems)}
12949
12944
  `;
12950
12945
  var GridComponent = forwardRef17(
12951
- ({ children, columns = "auto", minChildWidth = "auto", gap = "space-02", renderAs, ...props }, ref) => {
12946
+ ({
12947
+ children,
12948
+ columns = "auto",
12949
+ minChildWidth = "auto",
12950
+ gap = "space-02",
12951
+ expandItems = false,
12952
+ renderAs,
12953
+ ...props
12954
+ }, ref) => {
12952
12955
  const responsiveGap = useResponsiveProp(gap);
12953
12956
  const { column, row } = isRecord5(responsiveGap) ? responsiveGap : { column: responsiveGap, row: responsiveGap };
12954
12957
  const responsiveColumns = useResponsiveProp(columns);
@@ -12958,6 +12961,7 @@ var GridComponent = forwardRef17(
12958
12961
  {
12959
12962
  ref,
12960
12963
  $columnGap: column,
12964
+ $expandItems: expandItems,
12961
12965
  $maxColumns: responsiveColumns,
12962
12966
  $minChildWidth: responsiveMinChildWidth,
12963
12967
  $rowGap: row,