@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.cjs 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
  *
@@ -13047,49 +13047,52 @@ var import_styled_components74 = __toESM(require("styled-components"));
13047
13047
  var import_type_guards40 = require("@wistia/type-guards");
13048
13048
  var import_jsx_runtime262 = require("react/jsx-runtime");
13049
13049
  var DEFAULT_ELEMENT5 = "div";
13050
+ var getGridTemplateColumns = (maxColumns, minChildWidth, expandItems) => {
13051
+ if (minChildWidth === "auto" && maxColumns === "auto") {
13052
+ return import_styled_components74.css`
13053
+ grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
13054
+ `;
13055
+ }
13056
+ const gridMode = expandItems ? "auto-fit" : "auto-fill";
13057
+ const minChildWidthValue = minChildWidth === "auto" ? 0 : minChildWidth;
13058
+ if (maxColumns === "auto") {
13059
+ return import_styled_components74.css`
13060
+ grid-template-columns: repeat(${gridMode}, minmax(${minChildWidthValue}px, 1fr));
13061
+ `;
13062
+ }
13063
+ return import_styled_components74.css`
13064
+ /* Adapted from https://9elements.com/blog/building-a-rock-solid-auto-grid/ */
13065
+ --wui-grid-total-column-gap-width: calc(${maxColumns - 1} * var(--wui-grid-column-gap));
13066
+ --wui-grid-max-column-width: calc(
13067
+ (100% - var(--wui-grid-total-column-gap-width)) / ${maxColumns}
13068
+ );
13069
+
13070
+ grid-template-columns: repeat(
13071
+ ${gridMode},
13072
+ minmax(max(${minChildWidthValue}px, var(--wui-grid-max-column-width)), 1fr)
13073
+ );
13074
+ `;
13075
+ };
13050
13076
  var StyledGrid = import_styled_components74.default.div`
13051
13077
  --wui-grid-column-gap: ${({ $columnGap }) => `var(--wui-${$columnGap})`};
13052
13078
  --wui-grid-row-gap: ${({ $rowGap }) => `var(--wui-${$rowGap})`};
13053
- --wui-grid-min-column-size: ${({ $minChildWidth }) => $minChildWidth === "auto" ? "0" : `${$minChildWidth}px`};
13054
- --wui-grid-max-columns: ${({ $maxColumns }) => $maxColumns === "auto" ? "infinity" : $maxColumns};
13055
- --wui-grid-column-gap-count: calc(var(--wui-grid-max-columns) - 1);
13056
- --wui-grid-total-column-gap-width: calc(
13057
- var(--wui-grid-column-gap-count) * var(--wui-grid-column-gap)
13058
- );
13059
- --wui-grid-max-column-width: calc(
13060
- (100% - var(--wui-grid-total-column-gap-width)) / var(--wui-grid-max-columns)
13061
- );
13062
13079
 
13063
13080
  display: grid;
13064
13081
  gap: var(--wui-grid-column-gap) var(--wui-grid-row-gap);
13065
13082
  width: 100%;
13066
13083
 
13067
- ${({ $maxColumns, $minChildWidth }) => {
13068
- if ($maxColumns === "auto" && $minChildWidth === "auto") {
13069
- return import_styled_components74.css`
13070
- grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
13071
- `;
13072
- }
13073
- if ($maxColumns !== "auto" && $minChildWidth === "auto") {
13074
- return import_styled_components74.css`
13075
- grid-template-columns: repeat(${$maxColumns}, minmax(0, 1fr));
13076
- `;
13077
- }
13078
- if ($maxColumns === "auto" && $minChildWidth !== "auto") {
13079
- return import_styled_components74.css`
13080
- grid-template-columns: repeat(auto-fit, minmax(${$minChildWidth}px, 1fr));
13081
- `;
13082
- }
13083
- return import_styled_components74.css`
13084
- grid-template-columns: repeat(
13085
- auto-fit,
13086
- minmax(max(var(--wui-grid-min-column-size), var(--wui-grid-max-column-width)), 1fr)
13087
- );
13088
- `;
13089
- }}
13084
+ ${({ $maxColumns, $minChildWidth, $expandItems }) => getGridTemplateColumns($maxColumns, $minChildWidth, $expandItems)}
13090
13085
  `;
13091
13086
  var GridComponent = (0, import_react61.forwardRef)(
13092
- ({ children, columns = "auto", minChildWidth = "auto", gap = "space-02", renderAs, ...props }, ref) => {
13087
+ ({
13088
+ children,
13089
+ columns = "auto",
13090
+ minChildWidth = "auto",
13091
+ gap = "space-02",
13092
+ expandItems = false,
13093
+ renderAs,
13094
+ ...props
13095
+ }, ref) => {
13093
13096
  const responsiveGap = useResponsiveProp(gap);
13094
13097
  const { column, row } = (0, import_type_guards40.isRecord)(responsiveGap) ? responsiveGap : { column: responsiveGap, row: responsiveGap };
13095
13098
  const responsiveColumns = useResponsiveProp(columns);
@@ -13099,6 +13102,7 @@ var GridComponent = (0, import_react61.forwardRef)(
13099
13102
  {
13100
13103
  ref,
13101
13104
  $columnGap: column,
13105
+ $expandItems: expandItems,
13102
13106
  $maxColumns: responsiveColumns,
13103
13107
  $minChildWidth: responsiveMinChildWidth,
13104
13108
  $rowGap: row,