@homebound/beam 2.345.0 → 2.347.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 +52 -18
- package/dist/Css.js +21 -12
- package/dist/components/MaxLines.d.ts +5 -0
- package/dist/components/MaxLines.js +37 -0
- package/dist/components/Pagination.js +1 -1
- package/dist/inputs/TextFieldBase.d.ts +1 -0
- package/dist/inputs/TextFieldBase.js +14 -4
- package/dist/inputs/internal/ComboBoxInput.js +7 -3
- package/package.json +1 -1
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";
|
|
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";
|
|
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";
|
|
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";
|
|
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";
|
|
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";
|
|
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;
|
|
@@ -4232,6 +4244,28 @@ declare class CssBuilder<T extends Properties> {
|
|
|
4232
4244
|
} & {
|
|
4233
4245
|
backgroundColor: import("csstype").Property.BackgroundColor | undefined;
|
|
4234
4246
|
}>;
|
|
4247
|
+
/** Sets `position: "absolute"; overflow: "hidden"; clip: "inset(50%)"; clipPath: ""; border: 0; height: "1px"; margin: "-1px"; width: "1px"; padding: 0; whiteSpace: "nowrap"`. */
|
|
4248
|
+
get visuallyHidden(): CssBuilder<T & {
|
|
4249
|
+
position: import("csstype").Property.Position | undefined;
|
|
4250
|
+
} & {
|
|
4251
|
+
overflow: import("csstype").Property.Overflow | undefined;
|
|
4252
|
+
} & {
|
|
4253
|
+
clip: import("csstype").Property.Clip | undefined;
|
|
4254
|
+
} & {
|
|
4255
|
+
clipPath: import("csstype").Property.ClipPath | undefined;
|
|
4256
|
+
} & {
|
|
4257
|
+
border: import("csstype").Property.Border<string | 0> | undefined;
|
|
4258
|
+
} & {
|
|
4259
|
+
height: import("csstype").Property.Height<string | 0> | undefined;
|
|
4260
|
+
} & {
|
|
4261
|
+
margin: import("csstype").Property.Margin<string | 0> | undefined;
|
|
4262
|
+
} & {
|
|
4263
|
+
width: import("csstype").Property.Width<string | 0> | undefined;
|
|
4264
|
+
} & {
|
|
4265
|
+
padding: import("csstype").Property.Padding<string | 0> | undefined;
|
|
4266
|
+
} & {
|
|
4267
|
+
whiteSpace: import("csstype").Property.WhiteSpace | undefined;
|
|
4268
|
+
}>;
|
|
4235
4269
|
/** Sets `content: "''"`. */
|
|
4236
4270
|
get contentEmpty(): CssBuilder<T & {
|
|
4237
4271
|
content: import("csstype").Property.Content | 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";
|
|
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("
|
|
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";
|
|
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("
|
|
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";
|
|
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("
|
|
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";
|
|
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("
|
|
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";
|
|
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("
|
|
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";
|
|
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("
|
|
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() {
|
|
@@ -3773,6 +3777,11 @@ class CssBuilder {
|
|
|
3773
3777
|
get underlay() {
|
|
3774
3778
|
return this.add("position", "fixed").add("top", 0).add("bottom", 0).add("left", 0).add("right", 0).add("display", "flex").add("alignItems", "center").add("justifyContent", "center").add("backgroundColor", "rgba(36,36,36,0.2)");
|
|
3775
3779
|
}
|
|
3780
|
+
// visuallyHidden
|
|
3781
|
+
/** Sets `position: "absolute"; overflow: "hidden"; clip: "inset(50%)"; clipPath: ""; border: 0; height: "1px"; margin: "-1px"; width: "1px"; padding: 0; whiteSpace: "nowrap"`. */
|
|
3782
|
+
get visuallyHidden() {
|
|
3783
|
+
return this.add("position", "absolute").add("overflow", "hidden").add("clip", "inset(50%)").add("clipPath", "").add("border", 0).add("height", "1px").add("margin", "-1px").add("width", "1px").add("padding", 0).add("whiteSpace", "nowrap");
|
|
3784
|
+
}
|
|
3776
3785
|
// contentEmpty
|
|
3777
3786
|
/** Sets `content: "''"`. */
|
|
3778
3787
|
get contentEmpty() {
|
|
@@ -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;
|
|
@@ -29,7 +29,7 @@ function Pagination(props) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
const tid = (0, utils_1.useTestIds)(props, "pagination");
|
|
32
|
-
return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.bGray200.bt.xs.gray500.px2.pt2.$, ...tid, children: [(0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.mya.mr2.$, ...tid.pageSizeLabel, children: "Page size:" }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.wPx(
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.bGray200.bt.xs.gray500.px2.pt2.$, ...tid, children: [(0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.mya.mr2.$, ...tid.pageSizeLabel, children: "Page size:" }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.wPx(95).$, children: (0, jsx_runtime_1.jsx)(inputs_1.SelectField, { compact: true, label: "Page Size", labelStyle: "hidden", options: exports.pageOptions, value: pageSize, onSelect: (val) => set({ pageNumber: 1, pageSize: val }), ...tid.pageSize }) }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.mla.mya.df.$, children: [(0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.mya.mr2.$, ...tid.pageInfoLabel, children: [first, " ", showLast ? `- ${last}` : "", " of ", totalCount] }), (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "chevronLeft", color: hasPrevPage ? Css_1.Palette.Blue700 : Css_1.Palette.Gray200, onClick: () => set({ pageNumber: pageNumber - 1, pageSize }), disabled: !hasPrevPage, ...tid.previousIcon }), (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "chevronRight", color: hasNextPage ? Css_1.Palette.Blue700 : Css_1.Palette.Gray200, onClick: () => set({ pageNumber: pageNumber + 1, pageSize }), disabled: !hasNextPage, ...tid.nextIcon })] })] }));
|
|
33
33
|
}
|
|
34
34
|
exports.Pagination = Pagination;
|
|
35
35
|
function toLimitAndOffset(page) {
|
|
@@ -17,5 +17,6 @@ export interface TextFieldBaseProps<X> extends Pick<BeamTextFieldProps<X>, "labe
|
|
|
17
17
|
tooltip?: ReactNode;
|
|
18
18
|
hideErrorMessage?: boolean;
|
|
19
19
|
alwaysShowHelperText?: boolean;
|
|
20
|
+
unfocusedPlaceholder?: ReactNode;
|
|
20
21
|
}
|
|
21
22
|
export declare function TextFieldBase<X extends Only<TextFieldXss, X>>(props: TextFieldBaseProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -19,7 +19,7 @@ const utils_1 = require("./utils");
|
|
|
19
19
|
function TextFieldBase(props) {
|
|
20
20
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
21
|
const { fieldProps, wrap = false } = (0, PresentationContext_1.usePresentationContext)();
|
|
22
|
-
const { label, required, labelProps, inputProps, inputRef, inputWrapRef, groupProps, compact = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.compact) !== null && _a !== void 0 ? _a : false, errorMsg, helperText, multiline = false, onChange, onBlur, onFocus, xss, endAdornment, startAdornment, labelStyle = (_b = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _b !== void 0 ? _b : "above", contrast = false, borderless = (_c = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.borderless) !== null && _c !== void 0 ? _c : false, textAreaMinHeight = 96, clearable = false, tooltip, visuallyDisabled = (_d = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.visuallyDisabled) !== null && _d !== void 0 ? _d : true, errorInTooltip = (_e = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.errorInTooltip) !== null && _e !== void 0 ? _e : false, hideErrorMessage = false, alwaysShowHelperText = false, fullWidth = (_f = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _f !== void 0 ? _f : false, } = props;
|
|
22
|
+
const { label, required, labelProps, inputProps, inputRef, inputWrapRef, groupProps, compact = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.compact) !== null && _a !== void 0 ? _a : false, errorMsg, helperText, multiline = false, onChange, onBlur, onFocus, xss, endAdornment, startAdornment, labelStyle = (_b = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _b !== void 0 ? _b : "above", contrast = false, borderless = (_c = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.borderless) !== null && _c !== void 0 ? _c : false, textAreaMinHeight = 96, clearable = false, tooltip, visuallyDisabled = (_d = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.visuallyDisabled) !== null && _d !== void 0 ? _d : true, errorInTooltip = (_e = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.errorInTooltip) !== null && _e !== void 0 ? _e : false, hideErrorMessage = false, alwaysShowHelperText = false, fullWidth = (_f = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _f !== void 0 ? _f : false, unfocusedPlaceholder, } = props;
|
|
23
23
|
const typeScale = (_g = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.typeScale) !== null && _g !== void 0 ? _g : (inputProps.readOnly && labelStyle !== "hidden" ? "smMd" : "sm");
|
|
24
24
|
const internalProps = props.internalProps || {};
|
|
25
25
|
const { compound = false, forceFocus = false, forceHover = false } = internalProps;
|
|
@@ -73,7 +73,7 @@ function TextFieldBase(props) {
|
|
|
73
73
|
// Not using Truss's inline `if` statement here because `addIn` properties do not respect the if statement.
|
|
74
74
|
...(contrast && Css_1.Css.addIn("&::selection", Css_1.Css.bgGray800.$).$),
|
|
75
75
|
// For "multiline" fields we add top and bottom padding of 7px for compact, or 11px for non-compact, to properly match the height of the single line fields
|
|
76
|
-
...(multiline ? Css_1.Css.br4.
|
|
76
|
+
...(multiline ? Css_1.Css.br4.pyPx(compact ? 7 : 11).add("resize", "none").$ : Css_1.Css.truncate.$),
|
|
77
77
|
},
|
|
78
78
|
hover: Css_1.Css.bgColor(hoverBgColor).if(contrast).bGray600.$,
|
|
79
79
|
focus: Css_1.Css.bBlue700.if(contrast).bBlue500.$,
|
|
@@ -95,6 +95,12 @@ function TextFieldBase(props) {
|
|
|
95
95
|
const onFocusChained = (0, react_aria_1.chain)((e) => {
|
|
96
96
|
e.target.select();
|
|
97
97
|
}, onFocus);
|
|
98
|
+
// Simulate clicking `ElementType` when using an unfocused placeholder
|
|
99
|
+
function handleUnfocusedPlaceholderClick(e) {
|
|
100
|
+
var _a;
|
|
101
|
+
e.stopPropagation();
|
|
102
|
+
(_a = fieldRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
103
|
+
}
|
|
98
104
|
const showFocus = (isFocused && !inputProps.readOnly) || forceFocus;
|
|
99
105
|
const showHover = (isHovered && !inputProps.disabled && !inputProps.readOnly && !isFocused) || forceHover;
|
|
100
106
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { css: fieldStyles.container, ...groupProps, ...focusWithinProps, children: [label && labelStyle !== "inline" && ((0, jsx_runtime_1.jsx)(Label_1.Label, { labelProps: labelProps, hidden: labelStyle === "hidden" || compound, label: label, inline: labelStyle !== "above", suffix: labelSuffix, contrast: contrast, ...tid.label })), (0, components_1.maybeTooltip)({
|
|
@@ -114,11 +120,15 @@ function TextFieldBase(props) {
|
|
|
114
120
|
...(showHover ? fieldStyles.hover : {}),
|
|
115
121
|
// Only show error styles if the field is not disabled, following the pattern that the error message is also hidden
|
|
116
122
|
...(errorMsg && !inputProps.disabled ? fieldStyles.error : {}),
|
|
117
|
-
...Css_1.Css.if(multiline).aifs.mhPx(textAreaMinHeight).$,
|
|
118
|
-
}, ...hoverProps, ref: inputWrapRef, children: [labelStyle === "inline" && label && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, { multiline: multiline, labelProps: labelProps, label: label, ...tid.label })), startAdornment && (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.df.aic.asc.fs0.br4.pr1.$, children: startAdornment }), (0, jsx_runtime_1.jsx)(
|
|
123
|
+
...Css_1.Css.if(multiline).aifs.overflowHidden.mhPx(textAreaMinHeight).$,
|
|
124
|
+
}, ...hoverProps, ref: inputWrapRef, onClick: unfocusedPlaceholder ? handleUnfocusedPlaceholderClick : undefined, children: [labelStyle === "inline" && label && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, { multiline: multiline, labelProps: labelProps, label: label, ...tid.label })), startAdornment && (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.df.aic.asc.fs0.br4.pr1.$, children: startAdornment }), unfocusedPlaceholder && ((0, jsx_runtime_1.jsx)("div", { ...tid.unfocusedPlaceholderContainer, css: {
|
|
125
|
+
...Css_1.Css.df.asc.w100.maxh100.overflowAuto.$,
|
|
126
|
+
...(isFocused && Css_1.Css.visuallyHidden.$),
|
|
127
|
+
}, children: unfocusedPlaceholder })), (0, jsx_runtime_1.jsx)(ElementType, { ...(0, react_aria_1.mergeProps)(inputProps, { onBlur, onFocus: onFocusChained, onChange: onDomChange }, { "aria-invalid": Boolean(errorMsg), ...(labelStyle === "hidden" ? { "aria-label": label } : {}) }), ...(errorMsg ? { "aria-errormessage": errorMessageId } : {}), ref: fieldRef, rows: multiline ? 1 : undefined, css: {
|
|
119
128
|
...fieldStyles.input,
|
|
120
129
|
...(inputProps.disabled ? fieldStyles.disabled : {}),
|
|
121
130
|
...(showHover ? fieldStyles.hover : {}),
|
|
131
|
+
...(unfocusedPlaceholder && !isFocused && Css_1.Css.visuallyHidden.$),
|
|
122
132
|
...xss,
|
|
123
133
|
}, ...tid }), isFocused && clearable && onChange && inputProps.value && ((0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "xCircle", color: Css_1.Palette.Gray700, onClick: () => {
|
|
124
134
|
var _a;
|
|
@@ -7,7 +7,6 @@ const react_aria_1 = require("react-aria");
|
|
|
7
7
|
const components_1 = require("../../components");
|
|
8
8
|
const PresentationContext_1 = require("../../components/PresentationContext");
|
|
9
9
|
const Css_1 = require("../../Css");
|
|
10
|
-
const useGrowingTextField_1 = require("../hooks/useGrowingTextField");
|
|
11
10
|
const TextFieldBase_1 = require("../TextFieldBase");
|
|
12
11
|
const TreeSelectField_1 = require("../TreeSelectField/TreeSelectField");
|
|
13
12
|
const utils_1 = require("../TreeSelectField/utils");
|
|
@@ -21,11 +20,13 @@ function ComboBoxInput(props) {
|
|
|
21
20
|
const [isFocused, setIsFocused] = (0, react_1.useState)(false);
|
|
22
21
|
const isMultiSelect = state.selectionManager.selectionMode === "multiple";
|
|
23
22
|
const showNumSelection = isMultiSelect && state.selectionManager.selectedKeys.size > 1;
|
|
23
|
+
// Show selections as chips
|
|
24
|
+
const hasSelection = state.selectionManager.selectedKeys.size > 0;
|
|
24
25
|
// For MultiSelect only show the `fieldDecoration` when input is not in focus.
|
|
25
26
|
const showFieldDecoration = (!isMultiSelect || (isMultiSelect && !isFocused)) && fieldDecoration && selectedOptions.length === 1;
|
|
26
27
|
const multilineProps = allowWrap ? { textAreaMinHeight: 0, multiline: true } : {};
|
|
27
|
-
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { ...otherProps, ...multilineProps, inputRef: inputRef, inputWrapRef: inputWrapRef, errorMsg: errorMsg, contrast: contrast, xss: otherProps.labelStyle !== "inline" && !inputProps.readOnly ? Css_1.Css.fw5.$ : {}, startAdornment: (showNumSelection && ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.wPx(16).hPx(16).fs0.br100.bgBlue700.white.tinySb.df.aic.jcc.$, "data-testid": "selectedOptionsCount", children: isTree ? selectedOptionsLabels === null || selectedOptionsLabels === void 0 ? void 0 : selectedOptionsLabels.length : state.selectionManager.selectedKeys.size }))) ||
|
|
28
|
+
const chipLabels = isTree ? selectedOptionsLabels || [] : selectedOptions.map((o) => getOptionLabel(o));
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { ...otherProps, ...multilineProps, unfocusedPlaceholder: hasSelection && (0, jsx_runtime_1.jsx)(components_1.Chips, { compact: otherProps.compact, values: chipLabels }), inputRef: inputRef, inputWrapRef: inputWrapRef, errorMsg: errorMsg, contrast: contrast, xss: otherProps.labelStyle !== "inline" && !inputProps.readOnly ? Css_1.Css.fw5.$ : {}, startAdornment: (showNumSelection && ((0, jsx_runtime_1.jsx)(components_1.Tooltip, { title: (0, jsx_runtime_1.jsx)(SelectedOptionBullets, { labels: chipLabels }), children: (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.wPx(16).hPx(16).fs0.br100.bgBlue700.white.tinySb.df.aic.jcc.$, "data-testid": "selectedOptionsCount", children: isTree ? selectedOptionsLabels === null || selectedOptionsLabels === void 0 ? void 0 : selectedOptionsLabels.length : state.selectionManager.selectedKeys.size }) }))) ||
|
|
29
30
|
(showFieldDecoration && fieldDecoration(selectedOptions[0])), endAdornment: !inputProps.readOnly && ((0, jsx_runtime_1.jsx)("button", { ...buttonProps, disabled: inputProps.disabled, ref: buttonRef, css: {
|
|
30
31
|
...Css_1.Css.br4.outline0.gray700.if(contrast).gray400.$,
|
|
31
32
|
...(inputProps.disabled ? Css_1.Css.cursorNotAllowed.gray400.if(contrast).gray600.$ : {}),
|
|
@@ -141,3 +142,6 @@ function ComboBoxInput(props) {
|
|
|
141
142
|
} }));
|
|
142
143
|
}
|
|
143
144
|
exports.ComboBoxInput = ComboBoxInput;
|
|
145
|
+
function SelectedOptionBullets({ labels = [] }) {
|
|
146
|
+
return (0, jsx_runtime_1.jsx)("div", { children: labels === null || labels === void 0 ? void 0 : labels.map((label) => (0, jsx_runtime_1.jsx)("li", { children: label }, label)) });
|
|
147
|
+
}
|