@homebound/beam 2.122.0 → 2.123.1
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/PresentationContext.d.ts +1 -0
- package/dist/components/Table/CollapseToggle.d.ts +2 -2
- package/dist/components/Table/CollapseToggle.js +3 -3
- package/dist/components/Table/GridTable.d.ts +14 -3
- package/dist/components/Table/GridTable.js +13 -7
- package/dist/components/Table/columns.js +7 -3
- package/dist/components/Table/sortRows.js +2 -2
- package/dist/components/Table/styles.js +4 -4
- package/dist/forms/formStateDomain.d.ts +2 -0
- package/dist/forms/formStateDomain.js +2 -1
- package/dist/inputs/TextFieldBase.js +16 -11
- package/dist/interfaces.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GridDataRow } from "..";
|
|
2
|
-
export interface GridTableCollapseToggleProps {
|
|
1
|
+
import { GridDataRow, IconButtonProps } from "..";
|
|
2
|
+
export interface GridTableCollapseToggleProps extends Pick<IconButtonProps, "compact"> {
|
|
3
3
|
row: GridDataRow<any>;
|
|
4
4
|
}
|
|
5
5
|
/** Provides a chevron icons to collapse/un-collapse for parent/child tables. */
|
|
@@ -7,16 +7,16 @@ const components_1 = require("..");
|
|
|
7
7
|
const hooks_1 = require("../../hooks");
|
|
8
8
|
/** Provides a chevron icons to collapse/un-collapse for parent/child tables. */
|
|
9
9
|
function CollapseToggle(props) {
|
|
10
|
-
const { row } = props;
|
|
10
|
+
const { row, compact } = props;
|
|
11
11
|
const { rowState } = (0, react_1.useContext)(components_1.RowStateContext);
|
|
12
12
|
const isCollapsed = (0, hooks_1.useComputed)(() => rowState.isCollapsed(row.id), [rowState]);
|
|
13
13
|
const iconKey = isCollapsed ? "chevronRight" : "chevronDown";
|
|
14
14
|
const headerIconKey = isCollapsed ? "chevronsRight" : "chevronsDown";
|
|
15
15
|
// If we're not a header, only render a toggle if we have child rows to actually collapse
|
|
16
16
|
const isHeader = row.kind === "header";
|
|
17
|
-
if (!isHeader && (!
|
|
17
|
+
if (!isHeader && (!row.children || row.children.length === 0)) {
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
|
-
return (0, jsx_runtime_1.jsx)(components_1.IconButton, { onClick: () => rowState.toggleCollapsed(row.id), icon: isHeader ? headerIconKey : iconKey }, void 0);
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(components_1.IconButton, { onClick: () => rowState.toggleCollapsed(row.id), icon: isHeader ? headerIconKey : iconKey, compact: compact }, void 0));
|
|
21
21
|
}
|
|
22
22
|
exports.CollapseToggle = CollapseToggle;
|
|
@@ -53,7 +53,8 @@ export interface GridStyle {
|
|
|
53
53
|
minWidthPx?: number;
|
|
54
54
|
/** Css to apply at each level of a parent/child nested table. */
|
|
55
55
|
levels?: Record<number, {
|
|
56
|
-
cellCss
|
|
56
|
+
cellCss?: Properties;
|
|
57
|
+
firstContentColumn?: Properties;
|
|
57
58
|
}>;
|
|
58
59
|
/** Allows for customization of the background color used to denote an "active" row */
|
|
59
60
|
activeBgColor?: Palette;
|
|
@@ -232,7 +233,15 @@ declare type GridRowKind<R extends Kinded, P extends R["kind"]> = DiscriminateUn
|
|
|
232
233
|
export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
233
234
|
[K in R["kind"]]: string | GridCellContent | (DiscriminateUnion<R, "kind", K> extends {
|
|
234
235
|
data: infer D;
|
|
235
|
-
} ? (data: D,
|
|
236
|
+
} ? (data: D, opts: {
|
|
237
|
+
row: GridRowKind<R, K>;
|
|
238
|
+
api: GridTableApi<R>;
|
|
239
|
+
level: number;
|
|
240
|
+
}) => ReactNode | GridCellContent : (data: undefined, opts: {
|
|
241
|
+
row: GridRowKind<R, K>;
|
|
242
|
+
api: GridTableApi<R>;
|
|
243
|
+
level: number;
|
|
244
|
+
}) => ReactNode | GridCellContent);
|
|
236
245
|
} & {
|
|
237
246
|
/**
|
|
238
247
|
* The column's width.
|
|
@@ -253,6 +262,8 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
|
253
262
|
sticky?: "left" | "right";
|
|
254
263
|
/** Prevent column from supporting RowStyle.onClick/rowLink in order to avoid nested interactivity. Defaults to true */
|
|
255
264
|
wrapAction?: false;
|
|
265
|
+
/** Used as a signal to defer adding the 'indent' styling */
|
|
266
|
+
isAction?: true;
|
|
256
267
|
};
|
|
257
268
|
export declare const nonKindGridColumnKeys: string[];
|
|
258
269
|
/** Allows rendering a specific cell. */
|
|
@@ -317,6 +328,6 @@ export declare type GridDataRow<R extends Kinded> = {
|
|
|
317
328
|
} & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
|
|
318
329
|
declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
319
330
|
/** Return the content for a given column def applied to a given row. */
|
|
320
|
-
export declare function applyRowFn<R extends Kinded>(column: GridColumn<R>, row: GridDataRow<R>, api: GridTableApi<R
|
|
331
|
+
export declare function applyRowFn<R extends Kinded>(column: GridColumn<R>, row: GridDataRow<R>, api: GridTableApi<R>, level: number): ReactNode | GridCellContent;
|
|
321
332
|
export declare function matchesFilter(maybeContent: ReactNode | GridCellContent, filter: string): boolean;
|
|
322
333
|
export {};
|
|
@@ -125,7 +125,7 @@ function GridTable(props) {
|
|
|
125
125
|
const matches = row.kind === "header" ||
|
|
126
126
|
filters.length === 0 ||
|
|
127
127
|
!!row.pin ||
|
|
128
|
-
filters.every((f) => columns.map((c) => applyRowFn(c, row, api)).some((maybeContent) => matchesFilter(maybeContent, f)));
|
|
128
|
+
filters.every((f) => columns.map((c) => applyRowFn(c, row, api, 0)).some((maybeContent) => matchesFilter(maybeContent, f)));
|
|
129
129
|
// If the row matches, add it in
|
|
130
130
|
if (matches) {
|
|
131
131
|
return acc.concat([[row, (_b = (_a = row.children) === null || _a === void 0 ? void 0 : _a.reduce(filterRows, [])) !== null && _b !== void 0 ? _b : []]]);
|
|
@@ -237,6 +237,7 @@ function GridTable(props) {
|
|
|
237
237
|
hideLabel: true,
|
|
238
238
|
numberAlignment: "right",
|
|
239
239
|
compact: true,
|
|
240
|
+
errorInTooltip: true,
|
|
240
241
|
// Avoid passing `undefined` as it will unset existing PresentationContext settings
|
|
241
242
|
...(borderless !== undefined ? { borderless } : {}),
|
|
242
243
|
...(typeScale !== undefined ? { typeScale } : {}),
|
|
@@ -490,9 +491,12 @@ function GridRow(props) {
|
|
|
490
491
|
...(0, nestedCards_1.getNestedCardStyles)(row, openCardStyles, style, isActive),
|
|
491
492
|
};
|
|
492
493
|
let currentColspan = 1;
|
|
494
|
+
let firstContentColumnStylesApplied = false;
|
|
493
495
|
const rowNode = ((0, jsx_runtime_1.jsx)(Row, Object.assign({ css: rowCss }, others, { "data-gridrow": true }, getCount(row.id), { children: columns.map((column, columnIndex) => {
|
|
494
|
-
var _a, _b, _c, _d, _e;
|
|
495
|
-
const { wrapAction = true } = column;
|
|
496
|
+
var _a, _b, _c, _d, _e, _f;
|
|
497
|
+
const { wrapAction = true, isAction = false } = column;
|
|
498
|
+
const applyFirstContentColumnStyles = !isAction && !firstContentColumnStylesApplied;
|
|
499
|
+
firstContentColumnStylesApplied || (firstContentColumnStylesApplied = applyFirstContentColumnStyles);
|
|
496
500
|
if (column.mw) {
|
|
497
501
|
// Validate the column's minWidth definition if set.
|
|
498
502
|
if (!column.mw.endsWith("px") && !column.mw.endsWith("%")) {
|
|
@@ -504,7 +508,7 @@ function GridRow(props) {
|
|
|
504
508
|
currentColspan -= 1;
|
|
505
509
|
return null;
|
|
506
510
|
}
|
|
507
|
-
const maybeContent = applyRowFn(column, row, api);
|
|
511
|
+
const maybeContent = applyRowFn(column, row, api, level);
|
|
508
512
|
currentColspan = isGridCellContent(maybeContent) ? (_a = maybeContent.colspan) !== null && _a !== void 0 ? _a : 1 : 1;
|
|
509
513
|
const canSortColumn = (sortOn === "client" && column.clientSideSort !== false) ||
|
|
510
514
|
(sortOn === "server" && !!column.serverSideSortKey);
|
|
@@ -559,11 +563,13 @@ function GridRow(props) {
|
|
|
559
563
|
...(isHeader && style.headerCellCss),
|
|
560
564
|
// Or level-specific styling
|
|
561
565
|
...(!isHeader && !!style.levels && ((_d = style.levels[level]) === null || _d === void 0 ? void 0 : _d.cellCss)),
|
|
566
|
+
// Level specific styling for the first content column
|
|
567
|
+
...(applyFirstContentColumnStyles && !!style.levels && ((_e = style.levels[level]) === null || _e === void 0 ? void 0 : _e.firstContentColumn)),
|
|
562
568
|
// The specific cell's css (if any from GridCellContent)
|
|
563
569
|
...rowStyleCellCss,
|
|
564
570
|
// Apply active row styling for non-nested card styles.
|
|
565
571
|
...(style.nestedCards === undefined && isActive
|
|
566
|
-
? Css_1.Css.bgColor((
|
|
572
|
+
? Css_1.Css.bgColor((_f = style.activeBgColor) !== null && _f !== void 0 ? _f : Css_1.Palette.LightBlue50).$
|
|
567
573
|
: {}),
|
|
568
574
|
// Add any cell specific style overrides
|
|
569
575
|
...(isGridCellContent(maybeContent) && maybeContent.typeScale ? Css_1.Css[maybeContent.typeScale].$ : {}),
|
|
@@ -637,12 +643,12 @@ function isContentEmpty(content) {
|
|
|
637
643
|
return emptyValues.includes(content);
|
|
638
644
|
}
|
|
639
645
|
/** Return the content for a given column def applied to a given row. */
|
|
640
|
-
function applyRowFn(column, row, api) {
|
|
646
|
+
function applyRowFn(column, row, api, level) {
|
|
641
647
|
// Usually this is a function to apply against the row, but sometimes it's a hard-coded value, i.e. for headers
|
|
642
648
|
const maybeContent = column[row.kind];
|
|
643
649
|
if (typeof maybeContent === "function") {
|
|
644
650
|
// Auto-destructure data
|
|
645
|
-
return maybeContent(row["data"], row, api);
|
|
651
|
+
return maybeContent(row["data"], { row: row, api, level });
|
|
646
652
|
}
|
|
647
653
|
else {
|
|
648
654
|
return maybeContent;
|
|
@@ -24,7 +24,7 @@ function numericColumn(columnDef) {
|
|
|
24
24
|
exports.numericColumn = numericColumn;
|
|
25
25
|
/** Provides default styling for a GridColumn representing an Action. */
|
|
26
26
|
function actionColumn(columnDef) {
|
|
27
|
-
return { clientSideSort: false, ...columnDef, align: "center" };
|
|
27
|
+
return { clientSideSort: false, ...columnDef, align: "center", isAction: true };
|
|
28
28
|
}
|
|
29
29
|
exports.actionColumn = actionColumn;
|
|
30
30
|
/**
|
|
@@ -42,11 +42,12 @@ function selectColumn(columnDef) {
|
|
|
42
42
|
// Defining `w: 48px` to accommodate for the `16px` wide checkbox and `16px` of padding on either side.
|
|
43
43
|
w: "48px",
|
|
44
44
|
wrapAction: false,
|
|
45
|
+
isAction: true,
|
|
45
46
|
// Use any of the user's per-row kind methods if they have them.
|
|
46
47
|
...columnDef,
|
|
47
48
|
};
|
|
48
49
|
return (0, index_1.newMethodMissingProxy)(base, (key) => {
|
|
49
|
-
return (data, row) => ({ content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id }, void 0) });
|
|
50
|
+
return (data, { row }) => ({ content: (0, jsx_runtime_1.jsx)(SelectToggle_1.SelectToggle, { id: row.id }, void 0) });
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
exports.selectColumn = selectColumn;
|
|
@@ -65,10 +66,13 @@ function collapseColumn(columnDef) {
|
|
|
65
66
|
// Defining `w: 38px` based on the designs
|
|
66
67
|
w: "38px",
|
|
67
68
|
wrapAction: false,
|
|
69
|
+
isAction: true,
|
|
68
70
|
...columnDef,
|
|
69
71
|
};
|
|
70
72
|
return (0, index_1.newMethodMissingProxy)(base, (key) => {
|
|
71
|
-
return (data,
|
|
73
|
+
return (data, { row, level }) => ({
|
|
74
|
+
content: (0, jsx_runtime_1.jsx)(CollapseToggle_1.CollapseToggle, { row: row, compact: level > 0 }, void 0),
|
|
75
|
+
});
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
exports.collapseColumn = collapseColumn;
|
|
@@ -21,8 +21,8 @@ function sortBatch(columns, batch, sortState) {
|
|
|
21
21
|
const invert = direction === "DESC";
|
|
22
22
|
// Make a shallow copy for sorting to avoid mutating the original list
|
|
23
23
|
return [...batch].sort((a, b) => {
|
|
24
|
-
const v1 = sortValue((0, GridTable_1.applyRowFn)(column, a, {}));
|
|
25
|
-
const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}));
|
|
24
|
+
const v1 = sortValue((0, GridTable_1.applyRowFn)(column, a, {}, 0));
|
|
25
|
+
const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}, 0));
|
|
26
26
|
const v1e = v1 === null || v1 === undefined;
|
|
27
27
|
const v2e = v2 === null || v2 === undefined;
|
|
28
28
|
if (a.pin || b.pin) {
|
|
@@ -42,7 +42,7 @@ exports.cardStyle = {
|
|
|
42
42
|
// Once completely rolled out across all tables in Blueprint, this will change to be the `defaultStyle`.
|
|
43
43
|
exports.beamFixedStyle = {
|
|
44
44
|
headerCellCss: Css_1.Css.gray700.xsEm.bgGray200.aic.nowrap.pxPx(12).hPx(40).$,
|
|
45
|
-
cellCss: Css_1.Css.gray900.xs.bgWhite.aic.nowrap.pxPx(12).hPx(36).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.
|
|
45
|
+
cellCss: Css_1.Css.gray900.xs.bgWhite.aic.nowrap.pxPx(12).hPx(36).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
|
|
46
46
|
emptyCell: "-",
|
|
47
47
|
presentationSettings: { borderless: true, typeScale: "xs", wrap: false },
|
|
48
48
|
firstRowMessageCss: Css_1.Css.tc.py3.$,
|
|
@@ -57,7 +57,7 @@ exports.beamGroupRowStyle = Css_1.Css.xsEm
|
|
|
57
57
|
exports.beamTotalsRowStyle = Css_1.Css.gray700.smEm.hPx(40).mb1.bgWhite.boxShadow("none").$;
|
|
58
58
|
exports.beamNestedFixedStyle = {
|
|
59
59
|
...exports.beamFixedStyle,
|
|
60
|
-
levels: { 0: { cellCss: exports.beamGroupRowStyle } },
|
|
60
|
+
levels: { 0: { cellCss: exports.beamGroupRowStyle }, 2: { firstContentColumn: Css_1.Css.tiny.pl3.$ } },
|
|
61
61
|
};
|
|
62
62
|
exports.beamTotalsFixedStyle = {
|
|
63
63
|
...exports.beamFixedStyle,
|
|
@@ -66,11 +66,11 @@ exports.beamTotalsFixedStyle = {
|
|
|
66
66
|
exports.beamFlexibleStyle = {
|
|
67
67
|
...exports.beamFixedStyle,
|
|
68
68
|
cellCss: Css_1.Css.xs.bgWhite.aic.p2.boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray100}`).$,
|
|
69
|
-
presentationSettings: { borderless:
|
|
69
|
+
presentationSettings: { borderless: true, typeScale: "xs", wrap: true },
|
|
70
70
|
};
|
|
71
71
|
exports.beamNestedFlexibleStyle = {
|
|
72
72
|
...exports.beamFlexibleStyle,
|
|
73
|
-
levels: { 0: { cellCss: exports.beamGroupRowStyle } },
|
|
73
|
+
levels: { 0: { cellCss: exports.beamGroupRowStyle }, 2: { firstContentColumn: Css_1.Css.tiny.pl3.$ } },
|
|
74
74
|
};
|
|
75
75
|
exports.beamTotalsFlexibleStyle = {
|
|
76
76
|
...exports.beamFlexibleStyle,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const jan1: Date;
|
|
2
2
|
export declare const jan2: Date;
|
|
3
3
|
export declare const jan10: Date;
|
|
4
|
+
export declare const jan29: Date;
|
|
4
5
|
export declare const dd100: DeweyDecimalClassification;
|
|
5
6
|
export declare const dd200: DeweyDecimalClassification;
|
|
6
7
|
export interface AuthorInput {
|
|
@@ -18,6 +19,7 @@ export interface AuthorInput {
|
|
|
18
19
|
favoriteShapes?: string[] | null;
|
|
19
20
|
isAvailable?: boolean | null;
|
|
20
21
|
animals?: string[] | null;
|
|
22
|
+
bio?: string | null;
|
|
21
23
|
}
|
|
22
24
|
export interface AuthorAddress {
|
|
23
25
|
street?: string | null;
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
// by a GraphQL schema for a `saveAuthor` mutation that takes an author
|
|
4
4
|
// plus the author's books.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DateOnly = exports.dd200 = exports.dd100 = exports.jan10 = exports.jan2 = exports.jan1 = void 0;
|
|
6
|
+
exports.DateOnly = exports.dd200 = exports.dd100 = exports.jan29 = exports.jan10 = exports.jan2 = exports.jan1 = void 0;
|
|
7
7
|
exports.jan1 = new Date(2020, 0, 1);
|
|
8
8
|
exports.jan2 = new Date(2020, 0, 2);
|
|
9
9
|
exports.jan10 = new Date(2020, 0, 10);
|
|
10
|
+
exports.jan29 = new Date(2020, 0, 29);
|
|
10
11
|
exports.dd100 = { number: "100", category: "Philosophy" };
|
|
11
12
|
exports.dd200 = { number: "200", category: "Religion" };
|
|
12
13
|
class DateOnly {
|
|
@@ -15,12 +15,13 @@ const defaultTestId_1 = require("../utils/defaultTestId");
|
|
|
15
15
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
16
16
|
// Used by both TextField and TextArea
|
|
17
17
|
function TextFieldBase(props) {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f;
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
19
19
|
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
20
20
|
const { label, required, labelProps, hideLabel = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.hideLabel) !== null && _a !== void 0 ? _a : false, inputProps, inputRef, inputWrapRef, groupProps, compact = (_b = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.compact) !== null && _b !== void 0 ? _b : false, errorMsg, helperText, multiline = false, onChange, onBlur, onFocus, xss, endAdornment, startAdornment, inlineLabel, 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, } = props;
|
|
21
21
|
const typeScale = (_e = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.typeScale) !== null && _e !== void 0 ? _e : "sm";
|
|
22
|
+
const errorInTooltip = (_f = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.errorInTooltip) !== null && _f !== void 0 ? _f : false;
|
|
22
23
|
const internalProps = props.internalProps || {};
|
|
23
|
-
const { compound = false } = internalProps;
|
|
24
|
+
const { compound = false, forceFocus = false, forceHover = false } = internalProps;
|
|
24
25
|
const errorMessageId = `${inputProps.id}-error`;
|
|
25
26
|
const labelSuffix = (0, labelUtils_1.getLabelSuffix)(required);
|
|
26
27
|
const ElementType = multiline ? "textarea" : "input";
|
|
@@ -49,14 +50,16 @@ function TextFieldBase(props) {
|
|
|
49
50
|
.if(compact)
|
|
50
51
|
.mhPx(compactFieldHeight - maybeSmaller).$,
|
|
51
52
|
...Css_1.Css.gray900.if(contrast).white.$,
|
|
53
|
+
// Make read-only fields vertically line up with editable fields in tables
|
|
54
|
+
...(borderless ? Css_1.Css.px1.$ : {}),
|
|
52
55
|
},
|
|
53
56
|
input: {
|
|
54
|
-
...Css_1.Css.w100.mw0.outline0.br4
|
|
57
|
+
...Css_1.Css.w100.mw0.outline0.fg1.if(multiline).br4.$,
|
|
55
58
|
// Not using Truss's inline `if` statement here because `addIn` properties do not respect the if statement.
|
|
56
59
|
...(!contrast ? Css_1.Css.bgWhite.$ : Css_1.Css.bgGray700.addIn("&::selection", Css_1.Css.bgGray800.$).$),
|
|
57
60
|
},
|
|
58
61
|
hover: Css_1.Css.bgGray100.if(contrast).bgGray600.bGray600.$,
|
|
59
|
-
focus:
|
|
62
|
+
focus: Css_1.Css.bLightBlue700.if(contrast).bLightBlue500.$,
|
|
60
63
|
disabled: visuallyDisabled
|
|
61
64
|
? Css_1.Css.cursorNotAllowed.gray400.bgGray100.if(contrast).gray500.bgGray700.$
|
|
62
65
|
: Css_1.Css.cursorNotAllowed.$,
|
|
@@ -75,10 +78,12 @@ function TextFieldBase(props) {
|
|
|
75
78
|
const onFocusChained = (0, react_aria_1.chain)((e) => {
|
|
76
79
|
e.target.select();
|
|
77
80
|
}, onFocus);
|
|
81
|
+
const showFocus = (isFocused && !inputProps.readOnly) || forceFocus;
|
|
82
|
+
const showHover = (isHovered && !inputProps.disabled && !inputProps.readOnly && !isFocused) || forceHover;
|
|
78
83
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: fieldStyles.container }, groupProps, focusWithinProps, { children: [label && !inlineLabel && (
|
|
79
84
|
// set `hidden` if being rendered as a compound field
|
|
80
85
|
(0, jsx_runtime_1.jsx)(Label_1.Label, Object.assign({ labelProps: labelProps, hidden: hideLabel || compound, label: label, suffix: labelSuffix, contrast: contrast }, tid.label), void 0)), (0, components_1.maybeTooltip)({
|
|
81
|
-
title: tooltip,
|
|
86
|
+
title: (errorInTooltip && errorMsg) || tooltip,
|
|
82
87
|
placement: "top",
|
|
83
88
|
children: inputProps.readOnly ? ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
84
89
|
// Use input wrapper to get common styles, but then we need to override some
|
|
@@ -86,19 +91,19 @@ function TextFieldBase(props) {
|
|
|
86
91
|
...(multiline ? Css_1.Css.fdc.aifs.childGap2.$ : Css_1.Css.truncate.$),
|
|
87
92
|
...xss,
|
|
88
93
|
}, "data-readonly": "true" }, tid, { children: [!multiline && inlineLabel && label && !hideLabel && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, Object.assign({ labelProps: labelProps, label: label }, tid.label), void 0)), multiline
|
|
89
|
-
? (
|
|
94
|
+
? (_g = inputProps.value) === null || _g === void 0 ? void 0 : _g.split("\n\n").map((p, i) => ((0, jsx_runtime_1.jsx)("p", Object.assign({ css: Css_1.Css.my1.$ }, { children: p.split("\n").map((sentence, j) => ((0, jsx_runtime_1.jsxs)("span", { children: [sentence, (0, jsx_runtime_1.jsx)("br", {}, void 0)] }, j))) }), i)))
|
|
90
95
|
: inputProps.value] }), void 0)) : ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
91
96
|
...fieldStyles.inputWrapper,
|
|
92
97
|
...(inputProps.disabled ? fieldStyles.disabled : {}),
|
|
93
|
-
...(
|
|
94
|
-
...(
|
|
98
|
+
...(showFocus ? fieldStyles.focus : {}),
|
|
99
|
+
...(showHover ? fieldStyles.hover : {}),
|
|
95
100
|
...(errorMsg ? fieldStyles.error : {}),
|
|
96
101
|
...Css_1.Css.if(multiline).aifs.px0.mhPx(textAreaMinHeight).$,
|
|
97
102
|
} }, hoverProps, { ref: inputWrapRef }, { children: [!multiline && inlineLabel && label && !hideLabel && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, Object.assign({ labelProps: labelProps, label: label }, tid.label), void 0)), !multiline && startAdornment && (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.df.aic.fs0.br4.pr1.$ }, { children: startAdornment }), void 0), (0, jsx_runtime_1.jsx)(ElementType, Object.assign({}, (0, react_aria_1.mergeProps)(inputProps, { onBlur, onFocus: onFocusChained, onChange: onDomChange }, { "aria-invalid": Boolean(errorMsg), ...(hideLabel ? { "aria-label": label } : {}) }), (errorMsg ? { "aria-errormessage": errorMessageId } : {}), { ref: fieldRef, rows: multiline ? 1 : undefined, css: {
|
|
98
103
|
...fieldStyles.input,
|
|
99
104
|
...(inputProps.disabled ? fieldStyles.disabled : {}),
|
|
100
|
-
...(
|
|
101
|
-
...(multiline ? Css_1.Css.h100.p1.add("resize", "none")
|
|
105
|
+
...(showHover ? fieldStyles.hover : {}),
|
|
106
|
+
...(multiline ? Css_1.Css.h100.p1.add("resize", "none").$ : Css_1.Css.truncate.$),
|
|
102
107
|
...xss,
|
|
103
108
|
} }, tid), void 0), isFocused && clearable && onChange && inputProps.value && ((0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "xCircle", color: Css_1.Palette.Gray700, onClick: () => {
|
|
104
109
|
var _a;
|
|
@@ -106,6 +111,6 @@ function TextFieldBase(props) {
|
|
|
106
111
|
// Reset focus to input element
|
|
107
112
|
(_a = fieldRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
108
113
|
} }, void 0)), !multiline && endAdornment && (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.df.aic.pl1.fs0.$ }, { children: endAdornment }), void 0)] }), void 0)),
|
|
109
|
-
}), errorMsg && !compound && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, Object.assign({ id: errorMessageId, errorMsg: errorMsg }, tid.errorMsg), void 0), helperText && !compound && (0, jsx_runtime_1.jsx)(HelperText_1.HelperText, Object.assign({ helperText: helperText }, tid.helperText), void 0)] }), void 0));
|
|
114
|
+
}), errorMsg && !compound && !errorInTooltip && ((0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, Object.assign({ id: errorMessageId, errorMsg: errorMsg }, tid.errorMsg), void 0)), helperText && !compound && (0, jsx_runtime_1.jsx)(HelperText_1.HelperText, Object.assign({ helperText: helperText }, tid.helperText), void 0)] }), void 0));
|
|
110
115
|
}
|
|
111
116
|
exports.TextFieldBase = TextFieldBase;
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -52,4 +52,8 @@ export interface TextFieldInternalProps {
|
|
|
52
52
|
* This is explicitly an internal property that is not exposed to any field's API.
|
|
53
53
|
*/
|
|
54
54
|
compound?: boolean;
|
|
55
|
+
/** Forces focus styles for storybook purposes */
|
|
56
|
+
forceFocus?: true;
|
|
57
|
+
/** Forces hover styles for storybook purposes */
|
|
58
|
+
forceHover?: boolean;
|
|
55
59
|
}
|