@homebound/beam 2.366.1 → 2.368.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/components/SuperDrawer/components/SuperDrawerHeader.d.ts +1 -1
- package/dist/components/SuperDrawer/components/SuperDrawerHeader.js +1 -1
- package/dist/forms/BoundNumberField.js +1 -1
- package/dist/forms/formStateDomain.d.ts +1 -0
- package/dist/inputs/NumberField.d.ts +1 -1
- package/dist/inputs/NumberField.js +8 -6
- package/dist/inputs/RichTextField.js +1 -0
- package/dist/inputs/TextField.d.ts +2 -0
- package/dist/inputs/TextFieldBase.d.ts +2 -0
- package/dist/inputs/TextFieldBase.js +3 -2
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ function SuperDrawerHeader(props) {
|
|
|
16
16
|
const currentContent = (_b = contentStack.current[contentStack.current.length - 1]) === null || _b === void 0 ? void 0 : _b.opts;
|
|
17
17
|
const isDetail = currentContent !== firstContent;
|
|
18
18
|
const tid = (0, utils_1.useTestIds)({}, "superDrawerHeader");
|
|
19
|
-
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.aic.jcsb.gap3.$, ...tid, children: [isStructuredProps(props) ? ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.jcsb.aic.gap2.fg1.$, children: [(0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.fg1.df.aic.gap2.$, children: [(0, jsx_runtime_1.jsx)("h1", { children: props.title }), props.left] }), props.right && (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fs0.$, children: props.right })] })) : ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fg1.$, children: props.children })), !hideControls && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fs0.if(isDetail).vh.$, children: (0, jsx_runtime_1.jsx)(ButtonGroup_1.ButtonGroup, { buttons: [
|
|
19
|
+
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.aic.jcsb.gap3.$, ...tid, children: [isStructuredProps(props) ? ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.jcsb.aic.gap2.fg1.$, children: [(0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.fg1.df.aic.gap2.$, children: [typeof props.title === "string" ? (0, jsx_runtime_1.jsx)("h1", { children: props.title }) : props.title, props.left] }), props.right && (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fs0.$, children: props.right })] })) : ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fg1.$, children: props.children })), !hideControls && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.fs0.if(isDetail).vh.$, children: (0, jsx_runtime_1.jsx)(ButtonGroup_1.ButtonGroup, { buttons: [
|
|
20
20
|
{ icon: "chevronLeft", onClick: () => onPrevClick && onPrevClick(), disabled: !onPrevClick },
|
|
21
21
|
{ icon: "chevronRight", onClick: () => onNextClick && onNextClick(), disabled: !onNextClick },
|
|
22
22
|
], ...tid.actions }) }))] }), sdHeaderDiv);
|
|
@@ -8,7 +8,7 @@ const utils_1 = require("../utils");
|
|
|
8
8
|
const defaultLabel_1 = require("../utils/defaultLabel");
|
|
9
9
|
/** Wraps `NumberField` and binds it to a form field. */
|
|
10
10
|
function BoundNumberField(props) {
|
|
11
|
-
const { field, readOnly, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key.replace(/InCents$/, "")), type = field.key.endsWith("InCents") ? "cents" : undefined, onFocus, onBlur, onEnter, ...others } = props;
|
|
11
|
+
const { field, readOnly, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key.replace(/(InCents|InMills)$/, "")), type = field.key.endsWith("InCents") ? "cents" : field.key.endsWith("InMills") ? "mills" : undefined, onFocus, onBlur, onEnter, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, label || field.key);
|
|
13
13
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { label: label, value: typeof field.value === "number" ? field.value : undefined, onChange: onChange, type: type, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onFocus: () => {
|
|
14
14
|
field.focus();
|
|
@@ -19,6 +19,7 @@ export interface AuthorInput {
|
|
|
19
19
|
birthday?: Date | null;
|
|
20
20
|
heightInInches?: number | null;
|
|
21
21
|
royaltiesInCents?: number | null;
|
|
22
|
+
royaltiesInMills?: number | null;
|
|
22
23
|
books?: BookInput[] | null;
|
|
23
24
|
address?: AuthorAddress | null;
|
|
24
25
|
favoriteSport?: string | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { PresentationFieldProps } from "../components/PresentationContext";
|
|
3
3
|
import { Xss } from "../Css";
|
|
4
|
-
export type NumberFieldType = "cents" | "dollars" | "percent" | "basisPoints" | "days";
|
|
4
|
+
export type NumberFieldType = "cents" | "dollars" | "percent" | "basisPoints" | "days" | "mills";
|
|
5
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 */
|
|
@@ -19,7 +19,7 @@ function NumberField(props) {
|
|
|
19
19
|
const { disabled, required, readOnly, type, label, onBlur, onFocus, errorMsg, helperText, value, onChange, xss, displayDirection = false, numFractionDigits = type === "dollars" ? 2 : undefined, truncate = false, onEnter, numberFormatOptions, numIntegerDigits, useGrouping = true, sizeToContent = false, positiveOnly = false, ...otherProps } = props;
|
|
20
20
|
const isDisabled = !!disabled;
|
|
21
21
|
const isReadOnly = !!readOnly;
|
|
22
|
-
const factor = type === "percent"
|
|
22
|
+
const factor = type === "percent" ? 100 : type === "cents" ? 100 : type === "mills" ? 1000 : type === "basisPoints" ? 10000 : 1;
|
|
23
23
|
const signDisplay = displayDirection ? "always" : "auto";
|
|
24
24
|
const defaultFormatOptions = (0, react_1.useMemo)(() => ({
|
|
25
25
|
[truncate ? "maximumFractionDigits" : "minimumFractionDigits"]: numFractionDigits,
|
|
@@ -40,11 +40,13 @@ function NumberField(props) {
|
|
|
40
40
|
? { style: "percent", minimumFractionDigits: 2 }
|
|
41
41
|
: type === "cents"
|
|
42
42
|
? { style: "currency", currency: "USD", minimumFractionDigits: 2 }
|
|
43
|
-
: type === "
|
|
44
|
-
? { style: "currency", currency: "USD", minimumFractionDigits:
|
|
45
|
-
: type === "
|
|
46
|
-
? { style: "
|
|
47
|
-
:
|
|
43
|
+
: type === "mills"
|
|
44
|
+
? { style: "currency", currency: "USD", minimumFractionDigits: 3 }
|
|
45
|
+
: type === "dollars"
|
|
46
|
+
? { style: "currency", currency: "USD", minimumFractionDigits: numFractionDigits !== null && numFractionDigits !== void 0 ? numFractionDigits : 2 }
|
|
47
|
+
: type === "days"
|
|
48
|
+
? { style: "unit", unit: "day", unitDisplay: "long", maximumFractionDigits: 0 }
|
|
49
|
+
: {};
|
|
48
50
|
return { ...defaultFormatOptions, ...typeFormat };
|
|
49
51
|
}, [type, numberFormatOptions, defaultFormatOptions, numFractionDigits]);
|
|
50
52
|
const numberParser = (0, react_1.useMemo)(() => new number_1.NumberParser(locale, formatOptions), [locale, formatOptions]);
|
|
@@ -89,6 +89,7 @@ function RichTextField(props) {
|
|
|
89
89
|
// The <trix-editor /> web component's `trix-initialize` event may fire before a `useEffect` hook in the component is executed, making it difficult ot attach the event listener locally.
|
|
90
90
|
window.addEventListener("trix-initialize", onEditorInit);
|
|
91
91
|
return id;
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
92
93
|
}, [readOnly]);
|
|
93
94
|
(0, react_2.useEffect)(() => {
|
|
94
95
|
// If our value prop changes (without the change coming from us), reload it
|
|
@@ -19,6 +19,8 @@ export interface TextFieldProps<X> extends BeamTextFieldProps<X> {
|
|
|
19
19
|
endAdornment?: ReactNode;
|
|
20
20
|
startAdornment?: ReactNode;
|
|
21
21
|
hideErrorMessage?: boolean;
|
|
22
|
+
/** Allow focusing without selecting, i.e. to let the user keep typing after we've pre-filled text + called focus, like the Add New component. */
|
|
23
|
+
selectOnFocus?: boolean;
|
|
22
24
|
}
|
|
23
25
|
export declare function TextField<X extends Only<TextFieldXss, X>>(props: TextFieldProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
24
26
|
export type TextFieldApi = {
|
|
@@ -18,5 +18,7 @@ export interface TextFieldBaseProps<X> extends Pick<BeamTextFieldProps<X>, "labe
|
|
|
18
18
|
hideErrorMessage?: boolean;
|
|
19
19
|
alwaysShowHelperText?: boolean;
|
|
20
20
|
unfocusedPlaceholder?: ReactNode;
|
|
21
|
+
/** Allow focusing without selecting, i.e. to let the user keep typing after we've pre-filled text + called focus, like the Add New component. */
|
|
22
|
+
selectOnFocus?: boolean;
|
|
21
23
|
}
|
|
22
24
|
export declare function TextFieldBase<X extends Only<TextFieldXss, X>>(props: TextFieldBaseProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -20,7 +20,7 @@ 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
22
|
const { labelLeftFieldWidth = "50%" } = fieldProps !== null && fieldProps !== void 0 ? fieldProps : {};
|
|
23
|
-
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
|
+
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, selectOnFocus = true, } = props;
|
|
24
24
|
const typeScale = (_g = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.typeScale) !== null && _g !== void 0 ? _g : (inputProps.readOnly && labelStyle !== "hidden" ? "smMd" : "sm");
|
|
25
25
|
const internalProps = props.internalProps || {};
|
|
26
26
|
const { compound = false, forceFocus = false, forceHover = false } = internalProps;
|
|
@@ -104,7 +104,8 @@ function TextFieldBase(props) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
const onFocusChained = (0, react_aria_1.chain)((e) => {
|
|
107
|
-
|
|
107
|
+
if (selectOnFocus)
|
|
108
|
+
e.target.select();
|
|
108
109
|
}, onFocus);
|
|
109
110
|
// Simulate clicking `ElementType` when using an unfocused placeholder
|
|
110
111
|
function handleUnfocusedPlaceholderClick(e) {
|