@homebound/beam 2.202.1 → 2.204.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/Tag.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IconKey } from "./";
|
|
1
2
|
import { Margin, Only, Xss } from "../Css";
|
|
2
3
|
declare type TagXss = Margin;
|
|
3
4
|
export declare type TagType = "info" | "caution" | "warning" | "success" | "neutral";
|
|
@@ -5,6 +6,7 @@ interface TagProps<X> {
|
|
|
5
6
|
text: string;
|
|
6
7
|
type?: TagType;
|
|
7
8
|
xss?: X;
|
|
9
|
+
icon?: IconKey;
|
|
8
10
|
}
|
|
9
11
|
/** Tag used for indicating a status */
|
|
10
12
|
export declare function Tag<X extends Only<Xss<TagXss>, X>>({ text, type, xss, ...otherProps }: TagProps<X>): import("@emotion/react/jsx-runtime").JSX.Element;
|
package/dist/components/Tag.js
CHANGED
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Tag = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const components_1 = require("./");
|
|
5
6
|
const Css_1 = require("../Css");
|
|
6
7
|
const utils_1 = require("../utils");
|
|
7
8
|
/** Tag used for indicating a status */
|
|
8
9
|
function Tag({ text, type, xss, ...otherProps }) {
|
|
9
10
|
const typeStyles = getStyles(type);
|
|
10
11
|
const tid = (0, utils_1.useTestIds)(otherProps);
|
|
11
|
-
return ((0, jsx_runtime_1.
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)("span", Object.assign({}, tid, { css: { ...Css_1.Css.dif.tinySb.ttu.aic.gapPx(4).pxPx(6).pyPx(2).gray900.br4.$, ...typeStyles, ...xss }, title: text }, { children: [otherProps.icon && ((0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.fs0.$ }, { children: (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: otherProps.icon, inc: 1.5 }, void 0) }), void 0)), (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.lineClamp1.breakAll.$ }, { children: text }), void 0)] }), void 0));
|
|
12
13
|
}
|
|
13
14
|
exports.Tag = Tag;
|
|
14
15
|
function getStyles(type) {
|
|
15
16
|
switch (type) {
|
|
16
17
|
case "info":
|
|
17
|
-
return Css_1.Css.
|
|
18
|
+
return Css_1.Css.bgLightBlue100.$;
|
|
18
19
|
case "caution":
|
|
19
|
-
return Css_1.Css.
|
|
20
|
+
return Css_1.Css.bgYellow200.$;
|
|
20
21
|
case "warning":
|
|
21
22
|
return Css_1.Css.bgRed100.$;
|
|
22
23
|
case "success":
|
|
23
|
-
return Css_1.Css.
|
|
24
|
+
return Css_1.Css.bgGreen100.$;
|
|
24
25
|
default:
|
|
25
26
|
// Neutral case
|
|
26
27
|
return Css_1.Css.bgGray200.$;
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -10,6 +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
|
+
__exportStar(require("./useBreakpoint"), exports);
|
|
13
14
|
__exportStar(require("./useComputed"), exports);
|
|
14
15
|
__exportStar(require("./useGroupBy"), exports);
|
|
15
16
|
__exportStar(require("./useHover"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BreakpointKey } from "../Css";
|
|
2
|
+
/**
|
|
3
|
+
* A React hook to return a record of responsive breakpoints that updates on resize.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const { breakpoints } = useBreakpoint();
|
|
7
|
+
* if(breakpoints.mdAndDown) {...do something cool}
|
|
8
|
+
*/
|
|
9
|
+
declare type BreakpointsType = Record<BreakpointKey, boolean>;
|
|
10
|
+
export declare const useBreakpoint: () => BreakpointsType;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useBreakpoint = void 0;
|
|
7
|
+
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const use_debounce_1 = require("use-debounce");
|
|
10
|
+
const Css_1 = require("../Css");
|
|
11
|
+
const useBreakpoint = () => {
|
|
12
|
+
const [breakpoints, setBreakpoints] = (0, react_1.useState)(matchMediaBreakpoints());
|
|
13
|
+
const handleResize = (0, use_debounce_1.useDebouncedCallback)(() => {
|
|
14
|
+
const newBps = matchMediaBreakpoints();
|
|
15
|
+
if ((0, fast_deep_equal_1.default)(breakpoints, newBps))
|
|
16
|
+
return;
|
|
17
|
+
setBreakpoints(newBps);
|
|
18
|
+
}, 1000);
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
window.addEventListener("resize", handleResize);
|
|
21
|
+
// Remove event listener on cleanup
|
|
22
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
23
|
+
}, []);
|
|
24
|
+
return breakpoints;
|
|
25
|
+
};
|
|
26
|
+
exports.useBreakpoint = useBreakpoint;
|
|
27
|
+
function matchMediaBreakpoints() {
|
|
28
|
+
let bps = {};
|
|
29
|
+
Object.entries(Css_1.Breakpoints).forEach(([name, bp]) => {
|
|
30
|
+
bps[name] = window.matchMedia(bp.replace("@media ", "")).matches;
|
|
31
|
+
});
|
|
32
|
+
return bps;
|
|
33
|
+
}
|