@homebound/beam 2.122.0 → 2.122.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.
@@ -9,6 +9,7 @@ export interface PresentationFieldProps {
9
9
  compact?: boolean;
10
10
  typeScale?: Typography;
11
11
  visuallyDisabled?: false;
12
+ errorInTooltip?: true;
12
13
  }
13
14
  export declare type PresentationContextProps = {
14
15
  fieldProps?: PresentationFieldProps;
@@ -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 } : {}),
@@ -66,7 +66,7 @@ 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: false, typeScale: "xs", wrap: true },
69
+ presentationSettings: { borderless: true, typeScale: "xs", wrap: true },
70
70
  };
71
71
  exports.beamNestedFlexibleStyle = {
72
72
  ...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.fg1.$,
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: borderless ? Css_1.Css.bshFocus.z1.$ : Css_1.Css.bLightBlue700.if(contrast).bLightBlue500.$,
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
- ? (_f = inputProps.value) === null || _f === void 0 ? void 0 : _f.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)))
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
- ...(isFocused && !inputProps.readOnly ? fieldStyles.focus : {}),
94
- ...(isHovered && !inputProps.disabled && !inputProps.readOnly && !isFocused ? fieldStyles.hover : {}),
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
- ...(isHovered && !inputProps.disabled && !inputProps.readOnly && !isFocused ? fieldStyles.hover : {}),
101
- ...(multiline ? Css_1.Css.h100.p1.add("resize", "none").if(borderless).pPx(4).$ : Css_1.Css.truncate.$),
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;
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.122.0",
3
+ "version": "2.122.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",