@homebound/beam 2.398.0 → 2.399.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/index.cjs CHANGED
@@ -8562,7 +8562,7 @@ function TextFieldBase(props) {
8562
8562
  const fieldStyles = {
8563
8563
  container: Css.df.fdc.w100.maxw(fieldMaxWidth).relative.if(labelStyle === "left").maxw100.fdr.gap2.jcsb.aic.$,
8564
8564
  inputWrapper: {
8565
- ...Css[typeScale].df.aic.br4.px1.w100.bgColor(bgColor).gray900.if(contrast && !inputStylePalette).white.if(labelStyle === "left").w(labelLeftFieldWidth).$,
8565
+ ...Css[typeScale].df.aic.br4.pxPx(textFieldBasePadding).w100.bgColor(bgColor).gray900.if(contrast && !inputStylePalette).white.if(labelStyle === "left").w(labelLeftFieldWidth).$,
8566
8566
  // When borderless then perceived vertical alignments are misaligned. As there is no longer a border, then the field looks oddly indented.
8567
8567
  // This typically happens in tables when a column has a mix of static text (i.e. "roll up" rows and table headers) and input fields.
8568
8568
  // To remedy this perceived misalignment then we increase the width by the horizontal padding applied (16px), and set a negative margin left margin to re-center the field.
@@ -8592,7 +8592,7 @@ function TextFieldBase(props) {
8592
8592
  // Make the background transparent when highlighting the field on hover
8593
8593
  ...borderOnHover && Css.bgTransparent.$,
8594
8594
  // 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
8595
- ...multiline ? Css.br4.pyPx(compact ? 7 : 11).add("resize", "none").$ : Css.truncate.$
8595
+ ...multiline ? Css.br4.pyPx(compact ? 7 : textFieldBaseMultilineTopPadding).add("resize", "none").$ : Css.truncate.$
8596
8596
  },
8597
8597
  hover: Css.bgColor(hoverBgColor).if(contrast).bcGray600.$,
8598
8598
  focus: Css.bcBlue700.if(contrast).bcBlue500.if(borderOnHover).bgColor(hoverBgColor).bcBlue500.$,
@@ -8752,6 +8752,8 @@ function getInputStylePalette(inputStylePalette) {
8752
8752
  return ["rgba(255,255,255,1)" /* White */, "rgba(247, 245, 245, 1)" /* Gray100 */, "rgba(247, 245, 245, 1)" /* Gray100 */];
8753
8753
  }
8754
8754
  }
8755
+ var textFieldBasePadding = increment(1);
8756
+ var textFieldBaseMultilineTopPadding = 11;
8755
8757
 
8756
8758
  // src/inputs/internal/MenuSearchField.tsx
8757
8759
  var import_jsx_runtime35 = require("@emotion/react/jsx-runtime");
@@ -9068,7 +9070,16 @@ var import_react_aria26 = require("react-aria");
9068
9070
  // src/inputs/hooks/useGrowingTextField.tsx
9069
9071
  var import_utils32 = require("@react-aria/utils");
9070
9072
  var import_react36 = require("react");
9071
- function useGrowingTextField({ inputRef, inputWrapRef, value, disabled }) {
9073
+ function useGrowingTextField({ inputRef, inputWrapRef, value, disabled, maxLines }) {
9074
+ const getLineHeight = (0, import_react36.useCallback)((element) => {
9075
+ const computedStyle = window.getComputedStyle(element);
9076
+ const lineHeight = computedStyle.lineHeight;
9077
+ if (lineHeight === "normal") {
9078
+ const fontSize = parseFloat(computedStyle.fontSize);
9079
+ return fontSize * 1.2;
9080
+ }
9081
+ return parseFloat(lineHeight);
9082
+ }, []);
9072
9083
  const onHeightChange = (0, import_react36.useCallback)(() => {
9073
9084
  if (disabled) return;
9074
9085
  const input = inputRef.current;
@@ -9077,11 +9088,27 @@ function useGrowingTextField({ inputRef, inputWrapRef, value, disabled }) {
9077
9088
  const prevAlignment = input.style.alignSelf;
9078
9089
  input.style.alignSelf = "start";
9079
9090
  input.style.height = "auto";
9080
- inputWrap.style.height = `${input.scrollHeight + 2}px`;
9091
+ const naturalHeight = input.scrollHeight + 2;
9092
+ let finalHeight = naturalHeight;
9093
+ if (maxLines && input instanceof HTMLTextAreaElement) {
9094
+ const lineHeight = getLineHeight(input);
9095
+ const maxHeight = maxLines * lineHeight + 2;
9096
+ finalHeight = Math.min(naturalHeight, maxHeight) + textFieldBaseMultilineTopPadding;
9097
+ if (naturalHeight > maxHeight) {
9098
+ input.style.overflowY = "auto";
9099
+ input.style.paddingRight = `${textFieldBasePadding}px`;
9100
+ inputWrap.style.paddingRight = "0px";
9101
+ } else {
9102
+ input.style.overflowY = "hidden";
9103
+ input.style.paddingRight = "0px";
9104
+ inputWrap.style.paddingRight = `${textFieldBasePadding}px`;
9105
+ }
9106
+ }
9107
+ inputWrap.style.height = `${finalHeight}px`;
9081
9108
  input.style.height = "100%";
9082
9109
  input.style.alignSelf = prevAlignment;
9083
9110
  }
9084
- }, [inputRef, disabled, inputWrapRef]);
9111
+ }, [inputRef, disabled, inputWrapRef, maxLines, getLineHeight]);
9085
9112
  (0, import_utils32.useLayoutEffect)(() => {
9086
9113
  if (disabled) {
9087
9114
  if (inputWrapRef.current) {
@@ -12260,6 +12287,7 @@ function TextAreaField(props) {
12260
12287
  onFocus,
12261
12288
  preventNewLines,
12262
12289
  onEnter,
12290
+ maxLines,
12263
12291
  ...otherProps
12264
12292
  } = props;
12265
12293
  const isDisabled = !!disabled;
@@ -12267,7 +12295,7 @@ function TextAreaField(props) {
12267
12295
  const textFieldProps = { ...otherProps, value, isDisabled, isReadOnly };
12268
12296
  const inputRef = (0, import_react61.useRef)(null);
12269
12297
  const inputWrapRef = (0, import_react61.useRef)(null);
12270
- useGrowingTextField({ inputRef, inputWrapRef, value });
12298
+ useGrowingTextField({ inputRef, inputWrapRef, value, maxLines });
12271
12299
  const { labelProps, inputProps } = (0, import_react_aria36.useTextField)(
12272
12300
  {
12273
12301
  ...textFieldProps,