@homebound/beam 2.417.5 → 2.417.6
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 +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -11
- package/dist/index.d.ts +90 -11
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -7155,22 +7155,60 @@ interface useResponsiveGridProps {
|
|
|
7155
7155
|
/**
|
|
7156
7156
|
* Returns container styles for a responsive CSS grid.
|
|
7157
7157
|
*
|
|
7158
|
-
*
|
|
7159
|
-
*
|
|
7160
|
-
*
|
|
7161
|
-
*
|
|
7158
|
+
* ## Layout algorithm
|
|
7159
|
+
*
|
|
7160
|
+
* The grid uses `auto-fill` columns with a clamped width:
|
|
7161
|
+
*
|
|
7162
|
+
* ```
|
|
7163
|
+
* grid-template-columns: repeat(auto-fill, minmax(max(minColumnWidth, maxColumnWidth), 1fr))
|
|
7164
|
+
* ```
|
|
7165
|
+
*
|
|
7166
|
+
* where `maxColumnWidth = (100% - totalGapWidth) / columns`.
|
|
7167
|
+
*
|
|
7168
|
+
* - The `max(minColumnWidth, maxColumnWidth)` clamp means each column is *at
|
|
7169
|
+
* least* `minColumnWidth` wide, but when the container is wide enough to fit
|
|
7170
|
+
* all `columns`, each column grows to fill the space equally.
|
|
7171
|
+
* - `auto-fill` lets the browser drop columns automatically as the container
|
|
7172
|
+
* shrinks — once there isn't room for the next column at `minColumnWidth`,
|
|
7173
|
+
* the grid reflows to fewer columns.
|
|
7174
|
+
* - The grid is also a CSS `container` (`container-type: inline-size`) so that
|
|
7175
|
+
* child items can use `@container` queries to adapt their `grid-column` span
|
|
7176
|
+
* based on the grid's current width. See `useResponsiveGridItem`.
|
|
7177
|
+
*
|
|
7178
|
+
* ### Trade-offs
|
|
7179
|
+
*
|
|
7180
|
+
* **Pros**
|
|
7181
|
+
* - Fully CSS-driven reflow — no JS resize observers or manual breakpoint
|
|
7182
|
+
* bookkeeping; the browser handles column count changes natively.
|
|
7183
|
+
* - Container queries keep span adjustments scoped to the grid's own width
|
|
7184
|
+
* rather than the viewport, so the grid works correctly inside any layout
|
|
7185
|
+
* (sidebars, split panes, etc.).
|
|
7186
|
+
*
|
|
7187
|
+
* **Cons**
|
|
7188
|
+
* - `auto-fill` can produce an empty trailing column when the container is
|
|
7189
|
+
* slightly wider than `columns * minColumnWidth` but not wide enough for
|
|
7190
|
+
* `columns + 1` full columns.
|
|
7191
|
+
* - Items that span multiple columns need coordinated `@container` queries
|
|
7192
|
+
* (via `useResponsiveGridItem`) to gracefully reduce their span — without
|
|
7193
|
+
* those styles an item requesting e.g. `span 3` will overflow or leave
|
|
7194
|
+
* blank tracks when only 2 columns fit.
|
|
7195
|
+
*
|
|
7196
|
+
* ## Usage
|
|
7197
|
+
*
|
|
7198
|
+
* When using the hooks directly (without `ResponsiveGrid`), pass the same
|
|
7199
|
+
* config object to both hooks so that items can compute their container query
|
|
7200
|
+
* breakpoints:
|
|
7201
|
+
*
|
|
7202
|
+
* ```tsx
|
|
7203
|
+
* const gridConfig = { minColumnWidth: 276, columns: 4, gap: 24 };
|
|
7204
|
+
* const { gridStyles } = useResponsiveGrid(gridConfig);
|
|
7205
|
+
* const { gridItemProps, gridItemStyles } = useResponsiveGridItem({ colSpan: 3, gridConfig });
|
|
7206
|
+
* ```
|
|
7162
7207
|
*/
|
|
7163
7208
|
declare function useResponsiveGrid(props: useResponsiveGridProps): {
|
|
7164
7209
|
gridStyles: Properties;
|
|
7165
7210
|
};
|
|
7166
7211
|
|
|
7167
|
-
declare function useResponsiveGridItem({ colSpan }: {
|
|
7168
|
-
colSpan?: number;
|
|
7169
|
-
}): {
|
|
7170
|
-
gridItemProps: Record<string, number>;
|
|
7171
|
-
gridItemStyles: Properties;
|
|
7172
|
-
};
|
|
7173
|
-
|
|
7174
7212
|
interface ResponsiveGridConfig {
|
|
7175
7213
|
minColumnWidth: number;
|
|
7176
7214
|
gap: number;
|
|
@@ -7178,6 +7216,47 @@ interface ResponsiveGridConfig {
|
|
|
7178
7216
|
}
|
|
7179
7217
|
declare const ResponsiveGridContext: React$1.Context<ResponsiveGridConfig | undefined>;
|
|
7180
7218
|
|
|
7219
|
+
interface UseResponsiveGridItemProps {
|
|
7220
|
+
/** How many grid columns this item should span. Defaults to 1. */
|
|
7221
|
+
colSpan?: number;
|
|
7222
|
+
/**
|
|
7223
|
+
* The grid configuration for computing container-query breakpoints.
|
|
7224
|
+
*
|
|
7225
|
+
* When items are rendered inside a `ResponsiveGrid` (or a manual
|
|
7226
|
+
* `ResponsiveGridContext.Provider`), this is picked up from context
|
|
7227
|
+
* automatically and can be omitted.
|
|
7228
|
+
*
|
|
7229
|
+
* When using the hooks directly (i.e. `useResponsiveGrid` +
|
|
7230
|
+
* `useResponsiveGridItem` without a Provider), this **must** be supplied
|
|
7231
|
+
* so the item can generate the correct `@container` query styles.
|
|
7232
|
+
* Pass the same config object you gave to `useResponsiveGrid`:
|
|
7233
|
+
*
|
|
7234
|
+
* ```tsx
|
|
7235
|
+
* const gridConfig = { minColumnWidth: 276, columns: 4, gap: 24 };
|
|
7236
|
+
* const { gridStyles } = useResponsiveGrid(gridConfig);
|
|
7237
|
+
* const { gridItemProps, gridItemStyles } = useResponsiveGridItem({ colSpan: 3, gridConfig });
|
|
7238
|
+
* ```
|
|
7239
|
+
*/
|
|
7240
|
+
gridConfig?: ResponsiveGridConfig;
|
|
7241
|
+
}
|
|
7242
|
+
/**
|
|
7243
|
+
* Returns props and styles for a responsive grid item.
|
|
7244
|
+
*
|
|
7245
|
+
* - `gridItemProps` — a data attribute used to identify the item's requested
|
|
7246
|
+
* column span. Spread this onto the item's root element.
|
|
7247
|
+
* - `gridItemStyles` — `@container` query CSS that gracefully reduces the
|
|
7248
|
+
* item's `grid-column` span as the grid container shrinks. Apply these to
|
|
7249
|
+
* the item's `css` prop.
|
|
7250
|
+
*
|
|
7251
|
+
* The container query breakpoints are derived from the grid config (see
|
|
7252
|
+
* `UseResponsiveGridItemProps.gridConfig`). When `colSpan` is 1 or the
|
|
7253
|
+
* config is unavailable, `gridItemStyles` will be an empty object.
|
|
7254
|
+
*/
|
|
7255
|
+
declare function useResponsiveGridItem(props: UseResponsiveGridItemProps): {
|
|
7256
|
+
gridItemProps: Record<string, number>;
|
|
7257
|
+
gridItemStyles: Properties;
|
|
7258
|
+
};
|
|
7259
|
+
|
|
7181
7260
|
interface HbLoadingSpinnerProps {
|
|
7182
7261
|
/** Reverts loading text to `Loading...` if true. May override global noQuips by passing in noQuips={false}. */
|
|
7183
7262
|
noQuips?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -7155,22 +7155,60 @@ interface useResponsiveGridProps {
|
|
|
7155
7155
|
/**
|
|
7156
7156
|
* Returns container styles for a responsive CSS grid.
|
|
7157
7157
|
*
|
|
7158
|
-
*
|
|
7159
|
-
*
|
|
7160
|
-
*
|
|
7161
|
-
*
|
|
7158
|
+
* ## Layout algorithm
|
|
7159
|
+
*
|
|
7160
|
+
* The grid uses `auto-fill` columns with a clamped width:
|
|
7161
|
+
*
|
|
7162
|
+
* ```
|
|
7163
|
+
* grid-template-columns: repeat(auto-fill, minmax(max(minColumnWidth, maxColumnWidth), 1fr))
|
|
7164
|
+
* ```
|
|
7165
|
+
*
|
|
7166
|
+
* where `maxColumnWidth = (100% - totalGapWidth) / columns`.
|
|
7167
|
+
*
|
|
7168
|
+
* - The `max(minColumnWidth, maxColumnWidth)` clamp means each column is *at
|
|
7169
|
+
* least* `minColumnWidth` wide, but when the container is wide enough to fit
|
|
7170
|
+
* all `columns`, each column grows to fill the space equally.
|
|
7171
|
+
* - `auto-fill` lets the browser drop columns automatically as the container
|
|
7172
|
+
* shrinks — once there isn't room for the next column at `minColumnWidth`,
|
|
7173
|
+
* the grid reflows to fewer columns.
|
|
7174
|
+
* - The grid is also a CSS `container` (`container-type: inline-size`) so that
|
|
7175
|
+
* child items can use `@container` queries to adapt their `grid-column` span
|
|
7176
|
+
* based on the grid's current width. See `useResponsiveGridItem`.
|
|
7177
|
+
*
|
|
7178
|
+
* ### Trade-offs
|
|
7179
|
+
*
|
|
7180
|
+
* **Pros**
|
|
7181
|
+
* - Fully CSS-driven reflow — no JS resize observers or manual breakpoint
|
|
7182
|
+
* bookkeeping; the browser handles column count changes natively.
|
|
7183
|
+
* - Container queries keep span adjustments scoped to the grid's own width
|
|
7184
|
+
* rather than the viewport, so the grid works correctly inside any layout
|
|
7185
|
+
* (sidebars, split panes, etc.).
|
|
7186
|
+
*
|
|
7187
|
+
* **Cons**
|
|
7188
|
+
* - `auto-fill` can produce an empty trailing column when the container is
|
|
7189
|
+
* slightly wider than `columns * minColumnWidth` but not wide enough for
|
|
7190
|
+
* `columns + 1` full columns.
|
|
7191
|
+
* - Items that span multiple columns need coordinated `@container` queries
|
|
7192
|
+
* (via `useResponsiveGridItem`) to gracefully reduce their span — without
|
|
7193
|
+
* those styles an item requesting e.g. `span 3` will overflow or leave
|
|
7194
|
+
* blank tracks when only 2 columns fit.
|
|
7195
|
+
*
|
|
7196
|
+
* ## Usage
|
|
7197
|
+
*
|
|
7198
|
+
* When using the hooks directly (without `ResponsiveGrid`), pass the same
|
|
7199
|
+
* config object to both hooks so that items can compute their container query
|
|
7200
|
+
* breakpoints:
|
|
7201
|
+
*
|
|
7202
|
+
* ```tsx
|
|
7203
|
+
* const gridConfig = { minColumnWidth: 276, columns: 4, gap: 24 };
|
|
7204
|
+
* const { gridStyles } = useResponsiveGrid(gridConfig);
|
|
7205
|
+
* const { gridItemProps, gridItemStyles } = useResponsiveGridItem({ colSpan: 3, gridConfig });
|
|
7206
|
+
* ```
|
|
7162
7207
|
*/
|
|
7163
7208
|
declare function useResponsiveGrid(props: useResponsiveGridProps): {
|
|
7164
7209
|
gridStyles: Properties;
|
|
7165
7210
|
};
|
|
7166
7211
|
|
|
7167
|
-
declare function useResponsiveGridItem({ colSpan }: {
|
|
7168
|
-
colSpan?: number;
|
|
7169
|
-
}): {
|
|
7170
|
-
gridItemProps: Record<string, number>;
|
|
7171
|
-
gridItemStyles: Properties;
|
|
7172
|
-
};
|
|
7173
|
-
|
|
7174
7212
|
interface ResponsiveGridConfig {
|
|
7175
7213
|
minColumnWidth: number;
|
|
7176
7214
|
gap: number;
|
|
@@ -7178,6 +7216,47 @@ interface ResponsiveGridConfig {
|
|
|
7178
7216
|
}
|
|
7179
7217
|
declare const ResponsiveGridContext: React$1.Context<ResponsiveGridConfig | undefined>;
|
|
7180
7218
|
|
|
7219
|
+
interface UseResponsiveGridItemProps {
|
|
7220
|
+
/** How many grid columns this item should span. Defaults to 1. */
|
|
7221
|
+
colSpan?: number;
|
|
7222
|
+
/**
|
|
7223
|
+
* The grid configuration for computing container-query breakpoints.
|
|
7224
|
+
*
|
|
7225
|
+
* When items are rendered inside a `ResponsiveGrid` (or a manual
|
|
7226
|
+
* `ResponsiveGridContext.Provider`), this is picked up from context
|
|
7227
|
+
* automatically and can be omitted.
|
|
7228
|
+
*
|
|
7229
|
+
* When using the hooks directly (i.e. `useResponsiveGrid` +
|
|
7230
|
+
* `useResponsiveGridItem` without a Provider), this **must** be supplied
|
|
7231
|
+
* so the item can generate the correct `@container` query styles.
|
|
7232
|
+
* Pass the same config object you gave to `useResponsiveGrid`:
|
|
7233
|
+
*
|
|
7234
|
+
* ```tsx
|
|
7235
|
+
* const gridConfig = { minColumnWidth: 276, columns: 4, gap: 24 };
|
|
7236
|
+
* const { gridStyles } = useResponsiveGrid(gridConfig);
|
|
7237
|
+
* const { gridItemProps, gridItemStyles } = useResponsiveGridItem({ colSpan: 3, gridConfig });
|
|
7238
|
+
* ```
|
|
7239
|
+
*/
|
|
7240
|
+
gridConfig?: ResponsiveGridConfig;
|
|
7241
|
+
}
|
|
7242
|
+
/**
|
|
7243
|
+
* Returns props and styles for a responsive grid item.
|
|
7244
|
+
*
|
|
7245
|
+
* - `gridItemProps` — a data attribute used to identify the item's requested
|
|
7246
|
+
* column span. Spread this onto the item's root element.
|
|
7247
|
+
* - `gridItemStyles` — `@container` query CSS that gracefully reduces the
|
|
7248
|
+
* item's `grid-column` span as the grid container shrinks. Apply these to
|
|
7249
|
+
* the item's `css` prop.
|
|
7250
|
+
*
|
|
7251
|
+
* The container query breakpoints are derived from the grid config (see
|
|
7252
|
+
* `UseResponsiveGridItemProps.gridConfig`). When `colSpan` is 1 or the
|
|
7253
|
+
* config is unavailable, `gridItemStyles` will be an empty object.
|
|
7254
|
+
*/
|
|
7255
|
+
declare function useResponsiveGridItem(props: UseResponsiveGridItemProps): {
|
|
7256
|
+
gridItemProps: Record<string, number>;
|
|
7257
|
+
gridItemStyles: Properties;
|
|
7258
|
+
};
|
|
7259
|
+
|
|
7181
7260
|
interface HbLoadingSpinnerProps {
|
|
7182
7261
|
/** Reverts loading text to `Loading...` if true. May override global noQuips by passing in noQuips={false}. */
|
|
7183
7262
|
noQuips?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -18023,8 +18023,10 @@ function useResponsiveGrid(props) {
|
|
|
18023
18023
|
|
|
18024
18024
|
// src/components/Grid/useResponsiveGridItem.ts
|
|
18025
18025
|
import { useContext as useContext18, useMemo as useMemo45 } from "react";
|
|
18026
|
-
function useResponsiveGridItem(
|
|
18027
|
-
const
|
|
18026
|
+
function useResponsiveGridItem(props) {
|
|
18027
|
+
const { colSpan = 1, gridConfig } = props;
|
|
18028
|
+
const contextConfig = useContext18(ResponsiveGridContext);
|
|
18029
|
+
const config = gridConfig ?? contextConfig;
|
|
18028
18030
|
const gridItemStyles = useMemo45(() => {
|
|
18029
18031
|
if (!config || colSpan <= 1) return {};
|
|
18030
18032
|
const { minColumnWidth, gap } = config;
|