@homebound/beam 2.346.0 → 2.347.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/Css.d.ts CHANGED
@@ -4244,6 +4244,28 @@ declare class CssBuilder<T extends Properties> {
4244
4244
  } & {
4245
4245
  backgroundColor: import("csstype").Property.BackgroundColor | undefined;
4246
4246
  }>;
4247
+ /** Sets `position: "absolute"; overflow: "hidden"; clip: "inset(50%)"; clipPath: ""; border: 0; height: "1px"; margin: "-1px"; width: "1px"; padding: 0; whiteSpace: "nowrap"`. */
4248
+ get visuallyHidden(): CssBuilder<T & {
4249
+ position: import("csstype").Property.Position | undefined;
4250
+ } & {
4251
+ overflow: import("csstype").Property.Overflow | undefined;
4252
+ } & {
4253
+ clip: import("csstype").Property.Clip | undefined;
4254
+ } & {
4255
+ clipPath: import("csstype").Property.ClipPath | undefined;
4256
+ } & {
4257
+ border: import("csstype").Property.Border<string | 0> | undefined;
4258
+ } & {
4259
+ height: import("csstype").Property.Height<string | 0> | undefined;
4260
+ } & {
4261
+ margin: import("csstype").Property.Margin<string | 0> | undefined;
4262
+ } & {
4263
+ width: import("csstype").Property.Width<string | 0> | undefined;
4264
+ } & {
4265
+ padding: import("csstype").Property.Padding<string | 0> | undefined;
4266
+ } & {
4267
+ whiteSpace: import("csstype").Property.WhiteSpace | undefined;
4268
+ }>;
4247
4269
  /** Sets `content: "''"`. */
4248
4270
  get contentEmpty(): CssBuilder<T & {
4249
4271
  content: import("csstype").Property.Content | undefined;
package/dist/Css.js CHANGED
@@ -3777,6 +3777,11 @@ class CssBuilder {
3777
3777
  get underlay() {
3778
3778
  return this.add("position", "fixed").add("top", 0).add("bottom", 0).add("left", 0).add("right", 0).add("display", "flex").add("alignItems", "center").add("justifyContent", "center").add("backgroundColor", "rgba(36,36,36,0.2)");
3779
3779
  }
3780
+ // visuallyHidden
3781
+ /** Sets `position: "absolute"; overflow: "hidden"; clip: "inset(50%)"; clipPath: ""; border: 0; height: "1px"; margin: "-1px"; width: "1px"; padding: 0; whiteSpace: "nowrap"`. */
3782
+ get visuallyHidden() {
3783
+ return this.add("position", "absolute").add("overflow", "hidden").add("clip", "inset(50%)").add("clipPath", "").add("border", 0).add("height", "1px").add("margin", "-1px").add("width", "1px").add("padding", 0).add("whiteSpace", "nowrap");
3784
+ }
3780
3785
  // contentEmpty
3781
3786
  /** Sets `content: "''"`. */
3782
3787
  get contentEmpty() {
@@ -29,7 +29,7 @@ function Pagination(props) {
29
29
  }
30
30
  }
31
31
  const tid = (0, utils_1.useTestIds)(props, "pagination");
32
- return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.bGray200.bt.xs.gray500.px2.pt2.$, ...tid, children: [(0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.mya.mr2.$, ...tid.pageSizeLabel, children: "Page size:" }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.wPx(78).$, children: (0, jsx_runtime_1.jsx)(inputs_1.SelectField, { compact: true, label: "Page Size", labelStyle: "hidden", options: exports.pageOptions, value: pageSize, onSelect: (val) => set({ pageNumber: 1, pageSize: val }), ...tid.pageSize }) }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.mla.mya.df.$, children: [(0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.mya.mr2.$, ...tid.pageInfoLabel, children: [first, " ", showLast ? `- ${last}` : "", " of ", totalCount] }), (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "chevronLeft", color: hasPrevPage ? Css_1.Palette.Blue700 : Css_1.Palette.Gray200, onClick: () => set({ pageNumber: pageNumber - 1, pageSize }), disabled: !hasPrevPage, ...tid.previousIcon }), (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "chevronRight", color: hasNextPage ? Css_1.Palette.Blue700 : Css_1.Palette.Gray200, onClick: () => set({ pageNumber: pageNumber + 1, pageSize }), disabled: !hasNextPage, ...tid.nextIcon })] })] }));
32
+ return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.bGray200.bt.xs.gray500.px2.pt2.$, ...tid, children: [(0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.mya.mr2.$, ...tid.pageSizeLabel, children: "Page size:" }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.wPx(95).$, children: (0, jsx_runtime_1.jsx)(inputs_1.SelectField, { compact: true, label: "Page Size", labelStyle: "hidden", options: exports.pageOptions, value: pageSize, onSelect: (val) => set({ pageNumber: 1, pageSize: val }), ...tid.pageSize }) }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.mla.mya.df.$, children: [(0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.mya.mr2.$, ...tid.pageInfoLabel, children: [first, " ", showLast ? `- ${last}` : "", " of ", totalCount] }), (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "chevronLeft", color: hasPrevPage ? Css_1.Palette.Blue700 : Css_1.Palette.Gray200, onClick: () => set({ pageNumber: pageNumber - 1, pageSize }), disabled: !hasPrevPage, ...tid.previousIcon }), (0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "chevronRight", color: hasNextPage ? Css_1.Palette.Blue700 : Css_1.Palette.Gray200, onClick: () => set({ pageNumber: pageNumber + 1, pageSize }), disabled: !hasNextPage, ...tid.nextIcon })] })] }));
33
33
  }
