vue-devui 1.5.6 → 1.5.7-hotfix.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.
Files changed (84) hide show
  1. package/action-timeline/style.css +1 -1
  2. package/alert/style.css +1 -1
  3. package/auto-complete/style.css +1 -1
  4. package/badge/style.css +1 -1
  5. package/breadcrumb/style.css +1 -1
  6. package/button/style.css +1 -1
  7. package/card/style.css +1 -1
  8. package/carousel/style.css +1 -1
  9. package/checkbox/style.css +1 -1
  10. package/code-editor/index.es.js +30 -16
  11. package/code-editor/index.umd.js +7 -7
  12. package/code-review/index.es.js +6229 -23
  13. package/code-review/index.umd.js +38 -1
  14. package/code-review/style.css +1 -1
  15. package/collapse/style.css +1 -1
  16. package/date-picker-pro/style.css +1 -1
  17. package/drawer/style.css +1 -1
  18. package/dropdown/style.css +1 -1
  19. package/editable-select/style.css +1 -1
  20. package/editor-md/index.es.js +2 -1
  21. package/editor-md/index.umd.js +30 -30
  22. package/editor-md/style.css +1 -1
  23. package/form/style.css +1 -1
  24. package/global.d.ts +2 -1
  25. package/icon/style.css +1 -1
  26. package/image-preview/style.css +1 -1
  27. package/input/style.css +1 -1
  28. package/input-number/index.es.js +1 -0
  29. package/input-number/index.umd.js +14 -14
  30. package/input-number/style.css +1 -1
  31. package/mention/style.css +1 -1
  32. package/menu/index.es.js +1 -0
  33. package/menu/index.umd.js +1 -1
  34. package/menu/style.css +1 -1
  35. package/message/style.css +1 -1
  36. package/modal/style.css +1 -1
  37. package/notification/style.css +1 -1
  38. package/nuxt/components/CodeReviewInjectionKey.js +3 -0
  39. package/overlay/style.css +1 -1
  40. package/package.json +10 -9
  41. package/pagination/style.css +1 -1
  42. package/panel/style.css +1 -1
  43. package/popover/style.css +1 -1
  44. package/progress/index.es.js +1 -0
  45. package/progress/index.umd.js +2 -2
  46. package/radio/style.css +1 -1
  47. package/result/style.css +1 -1
  48. package/search/style.css +1 -1
  49. package/select/style.css +1 -1
  50. package/slider/index.es.js +1 -0
  51. package/slider/index.umd.js +1 -1
  52. package/slider/style.css +1 -1
  53. package/splitter/index.es.js +1 -0
  54. package/splitter/index.umd.js +9 -9
  55. package/splitter/style.css +1 -1
  56. package/status/style.css +1 -1
  57. package/steps/style.css +1 -1
  58. package/style.css +1 -1
  59. package/switch/style.css +1 -1
  60. package/table/index.es.js +1 -0
  61. package/table/index.umd.js +12 -12
  62. package/table/style.css +1 -1
  63. package/tabs/style.css +1 -1
  64. package/tag/style.css +1 -1
  65. package/textarea/style.css +1 -1
  66. package/time-picker/style.css +1 -1
  67. package/time-select/style.css +1 -1
  68. package/timeline/style.css +1 -1
  69. package/tooltip/style.css +1 -1
  70. package/tree/index.es.js +1 -0
  71. package/tree/index.umd.js +11 -11
  72. package/tree/style.css +1 -1
  73. package/types/code-editor/src/code-highlight-directive.d.ts +5 -0
  74. package/types/code-review/src/code-review-types.d.ts +12 -1
  75. package/types/code-review/src/code-review.d.ts +10 -2
  76. package/types/code-review/src/components/code-review-header.d.ts +2 -0
  77. package/types/code-review/src/components/code-review-icons.d.ts +2 -0
  78. package/types/code-review/src/composables/use-code-review-header.d.ts +6 -0
  79. package/types/code-review/src/composables/use-code-review.d.ts +3 -1
  80. package/types/shared/utils/index.d.ts +1 -0
  81. package/types/shared/utils/to-clipboard.d.ts +1 -0
  82. package/upload/style.css +1 -1
  83. package/vue-devui.es.js +203 -30
  84. package/vue-devui.umd.js +53 -50
