@homebound/beam 2.330.0 → 2.331.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.
@@ -49,6 +49,8 @@ export interface GridStyle {
49
49
  minWidthPx?: number;
50
50
  /** Css to apply at each level of a parent/child nested table. */
51
51
  levels?: Record<number, {
52
+ /** Number of pixels to indent the row. This value will be subtracted from the "first content column" width. First content column is the first column that is not an 'action' column (i.e. non-checkbox or non-collapse button column) */
53
+ rowIndent?: number;
52
54
  cellCss?: Properties;
53
55
  firstContentColumn?: Properties;
54
56
  }>;
@@ -102,6 +102,10 @@ exports.cardStyle = {
102
102
  },
103
103
  rowHoverColor: "none",
104
104
  nonHeaderRowHoverCss: Css_1.Css.bshHover.bGray700.$,
105
+ levels: {
106
+ 1: { rowIndent: 24 },
107
+ 2: { rowIndent: 48 },
108
+ },
105
109
  };
106
110
  function resolveStyles(style) {
107
111
  const defKeysRecord = {
@@ -13,7 +13,7 @@ const Css_1 = require("../../../Css");
13
13
  const utils_2 = require("../../../utils");
14
14
  // We extract Row to its own mini-component primarily so we can React.memo'ize it.
15
15
  function RowImpl(props) {
16
- var _a, _b;
16
+ var _a, _b, _c;
17
17
  const { as, rs, style, rowStyles, columnSizes, getCount, cellHighlight, omitRowHover, hasExpandableHeader, ...others } = props;
18
18
  const { tableState } = (0, react_1.useContext)(TableState_1.TableStateContext);
19
19
  // We're wrapped in observer, so can access these without useComputeds
@@ -30,18 +30,20 @@ function RowImpl(props) {
30
30
  const revealOnRowHoverClass = "revealOnRowHover";
31
31
  const showRowHoverColor = !utils_1.reservedRowKinds.includes(row.kind) && !omitRowHover && style.rowHoverColor !== "none";
32
32
  const rowStyleCellCss = (0, utils_1.maybeApplyFunction)(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.cellCss);
33
+ const levelIndent = style.levels && ((_b = style.levels[level]) === null || _b === void 0 ? void 0 : _b.rowIndent);
33
34
  const rowCss = {
34
35
  ...(!utils_1.reservedRowKinds.includes(row.kind) && style.nonHeaderRowCss),
35
36
  // Optionally include the row hover styles, by default they should be turned on.
36
37
  ...(showRowHoverColor && {
37
38
  // Even though backgroundColor is set on the cellCss, the hover target is the row.
38
- "&:hover > *": Css_1.Css.bgColor((_b = style.rowHoverColor) !== null && _b !== void 0 ? _b : Css_1.Palette.Blue100).$,
39
+ "&:hover > *": Css_1.Css.bgColor((_c = style.rowHoverColor) !== null && _c !== void 0 ? _c : Css_1.Palette.Blue100).$,
39
40
  }),
40
41
  ...(!utils_1.reservedRowKinds.includes(row.kind) &&
41
42
  style.nonHeaderRowHoverCss && {
42
43
  // Need to spread this to make TS happy.
43
44
  ":hover": { ...style.nonHeaderRowHoverCss },
44
45
  }),
46
+ ...(levelIndent && Css_1.Css.mlPx(levelIndent).$),
45
47
  // For virtual tables use `display: flex` to keep all cells on the same row. For each cell in the row use `flexNone` to ensure they stay their defined widths
46
48
  ...(as === "table" ? {} : Css_1.Css.relative.df.fg1.fs1.addIn("&>*", Css_1.Css.flexNone.$).$),
47
49
  // Apply `cursorPointer` to the row if it has a link or `onClick` value.
@@ -195,7 +197,8 @@ function RowImpl(props) {
195
197
  // Apply cell highlight styles to active cell and hover
196
198
  ...Css_1.Css.if(applyCellHighlight && isCellActive).br4.boxShadow(`inset 0 0 0 1px ${Css_1.Palette.Blue700}`).$,
197
199
  // Define the width of the column on each cell. Supports col spans.
198
- width: `calc(${columnSizes.slice(columnIndex, columnIndex + currentColspan).join(" + ")})`,
200
+ // If we have a 'levelIndent' defined, then subtract that amount from the first content column's width to ensure all columns will still line up properly
201
+ width: `calc(${columnSizes.slice(columnIndex, columnIndex + currentColspan).join(" + ")}${applyFirstContentColumnStyles && levelIndent ? ` - ${levelIndent}px` : ""})`,
199
202
  ...(typeof column.mw === "string" ? Css_1.Css.mw(column.mw).$ : {}),
200
203
  };
201
204
  const cellClassNames = revealOnRowHover ? revealOnRowHoverClass : undefined;
@@ -10,7 +10,7 @@ export interface SwitchProps {
10
10
  label: string;
11
11
  /** Where to put the label. */
12
12
  labelStyle?: "form" | "inline" | "filter" | "hidden" | "left" | "centered";
13
- /** Whether or not to hide the label */
13
+ /** Whether to hide the label */
14
14
  hideLabel?: boolean;
15
15
  /** Handler when the interactive element state changes. */
16
16
  onChange: (value: boolean) => void;
@@ -19,8 +19,9 @@ function Switch(props) {
19
19
  const { isFocusVisible: isKeyboardFocus, focusProps } = (0, react_aria_1.useFocusRing)(otherProps);
20
20
  const { hoverProps, isHovered } = (0, react_aria_1.useHover)(ariaProps);
21
21
  const tooltip = (0, components_1.resolveTooltip)(disabled, props.tooltip);
22
- return ((0, jsx_runtime_1.jsxs)("div", { ...hoverProps, css: {
23
- ...Css_1.Css.relative.cursorPointer.df.w("max-content").selectNone.$,
22
+ const tid = (0, utils_1.useTestIds)(otherProps, label);
23
+ return ((0, jsx_runtime_1.jsxs)("label", { ...hoverProps, css: {
24
+ ...Css_1.Css.relative.cursorPointer.df.wmaxc.selectNone.$,
24
25
  ...(labelStyle === "form" && Css_1.Css.fdc.$),
25
26
  ...(labelStyle === "left" && Css_1.Css.w100.aic.$),
26
27
  ...(labelStyle === "inline" && Css_1.Css.gap2.aic.$),
@@ -38,7 +39,7 @@ function Switch(props) {
38
39
  ...switchCircleDefaultStyles(compact),
39
40
  ...(isDisabled && Css_1.Css.bgGray100.$),
40
41
  ...(isSelected && switchCircleSelectedStyles(compact)),
41
- }, children: withIcon && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: isSelected ? "check" : "x", color: isSelected ? Css_1.Palette.Blue700 : Css_1.Palette.Gray400 })) }) }), labelStyle === "inline" && ((0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, tooltip: tooltip, inline: true, xss: Css_1.Css.smMd.gray900.if(compact).add("lineHeight", "1").$ })), (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...inputProps, ...focusProps }) })] }));
42
+ }, children: withIcon && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: isSelected ? "check" : "x", color: isSelected ? Css_1.Palette.Blue700 : Css_1.Palette.Gray400 })) }) }), labelStyle === "inline" && ((0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, tooltip: tooltip, inline: true, xss: Css_1.Css.smMd.gray900.if(compact).add("lineHeight", "1").$ })), (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...inputProps, ...focusProps, ...tid }) })] }));
42
43
  }
