vue-devui 1.6.19 → 1.6.21

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 (48) hide show
  1. package/action-timeline/index.es.js +12 -8
  2. package/action-timeline/index.umd.js +1 -1
  3. package/breadcrumb/index.es.js +6 -2
  4. package/breadcrumb/index.umd.js +2 -2
  5. package/category-search/index.es.js +1036 -2037
  6. package/category-search/index.umd.js +34 -34
  7. package/code-review/index.es.js +185 -9
  8. package/code-review/index.umd.js +27 -27
  9. package/code-review/style.css +1 -1
  10. package/data-grid/index.es.js +6 -2
  11. package/data-grid/index.umd.js +11 -11
  12. package/date-picker-pro/index.es.js +1 -1
  13. package/date-picker-pro/index.umd.js +1 -1
  14. package/dropdown/index.es.js +6 -2
  15. package/dropdown/index.umd.js +2 -2
  16. package/editable-select/index.es.js +1 -1
  17. package/editable-select/index.umd.js +1 -1
  18. package/editor-md/index.es.js +21 -8
  19. package/editor-md/index.umd.js +36 -36
  20. package/global.d.ts +0 -2
  21. package/input/index.es.js +1 -1
  22. package/input/index.umd.js +1 -1
  23. package/input-number/index.es.js +13 -9
  24. package/input-number/index.umd.js +10 -10
  25. package/package.json +1 -1
  26. package/pagination/index.es.js +7 -3
  27. package/pagination/index.umd.js +12 -12
  28. package/search/index.es.js +2 -8
  29. package/search/index.umd.js +1 -7
  30. package/select/index.es.js +1 -1
  31. package/select/index.umd.js +1 -1
  32. package/style.css +1 -1
  33. package/table/index.es.js +6 -2
  34. package/table/index.umd.js +11 -11
  35. package/time-picker/index.es.js +1 -1
  36. package/time-picker/index.umd.js +1 -1
  37. package/time-select/index.es.js +1 -1
  38. package/time-select/index.umd.js +1 -1
  39. package/tree/index.es.js +2 -2
  40. package/tree/index.umd.js +1 -1
  41. package/types/code-review/src/code-review-types.d.ts +4 -0
  42. package/types/code-review/src/composables/use-code-review-comment.d.ts +3 -0
  43. package/types/editor-md/src/composables/use-editor-md-toolbar.d.ts +1 -0
  44. package/types/editor-md/src/composables/use-editor-md.d.ts +2 -0
  45. package/types/editor-md/src/editor-md-types.d.ts +1 -0
  46. package/types/input-number/src/input-number-types.d.ts +10 -6
  47. package/vue-devui.es.js +455 -1273
  48. package/vue-devui.umd.js +98 -104
@@ -1,4 +1,4 @@
1
- import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, computed, nextTick, unref, withModifiers, Comment, Text, Fragment, h, inject, withDirectives, cloneVNode, onMounted, provide, Teleport, createTextVNode, vShow } from "vue";
1
+ import { watch, onUnmounted, defineComponent, toRefs, createVNode, Transition, mergeProps, ref, computed, nextTick, unref, withModifiers, Comment, Text, Fragment, h, inject, withDirectives, cloneVNode, onMounted, provide, Teleport, createTextVNode, onBeforeUnmount, vShow } from "vue";
2
2
  import { offset, flip, arrow, computePosition } from "@floating-ui/dom";
3
3
  import Clipboard from "clipboard";
4
4
  import * as Diff2Html from "diff2html";
@@ -6258,6 +6258,10 @@ const codeReviewProps = {
6258
6258
  type: Boolean,
6259
6259
  default: true
6260
6260
  },
