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.

Files changed (38) hide show
  1. package/README.md +5 -0
  2. package/dist/{403-D8dRpQKz.js → 403-BgYs1MY9.js} +2 -2
  3. package/dist/{404-DXM7nyXC.js → 404-DHj5v1Yh.js} +2 -2
  4. package/dist/{500-BUCjxPG1.js → 500-BMPMnB5R.js} +2 -2
  5. package/dist/CrontabDay-BtWkPZgc.js +4 -0
  6. package/dist/CrontabHour-CWW94JsR.js +4 -0
  7. package/dist/CrontabMin-4na7Y7jF.js +4 -0
  8. package/dist/CrontabMonth-dsg6XXW5.js +4 -0
  9. package/dist/CrontabResult-rMgvC2Ov.js +4 -0
  10. package/dist/CrontabSecond-B57qJvYE.js +4 -0
  11. package/dist/CrontabWeek-dPVVzR9P.js +4 -0
  12. package/dist/CrontabYear-DImaFqLN.js +4 -0
  13. package/dist/EditExecutor-DZ3Ic8Ex.js +4 -0
  14. package/dist/JobTaskClearDialog-D-E19g9O.js +4 -0
  15. package/dist/RunOnceView-D4oyLKNh.js +4 -0
  16. package/dist/{index-Bf5gEacT.js → index-C8Y_Od96.js} +18120 -16315
  17. package/dist/{index-OKUPhEWh.js → index-D6UxUdAp.js} +1673 -1222
  18. package/dist/index-DI263EBt.js +4 -0
  19. package/dist/index-DvUlhZYD.js +4 -0
  20. package/dist/index-Zr37j6aO.js +4 -0
  21. package/dist/style.css +1 -0
  22. package/dist/xxl-job-vue3.es.js +2 -3
  23. package/dist/xxl-job-vue3.umd.js +19 -15
  24. package/package.json +1 -1
  25. package/dist/CrontabDay-DqR3VUYR.js +0 -4
  26. package/dist/CrontabHour-B0Ub5MaR.js +0 -4
  27. package/dist/CrontabMin-DtjfCxp1.js +0 -4
  28. package/dist/CrontabMonth-BU6m9TVZ.js +0 -4
  29. package/dist/CrontabResult-DGO_apJU.js +0 -4
  30. package/dist/CrontabSecond-BqQGVOZ9.js +0 -4
  31. package/dist/CrontabWeek-DHqRjAy-.js +0 -4
  32. package/dist/CrontabYear-D3Z1OkFC.js +0 -4
  33. package/dist/EditExecutor-C-jVvoY3.js +0 -4
  34. package/dist/JobTaskClearDialog-CpXLIi7N.js +0 -4
  35. package/dist/RunOnceView-Bk8stgp6.js +0 -4
  36. package/dist/index-Btu-nIzi.js +0 -4
  37. package/dist/index-CXZ4_Fnb.js +0 -4
  38. 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, watchEffect, reactive, nextTick, createCommentVNode, withDirectives, createVNode, 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 EVENT_CODE, y as isString, z as isNil, C as CHANGE_EVENT, U as UPDATE_MODEL_EVENT, A as useAriaProps, B as useTooltipContentProps, D as useSizeProp, F as hasOwn, G as useFormItem, H as useFormSize, I as useFormDisabled, J as useFormItemInputId, K as useFocusController, L as debounce, M as ElTooltip, N as arrow_down_default, O as close_default, P as ElInput, Q as ElButton, R as ClickOutside, S as debugWarn, T as triggerEvent, V as addClass, W as hasClass, X as removeClass, Y as TinyColor, Z as throwError, $ as arrow_right_default, a0 as useTimeoutFn, a1 as isArray, a2 as isObject, a3 as useResizeObserver, a4 as flattedChildren, a5 as more_default, a6 as mutable, a7 as useGlobalStore, a8 as DEFAULT_PRIMARY, a9 as ElSwitch, aa as moon_default, ab as sunny_default, ac as ElDrawer, ad as _export_sfc$1, ae as piniaPersistConfig, af as getUrlWithParams, ag as router, ah as useAuthStore, ai as useRoute, aj as useRouter, ak as ElDropdown, al as ElDropdownMenu, am as ElDropdownItem, an as Sortable, ao as ElTabs, ap as ElTabPane, aq as useDebounceFn, ar as useUserStore, as as normalizeStyle$1, at as ElScrollbar } from "./index-Bf5gEacT.js";
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 __default__$h = defineComponent({
16
- name: "ElBreadcrumb"
17
- });
18
- const _sfc_main$y = /* @__PURE__ */ defineComponent({
19
- ...__default__$h,
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, ["aria-label"]);
43
+ ], 10, _hoisted_1$g);
43
44
  };
