@homebound/beam 2.128.4 → 2.131.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/Css.d.ts +21 -0
- package/dist/Css.js +7 -0
- package/dist/components/BeamContext.js +2 -1
- package/dist/components/Button.d.ts +3 -3
- package/dist/components/Button.js +34 -29
- package/dist/components/Snackbar/Snackbar.d.ts +6 -0
- package/dist/components/Snackbar/Snackbar.js +10 -0
- package/dist/components/Snackbar/SnackbarContext.d.ts +8 -0
- package/dist/components/Snackbar/SnackbarContext.js +17 -0
- package/dist/components/Snackbar/SnackbarNotice.d.ts +19 -0
- package/dist/components/Snackbar/SnackbarNotice.js +23 -0
- package/dist/components/Snackbar/index.d.ts +2 -0
- package/dist/components/Snackbar/index.js +5 -0
- package/dist/components/Snackbar/useSnackbar.d.ts +12 -0
- package/dist/components/Snackbar/useSnackbar.js +56 -0
- package/dist/components/Table/GridTable.d.ts +1 -0
- package/dist/components/Table/GridTable.js +3 -3
- package/dist/components/Table/sortRows.d.ts +1 -1
- package/dist/components/Table/sortRows.js +11 -10
- package/dist/components/Table/useSortState.d.ts +1 -1
- package/dist/components/Table/useSortState.js +3 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/package.json +2 -2
package/dist/Css.d.ts
CHANGED
|
@@ -545,6 +545,27 @@ declare class CssBuilder<T extends Properties1> {
|
|
|
545
545
|
jc(value: Properties["justifyContent"]): CssBuilder<T & {
|
|
546
546
|
justifyContent: import("csstype").Property.JustifyContent | undefined;
|
|
547
547
|
}>;
|
|
548
|
+
get jifs(): CssBuilder<T & {
|
|
549
|
+
justifyItems: import("csstype").Property.JustifyItems | undefined;
|
|
550
|
+
}>;
|
|
551
|
+
get jife(): CssBuilder<T & {
|
|
552
|
+
justifyItems: import("csstype").Property.JustifyItems | undefined;
|
|
553
|
+
}>;
|
|
554
|
+
get jic(): CssBuilder<T & {
|
|
555
|
+
justifyItems: import("csstype").Property.JustifyItems | undefined;
|
|
556
|
+
}>;
|
|
557
|
+
get jisb(): CssBuilder<T & {
|
|
558
|
+
justifyItems: import("csstype").Property.JustifyItems | undefined;
|
|
559
|
+
}>;
|
|
560
|
+
get jisa(): CssBuilder<T & {
|
|
561
|
+
justifyItems: import("csstype").Property.JustifyItems | undefined;
|
|
562
|
+
}>;
|
|
563
|
+
get jise(): CssBuilder<T & {
|
|
564
|
+
justifyItems: import("csstype").Property.JustifyItems | undefined;
|
|
565
|
+
}>;
|
|
566
|
+
ji(value: Properties["justifyItems"]): CssBuilder<T & {
|
|
567
|
+
justifyItems: import("csstype").Property.JustifyItems | undefined;
|
|
568
|
+
}>;
|
|
548
569
|
get asfs(): CssBuilder<T & {
|
|
549
570
|
alignSelf: import("csstype").Property.AlignSelf | undefined;
|
|
550
571
|
}>;
|
package/dist/Css.js
CHANGED
|
@@ -196,6 +196,13 @@ class CssBuilder {
|
|
|
196
196
|
get jcsa() { return this.add("justifyContent", "space-around"); }
|
|
197
197
|
get jcse() { return this.add("justifyContent", "space-evenly"); }
|
|
198
198
|
jc(value) { return this.add("justifyContent", value); }
|
|
199
|
+
get jifs() { return this.add("justifyItems", "flex-start"); }
|
|
200
|
+
get jife() { return this.add("justifyItems", "flex-end"); }
|
|
201
|
+
get jic() { return this.add("justifyItems", "center"); }
|
|
202
|
+
get jisb() { return this.add("justifyItems", "space-between"); }
|
|
203
|
+
get jisa() { return this.add("justifyItems", "space-around"); }
|
|
204
|
+
get jise() { return this.add("justifyItems", "space-evenly"); }
|
|
205
|
+
ji(value) { return this.add("justifyItems", value); }
|
|
199
206
|
get asfs() { return this.add("alignSelf", "flex-start"); }
|
|
200
207
|
get asfe() { return this.add("alignSelf", "flex-end"); }
|
|
201
208
|
get asc() { return this.add("alignSelf", "center"); }
|
|
@@ -6,6 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const react_aria_1 = require("react-aria");
|
|
7
7
|
const Modal_1 = require("./Modal/Modal");
|
|
8
8
|
const PresentationContext_1 = require("./PresentationContext");
|
|
9
|
+
const SnackbarContext_1 = require("./Snackbar/SnackbarContext");
|
|
9
10
|
const SuperDrawer_1 = require("./SuperDrawer/SuperDrawer");
|
|
10
11
|
const index_1 = require("../utils/index");
|
|
11
12
|
/** This is only exported internally, for useModal and useSuperDrawer, it's not a public API. */
|
|
@@ -55,7 +56,7 @@ function BeamProvider({ children, ...presentationProps }) {
|
|
|
55
56
|
tabActionsDiv,
|
|
56
57
|
};
|
|
57
58
|
}, [modalBodyDiv, modalFooterDiv]);
|
|
58
|
-
return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, Object.assign({ value: { ...context } }, { children: (0, jsx_runtime_1.
|
|
59
|
+
return ((0, jsx_runtime_1.jsx)(exports.BeamContext.Provider, Object.assign({ value: { ...context } }, { children: (0, jsx_runtime_1.jsx)(PresentationContext_1.PresentationProvider, Object.assign({}, presentationProps, { children: (0, jsx_runtime_1.jsxs)(SnackbarContext_1.SnackbarProvider, { children: [(0, jsx_runtime_1.jsxs)(react_aria_1.OverlayProvider, { children: [children, modalRef.current && drawerContentStackRef.current.length === 0 && (0, jsx_runtime_1.jsx)(Modal_1.Modal, Object.assign({}, modalRef.current), void 0)] }, void 0), (0, jsx_runtime_1.jsx)(SuperDrawer_1.SuperDrawer, {}, void 0)] }, void 0) }), void 0) }), void 0));
|
|
59
60
|
}
|
|
60
61
|
exports.BeamProvider = BeamProvider;
|
|
61
62
|
/** Looks like a ref, but invokes a re-render on set (w/o changing the setter identity). */
|
|
@@ -16,8 +16,8 @@ export interface ButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
16
16
|
type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
17
17
|
/** Denotes if this button is used to download a resource. Uses the anchor tag with the `download` attribute */
|
|
18
18
|
download?: boolean;
|
|
19
|
+
contrast?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export declare function Button(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
|
-
declare type ButtonSize = "sm" | "md" | "lg";
|
|
22
|
-
declare type ButtonVariant = "primary" | "secondary" | "tertiary" | "danger" | "text";
|
|
23
|
-
export {};
|
|
22
|
+
export declare type ButtonSize = "sm" | "md" | "lg";
|
|
23
|
+
export declare type ButtonVariant = "primary" | "secondary" | "tertiary" | "danger" | "text";
|
|
@@ -10,7 +10,7 @@ const Css_1 = require("../Css");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
12
12
|
function Button(props) {
|
|
13
|
-
const { onClick: onPress, disabled, endAdornment, menuTriggerProps, tooltip, openInNew, download, ...otherProps } = props;
|
|
13
|
+
const { onClick: onPress, disabled, endAdornment, menuTriggerProps, tooltip, openInNew, download, contrast = false, ...otherProps } = props;
|
|
14
14
|
const showExternalLinkIcon = (typeof onPress === "string" && (0, utils_1.isAbsoluteUrl)(onPress)) || openInNew;
|
|
15
15
|
const isDisabled = !!disabled;
|
|
16
16
|
const ariaProps = { onPress, isDisabled, ...otherProps, ...menuTriggerProps };
|
|
@@ -26,8 +26,12 @@ function Button(props) {
|
|
|
26
26
|
}, ref);
|
|
27
27
|
const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)(ariaProps);
|
|
28
28
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)(ariaProps);
|
|
29
|
-
const { baseStyles, hoverStyles, disabledStyles, pressedStyles } = (0, react_1.useMemo)(() => getButtonStyles(variant, size), [variant, size]);
|
|
30
|
-
const
|
|
29
|
+
const { baseStyles, hoverStyles, disabledStyles, pressedStyles } = (0, react_1.useMemo)(() => getButtonStyles(variant, size, contrast), [variant, size, contrast]);
|
|
30
|
+
const focusStyles = (0, react_1.useMemo)(() => !contrast
|
|
31
|
+
? variant === "danger"
|
|
32
|
+
? Css_1.Css.bshDanger.$
|
|
33
|
+
: Css_1.Css.bshFocus.$
|
|
34
|
+
: Css_1.Css.boxShadow(`0 0 0 2px ${variant === "tertiary" ? Css_1.Palette.LightBlue700 : Css_1.Palette.White}`).if(variant === "tertiary").bgGray700.white.$, [variant, contrast]);
|
|
31
35
|
const buttonContent = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon && (0, jsx_runtime_1.jsx)(components_1.Icon, { xss: iconStyles[size], icon: icon }, void 0), label, endAdornment && (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.ml1.$ }, { children: endAdornment }), void 0)] }, void 0));
|
|
32
36
|
const buttonAttrs = {
|
|
33
37
|
ref: ref,
|
|
@@ -35,12 +39,12 @@ function Button(props) {
|
|
|
35
39
|
...focusProps,
|
|
36
40
|
...hoverProps,
|
|
37
41
|
css: {
|
|
38
|
-
...Css_1.Css.buttonBase.$,
|
|
42
|
+
...Css_1.Css.buttonBase.tt("inherit").$,
|
|
39
43
|
...baseStyles,
|
|
40
44
|
...(isHovered && !isPressed ? hoverStyles : {}),
|
|
41
45
|
...(isPressed ? pressedStyles : {}),
|
|
42
46
|
...(isDisabled ? { ...disabledStyles, ...Css_1.Css.cursorNotAllowed.$ } : {}),
|
|
43
|
-
...(isFocusVisible ?
|
|
47
|
+
...(isFocusVisible ? focusStyles : {}),
|
|
44
48
|
},
|
|
45
49
|
...tid,
|
|
46
50
|
};
|
|
@@ -53,48 +57,49 @@ function Button(props) {
|
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
exports.Button = Button;
|
|
56
|
-
function getButtonStyles(variant, size) {
|
|
60
|
+
function getButtonStyles(variant, size, contrast) {
|
|
61
|
+
const styles = variantStyles(contrast)[variant];
|
|
57
62
|
if (variant === "text") {
|
|
58
63
|
// The text variant does not support the 'size'. The 'size' prop only effects the button's height and padding which is not relevant for this variant.
|
|
59
|
-
return
|
|
64
|
+
return styles;
|
|
60
65
|
}
|
|
61
66
|
return {
|
|
62
|
-
...
|
|
63
|
-
baseStyles: { ...
|
|
67
|
+
...styles,
|
|
68
|
+
baseStyles: { ...styles.baseStyles, ...sizeStyles[size] },
|
|
64
69
|
};
|
|
65
70
|
}
|
|
66
|
-
const variantStyles = {
|
|
71
|
+
const variantStyles = (contrast) => ({
|
|
67
72
|
primary: {
|
|
68
|
-
baseStyles: Css_1.Css.bgLightBlue700.white.$,
|
|
69
|
-
hoverStyles: Css_1.Css.bgLightBlue900.$,
|
|
70
|
-
pressedStyles: Css_1.Css.bgLightBlue500.$,
|
|
71
|
-
disabledStyles: Css_1.Css.bgLightBlue200.$,
|
|
73
|
+
baseStyles: Css_1.Css.bgLightBlue700.white.if(contrast).bgLightBlue400.$,
|
|
74
|
+
hoverStyles: Css_1.Css.bgLightBlue900.if(contrast).bgLightBlue500.$,
|
|
75
|
+
pressedStyles: Css_1.Css.bgLightBlue500.if(contrast).bgLightBlue900.$,
|
|
76
|
+
disabledStyles: Css_1.Css.bgLightBlue200.if(contrast).gray600.bgLightBlue900.$,
|
|
72
77
|
},
|
|
73
78
|
secondary: {
|
|
74
79
|
baseStyles: Css_1.Css.bgWhite.bGray300.bw1.ba.gray800.$,
|
|
75
|
-
hoverStyles: Css_1.Css.bgGray100.$,
|
|
76
|
-
pressedStyles: Css_1.Css.bgGray200.$,
|
|
80
|
+
hoverStyles: Css_1.Css.bgGray100.if(contrast).bgGray300.$,
|
|
81
|
+
pressedStyles: Css_1.Css.bgGray200.if(contrast).bgGray100.$,
|
|
77
82
|
disabledStyles: Css_1.Css.bgWhite.gray400.$,
|
|
78
83
|
},
|
|
79
84
|
tertiary: {
|
|
80
|
-
baseStyles: Css_1.Css.bgTransparent.lightBlue700.$,
|
|
81
|
-
hoverStyles: Css_1.Css.bgGray100.$,
|
|
82
|
-
pressedStyles: Css_1.Css.lightBlue900.$,
|
|
83
|
-
disabledStyles: Css_1.Css.gray400.$,
|
|
85
|
+
baseStyles: Css_1.Css.bgTransparent.lightBlue700.if(contrast).lightBlue400.$,
|
|
86
|
+
hoverStyles: Css_1.Css.bgGray100.if(contrast).bgGray700.white.$,
|
|
87
|
+
pressedStyles: Css_1.Css.lightBlue900.if(contrast).bgWhite.gray900.$,
|
|
88
|
+
disabledStyles: Css_1.Css.gray400.if(contrast).gray700.$,
|
|
84
89
|
},
|
|
85
90
|
danger: {
|
|
86
|
-
baseStyles: Css_1.Css.bgRed900.white.$,
|
|
87
|
-
hoverStyles: Css_1.Css.bgRed500.$,
|
|
88
|
-
pressedStyles: Css_1.Css.bgRed900.$,
|
|
89
|
-
disabledStyles: Css_1.Css.bgRed200.$,
|
|
91
|
+
baseStyles: Css_1.Css.bgRed900.white.if(contrast).bgRed800.$,
|
|
92
|
+
hoverStyles: Css_1.Css.bgRed500.if(contrast).bgRed600.$,
|
|
93
|
+
pressedStyles: Css_1.Css.bgRed900.if(contrast).bgRed800.$,
|
|
94
|
+
disabledStyles: Css_1.Css.bgRed200.if(contrast).bgRed900.gray600.$,
|
|
90
95
|
},
|
|
91
96
|
text: {
|
|
92
|
-
baseStyles: Css_1.Css.lightBlue700.add("fontSize", "inherit").$,
|
|
93
|
-
hoverStyles:
|
|
94
|
-
pressedStyles:
|
|
95
|
-
disabledStyles: Css_1.Css.lightBlue300.$,
|
|
97
|
+
baseStyles: Css_1.Css.lightBlue700.add("fontSize", "inherit").if(contrast).lightBlue400.$,
|
|
98
|
+
hoverStyles: Css_1.Css.lightBlue600.if(contrast).lightBlue300.$,
|
|
99
|
+
pressedStyles: Css_1.Css.lightBlue700.if(contrast).lightBlue200.$,
|
|
100
|
+
disabledStyles: Css_1.Css.lightBlue300.if(contrast).lightBlue700.$,
|
|
96
101
|
},
|
|
97
|
-
};
|
|
102
|
+
});
|
|
98
103
|
const sizeStyles = {
|
|
99
104
|
sm: Css_1.Css.hPx(32).pxPx(12).$,
|
|
100
105
|
md: Css_1.Css.hPx(40).px2.$,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Snackbar = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const SnackbarNotice_1 = require("./SnackbarNotice");
|
|
6
|
+
const Css_1 = require("../../Css");
|
|
7
|
+
function Snackbar({ notices }) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: Css_1.Css.fixed.bottom3.right3.df.fdc.aife.gapPx(12).$ }, { children: notices.map((data) => ((0, jsx_runtime_1.jsx)(SnackbarNotice_1.SnackbarNotice, Object.assign({}, data), data.id))) }), void 0));
|
|
9
|
+
}
|
|
10
|
+
exports.Snackbar = Snackbar;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { SnackbarNoticeProps } from "./SnackbarNotice";
|
|
3
|
+
export declare type SnackbarContextProps = {
|
|
4
|
+
setNotices: React.Dispatch<React.SetStateAction<SnackbarNoticeProps[]>>;
|
|
5
|
+
};
|
|
6
|
+
export declare const SnackbarContext: React.Context<SnackbarContextProps>;
|
|
7
|
+
export declare function SnackbarProvider(props: PropsWithChildren<{}>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function useSnackbarContext(): SnackbarContextProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSnackbarContext = exports.SnackbarProvider = exports.SnackbarContext = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Snackbar_1 = require("./Snackbar");
|
|
7
|
+
exports.SnackbarContext = (0, react_1.createContext)({ setNotices: () => { } });
|
|
8
|
+
function SnackbarProvider(props) {
|
|
9
|
+
const [notices, setNotices] = (0, react_1.useState)([]);
|
|
10
|
+
const contextValue = (0, react_1.useMemo)(() => ({ setNotices }), []);
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(exports.SnackbarContext.Provider, Object.assign({ value: contextValue }, { children: [props.children, (0, jsx_runtime_1.jsx)(Snackbar_1.Snackbar, { notices: notices }, void 0)] }), void 0));
|
|
12
|
+
}
|
|
13
|
+
exports.SnackbarProvider = SnackbarProvider;
|
|
14
|
+
function useSnackbarContext() {
|
|
15
|
+
return (0, react_1.useContext)(exports.SnackbarContext);
|
|
16
|
+
}
|
|
17
|
+
exports.useSnackbarContext = useSnackbarContext;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { ButtonProps } from "../Button";
|
|
3
|
+
export declare type SnackbarNoticeTypes = "error" | "warning" | "success" | "info";
|
|
4
|
+
export interface SnackbarNoticeProps {
|
|
5
|
+
/** Adds action button to the right of the notice */
|
|
6
|
+
action?: Pick<ButtonProps, "label" | "onClick" | "variant">;
|
|
7
|
+
/** Does not allow the user to close the notice manually. Notice will fade away in 10s. Value will be ignored if 'persistent' is set to 'true'. */
|
|
8
|
+
hideCloseButton?: boolean;
|
|
9
|
+
message: ReactNode;
|
|
10
|
+
/** This notice will persist on the screen until systematically closed by the app or by the user clicking the close button. */
|
|
11
|
+
persistent?: boolean;
|
|
12
|
+
/** Defines the icon that will show on the left side of the notification. */
|
|
13
|
+
icon?: SnackbarNoticeTypes;
|
|
14
|
+
/** Unique identifier to allow notice to close itself */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Removes the snackbar notice from the stack */
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function SnackbarNotice(props: SnackbarNoticeProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnackbarNotice = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const Button_1 = require("../Button");
|
|
6
|
+
const Icon_1 = require("../Icon");
|
|
7
|
+
const IconButton_1 = require("../IconButton");
|
|
8
|
+
const Css_1 = require("../../Css");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
function SnackbarNotice(props) {
|
|
11
|
+
const { icon, message, action, hideCloseButton, persistent, onClose } = props;
|
|
12
|
+
const tid = (0, utils_1.useTestIds)(props, "snackbar");
|
|
13
|
+
// Only allow the "close" button to be hidden if not a `persistent` notice. Otherwise we could get in a state where the user cannot remove the notice from the screen.
|
|
14
|
+
const reallyHideClose = hideCloseButton && !persistent;
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ css: Css_1.Css.white.bgGray800.br4.base.df.aic.maxwPx(420).$ }, tid, { children: [icon && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.plPx(12).$ }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, Object.assign({ icon: typeToIcon[icon] }, tid.icon), void 0) }), void 0)), (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp3.pr2.myPx(12).plPx(icon ? 8 : 16).$ }, (typeof message === "string" ? { title: message } : undefined), tid.message, { children: message }), void 0), (action || !reallyHideClose) && ((0, jsx_runtime_1.jsxs)("span", Object.assign({ css: Css_1.Css.fs0.df.aic.$ }, { children: [action && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.ttu.sm.prPx(!reallyHideClose && action.variant !== "text" ? 4 : 8).$ }, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ contrast: true }, action, tid.action), void 0) }), void 0)), !reallyHideClose && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.pr1.add("lineHeight", 0).$ }, { children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({ icon: "x", contrast: true, onClick: onClose }, tid.close), void 0) }), void 0))] }), void 0))] }), void 0));
|
|
16
|
+
}
|
|
17
|
+
exports.SnackbarNotice = SnackbarNotice;
|
|
18
|
+
const typeToIcon = {
|
|
19
|
+
error: "xCircle",
|
|
20
|
+
warning: "error",
|
|
21
|
+
success: "checkCircle",
|
|
22
|
+
info: "infoCircle",
|
|
23
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSnackbar = void 0;
|
|
4
|
+
var useSnackbar_1 = require("./useSnackbar");
|
|
5
|
+
Object.defineProperty(exports, "useSnackbar", { enumerable: true, get: function () { return useSnackbar_1.useSnackbar; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SnackbarNoticeProps } from "./SnackbarNotice";
|
|
2
|
+
export interface UseSnackbarHook {
|
|
3
|
+
triggerNotice: (props: TriggerNoticeProps) => {
|
|
4
|
+
close: () => void;
|
|
5
|
+
};
|
|
6
|
+
closeNotice: (id: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSnackbar(): UseSnackbarHook;
|
|
9
|
+
export interface TriggerNoticeProps extends Omit<SnackbarNoticeProps, "id" | "onClose"> {
|
|
10
|
+
id?: string;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSnackbar = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const SnackbarContext_1 = require("./SnackbarContext");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
function useSnackbar() {
|
|
8
|
+
const { setNotices } = (0, SnackbarContext_1.useSnackbarContext)();
|
|
9
|
+
const onClose = (0, react_1.useCallback)((noticeId) => {
|
|
10
|
+
setNotices((prev) => {
|
|
11
|
+
let returnValue = prev;
|
|
12
|
+
// check to see if the notice is still in our existing stack, if so then remove it. Otherwise it was manually closed, so return the existing value.
|
|
13
|
+
if (prev.some(({ id }) => id === noticeId)) {
|
|
14
|
+
returnValue = prev.filter(({ id }) => id !== noticeId);
|
|
15
|
+
}
|
|
16
|
+
// For good measure, reset the snackbarId when notices array is emptied.
|
|
17
|
+
if (returnValue.length === 0) {
|
|
18
|
+
snackbarId = 1;
|
|
19
|
+
}
|
|
20
|
+
return returnValue;
|
|
21
|
+
});
|
|
22
|
+
}, []);
|
|
23
|
+
const triggerNotice = (0, react_1.useCallback)((props) => {
|
|
24
|
+
var _a;
|
|
25
|
+
// Sets `noticeId` to the current value of `snackbarId` and then increments.
|
|
26
|
+
const noticeId = (_a = props.id) !== null && _a !== void 0 ? _a : `beamSnackbar:${snackbarId++}`;
|
|
27
|
+
let maybeTimeout;
|
|
28
|
+
if (!props.persistent) {
|
|
29
|
+
maybeTimeout = window.setTimeout(() => {
|
|
30
|
+
onClose(noticeId);
|
|
31
|
+
// Auto close in 10s
|
|
32
|
+
}, 10000);
|
|
33
|
+
}
|
|
34
|
+
setNotices((prev) => prev.concat({
|
|
35
|
+
...props,
|
|
36
|
+
id: noticeId,
|
|
37
|
+
onClose: () => {
|
|
38
|
+
// Because we reset the `snackbarId` if the notices array is empty, then we need to call `clearTimeout` to ensure we don't accidentally close the wrong notice
|
|
39
|
+
clearTimeout(maybeTimeout);
|
|
40
|
+
onClose(noticeId);
|
|
41
|
+
(0, utils_1.maybeCall)(props.onClose);
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
return {
|
|
45
|
+
close: () => {
|
|
46
|
+
// Because we reset the `snackbarId` if the notices array is empty, then we need to call `clearTimeout` to ensure we don't accidentally close the wrong notice
|
|
47
|
+
clearTimeout(maybeTimeout);
|
|
48
|
+
onClose(noticeId);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}, [onClose, setNotices]);
|
|
52
|
+
const closeNotice = (0, react_1.useCallback)((id) => onClose(id), [onClose]);
|
|
53
|
+
return { triggerNotice, closeNotice };
|
|
54
|
+
}
|
|
55
|
+
exports.useSnackbar = useSnackbar;
|
|
56
|
+
let snackbarId = 1;
|
|
@@ -121,6 +121,7 @@ export declare type GridSortConfig<S> = {
|
|
|
121
121
|
on: "client";
|
|
122
122
|
/** The optional initial column (index in columns) and direction to sort. */
|
|
123
123
|
initial?: [S | GridColumn<any>, Direction] | undefined;
|
|
124
|
+
caseSensitive?: boolean;
|
|
124
125
|
} | {
|
|
125
126
|
on: "server";
|
|
126
127
|
/** The current sort by value + direction (if server-side sorting). */
|
|
@@ -113,14 +113,14 @@ function GridTable(props) {
|
|
|
113
113
|
const columnSizes = (0, columnSizes_1.useSetupColumnSizes)(style, columns, tableRef, resizeTarget);
|
|
114
114
|
// Make a single copy of our current collapsed state, so we'll have a single observer.
|
|
115
115
|
const collapsedIds = (0, hooks_1.useComputed)(() => rowState.collapsedIds, [rowState]);
|
|
116
|
-
const [sortState, setSortKey, sortOn] = (0, useSortState_1.useSortState)(columns, props.sorting);
|
|
116
|
+
const [sortState, setSortKey, sortOn, caseSensitive] = (0, useSortState_1.useSortState)(columns, props.sorting);
|
|
117
117
|
const maybeSorted = (0, react_1.useMemo)(() => {
|
|
118
118
|
if (sortOn === "client" && sortState) {
|
|
119
119
|
// If using client-side sort, the sortState use S = number
|
|
120
|
-
return (0, sortRows_1.sortRows)(columns, rows, sortState);
|
|
120
|
+
return (0, sortRows_1.sortRows)(columns, rows, sortState, caseSensitive);
|
|
121
121
|
}
|
|
122
122
|
return rows;
|
|
123
|
-
}, [columns, rows, sortOn, sortState]);
|
|
123
|
+
}, [columns, rows, sortOn, sortState, caseSensitive]);
|
|
124
124
|
let hasTotalsRow = false;
|
|
125
125
|
// Filter rows - ensures parent rows remain in the list if any children match the filter.
|
|
126
126
|
const filterRows = (0, react_1.useCallback)((acc, row) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { GridCellContent, GridColumn, GridDataRow, Kinded } from "./GridTable";
|
|
3
3
|
import { SortOn, SortState } from "./useSortState";
|
|
4
|
-
export declare function sortRows<R extends Kinded>(columns: GridColumn<R>[], rows: GridDataRow<R>[], sortState: SortState<number
|
|
4
|
+
export declare function sortRows<R extends Kinded>(columns: GridColumn<R>[], rows: GridDataRow<R>[], sortState: SortState<number>, caseSensitive: boolean): GridDataRow<R>[];
|
|
5
5
|
export declare function ensureClientSideSortValueIsSortable(sortOn: SortOn, isHeader: boolean, column: GridColumn<any>, idx: number, maybeContent: ReactNode | GridCellContent): void;
|
|
@@ -3,26 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ensureClientSideSortValueIsSortable = exports.sortRows = void 0;
|
|
4
4
|
const GridTable_1 = require("./GridTable");
|
|
5
5
|
// Returns a shallow copy of the `rows` parameter sorted based on `sortState`
|
|
6
|
-
function sortRows(columns, rows, sortState) {
|
|
7
|
-
const sorted = sortBatch(columns, rows, sortState);
|
|
6
|
+
function sortRows(columns, rows, sortState, caseSensitive) {
|
|
7
|
+
const sorted = sortBatch(columns, rows, sortState, caseSensitive);
|
|
8
8
|
// Recursively sort child rows
|
|
9
9
|
sorted.forEach((row, i) => {
|
|
10
10
|
if (row.children) {
|
|
11
|
-
sorted[i].children = sortRows(columns, row.children, sortState);
|
|
11
|
+
sorted[i].children = sortRows(columns, row.children, sortState, caseSensitive);
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
return sorted;
|
|
15
15
|
}
|
|
16
16
|
exports.sortRows = sortRows;
|
|
17
|
-
function sortBatch(columns, batch, sortState) {
|
|
17
|
+
function sortBatch(columns, batch, sortState, caseSensitive) {
|
|
18
18
|
// When client-side sort, the sort value is the column index
|
|
19
19
|
const [value, direction] = sortState;
|
|
20
20
|
const column = columns[value];
|
|
21
21
|
const invert = direction === "DESC";
|
|
22
22
|
// Make a shallow copy for sorting to avoid mutating the original list
|
|
23
23
|
return [...batch].sort((a, b) => {
|
|
24
|
-
const v1 = sortValue((0, GridTable_1.applyRowFn)(column, a, {}, 0));
|
|
25
|
-
const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}, 0));
|
|
24
|
+
const v1 = sortValue((0, GridTable_1.applyRowFn)(column, a, {}, 0), caseSensitive);
|
|
25
|
+
const v2 = sortValue((0, GridTable_1.applyRowFn)(column, b, {}, 0), caseSensitive);
|
|
26
26
|
const v1e = v1 === null || v1 === undefined;
|
|
27
27
|
const v2e = v2 === null || v2 === undefined;
|
|
28
28
|
if (a.pin || b.pin) {
|
|
@@ -43,7 +43,7 @@ function sortBatch(columns, batch, sortState) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
/** Look at a row and get its sort value. */
|
|
46
|
-
function sortValue(value) {
|
|
46
|
+
function sortValue(value, caseSensitive) {
|
|
47
47
|
// Check sortValue and then fallback on value
|
|
48
48
|
let maybeFn = value;
|
|
49
49
|
if (value && typeof value === "object") {
|
|
@@ -60,13 +60,14 @@ function sortValue(value) {
|
|
|
60
60
|
}
|
|
61
61
|
// Watch for functions that need to read from a potentially-changing proxy
|
|
62
62
|
if (maybeFn instanceof Function) {
|
|
63
|
-
|
|
63
|
+
maybeFn = maybeFn();
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
// If it is a string, then always lower case it for comparisons
|
|
66
|
+
return typeof maybeFn === "string" && !caseSensitive ? maybeFn.toLowerCase() : maybeFn;
|
|
66
67
|
}
|
|
67
68
|
function ensureClientSideSortValueIsSortable(sortOn, isHeader, column, idx, maybeContent) {
|
|
68
69
|
if (process.env.NODE_ENV !== "production" && !isHeader && sortOn === "client" && column.clientSideSort !== false) {
|
|
69
|
-
const value = sortValue(maybeContent);
|
|
70
|
+
const value = sortValue(maybeContent, false);
|
|
70
71
|
if (!canClientSideSort(value)) {
|
|
71
72
|
throw new Error(`Column ${idx} passed an unsortable value, use GridCellContent or clientSideSort=false`);
|
|
72
73
|
}
|
|
@@ -10,5 +10,5 @@ import { Direction, GridColumn, GridSortConfig, Kinded } from "./GridTable";
|
|
|
10
10
|
export declare type SortState<S> = readonly [S, Direction];
|
|
11
11
|
export declare type SortOn = "client" | "server" | undefined;
|
|
12
12
|
/** Small custom hook that wraps the "setSortColumn inverts the current sort" logic. */
|
|
13
|
-
export declare function useSortState<R extends Kinded, S>(columns: GridColumn<R, S>[], sorting?: GridSortConfig<S>): [SortState<S> | undefined, (value: S) => void, SortOn];
|
|
13
|
+
export declare function useSortState<R extends Kinded, S>(columns: GridColumn<R, S>[], sorting?: GridSortConfig<S>): [SortState<S> | undefined, (value: S) => void, SortOn, boolean];
|
|
14
14
|
export declare function deriveSortState<S>(currentSortState: SortState<S> | undefined, clickedKey: S, initialSortState: SortState<S> | undefined): SortState<S> | undefined;
|
|
@@ -47,7 +47,9 @@ function useSortState(columns, sorting) {
|
|
|
47
47
|
},
|
|
48
48
|
// Note that sorting.onSort is not listed here, so we bind to whatever the 1st sorting.onSort was
|
|
49
49
|
[initialSortState, sortState, onSort]);
|
|
50
|
-
|
|
50
|
+
// If sorting is done on the client, the by default the sort will NOT be case sensitive
|
|
51
|
+
const caseSensitive = (sorting === null || sorting === void 0 ? void 0 : sorting.on) === "client" ? !!sorting.caseSensitive : false;
|
|
52
|
+
return [sortState, setSortKey, sorting === null || sorting === void 0 ? void 0 : sorting.on, caseSensitive];
|
|
51
53
|
}
|
|
52
54
|
exports.useSortState = useSortState;
|
|
53
55
|
// Exported for testing purposes
|
|
@@ -19,6 +19,7 @@ export * from "./Modal";
|
|
|
19
19
|
export * from "./Modal/useModal";
|
|
20
20
|
export { NavLink } from "./NavLink";
|
|
21
21
|
export { PresentationProvider } from "./PresentationContext";
|
|
22
|
+
export * from "./Snackbar";
|
|
22
23
|
export * from "./Stepper";
|
|
23
24
|
export * from "./SuperDrawer";
|
|
24
25
|
export * from "./Table";
|
package/dist/components/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var NavLink_1 = require("./NavLink");
|
|
|
35
35
|
Object.defineProperty(exports, "NavLink", { enumerable: true, get: function () { return NavLink_1.NavLink; } });
|
|
36
36
|
var PresentationContext_1 = require("./PresentationContext");
|
|
37
37
|
Object.defineProperty(exports, "PresentationProvider", { enumerable: true, get: function () { return PresentationContext_1.PresentationProvider; } });
|
|
38
|
+
__exportStar(require("./Snackbar"), exports);
|
|
38
39
|
__exportStar(require("./Stepper"), exports);
|
|
39
40
|
__exportStar(require("./SuperDrawer"), exports);
|
|
40
41
|
__exportStar(require("./Table"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homebound/beam",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.131.0",
|
|
4
4
|
"author": "Homebound",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@emotion/react": "^11.1.5",
|
|
79
79
|
"@homebound/rtl-react-router-utils": "^1.0.3",
|
|
80
80
|
"@homebound/rtl-utils": "^2.59.3",
|
|
81
|
-
"@homebound/truss": "^1.
|
|
81
|
+
"@homebound/truss": "^1.113.0",
|
|
82
82
|
"@homebound/tsconfig": "^1.0.3",
|
|
83
83
|
"@semantic-release/exec": "^6.0.3",
|
|
84
84
|
"@semantic-release/git": "^9.0.0",
|