@homebound/beam 2.258.0 → 2.260.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.
@@ -1,7 +1,8 @@
1
1
  import { ReactElement } from "react";
2
2
  import { Palette } from "../../../Css";
3
- export declare function RightPaneLayout({ children, paneBgColor, paneWidth, }: {
3
+ export declare function RightPaneLayout({ children, paneBgColor, paneWidth, defaultPaneContent, }: {
4
4
  children: ReactElement;
5
5
  paneBgColor?: Palette;
6
6
  paneWidth?: number;
7
+ defaultPaneContent?: ReactElement;
7
8
  }): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -6,7 +6,7 @@ const framer_motion_1 = require("framer-motion");
6
6
  const react_1 = require("react");
7
7
  const Css_1 = require("../../../Css");
8
8
  const RightPaneContext_1 = require("./RightPaneContext");
9
- function RightPaneLayout({ children, paneBgColor = Css_1.Palette.White, paneWidth = 450, }) {
9
+ function RightPaneLayout({ children, paneBgColor = Css_1.Palette.White, paneWidth = 450, defaultPaneContent, }) {
10
10
  const { isRightPaneOpen, rightPaneContent, clearPane, closePane } = (0, RightPaneContext_1.useRightPaneContext)();
11
11
  // Close pane on page unmount because otherwise the next page that has a right pane will show our stale content
12
12
  (0, react_1.useEffect)(() => {
@@ -14,12 +14,21 @@ function RightPaneLayout({ children, paneBgColor = Css_1.Palette.White, paneWidt
14
14
  closePane();
15
15
  };
16
16
  }, []);
17
- return ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.h100.df.overflowXHidden.$, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.w(`calc(100% - ${paneWidth + 24}px)`)
18
- .add("transition", "width .2s linear")
19
- .h100.mr3.overflowXAuto.if(!isRightPaneOpen).w100.mr0.$, children: children }), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: isRightPaneOpen && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { layout: "position", "data-testid": "rightPaneContent", css: Css_1.Css.bgColor(paneBgColor).h100.wPx(paneWidth).$,
20
- // Keeping initial x to offset pane width and space between panel and page content
21
- initial: { x: paneWidth + 24 }, animate: { x: 0 }, transition: { ease: "linear", duration: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: paneWidth },
22
- // Clear the content of the detail pane when the animation is completed and only when pane is closing
23
- onAnimationComplete: (definition) => definition.x !== 0 && clearPane(), children: rightPaneContent }, "rightPane")) })] }) }));
17
+ return ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.h100.df.overflowXHidden.$, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { css: {
18
+ ...Css_1.Css.w(`calc(100% - ${paneWidth + 24}px)`).add("transition", "width .2s linear").h100.mr3.overflowXAuto.$,
19
+ ...Css_1.Css.if(!isRightPaneOpen).w100.mr0.$,
20
+ ...Css_1.Css.if(!!defaultPaneContent).w(`calc(100% - ${paneWidth + 24}px)`).mr3.$,
21
+ }, children: children }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.position("relative").if(!!defaultPaneContent).wPx(paneWidth).$, children: [defaultPaneContent && ((0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.h100
22
+ .wPx(paneWidth)
23
+ .left(0)
24
+ .position("absolute")
25
+ .add("transition", "all .3s ease-in-out")
26
+ .if(isRightPaneOpen)
27
+ .add("opacity", 0)
28
+ .left(100).$, children: defaultPaneContent })), (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: isRightPaneOpen && ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { layout: "position", "data-testid": "rightPaneContent", css: Css_1.Css.bgColor(paneBgColor).h100.wPx(paneWidth).$,
29
+ // Keeping initial x to offset pane width and space between panel and page content
30
+ initial: { x: paneWidth + 24, position: "absolute" }, animate: { x: 0 }, transition: { ease: "linear", duration: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: paneWidth },
31
+ // Clear the content of the detail pane when the animation is completed and only when pane is closing
32
+ onAnimationComplete: (definition) => definition.x !== 0 && clearPane(), children: rightPaneContent }, "rightPane")) })] })] }) }));
24
33
  }
