@vitus-labs/coolgrid 2.6.1 → 2.7.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/lib/index.js +7 -12
- package/lib/vitus-labs-coolgrid.native.js +7 -12
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ALIGN_CONTENT_MAP_X, Provider,
|
|
1
|
+
import { ALIGN_CONTENT_MAP_X, Provider, extendCss, makeItResponsive, value } from "@vitus-labs/unistyle";
|
|
2
2
|
import { createContext, useContext, useMemo } from "react";
|
|
3
|
-
import { config, get, omit, pick, useStableValue } from "@vitus-labs/core";
|
|
3
|
+
import { config, context, get, omit, pick, useStableValue } from "@vitus-labs/core";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/constants.ts
|
|
@@ -42,14 +42,13 @@ var RowContext_default = createContext({});
|
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/useContext.tsx
|
|
45
|
-
const pickThemeProps = (props, keywords) => pick(props, keywords);
|
|
46
45
|
const getGridContext = (props = {}, theme = {}) => ({
|
|
47
|
-
columns:
|
|
48
|
-
containerWidth:
|
|
46
|
+
columns: props.columns || get(theme, "grid.columns") || get(theme, "coolgrid.columns"),
|
|
47
|
+
containerWidth: props.width || get(theme, "grid.container") || get(theme, "coolgrid.container")
|
|
49
48
|
});
|
|
50
49
|
const useGridContext = (props) => {
|
|
51
50
|
const { theme } = useContext(context);
|
|
52
|
-
const stableCtxProps = useStableValue(
|
|
51
|
+
const stableCtxProps = useStableValue(pick(props, CONTEXT_KEYS));
|
|
53
52
|
return useMemo(() => {
|
|
54
53
|
return {
|
|
55
54
|
...getGridContext(stableCtxProps, theme),
|
|
@@ -60,6 +59,7 @@ const useGridContext = (props) => {
|
|
|
60
59
|
|
|
61
60
|
//#endregion
|
|
62
61
|
//#region src/utils.ts
|
|
62
|
+
const CONTEXT_KEYS_SET = new Set(CONTEXT_KEYS);
|
|
63
63
|
/** Checks whether a value is a finite number. */
|
|
64
64
|
const isNumber = (value) => Number.isFinite(value);
|
|
65
65
|
/** Checks whether a value is a finite number greater than zero. */
|
|
@@ -69,7 +69,7 @@ const hasValue = (value) => isNumber(value) && value > 0;
|
|
|
69
69
|
* size is undefined (auto) or a non-zero number. Size 0 hides the column.
|
|
70
70
|
*/
|
|
71
71
|
const isVisible = (value) => isNumber(value) && value !== 0 || value === void 0;
|
|
72
|
-
const omitCtxKeys = (props) => omit(props,
|
|
72
|
+
const omitCtxKeys = (props) => omit(props, CONTEXT_KEYS_SET);
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/Col/styled.ts
|
|
@@ -103,11 +103,6 @@ const spacingStyles$1 = (type, param, rootSize) => {
|
|
|
103
103
|
${`${type}: ${value(param / 2, rootSize)}`};
|
|
104
104
|
`;
|
|
105
105
|
};
|
|
106
|
-
/**
|
|
107
|
-
* Main responsive style block for Col. When the column is visible, applies
|
|
108
|
-
* width, padding, margin, and extra CSS. When hidden (size === 0), moves
|
|
109
|
-
* the element off-screen with fixed positioning.
|
|
110
|
-
*/
|
|
111
106
|
const styles$2 = ({ theme, css, rootSize }) => {
|
|
112
107
|
const { size, columns, gap, padding, extraStyles, RNparentWidth } = theme;
|
|
113
108
|
if (isVisible(size)) return css`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ALIGN_CONTENT_MAP_X, Provider,
|
|
1
|
+
import { ALIGN_CONTENT_MAP_X, Provider, extendCss, makeItResponsive, value } from "@vitus-labs/unistyle";
|
|
2
2
|
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
3
|
-
import { config, get, omit, pick, useStableValue } from "@vitus-labs/core";
|
|
3
|
+
import { config, context, get, omit, pick, useStableValue } from "@vitus-labs/core";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/constants.ts
|
|
@@ -42,14 +42,13 @@ var RowContext_default = createContext({});
|
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/useContext.tsx
|
|
45
|
-
const pickThemeProps = (props, keywords) => pick(props, keywords);
|
|
46
45
|
const getGridContext = (props = {}, theme = {}) => ({
|
|
47
|
-
columns:
|
|
48
|
-
containerWidth:
|
|
46
|
+
columns: props.columns || get(theme, "grid.columns") || get(theme, "coolgrid.columns"),
|
|
47
|
+
containerWidth: props.width || get(theme, "grid.container") || get(theme, "coolgrid.container")
|
|
49
48
|
});
|
|
50
49
|
const useGridContext = (props) => {
|
|
51
50
|
const { theme } = useContext(context);
|
|
52
|
-
const stableCtxProps = useStableValue(
|
|
51
|
+
const stableCtxProps = useStableValue(pick(props, CONTEXT_KEYS));
|
|
53
52
|
return useMemo(() => {
|
|
54
53
|
return {
|
|
55
54
|
...getGridContext(stableCtxProps, theme),
|
|
@@ -60,6 +59,7 @@ const useGridContext = (props) => {
|
|
|
60
59
|
|
|
61
60
|
//#endregion
|
|
62
61
|
//#region src/utils.ts
|
|
62
|
+
const CONTEXT_KEYS_SET = new Set(CONTEXT_KEYS);
|
|
63
63
|
/** Checks whether a value is a finite number. */
|
|
64
64
|
const isNumber = (value) => Number.isFinite(value);
|
|
65
65
|
/** Checks whether a value is a finite number greater than zero. */
|
|
@@ -69,7 +69,7 @@ const hasValue = (value) => isNumber(value) && value > 0;
|
|
|
69
69
|
* size is undefined (auto) or a non-zero number. Size 0 hides the column.
|
|
70
70
|
*/
|
|
71
71
|
const isVisible = (value) => isNumber(value) && value !== 0 || value === void 0;
|
|
72
|
-
const omitCtxKeys = (props) => omit(props,
|
|
72
|
+
const omitCtxKeys = (props) => omit(props, CONTEXT_KEYS_SET);
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/Col/styled.ts
|
|
@@ -103,11 +103,6 @@ const spacingStyles$1 = (type, param, rootSize) => {
|
|
|
103
103
|
${`${type}: ${value(param / 2, rootSize)}`};
|
|
104
104
|
`;
|
|
105
105
|
};
|
|
106
|
-
/**
|
|
107
|
-
* Main responsive style block for Col. When the column is visible, applies
|
|
108
|
-
* width, padding, margin, and extra CSS. When hidden (size === 0), moves
|
|
109
|
-
* the element off-screen with fixed positioning.
|
|
110
|
-
*/
|
|
111
106
|
const styles$2 = ({ theme, css, rootSize }) => {
|
|
112
107
|
const { size, columns, gap, padding, extraStyles, RNparentWidth } = theme;
|
|
113
108
|
if (isVisible(size)) return css`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/coolgrid",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"typecheck": "tsc --noEmit"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@vitus-labs/core": "^2.
|
|
65
|
-
"@vitus-labs/unistyle": "^2.
|
|
64
|
+
"@vitus-labs/core": "^2.7.0",
|
|
65
|
+
"@vitus-labs/unistyle": "^2.7.0",
|
|
66
66
|
"react": ">= 19",
|
|
67
67
|
"react-native": ">= 0.76"
|
|
68
68
|
},
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@vitus-labs/core": "workspace:*",
|
|
76
|
-
"@vitus-labs/tools-rolldown": "2.
|
|
77
|
-
"@vitus-labs/tools-storybook": "2.
|
|
78
|
-
"@vitus-labs/tools-typescript": "2.
|
|
76
|
+
"@vitus-labs/tools-rolldown": "2.5.0",
|
|
77
|
+
"@vitus-labs/tools-storybook": "2.5.0",
|
|
78
|
+
"@vitus-labs/tools-typescript": "2.5.0",
|
|
79
79
|
"@vitus-labs/unistyle": "workspace:*",
|
|
80
80
|
"react-native": ">=0.84.1"
|
|
81
81
|
}
|