@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 +34 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -6969,6 +6969,7 @@ declare const switchSelectedHoverStyles: {
|
|
|
6969
6969
|
interface TextAreaFieldProps<X> extends BeamTextFieldProps<X> {
|
|
6970
6970
|
preventNewLines?: boolean;
|
|
6971
6971
|
onEnter?: VoidFunction;
|
|
6972
|
+
maxLines?: number;
|
|
6972
6973
|
}
|
|
6973
6974
|
/** Returns a <textarea /> element that auto-adjusts height based on the field's value */
|
|
6974
6975
|
declare function TextAreaField<X extends Only<TextFieldXss, X>>(props: TextAreaFieldProps<X>): _emotion_react_jsx_runtime.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -6969,6 +6969,7 @@ declare const switchSelectedHoverStyles: {
|
|
|
6969
6969
|
interface TextAreaFieldProps<X> extends BeamTextFieldProps<X> {
|
|
6970
6970
|
preventNewLines?: boolean;
|
|
6971
6971
|
onEnter?: VoidFunction;
|
|
6972
|
+
maxLines?: number;
|
|
6972
6973
|
}
|
|
6973
6974
|
/** Returns a <textarea /> element that auto-adjusts height based on the field's value */
|
|
6974
6975
|
declare function TextAreaField<X extends Only<TextFieldXss, X>>(props: TextAreaFieldProps<X>): _emotion_react_jsx_runtime.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -8190,7 +8190,7 @@ function TextFieldBase(props) {
|
|
|
8190
8190
|
const fieldStyles = {
|
|
8191
8191
|
container: Css.df.fdc.w100.maxw(fieldMaxWidth).relative.if(labelStyle === "left").maxw100.fdr.gap2.jcsb.aic.$,
|
|
8192
8192
|
inputWrapper: {
|
|
8193
|
-
...Css[typeScale].df.aic.br4.
|
|
8193
|
+
...Css[typeScale].df.aic.br4.pxPx(textFieldBasePadding).w100.bgColor(bgColor).gray900.if(contrast && !inputStylePalette).white.if(labelStyle === "left").w(labelLeftFieldWidth).$,
|
|
8194
8194
|
// When borderless then perceived vertical alignments are misaligned. As there is no longer a border, then the field looks oddly indented.
|
|
8195
8195
|
// 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.
|
|
8196
8196
|
// 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.
|
|
@@ -8220,7 +8220,7 @@ function TextFieldBase(props) {
|
|
|
8220
8220
|
// Make the background transparent when highlighting the field on hover
|
|
8221
8221
|
...borderOnHover && Css.bgTransparent.$,
|
|
8222
8222
|
// 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
|
|
8223
|
-
...multiline ? Css.br4.pyPx(compact ? 7 :
|
|
8223
|
+
...multiline ? Css.br4.pyPx(compact ? 7 : textFieldBaseMultilineTopPadding).add("resize", "none").$ : Css.truncate.$
|
|
8224
8224
|
},
|
|
8225
8225
|
hover: Css.bgColor(hoverBgColor).if(contrast).bcGray600.$,
|
|
8226
8226
|
focus: Css.bcBlue700.if(contrast).bcBlue500.if(borderOnHover).bgColor(hoverBgColor).bcBlue500.$,
|
|
@@ -8380,6 +8380,8 @@ function getInputStylePalette(inputStylePalette) {
|
|
|
8380
8380
|
return ["rgba(255,255,255,1)" /* White */, "rgba(247, 245, 245, 1)" /* Gray100 */, "rgba(247, 245, 245, 1)" /* Gray100 */];
|
|
8381
8381
|
}
|
|
8382
8382
|
}
|
|
8383
|
+
var textFieldBasePadding = increment(1);
|
|
8384
|
+
var textFieldBaseMultilineTopPadding = 11;
|
|
8383
8385
|
|
|
8384
8386
|
// src/inputs/internal/MenuSearchField.tsx
|
|
8385
8387
|
import { jsx as jsx35 } from "@emotion/react/jsx-runtime";
|
|
@@ -8698,7 +8700,16 @@ import { mergeProps as mergeProps7 } from "react-aria";
|
|
|
8698
8700
|
// src/inputs/hooks/useGrowingTextField.tsx
|
|
8699
8701
|
import { useLayoutEffect } from "@react-aria/utils";
|
|
8700
8702
|
import { useCallback as useCallback8 } from "react";
|
|
8701
|
-
function useGrowingTextField({ inputRef, inputWrapRef, value, disabled }) {
|
|
8703
|
+
function useGrowingTextField({ inputRef, inputWrapRef, value, disabled, maxLines }) {
|
|
8704
|
+
const getLineHeight = useCallback8((element) => {
|
|
8705
|
+
const computedStyle = window.getComputedStyle(element);
|
|
8706
|
+
const lineHeight = computedStyle.lineHeight;
|
|
8707
|
+
if (lineHeight === "normal") {
|
|
8708
|
+
const fontSize = parseFloat(computedStyle.fontSize);
|
|
8709
|
+
return fontSize * 1.2;
|
|
8710
|
+
}
|
|
8711
|
+
return parseFloat(lineHeight);
|
|
8712
|
+
}, []);
|
|
8702
8713
|
const onHeightChange = useCallback8(() => {
|
|
8703
8714
|
if (disabled) return;
|
|
8704
8715
|
const input = inputRef.current;
|
|
@@ -8707,11 +8718,27 @@ function useGrowingTextField({ inputRef, inputWrapRef, value, disabled }) {
|
|
|
8707
8718
|
const prevAlignment = input.style.alignSelf;
|
|
8708
8719
|
input.style.alignSelf = "start";
|
|
8709
8720
|
input.style.height = "auto";
|
|
8710
|
-
|
|
8721
|
+
const naturalHeight = input.scrollHeight + 2;
|
|
8722
|
+
let finalHeight = naturalHeight;
|
|
8723
|
+
if (maxLines && input instanceof HTMLTextAreaElement) {
|
|
8724
|
+
const lineHeight = getLineHeight(input);
|
|
8725
|
+
const maxHeight = maxLines * lineHeight + 2;
|
|
8726
|
+
finalHeight = Math.min(naturalHeight, maxHeight) + textFieldBaseMultilineTopPadding;
|
|
8727
|
+
if (naturalHeight > maxHeight) {
|
|
8728
|
+
input.style.overflowY = "auto";
|
|
8729
|
+
input.style.paddingRight = `${textFieldBasePadding}px`;
|
|
8730
|
+
inputWrap.style.paddingRight = "0px";
|
|
8731
|
+
} else {
|
|
8732
|
+
input.style.overflowY = "hidden";
|
|
8733
|
+
input.style.paddingRight = "0px";
|
|
8734
|
+
inputWrap.style.paddingRight = `${textFieldBasePadding}px`;
|
|
8735
|
+
}
|
|
8736
|
+
}
|
|
8737
|
+
inputWrap.style.height = `${finalHeight}px`;
|
|
8711
8738
|
input.style.height = "100%";
|
|
8712
8739
|
input.style.alignSelf = prevAlignment;
|
|
8713
8740
|
}
|
|
8714
|
-
}, [inputRef, disabled, inputWrapRef]);
|
|
8741
|
+
}, [inputRef, disabled, inputWrapRef, maxLines, getLineHeight]);
|
|
8715
8742
|
useLayoutEffect(() => {
|
|
8716
8743
|
if (disabled) {
|
|
8717
8744
|
if (inputWrapRef.current) {
|
|
@@ -11897,6 +11924,7 @@ function TextAreaField(props) {
|
|
|
11897
11924
|
onFocus,
|
|
11898
11925
|
preventNewLines,
|
|
11899
11926
|
onEnter,
|
|
11927
|
+
maxLines,
|
|
11900
11928
|
...otherProps
|
|
11901
11929
|
} = props;
|
|
11902
11930
|
const isDisabled = !!disabled;
|
|
@@ -11904,7 +11932,7 @@ function TextAreaField(props) {
|
|
|
11904
11932
|
const textFieldProps = { ...otherProps, value, isDisabled, isReadOnly };
|
|
11905
11933
|
const inputRef = useRef31(null);
|
|
11906
11934
|
const inputWrapRef = useRef31(null);
|
|
11907
|
-
useGrowingTextField({ inputRef, inputWrapRef, value });
|
|
11935
|
+
useGrowingTextField({ inputRef, inputWrapRef, value, maxLines });
|
|
11908
11936
|
const { labelProps, inputProps } = useTextField3(
|
|
11909
11937
|
{
|
|
11910
11938
|
...textFieldProps,
|