vue-devui 1.5.7-hotfix.3 → 1.5.8

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/vue-devui.es.js CHANGED
@@ -6642,7 +6642,7 @@ var lodash = { exports: {} };
6642
6642
  position -= target.length;
6643
6643
  return position >= 0 && string3.slice(position, end) == target;
6644
6644
  }
6645
- function escape(string3) {
6645
+ function escape2(string3) {
6646
6646
  string3 = toString(string3);
6647
6647
  return string3 && reHasUnescapedHtml.test(string3) ? string3.replace(reUnescapedHtml, escapeHtmlChar) : string3;
6648
6648
  }
@@ -7245,7 +7245,7 @@ var lodash = { exports: {} };
7245
7245
  lodash2.divide = divide;
7246
7246
  lodash2.endsWith = endsWith;
7247
7247
  lodash2.eq = eq2;
7248
- lodash2.escape = escape;
7248
+ lodash2.escape = escape2;
7249
7249
  lodash2.escapeRegExp = escapeRegExp;
7250
7250
  lodash2.every = every;
7251
7251
  lodash2.find = find;
@@ -14156,6 +14156,88 @@ function CopyIcon() {
14156
14156
  "fill-rule": "nonzero"
14157
14157
  }, null)])]);
14158
14158
  }
14159
+ function CommentIcon() {
14160
+ return createVNode("svg", {
14161
+ "width": "12px",
14162
+ "height": "12px",
14163
+ "viewBox": "0 0 16 16",
14164
+ "version": "1.1",
14165
+ "xmlns": "http://www.w3.org/2000/svg"
14166
+ }, [createVNode("g", {
14167
+ "stroke": "none",
14168
+ "stroke-width": "1",
14169
+ "fill": "none",
14170
+ "fill-rule": "evenodd"
14171
+ }, [createVNode("path", {
14172
+ "d": `M14,1 C15.1045695,1 16,1.8954305 16,3 L16,11 C16,12.1045695 15.1045695,13 14,13 L11,13 L8,16 L5,13 L2,13
14173
+ C0.8954305,13 0,12.1045695 0,11 L0,3 C0,1.8954305 0.8954305,1 2,1 L14,1 Z M14,3 L2,3 L2,11 L5,11 C5.47149598,11
14174
+ 5.92582641,11.1664898 6.28439337,11.4669131 L6.41421356,11.5857864 L8,13.171 L9.58578644,11.5857864
14175
+ C9.91918444,11.2523884 10.3581707,11.0488544 10.8241472,11.0077406 L11,11 L14,11 L14,3 Z M8,6 C8.55228475,6
14176
+ 9,6.44771525 9,7 C9,7.55228475 8.55228475,8 8,8 C7.44771525,8 7,7.55228475 7,7 C7,6.44771525 7.44771525,6
14177
+ 8,6 Z M11,6 C11.5522847,6 12,6.44771525 12,7 C12,7.55228475 11.5522847,8 11,8 C10.4477153,8 10,7.55228475
14178
+ 10,7 C10,6.44771525 10.4477153,6 11,6 Z M5,6 C5.55228475,6 6,6.44771525 6,7 C6,7.55228475 5.55228475,8
14179
+ 5,8 C4.44771525,8 4,7.55228475 4,7 C4,6.44771525 4.44771525,6 5,6 Z`,
14180
+ "fill": "#5e7ce0",
14181
+ "fill-rule": "nonzero"
14182
+ }, null)])]);
14183
+ }
14184
+ function UpExpandIcon() {
14185
+ return `<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
14186
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
14187
+ <g transform="translate(-1365.000000,-11.000000)">
14188
+ <g transform="translate(1365.000000,11.000000)">
14189
+ <rect x="0" y="0" width="16" height="16"></rect>
14190
+ <g
14191
+ transform="translate(8.000000, 8.000000) scale(1, -1) translate(-8.000000, -8.000000) translate(1.000000, 4.000000)"
14192
+ fill="#71757F">
14193
+ <path
14194
+ d='M0.5,0 L13.5,0 C13.7761424,0 14,0.223857625 14,0.5 C14,0.776142375 13.7761424,1 13.5,1 L0.5,1 C0.223857625,1
14195
+ 0,0.776142375 0,0.5 C0,0.223857625 0.223857625,0 0.5,0 Z'></path>
14196
+ <polygon
14197
+ transform="translate(7.000000, 5.5000000) scale(1, -1) translate(-7.000000, -5.5000000)"
14198
+ points="7 3 10 8 4 8"></polygon>
14199
+ </g>
14200
+ </g>
14201
+ </g>
14202
+ </g>
14203
+ </svg>`;
14204
+ }
14205
+ function DownExpandIcon() {
14206
+ return `<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
14207
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
14208
+ <g transform="translate(-1344.000000,-11.000000)">
14209
+ <g transform="translate(1344.000000,11.000000)">
14210
+ <rect x="0" y="0" width="16" height="16"></rect>
14211
+ <g transform="translate(1.000000, 5.000000)" fill="#71757F">
14212
+ <path
14213
+ d="M0.5,0 L13.5,0 C13.7761424,0 14,0.223857625 14,0.5 C14,0.776142375 13.7761424,1 13.5,1 L0.5,1 C0.223857625,1
14214
+ 0,0.776142375 0,0.5 C0,0.223857625 0.223857625,0 0.5,0 Z"></path>
14215
+ <polygon
14216
+ transform="translate(7.000000,5.500000) scale(1, -1) translate(-7.000000, -5.500000)"
14217
+ points="7 3 10 8 4 8"></polygon>
14218
+ </g>
14219
+ </g>
14220
+ </g>
14221
+ </g>
14222
+ </svg>`;
14223
+ }
14224
+ function AllExpandIcon() {
14225
+ return `<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
14226
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
14227
+ <g transform="translate(-1301.000000,-11.000000)">
14228
+ <rect x="1301" y="11" width="16" height="16"></rect>
14229
+ <path
14230
+ d="M1302.5,18 L1315.5,18 C1315.77614,18 1316,18.2238576 1316,18.5 1316,18.7761424 1315.77614,19 1315.5,19 L1302.5,19
14231
+ C1302.22386,19 1302,18.7761424 1302,18.5 C1302,18.2238576 1302.22386,18 1302.5,18 Z" fill="#71757F"></path>
14232
+ <polygon fill="#71757F" points="1309 11 1312 16 1306 16"></polygon>
14233
+ <polygon
14234
+ fill="#71757F"
14235
+ transform="translate(1309.000000, 23.500000) scale(1, -1) translate(-1309.000000, -23.500000)"
14236
+ points="1309 21 1312 26 1306 26"></polygon>
14237
+ </g>
14238
+ </g>
14239
+ </svg>`;
14240
+ }
14159
14241
  const codeReviewProps = {
14160
14242
  diff: {
14161
14243
  type: String,
@@ -14169,6 +14251,10 @@ const codeReviewProps = {
14169
14251
  outputFormat: {
14170
14252
  type: String,
14171
14253
  default: "line-by-line"
14254
+ },
14255
+ expandAllThreshold: {
14256
+ type: Number,
14257
+ default: 50
14172
14258
  }
14173
14259
  };
14174
14260
  const CodeReviewInjectionKey = Symbol("d-code-review");
@@ -14238,17 +14324,159 @@ var CodeReviewHeader = defineComponent({
14238
14324
  }, [rootCtx.slots.headOperate()])]);
