@jobber/components 4.15.2 → 4.15.3-JOB-68798.3
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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* @interal Context to verify `Grid.Cell`'s are only usable inside of a `Grid`
|
|
4
|
+
*/
|
|
5
|
+
export interface InternalGridContextProps {
|
|
6
|
+
readonly gridName: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const defaultValues: InternalGridContextProps;
|
|
9
|
+
export declare const InternalGridContext: import("react").Context<InternalGridContextProps>;
|
|
10
|
+
export declare function useInternalGridContext(): InternalGridContextProps;
|
package/dist/Grid/index.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var classnames = require('classnames');
|
|
7
|
+
var useAssert = require('@jobber/hooks/useAssert');
|
|
7
8
|
var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
|
|
9
|
+
var uuid = require('uuid');
|
|
8
10
|
|
|
9
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
12
|
|
|
@@ -15,6 +17,19 @@ var css_248z$2 = "._3ktwlV3aNFk- {\n grid-column: initial;\n grid-column-end:
|
|
|
15
17
|
var styles$1 = {"gridCell":"_3ktwlV3aNFk-"};
|
|
16
18
|
styleInject_es.styleInject(css_248z$2);
|
|
17
19
|
|
|
20
|
+
const defaultValues = {
|
|
21
|
+
gridName: "",
|
|
22
|
+
};
|
|
23
|
+
const InternalGridContext = React.createContext(defaultValues);
|
|
24
|
+
function useInternalGridContext() {
|
|
25
|
+
return React.useContext(InternalGridContext);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function InternalGridProvider({ children, }) {
|
|
29
|
+
const gridNameRef = React.useRef(`grid${uuid.v1()}`);
|
|
30
|
+
return (React__default["default"].createElement(InternalGridContext.Provider, { value: { gridName: gridNameRef.current } }, children));
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
/**
|
|
19
34
|
* Breakpoints that we support
|
|
20
35
|
*/
|
|
@@ -27,6 +42,8 @@ function GridCell({ size, children }) {
|
|
|
27
42
|
* the column
|
|
28
43
|
*/
|
|
29
44
|
const cssSizeVariables = breakpoints.reduce(getSizeCSSVariables(size), {});
|
|
45
|
+
const gridContext = useInternalGridContext();
|
|
46
|
+
useAssert.useAssert(!gridContext.gridName, "`<Grid.Cell>` can only be used inside of a `<Grid>` component!");
|
|
30
47
|
return (React__default["default"].createElement("div", { "data-testid": GRID_CELL_TEST_ID, className: styles$1.gridCell, style: cssSizeVariables }, children));
|
|
31
48
|
}
|
|
32
49
|
function getSizeCSSVariables(size) {
|
|
@@ -57,7 +74,8 @@ function Grid({ alignItems = "start", gap = true, children, }) {
|
|
|
57
74
|
const classnames = classnames__default["default"](styles.grid, alignments[alignItems], {
|
|
58
75
|
[styles.gap]: gap,
|
|
59
76
|
});
|
|
60
|
-
return (React__default["default"].createElement(
|
|
77
|
+
return (React__default["default"].createElement(InternalGridProvider, null,
|
|
78
|
+
React__default["default"].createElement("div", { "data-testid": GRID_TEST_ID, className: classnames }, children)));
|
|
61
79
|
}
|
|
62
80
|
Grid.Cell = GridCell;
|
|
63
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.3-JOB-68798.3+214dd17f",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.39.0",
|
|
23
|
-
"@jobber/formatters": "
|
|
23
|
+
"@jobber/formatters": "^0.2.2",
|
|
24
24
|
"@jobber/hooks": "^2.1.2",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"> 1%",
|
|
84
84
|
"IE 10"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "214dd17fed20df6265ea04d4cb22c2d1af9159cf"
|
|
87
87
|
}
|