@homebound/beam 2.177.1 → 2.178.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/Table/GridTable.d.ts +8 -3
- package/dist/components/Table/GridTable.js +25 -13
- package/dist/components/Table/GridTableApi.d.ts +3 -0
- package/dist/components/Table/GridTableApi.js +3 -0
- package/dist/components/Table/RowState.d.ts +1 -0
- package/dist/components/Table/RowState.js +2 -0
- package/dist/components/Table/styles.d.ts +2 -0
- package/dist/components/Table/styles.js +2 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +2 -1
- package/dist/forms/FormStateApp.js +1 -1
- package/dist/forms/StepperFormApp.js +1 -1
- package/package.json +1 -1
|
@@ -169,8 +169,6 @@ export interface GridTableProps<R extends Kinded, S, X> {
|
|
|
169
169
|
filterMaxRows?: number;
|
|
170
170
|
/** Accepts the number of filtered rows (based on `filter`), for the caller to observe and display if they want. */
|
|
171
171
|
setRowCount?: (rowCount: number) => void;
|
|
172
|
-
/** Sets the rows to be wrapped by mobx observers. */
|
|
173
|
-
observeRows?: boolean;
|
|
174
172
|
/** A combination of CSS settings to set the static look & feel (vs. rowStyles which is per-row styling). */
|
|
175
173
|
style?: GridStyle | GridStyleDef;
|
|
176
174
|
/**
|
|
@@ -191,6 +189,11 @@ export interface GridTableProps<R extends Kinded, S, X> {
|
|
|
191
189
|
* Example "data_123"
|
|
192
190
|
*/
|
|
193
191
|
activeRowId?: string;
|
|
192
|
+
/**
|
|
193
|
+
* Defines which cell in the table should be provided with an "active" styling.
|
|
194
|
+
* Expected format is `${row.kind}_${row.id}_${column.name}`.
|
|
195
|
+
*/
|
|
196
|
+
activeCellId?: string;
|
|
194
197
|
}
|
|
195
198
|
/**
|
|
196
199
|
* Renders data in our table layout.
|
|
@@ -271,10 +274,12 @@ export declare type GridColumn<R extends Kinded, S = {}> = {
|
|
|
271
274
|
wrapAction?: false;
|
|
272
275
|
/** Used as a signal to defer adding the 'indent' styling */
|
|
273
276
|
isAction?: true;
|
|
277
|
+
/** Column name that will be used to generate an unique identifier for every row cell */
|
|
278
|
+
name?: string;
|
|
274
279
|
};
|
|
275
280
|
export declare const nonKindGridColumnKeys: string[];
|
|
276
281
|
/** Allows rendering a specific cell. */
|
|
277
|
-
declare type RenderCellFn<R extends Kinded> = (idx: number, css: Properties, content: ReactNode, row: R, rowStyle: RowStyle<R> | undefined, classNames: string | undefined) => ReactNode;
|
|
282
|
+
declare type RenderCellFn<R extends Kinded> = (idx: number, css: Properties, content: ReactNode, row: R, rowStyle: RowStyle<R> | undefined, classNames: string | undefined, onClick: (() => void) | undefined) => ReactNode;
|
|
278
283
|
/** Defines row-specific styling for each given row `kind` in `R` */
|
|
279
284
|
export declare type GridRowStyles<R extends Kinded> = {
|
|
280
285
|
[P in R["kind"]]?: RowStyle<DiscriminateUnion<R, "kind", P>>;
|
|
@@ -89,7 +89,7 @@ exports.setGridTableDefaults = setGridTableDefaults;
|
|
|
89
89
|
*/
|
|
90
90
|
function GridTable(props) {
|
|
91
91
|
var _a, _b, _c, _d;
|
|
92
|
-
const { id = "gridTable", as = "div", columns, rows, style: maybeStyle = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = 0, xss, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount,
|
|
92
|
+
const { id = "gridTable", as = "div", columns, rows, style: maybeStyle = defaults.style, rowStyles, stickyHeader = defaults.stickyHeader, stickyOffset = 0, xss, filter, filterMaxRows, fallbackMessage = "No rows found.", infoMessage, setRowCount, persistCollapse, resizeTarget, activeRowId, activeCellId, } = props;
|
|
93
93
|
// We only use this in as=virtual mode, but keep this here for rowLookup to use
|
|
94
94
|
const virtuosoRef = (0, react_1.useRef)(null);
|
|
95
95
|
// Use this ref to watch for changes in the GridTable's container and resize columns accordingly.
|
|
@@ -99,6 +99,7 @@ function GridTable(props) {
|
|
|
99
99
|
const api = (_a = props.api) !== null && _a !== void 0 ? _a : new GridTableApi_1.GridTableApiImpl();
|
|
100
100
|
api.init(persistCollapse, virtuosoRef, rows);
|
|
101
101
|
api.setActiveRowId(activeRowId);
|
|
102
|
+
api.setActiveCellId(activeCellId);
|
|
102
103
|
return api;
|
|
103
104
|
}, [props.api]);
|
|
104
105
|
const style = resolveStyles(maybeStyle);
|
|
@@ -107,6 +108,9 @@ function GridTable(props) {
|
|
|
107
108
|
(0, react_1.useEffect)(() => {
|
|
108
109
|
rowState.activeRowId = activeRowId;
|
|
109
110
|
}, [rowState, activeRowId]);
|
|
111
|
+
(0, react_1.useEffect)(() => {
|
|
112
|
+
rowState.activeCellId = activeCellId;
|
|
113
|
+
}, [rowState, activeCellId]);
|
|
110
114
|
// We track render count at the table level, which seems odd (we should be able to track this
|
|
111
115
|
// internally within each GridRow using a useRef), but we have suspicions that react-virtuoso
|
|
112
116
|
// (or us) is resetting component state more than necessary, so we track render counts from
|
|
@@ -130,8 +134,7 @@ function GridTable(props) {
|
|
|
130
134
|
// We only pass sortState to header rows, b/c non-headers rows shouldn't have to re-render on sorting
|
|
131
135
|
// changes, and so by not passing the sortProps, it means the data rows' React.memo will still cache them.
|
|
132
136
|
const sortProps = row.kind === "header" ? { sortOn, sortState, setSortKey } : { sortOn };
|
|
133
|
-
|
|
134
|
-
return ((0, jsx_runtime_1.jsx)(RowComponent, Object.assign({}, {
|
|
137
|
+
return ((0, jsx_runtime_1.jsx)(MemoizedGridRow, Object.assign({}, {
|
|
135
138
|
as,
|
|
136
139
|
columns,
|
|
137
140
|
row,
|
|
@@ -203,7 +206,6 @@ function GridTable(props) {
|
|
|
203
206
|
sortState,
|
|
204
207
|
stickyHeader,
|
|
205
208
|
stickyOffset,
|
|
206
|
-
observeRows,
|
|
207
209
|
columnSizes,
|
|
208
210
|
collapsedIds,
|
|
209
211
|
getCount,
|
|
@@ -265,7 +267,7 @@ function renderDiv(style, id, columns, headerRows, totalsRows, visibleDataRows,
|
|
|
265
267
|
the + operator as an offset.
|
|
266
268
|
Inspired by: https://stackoverflow.com/a/25005740/2551333
|
|
267
269
|
*/
|
|
268
|
-
...(style.betweenRowsCss ? Css_1.Css.addIn(`& > div:nth-of-type(n+
|
|
270
|
+
...(style.betweenRowsCss ? Css_1.Css.addIn(`& > div:nth-of-type(n+${headerRows.length + totalsRows.length + 2}) > *`, style.betweenRowsCss).$ : {}),
|
|
269
271
|
...(style.firstNonHeaderRowCss ? Css_1.Css.addIn(`& > div:nth-of-type(2) > *`, style.firstNonHeaderRowCss).$ : {}),
|
|
270
272
|
...style.rootCss,
|
|
271
273
|
...(style.minWidthPx ? Css_1.Css.mwPx(style.minWidthPx).$ : {}),
|
|
@@ -478,7 +480,8 @@ function GridRow(props) {
|
|
|
478
480
|
var _a;
|
|
479
481
|
const { as, columns, row, style, rowStyles, stickyHeader, stickyOffset, sortOn, sortState, setSortKey, openCards, columnSizes, level, getCount, api, ...others } = props;
|
|
480
482
|
const { rowState } = (0, react_1.useContext)(RowState_1.RowStateContext);
|
|
481
|
-
const
|
|
483
|
+
const rowId = `${row.kind}_${row.id}`;
|
|
484
|
+
const isActive = (0, hooks_1.useComputed)(() => rowState.activeRowId === rowId, [rowId, rowState]);
|
|
482
485
|
// We treat the "header" and "totals" kind as special for "good defaults" styling
|
|
483
486
|
const isHeader = row.kind === "header";
|
|
484
487
|
const isTotals = row.kind === "totals";
|
|
@@ -557,6 +560,9 @@ function GridRow(props) {
|
|
|
557
560
|
: {}),
|
|
558
561
|
}
|
|
559
562
|
: {};
|
|
563
|
+
const cellId = `${row.kind}_${row.id}_${column.name}`;
|
|
564
|
+
const applyCellHighlight = !!column.name && !isHeader && !isTotals;
|
|
565
|
+
const isCellActive = rowState.activeCellId === cellId;
|
|
560
566
|
// Note that it seems expensive to calc a per-cell class name/CSS-in-JS output,
|
|
561
567
|
// vs. setting global/table-wide CSS like `style.cellCss` on the root grid div with
|
|
562
568
|
// a few descendent selectors. However, that approach means the root grid-applied
|
|
@@ -596,6 +602,8 @@ function GridRow(props) {
|
|
|
596
602
|
...(isGridCellContent(maybeContent) && maybeContent.typeScale ? Css_1.Css[maybeContent.typeScale].$ : {}),
|
|
597
603
|
// And any cell specific css
|
|
598
604
|
...(isGridCellContent(maybeContent) && maybeContent.css ? maybeContent.css : {}),
|
|
605
|
+
// Apply cell highlight styles to active cell and hover
|
|
606
|
+
...Css_1.Css.if(applyCellHighlight && isCellActive).br4.boxShadow(`inset 0 0 0 1px ${Css_1.Palette.LightBlue700}`).$,
|
|
599
607
|
// Define the width of the column on each cell. Supports col spans.
|
|
600
608
|
...{
|
|
601
609
|
width: `calc(${columnSizes
|
|
@@ -605,6 +613,7 @@ function GridRow(props) {
|
|
|
605
613
|
...(column.mw ? Css_1.Css.mw(column.mw).$ : {}),
|
|
606
614
|
};
|
|
607
615
|
const cellClassNames = revealOnRowHover ? revealOnRowHoverClass : undefined;
|
|
616
|
+
const cellOnClick = applyCellHighlight ? () => api.setActiveCellId(cellId) : undefined;
|
|
608
617
|
const renderFn = ((rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.renderCell) || (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.rowLink)) && wrapAction
|
|
609
618
|
? rowLinkRenderFn(as)
|
|
610
619
|
: isHeader
|
|
@@ -612,7 +621,7 @@ function GridRow(props) {
|
|
|
612
621
|
: (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.onClick) && wrapAction
|
|
613
622
|
? rowClickRenderFn(as, api)
|
|
614
623
|
: defaultRenderFn(as);
|
|
615
|
-
return renderFn(columnIndex, cellCss, content, row, rowStyle, cellClassNames);
|
|
624
|
+
return renderFn(columnIndex, cellCss, content, row, rowStyle, cellClassNames, cellOnClick);
|
|
616
625
|
}) }), void 0));
|
|
617
626
|
return openCardStyles && openCardStyles.length > 0 ? (0, nestedCards_1.wrapCard)(openCardStyles, rowNode) : rowNode;
|
|
618
627
|
}
|
|
@@ -628,7 +637,7 @@ function GridRow(props) {
|
|
|
628
637
|
* memoization is.
|
|
629
638
|
*/
|
|
630
639
|
// Declared as a const + `as typeof GridRow` to work with generics, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/37087#issuecomment-656596623
|
|
631
|
-
const MemoizedGridRow = react_1.default.memo(GridRow, (one, two) => {
|
|
640
|
+
const MemoizedGridRow = react_1.default.memo((0, mobx_react_1.observer)(GridRow), (one, two) => {
|
|
632
641
|
const { row: row1, ...others1 } = one;
|
|
633
642
|
const { row: row2, ...others2 } = two;
|
|
634
643
|
return (0, shallowEqual_1.shallowEqual)(row1, row2) && (0, shallowEqual_1.shallowEqual)(others1, others2);
|
|
@@ -703,9 +712,9 @@ function applyRowFn(column, row, api, level) {
|
|
|
703
712
|
}
|
|
704
713
|
exports.applyRowFn = applyRowFn;
|
|
705
714
|
/** Renders our default cell element, i.e. if no row links and no custom renderCell are used. */
|
|
706
|
-
const defaultRenderFn = (as) => (key, css, content, row, rowStyle, classNames) => {
|
|
715
|
+
const defaultRenderFn = (as) => (key, css, content, row, rowStyle, classNames, onClick) => {
|
|
707
716
|
const Cell = as === "table" ? "td" : "div";
|
|
708
|
-
return ((0, jsx_runtime_1.jsx)(Cell, Object.assign({ css: { ...css, ...tableRowStyles(as) }, className: classNames }, { children: content }), key));
|
|
717
|
+
return ((0, jsx_runtime_1.jsx)(Cell, Object.assign({ css: { ...css, ...tableRowStyles(as) }, className: classNames, onClick: onClick }, { children: content }), key));
|
|
709
718
|
};
|
|
710
719
|
/** Sets up the `GridContext` so that header cells can access the current sort settings. */
|
|
711
720
|
const headerRenderFn = (columns, column, sortState, setSortKey, as) => (key, css, content, row, rowStyle, classNames) => {
|
|
@@ -728,9 +737,12 @@ const rowLinkRenderFn = (as) => (key, css, content, row, rowStyle, classNames) =
|
|
|
728
737
|
return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({ to: to, css: { ...Css_1.Css.noUnderline.color("unset").$, ...css }, className: `${CssReset_1.navLink} ${classNames}` }, { children: content }), key));
|
|
729
738
|
};
|
|
730
739
|
/** Renders a cell that will fire the RowStyle.onClick. */
|
|
731
|
-
const rowClickRenderFn = (as, api) => (key, css, content, row, rowStyle, classNames) => {
|
|
740
|
+
const rowClickRenderFn = (as, api) => (key, css, content, row, rowStyle, classNames, onClick) => {
|
|
732
741
|
const Row = as === "table" ? "tr" : "div";
|
|
733
|
-
return ((0, jsx_runtime_1.jsx)(Row, Object.assign({}, { key }, { css: { ...css, ...tableRowStyles(as) }, className: classNames, onClick: () =>
|
|
742
|
+
return ((0, jsx_runtime_1.jsx)(Row, Object.assign({}, { key }, { css: { ...css, ...tableRowStyles(as) }, className: classNames, onClick: (e) => {
|
|
743
|
+
rowStyle.onClick(row, api);
|
|
744
|
+
onClick && onClick();
|
|
745
|
+
} }, { children: content }), void 0));
|
|
734
746
|
};
|
|
735
747
|
const alignmentToJustify = {
|
|
736
748
|
left: "flex-start",
|
|
@@ -796,7 +808,7 @@ function tableRowStyles(as, column) {
|
|
|
796
808
|
: {};
|
|
797
809
|
}
|
|
798
810
|
function resolveStyles(style) {
|
|
799
|
-
const defKeys = ["inlineEditing", "grouped", "rowHeight"];
|
|
811
|
+
const defKeys = ["inlineEditing", "grouped", "rowHeight", "cellHighlight"];
|
|
800
812
|
const keys = (0, utils_1.safeKeys)(style);
|
|
801
813
|
if (keys.length === 0 || keys.some((k) => defKeys.includes(k))) {
|
|
802
814
|
return (0, styles_1.getTableStyles)(style);
|
|
@@ -32,6 +32,8 @@ export declare type GridTableApi<R extends Kinded> = {
|
|
|
32
32
|
clearSelections(): void;
|
|
33
33
|
/** Sets the internal state of 'activeRowId' */
|
|
34
34
|
setActiveRowId: (id: string | undefined) => void;
|
|
35
|
+
/** Sets the internal state of 'activeCellId' */
|
|
36
|
+
setActiveCellId: (id: string | undefined) => void;
|
|
35
37
|
/** Set selected state of a row by id */
|
|
36
38
|
selectRow: (id: string, selected?: boolean) => void;
|
|
37
39
|
};
|
|
@@ -45,5 +47,6 @@ export declare class GridTableApiImpl<R extends Kinded> implements GridTableApi<
|
|
|
45
47
|
getSelectedRows(kind?: string): any;
|
|
46
48
|
clearSelections(id?: string): void;
|
|
47
49
|
setActiveRowId(id: string | undefined): void;
|
|
50
|
+
setActiveCellId(id: string | undefined): void;
|
|
48
51
|
selectRow(id: string, selected?: boolean): void;
|
|
49
52
|
}
|
|
@@ -36,6 +36,8 @@ class RowState {
|
|
|
36
36
|
this.rows = [];
|
|
37
37
|
// Keeps track of the 'active' row, formatted `${row.kind}_${row.id}`
|
|
38
38
|
this.activeRowId = undefined;
|
|
39
|
+
// Keeps track of the 'active' cell, formatted `${row.kind}_${row.id}_${column.name}`
|
|
40
|
+
this.activeCellId = undefined;
|
|
39
41
|
// Make ourselves an observable so that mobx will do caching of .collapseIds so
|
|
40
42
|
// that it'll be a stable identity for GridTable to useMemo against.
|
|
41
43
|
(0, mobx_1.makeAutoObservable)(this,
|
|
@@ -9,5 +9,7 @@ export interface GridStyleDef {
|
|
|
9
9
|
inlineEditing?: boolean;
|
|
10
10
|
grouped?: boolean;
|
|
11
11
|
rowHeight?: "fixed" | "flexible";
|
|
12
|
+
/** Enables cells Highlight and hover */
|
|
13
|
+
cellHighlight?: boolean;
|
|
12
14
|
}
|
|
13
15
|
export declare const getTableStyles: (props?: GridStyleDef | undefined) => GridStyle;
|
|
@@ -44,7 +44,7 @@ exports.cardStyle = {
|
|
|
44
44
|
function memoizedTableStyles() {
|
|
45
45
|
const cache = {};
|
|
46
46
|
return (props) => {
|
|
47
|
-
const { inlineEditing = false, grouped = false, rowHeight = "flexible" } = props || {};
|
|
47
|
+
const { inlineEditing = false, grouped = false, rowHeight = "flexible", cellHighlight } = props || {};
|
|
48
48
|
const key = `${inlineEditing}|${grouped}|${rowHeight}`;
|
|
49
49
|
if (!cache[key]) {
|
|
50
50
|
const groupedLevels = {
|
|
@@ -63,6 +63,7 @@ function memoizedTableStyles() {
|
|
|
63
63
|
cellCss: {
|
|
64
64
|
...Css_1.Css.gray900.xs.bgWhite.aic.pxPx(12).boxShadow(`inset 0 -1px 0 ${Css_1.Palette.Gray200}`).$,
|
|
65
65
|
...(rowHeight === "flexible" ? Css_1.Css.pyPx(12).$ : Css_1.Css.nowrap.hPx(inlineEditing ? 48 : 36).$),
|
|
66
|
+
...(cellHighlight ? { "&:hover": Css_1.Css.bgGray100.$ } : {})
|
|
66
67
|
},
|
|
67
68
|
presentationSettings: { borderless: true, typeScale: "xs", wrap: rowHeight === "flexible" },
|
|
68
69
|
levels: grouped ? groupedLevels : defaultLevels,
|
|
@@ -27,7 +27,7 @@ export * from "./Stepper";
|
|
|
27
27
|
export type { Step, StepperProps } from "./Stepper";
|
|
28
28
|
export * from "./SuperDrawer";
|
|
29
29
|
export * from "./Table";
|
|
30
|
-
export { TabContent, Tabs, TabsWithContent } from "./Tabs";
|
|
30
|
+
export { TabActions, TabContent, Tabs, TabsWithContent } from "./Tabs";
|
|
31
31
|
export type { RouteTab, RouteTabWithContent, Tab, TabWithContent } from "./Tabs";
|
|
32
32
|
export * from "./Tag";
|
|
33
33
|
export * from "./Tooltip";
|
package/dist/components/index.js
CHANGED
|
@@ -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.TabsWithContent = exports.Tabs = exports.TabContent = exports.PresentationProvider = exports.NavLink = exports.BeamProvider = void 0;
|
|
13
|
+
exports.TabsWithContent = exports.Tabs = exports.TabContent = exports.TabActions = exports.PresentationProvider = exports.NavLink = exports.BeamProvider = void 0;
|
|
14
14
|
__exportStar(require("./Chip"), exports);
|
|
15
15
|
__exportStar(require("./Chips"), exports);
|
|
16
16
|
__exportStar(require("./Table/GridTable"), exports);
|
|
@@ -43,6 +43,7 @@ __exportStar(require("./Stepper"), exports);
|
|
|
43
43
|
__exportStar(require("./SuperDrawer"), exports);
|
|
44
44
|
__exportStar(require("./Table"), exports);
|
|
45
45
|
var Tabs_1 = require("./Tabs");
|
|
46
|
+
Object.defineProperty(exports, "TabActions", { enumerable: true, get: function () { return Tabs_1.TabActions; } });
|
|
46
47
|
Object.defineProperty(exports, "TabContent", { enumerable: true, get: function () { return Tabs_1.TabContent; } });
|
|
47
48
|
Object.defineProperty(exports, "Tabs", { enumerable: true, get: function () { return Tabs_1.Tabs; } });
|
|
48
49
|
Object.defineProperty(exports, "TabsWithContent", { enumerable: true, get: function () { return Tabs_1.TabsWithContent; } });
|
|
@@ -56,7 +56,7 @@ function FormStateApp() {
|
|
|
56
56
|
{ value: "a:4", label: "Iguana" },
|
|
57
57
|
{ value: "a:5", label: "Turtle" },
|
|
58
58
|
];
|
|
59
|
-
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.$ }, { children: [(0, jsx_runtime_1.jsxs)("header", Object.assign({ css: Css_1.Css.wPx(700).$ }, { children: [(0, jsx_runtime_1.jsxs)(FormLines_1.FormLines, Object.assign({ labelSuffix: { required: "*", optional: "(Opt)" } }, { children: [(0, jsx_runtime_1.jsx)("b", { children: "Author" }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.firstName }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.middleInitial }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.lastName }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundDateField, { field: formState.birthday }, void 0), (0, jsx_runtime_1.jsxs)(forms_1.FieldGroup, { children: [(0, jsx_runtime_1.jsx)(forms_1.StaticField, { label: "Revenue", value: "$500" }, void 0), (0, jsx_runtime_1.jsx)(forms_1.StaticField, Object.assign({ label: "Website" }, { children: (0, jsx_runtime_1.jsx)("a", Object.assign({ href: "https://google.com" }, { children: "google.com" }), void 0) }), void 0)] }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundNumberField, { field: formState.heightInInches }, void 0), (0, jsx_runtime_1.jsx)(forms_1.FormDivider, {}, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundSelectField, { field: formState.favoriteSport, options: sports }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundMultiSelectField, { field: formState.favoriteShapes, options: shapes }, void 0), (0, jsx_runtime_1.jsx)(BoundCheckboxGroupField_1.BoundCheckboxGroupField, { field: formState.favoriteColors, options: colors }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundToggleChipGroupField, { field: formState.animals, options: animals }, void 0), (0, jsx_runtime_1.jsx)(forms_1.FormDivider, {}, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundSwitchField, { field: formState.isAvailable }, void 0)] }), void 0), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("strong", { children: ["Books", (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "plus", onClick: () => formState.books.add({ id: String(formState.books.value.length) }) }, void 0)] }, void 0), (0, jsx_runtime_1.jsx)(components_1.GridTable, { columns: columns, rows: rows
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.$ }, { children: [(0, jsx_runtime_1.jsxs)("header", Object.assign({ css: Css_1.Css.wPx(700).$ }, { children: [(0, jsx_runtime_1.jsxs)(FormLines_1.FormLines, Object.assign({ labelSuffix: { required: "*", optional: "(Opt)" } }, { children: [(0, jsx_runtime_1.jsx)("b", { children: "Author" }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.firstName }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.middleInitial }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundTextField, { field: formState.lastName }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundDateField, { field: formState.birthday }, void 0), (0, jsx_runtime_1.jsxs)(forms_1.FieldGroup, { children: [(0, jsx_runtime_1.jsx)(forms_1.StaticField, { label: "Revenue", value: "$500" }, void 0), (0, jsx_runtime_1.jsx)(forms_1.StaticField, Object.assign({ label: "Website" }, { children: (0, jsx_runtime_1.jsx)("a", Object.assign({ href: "https://google.com" }, { children: "google.com" }), void 0) }), void 0)] }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundNumberField, { field: formState.heightInInches }, void 0), (0, jsx_runtime_1.jsx)(forms_1.FormDivider, {}, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundSelectField, { field: formState.favoriteSport, options: sports }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundMultiSelectField, { field: formState.favoriteShapes, options: shapes }, void 0), (0, jsx_runtime_1.jsx)(BoundCheckboxGroupField_1.BoundCheckboxGroupField, { field: formState.favoriteColors, options: colors }, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundToggleChipGroupField, { field: formState.animals, options: animals }, void 0), (0, jsx_runtime_1.jsx)(forms_1.FormDivider, {}, void 0), (0, jsx_runtime_1.jsx)(forms_1.BoundSwitchField, { field: formState.isAvailable }, void 0)] }), void 0), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("strong", { children: ["Books", (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "plus", onClick: () => formState.books.add({ id: String(formState.books.value.length) }) }, void 0)] }, void 0), (0, jsx_runtime_1.jsx)(components_1.GridTable, { columns: columns, rows: rows }, void 0)] }, void 0), (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.childGap1.$ }, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, { onClick: () => formState.revertChanges(), label: "Cancel" }, void 0), (0, jsx_runtime_1.jsx)(components_1.Button, { onClick: () => {
|
|
60
60
|
if (formState.canSave()) {
|
|
61
61
|
formState.commitChanges();
|
|
62
62
|
}
|
|
@@ -72,7 +72,7 @@ function AuthorDetails({ formState, onNext }) {
|
|
|
72
72
|
function BookList({ formState, onNext, onBack }) {
|
|
73
73
|
const columns = (0, react_1.useMemo)(() => createColumns(formState), [formState]);
|
|
74
74
|
const rows = (0, hooks_1.useComputed)(() => [components_1.simpleHeader, ...formState.books.rows.map((data) => ({ kind: "data", id: data.id.value, data }))], []);
|
|
75
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h1", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: ["Books", (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "plus", onClick: () => { var _a; return formState.books.add({ id: String(((_a = formState.books.value) === null || _a === void 0 ? void 0 : _a.length) || 1) }); } }, void 0)] }), void 0), (0, jsx_runtime_1.jsx)(components_1.GridTable, { columns: columns, rows: rows
|
|
75
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h1", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: ["Books", (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "plus", onClick: () => { var _a; return formState.books.add({ id: String(((_a = formState.books.value) === null || _a === void 0 ? void 0 : _a.length) || 1) }); } }, void 0)] }), void 0), (0, jsx_runtime_1.jsx)(components_1.GridTable, { columns: columns, rows: rows }, void 0), (0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.jcsb.bt.bGray300.py1.mt2.$ }, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, { variant: "tertiary", label: "Back", onClick: onBack }, void 0), (0, jsx_runtime_1.jsx)(components_1.Button, { label: "Continue to Misc.", disabled: !formState.books.valid, onClick: onNext }, void 0)] }), void 0)] }, void 0));
|
|
76
76
|
}
|
|
77
77
|
function createColumns(formState) {
|
|
78
78
|
return [
|