@homebound/beam 2.157.1 → 2.158.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/Stepper.d.ts +1 -1
- package/dist/components/Stepper.js +11 -5
- package/dist/components/SuperDrawer/SuperDrawer.js +5 -3
- package/dist/components/SuperDrawer/SuperDrawerContent.js +5 -2
- package/dist/components/SuperDrawer/index.d.ts +1 -0
- package/dist/components/SuperDrawer/index.js +1 -0
- package/dist/components/SuperDrawer/useSuperDrawer.d.ts +3 -0
- package/dist/components/SuperDrawer/utils.d.ts +4 -0
- package/dist/components/SuperDrawer/utils.js +9 -0
- package/dist/components/Table/sortRows.js +4 -1
- package/package.json +1 -1
|
@@ -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(
|
|
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
|
-
|
|
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(
|
|
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") {
|
|
@@ -12,6 +12,7 @@ const components_1 = require("..");
|
|
|
12
12
|
const BeamContext_1 = require("../BeamContext");
|
|
13
13
|
const Css_1 = require("../../Css");
|
|
14
14
|
const utils_1 = require("../../utils");
|
|
15
|
+
const utils_2 = require("./utils");
|
|
15
16
|
/**
|
|
16
17
|
* Global drawer component.
|
|
17
18
|
*
|
|
@@ -59,6 +60,7 @@ function SuperDrawer() {
|
|
|
59
60
|
const { onPrevClick, onNextClick, titleRightContent, titleLeftContent, hideControls } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
|
|
60
61
|
const isDetail = currentContent !== firstContent;
|
|
61
62
|
const title = content === undefined ? '' : currentContent.title || firstContent.title;
|
|
63
|
+
const { width = utils_2.SuperDrawerWidth.Normal } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
|
|
62
64
|
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
65
|
// Key is required for framer-motion animations
|
|
64
66
|
key: "superDrawer",
|
|
@@ -72,11 +74,11 @@ function SuperDrawer() {
|
|
|
72
74
|
animate: { opacity: 1 },
|
|
73
75
|
// Unmount styles
|
|
74
76
|
exit: { opacity: 0, transition: { delay: 0.2 } }, onClick: closeDrawer },
|
|
75
|
-
(0, jsx_runtime_1.jsx)(framer_motion_1.motion.aside, Object.assign({ css: Css_1.Css.bgWhite.h100.maxw((0, Css_1.px)(
|
|
77
|
+
(0, jsx_runtime_1.jsx)(framer_motion_1.motion.aside, Object.assign({ css: Css_1.Css.bgWhite.h100.maxw((0, Css_1.px)(width)).w100.df.fdc.relative.$,
|
|
76
78
|
// Keeping initial x to 1040 as this will still work if the container is smaller
|
|
77
|
-
initial: { x:
|
|
79
|
+
initial: { x: width }, animate: { x: 0 },
|
|
78
80
|
// Custom transitions settings for the translateX animation
|
|
79
|
-
transition: { ease: "linear", duration: 0.2, delay: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x:
|
|
81
|
+
transition: { ease: "linear", duration: 0.2, delay: 0.2 }, exit: { transition: { ease: "linear", duration: 0.2 }, x: width },
|
|
80
82
|
// Preventing clicks from triggering parent onClick
|
|
81
83
|
onClick: (e) => e.stopPropagation() }, { children: (0, jsx_runtime_1.jsxs)(form_state_1.AutoSaveStatusProvider, { children: [(0, jsx_runtime_1.jsxs)("header", Object.assign({ css: Css_1.Css.df.p3.bb.bGray200.df.aic.jcsb.gap2.$ }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.df.aic.$ }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.xl2Em.gray900.mr2.$ }, testId.title, { ref: drawerHeaderRef }, { children: !modalState.current && (title || null) }), void 0), !modalState.current && (titleLeftContent || null)] }), void 0), !modalState.current && (
|
|
82
84
|
// Forcing height to 32px to match title height
|
|
@@ -7,6 +7,7 @@ const BeamContext_1 = require("../BeamContext");
|
|
|
7
7
|
const Button_1 = require("../Button");
|
|
8
8
|
const useSuperDrawer_1 = require("./useSuperDrawer");
|
|
9
9
|
const Css_1 = require("../../Css");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
10
11
|
/**
|
|
11
12
|
* Helper component to place the given children and actions into the appropriate
|
|
12
13
|
* DOM format to render inside the SuperDrawer.
|
|
@@ -15,17 +16,19 @@ const Css_1 = require("../../Css");
|
|
|
15
16
|
* that knows how to handle the title, prev/next link and the onClose handler.
|
|
16
17
|
*/
|
|
17
18
|
const SuperDrawerContent = ({ children, actions }) => {
|
|
18
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
19
20
|
const { closeDrawerDetail } = (0, useSuperDrawer_1.useSuperDrawer)();
|
|
20
21
|
const { drawerContentStack: contentStack } = (0, BeamContext_1.useBeamContext)();
|
|
21
22
|
// Determine if the current element is a new content element or an detail element
|
|
22
23
|
const { kind } = (_a = contentStack.current[contentStack.current.length - 1]) !== null && _a !== void 0 ? _a : {};
|
|
24
|
+
const firstContent = (_b = contentStack.current[0]) === null || _b === void 0 ? void 0 : _b.opts;
|
|
25
|
+
const { width = utils_1.SuperDrawerWidth.Normal } = firstContent !== null && firstContent !== void 0 ? firstContent : {};
|
|
23
26
|
function wrapWithMotionAndMaybeBack(children) {
|
|
24
27
|
if (kind === "open") {
|
|
25
28
|
return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ css: Css_1.Css.p3.fg1.overflowAuto.$ }, { children: children }), "content"));
|
|
26
29
|
}
|
|
27
30
|
else if (kind === "detail") {
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, Object.assign({ css: Css_1.Css.px3.pt2.pb3.fg1.$, animate: { overflow: "auto" }, transition: { overflow: { delay: 0.3 } } }, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { label: "Back", icon: "chevronLeft", variant: "tertiary", onClick: closeDrawerDetail }, void 0), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ initial: { x:
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, Object.assign({ css: Css_1.Css.px3.pt2.pb3.fg1.$, animate: { overflow: "auto" }, transition: { overflow: { delay: 0.3 } } }, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { label: "Back", icon: "chevronLeft", variant: "tertiary", onClick: closeDrawerDetail }, void 0), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({ initial: { x: width, opacity: 0 }, animate: { x: 0, opacity: 1 }, transition: { ease: "linear", duration: 0.3, opacity: { delay: 0.15 } }, exit: { x: width, opacity: 0 }, css: Css_1.Css.pt2.$ }, { children: children }), void 0)] }), "content"));
|
|
29
32
|
}
|
|
30
33
|
else {
|
|
31
34
|
// Hides content changes when closing the drawer
|
|
@@ -14,3 +14,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
__exportStar(require("./ConfirmCloseModal"), exports);
|
|
15
15
|
__exportStar(require("./SuperDrawerContent"), exports);
|
|
16
16
|
__exportStar(require("./useSuperDrawer"), exports);
|
|
17
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { CanCloseCheck } from "../../types";
|
|
3
|
+
import { SuperDrawerWidth } from "./utils";
|
|
3
4
|
export interface OpenInDrawerOpts {
|
|
4
5
|
/** Title of the SuperDrawer */
|
|
5
6
|
title: string;
|
|
@@ -16,6 +17,8 @@ export interface OpenInDrawerOpts {
|
|
|
16
17
|
/** Adds a callback that is called _after_ close has definitely happened. */
|
|
17
18
|
onClose?: () => void;
|
|
18
19
|
content: ReactNode;
|
|
20
|
+
/** Adds the ability to change the SuperDrawer width based on some pre-defined values */
|
|
21
|
+
width?: SuperDrawerWidth;
|
|
19
22
|
}
|
|
20
23
|
export interface OpenDetailOpts {
|
|
21
24
|
/** Title of the SuperDrawer for this detail page (replaces the original title). */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SuperDrawerWidth = void 0;
|
|
4
|
+
var SuperDrawerWidth;
|
|
5
|
+
(function (SuperDrawerWidth) {
|
|
6
|
+
SuperDrawerWidth[SuperDrawerWidth["Small"] = 560] = "Small";
|
|
7
|
+
SuperDrawerWidth[SuperDrawerWidth["Normal"] = 1040] = "Normal";
|
|
8
|
+
})(SuperDrawerWidth = exports.SuperDrawerWidth || (exports.SuperDrawerWidth = {}));
|
|
9
|
+
;
|
|
@@ -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 (
|
|
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;
|