14239
14325
  }
14240
14326
  });
14327
+ const ExpandLineReg = /^@@ -(\d+),(\d+) \+(\d+),(\d+) @@/;
14328
+ const FirstLineReg = /^@@ -[0,1](?!\d)/;
14329
+ function notEmptyNode(node) {
14330
+ const classes = node.classList;
14331
+ return !classes.contains("d2h-info") && !classes.contains("d2h-emptyplaceholder") && !classes.contains("comment-cell");
14332
+ }
14333
+ function insertNode(parent, child) {
14334
+ if (parent.firstChild) {
14335
+ parent.insertBefore(child, parent.firstChild);
14336
+ } else {
14337
+ parent.appendChild(child);
14338
+ }
14339
+ }
14340
+ function addExpandButton(parentNode, className2, icon2) {
14341
+ const expandButton = document.createElement("div");
14342
+ expandButton.innerHTML = icon2;
14343
+ expandButton.classList.add("expand-icon");
14344
+ expandButton.classList.add(className2);
14345
+ insertNode(parentNode, expandButton);
14346
+ }
14347
+ function attachExpandUpDownButton(parentNode, direction) {
14348
+ var _a;
14349
+ const expandDirectionMap = {
14350
+ up: "up-expand",
14351
+ down: "down-expand",
14352
+ all: "all-expand"
14353
+ };
14354
+ const expandDirectionIconMap = {
14355
+ up: UpExpandIcon,
14356
+ down: DownExpandIcon,
14357
+ all: AllExpandIcon
14358
+ };
14359
+ parentNode.classList.add("expand-icon-wrapper");
14360
+ if (direction === "updown") {
14361
+ addExpandButton(parentNode, "up-expand", UpExpandIcon());
14362
+ addExpandButton(parentNode, "down-expand", DownExpandIcon());
14363
+ } else {
14364
+ addExpandButton(parentNode, expandDirectionMap[direction], (_a = expandDirectionIconMap[direction]) == null ? void 0 : _a.call(expandDirectionIconMap));
14365
+ }
14366
+ }
14367
+ function addCommentToPage(lineHost, commentDom, lineSide) {
14368
+ var _a, _b;
14369
+ const newLine = document.createElement("tr");
14370
+ const newCell = document.createElement("td");
14371
+ newCell.classList.add("comment-cell");
14372
+ newCell.style.width = "100%";
14373
+ newCell.setAttribute("colspan", "2");
14374
+ newCell.appendChild(commentDom);
14375
+ newLine.classList.add("comment-block");
14376
+ newLine.classList.add(lineSide);
14377
+ newLine.appendChild(newCell);
14378
+ if (lineHost.nextElementSibling) {
14379
+ (_a = lineHost.parentElement) == null ? void 0 : _a.insertBefore(newLine, lineHost.nextElementSibling);
14380
+ } else {
14381
+ (_b = lineHost.parentElement) == null ? void 0 : _b.appendChild(newLine);
14382
+ }
14383
+ }
14384
+ function useCodeReviewExpand(reviewContentRef, expandAllThreshold, outputFormat) {
14385
+ const processSideBySide = () => {
14386
+ const [leftTable, rightTable] = reviewContentRef.value.querySelectorAll("table");
14387
+ const trNodes = Array.from(leftTable.querySelectorAll("tr"));
14388
+ const totalLines = trNodes.length;
14389
+ for (const index2 in trNodes) {
14390
+ const lineIndex = parseInt(index2);
14391
+ const lineChildren = Array.from(trNodes[lineIndex].children);
14392
+ const lineNumberBox = lineChildren[0];
14393
+ const lineContentBox = lineChildren[1];
14394
+ const lineClassList = lineContentBox.classList.value;
14395
+ const lineContent = lineContentBox.innerText.trim();
14396
+ if (lineContent.match(ExpandLineReg) && !FirstLineReg.test(lineContent) && lineClassList && lineClassList.includes("d2h-info")) {
14397
+ const nextLineIndex = lineIndex + 1;
14398
+ const prevLineIndex = lineIndex - 1;
14399
+ if (lineIndex === 0 && nextLineIndex in trNodes) {
14400
+ attachExpandUpDownButton(lineNumberBox, "up");
14401
+ } else if (lineIndex > 0 && lineIndex < totalLines - 1 && nextLineIndex in trNodes && prevLineIndex in trNodes) {
14402
+ const preLineChildren = Array.from(trNodes[prevLineIndex].children);
14403
+ const nextLineChildren = Array.from(trNodes[nextLineIndex].children);
14404
+ const isExpandAll = parseInt(nextLineChildren[0].innerText) - parseInt(preLineChildren[0].innerText) - 1 < expandAllThreshold;
14405
+ attachExpandUpDownButton(lineNumberBox, isExpandAll ? "all" : "updown");
14406
+ }
14407
+ }
14408
+ }
14409
+ const endLine = trNodes[0].cloneNode(true);
14410
+ if (Object.prototype.hasOwnProperty.call(endLine.children[0].children, 0)) {
14411
+ endLine.children[0].removeChild(endLine.children[0].children[0]);
14412
+ }
14413
+ endLine.children[1].innerText = "";
14414
+ const leftEndLine = endLine.cloneNode(true);
14415
+ const rightEndLint = endLine.cloneNode(true);
14416
+ attachExpandUpDownButton(leftEndLine.children[0], "down");
14417
+ leftTable.tBodies[0].appendChild(leftEndLine);
14418
+ rightTable.tBodies[0].appendChild(rightEndLint);
14419
+ };
14420
+ const processLineByLine = () => {
14421
+ var _a;
14422
+ const trNodes = Array.from(reviewContentRef.value.querySelectorAll("tr"));
14423
+ const totalLines = trNodes.length;
14424
+ for (const index2 in trNodes) {
14425
+ const lineIndex = parseInt(index2);
14426
+ const tdNodes = Array.from(trNodes[lineIndex].children);
14427
+ const lineNumberBox = tdNodes[0];
14428
+ const lineContentBox = tdNodes[1];
14429
+ if (!lineContentBox) {
14430
+ continue;
14431
+ }
14432
+ const lineClassList = lineContentBox.classList.value;
14433
+ const lineContent = lineContentBox.innerText.trim();
14434
+ if (lineContent.match(ExpandLineReg) && !FirstLineReg.test(lineContent) && lineClassList && lineClassList.includes("d2h-info")) {
14435
+ const nextLineIndex = lineIndex + 1;
14436
+ const prevLineIndex = lineIndex - 1;
14437
+ if (lineIndex === 0 && nextLineIndex in trNodes) {
14438
+ attachExpandUpDownButton(lineNumberBox, "up");
14439
+ } else if (lineIndex > 0 && lineIndex < totalLines - 1 && nextLineIndex in trNodes && prevLineIndex in trNodes) {
14440
+ const prevTdNodes = Array.from(trNodes[prevLineIndex].children);
14441
+ const prevLineNumber = parseInt(prevTdNodes[0].children[0].innerText);
14442
+ const nextTdNodes = Array.from(trNodes[nextLineIndex].children);
14443
+ const nextLineNumber = parseInt(nextTdNodes[0].children[0].innerText);
14444
+ const isExpandAll = nextLineNumber - prevLineNumber - 1 < expandAllThreshold;
14445
+ attachExpandUpDownButton(lineNumberBox, isExpandAll ? "all" : "updown");
14446
+ }
14447
+ }
14448
+ }
14449
+ const loadMoreLine = trNodes[0].cloneNode(true);
14450
+ loadMoreLine.children[0].removeChild(loadMoreLine.children[0].children[0]);
14451
+ loadMoreLine.children[1].innerText = "";
14452
+ loadMoreLine.children[1].style.height = "20px";
14453
+ const lastTrNode = trNodes[totalLines - 1].children;
14454
+ const leftLineStart = parseInt(lastTrNode[0].children[0].innerText) + 1;
14455
+ const rightLineStart = parseInt(lastTrNode[0].children[1].innerText) + 1;
14456
+ if (leftLineStart && rightLineStart) {
14457
+ attachExpandUpDownButton(loadMoreLine.children[0], "down");
14458
+ }
14459
+ (_a = trNodes[0].parentElement) == null ? void 0 : _a.appendChild(loadMoreLine);
14460
+ };
14461
+ const insertExpandButton = () => {
14462
+ outputFormat === "side-by-side" ? processSideBySide() : processLineByLine();
14463
+ };
14464
+ return { insertExpandButton };
14465
+ }
14241
14466
  function useCodeReview(props, ctx2) {
14242
- const { diff, fold, outputFormat } = toRefs(props);
14467
+ const { diff, fold, outputFormat, expandAllThreshold } = toRefs(props);
14243
14468
  const renderHtml = ref("");
14244
14469
  const isFold = ref(fold.value);
14470
+ const reviewContentRef = ref();
14245
14471
  const diffFile = Diff2Html.parse(diff.value);
14472
+ const { insertExpandButton } = useCodeReviewExpand(reviewContentRef, expandAllThreshold.value, outputFormat.value);
14246
14473
  const initDiffContent = () => {
14247
14474
  renderHtml.value = Diff2Html.html(diffFile, {
14248
14475
  drawFileList: false,
14249
14476
  matching: "lines",
14250
14477
  outputFormat: outputFormat.value
14251
14478
  });
14479
+ nextTick(insertExpandButton);
14252
14480
  };
14253
14481
  const toggleFold = (status2) => {
14254
14482
  if (status2 !== void 0) {
@@ -14271,21 +14499,130 @@ function useCodeReview(props, ctx2) {
14271
14499
  initDiffContent();
14272
14500
  }
14273
14501
  });
14274
- provide(CodeReviewInjectionKey, { diffInfo: diffFile[0], isFold, rootCtx: ctx2 });
14275
- ctx2.expose({ toggleFold });
14276
- return { renderHtml, isFold };
14502
+ provide(CodeReviewInjectionKey, { reviewContentRef, diffInfo: diffFile[0], isFold, rootCtx: ctx2 });
14503
+ return { renderHtml, isFold, reviewContentRef, toggleFold };
14504
+ }
14505
+ function useCodeReviewComment(reviewContentRef, ctx2) {
14506
+ const ns2 = useNamespace("code-review");
14507
+ const commentLeft = ref(-100);
14508
+ const commentTop = ref(-100);
14509
+ let currentLeftLineNumber = -1;
14510
+ let currentRightLineNumber = -1;
14511
+ const resetLeftTop = () => {
14512
+ commentLeft.value = -100;
14513
+ commentTop.value = -100;
14514
+ currentLeftLineNumber = -1;
14515
+ currentRightLineNumber = -1;
14516
+ };
14517
+ const onMouseEnter = (e) => {
14518
+ e.currentTarget.getBoundingClientRect();
14519
+ };
14520
+ const onMouseMove = (e) => {
14521
+ var _a, _b;
14522
+ const composedPath = e.composedPath();
14523
+ const trNode = composedPath.find((item) => item.tagName === "TR");
14524
+ if (trNode) {
14525
+ const lineNumberContainer = Array.from(trNode.children)[0];
14526
+ if (notEmptyNode(lineNumberContainer)) {
14527
+ const { top, left } = lineNumberContainer.getBoundingClientRect();
14528
+ commentLeft.value = left;
14529
+ commentTop.value = top;
14530
+ currentLeftLineNumber = parseInt((_a = lineNumberContainer.children[0]) == null ? void 0 : _a.innerText) || -1;
14531
+ currentRightLineNumber = parseInt((_b = lineNumberContainer.children[1]) == null ? void 0 : _b.innerText) || -1;
14532
+ } else {
14533
+ resetLeftTop();
14534
+ }
14535
+ }
14536
+ };
14537
+ const onMouseleave = (e) => {
14538
+ var _a;
14539
+ if (!((_a = e.relatedTarget) == null ? void 0 : _a.classList.contains("comment-icon"))) {
14540
+ resetLeftTop();
14541
+ }
14542
+ };
14543
+ const onCommentMouseLeave = (e) => {
14544
+ var _a;
14545
+ if (!((_a = e.relatedTarget) == null ? void 0 : _a.classList.contains(ns2.e("content")))) {
14546
+ resetLeftTop();
14547
+ }
14548
+ };
14549
+ const onCommentIconClick = () => {
14550
+ ctx2.emit("addComment", { left: currentLeftLineNumber, right: currentRightLineNumber });
14551
+ };
14552
+ const findReferenceDom = (lineNumber, lineSide) => {
14553
+ var _a, _b, _c, _d;
14554
+ const trNodes = Array.from(reviewContentRef.value.querySelectorAll("tr"));
14555
+ for (const index2 in trNodes) {
14556
+ const lineIndex = parseInt(index2);
14557
+ const lineNumberBox = Array.from(trNodes[lineIndex].children)[0];
14558
+ if (notEmptyNode(lineNumberBox)) {
14559
+ const oldLineNumber = parseInt((_b = (_a = lineNumberBox.children[0]) == null ? void 0 : _a.innerText) != null ? _b : -1);
14560
+ const newLineNumber = parseInt((_d = (_c = lineNumberBox.children[1]) == null ? void 0 : _c.innerText) != null ? _d : -1);
14561
+ if (lineSide === "left" && oldLineNumber === lineNumber || lineSide === "right" && newLineNumber === lineNumber) {
14562
+ return trNodes[lineIndex];
14563
+ }
14564
+ }
14565
+ }
14566
+ };
14567
+ const insertComment = (lineNumber, lineSide, commentDom) => {
14568
+ const lineHost = findReferenceDom(lineNumber, lineSide);
14569
+ lineHost && addCommentToPage(lineHost, commentDom, lineSide);
14570
+ };
14571
+ const removeComment = (lineNumber, lineSide) => {
14572
+ const lineHost = findReferenceDom(lineNumber, lineSide);
14573
+ let nextLineHost = lineHost == null ? void 0 : lineHost.nextElementSibling;
14574
+ while (nextLineHost) {
14575
+ const classList = nextLineHost == null ? void 0 : nextLineHost.classList;
14576
+ if ((classList == null ? void 0 : classList.contains("comment-block")) && classList.contains(lineSide)) {
14577
+ nextLineHost.remove();
14578
+ return;
14579
+ }
14580
+ nextLineHost = nextLineHost.nextElementSibling;
14581
+ }
14582
+ };
14583
+ return {
14584
+ commentLeft,
14585
+ commentTop,
14586
+ onMouseEnter,
14587
+ onMouseMove,
14588
+ onMouseleave,
14589
+ onCommentMouseLeave,
14590
+ onCommentIconClick,
14591
+ insertComment,
14592
+ removeComment
14593
+ };
14277
14594
  }