43
44
  exports.Switch = Switch;
44
45
  /** Styles */
@@ -50,20 +51,24 @@ exports.switchHoverStyles = Css_1.Css.bgGray400.$;
50
51
  exports.switchFocusStyles = Css_1.Css.bshFocus.$;
51
52
  exports.switchSelectedHoverStyles = Css_1.Css.bgBlue900.$;
52
53
  // Circle inside Switcher/Toggle element styles
53
- const switchCircleDefaultStyles = (isCompact) => ({
54
- ...Css_1.Css.wPx(circleDiameter(isCompact))
55
- .hPx(circleDiameter(isCompact))
56
- .br100.bgWhite.bshBasic.absolute.leftPx(2)
57
- .topPx(2).transition.df.aic.jcc.$,
58
- svg: Css_1.Css.hPx(toggleHeight(isCompact) / 2).wPx(toggleHeight(isCompact) / 2).$,
59
- });
54
+ function switchCircleDefaultStyles(isCompact) {
55
+ return {
56
+ ...Css_1.Css.wPx(circleDiameter(isCompact))
57
+ .hPx(circleDiameter(isCompact))
58
+ .br100.bgWhite.bshBasic.absolute.leftPx(2)
59
+ .topPx(2).transition.df.aic.jcc.$,
60
+ svg: Css_1.Css.hPx(toggleHeight(isCompact) / 2).wPx(toggleHeight(isCompact) / 2).$,
61
+ };
62
+ }
60
63
  /**
61
64
  * Affecting the `left` property due to transitions only working when there is
62
65
  * a previous value to work from.
63
66
  *
64
- * Calculation is as follow:
67
+ * Calculation is as follows:
65
68
  * - `100%` is the toggle width
66
69
  * - `${circleDiameter(isCompact)}px` is the circle diameter
67
70
  * - `2px` is to keep 2px edge spacing.
68
71
  */
69
- const switchCircleSelectedStyles = (isCompact) => Css_1.Css.left(`calc(100% - ${circleDiameter(isCompact)}px - 2px);`).$;
72
+ function switchCircleSelectedStyles(isCompact) {
73
+ return Css_1.Css.left(`calc(100% - ${circleDiameter(isCompact)}px - 2px);`).$;
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.330.0",
3
+ "version": "2.331.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",