@homebound/beam 2.157.0 → 2.157.3

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.
@@ -9,4 +9,4 @@ export interface StepperProps {
9
9
  currentStep: Step["value"];
10
10
  onChange: (stepValue: string) => void;
11
11
  }
12
- export declare function Stepper({ steps, currentStep, onChange }: StepperProps): import("@emotion/react/jsx-runtime").JSX.Element;
12
+ export declare function Stepper(props: StepperProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -6,18 +6,22 @@ const react_1 = require("react");
6
6
  const react_aria_1 = require("react-aria");
7
7
  const Icon_1 = require("./Icon");
8
8
  const Css_1 = require("../Css");
9
- function Stepper({ steps, currentStep, onChange }) {
9
+ const utils_1 = require("../utils");
10
+ const defaultTestId_1 = require("../utils/defaultTestId");
11
+ function Stepper(props) {
12
+ const { steps, currentStep, onChange } = props;
10
13
  if (steps.length === 0) {
11
14
  throw new Error("Stepper must be initialized with at least one step");
12
15
  }
16
+ const tid = (0, utils_1.useTestIds)(props, "stepper");
13
17
  // calc progress based on last completed step - return -1 when no steps completed
14
18
  const lastCompletedStep = steps.map((step) => step.state).lastIndexOf("complete");
15
19
  const maxStepWidth = 200;
16
20
  const minStepWidth = 100;
17
21
  const gap = 8;
18
- return ((0, jsx_runtime_1.jsxs)("nav", Object.assign({ "aria-label": "steps", css: Css_1.Css.df.fdc.w100.$ }, { children: [(0, jsx_runtime_1.jsx)("ol", Object.assign({ css: Css_1.Css.listReset.df.gapPx(gap).$ }, { children: steps.map((step) => {
22
+ return ((0, jsx_runtime_1.jsxs)("nav", Object.assign({ "aria-label": "steps", css: Css_1.Css.df.fdc.w100.$ }, tid, { children: [(0, jsx_runtime_1.jsx)("ol", Object.assign({ css: Css_1.Css.listReset.df.gapPx(gap).$ }, { children: steps.map((step) => {
19
23
  const isCurrent = currentStep === step.value;
20
- return ((0, jsx_runtime_1.jsx)("li", Object.assign({ css: Css_1.Css.df.fg1.fdc.maxwPx(maxStepWidth).mwPx(minStepWidth).$, "aria-current": isCurrent }, { children: (0, jsx_runtime_1.jsx)(StepButton, Object.assign({}, step, { onClick: () => onChange(step.value), isCurrent: isCurrent }), void 0) }), step.label));
24
+ return ((0, jsx_runtime_1.jsx)("li", Object.assign({ css: Css_1.Css.df.fg1.fdc.maxwPx(maxStepWidth).mwPx(minStepWidth).$, "aria-current": isCurrent }, tid.step, { children: (0, jsx_runtime_1.jsx)(StepButton, Object.assign({}, step, { onClick: () => onChange(step.value), isCurrent: isCurrent }, tid.stepButton), void 0) }), step.label));
21
25
  }) }), void 0), (0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.mt1.bgGray300
22
26
  .hPx(4)
23
27
  .maxwPx(steps.length * maxStepWidth + (steps.length - 1) * gap)
@@ -26,13 +30,15 @@ function Stepper({ steps, currentStep, onChange }) {
26
30
  .h100.w(`${((lastCompletedStep + 1) / steps.length) * 100}%`).$ }, void 0) }), void 0)] }), void 0));
27
31
  }
28
32
  exports.Stepper = Stepper;
29
- function StepButton({ label, disabled, state, isCurrent, onClick }) {
33
+ function StepButton(props) {
34
+ const { label, disabled, state, isCurrent, onClick } = props;
30
35
  const ariaProps = { onPress: onClick, isDisabled: disabled };
31
36
  const ref = (0, react_1.useRef)(null);
32
37
  const { buttonProps, isPressed } = (0, react_aria_1.useButton)(ariaProps, ref);
33
38
  const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)();
34
39
  const { hoverProps, isHovered } = (0, react_aria_1.useHover)(ariaProps);
35
40
  const focusRingStyles = state === "error" ? Css_1.Css.bshDanger.$ : Css_1.Css.bshFocus.$;
41
+ const tid = (0, utils_1.useTestIds)(props, "stepButton");
36
42
  return ((0, jsx_runtime_1.jsxs)("button", Object.assign({ ref: ref }, buttonProps, focusProps, hoverProps, { css: {
37
43
  ...Css_1.Css.buttonBase.$,
38
44
  ...Css_1.Css.tl.w100.h100.sm.gray700.add("whiteSpace", "initial").if(state === "error").red600.$,
@@ -41,7 +47,7 @@ function StepButton({ label, disabled, state, isCurrent, onClick }) {
41
47
  ...(isPressed ? Css_1.Css.lightBlue500.if(state === "error").red900.$ : {}),
42
48
  ...(disabled ? Css_1.Css.gray400.cursorNotAllowed.if(state === "error").red200.$ : {}),
43
49
  ...(isFocusVisible ? focusRingStyles : {}),
44
- } }, { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.mrPx(4).$ }, { children: (0, jsx_runtime_1.jsx)(StepIcon, { state: state, isHovered: isHovered, isPressed: isPressed, isCurrent: isCurrent }, void 0) }), void 0), label] }), void 0));
50
+ } }, tid[(0, defaultTestId_1.defaultTestId)(label)], { children: [(0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.mrPx(4).$ }, { children: (0, jsx_runtime_1.jsx)(StepIcon, { state: state, isHovered: isHovered, isPressed: isPressed, isCurrent: isCurrent }, void 0) }), void 0), label] }), void 0));
45
51
  }
