@homebound/beam 2.202.0 → 2.203.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 +11 -0
- package/dist/Css.js +12 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useBreakpoint.d.ts +11 -0
- package/dist/hooks/useBreakpoint.js +33 -0
- package/package.json +2 -2
package/dist/Css.d.ts
CHANGED
|
@@ -3033,6 +3033,17 @@ declare type Brand<K, T> = K & {
|
|
|
3033
3033
|
__brand: T;
|
|
3034
3034
|
};
|
|
3035
3035
|
declare type Breakpoint = Brand<string, "Breakpoint">;
|
|
3036
|
+
export declare type BreakpointKey = "print" | "sm" | "md" | "smOrMd" | "mdAndUp" | "mdAndDown" | "lg" | "mdOrLg";
|
|
3037
|
+
export declare enum Breakpoints {
|
|
3038
|
+
print = "@media print",
|
|
3039
|
+
sm = "@media screen and (max-width:599px)",
|
|
3040
|
+
md = "@media screen and (min-width:600px) and (max-width:1024px)",
|
|
3041
|
+
smOrMd = "@media screen and (max-width:1024px)",
|
|
3042
|
+
mdAndUp = "@media screen and (min-width:600px)",
|
|
3043
|
+
mdAndDown = "@media screen and (max-width:1024px)",
|
|
3044
|
+
lg = "@media screen and (min-width:1025px)",
|
|
3045
|
+
mdOrLg = "@media screen and (min-width:600px)"
|
|
3046
|
+
}
|
|
3036
3047
|
export declare const print: Breakpoint;
|
|
3037
3048
|
export declare const sm: Breakpoint;
|
|
3038
3049
|
export declare const md: Breakpoint;
|
package/dist/Css.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mdOrLg = exports.lg = exports.mdAndDown = exports.mdAndUp = exports.smOrMd = exports.md = exports.sm = exports.print = exports.Css = exports.Palette = exports.px = exports.increment = exports.maybeInc = void 0;
|
|
3
|
+
exports.mdOrLg = exports.lg = exports.mdAndDown = exports.mdAndUp = exports.smOrMd = exports.md = exports.sm = exports.print = exports.Breakpoints = exports.Css = exports.Palette = exports.px = exports.increment = exports.maybeInc = void 0;
|
|
4
4
|
// prettier-ignore
|
|
5
5
|
class CssBuilder {
|
|
6
6
|
constructor(opts) {
|
|
@@ -998,6 +998,17 @@ var Palette;
|
|
|
998
998
|
})(Palette = exports.Palette || (exports.Palette = {}));
|
|
999
999
|
/** An entry point for Css expressions. CssBuilder is immutable so this is safe to share. */
|
|
1000
1000
|
exports.Css = new CssBuilder({ rules: {}, enabled: true, important: false, selector: undefined });
|
|
1001
|
+
var Breakpoints;
|
|
1002
|
+
(function (Breakpoints) {
|
|
1003
|
+
Breakpoints["print"] = "@media print";
|
|
1004
|
+
Breakpoints["sm"] = "@media screen and (max-width:599px)";
|
|
1005
|
+
Breakpoints["md"] = "@media screen and (min-width:600px) and (max-width:1024px)";
|
|
1006
|
+
Breakpoints["smOrMd"] = "@media screen and (max-width:1024px)";
|
|
1007
|
+
Breakpoints["mdAndUp"] = "@media screen and (min-width:600px)";
|
|
1008
|
+
Breakpoints["mdAndDown"] = "@media screen and (max-width:1024px)";
|
|
1009
|
+
Breakpoints["lg"] = "@media screen and (min-width:1025px)";
|
|
1010
|
+
Breakpoints["mdOrLg"] = "@media screen and (min-width:600px)";
|
|
1011
|
+
})(Breakpoints = exports.Breakpoints || (exports.Breakpoints = {}));
|
|
1001
1012
|
exports.print = "@media print";
|
|
1002
1013
|
exports.sm = "@media screen and (max-width:599px)";
|
|
1003
1014
|
exports.md = "@media screen and (min-width:600px) and (max-width:1024px)";
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homebound/beam",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.203.0",
|
|
4
4
|
"author": "Homebound",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@homebound/eslint-config": "1.5.1",
|
|
78
78
|
"@homebound/rtl-react-router-utils": "^1.0.3",
|
|
79
79
|
"@homebound/rtl-utils": "^2.59.3",
|
|
80
|
-
"@homebound/truss": "^1.
|
|
80
|
+
"@homebound/truss": "^1.115.0",
|
|
81
81
|
"@homebound/tsconfig": "^1.0.3",
|
|
82
82
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
|
|
83
83
|
"@semantic-release/exec": "^6.0.3",
|