@king-design/react 2.0.0-beta.1 → 2.0.2
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__/React Demos.md +321 -295
- package/__tests__/index.ts +5 -2
- package/__tests__/karma.conf.js +1 -1
- package/components/breadcrumb/item.d.ts +1 -1
- package/components/breadcrumb/item.js +3 -14
- package/components/breadcrumb/styles.js +1 -1
- package/components/button/index.vdt.js +26 -17
- package/components/button/styles.d.ts +82 -1
- package/components/button/styles.js +16 -2
- package/components/card/styles.js +1 -1
- package/components/carousel/styles.js +4 -1
- package/components/carousel/useSlide.js +10 -9
- package/components/cascader/index.spec.js +89 -1
- package/components/cascader/index.vdt.js +4 -4
- package/components/cascader/useLabel.js +8 -12
- package/components/checkbox/index.vdt.js +15 -10
- package/components/checkbox/styles.js +2 -2
- package/components/collapse/item.vdt.js +2 -1
- package/components/collapse/styles.js +5 -1
- package/components/colorpicker/index.d.ts +2 -0
- package/components/colorpicker/index.js +2 -1
- package/components/colorpicker/index.spec.js +1 -1
- package/components/colorpicker/index.vdt.js +3 -1
- package/components/context.d.ts +5 -2
- package/components/context.js +7 -4
- package/components/datepicker/helpers.d.ts +2 -1
- package/components/datepicker/helpers.js +8 -2
- package/components/datepicker/index.spec.js +1 -1
- package/components/datepicker/index.vdt.js +10 -5
- package/components/datepicker/styles.d.ts +46 -1
- package/components/diagram/shapes/generateShapes.js +3 -3
- package/components/diagram/shapes/line.d.ts +2 -2
- package/components/diagram/shapes/line.js +0 -1
- package/components/dialog/base.d.ts +2 -0
- package/components/dialog/base.js +2 -1
- package/components/dialog/index.spec.js +59 -94
- package/components/dialog/styles.js +5 -1
- package/components/dialog/useFixBody.d.ts +6 -0
- package/components/dialog/useFixBody.js +12 -0
- package/components/drawer/index.spec.js +5 -5
- package/components/drawer/styles.js +1 -1
- package/components/dropdown/dropdown.js +1 -0
- package/components/dropdown/index.js +1 -2
- package/components/dropdown/index.spec.js +3 -3
- package/components/dropdown/styles.js +1 -1
- package/components/editable/index.vdt.js +2 -1
- package/components/editable/styles.d.ts +8 -1
- package/components/form/index.spec.js +10 -12
- package/components/form/item.vdt.js +13 -9
- package/components/form/useError.d.ts +5 -1
- package/components/form/useError.js +3 -1
- package/components/form/useValidate.js +2 -2
- package/components/grid/col.vdt.js +4 -2
- package/components/grid/styles.js +1 -1
- package/components/grid/useGutter.d.ts +1 -1
- package/components/icon/index.vdt.js +3 -2
- package/components/icon/styles.js +8 -4
- package/components/input/index.d.ts +1 -0
- package/components/input/index.js +2 -1
- package/components/input/index.vdt.js +47 -32
- package/components/input/search.vdt.js +4 -2
- package/components/input/styles.js +8 -3
- package/components/layout/styles.d.ts +1 -1
- package/components/layout/styles.js +7 -3
- package/components/menu/index.spec.js +15 -8
- package/components/menu/item.d.ts +1 -2
- package/components/menu/item.js +10 -17
- package/components/menu/item.vdt.js +4 -4
- package/components/menu/menu.d.ts +3 -0
- package/components/menu/menu.js +4 -0
- package/components/menu/styles.d.ts +62 -1
- package/components/menu/styles.js +6 -2
- package/components/menu/useExpanded.d.ts +1 -4
- package/components/menu/useHighlight.d.ts +5 -8
- package/components/menu/useHighlight.js +44 -33
- package/components/message/index.spec.js +1 -1
- package/components/message/styles.js +6 -2
- package/components/pagination/styles.js +1 -1
- package/components/radio/index.vdt.js +14 -9
- package/components/radio/styles.js +9 -1
- package/components/rate/styles.js +5 -1
- package/components/scrollSelect/styles.d.ts +14 -1
- package/components/scrollSelect/styles.js +9 -1
- package/components/select/base.vdt.js +135 -121
- package/components/select/index.spec.js +1 -1
- package/components/select/menu.vdt.js +1 -0
- package/components/select/styles.js +9 -4
- package/components/select/useSearchable.d.ts +1 -1
- package/components/slider/styles.js +5 -1
- package/components/spinner/index.d.ts +1 -1
- package/components/spinner/index.js +1 -1
- package/components/split/style.js +1 -1
- package/components/steps/context.d.ts +1 -1
- package/components/steps/styles.js +5 -1
- package/components/switch/styles.js +5 -1
- package/components/table/index.d.ts +1 -0
- package/components/table/index.spec.js +2 -1
- package/components/table/row.vdt.js +12 -4
- package/components/table/styles.js +6 -1
- package/components/table/table.d.ts +1 -0
- package/components/table/table.js +2 -1
- package/components/table/table.vdt.js +30 -27
- package/components/table/useColumns.d.ts +1 -1
- package/components/table/useFixedColumns.d.ts +1 -1
- package/components/table/useFixedColumns.js +5 -2
- package/components/table/useGroup.d.ts +1 -1
- package/components/table/useResizable.d.ts +1 -1
- package/components/table/useSortable.d.ts +1 -1
- package/components/table/useWidth.js +7 -1
- package/components/tabs/index.spec.js +1 -1
- package/components/tabs/styles.js +9 -2
- package/components/tabs/tab.vdt.js +2 -1
- package/components/tabs/useActiveBar.js +6 -3
- package/components/tag/base.js +1 -0
- package/components/tag/styles.js +8 -2
- package/components/timepicker/constants.d.ts +2 -1
- package/components/timepicker/constants.js +3 -2
- package/components/timepicker/index.spec.js +36 -35
- package/components/timepicker/useStep.js +3 -3
- package/components/timepicker/useValue.js +2 -2
- package/components/tooltip/index.spec.js +32 -25
- package/components/transfer/index.spec.js +20 -19
- package/components/transfer/styles.js +2 -6
- package/components/tree/index.d.ts +1 -1
- package/components/tree/index.js +1 -1
- package/components/tree/index.spec.js +20 -19
- package/components/tree/index.vdt.js +1 -0
- package/components/tree/styles.js +5 -1
- package/components/treeSelect/index.spec.js +5 -5
- package/components/treeSelect/styles.js +5 -1
- package/components/upload/index.d.ts +1 -1
- package/components/upload/index.spec.js +1 -1
- package/components/upload/index.vdt.js +10 -11
- package/components/upload/styles.js +5 -1
- package/components/utils.d.ts +1 -1
- package/components/wave/index.d.ts +19 -0
- package/components/wave/index.js +120 -0
- package/components/wave/styles.d.ts +2 -0
- package/components/wave/styles.js +17 -0
- package/hooks/useRouter.d.ts +1 -0
- package/hooks/useRouter.js +10 -0
- package/i18n/en-US.d.ts +1 -0
- package/i18n/en-US.js +1 -0
- package/index.d.ts +3 -2
- package/index.js +3 -2
- package/package.json +2 -2
- package/styles/global.js +4 -3
- package/styles/theme.d.ts +16 -7
- package/styles/theme.js +15 -7
package/__tests__/index.ts
CHANGED
|
@@ -40,7 +40,10 @@ describe('React Demos', () => {
|
|
|
40
40
|
|
|
41
41
|
testDemos(reactReq, async (Demo) => {
|
|
42
42
|
const [instance, element] = mount(wrap(Demo as any));
|
|
43
|
-
await wait();
|
|
44
|
-
|
|
43
|
+
await wait(100);
|
|
44
|
+
// FIXME: I don't why the width of `autoWidth` input is an unexpected value
|
|
45
|
+
// while we run test on Github Actions.
|
|
46
|
+
const innerHTML = element.innerHTML.replace(/(\<input.*?style="width: )(?:.*?)(px;")/g, '$1$2');
|
|
47
|
+
expect(innerHTML).to.matchSnapshot();
|
|
45
48
|
});
|
|
46
49
|
});
|
package/__tests__/karma.conf.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = function (config) {
|
|
|
16
16
|
customLaunchers: {
|
|
17
17
|
'MyChromeHeadless': {
|
|
18
18
|
base: 'ChromeHeadless',
|
|
19
|
-
flags: ['--window-size=1920,1080'],
|
|
19
|
+
flags: ['--window-size=1920,1080', '--force-device-scale-factor=1'],
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
frameworks: ['webpack', 'mocha', 'sinon-chai', 'snapshot', 'mocha-snapshot'],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, TypeDefs } from 'intact-react';
|
|
2
2
|
export interface BreadcrumbItemProps {
|
|
3
|
-
to?: string;
|
|
3
|
+
to?: string | object;
|
|
4
4
|
}
|
|
5
5
|
export declare class BreadcrumbItem extends Component<BreadcrumbItemProps> {
|
|
6
6
|
static template: string | import("intact").Template<any>;
|
|
@@ -4,10 +4,9 @@ import { __decorate } from "tslib";
|
|
|
4
4
|
import { Component } from 'intact-react';
|
|
5
5
|
import { bind } from '../utils';
|
|
6
6
|
import template from './item.vdt';
|
|
7
|
-
import {
|
|
8
|
-
import { useRouter } from '../../hooks/useRouter';
|
|
7
|
+
import { useRouter, navigate } from '../../hooks/useRouter';
|
|
9
8
|
var typeDefs = {
|
|
10
|
-
to: String
|
|
9
|
+
to: [String, Object]
|
|
11
10
|
};
|
|
12
11
|
export var BreadcrumbItem = /*#__PURE__*/function (_Component) {
|
|
13
12
|
_inheritsLoose(BreadcrumbItem, _Component);
|
|
@@ -29,17 +28,7 @@ export var BreadcrumbItem = /*#__PURE__*/function (_Component) {
|
|
|
29
28
|
var _proto = BreadcrumbItem.prototype;
|
|
30
29
|
|
|
31
30
|
_proto.onClick = function onClick() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (to) {
|
|
35
|
-
var router = this.router.value;
|
|
36
|
-
|
|
37
|
-
if (router && !isExternalLink(to)) {
|
|
38
|
-
router.push(to);
|
|
39
|
-
} else {
|
|
40
|
-
window.location.href = to;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
31
|
+
navigate(this.router.value, this.get('to'));
|
|
43
32
|
};
|
|
44
33
|
|
|
45
34
|
return BreadcrumbItem;
|
|
@@ -24,5 +24,5 @@ setDefault(function () {
|
|
|
24
24
|
}).breadcrumb;
|
|
25
25
|
});
|
|
26
26
|
export default function makeStyles() {
|
|
27
|
-
return /*#__PURE__*/css("font-size:", breadcrumb.fontSize, ";.k-breadcrumb-item{
|
|
27
|
+
return /*#__PURE__*/css("font-size:", breadcrumb.fontSize, ";display:flex;align-items:center;.k-breadcrumb-item{&:last-of-type .k-breadcrumb-link{font-weight:", breadcrumb.activeFontWeight, ";color:", breadcrumb.activeColor, ";}}.k-breadcrumb-link,.k-breadcrumb-link a{color:", breadcrumb.color, ";}a.k-breadcrumb-link,.k-breadcrumb-link a{cursor:pointer;&:hover{color:", breadcrumb.hoverColor, ";}}.k-breadcrumb-separator{margin:0 ", breadcrumb.gap, ";}");
|
|
28
28
|
}
|
|
@@ -4,6 +4,8 @@ import { getRestProps } from '../utils';
|
|
|
4
4
|
import { Icon } from '../icon';
|
|
5
5
|
import { makeButtonStyles } from './styles';
|
|
6
6
|
import { DynamicButton } from './dynamicButton';
|
|
7
|
+
import { Wave } from '../wave';
|
|
8
|
+
import { button as theme } from './styles';
|
|
7
9
|
export default function ($props, $blocks, $__proto__) {
|
|
8
10
|
var _classNameObj;
|
|
9
11
|
|
|
@@ -72,22 +74,29 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
72
74
|
var buttonGroup = this.buttonGroup;
|
|
73
75
|
var checkType = buttonGroup ? buttonGroup.get('checkType') : 'none';
|
|
74
76
|
var isCheckType = checkType !== 'none';
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
'
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
'
|
|
87
|
-
'
|
|
88
|
-
'
|
|
89
|
-
'
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
var typeStyles = theme[type];
|
|
78
|
+
var waveColor = typeStyles && typeStyles.borderColor || theme.primary.borderColor;
|
|
79
|
+
return _$cc(Wave, {
|
|
80
|
+
'disabled': loading || disabled || type === 'none' || type === 'link',
|
|
81
|
+
'inset': '-2px',
|
|
82
|
+
'color': waveColor,
|
|
83
|
+
'children': _$cc(DynamicButton, _extends({
|
|
84
|
+
'className': _$cn(classNameObj),
|
|
85
|
+
'tagName': tagName
|
|
86
|
+
}, getRestProps(this), {
|
|
87
|
+
'ref': this.elementRef,
|
|
88
|
+
'tabindex': disabled || loading ? '-1' : tabindex,
|
|
89
|
+
'ev-click': this.onClick,
|
|
90
|
+
'ev-mouseup': this.onMouseUp,
|
|
91
|
+
'htmlType': htmlType,
|
|
92
|
+
'name': isCheckType ? null : name,
|
|
93
|
+
'children': [loading ? iconSide === 'right' ? [children, loadingIcon] : [loadingIcon, children] : children, isCheckType ? _$ce(64, 'input', null, 1, 'k-button-input', {
|
|
94
|
+
'type': checkType,
|
|
95
|
+
'name': name,
|
|
96
|
+
'checked': checked,
|
|
97
|
+
'tabindex': '-1'
|
|
98
|
+
}) : undefined]
|
|
99
|
+
}), null, this.elementRef)
|
|
100
|
+
});
|
|
92
101
|
}
|
|
93
102
|
;
|
|
@@ -1,6 +1,87 @@
|
|
|
1
1
|
import '../../styles/global';
|
|
2
|
+
declare type TypeStyles = {
|
|
3
|
+
color: string;
|
|
4
|
+
bgColor: string;
|
|
5
|
+
borderColor: string;
|
|
6
|
+
hoverBorderColor: string;
|
|
7
|
+
ghostColor: string;
|
|
8
|
+
};
|
|
9
|
+
declare type SizeStyles = {
|
|
10
|
+
fontSize: string;
|
|
11
|
+
height: string;
|
|
12
|
+
padding: string;
|
|
13
|
+
};
|
|
2
14
|
export declare const types: readonly ["primary", "warning", "danger", "active", "success"];
|
|
3
|
-
declare
|
|
15
|
+
declare const defaults: {
|
|
16
|
+
readonly transition: string;
|
|
17
|
+
active: TypeStyles;
|
|
18
|
+
secondary: {
|
|
19
|
+
readonly color: string;
|
|
20
|
+
readonly borderColor: string;
|
|
21
|
+
readonly hoverBgColor: string;
|
|
22
|
+
readonly activeBgColor: string;
|
|
23
|
+
};
|
|
24
|
+
link: {
|
|
25
|
+
readonly color: string;
|
|
26
|
+
readonly hoverColor: string;
|
|
27
|
+
readonly hoverBgColor: string;
|
|
28
|
+
};
|
|
29
|
+
none: {
|
|
30
|
+
readonly hoverBgColor: string;
|
|
31
|
+
};
|
|
32
|
+
group: {
|
|
33
|
+
primary: {
|
|
34
|
+
readonly borderColor: string;
|
|
35
|
+
};
|
|
36
|
+
warning: {
|
|
37
|
+
readonly borderColor: string;
|
|
38
|
+
};
|
|
39
|
+
danger: {
|
|
40
|
+
readonly borderColor: string;
|
|
41
|
+
};
|
|
42
|
+
success: {
|
|
43
|
+
readonly borderColor: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
} & {
|
|
47
|
+
readonly color: string;
|
|
48
|
+
bgColor: string;
|
|
49
|
+
lineHeight: string;
|
|
50
|
+
readonly padding: string;
|
|
51
|
+
readonly borderColor: string;
|
|
52
|
+
readonly borderRadius: string;
|
|
53
|
+
readonly fontSize: string;
|
|
54
|
+
readonly height: string;
|
|
55
|
+
readonly hoverBorderColor: string;
|
|
56
|
+
readonly hoverColor: string;
|
|
57
|
+
ghost: {
|
|
58
|
+
color: string;
|
|
59
|
+
readonly hoverColor: string;
|
|
60
|
+
borderColor: string;
|
|
61
|
+
readonly hoverBorderColor: string;
|
|
62
|
+
};
|
|
63
|
+
icon: {
|
|
64
|
+
gap: string;
|
|
65
|
+
fontSize: string;
|
|
66
|
+
};
|
|
67
|
+
disabled: {
|
|
68
|
+
readonly color: string;
|
|
69
|
+
readonly bgColor: string;
|
|
70
|
+
readonly borderColor: string;
|
|
71
|
+
readonly ghostBorderColor: string;
|
|
72
|
+
};
|
|
73
|
+
} & {
|
|
74
|
+
primary: TypeStyles;
|
|
75
|
+
warning: TypeStyles;
|
|
76
|
+
danger: TypeStyles;
|
|
77
|
+
success: TypeStyles;
|
|
78
|
+
active: TypeStyles;
|
|
79
|
+
} & {
|
|
80
|
+
small: SizeStyles;
|
|
81
|
+
large: SizeStyles;
|
|
82
|
+
mini: SizeStyles;
|
|
83
|
+
};
|
|
84
|
+
declare let button: typeof defaults;
|
|
4
85
|
export { button };
|
|
5
86
|
export declare function makeButtonStyles({ iconSide }: {
|
|
6
87
|
iconSide?: string;
|
|
@@ -149,6 +149,10 @@ var btnSizeStyles = sizes.reduce(function (memo, size) {
|
|
|
149
149
|
return memo;
|
|
150
150
|
}, {});
|
|
151
151
|
var defaults = deepDefaults({
|
|
152
|
+
get transition() {
|
|
153
|
+
return theme.transition.middle;
|
|
154
|
+
},
|
|
155
|
+
|
|
152
156
|
active: btnActiveStyles,
|
|
153
157
|
secondary: {
|
|
154
158
|
get color() {
|
|
@@ -175,6 +179,16 @@ var defaults = deepDefaults({
|
|
|
175
179
|
|
|
176
180
|
get hoverColor() {
|
|
177
181
|
return theme.color.linkHover;
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
get hoverBgColor() {
|
|
185
|
+
return theme.color.hoverBg;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
},
|
|
189
|
+
none: {
|
|
190
|
+
get hoverBgColor() {
|
|
191
|
+
return theme.color.bg;
|
|
178
192
|
}
|
|
179
193
|
|
|
180
194
|
},
|
|
@@ -221,10 +235,10 @@ export function makeButtonStyles(_ref) {
|
|
|
221
235
|
return cx(
|
|
222
236
|
/*#__PURE__*/
|
|
223
237
|
// extract static styles to individual css method for performance
|
|
224
|
-
css("display:inline-flex;align-items:center;justify-content:center;cursor:pointer;height:", button.height, ";padding:", button.padding, ";outline:none;vertical-align:middle;color:", button.color, ";background:", button.bgColor, ";border-radius:", button.borderRadius, ";border:1px solid ", button.borderColor, ";font-size:", button.fontSize, ";white-space:nowrap;transition:all ",
|
|
238
|
+
css("display:inline-flex;align-items:center;justify-content:center;cursor:pointer;height:", button.height, ";padding:", button.padding, ";outline:none;vertical-align:middle;color:", button.color, ";background:", button.bgColor, ";border-radius:", button.borderRadius, ";border:1px solid ", button.borderColor, ";font-size:", button.fontSize, ";white-space:nowrap;transition:all ", button.transition, ";line-height:", button.lineHeight, ";&:hover,&:focus{border-color:", button.hoverBorderColor, ";color:", button.hoverColor, ";}&:active{background:", palette(theme.color.primary, -4), ";}.k-button-input{position:absolute;opacity:0;width:0;height:0;}", _mapInstanceProperty(types).call(types, function (type) {
|
|
225
239
|
var typeStyles = button[type];
|
|
226
240
|
return /*#__PURE__*/css("&.k-", type, "{background:", typeStyles.bgColor, ";color:", typeStyles.color, ";border-color:", typeStyles.borderColor, ";&:hover,&:focus{background:", palette(typeStyles.bgColor, -1), ";border-color:", typeStyles.hoverBorderColor, ";color:", typeStyles.color, ";}&:active{background:", palette(typeStyles.bgColor, 1), ";border-color:", palette(typeStyles.borderColor, 1), ";}}");
|
|
227
|
-
}), "&.k-secondary{color:", secondary.color, ";border-color:", secondary.borderColor, ";&:hover,&:focus{background:", secondary.hoverBgColor, ";}&:active{background:", secondary.activeBgColor, ";}}&.k-link{color:", link.color, ";&:hover{color:", link.hoverColor, ";}}&.k-disabled{&,&:hover{color:", button.disabled.color, ";background:", button.disabled.bgColor, ";border-color:", button.disabled.borderColor, ";cursor:not-allowed;}}&.k-none,&.k-link{
|
|
241
|
+
}), "&.k-secondary{color:", secondary.color, ";border-color:", secondary.borderColor, ";&:hover,&:focus{background:", secondary.hoverBgColor, ";}&:active{background:", secondary.activeBgColor, ";}}&.k-link{color:", link.color, ";&:hover{color:", link.hoverColor, ";background:", link.hoverBgColor, ";}}&.k-disabled{&,&:hover{color:", button.disabled.color, ";background:", button.disabled.bgColor, ";border-color:", button.disabled.borderColor, ";cursor:not-allowed;}}&.k-none,&.k-link{background:transparent;&,&:hover{border:none;}&.k-active{color:", theme.color.primary, ";}}&.k-none:hover{background:", button.none.hoverBgColor, ";}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
228
242
|
var styles = button[size];
|
|
229
243
|
return /*#__PURE__*/css("&.k-", size, "{font-size:", styles.fontSize, ";height:", styles.height, ";padding:", styles.padding, ";&.k-btn-icon{width:", styles.height, ";}}");
|
|
230
244
|
}), "&.k-btn-icon{width:", button.height, ";padding:0;.k-icon{margin:0;}}&.k-fluid{width:100%;padding:0;}&.k-circle{border-radius:calc(", button.large.height, " / 2);}&.k-loading{", _mapInstanceProperty(types).call(types, function (type) {
|
|
@@ -3,7 +3,10 @@ import { theme, setDefault } from '../../styles/theme';
|
|
|
3
3
|
import { deepDefaults } from '../../styles/utils';
|
|
4
4
|
import '../../styles/global';
|
|
5
5
|
var defaults = {
|
|
6
|
-
transition
|
|
6
|
+
get transition() {
|
|
7
|
+
return theme.transition.large;
|
|
8
|
+
},
|
|
9
|
+
|
|
7
10
|
height: "300px",
|
|
8
11
|
indicator: {
|
|
9
12
|
bottom: "8px",
|
|
@@ -48,7 +48,7 @@ export function useSlide(getItems, getItemsWithCloned) {
|
|
|
48
48
|
|
|
49
49
|
function _translateToItem() {
|
|
50
50
|
_translateToItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(item, oldIndex, newIndex, keepDirection) {
|
|
51
|
-
var itemsWithCloned, length;
|
|
51
|
+
var itemsWithCloned, length, lengthWithCloned;
|
|
52
52
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
53
53
|
while (1) {
|
|
54
54
|
switch (_context.prev = _context.next) {
|
|
@@ -62,7 +62,7 @@ export function useSlide(getItems, getItemsWithCloned) {
|
|
|
62
62
|
|
|
63
63
|
case 2:
|
|
64
64
|
if (!keepDirection) {
|
|
65
|
-
_context.next =
|
|
65
|
+
_context.next = 14;
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -75,25 +75,26 @@ export function useSlide(getItems, getItemsWithCloned) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
_context.next = 8;
|
|
78
|
-
return setTranslate(itemsWithCloned[
|
|
78
|
+
return setTranslate(itemsWithCloned[(itemsWithCloned.length - length) / 2 - 1], false);
|
|
79
79
|
|
|
80
80
|
case 8:
|
|
81
|
-
_context.next =
|
|
81
|
+
_context.next = 14;
|
|
82
82
|
break;
|
|
83
83
|
|
|
84
84
|
case 10:
|
|
85
85
|
if (!(oldIndex === 0 && newIndex === length - 1)) {
|
|
86
|
-
_context.next =
|
|
86
|
+
_context.next = 14;
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
lengthWithCloned = itemsWithCloned.length;
|
|
91
|
+
_context.next = 14;
|
|
92
|
+
return setTranslate(itemsWithCloned[lengthWithCloned - (lengthWithCloned - length) / 2], false);
|
|
92
93
|
|
|
93
|
-
case
|
|
94
|
+
case 14:
|
|
94
95
|
setTranslate(item, true);
|
|
95
96
|
|
|
96
|
-
case
|
|
97
|
+
case 15:
|
|
97
98
|
case "end":
|
|
98
99
|
return _context.stop();
|
|
99
100
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
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 BasicDemo from '~/components/cascader/demos/basic';
|
|
4
6
|
import CustomDemo from '~/components/cascader/demos/custom';
|
|
@@ -6,6 +8,8 @@ import ChangeOnSelectDemo from '~/components/cascader/demos/changeOnSelect';
|
|
|
6
8
|
import LoadDataDemo from '~/components/cascader/demos/loadData';
|
|
7
9
|
import FilterDemo from '~/components/cascader/demos/filterable';
|
|
8
10
|
import { mount, unmount, dispatchEvent, getElement, getElements, wait } from '../../test/utils';
|
|
11
|
+
import { Cascader } from './';
|
|
12
|
+
import { Component } from 'intact-react';
|
|
9
13
|
describe('Cascader', function () {
|
|
10
14
|
afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
11
15
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -14,7 +18,7 @@ describe('Cascader', function () {
|
|
|
14
18
|
case 0:
|
|
15
19
|
unmount();
|
|
16
20
|
_context.next = 3;
|
|
17
|
-
return wait(
|
|
21
|
+
return wait(500);
|
|
18
22
|
|
|
19
23
|
case 3:
|
|
20
24
|
case "end":
|
|
@@ -278,4 +282,88 @@ describe('Cascader', function () {
|
|
|
278
282
|
}
|
|
279
283
|
}, _callee7);
|
|
280
284
|
})));
|
|
285
|
+
it('duplicated sub data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
286
|
+
var Demo, _mount7, instance, element, _getElements2, dropdown1, dropdown2, _dropdown1$querySelec4, item1, item2, _dropdown2$querySelec3, item21, dropdown3, _dropdown3$querySelec2, item31;
|
|
287
|
+
|
|
288
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
289
|
+
while (1) {
|
|
290
|
+
switch (_context9.prev = _context9.next) {
|
|
291
|
+
case 0:
|
|
292
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
293
|
+
_inheritsLoose(Demo, _Component);
|
|
294
|
+
|
|
295
|
+
function Demo() {
|
|
296
|
+
var _context8;
|
|
297
|
+
|
|
298
|
+
var _this;
|
|
299
|
+
|
|
300
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
301
|
+
args[_key] = arguments[_key];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context8 = [this]).call(_context8, args)) || this;
|
|
305
|
+
_this.Cascader = Cascader;
|
|
306
|
+
return _this;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
Demo.defaults = function defaults() {
|
|
310
|
+
return {
|
|
311
|
+
value: ['beijing', 'haidian'],
|
|
312
|
+
data: [{
|
|
313
|
+
value: 'beijing',
|
|
314
|
+
label: '北京',
|
|
315
|
+
children: [{
|
|
316
|
+
value: 'haidian',
|
|
317
|
+
label: '海淀区'
|
|
318
|
+
}]
|
|
319
|
+
}, {
|
|
320
|
+
value: 'hunan',
|
|
321
|
+
label: '湖南',
|
|
322
|
+
children: [{
|
|
323
|
+
value: 'haidian',
|
|
324
|
+
label: '海淀区'
|
|
325
|
+
}]
|
|
326
|
+
}]
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
return Demo;
|
|
331
|
+
}(Component);
|
|
332
|
+
|
|
333
|
+
Demo.template = "const {Cascader} = this; <Cascader data={this.get('data')} v-model=\"value\" />";
|
|
334
|
+
_mount7 = mount(Demo), instance = _mount7[0], element = _mount7[1];
|
|
335
|
+
dispatchEvent(element, 'click');
|
|
336
|
+
_context9.next = 6;
|
|
337
|
+
return wait();
|
|
338
|
+
|
|
339
|
+
case 6:
|
|
340
|
+
_getElements2 = getElements('.k-cascader-menu'), dropdown1 = _getElements2[0], dropdown2 = _getElements2[1];
|
|
341
|
+
_dropdown1$querySelec4 = dropdown1.querySelectorAll(':scope > .k-dropdown-item'), item1 = _dropdown1$querySelec4[0], item2 = _dropdown1$querySelec4[1];
|
|
342
|
+
expect(item1.classList.contains('k-selected')).to.be.true;
|
|
343
|
+
expect(item2.classList.contains('k-selected')).to.be.false;
|
|
344
|
+
_dropdown2$querySelec3 = dropdown2.querySelectorAll(':scope > .k-dropdown-item'), item21 = _dropdown2$querySelec3[0];
|
|
345
|
+
expect(item21.classList.contains('k-selected')).to.be.true;
|
|
346
|
+
dispatchEvent(item2, 'click');
|
|
347
|
+
_context9.next = 15;
|
|
348
|
+
return wait();
|
|
349
|
+
|
|
350
|
+
case 15:
|
|
351
|
+
dropdown3 = getElement('.k-cascader-menu');
|
|
352
|
+
_dropdown3$querySelec2 = dropdown3.querySelectorAll(':scope > .k-dropdown-item'), item31 = _dropdown3$querySelec2[0];
|
|
353
|
+
expect(item31.classList.contains('k-selected')).to.be.false;
|
|
354
|
+
dispatchEvent(item31, 'click');
|
|
355
|
+
_context9.next = 21;
|
|
356
|
+
return wait();
|
|
357
|
+
|
|
358
|
+
case 21:
|
|
359
|
+
expect(instance.get('value')).to.eql(['hunan', 'haidian']);
|
|
360
|
+
expect(element.textContent).to.eql('湖南 / 海淀区');
|
|
361
|
+
|
|
362
|
+
case 23:
|
|
363
|
+
case "end":
|
|
364
|
+
return _context9.stop();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}, _callee8);
|
|
368
|
+
})));
|
|
281
369
|
});
|
|
@@ -41,7 +41,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
41
41
|
onSelect = _this$value.onSelect,
|
|
42
42
|
toggleShowedValue = _this$value.toggleShowedValue;
|
|
43
43
|
|
|
44
|
-
var Options = function Options(data, level, loaded) {
|
|
44
|
+
var Options = function Options(data, level, loaded, parentSelected) {
|
|
45
45
|
if (!data.length) {
|
|
46
46
|
if (!loaded) {
|
|
47
47
|
return _$cc(Icon, _$tmp0);
|
|
@@ -53,7 +53,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
53
53
|
return _mapInstanceProperty(data).call(data, function (item, index) {
|
|
54
54
|
var value = item.value;
|
|
55
55
|
var showed = isShowed(value, level);
|
|
56
|
-
var selected = isSelected(value, level);
|
|
56
|
+
var selected = parentSelected && isSelected(value, level);
|
|
57
57
|
var children = item.children;
|
|
58
58
|
|
|
59
59
|
var Item = function Item() {
|
|
@@ -79,7 +79,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
79
79
|
'ev-show': _this.load.bind(null, item),
|
|
80
80
|
'children': [Item(), _$cc(DropdownMenu, {
|
|
81
81
|
'className': _$cn(classNameObj),
|
|
82
|
-
'children': showed ? Options(children, level + 1, item.loaded) : null
|
|
82
|
+
'children': showed ? Options(children, level + 1, item.loaded, selected) : null
|
|
83
83
|
})]
|
|
84
84
|
}) : Item();
|
|
85
85
|
});
|
|
@@ -100,7 +100,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
100
100
|
return !filterable || !keywords ? _$cc(DropdownMenu, {
|
|
101
101
|
'className': _$cn(classNameObj),
|
|
102
102
|
'key': 'common',
|
|
103
|
-
'children': Options(data, 0, true)
|
|
103
|
+
'children': Options(data, 0, true, true)
|
|
104
104
|
}, 'common') : _$cc(DropdownMenu, {
|
|
105
105
|
'key': 'filter',
|
|
106
106
|
'className': _$cn((_$cn2 = {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
2
1
|
import { useInstance } from 'intact-react';
|
|
3
2
|
import { useBaseLabel } from '../select/useBaseLabel';
|
|
4
3
|
export function useLabel() {
|
|
@@ -11,27 +10,24 @@ export function useLabel() {
|
|
|
11
10
|
var labels = [];
|
|
12
11
|
var length = value.length;
|
|
13
12
|
|
|
14
|
-
var loop = function loop(data) {
|
|
13
|
+
var loop = function loop(data, level) {
|
|
14
|
+
if (level === length) return;
|
|
15
|
+
|
|
15
16
|
for (var i = 0; i < data.length; i++) {
|
|
16
17
|
var item = data[i];
|
|
17
18
|
|
|
18
|
-
if (
|
|
19
|
+
if (item.value === value[level]) {
|
|
19
20
|
labels.push(item.label);
|
|
21
|
+
var children = item.children;
|
|
20
22
|
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
+
if (children) {
|
|
24
|
+
loop(children, level + 1);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
var children = item.children;
|
|
27
|
-
|
|
28
|
-
if (children) {
|
|
29
|
-
loop(children);
|
|
30
|
-
}
|
|
31
27
|
}
|
|
32
28
|
};
|
|
33
29
|
|
|
34
|
-
loop(data);
|
|
30
|
+
loop(data, 0);
|
|
35
31
|
return labels.length ? format(labels) : null;
|
|
36
32
|
}
|
|
37
33
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime-corejs3/helpers/objectWithoutPropertiesLoose";
|
|
3
3
|
var _excluded = ["className", "disabled", "falseValue", "children", "value", "trueValue", "style", "indeterminate", "title"];
|
|
4
|
-
import { createVNode as _$cv, className as _$cn, createElementVNode as _$ce } from 'intact-react';
|
|
4
|
+
import { createVNode as _$cv, className as _$cn, createUnknownComponentVNode as _$cc, createElementVNode as _$ce } from 'intact-react';
|
|
5
5
|
import { getRestProps } from '../utils';
|
|
6
6
|
import makeStyles from './styles';
|
|
7
|
+
import { Wave } from '../wave';
|
|
7
8
|
export default function ($props, $blocks, $__proto__) {
|
|
8
9
|
var _classNameObj;
|
|
9
10
|
|
|
@@ -51,15 +52,19 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
51
52
|
'title': title,
|
|
52
53
|
'ev-click': this.onClick,
|
|
53
54
|
'ev-keypress': this.onKeypress
|
|
54
|
-
}, events), [_$
|
|
55
|
-
'type': 'checkbox',
|
|
56
|
-
'checked': isChecked,
|
|
57
|
-
'value': trueValue,
|
|
58
|
-
'trueValue': trueValue,
|
|
59
|
-
'falseValue': falseValue,
|
|
55
|
+
}, events), [_$cc(Wave, {
|
|
60
56
|
'disabled': disabled,
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
|
|
57
|
+
'inset': '-2px',
|
|
58
|
+
'children': _$ce(2, 'span', _$cv('input', _extends({
|
|
59
|
+
'type': 'checkbox',
|
|
60
|
+
'checked': isChecked,
|
|
61
|
+
'value': trueValue,
|
|
62
|
+
'trueValue': trueValue,
|
|
63
|
+
'falseValue': falseValue,
|
|
64
|
+
'disabled': disabled,
|
|
65
|
+
'tabindex': '-1',
|
|
66
|
+
'ref': this.inputRef
|
|
67
|
+
}, getRestProps(this, rest))), 2, 'k-checkbox-wrapper')
|
|
68
|
+
}), children ? _$ce(2, 'span', children, 0, 'k-checkbox-text') : undefined]);
|
|
64
69
|
}
|
|
65
70
|
;
|
|
@@ -14,7 +14,7 @@ var defaults = {
|
|
|
14
14
|
},
|
|
15
15
|
|
|
16
16
|
get transition() {
|
|
17
|
-
return theme.transition;
|
|
17
|
+
return theme.transition.small;
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
bgColor: '#fff',
|
|
@@ -71,5 +71,5 @@ setDefault(function () {
|
|
|
71
71
|
}).checkbox;
|
|
72
72
|
});
|
|
73
73
|
export default function makeStyles() {
|
|
74
|
-
return /*#__PURE__*/css("display:inline-flex;align-items:center;cursor:pointer;vertical-align:middle;.k-checkbox-wrapper{
|
|
74
|
+
return /*#__PURE__*/css("display:inline-flex;align-items:center;cursor:pointer;vertical-align:middle;.k-checkbox-wrapper{width:", checkbox.width, ";height:", checkbox.width, ";border:1px solid ", checkbox.borderColor, ";border-radius:", checkbox.borderRadius, ";position:relative;transition:all ", checkbox.transition, ";background:", checkbox.bgColor, ";flex:0 0 auto;&:before{content:\"\";display:block;position:absolute;width:", checkbox.inner.width, ";height:", checkbox.inner.height, ";top:", checkbox.inner.top, ";left:", checkbox.inner.left, ";border:", checkbox.inner.border, ";border-top:0;border-left:0;transform:rotate(45deg) scale(0);transition:all ", checkbox.transition, ";}}input{width:100%;height:100%;opacity:0;cursor:pointer;position:absolute;left:0;top:0;margin:0;}.k-checkbox-text{margin-left:", checkbox.text.gap, ";flex:0 1 auto;}&.k-checked,&.k-indeterminate{.k-checkbox-wrapper{border-color:", checkbox.checked.borderColor, ";background:", checkbox.checked.bgColor, ";}}&.k-indeterminate{.k-checkbox-wrapper{&:before{transform:rotate(90deg) scale(1);border-bottom:0;left:", checkbox.indeterminate.innerLeft, ";}}}&.k-checked{.k-checkbox-wrapper{&:before{transform:rotate(45deg) scale(1);}}}&:focus{outline:none;.k-checkbox-wrapper{border-color:", checkbox.checked.borderColor, ";}}&.k-disabled{color:", checkbox.disabled.color, ";cursor:not-allowed;.k-checkbox-wrapper{border-color:", checkbox.disabled.borderColor, ";background:", checkbox.disabled.bgColor, ";&:before{border-color:", checkbox.disabled.innerColor, ";}}input{cursor:not-allowed;}}");
|
|
75
75
|
}
|
|
@@ -39,7 +39,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
39
39
|
|
|
40
40
|
return block ? block.call($this, callBlock, data) : callBlock();
|
|
41
41
|
}, __$blocks['title'](_$no)), _$cc(Icon, {
|
|
42
|
-
'className': _$cn((_$cn2 = {}, _$cn2[kls('arrow')] = true, _$cn2['ion-ios-arrow-right'] = true, _$cn2))
|
|
42
|
+
'className': _$cn((_$cn2 = {}, _$cn2[kls('arrow')] = true, _$cn2['ion-ios-arrow-right'] = true, _$cn2)),
|
|
43
|
+
'hoverable': !disabled
|
|
43
44
|
})], 0, _$cn(kls('title')), {
|
|
44
45
|
'ev-click': this.toggle
|
|
45
46
|
}), _$cc(Transition, _extends({
|
|
@@ -6,6 +6,10 @@ export var kls = function kls(className) {
|
|
|
6
6
|
return "k-collapse-" + className;
|
|
7
7
|
};
|
|
8
8
|
var defaults = {
|
|
9
|
+
get transition() {
|
|
10
|
+
return theme.transition.large;
|
|
11
|
+
},
|
|
12
|
+
|
|
9
13
|
fontSize: '12px',
|
|
10
14
|
titleMarginRight: '8px',
|
|
11
15
|
borderPadding: '0 24px',
|
|
@@ -27,5 +31,5 @@ export function makeStyles() {
|
|
|
27
31
|
}
|
|
28
32
|
export function makeItemStyles() {
|
|
29
33
|
var collapseItem = collapse.item;
|
|
30
|
-
return /*#__PURE__*/css("border-bottom:", collapseItem.borderBottom, ";&:last-of-type{border-bottom-color:transparent;}.", kls('title'), "{cursor:pointer;font-weight:bold;height:", collapseItem.titleHeight, ";line-height:", collapseItem.titleHeight, ";transition:color ",
|
|
34
|
+
return /*#__PURE__*/css("border-bottom:", collapseItem.borderBottom, ";&:last-of-type{border-bottom-color:transparent;}.", kls('title'), "{cursor:pointer;font-weight:bold;height:", collapseItem.titleHeight, ";line-height:", collapseItem.titleHeight, ";transition:color ", collapse.transition, ";}.", kls('arrow'), "{float:right;transition:transform ", collapse.transition, ";line-height:", collapseItem.titleHeight, ";height:", collapseItem.titleHeight, ";transform-origin:left center 0;}&:not(.k-disabled){.", kls('title'), "{&:hover{color:", theme.color.primary, ";}}}.", kls('content'), "{overflow:hidden;.", kls('wrapper'), "{overflow:hidden;padding:", collapseItem.contentPadding, ";}}&.k-active{.", kls('arrow'), "{transform:rotate(90deg);}}&.k-disabled{color:", theme.color.disabledBorder, ";.", kls('title'), "{cursor:not-allowed;}}");
|
|
31
35
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Component, TypeDefs } from 'intact-react';
|
|
2
2
|
import { Sizes } from '../../styles/utils';
|
|
3
|
+
import { Container } from '../portal';
|
|
3
4
|
export interface ColorpickerProps {
|
|
4
5
|
value: string;
|
|
5
6
|
presets?: string[];
|
|
6
7
|
size?: Sizes;
|
|
7
8
|
disabled?: boolean;
|
|
9
|
+
container?: Container;
|
|
8
10
|
}
|
|
9
11
|
export interface ColorpickerEvents {
|
|
10
12
|
}
|