@homebound/beam 2.370.1 → 2.371.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/components/Banner.d.ts +1 -0
- package/dist/components/Banner.js +2 -2
- package/dist/components/Icon.d.ts +1 -0
- package/dist/components/Icon.js +1 -0
- package/dist/components/PresentationContext.d.ts +1 -0
- package/dist/components/Table/GridTable.js +5 -3
- package/dist/components/Table/TableStyles.d.ts +3 -1
- package/dist/components/Table/TableStyles.js +9 -3
- package/dist/components/Table/components/Row.d.ts +2 -0
- package/dist/components/Table/components/Row.js +5 -2
- package/dist/inputs/TextFieldBase.d.ts +1 -1
- package/dist/inputs/TextFieldBase.js +24 -10
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ export interface BannerProps {
|
|
|
3
3
|
type: BannerTypes;
|
|
4
4
|
message: ReactNode;
|
|
5
5
|
onClose?: VoidFunction;
|
|
6
|
+
showIcon?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare function Banner(props: BannerProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
9
|
export type BannerTypes = "error" | "warning" | "success" | "info" | "alert";
|
|
@@ -7,9 +7,9 @@ const IconButton_1 = require("./IconButton");
|
|
|
7
7
|
const Css_1 = require("../Css");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
function Banner(props) {
|
|
10
|
-
const { type, message, onClose = false, ...others } = props;
|
|
10
|
+
const { type, message, onClose = false, showIcon = true, ...others } = props;
|
|
11
11
|
const tid = (0, utils_1.useTestIds)(others, "banner");
|
|
12
|
-
return ((0, jsx_runtime_1.jsxs)("div", { css: { ...variantStyles[type], ...Css_1.Css.df.aic.w100.gap1.p2.gray900.base.bshBasic.$ }, ...tid, role: "alert", children: [(0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.$, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: typeToIcon[type], ...tid.type, color: Css_1.Palette.Gray900 }) }), (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fg1.$, ...tid.message, children: message }), onClose && ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lh(0).$, children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { icon: "x", onClick: onClose, ...tid.close, color: Css_1.Palette.Gray900 }) }))] }));
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: { ...variantStyles[type], ...Css_1.Css.df.aic.w100.gap1.p2.gray900.base.bshBasic.$ }, ...tid, role: "alert", children: [showIcon && ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.$, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: typeToIcon[type], ...tid.type, color: Css_1.Palette.Gray900 }) })), (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fg1.$, ...tid.message, children: message }), onClose && ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.lh(0).$, children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { icon: "x", onClick: onClose, ...tid.close, color: Css_1.Palette.Gray900 }) }))] }));
|
|
13
13
|
}
|
|
14
14
|
const typeToIcon = {
|
|
15
15
|
success: "checkCircle",
|
|
@@ -39,6 +39,7 @@ export declare const Icons: {
|
|
|
39
39
|
check: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
40
40
|
search: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
41
41
|
comment: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
42
|
+
commentFilled: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
42
43
|
plus: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
43
44
|
minus: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
44
45
|
pencil: import("@emotion/react/jsx-runtime").JSX.Element;
|
package/dist/components/Icon.js
CHANGED
|
@@ -44,6 +44,7 @@ exports.Icons = {
|
|
|
44
44
|
check: ((0, jsx_runtime_1.jsx)("path", { d: "M9.99997 15.586L6.70697 12.293L5.29297 13.707L9.99997 18.414L19.707 8.70697L18.293 7.29297L9.99997 15.586Z" })),
|
|
45
45
|
search: ((0, jsx_runtime_1.jsx)("path", { d: "M10 18C11.846 18 13.543 17.365 14.897 16.312L19.293 20.708L20.707 19.294L16.311 14.898C17.365 13.543 18 11.846 18 10C18 5.589 14.411 2 10 2C5.589 2 2 5.589 2 10C2 14.411 5.589 18 10 18ZM10 4C13.309 4 16 6.691 16 10C16 13.309 13.309 16 10 16C6.691 16 4 13.309 4 10C4 6.691 6.691 4 10 4Z" })),
|
|
46
46
|
comment: ((0, jsx_runtime_1.jsx)("path", { d: "M12 2C6.486 2 2 5.589 2 10C2 12.908 3.898 15.516 7 16.934V22L12.34 17.995C17.697 17.852 22 14.32 22 10C22 5.589 17.514 2 12 2ZM12 16H11.667L9 18V15.583L8.359 15.336C5.67 14.301 4 12.256 4 10C4 6.691 7.589 4 12 4C16.411 4 20 6.691 20 10C20 13.309 16.411 16 12 16Z" })),
|
|
47
|
+
commentFilled: ((0, jsx_runtime_1.jsx)("path", { d: "M10 0C4.486 0 0 3.589 0 8C0 10.908 1.898 13.516 5 14.934V20L10.34 15.995C15.697 15.852 20 12.32 20 8C20 3.589 15.514 0 10 0Z" })),
|
|
47
48
|
plus: (0, jsx_runtime_1.jsx)("path", { d: "M19 11H13V5H11V11H5V13H11V19H13V13H19V11Z" }),
|
|
48
49
|
minus: (0, jsx_runtime_1.jsx)("rect", { x: "6", y: "11", width: "12", height: "2" }),
|
|
49
50
|
pencil: ((0, jsx_runtime_1.jsx)("path", { d: "M4.0031 21.0001C4.0841 21.0001 4.1651 20.9901 4.2451 20.9701L8.2451 19.9701C8.4211 19.9261 8.5821 19.8351 8.7101 19.7071L21.0031 7.41411C21.3811 7.03611 21.5891 6.53411 21.5891 6.00011C21.5891 5.46611 21.3811 4.96411 21.0031 4.58611L19.4171 3.00011C18.6611 2.24411 17.3451 2.24411 16.5891 3.00011L4.2961 15.2931C4.1681 15.4211 4.0771 15.5821 4.0331 15.7571L3.0331 19.7571C2.9471 20.0981 3.0481 20.4581 3.2961 20.7071C3.4851 20.8971 3.7411 21.0001 4.0031 21.0001ZM18.0031 4.41411L19.5891 6.00011L18.0031 7.58611L16.4171 6.00011L18.0031 4.41411ZM5.9061 16.5111L15.0031 7.41411L16.5891 9.00011L7.4911 18.0971L5.3771 18.6251L5.9061 16.5111Z" })),
|
|
@@ -87,7 +87,7 @@ function setGridTableDefaults(opts) {
|
|
|
87
87
|
* https://docs.google.com/document/d/1DFnlkDubK4nG_GLf_hB8yp0flnSNt_3IBh5iOicuaFM/edit#heading=h.9m9cpwgeqfc9
|
|
88
88
|
*/
|
|
89
89
|
function GridTable(props) {
|
|
90
|
-
var _a, _b, _c;
|
|
90
|
+
var _a, _b, _c, _d;
|
|
91
91
|
const { id = "gridTable", as = "div", columns: _columns, rows, style: maybeStyle = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = 0, xss, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, persistCollapse, resizeTarget, activeRowId, activeCellId, visibleColumnsStorageKey, infiniteScroll, onRowSelect, onRowDrop: droppedCallback, csvPrefixRows, } = props;
|
|
92
92
|
const columnsWithIds = (0, react_1.useMemo)(() => (0, columns_1.assignDefaultColumnIds)(_columns), [_columns]);
|
|
93
93
|
// We only use this in as=virtual mode, but keep this here for rowLookup to use
|
|
@@ -277,6 +277,7 @@ function GridTable(props) {
|
|
|
277
277
|
const firstRowMessage = (noData && fallbackMessage) || (tooManyClientSideRows && "Hiding some rows, use filter...") || infoMessage;
|
|
278
278
|
const borderless = (_a = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _a === void 0 ? void 0 : _a.borderless;
|
|
279
279
|
const typeScale = (_b = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _b === void 0 ? void 0 : _b.typeScale;
|
|
280
|
+
const borderOnHover = (_c = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _c === void 0 ? void 0 : _c.borderOnHover;
|
|
280
281
|
const fieldProps = (0, react_1.useMemo)(() => ({
|
|
281
282
|
labelStyle: "hidden",
|
|
282
283
|
numberAlignment: "right",
|
|
@@ -285,14 +286,15 @@ function GridTable(props) {
|
|
|
285
286
|
// Avoid passing `undefined` as it will unset existing PresentationContext settings
|
|
286
287
|
...(borderless !== undefined ? { borderless } : {}),
|
|
287
288
|
...(typeScale !== undefined ? { typeScale } : {}),
|
|
288
|
-
|
|
289
|
+
...(borderOnHover !== undefined ? { borderOnHover } : {}),
|
|
290
|
+
}), [borderOnHover, borderless, typeScale]);
|
|
289
291
|
// If we're running in Jest, force using `as=div` b/c jsdom doesn't support react-virtuoso.
|
|
290
292
|
// This enables still putting the application's business/rendering logic under test, and letting it
|
|
291
293
|
// just trust the GridTable impl that, at runtime, `as=virtual` will (other than being virtualized)
|
|
292
294
|
// behave semantically the same as `as=div` did for its tests.
|
|
293
295
|
const _as = as === "virtual" && runningInJest ? "div" : as;
|
|
294
296
|
const rowStateContext = (0, react_1.useMemo)(() => ({ tableState: tableState }), [tableState]);
|
|
295
|
-
return ((0, jsx_runtime_1.jsx)(TableState_1.TableStateContext.Provider, { value: rowStateContext, children: (0, jsx_runtime_1.jsxs)(PresentationContext_1.PresentationProvider, { fieldProps: fieldProps, wrap: (
|
|
297
|
+
return ((0, jsx_runtime_1.jsx)(TableState_1.TableStateContext.Provider, { value: rowStateContext, children: (0, jsx_runtime_1.jsxs)(PresentationContext_1.PresentationProvider, { fieldProps: fieldProps, wrap: (_d = style === null || style === void 0 ? void 0 : style.presentationSettings) === null || _d === void 0 ? void 0 : _d.wrap, children: [(0, jsx_runtime_1.jsx)("div", { ref: resizeRef, css: (0, components_1.getTableRefWidthStyles)(as === "virtual") }), renders[_as](style, id, columns, visibleDataRows, keptSelectedRows, firstRowMessage, stickyHeader, xss, virtuosoRef, tableHeadRows, stickyOffset, infiniteScroll)] }) }));
|
|
296
298
|
}
|
|
297
299
|
// Determine which HTML element to use to build the GridTable
|
|
298
300
|
const renders = {
|
|
@@ -44,7 +44,7 @@ export interface GridStyle {
|
|
|
44
44
|
nonHeaderRowHoverCss?: Properties;
|
|
45
45
|
/** Default content to put into an empty cell */
|
|
46
46
|
emptyCell?: ReactNode;
|
|
47
|
-
presentationSettings?: Pick<PresentationFieldProps, "borderless" | "typeScale"> & Pick<PresentationContextProps, "wrap">;
|
|
47
|
+
presentationSettings?: Pick<PresentationFieldProps, "borderless" | "borderOnHover" | "typeScale"> & Pick<PresentationContextProps, "wrap">;
|
|
48
48
|
/** Minimum table width in pixels. Used when calculating columns sizes */
|
|
49
49
|
minWidthPx?: number;
|
|
50
50
|
/** Css to apply at each level of a parent/child nested table. */
|
|
@@ -84,6 +84,8 @@ export interface GridStyleDef {
|
|
|
84
84
|
vAlign?: "top" | "center" | "bottom";
|
|
85
85
|
/** Defines the Typography for the table body's cells (not the header). This only applies to rows that are not nested/grouped */
|
|
86
86
|
cellTypography?: Typography;
|
|
87
|
+
/** Defines if the table should highlight the row on hover. Defaults to true */
|
|
88
|
+
highlightOnHover?: boolean;
|
|
87
89
|
}
|
|
88
90
|
export declare const getTableStyles: (props?: GridStyleDef) => GridStyle;
|
|
89
91
|
export declare const totalsRowHeight = 40;
|
|
@@ -8,7 +8,7 @@ const utils_1 = require("../../utils");
|
|
|
8
8
|
function memoizedTableStyles() {
|
|
9
9
|
const cache = {};
|
|
10
10
|
return (props = {}) => {
|
|
11
|
-
const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight = false, allWhite = false, bordered = false, vAlign = "center", cellTypography = "xs", } = props;
|
|
11
|
+
const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight = false, allWhite = false, bordered = false, vAlign = "center", cellTypography = "xs", highlightOnHover = true, } = props;
|
|
12
12
|
const key = (0, utils_1.safeKeys)(props)
|
|
13
13
|
.sort()
|
|
14
14
|
.map((k) => `${k}_${props[k]}`)
|
|
@@ -64,9 +64,14 @@ function memoizedTableStyles() {
|
|
|
64
64
|
lastRowCss: bordered
|
|
65
65
|
? Css_1.Css.addIn("& > *:first-of-type", Css_1.Css.borderRadius("0 0 0 8px").$).addIn("& > *:last-of-type", Css_1.Css.borderRadius("0 0 8px 0").$).$
|
|
66
66
|
: Css_1.Css.addIn("> *", Css_1.Css.bsh0.$).$,
|
|
67
|
-
presentationSettings: {
|
|
67
|
+
presentationSettings: {
|
|
68
|
+
borderless: true,
|
|
69
|
+
typeScale: "xs",
|
|
70
|
+
wrap: rowHeight === "flexible",
|
|
71
|
+
borderOnHover: highlightOnHover,
|
|
72
|
+
},
|
|
68
73
|
levels: grouped ? groupedLevels : defaultLevels,
|
|
69
|
-
rowHoverColor: Css_1.Palette.
|
|
74
|
+
rowHoverColor: Css_1.Palette.Blue50,
|
|
70
75
|
keptGroupRowCss: Css_1.Css.bgYellow100.gray900.xsMd.df.aic.$,
|
|
71
76
|
keptLastRowCss: Css_1.Css.boxShadow("inset 0px -14px 8px -11px rgba(63,63,63,.18)").$,
|
|
72
77
|
};
|
|
@@ -117,6 +122,7 @@ function resolveStyles(style) {
|
|
|
117
122
|
rowHover: true,
|
|
118
123
|
vAlign: true,
|
|
119
124
|
cellTypography: true,
|
|
125
|
+
highlightOnHover: true,
|
|
120
126
|
};
|
|
121
127
|
const keys = (0, utils_1.safeKeys)(style);
|
|
122
128
|
const defKeys = (0, utils_1.safeKeys)(defKeysRecord);
|
|
@@ -72,4 +72,6 @@ export type GridDataRow<R extends Kinded> = {
|
|
|
72
72
|
/** Whether this row is draggable, usually to allow drag & drop reordering of rows */
|
|
73
73
|
draggable?: boolean;
|
|
74
74
|
} & IfAny<R, AnyObject, DiscriminateUnion<R, "kind", R["kind"]>>;
|
|
75
|
+
export declare const BorderHoverParent = "BorderHoverParent";
|
|
76
|
+
export declare const BorderHoverChild = "BorderHoverChild";
|
|
75
77
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Row = void 0;
|
|
3
|
+
exports.BorderHoverChild = exports.BorderHoverParent = exports.Row = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const mobx_react_1 = require("mobx-react");
|
|
6
6
|
const react_1 = require("react");
|
|
@@ -75,7 +75,7 @@ function RowImpl(props) {
|
|
|
75
75
|
const dragOverCallback = (0, react_1.useCallback)((row, evt) => onDragOver === null || onDragOver === void 0 ? void 0 : onDragOver(row, evt), [onDragOver]);
|
|
76
76
|
// when the event is not called, we still need to call preventDefault
|
|
77
77
|
const onDragOverDebounced = (0, use_debounce_1.useDebouncedCallback)(dragOverCallback, 100);
|
|
78
|
-
const RowContent = () => ((0, jsx_runtime_1.jsx)(RowTag, { css: rowCss, ...others, "data-gridrow": true, ...getCount(row.id), ref: ref, children: isKeptGroupRow ? ((0, jsx_runtime_1.jsx)(KeptGroupRow_1.KeptGroupRow, { as: as, style: style, columnSizes: columnSizes, row: row, colSpan: columns.length })) : (columns.map((column, columnIndex) => {
|
|
78
|
+
const RowContent = () => ((0, jsx_runtime_1.jsx)(RowTag, { css: rowCss, ...others, "data-gridrow": true, ...getCount(row.id), ref: ref, className: exports.BorderHoverParent, children: isKeptGroupRow ? ((0, jsx_runtime_1.jsx)(KeptGroupRow_1.KeptGroupRow, { as: as, style: style, columnSizes: columnSizes, row: row, colSpan: columns.length })) : (columns.map((column, columnIndex) => {
|
|
79
79
|
var _a, _b;
|
|
80
80
|
// If the expandable column was hidden, then we need to look at the previous column to format the `expandHeader` and 'header' kinds correctly.
|
|
81
81
|
const maybeExpandedColumn = expandColumnHidden ? columns[columnIndex - 1] : column;
|
|
@@ -251,3 +251,6 @@ function RowImpl(props) {
|
|
|
251
251
|
*/
|
|
252
252
|
// Declared as a const + `as typeof RowImpl` to work with generics, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/37087#issuecomment-656596623
|
|
253
253
|
exports.Row = (0, mobx_react_1.observer)(RowImpl);
|
|
254
|
+
// Used by TextFieldBase to set a border when the row is being hovered over
|
|
255
|
+
exports.BorderHoverParent = "BorderHoverParent";
|
|
256
|
+
exports.BorderHoverChild = "BorderHoverChild";
|
|
@@ -2,7 +2,7 @@ import type { NumberFieldAria } from "@react-aria/numberfield";
|
|
|
2
2
|
import { InputHTMLAttributes, LabelHTMLAttributes, MutableRefObject, ReactNode, TextareaHTMLAttributes } from "react";
|
|
3
3
|
import { Only } from "../Css";
|
|
4
4
|
import { BeamTextFieldProps, TextFieldXss } from "../interfaces";
|
|
5
|
-
export interface TextFieldBaseProps<X> extends Pick<BeamTextFieldProps<X>, "label" | "required" | "errorMsg" | "errorInTooltip" | "onBlur" | "onFocus" | "helperText" | "labelStyle" | "placeholder" | "compact" | "borderless" | "visuallyDisabled" | "fullWidth" | "xss">, Partial<Pick<BeamTextFieldProps<X>, "onChange">> {
|
|
5
|
+
export interface TextFieldBaseProps<X> extends Pick<BeamTextFieldProps<X>, "label" | "required" | "errorMsg" | "errorInTooltip" | "onBlur" | "onFocus" | "helperText" | "labelStyle" | "placeholder" | "compact" | "borderless" | "borderOnHover" | "visuallyDisabled" | "fullWidth" | "xss">, Partial<Pick<BeamTextFieldProps<X>, "onChange">> {
|
|
6
6
|
labelProps?: LabelHTMLAttributes<HTMLLabelElement>;
|
|
7
7
|
inputProps: InputHTMLAttributes<HTMLInputElement> | TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
8
8
|
inputRef?: MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null>;
|
|
@@ -8,6 +8,7 @@ const components_1 = require("../components");
|
|
|
8
8
|
const HelperText_1 = require("../components/HelperText");
|
|
9
9
|
const Label_1 = require("../components/Label");
|
|
10
10
|
const PresentationContext_1 = require("../components/PresentationContext");
|
|
11
|
+
const Row_1 = require("../components/Table/components/Row");
|
|
11
12
|
const Css_1 = require("../Css");
|
|
12
13
|
const labelUtils_1 = require("../forms/labelUtils");
|
|
13
14
|
const useGetRef_1 = require("../hooks/useGetRef");
|
|
@@ -17,11 +18,11 @@ const defaultTestId_1 = require("../utils/defaultTestId");
|
|
|
17
18
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
18
19
|
// Used by both TextField and TextArea
|
|
19
20
|
function TextFieldBase(props) {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
21
22
|
const { fieldProps, wrap = false } = (0, PresentationContext_1.usePresentationContext)();
|
|
22
23
|
const { labelLeftFieldWidth = "50%" } = fieldProps !== null && fieldProps !== void 0 ? fieldProps : {};
|
|
23
|
-
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 = (
|
|
24
|
-
const typeScale = (
|
|
24
|
+
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, borderOnHover = (_d = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.borderOnHover) !== null && _d !== void 0 ? _d : false, textAreaMinHeight = 96, clearable = false, tooltip, visuallyDisabled = (_e = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.visuallyDisabled) !== null && _e !== void 0 ? _e : true, errorInTooltip = (_f = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.errorInTooltip) !== null && _f !== void 0 ? _f : false, hideErrorMessage = false, alwaysShowHelperText = false, fullWidth = (_g = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _g !== void 0 ? _g : false, unfocusedPlaceholder, selectOnFocus = true, } = props;
|
|
25
|
+
const typeScale = (_h = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.typeScale) !== null && _h !== void 0 ? _h : (inputProps.readOnly && labelStyle !== "hidden" ? "smMd" : "sm");
|
|
25
26
|
const internalProps = props.internalProps || {};
|
|
26
27
|
const { compound = false, forceFocus = false, forceHover = false } = internalProps;
|
|
27
28
|
const errorMessageId = `${inputProps.id}-error`;
|
|
@@ -37,9 +38,12 @@ function TextFieldBase(props) {
|
|
|
37
38
|
const compactFieldHeight = 32;
|
|
38
39
|
const [bgColor, hoverBgColor, disabledBgColor] = contrast
|
|
39
40
|
? [Css_1.Palette.Gray700, Css_1.Palette.Gray600, Css_1.Palette.Gray700]
|
|
40
|
-
:
|
|
41
|
-
?
|
|
42
|
-
|
|
41
|
+
: borderOnHover
|
|
42
|
+
? // Use transparent backgrounds to blend with the table row hover color
|
|
43
|
+
[Css_1.Palette.Transparent, Css_1.Palette.Blue100, Css_1.Palette.Gray100]
|
|
44
|
+
: borderless && !compound
|
|
45
|
+
? [Css_1.Palette.Gray100, Css_1.Palette.Gray200, Css_1.Palette.Gray200]
|
|
46
|
+
: [Css_1.Palette.White, Css_1.Palette.Gray100, Css_1.Palette.Gray100];
|
|
43
47
|
const fieldMaxWidth = (0, utils_1.getFieldWidth)(fullWidth);
|
|
44
48
|
const fieldStyles = {
|
|
45
49
|
container: Css_1.Css.df.fdc.w100.maxw(fieldMaxWidth).relative.if(labelStyle === "left").maxw100.fdr.gap2.jcsb.aic.$,
|
|
@@ -58,6 +62,12 @@ function TextFieldBase(props) {
|
|
|
58
62
|
: Css_1.Css.bcGray300.if(contrast).bcGray700.$),
|
|
59
63
|
// Do not add borders to compound fields. A compound field is responsible for drawing its own borders
|
|
60
64
|
...(!compound ? Css_1.Css.ba.$ : {}),
|
|
65
|
+
...(borderOnHover && Css_1.Css.br4.ba.bcTransparent.add("transition", "border-color 200ms").$),
|
|
66
|
+
...(borderOnHover && Css_1.Css.if(isHovered).bgBlue100.ba.bcBlue300.$),
|
|
67
|
+
...{
|
|
68
|
+
// Highlight the field when hovering over the row in a table, unless some other edit component (including ourselves) is hovered
|
|
69
|
+
[`.${Row_1.BorderHoverParent}:hover:not(:has(.${Row_1.BorderHoverChild}:hover)) &`]: Css_1.Css.ba.bcBlue300.$,
|
|
70
|
+
},
|
|
61
71
|
// When multiline is true, then we want to allow the field to grow to the height of the content, but not shrink below the minHeight
|
|
62
72
|
// Otherwise, set fixed heights values accordingly.
|
|
63
73
|
...(multiline
|
|
@@ -83,11 +93,13 @@ function TextFieldBase(props) {
|
|
|
83
93
|
...Css_1.Css.w100.mw0.outline0.fg1.bgColor(bgColor).$,
|
|
84
94
|
// Not using Truss's inline `if` statement here because `addIn` properties do not respect the if statement.
|
|
85
95
|
...(contrast && Css_1.Css.addIn("&::selection", Css_1.Css.bgGray800.$).$),
|
|
96
|
+
// Make the background transparent when highlighting the field on hover
|
|
97
|
+
...(borderOnHover && Css_1.Css.bgTransparent.$),
|
|
86
98
|
// 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
|
|
87
99
|
...(multiline ? Css_1.Css.br4.pyPx(compact ? 7 : 11).add("resize", "none").$ : Css_1.Css.truncate.$),
|
|
88
100
|
},
|
|
89
101
|
hover: Css_1.Css.bgColor(hoverBgColor).if(contrast).bcGray600.$,
|
|
90
|
-
focus: Css_1.Css.bcBlue700.if(contrast).bcBlue500.$,
|
|
102
|
+
focus: Css_1.Css.bcBlue700.if(contrast).bcBlue500.if(borderOnHover).bgBlue100.bcBlue500.$,
|
|
91
103
|
disabled: visuallyDisabled
|
|
92
104
|
? Css_1.Css.cursorNotAllowed.gray600.bgColor(disabledBgColor).if(contrast).gray500.$
|
|
93
105
|
: Css_1.Css.cursorNotAllowed.$,
|
|
@@ -123,8 +135,8 @@ function TextFieldBase(props) {
|
|
|
123
135
|
...fieldStyles.inputWrapperReadOnly,
|
|
124
136
|
...(multiline ? Css_1.Css.fdc.aifs.gap2.$ : Css_1.Css.if(wrap === false).truncate.$),
|
|
125
137
|
...xss,
|
|
126
|
-
}, "data-readonly": "true", ...tid, children: [labelStyle === "inline" && label && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, { multiline: multiline, labelProps: labelProps, label: label, ...tid.label })), multiline
|
|
127
|
-
? (
|
|
138
|
+
}, className: Row_1.BorderHoverChild, "data-readonly": "true", ...tid, children: [labelStyle === "inline" && label && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, { multiline: multiline, labelProps: labelProps, label: label, ...tid.label })), multiline
|
|
139
|
+
? (_j = inputProps.value) === null || _j === void 0 ? void 0 : _j.split("\n\n").map((p, i) => ((0, jsx_runtime_1.jsx)("p", { css: Css_1.Css.py1.$, children: p.split("\n").map((sentence, j) => ((0, jsx_runtime_1.jsxs)("span", { children: [sentence, (0, jsx_runtime_1.jsx)("br", {})] }, j))) }, i)))
|
|
128
140
|
: inputProps.value] })) : ((0, jsx_runtime_1.jsxs)("div", { css: {
|
|
129
141
|
...fieldStyles.inputWrapper,
|
|
130
142
|
...(inputProps.disabled ? fieldStyles.disabled : {}),
|
|
@@ -133,7 +145,9 @@ function TextFieldBase(props) {
|
|
|
133
145
|
// Only show error styles if the field is not disabled, following the pattern that the error message is also hidden
|
|
134
146
|
...(errorMsg && !inputProps.disabled ? fieldStyles.error : {}),
|
|
135
147
|
...Css_1.Css.if(multiline).aifs.oh.mhPx(textAreaMinHeight).$,
|
|
136
|
-
},
|
|
148
|
+
},
|
|
149
|
+
// Class name used for the grid table on row hover for highlighting
|
|
150
|
+
className: Row_1.BorderHoverChild, ...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", {
|
|
137
151
|
// Setting -1 tabIndex as this is a scrollable container, which is focusable by default.
|
|
138
152
|
// However, we want the user's focus to move to the field element, which will hide this container.
|
|
139
153
|
tabIndex: -1, ...tid.unfocusedPlaceholderContainer, css: {
|