@homebound/beam 2.121.1 → 2.123.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/Modal/TestModalContent.js +1 -1
- 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 +15 -3
- package/dist/components/Table/GridTable.js +14 -13
- package/dist/components/Table/columns.js +7 -3
- package/dist/components/Table/index.d.ts +2 -2
- package/dist/components/Table/index.js +1 -2
- package/dist/components/Table/simpleHelpers.d.ts +4 -12
- package/dist/components/Table/simpleHelpers.js +3 -8
- 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 +14 -11
- package/dist/interfaces.d.ts +4 -0
- package/package.json +1 -1
|
@@ -42,7 +42,7 @@ const users = [
|
|
|
42
42
|
{ id: "9", name: "Captain Marvel", role: "Does it all" },
|
|
43
43
|
{ id: "10", name: "Doctor Strange", role: "Doctor" },
|
|
44
44
|
];
|
|
45
|
-
const rows = [Table_1.simpleHeader, ...users.map((u) => ({ kind: "data",
|
|
45
|
+
const rows = [Table_1.simpleHeader, ...users.map((u) => ({ kind: "data", id: u.id, data: u }))];
|
|
46
46
|
const columns = [
|
|
47
47
|
{ header: () => "Name", data: ({ name }) => name },
|
|
48
48
|
{ header: () => "Role", data: ({ role }) => role },
|
|
@@ -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. */
|
|
@@ -313,9 +324,10 @@ export declare type GridDataRow<R extends Kinded> = {
|
|
|
313
324
|
children?: GridDataRow<R>[];
|
|
314
325
|
/** Whether to pin this sort to the first/last of its parent's children. */
|
|
315
326
|
pin?: "first" | "last";
|
|
327
|
+
data: unknown;
|
|
316
328
|
} & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
|
|
317
329
|
declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
|
|
318
330
|
/** Return the content for a given column def applied to a given row. */
|
|
319
|
-
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;
|
|
320
332
|
export declare function matchesFilter(maybeContent: ReactNode | GridCellContent, filter: string): boolean;
|
|
321
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,17 +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
|
-
|
|
645
|
-
|
|
646
|
-
return maybeContent(row["data"], row["id"], api);
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
return maybeContent(row, api);
|
|
650
|
-
}
|
|
650
|
+
// Auto-destructure data
|
|
651
|
+
return maybeContent(row["data"], { row: row, api, level });
|
|
651
652
|
}
|
|
652
653
|
else {
|
|
653
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 (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 (
|
|
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;
|
|
@@ -8,7 +8,7 @@ export { useGridTableApi } from "./GridTableApi";
|
|
|
8
8
|
export type { GridTableApi } from "./GridTableApi";
|
|
9
9
|
export { RowState, RowStateContext } from "./RowState";
|
|
10
10
|
export * from "./SelectToggle";
|
|
11
|
-
export { simpleDataRows, simpleHeader
|
|
12
|
-
export type {
|
|
11
|
+
export { simpleDataRows, simpleHeader } from "./simpleHelpers";
|
|
12
|
+
export type { SimpleHeaderAndData } from "./simpleHelpers";
|
|
13
13
|
export { SortHeader } from "./SortHeader";
|
|
14
14
|
export { beamFixedStyle, beamFlexibleStyle, beamNestedFixedStyle, beamNestedFlexibleStyle, beamTotalsFixedStyle, beamTotalsFlexibleStyle, cardStyle, condensedStyle, defaultStyle, } from "./styles";
|
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.defaultStyle = exports.condensedStyle = exports.cardStyle = exports.beamTotalsFlexibleStyle = exports.beamTotalsFixedStyle = exports.beamNestedFlexibleStyle = exports.beamNestedFixedStyle = exports.beamFlexibleStyle = exports.beamFixedStyle = exports.SortHeader = exports.
|
|
13
|
+
exports.defaultStyle = exports.condensedStyle = exports.cardStyle = exports.beamTotalsFlexibleStyle = exports.beamTotalsFixedStyle = exports.beamNestedFlexibleStyle = exports.beamNestedFixedStyle = exports.beamFlexibleStyle = exports.beamFixedStyle = exports.SortHeader = exports.simpleHeader = exports.simpleDataRows = exports.RowStateContext = exports.RowState = exports.useGridTableApi = exports.setGridTableDefaults = exports.setDefaultStyle = exports.GridTable = exports.DESC = exports.ASC = exports.GridSortContext = void 0;
|
|
14
14
|
__exportStar(require("./CollapseToggle"), exports);
|
|
15
15
|
__exportStar(require("./columns"), exports);
|
|
16
16
|
var GridSortContext_1 = require("./GridSortContext");
|
|
@@ -30,7 +30,6 @@ __exportStar(require("./SelectToggle"), exports);
|
|
|
30
30
|
var simpleHelpers_1 = require("./simpleHelpers");
|
|
31
31
|
Object.defineProperty(exports, "simpleDataRows", { enumerable: true, get: function () { return simpleHelpers_1.simpleDataRows; } });
|
|
32
32
|
Object.defineProperty(exports, "simpleHeader", { enumerable: true, get: function () { return simpleHelpers_1.simpleHeader; } });
|
|
33
|
-
Object.defineProperty(exports, "simpleRows", { enumerable: true, get: function () { return simpleHelpers_1.simpleRows; } });
|
|
34
33
|
var SortHeader_1 = require("./SortHeader");
|
|
35
34
|
Object.defineProperty(exports, "SortHeader", { enumerable: true, get: function () { return SortHeader_1.SortHeader; } });
|
|
36
35
|
var styles_1 = require("./styles");
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { GridDataRow } from "./GridTable";
|
|
2
|
-
/** A helper for making `Row` type aliases of simple/flat tables that are just header + data. */
|
|
3
|
-
export declare type SimpleHeaderAndDataOf<T> = {
|
|
4
|
-
kind: "header";
|
|
5
|
-
} | ({
|
|
6
|
-
kind: "data";
|
|
7
|
-
} & T);
|
|
8
2
|
/**
|
|
9
3
|
* A helper for making `Row` type aliases of simple/flat tables that are just header + data.
|
|
10
4
|
*
|
|
@@ -12,7 +6,7 @@ export declare type SimpleHeaderAndDataOf<T> = {
|
|
|
12
6
|
* when rows are mobx proxies and we need proxy accesses to happen within the column
|
|
13
7
|
* rendering.
|
|
14
8
|
*/
|
|
15
|
-
export declare type
|
|
9
|
+
export declare type SimpleHeaderAndData<T> = {
|
|
16
10
|
kind: "header";
|
|
17
11
|
} | {
|
|
18
12
|
kind: "data";
|
|
@@ -23,11 +17,9 @@ export declare type SimpleHeaderAndDataWith<T> = {
|
|
|
23
17
|
export declare const simpleHeader: {
|
|
24
18
|
kind: "header";
|
|
25
19
|
id: string;
|
|
20
|
+
data: {};
|
|
26
21
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}> | undefined): GridDataRow<R>[];
|
|
30
|
-
/** Like `simpleRows` but for `SimpleHeaderAndDataWith`. */
|
|
31
|
-
export declare function simpleDataRows<R extends SimpleHeaderAndDataWith<D>, D>(data?: Array<D & {
|
|
22
|
+
/** Like `simpleRows` but for `SimpleHeaderAndData`. */
|
|
23
|
+
export declare function simpleDataRows<R extends SimpleHeaderAndData<D>, D>(data?: Array<D & {
|
|
32
24
|
id: string;
|
|
33
25
|
}> | undefined): GridDataRow<R>[];
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.simpleDataRows = exports.
|
|
3
|
+
exports.simpleDataRows = exports.simpleHeader = void 0;
|
|
4
4
|
/** A const for a marker header row. */
|
|
5
|
-
exports.simpleHeader = { kind: "header", id: "header" };
|
|
6
|
-
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
return [exports.simpleHeader, ...data.map((c) => ({ kind: "data", ...c }))];
|
|
9
|
-
}
|
|
10
|
-
exports.simpleRows = simpleRows;
|
|
11
|
-
/** Like `simpleRows` but for `SimpleHeaderAndDataWith`. */
|
|
5
|
+
exports.simpleHeader = { kind: "header", id: "header", data: {} };
|
|
6
|
+
/** Like `simpleRows` but for `SimpleHeaderAndData`. */
|
|
12
7
|
function simpleDataRows(data = []) {
|
|
13
8
|
// @ts-ignore Not sure why this doesn't type-check, something esoteric with the DiscriminateUnion type
|
|
14
9
|
return [exports.simpleHeader, ...data.map((data) => ({ kind: "data", data, id: data.id }))];
|
|
@@ -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";
|
|
@@ -51,12 +52,12 @@ function TextFieldBase(props) {
|
|
|
51
52
|
...Css_1.Css.gray900.if(contrast).white.$,
|
|
52
53
|
},
|
|
53
54
|
input: {
|
|
54
|
-
...Css_1.Css.w100.mw0.outline0.br4
|
|
55
|
+
...Css_1.Css.w100.mw0.outline0.fg1.if(multiline).br4.$,
|
|
55
56
|
// Not using Truss's inline `if` statement here because `addIn` properties do not respect the if statement.
|
|
56
57
|
...(!contrast ? Css_1.Css.bgWhite.$ : Css_1.Css.bgGray700.addIn("&::selection", Css_1.Css.bgGray800.$).$),
|
|
57
58
|
},
|
|
58
59
|
hover: Css_1.Css.bgGray100.if(contrast).bgGray600.bGray600.$,
|
|
59
|
-
focus:
|
|
60
|
+
focus: Css_1.Css.bLightBlue700.if(contrast).bLightBlue500.$,
|
|
60
61
|
disabled: visuallyDisabled
|
|
61
62
|
? Css_1.Css.cursorNotAllowed.gray400.bgGray100.if(contrast).gray500.bgGray700.$
|
|
62
63
|
: Css_1.Css.cursorNotAllowed.$,
|
|
@@ -75,10 +76,12 @@ function TextFieldBase(props) {
|
|
|
75
76
|
const onFocusChained = (0, react_aria_1.chain)((e) => {
|
|
76
77
|
e.target.select();
|
|
77
78
|
}, onFocus);
|
|
79
|
+
const showFocus = (isFocused && !inputProps.readOnly) || forceFocus;
|
|
80
|
+
const showHover = (isHovered && !inputProps.disabled && !inputProps.readOnly && !isFocused) || forceHover;
|
|
78
81
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: fieldStyles.container }, groupProps, focusWithinProps, { children: [label && !inlineLabel && (
|
|
79
82
|
// set `hidden` if being rendered as a compound field
|
|
80
83
|
(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,
|
|
84
|
+
title: (errorInTooltip && errorMsg) || tooltip,
|
|
82
85
|
placement: "top",
|
|
83
86
|
children: inputProps.readOnly ? ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
84
87
|
// Use input wrapper to get common styles, but then we need to override some
|
|
@@ -86,19 +89,19 @@ function TextFieldBase(props) {
|
|
|
86
89
|
...(multiline ? Css_1.Css.fdc.aifs.childGap2.$ : Css_1.Css.truncate.$),
|
|
87
90
|
...xss,
|
|
88
91
|
}, "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
|
-
? (
|
|
92
|
+
? (_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
93
|
: inputProps.value] }), void 0)) : ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: {
|
|
91
94
|
...fieldStyles.inputWrapper,
|
|
92
95
|
...(inputProps.disabled ? fieldStyles.disabled : {}),
|
|
93
|
-
...(
|
|
94
|
-
...(
|
|
96
|
+
...(showFocus ? fieldStyles.focus : {}),
|
|
97
|
+
...(showHover ? fieldStyles.hover : {}),
|
|
95
98
|
...(errorMsg ? fieldStyles.error : {}),
|
|
96
99
|
...Css_1.Css.if(multiline).aifs.px0.mhPx(textAreaMinHeight).$,
|
|
97
100
|
} }, 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
101
|
...fieldStyles.input,
|
|
99
102
|
...(inputProps.disabled ? fieldStyles.disabled : {}),
|
|
100
|
-
...(
|
|
101
|
-
...(multiline ? Css_1.Css.h100.p1.add("resize", "none")
|
|
103
|
+
...(showHover ? fieldStyles.hover : {}),
|
|
104
|
+
...(multiline ? Css_1.Css.h100.p1.add("resize", "none").$ : Css_1.Css.truncate.$),
|
|
102
105
|
...xss,
|
|
103
106
|
} }, 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
107
|
var _a;
|
|
@@ -106,6 +109,6 @@ function TextFieldBase(props) {
|
|
|
106
109
|
// Reset focus to input element
|
|
107
110
|
(_a = fieldRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
108
111
|
} }, 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));
|
|
112
|
+
}), 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
113
|
}
|
|
111
114
|
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
|
}
|