34
34
  exports.Pagination = Pagination;
35
35
  function toLimitAndOffset(page) {
@@ -17,5 +17,6 @@ export interface TextFieldBaseProps<X> extends Pick<BeamTextFieldProps<X>, "labe
17
17
  tooltip?: ReactNode;
18
18
  hideErrorMessage?: boolean;
19
19
  alwaysShowHelperText?: boolean;
20
+ unfocusedPlaceholder?: ReactNode;
20
21
  }
21
22
  export declare function TextFieldBase<X extends Only<TextFieldXss, X>>(props: TextFieldBaseProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -19,7 +19,7 @@ const utils_1 = require("./utils");
19
19
  function TextFieldBase(props) {
20
20
  var _a, _b, _c, _d, _e, _f, _g, _h;
21
21
  const { fieldProps, wrap = false } = (0, PresentationContext_1.usePresentationContext)();
22
- const { label, required, labelProps, inputProps, inputRef, inputWrapRef, groupProps, compact = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.compact) !== null && _a !== void 0 ? _a : false, errorMsg, helperText, multiline = false, onChange, onBlur, onFocus, xss, endAdornment, startAdornment, labelStyle = (_b = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _b !== void 0 ? _b : "above", 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, errorInTooltip = (_e = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.errorInTooltip) !== null && _e !== void 0 ? _e : false, hideErrorMessage = false, alwaysShowHelperText = false, fullWidth = (_f = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _f !== void 0 ? _f : false, } = props;
22
+ const { label, required, labelProps, inputProps, inputRef, inputWrapRef, groupProps, compact = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.compact) !== null && _a !== void 0 ? _a : false, errorMsg, helperText, multiline = false, onChange, onBlur, onFocus, xss, endAdornment, startAdornment, labelStyle = (_b = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _b !== void 0 ? _b : "above", 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, errorInTooltip = (_e = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.errorInTooltip) !== null && _e !== void 0 ? _e : false, hideErrorMessage = false, alwaysShowHelperText = false, fullWidth = (_f = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _f !== void 0 ? _f : false, unfocusedPlaceholder, } = props;
23
23
  const typeScale = (_g = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.typeScale) !== null && _g !== void 0 ? _g : (inputProps.readOnly && labelStyle !== "hidden" ? "smMd" : "sm");
24
24
  const internalProps = props.internalProps || {};
25
25
  const { compound = false, forceFocus = false, forceHover = false } = internalProps;
@@ -73,7 +73,7 @@ function TextFieldBase(props) {
73
73
  // Not using Truss's inline `if` statement here because `addIn` properties do not respect the if statement.
74
74
  ...(contrast && Css_1.Css.addIn("&::selection", Css_1.Css.bgGray800.$).$),
75
75
  // For "multiline" fields we add top and bottom padding of 7px for compact, or 11px for non-compact, to properly match the height of the single line fields
76
- ...(multiline ? Css_1.Css.br4.h100.pyPx(compact ? 7 : 11).add("resize", "none").$ : Css_1.Css.truncate.$),
76
+ ...(multiline ? Css_1.Css.br4.pyPx(compact ? 7 : 11).add("resize", "none").$ : Css_1.Css.truncate.$),
77
77
  },
78
78
  hover: Css_1.Css.bgColor(hoverBgColor).if(contrast).bGray600.$,
79
79
  focus: Css_1.Css.bBlue700.if(contrast).bBlue500.$,
@@ -95,6 +95,12 @@ function TextFieldBase(props) {
95
95
  const onFocusChained = (0, react_aria_1.chain)((e) => {
96
96
  e.target.select();
97
97
  }, onFocus);
98
+ // Simulate clicking `ElementType` when using an unfocused placeholder
99
+ function handleUnfocusedPlaceholderClick(e) {
100
+ var _a;
101
+ e.stopPropagation();
102
+ (_a = fieldRef.current) === null || _a === void 0 ? void 0 : _a.click();
103
+ }
98
104
  const showFocus = (isFocused && !inputProps.readOnly) || forceFocus;
99
105
  const showHover = (isHovered && !inputProps.disabled && !inputProps.readOnly && !isFocused) || forceHover;
100
106
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { css: fieldStyles.container, ...groupProps, ...focusWithinProps, children: [label && labelStyle !== "inline" && ((0, jsx_runtime_1.jsx)(Label_1.Label, { labelProps: labelProps, hidden: labelStyle === "hidden" || compound, label: label, inline: labelStyle !== "above", suffix: labelSuffix, contrast: contrast, ...tid.label })), (0, components_1.maybeTooltip)({
@@ -114,11 +120,15 @@ function TextFieldBase(props) {
114
120
  ...(showHover ? fieldStyles.hover : {}),
115
121
  // Only show error styles if the field is not disabled, following the pattern that the error message is also hidden
116
122
  ...(errorMsg && !inputProps.disabled ? fieldStyles.error : {}),
117
- ...Css_1.Css.if(multiline).aifs.mhPx(textAreaMinHeight).$,
118
- }, ...hoverProps, ref: inputWrapRef, children: [labelStyle === "inline" && label && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, { multiline: multiline, labelProps: labelProps, label: label, ...tid.label })), startAdornment && (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.df.aic.asc.fs0.br4.pr1.$, children: startAdornment }), (0, jsx_runtime_1.jsx)(ElementType, { ...(0, react_aria_1.mergeProps)(inputProps, { onBlur, onFocus: onFocusChained, onChange: onDomChange }, { "aria-invalid": Boolean(errorMsg), ...(labelStyle === "hidden" ? { "aria-label": label } : {}) }), ...(errorMsg ? { "aria-errormessage": errorMessageId } : {}), ref: fieldRef, rows: multiline ? 1 : undefined, css: {
123
+ ...Css_1.Css.if(multiline).aifs.overflowHidden.mhPx(textAreaMinHeight).$,
124
+ }, ...hoverProps, ref: inputWrapRef, onClick: unfocusedPlaceholder ? handleUnfocusedPlaceholderClick : undefined, children: [labelStyle === "inline" && label && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, { multiline: multiline, labelProps: labelProps, label: label, ...tid.label })), startAdornment && (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.df.aic.asc.fs0.br4.pr1.$, children: startAdornment }), unfocusedPlaceholder && ((0, jsx_runtime_1.jsx)("div", { ...tid.unfocusedPlaceholderContainer, css: {
125
+ ...Css_1.Css.df.asc.w100.maxh100.overflowAuto.$,
126
+ ...(isFocused && Css_1.Css.visuallyHidden.$),
127
+ }, children: unfocusedPlaceholder })), (0, jsx_runtime_1.jsx)(ElementType, { ...(0, react_aria_1.mergeProps)(inputProps, { onBlur, onFocus: onFocusChained, onChange: onDomChange }, { "aria-invalid": Boolean(errorMsg), ...(labelStyle === "hidden" ? { "aria-label": label } : {}) }), ...(errorMsg ? { "aria-errormessage": errorMessageId } : {}), ref: fieldRef, rows: multiline ? 1 : undefined, css: {
119
128
  ...fieldStyles.input,
120
129
  ...(inputProps.disabled ? fieldStyles.disabled : {}),
121
130
  ...(showHover ? fieldStyles.hover : {}),
131
+ ...(unfocusedPlaceholder && !isFocused && Css_1.Css.visuallyHidden.$),
122
132
  ...xss,
123
133
  }, ...tid }), isFocused && clearable && onChange && inputProps.value && ((0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: "xCircle", color: Css_1.Palette.Gray700, onClick: () => {
124
134
  var _a;
@@ -7,7 +7,6 @@ const react_aria_1 = require("react-aria");
7
7
  const components_1 = require("../../components");
8
8
  const PresentationContext_1 = require("../../components/PresentationContext");
9
9
  const Css_1 = require("../../Css");
10
- const useGrowingTextField_1 = require("../hooks/useGrowingTextField");
11
10
  const TextFieldBase_1 = require("../TextFieldBase");
12
11
  const TreeSelectField_1 = require("../TreeSelectField/TreeSelectField");
13
12
  const utils_1 = require("../TreeSelectField/utils");
@@ -21,11 +20,13 @@ function ComboBoxInput(props) {
21
20
  const [isFocused, setIsFocused] = (0, react_1.useState)(false);
22
21
  const isMultiSelect = state.selectionManager.selectionMode === "multiple";
23
22
  const showNumSelection = isMultiSelect && state.selectionManager.selectedKeys.size > 1;
23
+ // Show selections as chips
24
+ const hasSelection = state.selectionManager.selectedKeys.size > 0;
24
25
  // For MultiSelect only show the `fieldDecoration` when input is not in focus.
25
26
  const showFieldDecoration = (!isMultiSelect || (isMultiSelect && !isFocused)) && fieldDecoration && selectedOptions.length === 1;
26
27
  const multilineProps = allowWrap ? { textAreaMinHeight: 0, multiline: true } : {};
27
- (0, useGrowingTextField_1.useGrowingTextField)({ disabled: !allowWrap, inputRef, inputWrapRef, value: inputProps.value });
28
- return ((0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { ...otherProps, ...multilineProps, inputRef: inputRef, inputWrapRef: inputWrapRef, errorMsg: errorMsg, contrast: contrast, xss: otherProps.labelStyle !== "inline" && !inputProps.readOnly ? Css_1.Css.fw5.$ : {}, startAdornment: (showNumSelection && ((0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.wPx(16).hPx(16).fs0.br100.bgBlue700.white.tinySb.df.aic.jcc.$, "data-testid": "selectedOptionsCount", children: isTree ? selectedOptionsLabels === null || selectedOptionsLabels === void 0 ? void 0 : selectedOptionsLabels.length : state.selectionManager.selectedKeys.size }))) ||
28
+ const chipLabels = isTree ? selectedOptionsLabels || [] : selectedOptions.map((o) => getOptionLabel(o));
29
+ return ((0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { ...otherProps, ...multilineProps, unfocusedPlaceholder: hasSelection && (0, jsx_runtime_1.jsx)(components_1.Chips, { compact: otherProps.compact, values: chipLabels }), inputRef: inputRef, inputWrapRef: inputWrapRef, errorMsg: errorMsg, contrast: contrast, xss: otherProps.labelStyle !== "inline" && !inputProps.readOnly ? Css_1.Css.fw5.$ : {}, startAdornment: (showNumSelection && ((0, jsx_runtime_1.jsx)(components_1.Tooltip, { title: (0, jsx_runtime_1.jsx)(SelectedOptionBullets, { labels: chipLabels }), children: (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.wPx(16).hPx(16).fs0.br100.bgBlue700.white.tinySb.df.aic.jcc.$, "data-testid": "selectedOptionsCount", children: isTree ? selectedOptionsLabels === null || selectedOptionsLabels === void 0 ? void 0 : selectedOptionsLabels.length : state.selectionManager.selectedKeys.size }) }))) ||
29
30
  (showFieldDecoration && fieldDecoration(selectedOptions[0])), endAdornment: !inputProps.readOnly && ((0, jsx_runtime_1.jsx)("button", { ...buttonProps, disabled: inputProps.disabled, ref: buttonRef, css: {
30
31
  ...Css_1.Css.br4.outline0.gray700.if(contrast).gray400.$,
31
32
  ...(inputProps.disabled ? Css_1.Css.cursorNotAllowed.gray400.if(contrast).gray600.$ : {}),
@@ -141,3 +142,6 @@ function ComboBoxInput(props) {
141
142
  } }));
142
143
  }
143
144
  exports.ComboBoxInput = ComboBoxInput;
145
+ function SelectedOptionBullets({ labels = [] }) {
146
+ return (0, jsx_runtime_1.jsx)("div", { children: labels === null || labels === void 0 ? void 0 : labels.map((label) => (0, jsx_runtime_1.jsx)("li", { children: label }, label)) });
147
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.346.0",
3
+ "version": "2.347.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",