xxl-job-vue3 1.0.0 → 1.0.1
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.
Potentially problematic release.
This version of xxl-job-vue3 might be problematic. Click here for more details.
- package/README.md +5 -0
- package/dist/{403-D8dRpQKz.js → 403-BgYs1MY9.js} +2 -2
- package/dist/{404-DXM7nyXC.js → 404-DHj5v1Yh.js} +2 -2
- package/dist/{500-BUCjxPG1.js → 500-BMPMnB5R.js} +2 -2
- package/dist/CrontabDay-BtWkPZgc.js +4 -0
- package/dist/CrontabHour-CWW94JsR.js +4 -0
- package/dist/CrontabMin-4na7Y7jF.js +4 -0
- package/dist/CrontabMonth-dsg6XXW5.js +4 -0
- package/dist/CrontabResult-rMgvC2Ov.js +4 -0
- package/dist/CrontabSecond-B57qJvYE.js +4 -0
- package/dist/CrontabWeek-dPVVzR9P.js +4 -0
- package/dist/CrontabYear-DImaFqLN.js +4 -0
- package/dist/EditExecutor-DZ3Ic8Ex.js +4 -0
- package/dist/JobTaskClearDialog-D-E19g9O.js +4 -0
- package/dist/RunOnceView-D4oyLKNh.js +4 -0
- package/dist/{index-Bf5gEacT.js → index-C8Y_Od96.js} +18120 -16315
- package/dist/{index-OKUPhEWh.js → index-D6UxUdAp.js} +1673 -1222
- package/dist/index-DI263EBt.js +4 -0
- package/dist/index-DvUlhZYD.js +4 -0
- package/dist/index-Zr37j6aO.js +4 -0
- package/dist/style.css +1 -0
- package/dist/xxl-job-vue3.es.js +2 -3
- package/dist/xxl-job-vue3.umd.js +19 -15
- package/package.json +1 -1
- package/dist/CrontabDay-DqR3VUYR.js +0 -4
- package/dist/CrontabHour-B0Ub5MaR.js +0 -4
- package/dist/CrontabMin-DtjfCxp1.js +0 -4
- package/dist/CrontabMonth-BU6m9TVZ.js +0 -4
- package/dist/CrontabResult-DGO_apJU.js +0 -4
- package/dist/CrontabSecond-BqQGVOZ9.js +0 -4
- package/dist/CrontabWeek-DHqRjAy-.js +0 -4
- package/dist/CrontabYear-D3Z1OkFC.js +0 -4
- package/dist/EditExecutor-C-jVvoY3.js +0 -4
- package/dist/JobTaskClearDialog-CpXLIi7N.js +0 -4
- package/dist/RunOnceView-Bk8stgp6.js +0 -4
- package/dist/index-Btu-nIzi.js +0 -4
- package/dist/index-CXZ4_Fnb.js +0 -4
- package/dist/index-tWx7VrPi.js +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent, ref, provide, onMounted, createElementBlock, openBlock, unref, normalizeClass, renderSlot, getCurrentInstance, inject, createElementVNode, createBlock, withCtx, resolveDynamicComponent, toDisplayString, Transition, mergeProps, toHandlers, shallowRef, computed, watch, normalizeStyle, Fragment, renderList,
|
|
2
|
-
import { n as buildProps, o as iconPropType, p as _export_sfc, u as useLocale, q as useNamespace, r as definePropType, E as ElIcon, w as withInstall, s as withNoopInstall, t as isClient, v as addUnit, x as
|
|
3
|
-
import { storeToRefs, defineStore } from "pinia";
|
|
1
|
+
import { defineComponent, ref, provide, onMounted, createElementBlock, openBlock, unref, normalizeClass, renderSlot, getCurrentInstance, inject, createElementVNode, createBlock, withCtx, resolveDynamicComponent, toDisplayString, Transition, mergeProps, toHandlers, shallowRef, computed, watch, normalizeStyle, watchEffect, Fragment, renderList, reactive, nextTick, createCommentVNode, createVNode, withDirectives, vShow, withKeys, createTextVNode, useSlots, onBeforeUnmount, h, toRef, resolveComponent, isRef, KeepAlive, TransitionGroup } from "vue";
|
|
2
|
+
import { n as buildProps, o as iconPropType, p as _export_sfc, u as useLocale, q as useNamespace, r as definePropType, E as ElIcon, w as withInstall, s as withNoopInstall, t as isClient, v as addUnit, x as getEventCode, y as EVENT_CODE, z as isString, A as isNil, U as UPDATE_MODEL_EVENT, T as TinyColor, B as hasOwn, C as useFormItem, D as useFormDisabled, F as debugWarn, G as ElInput, H as CHANGE_EVENT, I as useAriaProps, J as useEmptyValuesProps, K as useTooltipContentProps, L as useSizeProp, M as useFormSize, N as useEmptyValues, O as useFormItemInputId, P as useFocusController, Q as reactiveComputed, R as pick, S as debounce, V as ElTooltip, W as ElButton, X as ClickOutside, Y as triggerEvent, Z as addClass, $ as hasClass, a0 as removeClass, a1 as throwError, a2 as isUndefined, a3 as useTimeoutFn, a4 as focusElement, a5 as isArray, a6 as isObject, a7 as useResizeObserver, a8 as flattedChildren, a9 as mutable, aa as unrefElement, ab as isPropAbsent, ac as useGlobalStore, ad as storeToRefs, ae as DEFAULT_PRIMARY, af as ElSwitch, ag as ElDrawer, ah as _export_sfc$1, ai as defineStore, aj as piniaPersistConfig, ak as getUrlWithParams, al as router, am as useAuthStore, an as useRoute, ao as useRouter, ap as ElDropdown, aq as ElDropdownMenu, ar as ElDropdownItem, as as Sortable, at as ElTabs, au as ElTabPane, av as useDebounceFn, aw as useUserStore, ax as normalizeStyle$1, ay as ElScrollbar } from "./index-C8Y_Od96.js";
|
|
4
3
|
import { ElMessage } from "element-plus";
|
|
4
|
+
import { ArrowDown, Close, ArrowRight, More, Moon, Sunny } from "@element-plus/icons-vue";
|
|
5
5
|
const breadcrumbKey = Symbol("breadcrumbKey");
|
|
6
6
|
const breadcrumbProps = buildProps({
|
|
7
7
|
separator: {
|
|
@@ -12,15 +12,16 @@ const breadcrumbProps = buildProps({
|
|
|
12
12
|
type: iconPropType
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const _hoisted_1$g = ["aria-label"];
|
|
16
|
+
const _sfc_main$z = defineComponent({
|
|
17
|
+
...{
|
|
18
|
+
name: "ElBreadcrumb"
|
|
19
|
+
},
|
|
20
|
+
__name: "breadcrumb",
|
|
20
21
|
props: breadcrumbProps,
|
|
21
22
|
setup(__props) {
|
|
22
|
-
const props = __props;
|
|
23
23
|
const { t } = useLocale();
|
|
24
|
+
const props = __props;
|
|
24
25
|
const ns = useNamespace("breadcrumb");
|
|
25
26
|
const breadcrumb = ref();
|
|
26
27
|
provide(breadcrumbKey, props);
|
|
@@ -39,11 +40,11 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
39
40
|
role: "navigation"
|
|
40
41
|
}, [
|
|
41
42
|
renderSlot(_ctx.$slots, "default")
|
|
42
|
-
], 10,
|
|
43
|
+
], 10, _hoisted_1$g);
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
|
-
var Breadcrumb$1 = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
47
|
+
var Breadcrumb$1 = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/breadcrumb/src/breadcrumb.vue"]]);
|
|
47
48
|
const breadcrumbItemProps = buildProps({
|
|
48
49
|
to: {
|
|
49
50
|
type: definePropType([String, Object]),
|
|
@@ -51,11 +52,11 @@ const breadcrumbItemProps = buildProps({
|
|
|
51
52
|
},
|
|
52
53
|
replace: Boolean
|
|
53
54
|
});
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const _sfc_main$y = defineComponent({
|
|
56
|
+
...{
|
|
57
|
+
name: "ElBreadcrumbItem"
|
|
58
|
+
},
|
|
59
|
+
__name: "breadcrumb-item",
|
|
59
60
|
props: breadcrumbItemProps,
|
|
60
61
|
setup(__props) {
|
|
61
62
|
const props = __props;
|
|
@@ -63,7 +64,6 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
63
64
|
const breadcrumbContext = inject(breadcrumbKey, void 0);
|
|
64
65
|
const ns = useNamespace("breadcrumb");
|
|
65
66
|
const router2 = instance.appContext.config.globalProperties.$router;
|
|
66
|
-
const link = ref();
|
|
67
67
|
const onClick = () => {
|
|
68
68
|
if (!props.to || !router2)
|
|
69
69
|
return;
|
|
@@ -71,45 +71,58 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
71
71
|
};
|
|
72
72
|
return (_ctx, _cache) => {
|
|
73
73
|
var _a, _b;
|
|
74
|
-
return openBlock(), createElementBlock(
|
|
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
|
-
|
|
74
|
+
return openBlock(), createElementBlock(
|
|
75
|
+
"span",
|
|
76
|
+
{
|
|
77
|
+
class: normalizeClass(unref(ns).e("item"))
|
|
78
|
+
},
|
|
79
|
+
[
|
|
80
|
+
createElementVNode(
|
|
81
|
+
"span",
|
|
82
|
+
{
|
|
83
|
+
class: normalizeClass([unref(ns).e("inner"), unref(ns).is("link", !!_ctx.to)]),
|
|
84
|
+
role: "link",
|
|
85
|
+
onClick
|
|
86
|
+
},
|
|
87
|
+
[
|
|
88
|
+
renderSlot(_ctx.$slots, "default")
|
|
89
|
+
],
|
|
90
|
+
2
|
|
91
|
+
),
|
|
92
|
+
((_a = unref(breadcrumbContext)) == null ? void 0 : _a.separatorIcon) ? (openBlock(), createBlock(unref(ElIcon), {
|
|
93
|
+
key: 0,
|
|
94
|
+
class: normalizeClass(unref(ns).e("separator"))
|
|
95
|
+
}, {
|
|
96
|
+
default: withCtx(() => [
|
|
97
|
+
(openBlock(), createBlock(resolveDynamicComponent(unref(breadcrumbContext).separatorIcon)))
|
|
98
|
+
]),
|
|
99
|
+
_: 1
|
|
100
|
+
}, 8, ["class"])) : (openBlock(), createElementBlock(
|
|
101
|
+
"span",
|
|
102
|
+
{
|
|
103
|
+
key: 1,
|
|
104
|
+
class: normalizeClass(unref(ns).e("separator")),
|
|
105
|
+
role: "presentation"
|
|
106
|
+
},
|
|
107
|
+
toDisplayString((_b = unref(breadcrumbContext)) == null ? void 0 : _b.separator),
|
|
108
|
+
3
|
|
109
|
+
))
|
|
110
|
+
],
|
|
111
|
+
2
|
|
112
|
+
);
|
|
100
113
|
};
|
|
101
114
|
}
|
|
102
115
|
});
|
|
103
|
-
var BreadcrumbItem = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
116
|
+
var BreadcrumbItem = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/breadcrumb/src/breadcrumb-item.vue"]]);
|
|
104
117
|
const ElBreadcrumb = withInstall(Breadcrumb$1, {
|
|
105
118
|
BreadcrumbItem
|
|
106
119
|
});
|
|
107
120
|
const ElBreadcrumbItem = withNoopInstall(BreadcrumbItem);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
121
|
+
const _sfc_main$x = defineComponent({
|
|
122
|
+
...{
|
|
123
|
+
name: "ElCollapseTransition"
|
|
124
|
+
},
|
|
125
|
+
__name: "collapse-transition",
|
|
113
126
|
setup(__props) {
|
|
114
127
|
const ns = useNamespace("collapse-transition");
|
|
115
128
|
const reset = (el) => {
|
|
@@ -187,18 +200,17 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
187
200
|
};
|
|
188
201
|
}
|
|
189
202
|
});
|
|
190
|
-
var CollapseTransition = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
203
|
+
var CollapseTransition = /* @__PURE__ */ _export_sfc(_sfc_main$x, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/collapse-transition/src/collapse-transition.vue"]]);
|
|
191
204
|
const ElCollapseTransition = withInstall(CollapseTransition);
|
|
192
205
|
const alphaSliderProps = buildProps({
|
|
193
206
|
color: {
|
|
194
207
|
type: definePropType(Object),
|
|
195
208
|
required: true
|
|
196
209
|
},
|
|
197
|
-
vertical:
|
|
198
|
-
|
|
199
|
-
default: false
|
|
200
|
-
}
|
|
210
|
+
vertical: Boolean,
|
|
211
|
+
disabled: Boolean
|
|
201
212
|
});
|
|
213
|
+
const hueSliderProps = alphaSliderProps;
|
|
202
214
|
let isDragging = false;
|
|
203
215
|
function draggable(element, options) {
|
|
204
216
|
if (!isClient)
|
|
@@ -222,7 +234,6 @@ function draggable(element, options) {
|
|
|
222
234
|
var _a;
|
|
223
235
|
if (isDragging)
|
|
224
236
|
return;
|
|
225
|
-
event.preventDefault();
|
|
226
237
|
document.onselectstart = () => false;
|
|
227
238
|
document.ondragstart = () => false;
|
|
228
239
|
document.addEventListener("mousemove", moveFn);
|
|
@@ -253,15 +264,15 @@ const getClientXY = (event) => {
|
|
|
253
264
|
clientY
|
|
254
265
|
};
|
|
255
266
|
};
|
|
256
|
-
const
|
|
267
|
+
const useSlider = (props, { key, minValue: minValue2, maxValue: maxValue2 }) => {
|
|
257
268
|
const instance = getCurrentInstance();
|
|
258
|
-
const { t } = useLocale();
|
|
259
269
|
const thumb = shallowRef();
|
|
260
270
|
const bar = shallowRef();
|
|
261
|
-
const
|
|
262
|
-
const alphaLabel = computed(() => t("el.colorpicker.alphaLabel"));
|
|
271
|
+
const currentValue = computed(() => props.color.get(key));
|
|
263
272
|
function handleClick(event) {
|
|
264
273
|
var _a;
|
|
274
|
+
if (props.disabled)
|
|
275
|
+
return;
|
|
265
276
|
const target = event.target;
|
|
266
277
|
if (target !== thumb.value) {
|
|
267
278
|
handleDrag(event);
|
|
@@ -269,63 +280,89 @@ const useAlphaSlider = (props) => {
|
|
|
269
280
|
(_a = thumb.value) == null ? void 0 : _a.focus();
|
|
270
281
|
}
|
|
271
282
|
function handleDrag(event) {
|
|
272
|
-
if (!bar.value || !thumb.value)
|
|
283
|
+
if (!bar.value || !thumb.value || props.disabled)
|
|
273
284
|
return;
|
|
274
285
|
const el = instance.vnode.el;
|
|
275
286
|
const rect = el.getBoundingClientRect();
|
|
276
287
|
const { clientX, clientY } = getClientXY(event);
|
|
288
|
+
let value;
|
|
277
289
|
if (!props.vertical) {
|
|
278
290
|
let left = clientX - rect.left;
|
|
279
291
|
left = Math.max(thumb.value.offsetWidth / 2, left);
|
|
280
292
|
left = Math.min(left, rect.width - thumb.value.offsetWidth / 2);
|
|
281
|
-
|
|
293
|
+
value = Math.round(
|
|
294
|
+
(left - thumb.value.offsetWidth / 2) / (rect.width - thumb.value.offsetWidth) * maxValue2
|
|
295
|
+
);
|
|
282
296
|
} else {
|
|
283
297
|
let top = clientY - rect.top;
|
|
284
298
|
top = Math.max(thumb.value.offsetHeight / 2, top);
|
|
285
299
|
top = Math.min(top, rect.height - thumb.value.offsetHeight / 2);
|
|
286
|
-
|
|
300
|
+
value = Math.round(
|
|
301
|
+
(top - thumb.value.offsetHeight / 2) / (rect.height - thumb.value.offsetHeight) * maxValue2
|
|
302
|
+
);
|
|
287
303
|
}
|
|
304
|
+
props.color.set(key, value);
|
|
288
305
|
}
|
|
289
306
|
function handleKeydown(event) {
|
|
290
|
-
|
|
307
|
+
if (props.disabled)
|
|
308
|
+
return;
|
|
309
|
+
const { shiftKey } = event;
|
|
310
|
+
const code = getEventCode(event);
|
|
291
311
|
const step = shiftKey ? 10 : 1;
|
|
312
|
+
const reverse = key === "hue" ? -1 : 1;
|
|
313
|
+
let isPreventDefault = true;
|
|
292
314
|
switch (code) {
|
|
293
315
|
case EVENT_CODE.left:
|
|
294
316
|
case EVENT_CODE.down:
|
|
295
|
-
|
|
296
|
-
event.stopPropagation();
|
|
297
|
-
incrementPosition(-step);
|
|
317
|
+
incrementPosition(-step * reverse);
|
|
298
318
|
break;
|
|
299
319
|
case EVENT_CODE.right:
|
|
300
320
|
case EVENT_CODE.up:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
321
|
+
incrementPosition(step * reverse);
|
|
322
|
+
break;
|
|
323
|
+
case EVENT_CODE.home:
|
|
324
|
+
props.color.set(key, key === "hue" ? maxValue2 : minValue2);
|
|
325
|
+
break;
|
|
326
|
+
case EVENT_CODE.end:
|
|
327
|
+
props.color.set(key, key === "hue" ? minValue2 : maxValue2);
|
|
328
|
+
break;
|
|
329
|
+
case EVENT_CODE.pageDown:
|
|
330
|
+
incrementPosition(-4 * reverse);
|
|
331
|
+
break;
|
|
332
|
+
case EVENT_CODE.pageUp:
|
|
333
|
+
incrementPosition(4 * reverse);
|
|
334
|
+
break;
|
|
335
|
+
default:
|
|
336
|
+
isPreventDefault = false;
|
|
304
337
|
break;
|
|
305
338
|
}
|
|
339
|
+
isPreventDefault && event.preventDefault();
|
|
306
340
|
}
|
|
307
341
|
function incrementPosition(step) {
|
|
308
|
-
let next =
|
|
309
|
-
next = next <
|
|
310
|
-
props.color.set(
|
|
342
|
+
let next = currentValue.value + step;
|
|
343
|
+
next = next < minValue2 ? minValue2 : next > maxValue2 ? maxValue2 : next;
|
|
344
|
+
props.color.set(key, next);
|
|
311
345
|
}
|
|
312
346
|
return {
|
|
313
347
|
thumb,
|
|
314
348
|
bar,
|
|
315
|
-
|
|
316
|
-
alphaLabel,
|
|
349
|
+
currentValue,
|
|
317
350
|
handleDrag,
|
|
318
351
|
handleClick,
|
|
319
352
|
handleKeydown
|
|
320
353
|
};
|
|
321
354
|
};
|
|
322
|
-
const
|
|
355
|
+
const useSliderDOM = (props, {
|
|
356
|
+
namespace,
|
|
357
|
+
maxValue: maxValue2,
|
|
323
358
|
bar,
|
|
324
359
|
thumb,
|
|
325
|
-
|
|
360
|
+
currentValue,
|
|
361
|
+
handleDrag,
|
|
362
|
+
getBackground
|
|
326
363
|
}) => {
|
|
327
364
|
const instance = getCurrentInstance();
|
|
328
|
-
const ns = useNamespace(
|
|
365
|
+
const ns = useNamespace(namespace);
|
|
329
366
|
const thumbLeft = ref(0);
|
|
330
367
|
const thumbTop = ref(0);
|
|
331
368
|
const background = ref();
|
|
@@ -335,10 +372,12 @@ const useAlphaSliderDOM = (props, {
|
|
|
335
372
|
if (props.vertical)
|
|
336
373
|
return 0;
|
|
337
374
|
const el = instance.vnode.el;
|
|
338
|
-
const
|
|
375
|
+
const value = currentValue.value;
|
|
339
376
|
if (!el)
|
|
340
377
|
return 0;
|
|
341
|
-
return Math.round(
|
|
378
|
+
return Math.round(
|
|
379
|
+
value * (el.offsetWidth - thumb.value.offsetWidth / 2) / maxValue2
|
|
380
|
+
);
|
|
342
381
|
}
|
|
343
382
|
function getThumbTop() {
|
|
344
383
|
if (!thumb.value)
|
|
@@ -346,22 +385,17 @@ const useAlphaSliderDOM = (props, {
|
|
|
346
385
|
const el = instance.vnode.el;
|
|
347
386
|
if (!props.vertical)
|
|
348
387
|
return 0;
|
|
349
|
-
const
|
|
388
|
+
const value = currentValue.value;
|
|
350
389
|
if (!el)
|
|
351
390
|
return 0;
|
|
352
|
-
return Math.round(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (props.color && props.color.value) {
|
|
356
|
-
const { r, g, b } = props.color.toRgb();
|
|
357
|
-
return `linear-gradient(to right, rgba(${r}, ${g}, ${b}, 0) 0%, rgba(${r}, ${g}, ${b}, 1) 100%)`;
|
|
358
|
-
}
|
|
359
|
-
return "";
|
|
391
|
+
return Math.round(
|
|
392
|
+
value * (el.offsetHeight - thumb.value.offsetHeight / 2) / maxValue2
|
|
393
|
+
);
|
|
360
394
|
}
|
|
361
395
|
function update() {
|
|
362
396
|
thumbLeft.value = getThumbLeft();
|
|
363
397
|
thumbTop.value = getThumbTop();
|
|
364
|
-
background.value = getBackground();
|
|
398
|
+
background.value = getBackground == null ? void 0 : getBackground();
|
|
365
399
|
}
|
|
366
400
|
onMounted(() => {
|
|
367
401
|
if (!bar.value || !thumb.value)
|
|
@@ -378,9 +412,16 @@ const useAlphaSliderDOM = (props, {
|
|
|
378
412
|
draggable(thumb.value, dragConfig);
|
|
379
413
|
update();
|
|
380
414
|
});
|
|
381
|
-
watch(
|
|
382
|
-
watch(
|
|
383
|
-
|
|
415
|
+
watch(currentValue, () => update());
|
|
416
|
+
watch(
|
|
417
|
+
() => props.color.value,
|
|
418
|
+
() => update()
|
|
419
|
+
);
|
|
420
|
+
const rootKls = computed(() => [
|
|
421
|
+
ns.b(),
|
|
422
|
+
ns.is("vertical", props.vertical),
|
|
423
|
+
ns.is("disabled", props.disabled)
|
|
424
|
+
]);
|
|
384
425
|
const barKls = computed(() => ns.e("bar"));
|
|
385
426
|
const thumbKls = computed(() => ns.e("thumb"));
|
|
386
427
|
const barStyle = computed(() => ({ background: background.value }));
|
|
@@ -388,353 +429,225 @@ const useAlphaSliderDOM = (props, {
|
|
|
388
429
|
left: addUnit(thumbLeft.value),
|
|
389
430
|
top: addUnit(thumbTop.value)
|
|
390
431
|
}));
|
|
391
|
-
return {
|
|
432
|
+
return {
|
|
433
|
+
rootKls,
|
|
434
|
+
barKls,
|
|
435
|
+
barStyle,
|
|
436
|
+
thumbKls,
|
|
437
|
+
thumbStyle,
|
|
438
|
+
thumbLeft,
|
|
439
|
+
thumbTop,
|
|
440
|
+
update
|
|
441
|
+
};
|
|
392
442
|
};
|
|
393
|
-
const
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
443
|
+
const _hoisted_1$f = ["aria-label", "aria-valuenow", "aria-valuetext", "aria-orientation", "tabindex", "aria-disabled"];
|
|
444
|
+
const minValue$1 = 0;
|
|
445
|
+
const maxValue$1 = 100;
|
|
446
|
+
const _sfc_main$w = defineComponent({
|
|
447
|
+
...{
|
|
448
|
+
name: "ElColorAlphaSlider"
|
|
449
|
+
},
|
|
450
|
+
__name: "alpha-slider",
|
|
399
451
|
props: alphaSliderProps,
|
|
400
|
-
setup(__props, { expose }) {
|
|
452
|
+
setup(__props, { expose: __expose }) {
|
|
401
453
|
const props = __props;
|
|
402
|
-
const {
|
|
403
|
-
|
|
404
|
-
|
|
454
|
+
const { currentValue, bar, thumb, handleDrag, handleClick, handleKeydown } = useSlider(props, { key: "alpha", minValue: minValue$1, maxValue: maxValue$1 });
|
|
455
|
+
const { rootKls, barKls, barStyle, thumbKls, thumbStyle, update } = useSliderDOM(props, {
|
|
456
|
+
namespace: "color-alpha-slider",
|
|
457
|
+
maxValue: maxValue$1,
|
|
458
|
+
currentValue,
|
|
405
459
|
bar,
|
|
406
460
|
thumb,
|
|
407
461
|
handleDrag,
|
|
408
|
-
|
|
409
|
-
handleKeydown
|
|
410
|
-
} = useAlphaSlider(props);
|
|
411
|
-
const { rootKls, barKls, barStyle, thumbKls, thumbStyle, update } = useAlphaSliderDOM(props, {
|
|
412
|
-
bar,
|
|
413
|
-
thumb,
|
|
414
|
-
handleDrag
|
|
462
|
+
getBackground
|
|
415
463
|
});
|
|
416
|
-
|
|
464
|
+
const { t } = useLocale();
|
|
465
|
+
const ariaLabel = computed(() => t("el.colorpicker.alphaLabel"));
|
|
466
|
+
const ariaValuetext = computed(() => {
|
|
467
|
+
return t("el.colorpicker.alphaDescription", {
|
|
468
|
+
alpha: currentValue.value,
|
|
469
|
+
color: props.color.value
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
function getBackground() {
|
|
473
|
+
if (props.color && props.color.value) {
|
|
474
|
+
const { r, g, b } = props.color.toRgb();
|
|
475
|
+
return `linear-gradient(to right, rgba(${r}, ${g}, ${b}, 0) 0%, rgba(${r}, ${g}, ${b}, 1) 100%)`;
|
|
476
|
+
}
|
|
477
|
+
return "";
|
|
478
|
+
}
|
|
479
|
+
__expose({
|
|
417
480
|
update,
|
|
418
481
|
bar,
|
|
419
482
|
thumb
|
|
420
483
|
});
|
|
421
484
|
return (_ctx, _cache) => {
|
|
422
|
-
return openBlock(), createElementBlock(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
"
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
485
|
+
return openBlock(), createElementBlock(
|
|
486
|
+
"div",
|
|
487
|
+
{
|
|
488
|
+
class: normalizeClass(unref(rootKls))
|
|
489
|
+
},
|
|
490
|
+
[
|
|
491
|
+
createElementVNode(
|
|
492
|
+
"div",
|
|
493
|
+
{
|
|
494
|
+
ref_key: "bar",
|
|
495
|
+
ref: bar,
|
|
496
|
+
class: normalizeClass(unref(barKls)),
|
|
497
|
+
style: normalizeStyle(unref(barStyle)),
|
|
498
|
+
onClick: _cache[0] || (_cache[0] = (...args) => unref(handleClick) && unref(handleClick)(...args))
|
|
499
|
+
},
|
|
500
|
+
null,
|
|
501
|
+
6
|
|
502
|
+
),
|
|
503
|
+
createElementVNode("div", {
|
|
504
|
+
ref_key: "thumb",
|
|
505
|
+
ref: thumb,
|
|
506
|
+
class: normalizeClass(unref(thumbKls)),
|
|
507
|
+
style: normalizeStyle(unref(thumbStyle)),
|
|
508
|
+
"aria-label": ariaLabel.value,
|
|
509
|
+
"aria-valuenow": unref(currentValue),
|
|
510
|
+
"aria-valuetext": ariaValuetext.value,
|
|
511
|
+
"aria-orientation": _ctx.vertical ? "vertical" : "horizontal",
|
|
512
|
+
"aria-valuemin": minValue$1,
|
|
513
|
+
"aria-valuemax": maxValue$1,
|
|
514
|
+
role: "slider",
|
|
515
|
+
tabindex: _ctx.disabled ? void 0 : 0,
|
|
516
|
+
"aria-disabled": _ctx.disabled,
|
|
517
|
+
onKeydown: _cache[1] || (_cache[1] = (...args) => unref(handleKeydown) && unref(handleKeydown)(...args))
|
|
518
|
+
}, null, 46, _hoisted_1$f)
|
|
519
|
+
],
|
|
520
|
+
2
|
|
521
|
+
);
|
|
447
522
|
};
|
|
448
523
|
}
|
|
449
524
|
});
|
|
450
|
-
var AlphaSlider = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
},
|
|
458
|
-
vertical: Boolean
|
|
525
|
+
var AlphaSlider = /* @__PURE__ */ _export_sfc(_sfc_main$w, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/color-picker-panel/src/components/alpha-slider.vue"]]);
|
|
526
|
+
const _hoisted_1$e = ["aria-label", "aria-valuenow", "aria-valuetext", "aria-orientation", "tabindex", "aria-disabled"];
|
|
527
|
+
const minValue = 0;
|
|
528
|
+
const maxValue = 360;
|
|
529
|
+
const _sfc_main$v = defineComponent({
|
|
530
|
+
...{
|
|
531
|
+
name: "ElColorHueSlider"
|
|
459
532
|
},
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const
|
|
464
|
-
const bar =
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
533
|
+
__name: "hue-slider",
|
|
534
|
+
props: hueSliderProps,
|
|
535
|
+
setup(__props, { expose: __expose }) {
|
|
536
|
+
const props = __props;
|
|
537
|
+
const { currentValue, bar, thumb, handleDrag, handleClick, handleKeydown } = useSlider(props, { key: "hue", minValue, maxValue });
|
|
538
|
+
const { rootKls, barKls, thumbKls, thumbStyle, thumbTop, update } = useSliderDOM(props, {
|
|
539
|
+
namespace: "color-hue-slider",
|
|
540
|
+
maxValue,
|
|
541
|
+
currentValue,
|
|
542
|
+
bar,
|
|
543
|
+
thumb,
|
|
544
|
+
handleDrag
|
|
472
545
|
});
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
if (!bar.value || !thumb.value)
|
|
481
|
-
return;
|
|
482
|
-
const el = instance.vnode.el;
|
|
483
|
-
const rect = el.getBoundingClientRect();
|
|
484
|
-
const { clientX, clientY } = getClientXY(event);
|
|
485
|
-
let hue;
|
|
486
|
-
if (!props.vertical) {
|
|
487
|
-
let left = clientX - rect.left;
|
|
488
|
-
left = Math.min(left, rect.width - thumb.value.offsetWidth / 2);
|
|
489
|
-
left = Math.max(thumb.value.offsetWidth / 2, left);
|
|
490
|
-
hue = Math.round((left - thumb.value.offsetWidth / 2) / (rect.width - thumb.value.offsetWidth) * 360);
|
|
491
|
-
} else {
|
|
492
|
-
let top = clientY - rect.top;
|
|
493
|
-
top = Math.min(top, rect.height - thumb.value.offsetHeight / 2);
|
|
494
|
-
top = Math.max(thumb.value.offsetHeight / 2, top);
|
|
495
|
-
hue = Math.round((top - thumb.value.offsetHeight / 2) / (rect.height - thumb.value.offsetHeight) * 360);
|
|
496
|
-
}
|
|
497
|
-
props.color.set("hue", hue);
|
|
498
|
-
}
|
|
499
|
-
function getThumbLeft() {
|
|
500
|
-
if (!thumb.value)
|
|
501
|
-
return 0;
|
|
502
|
-
const el = instance.vnode.el;
|
|
503
|
-
if (props.vertical)
|
|
504
|
-
return 0;
|
|
505
|
-
const hue = props.color.get("hue");
|
|
506
|
-
if (!el)
|
|
507
|
-
return 0;
|
|
508
|
-
return Math.round(hue * (el.offsetWidth - thumb.value.offsetWidth / 2) / 360);
|
|
509
|
-
}
|
|
510
|
-
function getThumbTop() {
|
|
511
|
-
if (!thumb.value)
|
|
512
|
-
return 0;
|
|
513
|
-
const el = instance.vnode.el;
|
|
514
|
-
if (!props.vertical)
|
|
515
|
-
return 0;
|
|
516
|
-
const hue = props.color.get("hue");
|
|
517
|
-
if (!el)
|
|
518
|
-
return 0;
|
|
519
|
-
return Math.round(hue * (el.offsetHeight - thumb.value.offsetHeight / 2) / 360);
|
|
520
|
-
}
|
|
521
|
-
function update() {
|
|
522
|
-
thumbLeft.value = getThumbLeft();
|
|
523
|
-
thumbTop.value = getThumbTop();
|
|
524
|
-
}
|
|
525
|
-
onMounted(() => {
|
|
526
|
-
if (!bar.value || !thumb.value)
|
|
527
|
-
return;
|
|
528
|
-
const dragConfig = {
|
|
529
|
-
drag: (event) => {
|
|
530
|
-
handleDrag(event);
|
|
531
|
-
},
|
|
532
|
-
end: (event) => {
|
|
533
|
-
handleDrag(event);
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
draggable(bar.value, dragConfig);
|
|
537
|
-
draggable(thumb.value, dragConfig);
|
|
538
|
-
update();
|
|
546
|
+
const { t } = useLocale();
|
|
547
|
+
const ariaLabel = computed(() => t("el.colorpicker.hueLabel"));
|
|
548
|
+
const ariaValuetext = computed(() => {
|
|
549
|
+
return t("el.colorpicker.hueDescription", {
|
|
550
|
+
hue: currentValue.value,
|
|
551
|
+
color: props.color.value
|
|
552
|
+
});
|
|
539
553
|
});
|
|
540
|
-
|
|
554
|
+
__expose({
|
|
541
555
|
bar,
|
|
542
556
|
thumb,
|
|
543
|
-
thumbLeft,
|
|
544
557
|
thumbTop,
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
558
|
+
update
|
|
559
|
+
});
|
|
560
|
+
return (_ctx, _cache) => {
|
|
561
|
+
return openBlock(), createElementBlock(
|
|
562
|
+
"div",
|
|
563
|
+
{
|
|
564
|
+
class: normalizeClass(unref(rootKls))
|
|
565
|
+
},
|
|
566
|
+
[
|
|
567
|
+
createElementVNode(
|
|
568
|
+
"div",
|
|
569
|
+
{
|
|
570
|
+
ref_key: "bar",
|
|
571
|
+
ref: bar,
|
|
572
|
+
class: normalizeClass(unref(barKls)),
|
|
573
|
+
onClick: _cache[0] || (_cache[0] = (...args) => unref(handleClick) && unref(handleClick)(...args))
|
|
574
|
+
},
|
|
575
|
+
null,
|
|
576
|
+
2
|
|
577
|
+
),
|
|
578
|
+
createElementVNode("div", {
|
|
579
|
+
ref_key: "thumb",
|
|
580
|
+
ref: thumb,
|
|
581
|
+
class: normalizeClass(unref(thumbKls)),
|
|
582
|
+
style: normalizeStyle(unref(thumbStyle)),
|
|
583
|
+
"aria-label": ariaLabel.value,
|
|
584
|
+
"aria-valuenow": unref(currentValue),
|
|
585
|
+
"aria-valuetext": ariaValuetext.value,
|
|
586
|
+
"aria-orientation": _ctx.vertical ? "vertical" : "horizontal",
|
|
587
|
+
"aria-valuemin": minValue,
|
|
588
|
+
"aria-valuemax": maxValue,
|
|
589
|
+
role: "slider",
|
|
590
|
+
tabindex: _ctx.disabled ? void 0 : 0,
|
|
591
|
+
"aria-disabled": _ctx.disabled,
|
|
592
|
+
onKeydown: _cache[1] || (_cache[1] = (...args) => unref(handleKeydown) && unref(handleKeydown)(...args))
|
|
593
|
+
}, null, 46, _hoisted_1$e)
|
|
594
|
+
],
|
|
595
|
+
2
|
|
596
|
+
);
|
|
549
597
|
};
|
|
550
598
|
}
|
|
551
599
|
});
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
600
|
+
var HueSlider = /* @__PURE__ */ _export_sfc(_sfc_main$v, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/color-picker-panel/src/components/hue-slider.vue"]]);
|
|
601
|
+
const predefineProps = buildProps({
|
|
602
|
+
colors: {
|
|
603
|
+
type: definePropType(Array),
|
|
604
|
+
required: true
|
|
605
|
+
},
|
|
606
|
+
color: {
|
|
607
|
+
type: definePropType(Object),
|
|
608
|
+
required: true
|
|
609
|
+
},
|
|
610
|
+
enableAlpha: {
|
|
611
|
+
type: Boolean,
|
|
612
|
+
required: true
|
|
613
|
+
},
|
|
614
|
+
disabled: Boolean
|
|
615
|
+
});
|
|
616
|
+
const colorPickerPanelProps = buildProps({
|
|
617
|
+
modelValue: {
|
|
618
|
+
type: definePropType(String),
|
|
619
|
+
default: void 0
|
|
620
|
+
},
|
|
621
|
+
border: {
|
|
622
|
+
type: Boolean,
|
|
623
|
+
default: true
|
|
624
|
+
},
|
|
575
625
|
showAlpha: Boolean,
|
|
576
626
|
colorFormat: String,
|
|
577
627
|
disabled: Boolean,
|
|
578
|
-
size: useSizeProp,
|
|
579
|
-
popperClass: {
|
|
580
|
-
type: String,
|
|
581
|
-
default: ""
|
|
582
|
-
},
|
|
583
|
-
tabindex: {
|
|
584
|
-
type: [String, Number],
|
|
585
|
-
default: 0
|
|
586
|
-
},
|
|
587
|
-
teleported: useTooltipContentProps.teleported,
|
|
588
628
|
predefine: {
|
|
589
629
|
type: definePropType(Array)
|
|
590
630
|
},
|
|
591
631
|
validateEvent: {
|
|
592
632
|
type: Boolean,
|
|
593
633
|
default: true
|
|
594
|
-
},
|
|
595
|
-
...useAriaProps(["ariaLabel"])
|
|
596
|
-
});
|
|
597
|
-
const colorPickerEmits = {
|
|
598
|
-
[UPDATE_MODEL_EVENT]: (val) => isString(val) || isNil(val),
|
|
599
|
-
[CHANGE_EVENT]: (val) => isString(val) || isNil(val),
|
|
600
|
-
activeChange: (val) => isString(val) || isNil(val),
|
|
601
|
-
focus: (evt) => evt instanceof FocusEvent,
|
|
602
|
-
blur: (evt) => evt instanceof FocusEvent
|
|
603
|
-
};
|
|
604
|
-
const colorPickerContextKey = Symbol("colorPickerContextKey");
|
|
605
|
-
const hsv2hsl = function(hue, sat, val) {
|
|
606
|
-
return [
|
|
607
|
-
hue,
|
|
608
|
-
sat * val / ((hue = (2 - sat) * val) < 1 ? hue : 2 - hue) || 0,
|
|
609
|
-
hue / 2
|
|
610
|
-
];
|
|
611
|
-
};
|
|
612
|
-
const isOnePointZero = function(n) {
|
|
613
|
-
return isString(n) && n.includes(".") && Number.parseFloat(n) === 1;
|
|
614
|
-
};
|
|
615
|
-
const isPercentage = function(n) {
|
|
616
|
-
return isString(n) && n.includes("%");
|
|
617
|
-
};
|
|
618
|
-
const bound01 = function(value, max) {
|
|
619
|
-
if (isOnePointZero(value))
|
|
620
|
-
value = "100%";
|
|
621
|
-
const processPercent = isPercentage(value);
|
|
622
|
-
value = Math.min(max, Math.max(0, Number.parseFloat(`${value}`)));
|
|
623
|
-
if (processPercent) {
|
|
624
|
-
value = Number.parseInt(`${value * max}`, 10) / 100;
|
|
625
|
-
}
|
|
626
|
-
if (Math.abs(value - max) < 1e-6) {
|
|
627
|
-
return 1;
|
|
628
|
-
}
|
|
629
|
-
return value % max / Number.parseFloat(max);
|
|
630
|
-
};
|
|
631
|
-
const INT_HEX_MAP = {
|
|
632
|
-
10: "A",
|
|
633
|
-
11: "B",
|
|
634
|
-
12: "C",
|
|
635
|
-
13: "D",
|
|
636
|
-
14: "E",
|
|
637
|
-
15: "F"
|
|
638
|
-
};
|
|
639
|
-
const hexOne = (value) => {
|
|
640
|
-
value = Math.min(Math.round(value), 255);
|
|
641
|
-
const high = Math.floor(value / 16);
|
|
642
|
-
const low = value % 16;
|
|
643
|
-
return `${INT_HEX_MAP[high] || high}${INT_HEX_MAP[low] || low}`;
|
|
644
|
-
};
|
|
645
|
-
const toHex = function({ r, g, b }) {
|
|
646
|
-
if (Number.isNaN(+r) || Number.isNaN(+g) || Number.isNaN(+b))
|
|
647
|
-
return "";
|
|
648
|
-
return `#${hexOne(r)}${hexOne(g)}${hexOne(b)}`;
|
|
649
|
-
};
|
|
650
|
-
const HEX_INT_MAP = {
|
|
651
|
-
A: 10,
|
|
652
|
-
B: 11,
|
|
653
|
-
C: 12,
|
|
654
|
-
D: 13,
|
|
655
|
-
E: 14,
|
|
656
|
-
F: 15
|
|
657
|
-
};
|
|
658
|
-
const parseHexChannel = function(hex) {
|
|
659
|
-
if (hex.length === 2) {
|
|
660
|
-
return (HEX_INT_MAP[hex[0].toUpperCase()] || +hex[0]) * 16 + (HEX_INT_MAP[hex[1].toUpperCase()] || +hex[1]);
|
|
661
634
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
sat = sat / 100;
|
|
666
|
-
light = light / 100;
|
|
667
|
-
let smin = sat;
|
|
668
|
-
const lmin = Math.max(light, 0.01);
|
|
669
|
-
light *= 2;
|
|
670
|
-
sat *= light <= 1 ? light : 2 - light;
|
|
671
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
672
|
-
const v = (light + sat) / 2;
|
|
673
|
-
const sv = light === 0 ? 2 * smin / (lmin + smin) : 2 * sat / (light + sat);
|
|
674
|
-
return {
|
|
675
|
-
h: hue,
|
|
676
|
-
s: sv * 100,
|
|
677
|
-
v: v * 100
|
|
678
|
-
};
|
|
679
|
-
};
|
|
680
|
-
const rgb2hsv = (r, g, b) => {
|
|
681
|
-
r = bound01(r, 255);
|
|
682
|
-
g = bound01(g, 255);
|
|
683
|
-
b = bound01(b, 255);
|
|
684
|
-
const max = Math.max(r, g, b);
|
|
685
|
-
const min = Math.min(r, g, b);
|
|
686
|
-
let h2;
|
|
687
|
-
const v = max;
|
|
688
|
-
const d = max - min;
|
|
689
|
-
const s = max === 0 ? 0 : d / max;
|
|
690
|
-
if (max === min) {
|
|
691
|
-
h2 = 0;
|
|
692
|
-
} else {
|
|
693
|
-
switch (max) {
|
|
694
|
-
case r: {
|
|
695
|
-
h2 = (g - b) / d + (g < b ? 6 : 0);
|
|
696
|
-
break;
|
|
697
|
-
}
|
|
698
|
-
case g: {
|
|
699
|
-
h2 = (b - r) / d + 2;
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
case b: {
|
|
703
|
-
h2 = (r - g) / d + 4;
|
|
704
|
-
break;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
h2 /= 6;
|
|
708
|
-
}
|
|
709
|
-
return { h: h2 * 360, s: s * 100, v: v * 100 };
|
|
710
|
-
};
|
|
711
|
-
const hsv2rgb = function(h2, s, v) {
|
|
712
|
-
h2 = bound01(h2, 360) * 6;
|
|
713
|
-
s = bound01(s, 100);
|
|
714
|
-
v = bound01(v, 100);
|
|
715
|
-
const i = Math.floor(h2);
|
|
716
|
-
const f = h2 - i;
|
|
717
|
-
const p = v * (1 - s);
|
|
718
|
-
const q = v * (1 - f * s);
|
|
719
|
-
const t = v * (1 - (1 - f) * s);
|
|
720
|
-
const mod = i % 6;
|
|
721
|
-
const r = [v, q, p, p, t, v][mod];
|
|
722
|
-
const g = [t, v, v, q, p, p][mod];
|
|
723
|
-
const b = [p, p, t, v, v, q][mod];
|
|
724
|
-
return {
|
|
725
|
-
r: Math.round(r * 255),
|
|
726
|
-
g: Math.round(g * 255),
|
|
727
|
-
b: Math.round(b * 255)
|
|
728
|
-
};
|
|
635
|
+
});
|
|
636
|
+
const colorPickerPanelEmits = {
|
|
637
|
+
[UPDATE_MODEL_EVENT]: (val) => isString(val) || isNil(val)
|
|
729
638
|
};
|
|
639
|
+
const ROOT_COMMON_COLOR_INJECTION_KEY = Symbol("colorCommonPickerKey");
|
|
640
|
+
const colorPickerPanelContextKey = Symbol("colorPickerPanelContextKey");
|
|
730
641
|
class Color {
|
|
731
642
|
constructor(options = {}) {
|
|
732
643
|
this._hue = 0;
|
|
733
644
|
this._saturation = 100;
|
|
734
645
|
this._value = 100;
|
|
735
646
|
this._alpha = 100;
|
|
647
|
+
this._tiny = new TinyColor();
|
|
648
|
+
this._isValid = false;
|
|
736
649
|
this.enableAlpha = false;
|
|
737
|
-
this.format = "
|
|
650
|
+
this.format = "";
|
|
738
651
|
this.value = "";
|
|
739
652
|
for (const option in options) {
|
|
740
653
|
if (hasOwn(options, option)) {
|
|
@@ -757,349 +670,667 @@ class Color {
|
|
|
757
670
|
return;
|
|
758
671
|
}
|
|
759
672
|
this[`_${prop}`] = value;
|
|
673
|
+
this._isValid = true;
|
|
760
674
|
this.doOnChange();
|
|
761
675
|
}
|
|
762
676
|
get(prop) {
|
|
763
|
-
if (
|
|
764
|
-
return Math.
|
|
677
|
+
if (["hue", "saturation", "value", "alpha"].includes(prop)) {
|
|
678
|
+
return Math.round(this[`_${prop}`]);
|
|
765
679
|
}
|
|
766
680
|
return this[`_${prop}`];
|
|
767
681
|
}
|
|
768
682
|
toRgb() {
|
|
769
|
-
return
|
|
683
|
+
return this._isValid ? this._tiny.toRgb() : { r: 255, g: 255, b: 255, a: 0 };
|
|
770
684
|
}
|
|
771
685
|
fromString(value) {
|
|
772
|
-
|
|
686
|
+
const color = new TinyColor(value);
|
|
687
|
+
this._isValid = color.isValid;
|
|
688
|
+
if (color.isValid) {
|
|
689
|
+
const { h: h2, s, v, a } = color.toHsv();
|
|
690
|
+
this._hue = h2;
|
|
691
|
+
this._saturation = s * 100;
|
|
692
|
+
this._value = v * 100;
|
|
693
|
+
this._alpha = a * 100;
|
|
694
|
+
} else {
|
|
773
695
|
this._hue = 0;
|
|
774
696
|
this._saturation = 100;
|
|
775
697
|
this._value = 100;
|
|
776
|
-
this.
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
const fromHSV = (h2, s, v) => {
|
|
780
|
-
this._hue = Math.max(0, Math.min(360, h2));
|
|
781
|
-
this._saturation = Math.max(0, Math.min(100, s));
|
|
782
|
-
this._value = Math.max(0, Math.min(100, v));
|
|
783
|
-
this.doOnChange();
|
|
784
|
-
};
|
|
785
|
-
if (value.includes("hsl")) {
|
|
786
|
-
const parts = value.replace(/hsla|hsl|\(|\)/gm, "").split(/\s|,/g).filter((val) => val !== "").map((val, index2) => index2 > 2 ? Number.parseFloat(val) : Number.parseInt(val, 10));
|
|
787
|
-
if (parts.length === 4) {
|
|
788
|
-
this._alpha = Number.parseFloat(parts[3]) * 100;
|
|
789
|
-
} else if (parts.length === 3) {
|
|
790
|
-
this._alpha = 100;
|
|
791
|
-
}
|
|
792
|
-
if (parts.length >= 3) {
|
|
793
|
-
const { h: h2, s, v } = hsl2hsv(parts[0], parts[1], parts[2]);
|
|
794
|
-
fromHSV(h2, s, v);
|
|
795
|
-
}
|
|
796
|
-
} else if (value.includes("hsv")) {
|
|
797
|
-
const parts = value.replace(/hsva|hsv|\(|\)/gm, "").split(/\s|,/g).filter((val) => val !== "").map((val, index2) => index2 > 2 ? Number.parseFloat(val) : Number.parseInt(val, 10));
|
|
798
|
-
if (parts.length === 4) {
|
|
799
|
-
this._alpha = Number.parseFloat(parts[3]) * 100;
|
|
800
|
-
} else if (parts.length === 3) {
|
|
801
|
-
this._alpha = 100;
|
|
802
|
-
}
|
|
803
|
-
if (parts.length >= 3) {
|
|
804
|
-
fromHSV(parts[0], parts[1], parts[2]);
|
|
805
|
-
}
|
|
806
|
-
} else if (value.includes("rgb")) {
|
|
807
|
-
const parts = value.replace(/rgba|rgb|\(|\)/gm, "").split(/\s|,/g).filter((val) => val !== "").map((val, index2) => index2 > 2 ? Number.parseFloat(val) : Number.parseInt(val, 10));
|
|
808
|
-
if (parts.length === 4) {
|
|
809
|
-
this._alpha = Number.parseFloat(parts[3]) * 100;
|
|
810
|
-
} else if (parts.length === 3) {
|
|
811
|
-
this._alpha = 100;
|
|
812
|
-
}
|
|
813
|
-
if (parts.length >= 3) {
|
|
814
|
-
const { h: h2, s, v } = rgb2hsv(parts[0], parts[1], parts[2]);
|
|
815
|
-
fromHSV(h2, s, v);
|
|
816
|
-
}
|
|
817
|
-
} else if (value.includes("#")) {
|
|
818
|
-
const hex = value.replace("#", "").trim();
|
|
819
|
-
if (!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$|^[0-9a-fA-F]{8}$/.test(hex))
|
|
820
|
-
return;
|
|
821
|
-
let r, g, b;
|
|
822
|
-
if (hex.length === 3) {
|
|
823
|
-
r = parseHexChannel(hex[0] + hex[0]);
|
|
824
|
-
g = parseHexChannel(hex[1] + hex[1]);
|
|
825
|
-
b = parseHexChannel(hex[2] + hex[2]);
|
|
826
|
-
} else if (hex.length === 6 || hex.length === 8) {
|
|
827
|
-
r = parseHexChannel(hex.slice(0, 2));
|
|
828
|
-
g = parseHexChannel(hex.slice(2, 4));
|
|
829
|
-
b = parseHexChannel(hex.slice(4, 6));
|
|
830
|
-
}
|
|
831
|
-
if (hex.length === 8) {
|
|
832
|
-
this._alpha = parseHexChannel(hex.slice(6)) / 255 * 100;
|
|
833
|
-
} else if (hex.length === 3 || hex.length === 6) {
|
|
834
|
-
this._alpha = 100;
|
|
835
|
-
}
|
|
836
|
-
const { h: h2, s, v } = rgb2hsv(r, g, b);
|
|
837
|
-
fromHSV(h2, s, v);
|
|
698
|
+
this._alpha = 100;
|
|
838
699
|
}
|
|
700
|
+
this.doOnChange();
|
|
701
|
+
}
|
|
702
|
+
clear() {
|
|
703
|
+
this._isValid = false;
|
|
704
|
+
this.value = "";
|
|
705
|
+
this._hue = 0;
|
|
706
|
+
this._saturation = 100;
|
|
707
|
+
this._value = 100;
|
|
708
|
+
this._alpha = 100;
|
|
839
709
|
}
|
|
840
710
|
compare(color) {
|
|
841
|
-
|
|
711
|
+
const compareColor = new TinyColor({
|
|
712
|
+
h: color._hue,
|
|
713
|
+
s: color._saturation / 100,
|
|
714
|
+
v: color._value / 100,
|
|
715
|
+
a: color._alpha / 100
|
|
716
|
+
});
|
|
717
|
+
return this._tiny.equals(compareColor);
|
|
842
718
|
}
|
|
843
719
|
doOnChange() {
|
|
844
|
-
const { _hue, _saturation, _value, _alpha, format } = this;
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
const hsl = hsv2hsl(_hue, _saturation / 100, _value / 100);
|
|
849
|
-
this.value = `hsla(${_hue}, ${Math.round(hsl[1] * 100)}%, ${Math.round(hsl[2] * 100)}%, ${this.get("alpha") / 100})`;
|
|
850
|
-
break;
|
|
851
|
-
}
|
|
852
|
-
case "hsv": {
|
|
853
|
-
this.value = `hsva(${_hue}, ${Math.round(_saturation)}%, ${Math.round(_value)}%, ${this.get("alpha") / 100})`;
|
|
854
|
-
break;
|
|
855
|
-
}
|
|
856
|
-
case "hex": {
|
|
857
|
-
this.value = `${toHex(hsv2rgb(_hue, _saturation, _value))}${hexOne(_alpha * 255 / 100)}`;
|
|
858
|
-
break;
|
|
859
|
-
}
|
|
860
|
-
default: {
|
|
861
|
-
const { r, g, b } = hsv2rgb(_hue, _saturation, _value);
|
|
862
|
-
this.value = `rgba(${r}, ${g}, ${b}, ${this.get("alpha") / 100})`;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
} else {
|
|
866
|
-
switch (format) {
|
|
867
|
-
case "hsl": {
|
|
868
|
-
const hsl = hsv2hsl(_hue, _saturation / 100, _value / 100);
|
|
869
|
-
this.value = `hsl(${_hue}, ${Math.round(hsl[1] * 100)}%, ${Math.round(hsl[2] * 100)}%)`;
|
|
870
|
-
break;
|
|
871
|
-
}
|
|
872
|
-
case "hsv": {
|
|
873
|
-
this.value = `hsv(${_hue}, ${Math.round(_saturation)}%, ${Math.round(_value)}%)`;
|
|
874
|
-
break;
|
|
875
|
-
}
|
|
876
|
-
case "rgb": {
|
|
877
|
-
const { r, g, b } = hsv2rgb(_hue, _saturation, _value);
|
|
878
|
-
this.value = `rgb(${r}, ${g}, ${b})`;
|
|
879
|
-
break;
|
|
880
|
-
}
|
|
881
|
-
default: {
|
|
882
|
-
this.value = toHex(hsv2rgb(_hue, _saturation, _value));
|
|
883
|
-
}
|
|
884
|
-
}
|
|
720
|
+
const { _hue, _saturation, _value, _alpha, format, enableAlpha } = this;
|
|
721
|
+
let _format = format || (enableAlpha ? "rgb" : "hex");
|
|
722
|
+
if (format === "hex" && enableAlpha) {
|
|
723
|
+
_format = "hex8";
|
|
885
724
|
}
|
|
725
|
+
this._tiny = new TinyColor({
|
|
726
|
+
h: _hue,
|
|
727
|
+
s: _saturation / 100,
|
|
728
|
+
v: _value / 100,
|
|
729
|
+
a: _alpha / 100
|
|
730
|
+
});
|
|
731
|
+
this.value = this._isValid ? this._tiny.toString(_format) : "";
|
|
886
732
|
}
|
|
887
733
|
}
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
enableAlpha: {
|
|
899
|
-
type: Boolean,
|
|
900
|
-
required: true
|
|
901
|
-
}
|
|
902
|
-
},
|
|
903
|
-
setup(props) {
|
|
904
|
-
const ns = useNamespace("color-predefine");
|
|
905
|
-
const { currentColor } = inject(colorPickerContextKey);
|
|
906
|
-
const rgbaColors = ref(parseColors(props.colors, props.color));
|
|
907
|
-
watch(() => currentColor.value, (val) => {
|
|
908
|
-
const color = new Color();
|
|
909
|
-
color.fromString(val);
|
|
734
|
+
const usePredefine = (props) => {
|
|
735
|
+
const { currentColor } = inject(colorPickerPanelContextKey);
|
|
736
|
+
const rgbaColors = ref(parseColors(props.colors, props.color));
|
|
737
|
+
watch(
|
|
738
|
+
() => currentColor.value,
|
|
739
|
+
(val) => {
|
|
740
|
+
const color = new Color({
|
|
741
|
+
value: val,
|
|
742
|
+
enableAlpha: props.enableAlpha
|
|
743
|
+
});
|
|
910
744
|
rgbaColors.value.forEach((item) => {
|
|
911
745
|
item.selected = color.compare(item);
|
|
912
746
|
});
|
|
913
|
-
});
|
|
914
|
-
watchEffect(() => {
|
|
915
|
-
rgbaColors.value = parseColors(props.colors, props.color);
|
|
916
|
-
});
|
|
917
|
-
function handleSelect(index2) {
|
|
918
|
-
props.color.fromString(props.colors[index2]);
|
|
919
747
|
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
748
|
+
);
|
|
749
|
+
watchEffect(() => {
|
|
750
|
+
rgbaColors.value = parseColors(props.colors, props.color);
|
|
751
|
+
});
|
|
752
|
+
function handleSelect(index2) {
|
|
753
|
+
props.color.fromString(props.colors[index2]);
|
|
754
|
+
}
|
|
755
|
+
function parseColors(colors, color) {
|
|
756
|
+
return colors.map((value) => {
|
|
757
|
+
const c = new Color({
|
|
758
|
+
value,
|
|
759
|
+
enableAlpha: props.enableAlpha
|
|
928
760
|
});
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
761
|
+
c.selected = c.compare(color);
|
|
762
|
+
return c;
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
return {
|
|
766
|
+
rgbaColors,
|
|
767
|
+
handleSelect
|
|
768
|
+
};
|
|
769
|
+
};
|
|
770
|
+
const usePredefineDOM = (props) => {
|
|
771
|
+
const ns = useNamespace("color-predefine");
|
|
772
|
+
const rootKls = computed(() => [ns.b(), ns.is("disabled", props.disabled)]);
|
|
773
|
+
const colorsKls = computed(() => ns.e("colors"));
|
|
774
|
+
function colorSelectorKls(item) {
|
|
775
|
+
return [
|
|
776
|
+
ns.e("color-selector"),
|
|
777
|
+
ns.is("alpha", item.get("alpha") < 100),
|
|
778
|
+
{ selected: item.selected }
|
|
779
|
+
];
|
|
780
|
+
}
|
|
781
|
+
return {
|
|
782
|
+
rootKls,
|
|
783
|
+
colorsKls,
|
|
784
|
+
colorSelectorKls
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
const _hoisted_1$d = ["disabled", "aria-label", "onClick"];
|
|
788
|
+
const _sfc_main$u = defineComponent({
|
|
789
|
+
...{
|
|
790
|
+
name: "ElColorPredefine"
|
|
791
|
+
},
|
|
792
|
+
__name: "predefine",
|
|
793
|
+
props: predefineProps,
|
|
794
|
+
setup(__props) {
|
|
795
|
+
const props = __props;
|
|
796
|
+
const { rgbaColors, handleSelect } = usePredefine(props);
|
|
797
|
+
const { rootKls, colorsKls, colorSelectorKls } = usePredefineDOM(props);
|
|
798
|
+
const { t } = useLocale();
|
|
799
|
+
const ariaLabel = (value) => {
|
|
800
|
+
return t("el.colorpicker.predefineDescription", { value });
|
|
801
|
+
};
|
|
802
|
+
return (_ctx, _cache) => {
|
|
803
|
+
return openBlock(), createElementBlock(
|
|
804
|
+
"div",
|
|
805
|
+
{
|
|
806
|
+
class: normalizeClass(unref(rootKls))
|
|
807
|
+
},
|
|
808
|
+
[
|
|
809
|
+
createElementVNode(
|
|
810
|
+
"div",
|
|
811
|
+
{
|
|
812
|
+
class: normalizeClass(unref(colorsKls))
|
|
813
|
+
},
|
|
814
|
+
[
|
|
815
|
+
(openBlock(true), createElementBlock(
|
|
816
|
+
Fragment,
|
|
817
|
+
null,
|
|
818
|
+
renderList(unref(rgbaColors), (item, index2) => {
|
|
819
|
+
return openBlock(), createElementBlock("button", {
|
|
820
|
+
key: _ctx.colors[index2],
|
|
821
|
+
type: "button",
|
|
822
|
+
disabled: _ctx.disabled,
|
|
823
|
+
"aria-label": ariaLabel(item.value),
|
|
824
|
+
class: normalizeClass(unref(colorSelectorKls)(item)),
|
|
825
|
+
onClick: ($event) => unref(handleSelect)(index2)
|
|
826
|
+
}, [
|
|
827
|
+
createElementVNode(
|
|
828
|
+
"div",
|
|
829
|
+
{
|
|
830
|
+
style: normalizeStyle({ backgroundColor: item.value })
|
|
831
|
+
},
|
|
832
|
+
null,
|
|
833
|
+
4
|
|
834
|
+
)
|
|
835
|
+
], 10, _hoisted_1$d);
|
|
836
|
+
}),
|
|
837
|
+
128
|
|
838
|
+
))
|
|
839
|
+
],
|
|
840
|
+
2
|
|
841
|
+
)
|
|
842
|
+
],
|
|
843
|
+
2
|
|
844
|
+
);
|
|
934
845
|
};
|
|
935
846
|
}
|
|
936
847
|
});
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
class: normalizeClass(_ctx.ns.e("colors"))
|
|
943
|
-
}, [
|
|
944
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.rgbaColors, (item, index2) => {
|
|
945
|
-
return openBlock(), createElementBlock("div", {
|
|
946
|
-
key: _ctx.colors[index2],
|
|
947
|
-
class: normalizeClass([
|
|
948
|
-
_ctx.ns.e("color-selector"),
|
|
949
|
-
_ctx.ns.is("alpha", item._alpha < 100),
|
|
950
|
-
{ selected: item.selected }
|
|
951
|
-
]),
|
|
952
|
-
onClick: ($event) => _ctx.handleSelect(index2)
|
|
953
|
-
}, [
|
|
954
|
-
createElementVNode("div", {
|
|
955
|
-
style: normalizeStyle({ backgroundColor: item.value })
|
|
956
|
-
}, null, 4)
|
|
957
|
-
], 10, ["onClick"]);
|
|
958
|
-
}), 128))
|
|
959
|
-
], 2)
|
|
960
|
-
], 2);
|
|
961
|
-
}
|
|
962
|
-
var Predefine = /* @__PURE__ */ _export_sfc(_sfc_main$t, [["render", _sfc_render$3], ["__file", "predefine.vue"]]);
|
|
963
|
-
const _sfc_main$s = defineComponent({
|
|
964
|
-
name: "ElSlPanel",
|
|
965
|
-
props: {
|
|
966
|
-
color: {
|
|
967
|
-
type: Object,
|
|
968
|
-
required: true
|
|
969
|
-
}
|
|
848
|
+
var Predefine = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/color-picker-panel/src/components/predefine.vue"]]);
|
|
849
|
+
const svPanelProps = buildProps({
|
|
850
|
+
color: {
|
|
851
|
+
type: definePropType(Object),
|
|
852
|
+
required: true
|
|
970
853
|
},
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
background.value = `hsl(${props.color.get("hue")}, 100%, 50%)`;
|
|
990
|
-
}
|
|
991
|
-
function handleDrag(event) {
|
|
992
|
-
const el = instance.vnode.el;
|
|
993
|
-
const rect = el.getBoundingClientRect();
|
|
994
|
-
const { clientX, clientY } = getClientXY(event);
|
|
995
|
-
let left = clientX - rect.left;
|
|
996
|
-
let top = clientY - rect.top;
|
|
997
|
-
left = Math.max(0, left);
|
|
998
|
-
left = Math.min(left, rect.width);
|
|
999
|
-
top = Math.max(0, top);
|
|
1000
|
-
top = Math.min(top, rect.height);
|
|
1001
|
-
cursorLeft.value = left;
|
|
1002
|
-
cursorTop.value = top;
|
|
1003
|
-
props.color.set({
|
|
1004
|
-
saturation: left / rect.width * 100,
|
|
1005
|
-
value: 100 - top / rect.height * 100
|
|
1006
|
-
});
|
|
854
|
+
disabled: Boolean
|
|
855
|
+
});
|
|
856
|
+
const useSvPanel = (props) => {
|
|
857
|
+
const instance = getCurrentInstance();
|
|
858
|
+
const cursorRef = ref();
|
|
859
|
+
const cursorTop = ref(0);
|
|
860
|
+
const cursorLeft = ref(0);
|
|
861
|
+
const background = ref("hsl(0, 100%, 50%)");
|
|
862
|
+
const saturation = computed(() => props.color.get("saturation"));
|
|
863
|
+
const brightness = computed(() => props.color.get("value"));
|
|
864
|
+
const hue = computed(() => props.color.get("hue"));
|
|
865
|
+
function handleClick(event) {
|
|
866
|
+
var _a;
|
|
867
|
+
if (props.disabled)
|
|
868
|
+
return;
|
|
869
|
+
const target = event.target;
|
|
870
|
+
if (target !== cursorRef.value) {
|
|
871
|
+
handleDrag(event);
|
|
1007
872
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
873
|
+
(_a = cursorRef.value) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
874
|
+
}
|
|
875
|
+
function handleDrag(event) {
|
|
876
|
+
if (props.disabled)
|
|
877
|
+
return;
|
|
878
|
+
const el = instance.vnode.el;
|
|
879
|
+
const rect = el.getBoundingClientRect();
|
|
880
|
+
const { clientX, clientY } = getClientXY(event);
|
|
881
|
+
let left = clientX - rect.left;
|
|
882
|
+
let top = clientY - rect.top;
|
|
883
|
+
left = Math.max(0, left);
|
|
884
|
+
left = Math.min(left, rect.width);
|
|
885
|
+
top = Math.max(0, top);
|
|
886
|
+
top = Math.min(top, rect.height);
|
|
887
|
+
cursorLeft.value = left;
|
|
888
|
+
cursorTop.value = top;
|
|
889
|
+
props.color.set({
|
|
890
|
+
saturation: left / rect.width * 100,
|
|
891
|
+
value: 100 - top / rect.height * 100
|
|
1010
892
|
});
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
893
|
+
}
|
|
894
|
+
function handleKeydown(event) {
|
|
895
|
+
if (props.disabled)
|
|
896
|
+
return;
|
|
897
|
+
const { shiftKey } = event;
|
|
898
|
+
const code = getEventCode(event);
|
|
899
|
+
const step = shiftKey ? 10 : 1;
|
|
900
|
+
let isPreventDefault = true;
|
|
901
|
+
switch (code) {
|
|
902
|
+
case EVENT_CODE.left:
|
|
903
|
+
incrementSaturation(-step);
|
|
904
|
+
break;
|
|
905
|
+
case EVENT_CODE.right:
|
|
906
|
+
incrementSaturation(step);
|
|
907
|
+
break;
|
|
908
|
+
case EVENT_CODE.up:
|
|
909
|
+
incrementBrightness(step);
|
|
910
|
+
break;
|
|
911
|
+
case EVENT_CODE.down:
|
|
912
|
+
incrementBrightness(-step);
|
|
913
|
+
break;
|
|
914
|
+
default:
|
|
915
|
+
isPreventDefault = false;
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
isPreventDefault && event.preventDefault();
|
|
919
|
+
}
|
|
920
|
+
function incrementSaturation(step) {
|
|
921
|
+
let next = saturation.value + step;
|
|
922
|
+
next = next < 0 ? 0 : next > 100 ? 100 : next;
|
|
923
|
+
props.color.set("saturation", next);
|
|
924
|
+
}
|
|
925
|
+
function incrementBrightness(step) {
|
|
926
|
+
let next = brightness.value + step;
|
|
927
|
+
next = next < 0 ? 0 : next > 100 ? 100 : next;
|
|
928
|
+
props.color.set("value", next);
|
|
929
|
+
}
|
|
930
|
+
return {
|
|
931
|
+
cursorRef,
|
|
932
|
+
cursorTop,
|
|
933
|
+
cursorLeft,
|
|
934
|
+
background,
|
|
935
|
+
saturation,
|
|
936
|
+
brightness,
|
|
937
|
+
hue,
|
|
938
|
+
handleClick,
|
|
939
|
+
handleDrag,
|
|
940
|
+
handleKeydown
|
|
941
|
+
};
|
|
942
|
+
};
|
|
943
|
+
const useSvPanelDOM = (props, {
|
|
944
|
+
cursorTop,
|
|
945
|
+
cursorLeft,
|
|
946
|
+
background,
|
|
947
|
+
handleDrag
|
|
948
|
+
}) => {
|
|
949
|
+
const instance = getCurrentInstance();
|
|
950
|
+
const ns = useNamespace("color-svpanel");
|
|
951
|
+
function update() {
|
|
952
|
+
const saturation = props.color.get("saturation");
|
|
953
|
+
const brightness = props.color.get("value");
|
|
954
|
+
const el = instance.vnode.el;
|
|
955
|
+
const { clientWidth: width, clientHeight: height } = el;
|
|
956
|
+
cursorLeft.value = saturation * width / 100;
|
|
957
|
+
cursorTop.value = (100 - brightness) * height / 100;
|
|
958
|
+
background.value = `hsl(${props.color.get("hue")}, 100%, 50%)`;
|
|
959
|
+
}
|
|
960
|
+
onMounted(() => {
|
|
961
|
+
draggable(instance.vnode.el, {
|
|
962
|
+
drag: (event) => {
|
|
963
|
+
handleDrag(event);
|
|
964
|
+
},
|
|
965
|
+
end: (event) => {
|
|
966
|
+
handleDrag(event);
|
|
967
|
+
}
|
|
1021
968
|
});
|
|
1022
|
-
|
|
969
|
+
update();
|
|
970
|
+
});
|
|
971
|
+
watch(
|
|
972
|
+
[
|
|
973
|
+
() => props.color.get("hue"),
|
|
974
|
+
() => props.color.get("value"),
|
|
975
|
+
() => props.color.value
|
|
976
|
+
],
|
|
977
|
+
() => update()
|
|
978
|
+
);
|
|
979
|
+
const rootKls = computed(() => ns.b());
|
|
980
|
+
const cursorKls = computed(() => ns.e("cursor"));
|
|
981
|
+
const rootStyle = computed(() => ({
|
|
982
|
+
backgroundColor: background.value
|
|
983
|
+
}));
|
|
984
|
+
const cursorStyle = computed(() => ({
|
|
985
|
+
top: addUnit(cursorTop.value),
|
|
986
|
+
left: addUnit(cursorLeft.value)
|
|
987
|
+
}));
|
|
988
|
+
return {
|
|
989
|
+
rootKls,
|
|
990
|
+
cursorKls,
|
|
991
|
+
rootStyle,
|
|
992
|
+
cursorStyle,
|
|
993
|
+
update
|
|
994
|
+
};
|
|
995
|
+
};
|
|
996
|
+
const _hoisted_1$c = ["tabindex", "aria-disabled", "aria-label", "aria-valuenow", "aria-valuetext"];
|
|
997
|
+
const _sfc_main$t = defineComponent({
|
|
998
|
+
...{
|
|
999
|
+
name: "ElSvPanel"
|
|
1000
|
+
},
|
|
1001
|
+
__name: "sv-panel",
|
|
1002
|
+
props: svPanelProps,
|
|
1003
|
+
setup(__props, { expose: __expose }) {
|
|
1004
|
+
const props = __props;
|
|
1005
|
+
const {
|
|
1006
|
+
cursorRef,
|
|
1023
1007
|
cursorTop,
|
|
1024
1008
|
cursorLeft,
|
|
1025
1009
|
background,
|
|
1026
|
-
|
|
1010
|
+
saturation,
|
|
1011
|
+
brightness,
|
|
1012
|
+
handleClick,
|
|
1027
1013
|
handleDrag,
|
|
1028
|
-
|
|
1029
|
-
|
|
1014
|
+
handleKeydown
|
|
1015
|
+
} = useSvPanel(props);
|
|
1016
|
+
const { rootKls, cursorKls, rootStyle, cursorStyle, update } = useSvPanelDOM(
|
|
1017
|
+
props,
|
|
1018
|
+
{
|
|
1019
|
+
cursorTop,
|
|
1020
|
+
cursorLeft,
|
|
1021
|
+
background,
|
|
1022
|
+
handleDrag
|
|
1023
|
+
}
|
|
1024
|
+
);
|
|
1025
|
+
const { t } = useLocale();
|
|
1026
|
+
const ariaLabel = computed(() => t("el.colorpicker.svLabel"));
|
|
1027
|
+
const ariaValuetext = computed(() => {
|
|
1028
|
+
return t("el.colorpicker.svDescription", {
|
|
1029
|
+
saturation: saturation.value,
|
|
1030
|
+
brightness: brightness.value,
|
|
1031
|
+
color: props.color.value
|
|
1032
|
+
});
|
|
1033
|
+
});
|
|
1034
|
+
__expose({
|
|
1035
|
+
update
|
|
1036
|
+
});
|
|
1037
|
+
return (_ctx, _cache) => {
|
|
1038
|
+
return openBlock(), createElementBlock(
|
|
1039
|
+
"div",
|
|
1040
|
+
{
|
|
1041
|
+
class: normalizeClass(unref(rootKls)),
|
|
1042
|
+
style: normalizeStyle(unref(rootStyle)),
|
|
1043
|
+
onClick: _cache[1] || (_cache[1] = (...args) => unref(handleClick) && unref(handleClick)(...args))
|
|
1044
|
+
},
|
|
1045
|
+
[
|
|
1046
|
+
createElementVNode("div", {
|
|
1047
|
+
ref_key: "cursorRef",
|
|
1048
|
+
ref: cursorRef,
|
|
1049
|
+
class: normalizeClass(unref(cursorKls)),
|
|
1050
|
+
style: normalizeStyle(unref(cursorStyle)),
|
|
1051
|
+
tabindex: _ctx.disabled ? void 0 : 0,
|
|
1052
|
+
"aria-disabled": _ctx.disabled,
|
|
1053
|
+
role: "slider",
|
|
1054
|
+
"aria-valuemin": "0,0",
|
|
1055
|
+
"aria-valuemax": "100,100",
|
|
1056
|
+
"aria-label": ariaLabel.value,
|
|
1057
|
+
"aria-valuenow": `${unref(saturation)},${unref(brightness)}`,
|
|
1058
|
+
"aria-valuetext": ariaValuetext.value,
|
|
1059
|
+
onKeydown: _cache[0] || (_cache[0] = (...args) => unref(handleKeydown) && unref(handleKeydown)(...args))
|
|
1060
|
+
}, null, 46, _hoisted_1$c)
|
|
1061
|
+
],
|
|
1062
|
+
6
|
|
1063
|
+
);
|
|
1030
1064
|
};
|
|
1031
1065
|
}
|
|
1032
1066
|
});
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1067
|
+
var SvPanel = /* @__PURE__ */ _export_sfc(_sfc_main$t, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/color-picker-panel/src/components/sv-panel.vue"]]);
|
|
1068
|
+
const useCommonColor = (props, emit) => {
|
|
1069
|
+
const color = reactive(
|
|
1070
|
+
new Color({
|
|
1071
|
+
enableAlpha: props.showAlpha,
|
|
1072
|
+
format: props.colorFormat || "",
|
|
1073
|
+
value: props.modelValue
|
|
1038
1074
|
})
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1075
|
+
);
|
|
1076
|
+
watch(
|
|
1077
|
+
() => [props.colorFormat, props.showAlpha],
|
|
1078
|
+
() => {
|
|
1079
|
+
color.enableAlpha = props.showAlpha;
|
|
1080
|
+
color.format = props.colorFormat || color.format;
|
|
1081
|
+
color.doOnChange();
|
|
1082
|
+
emit(UPDATE_MODEL_EVENT, color.value);
|
|
1083
|
+
}
|
|
1084
|
+
);
|
|
1085
|
+
return {
|
|
1086
|
+
color
|
|
1087
|
+
};
|
|
1088
|
+
};
|
|
1089
|
+
const _sfc_main$s = defineComponent({
|
|
1090
|
+
...{
|
|
1091
|
+
name: "ElColorPickerPanel"
|
|
1092
|
+
},
|
|
1093
|
+
__name: "color-picker-panel",
|
|
1094
|
+
props: colorPickerPanelProps,
|
|
1095
|
+
emits: colorPickerPanelEmits,
|
|
1096
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1097
|
+
const props = __props;
|
|
1098
|
+
const emit = __emit;
|
|
1099
|
+
const ns = useNamespace("color-picker-panel");
|
|
1100
|
+
const { formItem } = useFormItem();
|
|
1101
|
+
const disabled = useFormDisabled();
|
|
1102
|
+
const hueRef = ref();
|
|
1103
|
+
const svRef = ref();
|
|
1104
|
+
const alphaRef = ref();
|
|
1105
|
+
const inputRef = ref();
|
|
1106
|
+
const customInput = ref("");
|
|
1107
|
+
const { color } = inject(
|
|
1108
|
+
ROOT_COMMON_COLOR_INJECTION_KEY,
|
|
1109
|
+
() => useCommonColor(props, emit),
|
|
1110
|
+
true
|
|
1111
|
+
);
|
|
1112
|
+
function handleConfirm() {
|
|
1113
|
+
color.fromString(customInput.value);
|
|
1114
|
+
if (color.value !== customInput.value) {
|
|
1115
|
+
customInput.value = color.value;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
function handleFocusout() {
|
|
1119
|
+
var _a;
|
|
1120
|
+
if (props.validateEvent) {
|
|
1121
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur").catch((err) => debugWarn(err));
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
function update() {
|
|
1125
|
+
var _a, _b, _c;
|
|
1126
|
+
(_a = hueRef.value) == null ? void 0 : _a.update();
|
|
1127
|
+
(_b = svRef.value) == null ? void 0 : _b.update();
|
|
1128
|
+
(_c = alphaRef.value) == null ? void 0 : _c.update();
|
|
1129
|
+
}
|
|
1130
|
+
onMounted(() => {
|
|
1131
|
+
if (props.modelValue) {
|
|
1132
|
+
customInput.value = color.value;
|
|
1133
|
+
}
|
|
1134
|
+
nextTick(update);
|
|
1135
|
+
});
|
|
1136
|
+
watch(
|
|
1137
|
+
() => props.modelValue,
|
|
1138
|
+
(newVal) => {
|
|
1139
|
+
if (newVal !== color.value) {
|
|
1140
|
+
newVal ? color.fromString(newVal) : color.clear();
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
);
|
|
1144
|
+
watch(
|
|
1145
|
+
() => color.value,
|
|
1146
|
+
(val) => {
|
|
1147
|
+
emit(UPDATE_MODEL_EVENT, val);
|
|
1148
|
+
customInput.value = val;
|
|
1149
|
+
if (props.validateEvent) {
|
|
1150
|
+
formItem == null ? void 0 : formItem.validate("change").catch((err) => debugWarn(err));
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
provide(colorPickerPanelContextKey, {
|
|
1155
|
+
currentColor: computed(() => color.value)
|
|
1156
|
+
});
|
|
1157
|
+
__expose({
|
|
1158
|
+
color,
|
|
1159
|
+
inputRef,
|
|
1160
|
+
update
|
|
1161
|
+
});
|
|
1162
|
+
return (_ctx, _cache) => {
|
|
1163
|
+
return openBlock(), createElementBlock(
|
|
1164
|
+
"div",
|
|
1165
|
+
{
|
|
1166
|
+
class: normalizeClass([unref(ns).b(), unref(ns).is("disabled", unref(disabled)), unref(ns).is("border", _ctx.border)]),
|
|
1167
|
+
onFocusout: handleFocusout
|
|
1168
|
+
},
|
|
1169
|
+
[
|
|
1170
|
+
createElementVNode(
|
|
1171
|
+
"div",
|
|
1172
|
+
{
|
|
1173
|
+
class: normalizeClass(unref(ns).e("wrapper"))
|
|
1174
|
+
},
|
|
1175
|
+
[
|
|
1176
|
+
createVNode(HueSlider, {
|
|
1177
|
+
ref_key: "hueRef",
|
|
1178
|
+
ref: hueRef,
|
|
1179
|
+
class: "hue-slider",
|
|
1180
|
+
color: unref(color),
|
|
1181
|
+
vertical: "",
|
|
1182
|
+
disabled: unref(disabled)
|
|
1183
|
+
}, null, 8, ["color", "disabled"]),
|
|
1184
|
+
createVNode(SvPanel, {
|
|
1185
|
+
ref_key: "svRef",
|
|
1186
|
+
ref: svRef,
|
|
1187
|
+
color: unref(color),
|
|
1188
|
+
disabled: unref(disabled)
|
|
1189
|
+
}, null, 8, ["color", "disabled"])
|
|
1190
|
+
],
|
|
1191
|
+
2
|
|
1192
|
+
),
|
|
1193
|
+
_ctx.showAlpha ? (openBlock(), createBlock(AlphaSlider, {
|
|
1194
|
+
key: 0,
|
|
1195
|
+
ref_key: "alphaRef",
|
|
1196
|
+
ref: alphaRef,
|
|
1197
|
+
color: unref(color),
|
|
1198
|
+
disabled: unref(disabled)
|
|
1199
|
+
}, null, 8, ["color", "disabled"])) : createCommentVNode("v-if", true),
|
|
1200
|
+
_ctx.predefine ? (openBlock(), createBlock(Predefine, {
|
|
1201
|
+
key: 1,
|
|
1202
|
+
ref: "predefine",
|
|
1203
|
+
"enable-alpha": _ctx.showAlpha,
|
|
1204
|
+
color: unref(color),
|
|
1205
|
+
colors: _ctx.predefine,
|
|
1206
|
+
disabled: unref(disabled)
|
|
1207
|
+
}, null, 8, ["enable-alpha", "color", "colors", "disabled"])) : createCommentVNode("v-if", true),
|
|
1208
|
+
createElementVNode(
|
|
1209
|
+
"div",
|
|
1210
|
+
{
|
|
1211
|
+
class: normalizeClass(unref(ns).e("footer"))
|
|
1212
|
+
},
|
|
1213
|
+
[
|
|
1214
|
+
createVNode(unref(ElInput), {
|
|
1215
|
+
ref_key: "inputRef",
|
|
1216
|
+
ref: inputRef,
|
|
1217
|
+
modelValue: customInput.value,
|
|
1218
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => customInput.value = $event),
|
|
1219
|
+
"validate-event": false,
|
|
1220
|
+
size: "small",
|
|
1221
|
+
disabled: unref(disabled),
|
|
1222
|
+
onChange: handleConfirm
|
|
1223
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
1224
|
+
renderSlot(_ctx.$slots, "footer")
|
|
1225
|
+
],
|
|
1226
|
+
2
|
|
1227
|
+
)
|
|
1228
|
+
],
|
|
1229
|
+
34
|
|
1230
|
+
);
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
var ColorPickerPanel = /* @__PURE__ */ _export_sfc(_sfc_main$s, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/color-picker-panel/src/color-picker-panel.vue"]]);
|
|
1235
|
+
const ElColorPickerPanel = withInstall(ColorPickerPanel);
|
|
1236
|
+
const colorPickerProps = buildProps({
|
|
1237
|
+
persistent: {
|
|
1238
|
+
type: Boolean,
|
|
1239
|
+
default: true
|
|
1240
|
+
},
|
|
1241
|
+
modelValue: {
|
|
1242
|
+
type: definePropType(String),
|
|
1243
|
+
default: void 0
|
|
1244
|
+
},
|
|
1245
|
+
id: String,
|
|
1246
|
+
showAlpha: Boolean,
|
|
1247
|
+
colorFormat: String,
|
|
1248
|
+
disabled: {
|
|
1249
|
+
type: Boolean,
|
|
1250
|
+
default: void 0
|
|
1251
|
+
},
|
|
1252
|
+
clearable: {
|
|
1253
|
+
type: Boolean,
|
|
1254
|
+
default: true
|
|
1255
|
+
},
|
|
1256
|
+
size: useSizeProp,
|
|
1257
|
+
popperClass: useTooltipContentProps.popperClass,
|
|
1258
|
+
popperStyle: useTooltipContentProps.popperStyle,
|
|
1259
|
+
tabindex: {
|
|
1260
|
+
type: [String, Number],
|
|
1261
|
+
default: 0
|
|
1262
|
+
},
|
|
1263
|
+
teleported: useTooltipContentProps.teleported,
|
|
1264
|
+
appendTo: useTooltipContentProps.appendTo,
|
|
1265
|
+
predefine: {
|
|
1266
|
+
type: definePropType(Array)
|
|
1267
|
+
},
|
|
1268
|
+
validateEvent: {
|
|
1269
|
+
type: Boolean,
|
|
1270
|
+
default: true
|
|
1271
|
+
},
|
|
1272
|
+
...useEmptyValuesProps,
|
|
1273
|
+
...useAriaProps(["ariaLabel"])
|
|
1060
1274
|
});
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1275
|
+
const colorPickerEmits = {
|
|
1276
|
+
[UPDATE_MODEL_EVENT]: (val) => isString(val) || isNil(val),
|
|
1277
|
+
[CHANGE_EVENT]: (val) => isString(val) || isNil(val),
|
|
1278
|
+
activeChange: (val) => isString(val) || isNil(val),
|
|
1279
|
+
focus: (evt) => evt instanceof FocusEvent,
|
|
1280
|
+
blur: (evt) => evt instanceof FocusEvent,
|
|
1281
|
+
clear: () => true
|
|
1282
|
+
};
|
|
1283
|
+
const _hoisted_1$b = ["id", "aria-label", "aria-labelledby", "aria-description", "aria-disabled", "tabindex"];
|
|
1284
|
+
const _sfc_main$r = defineComponent({
|
|
1285
|
+
...{
|
|
1286
|
+
name: "ElColorPicker"
|
|
1287
|
+
},
|
|
1288
|
+
__name: "color-picker",
|
|
1063
1289
|
props: colorPickerProps,
|
|
1064
1290
|
emits: colorPickerEmits,
|
|
1065
|
-
setup(__props, { expose, emit }) {
|
|
1291
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1066
1292
|
const props = __props;
|
|
1293
|
+
const emit = __emit;
|
|
1067
1294
|
const { t } = useLocale();
|
|
1068
1295
|
const ns = useNamespace("color");
|
|
1069
1296
|
const { formItem } = useFormItem();
|
|
1070
1297
|
const colorSize = useFormSize();
|
|
1071
1298
|
const colorDisabled = useFormDisabled();
|
|
1299
|
+
const { valueOnClear, isEmptyValue } = useEmptyValues(props, null);
|
|
1300
|
+
const commonColor = useCommonColor(props, emit);
|
|
1072
1301
|
const { inputId: buttonId, isLabeledByFormItem } = useFormItemInputId(props, {
|
|
1073
1302
|
formItemContext: formItem
|
|
1074
1303
|
});
|
|
1075
|
-
const hue = ref();
|
|
1076
|
-
const sv = ref();
|
|
1077
|
-
const alpha = ref();
|
|
1078
1304
|
const popper = ref();
|
|
1079
1305
|
const triggerRef = ref();
|
|
1080
|
-
const
|
|
1306
|
+
const pickerPanelRef = ref();
|
|
1307
|
+
const showPicker = ref(false);
|
|
1308
|
+
const showPanelColor = ref(false);
|
|
1309
|
+
let shouldActiveChange = true;
|
|
1081
1310
|
const { isFocused, handleFocus, handleBlur } = useFocusController(triggerRef, {
|
|
1082
|
-
|
|
1083
|
-
return colorDisabled.value;
|
|
1084
|
-
},
|
|
1311
|
+
disabled: colorDisabled,
|
|
1085
1312
|
beforeBlur(event) {
|
|
1086
1313
|
var _a;
|
|
1087
1314
|
return (_a = popper.value) == null ? void 0 : _a.isFocusInsideContent(event);
|
|
1088
1315
|
},
|
|
1089
1316
|
afterBlur() {
|
|
1317
|
+
var _a;
|
|
1090
1318
|
setShowPicker(false);
|
|
1091
1319
|
resetColor();
|
|
1320
|
+
if (props.validateEvent) {
|
|
1321
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur").catch((err) => debugWarn(err));
|
|
1322
|
+
}
|
|
1092
1323
|
}
|
|
1093
1324
|
});
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
|
|
1325
|
+
const color = reactiveComputed(
|
|
1326
|
+
() => {
|
|
1327
|
+
var _a, _b;
|
|
1328
|
+
return (_b = (_a = pickerPanelRef.value) == null ? void 0 : _a.color) != null ? _b : commonColor.color;
|
|
1329
|
+
}
|
|
1330
|
+
);
|
|
1331
|
+
const panelProps = computed(
|
|
1332
|
+
() => pick(props, Object.keys(colorPickerPanelProps))
|
|
1333
|
+
);
|
|
1103
1334
|
const displayedColor = computed(() => {
|
|
1104
1335
|
if (!props.modelValue && !showPanelColor.value) {
|
|
1105
1336
|
return "transparent";
|
|
@@ -1124,11 +1355,8 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1124
1355
|
];
|
|
1125
1356
|
});
|
|
1126
1357
|
function displayedRgb(color2, showAlpha) {
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
const { r, g, b } = color2.toRgb();
|
|
1131
|
-
return showAlpha ? `rgba(${r}, ${g}, ${b}, ${color2.get("alpha") / 100})` : `rgb(${r}, ${g}, ${b})`;
|
|
1358
|
+
const { r, g, b, a } = color2.toRgb();
|
|
1359
|
+
return showAlpha ? `rgba(${r}, ${g}, ${b}, ${a})` : `rgb(${r}, ${g}, ${b})`;
|
|
1132
1360
|
}
|
|
1133
1361
|
function setShowPicker(value) {
|
|
1134
1362
|
showPicker.value = value;
|
|
@@ -1163,13 +1391,10 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1163
1391
|
}
|
|
1164
1392
|
debounceSetShowPicker(!showPicker.value);
|
|
1165
1393
|
}
|
|
1166
|
-
function handleConfirm() {
|
|
1167
|
-
color.fromString(customInput.value);
|
|
1168
|
-
}
|
|
1169
1394
|
function confirmValue() {
|
|
1170
|
-
const value = color.value;
|
|
1395
|
+
const value = isEmptyValue(color.value) ? valueOnClear.value : color.value;
|
|
1171
1396
|
emit(UPDATE_MODEL_EVENT, value);
|
|
1172
|
-
emit(
|
|
1397
|
+
emit(CHANGE_EVENT, value);
|
|
1173
1398
|
if (props.validateEvent) {
|
|
1174
1399
|
formItem == null ? void 0 : formItem.validate("change").catch((err) => debugWarn(err));
|
|
1175
1400
|
}
|
|
@@ -1187,12 +1412,17 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1187
1412
|
}
|
|
1188
1413
|
function clear() {
|
|
1189
1414
|
debounceSetShowPicker(false);
|
|
1190
|
-
emit(UPDATE_MODEL_EVENT,
|
|
1191
|
-
emit(
|
|
1192
|
-
if (props.modelValue !==
|
|
1415
|
+
emit(UPDATE_MODEL_EVENT, valueOnClear.value);
|
|
1416
|
+
emit(CHANGE_EVENT, valueOnClear.value);
|
|
1417
|
+
if (props.modelValue !== valueOnClear.value && props.validateEvent) {
|
|
1193
1418
|
formItem == null ? void 0 : formItem.validate("change").catch((err) => debugWarn(err));
|
|
1194
1419
|
}
|
|
1195
1420
|
resetColor();
|
|
1421
|
+
emit("clear");
|
|
1422
|
+
}
|
|
1423
|
+
function handleShowTooltip() {
|
|
1424
|
+
var _a, _b;
|
|
1425
|
+
(_b = (_a = pickerPanelRef == null ? void 0 : pickerPanelRef.value) == null ? void 0 : _a.inputRef) == null ? void 0 : _b.focus();
|
|
1196
1426
|
}
|
|
1197
1427
|
function handleClickOutside() {
|
|
1198
1428
|
if (!showPicker.value)
|
|
@@ -1207,14 +1437,14 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1207
1437
|
resetColor();
|
|
1208
1438
|
}
|
|
1209
1439
|
function handleKeyDown(event) {
|
|
1210
|
-
|
|
1440
|
+
const code = getEventCode(event);
|
|
1441
|
+
switch (code) {
|
|
1211
1442
|
case EVENT_CODE.enter:
|
|
1212
1443
|
case EVENT_CODE.numpadEnter:
|
|
1213
1444
|
case EVENT_CODE.space:
|
|
1214
1445
|
event.preventDefault();
|
|
1215
1446
|
event.stopPropagation();
|
|
1216
1447
|
show();
|
|
1217
|
-
inputRef.value.focus();
|
|
1218
1448
|
break;
|
|
1219
1449
|
case EVENT_CODE.esc:
|
|
1220
1450
|
handleEsc(event);
|
|
@@ -1227,47 +1457,40 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1227
1457
|
function blur() {
|
|
1228
1458
|
triggerRef.value.blur();
|
|
1229
1459
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1460
|
+
watch(
|
|
1461
|
+
() => currentColor.value,
|
|
1462
|
+
(val) => {
|
|
1463
|
+
shouldActiveChange && emit("activeChange", val);
|
|
1464
|
+
shouldActiveChange = true;
|
|
1233
1465
|
}
|
|
1234
|
-
|
|
1235
|
-
watch(
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1466
|
+
);
|
|
1467
|
+
watch(
|
|
1468
|
+
() => color.value,
|
|
1469
|
+
() => {
|
|
1470
|
+
if (!props.modelValue && !showPanelColor.value) {
|
|
1471
|
+
showPanelColor.value = true;
|
|
1472
|
+
}
|
|
1241
1473
|
}
|
|
1242
|
-
|
|
1243
|
-
watch(
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
shouldActiveChange = true;
|
|
1253
|
-
});
|
|
1254
|
-
watch(() => color.value, () => {
|
|
1255
|
-
if (!props.modelValue && !showPanelColor.value) {
|
|
1256
|
-
showPanelColor.value = true;
|
|
1474
|
+
);
|
|
1475
|
+
watch(
|
|
1476
|
+
() => props.modelValue,
|
|
1477
|
+
(newVal) => {
|
|
1478
|
+
if (!newVal) {
|
|
1479
|
+
showPanelColor.value = false;
|
|
1480
|
+
} else if (newVal && newVal !== color.value) {
|
|
1481
|
+
shouldActiveChange = false;
|
|
1482
|
+
color.fromString(newVal);
|
|
1483
|
+
}
|
|
1257
1484
|
}
|
|
1258
|
-
|
|
1259
|
-
watch(
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
provide(colorPickerContextKey, {
|
|
1268
|
-
currentColor
|
|
1269
|
-
});
|
|
1270
|
-
expose({
|
|
1485
|
+
);
|
|
1486
|
+
watch(
|
|
1487
|
+
() => showPicker.value,
|
|
1488
|
+
() => {
|
|
1489
|
+
pickerPanelRef.value && nextTick(pickerPanelRef.value.update);
|
|
1490
|
+
}
|
|
1491
|
+
);
|
|
1492
|
+
provide(ROOT_COMMON_COLOR_INJECTION_KEY, commonColor);
|
|
1493
|
+
__expose({
|
|
1271
1494
|
color,
|
|
1272
1495
|
show,
|
|
1273
1496
|
hide,
|
|
@@ -1283,89 +1506,70 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1283
1506
|
"fallback-placements": ["bottom", "top", "right", "left"],
|
|
1284
1507
|
offset: 0,
|
|
1285
1508
|
"gpu-acceleration": false,
|
|
1286
|
-
"popper-class": [unref(ns).be("picker", "panel"),
|
|
1509
|
+
"popper-class": [unref(ns).be("picker", "panel"), _ctx.popperClass],
|
|
1510
|
+
"popper-style": _ctx.popperStyle,
|
|
1287
1511
|
"stop-popper-mouse-event": false,
|
|
1512
|
+
pure: "",
|
|
1513
|
+
loop: "",
|
|
1514
|
+
role: "dialog",
|
|
1288
1515
|
effect: "light",
|
|
1289
1516
|
trigger: "click",
|
|
1290
1517
|
teleported: _ctx.teleported,
|
|
1291
1518
|
transition: `${unref(ns).namespace.value}-zoom-in-top`,
|
|
1292
|
-
persistent:
|
|
1293
|
-
|
|
1519
|
+
persistent: _ctx.persistent,
|
|
1520
|
+
"append-to": _ctx.appendTo,
|
|
1521
|
+
onShow: handleShowTooltip,
|
|
1522
|
+
onHide: _cache[2] || (_cache[2] = ($event) => setShowPicker(false))
|
|
1294
1523
|
}, {
|
|
1295
1524
|
content: withCtx(() => [
|
|
1296
|
-
withDirectives((openBlock(),
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
},
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
], 2),
|
|
1345
|
-
createVNode(unref(ElButton), {
|
|
1346
|
-
class: normalizeClass(unref(ns).be("dropdown", "link-btn")),
|
|
1347
|
-
text: "",
|
|
1348
|
-
size: "small",
|
|
1349
|
-
onClick: clear
|
|
1350
|
-
}, {
|
|
1351
|
-
default: withCtx(() => [
|
|
1352
|
-
createTextVNode(toDisplayString(unref(t)("el.colorpicker.clear")), 1)
|
|
1353
|
-
]),
|
|
1354
|
-
_: 1
|
|
1355
|
-
}, 8, ["class"]),
|
|
1356
|
-
createVNode(unref(ElButton), {
|
|
1357
|
-
plain: "",
|
|
1358
|
-
size: "small",
|
|
1359
|
-
class: normalizeClass(unref(ns).be("dropdown", "btn")),
|
|
1360
|
-
onClick: confirmValue
|
|
1361
|
-
}, {
|
|
1362
|
-
default: withCtx(() => [
|
|
1363
|
-
createTextVNode(toDisplayString(unref(t)("el.colorpicker.confirm")), 1)
|
|
1364
|
-
]),
|
|
1365
|
-
_: 1
|
|
1366
|
-
}, 8, ["class"])
|
|
1367
|
-
], 2)
|
|
1368
|
-
], 40, ["onKeydown"])), [
|
|
1525
|
+
withDirectives((openBlock(), createBlock(
|
|
1526
|
+
unref(ElColorPickerPanel),
|
|
1527
|
+
mergeProps({
|
|
1528
|
+
ref_key: "pickerPanelRef",
|
|
1529
|
+
ref: pickerPanelRef
|
|
1530
|
+
}, panelProps.value, {
|
|
1531
|
+
border: false,
|
|
1532
|
+
"validate-event": false,
|
|
1533
|
+
onKeydown: withKeys(handleEsc, ["esc"])
|
|
1534
|
+
}),
|
|
1535
|
+
{
|
|
1536
|
+
footer: withCtx(() => [
|
|
1537
|
+
createElementVNode("div", null, [
|
|
1538
|
+
_ctx.clearable ? (openBlock(), createBlock(unref(ElButton), {
|
|
1539
|
+
key: 0,
|
|
1540
|
+
class: normalizeClass(unref(ns).be("footer", "link-btn")),
|
|
1541
|
+
text: "",
|
|
1542
|
+
size: "small",
|
|
1543
|
+
onClick: clear
|
|
1544
|
+
}, {
|
|
1545
|
+
default: withCtx(() => [
|
|
1546
|
+
createTextVNode(
|
|
1547
|
+
toDisplayString(unref(t)("el.colorpicker.clear")),
|
|
1548
|
+
1
|
|
1549
|
+
)
|
|
1550
|
+
]),
|
|
1551
|
+
_: 1
|
|
1552
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
1553
|
+
createVNode(unref(ElButton), {
|
|
1554
|
+
plain: "",
|
|
1555
|
+
size: "small",
|
|
1556
|
+
class: normalizeClass(unref(ns).be("footer", "btn")),
|
|
1557
|
+
onClick: confirmValue
|
|
1558
|
+
}, {
|
|
1559
|
+
default: withCtx(() => [
|
|
1560
|
+
createTextVNode(
|
|
1561
|
+
toDisplayString(unref(t)("el.colorpicker.confirm")),
|
|
1562
|
+
1
|
|
1563
|
+
)
|
|
1564
|
+
]),
|
|
1565
|
+
_: 1
|
|
1566
|
+
}, 8, ["class"])
|
|
1567
|
+
])
|
|
1568
|
+
]),
|
|
1569
|
+
_: 1
|
|
1570
|
+
},
|
|
1571
|
+
16
|
|
1572
|
+
)), [
|
|
1369
1573
|
[unref(ClickOutside), handleClickOutside, triggerRef.value]
|
|
1370
1574
|
])
|
|
1371
1575
|
]),
|
|
@@ -1375,76 +1579,88 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
1375
1579
|
ref_key: "triggerRef",
|
|
1376
1580
|
ref: triggerRef
|
|
1377
1581
|
}, _ctx.$attrs, {
|
|
1378
|
-
class:
|
|
1582
|
+
class: btnKls.value,
|
|
1379
1583
|
role: "button",
|
|
1380
|
-
"aria-label":
|
|
1381
|
-
"aria-labelledby":
|
|
1584
|
+
"aria-label": buttonAriaLabel.value,
|
|
1585
|
+
"aria-labelledby": buttonAriaLabelledby.value,
|
|
1382
1586
|
"aria-description": unref(t)("el.colorpicker.description", { color: _ctx.modelValue || "" }),
|
|
1383
1587
|
"aria-disabled": unref(colorDisabled),
|
|
1384
|
-
tabindex: unref(colorDisabled) ?
|
|
1588
|
+
tabindex: unref(colorDisabled) ? void 0 : _ctx.tabindex,
|
|
1385
1589
|
onKeydown: handleKeyDown,
|
|
1386
|
-
onFocus: unref(handleFocus),
|
|
1387
|
-
onBlur: unref(handleBlur)
|
|
1590
|
+
onFocus: _cache[0] || (_cache[0] = (...args) => unref(handleFocus) && unref(handleFocus)(...args)),
|
|
1591
|
+
onBlur: _cache[1] || (_cache[1] = (...args) => unref(handleBlur) && unref(handleBlur)(...args))
|
|
1388
1592
|
}), [
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1593
|
+
createElementVNode(
|
|
1594
|
+
"div",
|
|
1595
|
+
{
|
|
1596
|
+
class: normalizeClass(unref(ns).be("picker", "trigger")),
|
|
1597
|
+
onClick: handleTrigger
|
|
1598
|
+
},
|
|
1599
|
+
[
|
|
1600
|
+
createElementVNode(
|
|
1601
|
+
"span",
|
|
1602
|
+
{
|
|
1603
|
+
class: normalizeClass([unref(ns).be("picker", "color"), unref(ns).is("alpha", _ctx.showAlpha)])
|
|
1604
|
+
},
|
|
1605
|
+
[
|
|
1606
|
+
createElementVNode(
|
|
1607
|
+
"span",
|
|
1608
|
+
{
|
|
1609
|
+
class: normalizeClass(unref(ns).be("picker", "color-inner")),
|
|
1610
|
+
style: normalizeStyle({
|
|
1611
|
+
backgroundColor: displayedColor.value
|
|
1612
|
+
})
|
|
1613
|
+
},
|
|
1614
|
+
[
|
|
1615
|
+
withDirectives(createVNode(unref(ElIcon), {
|
|
1616
|
+
class: normalizeClass([unref(ns).be("picker", "icon"), unref(ns).is("icon-arrow-down")])
|
|
1617
|
+
}, {
|
|
1618
|
+
default: withCtx(() => [
|
|
1619
|
+
createVNode(unref(ArrowDown))
|
|
1620
|
+
]),
|
|
1621
|
+
_: 1
|
|
1622
|
+
}, 8, ["class"]), [
|
|
1623
|
+
[vShow, _ctx.modelValue || showPanelColor.value]
|
|
1624
|
+
]),
|
|
1625
|
+
withDirectives(createVNode(unref(ElIcon), {
|
|
1626
|
+
class: normalizeClass([unref(ns).be("picker", "empty"), unref(ns).is("icon-close")])
|
|
1627
|
+
}, {
|
|
1628
|
+
default: withCtx(() => [
|
|
1629
|
+
createVNode(unref(Close))
|
|
1630
|
+
]),
|
|
1631
|
+
_: 1
|
|
1632
|
+
}, 8, ["class"]), [
|
|
1633
|
+
[vShow, !_ctx.modelValue && !showPanelColor.value]
|
|
1634
|
+
])
|
|
1635
|
+
],
|
|
1636
|
+
6
|
|
1637
|
+
)
|
|
1638
|
+
],
|
|
1639
|
+
2
|
|
1640
|
+
)
|
|
1641
|
+
],
|
|
1642
|
+
2
|
|
1643
|
+
)
|
|
1644
|
+
], 16, _hoisted_1$b)
|
|
1430
1645
|
]),
|
|
1431
1646
|
_: 1
|
|
1432
|
-
}, 8, ["visible", "popper-class", "teleported", "transition", "
|
|
1647
|
+
}, 8, ["visible", "popper-class", "popper-style", "teleported", "transition", "persistent", "append-to"]);
|
|
1433
1648
|
};
|
|
1434
1649
|
}
|
|
1435
1650
|
});
|
|
1436
|
-
var ColorPicker = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__file", "color-picker.vue"]]);
|
|
1651
|
+
var ColorPicker = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/color-picker.vue"]]);
|
|
1437
1652
|
const ElColorPicker = withInstall(ColorPicker);
|
|
1438
|
-
const
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
props: {
|
|
1653
|
+
const _sfc_main$q = defineComponent({
|
|
1654
|
+
...{
|
|
1655
|
+
name: "ElContainer"
|
|
1656
|
+
},
|
|
1657
|
+
__name: "container",
|
|
1658
|
+
props: buildProps({
|
|
1444
1659
|
direction: {
|
|
1445
|
-
type: String
|
|
1660
|
+
type: String,
|
|
1661
|
+
values: ["horizontal", "vertical"]
|
|
1446
1662
|
}
|
|
1447
|
-
},
|
|
1663
|
+
}),
|
|
1448
1664
|
setup(__props) {
|
|
1449
1665
|
const props = __props;
|
|
1450
1666
|
const slots = useSlots();
|
|
@@ -1466,20 +1682,25 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1466
1682
|
}
|
|
1467
1683
|
});
|
|
1468
1684
|
return (_ctx, _cache) => {
|
|
1469
|
-
return openBlock(), createElementBlock(
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1685
|
+
return openBlock(), createElementBlock(
|
|
1686
|
+
"section",
|
|
1687
|
+
{
|
|
1688
|
+
class: normalizeClass([unref(ns).b(), unref(ns).is("vertical", isVertical.value)])
|
|
1689
|
+
},
|
|
1690
|
+
[
|
|
1691
|
+
renderSlot(_ctx.$slots, "default")
|
|
1692
|
+
],
|
|
1693
|
+
2
|
|
1694
|
+
);
|
|
1474
1695
|
};
|
|
1475
1696
|
}
|
|
1476
1697
|
});
|
|
1477
|
-
var Container = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__file", "container.vue"]]);
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1698
|
+
var Container = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/container/src/container.vue"]]);
|
|
1699
|
+
const _sfc_main$p = defineComponent({
|
|
1700
|
+
...{
|
|
1701
|
+
name: "ElAside"
|
|
1702
|
+
},
|
|
1703
|
+
__name: "aside",
|
|
1483
1704
|
props: {
|
|
1484
1705
|
width: {
|
|
1485
1706
|
type: String,
|
|
@@ -1489,23 +1710,30 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1489
1710
|
setup(__props) {
|
|
1490
1711
|
const props = __props;
|
|
1491
1712
|
const ns = useNamespace("aside");
|
|
1492
|
-
const style = computed(
|
|
1713
|
+
const style = computed(
|
|
1714
|
+
() => props.width ? ns.cssVarBlock({ width: props.width }) : {}
|
|
1715
|
+
);
|
|
1493
1716
|
return (_ctx, _cache) => {
|
|
1494
|
-
return openBlock(), createElementBlock(
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1717
|
+
return openBlock(), createElementBlock(
|
|
1718
|
+
"aside",
|
|
1719
|
+
{
|
|
1720
|
+
class: normalizeClass(unref(ns).b()),
|
|
1721
|
+
style: normalizeStyle(style.value)
|
|
1722
|
+
},
|
|
1723
|
+
[
|
|
1724
|
+
renderSlot(_ctx.$slots, "default")
|
|
1725
|
+
],
|
|
1726
|
+
6
|
|
1727
|
+
);
|
|
1500
1728
|
};
|
|
1501
1729
|
}
|
|
1502
1730
|
});
|
|
1503
|
-
var Aside = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["__file", "aside.vue"]]);
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1731
|
+
var Aside = /* @__PURE__ */ _export_sfc(_sfc_main$p, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/container/src/aside.vue"]]);
|
|
1732
|
+
const _sfc_main$o = defineComponent({
|
|
1733
|
+
...{
|
|
1734
|
+
name: "ElFooter"
|
|
1735
|
+
},
|
|
1736
|
+
__name: "footer",
|
|
1509
1737
|
props: {
|
|
1510
1738
|
height: {
|
|
1511
1739
|
type: String,
|
|
@@ -1515,23 +1743,30 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
1515
1743
|
setup(__props) {
|
|
1516
1744
|
const props = __props;
|
|
1517
1745
|
const ns = useNamespace("footer");
|
|
1518
|
-
const style = computed(
|
|
1746
|
+
const style = computed(
|
|
1747
|
+
() => props.height ? ns.cssVarBlock({ height: props.height }) : {}
|
|
1748
|
+
);
|
|
1519
1749
|
return (_ctx, _cache) => {
|
|
1520
|
-
return openBlock(), createElementBlock(
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1750
|
+
return openBlock(), createElementBlock(
|
|
1751
|
+
"footer",
|
|
1752
|
+
{
|
|
1753
|
+
class: normalizeClass(unref(ns).b()),
|
|
1754
|
+
style: normalizeStyle(style.value)
|
|
1755
|
+
},
|
|
1756
|
+
[
|
|
1757
|
+
renderSlot(_ctx.$slots, "default")
|
|
1758
|
+
],
|
|
1759
|
+
6
|
|
1760
|
+
);
|
|
1526
1761
|
};
|
|
1527
1762
|
}
|
|
1528
1763
|
});
|
|
1529
|
-
var Footer$1 = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__file", "footer.vue"]]);
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1764
|
+
var Footer$1 = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/container/src/footer.vue"]]);
|
|
1765
|
+
const _sfc_main$n = defineComponent({
|
|
1766
|
+
...{
|
|
1767
|
+
name: "ElHeader"
|
|
1768
|
+
},
|
|
1769
|
+
__name: "header",
|
|
1535
1770
|
props: {
|
|
1536
1771
|
height: {
|
|
1537
1772
|
type: String,
|
|
@@ -1547,33 +1782,43 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
1547
1782
|
}) : {};
|
|
1548
1783
|
});
|
|
1549
1784
|
return (_ctx, _cache) => {
|
|
1550
|
-
return openBlock(), createElementBlock(
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1785
|
+
return openBlock(), createElementBlock(
|
|
1786
|
+
"header",
|
|
1787
|
+
{
|
|
1788
|
+
class: normalizeClass(unref(ns).b()),
|
|
1789
|
+
style: normalizeStyle(style.value)
|
|
1790
|
+
},
|
|
1791
|
+
[
|
|
1792
|
+
renderSlot(_ctx.$slots, "default")
|
|
1793
|
+
],
|
|
1794
|
+
6
|
|
1795
|
+
);
|
|
1556
1796
|
};
|
|
1557
1797
|
}
|
|
1558
1798
|
});
|
|
1559
|
-
var Header = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["__file", "header.vue"]]);
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1799
|
+
var Header = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/container/src/header.vue"]]);
|
|
1800
|
+
const _sfc_main$m = defineComponent({
|
|
1801
|
+
...{
|
|
1802
|
+
name: "ElMain"
|
|
1803
|
+
},
|
|
1804
|
+
__name: "main",
|
|
1565
1805
|
setup(__props) {
|
|
1566
1806
|
const ns = useNamespace("main");
|
|
1567
1807
|
return (_ctx, _cache) => {
|
|
1568
|
-
return openBlock(), createElementBlock(
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1808
|
+
return openBlock(), createElementBlock(
|
|
1809
|
+
"main",
|
|
1810
|
+
{
|
|
1811
|
+
class: normalizeClass(unref(ns).b())
|
|
1812
|
+
},
|
|
1813
|
+
[
|
|
1814
|
+
renderSlot(_ctx.$slots, "default")
|
|
1815
|
+
],
|
|
1816
|
+
2
|
|
1817
|
+
);
|
|
1573
1818
|
};
|
|
1574
1819
|
}
|
|
1575
1820
|
});
|
|
1576
|
-
var Main$1 = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__file", "main.vue"]]);
|
|
1821
|
+
var Main$1 = /* @__PURE__ */ _export_sfc(_sfc_main$m, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/container/src/main.vue"]]);
|
|
1577
1822
|
const ElContainer = withInstall(Container, {
|
|
1578
1823
|
Aside,
|
|
1579
1824
|
Footer: Footer$1,
|
|
@@ -1600,11 +1845,11 @@ const dividerProps = buildProps({
|
|
|
1600
1845
|
default: "solid"
|
|
1601
1846
|
}
|
|
1602
1847
|
});
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1848
|
+
const _sfc_main$l = defineComponent({
|
|
1849
|
+
...{
|
|
1850
|
+
name: "ElDivider"
|
|
1851
|
+
},
|
|
1852
|
+
__name: "divider",
|
|
1608
1853
|
props: dividerProps,
|
|
1609
1854
|
setup(__props) {
|
|
1610
1855
|
const props = __props;
|
|
@@ -1615,22 +1860,32 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
1615
1860
|
});
|
|
1616
1861
|
});
|
|
1617
1862
|
return (_ctx, _cache) => {
|
|
1618
|
-
return openBlock(), createElementBlock(
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1863
|
+
return openBlock(), createElementBlock(
|
|
1864
|
+
"div",
|
|
1865
|
+
{
|
|
1866
|
+
class: normalizeClass([unref(ns).b(), unref(ns).m(_ctx.direction)]),
|
|
1867
|
+
style: normalizeStyle(dividerStyle.value),
|
|
1868
|
+
role: "separator"
|
|
1869
|
+
},
|
|
1870
|
+
[
|
|
1871
|
+
_ctx.$slots.default && _ctx.direction !== "vertical" ? (openBlock(), createElementBlock(
|
|
1872
|
+
"div",
|
|
1873
|
+
{
|
|
1874
|
+
key: 0,
|
|
1875
|
+
class: normalizeClass([unref(ns).e("text"), unref(ns).is(_ctx.contentPosition)])
|
|
1876
|
+
},
|
|
1877
|
+
[
|
|
1878
|
+
renderSlot(_ctx.$slots, "default")
|
|
1879
|
+
],
|
|
1880
|
+
2
|
|
1881
|
+
)) : createCommentVNode("v-if", true)
|
|
1882
|
+
],
|
|
1883
|
+
6
|
|
1884
|
+
);
|
|
1630
1885
|
};
|
|
1631
1886
|
}
|
|
1632
1887
|
});
|
|
1633
|
-
var Divider = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["__file", "divider.vue"]]);
|
|
1888
|
+
var Divider = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/divider/src/divider.vue"]]);
|
|
1634
1889
|
const ElDivider = withInstall(Divider);
|
|
1635
1890
|
let SubMenu$1 = class SubMenu {
|
|
1636
1891
|
constructor(parent, domNode) {
|
|
@@ -1657,8 +1912,9 @@ let SubMenu$1 = class SubMenu {
|
|
|
1657
1912
|
const parentNode = this.parent.domNode;
|
|
1658
1913
|
Array.prototype.forEach.call(this.subMenuItems, (el) => {
|
|
1659
1914
|
el.addEventListener("keydown", (event) => {
|
|
1915
|
+
const code = getEventCode(event);
|
|
1660
1916
|
let prevDef = false;
|
|
1661
|
-
switch (
|
|
1917
|
+
switch (code) {
|
|
1662
1918
|
case EVENT_CODE.down: {
|
|
1663
1919
|
this.gotoSubIndex(this.subIndex + 1);
|
|
1664
1920
|
prevDef = true;
|
|
@@ -1707,8 +1963,9 @@ let MenuItem$1 = class MenuItem {
|
|
|
1707
1963
|
}
|
|
1708
1964
|
addListeners() {
|
|
1709
1965
|
this.domNode.addEventListener("keydown", (event) => {
|
|
1966
|
+
const code = getEventCode(event);
|
|
1710
1967
|
let prevDef = false;
|
|
1711
|
-
switch (
|
|
1968
|
+
switch (code) {
|
|
1712
1969
|
case EVENT_CODE.down: {
|
|
1713
1970
|
triggerEvent(event.currentTarget, "mouseenter");
|
|
1714
1971
|
this.submenu && this.submenu.gotoSubIndex(0);
|
|
@@ -1753,11 +2010,11 @@ let Menu$1 = class Menu {
|
|
|
1753
2010
|
});
|
|
1754
2011
|
}
|
|
1755
2012
|
};
|
|
1756
|
-
const
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
2013
|
+
const _sfc_main$k = defineComponent({
|
|
2014
|
+
...{
|
|
2015
|
+
name: "ElMenuCollapseTransition"
|
|
2016
|
+
},
|
|
2017
|
+
__name: "menu-collapse-transition",
|
|
1761
2018
|
setup(__props) {
|
|
1762
2019
|
const ns = useNamespace("menu");
|
|
1763
2020
|
const listeners = {
|
|
@@ -1794,16 +2051,21 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
1794
2051
|
}
|
|
1795
2052
|
};
|
|
1796
2053
|
return (_ctx, _cache) => {
|
|
1797
|
-
return openBlock(), createBlock(
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
2054
|
+
return openBlock(), createBlock(
|
|
2055
|
+
Transition,
|
|
2056
|
+
mergeProps({ mode: "out-in" }, listeners),
|
|
2057
|
+
{
|
|
2058
|
+
default: withCtx(() => [
|
|
2059
|
+
renderSlot(_ctx.$slots, "default")
|
|
2060
|
+
]),
|
|
2061
|
+
_: 3
|
|
2062
|
+
},
|
|
2063
|
+
16
|
|
2064
|
+
);
|
|
1803
2065
|
};
|
|
1804
2066
|
}
|
|
1805
2067
|
});
|
|
1806
|
-
var ElMenuCollapseTransition = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__file", "menu-collapse-transition.vue"]]);
|
|
2068
|
+
var ElMenuCollapseTransition = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-collapse-transition.vue"]]);
|
|
1807
2069
|
function useMenu(instance, currentIndex) {
|
|
1808
2070
|
const indexPath = computed(() => {
|
|
1809
2071
|
let parent = instance.parent;
|
|
@@ -1837,15 +2099,19 @@ function useMenuColor(props) {
|
|
|
1837
2099
|
}
|
|
1838
2100
|
const useMenuCssVar = (props, level) => {
|
|
1839
2101
|
const ns = useNamespace("menu");
|
|
1840
|
-
return computed(
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
2102
|
+
return computed(
|
|
2103
|
+
() => ns.cssVarBlock({
|
|
2104
|
+
"text-color": props.textColor || "",
|
|
2105
|
+
"hover-text-color": props.textColor || "",
|
|
2106
|
+
"bg-color": props.backgroundColor || "",
|
|
2107
|
+
"hover-bg-color": useMenuColor(props).value || "",
|
|
2108
|
+
"active-color": props.activeTextColor || "",
|
|
2109
|
+
level: `${level}`
|
|
2110
|
+
})
|
|
2111
|
+
);
|
|
1848
2112
|
};
|
|
2113
|
+
const MENU_INJECTION_KEY = "rootMenu";
|
|
2114
|
+
const SUB_MENU_INJECTION_KEY = "subMenu:";
|
|
1849
2115
|
const subMenuProps = buildProps({
|
|
1850
2116
|
index: {
|
|
1851
2117
|
type: String,
|
|
@@ -1854,6 +2120,9 @@ const subMenuProps = buildProps({
|
|
|
1854
2120
|
showTimeout: Number,
|
|
1855
2121
|
hideTimeout: Number,
|
|
1856
2122
|
popperClass: String,
|
|
2123
|
+
popperStyle: {
|
|
2124
|
+
type: definePropType([String, Object])
|
|
2125
|
+
},
|
|
1857
2126
|
disabled: Boolean,
|
|
1858
2127
|
teleported: {
|
|
1859
2128
|
type: Boolean,
|
|
@@ -1879,13 +2148,18 @@ var SubMenu2 = defineComponent({
|
|
|
1879
2148
|
props: subMenuProps,
|
|
1880
2149
|
setup(props, { slots, expose }) {
|
|
1881
2150
|
const instance = getCurrentInstance();
|
|
1882
|
-
const { indexPath, parentMenu } = useMenu(
|
|
2151
|
+
const { indexPath, parentMenu } = useMenu(
|
|
2152
|
+
instance,
|
|
2153
|
+
computed(() => props.index)
|
|
2154
|
+
);
|
|
1883
2155
|
const nsMenu = useNamespace("menu");
|
|
1884
2156
|
const nsSubMenu = useNamespace("sub-menu");
|
|
1885
|
-
const rootMenu = inject(
|
|
2157
|
+
const rootMenu = inject(MENU_INJECTION_KEY);
|
|
1886
2158
|
if (!rootMenu)
|
|
1887
2159
|
throwError(COMPONENT_NAME$1, "can not inject root menu");
|
|
1888
|
-
const subMenu = inject(
|
|
2160
|
+
const subMenu = inject(
|
|
2161
|
+
`${SUB_MENU_INJECTION_KEY}${parentMenu.value.uid}`
|
|
2162
|
+
);
|
|
1889
2163
|
if (!subMenu)
|
|
1890
2164
|
throwError(COMPONENT_NAME$1, "can not inject sub menu");
|
|
1891
2165
|
const items = ref({});
|
|
@@ -1894,35 +2168,56 @@ var SubMenu2 = defineComponent({
|
|
|
1894
2168
|
const mouseInChild = ref(false);
|
|
1895
2169
|
const verticalTitleRef = ref();
|
|
1896
2170
|
const vPopper = ref();
|
|
1897
|
-
const
|
|
2171
|
+
const isFirstLevel = computed(() => subMenu.level === 0);
|
|
2172
|
+
const currentPlacement = computed(
|
|
2173
|
+
() => mode.value === "horizontal" && isFirstLevel.value ? "bottom-start" : "right-start"
|
|
2174
|
+
);
|
|
1898
2175
|
const subMenuTitleIcon = computed(() => {
|
|
1899
|
-
|
|
2176
|
+
const isExpandedMode = mode.value === "horizontal" && isFirstLevel.value || mode.value === "vertical" && !rootMenu.props.collapse;
|
|
2177
|
+
if (isExpandedMode) {
|
|
2178
|
+
if (props.expandCloseIcon && props.expandOpenIcon) {
|
|
2179
|
+
return opened.value ? props.expandOpenIcon : props.expandCloseIcon;
|
|
2180
|
+
}
|
|
2181
|
+
return ArrowDown;
|
|
2182
|
+
} else {
|
|
2183
|
+
if (props.collapseCloseIcon && props.collapseOpenIcon) {
|
|
2184
|
+
return opened.value ? props.collapseOpenIcon : props.collapseCloseIcon;
|
|
2185
|
+
}
|
|
2186
|
+
return ArrowRight;
|
|
2187
|
+
}
|
|
1900
2188
|
});
|
|
1901
|
-
const isFirstLevel = computed(() => subMenu.level === 0);
|
|
1902
2189
|
const appendToBody = computed(() => {
|
|
1903
2190
|
const value = props.teleported;
|
|
1904
|
-
return value
|
|
2191
|
+
return isUndefined(value) ? isFirstLevel.value : value;
|
|
1905
2192
|
});
|
|
1906
|
-
const menuTransitionName = computed(
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
"
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
2193
|
+
const menuTransitionName = computed(
|
|
2194
|
+
() => rootMenu.props.collapse ? `${nsMenu.namespace.value}-zoom-in-left` : `${nsMenu.namespace.value}-zoom-in-top`
|
|
2195
|
+
);
|
|
2196
|
+
const fallbackPlacements = computed(
|
|
2197
|
+
() => mode.value === "horizontal" && isFirstLevel.value ? [
|
|
2198
|
+
"bottom-start",
|
|
2199
|
+
"bottom-end",
|
|
2200
|
+
"top-start",
|
|
2201
|
+
"top-end",
|
|
2202
|
+
"right-start",
|
|
2203
|
+
"left-start"
|
|
2204
|
+
] : [
|
|
2205
|
+
"right-start",
|
|
2206
|
+
"right",
|
|
2207
|
+
"right-end",
|
|
2208
|
+
"left-start",
|
|
2209
|
+
"bottom-start",
|
|
2210
|
+
"bottom-end",
|
|
2211
|
+
"top-start",
|
|
2212
|
+
"top-end"
|
|
2213
|
+
]
|
|
2214
|
+
);
|
|
1924
2215
|
const opened = computed(() => rootMenu.openedMenus.includes(props.index));
|
|
1925
|
-
const active = computed(
|
|
2216
|
+
const active = computed(
|
|
2217
|
+
() => [...Object.values(items.value), ...Object.values(subMenus.value)].some(
|
|
2218
|
+
({ active: active2 }) => active2
|
|
2219
|
+
)
|
|
2220
|
+
);
|
|
1926
2221
|
const mode = computed(() => rootMenu.props.mode);
|
|
1927
2222
|
const persistent = computed(() => rootMenu.props.persistent);
|
|
1928
2223
|
const item = reactive({
|
|
@@ -1931,22 +2226,36 @@ var SubMenu2 = defineComponent({
|
|
|
1931
2226
|
active
|
|
1932
2227
|
});
|
|
1933
2228
|
const ulStyle = useMenuCssVar(rootMenu.props, subMenu.level + 1);
|
|
1934
|
-
const subMenuPopperOffset = computed(
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
const
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
2229
|
+
const subMenuPopperOffset = computed(
|
|
2230
|
+
() => {
|
|
2231
|
+
var _a;
|
|
2232
|
+
return (_a = props.popperOffset) != null ? _a : rootMenu.props.popperOffset;
|
|
2233
|
+
}
|
|
2234
|
+
);
|
|
2235
|
+
const subMenuPopperClass = computed(
|
|
2236
|
+
() => {
|
|
2237
|
+
var _a;
|
|
2238
|
+
return (_a = props.popperClass) != null ? _a : rootMenu.props.popperClass;
|
|
2239
|
+
}
|
|
2240
|
+
);
|
|
2241
|
+
const subMenuPopperStyle = computed(
|
|
2242
|
+
() => {
|
|
2243
|
+
var _a;
|
|
2244
|
+
return (_a = props.popperStyle) != null ? _a : rootMenu.props.popperStyle;
|
|
2245
|
+
}
|
|
2246
|
+
);
|
|
2247
|
+
const subMenuShowTimeout = computed(
|
|
2248
|
+
() => {
|
|
2249
|
+
var _a;
|
|
2250
|
+
return (_a = props.showTimeout) != null ? _a : rootMenu.props.showTimeout;
|
|
2251
|
+
}
|
|
2252
|
+
);
|
|
2253
|
+
const subMenuHideTimeout = computed(
|
|
2254
|
+
() => {
|
|
2255
|
+
var _a;
|
|
2256
|
+
return (_a = props.hideTimeout) != null ? _a : rootMenu.props.hideTimeout;
|
|
2257
|
+
}
|
|
2258
|
+
);
|
|
1950
2259
|
const doDestroy = () => {
|
|
1951
2260
|
var _a, _b, _c;
|
|
1952
2261
|
return (_c = (_b = (_a = vPopper.value) == null ? void 0 : _a.popperRef) == null ? void 0 : _b.popperInstanceRef) == null ? void 0 : _c.destroy();
|
|
@@ -1981,6 +2290,11 @@ var SubMenu2 = defineComponent({
|
|
|
1981
2290
|
if (appendToBody.value) {
|
|
1982
2291
|
(_a = parentMenu.value.vnode.el) == null ? void 0 : _a.dispatchEvent(new MouseEvent("mouseenter"));
|
|
1983
2292
|
}
|
|
2293
|
+
if (event.type === "mouseenter" && event.target) {
|
|
2294
|
+
nextTick(() => {
|
|
2295
|
+
focusElement(event.target, { preventScroll: true });
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
1984
2298
|
};
|
|
1985
2299
|
const handleMouseleave = (deepDispatch = false) => {
|
|
1986
2300
|
var _a;
|
|
@@ -1990,12 +2304,18 @@ var SubMenu2 = defineComponent({
|
|
|
1990
2304
|
}
|
|
1991
2305
|
timeout == null ? void 0 : timeout();
|
|
1992
2306
|
subMenu.mouseInChild.value = false;
|
|
1993
|
-
({ stop: timeout } = useTimeoutFn(
|
|
2307
|
+
({ stop: timeout } = useTimeoutFn(
|
|
2308
|
+
() => !mouseInChild.value && rootMenu.closeMenu(props.index, indexPath.value),
|
|
2309
|
+
subMenuHideTimeout.value
|
|
2310
|
+
));
|
|
1994
2311
|
if (appendToBody.value && deepDispatch) {
|
|
1995
2312
|
(_a = subMenu.handleMouseleave) == null ? void 0 : _a.call(subMenu, true);
|
|
1996
2313
|
}
|
|
1997
2314
|
};
|
|
1998
|
-
watch(
|
|
2315
|
+
watch(
|
|
2316
|
+
() => rootMenu.props.collapse,
|
|
2317
|
+
(value) => handleCollapseToggle(Boolean(value))
|
|
2318
|
+
);
|
|
1999
2319
|
{
|
|
2000
2320
|
const addSubMenu = (item2) => {
|
|
2001
2321
|
subMenus.value[item2.index] = item2;
|
|
@@ -2003,7 +2323,7 @@ var SubMenu2 = defineComponent({
|
|
|
2003
2323
|
const removeSubMenu = (item2) => {
|
|
2004
2324
|
delete subMenus.value[item2.index];
|
|
2005
2325
|
};
|
|
2006
|
-
provide(
|
|
2326
|
+
provide(`${SUB_MENU_INJECTION_KEY}${instance.uid}`, {
|
|
2007
2327
|
addSubMenu,
|
|
2008
2328
|
removeSubMenu,
|
|
2009
2329
|
handleMouseleave,
|
|
@@ -2026,87 +2346,127 @@ var SubMenu2 = defineComponent({
|
|
|
2026
2346
|
var _a;
|
|
2027
2347
|
const titleTag = [
|
|
2028
2348
|
(_a = slots.title) == null ? void 0 : _a.call(slots),
|
|
2029
|
-
h(
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2349
|
+
h(
|
|
2350
|
+
ElIcon,
|
|
2351
|
+
{
|
|
2352
|
+
class: nsSubMenu.e("icon-arrow"),
|
|
2353
|
+
style: {
|
|
2354
|
+
transform: opened.value ? props.expandCloseIcon && props.expandOpenIcon || props.collapseCloseIcon && props.collapseOpenIcon && rootMenu.props.collapse ? "none" : "rotateZ(180deg)" : "none"
|
|
2355
|
+
}
|
|
2356
|
+
},
|
|
2357
|
+
{
|
|
2358
|
+
default: () => isString(subMenuTitleIcon.value) ? h(instance.appContext.components[subMenuTitleIcon.value]) : h(subMenuTitleIcon.value)
|
|
2033
2359
|
}
|
|
2034
|
-
|
|
2035
|
-
default: () => isString(subMenuTitleIcon.value) ? h(instance.appContext.components[subMenuTitleIcon.value]) : h(subMenuTitleIcon.value)
|
|
2036
|
-
})
|
|
2360
|
+
)
|
|
2037
2361
|
];
|
|
2038
|
-
const child = rootMenu.isMenuPopup ? h(
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
return h("div", {
|
|
2056
|
-
class: [
|
|
2057
|
-
nsMenu.m(mode.value),
|
|
2058
|
-
nsMenu.m("popup-container"),
|
|
2059
|
-
subMenuPopperClass.value
|
|
2060
|
-
],
|
|
2061
|
-
onMouseenter: (evt) => handleMouseenter(evt, 100),
|
|
2062
|
-
onMouseleave: () => handleMouseleave(true),
|
|
2063
|
-
onFocus: (evt) => handleMouseenter(evt, 100)
|
|
2064
|
-
}, [
|
|
2065
|
-
h("ul", {
|
|
2066
|
-
class: [
|
|
2067
|
-
nsMenu.b(),
|
|
2068
|
-
nsMenu.m("popup"),
|
|
2069
|
-
nsMenu.m(`popup-${currentPlacement.value}`)
|
|
2070
|
-
],
|
|
2071
|
-
style: ulStyle.value
|
|
2072
|
-
}, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])
|
|
2073
|
-
]);
|
|
2362
|
+
const child = rootMenu.isMenuPopup ? h(
|
|
2363
|
+
ElTooltip,
|
|
2364
|
+
{
|
|
2365
|
+
ref: vPopper,
|
|
2366
|
+
visible: opened.value,
|
|
2367
|
+
effect: "light",
|
|
2368
|
+
pure: true,
|
|
2369
|
+
offset: subMenuPopperOffset.value,
|
|
2370
|
+
showArrow: false,
|
|
2371
|
+
persistent: persistent.value,
|
|
2372
|
+
popperClass: subMenuPopperClass.value,
|
|
2373
|
+
popperStyle: subMenuPopperStyle.value,
|
|
2374
|
+
placement: currentPlacement.value,
|
|
2375
|
+
teleported: appendToBody.value,
|
|
2376
|
+
fallbackPlacements: fallbackPlacements.value,
|
|
2377
|
+
transition: menuTransitionName.value,
|
|
2378
|
+
gpuAcceleration: false
|
|
2074
2379
|
},
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
onClick: handleClick
|
|
2078
|
-
}, titleTag)
|
|
2079
|
-
}) : h(Fragment, {}, [
|
|
2080
|
-
h("div", {
|
|
2081
|
-
class: nsSubMenu.e("title"),
|
|
2082
|
-
ref: verticalTitleRef,
|
|
2083
|
-
onClick: handleClick
|
|
2084
|
-
}, titleTag),
|
|
2085
|
-
h(ElCollapseTransition, {}, {
|
|
2086
|
-
default: () => {
|
|
2380
|
+
{
|
|
2381
|
+
content: () => {
|
|
2087
2382
|
var _a2;
|
|
2088
|
-
return
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2383
|
+
return h(
|
|
2384
|
+
"div",
|
|
2385
|
+
{
|
|
2386
|
+
class: [
|
|
2387
|
+
nsMenu.m(mode.value),
|
|
2388
|
+
nsMenu.m("popup-container"),
|
|
2389
|
+
subMenuPopperClass.value
|
|
2390
|
+
],
|
|
2391
|
+
onMouseenter: (evt) => handleMouseenter(evt, 100),
|
|
2392
|
+
onMouseleave: () => handleMouseleave(true),
|
|
2393
|
+
onFocus: (evt) => handleMouseenter(evt, 100)
|
|
2394
|
+
},
|
|
2395
|
+
[
|
|
2396
|
+
h(
|
|
2397
|
+
"ul",
|
|
2398
|
+
{
|
|
2399
|
+
class: [
|
|
2400
|
+
nsMenu.b(),
|
|
2401
|
+
nsMenu.m("popup"),
|
|
2402
|
+
nsMenu.m(`popup-${currentPlacement.value}`)
|
|
2403
|
+
],
|
|
2404
|
+
style: ulStyle.value
|
|
2405
|
+
},
|
|
2406
|
+
[(_a2 = slots.default) == null ? void 0 : _a2.call(slots)]
|
|
2407
|
+
)
|
|
2408
|
+
]
|
|
2409
|
+
);
|
|
2410
|
+
},
|
|
2411
|
+
default: () => h(
|
|
2412
|
+
"div",
|
|
2413
|
+
{
|
|
2414
|
+
class: nsSubMenu.e("title"),
|
|
2415
|
+
onClick: handleClick
|
|
2416
|
+
},
|
|
2417
|
+
titleTag
|
|
2418
|
+
)
|
|
2419
|
+
}
|
|
2420
|
+
) : h(Fragment, {}, [
|
|
2421
|
+
h(
|
|
2422
|
+
"div",
|
|
2423
|
+
{
|
|
2424
|
+
class: nsSubMenu.e("title"),
|
|
2425
|
+
ref: verticalTitleRef,
|
|
2426
|
+
onClick: handleClick
|
|
2427
|
+
},
|
|
2428
|
+
titleTag
|
|
2429
|
+
),
|
|
2430
|
+
h(
|
|
2431
|
+
ElCollapseTransition,
|
|
2432
|
+
{},
|
|
2433
|
+
{
|
|
2434
|
+
default: () => {
|
|
2435
|
+
var _a2;
|
|
2436
|
+
return withDirectives(
|
|
2437
|
+
h(
|
|
2438
|
+
"ul",
|
|
2439
|
+
{
|
|
2440
|
+
role: "menu",
|
|
2441
|
+
class: [nsMenu.b(), nsMenu.m("inline")],
|
|
2442
|
+
style: ulStyle.value
|
|
2443
|
+
},
|
|
2444
|
+
[(_a2 = slots.default) == null ? void 0 : _a2.call(slots)]
|
|
2445
|
+
),
|
|
2446
|
+
[[vShow, opened.value]]
|
|
2447
|
+
);
|
|
2448
|
+
}
|
|
2093
2449
|
}
|
|
2094
|
-
|
|
2450
|
+
)
|
|
2095
2451
|
]);
|
|
2096
|
-
return h(
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2452
|
+
return h(
|
|
2453
|
+
"li",
|
|
2454
|
+
{
|
|
2455
|
+
class: [
|
|
2456
|
+
nsSubMenu.b(),
|
|
2457
|
+
nsSubMenu.is("active", active.value),
|
|
2458
|
+
nsSubMenu.is("opened", opened.value),
|
|
2459
|
+
nsSubMenu.is("disabled", props.disabled)
|
|
2460
|
+
],
|
|
2461
|
+
role: "menuitem",
|
|
2462
|
+
ariaHaspopup: true,
|
|
2463
|
+
ariaExpanded: opened.value,
|
|
2464
|
+
onMouseenter: handleMouseenter,
|
|
2465
|
+
onMouseleave: () => handleMouseleave(),
|
|
2466
|
+
onFocus: handleMouseenter
|
|
2467
|
+
},
|
|
2468
|
+
[child]
|
|
2469
|
+
);
|
|
2110
2470
|
};
|
|
2111
2471
|
}
|
|
2112
2472
|
});
|
|
@@ -2150,13 +2510,16 @@ const menuProps = buildProps({
|
|
|
2150
2510
|
},
|
|
2151
2511
|
ellipsisIcon: {
|
|
2152
2512
|
type: iconPropType,
|
|
2153
|
-
default: () =>
|
|
2513
|
+
default: () => More
|
|
2154
2514
|
},
|
|
2155
2515
|
popperEffect: {
|
|
2156
2516
|
type: definePropType(String),
|
|
2157
2517
|
default: "dark"
|
|
2158
2518
|
},
|
|
2159
2519
|
popperClass: String,
|
|
2520
|
+
popperStyle: {
|
|
2521
|
+
type: definePropType([String, Object])
|
|
2522
|
+
},
|
|
2160
2523
|
showTimeout: {
|
|
2161
2524
|
type: Number,
|
|
2162
2525
|
default: 300
|
|
@@ -2174,8 +2537,9 @@ const checkIndexPath = (indexPath) => isArray(indexPath) && indexPath.every((pat
|
|
|
2174
2537
|
const menuEmits = {
|
|
2175
2538
|
close: (index2, indexPath) => isString(index2) && checkIndexPath(indexPath),
|
|
2176
2539
|
open: (index2, indexPath) => isString(index2) && checkIndexPath(indexPath),
|
|
2177
|
-
select: (index2, indexPath, item, routerResult) => isString(index2) && checkIndexPath(indexPath) && isObject(item) && (routerResult
|
|
2540
|
+
select: (index2, indexPath, item, routerResult) => isString(index2) && checkIndexPath(indexPath) && isObject(item) && (isUndefined(routerResult) || routerResult instanceof Promise)
|
|
2178
2541
|
};
|
|
2542
|
+
const DEFAULT_MORE_ITEM_WIDTH = 64;
|
|
2179
2543
|
var Menu2 = defineComponent({
|
|
2180
2544
|
name: "ElMenu",
|
|
2181
2545
|
props: menuProps,
|
|
@@ -2184,29 +2548,37 @@ var Menu2 = defineComponent({
|
|
|
2184
2548
|
const instance = getCurrentInstance();
|
|
2185
2549
|
const router2 = instance.appContext.config.globalProperties.$router;
|
|
2186
2550
|
const menu = ref();
|
|
2551
|
+
const subMenu = ref();
|
|
2187
2552
|
const nsMenu = useNamespace("menu");
|
|
2188
2553
|
const nsSubMenu = useNamespace("sub-menu");
|
|
2554
|
+
let moreItemWidth = DEFAULT_MORE_ITEM_WIDTH;
|
|
2189
2555
|
const sliceIndex = ref(-1);
|
|
2190
|
-
const openedMenus = ref(
|
|
2556
|
+
const openedMenus = ref(
|
|
2557
|
+
props.defaultOpeneds && !props.collapse ? props.defaultOpeneds.slice(0) : []
|
|
2558
|
+
);
|
|
2191
2559
|
const activeIndex = ref(props.defaultActive);
|
|
2192
2560
|
const items = ref({});
|
|
2193
2561
|
const subMenus = ref({});
|
|
2194
|
-
const isMenuPopup = computed(
|
|
2562
|
+
const isMenuPopup = computed(
|
|
2563
|
+
() => props.mode === "horizontal" || props.mode === "vertical" && props.collapse
|
|
2564
|
+
);
|
|
2195
2565
|
const initMenu = () => {
|
|
2196
2566
|
const activeItem = activeIndex.value && items.value[activeIndex.value];
|
|
2197
2567
|
if (!activeItem || props.mode === "horizontal" || props.collapse)
|
|
2198
2568
|
return;
|
|
2199
2569
|
const indexPath = activeItem.indexPath;
|
|
2200
2570
|
indexPath.forEach((index2) => {
|
|
2201
|
-
const
|
|
2202
|
-
|
|
2571
|
+
const subMenu2 = subMenus.value[index2];
|
|
2572
|
+
subMenu2 && openMenu(index2, subMenu2.indexPath);
|
|
2203
2573
|
});
|
|
2204
2574
|
};
|
|
2205
2575
|
const openMenu = (index2, indexPath) => {
|
|
2206
2576
|
if (openedMenus.value.includes(index2))
|
|
2207
2577
|
return;
|
|
2208
2578
|
if (props.uniqueOpened) {
|
|
2209
|
-
openedMenus.value = openedMenus.value.filter(
|
|
2579
|
+
openedMenus.value = openedMenus.value.filter(
|
|
2580
|
+
(index22) => indexPath.includes(index22)
|
|
2581
|
+
);
|
|
2210
2582
|
}
|
|
2211
2583
|
openedMenus.value.push(index2);
|
|
2212
2584
|
emit("open", index2, indexPath);
|
|
@@ -2242,7 +2614,13 @@ var Menu2 = defineComponent({
|
|
|
2242
2614
|
activeIndex.value = index2;
|
|
2243
2615
|
return res;
|
|
2244
2616
|
});
|
|
2245
|
-
emit(
|
|
2617
|
+
emit(
|
|
2618
|
+
"select",
|
|
2619
|
+
index2,
|
|
2620
|
+
indexPath,
|
|
2621
|
+
{ index: index2, indexPath, route },
|
|
2622
|
+
routerResult
|
|
2623
|
+
);
|
|
2246
2624
|
} else {
|
|
2247
2625
|
activeIndex.value = index2;
|
|
2248
2626
|
emit("select", index2, indexPath, { index: index2, indexPath });
|
|
@@ -2261,11 +2639,11 @@ var Menu2 = defineComponent({
|
|
|
2261
2639
|
return menuItem.offsetWidth + marginLeft + marginRight || 0;
|
|
2262
2640
|
};
|
|
2263
2641
|
const calcSliceIndex = () => {
|
|
2264
|
-
var _a, _b;
|
|
2265
2642
|
if (!menu.value)
|
|
2266
2643
|
return -1;
|
|
2267
|
-
const items2 = Array.from(
|
|
2268
|
-
|
|
2644
|
+
const items2 = Array.from(menu.value.childNodes).filter(
|
|
2645
|
+
(item) => item.nodeName !== "#comment" && (item.nodeName !== "#text" || item.nodeValue)
|
|
2646
|
+
);
|
|
2269
2647
|
const computedMenuStyle = getComputedStyle(menu.value);
|
|
2270
2648
|
const paddingLeft = Number.parseInt(computedMenuStyle.paddingLeft, 10);
|
|
2271
2649
|
const paddingRight = Number.parseInt(computedMenuStyle.paddingRight, 10);
|
|
@@ -2273,8 +2651,6 @@ var Menu2 = defineComponent({
|
|
|
2273
2651
|
let calcWidth = 0;
|
|
2274
2652
|
let sliceIndex2 = 0;
|
|
2275
2653
|
items2.forEach((item, index2) => {
|
|
2276
|
-
if (item.nodeName === "#comment")
|
|
2277
|
-
return;
|
|
2278
2654
|
calcWidth += calcMenuItemWidth(item);
|
|
2279
2655
|
if (calcWidth <= menuWidth - moreItemWidth) {
|
|
2280
2656
|
sliceIndex2 = index2 + 1;
|
|
@@ -2284,16 +2660,19 @@ var Menu2 = defineComponent({
|
|
|
2284
2660
|
};
|
|
2285
2661
|
const getIndexPath = (index2) => subMenus.value[index2].indexPath;
|
|
2286
2662
|
const debounce2 = (fn, wait = 33.34) => {
|
|
2287
|
-
let
|
|
2663
|
+
let timer;
|
|
2288
2664
|
return () => {
|
|
2289
|
-
|
|
2290
|
-
|
|
2665
|
+
timer && clearTimeout(timer);
|
|
2666
|
+
timer = setTimeout(() => {
|
|
2291
2667
|
fn();
|
|
2292
2668
|
}, wait);
|
|
2293
2669
|
};
|
|
2294
2670
|
};
|
|
2295
2671
|
let isFirstTimeRender = true;
|
|
2296
2672
|
const handleResize = () => {
|
|
2673
|
+
const el = unrefElement(subMenu);
|
|
2674
|
+
if (el)
|
|
2675
|
+
moreItemWidth = calcMenuItemWidth(el) || DEFAULT_MORE_ITEM_WIDTH;
|
|
2297
2676
|
if (sliceIndex.value === calcSliceIndex())
|
|
2298
2677
|
return;
|
|
2299
2678
|
const callback = () => {
|
|
@@ -2305,16 +2684,22 @@ var Menu2 = defineComponent({
|
|
|
2305
2684
|
isFirstTimeRender ? callback() : debounce2(callback)();
|
|
2306
2685
|
isFirstTimeRender = false;
|
|
2307
2686
|
};
|
|
2308
|
-
watch(
|
|
2309
|
-
|
|
2310
|
-
|
|
2687
|
+
watch(
|
|
2688
|
+
() => props.defaultActive,
|
|
2689
|
+
(currentActive) => {
|
|
2690
|
+
if (!items.value[currentActive]) {
|
|
2691
|
+
activeIndex.value = "";
|
|
2692
|
+
}
|
|
2693
|
+
updateActiveIndex(currentActive);
|
|
2311
2694
|
}
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2695
|
+
);
|
|
2696
|
+
watch(
|
|
2697
|
+
() => props.collapse,
|
|
2698
|
+
(value) => {
|
|
2699
|
+
if (value)
|
|
2700
|
+
openedMenus.value = [];
|
|
2701
|
+
}
|
|
2702
|
+
);
|
|
2318
2703
|
watch(items.value, initMenu);
|
|
2319
2704
|
let resizeStopper;
|
|
2320
2705
|
watchEffect(() => {
|
|
@@ -2337,23 +2722,26 @@ var Menu2 = defineComponent({
|
|
|
2337
2722
|
const removeMenuItem = (item) => {
|
|
2338
2723
|
delete items.value[item.index];
|
|
2339
2724
|
};
|
|
2340
|
-
provide(
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2725
|
+
provide(
|
|
2726
|
+
MENU_INJECTION_KEY,
|
|
2727
|
+
reactive({
|
|
2728
|
+
props,
|
|
2729
|
+
openedMenus,
|
|
2730
|
+
items,
|
|
2731
|
+
subMenus,
|
|
2732
|
+
activeIndex,
|
|
2733
|
+
isMenuPopup,
|
|
2734
|
+
addMenuItem,
|
|
2735
|
+
removeMenuItem,
|
|
2736
|
+
addSubMenu,
|
|
2737
|
+
removeSubMenu,
|
|
2738
|
+
openMenu,
|
|
2739
|
+
closeMenu,
|
|
2740
|
+
handleMenuItemClick,
|
|
2741
|
+
handleSubMenuClick
|
|
2742
|
+
})
|
|
2743
|
+
);
|
|
2744
|
+
provide(`${SUB_MENU_INJECTION_KEY}${instance.uid}`, {
|
|
2357
2745
|
addSubMenu,
|
|
2358
2746
|
removeSubMenu,
|
|
2359
2747
|
mouseInChild,
|
|
@@ -2373,6 +2761,7 @@ var Menu2 = defineComponent({
|
|
|
2373
2761
|
expose({
|
|
2374
2762
|
open,
|
|
2375
2763
|
close,
|
|
2764
|
+
updateActiveIndex,
|
|
2376
2765
|
handleResize
|
|
2377
2766
|
});
|
|
2378
2767
|
}
|
|
@@ -2382,23 +2771,36 @@ var Menu2 = defineComponent({
|
|
|
2382
2771
|
let slot = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) != null ? _b : [];
|
|
2383
2772
|
const vShowMore = [];
|
|
2384
2773
|
if (props.mode === "horizontal" && menu.value) {
|
|
2385
|
-
const originalSlot = flattedChildren(slot)
|
|
2774
|
+
const originalSlot = flattedChildren(slot).filter((vnode) => {
|
|
2775
|
+
return (vnode == null ? void 0 : vnode.shapeFlag) !== 8;
|
|
2776
|
+
});
|
|
2386
2777
|
const slotDefault = sliceIndex.value === -1 ? originalSlot : originalSlot.slice(0, sliceIndex.value);
|
|
2387
2778
|
const slotMore = sliceIndex.value === -1 ? [] : originalSlot.slice(sliceIndex.value);
|
|
2388
2779
|
if ((slotMore == null ? void 0 : slotMore.length) && props.ellipsis) {
|
|
2389
2780
|
slot = slotDefault;
|
|
2390
|
-
vShowMore.push(
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2781
|
+
vShowMore.push(
|
|
2782
|
+
h(
|
|
2783
|
+
SubMenu2,
|
|
2784
|
+
{
|
|
2785
|
+
ref: subMenu,
|
|
2786
|
+
index: "sub-menu-more",
|
|
2787
|
+
class: nsSubMenu.e("hide-arrow"),
|
|
2788
|
+
popperOffset: props.popperOffset
|
|
2789
|
+
},
|
|
2790
|
+
{
|
|
2791
|
+
title: () => h(
|
|
2792
|
+
ElIcon,
|
|
2793
|
+
{
|
|
2794
|
+
class: nsSubMenu.e("icon-more")
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
default: () => h(props.ellipsisIcon)
|
|
2798
|
+
}
|
|
2799
|
+
),
|
|
2800
|
+
default: () => slotMore
|
|
2801
|
+
}
|
|
2802
|
+
)
|
|
2803
|
+
);
|
|
2402
2804
|
}
|
|
2403
2805
|
}
|
|
2404
2806
|
const directives = props.closeOnClickOutside ? [
|
|
@@ -2408,23 +2810,32 @@ var Menu2 = defineComponent({
|
|
|
2408
2810
|
if (!openedMenus.value.length)
|
|
2409
2811
|
return;
|
|
2410
2812
|
if (!mouseInChild.value) {
|
|
2411
|
-
openedMenus.value.forEach(
|
|
2813
|
+
openedMenus.value.forEach(
|
|
2814
|
+
(openedMenu) => emit("close", openedMenu, getIndexPath(openedMenu))
|
|
2815
|
+
);
|
|
2412
2816
|
openedMenus.value = [];
|
|
2413
2817
|
}
|
|
2414
2818
|
}
|
|
2415
2819
|
]
|
|
2416
2820
|
] : [];
|
|
2417
|
-
const vMenu = withDirectives(
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2821
|
+
const vMenu = withDirectives(
|
|
2822
|
+
h(
|
|
2823
|
+
"ul",
|
|
2824
|
+
{
|
|
2825
|
+
key: String(props.collapse),
|
|
2826
|
+
role: "menubar",
|
|
2827
|
+
ref: menu,
|
|
2828
|
+
style: ulStyle.value,
|
|
2829
|
+
class: {
|
|
2830
|
+
[nsMenu.b()]: true,
|
|
2831
|
+
[nsMenu.m(props.mode)]: true,
|
|
2832
|
+
[nsMenu.m("collapse")]: props.collapse
|
|
2833
|
+
}
|
|
2834
|
+
},
|
|
2835
|
+
[...slot, ...vShowMore]
|
|
2836
|
+
),
|
|
2837
|
+
directives
|
|
2838
|
+
);
|
|
2428
2839
|
if (props.collapseTransition && props.mode === "vertical") {
|
|
2429
2840
|
return h(ElMenuCollapseTransition, () => vMenu);
|
|
2430
2841
|
}
|
|
@@ -2446,23 +2857,27 @@ const menuItemEmits = {
|
|
|
2446
2857
|
click: (item) => isString(item.index) && isArray(item.indexPath)
|
|
2447
2858
|
};
|
|
2448
2859
|
const COMPONENT_NAME = "ElMenuItem";
|
|
2449
|
-
const
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2860
|
+
const _sfc_main$j = defineComponent({
|
|
2861
|
+
...{
|
|
2862
|
+
name: COMPONENT_NAME
|
|
2863
|
+
},
|
|
2864
|
+
__name: "menu-item",
|
|
2454
2865
|
props: menuItemProps,
|
|
2455
2866
|
emits: menuItemEmits,
|
|
2456
|
-
setup(__props, { expose, emit }) {
|
|
2867
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2457
2868
|
const props = __props;
|
|
2869
|
+
const emit = __emit;
|
|
2870
|
+
isPropAbsent(props.index) && debugWarn(COMPONENT_NAME, 'Missing required prop: "index"');
|
|
2458
2871
|
const instance = getCurrentInstance();
|
|
2459
|
-
const rootMenu = inject(
|
|
2872
|
+
const rootMenu = inject(MENU_INJECTION_KEY);
|
|
2460
2873
|
const nsMenu = useNamespace("menu");
|
|
2461
2874
|
const nsMenuItem = useNamespace("menu-item");
|
|
2462
2875
|
if (!rootMenu)
|
|
2463
2876
|
throwError(COMPONENT_NAME, "can not inject root menu");
|
|
2464
2877
|
const { parentMenu, indexPath } = useMenu(instance, toRef(props, "index"));
|
|
2465
|
-
const subMenu = inject(
|
|
2878
|
+
const subMenu = inject(
|
|
2879
|
+
`${SUB_MENU_INJECTION_KEY}${parentMenu.value.uid}`
|
|
2880
|
+
);
|
|
2466
2881
|
if (!subMenu)
|
|
2467
2882
|
throwError(COMPONENT_NAME, "can not inject sub menu");
|
|
2468
2883
|
const active = computed(() => props.index === rootMenu.activeIndex);
|
|
@@ -2489,7 +2904,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2489
2904
|
subMenu.removeSubMenu(item);
|
|
2490
2905
|
rootMenu.removeMenuItem(item);
|
|
2491
2906
|
});
|
|
2492
|
-
|
|
2907
|
+
__expose({
|
|
2493
2908
|
parentMenu,
|
|
2494
2909
|
rootMenu,
|
|
2495
2910
|
active,
|
|
@@ -2498,73 +2913,109 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2498
2913
|
handleClick
|
|
2499
2914
|
});
|
|
2500
2915
|
return (_ctx, _cache) => {
|
|
2501
|
-
return openBlock(), createElementBlock(
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
tabindex: "-1",
|
|
2509
|
-
onClick: handleClick
|
|
2510
|
-
}, [
|
|
2511
|
-
unref(parentMenu).type.name === "ElMenu" && unref(rootMenu).props.collapse && _ctx.$slots.title ? (openBlock(), createBlock(unref(ElTooltip), {
|
|
2512
|
-
key: 0,
|
|
2513
|
-
effect: unref(rootMenu).props.popperEffect,
|
|
2514
|
-
placement: "right",
|
|
2515
|
-
"fallback-placements": ["left"],
|
|
2516
|
-
persistent: unref(rootMenu).props.persistent
|
|
2517
|
-
}, {
|
|
2518
|
-
content: withCtx(() => [
|
|
2519
|
-
renderSlot(_ctx.$slots, "title")
|
|
2520
|
-
]),
|
|
2521
|
-
default: withCtx(() => [
|
|
2522
|
-
createElementVNode("div", {
|
|
2523
|
-
class: normalizeClass(unref(nsMenu).be("tooltip", "trigger"))
|
|
2524
|
-
}, [
|
|
2525
|
-
renderSlot(_ctx.$slots, "default")
|
|
2526
|
-
], 2)
|
|
2916
|
+
return openBlock(), createElementBlock(
|
|
2917
|
+
"li",
|
|
2918
|
+
{
|
|
2919
|
+
class: normalizeClass([
|
|
2920
|
+
unref(nsMenuItem).b(),
|
|
2921
|
+
unref(nsMenuItem).is("active", active.value),
|
|
2922
|
+
unref(nsMenuItem).is("disabled", _ctx.disabled)
|
|
2527
2923
|
]),
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2924
|
+
role: "menuitem",
|
|
2925
|
+
tabindex: "-1",
|
|
2926
|
+
onClick: handleClick
|
|
2927
|
+
},
|
|
2928
|
+
[
|
|
2929
|
+
unref(parentMenu).type.name === "ElMenu" && unref(rootMenu).props.collapse && _ctx.$slots.title ? (openBlock(), createBlock(unref(ElTooltip), {
|
|
2930
|
+
key: 0,
|
|
2931
|
+
effect: unref(rootMenu).props.popperEffect,
|
|
2932
|
+
placement: "right",
|
|
2933
|
+
"fallback-placements": ["left"],
|
|
2934
|
+
"popper-class": unref(rootMenu).props.popperClass,
|
|
2935
|
+
"popper-style": unref(rootMenu).props.popperStyle,
|
|
2936
|
+
persistent: unref(rootMenu).props.persistent,
|
|
2937
|
+
"focus-on-target": ""
|
|
2938
|
+
}, {
|
|
2939
|
+
content: withCtx(() => [
|
|
2940
|
+
renderSlot(_ctx.$slots, "title")
|
|
2941
|
+
]),
|
|
2942
|
+
default: withCtx(() => [
|
|
2943
|
+
createElementVNode(
|
|
2944
|
+
"div",
|
|
2945
|
+
{
|
|
2946
|
+
class: normalizeClass(unref(nsMenu).be("tooltip", "trigger"))
|
|
2947
|
+
},
|
|
2948
|
+
[
|
|
2949
|
+
renderSlot(_ctx.$slots, "default")
|
|
2950
|
+
],
|
|
2951
|
+
2
|
|
2952
|
+
)
|
|
2953
|
+
]),
|
|
2954
|
+
_: 3
|
|
2955
|
+
}, 8, ["effect", "popper-class", "popper-style", "persistent"])) : (openBlock(), createElementBlock(
|
|
2956
|
+
Fragment,
|
|
2957
|
+
{ key: 1 },
|
|
2958
|
+
[
|
|
2959
|
+
renderSlot(_ctx.$slots, "default"),
|
|
2960
|
+
renderSlot(_ctx.$slots, "title")
|
|
2961
|
+
],
|
|
2962
|
+
64
|
|
2963
|
+
))
|
|
2964
|
+
],
|
|
2965
|
+
2
|
|
2966
|
+
);
|
|
2534
2967
|
};
|
|
2535
2968
|
}
|
|
2536
2969
|
});
|
|
2537
|
-
var MenuItem2 = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__file", "menu-item.vue"]]);
|
|
2970
|
+
var MenuItem2 = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-item.vue"]]);
|
|
2538
2971
|
const menuItemGroupProps = {
|
|
2539
2972
|
title: String
|
|
2540
2973
|
};
|
|
2541
|
-
const
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2974
|
+
const _sfc_main$i = defineComponent({
|
|
2975
|
+
...{
|
|
2976
|
+
name: "ElMenuItemGroup"
|
|
2977
|
+
},
|
|
2978
|
+
__name: "menu-item-group",
|
|
2546
2979
|
props: menuItemGroupProps,
|
|
2547
2980
|
setup(__props) {
|
|
2548
2981
|
const ns = useNamespace("menu-item-group");
|
|
2549
2982
|
return (_ctx, _cache) => {
|
|
2550
|
-
return openBlock(), createElementBlock(
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2983
|
+
return openBlock(), createElementBlock(
|
|
2984
|
+
"li",
|
|
2985
|
+
{
|
|
2986
|
+
class: normalizeClass(unref(ns).b())
|
|
2987
|
+
},
|
|
2988
|
+
[
|
|
2989
|
+
createElementVNode(
|
|
2990
|
+
"div",
|
|
2991
|
+
{
|
|
2992
|
+
class: normalizeClass(unref(ns).e("title"))
|
|
2993
|
+
},
|
|
2994
|
+
[
|
|
2995
|
+
!_ctx.$slots.title ? (openBlock(), createElementBlock(
|
|
2996
|
+
Fragment,
|
|
2997
|
+
{ key: 0 },
|
|
2998
|
+
[
|
|
2999
|
+
createTextVNode(
|
|
3000
|
+
toDisplayString(_ctx.title),
|
|
3001
|
+
1
|
|
3002
|
+
)
|
|
3003
|
+
],
|
|
3004
|
+
64
|
|
3005
|
+
)) : renderSlot(_ctx.$slots, "title", { key: 1 })
|
|
3006
|
+
],
|
|
3007
|
+
2
|
|
3008
|
+
),
|
|
3009
|
+
createElementVNode("ul", null, [
|
|
3010
|
+
renderSlot(_ctx.$slots, "default")
|
|
3011
|
+
])
|
|
3012
|
+
],
|
|
3013
|
+
2
|
|
3014
|
+
);
|
|
2564
3015
|
};
|
|
2565
3016
|
}
|
|
2566
3017
|
});
|
|
2567
|
-
var MenuItemGroup = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__file", "menu-item-group.vue"]]);
|
|
3018
|
+
var MenuItemGroup = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/menu/src/menu-item-group.vue"]]);
|
|
2568
3019
|
const ElMenu = withInstall(Menu2, {
|
|
2569
3020
|
MenuItem: MenuItem2,
|
|
2570
3021
|
MenuItemGroup,
|
|
@@ -2784,8 +3235,8 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
2784
3235
|
modelValue: unref(globalStore).isDark,
|
|
2785
3236
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(globalStore).isDark = $event),
|
|
2786
3237
|
"inline-prompt": "",
|
|
2787
|
-
"active-icon": unref(
|
|
2788
|
-
"inactive-icon": unref(
|
|
3238
|
+
"active-icon": unref(Sunny),
|
|
3239
|
+
"inactive-icon": unref(Moon),
|
|
2789
3240
|
onChange: unref(switchDark)
|
|
2790
3241
|
}, null, 8, ["modelValue", "active-icon", "inactive-icon", "onChange"]);
|
|
2791
3242
|
};
|
|
@@ -2881,7 +3332,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2881
3332
|
default: withCtx(() => [createVNode(_component_el_icon, null, {
|
|
2882
3333
|
default: withCtx(() => [createVNode(_component_Notification)]),
|
|
2883
3334
|
_: 1
|
|
2884
|
-
}), _cache[13] || (_cache[13] = createTextVNode(" 布局样式 "))]),
|
|
3335
|
+
}), _cache[13] || (_cache[13] = createTextVNode(" 布局样式 ", -1))]),
|
|
2885
3336
|
_: 1
|
|
2886
3337
|
}), createElementVNode("div", _hoisted_1$a, [createVNode(_component_el_tooltip, {
|
|
2887
3338
|
effect: "dark",
|
|
@@ -2931,7 +3382,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2931
3382
|
_: 1
|
|
2932
3383
|
})) : createCommentVNode("", true)], 2)]),
|
|
2933
3384
|
_: 1
|
|
2934
|
-
})]), createElementVNode("div", _hoisted_2$6, [createElementVNode("span", null, [_cache[18] || (_cache[18] = createTextVNode(" 头部反转色 ")), createVNode(_component_el_tooltip, {
|
|
3385
|
+
})]), createElementVNode("div", _hoisted_2$6, [createElementVNode("span", null, [_cache[18] || (_cache[18] = createTextVNode(" 头部反转色 ", -1)), createVNode(_component_el_tooltip, {
|
|
2935
3386
|
effect: "dark",
|
|
2936
3387
|
content: "头部颜色变为深色模式",
|
|
2937
3388
|
placement: "top"
|
|
@@ -2952,7 +3403,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2952
3403
|
default: withCtx(() => [createVNode(_component_el_icon, null, {
|
|
2953
3404
|
default: withCtx(() => [createVNode(_component_ColdDrink)]),
|
|
2954
3405
|
_: 1
|
|
2955
|
-
}), _cache[19] || (_cache[19] = createTextVNode(" 全局主题 "))]),
|
|
3406
|
+
}), _cache[19] || (_cache[19] = createTextVNode(" 全局主题 ", -1))]),
|
|
2956
3407
|
_: 1
|
|
2957
3408
|
}), createElementVNode("div", _hoisted_3$2, [_cache[20] || (_cache[20] = createElementVNode("span", null, "主题颜色", -1)), createVNode(_component_el_color_picker, {
|
|
2958
3409
|
modelValue: unref(primary),
|
|
@@ -2966,7 +3417,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
2966
3417
|
default: withCtx(() => [createVNode(_component_el_icon, null, {
|
|
2967
3418
|
default: withCtx(() => [createVNode(_component_Setting)]),
|
|
2968
3419
|
_: 1
|
|
2969
|
-
}), _cache[22] || (_cache[22] = createTextVNode(" 界面设置 "))]),
|
|
3420
|
+
}), _cache[22] || (_cache[22] = createTextVNode(" 界面设置 ", -1))]),
|
|
2970
3421
|
_: 1
|
|
2971
3422
|
}), createElementVNode("div", _hoisted_5, [_cache[23] || (_cache[23] = createElementVNode("span", null, "主菜单折叠", -1)), createVNode(_component_el_switch, {
|
|
2972
3423
|
modelValue: unref(isCollapse),
|
|
@@ -3031,9 +3482,9 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3031
3482
|
return openBlock(), createElementBlock("div", {
|
|
3032
3483
|
class: "maximize",
|
|
3033
3484
|
onClick: exitMaximize
|
|
3034
|
-
}, _cache[0] || (_cache[0] = [createElementVNode("i", {
|
|
3485
|
+
}, [..._cache[0] || (_cache[0] = [createElementVNode("i", {
|
|
3035
3486
|
class: normalizeClass("iconfont icon-tuichu")
|
|
3036
|
-
}, null, -1)]));
|
|
3487
|
+
}, null, -1)])]);
|
|
3037
3488
|
};
|
|
3038
3489
|
}
|
|
3039
3490
|
});
|
|
@@ -3338,10 +3789,10 @@ const _hoisted_1$8 = {
|
|
|
3338
3789
|
class: "footer flx-center"
|
|
3339
3790
|
};
|
|
3340
3791
|
function _sfc_render$1(_ctx, _cache) {
|
|
3341
|
-
return openBlock(), createElementBlock("div", _hoisted_1$8, _cache[0] || (_cache[0] = [createElementVNode("a", {
|
|
3792
|
+
return openBlock(), createElementBlock("div", _hoisted_1$8, [..._cache[0] || (_cache[0] = [createElementVNode("a", {
|
|
3342
3793
|
href: "#",
|
|
3343
3794
|
target: "_blank"
|
|
3344
|
-
}, " 2024 © 青岛安工数联信息科技有限公司 ", -1)]));
|
|
3795
|
+
}, " 2024 © 青岛安工数联信息科技有限公司 ", -1)])]);
|
|
3345
3796
|
}
|
|
3346
3797
|
const Footer = /* @__PURE__ */ _export_sfc$1(_sfc_main$c, [["render", _sfc_render$1], ["__scopeId", "data-v-1254311c"]]);
|
|
3347
3798
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
@@ -3414,9 +3865,9 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
3414
3865
|
const _component_el_main = ElMain;
|
|
3415
3866
|
const _component_el_footer = ElFooter;
|
|
3416
3867
|
return openBlock(), createElementBlock(Fragment, null, [withDirectives(createVNode(Maximize, null, null, 512), [[vShow, unref(maximize)]]), withDirectives(createVNode(Tabs, {
|
|
3417
|
-
"is-custom-tabs":
|
|
3868
|
+
"is-custom-tabs": __props.isShowCustomTabs
|
|
3418
3869
|
}, null, 8, ["is-custom-tabs"]), [[vShow, props.isShowCustomTabs && unref(tabs)]]), withDirectives(createVNode(Tabs, {
|
|
3419
|
-
"is-custom-tabs":
|
|
3870
|
+
"is-custom-tabs": __props.isShowCustomTabs
|
|
3420
3871
|
}, null, 8, ["is-custom-tabs"]), [[vShow, !props.isShowCustomTabs && unref(tabs)]]), createVNode(_component_el_main, null, {
|
|
3421
3872
|
default: withCtx(() => [createVNode(_component_router_view, null, {
|
|
3422
3873
|
default: withCtx(({
|
|
@@ -3467,7 +3918,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
3467
3918
|
const _component_SubMenu = resolveComponent("SubMenu", true);
|
|
3468
3919
|
const _component_el_sub_menu = ElSubMenu;
|
|
3469
3920
|
const _component_el_menu_item = ElMenuItem;
|
|
3470
|
-
return openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
3921
|
+
return openBlock(true), createElementBlock(Fragment, null, renderList(__props.menuList, (subItem) => {
|
|
3471
3922
|
var _a;
|
|
3472
3923
|
return openBlock(), createElementBlock(Fragment, {
|
|
3473
3924
|
key: subItem.path
|
|
@@ -3552,7 +4003,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
3552
4003
|
return openBlock(), createElementBlock("div", {
|
|
3553
4004
|
class: normalizeClass(["breadcrumb-box mask-image", !unref(globalStore).breadcrumbIcon && "no-icon"])
|
|
3554
4005
|
}, [createVNode(_component_el_breadcrumb, {
|
|
3555
|
-
"separator-icon": unref(
|
|
4006
|
+
"separator-icon": unref(ArrowRight)
|
|
3556
4007
|
}, {
|
|
3557
4008
|
default: withCtx(() => [createVNode(TransitionGroup, {
|
|
3558
4009
|
name: "breadcrumb"
|
|
@@ -3787,12 +4238,12 @@ function _sfc_render(_ctx, _cache) {
|
|
|
3787
4238
|
return openBlock(), createBlock(_component_el_dropdown, {
|
|
3788
4239
|
trigger: "click"
|
|
3789
4240
|
}, {
|
|
3790
|
-
default: withCtx(() => _cache[0] || (_cache[0] = [createElementVNode("div", {
|
|
4241
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createElementVNode("div", {
|
|
3791
4242
|
class: "avatar"
|
|
3792
4243
|
}, [createElementVNode("img", {
|
|
3793
4244
|
src: _imports_0,
|
|
3794
4245
|
alt: "avatar"
|
|
3795
|
-
})], -1)])),
|
|
4246
|
+
})], -1)])]),
|
|
3796
4247
|
_: 1
|
|
3797
4248
|
});
|
|
3798
4249
|
}
|