46
52
  function StepIcon({ state, isHovered = false, isPressed = false, isCurrent = false }) {
47
53
  if (state === "error") {
@@ -33,6 +33,7 @@ const utils_1 = require("../../utils");
33
33
  * above the SuperDrawer.
34
34
  */
35
35
  function SuperDrawer() {
36
+ var _a, _b;
36
37
  const { drawerContentStack: contentStack, modalState, modalBodyDiv, modalFooterDiv, modalHeaderDiv, } = (0, BeamContext_1.useBeamContext)();
37
38
  const { closeDrawer } = (0, components_1.useSuperDrawer)();
38
39
  const drawerHeaderRef = (0, react_3.useRef)(null);
@@ -48,17 +49,16 @@ function SuperDrawer() {
48
49
  }
49
50
  // eslint-disable-next-line react-hooks/exhaustive-deps
50
51
  }, [modalBodyRef.current, modalFooterRef.current, modalState.current]);
51
- if (contentStack.current.length === 0) {
52
- return null;
53
- }
54
52
  // Get the latest element on the stack
55
- const currentContent = contentStack.current[contentStack.current.length - 1].opts;
56
- const { content } = currentContent;
53
+ // We use undefined, nullish operators and empty object here to allow AnimatePresence
54
+ // to animate the drawers exit transition when our stack is empty
55
+ const currentContent = (_a = contentStack.current[contentStack.current.length - 1]) === null || _a === void 0 ? void 0 : _a.opts;
56
+ const { content } = currentContent !== null && currentContent !== void 0 ? currentContent : {};
57
57
  // Also get the first / non-detail element on the stack
58
- const firstContent = contentStack.current[0].opts;
59
- const { onPrevClick, onNextClick, titleRightContent, titleLeftContent, hideControls } = firstContent;
58
+ const firstContent = (_b = contentStack.current[0]) === null || _b === void 0 ? void 0 : _b.opts;
59
+ const { onPrevClick, onNextClick, titleRightContent, titleLeftContent, hideControls } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
60
60
  const isDetail = currentContent !== firstContent;
61
- const title = currentContent.title || firstContent.title;
61
+ const title = content === undefined ? '' : currentContent.title || firstContent.title;
62
62
  return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: content && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.Global, { styles: { body: Css_1.Css.overflowHidden.$ } }, void 0), (0, react_1.createElement)(framer_motion_1.motion.div, { ...testId,
63
63
  // Key is required for framer-motion animations
64
64
  key: "superDrawer",
@@ -15,10 +15,11 @@ const Css_1 = require("../../Css");
15
15
  * that knows how to handle the title, prev/next link and the onClose handler.
16
16
  */
17
17
  const SuperDrawerContent = ({ children, actions }) => {
18
+ var _a;
18
19
  const { closeDrawerDetail } = (0, useSuperDrawer_1.useSuperDrawer)();
19
20
  const { drawerContentStack: contentStack } = (0, BeamContext_1.useBeamContext)();
20
21
  // Determine if the current element is a new content element or an detail element
21
- const { kind } = contentStack.current[contentStack.current.length - 1];
22
+ const { kind } = (_a = contentStack.current[contentStack.current.length - 1]) !== null && _a !== void 0 ? _a : {};
22
23
  function wrapWithMotionAndMaybeBack(children) {
23
24
  if (kind === "open") {
24
25
  return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ css: Css_1.Css.p3.fg1.overflowAuto.$ }, { children: children }), "content"));
@@ -23,7 +23,10 @@ function sortBatch(columns, batch, sortState, caseSensitive) {
23
23
  const primaryColumn = primaryKey && columns[primaryKey];
24
24
  // Make a shallow copy for sorting to avoid mutating the original list
25
25
  return [...batch].sort((a, b) => {
26
- if ((a.pin || b.pin) && !(a.pin === b.pin)) {
26
+ if (a.pin || b.pin) {
27
+ // If both rows are pinned, we don't sort within them, because by pinning the page is taking
28
+ // explicit ownership over the order of the rows (and we also don't support "levels of pins",
29
+ // i.e. for change events putting "just added" rows `pin: last` and the "add new" row `pin: lastest`).
27
30
  const ap = a.pin === "first" ? -1 : a.pin === "last" ? 1 : 0;
28
31
  const bp = b.pin === "first" ? -1 : b.pin === "last" ? 1 : 0;
29
32
  return ap === bp ? 0 : ap < bp ? -1 : 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.157.0",
3
+ "version": "2.157.3",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",