6261
+ allowChecked: {
6262
+ type: Boolean,
6263
+ default: false
6264
+ },
6261
6265
  allowExpand: {
6262
6266
  type: Boolean,
6263
6267
  default: true
@@ -6513,6 +6517,17 @@ function updateExpandLineCount(expandDom, newExpandDom) {
6513
6517
  const newChangedNumRight = parseInt((curMatches == null ? void 0 : curMatches[4]) || "") + parseInt((newMatches == null ? void 0 : newMatches[4]) || "");
6514
6518
  expandDom.children[1].children[0].innerText = `@@ -${(newMatches == null ? void 0 : newMatches[1]) || 0},${newChangedNumLeft} +${(newMatches == null ? void 0 : newMatches[3]) || 0},${newChangedNumRight} @@`;
6515
6519
  }
6520
+ function addClassToDiffCode(codeStrArr, theClassName) {
6521
+ if (!codeStrArr || codeStrArr.length === 0) {
6522
+ return null;
6523
+ }
6524
+ const newArray = codeStrArr.map((item) => {
6525
+ const classNames = item == null ? void 0 : item.match(/class="([^"]+)"/)[1].split(" ");
6526
+ classNames.push(theClassName);
6527
+ return item.replace(/class="([^"]+)"/, `class="${classNames.join(" ")}"`);
6528
+ });
6529
+ return newArray;
6530
+ }
6516
6531
  function parseDiffCode(container, code, outputFormat, isAddCode = false) {
6517
6532
  var _a;
6518
6533
  const diff2HtmlUi = new Diff2HtmlUI(container, code, {
@@ -6532,8 +6547,10 @@ function parseDiffCode(container, code, outputFormat, isAddCode = false) {
6532
6547
  let newTrStr = "";
6533
6548
  const offset2 = trListLength / 2;
6534
6549
  for (let i = 0; i < trListLength / 2; i++) {
6535
- const leftTdList = trList[i].match(TableTdReg);
6536
- const rightTdList = trList[i + offset2].match(TableTdReg);
6550
+ let leftTdList = trList[i].match(TableTdReg);
6551
+ let rightTdList = trList[i + offset2].match(TableTdReg);
6552
+ leftTdList = addClassToDiffCode(leftTdList, "d-code-left");
6553
+ rightTdList = addClassToDiffCode(rightTdList, "d-code-right");
6537
6554
  newTrStr += `<tr>${leftTdList == null ? void 0 : leftTdList.join("")}${rightTdList == null ? void 0 : rightTdList.join("")}</tr>`;
6538
6555
  }
6539
6556
  const tbodyAttr = ((_a = diffHtmlStr.match(TableTbodyAttrReg)) == null ? void 0 : _a[1]) || "";
@@ -7010,13 +7027,24 @@ function useCodeReviewFold(props, ctx) {
7010
7027
  return { isFold, toggleFold };
7011
7028
  }
7012
7029
  function useCodeReviewComment(reviewContentRef, props, ctx) {
7013
- const { outputFormat, allowComment } = toRefs(props);
7030
+ const { outputFormat, allowComment, allowChecked } = toRefs(props);
7014
7031
  const ns2 = useNamespace("code-review");
7015
7032
  const commentLeft = ref(-100);
7016
7033
  const commentTop = ref(-100);
7017
7034
  let currentLeftLineNumber = -1;
7018
7035
  let currentRightLineNumber = -1;
7019
7036
  let lastLineNumberContainer;
7037
+ let checkedLineNumberContainer = [];
7038
+ let isShift = false;
7039
+ let currentLeftLineNumbers = [];
7040
+ let currentRightLineNumbers = [];
7041
+ let checkedLineCodeString = {};
7042
+ watch(() => outputFormat.value, () => {
7043
+ checkedLineNumberContainer = [];
7044
+ currentLeftLineNumbers = [];
7045
+ currentRightLineNumbers = [];
7046
+ checkedLineCodeString = [];
7047
+ });
7020
7048
  const resetLeftTop = () => {
7021
7049
  commentLeft.value = -100;
7022
7050
  commentTop.value = -100;
@@ -7099,6 +7127,141 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7099
7127
  resetLeftTop();
7100
7128
  }
7101
7129
  };
7130
+ function commentKeyDown(e) {
7131
+ switch (e.key) {
7132
+ case "Shift":
7133
+ isShift = true;
7134
+ break;
7135
+ }
7136
+ }
7137
+ function commentKeyUp(e) {
7138
+ e.preventDefault();
7139
+ switch (e.key) {
7140
+ case "Shift":
7141
+ isShift = false;
7142
+ break;
7143
+ }
7144
+ }
7145
+ const unCommentKeyDown = () => {
7146
+ document.removeEventListener("keydown", commentKeyDown);
7147
+ document.removeEventListener("keyup", commentKeyUp);
7148
+ };
7149
+ const onCommentKeyDown = () => {
7150
+ document.addEventListener("keydown", commentKeyDown);
7151
+ document.addEventListener("keyup", commentKeyUp);
7152
+ };
7153
+ const getLineNumbers = (currentNumber, currentNumbers, e) => {
7154
+ if (currentNumber === -1) {
7155
+ return currentNumbers;
7156
+ }
7157
+ if (currentNumbers.length === 0) {
7158
+ return [currentNumber];
7159
+ }
7160
+ const numbers = [...currentNumbers];
7161
+ let max = Math.max(...numbers);
7162
+ const min = Math.min(...numbers);
7163
+ if (currentNumber > max) {
7164
+ max = currentNumber;
7165
+ }
7166
+ return Array.from({ length: max - min + 1 }, (_, i) => i + min);
7167
+ };
7168
+ const getCommonClassAndJudge = (side) => {
7169
+ const lineClassName = side === "line-by-line" ? ".d2h-code-linenumber" : ".d2h-code-side-linenumber";
7170
+ const linenumberDom = reviewContentRef.value.querySelectorAll(lineClassName);
7171
+ const checkedLine = [currentLeftLineNumbers, currentRightLineNumbers];
7172
+ return {
7173
+ linenumberDom,
7174
+ checkedLine
7175
+ };
7176
+ };
7177
+ const addCommentCheckedClass = (Dom) => {
7178
+ !Dom.classList.contains("comment-checked") && Dom.classList.add("comment-checked");
7179
+ };
7180
+ const addCommentClassSingle = (side) => {
7181
+ const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
7182
+ const checkedCodeContent = [];
7183
+ for (let i = 0; i < linenumberDom.length; i++) {
7184
+ const lineNumberDomLeft = linenumberDom[i].children[0];
7185
+ const lineNumberDomRight = linenumberDom[i].children[1];
7186
+ if (lineNumberDomLeft || lineNumberDomRight) {
7187
+ const codeLineNumberLeft = parseInt(lineNumberDomLeft == null ? void 0 : lineNumberDomLeft.innerText);
7188
+ const codeLineNumberRight = parseInt(lineNumberDomRight == null ? void 0 : lineNumberDomRight.innerText);
7189
+ if (checkedLine[0].includes(codeLineNumberLeft) || checkedLine[1].includes(codeLineNumberRight)) {
7190
+ checkedLineNumberContainer.push(linenumberDom[i]);
7191
+ const codeNode = linenumberDom[i].nextSibling.nodeName === "#text" ? linenumberDom[i].nextSibling.nextSibling : linenumberDom[i].nextSibling;
7192
+ checkedCodeContent.push(codeNode == null ? void 0 : codeNode.innerText);
7193
+ addCommentCheckedClass(linenumberDom[i]);
7194
+ addCommentCheckedClass(codeNode);
7195
+ }
7196
+ }
7197
+ }
7198
+ checkedLineCodeString = checkedCodeContent;
7199
+ };
7200
+ const addCommentClassDouble = (side) => {
7201
+ var _a;
7202
+ const { linenumberDom, checkedLine } = getCommonClassAndJudge(side);
7203
+ const checkedCodeContentLeft = [];
7204
+ const checkedCodeContentRight = [];
7205
+ function checkedFunc(Dom) {
7206
+ checkedLineNumberContainer.push(Dom);
7207
+ const codeNode = Dom.nextSibling.nodeName === "#text" ? Dom.nextSibling.nextSibling : Dom.nextSibling;
7208
+ addCommentCheckedClass(Dom);
7209
+ addCommentCheckedClass(codeNode);
7210
+ return codeNode == null ? void 0 : codeNode.innerText;
7211
+ }
7212
+ for (let i = 0; i < linenumberDom.length; i++) {
7213
+ const codeLineNumber = parseInt((_a = linenumberDom[i]) == null ? void 0 : _a.innerHTML);
7214
+ if (linenumberDom[i].classList.contains("d-code-left") && checkedLine[0].includes(codeLineNumber)) {
7215
+ const lineNumText = checkedFunc(linenumberDom[i]);
7216
+ checkedCodeContentLeft.push(lineNumText);
7217
+ continue;
7218
+ }
7219
+ if (linenumberDom[i].classList.contains("d-code-right") && checkedLine[1].includes(codeLineNumber)) {
7220
+ const lineNumText = checkedFunc(linenumberDom[i]);
7221
+ checkedCodeContentRight.push(lineNumText);
7222
+ }
7223
+ }
7224
+ checkedLineCodeString = { leftCode: checkedCodeContentLeft, rightCode: checkedCodeContentRight };
7225
+ };
7226
+ const updateCheckedLineClass = () => {
7227
+ if (outputFormat.value === "line-by-line") {
7228
+ addCommentClassSingle(outputFormat.value);
7229
+ return;
7230
+ }
7231
+ addCommentClassDouble(outputFormat.value);
7232
+ };
7233
+ const resetCommentClass = () => {
7234
+ for (let i = 0; i < checkedLineNumberContainer.length; i++) {
7235
+ checkedLineNumberContainer[i].classList.remove("comment-checked");
7236
+ const codeNode = checkedLineNumberContainer[i].nextSibling.nodeName === "#text" ? checkedLineNumberContainer[i].nextSibling.nextSibling : checkedLineNumberContainer[i].nextSibling;
7237
+ codeNode == null ? void 0 : codeNode.classList.remove("comment-checked");
7238
+ }
7239
+ checkedLineNumberContainer = [];
7240
+ };
7241
+ const commentShiftClick = (e) => {
7242
+ currentLeftLineNumbers = currentLeftLineNumber === -1 ? currentLeftLineNumbers : getLineNumbers(currentLeftLineNumber, currentLeftLineNumbers);
7243
+ currentRightLineNumbers = currentRightLineNumber === -1 ? currentRightLineNumbers : getLineNumbers(currentRightLineNumber, currentRightLineNumbers);
7244
+ updateCheckedLineClass();
7245
+ };
7246
+ const commentClick = (e) => {
7247
+ let obj = { left: currentLeftLineNumber, right: currentRightLineNumber };
7248
+ if (currentLeftLineNumbers.length >= 1 || currentRightLineNumbers.length >= 1 && allowChecked.value) {
7249
+ const maxCurrentLeftLineNumber = currentLeftLineNumbers[currentLeftLineNumbers.length - 1];
7250
+ const maxCurrentRightLineNumber = currentRightLineNumbers[currentRightLineNumbers.length - 1];
7251
+ if (maxCurrentLeftLineNumber === currentLeftLineNumber || maxCurrentRightLineNumber === currentRightLineNumber) {
7252
+ obj = { left: currentLeftLineNumber, right: currentRightLineNumber, details: {
7253
+ lefts: currentLeftLineNumbers,
7254
+ rights: currentRightLineNumbers,
7255
+ codes: checkedLineCodeString
7256
+ } };
7257
+ } else {
7258
+ currentLeftLineNumbers = [];
7259
+ currentRightLineNumbers = [];
7260
+ resetCommentClass();
7261
+ }
7262
+ }
7263
+ ctx.emit("addComment", obj);
7264
+ };
7102
7265
  const onCommentIconClick = (e) => {
7103
7266
  if (e) {
7104
7267
  const composedPath = e.composedPath();
@@ -7112,9 +7275,11 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7112
7275
  return;
7113
7276
  }
7114
7277
  }
7115
- if (outputFormat.value === "line-by-line")
7116
- ;
7117
- ctx.emit("addComment", { left: currentLeftLineNumber, right: currentRightLineNumber });
7278
+ if (isShift && allowChecked.value) {
7279
+ commentShiftClick();
7280
+ return;
7281
+ }
7282
+ commentClick();
7118
7283
  };
7119
7284
  const insertComment = (lineNumber, lineSide, commentDom) => {
7120
7285
  if (outputFormat.value === "line-by-line") {
@@ -7163,8 +7328,11 @@ function useCodeReviewComment(reviewContentRef, props, ctx) {
7163
7328
  commentLeft,
7164
7329
  commentTop,
7165
7330
  mouseEvent,
7331
+ updateCheckedLineClass,
7166
7332
  onCommentMouseLeave,
7167
7333
  onCommentIconClick,
7334
+ onCommentKeyDown,
7335
+ unCommentKeyDown,
7168
7336
  insertComment,
7169
7337
  removeComment
7170
7338
  };
@@ -7195,15 +7363,23 @@ var CodeReview = defineComponent({
7195
7363
  mouseEvent,
7196
7364
  onCommentMouseLeave,
7197
7365
  onCommentIconClick,
7366
+ onCommentKeyDown,
7367
+ unCommentKeyDown,
7198
7368
  insertComment,
7199
- removeComment
7369
+ removeComment,
7370
+ updateCheckedLineClass
7200
7371
  } = useCodeReviewComment(reviewContentRef, props, ctx);
7201
7372
  onMounted(() => {
7202
7373
  ctx.emit("afterViewInit", {
7203
7374
  toggleFold,
7204
7375
  insertComment,
7205
- removeComment
7376
+ removeComment,
7377
+ updateCheckedLineClass
7206
7378
  });
7379
+ onCommentKeyDown();
7380
+ });
7381
+ onBeforeUnmount(() => {
7382
+ unCommentKeyDown();
7207
7383
  });
7208
7384
  provide(CodeReviewInjectionKey, {
7209
7385
  diffType,