@homebound/beam 2.178.0 → 2.179.1
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/Button.js +1 -4
- package/dist/components/Icon.d.ts +1 -0
- package/dist/components/Icon.js +2 -1
- package/dist/inputs/ToggleButton.d.ts +24 -0
- package/dist/inputs/ToggleButton.js +61 -0
- package/dist/inputs/index.d.ts +1 -0
- package/dist/inputs/index.js +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +5 -1
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@ function Button(props) {
|
|
|
27
27
|
? utils_1.noop
|
|
28
28
|
: (e) => {
|
|
29
29
|
const result = onPress(e);
|
|
30
|
-
if (isPromise(result)) {
|
|
30
|
+
if ((0, utils_1.isPromise)(result)) {
|
|
31
31
|
setAsyncInProgress(true);
|
|
32
32
|
result.finally(() => setAsyncInProgress(false));
|
|
33
33
|
}
|
|
@@ -130,6 +130,3 @@ const iconStyles = {
|
|
|
130
130
|
md: Css_1.Css.mr1.$,
|
|
131
131
|
lg: Css_1.Css.mrPx(10).$,
|
|
132
132
|
};
|
|
133
|
-
function isPromise(obj) {
|
|
134
|
-
return typeof obj === "object" && "then" in obj && typeof obj.then === "function";
|
|
135
|
-
}
|
|
@@ -87,6 +87,7 @@ export declare const Icons: {
|
|
|
87
87
|
calendar: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
88
88
|
buildingHouse: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
89
89
|
house: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
90
|
+
bell: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
90
91
|
projects: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
91
92
|
tasks: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
92
93
|
finances: import("@emotion/react/jsx-runtime").JSX.Element;
|
package/dist/components/Icon.js
CHANGED
|
@@ -60,7 +60,7 @@ exports.Icons = {
|
|
|
60
60
|
helpCircle: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M11.9999 6C9.83092 6 8.06592 7.765 8.06592 9.934H10.0659C10.0659 8.867 10.9339 8 11.9999 8C13.0659 8 13.9339 8.867 13.9339 9.934C13.9339 10.532 13.4529 10.966 12.7179 11.56C12.4629 11.767 12.2219 11.964 12.0269 12.159C11.0289 13.156 10.9999 14.215 10.9999 14.333V15H12.9999L12.9989 14.367C12.9999 14.351 13.0319 13.981 13.4399 13.574C13.5899 13.424 13.7789 13.274 13.9749 13.116C14.7539 12.485 15.9329 11.532 15.9329 9.934C15.9339 7.765 14.1689 6 11.9999 6ZM10.9999 16H12.9999V18H10.9999V16Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M12 2C6.486 2 2 6.486 2 12C2 17.514 6.486 22 12 22C17.514 22 22 17.514 22 12C22 6.486 17.514 2 12 2ZM12 20C7.589 20 4 16.411 4 12C4 7.589 7.589 4 12 4C16.411 4 20 7.589 20 12C20 16.411 16.411 20 12 20Z" }, void 0)] }, void 0)),
|
|
61
61
|
error: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M11.001 10H13.001V15H11.001V10ZM11 16H13V18H11V16Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M13.7679 4.19994C13.4199 3.54494 12.7419 3.13794 11.9999 3.13794C11.2579 3.13794 10.5799 3.54494 10.2319 4.20094L2.89392 18.0639C2.56292 18.6899 2.58292 19.4249 2.94792 20.0319C3.31292 20.6379 3.95292 20.9999 4.66092 20.9999H19.3389C20.0469 20.9999 20.6879 20.6379 21.0529 20.0319C21.4169 19.4259 21.4379 18.6899 21.1069 18.0639L13.7679 4.19994ZM4.66092 18.9999L11.9999 5.13694L19.3439 18.9999H4.66092Z" }, void 0)] }, void 0)),
|
|
62
62
|
xCircle: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M9.17181 16.2421L11.9998 13.4141L14.8278 16.2421L16.2418 14.8281L13.4138 12.0001L16.2418 9.17206L14.8278 7.75806L11.9998 10.5861L9.17181 7.75806L7.75781 9.17206L10.5858 12.0001L7.75781 14.8281L9.17181 16.2421Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M12 22C17.514 22 22 17.514 22 12C22 6.486 17.514 2 12 2C6.486 2 2 6.486 2 12C2 17.514 6.486 22 12 22ZM12 4C16.411 4 20 7.589 20 12C20 16.411 16.411 20 12 20C7.589 20 4 16.411 4 12C4 7.589 7.589 4 12 4Z" }, void 0)] }, void 0)),
|
|
63
|
-
flag: (
|
|
63
|
+
flag: (0, jsx_runtime_1.jsx)("path", { d: "M19 4H6V2H4V20H3V22H4H6H7V20H6V15H19C19.553 15 20 14.552 20 14V5C20 4.448 19.553 4 19 4Z" }, void 0),
|
|
64
64
|
outlineFlag: ((0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M6 2H4V20H3V22H7V20H6V15H19C19.5523 15 20 14.5523 20 14V5C20 4.44772 19.5523 4 19 4H6V2ZM6 6V13H18V6H6Z" }, void 0)),
|
|
65
65
|
// Arrows
|
|
66
66
|
chevronsDown: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M12 15.586L7.70697 11.293L6.29297 12.707L12 18.414L17.707 12.707L16.293 11.293L12 15.586Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M17.707 7.70697L16.293 6.29297L12 10.586L7.70697 6.29297L6.29297 7.70697L12 13.414L17.707 7.70697Z" }, void 0)] }, void 0)),
|
|
@@ -92,6 +92,7 @@ exports.Icons = {
|
|
|
92
92
|
calendar: ((0, jsx_runtime_1.jsx)("path", { d: "M2.99902 6V8V20C2.99902 21.103 3.89602 22 4.99902 22H18.999C20.102 22 20.999 21.103 20.999 20V8V6C20.999 4.897 20.102 4 18.999 4H16.999V2H14.999V4H8.99902V2H6.99902V4H4.99902C3.89602 4 2.99902 4.897 2.99902 6ZM19.001 20H4.99902V8H18.999L19.001 20Z" }, void 0)),
|
|
93
93
|
buildingHouse: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M19.0002 2.00002H9.00019C7.89719 2.00002 7.00019 2.89702 7.00019 4.00002V9.58602L2.29319 14.293C2.00719 14.579 1.92119 15.009 2.07619 15.383C2.23119 15.757 2.59619 16 3.00019 16V17V21C3.00019 21.553 3.44819 22 4.00019 22H12.0002H20.0002C20.5532 22 21.0002 21.553 21.0002 21V4.00002C21.0002 2.89702 20.1032 2.00002 19.0002 2.00002ZM11.0002 20H5.00019V17V15V14.414L8.00019 11.414L11.0002 14.414V15V18V20ZM19.0002 20H13.0002V18V16C13.4042 16 13.7702 15.757 13.9242 15.383C14.0792 15.009 13.9932 14.579 13.7072 14.293L9.00019 9.58602V4.00002H19.0002V20Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M11 6.00002H13V8.00002H11V6.00002ZM15 6.00002H17V8.00002H15V6.00002ZM15 10.031H17V12H15V10.031ZM15 14H17V16H15V14ZM7 15H9V17H7V15Z" }, void 0)] }, void 0)),
|
|
94
94
|
house: ((0, jsx_runtime_1.jsx)("path", { d: "M5.00299 22H9.00299H15.003H19.003C20.106 22 21.003 21.103 21.003 20V11C21.003 10.735 20.898 10.48 20.71 10.293L12.71 2.29301C12.319 1.90201 11.687 1.90201 11.296 2.29301L3.29599 10.293C3.10799 10.48 3.00299 10.735 3.00299 11V20C3.00299 21.103 3.89999 22 5.00299 22ZM10.003 20V15H14.003V20H10.003ZM5.00299 11.414L12.003 4.41401L19.003 11.414L19.004 20H16.003V15C16.003 13.897 15.106 13 14.003 13H10.003C8.89999 13 8.00299 13.897 8.00299 15V20H5.00299V11.414Z" }, void 0)),
|
|
95
|
+
bell: ((0, jsx_runtime_1.jsx)("path", { d: "M19 13.586V10C19 6.783 16.815 4.073 13.855 3.258C13.562 2.52 12.846 2 12 2C11.154 2 10.438 2.52 10.145 3.258C7.185 4.074 5 6.783 5 10V13.586L3.293 15.293C3.105 15.48 3 15.734 3 16V18C3 18.553 3.447 19 4 19H20C20.553 19 21 18.553 21 18V16C21 15.734 20.895 15.48 20.707 15.293L19 13.586ZM19 17H5V16.414L6.707 14.707C6.895 14.52 7 14.266 7 14V10C7 7.243 9.243 5 12 5C14.757 5 17 7.243 17 10V14C17 14.266 17.105 14.52 17.293 14.707L19 16.414V17ZM12 22C13.311 22 14.407 21.166 14.818 20H9.182C9.593 21.166 10.689 22 12 22Z" }, void 0)),
|
|
95
96
|
// Navigation
|
|
96
97
|
projects: ((0, jsx_runtime_1.jsx)("path", { d: "M4 6H6V8H4V6ZM4 11H6V13H4V11ZM4 16H6V18H4V16ZM20 8V6H18.8H9.2H8.023V8H9.2H18.8H20ZM8 11H20V13H8V11ZM8 16H20V18H8V16Z" }, void 0)),
|
|
97
98
|
tasks: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M5 22H19C20.103 22 21 21.103 21 20V5C21 3.897 20.103 3 19 3H17C17 2.447 16.553 2 16 2H8C7.447 2 7 2.447 7 3H5C3.897 3 3 3.897 3 5V20C3 21.103 3.897 22 5 22ZM5 5H7V7H17V5H19V20H5V5Z" }, void 0), (0, jsx_runtime_1.jsx)("path", { d: "M11 13.586L9.20697 11.793L7.79297 13.207L11 16.414L16.207 11.207L14.793 9.79297L11 13.586Z" }, void 0)] }, void 0)),
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { IconKey } from "../components";
|
|
3
|
+
export interface ToggleButtonProps {
|
|
4
|
+
/** Input label */
|
|
5
|
+
label: string;
|
|
6
|
+
selected?: boolean;
|
|
7
|
+
onChange: ((selected: boolean) => void) | ((selected: boolean) => Promise<void>);
|
|
8
|
+
autoFocus?: boolean;
|
|
9
|
+
icon?: IconKey;
|
|
10
|
+
/** Whether the field is disabled. If a ReactNode, it's treated as a "disabled reason" that's shown in a tooltip. */
|
|
11
|
+
disabled?: boolean | ReactNode;
|
|
12
|
+
tooltip?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function ToggleButton(props: ToggleButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
|
+
/** Styles */
|
|
16
|
+
export declare const toggleHoverStyles: {
|
|
17
|
+
backgroundColor: import("csstype").Property.BackgroundColor | undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare const toggleFocusStyles: {
|
|
20
|
+
boxShadow: import("csstype").Property.BoxShadow | undefined;
|
|
21
|
+
};
|
|
22
|
+
export declare const togglePressStyles: {
|
|
23
|
+
backgroundColor: import("csstype").Property.BackgroundColor | undefined;
|
|
24
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.togglePressStyles = exports.toggleFocusStyles = exports.toggleHoverStyles = exports.ToggleButton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_aria_1 = require("react-aria");
|
|
7
|
+
const react_stately_1 = require("react-stately");
|
|
8
|
+
const components_1 = require("../components");
|
|
9
|
+
const Css_1 = require("../Css");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
function ToggleButton(props) {
|
|
12
|
+
const { selected: isSelected = false, disabled = false, label, onChange, icon, ...otherProps } = props;
|
|
13
|
+
const [asyncInProgress, setAsyncInProgress] = (0, react_1.useState)(false);
|
|
14
|
+
const isDisabled = !!disabled || asyncInProgress;
|
|
15
|
+
const ariaProps = { "aria-label": label, isSelected, isDisabled, ...otherProps };
|
|
16
|
+
const state = (0, react_stately_1.useToggleState)({
|
|
17
|
+
...ariaProps,
|
|
18
|
+
onChange: (e) => {
|
|
19
|
+
const result = onChange(e);
|
|
20
|
+
if ((0, utils_1.isPromise)(result)) {
|
|
21
|
+
setAsyncInProgress(true);
|
|
22
|
+
result.finally(() => setAsyncInProgress(false));
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const labelRef = (0, react_1.useRef)(null);
|
|
28
|
+
const ref = (0, react_1.useRef)(null);
|
|
29
|
+
const tid = (0, utils_1.useTestIds)(props, label);
|
|
30
|
+
const { isPressed, pressProps } = (0, react_aria_1.usePress)({ ref: labelRef, isDisabled });
|
|
31
|
+
const { inputProps } = (0, react_aria_1.useSwitch)(ariaProps, state, ref);
|
|
32
|
+
const { isFocusVisible: isKeyboardFocus, focusProps } = (0, react_aria_1.useFocusRing)({ ...otherProps, within: true });
|
|
33
|
+
const { hoverProps, isHovered } = (0, react_aria_1.useHover)({ isDisabled });
|
|
34
|
+
const tooltip = (0, components_1.resolveTooltip)(disabled);
|
|
35
|
+
const labelAttrs = {
|
|
36
|
+
...focusProps,
|
|
37
|
+
...hoverProps,
|
|
38
|
+
...pressProps,
|
|
39
|
+
css: {
|
|
40
|
+
...Css_1.Css.br4.dif.aic.gap1.bgTransparent.gray500.hPx(32).plPx(4).pr1.relative.cursorPointer.w("max-content").smEm
|
|
41
|
+
.selectNone.$,
|
|
42
|
+
...(isHovered && exports.toggleHoverStyles),
|
|
43
|
+
...(isPressed && exports.togglePressStyles),
|
|
44
|
+
...(isSelected && !isDisabled && Css_1.Css.lightBlue700.$),
|
|
45
|
+
...(isKeyboardFocus && exports.toggleFocusStyles),
|
|
46
|
+
...(isDisabled && Css_1.Css.gray300.cursorNotAllowed.$),
|
|
47
|
+
},
|
|
48
|
+
...tid,
|
|
49
|
+
};
|
|
50
|
+
return (0, components_1.maybeTooltip)({
|
|
51
|
+
title: tooltip,
|
|
52
|
+
placement: "top",
|
|
53
|
+
children: ((0, jsx_runtime_1.jsxs)("label", Object.assign({}, labelAttrs, { children: [icon && (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon }, void 0), label, (0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", Object.assign({ ref: ref }, inputProps, tid.value), void 0) }, void 0)] }), void 0)),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.ToggleButton = ToggleButton;
|
|
57
|
+
/** Styles */
|
|
58
|
+
// Toggle element styles
|
|
59
|
+
exports.toggleHoverStyles = Css_1.Css.bgGray100.$;
|
|
60
|
+
exports.toggleFocusStyles = Css_1.Css.bshFocus.$;
|
|
61
|
+
exports.togglePressStyles = Css_1.Css.bgGray300.$;
|
package/dist/inputs/index.d.ts
CHANGED
package/dist/inputs/index.js
CHANGED
package/dist/utils/index.d.ts
CHANGED
|
@@ -28,3 +28,4 @@ export declare class EmptyRef<T> implements MutableRefObject<T> {
|
|
|
28
28
|
}
|
|
29
29
|
export declare const isAbsoluteUrl: (url: string) => boolean;
|
|
30
30
|
export declare function areArraysEqual(a: any[], b: any[]): boolean;
|
|
31
|
+
export declare function isPromise(obj: void | Promise<void>): obj is Promise<void>;
|
package/dist/utils/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.areArraysEqual = exports.isAbsoluteUrl = exports.EmptyRef = exports.safeEntries = exports.noop = exports.omitKey = exports.safeKeys = exports.maybeCall = exports.toGroupState = exports.toToggleState = void 0;
|
|
13
|
+
exports.isPromise = exports.areArraysEqual = exports.isAbsoluteUrl = exports.EmptyRef = exports.safeEntries = exports.noop = exports.omitKey = exports.safeKeys = exports.maybeCall = exports.toGroupState = exports.toToggleState = void 0;
|
|
14
14
|
/** Adapts our state to what useToggleState returns in a stateless manner. */
|
|
15
15
|
function toToggleState(isSelected, onChange) {
|
|
16
16
|
return {
|
|
@@ -78,3 +78,7 @@ function areArraysEqual(a, b) {
|
|
|
78
78
|
return a.length === b.length && a.every((val, idx) => val === b[idx]);
|
|
79
79
|
}
|
|
80
80
|
exports.areArraysEqual = areArraysEqual;
|
|
81
|
+
function isPromise(obj) {
|
|
82
|
+
return typeof obj === "object" && "then" in obj && typeof obj.then === "function";
|
|
83
|
+
}
|
|
84
|
+
exports.isPromise = isPromise;
|