@hi-ui/grid 4.0.5 → 4.0.7
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/CHANGELOG.md +28 -0
- package/lib/cjs/Grid.js +49 -84
- package/lib/cjs/context.js +0 -6
- package/lib/cjs/index.js +0 -3
- package/lib/cjs/styles/index.scss.js +2 -5
- package/lib/esm/Grid.js +47 -72
- package/lib/esm/context.js +0 -4
- package/lib/esm/index.js +1 -2
- package/lib/esm/styles/index.scss.js +2 -4
- package/lib/types/Grid.d.ts +1 -4
- package/package.json +8 -10
- package/LICENSE +0 -21
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @hi-ui/grid
|
|
2
|
+
|
|
3
|
+
## 4.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: 修复 rollup3 打包 cjs 模块问题
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @hi-ui/env@4.0.3
|
|
10
|
+
- @hi-ui/core@4.0.7
|
|
11
|
+
- @hi-ui/classname@4.0.3
|
|
12
|
+
- @hi-ui/type-assertion@4.0.3
|
|
13
|
+
|
|
14
|
+
## 4.0.6
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#2672](https://github.com/XiaoMi/hiui/pull/2672) [`1ebe27830`](https://github.com/XiaoMi/hiui/commit/1ebe2783098b3a8cd980bd10076d67635463800e) Thanks [@zyprepare](https://github.com/zyprepare)! - build: 升级到 rollup3,重新构建发布组件
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`1ebe27830`](https://github.com/XiaoMi/hiui/commit/1ebe2783098b3a8cd980bd10076d67635463800e)]:
|
|
21
|
+
- @hi-ui/core@4.0.6
|
|
22
|
+
- @hi-ui/classname@4.0.2
|
|
23
|
+
- @hi-ui/env@4.0.2
|
|
24
|
+
- @hi-ui/type-assertion@4.0.2
|
|
25
|
+
|
|
26
|
+
## 4.0.5
|
|
27
|
+
|
|
28
|
+
更新版本为 4.0.5
|
package/lib/cjs/Grid.js
CHANGED
|
@@ -10,76 +10,59 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
-
|
|
14
13
|
Object.defineProperty(exports, '__esModule', {
|
|
15
14
|
value: true
|
|
16
15
|
});
|
|
17
|
-
|
|
18
16
|
var tslib = require('tslib');
|
|
19
|
-
|
|
20
17
|
var React = require('react');
|
|
21
|
-
|
|
22
18
|
var classname = require('@hi-ui/classname');
|
|
23
|
-
|
|
24
19
|
var env = require('@hi-ui/env');
|
|
25
|
-
|
|
26
20
|
var context = require('./context.js');
|
|
27
|
-
|
|
28
21
|
var typeAssertion = require('@hi-ui/type-assertion');
|
|
29
|
-
|
|
30
|
-
function _interopDefaultLegacy(e) {
|
|
22
|
+
function _interopDefaultCompat(e) {
|
|
31
23
|
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
32
24
|
'default': e
|
|
33
25
|
};
|
|
34
26
|
}
|
|
35
|
-
|
|
36
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
37
|
-
|
|
27
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
38
28
|
var rowPrefix = classname.getPrefixCls('grid-row');
|
|
39
29
|
var gutterNameVar = classname.getPrefixStyleVar('grid-row-gutter');
|
|
40
30
|
var columnsNameVar = classname.getPrefixStyleVar('grid-row-columns');
|
|
41
|
-
var gapNameVar = classname.getPrefixStyleVar('grid-row-gap');
|
|
42
|
-
|
|
43
|
-
var DEFAULT_ROW_GAP = 16;
|
|
44
|
-
|
|
31
|
+
var gapNameVar = classname.getPrefixStyleVar('grid-row-gap');
|
|
32
|
+
// Row 与 Row 默认间距
|
|
33
|
+
var DEFAULT_ROW_GAP = 16;
|
|
34
|
+
// Row 内每项 Col 默认间距
|
|
45
35
|
var DEFAULT_GUTTER_GAP = 16;
|
|
46
36
|
/**
|
|
47
|
-
*
|
|
37
|
+
* 栅格
|
|
48
38
|
*/
|
|
49
|
-
|
|
50
39
|
var Row = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
51
40
|
var _Object$assign;
|
|
52
|
-
|
|
53
41
|
var _a$prefixCls = _a.prefixCls,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
42
|
+
prefixCls = _a$prefixCls === void 0 ? rowPrefix : _a$prefixCls,
|
|
43
|
+
className = _a.className,
|
|
44
|
+
children = _a.children,
|
|
45
|
+
styleProp = _a.style,
|
|
46
|
+
justifyContent = _a.justify,
|
|
47
|
+
_a$columns = _a.columns,
|
|
48
|
+
columns = _a$columns === void 0 ? 24 : _a$columns,
|
|
49
|
+
_a$rowGap = _a.rowGap,
|
|
50
|
+
rowGap = _a$rowGap === void 0 ? DEFAULT_ROW_GAP : _a$rowGap,
|
|
51
|
+
_a$gutter = _a.gutter,
|
|
52
|
+
gutterProp = _a$gutter === void 0 ? false : _a$gutter,
|
|
53
|
+
rest = tslib.__rest(_a, ["prefixCls", "className", "children", "style", "justify", "columns", "rowGap", "gutter"]);
|
|
67
54
|
var gutter = React.useMemo(function () {
|
|
68
55
|
if (typeof gutterProp === 'boolean') {
|
|
69
56
|
return gutterProp ? DEFAULT_GUTTER_GAP : 0;
|
|
70
57
|
}
|
|
71
|
-
|
|
72
58
|
if (typeAssertion.isNumeric(gutterProp)) {
|
|
73
59
|
var gap = Number(gutterProp);
|
|
74
|
-
|
|
75
60
|
if (gap < 0) {
|
|
76
61
|
console.info('Warning: The gutter should be a positive number.');
|
|
77
62
|
gap = DEFAULT_GUTTER_GAP;
|
|
78
63
|
}
|
|
79
|
-
|
|
80
64
|
return gap;
|
|
81
65
|
}
|
|
82
|
-
|
|
83
66
|
return 0;
|
|
84
67
|
}, [gutterProp]);
|
|
85
68
|
var justifyContentStyle = calcResponsiveGrid({
|
|
@@ -108,43 +91,33 @@ var Row = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
108
91
|
style: style
|
|
109
92
|
}, rest), children));
|
|
110
93
|
});
|
|
111
|
-
|
|
112
94
|
if (env.__DEV__) {
|
|
113
95
|
Row.displayName = 'Row';
|
|
114
96
|
}
|
|
115
|
-
|
|
116
|
-
|
|
97
|
+
var colPrefix = classname.getPrefixCls('grid-col');
|
|
98
|
+
// const spanNameVar = getPrefixStyleVar('grid-col-span')
|
|
117
99
|
// const offsetNameVar = getPrefixStyleVar('grid-col-offset')
|
|
118
|
-
|
|
119
100
|
var getGridStyleVar = function getGridStyleVar(prop, size) {
|
|
120
101
|
if (size) {
|
|
121
102
|
return classname.getPrefixStyleVar('grid-' + prop + '-' + size);
|
|
122
103
|
}
|
|
123
|
-
|
|
124
104
|
return classname.getPrefixStyleVar('grid-' + prop);
|
|
125
105
|
};
|
|
126
|
-
/**
|
|
127
|
-
* TODO: What is Grid Col
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
106
|
var Col = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
132
107
|
var _a$prefixCls2 = _a.prefixCls,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
108
|
+
prefixCls = _a$prefixCls2 === void 0 ? colPrefix : _a$prefixCls2,
|
|
109
|
+
className = _a.className,
|
|
110
|
+
children = _a.children,
|
|
111
|
+
styleProp = _a.style,
|
|
112
|
+
spanProp = _a.span,
|
|
113
|
+
_a$offset = _a.offset,
|
|
114
|
+
offsetProp = _a$offset === void 0 ? 0 : _a$offset,
|
|
115
|
+
justifyContent = _a.justify,
|
|
116
|
+
order = _a.order,
|
|
117
|
+
rest = tslib.__rest(_a, ["prefixCls", "className", "children", "style", "span", "offset", "justify", "order"]);
|
|
144
118
|
var _useGridContext = context.useGridContext(),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
119
|
+
_useGridContext$colum = _useGridContext.columns,
|
|
120
|
+
columns = _useGridContext$colum === void 0 ? 24 : _useGridContext$colum;
|
|
148
121
|
var spanStyle = calcResponsiveGrid({
|
|
149
122
|
name: 'col-span',
|
|
150
123
|
value: spanProp,
|
|
@@ -186,11 +159,13 @@ var Col = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
186
159
|
});
|
|
187
160
|
var style = Object.assign(justifyContent ? Object.assign(Object.assign(Object.assign({}, styleProp), {
|
|
188
161
|
display: 'flex'
|
|
189
|
-
}), justifyContentStyle) : Object.assign({}, styleProp), spanStyle, offsetStyle, orderStyle
|
|
162
|
+
}), justifyContentStyle) : Object.assign({}, styleProp), spanStyle, offsetStyle, orderStyle
|
|
163
|
+
// {
|
|
190
164
|
// [spanNameVar]: span === null ? 'unset' : `calc(${span} / ${columns} * 100%)`,
|
|
191
165
|
// [offsetNameVar]: `calc(${offset} / ${columns} * 100%)`,
|
|
192
166
|
// }
|
|
193
167
|
);
|
|
168
|
+
|
|
194
169
|
var cls = classname.cx(prefixCls, className);
|
|
195
170
|
return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
|
|
196
171
|
ref: ref,
|
|
@@ -198,43 +173,36 @@ var Col = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
198
173
|
style: style
|
|
199
174
|
}, rest), children);
|
|
200
175
|
});
|
|
201
|
-
|
|
202
176
|
if (env.__DEV__) {
|
|
203
177
|
Col.displayName = 'Col';
|
|
204
178
|
}
|
|
205
|
-
|
|
206
179
|
var setGridSpan = function setGridSpan(value, min, max, propName) {
|
|
207
180
|
var nextValue = Number(value);
|
|
208
|
-
|
|
209
181
|
if (env.__DEV__) {
|
|
210
182
|
env.invariant(nextValue >= min && nextValue <= max, "Please set " + propName + " in the range [" + min + ", " + max + "] When using Grid component.");
|
|
211
183
|
}
|
|
212
|
-
|
|
213
184
|
if (nextValue < 0) nextValue = 0;
|
|
214
185
|
if (nextValue > max) nextValue = max;
|
|
215
186
|
return nextValue;
|
|
216
187
|
};
|
|
217
|
-
|
|
218
188
|
var GRID_SIZE_ARRAY = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
219
|
-
|
|
220
189
|
function calcResponsiveGrid(_ref) {
|
|
221
190
|
var value = _ref.value,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
191
|
+
defaultValue = _ref.defaultValue,
|
|
192
|
+
allowSet = _ref.allowSet,
|
|
193
|
+
setValue = _ref.setValue,
|
|
194
|
+
name = _ref.name,
|
|
195
|
+
noneCallback = _ref.noneCallback;
|
|
227
196
|
var style = {};
|
|
228
|
-
|
|
229
197
|
if (typeAssertion.isObject(value)) {
|
|
230
198
|
var prevSpan;
|
|
231
199
|
GRID_SIZE_ARRAY.forEach(function (key) {
|
|
232
|
-
var varName = getGridStyleVar(name, key);
|
|
233
|
-
|
|
234
|
-
var sizeValue = value[key];
|
|
235
|
-
|
|
236
|
-
style[varName] = allowSet(sizeValue) ? setValue(sizeValue) : prevSpan;
|
|
237
|
-
|
|
200
|
+
var varName = getGridStyleVar(name, key);
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
var sizeValue = value[key];
|
|
203
|
+
// @ts-ignore
|
|
204
|
+
style[varName] = allowSet(sizeValue) ? setValue(sizeValue) : prevSpan;
|
|
205
|
+
// @ts-ignore
|
|
238
206
|
prevSpan = style[varName];
|
|
239
207
|
});
|
|
240
208
|
} else {
|
|
@@ -247,14 +215,11 @@ function calcResponsiveGrid(_ref) {
|
|
|
247
215
|
value = defaultValue;
|
|
248
216
|
}
|
|
249
217
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
218
|
+
var varName = getGridStyleVar(name);
|
|
219
|
+
// @ts-ignore
|
|
253
220
|
style[varName] = value;
|
|
254
221
|
}
|
|
255
|
-
|
|
256
222
|
return style;
|
|
257
223
|
}
|
|
258
|
-
|
|
259
224
|
exports.Col = Col;
|
|
260
225
|
exports.Row = Row;
|
package/lib/cjs/context.js
CHANGED
|
@@ -12,21 +12,15 @@
|
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
|
-
|
|
16
15
|
var React = require('react');
|
|
17
|
-
|
|
18
16
|
var gridContext = /*#__PURE__*/React.createContext({});
|
|
19
17
|
var GridProvider = gridContext.Provider;
|
|
20
|
-
|
|
21
18
|
var useGridContext = function useGridContext() {
|
|
22
19
|
var context = React.useContext(gridContext);
|
|
23
|
-
|
|
24
20
|
if (!context) {
|
|
25
21
|
throw new Error('The GridContext context is not defined, Maybe it should be wrapped in Row.');
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
return context;
|
|
29
24
|
};
|
|
30
|
-
|
|
31
25
|
exports.GridProvider = GridProvider;
|
|
32
26
|
exports.useGridContext = useGridContext;
|
package/lib/cjs/index.js
CHANGED
|
@@ -12,10 +12,7 @@
|
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
|
-
var css_248z = ".hi-v4-grid-row {position: relative;-webkit-box-sizing: border-box;box-sizing: border-box;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;-ms-flex-wrap: wrap;flex-wrap: wrap;row-gap: var(--hi-v4-grid-row-gap);margin-left: calc(-1 * var(--hi-v4-grid-row-gutter) / 2);margin-right: calc(-1 * var(--hi-v4-grid-row-gutter) / 2);-webkit-box-pack: var(--hi-v4-grid-row-justify);-ms-flex-pack: var(--hi-v4-grid-row-justify);justify-content: var(--hi-v4-grid-row-justify);
|
|
16
|
-
|
|
17
|
-
var __styleInject__ = require('inject-head-style')["default"];
|
|
18
|
-
|
|
15
|
+
var css_248z = ".hi-v4-grid-row {position: relative;-webkit-box-sizing: border-box;box-sizing: border-box;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;-ms-flex-wrap: wrap;flex-wrap: wrap;row-gap: var(--hi-v4-grid-row-gap);margin-left: calc(-1 * var(--hi-v4-grid-row-gutter) / 2);margin-right: calc(-1 * var(--hi-v4-grid-row-gutter) / 2);-webkit-box-pack: var(--hi-v4-grid-row-justify);-ms-flex-pack: var(--hi-v4-grid-row-justify);justify-content: var(--hi-v4-grid-row-justify);}.hi-v4-grid-row + .hi-v4-grid-row {margin-top: var(--hi-v4-grid-row-gap);}.hi-v4-grid-col {-webkit-box-sizing: border-box;box-sizing: border-box;-webkit-box-flex: 0;-ms-flex-positive: 0;flex-grow: 0;-ms-flex-negative: 0;flex-shrink: 0;min-width: 1px;padding-left: calc(var(--hi-v4-grid-row-gutter) / 2);padding-right: calc(var(--hi-v4-grid-row-gutter) / 2);-ms-flex-preferred-size: calc(var(--hi-v4-grid-col-span) / var(--hi-v4-grid-row-columns) * 100%);flex-basis: calc(var(--hi-v4-grid-col-span) / var(--hi-v4-grid-row-columns) * 100%);max-width: calc(var(--hi-v4-grid-col-span) / var(--hi-v4-grid-row-columns) * 100%);-webkit-margin-start: calc(var(--hi-v4-grid-col-offset) / var(--hi-v4-grid-row-columns) * 100%);margin-inline-start: calc(var(--hi-v4-grid-col-offset) / var(--hi-v4-grid-row-columns) * 100%);-webkit-box-ordinal-group: NaN;-ms-flex-order: var(--hi-v4-grid-col-order);order: var(--hi-v4-grid-col-order);-webkit-box-pack: var(--hi-v4-grid-col-justify);-ms-flex-pack: var(--hi-v4-grid-col-justify);justify-content: var(--hi-v4-grid-col-justify);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-xs);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-xs);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-xs);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-xs);}.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-xs);}@media only screen and (min-width: 576px) {.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-sm);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-sm);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-sm);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-sm);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-sm);}}@media only screen and (min-width: 768px) {.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-md);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-md);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-md);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-md);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-md);}}@media only screen and (min-width: 992px) {.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-lg);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-lg);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-lg);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-lg);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-lg);}}@media only screen and (min-width: 1200px) {.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-xl);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-xl);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-xl);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-xl);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-xl);}}";
|
|
16
|
+
var __styleInject__ = require('style-inject')["default"];
|
|
19
17
|
__styleInject__(css_248z);
|
|
20
|
-
|
|
21
18
|
exports["default"] = css_248z;
|
package/lib/esm/Grid.js
CHANGED
|
@@ -16,48 +16,41 @@ import { isNumeric, isObject, isString } from '@hi-ui/type-assertion';
|
|
|
16
16
|
var rowPrefix = getPrefixCls('grid-row');
|
|
17
17
|
var gutterNameVar = getPrefixStyleVar('grid-row-gutter');
|
|
18
18
|
var columnsNameVar = getPrefixStyleVar('grid-row-columns');
|
|
19
|
-
var gapNameVar = getPrefixStyleVar('grid-row-gap');
|
|
20
|
-
|
|
21
|
-
var DEFAULT_ROW_GAP = 16;
|
|
22
|
-
|
|
19
|
+
var gapNameVar = getPrefixStyleVar('grid-row-gap');
|
|
20
|
+
// Row 与 Row 默认间距
|
|
21
|
+
var DEFAULT_ROW_GAP = 16;
|
|
22
|
+
// Row 内每项 Col 默认间距
|
|
23
23
|
var DEFAULT_GUTTER_GAP = 16;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* 栅格
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
27
|
var Row = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
29
28
|
var _Object$assign;
|
|
30
|
-
|
|
31
29
|
var _a$prefixCls = _a.prefixCls,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
prefixCls = _a$prefixCls === void 0 ? rowPrefix : _a$prefixCls,
|
|
31
|
+
className = _a.className,
|
|
32
|
+
children = _a.children,
|
|
33
|
+
styleProp = _a.style,
|
|
34
|
+
justifyContent = _a.justify,
|
|
35
|
+
_a$columns = _a.columns,
|
|
36
|
+
columns = _a$columns === void 0 ? 24 : _a$columns,
|
|
37
|
+
_a$rowGap = _a.rowGap,
|
|
38
|
+
rowGap = _a$rowGap === void 0 ? DEFAULT_ROW_GAP : _a$rowGap,
|
|
39
|
+
_a$gutter = _a.gutter,
|
|
40
|
+
gutterProp = _a$gutter === void 0 ? false : _a$gutter,
|
|
41
|
+
rest = __rest(_a, ["prefixCls", "className", "children", "style", "justify", "columns", "rowGap", "gutter"]);
|
|
45
42
|
var gutter = useMemo(function () {
|
|
46
43
|
if (typeof gutterProp === 'boolean') {
|
|
47
44
|
return gutterProp ? DEFAULT_GUTTER_GAP : 0;
|
|
48
45
|
}
|
|
49
|
-
|
|
50
46
|
if (isNumeric(gutterProp)) {
|
|
51
47
|
var gap = Number(gutterProp);
|
|
52
|
-
|
|
53
48
|
if (gap < 0) {
|
|
54
49
|
console.info('Warning: The gutter should be a positive number.');
|
|
55
50
|
gap = DEFAULT_GUTTER_GAP;
|
|
56
51
|
}
|
|
57
|
-
|
|
58
52
|
return gap;
|
|
59
53
|
}
|
|
60
|
-
|
|
61
54
|
return 0;
|
|
62
55
|
}, [gutterProp]);
|
|
63
56
|
var justifyContentStyle = calcResponsiveGrid({
|
|
@@ -86,43 +79,33 @@ var Row = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
86
79
|
style: style
|
|
87
80
|
}, rest), children));
|
|
88
81
|
});
|
|
89
|
-
|
|
90
82
|
if (__DEV__) {
|
|
91
83
|
Row.displayName = 'Row';
|
|
92
84
|
}
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
var colPrefix = getPrefixCls('grid-col');
|
|
86
|
+
// const spanNameVar = getPrefixStyleVar('grid-col-span')
|
|
95
87
|
// const offsetNameVar = getPrefixStyleVar('grid-col-offset')
|
|
96
|
-
|
|
97
88
|
var getGridStyleVar = function getGridStyleVar(prop, size) {
|
|
98
89
|
if (size) {
|
|
99
90
|
return getPrefixStyleVar('grid-' + prop + '-' + size);
|
|
100
91
|
}
|
|
101
|
-
|
|
102
92
|
return getPrefixStyleVar('grid-' + prop);
|
|
103
93
|
};
|
|
104
|
-
/**
|
|
105
|
-
* TODO: What is Grid Col
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
94
|
var Col = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
110
95
|
var _a$prefixCls2 = _a.prefixCls,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
96
|
+
prefixCls = _a$prefixCls2 === void 0 ? colPrefix : _a$prefixCls2,
|
|
97
|
+
className = _a.className,
|
|
98
|
+
children = _a.children,
|
|
99
|
+
styleProp = _a.style,
|
|
100
|
+
spanProp = _a.span,
|
|
101
|
+
_a$offset = _a.offset,
|
|
102
|
+
offsetProp = _a$offset === void 0 ? 0 : _a$offset,
|
|
103
|
+
justifyContent = _a.justify,
|
|
104
|
+
order = _a.order,
|
|
105
|
+
rest = __rest(_a, ["prefixCls", "className", "children", "style", "span", "offset", "justify", "order"]);
|
|
122
106
|
var _useGridContext = useGridContext(),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
107
|
+
_useGridContext$colum = _useGridContext.columns,
|
|
108
|
+
columns = _useGridContext$colum === void 0 ? 24 : _useGridContext$colum;
|
|
126
109
|
var spanStyle = calcResponsiveGrid({
|
|
127
110
|
name: 'col-span',
|
|
128
111
|
value: spanProp,
|
|
@@ -164,11 +147,13 @@ var Col = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
164
147
|
});
|
|
165
148
|
var style = Object.assign(justifyContent ? Object.assign(Object.assign(Object.assign({}, styleProp), {
|
|
166
149
|
display: 'flex'
|
|
167
|
-
}), justifyContentStyle) : Object.assign({}, styleProp), spanStyle, offsetStyle, orderStyle
|
|
150
|
+
}), justifyContentStyle) : Object.assign({}, styleProp), spanStyle, offsetStyle, orderStyle
|
|
151
|
+
// {
|
|
168
152
|
// [spanNameVar]: span === null ? 'unset' : `calc(${span} / ${columns} * 100%)`,
|
|
169
153
|
// [offsetNameVar]: `calc(${offset} / ${columns} * 100%)`,
|
|
170
154
|
// }
|
|
171
155
|
);
|
|
156
|
+
|
|
172
157
|
var cls = cx(prefixCls, className);
|
|
173
158
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
174
159
|
ref: ref,
|
|
@@ -176,43 +161,36 @@ var Col = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
176
161
|
style: style
|
|
177
162
|
}, rest), children);
|
|
178
163
|
});
|
|
179
|
-
|
|
180
164
|
if (__DEV__) {
|
|
181
165
|
Col.displayName = 'Col';
|
|
182
166
|
}
|
|
183
|
-
|
|
184
167
|
var setGridSpan = function setGridSpan(value, min, max, propName) {
|
|
185
168
|
var nextValue = Number(value);
|
|
186
|
-
|
|
187
169
|
if (__DEV__) {
|
|
188
170
|
invariant(nextValue >= min && nextValue <= max, "Please set " + propName + " in the range [" + min + ", " + max + "] When using Grid component.");
|
|
189
171
|
}
|
|
190
|
-
|
|
191
172
|
if (nextValue < 0) nextValue = 0;
|
|
192
173
|
if (nextValue > max) nextValue = max;
|
|
193
174
|
return nextValue;
|
|
194
175
|
};
|
|
195
|
-
|
|
196
176
|
var GRID_SIZE_ARRAY = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
197
|
-
|
|
198
177
|
function calcResponsiveGrid(_ref) {
|
|
199
178
|
var value = _ref.value,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
179
|
+
defaultValue = _ref.defaultValue,
|
|
180
|
+
allowSet = _ref.allowSet,
|
|
181
|
+
setValue = _ref.setValue,
|
|
182
|
+
name = _ref.name,
|
|
183
|
+
noneCallback = _ref.noneCallback;
|
|
205
184
|
var style = {};
|
|
206
|
-
|
|
207
185
|
if (isObject(value)) {
|
|
208
186
|
var prevSpan;
|
|
209
187
|
GRID_SIZE_ARRAY.forEach(function (key) {
|
|
210
|
-
var varName = getGridStyleVar(name, key);
|
|
211
|
-
|
|
212
|
-
var sizeValue = value[key];
|
|
213
|
-
|
|
214
|
-
style[varName] = allowSet(sizeValue) ? setValue(sizeValue) : prevSpan;
|
|
215
|
-
|
|
188
|
+
var varName = getGridStyleVar(name, key);
|
|
189
|
+
// @ts-ignore
|
|
190
|
+
var sizeValue = value[key];
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
style[varName] = allowSet(sizeValue) ? setValue(sizeValue) : prevSpan;
|
|
193
|
+
// @ts-ignore
|
|
216
194
|
prevSpan = style[varName];
|
|
217
195
|
});
|
|
218
196
|
} else {
|
|
@@ -225,13 +203,10 @@ function calcResponsiveGrid(_ref) {
|
|
|
225
203
|
value = defaultValue;
|
|
226
204
|
}
|
|
227
205
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
206
|
+
var varName = getGridStyleVar(name);
|
|
207
|
+
// @ts-ignore
|
|
231
208
|
style[varName] = value;
|
|
232
209
|
}
|
|
233
|
-
|
|
234
210
|
return style;
|
|
235
211
|
}
|
|
236
|
-
|
|
237
212
|
export { Col, Row };
|
package/lib/esm/context.js
CHANGED
|
@@ -10,15 +10,11 @@
|
|
|
10
10
|
import { useContext, createContext } from 'react';
|
|
11
11
|
var gridContext = /*#__PURE__*/createContext({});
|
|
12
12
|
var GridProvider = gridContext.Provider;
|
|
13
|
-
|
|
14
13
|
var useGridContext = function useGridContext() {
|
|
15
14
|
var context = useContext(gridContext);
|
|
16
|
-
|
|
17
15
|
if (!context) {
|
|
18
16
|
throw new Error('The GridContext context is not defined, Maybe it should be wrapped in Row.');
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
return context;
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
export { GridProvider, useGridContext };
|
package/lib/esm/index.js
CHANGED
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
import __styleInject__ from 'inject
|
|
11
|
-
var css_248z = ".hi-v4-grid-row {position: relative;-webkit-box-sizing: border-box;box-sizing: border-box;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;-ms-flex-wrap: wrap;flex-wrap: wrap;row-gap: var(--hi-v4-grid-row-gap);margin-left: calc(-1 * var(--hi-v4-grid-row-gutter) / 2);margin-right: calc(-1 * var(--hi-v4-grid-row-gutter) / 2);-webkit-box-pack: var(--hi-v4-grid-row-justify);-ms-flex-pack: var(--hi-v4-grid-row-justify);justify-content: var(--hi-v4-grid-row-justify);
|
|
12
|
-
|
|
10
|
+
import __styleInject__ from 'style-inject';
|
|
11
|
+
var css_248z = ".hi-v4-grid-row {position: relative;-webkit-box-sizing: border-box;box-sizing: border-box;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: horizontal;-webkit-box-direction: normal;-ms-flex-direction: row;flex-direction: row;-ms-flex-wrap: wrap;flex-wrap: wrap;row-gap: var(--hi-v4-grid-row-gap);margin-left: calc(-1 * var(--hi-v4-grid-row-gutter) / 2);margin-right: calc(-1 * var(--hi-v4-grid-row-gutter) / 2);-webkit-box-pack: var(--hi-v4-grid-row-justify);-ms-flex-pack: var(--hi-v4-grid-row-justify);justify-content: var(--hi-v4-grid-row-justify);}.hi-v4-grid-row + .hi-v4-grid-row {margin-top: var(--hi-v4-grid-row-gap);}.hi-v4-grid-col {-webkit-box-sizing: border-box;box-sizing: border-box;-webkit-box-flex: 0;-ms-flex-positive: 0;flex-grow: 0;-ms-flex-negative: 0;flex-shrink: 0;min-width: 1px;padding-left: calc(var(--hi-v4-grid-row-gutter) / 2);padding-right: calc(var(--hi-v4-grid-row-gutter) / 2);-ms-flex-preferred-size: calc(var(--hi-v4-grid-col-span) / var(--hi-v4-grid-row-columns) * 100%);flex-basis: calc(var(--hi-v4-grid-col-span) / var(--hi-v4-grid-row-columns) * 100%);max-width: calc(var(--hi-v4-grid-col-span) / var(--hi-v4-grid-row-columns) * 100%);-webkit-margin-start: calc(var(--hi-v4-grid-col-offset) / var(--hi-v4-grid-row-columns) * 100%);margin-inline-start: calc(var(--hi-v4-grid-col-offset) / var(--hi-v4-grid-row-columns) * 100%);-webkit-box-ordinal-group: NaN;-ms-flex-order: var(--hi-v4-grid-col-order);order: var(--hi-v4-grid-col-order);-webkit-box-pack: var(--hi-v4-grid-col-justify);-ms-flex-pack: var(--hi-v4-grid-col-justify);justify-content: var(--hi-v4-grid-col-justify);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-xs);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-xs);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-xs);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-xs);}.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-xs);}@media only screen and (min-width: 576px) {.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-sm);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-sm);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-sm);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-sm);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-sm);}}@media only screen and (min-width: 768px) {.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-md);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-md);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-md);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-md);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-md);}}@media only screen and (min-width: 992px) {.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-lg);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-lg);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-lg);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-lg);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-lg);}}@media only screen and (min-width: 1200px) {.hi-v4-grid-row {--hi-v4-grid-row-justify: var(--hi-v4-grid-row-justify-xl);}.hi-v4-grid-col {--hi-v4-grid-col-span: var(--hi-v4-grid-col-span-xl);--hi-v4-grid-col-offset: var(--hi-v4-grid-col-offset-xl);--hi-v4-grid-col-order: var(--hi-v4-grid-col-order-xl);--hi-v4-grid-col-justify: var(--hi-v4-grid-col-justify-xl);}}";
|
|
13
12
|
__styleInject__(css_248z);
|
|
14
|
-
|
|
15
13
|
export { css_248z as default };
|
package/lib/types/Grid.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { HiBaseHTMLProps } from '@hi-ui/core';
|
|
3
3
|
import { GridJustifyEnum, GridResponsiveSize } from './types';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 栅格
|
|
6
6
|
*/
|
|
7
7
|
export declare const Row: React.ForwardRefExoticComponent<RowProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
8
8
|
export interface RowProps extends HiBaseHTMLProps<'div'> {
|
|
@@ -23,9 +23,6 @@ export interface RowProps extends HiBaseHTMLProps<'div'> {
|
|
|
23
23
|
*/
|
|
24
24
|
rowGap?: number;
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
* TODO: What is Grid Col
|
|
28
|
-
*/
|
|
29
26
|
export declare const Col: React.ForwardRefExoticComponent<ColProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
30
27
|
export interface ColProps extends HiBaseHTMLProps<'div'> {
|
|
31
28
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/grid",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
|
@@ -43,21 +43,19 @@
|
|
|
43
43
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@hi-ui/classname": "^4.0.
|
|
47
|
-
"@hi-ui/env": "^4.0.
|
|
48
|
-
"@hi-ui/type-assertion": "^4.0.
|
|
46
|
+
"@hi-ui/classname": "^4.0.3",
|
|
47
|
+
"@hi-ui/env": "^4.0.3",
|
|
48
|
+
"@hi-ui/type-assertion": "^4.0.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@hi-ui/core": ">=4.0.
|
|
51
|
+
"@hi-ui/core": ">=4.0.7",
|
|
52
52
|
"react": ">=16.8.6",
|
|
53
53
|
"react-dom": ">=16.8.6"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@hi-ui/core": "^4.0.
|
|
57
|
-
"@hi-ui/core-css": "^4.
|
|
58
|
-
"@hi-ui/hi-build": "^4.0.1",
|
|
56
|
+
"@hi-ui/core": "^4.0.7",
|
|
57
|
+
"@hi-ui/core-css": "^4.1.4",
|
|
59
58
|
"react": "^17.0.1",
|
|
60
59
|
"react-dom": "^17.0.1"
|
|
61
|
-
}
|
|
62
|
-
"gitHead": "686243832edd8a2d114ac385d0910838233c1e85"
|
|
60
|
+
}
|
|
63
61
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Xiaomi
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|