@canlooks/can-ui 0.0.43 → 0.0.45
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/cjs/components/card/card.style.js +2 -2
- package/dist/cjs/components/form/form.d.ts +1 -1
- package/dist/cjs/components/placeholder/placeholder.js +3 -3
- package/dist/cjs/components/segmented/segmented.d.ts +3 -1
- package/dist/cjs/components/segmented/segmented.js +2 -2
- package/dist/cjs/components/segmented/segmented.style.d.ts +4 -1
- package/dist/cjs/components/segmented/segmented.style.js +94 -90
- package/dist/cjs/components/theme/themeVariables.js +6 -6
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/utils/style.js +5 -1
- package/dist/esm/components/card/card.style.js +2 -2
- package/dist/esm/components/form/form.d.ts +1 -1
- package/dist/esm/components/placeholder/placeholder.js +3 -3
- package/dist/esm/components/segmented/segmented.d.ts +3 -1
- package/dist/esm/components/segmented/segmented.js +3 -3
- package/dist/esm/components/segmented/segmented.style.d.ts +4 -1
- package/dist/esm/components/segmented/segmented.style.js +93 -90
- package/dist/esm/components/theme/themeVariables.js +6 -6
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/utils/style.js +5 -1
- package/documentation/dist/assets/{index-DXo4Z-bc.js → index-Dqm5gD_7.js} +387 -387
- package/documentation/dist/components/segmented.md +14 -13
- package/documentation/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -38,11 +38,11 @@ exports.style = (0, utils_1.defineCss)(({ spacing, mode, background, divider, bo
|
|
|
38
38
|
`
|
|
39
39
|
: (0, react_1.css) `
|
|
40
40
|
&[data-elevation="0"] {
|
|
41
|
-
background-color: ${gray(.
|
|
41
|
+
background-color: ${gray(.1)};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
&[data-elevation="1"] {
|
|
45
|
-
background-color: ${gray(.
|
|
45
|
+
background-color: ${gray(.14)};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
&[data-elevation="2"] {
|
|
@@ -49,7 +49,7 @@ export type FormRef<V extends FormValue = FormValue> = {
|
|
|
49
49
|
isFieldTouched(field: FieldPath): boolean;
|
|
50
50
|
};
|
|
51
51
|
export declare const Form: {
|
|
52
|
-
<V extends FormValue, C extends ElementType>(props: FormProps<V, C>): ReactElement;
|
|
52
|
+
<V extends FormValue, C extends ElementType = "form">(props: FormProps<V, C>): ReactElement;
|
|
53
53
|
Item: typeof FormItem;
|
|
54
54
|
Relatable: typeof FormRelatable;
|
|
55
55
|
};
|
|
@@ -15,15 +15,15 @@ exports.imagePreset = {
|
|
|
15
15
|
info: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAAAsTAAALEwEAmpwYAAAF7klEQVR4nO1dS28cRRAeY0GACA5IeYADp9iEEyIPEIcEBdmSY3vt6W5GSYTgyMVckj/g38HJCUg5jKd7RhayxD/AOXHgkt3p6dl1UA4cIzC3QbV+YByv7Xh6pqtn+5NKsrxjb3d9/aiuqq7xPAcHBwcHBwcHBwcHB0T4Ylm9Tnj+ri+eTrAkvUp4+iUT6haNZYvGOaNRdrsv8HMsW/3PEnUTnvWFnAh+Vuen19qnTPfDGgRhMUp4+4Ifp1dAmWwlvcuEKicr6V1fqFuE55eDsDcG32G6n8hQjARh+wzhvWuE51+VVvgRAt/hC/V5ED4Z84pixBtWBGE4SqN0nMbdVtVKHyT9pSxKx5eK4hVvWABLAF1Vl2isfFOKf5EI5dNIXWr88gTTnvBs3rTC2QDxRbawEHfe95qGqV+enaZJ74ZpBbPjzogouzG3+sebXhMAVg2YiaaVyk6wWQer8gPPVsDGtm1OGlcmK0VE75p1mzQcfgjvTplWHtMkNOlOBmHxmmcDgrD3Rv8QhUBxTOtMkLPo94Wvf2q/DZaEaWWxigT6Bn30sI58zCYm0yQLUcef+vG30x6+NV/OmlYOq0lorGbQ7AlgITRpw2XHFMLlFArriK2kV00rgxkSMLONKh+O7fWPvOxbX8iHhKsO4dk/W6I6lKsH8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DMD8/f2G73b5eROoSDfcDeF3PiA3bjPrm/YzeZwDwZEYAeqZ8VavoIaquxObrbJEehr4joGe7T+gjKkopvadwu1LqWpIXrP19AB7PCOH5QgG4IMgGoWu7/a5D+M52252GUMqmvUuClBB0R267zc5CAPBrKfsFLgrJR6NbM/2Mr19AdIvtdjZaSN5B8usextcnezfabp8TEobh+dHLrvXVqM2dTuea9f/0D/kpCFxyBQcLAAAAAElFTkSuQmCC'
|
|
17
17
|
};
|
|
18
|
-
exports.Placeholder = (0, react_1.memo)(({ slots
|
|
18
|
+
exports.Placeholder = (0, react_1.memo)(({ slots, slotProps, status = 'empty', image, title = status === 'warning' ? '警告'
|
|
19
19
|
: status === 'error' ? '出错啦'
|
|
20
20
|
: status === 'success' ? '成功'
|
|
21
21
|
: void 0, description = status === 'empty' ? '暂无数据'
|
|
22
22
|
: status === 'searching' ? '搜索中...'
|
|
23
23
|
: void 0, extra, ...props }) => {
|
|
24
24
|
const { mode } = (0, theme_1.useTheme)();
|
|
25
|
-
const { title: Title = 'div', description: Description = 'div', extra: Extra = 'div' } = slots;
|
|
26
|
-
const { title: titleProps, description: descriptionProps, extra: extraProps } = slotProps;
|
|
25
|
+
const { title: Title = 'div', description: Description = 'div', extra: Extra = 'div' } = slots || {};
|
|
26
|
+
const { title: titleProps, description: descriptionProps, extra: extraProps } = slotProps || {};
|
|
27
27
|
return ((0, jsx_runtime_1.jsxs)("div", { ...props, css: placeholder_style_1.style, className: (0, utils_1.clsx)(placeholder_style_1.classes.root, props.className), children: [image ??
|
|
28
28
|
(0, jsx_runtime_1.jsx)("img", { className: placeholder_style_1.classes.image, src: status === 'empty'
|
|
29
29
|
? (mode === 'light' ? exports.imagePreset.emptyLight : exports.imagePreset.emptyDark)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { DivProps, Id, Obj, Size } from '../../types';
|
|
2
|
+
import { ColorPropsValue, DivProps, Id, Obj, Size } from '../../types';
|
|
3
3
|
import { SegmentedOption, SegmentedOptionProps } from './SegmentedOption';
|
|
4
4
|
export type ISegmentedOption = SegmentedOptionProps & Obj;
|
|
5
5
|
export interface SegmentedProps<O extends ISegmentedOption, V extends Id = Id> extends Omit<DivProps, 'defaultValue' | 'onChange'> {
|
|
@@ -9,6 +9,8 @@ export interface SegmentedProps<O extends ISegmentedOption, V extends Id = Id> e
|
|
|
9
9
|
labelKey?: keyof O;
|
|
10
10
|
primaryKey?: keyof O;
|
|
11
11
|
fullWidth?: boolean;
|
|
12
|
+
/** 指示器的颜色,默认为`background.content` */
|
|
13
|
+
indicatorColor?: ColorPropsValue;
|
|
12
14
|
defaultValue?: V;
|
|
13
15
|
value?: V;
|
|
14
16
|
onChange?(value: V): void;
|
|
@@ -7,7 +7,7 @@ const segmented_style_1 = require("./segmented.style");
|
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
8
|
const SegmentedOption_1 = require("./SegmentedOption");
|
|
9
9
|
const theme_1 = require("../theme");
|
|
10
|
-
exports.Segmented = (0, react_1.memo)(({ options, orientation = 'horizontal', size, labelKey = 'label', primaryKey = 'value', fullWidth, defaultValue, value, onChange, readOnly, disabled, ...props }) => {
|
|
10
|
+
exports.Segmented = (0, react_1.memo)(({ options, orientation = 'horizontal', size, labelKey = 'label', primaryKey = 'value', fullWidth, indicatorColor = 'background.content', defaultValue, value, onChange, readOnly, disabled, ...props }) => {
|
|
11
11
|
const theme = (0, theme_1.useTheme)();
|
|
12
12
|
size ??= theme.size;
|
|
13
13
|
const [animating, setAnimating] = (0, react_1.useState)(false);
|
|
@@ -77,6 +77,6 @@ exports.Segmented = (0, react_1.memo)(({ options, orientation = 'horizontal', si
|
|
|
77
77
|
return c;
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ...props, css: segmented_style_1.
|
|
80
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ...props, css: (0, segmented_style_1.useStyle)({ indicatorColor }), className: (0, utils_1.clsx)(segmented_style_1.classes.root, props.className), "data-full-width": fullWidth, "data-animating": animating, "data-orientation": orientation, "data-size": size, "data-read-only": readOnly, "data-disabled": disabled, children: [(0, jsx_runtime_1.jsx)("div", { className: segmented_style_1.classes.indicator, onTransitionEnd: () => setAnimating(false), style: indicatorRect.current }), renderOptions()] }));
|
|
81
81
|
});
|
|
82
82
|
exports.Segmented.Option = SegmentedOption_1.SegmentedOption;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ColorPropsValue } from '../../types';
|
|
1
2
|
export declare const classes: {
|
|
2
3
|
label: string;
|
|
3
4
|
option: string;
|
|
@@ -7,4 +8,6 @@ export declare const classes: {
|
|
|
7
8
|
} & {
|
|
8
9
|
root: string;
|
|
9
10
|
};
|
|
10
|
-
export declare
|
|
11
|
+
export declare function useStyle({ indicatorColor }: {
|
|
12
|
+
indicatorColor: ColorPropsValue;
|
|
13
|
+
}): import("@emotion/react").SerializedStyles;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.classes = void 0;
|
|
4
|
+
exports.useStyle = useStyle;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const react_1 = require("@emotion/react");
|
|
6
7
|
const utils_1 = require("../../utils");
|
|
@@ -12,115 +13,118 @@ exports.classes = (0, utils_1.defineInnerClasses)('segmented', [
|
|
|
12
13
|
'suffix',
|
|
13
14
|
'indicator'
|
|
14
15
|
]);
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
position: relative;
|
|
25
|
-
|
|
26
|
-
.${exports.classes.option} {
|
|
27
|
-
display: flex;
|
|
28
|
-
align-items: center;
|
|
29
|
-
justify-content: center;
|
|
30
|
-
gap: 6px;
|
|
31
|
-
padding: 4px 12px;
|
|
16
|
+
function useStyle({ indicatorColor }) {
|
|
17
|
+
const indicatorColorValue = (0, utils_1.useColor)(indicatorColor);
|
|
18
|
+
return (0, utils_1.useCss)(({ mode, background, borderRadius, easing, text }) => {
|
|
19
|
+
const bgColor = (0, color_1.default)(background.body);
|
|
20
|
+
const hoverBg = bgColor.darken(mode === 'light' ? .04 : .12).hex();
|
|
21
|
+
const activeBg = bgColor.darken(mode === 'light' ? .08 : .24).hex();
|
|
22
|
+
return (0, react_1.css) `
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
background-color: ${background.body};
|
|
32
25
|
border-radius: ${borderRadius}px;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
overflow: hidden;
|
|
36
|
-
z-index: 1;
|
|
37
|
-
transition: background-color .3s ${easing.easeOut};
|
|
38
|
-
-webkit-tap-highlight-color: transparent;
|
|
39
|
-
|
|
40
|
-
&[data-active=true] {
|
|
41
|
-
transition: background-color 0s;
|
|
42
|
-
}
|
|
26
|
+
padding: 2px;
|
|
27
|
+
position: relative;
|
|
43
28
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
.${exports.classes.option} {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
gap: 6px;
|
|
34
|
+
padding: 4px 12px;
|
|
35
|
+
border-radius: ${borderRadius}px;
|
|
36
|
+
white-space: nowrap;
|
|
37
|
+
text-overflow: ellipsis;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
transition: background-color .3s ${easing.easeOut};
|
|
41
|
+
-webkit-tap-highlight-color: transparent;
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
}
|
|
43
|
+
&[data-active=true] {
|
|
44
|
+
transition: background-color 0s;
|
|
45
|
+
}
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}
|
|
47
|
+
&[data-orientation=vertical] {
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
}
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
&[data-disabled=true] {
|
|
52
|
+
cursor: not-allowed;
|
|
53
|
+
color: ${text.disabled};
|
|
54
|
+
}
|
|
63
55
|
}
|
|
64
|
-
}
|
|
65
56
|
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
&[data-size=small] {
|
|
58
|
+
.${exports.classes.option} {
|
|
59
|
+
padding: 3px 12px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
&[data-size=large] {
|
|
64
|
+
.${exports.classes.option} {
|
|
65
|
+
padding: 11px 12px;
|
|
66
|
+
}
|
|
71
67
|
}
|
|
72
|
-
}
|
|
73
68
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
69
|
+
&[data-full-width=true] {
|
|
70
|
+
display: flex;
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
position: absolute;
|
|
83
|
-
transition: all .3s ${easing.bounce};
|
|
84
|
-
}
|
|
72
|
+
.${exports.classes.option} {
|
|
73
|
+
flex: 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
85
76
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
transition: background-color 0s;
|
|
77
|
+
&[data-orientation=vertical] {
|
|
78
|
+
flex-direction: column;
|
|
89
79
|
}
|
|
90
|
-
}
|
|
91
80
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
background-color: ${
|
|
81
|
+
.${exports.classes.indicator} {
|
|
82
|
+
border-radius: ${borderRadius}px;
|
|
83
|
+
background-color: ${indicatorColorValue};
|
|
95
84
|
box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
|
|
85
|
+
position: absolute;
|
|
86
|
+
transition: all .3s ${easing.bounce};
|
|
96
87
|
}
|
|
97
|
-
}
|
|
98
88
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
&[data-animating=true] {
|
|
90
|
+
.${exports.classes.option} {
|
|
91
|
+
transition: background-color 0s;
|
|
92
|
+
}
|
|
102
93
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
&:not([data-active=true]):hover {
|
|
110
|
-
background-color: ${hoverBg};
|
|
94
|
+
|
|
95
|
+
&:not([data-animating=true]) {
|
|
96
|
+
.${exports.classes.option}[data-active=true] {
|
|
97
|
+
background-color: ${indicatorColorValue};
|
|
98
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
|
|
111
99
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&:not(:has([data-active=true])) {
|
|
103
|
+
.${exports.classes.indicator} {
|
|
104
|
+
display: none;
|
|
116
105
|
}
|
|
117
106
|
}
|
|
118
|
-
}
|
|
119
107
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
&:not([data-read-only=true]):not([data-disabled=true]) {
|
|
109
|
+
.${exports.classes.option}:not([data-disabled=true]) {
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
|
|
112
|
+
&:not([data-active=true]):hover {
|
|
113
|
+
background-color: ${hoverBg};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&:not([data-active=true]):active {
|
|
117
|
+
transition: background-color 0s;
|
|
118
|
+
background-color: ${activeBg};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&[data-disabled=true] {
|
|
124
|
+
.${exports.classes.option} {
|
|
125
|
+
cursor: not-allowed;
|
|
126
|
+
}
|
|
123
127
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
128
|
+
`;
|
|
129
|
+
}, [indicatorColorValue]);
|
|
130
|
+
}
|
|
@@ -185,15 +185,15 @@ exports.defaultLightTheme = {
|
|
|
185
185
|
exports.defaultDarkTheme = {
|
|
186
186
|
mode: 'dark',
|
|
187
187
|
background: {
|
|
188
|
-
/* content: rGray(.
|
|
189
|
-
content: '#
|
|
190
|
-
/* body: rGray(.
|
|
191
|
-
body: '#
|
|
188
|
+
/* content: rGray(.14), */
|
|
189
|
+
content: '#242424',
|
|
190
|
+
/* body: rGray(.1), */
|
|
191
|
+
body: '#1a1a1a',
|
|
192
192
|
fixed: 'rgba(255, 255, 255, .06)'
|
|
193
193
|
},
|
|
194
194
|
gray: rGray,
|
|
195
|
-
/* divider: rGray(.
|
|
196
|
-
divider: '#
|
|
195
|
+
/* divider: rGray(.28), */
|
|
196
|
+
divider: '#474747',
|
|
197
197
|
colors: {
|
|
198
198
|
/* primary: Color(defaultLightTheme.colors!.primary).lighten(.1).hex(), */
|
|
199
199
|
primary: '#3780EE',
|
package/dist/cjs/types.d.ts
CHANGED
package/dist/cjs/utils/style.js
CHANGED
|
@@ -71,7 +71,7 @@ function useCss(callback, deps) {
|
|
|
71
71
|
* @param theme
|
|
72
72
|
*/
|
|
73
73
|
function colorTransfer(colorPropsValue, theme) {
|
|
74
|
-
const { colors, text } = theme;
|
|
74
|
+
const { colors, text, background } = theme;
|
|
75
75
|
if (colorPropsValue in colors) {
|
|
76
76
|
return colors[colorPropsValue].main;
|
|
77
77
|
}
|
|
@@ -84,6 +84,10 @@ function colorTransfer(colorPropsValue, theme) {
|
|
|
84
84
|
return text[member];
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
if (colorPropsValue.startsWith('background')) {
|
|
88
|
+
const [, member] = colorPropsValue.split('.');
|
|
89
|
+
return background[member];
|
|
90
|
+
}
|
|
87
91
|
return colorPropsValue;
|
|
88
92
|
}
|
|
89
93
|
/**
|
|
@@ -35,11 +35,11 @@ export const style = defineCss(({ spacing, mode, background, divider, boxShadow,
|
|
|
35
35
|
`
|
|
36
36
|
: css `
|
|
37
37
|
&[data-elevation="0"] {
|
|
38
|
-
background-color: ${gray(.
|
|
38
|
+
background-color: ${gray(.1)};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
&[data-elevation="1"] {
|
|
42
|
-
background-color: ${gray(.
|
|
42
|
+
background-color: ${gray(.14)};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
&[data-elevation="2"] {
|
|
@@ -49,7 +49,7 @@ export type FormRef<V extends FormValue = FormValue> = {
|
|
|
49
49
|
isFieldTouched(field: FieldPath): boolean;
|
|
50
50
|
};
|
|
51
51
|
export declare const Form: {
|
|
52
|
-
<V extends FormValue, C extends ElementType>(props: FormProps<V, C>): ReactElement;
|
|
52
|
+
<V extends FormValue, C extends ElementType = "form">(props: FormProps<V, C>): ReactElement;
|
|
53
53
|
Item: typeof FormItem;
|
|
54
54
|
Relatable: typeof FormRelatable;
|
|
55
55
|
};
|
|
@@ -12,15 +12,15 @@ export const imagePreset = {
|
|
|
12
12
|
info: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAACXBIWXMAAAsTAAALEwEAmpwYAAAF7klEQVR4nO1dS28cRRAeY0GACA5IeYADp9iEEyIPEIcEBdmSY3vt6W5GSYTgyMVckj/g38HJCUg5jKd7RhayxD/AOXHgkt3p6dl1UA4cIzC3QbV+YByv7Xh6pqtn+5NKsrxjb3d9/aiuqq7xPAcHBwcHBwcHBwcHB0T4Ylm9Tnj+ri+eTrAkvUp4+iUT6haNZYvGOaNRdrsv8HMsW/3PEnUTnvWFnAh+Vuen19qnTPfDGgRhMUp4+4Ifp1dAmWwlvcuEKicr6V1fqFuE55eDsDcG32G6n8hQjARh+wzhvWuE51+VVvgRAt/hC/V5ED4Z84pixBtWBGE4SqN0nMbdVtVKHyT9pSxKx5eK4hVvWABLAF1Vl2isfFOKf5EI5dNIXWr88gTTnvBs3rTC2QDxRbawEHfe95qGqV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mIo90yn07mkco8uLmA/oG2oT6/v/JygnM+T7CWLyEMkv0/SrlZFH96d634AgFMJTkAcSFjeyahjHe1h+B161pwygscLBxC9psrqfgCApwx1jiilfkpR5hmSX+mjKnq5IerIB93AH3f6BQ6IVCmlIcUunhWoxULodrs32jYwkulLlgBo3Vv0i9vurICBhxLoTCMhkLy0DqkIqyOjqRwf3pdWJwp9n0xdICilntEjqMZFQrfbvawu6UhEtgJ4Rz8I3AKEBwuDMD8/f2G73b5eROoSDfcDeF3PiA3bjPrm/YzeZwDwZEYAeqZ8VavoIaquxObrbJEehr4joGe7T+gjKkopvadwu1LqWpIXrP19AB7PCOH5QgG4IMgGoWu7/a5D+M52252GUMqmvUuClBB0R267zc5CAPBrKfsFLgrJR6NbM/2Mr19AdIvtdjZaSN5B8usextcnezfabp8TEobh+dHLrvXVqM2dTuea9f/0D/kpCFxyBQcLAAAAAElFTkSuQmCC'
|
|
14
14
|
};
|
|
15
|
-
export const Placeholder = memo(({ slots
|
|
15
|
+
export const Placeholder = memo(({ slots, slotProps, status = 'empty', image, title = status === 'warning' ? '警告'
|
|
16
16
|
: status === 'error' ? '出错啦'
|
|
17
17
|
: status === 'success' ? '成功'
|
|
18
18
|
: void 0, description = status === 'empty' ? '暂无数据'
|
|
19
19
|
: status === 'searching' ? '搜索中...'
|
|
20
20
|
: void 0, extra, ...props }) => {
|
|
21
21
|
const { mode } = useTheme();
|
|
22
|
-
const { title: Title = 'div', description: Description = 'div', extra: Extra = 'div' } = slots;
|
|
23
|
-
const { title: titleProps, description: descriptionProps, extra: extraProps } = slotProps;
|
|
22
|
+
const { title: Title = 'div', description: Description = 'div', extra: Extra = 'div' } = slots || {};
|
|
23
|
+
const { title: titleProps, description: descriptionProps, extra: extraProps } = slotProps || {};
|
|
24
24
|
return (_jsxs("div", { ...props, css: style, className: clsx(classes.root, props.className), children: [image ??
|
|
25
25
|
_jsx("img", { className: classes.image, src: status === 'empty'
|
|
26
26
|
? (mode === 'light' ? imagePreset.emptyLight : imagePreset.emptyDark)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { DivProps, Id, Obj, Size } from '../../types';
|
|
2
|
+
import { ColorPropsValue, DivProps, Id, Obj, Size } from '../../types';
|
|
3
3
|
import { SegmentedOption, SegmentedOptionProps } from './SegmentedOption';
|
|
4
4
|
export type ISegmentedOption = SegmentedOptionProps & Obj;
|
|
5
5
|
export interface SegmentedProps<O extends ISegmentedOption, V extends Id = Id> extends Omit<DivProps, 'defaultValue' | 'onChange'> {
|
|
@@ -9,6 +9,8 @@ export interface SegmentedProps<O extends ISegmentedOption, V extends Id = Id> e
|
|
|
9
9
|
labelKey?: keyof O;
|
|
10
10
|
primaryKey?: keyof O;
|
|
11
11
|
fullWidth?: boolean;
|
|
12
|
+
/** 指示器的颜色,默认为`background.content` */
|
|
13
|
+
indicatorColor?: ColorPropsValue;
|
|
12
14
|
defaultValue?: V;
|
|
13
15
|
value?: V;
|
|
14
16
|
onChange?(value: V): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { Children, cloneElement, isValidElement, memo, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { classes,
|
|
3
|
+
import { classes, useStyle } from './segmented.style';
|
|
4
4
|
import { clsx, cloneRef, isUnset, useControlled, useDerivedState } from '../../utils';
|
|
5
5
|
import { SegmentedOption } from './SegmentedOption';
|
|
6
6
|
import { useTheme } from '../theme';
|
|
7
|
-
export const Segmented = memo(({ options, orientation = 'horizontal', size, labelKey = 'label', primaryKey = 'value', fullWidth, defaultValue, value, onChange, readOnly, disabled, ...props }) => {
|
|
7
|
+
export const Segmented = memo(({ options, orientation = 'horizontal', size, labelKey = 'label', primaryKey = 'value', fullWidth, indicatorColor = 'background.content', defaultValue, value, onChange, readOnly, disabled, ...props }) => {
|
|
8
8
|
const theme = useTheme();
|
|
9
9
|
size ??= theme.size;
|
|
10
10
|
const [animating, setAnimating] = useState(false);
|
|
@@ -74,6 +74,6 @@ export const Segmented = memo(({ options, orientation = 'horizontal', size, labe
|
|
|
74
74
|
return c;
|
|
75
75
|
});
|
|
76
76
|
};
|
|
77
|
-
return (_jsxs("div", { ...props, css:
|
|
77
|
+
return (_jsxs("div", { ...props, css: useStyle({ indicatorColor }), className: clsx(classes.root, props.className), "data-full-width": fullWidth, "data-animating": animating, "data-orientation": orientation, "data-size": size, "data-read-only": readOnly, "data-disabled": disabled, children: [_jsx("div", { className: classes.indicator, onTransitionEnd: () => setAnimating(false), style: indicatorRect.current }), renderOptions()] }));
|
|
78
78
|
});
|
|
79
79
|
Segmented.Option = SegmentedOption;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ColorPropsValue } from '../../types';
|
|
1
2
|
export declare const classes: {
|
|
2
3
|
label: string;
|
|
3
4
|
option: string;
|
|
@@ -7,4 +8,6 @@ export declare const classes: {
|
|
|
7
8
|
} & {
|
|
8
9
|
root: string;
|
|
9
10
|
};
|
|
10
|
-
export declare
|
|
11
|
+
export declare function useStyle({ indicatorColor }: {
|
|
12
|
+
indicatorColor: ColorPropsValue;
|
|
13
|
+
}): import("@emotion/react").SerializedStyles;
|