@king-design/react 2.1.1 → 3.0.0-beta.1
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/__tests__/__snapshots__/Dialog.md +1 -1
- package/__tests__/__snapshots__/React Demos.md +410 -374
- package/__tests__/components/drawer.spec.tsx +67 -5
- package/components/button/index.d.ts +1 -1
- package/components/button/index.js +1 -1
- package/components/button/styles.js +3 -3
- package/components/card/styles.js +10 -2
- package/components/checkbox/styles.js +21 -10
- package/components/collapse/styles.js +6 -1
- package/components/copy/index.d.ts +17 -0
- package/components/copy/index.js +43 -0
- package/components/copy/index.spec.d.ts +1 -0
- package/components/copy/index.spec.js +52 -0
- package/components/copy/index.vdt.js +45 -0
- package/components/copy/styles.d.ts +2 -0
- package/components/copy/styles.js +14 -0
- package/components/copy/useCopy.d.ts +4 -0
- package/components/copy/useCopy.js +90 -0
- package/components/datepicker/index.spec.js +1 -1
- package/components/datepicker/index.vdt.js +1 -1
- package/components/datepicker/styles.d.ts +1 -1
- package/components/datepicker/styles.js +5 -2
- package/components/diagram/shapes/callout.d.ts +1 -1
- package/components/diagram/shapes/circle.d.ts +1 -1
- package/components/diagram/shapes/document.d.ts +1 -1
- package/components/diagram/shapes/ellipse.d.ts +1 -1
- package/components/diagram/shapes/hexagon.d.ts +1 -1
- package/components/diagram/shapes/image.d.ts +1 -1
- package/components/diagram/shapes/parallelogram.d.ts +1 -1
- package/components/diagram/shapes/rectangle.d.ts +1 -1
- package/components/diagram/shapes/square.d.ts +1 -1
- package/components/diagram/shapes/text.d.ts +1 -1
- package/components/dialog/alert.vdt.js +6 -5
- package/components/dialog/base.vdt.js +5 -6
- package/components/dialog/index.spec.js +4 -4
- package/components/dialog/styles.js +16 -14
- package/components/drawer/styles.js +20 -5
- package/components/dropdown/styles.js +1 -1
- package/components/form/index.spec.js +4 -2
- package/components/form/item.vdt.js +2 -1
- package/components/form/styles.js +5 -5
- package/components/grid/useGutter.js +8 -8
- package/components/icon/index.d.ts +1 -0
- package/components/icon/index.js +2 -1
- package/components/icon/index.vdt.js +4 -2
- package/components/icon/styles.js +10 -2
- package/components/input/index.d.ts +1 -0
- package/components/input/index.js +4 -11
- package/components/input/index.vdt.js +4 -2
- package/components/input/styles.js +13 -11
- package/components/message/message.js +1 -1
- package/components/message/message.vdt.js +7 -6
- package/components/message/styles.js +8 -8
- package/components/pagination/index.d.ts +1 -1
- package/components/pagination/index.js +1 -1
- package/components/pagination/index.spec.js +4 -2
- package/components/pagination/index.vdt.js +16 -18
- package/components/pagination/styles.js +12 -3
- package/components/popover/content.d.ts +19 -0
- package/components/popover/content.js +31 -0
- package/components/popover/content.vdt.js +68 -0
- package/components/popover/index.d.ts +16 -0
- package/components/popover/index.js +44 -0
- package/components/popover/index.spec.d.ts +1 -0
- package/components/popover/index.spec.js +195 -0
- package/components/popover/styles.d.ts +1 -0
- package/components/popover/styles.js +22 -0
- package/components/progress/index.js +1 -1
- package/components/progress/index.vdt.js +46 -8
- package/components/progress/styles.js +19 -13
- package/components/radio/styles.js +16 -6
- package/components/rate/styles.js +1 -1
- package/components/select/base.d.ts +5 -2
- package/components/select/base.js +7 -3
- package/components/select/base.vdt.js +46 -38
- package/components/select/index.spec.js +2 -2
- package/components/select/menu.vdt.js +1 -1
- package/components/select/styles.js +14 -28
- package/components/select/useDraggble.d.ts +2 -0
- package/components/select/useDraggble.js +11 -0
- package/components/select/useNowrap.d.ts +3 -0
- package/components/select/useNowrap.js +19 -0
- package/components/slider/index.spec.js +48 -9
- package/components/slider/index.vdt.js +23 -12
- package/components/slider/styles.js +23 -14
- package/components/slider/useValue.d.ts +3 -1
- package/components/slider/useValue.js +12 -0
- package/components/spinner/index.d.ts +0 -1
- package/components/spinner/index.js +1 -19
- package/components/spinner/index.vdt.js +15 -8
- package/components/spinner/styles.js +33 -5
- package/components/spinner/useChange.d.ts +1 -1
- package/components/spinner/useChange.js +2 -2
- package/components/spinner/useValue.d.ts +1 -0
- package/components/spinner/useValue.js +16 -1
- package/components/split/index.vdt.js +32 -20
- package/components/split/memo.d.ts +9 -0
- package/components/split/memo.js +26 -0
- package/components/steps/index.d.ts +3 -2
- package/components/steps/index.js +4 -3
- package/components/steps/index.spec.js +1 -1
- package/components/steps/index.vdt.js +8 -4
- package/components/steps/step.vdt.js +17 -9
- package/components/steps/styles.d.ts +2 -1
- package/components/steps/styles.js +106 -72
- package/components/switch/index.spec.js +82 -65
- package/components/switch/styles.js +20 -34
- package/components/table/styles.js +9 -4
- package/components/table/useDraggable.js +3 -10
- package/components/table/useStickyScrollbar.js +2 -2
- package/components/table/useWidth.js +2 -2
- package/components/tabs/index.d.ts +1 -1
- package/components/tabs/index.js +1 -1
- package/components/tabs/index.spec.js +67 -0
- package/components/tabs/index.vdt.js +5 -5
- package/components/tabs/styles.js +73 -29
- package/components/tabs/useScroll.d.ts +1 -1
- package/components/tabs/useScroll.js +75 -48
- package/components/tag/base.d.ts +1 -0
- package/components/tag/base.js +2 -2
- package/components/tag/index.d.ts +1 -0
- package/components/tag/index.js +2 -1
- package/components/tag/index.spec.js +147 -4
- package/components/tag/styles.d.ts +67 -0
- package/components/tag/styles.js +42 -12
- package/components/tag/tags.d.ts +27 -0
- package/components/tag/tags.js +51 -0
- package/components/tag/tags.vdt.js +79 -0
- package/components/tag/useChildren.d.ts +2 -0
- package/components/tag/useChildren.js +39 -0
- package/components/tag/useDraggable.d.ts +3 -0
- package/components/tag/useDraggable.js +89 -0
- package/components/tag/useNowrap.d.ts +7 -0
- package/components/tag/useNowrap.js +115 -0
- package/components/timepicker/index.spec.js +1 -1
- package/components/tip/index.vdt.js +1 -3
- package/components/tip/styles.js +4 -3
- package/components/tooltip/content.d.ts +2 -2
- package/components/tooltip/content.vdt.js +23 -13
- package/components/tooltip/index.spec.js +56 -108
- package/components/tooltip/styles.d.ts +1 -0
- package/components/tooltip/styles.js +13 -8
- package/components/transfer/index.vdt.js +3 -1
- package/components/transfer/styles.js +1 -1
- package/components/transfer/useCheck.d.ts +1 -0
- package/components/transfer/useCheck.js +8 -1
- package/components/upload/index.spec.js +5 -6
- package/components/upload/index.vdt.js +24 -21
- package/components/upload/styles.js +22 -30
- package/components/utils.d.ts +2 -0
- package/components/utils.js +24 -3
- package/hooks/useResizeObserver.d.ts +1 -1
- package/hooks/useResizeObserver.js +19 -6
- package/i18n/en-US.d.ts +6 -2
- package/i18n/en-US.js +8 -3
- package/index.d.ts +4 -2
- package/index.js +4 -2
- package/package.json +1 -1
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +2 -2
- package/styles/fonts/iconfont.svg +189 -369
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/ionicons.js +2 -2
- package/styles/global.js +1 -1
- package/styles/theme.d.ts +10 -2
- package/styles/theme.js +23 -21
- package/components/table/useResizeObserver.d.ts +0 -2
- package/components/table/useResizeObserver.js +0 -20
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
3
|
import BasicDemo from '~/components/switch/demos/basic';
|
|
4
|
+
import DisabledDemo from '~/components/switch/demos/disabled';
|
|
4
5
|
import ValueDemo from '~/components/switch/demos/value';
|
|
5
6
|
import WidthHeightDemo from '~/components/switch/demos/widthHeight';
|
|
6
7
|
import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
|
|
@@ -9,14 +10,14 @@ describe('Switch', function () {
|
|
|
9
10
|
unmount();
|
|
10
11
|
});
|
|
11
12
|
it('change value by clicking', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
12
|
-
var _mount, instance, element, _element$querySelecto, el,
|
|
13
|
+
var _mount, instance, element, _element$querySelecto, el, handle;
|
|
13
14
|
|
|
14
15
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
16
|
while (1) {
|
|
16
17
|
switch (_context.prev = _context.next) {
|
|
17
18
|
case 0:
|
|
18
19
|
_mount = mount(BasicDemo), instance = _mount[0], element = _mount[1];
|
|
19
|
-
_element$querySelecto = element.querySelectorAll('.k-switch'), el = _element$querySelecto[0]
|
|
20
|
+
_element$querySelecto = element.querySelectorAll('.k-switch'), el = _element$querySelecto[0];
|
|
20
21
|
el.click();
|
|
21
22
|
_context.next = 5;
|
|
22
23
|
return wait();
|
|
@@ -38,29 +39,61 @@ describe('Switch', function () {
|
|
|
38
39
|
|
|
39
40
|
case 16:
|
|
40
41
|
expect(instance.get('value')).to.be.false;
|
|
41
|
-
disabledEl.click();
|
|
42
|
-
_context.next = 20;
|
|
43
|
-
return wait();
|
|
44
|
-
|
|
45
|
-
case 20:
|
|
46
|
-
expect(element.outerHTML).to.matchSnapshot();
|
|
47
42
|
|
|
48
|
-
case
|
|
43
|
+
case 17:
|
|
49
44
|
case "end":
|
|
50
45
|
return _context.stop();
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
48
|
}, _callee);
|
|
54
49
|
})));
|
|
55
|
-
it('
|
|
56
|
-
var _mount2, instance, element,
|
|
50
|
+
it('disabled', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
51
|
+
var _mount2, instance, element, el;
|
|
57
52
|
|
|
58
53
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
59
54
|
while (1) {
|
|
60
55
|
switch (_context2.prev = _context2.next) {
|
|
61
56
|
case 0:
|
|
62
|
-
_mount2 = mount(
|
|
63
|
-
|
|
57
|
+
_mount2 = mount(DisabledDemo), instance = _mount2[0], element = _mount2[1];
|
|
58
|
+
el = element.querySelector('.k-switch');
|
|
59
|
+
el.click();
|
|
60
|
+
_context2.next = 5;
|
|
61
|
+
return wait();
|
|
62
|
+
|
|
63
|
+
case 5:
|
|
64
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
65
|
+
dispatchEvent(el, 'mousedown', {
|
|
66
|
+
which: 1,
|
|
67
|
+
clientX: 0
|
|
68
|
+
});
|
|
69
|
+
dispatchEvent(document, 'mousemove', {
|
|
70
|
+
clientX: 30
|
|
71
|
+
});
|
|
72
|
+
dispatchEvent(document, 'mouseup', {
|
|
73
|
+
clientX: 30
|
|
74
|
+
});
|
|
75
|
+
_context2.next = 11;
|
|
76
|
+
return wait();
|
|
77
|
+
|
|
78
|
+
case 11:
|
|
79
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
80
|
+
|
|
81
|
+
case 12:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context2.stop();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, _callee2);
|
|
87
|
+
})));
|
|
88
|
+
it('change value by draging', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
89
|
+
var _mount3, instance, element, _element$querySelecto2, el;
|
|
90
|
+
|
|
91
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
92
|
+
while (1) {
|
|
93
|
+
switch (_context3.prev = _context3.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
_mount3 = mount(BasicDemo), instance = _mount3[0], element = _mount3[1];
|
|
96
|
+
_element$querySelecto2 = element.querySelectorAll('.k-switch-handle'), el = _element$querySelecto2[0];
|
|
64
97
|
dispatchEvent(el, 'mousedown', {
|
|
65
98
|
which: 1,
|
|
66
99
|
clientX: 0
|
|
@@ -68,7 +101,7 @@ describe('Switch', function () {
|
|
|
68
101
|
dispatchEvent(document, 'mousemove', {
|
|
69
102
|
clientX: 1
|
|
70
103
|
});
|
|
71
|
-
|
|
104
|
+
_context3.next = 6;
|
|
72
105
|
return wait();
|
|
73
106
|
|
|
74
107
|
case 6:
|
|
@@ -77,7 +110,7 @@ describe('Switch', function () {
|
|
|
77
110
|
dispatchEvent(document, 'mouseup', {
|
|
78
111
|
clientX: 1
|
|
79
112
|
});
|
|
80
|
-
|
|
113
|
+
_context3.next = 10;
|
|
81
114
|
return wait();
|
|
82
115
|
|
|
83
116
|
case 10:
|
|
@@ -93,7 +126,7 @@ describe('Switch', function () {
|
|
|
93
126
|
dispatchEvent(document, 'mouseup', {
|
|
94
127
|
clientX: 30
|
|
95
128
|
});
|
|
96
|
-
|
|
129
|
+
_context3.next = 17;
|
|
97
130
|
return wait();
|
|
98
131
|
|
|
99
132
|
case 17:
|
|
@@ -109,7 +142,7 @@ describe('Switch', function () {
|
|
|
109
142
|
dispatchEvent(document, 'mouseup', {
|
|
110
143
|
clientX: -30
|
|
111
144
|
});
|
|
112
|
-
|
|
145
|
+
_context3.next = 24;
|
|
113
146
|
return wait();
|
|
114
147
|
|
|
115
148
|
case 24:
|
|
@@ -122,43 +155,27 @@ describe('Switch', function () {
|
|
|
122
155
|
dispatchEvent(document, 'mouseup', {
|
|
123
156
|
clientX: 0
|
|
124
157
|
});
|
|
125
|
-
|
|
158
|
+
_context3.next = 29;
|
|
126
159
|
return wait();
|
|
127
160
|
|
|
128
161
|
case 29:
|
|
129
|
-
expect(instance.get('value')).to.be.true;
|
|
130
|
-
|
|
131
|
-
dispatchEvent(disabledEl, 'mousedown', {
|
|
132
|
-
which: 1,
|
|
133
|
-
clientX: 0
|
|
134
|
-
});
|
|
135
|
-
dispatchEvent(document, 'mousemove', {
|
|
136
|
-
clientX: 30
|
|
137
|
-
});
|
|
138
|
-
dispatchEvent(document, 'mouseup', {
|
|
139
|
-
clientX: 30
|
|
140
|
-
});
|
|
141
|
-
_context2.next = 35;
|
|
142
|
-
return wait();
|
|
143
|
-
|
|
144
|
-
case 35:
|
|
145
|
-
expect(element.outerHTML).to.matchSnapshot();
|
|
162
|
+
expect(instance.get('value')).to.be.true;
|
|
146
163
|
|
|
147
|
-
case
|
|
164
|
+
case 30:
|
|
148
165
|
case "end":
|
|
149
|
-
return
|
|
166
|
+
return _context3.stop();
|
|
150
167
|
}
|
|
151
168
|
}
|
|
152
|
-
},
|
|
169
|
+
}, _callee3);
|
|
153
170
|
})));
|
|
154
|
-
it('drag switch which has custom width and height', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
155
|
-
var
|
|
171
|
+
it('drag switch which has custom width and height', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
172
|
+
var _mount4, instance, element, _element$querySelecto3, el;
|
|
156
173
|
|
|
157
|
-
return _regeneratorRuntime.wrap(function
|
|
174
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
158
175
|
while (1) {
|
|
159
|
-
switch (
|
|
176
|
+
switch (_context4.prev = _context4.next) {
|
|
160
177
|
case 0:
|
|
161
|
-
|
|
178
|
+
_mount4 = mount(WidthHeightDemo), instance = _mount4[0], element = _mount4[1];
|
|
162
179
|
_element$querySelecto3 = element.querySelectorAll('.k-switch-handle'), el = _element$querySelecto3[2];
|
|
163
180
|
dispatchEvent(el, 'mousedown', {
|
|
164
181
|
which: 1,
|
|
@@ -170,7 +187,7 @@ describe('Switch', function () {
|
|
|
170
187
|
dispatchEvent(document, 'mouseup', {
|
|
171
188
|
clientX: 50
|
|
172
189
|
});
|
|
173
|
-
|
|
190
|
+
_context4.next = 7;
|
|
174
191
|
return wait();
|
|
175
192
|
|
|
176
193
|
case 7:
|
|
@@ -185,7 +202,7 @@ describe('Switch', function () {
|
|
|
185
202
|
dispatchEvent(document, 'mouseup', {
|
|
186
203
|
clientX: -50
|
|
187
204
|
});
|
|
188
|
-
|
|
205
|
+
_context4.next = 13;
|
|
189
206
|
return wait();
|
|
190
207
|
|
|
191
208
|
case 13:
|
|
@@ -193,24 +210,24 @@ describe('Switch', function () {
|
|
|
193
210
|
|
|
194
211
|
case 14:
|
|
195
212
|
case "end":
|
|
196
|
-
return
|
|
213
|
+
return _context4.stop();
|
|
197
214
|
}
|
|
198
215
|
}
|
|
199
|
-
},
|
|
216
|
+
}, _callee4);
|
|
200
217
|
})));
|
|
201
|
-
it('change value by keypress', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
202
|
-
var
|
|
218
|
+
it('change value by keypress', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
219
|
+
var _mount5, instance, element, el;
|
|
203
220
|
|
|
204
|
-
return _regeneratorRuntime.wrap(function
|
|
221
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
205
222
|
while (1) {
|
|
206
|
-
switch (
|
|
223
|
+
switch (_context5.prev = _context5.next) {
|
|
207
224
|
case 0:
|
|
208
|
-
|
|
225
|
+
_mount5 = mount(BasicDemo), instance = _mount5[0], element = _mount5[1];
|
|
209
226
|
el = element.querySelector('.k-switch');
|
|
210
227
|
dispatchEvent(el, 'keypress', {
|
|
211
228
|
keyCode: 13
|
|
212
229
|
});
|
|
213
|
-
|
|
230
|
+
_context5.next = 5;
|
|
214
231
|
return wait();
|
|
215
232
|
|
|
216
233
|
case 5:
|
|
@@ -218,7 +235,7 @@ describe('Switch', function () {
|
|
|
218
235
|
dispatchEvent(el, 'keypress', {
|
|
219
236
|
keyCode: 13
|
|
220
237
|
});
|
|
221
|
-
|
|
238
|
+
_context5.next = 9;
|
|
222
239
|
return wait();
|
|
223
240
|
|
|
224
241
|
case 9:
|
|
@@ -226,30 +243,30 @@ describe('Switch', function () {
|
|
|
226
243
|
|
|
227
244
|
case 10:
|
|
228
245
|
case "end":
|
|
229
|
-
return
|
|
246
|
+
return _context5.stop();
|
|
230
247
|
}
|
|
231
248
|
}
|
|
232
|
-
},
|
|
249
|
+
}, _callee5);
|
|
233
250
|
})));
|
|
234
|
-
it('custom the value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
235
|
-
var
|
|
251
|
+
it('custom the value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
252
|
+
var _mount6, instance, element, _element$querySelecto4, el1, el2;
|
|
236
253
|
|
|
237
|
-
return _regeneratorRuntime.wrap(function
|
|
254
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
238
255
|
while (1) {
|
|
239
|
-
switch (
|
|
256
|
+
switch (_context6.prev = _context6.next) {
|
|
240
257
|
case 0:
|
|
241
|
-
|
|
258
|
+
_mount6 = mount(ValueDemo), instance = _mount6[0], element = _mount6[1];
|
|
242
259
|
_element$querySelecto4 = element.querySelectorAll('.k-switch'), el1 = _element$querySelecto4[0], el2 = _element$querySelecto4[1];
|
|
243
260
|
el1.click();
|
|
244
261
|
el2.click();
|
|
245
|
-
|
|
262
|
+
_context6.next = 6;
|
|
246
263
|
return wait();
|
|
247
264
|
|
|
248
265
|
case 6:
|
|
249
266
|
expect(element.outerHTML).to.matchSnapshot();
|
|
250
267
|
el1.click();
|
|
251
268
|
el2.click();
|
|
252
|
-
|
|
269
|
+
_context6.next = 11;
|
|
253
270
|
return wait();
|
|
254
271
|
|
|
255
272
|
case 11:
|
|
@@ -257,9 +274,9 @@ describe('Switch', function () {
|
|
|
257
274
|
|
|
258
275
|
case 12:
|
|
259
276
|
case "end":
|
|
260
|
-
return
|
|
277
|
+
return _context6.stop();
|
|
261
278
|
}
|
|
262
279
|
}
|
|
263
|
-
},
|
|
280
|
+
}, _callee6);
|
|
264
281
|
})));
|
|
265
282
|
});
|
|
@@ -1,68 +1,54 @@
|
|
|
1
1
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
2
2
|
import { css } from '@emotion/css';
|
|
3
3
|
import { theme, setDefault } from '../../styles/theme';
|
|
4
|
-
import { deepDefaults, sizes } from '../../styles/utils';
|
|
4
|
+
import { deepDefaults, sizes, palette } from '../../styles/utils';
|
|
5
5
|
import '../../styles/global';
|
|
6
6
|
var defaults = {
|
|
7
7
|
get transition() {
|
|
8
8
|
return theme.transition.middle;
|
|
9
9
|
},
|
|
10
10
|
|
|
11
|
-
bgColor
|
|
12
|
-
fontSize: "12px",
|
|
13
|
-
|
|
14
|
-
get color() {
|
|
15
|
-
return theme.color.text;
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
checkedBgColor: "#fff",
|
|
19
|
-
handleBorderRadius: "100%",
|
|
20
|
-
|
|
21
|
-
get handleBgColor() {
|
|
11
|
+
get bgColor() {
|
|
22
12
|
return theme.color.border;
|
|
23
13
|
},
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
fontSize: "12px",
|
|
16
|
+
color: '#fff',
|
|
17
|
+
handleBorderRadius: "100%",
|
|
18
|
+
handleBgColor: '#fff',
|
|
29
19
|
// checked
|
|
30
20
|
checked: {
|
|
31
|
-
get
|
|
32
|
-
return theme.color.primary;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
get color() {
|
|
21
|
+
get bgColor() {
|
|
36
22
|
return theme.color.primary;
|
|
37
23
|
},
|
|
38
24
|
|
|
39
|
-
get
|
|
40
|
-
return theme.color.primary;
|
|
25
|
+
get disabledBgColor() {
|
|
26
|
+
return palette(theme.color.primary, -3);
|
|
41
27
|
}
|
|
42
28
|
|
|
43
29
|
},
|
|
44
30
|
// default
|
|
45
31
|
default: {
|
|
46
|
-
width: "
|
|
47
|
-
height: "
|
|
48
|
-
padding: "
|
|
32
|
+
width: "45px",
|
|
33
|
+
height: "24px",
|
|
34
|
+
padding: "3px"
|
|
49
35
|
},
|
|
50
36
|
// large
|
|
51
37
|
large: {
|
|
52
|
-
width: "
|
|
53
|
-
height: "
|
|
54
|
-
padding: "
|
|
38
|
+
width: "58px",
|
|
39
|
+
height: "30px",
|
|
40
|
+
padding: "3px"
|
|
55
41
|
},
|
|
56
42
|
// small
|
|
57
43
|
small: {
|
|
58
|
-
width: "
|
|
44
|
+
width: "30px",
|
|
59
45
|
height: "16px",
|
|
60
46
|
padding: "2px"
|
|
61
47
|
},
|
|
62
48
|
// mini
|
|
63
49
|
mini: {
|
|
64
|
-
width: "
|
|
65
|
-
height: "
|
|
50
|
+
width: "18px",
|
|
51
|
+
height: "10px",
|
|
66
52
|
padding: "1px"
|
|
67
53
|
},
|
|
68
54
|
|
|
@@ -79,11 +65,11 @@ setDefault(function () {
|
|
|
79
65
|
}).switch;
|
|
80
66
|
});
|
|
81
67
|
export function makeStyles() {
|
|
82
|
-
return /*#__PURE__*/css("display:inline-block;vertical-align:middle;background:", kswitch.bgColor, ";position:relative;cursor:pointer;user-select:none;overflow:hidden;
|
|
68
|
+
return /*#__PURE__*/css("display:inline-block;vertical-align:middle;background:", kswitch.bgColor, ";position:relative;cursor:pointer;user-select:none;overflow:hidden;box-sizing:content-box;input{opacity:0;position:absolute;}.k-switch-bar,.k-switch-off{box-sizing:border-box;}.k-switch-bar{position:absolute;text-align:right;overflow:hidden;}.k-switch-wrapper{display:inline-block;position:relative;z-index:1;border-radius:", kswitch.handleBorderRadius, ";}.k-switch-bar,.k-switch-wrapper{height:100%;background:", kswitch.bgColor, ";transition:all ", kswitch.transition, ";}.k-switch-handle{border-radius:", kswitch.handleBorderRadius, ";background:", kswitch.handleBgColor, ";height:100%;cursor:pointer;transition:left ", kswitch.transition, ";display:inline-block;img{height:100%;visibility:hidden;}}.k-switch-on,.k-switch-off{position:absolute;font-size:", kswitch.fontSize, ";color:", kswitch.color, ";text-align:center;}&.k-dragging{.k-switch-bar,.k-switch-wrapper{background:", kswitch.checked.bgColor, ";transition:background ", kswitch.transition, ";}}&:focus{outline:none;}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
83
69
|
var _kswitch$size = kswitch[size],
|
|
84
70
|
width = _kswitch$size.width,
|
|
85
71
|
height = _kswitch$size.height,
|
|
86
72
|
padding = _kswitch$size.padding;
|
|
87
73
|
return /*#__PURE__*/css("&.k-", size, ",&.k-", size, " .k-switch-on,&.k-", size, " .k-switch-off{width:", width, ";height:", height, ";}&.k-", size, "{border-radius:", height, ";.k-switch-bar{width:", height, ";border-radius:", height, ";}.k-switch-wrapper{padding:", padding, ";}.k-switch-on,.k-switch-off{line-height:", height, ";left:0;}.k-switch-on{padding:0 ", height, " 0 calc(", height, " / 3);}.k-switch-off{padding:0 calc(", height, " / 3) 0 ", height, ";}}");
|
|
88
|
-
}), "&.k-checked{
|
|
74
|
+
}), "&.k-checked{.k-switch-bar,.k-switch-wrapper{background:", kswitch.checked.bgColor, ";}.k-switch-bar{width:100%;}}&.k-disabled{&,.k-switch-handle{cursor:not-allowed;}&,.k-switch-bar,.k-switch-wrapper{background:", kswitch.disabledBgColor, ";}&.k-checked{&,.k-switch-bar,.k-switch-wrapper{background:", kswitch.checked.disabledBgColor, ";}}}");
|
|
89
75
|
}
|
|
@@ -10,7 +10,12 @@ var defaults = {
|
|
|
10
10
|
},
|
|
11
11
|
|
|
12
12
|
// transition: '15000s',
|
|
13
|
-
border: "1px solid #
|
|
13
|
+
border: "1px solid #e2e5e8",
|
|
14
|
+
|
|
15
|
+
get borderRadius() {
|
|
16
|
+
return theme.borderRadius;
|
|
17
|
+
},
|
|
18
|
+
|
|
14
19
|
fontSize: "12px",
|
|
15
20
|
bgColor: "#fff",
|
|
16
21
|
|
|
@@ -30,7 +35,7 @@ var defaults = {
|
|
|
30
35
|
fontSize: "12px",
|
|
31
36
|
fontWeight: "bold",
|
|
32
37
|
textAlign: 'left',
|
|
33
|
-
height: "
|
|
38
|
+
height: "40px",
|
|
34
39
|
delimiterHeight: '12px',
|
|
35
40
|
delimiterColor: '#bfbfbf'
|
|
36
41
|
},
|
|
@@ -66,7 +71,7 @@ var defaults = {
|
|
|
66
71
|
sort: {
|
|
67
72
|
iconHeight: "7px",
|
|
68
73
|
gap: "10px",
|
|
69
|
-
color: "#
|
|
74
|
+
color: "#d0d5d9",
|
|
70
75
|
disabledColor: "#ddd"
|
|
71
76
|
},
|
|
72
77
|
expandBgColor: '#fdfcff',
|
|
@@ -90,7 +95,7 @@ setDefault(function () {
|
|
|
90
95
|
}).table;
|
|
91
96
|
});
|
|
92
97
|
export function makeStyles() {
|
|
93
|
-
return /*#__PURE__*/css("font-size:", table.fontSize, ";color:", table.color, ";
|
|
98
|
+
return /*#__PURE__*/css("font-size:", table.fontSize, ";color:", table.color, ";position:relative;z-index:0;.k-table-wrapper{border-bottom:", table.border, ";overflow:auto;border-radius:", table.borderRadius, ";}table{width:100%;border-spacing:0;table-layout:fixed;td,th{transition:all ", table.transition, ";}}thead{text-align:", table.thead.textAlign, ";font-size:", table.thead.fontSize, ";font-weight:", table.thead.fontWeight, ";position:sticky;top:0;z-index:2;tr{height:", table.thead.height, ";&:not(:last-of-type) th{border-bottom:", table.border, ";}}}th{padding:", table.thead.padding, ";position:relative;background:", table.thead.bgColor, ";line-height:normal;&:before{content:'';height:", table.thead.delimiterHeight, ";position:absolute;background-color:", table.thead.delimiterColor, ";width:1px;left:1px;top:50%;transform:translateY(-50%);}&:first-of-type:before{display:none;}}.k-table-title{display:inline-flex;align-items:center;max-width:100%;color:", theme.color.lightBlack, ";}.k-table-title-text{flex:1;}tbody{tr{&:hover td{background:", table.tbody.hoverBgcolor, ";}&:last-of-type td{border-bottom-color:transparent;}}}td{padding:", table.tbody.padding, ";border-bottom:", table.border, ";background:", table.bgColor, ";word-wrap:break-word;}.k-fixed-left,.k-fixed-right{position:sticky;z-index:1;&:after{content:'';display:block;transition:box-shadow ", table.transition, ";position:absolute;top:0;bottom:0px;width:10px;pointer-events:none;}}.k-fixed-left:after{right:-11px;}.k-fixed-right:after{left:-11px;}&.k-scroll-left .k-fixed-right:after{box-shadow:", table.fixRightShadow, ";}&.k-scroll-right .k-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}&.k-scroll-middle{.k-fixed-left:after{box-shadow:", table.fixLeftShadow, ";}.k-fixed-right:after{box-shadow:", table.fixRightShadow, ";}}.k-fixed-right+.k-fixed-right:after{display:none;}.k-table-affix-header{position:sticky;top:0;left:0;.k-affix-wrapper{overflow:hidden;}&.k-fixed{position:relative;}}&.k-border,&.k-grid{.k-table-wrapper{border-top:", table.border, ";border-left:", table.border, ";border-right:", table.border, ";}}&.k-grid{td:not(:last-of-type),th:not(:last-of-type){border-right:", table.border, ";}th:before{display:none;}}&.k-stripe{tr:nth-child(even):not(:hover) td{background:", table.stripeBgColor, ";}}.k-table-group{width:", table.group.width, "!important;height:", table.group.width, "!important;margin-left:", table.group.gap, ";position:relative;color:", table.group.color, ";&:hover{color:", theme.color.primary, ";}.k-icon{transition:transform ", table.transition, ";}&.k-dropdown-open .k-icon{transform:rotate(180deg);}}.k-table-check{.k-checkbox,.k-radio{position:relative;top:-1px;}}.k-column-sortable{cursor:pointer;}.k-column-sort{.k-icon{display:block;height:", _sortInstanceProperty(table).iconHeight, ";line-height:", _sortInstanceProperty(table).iconHeight, ";margin-left:", _sortInstanceProperty(table).gap, ";color:", _sortInstanceProperty(table).color, ";}&.k-asc .k-icon.k-desc,&.k-desc .k-icon.k-asc{color:", _sortInstanceProperty(table).disabledColor, ";}}.k-table-spin.k-overlay{z-index:2;}.k-table-empty{text-align:center;}tr.k-expand{td{padding:0;background:#fdfcff;}}&.k-with-expand{tr:not(.k-expand){td{border-bottom:none;}}}.k-table-expand{border-top:", table.border, ";box-sizing:content-box;}tbody tr.k-selected td{background:", table.selectedBgColor, ";}.k-table-arrow{margin-right:", table.arrow.gap, ";transition:transform ", table.transition, ";position:relative;top:-1px;}tr.k-spreaded{.k-table-arrow{transform:rotate(90deg);}}.k-table-resize{height:100%;width:", table.resizeWidth, ";position:absolute;top:0;left:-1px;cursor:ew-resize;}tr.k-dragging{opacity:", table.draggingOpacity, ";}.k-table-scrollbar{overflow-x:auto;overflow-y:hidden;}.k-table-scrollbar-inner{height:1px;}", _mapInstanceProperty(aligns).call(aligns, function (type) {
|
|
94
99
|
return /*#__PURE__*/css(".k-align-", type, "{text-align:", type, ";}");
|
|
95
100
|
}), ">.k-pagination{margin:16px 0;}");
|
|
96
101
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
2
|
-
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
3
1
|
import { useInstance, nextTick } from 'intact-react';
|
|
4
2
|
import { useState } from '../../hooks/useState';
|
|
3
|
+
import { swap } from '../utils';
|
|
5
4
|
export function useDraggable(data) {
|
|
6
5
|
var instance = useInstance();
|
|
7
6
|
var draggingKey = useState(null);
|
|
@@ -21,19 +20,13 @@ export function useDraggable(data) {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
function onRowDragOver(e, tableRow) {
|
|
24
|
-
var _context;
|
|
25
|
-
|
|
26
23
|
e.preventDefault();
|
|
27
24
|
e.stopPropagation();
|
|
25
|
+
if (draggingKey.value === null) return;
|
|
28
26
|
var newIndex = tableRow.get('index');
|
|
29
27
|
if (newIndex === draggingIndex) return; // swap data
|
|
30
28
|
|
|
31
|
-
var newData =
|
|
32
|
-
|
|
33
|
-
var item = _spliceInstanceProperty(newData).call(newData, draggingIndex, 1)[0];
|
|
34
|
-
|
|
35
|
-
_spliceInstanceProperty(newData).call(newData, newIndex, 0, item);
|
|
36
|
-
|
|
29
|
+
var newData = swap(data.value, draggingIndex, newIndex);
|
|
37
30
|
draggingIndex = newIndex;
|
|
38
31
|
data.set(newData);
|
|
39
32
|
}
|
|
@@ -2,7 +2,7 @@ import { createRef, useInstance, onMounted, nextTick } from 'intact-react';
|
|
|
2
2
|
import { useState } from '../../hooks/useState';
|
|
3
3
|
import { isStringOrNumber, isNull } from 'intact-shared';
|
|
4
4
|
import { debounce } from '../utils';
|
|
5
|
-
import { useResizeObserver } from '
|
|
5
|
+
import { useResizeObserver } from '../../hooks/useResizeObserver';
|
|
6
6
|
export function useStickyScrollbar(elementRef, _ref, tableRef, tableScroll) {
|
|
7
7
|
var scrollRef = _ref.scrollRef,
|
|
8
8
|
callbacks = _ref.callbacks;
|
|
@@ -14,7 +14,7 @@ export function useStickyScrollbar(elementRef, _ref, tableRef, tableScroll) {
|
|
|
14
14
|
instance.on('$receive:stickScrollbar', function (v) {
|
|
15
15
|
stick.set(v === true ? 0 : isStringOrNumber(v) ? +v : null);
|
|
16
16
|
});
|
|
17
|
-
useResizeObserver(scrollRef, setTableActualWidth);
|
|
17
|
+
useResizeObserver(scrollRef, setTableActualWidth, true);
|
|
18
18
|
onMounted(function () {
|
|
19
19
|
setTableActualWidth();
|
|
20
20
|
});
|
|
@@ -3,7 +3,7 @@ import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
|
3
3
|
import { useInstance, onMounted, createRef } from 'intact-react';
|
|
4
4
|
import { useState } from '../../hooks/useState';
|
|
5
5
|
import { scrollbarWidth } from '../position';
|
|
6
|
-
import { useResizeObserver } from '
|
|
6
|
+
import { useResizeObserver } from '../../hooks/useResizeObserver';
|
|
7
7
|
var hasLocalStorage = typeof localStorage !== 'undefined';
|
|
8
8
|
export function useWidth(scrollRef, getColumns) {
|
|
9
9
|
var instance = useInstance();
|
|
@@ -16,7 +16,7 @@ export function useWidth(scrollRef, getColumns) {
|
|
|
16
16
|
});
|
|
17
17
|
useResizeObserver(scrollRef, function () {
|
|
18
18
|
return checkTableWidth(false);
|
|
19
|
-
}); // if exist widthStoreKey, we get the default width from localStorage
|
|
19
|
+
}, true); // if exist widthStoreKey, we get the default width from localStorage
|
|
20
20
|
|
|
21
21
|
function initWidthFromStore() {
|
|
22
22
|
var _instance$get = instance.get(),
|
|
@@ -7,7 +7,7 @@ export interface TabsProps<T = any> {
|
|
|
7
7
|
value?: T;
|
|
8
8
|
vertical?: boolean;
|
|
9
9
|
size?: Sizes;
|
|
10
|
-
type?: 'default' | 'card' | '
|
|
10
|
+
type?: 'default' | 'card' | 'flat-card';
|
|
11
11
|
closable?: boolean;
|
|
12
12
|
beforeChange?: (value: T) => boolean | Promise<boolean>;
|
|
13
13
|
}
|
package/components/tabs/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
2
4
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
5
|
import ClosableDemo from '~/components/tabs/demos/closable';
|
|
4
6
|
import BeforeChangeDemo from '~/components/tabs/demos/beforeChange';
|
|
5
7
|
import { mount, unmount, wait } from '../../test/utils';
|
|
8
|
+
import { Tabs, Tab } from './';
|
|
9
|
+
import { Component } from 'intact-react';
|
|
6
10
|
describe('Tabs', function () {
|
|
7
11
|
afterEach(function () {
|
|
8
12
|
return unmount();
|
|
@@ -93,4 +97,67 @@ describe('Tabs', function () {
|
|
|
93
97
|
}
|
|
94
98
|
}, _callee2);
|
|
95
99
|
})));
|
|
100
|
+
it('vertical scroll', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
101
|
+
var Demo, _mount3, instance, element, prev, next;
|
|
102
|
+
|
|
103
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
104
|
+
while (1) {
|
|
105
|
+
switch (_context4.prev = _context4.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
108
|
+
_inheritsLoose(Demo, _Component);
|
|
109
|
+
|
|
110
|
+
function Demo() {
|
|
111
|
+
var _context3;
|
|
112
|
+
|
|
113
|
+
var _this;
|
|
114
|
+
|
|
115
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
116
|
+
args[_key] = arguments[_key];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context3 = [this]).call(_context3, args)) || this;
|
|
120
|
+
_this.Tabs = Tabs;
|
|
121
|
+
_this.Tab = Tab;
|
|
122
|
+
return _this;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
Demo.defaults = function defaults() {
|
|
126
|
+
return {
|
|
127
|
+
tab: 0
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return Demo;
|
|
132
|
+
}(Component);
|
|
133
|
+
|
|
134
|
+
Demo.template = "\n const { Tabs, Tab } = this;\n <Tabs v-model=\"tab\" vertical style=\"height: 200px;\">\n <Tab v-for={new Array(10).fill(0)} value={$key}>\n {$key}\n </Tab>\n </Tabs>\n ";
|
|
135
|
+
_mount3 = mount(Demo), instance = _mount3[0], element = _mount3[1];
|
|
136
|
+
_context4.next = 5;
|
|
137
|
+
return wait(100);
|
|
138
|
+
|
|
139
|
+
case 5:
|
|
140
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
141
|
+
prev = element.querySelector('.k-tabs-prev');
|
|
142
|
+
next = element.querySelector('.k-tabs-next');
|
|
143
|
+
next.click();
|
|
144
|
+
_context4.next = 11;
|
|
145
|
+
return wait();
|
|
146
|
+
|
|
147
|
+
case 11:
|
|
148
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
149
|
+
prev.click();
|
|
150
|
+
_context4.next = 15;
|
|
151
|
+
return wait();
|
|
152
|
+
|
|
153
|
+
case 15:
|
|
154
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
155
|
+
|
|
156
|
+
case 16:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context4.stop();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, _callee3);
|
|
162
|
+
})));
|
|
96
163
|
});
|