plain-design 1.0.0-beta.146 → 1.0.0-beta.148
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/plain-design.commonjs.min.js +1 -1
- package/dist/plain-design.min.css +2 -1
- package/dist/plain-design.min.js +1 -1
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/packages/components/$ai/index.tsx +227 -227
- package/src/packages/components/ColorPicker/ColorPanel.tsx +146 -125
- package/src/packages/components/ColorPicker/color-panel.scss +117 -97
- package/src/packages/components/ColorPicker/index.tsx +144 -131
- package/src/packages/components/Icon/icon.external.tsx +6 -0
- package/src/packages/components/IconPicker/DefaultIcons.ts +7 -0
- package/src/packages/components/IconPicker/icon-picker.scss +43 -0
- package/src/packages/components/IconPicker/index.tsx +189 -0
- package/src/packages/components/VirtualList/useVirtualList.tsx +1 -1
- package/src/packages/entry.tsx +323 -322
- package/src/packages/i18n/lang/en-us.ts +7 -0
- package/src/packages/i18n/lang/zh-cn.ts +7 -0
- package/src/packages/uses/createInputPopperAttrs.ts +9 -2
- package/src/packages/utils/installAllIcons.ts +20 -19
|
@@ -1,125 +1,146 @@
|
|
|
1
|
-
import './color-panel.scss';
|
|
2
|
-
import {designComponent, getComponentCls, iMouseEvent, reactive, useModel} from "@peryl/react-compose";
|
|
3
|
-
import {ColorSvPanel} from "./sub/ColorSvPanel";
|
|
4
|
-
import {ColorHueSlider} from "./sub/ColorHueSlider";
|
|
5
|
-
import {ColorAlphaSlider} from "./sub/ColorAlphaSlider";
|
|
6
|
-
import {PlainColor} from "./utils/PlainColor";
|
|
7
|
-
import {useColorPanelEditor} from "./useColorPanelEditor";
|
|
8
|
-
import {useColorPanelHistory} from "./useColorPanelHistory";
|
|
9
|
-
import {ColorPanelPublicPropOptions} from "./utils/color-picker.utils";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
import './color-panel.scss';
|
|
2
|
+
import {designComponent, getComponentCls, iMouseEvent, reactive, useModel} from "@peryl/react-compose";
|
|
3
|
+
import {ColorSvPanel} from "./sub/ColorSvPanel";
|
|
4
|
+
import {ColorHueSlider} from "./sub/ColorHueSlider";
|
|
5
|
+
import {ColorAlphaSlider} from "./sub/ColorAlphaSlider";
|
|
6
|
+
import {PlainColor} from "./utils/PlainColor";
|
|
7
|
+
import {useColorPanelEditor} from "./useColorPanelEditor";
|
|
8
|
+
import {useColorPanelHistory} from "./useColorPanelHistory";
|
|
9
|
+
import {ColorPanelPublicPropOptions} from "./utils/color-picker.utils";
|
|
10
|
+
import {Icon} from "../Icon";
|
|
11
|
+
import {$message} from "../$message";
|
|
12
|
+
import {i18n} from "../i18n";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const ColorPanel = designComponent({
|
|
16
|
+
name: 'color-panel',
|
|
17
|
+
props: {
|
|
18
|
+
...ColorPanelPublicPropOptions
|
|
19
|
+
},
|
|
20
|
+
emits: {
|
|
21
|
+
onUpdateModelValue: (val: any) => true,
|
|
22
|
+
onDblclickSvPanel: (e: iMouseEvent) => true,
|
|
23
|
+
},
|
|
24
|
+
inheritPropsType: HTMLDivElement,
|
|
25
|
+
setup({ props, event: { emit } }) {
|
|
26
|
+
|
|
27
|
+
const model = useModel(() => props.modelValue, emit.onUpdateModelValue, {
|
|
28
|
+
onChange: (value) => {
|
|
29
|
+
const prev = state.colorState;
|
|
30
|
+
const colorState = utils.getState(value, prev);
|
|
31
|
+
if (colorState !== prev) {
|
|
32
|
+
state.colorState = colorState;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const utils = {
|
|
38
|
+
getState: (value: string | null | undefined, prev?: iColorState): iColorState => {
|
|
39
|
+
if (!prev) {
|
|
40
|
+
return { color: new PlainColor(value || '#FFFFFF'), value };
|
|
41
|
+
} else {
|
|
42
|
+
if (prev.value == value) {
|
|
43
|
+
return prev;
|
|
44
|
+
} else {
|
|
45
|
+
return { color: new PlainColor(value || '#FFFFFF'), value };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const state = reactive({
|
|
52
|
+
colorState: utils.getState(model.value)
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const handler = {
|
|
56
|
+
svChange: ({ value, saturation }: { value: number, saturation: number }) => {
|
|
57
|
+
const color = state.colorState.color.useHsva({ v: value, s: saturation });
|
|
58
|
+
state.colorState = { color, value: color.value };
|
|
59
|
+
model.value = state.colorState.value!;
|
|
60
|
+
},
|
|
61
|
+
hueChange: (hue: number) => {
|
|
62
|
+
const color = state.colorState.color.useHsva({ h: hue });
|
|
63
|
+
state.colorState = { color, value: color.value };
|
|
64
|
+
model.value = state.colorState.value!;
|
|
65
|
+
},
|
|
66
|
+
alphaChange: (alpha: number) => {
|
|
67
|
+
const color = state.colorState.color.useHsva({ a: alpha / 100 });
|
|
68
|
+
state.colorState = { color, value: color.value };
|
|
69
|
+
model.value = state.colorState.value!;
|
|
70
|
+
},
|
|
71
|
+
dropColor: () => {
|
|
72
|
+
if (!('EyeDropper' in window)) {
|
|
73
|
+
$message.error(i18n.$it('colorPicker.notSupportDropper').d('您的浏览器不支持颜色拾取器,推荐使用谷歌浏览器'));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const close = $message(i18n.$it('colorPicker.exitDropperMode').d('按 ESC 键关闭取色吸管'), { time: null });
|
|
77
|
+
const eyeDropper = new (window as any).EyeDropper();
|
|
78
|
+
eyeDropper.open().then((result: { sRGBHex: string }) => {
|
|
79
|
+
state.colorState = utils.getState(result.sRGBHex);
|
|
80
|
+
model.value = state.colorState.value!;
|
|
81
|
+
close();
|
|
82
|
+
}).catch(() => {
|
|
83
|
+
close();
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const editor = useColorPanelEditor({
|
|
89
|
+
props,
|
|
90
|
+
getColor: () => state.colorState.color,
|
|
91
|
+
onChange: color => {
|
|
92
|
+
state.colorState = { color, value: color.value };
|
|
93
|
+
model.value = color.value;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const history = useColorPanelHistory({
|
|
98
|
+
onChange: color => {
|
|
99
|
+
state.colorState = { color, value: color.value };
|
|
100
|
+
model.value = color.value;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
render: () => (
|
|
106
|
+
<div className={getComponentCls('color-panel')}>
|
|
107
|
+
<div className="color-panel-card">
|
|
108
|
+
<ColorSvPanel
|
|
109
|
+
hue={state.colorState.color.h}
|
|
110
|
+
modelValue={state.colorState.color.v}
|
|
111
|
+
saturation={state.colorState.color.s}
|
|
112
|
+
onChange={handler.svChange}
|
|
113
|
+
onDblclick={emit.onDblclickSvPanel}
|
|
114
|
+
disable={props.disableSvPanel}
|
|
115
|
+
/>
|
|
116
|
+
<div className="color-panel-slider-bar">
|
|
117
|
+
<div className="color-panel-dropper" onClick={handler.dropColor}>
|
|
118
|
+
<Icon icon="ie-dropper"/>
|
|
119
|
+
</div>
|
|
120
|
+
<div className="color-panel-slider-container">
|
|
121
|
+
<ColorHueSlider
|
|
122
|
+
modelValue={state.colorState.color.h}
|
|
123
|
+
onChange={handler.hueChange}
|
|
124
|
+
/>
|
|
125
|
+
<ColorAlphaSlider
|
|
126
|
+
color={state.colorState.color.hex}
|
|
127
|
+
modelValue={state.colorState.color.a * 100}
|
|
128
|
+
onChange={handler.alphaChange}
|
|
129
|
+
disabled={!props.enableAlpha}
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
<div className="color-panel-slider-color" style={{ backgroundColor: state.colorState.color.hex }}/>
|
|
133
|
+
</div>
|
|
134
|
+
{editor.renderContent.value()}
|
|
135
|
+
</div>
|
|
136
|
+
{history.renderContent.value()}
|
|
137
|
+
</div>
|
|
138
|
+
)
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
interface iColorState {
|
|
144
|
+
color: PlainColor,
|
|
145
|
+
value: string | null | undefined
|
|
146
|
+
}
|
|
@@ -1,97 +1,117 @@
|
|
|
1
|
-
@include prefix(color-panel) {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
align-items: stretch;
|
|
5
|
-
justify-content: flex-start;
|
|
6
|
-
border: solid 1px plv(border-color);
|
|
7
|
-
background-color: plv(background-light);
|
|
8
|
-
|
|
9
|
-
.color-panel-card {
|
|
10
|
-
padding: 10px 10px 0;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.color-panel-slider-bar {
|
|
14
|
-
display: flex;
|
|
15
|
-
|
|
16
|
-
.color-panel-slider-container {
|
|
17
|
-
flex: 1;
|
|
18
|
-
overflow: hidden;
|
|
19
|
-
|
|
20
|
-
@include comp(color-slider) {
|
|
21
|
-
margin-top: 4px;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.color-panel-slider-color {
|
|
26
|
-
margin-top: 4px;
|
|
27
|
-
height: 24px;
|
|
28
|
-
width: 24px;
|
|
29
|
-
margin-left: 4px;
|
|
30
|
-
border-radius: plv(box-size-small-border-radius);
|
|
31
|
-
box-shadow: rgb(0 0 0 / 15%) 0 0 0 1px inset, rgb(0 0 0 / 25%) 0 0 4px inset;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
@include prefix(color-panel) {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: stretch;
|
|
5
|
+
justify-content: flex-start;
|
|
6
|
+
border: solid 1px plv(border-color);
|
|
7
|
+
background-color: plv(background-light);
|
|
8
|
+
|
|
9
|
+
.color-panel-card {
|
|
10
|
+
padding: 10px 10px 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.color-panel-slider-bar {
|
|
14
|
+
display: flex;
|
|
15
|
+
|
|
16
|
+
.color-panel-slider-container {
|
|
17
|
+
flex: 1;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
|
|
20
|
+
@include comp(color-slider) {
|
|
21
|
+
margin-top: 4px;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.color-panel-slider-color {
|
|
26
|
+
margin-top: 4px;
|
|
27
|
+
height: 24px;
|
|
28
|
+
width: 24px;
|
|
29
|
+
margin-left: 4px;
|
|
30
|
+
border-radius: plv(box-size-small-border-radius);
|
|
31
|
+
box-shadow: rgb(0 0 0 / 15%) 0 0 0 1px inset, rgb(0 0 0 / 25%) 0 0 4px inset;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.color-panel-dropper {
|
|
35
|
+
margin-top: 4px;
|
|
36
|
+
height: 24px;
|
|
37
|
+
width: 24px;
|
|
38
|
+
margin-right: 4px;
|
|
39
|
+
border-radius: plv(box-size-small-border-radius);
|
|
40
|
+
//box-shadow: rgb(0 0 0 / 15%) 0 0 0 1px inset, rgb(0 0 0 / 25%) 0 0 4px inset;
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
background-color: plv(secondary-light-2);
|
|
45
|
+
transition: all ease 300ms;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
|
|
48
|
+
&:hover {
|
|
49
|
+
background-color: plv(primary-6);
|
|
50
|
+
color: plv(pbfc);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.color-panel-editor {
|
|
56
|
+
margin-top: 4px;
|
|
57
|
+
font-size: 12px;
|
|
58
|
+
width: 200px;
|
|
59
|
+
|
|
60
|
+
$hexWidth: 60px;
|
|
61
|
+
|
|
62
|
+
& > div {
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
width: calc((200px - #{$hexWidth}) / 4);
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
|
|
70
|
+
&:first-child {
|
|
71
|
+
width: $hexWidth;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&:not(:first-child) {
|
|
75
|
+
padding-left: 6px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
input {
|
|
79
|
+
margin-bottom: 4px;
|
|
80
|
+
width: 100%;
|
|
81
|
+
font-size: 12px;
|
|
82
|
+
height: 20px;
|
|
83
|
+
padding: 0;
|
|
84
|
+
border-radius: 0;
|
|
85
|
+
box-shadow: #{plv(secondary-4)} 0 0 0 1px inset;
|
|
86
|
+
border: none;
|
|
87
|
+
outline: none;
|
|
88
|
+
text-align: center;
|
|
89
|
+
background-color: plv(background-light);
|
|
90
|
+
color: plv(text-2);
|
|
91
|
+
border-radius: plv(box-size-small-border-radius);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.color-panel-history {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-wrap: wrap;
|
|
99
|
+
width: 200px;
|
|
100
|
+
margin-top: 5px;
|
|
101
|
+
border-top: solid 1px plv(border-color);
|
|
102
|
+
padding: 10px 10px 0;
|
|
103
|
+
|
|
104
|
+
.color-panel-history-item {
|
|
105
|
+
height: 16px;
|
|
106
|
+
width: 16px;
|
|
107
|
+
margin-bottom: 10px;
|
|
108
|
+
box-shadow: rgba(0, 0, 0, 0.15) 0 0 0 1px inset, rgba(0, 0, 0, 0.25) 0 0 4px inset;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
border-radius: plv(box-size-small-border-radius);
|
|
111
|
+
|
|
112
|
+
&:not(:nth-child(8n)) {
|
|
113
|
+
margin-right: 10px;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|