package/vue-devui.es.js CHANGED
@@ -35,6 +35,7 @@ var __publicField = (obj, key, value) => {
35
35
  };
36
36
  import { createVNode, getCurrentInstance, defineComponent, toRefs, inject, computed, Fragment, mergeProps, resolveComponent, isVNode, ref, reactive, createTextVNode, provide, onMounted, watch, Transition, withDirectives, vShow, nextTick, onUnmounted, unref, withModifiers, Comment as Comment$1, Text, h, cloneVNode, Teleport, onBeforeUnmount, render as render$1, resolveDirective, resolveDynamicComponent, toRef, shallowRef, onBeforeMount, onUpdated, readonly, toRaw, watchEffect, renderSlot, useSlots, createApp, shallowReactive, effect, TransitionGroup } from "vue";
37
37
  import { useRoute } from "vue-router";
38
+ import Clipboard from "clipboard";
38
39
  import { offset, autoPlacement, arrow, shift, computePosition, flip } from "@floating-ui/dom";
39
40
  import { onClickOutside, toRefs as toRefs$1, useResizeObserver } from "@vueuse/core";
40
41
  import * as Diff2Html from "diff2html";
@@ -1546,6 +1547,26 @@ function randomId(n = 8) {
1546
1547
  }
1547
1548
  return result2;
1548
1549
  }
1550
+ function toClipboard(text) {
1551
+ return new Promise((resolve, reject) => {
1552
+ const ele = document.createElement("button");
1553
+ const clipboard = new Clipboard(ele, {
1554
+ text: () => text,
1555
+ action: () => "copy"
1556
+ });
1557
+ clipboard.on("success", (e) => {
1558
+ clipboard.destroy();
1559
+ resolve(e);
1560
+ });
1561
+ clipboard.on("error", (e) => {
1562
+ clipboard.destroy();
1563
+ reject(e);
1564
+ });
1565
+ document.body.appendChild(ele);
1566
+ ele.click();
1567
+ document.body.removeChild(ele);
1568
+ });
1569
+ }
1549
1570
  function setStyle(element, style) {
1550
1571
  const oldStyle = {};
1551
1572
  const styleKeys = Object.keys(style);
@@ -13693,7 +13714,7 @@ function useCodeEditor(props, ctx2) {
13693
13714
  addCommentIcon,
13694
13715
  expandCommentIcon
13695
13716
  } = toRefs(props);
13696
- let monaco;
13717
+ let monaco2;
13697
13718
  let editor;
13698
13719
  let diffEditor;
13699
13720
  let themeService;
@@ -13732,7 +13753,7 @@ function useCodeEditor(props, ctx2) {
13732
13753
  });
