@homebound/beam 2.328.0 → 2.330.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.
@@ -1,14 +1,21 @@
1
- import React, { LabelHTMLAttributes } from "react";
2
- interface LabelProps {
1
+ import { LabelHTMLAttributes, ReactNode } from "react";
2
+ import { Font, Only, Xss } from "../Css";
3
+ type LabelXss = Font | "color";
4
+ interface LabelProps<X> {
3
5
  labelProps?: LabelHTMLAttributes<HTMLLabelElement>;
4
6
  label: string;
5
7
  suffix?: string;
6
8
  hidden?: boolean;
7
9
  contrast?: boolean;
8
10
  multiline?: boolean;
11
+ tooltip?: ReactNode;
12
+ inline?: boolean;
13
+ xss?: X;
9
14
  }
10
15
  /** An internal helper component for rendering form labels. */
11
- export declare const Label: React.MemoExoticComponent<(props: LabelProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
16
+ declare function LabelComponent<X extends Only<Xss<LabelXss>, X>>(props: LabelProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
17
+ export declare const Label: typeof LabelComponent;
18
+ type InlineLabelProps = Omit<LabelProps<unknown>, "xss" | "inline">;
12
19
  /** Used for showing labels within text fields. */
13
- export declare function InlineLabel({ labelProps, label, contrast, multiline, ...others }: LabelProps): import("@emotion/react/jsx-runtime").JSX.Element;
20
+ export declare function InlineLabel({ labelProps, label, contrast, multiline, ...others }: InlineLabelProps): import("@emotion/react/jsx-runtime").JSX.Element;
14
21
  export {};
@@ -8,12 +8,14 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const react_aria_1 = require("react-aria");
10
10
  const Css_1 = require("../Css");
11
+ const src_1 = require("..");
11
12
  /** An internal helper component for rendering form labels. */
12
- exports.Label = react_1.default.memo((props) => {
13
- const { labelProps, label, hidden, suffix, contrast = false, ...others } = props;
14
- const labelEl = ((0, jsx_runtime_1.jsxs)("label", { ...labelProps, ...others, css: Css_1.Css.dib.sm.gray700.mbPx(4).if(contrast).white.$, children: [label, suffix && ` ${suffix}`] }));
13
+ function LabelComponent(props) {
14
+ const { labelProps, label, hidden, suffix, contrast = false, tooltip, inline, xss, ...others } = props;
15
+ const labelEl = ((0, jsx_runtime_1.jsxs)("label", { ...labelProps, ...others, css: { ...Css_1.Css.dif.aic.gap1.sm.gray700.mbPx(inline ? 0 : 4).if(contrast).white.$, ...xss }, children: [label, suffix && ` ${suffix}`, tooltip && ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.$, children: (0, jsx_runtime_1.jsx)(src_1.Icon, { icon: "infoCircle", tooltip: tooltip, inc: 2, color: contrast ? Css_1.Palette.White : Css_1.Palette.Gray700 }) }))] }));
15
16
  return hidden ? (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: labelEl }) : labelEl;
16
- });
17
+ }
18
+ exports.Label = react_1.default.memo(LabelComponent);
17
19
  /** Used for showing labels within text fields. */
18
20
  function InlineLabel({ labelProps, label, contrast, multiline = false, ...others }) {
19
21
  return ((0, jsx_runtime_1.jsxs)("label", { ...labelProps, ...others, css: Css_1.Css.smMd.nowrap.gray900.prPx(4).add("color", "currentColor").asc.if(multiline).asfs.pt1.$, children: [label, ":"] }));
@@ -235,7 +235,7 @@ function renderDiv(style, id, columns, visibleDataRows, keptSelectedRows, firstR
235
235
  ...Css_1.Css.if(stickyHeader).sticky.topPx(stickyOffset).z(utils_1.zIndices.stickyHeader).$,
236
236
  }, children: tableHeadRows }), (0, jsx_runtime_1.jsxs)("div", { css: {
237
237
  ...(style.betweenRowsCss ? Css_1.Css.addIn(`& > div > *`, style.betweenRowsCss).$ : {}),
238
- ...(style.firstNonHeaderRowCss ? Css_1.Css.addIn(`& > div:first-of-type > *`, style.firstNonHeaderRowCss).$ : {}),
238
+ ...(style.firstNonHeaderRowCss ? Css_1.Css.addIn(`& > div:first-of-type`, style.firstNonHeaderRowCss).$ : {}),
239
239
  ...(style.lastRowCss && Css_1.Css.addIn("& > div:last-of-type", style.lastRowCss).$),
240
240
  }, children: [keptSelectedRows, firstRowMessage && ((0, jsx_runtime_1.jsx)("div", { css: { ...style.firstRowMessageCss }, "data-gridrow": true, children: firstRowMessage })), visibleDataRows] })] }));
