@jetlinks-web/components 3.2.5 → 3.2.6
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/es/AutoComplete/AutoComplete.js +144 -42
- package/es/ProLayout/Basic/BasicLayout.js +2 -0
- package/es/ProLayout/Basic/Header.js +7 -0
- package/es/ProLayout/TopHeader/index.js +10 -1
- package/es/ProLayout/TopHeader/style.js +5 -1
- package/lib/AutoComplete/AutoComplete.js +144 -42
- package/lib/ProLayout/Basic/BasicLayout.js +2 -0
- package/lib/ProLayout/Basic/Header.js +7 -0
- package/lib/ProLayout/TopHeader/index.js +10 -1
- package/lib/ProLayout/TopHeader/style.js +5 -1
- package/package.json +2 -2
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) {
|
|
2
|
+
return lhs;
|
|
3
|
+
}
|
|
4
|
+
else {
|
|
5
|
+
return rhsFn();
|
|
6
|
+
} }
|
|
1
7
|
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
|
|
2
8
|
const op = ops[i];
|
|
3
9
|
const fn = ops[i + 1];
|
|
@@ -17,6 +23,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
|
|
|
17
23
|
/* Analyzed bindings: {
|
|
18
24
|
"searchKey": "props",
|
|
19
25
|
"multiple": "props",
|
|
26
|
+
"AutoComplete": "setup-maybe-ref",
|
|
20
27
|
"Select": "setup-maybe-ref",
|
|
21
28
|
"selectProps": "setup-maybe-ref",
|
|
22
29
|
"ref": "setup-const",
|
|
@@ -25,15 +32,25 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
|
|
|
25
32
|
"props": "setup-reactive-const",
|
|
26
33
|
"emit": "setup-const",
|
|
27
34
|
"myValue": "setup-ref",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
35
|
+
"searchValue": "setup-ref",
|
|
36
|
+
"customOptions": "setup-ref",
|
|
37
|
+
"isEmpty": "setup-const",
|
|
38
|
+
"normalizeText": "setup-const",
|
|
39
|
+
"isOptionMatched": "setup-const",
|
|
40
|
+
"componentProps": "setup-ref",
|
|
41
|
+
"mergedOptions": "setup-ref",
|
|
42
|
+
"displayOptions": "setup-ref",
|
|
43
|
+
"appendCustomOption": "setup-const",
|
|
31
44
|
"handleSearch": "setup-const",
|
|
32
|
-
"
|
|
45
|
+
"handleMultipleChange": "setup-const",
|
|
46
|
+
"handleSingleChange": "setup-const",
|
|
47
|
+
"handleSingleBlur": "setup-const",
|
|
48
|
+
"onSelect": "setup-const",
|
|
49
|
+
"normalizeValueByMode": "setup-const"
|
|
33
50
|
} */
|
|
34
51
|
import { defineComponent as _defineComponent } from 'vue';
|
|
35
|
-
import { unref as _unref, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock } from "vue";
|
|
36
|
-
import { Select } from 'ant-design-vue';
|
|
52
|
+
import { unref as _unref, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock, } from "vue";
|
|
53
|
+
import { AutoComplete, Select } from 'ant-design-vue';
|
|
37
54
|
import { selectProps } from 'ant-design-vue/lib/select';
|
|
38
55
|
import { ref, watch, computed, } from 'vue';
|
|
39
56
|
const __sfc_main__ = _defineComponent({
|
|
@@ -56,52 +73,137 @@ const __sfc_main__ = _defineComponent({
|
|
|
56
73
|
const props = __props;
|
|
57
74
|
const emit = __emit;
|
|
58
75
|
const myValue = ref();
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
const searchValue = ref('');
|
|
77
|
+
const customOptions = ref([]);
|
|
78
|
+
const isEmpty = (val) => val === undefined || val === null || val === '';
|
|
79
|
+
const normalizeText = (val) => {
|
|
80
|
+
if (isEmpty(val)) {
|
|
81
|
+
return '';
|
|
64
82
|
}
|
|
83
|
+
if (typeof val === 'object' && val !== null && 'value' in val) {
|
|
84
|
+
return String(_nullishCoalesce(val.value, () => (''))).trim();
|
|
85
|
+
}
|
|
86
|
+
return String(val).trim();
|
|
87
|
+
};
|
|
88
|
+
const isOptionMatched = (option, keyword) => {
|
|
89
|
+
const optionValue = normalizeText(_optionalChain([option, 'optionalAccess', _ => _.value]));
|
|
90
|
+
const optionLabel = normalizeText(_nullishCoalesce(_optionalChain([option, 'optionalAccess', _2 => _2[props.searchKey]]), () => (_optionalChain([option, 'optionalAccess', _3 => _3.label]))));
|
|
91
|
+
return optionValue === keyword || optionLabel === keyword;
|
|
65
92
|
};
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
const componentProps = computed(() => {
|
|
94
|
+
const { multiple, searchKey, options, value, mode, ...rest } = props;
|
|
95
|
+
return rest;
|
|
96
|
+
});
|
|
97
|
+
const mergedOptions = computed(() => {
|
|
98
|
+
const baseOptions = Array.isArray(props.options)
|
|
99
|
+
? (props.options)
|
|
100
|
+
: [];
|
|
101
|
+
const result = [];
|
|
102
|
+
const keys = new Set();
|
|
103
|
+
[...customOptions.value, ...baseOptions].forEach((option) => {
|
|
104
|
+
const key = normalizeText(_optionalChain([option, 'optionalAccess', _4 => _4.value]) || _optionalChain([option, 'optionalAccess', _5 => _5[props.searchKey]]) || _optionalChain([option, 'optionalAccess', _6 => _6.label]));
|
|
105
|
+
if (!key || keys.has(key)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
keys.add(key);
|
|
109
|
+
result.push(option);
|
|
110
|
+
});
|
|
111
|
+
return result;
|
|
112
|
+
});
|
|
113
|
+
const displayOptions = computed(() => {
|
|
114
|
+
const keyword = normalizeText(searchValue.value);
|
|
115
|
+
if (!keyword) {
|
|
116
|
+
return mergedOptions.value;
|
|
71
117
|
}
|
|
72
|
-
|
|
73
|
-
|
|
118
|
+
const exists = mergedOptions.value.some((option) => isOptionMatched(option, keyword));
|
|
119
|
+
if (exists) {
|
|
120
|
+
return mergedOptions.value;
|
|
121
|
+
}
|
|
122
|
+
return [{ label: keyword, value: keyword }, ...mergedOptions.value];
|
|
74
123
|
});
|
|
75
|
-
const
|
|
76
|
-
|
|
124
|
+
const appendCustomOption = (val) => {
|
|
125
|
+
const keyword = normalizeText(val);
|
|
126
|
+
if (!keyword) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const exists = mergedOptions.value.some((option) => isOptionMatched(option, keyword));
|
|
130
|
+
if (exists) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
customOptions.value = [{ label: keyword, value: keyword }, ...customOptions.value];
|
|
134
|
+
};
|
|
135
|
+
const handleSearch = (val) => {
|
|
136
|
+
searchValue.value = normalizeText(val);
|
|
137
|
+
};
|
|
138
|
+
const handleMultipleChange = (val) => {
|
|
139
|
+
const nextValue = Array.isArray(val)
|
|
140
|
+
? val
|
|
141
|
+
: isEmpty(val)
|
|
142
|
+
? []
|
|
143
|
+
: [val];
|
|
144
|
+
nextValue.forEach((item) => appendCustomOption(item));
|
|
145
|
+
myValue.value = nextValue;
|
|
146
|
+
emit('update:value', nextValue);
|
|
147
|
+
emit('change', nextValue);
|
|
148
|
+
};
|
|
149
|
+
const handleSingleChange = (val) => {
|
|
150
|
+
const nextValue = isEmpty(val) ? undefined : val;
|
|
151
|
+
myValue.value = nextValue;
|
|
152
|
+
emit('update:value', nextValue);
|
|
153
|
+
emit('change', nextValue);
|
|
154
|
+
};
|
|
155
|
+
const handleSingleBlur = () => {
|
|
156
|
+
appendCustomOption(myValue.value);
|
|
77
157
|
};
|
|
78
158
|
const onSelect = (val, option) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
159
|
+
appendCustomOption(val);
|
|
160
|
+
emit('select', val, option);
|
|
161
|
+
};
|
|
162
|
+
const normalizeValueByMode = (val) => {
|
|
163
|
+
if (isEmpty(val)) {
|
|
164
|
+
return props.multiple ? [] : undefined;
|
|
84
165
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
166
|
+
if (props.multiple) {
|
|
167
|
+
return Array.isArray(val) ? val : [val];
|
|
168
|
+
}
|
|
169
|
+
return Array.isArray(val) ? val[val.length - 1] : val;
|
|
88
170
|
};
|
|
89
|
-
watch(() => props.value, (val) => {
|
|
90
|
-
|
|
171
|
+
watch([() => props.value, () => props.multiple], ([val]) => {
|
|
172
|
+
const nextValue = normalizeValueByMode(val);
|
|
173
|
+
myValue.value = nextValue;
|
|
174
|
+
if (Array.isArray(nextValue)) {
|
|
175
|
+
nextValue.forEach((item) => appendCustomOption(item));
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
appendCustomOption(nextValue);
|
|
179
|
+
}
|
|
91
180
|
}, { immediate: true });
|
|
92
181
|
return (_ctx, _cache) => {
|
|
93
|
-
return (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
182
|
+
return (props.multiple)
|
|
183
|
+
? (_openBlock(), _createBlock(_unref(Select), _mergeProps({
|
|
184
|
+
key: 0,
|
|
185
|
+
value: myValue.value,
|
|
186
|
+
allowClear: ""
|
|
187
|
+
}, componentProps.value, {
|
|
188
|
+
mode: "tags",
|
|
189
|
+
options: displayOptions.value,
|
|
190
|
+
style: { "width": "100%" },
|
|
191
|
+
onSelect: onSelect,
|
|
192
|
+
onSearch: handleSearch,
|
|
193
|
+
onChange: handleMultipleChange
|
|
194
|
+
}), null, 16 /* FULL_PROPS */, ["value", "options"]))
|
|
195
|
+
: (_openBlock(), _createBlock(_unref(AutoComplete), _mergeProps({
|
|
196
|
+
key: 1,
|
|
197
|
+
value: myValue.value,
|
|
198
|
+
allowClear: ""
|
|
199
|
+
}, componentProps.value, {
|
|
200
|
+
options: displayOptions.value,
|
|
201
|
+
style: { "width": "100%" },
|
|
202
|
+
onSelect: onSelect,
|
|
203
|
+
onSearch: handleSearch,
|
|
204
|
+
onChange: handleSingleChange,
|
|
205
|
+
onBlur: handleSingleBlur
|
|
206
|
+
}), null, 16 /* FULL_PROPS */, ["value", "options"]));
|
|
105
207
|
};
|
|
106
208
|
}
|
|
107
209
|
});
|
|
@@ -210,6 +210,7 @@ export default defineComponent({
|
|
|
210
210
|
var collapsedButtonRender = getSlot(slots, props, 'collapsedButtonRender');
|
|
211
211
|
var headerContentRender = getSlot(slots, props, 'headerContentRender');
|
|
212
212
|
var rightContentRender = getSlot(slots, props, 'rightContentRender');
|
|
213
|
+
var leftContentRender = getSlot(slots, props, 'leftContentRender');
|
|
213
214
|
var customHeaderRender = getSlot(slots, props, 'headerRender');
|
|
214
215
|
// menu
|
|
215
216
|
var menuHeaderRender = getSlot(slots, props, 'menuHeaderRender');
|
|
@@ -232,6 +233,7 @@ export default defineComponent({
|
|
|
232
233
|
onSelect: onSelect,
|
|
233
234
|
onMenuHeaderClick: onMenuHeaderClick,
|
|
234
235
|
rightContentRender: rightContentRender,
|
|
236
|
+
leftContentRender: leftContentRender,
|
|
235
237
|
collapsedButtonRender: collapsedButtonRender,
|
|
236
238
|
headerTitleRender: menuHeaderRender,
|
|
237
239
|
menuExtraRender: menuExtraRender,
|
|
@@ -26,6 +26,12 @@ export var headerViewProps = _objectSpread(_objectSpread({}, baseHeaderProps), {
|
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
+
leftContentRender: {
|
|
30
|
+
type: [Object, Function, Boolean],
|
|
31
|
+
default: function _default() {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
29
35
|
hasSiderMenu: PropTypes.looseBool,
|
|
30
36
|
siderWidth: PropTypes.number.def(208)
|
|
31
37
|
});
|
|
@@ -56,6 +62,7 @@ export default defineComponent({
|
|
|
56
62
|
"theme": theme.value,
|
|
57
63
|
"mode": "horizontal"
|
|
58
64
|
}, props), {}, {
|
|
65
|
+
"leftContentRender": props.leftContentRender,
|
|
59
66
|
"onCollapse": onCollapse.value,
|
|
60
67
|
"menuData": context.menuData
|
|
61
68
|
}), null);
|
|
@@ -50,6 +50,12 @@ export var baseHeaderProps = _objectSpread(_objectSpread({}, defaultSettingProps
|
|
|
50
50
|
return undefined;
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
+
leftContentRender: {
|
|
54
|
+
type: [Object, Function],
|
|
55
|
+
default: function _default() {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
53
59
|
collapsedButtonRender: siderMenuProps.collapsedButtonRender,
|
|
54
60
|
matchMenuKeys: siderMenuProps.matchMenuKeys,
|
|
55
61
|
// events
|
|
@@ -90,6 +96,7 @@ export var TopNavHeader = function TopNavHeader(props) {
|
|
|
90
96
|
onOpenKeys = props.onOpenKeys,
|
|
91
97
|
onSelect = props.onSelect,
|
|
92
98
|
contentWidth = props.contentWidth,
|
|
99
|
+
leftContentRender = props.leftContentRender,
|
|
93
100
|
rightContentRender = props.rightContentRender,
|
|
94
101
|
topHeaderMenuRender = props.topHeaderMenuRender,
|
|
95
102
|
layout = props.layout,
|
|
@@ -146,7 +153,9 @@ export var TopNavHeader = function TopNavHeader(props) {
|
|
|
146
153
|
"class": "".concat(prefixCls, "-logo"),
|
|
147
154
|
"key": "logo",
|
|
148
155
|
"id": "logo"
|
|
149
|
-
}, [headerDom])]), _createVNode("div", {
|
|
156
|
+
}, [headerDom])]), leftContentRender && _createVNode("div", {
|
|
157
|
+
"class": "".concat(prefixCls, "-left-content")
|
|
158
|
+
}, [typeof leftContentRender === 'function' ? leftContentRender(_objectSpread({}, props)) : leftContentRender]), _createVNode("div", {
|
|
150
159
|
"style": {
|
|
151
160
|
flex: 1
|
|
152
161
|
},
|
|
@@ -84,13 +84,17 @@ export var genTopHeaderStyle = function genTopHeaderStyle(config) {
|
|
|
84
84
|
}
|
|
85
85
|
}), '.anticon', {
|
|
86
86
|
color: 'inherit'
|
|
87
|
-
})), "".concat(topNavHeaderCls, "-main"), _defineProperty({
|
|
87
|
+
})), "".concat(topNavHeaderCls, "-main"), _defineProperty(_defineProperty({
|
|
88
88
|
display: 'flex',
|
|
89
89
|
height: '100%',
|
|
90
90
|
paddingLeft: '16px'
|
|
91
91
|
}, "".concat(topNavHeaderCls, "-main-left"), {
|
|
92
92
|
display: 'flex',
|
|
93
93
|
minWidth: '192px'
|
|
94
|
+
}), "".concat(topNavHeaderCls, "-left-content"), {
|
|
95
|
+
display: 'flex',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
marginInlineEnd: '16px'
|
|
94
98
|
})), '.anticon', {
|
|
95
99
|
color: '#fff'
|
|
96
100
|
}), "".concat(topNavHeaderCls, "-logo"), {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) {
|
|
2
|
+
return lhs;
|
|
3
|
+
}
|
|
4
|
+
else {
|
|
5
|
+
return rhsFn();
|
|
6
|
+
} }
|
|
1
7
|
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
|
|
2
8
|
const op = ops[i];
|
|
3
9
|
const fn = ops[i + 1];
|
|
@@ -17,6 +23,7 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
|
|
|
17
23
|
/* Analyzed bindings: {
|
|
18
24
|
"searchKey": "props",
|
|
19
25
|
"multiple": "props",
|
|
26
|
+
"AutoComplete": "setup-maybe-ref",
|
|
20
27
|
"Select": "setup-maybe-ref",
|
|
21
28
|
"selectProps": "setup-maybe-ref",
|
|
22
29
|
"ref": "setup-const",
|
|
@@ -25,15 +32,25 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
|
|
|
25
32
|
"props": "setup-reactive-const",
|
|
26
33
|
"emit": "setup-const",
|
|
27
34
|
"myValue": "setup-ref",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
35
|
+
"searchValue": "setup-ref",
|
|
36
|
+
"customOptions": "setup-ref",
|
|
37
|
+
"isEmpty": "setup-const",
|
|
38
|
+
"normalizeText": "setup-const",
|
|
39
|
+
"isOptionMatched": "setup-const",
|
|
40
|
+
"componentProps": "setup-ref",
|
|
41
|
+
"mergedOptions": "setup-ref",
|
|
42
|
+
"displayOptions": "setup-ref",
|
|
43
|
+
"appendCustomOption": "setup-const",
|
|
31
44
|
"handleSearch": "setup-const",
|
|
32
|
-
"
|
|
45
|
+
"handleMultipleChange": "setup-const",
|
|
46
|
+
"handleSingleChange": "setup-const",
|
|
47
|
+
"handleSingleBlur": "setup-const",
|
|
48
|
+
"onSelect": "setup-const",
|
|
49
|
+
"normalizeValueByMode": "setup-const"
|
|
33
50
|
} */
|
|
34
51
|
import { defineComponent as _defineComponent } from 'vue';
|
|
35
|
-
import { unref as _unref, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock } from "vue";
|
|
36
|
-
import { Select } from 'ant-design-vue';
|
|
52
|
+
import { unref as _unref, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock, } from "vue";
|
|
53
|
+
import { AutoComplete, Select } from 'ant-design-vue';
|
|
37
54
|
import { selectProps } from 'ant-design-vue/lib/select';
|
|
38
55
|
import { ref, watch, computed, } from 'vue';
|
|
39
56
|
const __sfc_main__ = _defineComponent({
|
|
@@ -56,52 +73,137 @@ const __sfc_main__ = _defineComponent({
|
|
|
56
73
|
const props = __props;
|
|
57
74
|
const emit = __emit;
|
|
58
75
|
const myValue = ref();
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
const searchValue = ref('');
|
|
77
|
+
const customOptions = ref([]);
|
|
78
|
+
const isEmpty = (val) => val === undefined || val === null || val === '';
|
|
79
|
+
const normalizeText = (val) => {
|
|
80
|
+
if (isEmpty(val)) {
|
|
81
|
+
return '';
|
|
64
82
|
}
|
|
83
|
+
if (typeof val === 'object' && val !== null && 'value' in val) {
|
|
84
|
+
return String(_nullishCoalesce(val.value, () => (''))).trim();
|
|
85
|
+
}
|
|
86
|
+
return String(val).trim();
|
|
87
|
+
};
|
|
88
|
+
const isOptionMatched = (option, keyword) => {
|
|
89
|
+
const optionValue = normalizeText(_optionalChain([option, 'optionalAccess', _ => _.value]));
|
|
90
|
+
const optionLabel = normalizeText(_nullishCoalesce(_optionalChain([option, 'optionalAccess', _2 => _2[props.searchKey]]), () => (_optionalChain([option, 'optionalAccess', _3 => _3.label]))));
|
|
91
|
+
return optionValue === keyword || optionLabel === keyword;
|
|
65
92
|
};
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
const componentProps = computed(() => {
|
|
94
|
+
const { multiple, searchKey, options, value, mode, ...rest } = props;
|
|
95
|
+
return rest;
|
|
96
|
+
});
|
|
97
|
+
const mergedOptions = computed(() => {
|
|
98
|
+
const baseOptions = Array.isArray(props.options)
|
|
99
|
+
? (props.options)
|
|
100
|
+
: [];
|
|
101
|
+
const result = [];
|
|
102
|
+
const keys = new Set();
|
|
103
|
+
[...customOptions.value, ...baseOptions].forEach((option) => {
|
|
104
|
+
const key = normalizeText(_optionalChain([option, 'optionalAccess', _4 => _4.value]) || _optionalChain([option, 'optionalAccess', _5 => _5[props.searchKey]]) || _optionalChain([option, 'optionalAccess', _6 => _6.label]));
|
|
105
|
+
if (!key || keys.has(key)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
keys.add(key);
|
|
109
|
+
result.push(option);
|
|
110
|
+
});
|
|
111
|
+
return result;
|
|
112
|
+
});
|
|
113
|
+
const displayOptions = computed(() => {
|
|
114
|
+
const keyword = normalizeText(searchValue.value);
|
|
115
|
+
if (!keyword) {
|
|
116
|
+
return mergedOptions.value;
|
|
71
117
|
}
|
|
72
|
-
|
|
73
|
-
|
|
118
|
+
const exists = mergedOptions.value.some((option) => isOptionMatched(option, keyword));
|
|
119
|
+
if (exists) {
|
|
120
|
+
return mergedOptions.value;
|
|
121
|
+
}
|
|
122
|
+
return [{ label: keyword, value: keyword }, ...mergedOptions.value];
|
|
74
123
|
});
|
|
75
|
-
const
|
|
76
|
-
|
|
124
|
+
const appendCustomOption = (val) => {
|
|
125
|
+
const keyword = normalizeText(val);
|
|
126
|
+
if (!keyword) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const exists = mergedOptions.value.some((option) => isOptionMatched(option, keyword));
|
|
130
|
+
if (exists) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
customOptions.value = [{ label: keyword, value: keyword }, ...customOptions.value];
|
|
134
|
+
};
|
|
135
|
+
const handleSearch = (val) => {
|
|
136
|
+
searchValue.value = normalizeText(val);
|
|
137
|
+
};
|
|
138
|
+
const handleMultipleChange = (val) => {
|
|
139
|
+
const nextValue = Array.isArray(val)
|
|
140
|
+
? val
|
|
141
|
+
: isEmpty(val)
|
|
142
|
+
? []
|
|
143
|
+
: [val];
|
|
144
|
+
nextValue.forEach((item) => appendCustomOption(item));
|
|
145
|
+
myValue.value = nextValue;
|
|
146
|
+
emit('update:value', nextValue);
|
|
147
|
+
emit('change', nextValue);
|
|
148
|
+
};
|
|
149
|
+
const handleSingleChange = (val) => {
|
|
150
|
+
const nextValue = isEmpty(val) ? undefined : val;
|
|
151
|
+
myValue.value = nextValue;
|
|
152
|
+
emit('update:value', nextValue);
|
|
153
|
+
emit('change', nextValue);
|
|
154
|
+
};
|
|
155
|
+
const handleSingleBlur = () => {
|
|
156
|
+
appendCustomOption(myValue.value);
|
|
77
157
|
};
|
|
78
158
|
const onSelect = (val, option) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
159
|
+
appendCustomOption(val);
|
|
160
|
+
emit('select', val, option);
|
|
161
|
+
};
|
|
162
|
+
const normalizeValueByMode = (val) => {
|
|
163
|
+
if (isEmpty(val)) {
|
|
164
|
+
return props.multiple ? [] : undefined;
|
|
84
165
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
166
|
+
if (props.multiple) {
|
|
167
|
+
return Array.isArray(val) ? val : [val];
|
|
168
|
+
}
|
|
169
|
+
return Array.isArray(val) ? val[val.length - 1] : val;
|
|
88
170
|
};
|
|
89
|
-
watch(() => props.value, (val) => {
|
|
90
|
-
|
|
171
|
+
watch([() => props.value, () => props.multiple], ([val]) => {
|
|
172
|
+
const nextValue = normalizeValueByMode(val);
|
|
173
|
+
myValue.value = nextValue;
|
|
174
|
+
if (Array.isArray(nextValue)) {
|
|
175
|
+
nextValue.forEach((item) => appendCustomOption(item));
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
appendCustomOption(nextValue);
|
|
179
|
+
}
|
|
91
180
|
}, { immediate: true });
|
|
92
181
|
return (_ctx, _cache) => {
|
|
93
|
-
return (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
182
|
+
return (props.multiple)
|
|
183
|
+
? (_openBlock(), _createBlock(_unref(Select), _mergeProps({
|
|
184
|
+
key: 0,
|
|
185
|
+
value: myValue.value,
|
|
186
|
+
allowClear: ""
|
|
187
|
+
}, componentProps.value, {
|
|
188
|
+
mode: "tags",
|
|
189
|
+
options: displayOptions.value,
|
|
190
|
+
style: { "width": "100%" },
|
|
191
|
+
onSelect: onSelect,
|
|
192
|
+
onSearch: handleSearch,
|
|
193
|
+
onChange: handleMultipleChange
|
|
194
|
+
}), null, 16 /* FULL_PROPS */, ["value", "options"]))
|
|
195
|
+
: (_openBlock(), _createBlock(_unref(AutoComplete), _mergeProps({
|
|
196
|
+
key: 1,
|
|
197
|
+
value: myValue.value,
|
|
198
|
+
allowClear: ""
|
|
199
|
+
}, componentProps.value, {
|
|
200
|
+
options: displayOptions.value,
|
|
201
|
+
style: { "width": "100%" },
|
|
202
|
+
onSelect: onSelect,
|
|
203
|
+
onSearch: handleSearch,
|
|
204
|
+
onChange: handleSingleChange,
|
|
205
|
+
onBlur: handleSingleBlur
|
|
206
|
+
}), null, 16 /* FULL_PROPS */, ["value", "options"]));
|
|
105
207
|
};
|
|
106
208
|
}
|
|
107
209
|
});
|
|
@@ -218,6 +218,7 @@ var _default2 = exports.default = (0, _vue.defineComponent)({
|
|
|
218
218
|
var collapsedButtonRender = (0, _util.getSlot)(slots, props, 'collapsedButtonRender');
|
|
219
219
|
var headerContentRender = (0, _util.getSlot)(slots, props, 'headerContentRender');
|
|
220
220
|
var rightContentRender = (0, _util.getSlot)(slots, props, 'rightContentRender');
|
|
221
|
+
var leftContentRender = (0, _util.getSlot)(slots, props, 'leftContentRender');
|
|
221
222
|
var customHeaderRender = (0, _util.getSlot)(slots, props, 'headerRender');
|
|
222
223
|
// menu
|
|
223
224
|
var menuHeaderRender = (0, _util.getSlot)(slots, props, 'menuHeaderRender');
|
|
@@ -240,6 +241,7 @@ var _default2 = exports.default = (0, _vue.defineComponent)({
|
|
|
240
241
|
onSelect: onSelect,
|
|
241
242
|
onMenuHeaderClick: onMenuHeaderClick,
|
|
242
243
|
rightContentRender: rightContentRender,
|
|
244
|
+
leftContentRender: leftContentRender,
|
|
243
245
|
collapsedButtonRender: collapsedButtonRender,
|
|
244
246
|
headerTitleRender: menuHeaderRender,
|
|
245
247
|
menuExtraRender: menuExtraRender,
|
|
@@ -32,6 +32,12 @@ var headerViewProps = exports.headerViewProps = (0, _objectSpread2.default)((0,
|
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
+
leftContentRender: {
|
|
36
|
+
type: [Object, Function, Boolean],
|
|
37
|
+
default: function _default() {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
35
41
|
hasSiderMenu: _vueTypes.default.looseBool,
|
|
36
42
|
siderWidth: _vueTypes.default.number.def(208)
|
|
37
43
|
});
|
|
@@ -62,6 +68,7 @@ var _default2 = exports.default = (0, _vue.defineComponent)({
|
|
|
62
68
|
"theme": theme.value,
|
|
63
69
|
"mode": "horizontal"
|
|
64
70
|
}, props), {}, {
|
|
71
|
+
"leftContentRender": props.leftContentRender,
|
|
65
72
|
"onCollapse": onCollapse.value,
|
|
66
73
|
"menuData": context.menuData
|
|
67
74
|
}), null);
|
|
@@ -56,6 +56,12 @@ var baseHeaderProps = exports.baseHeaderProps = (0, _objectSpread2.default)((0,
|
|
|
56
56
|
return undefined;
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
+
leftContentRender: {
|
|
60
|
+
type: [Object, Function],
|
|
61
|
+
default: function _default() {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
59
65
|
collapsedButtonRender: _SiderMenu.siderMenuProps.collapsedButtonRender,
|
|
60
66
|
matchMenuKeys: _SiderMenu.siderMenuProps.matchMenuKeys,
|
|
61
67
|
// events
|
|
@@ -96,6 +102,7 @@ var TopNavHeader = exports.TopNavHeader = function TopNavHeader(props) {
|
|
|
96
102
|
onOpenKeys = props.onOpenKeys,
|
|
97
103
|
onSelect = props.onSelect,
|
|
98
104
|
contentWidth = props.contentWidth,
|
|
105
|
+
leftContentRender = props.leftContentRender,
|
|
99
106
|
rightContentRender = props.rightContentRender,
|
|
100
107
|
topHeaderMenuRender = props.topHeaderMenuRender,
|
|
101
108
|
layout = props.layout,
|
|
@@ -152,7 +159,9 @@ var TopNavHeader = exports.TopNavHeader = function TopNavHeader(props) {
|
|
|
152
159
|
"class": "".concat(prefixCls, "-logo"),
|
|
153
160
|
"key": "logo",
|
|
154
161
|
"id": "logo"
|
|
155
|
-
}, [headerDom])]), (0, _vue.createVNode)("div", {
|
|
162
|
+
}, [headerDom])]), leftContentRender && (0, _vue.createVNode)("div", {
|
|
163
|
+
"class": "".concat(prefixCls, "-left-content")
|
|
164
|
+
}, [typeof leftContentRender === 'function' ? leftContentRender((0, _objectSpread2.default)({}, props)) : leftContentRender]), (0, _vue.createVNode)("div", {
|
|
156
165
|
"style": {
|
|
157
166
|
flex: 1
|
|
158
167
|
},
|
|
@@ -91,13 +91,17 @@ var genTopHeaderStyle = exports.genTopHeaderStyle = function genTopHeaderStyle(c
|
|
|
91
91
|
}
|
|
92
92
|
}), '.anticon', {
|
|
93
93
|
color: 'inherit'
|
|
94
|
-
})), "".concat(topNavHeaderCls, "-main"), (0, _defineProperty2.default)({
|
|
94
|
+
})), "".concat(topNavHeaderCls, "-main"), (0, _defineProperty2.default)((0, _defineProperty2.default)({
|
|
95
95
|
display: 'flex',
|
|
96
96
|
height: '100%',
|
|
97
97
|
paddingLeft: '16px'
|
|
98
98
|
}, "".concat(topNavHeaderCls, "-main-left"), {
|
|
99
99
|
display: 'flex',
|
|
100
100
|
minWidth: '192px'
|
|
101
|
+
}), "".concat(topNavHeaderCls, "-left-content"), {
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
marginInlineEnd: '16px'
|
|
101
105
|
})), '.anticon', {
|
|
102
106
|
color: '#fff'
|
|
103
107
|
}), "".concat(topNavHeaderCls, "-logo"), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetlinks-web/components",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -154,8 +154,8 @@
|
|
|
154
154
|
"webpack-dev-server": "^4.0.0",
|
|
155
155
|
"webpack-merge": "^5.0.0",
|
|
156
156
|
"webpackbar": "^5.0.2",
|
|
157
|
-
"@jetlinks-web/hooks": "^1.1.1",
|
|
158
157
|
"@jetlinks-web/constants": "^1.0.9",
|
|
158
|
+
"@jetlinks-web/hooks": "^1.1.1",
|
|
159
159
|
"@jetlinks-web/utils": "^1.2.12"
|
|
160
160
|
},
|
|
161
161
|
"publishConfig": {
|