@homebound/beam 2.326.0 → 2.327.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 +16 -0
- package/dist/Css.js +16 -0
- package/dist/components/PresentationContext.d.ts +2 -0
- package/dist/forms/FormLines.js +2 -1
- package/dist/inputs/Autocomplete.d.ts +1 -2
- package/dist/inputs/ChipTextField.js +4 -2
- package/dist/inputs/DateFields/DateFieldBase.d.ts +1 -1
- package/dist/inputs/NumberField.d.ts +1 -1
- package/dist/inputs/RichTextField.d.ts +2 -3
- package/dist/inputs/RichTextField.js +4 -1
- package/dist/inputs/TextFieldBase.d.ts +1 -1
- package/dist/inputs/TextFieldBase.js +7 -5
- package/dist/inputs/TreeSelectField/TreeSelectField.js +8 -4
- package/dist/inputs/internal/ComboBoxBase.js +8 -6
- package/dist/inputs/utils.d.ts +1 -0
- package/dist/inputs/utils.js +7 -0
- package/package.json +2 -2
package/dist/Css.d.ts
CHANGED
|
@@ -1076,6 +1076,22 @@ declare class CssBuilder<T extends Properties> {
|
|
|
1076
1076
|
fd(value: Properties["flexDirection"]): CssBuilder<T & {
|
|
1077
1077
|
flexDirection: import("csstype").Property.FlexDirection | undefined;
|
|
1078
1078
|
}>;
|
|
1079
|
+
/** Sets `flexWrap: "wrap"`. */
|
|
1080
|
+
get fww(): CssBuilder<T & {
|
|
1081
|
+
flexWrap: import("csstype").Property.FlexWrap | undefined;
|
|
1082
|
+
}>;
|
|
1083
|
+
/** Sets `flexWrap: "wrap-reverse"`. */
|
|
1084
|
+
get fwr(): CssBuilder<T & {
|
|
1085
|
+
flexWrap: import("csstype").Property.FlexWrap | undefined;
|
|
1086
|
+
}>;
|
|
1087
|
+
/** Sets `flexWrap: "nowrap"`. */
|
|
1088
|
+
get fwnw(): CssBuilder<T & {
|
|
1089
|
+
flexWrap: import("csstype").Property.FlexWrap | undefined;
|
|
1090
|
+
}>;
|
|
1091
|
+
/** Sets `flexWrap: value`. */
|
|
1092
|
+
flexWrap(value: Properties["flexWrap"]): CssBuilder<T & {
|
|
1093
|
+
flexWrap: import("csstype").Property.FlexWrap | undefined;
|
|
1094
|
+
}>;
|
|
1079
1095
|
/** Sets `float: "left"`. */
|
|
1080
1096
|
get fl(): CssBuilder<T & {
|
|
1081
1097
|
float: import("csstype").Property.Float | undefined;
|
package/dist/Css.js
CHANGED
|
@@ -1072,6 +1072,22 @@ class CssBuilder {
|
|
|
1072
1072
|
fd(value) {
|
|
1073
1073
|
return this.add("flexDirection", value);
|
|
1074
1074
|
}
|
|
1075
|
+
/** Sets `flexWrap: "wrap"`. */
|
|
1076
|
+
get fww() {
|
|
1077
|
+
return this.add("flexWrap", "wrap");
|
|
1078
|
+
}
|
|
1079
|
+
/** Sets `flexWrap: "wrap-reverse"`. */
|
|
1080
|
+
get fwr() {
|
|
1081
|
+
return this.add("flexWrap", "wrap-reverse");
|
|
1082
|
+
}
|
|
1083
|
+
/** Sets `flexWrap: "nowrap"`. */
|
|
1084
|
+
get fwnw() {
|
|
1085
|
+
return this.add("flexWrap", "nowrap");
|
|
1086
|
+
}
|
|
1087
|
+
/** Sets `flexWrap: value`. */
|
|
1088
|
+
flexWrap(value) {
|
|
1089
|
+
return this.add("flexWrap", value);
|
|
1090
|
+
}
|
|
1075
1091
|
// float
|
|
1076
1092
|
/** Sets `float: "left"`. */
|
|
1077
1093
|
get fl() {
|
|
@@ -11,6 +11,8 @@ export interface PresentationFieldProps {
|
|
|
11
11
|
typeScale?: Typography;
|
|
12
12
|
visuallyDisabled?: false;
|
|
13
13
|
errorInTooltip?: true;
|
|
14
|
+
/** Allow the fields to grow to the width of its container. By default, fields will extend up to 550px */
|
|
15
|
+
fullWidth?: boolean;
|
|
14
16
|
}
|
|
15
17
|
export type PresentationContextProps = {
|
|
16
18
|
fieldProps?: PresentationFieldProps;
|
package/dist/forms/FormLines.js
CHANGED
|
@@ -12,13 +12,14 @@ const Css_1 = require("../Css");
|
|
|
12
12
|
* (see the `FieldGroup` component), where they will be laid out side-by-side.
|
|
13
13
|
*/
|
|
14
14
|
function FormLines(props) {
|
|
15
|
-
const { children, width = "
|
|
15
|
+
const { children, width = "lg", labelSuffix, labelStyle, compact } = props;
|
|
16
16
|
let firstFormHeading = true;
|
|
17
17
|
// Only overwrite `fieldProps` if new values are explicitly set. Ensures we only set to `undefined` if explicitly set.
|
|
18
18
|
const newFieldProps = {
|
|
19
19
|
...("labelSuffix" in props ? { labelSuffix } : {}),
|
|
20
20
|
...("labelStyle" in props ? { labelStyle } : {}),
|
|
21
21
|
...("compact" in props ? { compact } : {}),
|
|
22
|
+
...(width === "full" ? { fullWidth: true } : {}),
|
|
22
23
|
};
|
|
23
24
|
return ((0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, { fieldProps: newFieldProps, children: (0, jsx_runtime_1.jsx)("div", { css: {
|
|
24
25
|
// Note that we're purposefully not using display:flex so that our children's margins will collapse.
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { PresentationFieldProps } from "../components/PresentationContext";
|
|
3
3
|
import { TextFieldBaseProps } from "./TextFieldBase";
|
|
4
4
|
import { Value } from "./Value";
|
|
5
|
-
interface AutocompleteProps<T> extends Pick<PresentationFieldProps, "labelStyle">, Pick<TextFieldBaseProps<any>, "label" | "clearable" | "startAdornment"> {
|
|
5
|
+
export interface AutocompleteProps<T> extends Pick<PresentationFieldProps, "labelStyle">, Pick<TextFieldBaseProps<any>, "label" | "clearable" | "startAdornment" | "fullWidth"> {
|
|
6
6
|
onSelect: (item: T) => void;
|
|
7
7
|
/** A function that returns how to render the an option in the menu. If not set, `getOptionLabel` will be used */
|
|
8
8
|
getOptionMenuLabel?: (o: T) => ReactNode;
|
|
@@ -27,4 +27,3 @@ interface AutocompleteProps<T> extends Pick<PresentationFieldProps, "labelStyle"
|
|
|
27
27
|
})[];
|
|
28
28
|
}
|
|
29
29
|
export declare function Autocomplete<T extends object>(props: AutocompleteProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
30
|
-
export {};
|
|
@@ -53,9 +53,11 @@ function ChipTextField(props) {
|
|
|
53
53
|
}
|
|
54
54
|
}, onInput: (e) => {
|
|
55
55
|
var _a, _b, _c;
|
|
56
|
-
// Prevent user from pasting content that has new line characters and replace with empty space.
|
|
57
56
|
const target = e.target;
|
|
58
|
-
|
|
57
|
+
if ("inputType" in e.nativeEvent && e.nativeEvent.inputType === "insertFromPaste") {
|
|
58
|
+
// Clean up any formatting from pasted text
|
|
59
|
+
target.innerHTML = (_b = (_a = target.textContent) === null || _a === void 0 ? void 0 : _a.replace(/[A\n\r]/g, " ")) !== null && _b !== void 0 ? _b : "";
|
|
60
|
+
}
|
|
59
61
|
onChange((_c = target.textContent) !== null && _c !== void 0 ? _c : "");
|
|
60
62
|
}, ...focusProps, css: {
|
|
61
63
|
...Css_1.Css[typeScale].dib.br16.pl1.pxPx(10).pyPx(2).gray900.bgGray300.outline0.mwPx(32).$,
|
|
@@ -4,7 +4,7 @@ import { Properties } from "../../Css";
|
|
|
4
4
|
import { DateFieldMode, dateFormats } from "./utils";
|
|
5
5
|
import { TextFieldBaseProps } from "../TextFieldBase";
|
|
6
6
|
import { DateRange } from "../../types";
|
|
7
|
-
export interface DateFieldBaseProps extends Pick<TextFieldBaseProps<Properties>, "borderless" | "visuallyDisabled" | "labelStyle" | "compact"> {
|
|
7
|
+
export interface DateFieldBaseProps extends Pick<TextFieldBaseProps<Properties>, "borderless" | "visuallyDisabled" | "labelStyle" | "compact" | "fullWidth"> {
|
|
8
8
|
label: string;
|
|
9
9
|
/** Called when the component loses focus */
|
|
10
10
|
onBlur?: () => void;
|
|
@@ -2,7 +2,7 @@ import { ReactNode } from "react";
|
|
|
2
2
|
import { PresentationFieldProps } from "../components/PresentationContext";
|
|
3
3
|
import { Xss } from "../Css";
|
|
4
4
|
export type NumberFieldType = "cents" | "dollars" | "percent" | "basisPoints" | "days";
|
|
5
|
-
export interface NumberFieldProps extends Pick<PresentationFieldProps, "labelStyle"> {
|
|
5
|
+
export interface NumberFieldProps extends Pick<PresentationFieldProps, "labelStyle" | "fullWidth"> {
|
|
6
6
|
label: string;
|
|
7
7
|
/** If set, the label will be defined as 'aria-label` on the input element */
|
|
8
8
|
type?: NumberFieldType;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "tributejs/dist/tribute.css";
|
|
2
2
|
import "trix/dist/trix";
|
|
3
3
|
import "trix/dist/trix.css";
|
|
4
|
-
|
|
4
|
+
import { PresentationFieldProps } from "../components/PresentationContext";
|
|
5
|
+
export interface RichTextFieldProps extends Pick<PresentationFieldProps, "fullWidth"> {
|
|
5
6
|
/** The initial html value to show in the trix editor. */
|
|
6
7
|
value: string | undefined;
|
|
7
8
|
onChange: (html: string | undefined, text: string | undefined, mergeTags: string[]) => void;
|
|
@@ -20,8 +21,6 @@ export interface RichTextFieldProps {
|
|
|
20
21
|
onFocus?: () => void;
|
|
21
22
|
/** For rendering formatted text */
|
|
22
23
|
readOnly?: boolean;
|
|
23
|
-
/** Will set width to: 100% */
|
|
24
|
-
fullWidth?: boolean;
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
26
|
* Provides a simple rich text editor based on trix.
|
|
@@ -15,6 +15,7 @@ const tributejs_1 = __importDefault(require("tributejs"));
|
|
|
15
15
|
require("tributejs/dist/tribute.css");
|
|
16
16
|
require("trix/dist/trix");
|
|
17
17
|
require("trix/dist/trix.css");
|
|
18
|
+
const PresentationContext_1 = require("../components/PresentationContext");
|
|
18
19
|
/**
|
|
19
20
|
* Provides a simple rich text editor based on trix.
|
|
20
21
|
*
|
|
@@ -23,7 +24,9 @@ require("trix/dist/trix.css");
|
|
|
23
24
|
* We also integrate [tributejs]{@link https://github.com/zurb/tribute} for @ mentions.
|
|
24
25
|
*/
|
|
25
26
|
function RichTextField(props) {
|
|
26
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
29
|
+
const { mergeTags, label, value = "", onChange, onBlur = utils_1.noop, onFocus = utils_1.noop, readOnly, fullWidth = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _a !== void 0 ? _a : false, } = props;
|
|
27
30
|
// We get a reference to the Editor instance after trix-init fires
|
|
28
31
|
const [editor, setEditor] = (0, react_2.useState)();
|
|
29
32
|
const editorElement = (0, react_2.useRef)();
|
|
@@ -2,7 +2,7 @@ import type { NumberFieldAria } from "@react-aria/numberfield";
|
|
|
2
2
|
import { InputHTMLAttributes, LabelHTMLAttributes, MutableRefObject, ReactNode, TextareaHTMLAttributes } from "react";
|
|
3
3
|
import { Only } from "../Css";
|
|
4
4
|
import { BeamTextFieldProps, TextFieldXss } from "../interfaces";
|
|
5
|
-
export interface TextFieldBaseProps<X> extends Pick<BeamTextFieldProps<X>, "label" | "required" | "errorMsg" | "errorInTooltip" | "onBlur" | "onFocus" | "helperText" | "labelStyle" | "placeholder" | "compact" | "borderless" | "visuallyDisabled" | "xss">, Partial<Pick<BeamTextFieldProps<X>, "onChange">> {
|
|
5
|
+
export interface TextFieldBaseProps<X> extends Pick<BeamTextFieldProps<X>, "label" | "required" | "errorMsg" | "errorInTooltip" | "onBlur" | "onFocus" | "helperText" | "labelStyle" | "placeholder" | "compact" | "borderless" | "visuallyDisabled" | "fullWidth" | "xss">, Partial<Pick<BeamTextFieldProps<X>, "onChange">> {
|
|
6
6
|
labelProps?: LabelHTMLAttributes<HTMLLabelElement>;
|
|
7
7
|
inputProps: InputHTMLAttributes<HTMLInputElement> | TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
8
8
|
inputRef?: MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null>;
|
|
@@ -14,12 +14,13 @@ const useGetRef_1 = require("../hooks/useGetRef");
|
|
|
14
14
|
const ErrorMessage_1 = require("./ErrorMessage");
|
|
15
15
|
const defaultTestId_1 = require("../utils/defaultTestId");
|
|
16
16
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
17
18
|
// Used by both TextField and TextArea
|
|
18
19
|
function TextFieldBase(props) {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
20
21
|
const { fieldProps, wrap = false } = (0, PresentationContext_1.usePresentationContext)();
|
|
21
|
-
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, } = props;
|
|
22
|
-
const typeScale = (
|
|
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;
|
|
23
|
+
const typeScale = (_g = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.typeScale) !== null && _g !== void 0 ? _g : (inputProps.readOnly && labelStyle !== "hidden" ? "smMd" : "sm");
|
|
23
24
|
const internalProps = props.internalProps || {};
|
|
24
25
|
const { compound = false, forceFocus = false, forceHover = false } = internalProps;
|
|
25
26
|
const errorMessageId = `${inputProps.id}-error`;
|
|
@@ -38,8 +39,9 @@ function TextFieldBase(props) {
|
|
|
38
39
|
: borderless && !compound
|
|
39
40
|
? [Css_1.Palette.Gray100, Css_1.Palette.Gray200, Css_1.Palette.Gray200]
|
|
40
41
|
: [Css_1.Palette.White, Css_1.Palette.Gray100, Css_1.Palette.Gray100];
|
|
42
|
+
const fieldMaxWidth = (0, utils_1.getFieldWidth)(fullWidth);
|
|
41
43
|
const fieldStyles = {
|
|
42
|
-
container: Css_1.Css.df.fdc.w100.maxw(
|
|
44
|
+
container: Css_1.Css.df.fdc.w100.maxw(fieldMaxWidth).relative.if(labelStyle === "left").maxw100.fdr.gap2.jcsb.aic.$,
|
|
43
45
|
inputWrapper: {
|
|
44
46
|
...Css_1.Css[typeScale].df.aic.br4.px1.w100
|
|
45
47
|
.hPx(fieldHeight - maybeSmaller)
|
|
@@ -104,7 +106,7 @@ function TextFieldBase(props) {
|
|
|
104
106
|
...(multiline ? Css_1.Css.fdc.aifs.gap2.$ : Css_1.Css.if(wrap === false).truncate.$),
|
|
105
107
|
...xss,
|
|
106
108
|
}, "data-readonly": "true", ...tid, children: [labelStyle === "inline" && label && ((0, jsx_runtime_1.jsx)(Label_1.InlineLabel, { multiline: multiline, labelProps: labelProps, label: label, ...tid.label })), multiline
|
|
107
|
-
? (
|
|
109
|
+
? (_h = inputProps.value) === null || _h === void 0 ? void 0 : _h.split("\n\n").map((p, i) => ((0, jsx_runtime_1.jsx)("p", { css: Css_1.Css.py1.$, children: p.split("\n").map((sentence, j) => ((0, jsx_runtime_1.jsxs)("span", { children: [sentence, (0, jsx_runtime_1.jsx)("br", {})] }, j))) }, i)))
|
|
108
110
|
: inputProps.value] })) : ((0, jsx_runtime_1.jsxs)("div", { css: {
|
|
109
111
|
...fieldStyles.inputWrapper,
|
|
110
112
|
...(inputProps.disabled ? fieldStyles.disabled : {}),
|
|
@@ -30,11 +30,13 @@ const react_aria_1 = require("react-aria");
|
|
|
30
30
|
const react_stately_1 = require("react-stately");
|
|
31
31
|
const components_1 = require("../../components");
|
|
32
32
|
const internal_1 = require("../../components/internal");
|
|
33
|
+
const PresentationContext_1 = require("../../components/PresentationContext");
|
|
33
34
|
const Css_1 = require("../../Css");
|
|
34
35
|
const ComboBoxInput_1 = require("../internal/ComboBoxInput");
|
|
35
36
|
const ListBox_1 = require("../internal/ListBox");
|
|
36
37
|
const utils_1 = require("./utils");
|
|
37
38
|
const Value_1 = require("../Value");
|
|
39
|
+
const utils_2 = require("../utils");
|
|
38
40
|
function TreeSelectField(props) {
|
|
39
41
|
const { getOptionValue = (opt) => opt.id, // if unset, assume O implements HasId
|
|
40
42
|
getOptionLabel = (opt) => opt.name, // if unset, assume O implements HasName
|
|
@@ -60,8 +62,9 @@ exports.CollapsedContext = react_1.default.createContext({
|
|
|
60
62
|
getOptionValue: () => ({}),
|
|
61
63
|
});
|
|
62
64
|
function TreeSelectFieldBase(props) {
|
|
63
|
-
var _a;
|
|
64
|
-
const {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
67
|
+
const { values, options, getOptionValue, getOptionLabel, getOptionMenuLabel = getOptionLabel, disabled, readOnly, labelStyle, borderless, contrast = false, nothingSelectedText = "", onSelect, defaultCollapsed = false, placeholder, fullWidth = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _a !== void 0 ? _a : false, ...otherProps } = props;
|
|
65
68
|
const isDisabled = !!disabled;
|
|
66
69
|
const isReadOnly = !!readOnly;
|
|
67
70
|
const initialOptions = Array.isArray(options) ? options : options.current;
|
|
@@ -365,9 +368,10 @@ function TreeSelectFieldBase(props) {
|
|
|
365
368
|
});
|
|
366
369
|
positionProps.style = {
|
|
367
370
|
...positionProps.style,
|
|
368
|
-
width: (
|
|
371
|
+
width: (_b = comboBoxRef === null || comboBoxRef === void 0 ? void 0 : comboBoxRef.current) === null || _b === void 0 ? void 0 : _b.clientWidth,
|
|
369
372
|
// Ensures the menu never gets too small.
|
|
370
373
|
minWidth: 200,
|
|
371
374
|
};
|
|
372
|
-
|
|
375
|
+
const fieldMaxWidth = (0, utils_2.getFieldWidth)(fullWidth);
|
|
376
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.fdc.w100.maxw(fieldMaxWidth).if(labelStyle === "left").maxw100.$, ref: comboBoxRef, children: [(0, jsx_runtime_1.jsx)(ComboBoxInput_1.ComboBoxInput, { ...otherProps, fullWidth: fullWidth, labelStyle: labelStyle, buttonProps: buttonProps, buttonRef: triggerRef, inputProps: inputProps, inputRef: inputRef, inputWrapRef: inputWrapRef, listBoxRef: listBoxRef, state: state, labelProps: labelProps, selectedOptions: fieldState.selectedOptions, getOptionValue: getOptionValue, getOptionLabel: getOptionLabel, contrast: contrast, borderless: borderless, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly), resetField: resetField, nothingSelectedText: nothingSelectedText, isTree: true }), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, { triggerRef: triggerRef, popoverRef: popoverRef, positionProps: positionProps, onClose: () => state.close(), isOpen: state.isOpen, minWidth: 200, children: (0, jsx_runtime_1.jsx)(ListBox_1.ListBox, { ...listBoxProps, positionProps: positionProps, state: state, listBoxRef: listBoxRef, selectedOptions: fieldState.selectedOptions, getOptionLabel: getOptionLabel, getOptionValue: (o) => (0, Value_1.valueToKey)(getOptionValue(o)), contrast: contrast, horizontalLayout: labelStyle === "left", loading: fieldState.optionsLoading, allowCollapsing: fieldState.allowCollapsing, isTree: true }) }))] }));
|
|
373
377
|
}
|
|
@@ -12,6 +12,7 @@ const Css_1 = require("../../Css");
|
|
|
12
12
|
const ComboBoxInput_1 = require("./ComboBoxInput");
|
|
13
13
|
const ListBox_1 = require("./ListBox");
|
|
14
14
|
const Value_1 = require("../Value");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
15
16
|
/**
|
|
16
17
|
* Provides a non-native select/dropdown widget that allows the user to type to filter the options.
|
|
17
18
|
*
|
|
@@ -22,10 +23,10 @@ const Value_1 = require("../Value");
|
|
|
22
23
|
* and so we cannot easily change them.
|
|
23
24
|
*/
|
|
24
25
|
function ComboBoxBase(props) {
|
|
25
|
-
var _a, _b, _c, _d;
|
|
26
|
+
var _a, _b, _c, _d, _e;
|
|
26
27
|
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
27
|
-
const { disabled, readOnly, onSelect, options: propOptions, multiselect = false, values: propValues, nothingSelectedText = "", contrast, disabledOptions, borderless, unsetLabel, getOptionLabel: propOptionLabel, getOptionValue: propOptionValue, getOptionMenuLabel: propOptionMenuLabel, ...otherProps } = props;
|
|
28
|
-
const labelStyle = (
|
|
28
|
+
const { disabled, readOnly, onSelect, options: propOptions, multiselect = false, values: propValues, nothingSelectedText = "", contrast, disabledOptions, borderless, unsetLabel, getOptionLabel: propOptionLabel, getOptionValue: propOptionValue, getOptionMenuLabel: propOptionMenuLabel, fullWidth = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.fullWidth) !== null && _a !== void 0 ? _a : false, ...otherProps } = props;
|
|
29
|
+
const labelStyle = (_c = (_b = otherProps.labelStyle) !== null && _b !== void 0 ? _b : fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _c !== void 0 ? _c : "above";
|
|
29
30
|
// Memoize the callback functions and handle the `unset` option if provided.
|
|
30
31
|
const getOptionLabel = (0, react_1.useCallback)((o) => (unsetLabel && o === exports.unsetOption ? unsetLabel : propOptionLabel(o)),
|
|
31
32
|
// propOptionLabel is basically always a lambda, so don't dep on it
|
|
@@ -122,7 +123,7 @@ function ComboBoxBase(props) {
|
|
|
122
123
|
const popoverRef = (0, react_1.useRef)(null);
|
|
123
124
|
// `disabledKeys` from ComboBoxState does not support additional meta for showing a disabled reason to the user
|
|
124
125
|
// This lookup map helps us cleanly prune out the optional reason text, then access it further down the component tree
|
|
125
|
-
const disabledOptionsWithReasons = Object.fromEntries((
|
|
126
|
+
const disabledOptionsWithReasons = Object.fromEntries((_d = disabledOptions === null || disabledOptions === void 0 ? void 0 : disabledOptions.map(disabledOptionToKeyedTuple)) !== null && _d !== void 0 ? _d : []);
|
|
126
127
|
const comboBoxProps = {
|
|
127
128
|
...otherProps,
|
|
128
129
|
disabledKeys: Object.keys(disabledOptionsWithReasons),
|
|
@@ -202,11 +203,12 @@ function ComboBoxBase(props) {
|
|
|
202
203
|
});
|
|
203
204
|
positionProps.style = {
|
|
204
205
|
...positionProps.style,
|
|
205
|
-
width: (
|
|
206
|
+
width: (_e = comboBoxRef === null || comboBoxRef === void 0 ? void 0 : comboBoxRef.current) === null || _e === void 0 ? void 0 : _e.clientWidth,
|
|
206
207
|
// Ensures the menu never gets too small.
|
|
207
208
|
minWidth: 200,
|
|
208
209
|
};
|
|
209
|
-
|
|
210
|
+
const fieldMaxWidth = (0, utils_1.getFieldWidth)(fullWidth);
|
|
211
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.fdc.w100.maxw(fieldMaxWidth).if(labelStyle === "left").maxw100.$, ref: comboBoxRef, children: [(0, jsx_runtime_1.jsx)(ComboBoxInput_1.ComboBoxInput, { ...otherProps, fullWidth: fullWidth, buttonProps: buttonProps, buttonRef: triggerRef, inputProps: inputProps, inputRef: inputRef, inputWrapRef: inputWrapRef, listBoxRef: listBoxRef, state: state, labelProps: labelProps, selectedOptions: selectedOptions, getOptionValue: getOptionValue, getOptionLabel: getOptionLabel, contrast: contrast, nothingSelectedText: nothingSelectedText, borderless: borderless, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly), resetField: resetField }), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, { triggerRef: triggerRef, popoverRef: popoverRef, positionProps: positionProps, onClose: () => state.close(), isOpen: state.isOpen, minWidth: 200, children: (0, jsx_runtime_1.jsx)(ListBox_1.ListBox, { ...listBoxProps, positionProps: positionProps, state: state, listBoxRef: listBoxRef, selectedOptions: selectedOptions, getOptionLabel: getOptionLabel, getOptionValue: (o) => (0, Value_1.valueToKey)(getOptionValue(o)), contrast: contrast, horizontalLayout: labelStyle === "left", loading: fieldState.optionsLoading, disabledOptionsWithReasons: disabledOptionsWithReasons }) }))] }));
|
|
210
212
|
}
|
|
211
213
|
exports.ComboBoxBase = ComboBoxBase;
|
|
212
214
|
function getInputValue(selectedOptions, getOptionLabel, multiselect, nothingSelectedText) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFieldWidth(fullWidth: boolean | undefined): "100%" | "550px";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homebound/beam",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.327.0",
|
|
4
4
|
"author": "Homebound",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@homebound/eslint-config": "^1.8.0",
|
|
79
79
|
"@homebound/rtl-react-router-utils": "1.0.3",
|
|
80
80
|
"@homebound/rtl-utils": "^2.65.0",
|
|
81
|
-
"@homebound/truss": "^1.
|
|
81
|
+
"@homebound/truss": "^1.132.0",
|
|
82
82
|
"@homebound/tsconfig": "^1.0.3",
|
|
83
83
|
"@semantic-release/exec": "^6.0.3",
|
|
84
84
|
"@semantic-release/git": "^10.0.1",
|