14278
14595
  var codeReview = "";
14279
14596
  var CodeReview = defineComponent({
14280
14597
  name: "DCodeReview",
14281
14598
  props: codeReviewProps,
14282
- emits: ["foldChange"],
14599
+ emits: ["foldChange", "addComment", "afterViewInit"],
14283
14600
  setup(props, ctx2) {
14284
14601
  const ns2 = useNamespace("code-review");
14285
14602
  const {
14286
14603
  renderHtml,
14287
- isFold
14604
+ isFold,
14605
+ reviewContentRef,
14606
+ toggleFold
14288
14607
  } = useCodeReview(props, ctx2);
14608
+ const {
14609
+ commentLeft,
14610
+ commentTop,
14611
+ onMouseEnter,
14612
+ onMouseMove,
14613
+ onMouseleave,
14614
+ onCommentMouseLeave,
14615
+ onCommentIconClick,
14616
+ insertComment,
14617
+ removeComment
14618
+ } = useCodeReviewComment(reviewContentRef, ctx2);
14619
+ onMounted(() => {
14620
+ ctx2.emit("afterViewInit", {
14621
+ toggleFold,
14622
+ insertComment,
14623
+ removeComment
14624
+ });
14625
+ });
14289
14626
  return () => createVNode("div", {
14290
14627
  "class": ns2.b()
14291
14628
  }, [createVNode(CodeReviewHeader, {
@@ -14294,8 +14631,20 @@ var CodeReview = defineComponent({
14294
14631
  "class": [ns2.e("content"), {
14295
14632
  "hide-content": isFold.value
14296
14633
  }],
14297
- "innerHTML": renderHtml.value
14298
- }, null)]);
14634
+ "innerHTML": renderHtml.value,
14635
+ "ref": reviewContentRef,
14636
+ "onMouseenter": onMouseEnter,
14637
+ "onMousemove": onMouseMove,
14638
+ "onMouseleave": onMouseleave
14639
+ }, null), createVNode("div", {
14640
+ "class": "comment-icon",
14641
+ "style": {
14642
+ left: commentLeft.value + "px",
14643
+ top: commentTop.value + "px"
14644
+ },
14645
+ "onClick": onCommentIconClick,
14646
+ "onMouseleave": onCommentMouseLeave
14647
+ }, [createVNode(CommentIcon, null, null)])]);
14299
14648
  }
