@kdcloudjs/kdesign 1.7.28 → 1.7.29
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/kdesign-complete.less +22 -5
- package/dist/kdesign.css +40 -4
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +108 -89
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +2 -2
- package/dist/kdesign.min.js +6 -6
- package/dist/kdesign.min.js.map +1 -1
- package/es/grid/col.d.ts +1 -1
- package/es/grid/col.js +46 -31
- package/es/grid/row.d.ts +9 -1
- package/es/grid/row.js +20 -15
- package/es/select/style/index.css +39 -3
- package/es/select/style/index.less +15 -3
- package/es/select/style/mixin.less +6 -2
- package/lib/grid/col.d.ts +1 -1
- package/lib/grid/col.js +48 -33
- package/lib/grid/row.d.ts +9 -1
- package/lib/grid/row.js +24 -18
- package/lib/select/style/index.css +39 -3
- package/lib/select/style/index.less +15 -3
- package/lib/select/style/mixin.less +6 -2
- package/package.json +1 -1
package/es/grid/col.d.ts
CHANGED
package/es/grid/col.js
CHANGED
|
@@ -1,35 +1,52 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
2
3
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
3
|
-
|
|
4
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
5
|
+
var t = {};
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
7
|
+
if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { useContext } from 'react';
|
|
4
13
|
import classNames from 'classnames';
|
|
5
14
|
import { getCompProps } from '../_utils';
|
|
6
15
|
import { ConfigContext } from '../config-provider';
|
|
7
16
|
import { testBrowserType } from '../_utils/testBrowserType';
|
|
17
|
+
import { GapContext } from './row';
|
|
8
18
|
var Col = function Col(props) {
|
|
9
19
|
var _React$useContext = React.useContext(ConfigContext),
|
|
10
20
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
11
21
|
pkgPrefixCls = _React$useContext.prefixCls,
|
|
12
22
|
userDefaultProps = _React$useContext.compDefaultProps;
|
|
13
23
|
// 属性需要合并一遍用户定义的默认属性
|
|
14
|
-
var
|
|
15
|
-
xs =
|
|
16
|
-
sm =
|
|
17
|
-
md =
|
|
18
|
-
lg =
|
|
19
|
-
xl =
|
|
20
|
-
flex =
|
|
21
|
-
span =
|
|
22
|
-
pull =
|
|
23
|
-
push =
|
|
24
|
-
style =
|
|
25
|
-
order =
|
|
26
|
-
offset =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
var _a = getCompProps('Col', userDefaultProps, props),
|
|
25
|
+
xs = _a.xs,
|
|
26
|
+
sm = _a.sm,
|
|
27
|
+
md = _a.md,
|
|
28
|
+
lg = _a.lg,
|
|
29
|
+
xl = _a.xl,
|
|
30
|
+
flex = _a.flex,
|
|
31
|
+
span = _a.span,
|
|
32
|
+
pull = _a.pull,
|
|
33
|
+
push = _a.push,
|
|
34
|
+
style = _a.style,
|
|
35
|
+
order = _a.order,
|
|
36
|
+
offset = _a.offset,
|
|
37
|
+
children = _a.children,
|
|
38
|
+
className = _a.className,
|
|
39
|
+
customPrefixcls = _a.prefixCls,
|
|
40
|
+
others = __rest(_a, ["xs", "sm", "md", "lg", "xl", "flex", "span", "pull", "push", "style", "order", "offset", "children", "className", "prefixCls"]);
|
|
41
|
+
var rowGroup = useContext(GapContext);
|
|
42
|
+
var mergedWinWidth = rowGroup.winWidth;
|
|
43
|
+
var gap = rowGroup.gap;
|
|
31
44
|
// 浏览器名称
|
|
32
|
-
var
|
|
45
|
+
var isSogouOrIE = testBrowserType(/^sogou/i, 0) || /Trident|MSIE/.test(navigator.userAgent);
|
|
46
|
+
var colGapStyle = {
|
|
47
|
+
padding: "0 ".concat(gap.h / 2, "px")
|
|
48
|
+
};
|
|
49
|
+
if (isSogouOrIE && gap.v) colGapStyle.marginBottom = gap.v;
|
|
33
50
|
// className前缀
|
|
34
51
|
var prefixCls = getPrefixCls(pkgPrefixCls, 'col', customPrefixcls);
|
|
35
52
|
var columns = 24;
|
|
@@ -40,23 +57,23 @@ var Col = function Col(props) {
|
|
|
40
57
|
offset: offset,
|
|
41
58
|
order: order
|
|
42
59
|
};
|
|
43
|
-
if (xs &&
|
|
60
|
+
if (xs && mergedWinWidth > 0) {
|
|
44
61
|
if (xs.constructor === Number) base.span = xs;
|
|
45
62
|
if (xs.constructor === Object) base = _extends(_extends({}, base), xs);
|
|
46
63
|
}
|
|
47
|
-
if (sm &&
|
|
64
|
+
if (sm && mergedWinWidth >= 600) {
|
|
48
65
|
if (sm.constructor === Number) base.span = sm;
|
|
49
66
|
if (sm.constructor === Object) base = _extends(_extends({}, base), sm);
|
|
50
67
|
}
|
|
51
|
-
if (md &&
|
|
68
|
+
if (md && mergedWinWidth >= 1024) {
|
|
52
69
|
if (md.constructor === Number) base.span = md;
|
|
53
70
|
if (md.constructor === Object) base = _extends(_extends({}, base), md);
|
|
54
71
|
}
|
|
55
|
-
if (lg &&
|
|
72
|
+
if (lg && mergedWinWidth >= 1280) {
|
|
56
73
|
if (lg.constructor === Number) base.span = lg;
|
|
57
74
|
if (lg.constructor === Object) base = _extends(_extends({}, base), lg);
|
|
58
75
|
}
|
|
59
|
-
if (xl &&
|
|
76
|
+
if (xl && mergedWinWidth >= 1920) {
|
|
60
77
|
if (xl.constructor === Number) base.span = xl;
|
|
61
78
|
if (xl.constructor === Object) base = _extends(_extends({}, base), xl);
|
|
62
79
|
}
|
|
@@ -76,20 +93,18 @@ var Col = function Col(props) {
|
|
|
76
93
|
}
|
|
77
94
|
}
|
|
78
95
|
}
|
|
79
|
-
var styleString = _extends({
|
|
96
|
+
var styleString = _extends(_extends({
|
|
80
97
|
flex: flexstr,
|
|
81
98
|
maxWidth: width,
|
|
82
99
|
order: base.order,
|
|
83
100
|
left: base.push && base.push / columns * 100 + '%',
|
|
84
101
|
right: base.pull && base.pull / columns * 100 + '%',
|
|
85
102
|
marginLeft: base.offset && base.offset / columns * 100 + '%'
|
|
86
|
-
}, style);
|
|
87
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
88
|
-
className: classNames(prefixCls, className,
|
|
89
|
-
'sogou-col': isSogou
|
|
90
|
-
}),
|
|
103
|
+
}, colGapStyle), style);
|
|
104
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
105
|
+
className: classNames(prefixCls, className),
|
|
91
106
|
style: styleString
|
|
92
|
-
}, children);
|
|
107
|
+
}, others), children);
|
|
93
108
|
};
|
|
94
109
|
Col.displayName = 'Col';
|
|
95
110
|
export default Col;
|
package/es/grid/row.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
declare type Align = 'top' | 'middle' | 'bottom' | 'stretch';
|
|
3
3
|
declare type Justify = 'start' | 'end' | 'center' | 'space-around' | 'space-between';
|
|
4
4
|
interface gutterObject {
|
|
@@ -17,5 +17,13 @@ export interface RowProps {
|
|
|
17
17
|
style?: React.CSSProperties;
|
|
18
18
|
gutter?: number | gutterObject | Array<number | gutterObject>;
|
|
19
19
|
}
|
|
20
|
+
export interface GridContext {
|
|
21
|
+
gap: {
|
|
22
|
+
v: number;
|
|
23
|
+
h: number;
|
|
24
|
+
};
|
|
25
|
+
winWidth: number;
|
|
26
|
+
}
|
|
27
|
+
export declare const GapContext: React.Context<GridContext>;
|
|
20
28
|
declare const Row: React.FC<RowProps>;
|
|
21
29
|
export default Row;
|
package/es/grid/row.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
3
|
-
import
|
|
4
|
-
import * as React from 'react';
|
|
3
|
+
import React, { createContext } from 'react';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
5
|
import { getCompProps } from '../_utils';
|
|
7
6
|
import { ConfigContext } from '../config-provider';
|
|
@@ -21,8 +20,14 @@ function getGap(gutter, width) {
|
|
|
21
20
|
if (xl && width >= 1920) gap = xl;
|
|
22
21
|
return gap;
|
|
23
22
|
}
|
|
23
|
+
export var GapContext = /*#__PURE__*/createContext({
|
|
24
|
+
gap: {
|
|
25
|
+
h: 0,
|
|
26
|
+
v: 0
|
|
27
|
+
},
|
|
28
|
+
winWidth: window.innerWidth
|
|
29
|
+
});
|
|
24
30
|
var Row = function Row(props) {
|
|
25
|
-
var _context;
|
|
26
31
|
var _React$useContext = React.useContext(ConfigContext),
|
|
27
32
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
28
33
|
pkgPrefixCls = _React$useContext.prefixCls,
|
|
@@ -38,7 +43,7 @@ var Row = function Row(props) {
|
|
|
38
43
|
justify = _getCompProps.justify,
|
|
39
44
|
customPrefixcls = _getCompProps.prefixCls;
|
|
40
45
|
// 浏览器名称
|
|
41
|
-
var
|
|
46
|
+
var isSogouOrIe = testBrowserType(/^sogou/i, 0) || /Trident|MSIE/.test(navigator.userAgent);
|
|
42
47
|
// className前缀
|
|
43
48
|
var prefixCls = getPrefixCls(pkgPrefixCls, 'row', customPrefixcls);
|
|
44
49
|
var _React$useState = React.useState(window.innerWidth),
|
|
@@ -70,9 +75,10 @@ var Row = function Row(props) {
|
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
var rowStyle = {
|
|
73
|
-
'
|
|
78
|
+
'row-gap': "".concat(gap.v, "px"),
|
|
79
|
+
margin: "0 ".concat(-1 * gap.h, "px")
|
|
74
80
|
};
|
|
75
|
-
if (gap.v) rowStyle['
|
|
81
|
+
if (gap.v && isSogouOrIe) rowStyle['margin-bottom'] = "".concat(-1 * gap.v / 2, "px");
|
|
76
82
|
var toalign = {
|
|
77
83
|
top: 'flex-start',
|
|
78
84
|
middle: 'center',
|
|
@@ -82,22 +88,21 @@ var Row = function Row(props) {
|
|
|
82
88
|
start: 'flex-start',
|
|
83
89
|
end: 'flex-end'
|
|
84
90
|
};
|
|
85
|
-
var styleString = _extends(_extends(_extends({},
|
|
91
|
+
var styleString = _extends(_extends(_extends({}, rowStyle), style), {
|
|
86
92
|
alignItems: toalign[align] || align,
|
|
87
93
|
justifyContent: tojustify[justify] || justify
|
|
88
94
|
});
|
|
89
|
-
return /*#__PURE__*/React.createElement(
|
|
95
|
+
return /*#__PURE__*/React.createElement(GapContext.Provider, {
|
|
96
|
+
value: {
|
|
97
|
+
gap: gap,
|
|
98
|
+
winWidth: winWidth
|
|
99
|
+
}
|
|
100
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
90
101
|
className: classNames(prefixCls, className, {
|
|
91
102
|
nowrap: !wrap
|
|
92
|
-
}, {
|
|
93
|
-
'sogou-row': isSogou
|
|
94
103
|
}),
|
|
95
104
|
style: styleString
|
|
96
|
-
},
|
|
97
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
98
|
-
winWidth: winWidth
|
|
99
|
-
});
|
|
100
|
-
}));
|
|
105
|
+
}, children));
|
|
101
106
|
};
|
|
102
107
|
Row.displayName = 'Row';
|
|
103
108
|
export default Row;
|
|
@@ -280,6 +280,14 @@
|
|
|
280
280
|
.kd-select-icon-clear {
|
|
281
281
|
opacity: 0;
|
|
282
282
|
z-index: 1;
|
|
283
|
+
top: 0;
|
|
284
|
+
bottom: 0;
|
|
285
|
+
display: -webkit-box;
|
|
286
|
+
display: -ms-flexbox;
|
|
287
|
+
display: flex;
|
|
288
|
+
-webkit-box-align: center;
|
|
289
|
+
-ms-flex-align: center;
|
|
290
|
+
align-items: center;
|
|
283
291
|
position: absolute;
|
|
284
292
|
background: #fff;
|
|
285
293
|
-webkit-transition: opacity 0.15s ease;
|
|
@@ -299,6 +307,15 @@
|
|
|
299
307
|
text-overflow: ellipsis;
|
|
300
308
|
right: 28px;
|
|
301
309
|
left: 0;
|
|
310
|
+
top: 0;
|
|
311
|
+
bottom: 0;
|
|
312
|
+
z-index: -1;
|
|
313
|
+
display: -webkit-box;
|
|
314
|
+
display: -ms-flexbox;
|
|
315
|
+
display: flex;
|
|
316
|
+
-webkit-box-align: center;
|
|
317
|
+
-ms-flex-align: center;
|
|
318
|
+
align-items: center;
|
|
302
319
|
}
|
|
303
320
|
.kd-select-borderless {
|
|
304
321
|
border: none;
|
|
@@ -433,18 +450,32 @@
|
|
|
433
450
|
max-height: calc(var(--kd-c-select-sizing-height-small, 24px) * 3 - 10px);
|
|
434
451
|
font-size: var(--kd-c-select-font-size-small, 12px);
|
|
435
452
|
}
|
|
453
|
+
.kd-select-size-small .kd-select-selection-item {
|
|
454
|
+
min-height: calc(var(--kd-c-select-sizing-height-small, 24px) - 4px);
|
|
455
|
+
line-height: calc(var(--kd-c-select-sizing-height-small, 24px) - 4px);
|
|
456
|
+
}
|
|
436
457
|
.kd-select-size-middle {
|
|
437
458
|
min-height: var(--kd-c-select-sizing-height-middle, 30px);
|
|
438
459
|
max-height: calc(var(--kd-c-select-sizing-height-middle, 30px) * 3 - 10px);
|
|
439
460
|
font-size: var(--kd-c-select-font-size-middle, 14px);
|
|
440
461
|
}
|
|
462
|
+
.kd-select-size-middle .kd-select-selection-item {
|
|
463
|
+
min-height: calc(var(--kd-c-select-sizing-height-middle, 30px) - 4px);
|
|
464
|
+
line-height: calc(var(--kd-c-select-sizing-height-middle, 30px) - 4px);
|
|
465
|
+
}
|
|
441
466
|
.kd-select-size-large {
|
|
442
467
|
min-height: var(--kd-c-select-sizing-height-large, 36px);
|
|
443
468
|
max-height: calc(var(--kd-c-select-sizing-height-large, 36px) * 3 - 10px);
|
|
444
469
|
font-size: var(--kd-c-select-font-size-large, 16px);
|
|
445
470
|
}
|
|
471
|
+
.kd-select-size-large .kd-select-selection-item {
|
|
472
|
+
min-height: calc(var(--kd-c-select-sizing-height-large, 36px) - 4px);
|
|
473
|
+
line-height: calc(var(--kd-c-select-sizing-height-large, 36px) - 4px);
|
|
474
|
+
}
|
|
446
475
|
.kd-select-suffix {
|
|
447
476
|
right: 0;
|
|
477
|
+
top: 0;
|
|
478
|
+
bottom: 0;
|
|
448
479
|
position: absolute;
|
|
449
480
|
display: -webkit-box;
|
|
450
481
|
display: -ms-flexbox;
|
|
@@ -467,6 +498,14 @@
|
|
|
467
498
|
right: 28px;
|
|
468
499
|
left: 0;
|
|
469
500
|
height: 100%;
|
|
501
|
+
top: 0;
|
|
502
|
+
bottom: 0;
|
|
503
|
+
display: -webkit-box;
|
|
504
|
+
display: -ms-flexbox;
|
|
505
|
+
display: flex;
|
|
506
|
+
-webkit-box-align: center;
|
|
507
|
+
-ms-flex-align: center;
|
|
508
|
+
align-items: center;
|
|
470
509
|
}
|
|
471
510
|
.kd-select .kd-select-single .kd-select-selection-search-input {
|
|
472
511
|
outline: 0;
|
|
@@ -525,9 +564,6 @@
|
|
|
525
564
|
align-items: center;
|
|
526
565
|
vertical-align: middle;
|
|
527
566
|
max-width: 100%;
|
|
528
|
-
height: 20px;
|
|
529
|
-
line-height: 20px;
|
|
530
|
-
margin: 2px 8px 2px 0;
|
|
531
567
|
cursor: default;
|
|
532
568
|
-webkit-user-select: none;
|
|
533
569
|
-moz-user-select: none;
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
&-clear {
|
|
47
47
|
opacity: 0;
|
|
48
48
|
z-index: 1;
|
|
49
|
+
top: 0;
|
|
50
|
+
bottom: 0;
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
49
53
|
position: absolute;
|
|
50
54
|
background: #fff;
|
|
51
55
|
transition: opacity 0.15s ease;
|
|
@@ -66,6 +70,11 @@
|
|
|
66
70
|
text-overflow: ellipsis;
|
|
67
71
|
right: 28px;
|
|
68
72
|
left: 0;
|
|
73
|
+
top: 0;
|
|
74
|
+
bottom: 0;
|
|
75
|
+
z-index: -1;
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
&-borderless {
|
|
@@ -220,6 +229,8 @@
|
|
|
220
229
|
|
|
221
230
|
&-suffix {
|
|
222
231
|
right: 0;
|
|
232
|
+
top: 0;
|
|
233
|
+
bottom: 0;
|
|
223
234
|
position: absolute;
|
|
224
235
|
display: flex;
|
|
225
236
|
flex: 0;
|
|
@@ -235,6 +246,10 @@
|
|
|
235
246
|
right: 28px;
|
|
236
247
|
left: 0;
|
|
237
248
|
height: 100%;
|
|
249
|
+
top: 0;
|
|
250
|
+
bottom: 0;
|
|
251
|
+
display: flex;
|
|
252
|
+
align-items: center;
|
|
238
253
|
&-input {
|
|
239
254
|
outline: 0;
|
|
240
255
|
border-radius: 0;
|
|
@@ -289,9 +304,6 @@
|
|
|
289
304
|
align-items: center;
|
|
290
305
|
vertical-align: middle;
|
|
291
306
|
max-width: 100%;
|
|
292
|
-
height: 20px;
|
|
293
|
-
line-height: 20px;
|
|
294
|
-
margin: 2px 8px 2px 0;
|
|
295
307
|
cursor: default;
|
|
296
308
|
user-select: none;
|
|
297
309
|
&-small {
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
min-height: @height;
|
|
20
20
|
max-height: calc(@maxHeight * 3 - 10px);
|
|
21
21
|
font-size: @fontSize;
|
|
22
|
+
|
|
23
|
+
.@{select-prefix-cls}-selection-item {
|
|
24
|
+
min-height: calc(@height - 4px);
|
|
25
|
+
line-height: calc(@height - 4px);
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
.over() {
|
|
@@ -52,7 +57,6 @@
|
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
|
|
56
60
|
@keyframes SlideUpIn {
|
|
57
61
|
0% {
|
|
58
62
|
transform: scaleY(0.8);
|
|
@@ -77,4 +81,4 @@
|
|
|
77
81
|
transform-origin: 100% 100%;
|
|
78
82
|
opacity: 0;
|
|
79
83
|
}
|
|
80
|
-
}
|
|
84
|
+
}
|
package/lib/grid/col.d.ts
CHANGED
package/lib/grid/col.js
CHANGED
|
@@ -8,40 +8,57 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
12
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
13
|
-
var
|
|
12
|
+
var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
|
|
13
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
16
|
var _utils = require("../_utils");
|
|
16
17
|
var _configProvider = require("../config-provider");
|
|
17
18
|
var _testBrowserType = require("../_utils/testBrowserType");
|
|
19
|
+
var _row = require("./row");
|
|
18
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
23
|
+
var t = {};
|
|
24
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
25
|
+
if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
|
|
26
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
27
|
+
}
|
|
28
|
+
return t;
|
|
29
|
+
};
|
|
20
30
|
var Col = function Col(props) {
|
|
21
|
-
var _React$useContext =
|
|
31
|
+
var _React$useContext = _react.default.useContext(_configProvider.ConfigContext),
|
|
22
32
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
23
33
|
pkgPrefixCls = _React$useContext.prefixCls,
|
|
24
34
|
userDefaultProps = _React$useContext.compDefaultProps;
|
|
25
35
|
// 属性需要合并一遍用户定义的默认属性
|
|
26
|
-
var
|
|
27
|
-
xs =
|
|
28
|
-
sm =
|
|
29
|
-
md =
|
|
30
|
-
lg =
|
|
31
|
-
xl =
|
|
32
|
-
flex =
|
|
33
|
-
span =
|
|
34
|
-
pull =
|
|
35
|
-
push =
|
|
36
|
-
style =
|
|
37
|
-
order =
|
|
38
|
-
offset =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
var _a = (0, _utils.getCompProps)('Col', userDefaultProps, props),
|
|
37
|
+
xs = _a.xs,
|
|
38
|
+
sm = _a.sm,
|
|
39
|
+
md = _a.md,
|
|
40
|
+
lg = _a.lg,
|
|
41
|
+
xl = _a.xl,
|
|
42
|
+
flex = _a.flex,
|
|
43
|
+
span = _a.span,
|
|
44
|
+
pull = _a.pull,
|
|
45
|
+
push = _a.push,
|
|
46
|
+
style = _a.style,
|
|
47
|
+
order = _a.order,
|
|
48
|
+
offset = _a.offset,
|
|
49
|
+
children = _a.children,
|
|
50
|
+
className = _a.className,
|
|
51
|
+
customPrefixcls = _a.prefixCls,
|
|
52
|
+
others = __rest(_a, ["xs", "sm", "md", "lg", "xl", "flex", "span", "pull", "push", "style", "order", "offset", "children", "className", "prefixCls"]);
|
|
53
|
+
var rowGroup = (0, _react.useContext)(_row.GapContext);
|
|
54
|
+
var mergedWinWidth = rowGroup.winWidth;
|
|
55
|
+
var gap = rowGroup.gap;
|
|
43
56
|
// 浏览器名称
|
|
44
|
-
var
|
|
57
|
+
var isSogouOrIE = (0, _testBrowserType.testBrowserType)(/^sogou/i, 0) || /Trident|MSIE/.test(navigator.userAgent);
|
|
58
|
+
var colGapStyle = {
|
|
59
|
+
padding: "0 ".concat(gap.h / 2, "px")
|
|
60
|
+
};
|
|
61
|
+
if (isSogouOrIE && gap.v) colGapStyle.marginBottom = gap.v;
|
|
45
62
|
// className前缀
|
|
46
63
|
var prefixCls = getPrefixCls(pkgPrefixCls, 'col', customPrefixcls);
|
|
47
64
|
var columns = 24;
|
|
@@ -52,23 +69,23 @@ var Col = function Col(props) {
|
|
|
52
69
|
offset: offset,
|
|
53
70
|
order: order
|
|
54
71
|
};
|
|
55
|
-
if (xs &&
|
|
72
|
+
if (xs && mergedWinWidth > 0) {
|
|
56
73
|
if (xs.constructor === Number) base.span = xs;
|
|
57
74
|
if (xs.constructor === Object) base = (0, _extends2.default)((0, _extends2.default)({}, base), xs);
|
|
58
75
|
}
|
|
59
|
-
if (sm &&
|
|
76
|
+
if (sm && mergedWinWidth >= 600) {
|
|
60
77
|
if (sm.constructor === Number) base.span = sm;
|
|
61
78
|
if (sm.constructor === Object) base = (0, _extends2.default)((0, _extends2.default)({}, base), sm);
|
|
62
79
|
}
|
|
63
|
-
if (md &&
|
|
80
|
+
if (md && mergedWinWidth >= 1024) {
|
|
64
81
|
if (md.constructor === Number) base.span = md;
|
|
65
82
|
if (md.constructor === Object) base = (0, _extends2.default)((0, _extends2.default)({}, base), md);
|
|
66
83
|
}
|
|
67
|
-
if (lg &&
|
|
84
|
+
if (lg && mergedWinWidth >= 1280) {
|
|
68
85
|
if (lg.constructor === Number) base.span = lg;
|
|
69
86
|
if (lg.constructor === Object) base = (0, _extends2.default)((0, _extends2.default)({}, base), lg);
|
|
70
87
|
}
|
|
71
|
-
if (xl &&
|
|
88
|
+
if (xl && mergedWinWidth >= 1920) {
|
|
72
89
|
if (xl.constructor === Number) base.span = xl;
|
|
73
90
|
if (xl.constructor === Object) base = (0, _extends2.default)((0, _extends2.default)({}, base), xl);
|
|
74
91
|
}
|
|
@@ -88,20 +105,18 @@ var Col = function Col(props) {
|
|
|
88
105
|
}
|
|
89
106
|
}
|
|
90
107
|
}
|
|
91
|
-
var styleString = (0, _extends2.default)({
|
|
108
|
+
var styleString = (0, _extends2.default)((0, _extends2.default)({
|
|
92
109
|
flex: flexstr,
|
|
93
110
|
maxWidth: width,
|
|
94
111
|
order: base.order,
|
|
95
112
|
left: base.push && base.push / columns * 100 + '%',
|
|
96
113
|
right: base.pull && base.pull / columns * 100 + '%',
|
|
97
114
|
marginLeft: base.offset && base.offset / columns * 100 + '%'
|
|
98
|
-
}, style);
|
|
99
|
-
return /*#__PURE__*/
|
|
100
|
-
className: (0, _classnames.default)(prefixCls, className,
|
|
101
|
-
'sogou-col': isSogou
|
|
102
|
-
}),
|
|
115
|
+
}, colGapStyle), style);
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
117
|
+
className: (0, _classnames.default)(prefixCls, className),
|
|
103
118
|
style: styleString
|
|
104
|
-
}, children);
|
|
119
|
+
}, others), children);
|
|
105
120
|
};
|
|
106
121
|
Col.displayName = 'Col';
|
|
107
122
|
var _default = Col;
|
package/lib/grid/row.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
declare type Align = 'top' | 'middle' | 'bottom' | 'stretch';
|
|
3
3
|
declare type Justify = 'start' | 'end' | 'center' | 'space-around' | 'space-between';
|
|
4
4
|
interface gutterObject {
|
|
@@ -17,5 +17,13 @@ export interface RowProps {
|
|
|
17
17
|
style?: React.CSSProperties;
|
|
18
18
|
gutter?: number | gutterObject | Array<number | gutterObject>;
|
|
19
19
|
}
|
|
20
|
+
export interface GridContext {
|
|
21
|
+
gap: {
|
|
22
|
+
v: number;
|
|
23
|
+
h: number;
|
|
24
|
+
};
|
|
25
|
+
winWidth: number;
|
|
26
|
+
}
|
|
27
|
+
export declare const GapContext: React.Context<GridContext>;
|
|
20
28
|
declare const Row: React.FC<RowProps>;
|
|
21
29
|
export default Row;
|
package/lib/grid/row.js
CHANGED
|
@@ -7,11 +7,10 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.default = void 0;
|
|
11
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
10
|
+
exports.default = exports.GapContext = void 0;
|
|
12
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
13
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
14
|
-
var
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
15
|
var _utils = require("../_utils");
|
|
17
16
|
var _configProvider = require("../config-provider");
|
|
@@ -33,9 +32,16 @@ function getGap(gutter, width) {
|
|
|
33
32
|
if (xl && width >= 1920) gap = xl;
|
|
34
33
|
return gap;
|
|
35
34
|
}
|
|
35
|
+
var GapContext = /*#__PURE__*/(0, _react.createContext)({
|
|
36
|
+
gap: {
|
|
37
|
+
h: 0,
|
|
38
|
+
v: 0
|
|
39
|
+
},
|
|
40
|
+
winWidth: window.innerWidth
|
|
41
|
+
});
|
|
42
|
+
exports.GapContext = GapContext;
|
|
36
43
|
var Row = function Row(props) {
|
|
37
|
-
var
|
|
38
|
-
var _React$useContext = React.useContext(_configProvider.ConfigContext),
|
|
44
|
+
var _React$useContext = _react.default.useContext(_configProvider.ConfigContext),
|
|
39
45
|
getPrefixCls = _React$useContext.getPrefixCls,
|
|
40
46
|
pkgPrefixCls = _React$useContext.prefixCls,
|
|
41
47
|
userDefaultProps = _React$useContext.compDefaultProps;
|
|
@@ -50,10 +56,10 @@ var Row = function Row(props) {
|
|
|
50
56
|
justify = _getCompProps.justify,
|
|
51
57
|
customPrefixcls = _getCompProps.prefixCls;
|
|
52
58
|
// 浏览器名称
|
|
53
|
-
var
|
|
59
|
+
var isSogouOrIe = (0, _testBrowserType.testBrowserType)(/^sogou/i, 0) || /Trident|MSIE/.test(navigator.userAgent);
|
|
54
60
|
// className前缀
|
|
55
61
|
var prefixCls = getPrefixCls(pkgPrefixCls, 'row', customPrefixcls);
|
|
56
|
-
var _React$useState =
|
|
62
|
+
var _React$useState = _react.default.useState(window.innerWidth),
|
|
57
63
|
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
58
64
|
winWidth = _React$useState2[0],
|
|
59
65
|
setWinWidth = _React$useState2[1];
|
|
@@ -82,9 +88,10 @@ var Row = function Row(props) {
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
var rowStyle = {
|
|
85
|
-
'
|
|
91
|
+
'row-gap': "".concat(gap.v, "px"),
|
|
92
|
+
margin: "0 ".concat(-1 * gap.h, "px")
|
|
86
93
|
};
|
|
87
|
-
if (gap.v) rowStyle['
|
|
94
|
+
if (gap.v && isSogouOrIe) rowStyle['margin-bottom'] = "".concat(-1 * gap.v / 2, "px");
|
|
88
95
|
var toalign = {
|
|
89
96
|
top: 'flex-start',
|
|
90
97
|
middle: 'center',
|
|
@@ -94,22 +101,21 @@ var Row = function Row(props) {
|
|
|
94
101
|
start: 'flex-start',
|
|
95
102
|
end: 'flex-end'
|
|
96
103
|
};
|
|
97
|
-
var styleString = (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({},
|
|
104
|
+
var styleString = (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({}, rowStyle), style), {
|
|
98
105
|
alignItems: toalign[align] || align,
|
|
99
106
|
justifyContent: tojustify[justify] || justify
|
|
100
107
|
});
|
|
101
|
-
return /*#__PURE__*/
|
|
108
|
+
return /*#__PURE__*/_react.default.createElement(GapContext.Provider, {
|
|
109
|
+
value: {
|
|
110
|
+
gap: gap,
|
|
111
|
+
winWidth: winWidth
|
|
112
|
+
}
|
|
113
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
102
114
|
className: (0, _classnames.default)(prefixCls, className, {
|
|
103
115
|
nowrap: !wrap
|
|
104
|
-
}, {
|
|
105
|
-
'sogou-row': isSogou
|
|
106
116
|
}),
|
|
107
117
|
style: styleString
|
|
108
|
-
},
|
|
109
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
110
|
-
winWidth: winWidth
|
|
111
|
-
});
|
|
112
|
-
}));
|
|
118
|
+
}, children));
|
|
113
119
|
};
|
|
114
120
|
Row.displayName = 'Row';
|
|
115
121
|
var _default = Row;
|