@homebound/beam 2.345.0 → 2.346.0

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/Css.d.ts CHANGED
@@ -1470,82 +1470,94 @@ declare class CssBuilder<T extends Properties> {
1470
1470
  } & {
1471
1471
  width: import("csstype").Property.Width<string | 0> | undefined;
1472
1472
  }>;
1473
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 1; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1473
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 1`. */
1474
1474
  get lineClamp1(): CssBuilder<T & {
1475
1475
  overflow: import("csstype").Property.Overflow | undefined;
1476
1476
  } & {
1477
1477
  display: import("csstype").Property.Display | undefined;
1478
- } & {
1479
- WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1480
1478
  } & {
1481
1479
  WebkitBoxOrient: import("csstype").Property.BoxOrient | undefined;
1482
1480
  } & {
1483
1481
  textOverflow: import("csstype").Property.TextOverflow | undefined;
1482
+ } & {
1483
+ WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1484
1484
  }>;
1485
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 2; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1485
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 2`. */
1486
1486
  get lineClamp2(): CssBuilder<T & {
1487
1487
  overflow: import("csstype").Property.Overflow | undefined;
1488
1488
  } & {
1489
1489
  display: import("csstype").Property.Display | undefined;
1490
- } & {
1491
- WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1492
1490
  } & {
1493
1491
  WebkitBoxOrient: import("csstype").Property.BoxOrient | undefined;
1494
1492
  } & {
1495
1493
  textOverflow: import("csstype").Property.TextOverflow | undefined;
1494
+ } & {
1495
+ WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1496
1496
  }>;
1497
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 3; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1497
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 3`. */
1498
1498
  get lineClamp3(): CssBuilder<T & {
1499
1499
  overflow: import("csstype").Property.Overflow | undefined;
1500
1500
  } & {
1501
1501
  display: import("csstype").Property.Display | undefined;
1502
- } & {
1503
- WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1504
1502
  } & {
1505
1503
  WebkitBoxOrient: import("csstype").Property.BoxOrient | undefined;
1506
1504
  } & {
1507
1505
  textOverflow: import("csstype").Property.TextOverflow | undefined;
1506
+ } & {
1507
+ WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1508
1508
  }>;
1509
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 4; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1509
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 4`. */
1510
1510
  get lineClamp4(): CssBuilder<T & {
1511
1511
  overflow: import("csstype").Property.Overflow | undefined;
1512
1512
  } & {
1513
1513
  display: import("csstype").Property.Display | undefined;
1514
- } & {
1515
- WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1516
1514
  } & {
1517
1515
  WebkitBoxOrient: import("csstype").Property.BoxOrient | undefined;
1518
1516
  } & {
1519
1517
  textOverflow: import("csstype").Property.TextOverflow | undefined;
1518
+ } & {
1519
+ WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1520
1520
  }>;
1521
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 5; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1521
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 5`. */
1522
1522
  get lineClamp5(): CssBuilder<T & {
1523
1523
  overflow: import("csstype").Property.Overflow | undefined;
1524
1524
  } & {
1525
1525
  display: import("csstype").Property.Display | undefined;
1526
- } & {
1527
- WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1528
1526
  } & {
1529
1527
  WebkitBoxOrient: import("csstype").Property.BoxOrient | undefined;
1530
1528
  } & {
1531
1529
  textOverflow: import("csstype").Property.TextOverflow | undefined;
1530
+ } & {
1531
+ WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1532
1532
  }>;
1533
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 6; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1533
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 6`. */
1534
1534
  get lineClamp6(): CssBuilder<T & {
1535
1535
  overflow: import("csstype").Property.Overflow | undefined;
1536
1536
  } & {
1537
1537
  display: import("csstype").Property.Display | undefined;
1538
- } & {
1539
- WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1540
1538
  } & {
1541
1539
  WebkitBoxOrient: import("csstype").Property.BoxOrient | undefined;
1542
1540
  } & {
1543
1541
  textOverflow: import("csstype").Property.TextOverflow | undefined;
1542
+ } & {
1543
+ WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1544
1544
  }>;
1545
1545
  /** Sets `WebkitLineClamp: "unset"`. */
1546
1546
  get lineClampNone(): CssBuilder<T & {
1547
1547
  WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1548
1548
  }>;
1549
+ /** Sets `WebkitLineClamp: value`. */
1550
+ lineClamp(value: Properties["WebkitLineClamp"]): CssBuilder<T & {
1551
+ WebkitLineClamp: import("csstype").Property.WebkitLineClamp | undefined;
1552
+ } & {
1553
+ overflow: import("csstype").Property.Overflow | undefined;
1554
+ } & {
1555
+ display: import("csstype").Property.Display | undefined;
1556
+ } & {
1557
+ WebkitBoxOrient: import("csstype").Property.BoxOrient | undefined;
1558
+ } & {
1559
+ textOverflow: import("csstype").Property.TextOverflow | undefined;
1560
+ }>;
1549
1561
  /** Sets `objectFit: "contain"`. */