14300
14649
  });
14301
14650
  var CodeReviewInstall = {
@@ -26148,6 +26497,633 @@ var GanttInstall = {
26148
26497
  app.use(Gantt);
26149
26498
  }
26150
26499
  };
26500
+ const gitGraphProps = {
26501
+ option: {
26502
+ type: Object
26503
+ }
26504
+ };
26505
+ class GitGraph$1 {
26506
+ constructor() {
26507
+ __publicField(this, "element");
26508
+ __publicField(this, "options");
26509
+ __publicField(this, "mtime", 0);
26510
+ __publicField(this, "mspace", 0);
26511
+ __publicField(this, "parents", {});
26512
+ __publicField(this, "offsetX", 70);
26513
+ __publicField(this, "offsetY", 60);
26514
+ __publicField(this, "unitTime", 50);
26515
+ __publicField(this, "unitSpace", 15);
26516
+ __publicField(this, "prev_start", -1);
26517
+ __publicField(this, "preparedCommits", {});
26518
+ __publicField(this, "preStart", 1);
26519
+ __publicField(this, "isDark", false);
26520
+ __publicField(this, "daysBefore", "\u5929\u524D");
26521
+ __publicField(this, "hoursAgo", "\u5C0F\u65F6\u524D");
26522
+ __publicField(this, "minutesAgo", "\u5206\u949F\u524D");
26523
+ __publicField(this, "aMinutesAgo", "1\u5206\u949F\u524D");
26524
+ __publicField(this, "maxNameLength", 25);
26525
+ __publicField(this, "commits", []);
26526
+ __publicField(this, "graphHeight", 0);
26527
+ __publicField(this, "graphWidth", 0);
26528
+ __publicField(this, "svg");
26529
+ __publicField(this, "barHeight", 0);
26530
+ __publicField(this, "messageBoxWidth", 0);
26531
+ __publicField(this, "colors", [
26532
+ "#5C8DFF",
26533
+ "#BC94FF",
26534
+ "#54D2EB",
26535
+ "#A6DD82",
26536
+ "#FCDA6B",
26537
+ "#CA7ED6",
26538
+ "#7298F1",
26539
+ "#73CEA6",
26540
+ "#EDD249",
26541
+ "#CAABFF",
26542
+ "#85CAFF",
26543
+ "#93D99A",
26544
+ "#96ADFA",
26545
+ "#F4AF8F",
26546
+ "#A282E9",
26547
+ "#FFBB6B",
26548
+ "#69DBB9",
26549
+ "#76DBEF",
26550
+ "#B1CE4F",
26551
+ "#5DA4DC"
26552
+ ]);
26553
+ __publicField(this, "toolTipList");
26554
+ }
26555
+ load(element, options, isDark) {
26556
+ this.element = element;
26557
+ this.options = options;
26558
+ this.isDark = !!isDark;
26559
+ this.daysBefore = options.params.daysBefore || this.daysBefore;
26560
+ this.hoursAgo = options.params.hoursAgo || this.hoursAgo;
26561
+ this.minutesAgo = options.params.minutesAgo || this.minutesAgo;
26562
+ this.aMinutesAgo = options.params.aMinutesAgo || this.aMinutesAgo;
26563
+ this.maxNameLength = options.params.maxNameLength || 25;
26564
+ const commits = lodash.exports.cloneDeep(this.options.data.commits);
26565
+ this.prepareData(commits);
26566
+ return this.buildGraph("refName");
26567
+ }
26568
+ prepareData(commits) {
26569
+ var _a;
26570
+ let c;
26571
+ this.commits = commits;
26572
+ this.collectParent();
26573
+ this.graphHeight = this.element.getBoundingClientRect().height;
26574
+ this.graphWidth = this.element.getBoundingClientRect().width;
26575
+ const ch = Math.max(this.graphHeight, this.offsetY + this.unitTime * this.mtime + 150);
26576
+ Math.max(this.graphWidth, this.offsetX + this.unitSpace * this.mspace + 300);
26577
+ this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
26578
+ this.svg.setAttribute("height", ch + "");
26579
+ this.svg.setAttribute("width", "100%");
26580
+ (_a = this.element) == null ? void 0 : _a.appendChild(this.svg);
26581
+ this.barHeight = Math.max(this.graphHeight, this.unitTime * this.commits.length + 320);
26582
+ const _ref = this.commits;
26583
+ for (let _i = 0; _i < _ref.length; _i++) {
26584
+ c = _ref[_i];
26585
+ this.preparedCommits[c.id] = c;
26586
+ }
26587
+ }
26588
+ collectParent() {
26589
+ let c;
26590
+ let p;
26591
+ let _i;
26592
+ let _len;
26593
+ const _this = this;
26594
+ const _ref = this.commits;
26595
+ const _results = [];
26596
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
26597
+ c = _ref[_i];
26598
+ this.mtime = Math.max(this.mtime, c.time);
26599
+ this.mspace = Math.max(this.mspace, c.space);
26600
+ _results.push(function() {
26601
+ let _j;
26602
+ let _len2;
26603
+ const _ref2 = c.parents;
26604
+ const _result2 = [];
26605
+ for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
26606
+ p = _ref2[_j];
26607
+ _this.parents[p[0]] = true;
26608
+ _result2.push(_this.mspace = Math.max(_this.mspace, p[1]));
26609
+ }
26610
+ return _result2;
26611
+ }.call(_this));
26612
+ }
26613
+ return _results;
26614
+ }
26615
+ buildGraph(refName) {
26616
+ let curDay = new Date(0);
26617
+ let day;
26618
+ let mm;
26619
+ let _len;
26620
+ const _ref = this.commits;
26621
+ for (mm = 0, _len = _ref.length; mm < _len; mm++) {
26622
+ day = _ref[mm].date;
26623
+ if (curDay.getDate() !== new Date(day).getDate() || curDay.getMonth() !== new Date(day).getMonth() || curDay.getFullYear() !== new Date(day).getFullYear()) {
26624
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
26625
+ const date4 = new Date(day);
26626
+ const attrs = {
26627
+ x: this.offsetX + this.unitSpace * this.mspace + 56,
26628
+ y: this.offsetY + this.unitTime * mm - 22,
26629
+ "font-size": "12px",
26630
+ fill: "#999",
26631
+ "text-anchor": "start"
26632
+ };
26633
+ this.setNodeAttr(text, attrs);
26634
+ const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
26635
+ tspan.appendChild(document.createTextNode(date4.getFullYear() + " / " + (date4.getMonth() + 1) + " / " + date4.getDate()));
26636
+ text.appendChild(tspan);
26637
+ this.svg.appendChild(text);
26638
+ curDay = date4;
26639
+ }
26640
+ }
26641
+ this.renderPartialGraph(refName);
26642
+ }
26643
+ setNodeAttr(node, attrs) {
26644
+ Object.keys(attrs).forEach((key) => {
26645
+ node.setAttribute(key, attrs[key]);
26646
+ });
26647
+ }
26648
+ __transform(time) {
26649
+ let timeTip = "";
26650
+ const now = new Date().getTime();
26651
+ const commitTime = new Date(time).getTime();
26652
+ const day = (now - commitTime) / (60 * 60 * 24 * 1e3);
26653
+ const hour = (now - commitTime) / (60 * 60 * 1e3);
26654
+ const minutes = (now - commitTime) / (60 * 1e3);
26655
+ if (day >= 1) {
26656
+ timeTip = Math.floor(day) + this.daysBefore;
26657
+ } else {
26658
+ if (hour >= 1) {
26659
+ timeTip = Math.floor(hour) + this.hoursAgo;
26660
+ } else {
26661
+ if (minutes >= 1) {
26662
+ timeTip = Math.floor(minutes) + this.minutesAgo;
26663
+ } else {
26664
+ timeTip = this.aMinutesAgo;
26665
+ }
26666
+ }
26667
+ }
26668
+ return timeTip;
26669
+ }
26670
+ renderPartialGraph(refName) {
26671
+ let commit;
26672
+ let end;
26673
+ let i;
26674
+ let isGraphEdge;
26675
+ let start;
26676
+ let x;
26677
+ let y;
26678
+ start = Math.floor((this.element.scrollTop - this.offsetY) / this.unitTime) - 10;
26679
+ if (start < 0) {
26680
+ isGraphEdge = true;
26681
+ start = 0;
26682
+ }
26683
+ end = this.element.scrollHeight > this.element.clientHeight ? start + 40 : Infinity;
26684
+ if (this.preStart <= end) {
26685
+ isGraphEdge = true;
26686
+ start = this.preStart - 1;
26687
+ this.preStart = end;
26688
+ }
26689
+ if (this.commits.length < end) {
26690
+ isGraphEdge = true;
26691
+ end = this.commits.length;
26692
+ }
26693
+ if (this.prev_start === -1 || Math.abs(this.prev_start - start) > 10 || isGraphEdge) {
26694
+ i = start;
26695
+ this.prev_start = start;
26696
+ while (i < end) {
26697
+ commit = this.commits[i];
26698
+ i += 1;
26699
+ if (commit["hasDrawn"] !== true) {
26700
+ x = this.offsetX + this.unitSpace * (this.mspace - commit.space);
26701
+ y = this.offsetY + this.unitTime * commit.time;
26702
+ this.drawDot(x, y, commit);
26703
+ this.drawLines(x, y, commit);
26704
+ this.appendLabel(x, y, commit);
26705
+ this.appendAnchor(x, y, commit, refName);
26706
+ commit["hasDrawn"] = true;
26707
+ }
26708
+ }
26709
+ }
26710
+ }
26711
+ drawDot(x, y, commit) {
26712
+ const options = this.options;
26713
+ const isdark = this.isDark;
26714
+ const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
26715
+ const attrs = {
26716
+ cx: x,
26717
+ cy: y,
26718
+ r: 4,
26719
+ fill: "#fff",
26720
+ strokeWidth: 1,
26721
+ stroke: this.colors[commit.space],
26722
+ style: "cursor: pointer;"
26723
+ };
26724
+ this.setNodeAttr(circle, attrs);
26725
+ this.svg.appendChild(circle);
26726
+ const avatar_box_x = this.offsetX + this.unitSpace * this.mspace + 16;
26727
+ const avatar_box_y = y - 13;
26728
+ const img = document.createElementNS("http://www.w3.org/2000/svg", "image");
26729
+ const imgAttrs = {
26730
+ width: 30,
26731
+ height: 30,
26732
+ preserveAspectRatio: "none",
26733
+ href: commit.author.avatar_url,
26734
+ x: avatar_box_x,
26735
+ y: avatar_box_y,
26736
+ style: "clip-path: circle(50%)"
26737
+ };
26738
+ this.setNodeAttr(img, imgAttrs);
26739
+ this.svg.appendChild(img);
26740
+ if (!this.messageBoxWidth) {
26741
+ this.messageBoxWidth = this.svg.getBoundingClientRect.width - (avatar_box_x + 40);
26742
+ }
26743
+ let route = ["M", avatar_box_x + 15, avatar_box_y - 20, "L", avatar_box_x + 15, avatar_box_y];
26744
+ const line1 = document.createElementNS("http://www.w3.org/2000/svg", "path");
26745
+ const lineAttrs1 = {
26746
+ d: route.join(" "),
26747
+ stroke: "#ccc",
26748
+ fill: "none",
26749
+ "stroke-width": 2
26750
+ };
26751
+ this.setNodeAttr(line1, lineAttrs1);
26752
+ this.svg.appendChild(line1);
26753
+ route = ["M", avatar_box_x + 15, avatar_box_y + 30, "L", avatar_box_x + 15, avatar_box_y + 50];
26754
+ const line2 = document.createElementNS("http://www.w3.org/2000/svg", "path");
26755
+ const lineAttrs2 = {
26756
+ d: route.join(" "),
26757
+ stroke: "#ccc",
26758
+ "stroke-width": 2
26759
+ };
26760
+ this.setNodeAttr(line2, lineAttrs2);
26761
+ this.svg.appendChild(line2);
26762
+ if (commit.author.name.length > this.maxNameLength) {
26763
+ commit.author.name = commit.author.name.substr(0, this.maxNameLength) + "...";
26764
+ }
26765
+ const commitText = document.createElementNS("http://www.w3.org/2000/svg", "text");
26766
+ const commitAttrs = {
26767
+ x: avatar_box_x + 40,
26768
+ y: y + 4,
26769
+ "text-anchor": "start",
26770
+ style: "cursor: pointer;text-anchor: start;",
26771
+ fill: isdark ? "#e8e8e8" : "#2e2e2e",
26772
+ "font-size": 14
26773
+ };
26774
+ this.setNodeAttr(commitText, commitAttrs);
26775
+ const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
26776
+ tspan.appendChild(document.createTextNode(commit.message.replace(/\n/g, " ")));
26777
+ commitText.appendChild(tspan);
26778
+ const titleText = document.createElementNS("http://www.w3.org/2000/svg", "title");
26779
+ titleText.appendChild(document.createTextNode(commit.message));
26780
+ commitText.appendChild(titleText);
26781
+ this.svg.appendChild(commitText);
26782
+ commitText.onclick = function() {
26783
+ const url2 = commit.customUrl || (options == null ? void 0 : options.commit_url.replace("{commitId}", commit.id));
26784
+ return window.open(url2, "_blank");
26785
+ };
26786
+ }
26787
+ drawLines(x, y, commit) {
26788
+ let arrow2;
26789
+ let color2;
26790
+ let offset2;
26791
+ let parent;
26792
+ let parentCommit;
26793
+ let parentX1;
26794
+ let parentX2;
26795
+ let parentY;
26796
+ let route;
26797
+ const _ref = commit.parents;
26798
+ for (let i = 0; i < _ref.length; i++) {
26799
+ parent = _ref[i];
26800
+ parentCommit = this.preparedCommits[parent[0]];
26801
+ if (!parentCommit) {
26802
+ break;
26803
+ }
26804
+ parentY = this.offsetY + this.unitTime * parentCommit.time;
26805
+ parentX1 = this.offsetX + this.unitSpace * (this.mspace - parentCommit.space);
26806
+ parentX2 = this.offsetX + this.unitSpace * (this.mspace - parent[1]);
26807
+ if (parentCommit.space <= commit.space) {
26808
+ color2 = this.colors[commit.space];
26809
+ } else {
26810
+ color2 = this.colors[parentCommit.space];
26811
+ }
26812
+ if (parent[1] === commit.space) {
26813
+ offset2 = [0, 5];
26814
+ arrow2 = "l-2,5,4,0,-2,-5,0,5".split(",");
26815
+ } else if (parent[1] < commit.space) {
26816
+ offset2 = [3, 3];
26817
+ arrow2 = "l5,0,-2,4,-3,-4,4,2".split(",");
26818
+ } else {
26819
+ offset2 = [-3, 3];
26820
+ arrow2 = "l-5,0,2,4,3,-4,-4,2".split(",");
26821
+ }
26822
+ route = ["M", x + offset2[0], y + offset2[1]];
26823
+ if (i > 0) {
26824
+ route.push(...arrow2);
26825
+ }
26826
+ if (commit.space !== parentCommit.space || commit.space !== parent[1]) {
26827
+ route.push("L", parentX2, y + 10, "L", parentX2, parentY - 5);
26828
+ }
26829
+ route.push("L", parentX1, parentY);
26830
+ const line = document.createElementNS("http://www.w3.org/2000/svg", "path");
26831
+ const lineAttrs = {
26832
+ d: route.join(" "),
26833
+ stroke: color2,
26834
+ "stroke-width": 1,
26835
+ fill: "none"
26836
+ };
26837
+ this.setNodeAttr(line, lineAttrs);
26838
+ this.svg.appendChild(line);
26839
+ }
26840
+ }
26841
+ appendLabel(x, y, commit) {
26842
+ let shortrefs;
26843
+ if (!commit.refs) {
26844
+ return;
26845
+ }
26846
+ shortrefs = commit.refs;
26847
+ if (shortrefs.length > 7) {
26848
+ if (escape(shortrefs).indexOf("%u") < 0) {
26849
+ shortrefs = shortrefs.substr(0, 5) + "...";
26850
+ } else {
26851
+ shortrefs = shortrefs.substr(0, 3) + "...";
26852
+ }
26853
+ }
26854
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
26855
+ const textAttrs = {
26856
+ x: x + 4,
26857
+ y: y + 4,
26858
+ "text-anchor": "start",
26859
+ fill: "none",
26860
+ style: "font-size: 10px;"
26861
+ };
26862
+ this.setNodeAttr(text, textAttrs);
26863
+ const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
26864
+ const rect = document.createElementNS("http://www.w3.org/2000/svg", "path");
26865
+ tspan.appendChild(document.createTextNode(shortrefs));
26866
+ text.appendChild(tspan);
26867
+ const titleText = document.createElementNS("http://www.w3.org/2000/svg", "title");
26868
+ titleText.appendChild(document.createTextNode(commit.refs));
26869
+ text.appendChild(titleText);
26870
+ this.svg.appendChild(rect);
26871
+ this.svg.appendChild(text);
26872
+ setTimeout(() => {
26873
+ const textbox = text.getBBox();
26874
+ const path = [
26875
+ "M",
26876
+ x,
26877
+ y - 7,
26878
+ "L",
26879
+ x,
26880
+ y - 7 + textbox.height + 4,
26881
+ "L",
26882
+ x + textbox.width + 8,
26883
+ y - 7 + textbox.height + 4,
26884
+ "L",
26885
+ x + textbox.width + 8,
26886
+ y + 4,
26887
+ "L",
26888
+ x + textbox.width + 18,
26889
+ y,
26890
+ "L",
26891
+ x + textbox.width + 8,
26892
+ y - 4,
26893
+ "L",
26894
+ x + textbox.width + 8,
26895
+ y - 7,
26896
+ "Z"
26897
+ ];
26898
+ const rectAttrs = {
26899
+ fill: this.isDark ? "#4C4C4C" : "#fff",
26900
+ stroke: this.colors[commit.space],
26901
+ "stroke-width": "1px",
26902
+ d: path.join(" "),
26903
+ transform: `matrix(1,0,0,1,-${textbox.width + 26},0)`
26904
+ };
26905
+ const newAttrs = {
26906
+ transform: `matrix(1,0,0,1,-${textbox.width + 26},0)`,
26907
+ fill: this.colors[commit.space]
26908
+ };
26909
+ this.setNodeAttr(text, newAttrs);
26910
+ this.setNodeAttr(rect, rectAttrs);
26911
+ });
26912
+ }
26913
+ appendAnchor(x, y, commit, refName) {
26914
+ const options = this.options;
26915
+ const isDark = this.isDark;
26916
+ const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
26917
+ const attrs = {
26918
+ cx: x,
26919
+ cy: y,
26920
+ r: 10,
26921
+ fill: "#000",
26922
+ opacity: 0,
26923
+ style: "cursor:pointer;"
26924
+ };
26925
+ this.setNodeAttr(circle, attrs);
26926
+ circle.onclick = function() {
26927
+ localStorage.setItem("refName", refName);
26928
+ const url2 = commit.customUrl || (options == null ? void 0 : options.commit_url.replace("{commitId}", commit.id));
26929
+ return window.open(url2, "_blank");
26930
+ };
26931
+ circle.onmouseover = () => {
26932
+ this.commitTooltip(x + 20, y + 20, commit, isDark);
26933
+ };
26934
+ circle.onmouseleave = () => {
26935
+ this.toolTipList.forEach((element) => {
26936
+ this.svg.removeChild(element);
26937
+ });
26938
+ };
26939
+ this.svg.appendChild(circle);
26940
+ }
26941
+ getText(x, y, text, attrs = {}) {
26942
+ const resText = document.createElementNS("http://www.w3.org/2000/svg", "text");
26943
+ this.setNodeAttr(resText, __spreadValues({
26944
+ x,
26945
+ y
26946
+ }, attrs));
26947
+ const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
26948
+ tspan.appendChild(document.createTextNode(text));
26949
+ resText.appendChild(tspan);
26950
+ return resText;
26951
+ }
26952
+ commitTooltip(x, y, commit, isDark) {
26953
+ let boxHeight;
26954
+ let boxWidth;
26955
+ let messageText;
26956
+ boxWidth = 300;
26957
+ boxHeight = 200;
26958
+ const nameText = this.getText(x, y + 10, commit.author.name, {
26959
+ font: "14px Arial",
26960
+ "font-weight": "bold",
26961
+ "text-anchor": "start"
26962
+ });
26963
+ const idText = this.getText(x, y + 55, commit.id, {
26964
+ fill: isDark ? "#73788a" : "#71757f",
26965
+ "text-anchor": "start"
26966
+ });
26967
+ const timeText = this.getText(x, y + 35, this.__transform(commit.date), {
26968
+ font: "12px Arial",
26969
+ fill: isDark ? "#73788a" : "#71757f",
26970
+ "text-anchor": "start"
26971
+ });
26972
+ const branchText = commit.branch ? this.getText(x + 70, y + 35, commit.branch, {
26973
+ font: "12px Arial",
26974
+ fill: isDark ? "#73788a" : "#71757f"
26975
+ }) : null;
26976
+ const strList = commit.message.split("\n");
26977
+ if (strList.length > 10) {
26978
+ messageText = this.getText(x, y + 70, strList.slice(0, 10).join("\n") + "...", {
26979
+ fill: isDark ? "#E8E8E8" : "#2e2e2e",
26980
+ "text-anchor": "start",
26981
+ font: "12px Monaco, monospace"
26982
+ });
26983
+ } else if (commit.message.length > 1500) {
26984
+ messageText = this.getText(x, y + 70, commit.message.slice(0, 1500) + "...", {
26985
+ fill: isDark ? "#E8E8E8" : "#2e2e2e",
26986
+ "text-anchor": "start",
26987
+ font: "12px Monaco, monospace"
26988
+ });
26989
+ } else {
26990
+ messageText = this.getText(x, y + 70, commit.message, {
26991
+ fill: isDark ? "#E8E8E8" : "#2e2e2e",
26992
+ "text-anchor": "start",
26993
+ font: "12px Monaco, monospace"
26994
+ });
26995
+ }
26996
+ const textArr = commit.branch ? [nameText, idText, messageText, timeText, branchText] : [nameText, idText, messageText, timeText];
26997
+ this.textWrap(messageText, boxWidth - 50, x);
26998
+ const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
26999
+ this.setNodeAttr(rect, {
27000
+ x: x - 10,
27001
+ y: y - 10,
27002
+ width: boxWidth,
27003
+ height: 100,
27004
+ fill: isDark ? "#4c4c4c" : "#fff",
27005
+ stroke: isDark ? "#4c4c4c" : "#fff",
27006
+ "stroke-linecap": "round",
27007
+ "stroke-width": "1px"
27008
+ });
27009
+ textArr.unshift(rect);
27010
+ const rectShadow = document.createElementNS("http://www.w3.org/2000/svg", "rect");
27011
+ this.setNodeAttr(rectShadow, {
27012
+ x: x - 11,
27013
+ y: y - 10,
27014
+ width: boxWidth + 2,
27015
+ height: 100,
27016
+ fill: isDark ? "#4c4c4c" : "#eee",
27017
+ stroke: isDark ? "#4c4c4c" : "#eee",
27018
+ "stroke-linecap": "round",
27019
+ "stroke-width": "1px"
27020
+ });
27021
+ textArr.unshift(rectShadow);
27022
+ textArr.forEach((t) => {
27023
+ this.svg.appendChild(t);
27024
+ });
27025
+ boxWidth = messageText.getBBox().width + 20 > boxWidth ? messageText.getBBox().width + 20 : boxWidth;
27026
+ boxHeight = 80 + messageText.getBBox().height;
27027
+ this.toolTipList = textArr;
27028
+ this.setNodeAttr(rect, {
27029
+ height: boxHeight + 10,
27030
+ width: boxWidth
27031
+ });
27032
+ this.setNodeAttr(rectShadow, {
27033
+ height: boxHeight + 13,
27034
+ width: boxWidth + 2
27035
+ });
27036
+ }
27037
+ textWrap(t, width, x) {
27038
+ const content2 = t.children[0].innerHTML;
27039
+ let words = content2.split("\n").filter((item) => item !== "");
27040
+ words = words.map((str) => {
27041
+ str = str.trim();
27042
+ let len = str.length;
27043
+ const strList = [];
27044
+ while (len > 70) {
27045
+ strList.push(str.slice(0, 70));
27046
+ str = str.slice(70);
27047
+ len = str.length;
27048
+ }
27049
+ strList.push(str);
27050
+ return strList.join("\n");
27051
+ });
27052
+ t.removeChild(t.children[0]);
27053
+ words.forEach((str) => {
27054
+ const list2 = str.split("\n");
27055
+ list2.forEach((item) => {
27056
+ const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
27057
+ tspan.appendChild(document.createTextNode(item));
27058
+ this.setNodeAttr(tspan, {
27059
+ dy: 14.4,
27060
+ x
27061
+ });
27062
+ t.appendChild(tspan);
27063
+ });
27064
+ const space = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
27065
+ space.appendChild(document.createTextNode(" "));
27066
+ this.setNodeAttr(space, {
27067
+ dy: 14.4,
27068
+ x
27069
+ });
27070
+ t.appendChild(space);
27071
+ });
27072
+ }
27073
+ }
27074
+ function useGitGraph(props, ctx2, isDark) {
27075
+ let themeService;
27076
+ const graph = new GitGraph$1();
27077
+ const themeChange = () => {
27078
+ var _a;
27079
+ isDark.value = !!((_a = themeService == null ? void 0 : themeService.currentTheme) == null ? void 0 : _a.isDark);
27080
+ };
27081
+ const initTheme = () => {
27082
+ var _a;
27083
+ themeService = window["devuiThemeService"];
27084
+ isDark.value = !!((_a = themeService == null ? void 0 : themeService.currentTheme) == null ? void 0 : _a.isDark);
27085
+ if (themeService) {
27086
+ themeService.eventBus.add("themeChanged", themeChange);
27087
+ }
27088
+ };
27089
+ const initGraph = (element, options, isDarkMode) => {
27090
+ graph.load(element, options, isDarkMode);
27091
+ };
27092
+ return {
27093
+ initTheme,
27094
+ initGraph
27095
+ };
27096
+ }
27097
+ var GitGraph = defineComponent({
27098
+ name: "DGitGraph",
27099
+ props: gitGraphProps,
27100
+ emits: ["scrollToBottom"],
27101
+ setup(props, ctx2) {
27102
+ const isDark = ref(false);
27103
+ const {
27104
+ initTheme,
27105
+ initGraph
27106
+ } = useGitGraph(props, ctx2, isDark);
27107
+ onMounted(() => {
27108
+ nextTick(() => {
27109
+ const graphEle = document.getElementsByClassName("d-graph-wrapper")[0];
27110
+ initTheme();
27111
+ initGraph(graphEle, props.option, isDark.value);
27112
+ });
27113
+ });
27114
+ return () => createVNode("div", {
27115
+ "class": "d-graph-wrapper"
27116
+ }, null);
27117
+ }
27118
+ });
27119
+ var GitGraphInstall = {
27120
+ title: "GitGraph \u63D0\u4EA4\u7F51\u7EDC\u56FE",
27121
+ category: "\u6F14\u8FDB\u4E2D",
27122
+ status: "100%",
27123
+ install(app) {
27124
+ app.component(GitGraph.name, GitGraph);
27125
+ }
27126
+ };
26151
27127
  const rowProps = {
26152
27128
  align: {
26153
27129
  type: String,
@@ -42168,6 +43144,7 @@ const installs = [
42168
43144
  FormInstall,
42169
43145
  FullscreenInstall,
42170
43146
  GanttInstall,
43147
+ GitGraphInstall,
42171
43148
  GridInstall,
42172
43149
  IconInstall,
42173
43150
  ImagePreviewInstall,
@@ -42222,9 +43199,9 @@ const installs = [
42222
43199
  VirtualListInstall
42223
43200
  ];
42224
43201
  var vueDevui = {
42225
- version: "1.5.7-hotfix.3",
43202
+ version: "1.5.8",
42226
43203
  install(app) {
42227
43204
  installs.forEach((p) => app.use(p));
42228
43205
  }
42229
43206
  };
42230
- export { Accordion, ActionTimeline, Alert, Anchor, Aside, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, BreadcrumbItem, DButton as Button, ButtonGroup, Card, Carousel, CarouselItem, Cascader, Checkbox, CheckboxButton, DCheckboxGroup as CheckboxGroup, CodeEditor, CodeReview, Col, Collapse, CollapseItem, ColorPicker, Column, Comment, Content, Countdown, DChart, DRangeDatePickerPro, DatePicker, DatePickerPro, DraggableDirective, Drawer, DrawerService, Dropdown$1 as Dropdown, DropdownMenu, DroppableDirective, EditableSelect, EditorMd, FixedOverlay, FlexibleOverlay, Footer, Form, FormItem, FormOperation, Fullscreen, Gantt, Header, DIcon as Icon, IconGroup, ImagePreviewDirective, ImagePreviewService, DInput as Input, InputIcon, InputNumber, Layout, List, ListItem, LoadingDirective, loading as LoadingService, MdRender, Mention, Menu, MenuItem, Message, Modal, ModalBody, ModalFooter, ModalHeader, MultiAutoComplete, NavSprite, Notification, NotificationService, Option, OptionGroup, Pagination, Panel, PanelBody, PanelFooter, PanelHeader, Popover, Progress, QuadrantDiagram, Radio, RadioButton, RadioGroup, Rate, ReadTip, Result, RippleDirective, Row, DSearch as Search, Select, Skeleton, SkeletonItem, Slider, SortableDirective, Splitter, SplitterPane, Statistic, Status, Step, Steps, StepsGuide, StepsGuideDirective, StickSlider, Sticky, SubMenu, Switch, Tab, Table, Tabs, Tag, TagInput, Textarea, TimePicker, TimeSelect, Timeline, TimelineItem, Tooltip, Transfer, Tree, TreeSelect, Upload, VirtualList, vueDevui as default, fileDropDirective };
43207
+ export { Accordion, ActionTimeline, Alert, Anchor, Aside, AutoComplete, Avatar, BackTop, Badge, Breadcrumb, BreadcrumbItem, DButton as Button, ButtonGroup, Card, Carousel, CarouselItem, Cascader, Checkbox, CheckboxButton, DCheckboxGroup as CheckboxGroup, CodeEditor, CodeReview, Col, Collapse, CollapseItem, ColorPicker, Column, Comment, Content, Countdown, DChart, DRangeDatePickerPro, DatePicker, DatePickerPro, DraggableDirective, Drawer, DrawerService, Dropdown$1 as Dropdown, DropdownMenu, DroppableDirective, EditableSelect, EditorMd, FixedOverlay, FlexibleOverlay, Footer, Form, FormItem, FormOperation, Fullscreen, Gantt, GitGraph, Header, DIcon as Icon, IconGroup, ImagePreviewDirective, ImagePreviewService, DInput as Input, InputIcon, InputNumber, Layout, List, ListItem, LoadingDirective, loading as LoadingService, MdRender, Mention, Menu, MenuItem, Message, Modal, ModalBody, ModalFooter, ModalHeader, MultiAutoComplete, NavSprite, Notification, NotificationService, Option, OptionGroup, Pagination, Panel, PanelBody, PanelFooter, PanelHeader, Popover, Progress, QuadrantDiagram, Radio, RadioButton, RadioGroup, Rate, ReadTip, Result, RippleDirective, Row, DSearch as Search, Select, Skeleton, SkeletonItem, Slider, SortableDirective, Splitter, SplitterPane, Statistic, Status, Step, Steps, StepsGuide, StepsGuideDirective, StickSlider, Sticky, SubMenu, Switch, Tab, Table, Tabs, Tag, TagInput, Textarea, TimePicker, TimeSelect, Timeline, TimelineItem, Tooltip, Transfer, Tree, TreeSelect, Upload, VirtualList, vueDevui as default, fileDropDirective };