@homebound/beam 2.398.0 → 2.399.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.
- package/dist/index.cjs +37 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +37 -9
- 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;
|
|
@@ -8311,12 +8312,23 @@ interface UseToastProps {
|
|
|
8311
8312
|
declare function useToast(): UseToastProps;
|
|
8312
8313
|
|
|
8313
8314
|
type TooltipXss = Xss<Padding | "borderRadius">;
|
|
8315
|
+
/** Note: Only 1 tooltip is ever on screen at a time */
|
|
8314
8316
|
interface TooltipProps {
|
|
8315
8317
|
/** The content that shows up when hovered */
|
|
8316
8318
|
title: ReactNode;
|
|
8317
8319
|
children: ReactNode;
|
|
8318
8320
|
placement?: Placement;
|
|
8321
|
+
/**
|
|
8322
|
+
* The delay for the tooltip to appear.
|
|
8323
|
+
*
|
|
8324
|
+
* Note: If tooltip `A` is still showing when tooltip `B` is triggered, tooltip `B`'s `delay` property will be ignored and it will render immediately.
|
|
8325
|
+
* @default 0
|
|
8326
|
+
*/
|
|
8319
8327
|
delay?: number;
|
|
8328
|
+
/** The delay time for the tooltip to disappear.
|
|
8329
|
+
* @default 500
|
|
8330
|
+
*/
|
|
8331
|
+
closeDelay?: number;
|
|
8320
8332
|
disabled?: boolean;
|
|
8321
8333
|
bgColor?: Palette;
|
|
8322
8334
|
xss?: TooltipXss;
|
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;
|
|
@@ -8311,12 +8312,23 @@ interface UseToastProps {
|
|
|
8311
8312
|
declare function useToast(): UseToastProps;
|
|
8312
8313
|
|
|
8313
8314
|
type TooltipXss = Xss<Padding | "borderRadius">;
|
|
8315
|
+
/** Note: Only 1 tooltip is ever on screen at a time */
|
|
8314
8316
|
interface TooltipProps {
|
|
8315
8317
|
/** The content that shows up when hovered */
|
|
8316
8318
|
title: ReactNode;
|
|
8317
8319
|
children: ReactNode;
|
|
8318
8320
|
placement?: Placement;
|
|
8321
|
+
/**
|
|
8322
|
+
* The delay for the tooltip to appear.
|
|
8323
|
+
*
|
|
8324
|
+
* Note: If tooltip `A` is still showing when tooltip `B` is triggered, tooltip `B`'s `delay` property will be ignored and it will render immediately.
|
|
8325
|
+
* @default 0
|
|
8326
|
+
*/
|
|
8319
8327
|
delay?: number;
|
|
8328
|
+
/** The delay time for the tooltip to disappear.
|
|
8329
|
+
* @default 500
|
|
8330
|
+
*/
|
|
8331
|
+
closeDelay?: number;
|
|
8320
8332
|
disabled?: boolean;
|
|
8321
8333
|
bgColor?: Palette;
|
|
8322
8334
|
xss?: TooltipXss;
|
package/dist/index.js
CHANGED
|
@@ -4169,8 +4169,8 @@ import { usePopper } from "react-popper";
|
|
|
4169
4169
|
import { useTooltipTriggerState } from "react-stately";
|
|
4170
4170
|
import { Fragment, jsx as jsx2, jsxs } from "@emotion/react/jsx-runtime";
|
|
4171
4171
|
function Tooltip(props) {
|
|
4172
|
-
const { placement, children, title, disabled, delay = 0, bgColor, xss } = props;
|
|
4173
|
-
const state = useTooltipTriggerState({ delay, isDisabled: disabled });
|
|
4172
|
+
const { placement, children, title, disabled, delay = 0, closeDelay = 500, bgColor, xss } = props;
|
|
4173
|
+
const state = useTooltipTriggerState({ delay, closeDelay, isDisabled: disabled });
|
|
4174
4174
|
const triggerRef = useRef2(null);
|
|
4175
4175
|
const { triggerProps, tooltipProps: _tooltipProps } = useTooltipTrigger({ isDisabled: disabled }, state, triggerRef);
|
|
4176
4176
|
const { tooltipProps } = useTooltip(_tooltipProps, state);
|
|
@@ -4183,7 +4183,7 @@ function Tooltip(props) {
|
|
|
4183
4183
|
...triggerProps,
|
|
4184
4184
|
...!state.isOpen && typeof title === "string" ? { title } : {},
|
|
4185
4185
|
...tid,
|
|
4186
|
-
css: Css.display("contents").addIn(":active", Css.add("pointerEvents", "none").$).$,
|
|
4186
|
+
css: Css.display("contents").addIn(":active:not(:has(a))", Css.add("pointerEvents", "none").$).$,
|
|
4187
4187
|
draggable: true,
|
|
4188
4188
|
onDragStart: (e) => e.preventDefault(),
|
|
4189
4189
|
children
|
|
@@ -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,
|