@homebound/beam 2.157.3 → 2.160.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/Chip.d.ts +5 -1
- package/dist/components/Chip.js +21 -3
- 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/package.json +1 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Margin, Only, Xss } from "../Css";
|
|
2
|
+
declare type ChipType = "caution" | "warning" | "success" | "light" | "dark" | "neutral";
|
|
3
|
+
export declare const ChipTypes: Record<ChipType, ChipType>;
|
|
2
4
|
export interface ChipProps<X> {
|
|
3
5
|
text: string;
|
|
4
6
|
xss?: X;
|
|
7
|
+
type?: ChipType;
|
|
5
8
|
}
|
|
6
9
|
/** Kinda like a chip, but read-only, so no `onClick` or `hover`. */
|
|
7
|
-
export declare function Chip<X extends Only<Xss<Margin>, X>>(props: ChipProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function Chip<X extends Only<Xss<Margin>, X>>({ type, ...props }: ChipProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
package/dist/components/Chip.js
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Chip = void 0;
|
|
3
|
+
exports.Chip = exports.ChipTypes = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const PresentationContext_1 = require("./PresentationContext");
|
|
6
6
|
const Css_1 = require("../Css");
|
|
7
7
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
8
|
+
// exporting for using in type prop as constant - this could be moved and become a global list for colors
|
|
9
|
+
exports.ChipTypes = {
|
|
10
|
+
caution: "caution",
|
|
11
|
+
warning: "warning",
|
|
12
|
+
success: "success",
|
|
13
|
+
light: "light",
|
|
14
|
+
dark: "dark",
|
|
15
|
+
neutral: "neutral",
|
|
16
|
+
};
|
|
8
17
|
/** Kinda like a chip, but read-only, so no `onClick` or `hover`. */
|
|
9
|
-
function Chip(props) {
|
|
18
|
+
function Chip({ type = exports.ChipTypes.neutral, ...props }) {
|
|
10
19
|
const { text, xss = {} } = props;
|
|
11
20
|
const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
|
|
12
21
|
const compact = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.compact;
|
|
13
22
|
const tid = (0, useTestIds_1.useTestIds)(props, "chip");
|
|
14
23
|
return ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: {
|
|
15
|
-
...Css_1.Css[compact ? "xs" : "sm"].dif.aic.br16.pl1.px1.pyPx(2).gray900
|
|
24
|
+
...Css_1.Css[compact ? "xs" : "sm"].dif.aic.br16.pl1.px1.pyPx(2).gray900.$,
|
|
25
|
+
...typeStyles[type],
|
|
16
26
|
...xss,
|
|
17
27
|
} }, tid, { title: text }, { children: (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp1.breakAll.$ }, { children: text }), void 0) }), void 0));
|
|
18
28
|
}
|
|
19
29
|
exports.Chip = Chip;
|
|
30
|
+
const typeStyles = {
|
|
31
|
+
caution: Css_1.Css.bgYellow200.$,
|
|
32
|
+
warning: Css_1.Css.bgRed100.$,
|
|
33
|
+
success: Css_1.Css.bgGreen100.$,
|
|
34
|
+
light: Css_1.Css.bgWhite.$,
|
|
35
|
+
dark: Css_1.Css.bgGray900.white.$,
|
|
36
|
+
neutral: Css_1.Css.bgGray200.$,
|
|
37
|
+
};
|
|
@@ -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
|
+
;
|