1550
1562
  get objectContain(): CssBuilder<T & {
1551
1563
  objectFit: import("csstype").Property.ObjectFit | undefined;
package/dist/Css.js CHANGED
@@ -1469,34 +1469,38 @@ class CssBuilder {
1469
1469
  return this.add("height", `${px}px`).add("width", `${px}px`);
1470
1470
  }
1471
1471
  // lineClamp
1472
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 1; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1472
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 1`. */
1473
1473
  get lineClamp1() {
1474
- return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitLineClamp", 1).add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis");
1474
+ return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis").add("WebkitLineClamp", 1);
1475
1475
  }
1476
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 2; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1476
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 2`. */
1477
1477
  get lineClamp2() {
1478
- return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitLineClamp", 2).add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis");
1478
+ return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis").add("WebkitLineClamp", 2);
1479
1479
  }
1480
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 3; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1480
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 3`. */
1481
1481
  get lineClamp3() {
1482
- return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitLineClamp", 3).add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis");
1482
+ return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis").add("WebkitLineClamp", 3);
1483
1483
  }
1484
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 4; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1484
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 4`. */
1485
1485
  get lineClamp4() {
1486
- return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitLineClamp", 4).add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis");
1486
+ return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis").add("WebkitLineClamp", 4);
1487
1487
  }
1488
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 5; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1488
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 5`. */
1489
1489
  get lineClamp5() {
1490
- return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitLineClamp", 5).add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis");
1490
+ return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis").add("WebkitLineClamp", 5);
1491
1491
  }
1492
- /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitLineClamp: 6; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"`. */
1492
+ /** Sets `overflow: "hidden"; display: "-webkit-box"; WebkitBoxOrient: "vertical"; textOverflow: "ellipsis"; WebkitLineClamp: 6`. */
1493
1493
  get lineClamp6() {
1494
- return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitLineClamp", 6).add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis");
1494
+ return this.add("overflow", "hidden").add("display", "-webkit-box").add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis").add("WebkitLineClamp", 6);
1495
1495
  }
1496
1496
  /** Sets `WebkitLineClamp: "unset"`. */
1497
1497
  get lineClampNone() {
1498
1498
  return this.add("WebkitLineClamp", "unset");
1499
1499
  }
1500
+ /** Sets `WebkitLineClamp: value`. */
1501
+ lineClamp(value) {
1502
+ return this.add("WebkitLineClamp", value).add("overflow", "hidden").add("display", "-webkit-box").add("WebkitBoxOrient", "vertical").add("textOverflow", "ellipsis");
1503
+ }
1500
1504
  // objectFit
1501
1505
  /** Sets `objectFit: "contain"`. */
1502
1506
  get objectContain() {
@@ -0,0 +1,5 @@
1
+ import { PropsWithChildren } from "react";
2
+ export type MaxLinesProps = PropsWithChildren<{
3
+ maxLines: number;
4
+ }>;
5
+ export declare function MaxLines({ maxLines, children }: MaxLinesProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MaxLines = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const src_1 = require("..");
6
+ const react_1 = require("react");
7
+ const utils_1 = require("@react-aria/utils");
8
+ function MaxLines({ maxLines, children }) {
9
+ const elRef = (0, react_1.useRef)(null);
10
+ const [hasMore, setHasMore] = (0, react_1.useState)(false);
11
+ const [expanded, setExpanded] = (0, react_1.useState)(false);
12
+ // When first rendered it will not be expanded and we'll have the `lineClamp` styles applied.
13
+ // Determine if we need the show more/less buttons.
14
+ // If the content is larger, then we need to set the height of the collapsed content to return to.
15
+ (0, utils_1.useLayoutEffect)(() => {
16
+ if (!elRef.current)
17
+ return;
18
+ // If the content overflows, then set the `hasMore` state to true.
19
+ setHasMore(elRef.current.scrollHeight > elRef.current.clientHeight);
20
+ }, []);
21
+ // Whenever the content changes, reset state
22
+ (0, react_1.useEffect)(() => {
23
+ setExpanded(false);
24
+ }, [children]);
25
+ const onResize = (0, react_1.useCallback)(() => {
26
+ // Listen for changes in the content height and determine if we still need the "show more/less" buttons.
27
+ // This content can change if the user resizes the window, or if the `props.children` change.
28
+ // The tricky part here is that setting `lineClamp` styles also triggers a resize event.
29
+ // We'll need to be aware of when this is triggered from our own `lineClamp` styles, vs externally.
30
+ if (!elRef.current)
31
+ return;
32
+ !expanded && setHasMore(elRef.current.scrollHeight > elRef.current.clientHeight);
33
+ }, [expanded]);
34
+ (0, utils_1.useResizeObserver)({ ref: elRef, onResize });
35
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { ref: elRef, css: src_1.Css.if(!expanded).lineClamp(maxLines).$, children: children }), hasMore && ((0, jsx_runtime_1.jsx)("button", { css: src_1.Css.db.smMd.$, onClick: () => setExpanded((prev) => !prev), children: expanded ? "Show Less" : "Show More" }))] }));
36
+ }
37
+ exports.MaxLines = MaxLines;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.345.0",
3
+ "version": "2.346.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",