44
45
  }
45
46
  });
46
- var Breadcrumb$1 = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__file", "breadcrumb.vue"]]);
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 __default__$g = defineComponent({
55
- name: "ElBreadcrumbItem"
56
- });
57
- const _sfc_main$x = /* @__PURE__ */ defineComponent({
58
- ...__default__$g,
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("span", {
75
- class: normalizeClass(unref(ns).e("item"))
76
- }, [
77
- createElementVNode("span", {
78
- ref_key: "link",
79
- ref: link,
80
- class: normalizeClass([unref(ns).e("inner"), unref(ns).is("link", !!_ctx.to)]),
81
- role: "link",
82
- onClick
83
- }, [
84
- renderSlot(_ctx.$slots, "default")
85
- ], 2),
86
- ((_a = unref(breadcrumbContext)) == null ? void 0 : _a.separatorIcon) ? (openBlock(), createBlock(unref(ElIcon), {
87
- key: 0,
88
- class: normalizeClass(unref(ns).e("separator"))
89
- }, {
90
- default: withCtx(() => [
91
- (openBlock(), createBlock(resolveDynamicComponent(unref(breadcrumbContext).separatorIcon)))
92
- ]),
93
- _: 1
94
- }, 8, ["class"])) : (openBlock(), createElementBlock("span", {
95
- key: 1,
96
- class: normalizeClass(unref(ns).e("separator")),
97
- role: "presentation"
98
- }, toDisplayString((_b = unref(breadcrumbContext)) == null ? void 0 : _b.separator), 3))
99
- ], 2);
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$x, [["__file", "breadcrumb-item.vue"]]);
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 __default__$f = defineComponent({
109
- name: "ElCollapseTransition"
110
- });
111
- const _sfc_main$w = /* @__PURE__ */ defineComponent({
112
- ...__default__$f,
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$w, [["__file", "collapse-transition.vue"]]);
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
- type: Boolean,
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 useAlphaSlider = (props) => {
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 alpha = computed(() => props.color.get("alpha"));
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
- props.color.set("alpha", Math.round((left - thumb.value.offsetWidth / 2) / (rect.width - thumb.value.offsetWidth) * 100));
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
- props.color.set("alpha", Math.round((top - thumb.value.offsetHeight / 2) / (rect.height - thumb.value.offsetHeight) * 100));
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
- const { code, shiftKey } = event;
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
- event.preventDefault();
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
- event.preventDefault();
302
- event.stopPropagation();
303
- incrementPosition(step);
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 = alpha.value + step;
309
- next = next < 0 ? 0 : next > 100 ? 100 : next;
310
- props.color.set("alpha", next);
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
- alpha,
316
- alphaLabel,
349
+ currentValue,
317
350
  handleDrag,
318
351
  handleClick,
319
352
  handleKeydown
320
353
  };
321
354
  };
322
- const useAlphaSliderDOM = (props, {
355
+ const useSliderDOM = (props, {
356
+ namespace,
357
+ maxValue: maxValue2,
323
358
  bar,
324
359
  thumb,
325
- handleDrag
360
+ currentValue,
361
+ handleDrag,
362
+ getBackground
326
363
  }) => {
327
364
  const instance = getCurrentInstance();
328
- const ns = useNamespace("color-alpha-slider");
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 alpha = props.color.get("alpha");
375
+ const value = currentValue.value;
339
376
  if (!el)
340
377
  return 0;
341
- return Math.round(alpha * (el.offsetWidth - thumb.value.offsetWidth / 2) / 100);
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 alpha = props.color.get("alpha");
388
+ const value = currentValue.value;
350
389
  if (!el)
351
390
  return 0;
352
- return Math.round(alpha * (el.offsetHeight - thumb.value.offsetHeight / 2) / 100);
353
- }
354
- function getBackground() {
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(() => props.color.get("alpha"), () => update());
382
- watch(() => props.color.value, () => update());
383
- const rootKls = computed(() => [ns.b(), ns.is("vertical", props.vertical)]);
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 { rootKls, barKls, barStyle, thumbKls, thumbStyle, update };
432
+ return {
433
+ rootKls,
434
+ barKls,
435
+ barStyle,
436
+ thumbKls,
437
+ thumbStyle,
438
+ thumbLeft,
439
+ thumbTop,
440
+ update
441
+ };
392
442
  };
393
- const COMPONENT_NAME$2 = "ElColorAlphaSlider";
394
- const __default__$e = defineComponent({
395
- name: COMPONENT_NAME$2
396
- });
397
- const _sfc_main$v = /* @__PURE__ */ defineComponent({
398
- ...__default__$e,
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
- alpha,
404
- alphaLabel,
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
- handleClick,
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
- expose({
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("div", {
423
- class: normalizeClass(unref(rootKls))
424
- }, [
425
- createElementVNode("div", {
426
- ref_key: "bar",
427
- ref: bar,
428
- class: normalizeClass(unref(barKls)),
429
- style: normalizeStyle(unref(barStyle)),
430
- onClick: unref(handleClick)
431
- }, null, 14, ["onClick"]),
432
- createElementVNode("div", {
433
- ref_key: "thumb",
434
- ref: thumb,
435
- class: normalizeClass(unref(thumbKls)),
436
- style: normalizeStyle(unref(thumbStyle)),
437
- "aria-label": unref(alphaLabel),
438
- "aria-valuenow": unref(alpha),
439
- "aria-orientation": _ctx.vertical ? "vertical" : "horizontal",
440
- "aria-valuemin": "0",
441
- "aria-valuemax": "100",
442
- role: "slider",
443
- tabindex: "0",
444
- onKeydown: unref(handleKeydown)
445
- }, null, 46, ["aria-label", "aria-valuenow", "aria-orientation", "onKeydown"])
446
- ], 2);
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$v, [["__file", "alpha-slider.vue"]]);
451
- const _sfc_main$u = defineComponent({
452
- name: "ElColorHueSlider",
453
- props: {
454
- color: {
455
- type: Object,
456
- required: true
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
- setup(props) {
461
- const ns = useNamespace("color-hue-slider");
462
- const instance = getCurrentInstance();
463
- const thumb = ref();
464
- const bar = ref();
465
- const thumbLeft = ref(0);
466
- const thumbTop = ref(0);
467
- const hueValue = computed(() => {
468
- return props.color.get("hue");
469
- });
470
- watch(() => hueValue.value, () => {
471
- update();
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
- function handleClick(event) {
474
- const target = event.target;
475
- if (target !== thumb.value) {
476
- handleDrag(event);
477
- }
478
- }
479
- function handleDrag(event) {
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
- return {
554
+ __expose({
541
555
  bar,
542
556
  thumb,
543
- thumbLeft,
544
557
  thumbTop,
545
- hueValue,
546
- handleClick,
547
- update,
548
- ns
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
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
553
- return openBlock(), createElementBlock("div", {
554
- class: normalizeClass([_ctx.ns.b(), _ctx.ns.is("vertical", _ctx.vertical)])
555
- }, [
556
- createElementVNode("div", {
557
- ref: "bar",
558
- class: normalizeClass(_ctx.ns.e("bar")),
559
- onClick: _ctx.handleClick
560
- }, null, 10, ["onClick"]),
561
- createElementVNode("div", {
562
- ref: "thumb",
563
- class: normalizeClass(_ctx.ns.e("thumb")),
564
- style: normalizeStyle({
565
- left: _ctx.thumbLeft + "px",
566
- top: _ctx.thumbTop + "px"
567
- })
568
- }, null, 6)
569
- ], 2);
570
- }
571
- var HueSlider = /* @__PURE__ */ _export_sfc(_sfc_main$u, [["render", _sfc_render$4], ["__file", "hue-slider.vue"]]);
572
- const colorPickerProps = buildProps({
573
- modelValue: String,
574
- id: String,
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
- return HEX_INT_MAP[hex[1].toUpperCase()] || +hex[1];
663
- };
664
- const hsl2hsv = function(hue, sat, light) {
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 = "hex";
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 (prop === "alpha") {
764
- return Math.floor(this[`_${prop}`]);
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 hsv2rgb(this._hue, this._saturation, this._value);
683
+ return this._isValid ? this._tiny.toRgb() : { r: 255, g: 255, b: 255, a: 0 };
770
684
  }
771
685
  fromString(value) {
772
- if (!value) {
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.doOnChange();
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
- return Math.abs(color._hue - this._hue) < 2 && Math.abs(color._saturation - this._saturation) < 1 && Math.abs(color._value - this._value) < 1 && Math.abs(color._alpha - this._alpha) < 1;
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
- if (this.enableAlpha) {
846
- switch (format) {
847
- case "hsl": {
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 _sfc_main$t = defineComponent({
889
- props: {
890
- colors: {
891
- type: Array,
892
- required: true
893
- },
894
- color: {
895
- type: Object,
896
- required: true
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
- function parseColors(colors, color) {
921
- return colors.map((value) => {
922
- const c = new Color();
923
- c.enableAlpha = props.enableAlpha;
924
- c.format = "rgba";
925
- c.fromString(value);
926
- c.selected = c.value === color.value;
927
- return c;
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
- return {
931
- rgbaColors,
932
- handleSelect,
933
- ns
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
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
938
- return openBlock(), createElementBlock("div", {
939
- class: normalizeClass(_ctx.ns.b())
940
- }, [
941
- createElementVNode("div", {
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
- setup(props) {
972
- const ns = useNamespace("color-svpanel");
973
- const instance = getCurrentInstance();
974
- const cursorTop = ref(0);
975
- const cursorLeft = ref(0);
976
- const background = ref("hsl(0, 100%, 50%)");
977
- const colorValue = computed(() => {
978
- const hue = props.color.get("hue");
979
- const value = props.color.get("value");
980
- return { hue, value };
981
- });
982
- function update() {
983
- const saturation = props.color.get("saturation");
984
- const value = props.color.get("value");
985
- const el = instance.vnode.el;
986
- const { clientWidth: width, clientHeight: height } = el;
987
- cursorLeft.value = saturation * width / 100;
988
- cursorTop.value = (100 - value) * height / 100;
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
- watch(() => colorValue.value, () => {
1009
- update();
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
- onMounted(() => {
1012
- draggable(instance.vnode.el, {
1013
- drag: (event) => {
1014
- handleDrag(event);
1015
- },
1016
- end: (event) => {
1017
- handleDrag(event);
1018
- }
1019
- });
1020
- update();
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
- return {
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
- colorValue,
1010
+ saturation,
1011
+ brightness,
1012
+ handleClick,
1027
1013
  handleDrag,
1028
- update,
1029
- ns
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
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
1034
- return openBlock(), createElementBlock("div", {
1035
- class: normalizeClass(_ctx.ns.b()),
1036
- style: normalizeStyle({
1037
- backgroundColor: _ctx.background
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
- createElementVNode("div", {
1041
- class: normalizeClass(_ctx.ns.e("white"))
1042
- }, null, 2),
1043
- createElementVNode("div", {
1044
- class: normalizeClass(_ctx.ns.e("black"))
1045
- }, null, 2),
1046
- createElementVNode("div", {
1047
- class: normalizeClass(_ctx.ns.e("cursor")),
1048
- style: normalizeStyle({
1049
- top: _ctx.cursorTop + "px",
1050
- left: _ctx.cursorLeft + "px"
1051
- })
1052
- }, [
1053
- createElementVNode("div")
1054
- ], 6)
1055
- ], 6);
1056
- }
1057
- var SvPanel = /* @__PURE__ */ _export_sfc(_sfc_main$s, [["render", _sfc_render$2], ["__file", "sv-panel.vue"]]);
1058
- const __default__$d = defineComponent({
1059
- name: "ElColorPicker"
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 _sfc_main$r = /* @__PURE__ */ defineComponent({
1062
- ...__default__$d,
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 inputRef = ref();
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
- beforeFocus() {
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
- let shouldActiveChange = true;
1095
- const color = reactive(new Color({
1096
- enableAlpha: props.showAlpha,
1097
- format: props.colorFormat || "",
1098
- value: props.modelValue
1099
- }));
1100
- const showPicker = ref(false);
1101
- const showPanelColor = ref(false);
1102
- const customInput = ref("");
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
- if (!(color2 instanceof Color)) {
1128
- throw new TypeError("color should be instance of _color Class");
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("change", value);
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, null);
1191
- emit("change", null);
1192
- if (props.modelValue !== null && props.validateEvent) {
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
- switch (event.code) {
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
- onMounted(() => {
1231
- if (props.modelValue) {
1232
- customInput.value = currentColor.value;
1460
+ watch(
1461
+ () => currentColor.value,
1462
+ (val) => {
1463
+ shouldActiveChange && emit("activeChange", val);
1464
+ shouldActiveChange = true;
1233
1465
  }
1234
- });
1235
- watch(() => props.modelValue, (newVal) => {
1236
- if (!newVal) {
1237
- showPanelColor.value = false;
1238
- } else if (newVal && newVal !== color.value) {
1239
- shouldActiveChange = false;
1240
- color.fromString(newVal);
1466
+ );
1467
+ watch(
1468
+ () => color.value,
1469
+ () => {
1470
+ if (!props.modelValue && !showPanelColor.value) {
1471
+ showPanelColor.value = true;
1472
+ }
1241
1473
  }
1242
- });
1243
- watch(() => [props.colorFormat, props.showAlpha], () => {
1244
- color.enableAlpha = props.showAlpha;
1245
- color.format = props.colorFormat || color.format;
1246
- color.doOnChange();
1247
- emit(UPDATE_MODEL_EVENT, color.value);
1248
- });
1249
- watch(() => currentColor.value, (val) => {
1250
- customInput.value = val;
1251
- shouldActiveChange && emit("activeChange", val);
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(() => showPicker.value, () => {
1260
- nextTick(() => {
1261
- var _a, _b, _c;
1262
- (_a = hue.value) == null ? void 0 : _a.update();
1263
- (_b = sv.value) == null ? void 0 : _b.update();
1264
- (_c = alpha.value) == null ? void 0 : _c.update();
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"), unref(ns).b("dropdown"), _ctx.popperClass],
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
- onHide: ($event) => setShowPicker(false)
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(), createElementBlock("div", {
1297
- onKeydown: withKeys(handleEsc, ["esc"])
1298
- }, [
1299
- createElementVNode("div", {
1300
- class: normalizeClass(unref(ns).be("dropdown", "main-wrapper"))
1301
- }, [
1302
- createVNode(HueSlider, {
1303
- ref_key: "hue",
1304
- ref: hue,
1305
- class: "hue-slider",
1306
- color: unref(color),
1307
- vertical: ""
1308
- }, null, 8, ["color"]),
1309
- createVNode(SvPanel, {
1310
- ref_key: "sv",
1311
- ref: sv,
1312
- color: unref(color)
1313
- }, null, 8, ["color"])
1314
- ], 2),
1315
- _ctx.showAlpha ? (openBlock(), createBlock(AlphaSlider, {
1316
- key: 0,
1317
- ref_key: "alpha",
1318
- ref: alpha,
1319
- color: unref(color)
1320
- }, null, 8, ["color"])) : createCommentVNode("v-if", true),
1321
- _ctx.predefine ? (openBlock(), createBlock(Predefine, {
1322
- key: 1,
1323
- ref: "predefine",
1324
- "enable-alpha": _ctx.showAlpha,
1325
- color: unref(color),
1326
- colors: _ctx.predefine
1327
- }, null, 8, ["enable-alpha", "color", "colors"])) : createCommentVNode("v-if", true),
1328
- createElementVNode("div", {
1329
- class: normalizeClass(unref(ns).be("dropdown", "btns"))
1330
- }, [
1331
- createElementVNode("span", {
1332
- class: normalizeClass(unref(ns).be("dropdown", "value"))
1333
- }, [
1334
- createVNode(unref(ElInput), {
1335
- ref_key: "inputRef",
1336
- ref: inputRef,
1337
- modelValue: customInput.value,
1338
- "onUpdate:modelValue": ($event) => customInput.value = $event,
1339
- "validate-event": false,
1340
- size: "small",
1341
- onKeyup: withKeys(handleConfirm, ["enter"]),
1342
- onBlur: handleConfirm
1343
- }, null, 8, ["modelValue", "onUpdate:modelValue", "onKeyup"])
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: unref(btnKls),
1582
+ class: btnKls.value,
1379
1583
  role: "button",
1380
- "aria-label": unref(buttonAriaLabel),
1381
- "aria-labelledby": unref(buttonAriaLabelledby),
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) ? -1 : _ctx.tabindex,
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
- unref(colorDisabled) ? (openBlock(), createElementBlock("div", {
1390
- key: 0,
1391
- class: normalizeClass(unref(ns).be("picker", "mask"))
1392
- }, null, 2)) : createCommentVNode("v-if", true),
1393
- createElementVNode("div", {
1394
- class: normalizeClass(unref(ns).be("picker", "trigger")),
1395
- onClick: handleTrigger
1396
- }, [
1397
- createElementVNode("span", {
1398
- class: normalizeClass([unref(ns).be("picker", "color"), unref(ns).is("alpha", _ctx.showAlpha)])
1399
- }, [
1400
- createElementVNode("span", {
1401
- class: normalizeClass(unref(ns).be("picker", "color-inner")),
1402
- style: normalizeStyle({
1403
- backgroundColor: unref(displayedColor)
1404
- })
1405
- }, [
1406
- withDirectives(createVNode(unref(ElIcon), {
1407
- class: normalizeClass([unref(ns).be("picker", "icon"), unref(ns).is("icon-arrow-down")])
1408
- }, {
1409
- default: withCtx(() => [
1410
- createVNode(unref(arrow_down_default))
1411
- ]),
1412
- _: 1
1413
- }, 8, ["class"]), [
1414
- [vShow, _ctx.modelValue || showPanelColor.value]
1415
- ]),
1416
- withDirectives(createVNode(unref(ElIcon), {
1417
- class: normalizeClass([unref(ns).be("picker", "empty"), unref(ns).is("icon-close")])
1418
- }, {
1419
- default: withCtx(() => [
1420
- createVNode(unref(close_default))
1421
- ]),
1422
- _: 1
1423
- }, 8, ["class"]), [
1424
- [vShow, !_ctx.modelValue && !showPanelColor.value]
1425
- ])
1426
- ], 6)
1427
- ], 2)
1428
- ], 2)
1429
- ], 16, ["id", "aria-label", "aria-labelledby", "aria-description", "aria-disabled", "tabindex", "onFocus", "onBlur"])
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", "onHide"]);
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 __default__$c = defineComponent({
1439
- name: "ElContainer"
1440
- });
1441
- const _sfc_main$q = /* @__PURE__ */ defineComponent({
1442
- ...__default__$c,
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("section", {
1470
- class: normalizeClass([unref(ns).b(), unref(ns).is("vertical", unref(isVertical))])
1471
- }, [
1472
- renderSlot(_ctx.$slots, "default")
1473
- ], 2);
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 __default__$b = defineComponent({
1479
- name: "ElAside"
1480
- });
1481
- const _sfc_main$p = /* @__PURE__ */ defineComponent({
1482
- ...__default__$b,
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(() => props.width ? ns.cssVarBlock({ width: props.width }) : {});
1713
+ const style = computed(
1714
+ () => props.width ? ns.cssVarBlock({ width: props.width }) : {}
1715
+ );
1493
1716
  return (_ctx, _cache) => {
1494
- return openBlock(), createElementBlock("aside", {
1495
- class: normalizeClass(unref(ns).b()),
1496
- style: normalizeStyle(unref(style))
1497
- }, [
1498
- renderSlot(_ctx.$slots, "default")
1499
- ], 6);
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 __default__$a = defineComponent({
1505
- name: "ElFooter"
1506
- });
1507
- const _sfc_main$o = /* @__PURE__ */ defineComponent({
1508
- ...__default__$a,
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(() => props.height ? ns.cssVarBlock({ height: props.height }) : {});
1746
+ const style = computed(
1747
+ () => props.height ? ns.cssVarBlock({ height: props.height }) : {}
1748
+ );
1519
1749
  return (_ctx, _cache) => {
1520
- return openBlock(), createElementBlock("footer", {
1521
- class: normalizeClass(unref(ns).b()),
1522
- style: normalizeStyle(unref(style))
1523
- }, [
1524
- renderSlot(_ctx.$slots, "default")
1525
- ], 6);
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 __default__$9 = defineComponent({
1531
- name: "ElHeader"
1532
- });
1533
- const _sfc_main$n = /* @__PURE__ */ defineComponent({
1534
- ...__default__$9,
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("header", {
1551
- class: normalizeClass(unref(ns).b()),
1552
- style: normalizeStyle(unref(style))
1553
- }, [
1554
- renderSlot(_ctx.$slots, "default")
1555
- ], 6);
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 __default__$8 = defineComponent({
1561
- name: "ElMain"
1562
- });
1563
- const _sfc_main$m = /* @__PURE__ */ defineComponent({
1564
- ...__default__$8,
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("main", {
1569
- class: normalizeClass(unref(ns).b())
1570
- }, [
1571
- renderSlot(_ctx.$slots, "default")
1572
- ], 2);
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 __default__$7 = defineComponent({
1604
- name: "ElDivider"
1605
- });
1606
- const _sfc_main$l = /* @__PURE__ */ defineComponent({
1607
- ...__default__$7,
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("div", {
1619
- class: normalizeClass([unref(ns).b(), unref(ns).m(_ctx.direction)]),
1620
- style: normalizeStyle(unref(dividerStyle)),
1621
- role: "separator"
1622
- }, [
1623
- _ctx.$slots.default && _ctx.direction !== "vertical" ? (openBlock(), createElementBlock("div", {
1624
- key: 0,
1625
- class: normalizeClass([unref(ns).e("text"), unref(ns).is(_ctx.contentPosition)])
1626
- }, [
1627
- renderSlot(_ctx.$slots, "default")
1628
- ], 2)) : createCommentVNode("v-if", true)
1629
- ], 6);
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 (event.code) {
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 (event.code) {
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 __default__$6 = defineComponent({
1757
- name: "ElMenuCollapseTransition"
1758
- });
1759
- const _sfc_main$k = /* @__PURE__ */ defineComponent({
1760
- ...__default__$6,
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(Transition, mergeProps({ mode: "out-in" }, unref(listeners)), {
1798
- default: withCtx(() => [
1799
- renderSlot(_ctx.$slots, "default")
1800
- ]),
1801
- _: 3
1802
- }, 16);
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(() => ns.cssVarBlock({
1841
- "text-color": props.textColor || "",
1842
- "hover-text-color": props.textColor || "",
1843
- "bg-color": props.backgroundColor || "",
1844
- "hover-bg-color": useMenuColor(props).value || "",
1845
- "active-color": props.activeTextColor || "",
1846
- level: `${level}`
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(instance, computed(() => props.index));
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("rootMenu");
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(`subMenu:${parentMenu.value.uid}`);
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 currentPlacement = computed(() => mode.value === "horizontal" && isFirstLevel.value ? "bottom-start" : "right-start");
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
- return mode.value === "horizontal" && isFirstLevel.value || mode.value === "vertical" && !rootMenu.props.collapse ? props.expandCloseIcon && props.expandOpenIcon ? opened.value ? props.expandOpenIcon : props.expandCloseIcon : arrow_down_default : props.collapseCloseIcon && props.collapseOpenIcon ? opened.value ? props.collapseOpenIcon : props.collapseCloseIcon : arrow_right_default;
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 === void 0 ? isFirstLevel.value : value;
2191
+ return isUndefined(value) ? isFirstLevel.value : value;
1905
2192
  });
1906
- const menuTransitionName = computed(() => rootMenu.props.collapse ? `${nsMenu.namespace.value}-zoom-in-left` : `${nsMenu.namespace.value}-zoom-in-top`);
1907
- const fallbackPlacements = computed(() => mode.value === "horizontal" && isFirstLevel.value ? [
1908
- "bottom-start",
1909
- "bottom-end",
1910
- "top-start",
1911
- "top-end",
1912
- "right-start",
1913
- "left-start"
1914
- ] : [
1915
- "right-start",
1916
- "right",
1917
- "right-end",
1918
- "left-start",
1919
- "bottom-start",
1920
- "bottom-end",
1921
- "top-start",
1922
- "top-end"
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(() => [...Object.values(items.value), ...Object.values(subMenus.value)].some(({ active: active2 }) => active2));
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
- var _a;
1936
- return (_a = props.popperOffset) != null ? _a : rootMenu.props.popperOffset;
1937
- });
1938
- const subMenuPopperClass = computed(() => {
1939
- var _a;
1940
- return (_a = props.popperClass) != null ? _a : rootMenu.props.popperClass;
1941
- });
1942
- const subMenuShowTimeout = computed(() => {
1943
- var _a;
1944
- return (_a = props.showTimeout) != null ? _a : rootMenu.props.showTimeout;
1945
- });
1946
- const subMenuHideTimeout = computed(() => {
1947
- var _a;
1948
- return (_a = props.hideTimeout) != null ? _a : rootMenu.props.hideTimeout;
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(() => !mouseInChild.value && rootMenu.closeMenu(props.index, indexPath.value), subMenuHideTimeout.value));
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(() => rootMenu.props.collapse, (value) => handleCollapseToggle(Boolean(value)));
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(`subMenu:${instance.uid}`, {
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(ElIcon, {
2030
- class: nsSubMenu.e("icon-arrow"),
2031
- style: {
2032
- transform: opened.value ? props.expandCloseIcon && props.expandOpenIcon || props.collapseCloseIcon && props.collapseOpenIcon && rootMenu.props.collapse ? "none" : "rotateZ(180deg)" : "none"
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(ElTooltip, {
2039
- ref: vPopper,
2040
- visible: opened.value,
2041
- effect: "light",
2042
- pure: true,
2043
- offset: subMenuPopperOffset.value,
2044
- showArrow: false,
2045
- persistent: persistent.value,
2046
- popperClass: subMenuPopperClass.value,
2047
- placement: currentPlacement.value,
2048
- teleported: appendToBody.value,
2049
- fallbackPlacements: fallbackPlacements.value,
2050
- transition: menuTransitionName.value,
2051
- gpuAcceleration: false
2052
- }, {
2053
- content: () => {
2054
- var _a2;
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
- default: () => h("div", {
2076
- class: nsSubMenu.e("title"),
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 withDirectives(h("ul", {
2089
- role: "menu",
2090
- class: [nsMenu.b(), nsMenu.m("inline")],
2091
- style: ulStyle.value
2092
- }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)]), [[vShow, opened.value]]);
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("li", {
2097
- class: [
2098
- nsSubMenu.b(),
2099
- nsSubMenu.is("active", active.value),
2100
- nsSubMenu.is("opened", opened.value),
2101
- nsSubMenu.is("disabled", props.disabled)
2102
- ],
2103
- role: "menuitem",
2104
- ariaHaspopup: true,
2105
- ariaExpanded: opened.value,
2106
- onMouseenter: handleMouseenter,
2107
- onMouseleave: () => handleMouseleave(),
2108
- onFocus: handleMouseenter
2109
- }, [child]);
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: () => more_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 === void 0 || routerResult instanceof Promise)
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(props.defaultOpeneds && !props.collapse ? props.defaultOpeneds.slice(0) : []);
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(() => props.mode === "horizontal" || props.mode === "vertical" && props.collapse);
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 subMenu = subMenus.value[index2];
2202
- subMenu && openMenu(index2, subMenu.indexPath);
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((index22) => indexPath.includes(index22));
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("select", index2, indexPath, { index: index2, indexPath, route }, routerResult);
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((_b = (_a = menu.value) == null ? void 0 : _a.childNodes) != null ? _b : []).filter((item) => item.nodeName !== "#text" || item.nodeValue);
2268
- const moreItemWidth = 64;
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 timmer;
2663
+ let timer;
2288
2664
  return () => {
2289
- timmer && clearTimeout(timmer);
2290
- timmer = setTimeout(() => {
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(() => props.defaultActive, (currentActive) => {
2309
- if (!items.value[currentActive]) {
2310
- activeIndex.value = "";
2687
+ watch(
2688
+ () => props.defaultActive,
2689
+ (currentActive) => {
2690
+ if (!items.value[currentActive]) {
2691
+ activeIndex.value = "";
2692
+ }
2693
+ updateActiveIndex(currentActive);
2311
2694
  }
2312
- updateActiveIndex(currentActive);
2313
- });
2314
- watch(() => props.collapse, (value) => {
2315
- if (value)
2316
- openedMenus.value = [];
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("rootMenu", reactive({
2341
- props,
2342
- openedMenus,
2343
- items,
2344
- subMenus,
2345
- activeIndex,
2346
- isMenuPopup,
2347
- addMenuItem,
2348
- removeMenuItem,
2349
- addSubMenu,
2350
- removeSubMenu,
2351
- openMenu,
2352
- closeMenu,
2353
- handleMenuItemClick,
2354
- handleSubMenuClick
2355
- }));
2356
- provide(`subMenu:${instance.uid}`, {
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(h(SubMenu2, {
2391
- index: "sub-menu-more",
2392
- class: nsSubMenu.e("hide-arrow"),
2393
- popperOffset: props.popperOffset
2394
- }, {
2395
- title: () => h(ElIcon, {
2396
- class: nsSubMenu.e("icon-more")
2397
- }, {
2398
- default: () => h(props.ellipsisIcon)
2399
- }),
2400
- default: () => slotMore
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((openedMenu) => emit("close", openedMenu, getIndexPath(openedMenu)));
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(h("ul", {
2418
- key: String(props.collapse),
2419
- role: "menubar",
2420
- ref: menu,
2421
- style: ulStyle.value,
2422
- class: {
2423
- [nsMenu.b()]: true,
2424
- [nsMenu.m(props.mode)]: true,
2425
- [nsMenu.m("collapse")]: props.collapse
2426
- }
2427
- }, [...slot, ...vShowMore]), directives);
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 __default__$5 = defineComponent({
2450
- name: COMPONENT_NAME
2451
- });
2452
- const _sfc_main$j = /* @__PURE__ */ defineComponent({
2453
- ...__default__$5,
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("rootMenu");
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(`subMenu:${parentMenu.value.uid}`);
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
- expose({
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("li", {
2502
- class: normalizeClass([
2503
- unref(nsMenuItem).b(),
2504
- unref(nsMenuItem).is("active", unref(active)),
2505
- unref(nsMenuItem).is("disabled", _ctx.disabled)
2506
- ]),
2507
- role: "menuitem",
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
- _: 3
2529
- }, 8, ["effect", "persistent"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2530
- renderSlot(_ctx.$slots, "default"),
2531
- renderSlot(_ctx.$slots, "title")
2532
- ], 64))
2533
- ], 2);
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 __default__$4 = defineComponent({
2542
- name: "ElMenuItemGroup"
2543
- });
2544
- const _sfc_main$i = /* @__PURE__ */ defineComponent({
2545
- ...__default__$4,
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("li", {
2551
- class: normalizeClass(unref(ns).b())
2552
- }, [
2553
- createElementVNode("div", {
2554
- class: normalizeClass(unref(ns).e("title"))
2555
- }, [
2556
- !_ctx.$slots.title ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2557
- createTextVNode(toDisplayString(_ctx.title), 1)
2558
- ], 64)) : renderSlot(_ctx.$slots, "title", { key: 1 })
2559
- ], 2),
2560
- createElementVNode("ul", null, [
2561
- renderSlot(_ctx.$slots, "default")
2562
- ])
2563
- ], 2);
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(sunny_default),
2788
- "inactive-icon": unref(moon_default),
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": _ctx.isShowCustomTabs
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": _ctx.isShowCustomTabs
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(_ctx.menuList, (subItem) => {
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(arrow_right_default)
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
  }