eoss 0.1.0-alpha.48 → 0.1.0-alpha.49
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/lib/dropdown-item.js +23 -4
- package/lib/eoss.common.js +29 -10
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/packages/dropdown/src/dropdown-item.vue +21 -3
- package/packages/theme-chalk/src/mixins/function.scss +61 -12
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- 根据rules
|
|
2
|
+
<!-- 根据rules条件决定是否渲染;表格操作列场景下行数据从 esButtonGroup 取 -->
|
|
3
3
|
<li
|
|
4
|
-
v-if="
|
|
4
|
+
v-if="checkRules()"
|
|
5
5
|
class="es-dropdown-menu__item"
|
|
6
6
|
:class="{
|
|
7
7
|
'is-disabled': disabled,
|
|
@@ -55,7 +55,11 @@ export default {
|
|
|
55
55
|
name: 'EsDropdownItem',
|
|
56
56
|
|
|
57
57
|
mixins: [Emitter],
|
|
58
|
-
inject:
|
|
58
|
+
inject: {
|
|
59
|
+
dropdownMenu: { default: null },
|
|
60
|
+
// 按钮组内使用时由 es-button-group provide;独立使用 dropdown 时为 null
|
|
61
|
+
esButtonGroup: { default: null }
|
|
62
|
+
},
|
|
59
63
|
components: { EsTooltip, EsIcon },
|
|
60
64
|
|
|
61
65
|
props: {
|
|
@@ -117,6 +121,20 @@ export default {
|
|
|
117
121
|
this.dropdownMenu.menuItemCreate(this.$el, this.divided);
|
|
118
122
|
},
|
|
119
123
|
methods: {
|
|
124
|
+
/**
|
|
125
|
+
* rules 校验:按钮组场景(表格操作列)用行数据调用,
|
|
126
|
+
* 否则 rules 拿到 undefined 会把本该显示的菜单项判掉
|
|
127
|
+
* @returns {Boolean} 是否渲染该菜单项
|
|
128
|
+
*/
|
|
129
|
+
checkRules() {
|
|
130
|
+
if (!this.rules) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
if (this.esButtonGroup) {
|
|
134
|
+
return this.rules(this.esButtonGroup.data, this.esButtonGroup.rowData);
|
|
135
|
+
}
|
|
136
|
+
return this.rules(this.param);
|
|
137
|
+
},
|
|
120
138
|
/**
|
|
121
139
|
* 处理点击事件
|
|
122
140
|
* @param {Event} evt - 点击事件对象
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@use 'sass:color';
|
|
2
2
|
@use 'sass:string';
|
|
3
|
+
@use 'sass:math';
|
|
3
4
|
|
|
4
5
|
@import 'config.scss';
|
|
5
6
|
|
|
@@ -85,25 +86,73 @@
|
|
|
85
86
|
|
|
86
87
|
/* Custom mix function for CSS variables
|
|
87
88
|
-------------------------- */
|
|
89
|
+
$_hex-digits: '0123456789abcdef';
|
|
90
|
+
|
|
91
|
+
/* 解析 hex 串中第 $i、$i+1 位(1 起)组成的字节值 */
|
|
92
|
+
@function hex-pair($hex, $i) {
|
|
93
|
+
$d1: string.index($_hex-digits, string.slice($hex, $i, $i)) - 1;
|
|
94
|
+
$d2: string.index($_hex-digits, string.slice($hex, $i + 1, $i + 1)) - 1;
|
|
95
|
+
@return $d1 * 16 + $d2;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* 编译期按权重混合两个 hex 串($weight 为 $hex1 占比),返回 hex 串;
|
|
99
|
+
供主题变量场景产出回退色,sass 原生 mix 吃不了字符串 */
|
|
100
|
+
@function mix-hex($hex1, $hex2, $weight) {
|
|
101
|
+
$hex1: string.to-lower-case('#{$hex1}');
|
|
102
|
+
$hex2: string.to-lower-case('#{$hex2}');
|
|
103
|
+
@if string.slice($hex1, 1, 1) == '#' {
|
|
104
|
+
$hex1: string.slice($hex1, 2);
|
|
105
|
+
}
|
|
106
|
+
@if string.slice($hex2, 1, 1) == '#' {
|
|
107
|
+
$hex2: string.slice($hex2, 2);
|
|
108
|
+
}
|
|
109
|
+
$w: math.div($weight, 1%);
|
|
110
|
+
$out: '#';
|
|
111
|
+
@for $i from 0 to 3 {
|
|
112
|
+
$p: 1 + $i * 2;
|
|
113
|
+
$v1: hex-pair($hex1, $p);
|
|
114
|
+
$v2: hex-pair($hex2, $p);
|
|
115
|
+
$v: math.round(math.div($v1 * $w + $v2 * (100 - $w), 100));
|
|
116
|
+
$hi: math.floor(math.div($v, 16));
|
|
117
|
+
$lo: $v % 16;
|
|
118
|
+
$out: '#{$out}#{string.slice($_hex-digits, $hi + 1, $hi + 1)}#{string.slice($_hex-digits, $lo + 1, $lo + 1)}';
|
|
119
|
+
}
|
|
120
|
+
@return $out;
|
|
121
|
+
}
|
|
122
|
+
|
|
88
123
|
@function custom-mix($color1, $color2, $weight: 50%) {
|
|
89
124
|
// 提取默认颜色
|
|
90
125
|
$color1-extracted: extract-default-color($color1);
|
|
91
126
|
$color2-extracted: extract-default-color($color2);
|
|
92
127
|
|
|
93
|
-
//
|
|
94
|
-
@if type-of($color1-extracted)
|
|
95
|
-
'string'
|
|
96
|
-
type-of($color2-extracted)
|
|
128
|
+
// 两边都是实色时走原生 mix
|
|
129
|
+
@if type-of($color1-extracted) !=
|
|
130
|
+
'string' and
|
|
131
|
+
type-of($color2-extracted) !=
|
|
97
132
|
'string'
|
|
98
133
|
{
|
|
99
|
-
|
|
100
|
-
@if type-of($color2) == 'string' and string.index($color2, 'var(') != null {
|
|
101
|
-
@return $color2;
|
|
102
|
-
}
|
|
103
|
-
// 否则返回第一个颜色
|
|
104
|
-
@return $color1;
|
|
134
|
+
@return color.mix($color1-extracted, $color2-extracted, $weight);
|
|
105
135
|
}
|
|
106
136
|
|
|
107
|
-
//
|
|
108
|
-
|
|
137
|
+
// 主题变量场景:编译期用默认色混出回退值,
|
|
138
|
+
// 不能直接返回原色(plain 背景会塌成主色自身,与文字同色)
|
|
139
|
+
$fallback: mix-hex($color1-extracted, $color2-extracted, $weight);
|
|
140
|
+
|
|
141
|
+
// 白 × 主题主色 的淡色:接 updateTheme 运行时设置的色板变量。
|
|
142
|
+
// 色板编号是 ant 式:1-5 浅色阶、6 基色、7-10 深色阶,
|
|
143
|
+
// 白混比例到浅色阶位置对应为 90%→1 … 50%→5,超出范围只落回退值
|
|
144
|
+
@if type-of($color2) ==
|
|
145
|
+
'string' and
|
|
146
|
+
string.index($color2, 'var(') !=
|
|
147
|
+
null and
|
|
148
|
+
string.index('#{$color1-extracted}', 'ffffff') !=
|
|
149
|
+
null
|
|
150
|
+
{
|
|
151
|
+
$level: 10 - math.div($weight, 10%);
|
|
152
|
+
@if $level >= 1 and $level <= 5 and math.round($level) == $level {
|
|
153
|
+
$varname: string.slice($color2, 5, string.index($color2, ',') - 1);
|
|
154
|
+
@return string.unquote('var(#{$varname}-light-#{$level}, #{$fallback})');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
@return string.unquote($fallback);
|
|
109
158
|
}
|