25
34
  exports.RightPaneLayout = RightPaneLayout;
@@ -35,6 +35,7 @@ export interface NumberFieldProps extends Pick<PresentationFieldProps, "labelSty
35
35
  borderless?: boolean;
36
36
  sizeToContent?: boolean;
37
37
  alwaysShowHelperText?: boolean;
38
+ positiveOnly?: boolean;
38
39
  }
39
40
  export declare function NumberField(props: NumberFieldProps): import("@emotion/react/jsx-runtime").JSX.Element;
40
- export declare function formatValue(value: number, factor: number, numFractionDigits: number | undefined, numIntegerDigits: number | undefined): number | undefined;
41
+ export declare function formatValue(value: number, factor: number, numFractionDigits: number | undefined, numIntegerDigits: number | undefined, positiveOnly?: boolean): number | undefined;
@@ -16,7 +16,7 @@ function NumberField(props) {
16
16
  // Determine default alignment based on presentation context
17
17
  const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
18
18
  const alignment = (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.numberAlignment) === "right" ? Css_1.Css.tr.jcfe.$ : Css_1.Css.tl.jcfs.$;
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, ...otherProps } = props;
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
22
  const factor = type === "percent" || type === "cents" ? 100 : type === "basisPoints" ? 10000 : 1;
@@ -56,7 +56,7 @@ function NumberField(props) {
56
56
  value: valueRef.current.wip ? valueRef.current.value : value === undefined ? Number.NaN : value / factor,
57
57
  // // This is called on blur with the final/committed value.
58
58
  onChange: (value) => {
59
- onChange(formatValue(value, factor, numFractionDigits, numIntegerDigits));
59
+ onChange(formatValue(value, factor, numFractionDigits, numIntegerDigits, positiveOnly));
60
60
  },
61
61
  onFocus: () => {
62
62
  valueRef.current = { wip: true, value: value === undefined ? Number.NaN : value / factor };
@@ -92,11 +92,11 @@ function NumberField(props) {
92
92
  // This is called on each DOM change, to push the latest value into the field
93
93
  onChange: (rawInputValue) => {
94
94
  const parsedValue = numberParser.parse(rawInputValue || "");
95
- onChange(formatValue(parsedValue, factor, numFractionDigits, numIntegerDigits));
95
+ onChange(formatValue(parsedValue, factor, numFractionDigits, numIntegerDigits, positiveOnly));
96
96
  }, inputRef: inputRef, onBlur: onBlur, onFocus: onFocus, errorMsg: errorMsg, helperText: helperText, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly), ...otherProps }));
97
97
  }
98
98
  exports.NumberField = NumberField;
99
- function formatValue(value, factor, numFractionDigits, numIntegerDigits) {
99
+ function formatValue(value, factor, numFractionDigits, numIntegerDigits, positiveOnly = false) {
100
100
  // We treat percents & cents as (mostly) integers, while useNumberField wants decimals, so
101
101
  // undo that via `* factor` and `Math.round`, but also keep any specifically-requested `numFractionDigits`,
102
102
  // i.e. for `type=percent value=12.34`, `value` will be `0.1234` that we want turn into `12.34`.
@@ -104,7 +104,7 @@ function formatValue(value, factor, numFractionDigits, numIntegerDigits) {
104
104
  // Reverse the integer/decimal conversion
105
105
  const decimalAdjusted = Number.isNaN(value)
106
106
  ? undefined
107
- : Math.round(value * factor * maybeAdjustForDecimals) / maybeAdjustForDecimals;
107
+ : Math.round((positiveOnly ? Math.abs(value) : value) * factor * maybeAdjustForDecimals) / maybeAdjustForDecimals;
108
108
  if (numIntegerDigits === undefined || decimalAdjusted === undefined) {
109
109
  return decimalAdjusted;
110
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.258.0",
3
+ "version": "2.260.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",