@homebound/beam 2.331.0 → 2.332.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.
@@ -22,6 +22,8 @@ class ColumnState {
22
22
  this.visible = (_a = storage.wasVisible(column.id)) !== null && _a !== void 0 ? _a : (column.canHide ? (_b = column.initVisible) !== null && _b !== void 0 ? _b : false : true);
23
23
  if (this.visible && ((_c = storage.wasExpanded(column.id)) !== null && _c !== void 0 ? _c : column.initExpanded)) {
24
24
  this.expanded = true;
25
+ // TODO: verify this eslint ignore
26
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
25
27
  this.doExpand();
26
28
  }
27
29
  (0, mobx_1.makeAutoObservable)(this, { column: mobx_1.observable.ref }, { name: `ColumnState@${column.id}` });
@@ -32,6 +34,8 @@ class ColumnState {
32
34
  // If an expandable header is becoming visible for the 1st time, expand it
33
35
  if (!wasVisible && visible && this.column.initExpanded && this.children === undefined) {
34
36
  this.expanded = true;
37
+ // TODO: verify this eslint ignore
38
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
35
39
  this.doExpand();
36
40
  }
37
41
  }
@@ -44,6 +48,8 @@ class ColumnState {
44
48
  // The first time we expand, fetch our children. Note that ExpandableHeader
45
49
  // technically pre-loads our children, so it can show a spinner while loading,
46
50
  // and only after loading is complete, tell our column to expand.
51
+ // TODO: verify this eslint ignore
52
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
47
53
  if (!wasExpanded)
48
54
  this.doExpand();
49
55
  }
@@ -44,6 +44,8 @@ class ColumnStates {
44
44
  else {
45
45
  existing.column = column;
46
46
  // Any time a column is re-added (i.e. props.columns changed), re-expand it
47
+ // TODO: verify this eslint ignore
48
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
47
49
  if (existing.isExpanded)
48
50
  existing.doExpand(true);
49
51
  return existing;
@@ -0,0 +1,8 @@
1
+ import { ObjectState } from "@homebound/form-state";
2
+ import { ButtonProps } from "..";
3
+ export type SubmitButtonProps<T> = Omit<ButtonProps, "label"> & {
4
+ label?: ButtonProps["label"];
5
+ form: ObjectState<T>;
6
+ };
7
+ /** Provides a Button that will auto-disable if `formState` is invalid. */
8
+ export declare function SubmitButton<T>(props: SubmitButtonProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubmitButton = void 0;
4
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
+ const src_1 = require("..");
6
+ /** Provides a Button that will auto-disable if `formState` is invalid. */
7
+ function SubmitButton(props) {
8
+ const { form, disabled, onClick, label = "Submit", ...others } = props;
9
+ if (typeof onClick === "string") {
10
+ throw new Error("SubmitButton.onClick doesn't support strings yet");
11
+ }
12
+ // Enable the button whenever the form is dirty, even if the form is partially invalid,
13
+ // because submitting will then force-touch all fields and show all errors instead of
14
+ // just errors-so-far.
15
+ const dirty = (0, src_1.useComputed)(() => form.dirty, [form]);
16
+ return ((0, jsx_runtime_1.jsx)(src_1.Button, { label: label, disabled: disabled || !dirty, onClick: (e) => {
17
+ // canSave will touch any not-yet-keyed-in fields to show errors
18
+ if (form.canSave()) {
19
+ void onClick(e);
20
+ }
21
+ }, ...others }));
22
+ }
23
+ exports.SubmitButton = SubmitButton;
@@ -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
+ }
@@ -182,6 +182,8 @@ function TreeSelectFieldBase(props) {
182
182
  const firstOpen = (0, react_1.useRef)(true);
183
183
  function onOpenChange(isOpen) {
184
184
  if (firstOpen.current && isOpen) {
185
+ // TODO: verify this eslint ignore
186
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
185
187
  maybeInitLoad(options, fieldState, setFieldState);
186
188
  firstOpen.current = false;
187
189
  }
@@ -3,6 +3,7 @@ export * from "./Checkbox";
3
3
  export * from "./CheckboxGroup";
4
4
  export * from "./ChipSelectField";
5
5
  export * from "./DateFields";
6
+ export * from "./ErrorMessage";
6
7
  export * from "./MultiLineSelectField";
7
8
  export * from "./MultiSelectField";
8
9
  export * from "./NumberField";
@@ -20,6 +20,7 @@ __exportStar(require("./Checkbox"), exports);
20
20
  __exportStar(require("./CheckboxGroup"), exports);
21
21
  __exportStar(require("./ChipSelectField"), exports);
22
22
  __exportStar(require("./DateFields"), exports);
23
+ __exportStar(require("./ErrorMessage"), exports);
23
24
  __exportStar(require("./MultiLineSelectField"), exports);
24
25
  __exportStar(require("./MultiSelectField"), exports);
25
26
  __exportStar(require("./NumberField"), exports);
@@ -106,6 +106,8 @@ function ComboBoxBase(props) {
106
106
  const firstOpen = (0, react_1.useRef)(true);
107
107
  function onOpenChange(isOpen) {
108
108
  if (firstOpen.current && isOpen) {
109
+ // TODO: verify this eslint ignore
110
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
109
111
  maybeInitLoad();
110
112
  firstOpen.current = false;
111
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.331.0",
3
+ "version": "2.332.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -75,7 +75,7 @@
75
75
  "@emotion/babel-preset-css-prop": "^11.10.0",
76
76
  "@emotion/jest": "^11.10.5",
77
77
  "@emotion/react": "^11.10.6",
78
- "@homebound/eslint-config": "^1.8.0",
78
+ "@homebound/eslint-config": "^1.10.2",
79
79
  "@homebound/rtl-react-router-utils": "1.0.3",
80
80
  "@homebound/rtl-utils": "^2.65.0",
81
81
  "@homebound/truss": "^1.132.0",
@@ -108,7 +108,7 @@
108
108
  "babel-loader": "^8.2.2",
109
109
  "chromatic": "^6.17.0",
110
110
  "conventional-changelog-conventionalcommits": "^5.0.0",
111
- "eslint": "^8.12.0",
111
+ "eslint": "^8.52.0",
112
112
  "eslint-plugin-storybook": "^0.6.14",
113
113
  "husky": "^5.1.1",
114
114
  "identity-obj-proxy": "^3.0.0",