@homebound/beam 2.140.0 → 2.141.2
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,10 +9,11 @@ export interface NavLinkProps extends BeamFocusableProps {
|
|
|
9
9
|
icon?: IconKey;
|
|
10
10
|
variant: NavLinkVariant;
|
|
11
11
|
openInNew?: boolean;
|
|
12
|
+
contrast?: boolean;
|
|
12
13
|
}
|
|
13
14
|
declare type NavLinkVariant = "side" | "global";
|
|
14
15
|
export declare function NavLink(props: NavLinkProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare function getNavLinkStyles(variant: NavLinkVariant): {
|
|
16
|
+
export declare function getNavLinkStyles(variant: NavLinkVariant, contrast: boolean): {
|
|
16
17
|
baseStyles: {};
|
|
17
18
|
hoverStyles: {};
|
|
18
19
|
disabledStyles: {};
|
|
@@ -10,7 +10,7 @@ const Css_1 = require("../Css");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const Icon_1 = require("./Icon");
|
|
12
12
|
function NavLink(props) {
|
|
13
|
-
const { disabled: isDisabled, label, openInNew, ...otherProps } = props;
|
|
13
|
+
const { disabled: isDisabled, label, openInNew, contrast = false, ...otherProps } = props;
|
|
14
14
|
const ariaProps = { children: label, isDisabled, ...otherProps };
|
|
15
15
|
const { href, active = false, icon = false, variant } = ariaProps;
|
|
16
16
|
const ref = (0, react_1.useRef)();
|
|
@@ -19,7 +19,7 @@ function NavLink(props) {
|
|
|
19
19
|
const { type, ...otherButtonProps } = buttonProps;
|
|
20
20
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)({ isDisabled });
|
|
21
21
|
const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)(ariaProps);
|
|
22
|
-
const { baseStyles, activeStyles, focusRingStyles, hoverStyles, disabledStyles, pressedStyles } = (0, react_1.useMemo)(() => getNavLinkStyles(variant), [variant]);
|
|
22
|
+
const { baseStyles, activeStyles, focusRingStyles, hoverStyles, disabledStyles, pressedStyles } = (0, react_1.useMemo)(() => getNavLinkStyles(variant, contrast), [variant, contrast]);
|
|
23
23
|
const external = (0, utils_1.isAbsoluteUrl)(href) || openInNew;
|
|
24
24
|
const linkAttributes = {
|
|
25
25
|
className: components_1.navLink,
|
|
@@ -43,19 +43,19 @@ function NavLink(props) {
|
|
|
43
43
|
return external ? ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: href }, (0, react_aria_1.mergeProps)(otherButtonProps, focusProps, hoverProps), linkAttributes, { children: linkContent }), void 0)) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, Object.assign({ to: href }, (0, react_aria_1.mergeProps)(otherButtonProps, focusProps, hoverProps), linkAttributes, { children: linkContent }), void 0));
|
|
44
44
|
}
|
|
45
45
|
exports.NavLink = NavLink;
|
|
46
|
-
function getNavLinkStyles(variant) {
|
|
47
|
-
return navLinkVariantStyles[variant];
|
|
46
|
+
function getNavLinkStyles(variant, contrast) {
|
|
47
|
+
return navLinkVariantStyles(contrast)[variant];
|
|
48
48
|
}
|
|
49
49
|
exports.getNavLinkStyles = getNavLinkStyles;
|
|
50
50
|
const baseStyles = Css_1.Css.df.aic.hPx(32).pyPx(6).px1.br4.smEm.outline0.$;
|
|
51
|
-
const navLinkVariantStyles = {
|
|
51
|
+
const navLinkVariantStyles = (contrast) => ({
|
|
52
52
|
side: {
|
|
53
|
-
baseStyles: { ...baseStyles, ...Css_1.Css.gray700.$ },
|
|
54
|
-
activeStyles: Css_1.Css.lightBlue700.bgLightBlue50.$,
|
|
55
|
-
disabledStyles: Css_1.Css.gray400.cursorNotAllowed.$,
|
|
56
|
-
focusRingStyles: Css_1.Css.bgLightBlue50.bshFocus.$,
|
|
57
|
-
hoverStyles: Css_1.Css.gray700.bgGray100.$,
|
|
58
|
-
pressedStyles: Css_1.Css.gray700.bgGray200.$,
|
|
53
|
+
baseStyles: { ...baseStyles, ...Css_1.Css.gray700.if(contrast).gray600.$ },
|
|
54
|
+
activeStyles: Css_1.Css.lightBlue700.bgLightBlue50.if(contrast).white.bgGray700.$,
|
|
55
|
+
disabledStyles: Css_1.Css.gray400.cursorNotAllowed.if(contrast).gray800.$,
|
|
56
|
+
focusRingStyles: Css_1.Css.bgLightBlue50.bshFocus.if(contrast).bgGray700.white.$,
|
|
57
|
+
hoverStyles: Css_1.Css.gray700.bgGray100.if(contrast).bgGray800.gray600.$,
|
|
58
|
+
pressedStyles: Css_1.Css.gray700.bgGray200.if(contrast).bgGray200.gray800.$,
|
|
59
59
|
},
|
|
60
60
|
global: {
|
|
61
61
|
baseStyles: { ...baseStyles, ...Css_1.Css.add("width", "max-content").gray500.$ },
|
|
@@ -64,5 +64,5 @@ const navLinkVariantStyles = {
|
|
|
64
64
|
focusRingStyles: Css_1.Css.gray500.bgGray900.add("boxShadow", `0px 1px 2px rgba(0, 0, 0, 0.05), 0px 0px 0px 2px #242424, 0px 0px 0px 4px #0EA5E9`).$,
|
|
65
65
|
hoverStyles: Css_1.Css.gray500.bgGray900.$,
|
|
66
66
|
pressedStyles: Css_1.Css.gray500.bgGray700.$,
|
|
67
|
-
}
|
|
68
|
-
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
@@ -8,12 +8,12 @@ const utils_1 = require("../utils");
|
|
|
8
8
|
const defaultLabel_1 = require("../utils/defaultLabel");
|
|
9
9
|
/** Wraps `TextField` and binds it to a form field. */
|
|
10
10
|
function BoundDateField(props) {
|
|
11
|
-
const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onBlur, onFocus, onEnter, ...others } = props;
|
|
11
|
+
const { field, readOnly, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onBlur, onFocus, onEnter, ...others } = props;
|
|
12
12
|
const testId = (0, utils_1.useTestIds)(props, field.key);
|
|
13
13
|
return ((0, jsx_runtime_1.jsx)(mobx_react_1.Observer, { children: () => ((0, jsx_runtime_1.jsx)(inputs_1.DateField, Object.assign({ label: label, value: field.value || undefined, onChange: (value) => {
|
|
14
14
|
onChange(value);
|
|
15
15
|
field.maybeAutoSave();
|
|
16
|
-
}, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onBlur: () => {
|
|
16
|
+
}, readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : field.readOnly, errorMsg: field.touched ? field.errors.join(" ") : undefined, required: field.required, onBlur: () => {
|
|
17
17
|
field.blur();
|
|
18
18
|
(0, utils_1.maybeCall)(onBlur);
|
|
19
19
|
}, onFocus: () => {
|