lew-ui 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { h as h$1, defineComponent, openBlock, createBlock, resolveDynamicComponent, normalizeClass, normalizeStyle, unref, createApp, computed, createElementBlock, renderSlot, getCurrentScope, onScopeDispose, toRef as toRef$1, readonly, customRef, ref, onMounted, nextTick, getCurrentInstance, shallowRef, watch, toRefs, mergeModels, useModel, reactive, withCtx, createElementVNode, createVNode, Transition, createCommentVNode, withModifiers, withDirectives, toDisplayString, vShow, Fragment, renderList, createTextVNode, resolveComponent, resolveDirective, isRef, vModelText, mergeProps, createSlots, onUnmounted, vModelDynamic, watchEffect, TransitionGroup, toRaw, vModelCheckbox, onActivated, normalizeProps, guardReactiveProps, Teleport, provide, inject } from "vue";
1
+ import { h as h$1, defineComponent, openBlock, createBlock, resolveDynamicComponent, normalizeClass, normalizeStyle, unref, createApp, computed, createElementBlock, renderSlot, getCurrentScope, onScopeDispose, toRef as toRef$1, readonly, customRef, ref, onMounted, nextTick, getCurrentInstance, shallowRef, watch, toRefs, mergeModels, useModel, reactive, withCtx, createElementVNode, createVNode, Transition, createCommentVNode, withModifiers, withDirectives, toDisplayString, vShow, Fragment, renderList, createTextVNode, resolveDirective, isRef, vModelText, mergeProps, createSlots, onUnmounted, vModelDynamic, watchEffect, TransitionGroup, resolveComponent, toRaw, vModelCheckbox, onActivated, normalizeProps, guardReactiveProps, Teleport, provide, inject } from "vue";
2
2
  const flexProps = {
3
3
  direction: {
4
4
  type: String,
@@ -4330,7 +4330,6 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
4330
4330
  };
4331
4331
  __expose({ init, getTreeList });
4332
4332
  return (_ctx, _cache) => {
4333
- const _component_lew_checkbox = resolveComponent("lew-checkbox");
4334
4333
  const _directive_loading = resolveDirective("loading");
4335
4334
  return withDirectives((openBlock(), createElementBlock("div", {
4336
4335
  style: normalizeStyle({
@@ -4382,7 +4381,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
4382
4381
  onClick: ($event) => select(item)
4383
4382
  }, [
4384
4383
  item.level > 0 && _ctx.showLine ? (openBlock(), createElementBlock("div", _hoisted_3$o)) : createCommentVNode("", true),
4385
- _ctx.showCheckbox ? (openBlock(), createBlock(_component_lew_checkbox, {
4384
+ _ctx.showCheckbox ? (openBlock(), createBlock(unref(LewCheckbox), {
4386
4385
  key: 1,
4387
4386
  certain: _ctx.multiple && unref(certainKeys).includes(item.key) && !(modelValue.value || []).includes(item.key),
4388
4387
  checked: _ctx.multiple ? (modelValue.value || []).includes(item.key) : modelValue.value === item.key,
@@ -4412,7 +4411,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
4412
4411
  };
4413
4412
  }
4414
4413
  });
4415
- const LewTree = /* @__PURE__ */ _export_sfc(_sfc_main$V, [["__scopeId", "data-v-4157bf8d"]]);
4414
+ const LewTree = /* @__PURE__ */ _export_sfc(_sfc_main$V, [["__scopeId", "data-v-39cc6823"]]);
4416
4415
  function tryOnScopeDispose(fn2) {
4417
4416
  if (getCurrentScope()) {
4418
4417
  onScopeDispose(fn2);
@@ -5563,7 +5562,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
5563
5562
  };
5564
5563
  }
5565
5564
  });
5566
- const LewTreeSelect = /* @__PURE__ */ _export_sfc(_sfc_main$U, [["__scopeId", "data-v-ddff40e4"]]);
5565
+ const LewTreeSelect = /* @__PURE__ */ _export_sfc(_sfc_main$U, [["__scopeId", "data-v-e7e4d91d"]]);
5567
5566
  const tabsModel = {
5568
5567
  modelValue: {
5569
5568
  type: [String, Number],
@@ -6117,7 +6116,6 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
6117
6116
  setup(__props) {
6118
6117
  const stepsValue = useModel(__props, "modelValue");
6119
6118
  return (_ctx, _cache) => {
6120
- const _component_lew_text_trim = resolveComponent("lew-text-trim");
6121
6119
  return openBlock(), createElementBlock("div", _hoisted_1$B, [
6122
6120
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (item, index2) => {
6123
6121
  return openBlock(), createElementBlock("div", {
@@ -6157,13 +6155,13 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
6157
6155
  ]),
6158
6156
  createElementVNode("div", _hoisted_4$d, [
6159
6157
  createElementVNode("div", _hoisted_5$9, [
6160
- createVNode(_component_lew_text_trim, {
6158
+ createVNode(unref(LewTextTrim), {
6161
6159
  placement: "bottom",
6162
6160
  text: item.title
6163
6161
  }, null, 8, ["text"])
6164
6162
  ]),
6165
6163
  createElementVNode("div", _hoisted_6$7, [
6166
- createVNode(_component_lew_text_trim, {
6164
+ createVNode(unref(LewTextTrim), {
6167
6165
  allowHTML: "",
6168
6166
  lineClamp: 2,
6169
6167
  placement: "bottom",
@@ -10125,11 +10123,11 @@ const radioProps = {
10125
10123
  size: {
10126
10124
  type: String,
10127
10125
  default: "medium",
10128
- description: "单选框尺寸",
10129
- validator(value) {
10126
+ description: "复选框组中复选框的尺寸",
10127
+ validator: (value) => {
10130
10128
  if (!validSizes.includes(value)) {
10131
10129
  console.warn(
10132
- `[LewRadio] 无效的尺寸: ${value}。请使用 ${validSizes.join(", ")} 中的一个。`
10130
+ '[LewRadio] 无效的 size 值,请使用 "small"、"medium" "large"'
10133
10131
  );
10134
10132
  return false;
10135
10133
  }
@@ -10158,13 +10156,10 @@ const radioGroupProps = {
10158
10156
  direction: {
10159
10157
  type: String,
10160
10158
  default: "x",
10161
- description: "排列方向",
10162
- validator(value) {
10163
- const validDirections = ["x", "y"];
10164
- if (!validDirections.includes(value)) {
10165
- console.warn(
10166
- `[LewRadioGroup] 无效的排列方向: ${value}。请使用 ${validDirections.join(", ")} 中的一个。`
10167
- );
10159
+ description: "复选框组的排列方向",
10160
+ validator: (value) => {
10161
+ if (!validDirection.includes(value)) {
10162
+ console.warn('[LewRadioGroup] 无效的 direction 值,请使用 "x" 或 "y"');
10168
10163
  return false;
10169
10164
  }
10170
10165
  return true;
@@ -10198,11 +10193,11 @@ const radioGroupProps = {
10198
10193
  size: {
10199
10194
  type: String,
10200
10195
  default: "medium",
10201
- description: "单选框组尺寸",
10202
- validator(value) {
10196
+ description: "复选框组中复选框的尺寸",
10197
+ validator: (value) => {
10203
10198
  if (!validSizes.includes(value)) {
10204
10199
  console.warn(
10205
- `[LewRadioGroup] 无效的尺寸: ${value}。请使用 ${validSizes.join(", ")} 中的一个。`
10200
+ '[LewRadioGroup] 无效的 size 值,请使用 "small"、"medium" "large"'
10206
10201
  );
10207
10202
  return false;
10208
10203
  }
@@ -10595,8 +10590,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
10595
10590
  );
10596
10591
  __expose({ show, hide: hide2 });
10597
10592
  return (_ctx, _cache) => {
10598
- const _component_lew_empty = resolveComponent("lew-empty");
10599
- const _component_lew_text_trim = resolveComponent("lew-text-trim");
10600
10593
  return openBlock(), createBlock(unref(_sfc_main$k), {
10601
10594
  ref_key: "lewPopoverRef",
10602
10595
  ref: lewPopoverRef,
@@ -10665,7 +10658,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
10665
10658
  class: "lew-not-found"
10666
10659
  }, {
10667
10660
  default: withCtx(() => [
10668
- createVNode(_component_lew_empty, { title: "暂无结果" })
10661
+ createVNode(unref(_sfc_main$d), { title: "暂无结果" })
10669
10662
  ]),
10670
10663
  _: 1
10671
10664
  }))
@@ -10695,7 +10688,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
10695
10688
  key: 1,
10696
10689
  class: normalizeClass(["lew-select-item", getSelectItemClassName(templateProps)])
10697
10690
  }, [
10698
- createVNode(_component_lew_text_trim, {
10691
+ createVNode(unref(LewTextTrim), {
10699
10692
  text: templateProps.label,
10700
10693
  delay: [500, 0],
10701
10694
  class: "lew-select-label"
@@ -10720,7 +10713,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
10720
10713
  };
10721
10714
  }
10722
10715
  });
10723
- const LewSelect = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-2a4af6cb"]]);
10716
+ const LewSelect = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-aba2a338"]]);
10724
10717
  const selectMultipleModel = {
10725
10718
  modelValue: {
10726
10719
  type: Array,
@@ -10998,11 +10991,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
10998
10991
  });
10999
10992
  __expose({ show, hide: hide2 });
11000
10993
  return (_ctx, _cache) => {
11001
- const _component_lew_tag = resolveComponent("lew-tag");
11002
- const _component_lew_flex = resolveComponent("lew-flex");
11003
10994
  const _component_lew_empty = resolveComponent("lew-empty");
11004
- const _component_lew_checkbox = resolveComponent("lew-checkbox");
11005
- const _component_lew_text_trim = resolveComponent("lew-text-trim");
11006
10995
  return openBlock(), createBlock(unref(_sfc_main$k), {
11007
10996
  ref_key: "lewPopoverRef",
11008
10997
  ref: lewPopoverRef,
@@ -11045,7 +11034,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
11045
11034
  _: 1
11046
11035
  }),
11047
11036
  unref(getLabels) && unref(getLabels).length > 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
11048
- _ctx.valueLayout === "tag" ? (openBlock(), createBlock(_component_lew_flex, {
11037
+ _ctx.valueLayout === "tag" ? (openBlock(), createBlock(unref(LewFlex), {
11049
11038
  key: 0,
11050
11039
  style: { "padding": "5px" },
11051
11040
  x: "start",
@@ -11058,7 +11047,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
11058
11047
  createVNode(TransitionGroup, { name: "list" }, {
11059
11048
  default: withCtx(() => [
11060
11049
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(getLabels), (item, index2) => {
11061
- return openBlock(), createBlock(_component_lew_tag, {
11050
+ return openBlock(), createBlock(unref(_sfc_main$o), {
11062
11051
  key: index2,
11063
11052
  type: "light",
11064
11053
  size: _ctx.size,
@@ -11090,7 +11079,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
11090
11079
  createElementVNode("div", _hoisted_1$t, toDisplayString(unref(getLabels).join(_ctx.valueTextSplit)), 1)
11091
11080
  ]),
11092
11081
  "popover-body": withCtx(() => [
11093
- createVNode(_component_lew_flex, {
11082
+ createVNode(unref(LewFlex), {
11094
11083
  x: "start",
11095
11084
  y: "center",
11096
11085
  gap: 5,
@@ -11100,7 +11089,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
11100
11089
  }, {
11101
11090
  default: withCtx(() => [
11102
11091
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(getLabels), (item, index2) => {
11103
- return openBlock(), createBlock(_component_lew_tag, {
11092
+ return openBlock(), createBlock(unref(_sfc_main$o), {
11104
11093
  key: index2,
11105
11094
  type: "light",
11106
11095
  size: _ctx.size,
@@ -11145,7 +11134,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
11145
11134
  ])) : createCommentVNode("", true),
11146
11135
  createElementVNode("div", _hoisted_3$g, [
11147
11136
  unref(state).options && unref(state).options.length === 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
11148
- _ctx.$slots.empty ? renderSlot(_ctx.$slots, "empty", { key: 0 }, void 0, true) : (openBlock(), createBlock(_component_lew_flex, {
11137
+ _ctx.$slots.empty ? renderSlot(_ctx.$slots, "empty", { key: 0 }, void 0, true) : (openBlock(), createBlock(unref(LewFlex), {
11149
11138
  key: 1,
11150
11139
  direction: "y",
11151
11140
  class: "lew-not-found"
@@ -11182,12 +11171,12 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
11182
11171
  key: 1,
11183
11172
  class: normalizeClass(["lew-select-item lew-select-item-mul", getSelectItemClassName(templateProps)])
11184
11173
  }, [
11185
- (openBlock(), createBlock(_component_lew_checkbox, {
11174
+ (openBlock(), createBlock(unref(LewCheckbox), {
11186
11175
  key: templateProps.value,
11187
11176
  class: "lew-select-checkbox",
11188
11177
  checked: unref(getChecked)(templateProps.value)
11189
11178
  }, null, 8, ["checked"])),
11190
- createVNode(_component_lew_text_trim, {
11179
+ createVNode(unref(LewTextTrim), {
11191
11180
  text: templateProps.label,
11192
11181
  delay: [500, 0],
11193
11182
  class: "lew-select-label"
@@ -11206,7 +11195,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
11206
11195
  };
11207
11196
  }
11208
11197
  });
11209
- const LewSelectMultiple = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-f0df7603"]]);
11198
+ const LewSelectMultiple = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-3ebc2970"]]);
11210
11199
  const switchModel = {
11211
11200
  modelValue: {
11212
11201
  type: Boolean,
@@ -14655,7 +14644,6 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
14655
14644
  return styleObj;
14656
14645
  });
14657
14646
  return (_ctx, _cache) => {
14658
- const _component_lew_text_trim = resolveComponent("lew-text-trim");
14659
14647
  return openBlock(), createElementBlock("div", {
14660
14648
  class: normalizeClass(["lew-tag", unref(tagClassName)]),
14661
14649
  style: normalizeStyle(unref(getStyle))
@@ -14664,10 +14652,10 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
14664
14652
  renderSlot(_ctx.$slots, "left")
14665
14653
  ]),
14666
14654
  createElementVNode("div", _hoisted_2$b, [
14667
- _ctx.text ? (openBlock(), createBlock(_component_lew_text_trim, {
14655
+ _ctx.text ? (openBlock(), createBlock(unref(LewTextTrim), {
14668
14656
  key: 0,
14669
14657
  text: _ctx.text
14670
- }, null, 8, ["text"])) : (openBlock(), createBlock(_component_lew_text_trim, { key: 1 }, {
14658
+ }, null, 8, ["text"])) : (openBlock(), createBlock(unref(LewTextTrim), { key: 1 }, {
14671
14659
  default: withCtx(() => [
14672
14660
  renderSlot(_ctx.$slots, "default")
14673
14661
  ]),
@@ -19377,13 +19365,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19377
19365
  }
19378
19366
  });
19379
19367
  return (_ctx, _cache) => {
19380
- const _component_lew_flex = resolveComponent("lew-flex");
19381
- const _component_lew_alert = resolveComponent("lew-alert");
19382
- const _component_lew_image = resolveComponent("lew-image");
19383
- const _component_lew_text_trim = resolveComponent("lew-text-trim");
19384
- const _component_lew_tag = resolveComponent("lew-tag");
19385
19368
  const _directive_tooltip = resolveDirective("tooltip");
19386
- return openBlock(), createBlock(_component_lew_flex, {
19369
+ return openBlock(), createBlock(unref(LewFlex), {
19387
19370
  class: "lew-upload-wrapper",
19388
19371
  direction: "y",
19389
19372
  gap: "10"
@@ -19401,7 +19384,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19401
19384
  class: normalizeClass(["lew-upload-label", unref(getUploadLabelClass)]),
19402
19385
  style: { "width": "100%" }
19403
19386
  }, [
19404
- createVNode(_component_lew_flex, {
19387
+ createVNode(unref(LewFlex), {
19405
19388
  ref_key: "dropRef",
19406
19389
  ref: dropRef,
19407
19390
  direction: "y",
@@ -19456,12 +19439,12 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19456
19439
  ], 34), [
19457
19440
  [vShow, (modelValue.value || []).length < _ctx.limit]
19458
19441
  ]),
19459
- !unref(isFunction)(_ctx.uploadHelper) ? (openBlock(), createBlock(_component_lew_alert, {
19442
+ !unref(isFunction)(_ctx.uploadHelper) ? (openBlock(), createBlock(unref(LewAlert), {
19460
19443
  key: 0,
19461
19444
  type: "error",
19462
19445
  title: "uploadHelper Error: 未配置上传方法"
19463
19446
  })) : createCommentVNode("", true),
19464
- withDirectives(createVNode(_component_lew_flex, {
19447
+ withDirectives(createVNode(unref(LewFlex), {
19465
19448
  direction: "y",
19466
19449
  class: "lew-upload-file-list",
19467
19450
  gap: "10"
@@ -19470,7 +19453,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19470
19453
  createVNode(TransitionGroup, { name: "upload-list" }, {
19471
19454
  default: withCtx(() => [
19472
19455
  (openBlock(true), createElementBlock(Fragment, null, renderList(modelValue.value, (item) => {
19473
- return openBlock(), createBlock(_component_lew_flex, {
19456
+ return openBlock(), createBlock(unref(LewFlex), {
19474
19457
  key: item.id,
19475
19458
  class: "lew-upload-file-item",
19476
19459
  mode: "between",
@@ -19480,7 +19463,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19480
19463
  })
19481
19464
  }, {
19482
19465
  default: withCtx(() => [
19483
- createVNode(_component_lew_flex, {
19466
+ createVNode(unref(LewFlex), {
19484
19467
  style: normalizeStyle({
19485
19468
  width: `${fileIconSizeMap[_ctx.size]}px`,
19486
19469
  height: `${fileIconSizeMap[_ctx.size]}px`
@@ -19488,7 +19471,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19488
19471
  class: "lew-upload-icon-wrapper"
19489
19472
  }, {
19490
19473
  default: withCtx(() => [
19491
- checkUrlIsImg(item.url) ? (openBlock(), createBlock(_component_lew_image, {
19474
+ checkUrlIsImg(item.url) ? (openBlock(), createBlock(unref(LewImage), {
19492
19475
  key: 0,
19493
19476
  class: "lew-upload-file-image",
19494
19477
  src: item.url
@@ -19500,14 +19483,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19500
19483
  ]),
19501
19484
  _: 2
19502
19485
  }, 1032, ["style"]),
19503
- createVNode(_component_lew_flex, {
19486
+ createVNode(unref(LewFlex), {
19504
19487
  class: "lew-upload-file-info",
19505
19488
  style: normalizeStyle({ width: `calc(100% - ${fileIconSizeMap[_ctx.size]}px - 8px)` }),
19506
19489
  direction: "y",
19507
19490
  gap: "0"
19508
19491
  }, {
19509
19492
  default: withCtx(() => [
19510
- item.status === "fail" ? withDirectives((openBlock(), createBlock(_component_lew_flex, {
19493
+ item.status === "fail" ? withDirectives((openBlock(), createBlock(unref(LewFlex), {
19511
19494
  key: 0,
19512
19495
  onClick: withModifiers(($event) => reUpload(item.id), ["stop"]),
19513
19496
  x: "center",
@@ -19532,7 +19515,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19532
19515
  trigger: "mouseenter"
19533
19516
  }]
19534
19517
  ]) : createCommentVNode("", true),
19535
- withDirectives((openBlock(), createBlock(_component_lew_flex, {
19518
+ withDirectives((openBlock(), createBlock(unref(LewFlex), {
19536
19519
  onClick: withModifiers(($event) => deleteFile(item.id), ["stop"]),
19537
19520
  x: "center",
19538
19521
  y: "center",
@@ -19556,19 +19539,19 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19556
19539
  trigger: "mouseenter"
19557
19540
  }]
19558
19541
  ]),
19559
- createVNode(_component_lew_flex, {
19542
+ createVNode(unref(LewFlex), {
19560
19543
  mode: "between",
19561
19544
  gap: "5",
19562
19545
  y: "center"
19563
19546
  }, {
19564
19547
  default: withCtx(() => [
19565
- createVNode(_component_lew_flex, {
19548
+ createVNode(unref(LewFlex), {
19566
19549
  y: "center",
19567
19550
  x: "start",
19568
19551
  gap: "5"
19569
19552
  }, {
19570
19553
  default: withCtx(() => [
19571
- createVNode(_component_lew_text_trim, {
19554
+ createVNode(unref(LewTextTrim), {
19572
19555
  text: unref(getFileName)(item),
19573
19556
  style: normalizeStyle({
19574
19557
  width: `calc(100% - 60px)`,
@@ -19582,12 +19565,12 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19582
19565
  ]),
19583
19566
  _: 2
19584
19567
  }, 1024),
19585
- item.percent ? (openBlock(), createBlock(_component_lew_flex, {
19568
+ item.percent ? (openBlock(), createBlock(unref(LewFlex), {
19586
19569
  key: 1,
19587
19570
  class: normalizeClass(["lew-upload-progress", [`lew-upload-progress-${item.status}`]])
19588
19571
  }, {
19589
19572
  default: withCtx(() => [
19590
- createVNode(_component_lew_flex, {
19573
+ createVNode(unref(LewFlex), {
19591
19574
  y: "center",
19592
19575
  class: "lew-upload-progress-box"
19593
19576
  }, {
@@ -19605,7 +19588,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19605
19588
  ]),
19606
19589
  _: 2
19607
19590
  }, 1032, ["class"])) : createCommentVNode("", true),
19608
- createVNode(_component_lew_flex, {
19591
+ createVNode(unref(LewFlex), {
19609
19592
  mode: "between",
19610
19593
  y: "center",
19611
19594
  class: "lew-upload-footer"
@@ -19621,13 +19604,13 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19621
19604
  ], 64)) : createCommentVNode("", true),
19622
19605
  item.size ? (openBlock(), createElementBlock("span", _hoisted_3$3, toDisplayString(unref(formatBytes)(item.size)), 1)) : createCommentVNode("", true)
19623
19606
  ], 4),
19624
- createVNode(_component_lew_flex, {
19607
+ createVNode(unref(LewFlex), {
19625
19608
  style: { "max-width": "200px" },
19626
19609
  y: "center",
19627
19610
  x: "end"
19628
19611
  }, {
19629
19612
  default: withCtx(() => [
19630
- createVNode(_component_lew_tag, {
19613
+ createVNode(unref(_sfc_main$o), {
19631
19614
  type: "light",
19632
19615
  size: "small",
19633
19616
  color: statusColorMap[item.status || "complete"]
@@ -19672,7 +19655,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
19672
19655
  };
19673
19656
  }
19674
19657
  });
19675
- const LewUpload = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-6b40b74b"]]);
19658
+ const LewUpload = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-6be88b57"]]);
19676
19659
  const collapseModel = {
19677
19660
  modelValue: {
19678
19661
  type: [Array, String],
@@ -24063,937 +24046,936 @@ const components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
24063
24046
  treeSelectProps,
24064
24047
  uploadProps
24065
24048
  }, Symbol.toStringTag, { value: "Module" }));
24066
- const createMessageList$1 = () => {
24067
- const messageContainer = document.createElement("div");
24068
- messageContainer.setAttribute("id", "lew-message");
24069
- document.body.appendChild(messageContainer);
24070
- };
24071
- const showMessage = ({ type, e: e2 }) => {
24072
- const { id, content, duration } = e2;
24073
- const messageContainer = document.getElementById("lew-message");
24074
- const hasMessageById = id ? document.getElementById(`lew-message-id-${id}`) : false;
24075
- const messageElement = hasMessageById || document.createElement("div");
24076
- messageElement.innerHTML = `${getIconInnerHTML({ type, strokeWidth: type === "loading" ? 2.5 : void 0, spinning: type === "loading" })}<div class="lew-message-content">${content || e2}</div>`;
24077
- if (!hasMessageById) {
24078
- if (id) {
24079
- messageElement.setAttribute("id", `lew-message-id-${id}`);
24080
- }
24081
- messageContainer == null ? void 0 : messageContainer.appendChild(
24082
- messageElement,
24083
- messageContainer == null ? void 0 : messageContainer.childNodes[0]
24084
- );
24085
- } else {
24086
- clearTimeout(LewMessage$1.timer[id]);
24087
- }
24088
- messageElement.setAttribute(
24089
- "class",
24090
- `lew-message lew-message-${type} lew-message-id-${id}`
24091
- );
24092
- setTimeout(() => {
24093
- nextTick(() => {
24094
- messageElement.setAttribute(
24095
- "class",
24096
- `lew-message lew-message-${type} lew-message-show`
24097
- );
24098
- LewMessage$1.timer[id] = setTimeout(
24099
- () => {
24100
- messageElement.setAttribute(
24101
- "class",
24102
- `lew-message lew-message-${type} lew-message-hidden`
24103
- );
24104
- setTimeout(() => {
24105
- if (messageElement) messageContainer == null ? void 0 : messageContainer.removeChild(messageElement);
24106
- }, 250);
24107
- },
24108
- duration === 0 ? 31536e6 : duration || 3e3
24109
- );
24049
+ const LewTooltip = {
24050
+ install(app) {
24051
+ app.directive("tooltip", {
24052
+ mounted(el, binding) {
24053
+ var _a;
24054
+ const { trigger, content, placement, allowHTML, delay } = binding.value;
24055
+ let _trigger = trigger;
24056
+ if (trigger === "hover") {
24057
+ _trigger = "mouseenter";
24058
+ }
24059
+ if (!trigger) {
24060
+ _trigger = "mouseenter";
24061
+ }
24062
+ el.instance = tippy(el, {
24063
+ theme: "light",
24064
+ trigger: _trigger,
24065
+ content,
24066
+ animation: "scale",
24067
+ interactive: true,
24068
+ appendTo: () => document.body,
24069
+ placement,
24070
+ allowHTML,
24071
+ arrow: ROUND_ARROW,
24072
+ maxWidth: 250,
24073
+ duration: [250, 250],
24074
+ delay: trigger === "mouseenter" ? delay || [80, 80] : void 0
24075
+ });
24076
+ el.instance.popper.children[0].setAttribute("data-lew", "tooltip");
24077
+ if (!((_a = binding == null ? void 0 : binding.value) == null ? void 0 : _a.content)) {
24078
+ el.instance.disable();
24079
+ }
24080
+ },
24081
+ updated(el, binding) {
24082
+ const { triggerFrom, content } = binding.value;
24083
+ if (!content) {
24084
+ el.instance.disable();
24085
+ } else {
24086
+ el.instance.enable();
24087
+ el.instance.setContent(content);
24088
+ }
24089
+ if (triggerFrom === "input-number") {
24090
+ if (content) {
24091
+ el.instance.show();
24092
+ } else {
24093
+ el.instance.hide();
24094
+ }
24095
+ }
24096
+ },
24097
+ unmounted(el) {
24098
+ el.instance.hide();
24099
+ el.instance = null;
24100
+ }
24110
24101
  });
24111
- }, 10);
24112
- };
24113
- const removeClass = (element, className) => {
24114
- element.classList.remove(className);
24115
- };
24116
- const addClass = (element, className) => {
24117
- element.classList.add(className);
24102
+ }
24118
24103
  };
24119
- const LewMessage$1 = {
24120
- name: "LewMessage",
24121
- message: ({ type, e: e2 }) => {
24122
- if (!document.getElementById("lew-message")) {
24123
- createMessageList$1();
24124
- LewMessage$1.message({ type, e: e2 });
24125
- } else {
24126
- showMessage({ type, e: e2 });
24104
+ const createBackTopHandler = (target) => {
24105
+ const dom = shallowRef(document.documentElement);
24106
+ if (target) {
24107
+ const targetElement = document.querySelector(`.${target}`);
24108
+ if (!targetElement) {
24109
+ throw new Error(`目标元素不存在: ${target}`);
24127
24110
  }
24128
- },
24129
- close: ({ id }) => {
24130
- const messageElement = document.getElementById(`lew-message-id-${id}`);
24131
- if (messageElement) {
24132
- removeClass(messageElement, "lew-message-show");
24133
- addClass(messageElement, "lew-message-hidden");
24134
- setTimeout(() => {
24135
- clearTimeout(LewMessage$1.timer[id]);
24136
- messageElement.remove();
24137
- }, 350);
24111
+ dom.value = targetElement;
24112
+ }
24113
+ return () => {
24114
+ if (dom.value) {
24115
+ dom.value.scrollTo({ top: 0, behavior: "smooth" });
24138
24116
  }
24139
- },
24140
- request: async ({ loadingMessage }, asyncFn) => {
24141
- try {
24142
- LewMessage$1.loading({
24143
- id: "lew-request-loading",
24144
- content: loadingMessage,
24145
- duration: 0
24146
- });
24147
- const startTime = (/* @__PURE__ */ new Date()).getTime();
24148
- asyncFn().then(
24149
- async ({
24150
- content = "请求成功!",
24151
- duration = 3e3,
24152
- type = "success"
24153
- }) => {
24154
- const endTime = (/* @__PURE__ */ new Date()).getTime();
24155
- const delay = 250;
24156
- if (endTime - startTime < delay) {
24157
- await new Promise(
24158
- (resolve) => setTimeout(resolve, delay - (endTime - startTime))
24159
- );
24160
- }
24161
- LewMessage$1.close({ id: "lew-request-loading" });
24162
- LewMessage$1[type]({
24163
- content,
24164
- duration
24165
- });
24117
+ };
24118
+ };
24119
+ const index$1 = {
24120
+ install(app) {
24121
+ app.directive("backtop", {
24122
+ mounted(el, binding) {
24123
+ const backTopHandler = createBackTopHandler(binding.value);
24124
+ el.addEventListener("click", backTopHandler);
24125
+ el._backTopHandler = backTopHandler;
24126
+ },
24127
+ unmounted(el) {
24128
+ if (el._backTopHandler) {
24129
+ el.removeEventListener("click", el._backTopHandler);
24130
+ delete el._backTopHandler;
24166
24131
  }
24167
- ).catch(
24168
- ({
24169
- content = "加载失败!",
24170
- duration = 3e3
24171
- }) => {
24172
- LewMessage$1.close({ id: "lew-request-loading" });
24173
- LewMessage$1.error({
24174
- id: "lew-request-fail",
24175
- content,
24176
- duration
24177
- });
24132
+ }
24133
+ });
24134
+ }
24135
+ };
24136
+ const LewLoading = {
24137
+ install(app) {
24138
+ app.directive("loading", {
24139
+ mounted(el, binding) {
24140
+ const { tip, iconSize, visible } = binding.value;
24141
+ const loadingWrapper = document.createElement("div");
24142
+ const loadingBox = document.createElement("div");
24143
+ loadingWrapper.classList.add("lew-loading-wrapper");
24144
+ loadingBox.classList.add("lew-loading-box");
24145
+ el.classList.add("lew-loading");
24146
+ const loader = createApp(Icon, {
24147
+ type: "loader",
24148
+ spinning: true,
24149
+ size: iconSize || 24
24150
+ });
24151
+ loader.mount(loadingBox);
24152
+ loadingBox.setAttribute("data-after", tip || "");
24153
+ loadingWrapper.appendChild(loadingBox);
24154
+ el.appendChild(loadingWrapper);
24155
+ if (visible) {
24156
+ el.classList.add("lew-loading-show");
24178
24157
  }
24179
- );
24180
- } catch (error2) {
24181
- LewMessage$1.error({
24182
- id: "lew-request-loading",
24183
- content: "An error occurred",
24184
- duration: 3e3,
24185
- onClose: () => {
24158
+ },
24159
+ updated(el, binding) {
24160
+ const { tip, visible } = binding.value;
24161
+ const loadingBox = el.querySelector(".lew-loading-box");
24162
+ loadingBox && loadingBox.setAttribute("data-after", tip || "");
24163
+ if (visible) {
24164
+ el.classList.add("lew-loading-show");
24165
+ } else {
24166
+ el.classList.remove("lew-loading-show");
24186
24167
  }
24187
- });
24188
- }
24189
- },
24190
- timer: {}
24191
- };
24192
- LewMessage$1.warning = (e2) => LewMessage$1.message({ type: "warning", e: e2 });
24193
- LewMessage$1.error = (e2) => LewMessage$1.message({ type: "error", e: e2 });
24194
- LewMessage$1.info = (e2) => LewMessage$1.message({ type: "info", e: e2 });
24195
- LewMessage$1.normal = (e2) => LewMessage$1.message({ type: "normal", e: e2 });
24196
- LewMessage$1.success = (e2) => LewMessage$1.message({ type: "success", e: e2 });
24197
- LewMessage$1.loading = (e2) => LewMessage$1.message({ type: "loading", e: e2 });
24198
- const dialogProps = {
24199
- type: {
24200
- type: String,
24201
- default: "error",
24202
- description: "对话框类型",
24203
- validator: (value) => {
24204
- const validTypes = [
24205
- "primary",
24206
- "success",
24207
- "warning",
24208
- "error",
24209
- "info"
24210
- ];
24211
- if (!validTypes.includes(value)) {
24212
- console.warn(
24213
- `[LewDialog] 无效的类型: ${value}。请使用 ${validTypes.join(", ")} 中的一个。`
24214
- );
24215
- return false;
24216
24168
  }
24217
- return true;
24218
- }
24219
- },
24220
- okText: {
24221
- type: String,
24222
- default: "确定",
24223
- description: "确认按钮文本"
24224
- },
24225
- cancelText: {
24226
- type: String,
24227
- default: "取消",
24228
- description: "取消按钮文本"
24229
- },
24230
- ok: {
24231
- type: Function,
24232
- default: () => true,
24233
- description: "点击确认按钮时的回调函数"
24234
- },
24235
- cancel: {
24236
- type: Function,
24237
- default: () => true,
24238
- description: "点击取消按钮时的回调函数"
24239
- },
24240
- layout: {
24241
- type: String,
24242
- default: "normal",
24243
- description: "对话框布局方式",
24244
- validator: (value) => {
24245
- const validLayouts = ["normal", "mini"];
24246
- if (!validLayouts.includes(value)) {
24247
- console.warn(
24248
- `[LewDialog] 无效的布局: ${value}。请使用 ${validLayouts.join(", ")} 中的一个。`
24249
- );
24250
- return false;
24169
+ });
24170
+ }
24171
+ };
24172
+ const initLewContextMenu = () => {
24173
+ window.LewContextMenu = {
24174
+ menu: {},
24175
+ contextMenu: null,
24176
+ instance: tippy(document.body, {
24177
+ theme: "light",
24178
+ animation: "shift-away-subtle",
24179
+ trigger: "manual",
24180
+ interactive: true,
24181
+ placement: "right-start",
24182
+ duration: [250, 250],
24183
+ delay: [250, 250],
24184
+ arrow: false,
24185
+ appendTo: () => document.body,
24186
+ allowHTML: true
24187
+ }),
24188
+ menuInstance: {}
24189
+ };
24190
+ window.LewContextMenu.instance.popper.children[0].setAttribute(
24191
+ "data-lew",
24192
+ "popover"
24193
+ );
24194
+ };
24195
+ const findContextMenuId = (el) => {
24196
+ try {
24197
+ const id = el.getAttribute("lew-context-menu-id");
24198
+ if (id) return id;
24199
+ return el.parentNode ? findContextMenuId(el.parentNode) : "";
24200
+ } catch {
24201
+ return "";
24202
+ }
24203
+ };
24204
+ const LewVContextMenu = {
24205
+ install(app) {
24206
+ app.directive("context-menu", {
24207
+ mounted(el, binding) {
24208
+ if (!window.LewContextMenu) {
24209
+ initLewContextMenu();
24210
+ }
24211
+ if (!el.id) {
24212
+ const id = getUniqueId();
24213
+ el.setAttribute("lew-context-menu-id", id);
24214
+ const { options } = binding.value;
24215
+ window.LewContextMenu.menu[id] = options || [];
24216
+ }
24217
+ if (!window.LewContextMenu.contextMenu) {
24218
+ window.LewContextMenu.contextMenu = (e2) => {
24219
+ const id = findContextMenuId(e2.target);
24220
+ if (!id) return;
24221
+ e2.preventDefault();
24222
+ const options = window.LewContextMenu.menu[id];
24223
+ const { instance } = window.LewContextMenu;
24224
+ instance.hide();
24225
+ const menuDom = document.createElement("div");
24226
+ Object.keys(window.LewContextMenu.menuInstance).forEach(
24227
+ (key) => {
24228
+ window.LewContextMenu.menuInstance[key].destroy();
24229
+ delete window.LewContextMenu.menuInstance[key];
24230
+ }
24231
+ );
24232
+ createApp({
24233
+ render() {
24234
+ return h$1(LewContextMenu, {
24235
+ options,
24236
+ onSelect: (item) => {
24237
+ const { selectHandler } = binding.value;
24238
+ if (isFunction(selectHandler)) {
24239
+ selectHandler(item);
24240
+ }
24241
+ if (!(item.children || []).length) {
24242
+ instance.hide();
24243
+ }
24244
+ }
24245
+ });
24246
+ }
24247
+ }).mount(menuDom);
24248
+ setTimeout(() => {
24249
+ instance.setProps({
24250
+ content: menuDom,
24251
+ getReferenceClientRect: () => ({
24252
+ width: 0,
24253
+ height: 0,
24254
+ top: e2.clientY,
24255
+ bottom: e2.clientY,
24256
+ left: e2.clientX,
24257
+ right: e2.clientX
24258
+ })
24259
+ });
24260
+ instance.show();
24261
+ }, 120);
24262
+ };
24263
+ window.addEventListener(
24264
+ "contextmenu",
24265
+ window.LewContextMenu.contextMenu
24266
+ );
24267
+ }
24268
+ },
24269
+ updated(el, binding) {
24270
+ const id = findContextMenuId(el);
24271
+ if (id) {
24272
+ const { options } = binding.value;
24273
+ window.LewContextMenu.menu[id] = options || [];
24274
+ } else {
24275
+ console.error("发生未知错误!找不到 lew-context-menu-id。");
24276
+ }
24251
24277
  }
24252
- return true;
24253
- }
24254
- },
24255
- closeOnClickOverlay: {
24256
- type: Boolean,
24257
- default: false,
24258
- description: "是否在点击遮罩层时关闭对话框"
24259
- },
24260
- closeByEsc: {
24261
- type: Boolean,
24262
- default: false,
24263
- description: "是否允许通过按下 ESC 键关闭对话框"
24264
- },
24265
- transformOrigin: {
24266
- type: String,
24267
- default: "0 0",
24268
- description: "对话框变换原点(内部使用,无需手动设置)"
24278
+ });
24269
24279
  }
24270
24280
  };
24271
- const _hoisted_1$1 = {
24272
- key: 0,
24273
- class: "lew-dialog-mask"
24281
+ const contextMenuProps = {
24282
+ options: {
24283
+ type: Array,
24284
+ default: () => [],
24285
+ description: "右键菜单配置"
24286
+ }
24274
24287
  };
24275
- const _hoisted_2$1 = { class: "left" };
24276
- const _hoisted_3$1 = { class: "right" };
24277
- const _hoisted_4 = { class: "left" };
24288
+ const _hoisted_1$1 = ["onClick"];
24289
+ const _hoisted_2$1 = { class: "lew-context-menu-label" };
24290
+ const _hoisted_3$1 = ["title"];
24278
24291
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
24279
- __name: "LewDialog",
24280
- props: dialogProps,
24281
- emits: ["close"],
24292
+ __name: "LewContextMenu",
24293
+ props: contextMenuProps,
24294
+ emits: ["select"],
24282
24295
  setup(__props, { emit: __emit }) {
24283
- const { Escape } = useMagicKeys();
24284
- useDOMCreate("lew-dialog");
24285
24296
  const props = __props;
24286
24297
  const emit = __emit;
24287
- const visible = ref(false);
24288
- const okLoading = ref(false);
24289
- const cancelLoading = ref(false);
24290
- const okRef1 = ref();
24291
- const okRef2 = ref();
24292
- const maskClick = () => {
24293
- if (props.closeOnClickOverlay) {
24294
- visible.value = false;
24295
- }
24296
- };
24297
- onMounted(() => {
24298
- visible.value = true;
24299
- nextTick(() => {
24300
- if (okRef1.value) okRef1.value.focus();
24301
- if (okRef2.value) okRef2.value.focus();
24302
- });
24303
- });
24304
- watch(visible, (newVal) => {
24305
- if (!newVal) {
24306
- setTimeout(() => emit("close"), 500);
24307
- }
24308
- });
24309
- const handleAction = async (action) => {
24310
- const actionFunction = props[action];
24311
- const loadingRef = action === "ok" ? okLoading : cancelLoading;
24312
- if (typeof actionFunction === "function") {
24313
- loadingRef.value = true;
24314
- const result = await actionFunction();
24315
- if (result !== false) {
24316
- visible.value = false;
24317
- }
24318
- loadingRef.value = false;
24319
- }
24298
+ const clickItem = (item) => {
24299
+ emit("select", item);
24320
24300
  };
24321
- const ok = () => handleAction("ok");
24322
- const cancel = () => handleAction("cancel");
24323
- if (props.closeByEsc) {
24324
- watch(Escape, (v2) => {
24325
- if (v2 && visible.value) {
24326
- visible.value = false;
24301
+ let itemRefs = ref([]);
24302
+ const initTippy = () => {
24303
+ itemRefs.value.forEach((el, index2) => {
24304
+ const item = props.options[index2];
24305
+ if (!el || item.disabled || (item.children || []).length === 0) {
24306
+ return;
24327
24307
  }
24328
- });
24329
- }
24330
- return (_ctx, _cache) => {
24331
- return openBlock(), createBlock(Teleport, { to: "#lew-dialog" }, [
24332
- createElementVNode("div", {
24333
- class: "lew-dialog-container",
24334
- style: normalizeStyle({
24335
- "--lew-dialog-transform-origin": _ctx.transformOrigin
24336
- })
24337
- }, [
24338
- createVNode(Transition, { name: "lew-dialog-mask" }, {
24339
- default: withCtx(() => [
24340
- visible.value ? (openBlock(), createElementBlock("div", _hoisted_1$1)) : createCommentVNode("", true)
24341
- ]),
24342
- _: 1
24343
- }),
24344
- createVNode(Transition, { name: "lew-dialog" }, {
24345
- default: withCtx(() => [
24346
- visible.value ? (openBlock(), createElementBlock("div", {
24347
- key: 0,
24348
- class: "lew-dialog",
24349
- onClick: maskClick
24308
+ const menuDom = document.createElement("div");
24309
+ createApp({
24310
+ render() {
24311
+ return h$1(LewContextMenu, {
24312
+ options: item.children,
24313
+ onSelect: (item2) => {
24314
+ emit("select", item2);
24315
+ }
24316
+ });
24317
+ }
24318
+ }).mount(menuDom);
24319
+ const uniqueId2 = getUniqueId();
24320
+ if (!window.LewContextMenu) {
24321
+ initLewContextMenu();
24322
+ }
24323
+ window.LewContextMenu.menuInstance[uniqueId2] = tippy(el, {
24324
+ theme: "light",
24325
+ animation: "shift-away-subtle",
24326
+ trigger: "mouseenter",
24327
+ interactive: true,
24328
+ placement: "right-start",
24329
+ duration: [250, 250],
24330
+ delay: [250, 250],
24331
+ arrow: false,
24332
+ offset: [0, 0],
24333
+ allowHTML: true,
24334
+ hideOnClick: false,
24335
+ zIndex: 9999,
24336
+ content: menuDom
24337
+ });
24338
+ window.LewContextMenu.menuInstance[uniqueId2].popper.children[0].setAttribute("data-lew", "popover");
24339
+ });
24340
+ };
24341
+ const renderIcon = ({ renderIcon: renderIcon2 }) => {
24342
+ if (renderIcon2) return renderIcon2();
24343
+ return "";
24344
+ };
24345
+ onMounted(() => {
24346
+ initTippy();
24347
+ });
24348
+ return (_ctx, _cache) => {
24349
+ return openBlock(), createBlock(unref(LewFlex), {
24350
+ direction: "y",
24351
+ gap: "0",
24352
+ class: "lew-context-menu"
24353
+ }, {
24354
+ default: withCtx(() => [
24355
+ (_ctx.options || []).length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.options, (item, index2) => {
24356
+ return openBlock(), createElementBlock("div", {
24357
+ key: index2,
24358
+ class: normalizeClass(["lew-context-menu-box", {
24359
+ "lew-context-menu-box-disabled": item.disabled,
24360
+ "lew-context-menu-box-divider-line": item.isDividerLine
24361
+ }])
24362
+ }, [
24363
+ createElementVNode("div", {
24364
+ ref_for: true,
24365
+ ref: (el) => unref(itemRefs).push(el),
24366
+ onClick: ($event) => clickItem(item),
24367
+ class: "lew-context-menu-item",
24368
+ style: normalizeStyle({ "animation-delay": index2 * 15 + "ms" })
24350
24369
  }, [
24351
- _ctx.layout === "normal" ? (openBlock(), createBlock(unref(LewFlex), {
24370
+ createElementVNode("div", _hoisted_2$1, [
24371
+ item.renderIcon ? (openBlock(), createBlock(renderIcon, {
24372
+ key: 0,
24373
+ renderIcon: item.renderIcon
24374
+ }, null, 8, ["renderIcon"])) : createCommentVNode("", true),
24375
+ createElementVNode("div", {
24376
+ title: item.label,
24377
+ class: "lew-context-menu-label-text"
24378
+ }, toDisplayString(item.label), 9, _hoisted_3$1)
24379
+ ]),
24380
+ (item.children || []).length > 0 ? (openBlock(), createBlock(Icon, {
24352
24381
  key: 0,
24353
- direction: "y",
24354
- gap: "20",
24355
- class: "lew-dialog-box lew-dialog-box-normal",
24356
- onClick: _cache[0] || (_cache[0] = withModifiers(() => {
24357
- }, ["stop"]))
24358
- }, {
24359
- default: withCtx(() => [
24360
- createVNode(unref(LewFlex), { y: "start" }, {
24361
- default: withCtx(() => [
24362
- createElementVNode("div", _hoisted_2$1, [
24363
- createVNode(Icon, {
24364
- type: _ctx.type,
24365
- size: 30
24366
- }, null, 8, ["type"])
24367
- ]),
24368
- createElementVNode("div", _hoisted_3$1, [
24369
- createElementVNode("header", null, [
24370
- renderSlot(_ctx.$slots, "title", {}, void 0, true)
24371
- ]),
24372
- createElementVNode("main", null, [
24373
- renderSlot(_ctx.$slots, "content", {}, void 0, true)
24374
- ])
24375
- ])
24376
- ]),
24377
- _: 3
24378
- }),
24379
- createElementVNode("footer", null, [
24380
- _ctx.cancelText ? (openBlock(), createBlock(unref(LewButton), {
24381
- key: 0,
24382
- text: _ctx.cancelText,
24383
- color: "gray",
24384
- type: "text",
24385
- loading: cancelLoading.value,
24386
- onClick: withModifiers(cancel, ["stop"])
24387
- }, null, 8, ["text", "loading"])) : createCommentVNode("", true),
24388
- _ctx.okText ? (openBlock(), createBlock(unref(LewButton), {
24389
- key: 1,
24390
- ref_key: "okRef1",
24391
- ref: okRef1,
24392
- text: _ctx.okText,
24393
- type: "fill",
24394
- color: _ctx.type,
24395
- loading: okLoading.value,
24396
- onClick: withModifiers(ok, ["stop"])
24397
- }, null, 8, ["text", "color", "loading"])) : createCommentVNode("", true)
24398
- ])
24399
- ]),
24400
- _: 3
24401
- })) : createCommentVNode("", true),
24402
- _ctx.layout === "mini" ? (openBlock(), createElementBlock("div", {
24403
- key: 1,
24404
- class: "lew-dialog-box lew-dialog-box-mini",
24405
- onClick: _cache[1] || (_cache[1] = withModifiers(() => {
24406
- }, ["stop"]))
24407
- }, [
24408
- createElementVNode("div", _hoisted_4, [
24409
- createVNode(Icon, {
24410
- size: 24,
24411
- type: _ctx.type
24412
- }, null, 8, ["type"])
24413
- ]),
24414
- createVNode(unref(LewFlex), { class: "right" }, {
24415
- default: withCtx(() => [
24416
- createElementVNode("main", null, [
24417
- renderSlot(_ctx.$slots, "content", {}, void 0, true)
24418
- ]),
24419
- createVNode(unref(LewFlex), { x: "end" }, {
24420
- default: withCtx(() => [
24421
- _ctx.cancelText ? (openBlock(), createBlock(unref(LewButton), {
24422
- key: 0,
24423
- text: _ctx.cancelText,
24424
- type: "text",
24425
- size: "small",
24426
- color: "gray",
24427
- round: "",
24428
- loading: cancelLoading.value,
24429
- onClick: withModifiers(cancel, ["stop"])
24430
- }, null, 8, ["text", "loading"])) : createCommentVNode("", true),
24431
- _ctx.okText ? (openBlock(), createBlock(unref(LewButton), {
24432
- key: 1,
24433
- ref_key: "okRef2",
24434
- ref: okRef2,
24435
- text: _ctx.okText,
24436
- type: "fill",
24437
- size: "small",
24438
- round: "",
24439
- color: _ctx.type,
24440
- loading: okLoading.value,
24441
- onClick: withModifiers(ok, ["stop"])
24442
- }, null, 8, ["text", "color", "loading"])) : createCommentVNode("", true)
24443
- ]),
24444
- _: 1
24445
- })
24446
- ]),
24447
- _: 3
24448
- })
24449
- ])) : createCommentVNode("", true)
24450
- ])) : createCommentVNode("", true)
24451
- ]),
24452
- _: 3
24453
- })
24454
- ], 4)
24455
- ]);
24382
+ size: 14,
24383
+ type: "chevron-right"
24384
+ })) : createCommentVNode("", true)
24385
+ ], 12, _hoisted_1$1)
24386
+ ], 2);
24387
+ }), 128)) : (openBlock(), createBlock(unref(_sfc_main$d), {
24388
+ key: 1,
24389
+ width: "120px",
24390
+ padding: "5px",
24391
+ "font-size": "12px",
24392
+ type: "search",
24393
+ title: "暂无操作"
24394
+ }))
24395
+ ]),
24396
+ _: 1
24397
+ });
24456
24398
  };
24457
24399
  }
24458
24400
  });
24459
- const _LewDialog = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-32b2fb4b"]]);
24460
- const { x, y } = useMouse();
24461
- const createDialog = (type) => (options) => dialog(type, options);
24462
- const dialogTypes = {
24463
- warning: createDialog("warning"),
24464
- error: createDialog("error"),
24465
- info: createDialog("info"),
24466
- normal: createDialog("normal"),
24467
- success: createDialog("success")
24401
+ const LewContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-e1377a5c"]]);
24402
+ const directives = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
24403
+ __proto__: null,
24404
+ LewBacktop: index$1,
24405
+ LewContextMenu,
24406
+ LewLoading,
24407
+ LewTooltip,
24408
+ LewVContextMenu,
24409
+ contextMenuProps,
24410
+ initLewContextMenu
24411
+ }, Symbol.toStringTag, { value: "Module" }));
24412
+ const createMessageList$1 = () => {
24413
+ const messageContainer = document.createElement("div");
24414
+ messageContainer.setAttribute("id", "lew-message");
24415
+ document.body.appendChild(messageContainer);
24468
24416
  };
24469
- const dialog = (type, options) => {
24470
- const {
24471
- title,
24472
- content,
24473
- ok = () => true,
24474
- cancel = () => true,
24475
- okText,
24476
- cancelText,
24477
- layout,
24478
- closeOnClickOverlay,
24479
- closeByEsc
24480
- } = options;
24481
- const div2 = document.createElement("div");
24482
- const transformOrigin = `${x.value}px ${y.value}px`;
24483
- document.body.appendChild(div2);
24484
- const app = createApp({
24485
- render() {
24486
- return h$1(
24487
- _LewDialog,
24488
- {
24489
- closeOnClickOverlay,
24490
- closeByEsc,
24491
- type,
24492
- layout,
24493
- okText,
24494
- cancelText,
24495
- transformOrigin,
24496
- ok,
24497
- onClose: () => {
24498
- app.unmount();
24499
- div2.remove();
24500
- },
24501
- cancel
24417
+ const showMessage = ({ type, e: e2 }) => {
24418
+ const { id, content, duration } = e2;
24419
+ const messageContainer = document.getElementById("lew-message");
24420
+ const hasMessageById = id ? document.getElementById(`lew-message-id-${id}`) : false;
24421
+ const messageElement = hasMessageById || document.createElement("div");
24422
+ messageElement.innerHTML = `${getIconInnerHTML({ type, strokeWidth: type === "loading" ? 2.5 : void 0, spinning: type === "loading" })}<div class="lew-message-content">${content || e2}</div>`;
24423
+ if (!hasMessageById) {
24424
+ if (id) {
24425
+ messageElement.setAttribute("id", `lew-message-id-${id}`);
24426
+ }
24427
+ messageContainer == null ? void 0 : messageContainer.appendChild(
24428
+ messageElement,
24429
+ messageContainer == null ? void 0 : messageContainer.childNodes[0]
24430
+ );
24431
+ } else {
24432
+ clearTimeout(LewMessage$1.timer[id]);
24433
+ }
24434
+ messageElement.setAttribute(
24435
+ "class",
24436
+ `lew-message lew-message-${type} lew-message-id-${id}`
24437
+ );
24438
+ setTimeout(() => {
24439
+ nextTick(() => {
24440
+ messageElement.setAttribute(
24441
+ "class",
24442
+ `lew-message lew-message-${type} lew-message-show`
24443
+ );
24444
+ LewMessage$1.timer[id] = setTimeout(
24445
+ () => {
24446
+ messageElement.setAttribute(
24447
+ "class",
24448
+ `lew-message lew-message-${type} lew-message-hidden`
24449
+ );
24450
+ setTimeout(() => {
24451
+ if (messageElement) messageContainer == null ? void 0 : messageContainer.removeChild(messageElement);
24452
+ }, 250);
24502
24453
  },
24503
- {
24504
- title: () => title,
24505
- content: () => content
24506
- }
24454
+ duration === 0 ? 31536e6 : duration || 3e3
24507
24455
  );
24508
- }
24509
- });
24510
- app.mount(div2);
24456
+ });
24457
+ }, 10);
24511
24458
  };
24512
- const LewDialog$1 = {
24513
- name: "LewDialog",
24514
- ...dialogTypes
24459
+ const removeClass = (element, className) => {
24460
+ element.classList.remove(className);
24515
24461
  };
24516
- const LewTooltip = {
24517
- install(app) {
24518
- app.directive("tooltip", {
24519
- mounted(el, binding) {
24520
- var _a;
24521
- const { trigger, content, placement, allowHTML, delay } = binding.value;
24522
- let _trigger = trigger;
24523
- if (trigger === "hover") {
24524
- _trigger = "mouseenter";
24525
- }
24526
- if (!trigger) {
24527
- _trigger = "mouseenter";
24528
- }
24529
- el.instance = tippy(el, {
24530
- theme: "light",
24531
- trigger: _trigger,
24532
- content,
24533
- animation: "scale",
24534
- interactive: true,
24535
- appendTo: () => document.body,
24536
- placement,
24537
- allowHTML,
24538
- arrow: ROUND_ARROW,
24539
- maxWidth: 250,
24540
- duration: [250, 250],
24541
- delay: trigger === "mouseenter" ? delay || [80, 80] : void 0
24542
- });
24543
- el.instance.popper.children[0].setAttribute("data-lew", "tooltip");
24544
- if (!((_a = binding == null ? void 0 : binding.value) == null ? void 0 : _a.content)) {
24545
- el.instance.disable();
24462
+ const addClass = (element, className) => {
24463
+ element.classList.add(className);
24464
+ };
24465
+ const LewMessage$1 = {
24466
+ name: "LewMessage",
24467
+ message: ({ type, e: e2 }) => {
24468
+ if (!document.getElementById("lew-message")) {
24469
+ createMessageList$1();
24470
+ LewMessage$1.message({ type, e: e2 });
24471
+ } else {
24472
+ showMessage({ type, e: e2 });
24473
+ }
24474
+ },
24475
+ close: ({ id }) => {
24476
+ const messageElement = document.getElementById(`lew-message-id-${id}`);
24477
+ if (messageElement) {
24478
+ removeClass(messageElement, "lew-message-show");
24479
+ addClass(messageElement, "lew-message-hidden");
24480
+ setTimeout(() => {
24481
+ clearTimeout(LewMessage$1.timer[id]);
24482
+ messageElement.remove();
24483
+ }, 350);
24484
+ }
24485
+ },
24486
+ request: async ({ loadingMessage }, asyncFn) => {
24487
+ try {
24488
+ LewMessage$1.loading({
24489
+ id: "lew-request-loading",
24490
+ content: loadingMessage,
24491
+ duration: 0
24492
+ });
24493
+ const startTime = (/* @__PURE__ */ new Date()).getTime();
24494
+ asyncFn().then(
24495
+ async ({
24496
+ content = "请求成功!",
24497
+ duration = 3e3,
24498
+ type = "success"
24499
+ }) => {
24500
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
24501
+ const delay = 250;
24502
+ if (endTime - startTime < delay) {
24503
+ await new Promise(
24504
+ (resolve) => setTimeout(resolve, delay - (endTime - startTime))
24505
+ );
24506
+ }
24507
+ LewMessage$1.close({ id: "lew-request-loading" });
24508
+ LewMessage$1[type]({
24509
+ content,
24510
+ duration
24511
+ });
24546
24512
  }
24547
- },
24548
- updated(el, binding) {
24549
- const { triggerFrom, content } = binding.value;
24550
- if (!content) {
24551
- el.instance.disable();
24552
- } else {
24553
- el.instance.enable();
24554
- el.instance.setContent(content);
24513
+ ).catch(
24514
+ ({
24515
+ content = "加载失败!",
24516
+ duration = 3e3
24517
+ }) => {
24518
+ LewMessage$1.close({ id: "lew-request-loading" });
24519
+ LewMessage$1.error({
24520
+ id: "lew-request-fail",
24521
+ content,
24522
+ duration
24523
+ });
24555
24524
  }
24556
- if (triggerFrom === "input-number") {
24557
- if (content) {
24558
- el.instance.show();
24559
- } else {
24560
- el.instance.hide();
24561
- }
24525
+ );
24526
+ } catch (error2) {
24527
+ LewMessage$1.error({
24528
+ id: "lew-request-loading",
24529
+ content: "An error occurred",
24530
+ duration: 3e3,
24531
+ onClose: () => {
24562
24532
  }
24563
- },
24564
- unmounted(el) {
24565
- el.instance.hide();
24566
- el.instance = null;
24567
- }
24568
- });
24569
- }
24570
- };
24571
- const createBackTopHandler = (target) => {
24572
- const dom = shallowRef(document.documentElement);
24573
- if (target) {
24574
- const targetElement = document.querySelector(`.${target}`);
24575
- if (!targetElement) {
24576
- throw new Error(`目标元素不存在: ${target}`);
24577
- }
24578
- dom.value = targetElement;
24579
- }
24580
- return () => {
24581
- if (dom.value) {
24582
- dom.value.scrollTo({ top: 0, behavior: "smooth" });
24533
+ });
24583
24534
  }
24584
- };
24535
+ },
24536
+ timer: {}
24585
24537
  };
24586
- const index$1 = {
24587
- install(app) {
24588
- app.directive("backtop", {
24589
- mounted(el, binding) {
24590
- const backTopHandler = createBackTopHandler(binding.value);
24591
- el.addEventListener("click", backTopHandler);
24592
- el._backTopHandler = backTopHandler;
24593
- },
24594
- unmounted(el) {
24595
- if (el._backTopHandler) {
24596
- el.removeEventListener("click", el._backTopHandler);
24597
- delete el._backTopHandler;
24598
- }
24538
+ LewMessage$1.warning = (e2) => LewMessage$1.message({ type: "warning", e: e2 });
24539
+ LewMessage$1.error = (e2) => LewMessage$1.message({ type: "error", e: e2 });
24540
+ LewMessage$1.info = (e2) => LewMessage$1.message({ type: "info", e: e2 });
24541
+ LewMessage$1.normal = (e2) => LewMessage$1.message({ type: "normal", e: e2 });
24542
+ LewMessage$1.success = (e2) => LewMessage$1.message({ type: "success", e: e2 });
24543
+ LewMessage$1.loading = (e2) => LewMessage$1.message({ type: "loading", e: e2 });
24544
+ const dialogProps = {
24545
+ type: {
24546
+ type: String,
24547
+ default: "error",
24548
+ description: "对话框类型",
24549
+ validator: (value) => {
24550
+ const validTypes = [
24551
+ "primary",
24552
+ "success",
24553
+ "warning",
24554
+ "error",
24555
+ "info"
24556
+ ];
24557
+ if (!validTypes.includes(value)) {
24558
+ console.warn(
24559
+ `[LewDialog] 无效的类型: ${value}。请使用 ${validTypes.join(", ")} 中的一个。`
24560
+ );
24561
+ return false;
24599
24562
  }
24600
- });
24601
- }
24602
- };
24603
- const warning = ({ title, content, delay = 3e3 }) => {
24604
- notification("warning", title, content, delay);
24605
- };
24606
- const error = ({ title, content, delay = 3e3 }) => {
24607
- notification("error", title, content, delay);
24608
- };
24609
- const info = ({ title, content, delay = 3e3 }) => {
24610
- notification("info", title, content, delay);
24611
- };
24612
- const normal = ({ title, content, delay = 3e3 }) => {
24613
- notification("normal", title, content, delay);
24614
- };
24615
- const success = ({ title, content, delay = 3e3 }) => {
24616
- notification("success", title, content, delay);
24617
- };
24618
- const createMessageList = () => {
24619
- const div2 = document.createElement("div");
24620
- div2.setAttribute("id", "lew-notification");
24621
- document.body.appendChild(div2);
24622
- };
24623
- const notification = (type, title, content, delay) => {
24624
- if (!document.getElementById("lew-notification")) {
24625
- createMessageList();
24626
- notification(type, title, content, delay);
24627
- } else {
24628
- add(type, title, content, delay);
24629
- }
24630
- };
24631
- const add = (type, title, content, delay) => {
24632
- const LewMessageDom = document.getElementById("lew-notification");
24633
- const newMessage = document.createElement("div");
24634
- newMessage.innerHTML = `
24635
- <div class="lew-notification-box">
24636
- <div class="lew-notification-icon">
24637
- ${getIconInnerHTML({ type, size: 18 })}
24638
- </div>
24639
- <div class="lew-notification-body">
24640
- <div class="lew-notification-title">${title}</div>
24641
- ${content ? `<div class="lew-notification-content">${content}</div>` : ""}
24642
- </div>
24643
- <div class="lew-notification-close-icon">
24644
- ${getIconInnerHTML({ type: "close", size: 16 })}
24645
- </div>
24646
- </div>
24647
- `;
24648
- LewMessageDom == null ? void 0 : LewMessageDom.insertBefore(newMessage, LewMessageDom == null ? void 0 : LewMessageDom.childNodes[0]);
24649
- newMessage.setAttribute("class", `lew-notification lew-notification-${type}`);
24650
- let timer;
24651
- let lock = false;
24652
- function startTimer() {
24653
- if (delay > 0) {
24654
- ({ stop: timer } = useTimeoutFn(() => {
24655
- handleClose();
24656
- }, delay));
24657
- }
24658
- }
24659
- function clearTimer() {
24660
- timer == null ? void 0 : timer();
24661
- }
24662
- function handleClose() {
24663
- if (lock) {
24664
- return;
24563
+ return true;
24665
24564
  }
24666
- lock = true;
24667
- newMessage.setAttribute(
24668
- "class",
24669
- `lew-notification lew-notification-${type} lew-notification-hidden`
24670
- );
24671
- if (newMessage) {
24672
- if (LewMessageDom) {
24673
- setTimeout(() => {
24674
- LewMessageDom.removeChild(newMessage);
24675
- }, 250);
24565
+ },
24566
+ okText: {
24567
+ type: String,
24568
+ default: "确定",
24569
+ description: "确认按钮文本"
24570
+ },
24571
+ cancelText: {
24572
+ type: String,
24573
+ default: "取消",
24574
+ description: "取消按钮文本"
24575
+ },
24576
+ ok: {
24577
+ type: Function,
24578
+ default: () => true,
24579
+ description: "点击确认按钮时的回调函数"
24580
+ },
24581
+ cancel: {
24582
+ type: Function,
24583
+ default: () => true,
24584
+ description: "点击取消按钮时的回调函数"
24585
+ },
24586
+ layout: {
24587
+ type: String,
24588
+ default: "normal",
24589
+ description: "对话框布局方式",
24590
+ validator: (value) => {
24591
+ const validLayouts = ["normal", "mini"];
24592
+ if (!validLayouts.includes(value)) {
24593
+ console.warn(
24594
+ `[LewDialog] 无效的布局: ${value}。请使用 ${validLayouts.join(", ")} 中的一个。`
24595
+ );
24596
+ return false;
24676
24597
  }
24598
+ return true;
24677
24599
  }
24600
+ },
24601
+ closeOnClickOverlay: {
24602
+ type: Boolean,
24603
+ default: false,
24604
+ description: "是否在点击遮罩层时关闭对话框"
24605
+ },
24606
+ closeByEsc: {
24607
+ type: Boolean,
24608
+ default: false,
24609
+ description: "是否允许通过按下 ESC 键关闭对话框"
24610
+ },
24611
+ transformOrigin: {
24612
+ type: String,
24613
+ default: "0 0",
24614
+ description: "对话框变换原点(内部使用,无需手动设置)"
24678
24615
  }
24679
- newMessage.children[0].children[2].addEventListener("click", handleClose);
24680
- newMessage.addEventListener("mouseenter", clearTimer);
24681
- newMessage.addEventListener("mouseleave", startTimer);
24682
- setTimeout(() => {
24683
- lock = false;
24684
- newMessage.setAttribute(
24685
- "class",
24686
- `lew-notification lew-notification-${type} lew-notification-show`
24687
- );
24688
- delay > 0 && startTimer();
24689
- }, 10);
24690
24616
  };
24691
- const LewNotification = {
24692
- name: "LewNotification",
24693
- warning,
24694
- info,
24695
- normal,
24696
- success,
24697
- error
24617
+ const _hoisted_1 = {
24618
+ key: 0,
24619
+ class: "lew-dialog-mask"
24698
24620
  };
24699
- const LewLoading = {
24700
- install(app) {
24701
- app.directive("loading", {
24702
- mounted(el, binding) {
24703
- const { tip, iconSize, visible } = binding.value;
24704
- const loadingWrapper = document.createElement("div");
24705
- const loadingBox = document.createElement("div");
24706
- loadingWrapper.classList.add("lew-loading-wrapper");
24707
- loadingBox.classList.add("lew-loading-box");
24708
- el.classList.add("lew-loading");
24709
- const loader = createApp(Icon, {
24710
- type: "loader",
24711
- spinning: true,
24712
- size: iconSize || 24
24713
- });
24714
- loader.mount(loadingBox);
24715
- loadingBox.setAttribute("data-after", tip || "");
24716
- loadingWrapper.appendChild(loadingBox);
24717
- el.appendChild(loadingWrapper);
24718
- if (visible) {
24719
- el.classList.add("lew-loading-show");
24720
- }
24721
- },
24722
- updated(el, binding) {
24723
- const { tip, visible } = binding.value;
24724
- const loadingBox = el.querySelector(".lew-loading-box");
24725
- loadingBox && loadingBox.setAttribute("data-after", tip || "");
24726
- if (visible) {
24727
- el.classList.add("lew-loading-show");
24728
- } else {
24729
- el.classList.remove("lew-loading-show");
24730
- }
24621
+ const _hoisted_2 = { class: "left" };
24622
+ const _hoisted_3 = { class: "right" };
24623
+ const _hoisted_4 = { class: "left" };
24624
+ const _sfc_main = /* @__PURE__ */ defineComponent({
24625
+ __name: "LewDialog",
24626
+ props: dialogProps,
24627
+ emits: ["close"],
24628
+ setup(__props, { emit: __emit }) {
24629
+ const { Escape } = useMagicKeys();
24630
+ useDOMCreate("lew-dialog");
24631
+ const props = __props;
24632
+ const emit = __emit;
24633
+ const visible = ref(false);
24634
+ const okLoading = ref(false);
24635
+ const cancelLoading = ref(false);
24636
+ const okRef1 = ref();
24637
+ const okRef2 = ref();
24638
+ const maskClick = () => {
24639
+ if (props.closeOnClickOverlay) {
24640
+ visible.value = false;
24731
24641
  }
24642
+ };
24643
+ onMounted(() => {
24644
+ visible.value = true;
24645
+ nextTick(() => {
24646
+ if (okRef1.value) okRef1.value.focus();
24647
+ if (okRef2.value) okRef2.value.focus();
24648
+ });
24732
24649
  });
24733
- }
24734
- };
24735
- const initLewContextMenu = () => {
24736
- window.LewContextMenu = {
24737
- menu: {},
24738
- contextMenu: null,
24739
- instance: tippy(document.body, {
24740
- theme: "light",
24741
- animation: "shift-away-subtle",
24742
- trigger: "manual",
24743
- interactive: true,
24744
- placement: "right-start",
24745
- duration: [250, 250],
24746
- delay: [250, 250],
24747
- arrow: false,
24748
- appendTo: () => document.body,
24749
- allowHTML: true
24750
- }),
24751
- menuInstance: {}
24752
- };
24753
- window.LewContextMenu.instance.popper.children[0].setAttribute(
24754
- "data-lew",
24755
- "popover"
24756
- );
24757
- };
24758
- const findContextMenuId = (el) => {
24759
- try {
24760
- const id = el.getAttribute("lew-context-menu-id");
24761
- if (id) return id;
24762
- return el.parentNode ? findContextMenuId(el.parentNode) : "";
24763
- } catch {
24764
- return "";
24765
- }
24766
- };
24767
- const LewVContextMenu = {
24768
- install(app) {
24769
- app.directive("context-menu", {
24770
- mounted(el, binding) {
24771
- if (!window.LewContextMenu) {
24772
- initLewContextMenu();
24773
- }
24774
- if (!el.id) {
24775
- const id = getUniqueId();
24776
- el.setAttribute("lew-context-menu-id", id);
24777
- const { options } = binding.value;
24778
- window.LewContextMenu.menu[id] = options || [];
24650
+ watch(visible, (newVal) => {
24651
+ if (!newVal) {
24652
+ setTimeout(() => emit("close"), 500);
24653
+ }
24654
+ });
24655
+ const handleAction = async (action) => {
24656
+ const actionFunction = props[action];
24657
+ const loadingRef = action === "ok" ? okLoading : cancelLoading;
24658
+ if (typeof actionFunction === "function") {
24659
+ loadingRef.value = true;
24660
+ const result = await actionFunction();
24661
+ if (result !== false) {
24662
+ visible.value = false;
24779
24663
  }
24780
- if (!window.LewContextMenu.contextMenu) {
24781
- window.LewContextMenu.contextMenu = (e2) => {
24782
- const id = findContextMenuId(e2.target);
24783
- if (!id) return;
24784
- e2.preventDefault();
24785
- const options = window.LewContextMenu.menu[id];
24786
- const { instance } = window.LewContextMenu;
24787
- instance.hide();
24788
- const menuDom = document.createElement("div");
24789
- Object.keys(window.LewContextMenu.menuInstance).forEach(
24790
- (key) => {
24791
- window.LewContextMenu.menuInstance[key].destroy();
24792
- delete window.LewContextMenu.menuInstance[key];
24793
- }
24794
- );
24795
- createApp({
24796
- render() {
24797
- return h$1(LewContextMenu, {
24798
- options,
24799
- onSelect: (item) => {
24800
- const { selectHandler } = binding.value;
24801
- if (isFunction(selectHandler)) {
24802
- selectHandler(item);
24803
- }
24804
- if (!(item.children || []).length) {
24805
- instance.hide();
24806
- }
24807
- }
24808
- });
24809
- }
24810
- }).mount(menuDom);
24811
- setTimeout(() => {
24812
- instance.setProps({
24813
- content: menuDom,
24814
- getReferenceClientRect: () => ({
24815
- width: 0,
24816
- height: 0,
24817
- top: e2.clientY,
24818
- bottom: e2.clientY,
24819
- left: e2.clientX,
24820
- right: e2.clientX
24821
- })
24822
- });
24823
- instance.show();
24824
- }, 120);
24825
- };
24826
- window.addEventListener(
24827
- "contextmenu",
24828
- window.LewContextMenu.contextMenu
24829
- );
24664
+ loadingRef.value = false;
24665
+ }
24666
+ };
24667
+ const ok = () => handleAction("ok");
24668
+ const cancel = () => handleAction("cancel");
24669
+ if (props.closeByEsc) {
24670
+ watch(Escape, (v2) => {
24671
+ if (v2 && visible.value) {
24672
+ visible.value = false;
24830
24673
  }
24831
- },
24832
- updated(el, binding) {
24833
- const id = findContextMenuId(el);
24834
- if (id) {
24835
- const { options } = binding.value;
24836
- window.LewContextMenu.menu[id] = options || [];
24837
- } else {
24838
- console.error("发生未知错误!找不到 lew-context-menu-id。");
24674
+ });
24675
+ }
24676
+ return (_ctx, _cache) => {
24677
+ return openBlock(), createBlock(Teleport, { to: "#lew-dialog" }, [
24678
+ createElementVNode("div", {
24679
+ class: "lew-dialog-container",
24680
+ style: normalizeStyle({
24681
+ "--lew-dialog-transform-origin": _ctx.transformOrigin
24682
+ })
24683
+ }, [
24684
+ createVNode(Transition, { name: "lew-dialog-mask" }, {
24685
+ default: withCtx(() => [
24686
+ visible.value ? (openBlock(), createElementBlock("div", _hoisted_1)) : createCommentVNode("", true)
24687
+ ]),
24688
+ _: 1
24689
+ }),
24690
+ createVNode(Transition, { name: "lew-dialog" }, {
24691
+ default: withCtx(() => [
24692
+ visible.value ? (openBlock(), createElementBlock("div", {
24693
+ key: 0,
24694
+ class: "lew-dialog",
24695
+ onClick: maskClick
24696
+ }, [
24697
+ _ctx.layout === "normal" ? (openBlock(), createBlock(unref(LewFlex), {
24698
+ key: 0,
24699
+ direction: "y",
24700
+ gap: "20",
24701
+ class: "lew-dialog-box lew-dialog-box-normal",
24702
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
24703
+ }, ["stop"]))
24704
+ }, {
24705
+ default: withCtx(() => [
24706
+ createVNode(unref(LewFlex), { y: "start" }, {
24707
+ default: withCtx(() => [
24708
+ createElementVNode("div", _hoisted_2, [
24709
+ createVNode(Icon, {
24710
+ type: _ctx.type,
24711
+ size: 30
24712
+ }, null, 8, ["type"])
24713
+ ]),
24714
+ createElementVNode("div", _hoisted_3, [
24715
+ createElementVNode("header", null, [
24716
+ renderSlot(_ctx.$slots, "title", {}, void 0, true)
24717
+ ]),
24718
+ createElementVNode("main", null, [
24719
+ renderSlot(_ctx.$slots, "content", {}, void 0, true)
24720
+ ])
24721
+ ])
24722
+ ]),
24723
+ _: 3
24724
+ }),
24725
+ createElementVNode("footer", null, [
24726
+ _ctx.cancelText ? (openBlock(), createBlock(unref(LewButton), {
24727
+ key: 0,
24728
+ text: _ctx.cancelText,
24729
+ color: "gray",
24730
+ type: "text",
24731
+ loading: cancelLoading.value,
24732
+ onClick: withModifiers(cancel, ["stop"])
24733
+ }, null, 8, ["text", "loading"])) : createCommentVNode("", true),
24734
+ _ctx.okText ? (openBlock(), createBlock(unref(LewButton), {
24735
+ key: 1,
24736
+ ref_key: "okRef1",
24737
+ ref: okRef1,
24738
+ text: _ctx.okText,
24739
+ type: "fill",
24740
+ color: _ctx.type,
24741
+ loading: okLoading.value,
24742
+ onClick: withModifiers(ok, ["stop"])
24743
+ }, null, 8, ["text", "color", "loading"])) : createCommentVNode("", true)
24744
+ ])
24745
+ ]),
24746
+ _: 3
24747
+ })) : createCommentVNode("", true),
24748
+ _ctx.layout === "mini" ? (openBlock(), createElementBlock("div", {
24749
+ key: 1,
24750
+ class: "lew-dialog-box lew-dialog-box-mini",
24751
+ onClick: _cache[1] || (_cache[1] = withModifiers(() => {
24752
+ }, ["stop"]))
24753
+ }, [
24754
+ createElementVNode("div", _hoisted_4, [
24755
+ createVNode(Icon, {
24756
+ size: 24,
24757
+ type: _ctx.type
24758
+ }, null, 8, ["type"])
24759
+ ]),
24760
+ createVNode(unref(LewFlex), { class: "right" }, {
24761
+ default: withCtx(() => [
24762
+ createElementVNode("main", null, [
24763
+ renderSlot(_ctx.$slots, "content", {}, void 0, true)
24764
+ ]),
24765
+ createVNode(unref(LewFlex), { x: "end" }, {
24766
+ default: withCtx(() => [
24767
+ _ctx.cancelText ? (openBlock(), createBlock(unref(LewButton), {
24768
+ key: 0,
24769
+ text: _ctx.cancelText,
24770
+ type: "text",
24771
+ size: "small",
24772
+ color: "gray",
24773
+ round: "",
24774
+ loading: cancelLoading.value,
24775
+ onClick: withModifiers(cancel, ["stop"])
24776
+ }, null, 8, ["text", "loading"])) : createCommentVNode("", true),
24777
+ _ctx.okText ? (openBlock(), createBlock(unref(LewButton), {
24778
+ key: 1,
24779
+ ref_key: "okRef2",
24780
+ ref: okRef2,
24781
+ text: _ctx.okText,
24782
+ type: "fill",
24783
+ size: "small",
24784
+ round: "",
24785
+ color: _ctx.type,
24786
+ loading: okLoading.value,
24787
+ onClick: withModifiers(ok, ["stop"])
24788
+ }, null, 8, ["text", "color", "loading"])) : createCommentVNode("", true)
24789
+ ]),
24790
+ _: 1
24791
+ })
24792
+ ]),
24793
+ _: 3
24794
+ })
24795
+ ])) : createCommentVNode("", true)
24796
+ ])) : createCommentVNode("", true)
24797
+ ]),
24798
+ _: 3
24799
+ })
24800
+ ], 4)
24801
+ ]);
24802
+ };
24803
+ }
24804
+ });
24805
+ const _LewDialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-46b17cfb"]]);
24806
+ const { x, y } = useMouse();
24807
+ const createDialog = (type) => (options) => dialog(type, options);
24808
+ const dialogTypes = {
24809
+ warning: createDialog("warning"),
24810
+ error: createDialog("error"),
24811
+ info: createDialog("info"),
24812
+ normal: createDialog("normal"),
24813
+ success: createDialog("success")
24814
+ };
24815
+ const dialog = (type, options) => {
24816
+ const {
24817
+ title,
24818
+ content,
24819
+ ok = () => true,
24820
+ cancel = () => true,
24821
+ okText,
24822
+ cancelText,
24823
+ layout,
24824
+ closeOnClickOverlay,
24825
+ closeByEsc
24826
+ } = options;
24827
+ const div2 = document.createElement("div");
24828
+ const transformOrigin = `${x.value}px ${y.value}px`;
24829
+ document.body.appendChild(div2);
24830
+ const app = createApp({
24831
+ render() {
24832
+ return h$1(
24833
+ _LewDialog,
24834
+ {
24835
+ closeOnClickOverlay,
24836
+ closeByEsc,
24837
+ type,
24838
+ layout,
24839
+ okText,
24840
+ cancelText,
24841
+ transformOrigin,
24842
+ ok,
24843
+ onClose: () => {
24844
+ app.unmount();
24845
+ div2.remove();
24846
+ },
24847
+ cancel
24848
+ },
24849
+ {
24850
+ title: () => title,
24851
+ content: () => content
24839
24852
  }
24840
- }
24841
- });
24842
- }
24853
+ );
24854
+ }
24855
+ });
24856
+ app.mount(div2);
24843
24857
  };
24844
- const contextMenuProps = {
24845
- options: {
24846
- type: Array,
24847
- default: () => [],
24848
- description: "右键菜单配置"
24858
+ const LewDialog$1 = {
24859
+ name: "LewDialog",
24860
+ ...dialogTypes
24861
+ };
24862
+ const warning = ({ title, content, delay = 3e3 }) => {
24863
+ notification("warning", title, content, delay);
24864
+ };
24865
+ const error = ({ title, content, delay = 3e3 }) => {
24866
+ notification("error", title, content, delay);
24867
+ };
24868
+ const info = ({ title, content, delay = 3e3 }) => {
24869
+ notification("info", title, content, delay);
24870
+ };
24871
+ const normal = ({ title, content, delay = 3e3 }) => {
24872
+ notification("normal", title, content, delay);
24873
+ };
24874
+ const success = ({ title, content, delay = 3e3 }) => {
24875
+ notification("success", title, content, delay);
24876
+ };
24877
+ const createMessageList = () => {
24878
+ const div2 = document.createElement("div");
24879
+ div2.setAttribute("id", "lew-notification");
24880
+ document.body.appendChild(div2);
24881
+ };
24882
+ const notification = (type, title, content, delay) => {
24883
+ if (!document.getElementById("lew-notification")) {
24884
+ createMessageList();
24885
+ notification(type, title, content, delay);
24886
+ } else {
24887
+ add(type, title, content, delay);
24849
24888
  }
24850
24889
  };
24851
- const _hoisted_1 = ["onClick"];
24852
- const _hoisted_2 = { class: "lew-context-menu-label" };
24853
- const _hoisted_3 = ["title"];
24854
- const _sfc_main = /* @__PURE__ */ defineComponent({
24855
- __name: "LewContextMenu",
24856
- props: contextMenuProps,
24857
- emits: ["select"],
24858
- setup(__props, { emit: __emit }) {
24859
- const props = __props;
24860
- const emit = __emit;
24861
- const clickItem = (item) => {
24862
- emit("select", item);
24863
- };
24864
- let itemRefs = ref([]);
24865
- const initTippy = () => {
24866
- itemRefs.value.forEach((el, index2) => {
24867
- const item = props.options[index2];
24868
- if (!el || item.disabled || (item.children || []).length === 0) {
24869
- return;
24870
- }
24871
- const menuDom = document.createElement("div");
24872
- createApp({
24873
- render() {
24874
- return h$1(LewContextMenu, {
24875
- options: item.children,
24876
- onSelect: (item2) => {
24877
- emit("select", item2);
24878
- }
24879
- });
24880
- }
24881
- }).mount(menuDom);
24882
- const uniqueId2 = getUniqueId();
24883
- if (!window.LewContextMenu) {
24884
- initLewContextMenu();
24885
- }
24886
- window.LewContextMenu.menuInstance[uniqueId2] = tippy(el, {
24887
- theme: "light",
24888
- animation: "shift-away-subtle",
24889
- trigger: "mouseenter",
24890
- interactive: true,
24891
- placement: "right-start",
24892
- duration: [250, 250],
24893
- delay: [250, 250],
24894
- arrow: false,
24895
- offset: [0, 0],
24896
- allowHTML: true,
24897
- hideOnClick: false,
24898
- zIndex: 9999,
24899
- content: menuDom
24900
- });
24901
- window.LewContextMenu.menuInstance[uniqueId2].popper.children[0].setAttribute("data-lew", "popover");
24902
- });
24903
- };
24904
- const renderIcon = ({ renderIcon: renderIcon2 }) => {
24905
- if (renderIcon2) return renderIcon2();
24906
- return "";
24907
- };
24908
- onMounted(() => {
24909
- initTippy();
24910
- });
24911
- return (_ctx, _cache) => {
24912
- return openBlock(), createBlock(unref(LewFlex), {
24913
- direction: "y",
24914
- gap: "0",
24915
- class: "lew-context-menu"
24916
- }, {
24917
- default: withCtx(() => [
24918
- (_ctx.options || []).length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.options, (item, index2) => {
24919
- return openBlock(), createElementBlock("div", {
24920
- key: index2,
24921
- class: normalizeClass(["lew-context-menu-box", {
24922
- "lew-context-menu-box-disabled": item.disabled,
24923
- "lew-context-menu-box-divider-line": item.isDividerLine
24924
- }])
24925
- }, [
24926
- createElementVNode("div", {
24927
- ref_for: true,
24928
- ref: (el) => unref(itemRefs).push(el),
24929
- onClick: ($event) => clickItem(item),
24930
- class: "lew-context-menu-item",
24931
- style: normalizeStyle({ "animation-delay": index2 * 15 + "ms" })
24932
- }, [
24933
- createElementVNode("div", _hoisted_2, [
24934
- item.renderIcon ? (openBlock(), createBlock(renderIcon, {
24935
- key: 0,
24936
- renderIcon: item.renderIcon
24937
- }, null, 8, ["renderIcon"])) : createCommentVNode("", true),
24938
- createElementVNode("div", {
24939
- title: item.label,
24940
- class: "lew-context-menu-label-text"
24941
- }, toDisplayString(item.label), 9, _hoisted_3)
24942
- ]),
24943
- (item.children || []).length > 0 ? (openBlock(), createBlock(Icon, {
24944
- key: 0,
24945
- size: 14,
24946
- type: "chevron-right"
24947
- })) : createCommentVNode("", true)
24948
- ], 12, _hoisted_1)
24949
- ], 2);
24950
- }), 128)) : (openBlock(), createBlock(unref(_sfc_main$d), {
24951
- key: 1,
24952
- width: "120px",
24953
- padding: "5px",
24954
- "font-size": "12px",
24955
- type: "search",
24956
- title: "暂无操作"
24957
- }))
24958
- ]),
24959
- _: 1
24960
- });
24961
- };
24890
+ const add = (type, title, content, delay) => {
24891
+ const LewMessageDom = document.getElementById("lew-notification");
24892
+ const newMessage = document.createElement("div");
24893
+ newMessage.innerHTML = `
24894
+ <div class="lew-notification-box">
24895
+ <div class="lew-notification-icon">
24896
+ ${getIconInnerHTML({ type, size: 18 })}
24897
+ </div>
24898
+ <div class="lew-notification-body">
24899
+ <div class="lew-notification-title">${title}</div>
24900
+ ${content ? `<div class="lew-notification-content">${content}</div>` : ""}
24901
+ </div>
24902
+ <div class="lew-notification-close-icon">
24903
+ ${getIconInnerHTML({ type: "close", size: 16 })}
24904
+ </div>
24905
+ </div>
24906
+ `;
24907
+ LewMessageDom == null ? void 0 : LewMessageDom.insertBefore(newMessage, LewMessageDom == null ? void 0 : LewMessageDom.childNodes[0]);
24908
+ newMessage.setAttribute("class", `lew-notification lew-notification-${type}`);
24909
+ let timer;
24910
+ let lock = false;
24911
+ function startTimer() {
24912
+ if (delay > 0) {
24913
+ ({ stop: timer } = useTimeoutFn(() => {
24914
+ handleClose();
24915
+ }, delay));
24916
+ }
24962
24917
  }
24963
- });
24964
- const LewContextMenu = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-e1377a5c"]]);
24965
- const directives = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
24918
+ function clearTimer() {
24919
+ timer == null ? void 0 : timer();
24920
+ }
24921
+ function handleClose() {
24922
+ if (lock) {
24923
+ return;
24924
+ }
24925
+ lock = true;
24926
+ newMessage.setAttribute(
24927
+ "class",
24928
+ `lew-notification lew-notification-${type} lew-notification-hidden`
24929
+ );
24930
+ if (newMessage) {
24931
+ if (LewMessageDom) {
24932
+ setTimeout(() => {
24933
+ LewMessageDom.removeChild(newMessage);
24934
+ }, 250);
24935
+ }
24936
+ }
24937
+ }
24938
+ newMessage.children[0].children[2].addEventListener("click", handleClose);
24939
+ newMessage.addEventListener("mouseenter", clearTimer);
24940
+ newMessage.addEventListener("mouseleave", startTimer);
24941
+ setTimeout(() => {
24942
+ lock = false;
24943
+ newMessage.setAttribute(
24944
+ "class",
24945
+ `lew-notification lew-notification-${type} lew-notification-show`
24946
+ );
24947
+ delay > 0 && startTimer();
24948
+ }, 10);
24949
+ };
24950
+ const LewNotification = {
24951
+ name: "LewNotification",
24952
+ warning,
24953
+ info,
24954
+ normal,
24955
+ success,
24956
+ error
24957
+ };
24958
+ const methods = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
24966
24959
  __proto__: null,
24967
- LewBacktop: index$1,
24968
- LewContextMenu,
24969
24960
  LewDialog: LewDialog$1,
24970
- LewLoading,
24971
24961
  LewMessage: LewMessage$1,
24972
24962
  LewNotification,
24973
- LewTooltip,
24974
- LewVContextMenu,
24975
- contextMenuProps,
24976
- dialogProps,
24977
- initLewContextMenu
24963
+ dialogProps
24978
24964
  }, Symbol.toStringTag, { value: "Module" }));
24979
24965
  const install = (Vue) => {
24980
- const componentList = Object.keys(components).map(
24981
- (key) => components[key]
24982
- );
24983
- const directiveList = Object.keys(directives).map(
24984
- (key) => directives[key]
24985
- );
24986
- componentList.forEach((component) => {
24987
- if (Object.prototype.hasOwnProperty.call(component, "name") || Object.prototype.hasOwnProperty.call(component, "__name")) {
24988
- Vue.component(`${component.name || component.__name}`, component);
24966
+ Object.keys(components).forEach((key) => {
24967
+ const component = components[key];
24968
+ if (component.name || component.__name) {
24969
+ Vue.component(component.name || component.__name, component);
24989
24970
  }
24990
24971
  });
24991
- directiveList.forEach((directive) => {
24992
- if (Object.prototype.hasOwnProperty.call(directive, "install")) {
24993
- Vue.use(directive);
24994
- } else if (Object.prototype.hasOwnProperty.call(directive, "name")) {
24995
- window[directive.name] = directive;
24996
- Vue.config.globalProperties[directive.name] = directive;
24972
+ Object.keys(directives).forEach((key) => {
24973
+ Vue.use(directives[key]);
24974
+ });
24975
+ Object.keys(methods).forEach((key) => {
24976
+ const methodInstance = methods[key];
24977
+ if (methodInstance.name) {
24978
+ window[methodInstance.name] = methodInstance;
24997
24979
  }
24998
24980
  });
24999
24981
  };