241
241
  }
@@ -245,7 +245,7 @@ function renderTable(style, id, columns, visibleDataRows, keptSelectedRows, firs
245
245
  ...Css_1.Css.w100.add("borderCollapse", "separate").add("borderSpacing", "0").$,
246
246
  ...Css_1.Css.addIn("& > tbody > tr > * ", style.betweenRowsCss || {})
247
247
  // removes border between header and second row
248
- .addIn("& > tbody > tr:first-of-type > *", style.firstNonHeaderRowCss || {}).$,
248
+ .addIn("& > tbody > tr:first-of-type", style.firstNonHeaderRowCss || {}).$,
249
249
  ...Css_1.Css.addIn("& > tbody > tr:last-of-type", style.lastRowCss).$,
250
250
  ...Css_1.Css.addIn("& > thead > tr:first-of-type", style.firstRowCss).$,
251
251
  ...style.rootCss,
@@ -364,7 +364,7 @@ const VirtualRoot = (0, memoize_one_1.default)((gs, _columns, id, xss) => {
364
364
  ...(isHeader
365
365
  ? Css_1.Css.addIn("& > div:first-of-type > *", gs.firstRowCss).$
366
366
  : {
367
- ...Css_1.Css.addIn("& > div:first-of-type > *", gs.firstNonHeaderRowCss).$,
367
+ ...Css_1.Css.addIn("& > div:first-of-type", gs.firstNonHeaderRowCss).$,
368
368
  ...Css_1.Css.addIn("& > div:last-of-type > *", gs.lastRowCss).$,
369
369
  }),
370
370
  ...gs.rootCss,
@@ -13,6 +13,8 @@ export interface GridStyle {
13
13
  lastRowCss?: Properties;
14
14
  /** Applied on the first row of the table (could be the Header or Totals row). */
15
15
  firstRowCss?: Properties;
16
+ /** Applied to every non-header row of the table */
17
+ nonHeaderRowCss?: Properties;
16
18
  /** Applied to the first non-header row, i.e. if you want to cancel out `betweenRowsCss`. */
17
19
  firstNonHeaderRowCss?: Properties;
18
20
  /** Applied to all cell divs (via a selector off the base div). */
@@ -37,7 +39,9 @@ export interface GridStyle {
37
39
  /** Applied if there is a fallback/overflow message showing. */
38
40
  firstRowMessageCss?: Properties;
39
41
  /** Applied on hover if a row has a rowLink/onClick set. */
40
- rowHoverColor?: Palette;
42
+ rowHoverColor?: Palette | "none";
43
+ /** Applied on hover of a row */
44
+ nonHeaderRowHoverCss?: Properties;
41
45
  /** Default content to put into an empty cell */
42
46
  emptyCell?: ReactNode;
43
47
  presentationSettings?: Pick<PresentationFieldProps, "borderless" | "typeScale"> & Pick<PresentationContextProps, "wrap">;
@@ -92,18 +92,16 @@ exports.condensedStyle = {
92
92
  exports.cardStyle = {
93
93
  ...exports.defaultStyle,
94
94
  betweenRowsCss: {},
95
- firstNonHeaderRowCss: Css_1.Css.mt2.$,
96
- cellCss: Css_1.Css.p2.my1.bt.bb.bGray400.$,
97
- firstCellCss: Css_1.Css.bl.add({ borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }).$,
98
- lastCellCss: Css_1.Css.br.add({ borderTopRightRadius: "4px", borderBottomRightRadius: "4px" }).$,
95
+ nonHeaderRowCss: Css_1.Css.br4.overflowHidden.ba.bGray400.mt2.add("transition", "all 240ms").$,
96
+ firstRowCss: Css_1.Css.bl.br.bGray200.borderRadius("8px 8px 0 0").overflowHidden.$,
97
+ cellCss: Css_1.Css.p2.$,
99
98
  // Undo the card look & feel for the header
100
99
  headerCellCss: {
101
100
  ...exports.defaultStyle.headerCellCss,
102
- ...Css_1.Css.add({
103
- border: "none",
104
- borderRadius: "unset",
105
- }).p1.m0.xsMd.gray700.$,
101
+ ...Css_1.Css.p1.m0.xsMd.gray700.$,
106
102
  },
103
+ rowHoverColor: "none",
104
+ nonHeaderRowHoverCss: Css_1.Css.bshHover.bGray700.$,
107
105
  };
108
106
  function resolveStyles(style) {
109
107
  const defKeysRecord = {
@@ -28,14 +28,20 @@ function RowImpl(props) {
28
28
  const RowTag = as === "table" ? "tr" : "div";
29
29
  const sortOn = (_a = tableState.sortConfig) === null || _a === void 0 ? void 0 : _a.on;
30
30
  const revealOnRowHoverClass = "revealOnRowHover";
31
- const showRowHoverColor = !utils_1.reservedRowKinds.includes(row.kind) && !omitRowHover;
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
33
  const rowCss = {
34
+ ...(!utils_1.reservedRowKinds.includes(row.kind) && style.nonHeaderRowCss),
34
35
  // Optionally include the row hover styles, by default they should be turned on.
35
36
  ...(showRowHoverColor && {
36
37
  // Even though backgroundColor is set on the cellCss, the hover target is the row.
37
38
  "&:hover > *": Css_1.Css.bgColor((_b = style.rowHoverColor) !== null && _b !== void 0 ? _b : Css_1.Palette.Blue100).$,
38
39
  }),
40
+ ...(!utils_1.reservedRowKinds.includes(row.kind) &&
41
+ style.nonHeaderRowHoverCss && {
42
+ // Need to spread this to make TS happy.
43
+ ":hover": { ...style.nonHeaderRowHoverCss },
44
+ }),
39
45
  // 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
40
46
  ...(as === "table" ? {} : Css_1.Css.relative.df.fg1.fs1.addIn("&>*", Css_1.Css.flexNone.$).$),
41
47
  // Apply `cursorPointer` to the row if it has a link or `onClick` value.
@@ -9,7 +9,7 @@ export interface SwitchProps {
9
9
  /** Input label */
10
10
  label: string;
11
11
  /** Where to put the label. */
12
- labelStyle?: "form" | "inline" | "filter" | "hidden" | "left";
12
+ labelStyle?: "form" | "inline" | "filter" | "hidden" | "left" | "centered";
13
13
  /** Whether or not to hide the label */
14
14
  hideLabel?: boolean;
15
15
  /** Handler when the interactive element state changes. */
@@ -18,6 +18,8 @@ export interface SwitchProps {
18
18
  selected: boolean;
19
19
  /** Whether to include icons like the check mark */
20
20
  withIcon?: boolean;
21
+ /** Adds tooltip for the switch */
22
+ tooltip?: ReactNode;
21
23
  }
22
24
  export declare function Switch(props: SwitchProps): import("@emotion/react/jsx-runtime").JSX.Element;
23
25
  export declare const switchHoverStyles: {
@@ -18,33 +18,27 @@ function Switch(props) {
18
18
  const { inputProps } = (0, react_aria_1.useSwitch)({ ...ariaProps, "aria-label": label }, state, ref);
19
19
  const { isFocusVisible: isKeyboardFocus, focusProps } = (0, react_aria_1.useFocusRing)(otherProps);
20
20
  const { hoverProps, isHovered } = (0, react_aria_1.useHover)(ariaProps);
21
- const tooltip = (0, components_1.resolveTooltip)(disabled);
22
- return (0, components_1.maybeTooltip)({
23
- title: tooltip,
24
- placement: "top",
25
- children: ((0, jsx_runtime_1.jsxs)("label", { ...hoverProps, css: {
26
- ...Css_1.Css.relative.cursorPointer.df.w("max-content").smMd.selectNone.$,
27
- ...(labelStyle === "form" && Css_1.Css.fdc.$),
28
- ...(labelStyle === "left" && Css_1.Css.w100.fdr.$),
29
- ...(labelStyle === "inline" && Css_1.Css.gap2.aic.$),
30
- ...(labelStyle === "filter" && Css_1.Css.jcsb.gap1.aic.wa.sm.$),
31
- ...(isDisabled && Css_1.Css.cursorNotAllowed.gray400.$),
32
- }, "aria-label": label, children: [(labelStyle === "form" || labelStyle === "left") && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.if(labelStyle === "left").w50.$, children: (0, jsx_runtime_1.jsx)(Label_1.Label, { label: label }) })), labelStyle === "filter" && (0, jsx_runtime_1.jsx)("span", { children: label }), (0, jsx_runtime_1.jsx)("div", { "aria-hidden": "true", css: {
33
- ...Css_1.Css.wPx(40).hPx(toggleHeight(compact)).bgGray200.br12.relative.transition.$,
34
- ...(isHovered && exports.switchHoverStyles),
35
- ...(isKeyboardFocus && exports.switchFocusStyles),
36
- ...(isDisabled && Css_1.Css.bgGray300.$),
37
- ...(isSelected && Css_1.Css.bgBlue700.$),
38
- ...(isSelected && isHovered && exports.switchSelectedHoverStyles),
39
- }, children: (0, jsx_runtime_1.jsx)("div", { css: {
40
- ...switchCircleDefaultStyles(compact),
41
- ...(isDisabled && Css_1.Css.bgGray100.$),
42
- ...(isSelected && switchCircleSelectedStyles(compact)),
43
- }, 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)("span", { css: {
44
- // LineHeight is conditionally applied to handle compact version text alignment
45
- ...Css_1.Css.if(compact).add("lineHeight", "1").$,
46
- }, children: label })), (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ref: ref, ...inputProps, ...focusProps }) })] })),
47
- });
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.$,
24
+ ...(labelStyle === "form" && Css_1.Css.fdc.$),
25
+ ...(labelStyle === "left" && Css_1.Css.w100.aic.$),
26
+ ...(labelStyle === "inline" && Css_1.Css.gap2.aic.$),
27
+ ...(labelStyle === "filter" && Css_1.Css.jcsb.gap1.aic.wa.sm.$),
28
+ ...(labelStyle === "centered" && Css_1.Css.fdc.aic.$),
29
+ ...(isDisabled && Css_1.Css.cursorNotAllowed.gray400.$),
30
+ }, children: [labelStyle !== "inline" && labelStyle !== "hidden" && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.if(labelStyle === "left").w50.$, children: (0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, tooltip: tooltip, xss: Css_1.Css.if(labelStyle === "filter").gray900.$, inline: labelStyle === "left" || labelStyle === "filter" }) })), (0, jsx_runtime_1.jsx)("div", { "aria-hidden": "true", css: {
31
+ ...Css_1.Css.wPx(40).hPx(toggleHeight(compact)).bgGray200.br12.relative.transition.$,
32
+ ...(isHovered && exports.switchHoverStyles),
33
+ ...(isKeyboardFocus && exports.switchFocusStyles),
34
+ ...(isDisabled && Css_1.Css.bgGray300.$),
35
+ ...(isSelected && Css_1.Css.bgBlue700.$),
36
+ ...(isSelected && isHovered && exports.switchSelectedHoverStyles),
37
+ }, children: (0, jsx_runtime_1.jsx)("div", { css: {
38
+ ...switchCircleDefaultStyles(compact),
39
+ ...(isDisabled && Css_1.Css.bgGray100.$),
40
+ ...(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 }) })] }));
48
42
  }
49
43
  exports.Switch = Switch;
50
44
  /** Styles */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.328.0",
3
+ "version": "2.330.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",