13733
13754
  onMounted(async () => {
13734
13755
  if (inBrowser) {
13735
- monaco = await import("monaco-editor");
13756
+ monaco2 = await import("monaco-editor");
13736
13757
  setCurrentTheme();
13737
13758
  init();
13738
13759
  if (mode.value === "review") {
@@ -13751,15 +13772,15 @@ function useCodeEditor(props, ctx2) {
13751
13772
  initDiffEditor();
13752
13773
  }
13753
13774
  if (!options.value["theme"]) {
13754
- monaco.editor.setTheme(currentTheme);
13775
+ monaco2.editor.setTheme(currentTheme);
13755
13776
  }
13756
13777
  handleAutoHeight();
13757
13778
  setValueEmitter();
13758
13779
  }
13759
13780
  function initNormalEditor() {
13760
13781
  if (!editor) {
13761
- editor = monaco.editor.create(editorEl.value, options.value);
13762
- editor.setModel(monaco.editor.createModel(modelValue.value, options.value["language"]));
13782
+ editor = monaco2.editor.create(editorEl.value, options.value);
13783
+ editor.setModel(monaco2.editor.createModel(modelValue.value, options.value["language"]));
13763
13784
  ctx2.emit("afterEditorInit", editor);
13764
13785
  if (mode.value === "review") {
13765
13786
  editor.onMouseMove(handleMouseMove);
@@ -13770,10 +13791,10 @@ function useCodeEditor(props, ctx2) {
13770
13791
  }
13771
13792
  function initDiffEditor() {
13772
13793
  if (!diffEditor) {
13773
- diffEditor = monaco.editor.createDiffEditor(editorEl.value, options.value);
13794
+ diffEditor = monaco2.editor.createDiffEditor(editorEl.value, options.value);
13774
13795
  diffEditor.setModel({
13775
- original: monaco.editor.createModel(originalText.value, options.value["language"]),
13776
- modified: monaco.editor.createModel(modelValue.value, options.value["language"])
13796
+ original: monaco2.editor.createModel(originalText.value, options.value["language"]),
13797
+ modified: monaco2.editor.createModel(modelValue.value, options.value["language"])
13777
13798
  });
13778
13799
  ctx2.emit("afterEditorInit", diffEditor);
13779
13800
  }
@@ -13786,11 +13807,10 @@ function useCodeEditor(props, ctx2) {
13786
13807
  }
13787
13808
  }
13788
13809
  function setEditorValue() {
13789
- var _a;
13790
13810
  if (!editor || !editor.getModel()) {
13791
13811
  return;
13792
13812
  }
13793
- (_a = editor.getModel().modified) == null ? void 0 : _a.setValue(modelValue.value);
13813
+ editor.getModel().setValue(modelValue.value);
13794
13814
  }
13795
13815
  function setDiffEditorValue() {
13796
13816
  var _a;
@@ -13809,7 +13829,7 @@ function useCodeEditor(props, ctx2) {
13809
13829
  currentTheme = themeService && themeService.currentTheme.isDark ? "vs" : "vs-dark";
13810
13830
  }
13811
13831
  if (editor) {
13812
- monaco.editor.setTheme(currentTheme);
13832
+ monaco2.editor.setTheme(currentTheme);
13813
13833
  }
13814
13834
  }
13815
13835
  function handleAutoHeight() {
@@ -13843,8 +13863,8 @@ function useCodeEditor(props, ctx2) {
13843
13863
  if (editor) {
13844
13864
  if (mode.value === "normal" || mode.value === "review") {
13845
13865
  const model = diffEditor.getModel();
13846
- monaco.editor.setModelLanguage(model.modified, language);
13847
- monaco.editor.setModelLanguage(model.original, language);
13866
+ monaco2.editor.setModelLanguage(model.modified, language);
13867
+ monaco2.editor.setModelLanguage(model.original, language);
13848
13868
  }
13849
13869
  }
13850
13870
  }
@@ -13858,7 +13878,7 @@ function useCodeEditor(props, ctx2) {
13858
13878
  }
13859
13879
  function updateEditorHeightAuto() {
13860
13880
  var _a;
13861
- const lineHeight = editor.getOption(monaco.editor.EditorOption.lineHeight);
13881
+ const lineHeight = editor.getOption(monaco2.editor.EditorOption.lineHeight);
13862
13882
  const lineCount = ((_a = editor.getModel()) == null ? void 0 : _a.getLineCount()) || 1;
13863
13883
  const height = editor.getTopForLineNumber(lineCount + 1) + lineHeight;
13864
13884
  if (editorEl.value) {
@@ -13872,7 +13892,7 @@ function useCodeEditor(props, ctx2) {
13872
13892
  if (!isDecorationExisted(currentLineNumber)) {
13873
13893
  const lineDecoration = [
13874
13894
  {
13875
- range: new monaco.Range(currentLineNumber, 0, currentLineNumber, 0),
13895
+ range: new monaco2.Range(currentLineNumber, 0, currentLineNumber, 0),
13876
13896
  option: {
13877
13897
  isWholeLine: true,
13878
13898
  glyphMarginClassName: `icon-pointer ${addCommentIcon.value}`
@@ -13904,7 +13924,7 @@ function useCodeEditor(props, ctx2) {
13904
13924
  }
13905
13925
  function setDecorations(decoration) {
13906
13926
  return {
13907
- range: new monaco.Range(decoration.lineNumber, 1, decoration.lineNumber, 1),
13927
+ range: new monaco2.Range(decoration.lineNumber, 1, decoration.lineNumber, 1),
13908
13928
  options: {
13909
13929
  isWholeLine: true,
13910
13930
  className: decoration.customClasses || "",
@@ -14058,51 +14078,204 @@ var CodeEditor = defineComponent({
14058
14078
  }, null);
14059
14079
  }
14060
14080
  });
14081
+ let monaco;
14082
+ const CodeHighlightDirective = {
14083
+ async mounted(el) {
14084
+ if (inBrowser) {
14085
+ monaco = await import("monaco-editor");
14086
+ monaco.editor.colorizeElement(el);
14087
+ }
14088
+ },
14089
+ updated(el) {
14090
+ if (inBrowser) {
14091
+ monaco.editor.colorizeElement(el);
14092
+ }
14093
+ }
14094
+ };
14061
14095
  var CodeEditorInstall = {
14062
14096
  title: "Code Editor \u4EE3\u7801\u7F16\u8F91\u5668",
14063
14097
  category: "\u6F14\u8FDB\u4E2D",
14064
14098
  status: "100%",
14065
14099
  install(app) {
14100
+ app.directive("d-code-highlight", CodeHighlightDirective);
14066
14101
  app.component(CodeEditor.name, CodeEditor);
14067
14102
  }
14068
14103
  };
14104
+ function FoldIcon() {
14105
+ return createVNode("svg", {
14106
+ "width": "16px",
14107
+ "height": "16px",
14108
+ "viewBox": "0 0 16 16",
14109
+ "xmlns": "http://www.w3.org/2000/svg"
14110
+ }, [createVNode("g", {
14111
+ "stroke": "none",
14112
+ "stroke-width": "1",
14113
+ "fill-rule": "evenodd"
14114
+ }, [createVNode("polygon", {
14115
+ "points": "4.5 5 8 8.76923077 11.5 5 13 6.61538462 8 12 3 6.61538462"
14116
+ }, null)])]);
14117
+ }
14118
+ function CopyIcon() {
14119
+ return createVNode("svg", {
14120
+ "width": "16px",
14121
+ "height": "16px",
14122
+ "viewBox": "0 0 16 16",
14123
+ "version": "1.1",
14124
+ "xmlns": "http://www.w3.org/2000/svg"
14125
+ }, [createVNode("g", {
14126
+ "stroke": "none",
14127
+ "stroke-width": "1",
14128
+ "fill": "none",
14129
+ "fill-rule": "evenodd"
14130
+ }, [createVNode("path", {
14131
+ "d": `M14,1 C14.5522847,1 15,1.44771525 15,2 L15,10 C15,10.5522847 14.5522847,11 14,11 L11,11 L11,14
14132
+ C11,14.5522847 10.5522847,15 10,15 L2,15 C1.44771525,15 1,14.5522847 1,14 L1,6 C1,5.44771525 1.44771525,5
14133
+ 2,5 L5,5 L5,2 C5,1.44771525 5.44771525,1 6,1 L14,1 Z M10,6 L2,6 L2,14 L10,14 L10,6 Z M9,11 L9,12 L3,12
14134
+ L3,11 L9,11 Z M14,2 L6,2 L6,5 L10,5 C10.5522847,5 11,5.44771525 11,6 L11,10 L14,10 L14,2 Z M9,8 L9,9 L3,9 L3,8 L9,8 Z`,
14135
+ "fill": "#babbc0",
14136
+ "fill-rule": "nonzero"
14137
+ }, null)])]);
14138
+ }
14069
14139
  const codeReviewProps = {
14070
14140
  diff: {
14071
14141
  type: String,
14072
14142
  required: true,
14073
14143
  default: ""
14074
14144
  },
14145
+ fold: {
14146
+ type: Boolean,
14147
+ default: false
14148
+ },
14075
14149
  outputFormat: {
14076
14150
  type: String,
14077
14151
  default: "line-by-line"
14078
14152
  }
14079
14153
  };
14080
- function useCodeReview(props) {
14081
- const { diff, outputFormat } = toRefs(props);
14154
+ const CodeReviewInjectionKey = Symbol("d-code-review");
14155
+ function useCodeReviewCopy(diffInfo) {
14156
+ const copyTipsText = ref("\u590D\u5236\u6587\u4EF6\u8DEF\u5F84");
14157
+ const tipsPopType = ref("default");
14158
+ const onCopy = () => {
14159
+ toClipboard(diffInfo.newName).then(() => {
14160
+ });
14161
+ };
14162
+ return { copyTipsText, tipsPopType, onCopy };
14163
+ }
14164
+ var CodeReviewHeader = defineComponent({
14165
+ name: "DCodeReviewHeader",
14166
+ emits: ["click"],
14167
+ setup(_, ctx2) {
14168
+ const ns2 = useNamespace("code-review");
14169
+ const {
14170
+ diffInfo,
14171
+ isFold,
14172
+ rootCtx
14173
+ } = inject(CodeReviewInjectionKey);
14174
+ const {
14175
+ copyTipsText,
14176
+ tipsPopType,
14177
+ onCopy
14178
+ } = useCodeReviewCopy(diffInfo);
14179
+ const onClick = (e) => {
14180
+ const composedPath = e.composedPath();
14181
+ const isPreventEvent = composedPath.some((item) => {
14182
+ var _a, _b;
14183
+ return ((_a = item.classList) == null ? void 0 : _a.contains("operate-area")) || ((_b = item.classList) == null ? void 0 : _b.contains("icon-copy"));
14184
+ });
14185
+ if (!isPreventEvent) {
14186
+ ctx2.emit("click");
14187
+ }
14188
+ };
14189
+ return () => createVNode("div", {
14190
+ "class": [ns2.e("header"), {
14191
+ [ns2.em("header", "unfold")]: !isFold.value
14192
+ }],
14193
+ "onClick": onClick
14194
+ }, [createVNode("div", {
14195
+ "class": "file-info"
14196
+ }, [createVNode(FoldIcon, {
14197
+ "class": {
14198
+ invert: !isFold.value
14199
+ }
14200
+ }, null), createVNode("span", {
14201
+ "class": "file-name"
14202
+ }, [diffInfo.newName]), createVNode("span", {
14203
+ "class": "diff-lines add-lines"
14204
+ }, [createTextVNode("+"), diffInfo.addedLines]), createVNode("span", {
14205
+ "class": "diff-lines delete-lines"
14206
+ }, [createTextVNode("-"), diffInfo.deletedLines]), createVNode(Popover, {
14207
+ "content": copyTipsText.value,
14208
+ "pop-type": tipsPopType.value,
14209
+ "trigger": "hover",
14210
+ "position": ["right"]
14211
+ }, {
14212
+ default: () => [createVNode(CopyIcon, {
14213
+ "class": "icon-copy",
14214
+ "onClick": onCopy
14215
+ }, null)]
14216
+ })]), rootCtx.slots.headOperate && createVNode("div", {
14217
+ "class": "operate-area"
14218
+ }, [rootCtx.slots.headOperate()])]);
14219
+ }
14220
+ });
14221
+ function useCodeReview(props, ctx2) {
14222
+ const { diff, fold, outputFormat } = toRefs(props);
14082
14223
  const renderHtml = ref("");
14083
- onMounted(() => {
14084
- renderHtml.value = Diff2Html.html(diff.value, {
14085
- drawFileList: true,
14224
+ const isFold = ref(fold.value);
14225
+ const diffFile = Diff2Html.parse(diff.value);
14226
+ const initDiffContent = () => {
14227
+ renderHtml.value = Diff2Html.html(diffFile, {
14228
+ drawFileList: false,
14086
14229
  matching: "lines",
14087
14230
  outputFormat: outputFormat.value
14088
14231
  });
14232
+ };
14233
+ const toggleFold = (status2) => {
14234
+ if (status2 !== void 0) {
14235
+ isFold.value = status2;
14236
+ } else {
14237
+ isFold.value = !isFold.value;
14238
+ }
14239
+ };
14240
+ watch(fold, (val) => {
14241
+ isFold.value = val;
14089
14242
  });
14090
- return { renderHtml };
14243
+ watch(isFold, () => {
14244
+ if (!isFold.value && renderHtml.value === "") {
14245
+ initDiffContent();
14246
+ }
14247
+ ctx2.emit("foldChange", isFold.value);
14248
+ });
14249
+ onBeforeMount(() => {
14250
+ if (!isFold.value) {
14251
+ initDiffContent();
14252
+ }
14253
+ });
14254
+ provide(CodeReviewInjectionKey, { diffInfo: diffFile[0], isFold, rootCtx: ctx2 });
14255
+ ctx2.expose({ toggleFold });
14256
+ return { renderHtml, isFold };
14091
14257
  }
14092
- var diff2html_min = "";
14093
14258
  var codeReview = "";
14094
14259
  var CodeReview = defineComponent({
14095
14260
  name: "DCodeReview",
14096
14261
  props: codeReviewProps,
14097
- setup(props) {
14262
+ emits: ["foldChange"],
14263
+ setup(props, ctx2) {
14098
14264
  const ns2 = useNamespace("code-review");
14099
14265
  const {
14100
- renderHtml
14101
- } = useCodeReview(props);
14266
+ renderHtml,
14267
+ isFold
14268
+ } = useCodeReview(props, ctx2);
14102
14269
  return () => createVNode("div", {
14103
- "class": ns2.b(),
14270
+ "class": ns2.b()
14271
+ }, [createVNode(CodeReviewHeader, {
14272
+ "onClick": () => isFold.value = !isFold.value
14273
+ }, null), createVNode("div", {
14274
+ "class": [ns2.e("content"), {
14275
+ "hide-content": isFold.value
14276
+ }],
14104
14277
  "innerHTML": renderHtml.value
14105
- }, null);
14278
+ }, null)]);
14106
14279
  }
14107
14280
  });
14108
14281
  var CodeReviewInstall = {
@@ -25208,7 +25381,7 @@ function useEditorMdRender(props, ctx2) {
25208
25381
  clearTimeout(timer);
25209
25382
  }
25210
25383
  timer = setTimeout(() => {
25211
- if (!content2.value) {
25384
+ if (content2.value === void 0) {
25212
25385
  return;
25213
25386
  }
25214
25387
  let html = renderService.generateHTML(content2.value);
@@ -42029,7 +42202,7 @@ const installs = [
42029
42202
  VirtualListInstall
42030
42203
  ];
42031
42204
  var vueDevui = {
42032
- version: "1.5.6",
42205
+ version: "1.5.7-hotfix.1",
42033
42206
  install(app) {
42034
42207
  installs.forEach((p) => app.use(p));
42035
42208
  }