@ni/nimble-components 24.1.12 → 24.1.14

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 (98) hide show
  1. package/dist/all-components-bundle.js +1622 -1350
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +1815 -1785
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/anchor/index.js.map +1 -1
  6. package/dist/esm/anchor-button/index.js.map +1 -1
  7. package/dist/esm/anchor-menu-item/index.js.map +1 -1
  8. package/dist/esm/anchor-tab/index.js.map +1 -1
  9. package/dist/esm/anchor-tabs/index.js.map +1 -1
  10. package/dist/esm/anchor-tree-item/index.js.map +1 -1
  11. package/dist/esm/banner/index.js.map +1 -1
  12. package/dist/esm/breadcrumb/index.js.map +1 -1
  13. package/dist/esm/button/index.js.map +1 -1
  14. package/dist/esm/card-button/index.js.map +1 -1
  15. package/dist/esm/combobox/index.js.map +1 -1
  16. package/dist/esm/dialog/index.js.map +1 -1
  17. package/dist/esm/drawer/index.js.map +1 -1
  18. package/dist/esm/icon-base/index.js.map +1 -1
  19. package/dist/esm/label-provider/core/index.js.map +1 -1
  20. package/dist/esm/label-provider/rich-text/index.js.map +1 -1
  21. package/dist/esm/label-provider/table/index.js.map +1 -1
  22. package/dist/esm/list-option/index.js.map +1 -1
  23. package/dist/esm/mapping/base/index.js.map +1 -1
  24. package/dist/esm/mapping/icon/index.js.map +1 -1
  25. package/dist/esm/mapping/spinner/index.js.map +1 -1
  26. package/dist/esm/mapping/text/index.js.map +1 -1
  27. package/dist/esm/mapping/user/index.js.map +1 -1
  28. package/dist/esm/menu-button/index.js.map +1 -1
  29. package/dist/esm/number-field/index.js.map +1 -1
  30. package/dist/esm/rich-text/base/index.js.map +1 -1
  31. package/dist/esm/rich-text/editor/index.js.map +1 -1
  32. package/dist/esm/rich-text/editor/testing/rich-text-editor.pageobject.js +3 -1
  33. package/dist/esm/rich-text/editor/testing/rich-text-editor.pageobject.js.map +1 -1
  34. package/dist/esm/rich-text/mention-listbox/index.js.map +1 -1
  35. package/dist/esm/rich-text/models/configuration.js +1 -1
  36. package/dist/esm/rich-text/models/configuration.js.map +1 -1
  37. package/dist/esm/rich-text/models/markdown-parser.js.map +1 -1
  38. package/dist/esm/rich-text/models/rich-text-validator.js +1 -1
  39. package/dist/esm/rich-text/models/rich-text-validator.js.map +1 -1
  40. package/dist/esm/rich-text/viewer/index.js.map +1 -1
  41. package/dist/esm/rich-text-mention/base/index.d.ts +1 -4
  42. package/dist/esm/rich-text-mention/base/index.js +5 -7
  43. package/dist/esm/rich-text-mention/base/index.js.map +1 -1
  44. package/dist/esm/rich-text-mention/base/models/mention-internals.d.ts +9 -7
  45. package/dist/esm/rich-text-mention/base/models/mention-internals.js +1 -7
  46. package/dist/esm/rich-text-mention/base/models/mention-internals.js.map +1 -1
  47. package/dist/esm/rich-text-mention/base/models/mention-validator.d.ts +1 -4
  48. package/dist/esm/rich-text-mention/base/models/mention-validator.js +1 -6
  49. package/dist/esm/rich-text-mention/base/models/mention-validator.js.map +1 -1
  50. package/dist/esm/rich-text-mention/base/view/index.js.map +1 -1
  51. package/dist/esm/rich-text-mention/users/index.d.ts +1 -2
  52. package/dist/esm/rich-text-mention/users/index.js +2 -4
  53. package/dist/esm/rich-text-mention/users/index.js.map +1 -1
  54. package/dist/esm/rich-text-mention/users/models/rich-text-mention-users-validator.d.ts +1 -2
  55. package/dist/esm/rich-text-mention/users/models/rich-text-mention-users-validator.js +2 -2
  56. package/dist/esm/rich-text-mention/users/models/rich-text-mention-users-validator.js.map +1 -1
  57. package/dist/esm/select/index.js.map +1 -1
  58. package/dist/esm/spinner/index.js.map +1 -1
  59. package/dist/esm/src/rich-text-mention/base/index.d.ts +1 -4
  60. package/dist/esm/src/rich-text-mention/base/models/mention-internals.d.ts +9 -7
  61. package/dist/esm/src/rich-text-mention/base/models/mention-validator.d.ts +1 -4
  62. package/dist/esm/src/rich-text-mention/users/index.d.ts +1 -2
  63. package/dist/esm/src/rich-text-mention/users/models/rich-text-mention-users-validator.d.ts +1 -2
  64. package/dist/esm/table/components/cell/index.js.map +1 -1
  65. package/dist/esm/table/components/group-row/index.js.map +1 -1
  66. package/dist/esm/table/components/header/index.js.map +1 -1
  67. package/dist/esm/table/components/row/index.js.map +1 -1
  68. package/dist/esm/table/index.js.map +1 -1
  69. package/dist/esm/table/models/table-layout-manager.js.map +1 -1
  70. package/dist/esm/table/models/virtualizer.js.map +1 -1
  71. package/dist/esm/table-column/anchor/cell-view/index.js.map +1 -1
  72. package/dist/esm/table-column/anchor/index.js.map +1 -1
  73. package/dist/esm/table-column/base/cell-view/index.js.map +1 -1
  74. package/dist/esm/table-column/base/group-header-view/index.js.map +1 -1
  75. package/dist/esm/table-column/base/index.js.map +1 -1
  76. package/dist/esm/table-column/base/models/column-internals.js.map +1 -1
  77. package/dist/esm/table-column/base/models/column-validator.js.map +1 -1
  78. package/dist/esm/table-column/date-text/index.js.map +1 -1
  79. package/dist/esm/table-column/enum-base/index.js.map +1 -1
  80. package/dist/esm/table-column/icon/cell-view/index.js.map +1 -1
  81. package/dist/esm/table-column/icon/group-header-view/index.js.map +1 -1
  82. package/dist/esm/table-column/number-text/index.js.map +1 -1
  83. package/dist/esm/table-column/text-base/cell-view/index.js.map +1 -1
  84. package/dist/esm/table-column/text-base/group-header-view/index.js.map +1 -1
  85. package/dist/esm/table-column/text-base/index.js.map +1 -1
  86. package/dist/esm/text-area/index.js.map +1 -1
  87. package/dist/esm/text-field/index.js.map +1 -1
  88. package/dist/esm/theme-provider/index.js.map +1 -1
  89. package/dist/esm/toggle-button/index.js.map +1 -1
  90. package/dist/esm/tooltip/index.js.map +1 -1
  91. package/dist/esm/tree-item/index.js.map +1 -1
  92. package/dist/esm/tree-view/index.js.map +1 -1
  93. package/dist/esm/unit/base/unit.js.map +1 -1
  94. package/dist/esm/unit/byte/index.js.map +1 -1
  95. package/dist/esm/utilities/models/document-element-lang.js.map +1 -1
  96. package/dist/esm/utilities/unit-format/default-unit-format.js.map +1 -1
  97. package/dist/esm/wafer-map/index.js.map +1 -1
  98. package/package.json +4 -4
@@ -16333,7 +16333,7 @@
16333
16333
 
16334
16334
  /**
16335
16335
  * Do not edit directly
16336
- * Generated on Wed, 10 Apr 2024 19:20:19 GMT
16336
+ * Generated on Mon, 15 Apr 2024 17:21:28 GMT
16337
16337
  */
16338
16338
 
16339
16339
  const Information100DarkUi = "#a46eff";
@@ -28524,6 +28524,8 @@
28524
28524
  return found;
28525
28525
  }
28526
28526
 
28527
+ function isTagRule(rule) { return rule.tag != null; }
28528
+ function isStyleRule(rule) { return rule.style != null; }
28527
28529
  /**
28528
28530
  A DOM parser represents a strategy for parsing DOM content into a
28529
28531
  ProseMirror document conforming to a given schema. Its behavior is
@@ -28555,9 +28557,9 @@
28555
28557
  */
28556
28558
  this.styles = [];
28557
28559
  rules.forEach(rule => {
28558
- if (rule.tag)
28560
+ if (isTagRule(rule))
28559
28561
  this.tags.push(rule);
28560
- else if (rule.style)
28562
+ else if (isStyleRule(rule))
28561
28563
  this.styles.push(rule);
28562
28564
  });
28563
28565
  // Only normalize list elements when lists in the schema can't directly contain themselves
@@ -32551,6 +32553,9 @@
32551
32553
  range.setStart(node, from || 0);
32552
32554
  return range;
32553
32555
  };
32556
+ const clearReusedRange = function () {
32557
+ reusedRange = null;
32558
+ };
32554
32559
  // Scans forward and backward through DOM positions equivalent to the
32555
32560
  // given one to see if the two are in the same place (i.e. after a
32556
32561
  // text node vs at the end of that text node)
@@ -32585,6 +32590,44 @@
32585
32590
  function nodeSize(node) {
32586
32591
  return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
32587
32592
  }
32593
+ function textNodeBefore$1(node, offset) {
32594
+ for (;;) {
32595
+ if (node.nodeType == 3 && offset)
32596
+ return node;
32597
+ if (node.nodeType == 1 && offset > 0) {
32598
+ if (node.contentEditable == "false")
32599
+ return null;
32600
+ node = node.childNodes[offset - 1];
32601
+ offset = nodeSize(node);
32602
+ }
32603
+ else if (node.parentNode && !hasBlockDesc(node)) {
32604
+ offset = domIndex(node);
32605
+ node = node.parentNode;
32606
+ }
32607
+ else {
32608
+ return null;
32609
+ }
32610
+ }
32611
+ }
32612
+ function textNodeAfter$1(node, offset) {
32613
+ for (;;) {
32614
+ if (node.nodeType == 3 && offset < node.nodeValue.length)
32615
+ return node;
32616
+ if (node.nodeType == 1 && offset < node.childNodes.length) {
32617
+ if (node.contentEditable == "false")
32618
+ return null;
32619
+ node = node.childNodes[offset];
32620
+ offset = 0;
32621
+ }
32622
+ else if (node.parentNode && !hasBlockDesc(node)) {
32623
+ offset = domIndex(node) + 1;
32624
+ node = node.parentNode;
32625
+ }
32626
+ else {
32627
+ return null;
32628
+ }
32629
+ }
32630
+ }
32588
32631
  function isOnEdge(node, offset, parent) {
32589
32632
  for (let atStart = offset == 0, atEnd = offset == nodeSize(node); atStart || atEnd;) {
32590
32633
  if (node == parent)
@@ -32661,6 +32704,12 @@
32661
32704
  const webkit_version = webkit ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
32662
32705
 
32663
32706
  function windowRect(doc) {
32707
+ let vp = doc.defaultView && doc.defaultView.visualViewport;
32708
+ if (vp)
32709
+ return {
32710
+ left: 0, right: vp.width,
32711
+ top: 0, bottom: vp.height
32712
+ };
32664
32713
  return { left: 0, right: doc.documentElement.clientWidth,
32665
32714
  top: 0, bottom: doc.documentElement.clientHeight };
32666
32715
  }
@@ -33596,6 +33645,7 @@
33596
33645
  }
33597
33646
  get domAtom() { return false; }
33598
33647
  get ignoreForCoords() { return false; }
33648
+ isText(text) { return false; }
33599
33649
  }
33600
33650
  // A widget desc represents a widget decoration, which is a DOM node
33601
33651
  // drawn between the document nodes.
@@ -33858,8 +33908,7 @@
33858
33908
  let { from, to } = view.state.selection;
33859
33909
  if (!(view.state.selection instanceof TextSelection) || from < pos || to > pos + this.node.content.size)
33860
33910
  return null;
33861
- let sel = view.domSelectionRange();
33862
- let textNode = nearbyTextNode(sel.focusNode, sel.focusOffset);
33911
+ let textNode = view.input.compositionNode;
33863
33912
  if (!textNode || !this.dom.contains(textNode.parentNode))
33864
33913
  return null;
33865
33914
  if (this.node.inlineContent) {
@@ -34001,6 +34050,7 @@
34001
34050
  this.dirty = NODE_DIRTY;
34002
34051
  }
34003
34052
  get domAtom() { return false; }
34053
+ isText(text) { return this.node.text == text; }
34004
34054
  }
34005
34055
  // A dummy desc used to tag trailing BR or IMG nodes created to work
34006
34056
  // around contentEditable terribleness.
@@ -34570,25 +34620,6 @@
34570
34620
  dom.style.cssText = oldCSS;
34571
34621
  }
34572
34622
  }
34573
- function nearbyTextNode(node, offset) {
34574
- for (;;) {
34575
- if (node.nodeType == 3)
34576
- return node;
34577
- if (node.nodeType == 1 && offset > 0) {
34578
- if (node.childNodes.length > offset && node.childNodes[offset].nodeType == 3)
34579
- return node.childNodes[offset];
34580
- node = node.childNodes[offset - 1];
34581
- offset = nodeSize(node);
34582
- }
34583
- else if (node.nodeType == 1 && offset < node.childNodes.length) {
34584
- node = node.childNodes[offset];
34585
- offset = 0;
34586
- }
34587
- else {
34588
- return null;
34589
- }
34590
- }
34591
- }
34592
34623
  // Find a piece of text in an inline fragment, overlapping from-to
34593
34624
  function findTextInFragment(frag, text, from, to) {
34594
34625
  for (let i = 0, pos = 0; i < frag.childCount && pos <= to;) {
@@ -35493,6 +35524,7 @@
35493
35524
  this.lastTouch = 0;
35494
35525
  this.lastAndroidDelete = 0;
35495
35526
  this.composing = false;
35527
+ this.compositionNode = null;
35496
35528
  this.composingTimeout = -1;
35497
35529
  this.compositionNodes = [];
35498
35530
  this.compositionEndedAt = -2e8;
@@ -35929,6 +35961,7 @@
35929
35961
  view.input.composing = false;
35930
35962
  view.input.compositionEndedAt = event.timeStamp;
35931
35963
  view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;
35964
+ view.input.compositionNode = null;
35932
35965
  if (view.input.compositionPendingChanges)
35933
35966
  Promise.resolve().then(() => view.domObserver.flush());
35934
35967
  view.input.compositionID++;
@@ -35948,6 +35981,25 @@
35948
35981
  while (view.input.compositionNodes.length > 0)
35949
35982
  view.input.compositionNodes.pop().markParentsDirty();
35950
35983
  }
35984
+ function findCompositionNode(view) {
35985
+ let sel = view.domSelectionRange();
35986
+ if (!sel.focusNode)
35987
+ return null;
35988
+ let textBefore = textNodeBefore$1(sel.focusNode, sel.focusOffset);
35989
+ let textAfter = textNodeAfter$1(sel.focusNode, sel.focusOffset);
35990
+ if (textBefore && textAfter && textBefore != textAfter) {
35991
+ let descAfter = textAfter.pmViewDesc;
35992
+ if (!descAfter || !descAfter.isText(textAfter.nodeValue)) {
35993
+ return textAfter;
35994
+ }
35995
+ else if (view.input.compositionNode == textAfter) {
35996
+ let descBefore = textBefore.pmViewDesc;
35997
+ if (!(!descBefore || !descBefore.isText(textBefore.nodeValue)))
35998
+ return textAfter;
35999
+ }
36000
+ }
36001
+ return textBefore;
36002
+ }
35951
36003
  function timestampFromCustomEvent() {
35952
36004
  let event = document.createEvent("Event");
35953
36005
  event.initEvent("event", true, true);
@@ -37182,9 +37234,25 @@
37182
37234
  cssCheckWarned = true;
37183
37235
  }
37184
37236
  }
37237
+ function rangeToSelectionRange(view, range) {
37238
+ let anchorNode = range.startContainer, anchorOffset = range.startOffset;
37239
+ let focusNode = range.endContainer, focusOffset = range.endOffset;
37240
+ let currentAnchor = view.domAtPos(view.state.selection.anchor);
37241
+ // Since such a range doesn't distinguish between anchor and head,
37242
+ // use a heuristic that flips it around if its end matches the
37243
+ // current anchor.
37244
+ if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
37245
+ [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
37246
+ return { anchorNode, anchorOffset, focusNode, focusOffset };
37247
+ }
37185
37248
  // Used to work around a Safari Selection/shadow DOM bug
37186
37249
  // Based on https://github.com/codemirror/dev/issues/414 fix
37187
- function safariShadowSelectionRange(view) {
37250
+ function safariShadowSelectionRange(view, selection) {
37251
+ if (selection.getComposedRanges) {
37252
+ let range = selection.getComposedRanges(view.root)[0];
37253
+ if (range)
37254
+ return rangeToSelectionRange(view, range);
37255
+ }
37188
37256
  let found;
37189
37257
  function read(event) {
37190
37258
  event.preventDefault();
@@ -37199,15 +37267,7 @@
37199
37267
  view.dom.addEventListener("beforeinput", read, true);
37200
37268
  document.execCommand("indent");
37201
37269
  view.dom.removeEventListener("beforeinput", read, true);
37202
- let anchorNode = found.startContainer, anchorOffset = found.startOffset;
37203
- let focusNode = found.endContainer, focusOffset = found.endOffset;
37204
- let currentAnchor = view.domAtPos(view.state.selection.anchor);
37205
- // Since such a range doesn't distinguish between anchor and head,
37206
- // use a heuristic that flips it around if its end matches the
37207
- // current anchor.
37208
- if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
37209
- [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
37210
- return { anchorNode, anchorOffset, focusNode, focusOffset };
37270
+ return found ? rangeToSelectionRange(view, found) : null;
37211
37271
  }
37212
37272
 
37213
37273
  // Note that all referencing and parsing is done with the
@@ -37350,13 +37410,6 @@
37350
37410
  return;
37351
37411
  }
37352
37412
  }
37353
- // Chrome sometimes leaves the cursor before the inserted text when
37354
- // composing after a cursor wrapper. This moves it forward.
37355
- if (chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from &&
37356
- parse.sel.head == parse.sel.anchor) {
37357
- let size = change.endB - change.start;
37358
- parse.sel = { anchor: parse.sel.anchor + size, head: parse.sel.anchor + size };
37359
- }
37360
37413
  view.input.domChangeCount++;
37361
37414
  // Handle the case where overwriting a selection by typing matches
37362
37415
  // the start or end of the selected content, creating a change
@@ -37402,7 +37455,7 @@
37402
37455
  }
37403
37456
  // Same for backspace
37404
37457
  if (view.state.selection.anchor > change.start &&
37405
- looksLikeJoin(doc, change.start, change.endA, $from, $to) &&
37458
+ looksLikeBackspace(doc, change.start, change.endA, $from, $to) &&
37406
37459
  view.someProp("handleKeyDown", f => f(view, keyEvent(8, "Backspace")))) {
37407
37460
  if (android && chrome)
37408
37461
  view.domObserver.suppressSelectionUpdates(); // #820
@@ -37514,14 +37567,18 @@
37514
37567
  if (Fragment.from(updated).eq(cur))
37515
37568
  return { mark, type };
37516
37569
  }
37517
- function looksLikeJoin(old, start, end, $newStart, $newEnd) {
37518
- if (!$newStart.parent.isTextblock ||
37519
- // The content must have shrunk
37520
- end - start <= $newEnd.pos - $newStart.pos ||
37570
+ function looksLikeBackspace(old, start, end, $newStart, $newEnd) {
37571
+ if ( // The content must have shrunk
37572
+ end - start <= $newEnd.pos - $newStart.pos ||
37521
37573
  // newEnd must point directly at or after the end of the block that newStart points into
37522
37574
  skipClosingAndOpening($newStart, true, false) < $newEnd.pos)
37523
37575
  return false;
37524
37576
  let $start = old.resolve(start);
37577
+ // Handle the case where, rather than joining blocks, the change just removed an entire block
37578
+ if (!$newStart.parent.isTextblock) {
37579
+ let after = $start.nodeAfter;
37580
+ return after != null && end == start + after.nodeSize;
37581
+ }
37525
37582
  // Start must be at the end of a block
37526
37583
  if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock)
37527
37584
  return false;
@@ -37759,8 +37816,10 @@
37759
37816
  // tracks that and forces a selection reset when our update
37760
37817
  // did write to the node.
37761
37818
  let chromeKludge = chrome ? (this.trackWrites = this.domSelectionRange().focusNode) : null;
37819
+ if (this.composing)
37820
+ this.input.compositionNode = findCompositionNode(this);
37762
37821
  if (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) {
37763
- this.docView.updateOuterDeco([]);
37822
+ this.docView.updateOuterDeco(outerDeco);
37764
37823
  this.docView.destroy();
37765
37824
  this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);
37766
37825
  }
@@ -38037,6 +38096,7 @@
38037
38096
  }
38038
38097
  this.docView.destroy();
38039
38098
  this.docView = null;
38099
+ clearReusedRange();
38040
38100
  }
38041
38101
  /**
38042
38102
  This is true when the view has been
@@ -38072,8 +38132,9 @@
38072
38132
  @internal
38073
38133
  */
38074
38134
  domSelectionRange() {
38075
- return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom
38076
- ? safariShadowSelectionRange(this) : this.domSelection();
38135
+ let sel = this.domSelection();
38136
+ return safari && this.root.nodeType === 11 &&
38137
+ deepActiveElement(this.dom.ownerDocument) == this.dom && safariShadowSelectionRange(this, sel) || sel;
38077
38138
  }
38078
38139
  /**
38079
38140
  @internal
@@ -39737,6 +39798,23 @@
39737
39798
  if (stored) {
39738
39799
  return stored;
39739
39800
  }
39801
+ // if InputRule is triggered by insertContent()
39802
+ const simulatedInputMeta = tr.getMeta('applyInputRules');
39803
+ const isSimulatedInput = !!simulatedInputMeta;
39804
+ if (isSimulatedInput) {
39805
+ setTimeout(() => {
39806
+ const { from, text } = simulatedInputMeta;
39807
+ const to = from + text.length;
39808
+ run$1$1({
39809
+ editor,
39810
+ from,
39811
+ to,
39812
+ text,
39813
+ rules,
39814
+ plugin,
39815
+ });
39816
+ });
39817
+ }
39740
39818
  return tr.selectionSet || tr.docChanged ? null : prev;
39741
39819
  },
39742
39820
  },
@@ -39868,6 +39946,14 @@
39868
39946
  const success = handlers.every(handler => handler !== null);
39869
39947
  return success;
39870
39948
  }
39949
+ const createClipboardPasteEvent = (text) => {
39950
+ var _a;
39951
+ const event = new ClipboardEvent('paste', {
39952
+ clipboardData: new DataTransfer(),
39953
+ });
39954
+ (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.setData('text/html', text);
39955
+ return event;
39956
+ };
39871
39957
  /**
39872
39958
  * Create an paste rules plugin. When enabled, it will cause pasted
39873
39959
  * text that matches any of the given rules to trigger the rule’s
@@ -39880,6 +39966,28 @@
39880
39966
  let isDroppedFromProseMirror = false;
39881
39967
  let pasteEvent = typeof ClipboardEvent !== 'undefined' ? new ClipboardEvent('paste') : null;
39882
39968
  let dropEvent = typeof DragEvent !== 'undefined' ? new DragEvent('drop') : null;
39969
+ const processEvent = ({ state, from, to, rule, pasteEvt, }) => {
39970
+ const tr = state.tr;
39971
+ const chainableState = createChainableState({
39972
+ state,
39973
+ transaction: tr,
39974
+ });
39975
+ const handler = run$2({
39976
+ editor,
39977
+ state: chainableState,
39978
+ from: Math.max(from - 1, 0),
39979
+ to: to.b - 1,
39980
+ rule,
39981
+ pasteEvent: pasteEvt,
39982
+ dropEvent,
39983
+ });
39984
+ if (!handler || !tr.steps.length) {
39985
+ return;
39986
+ }
39987
+ dropEvent = typeof DragEvent !== 'undefined' ? new DragEvent('drop') : null;
39988
+ pasteEvent = typeof ClipboardEvent !== 'undefined' ? new ClipboardEvent('paste') : null;
39989
+ return tr;
39990
+ };
39883
39991
  const plugins = rules.map(rule => {
39884
39992
  return new Plugin({
39885
39993
  // we register a global drag handler to track the current drag source element
@@ -39917,38 +40025,39 @@
39917
40025
  const transaction = transactions[0];
39918
40026
  const isPaste = transaction.getMeta('uiEvent') === 'paste' && !isPastedFromProseMirror;
39919
40027
  const isDrop = transaction.getMeta('uiEvent') === 'drop' && !isDroppedFromProseMirror;
39920
- if (!isPaste && !isDrop) {
40028
+ // if PasteRule is triggered by insertContent()
40029
+ const simulatedPasteMeta = transaction.getMeta('applyPasteRules');
40030
+ const isSimulatedPaste = !!simulatedPasteMeta;
40031
+ if (!isPaste && !isDrop && !isSimulatedPaste) {
39921
40032
  return;
39922
40033
  }
39923
- // stop if there is no changed range
40034
+ // Handle simulated paste
40035
+ if (isSimulatedPaste) {
40036
+ const { from, text } = simulatedPasteMeta;
40037
+ const to = from + text.length;
40038
+ const pasteEvt = createClipboardPasteEvent(text);
40039
+ return processEvent({
40040
+ rule,
40041
+ state,
40042
+ from,
40043
+ to: { b: to },
40044
+ pasteEvt,
40045
+ });
40046
+ }
40047
+ // handle actual paste/drop
39924
40048
  const from = oldState.doc.content.findDiffStart(state.doc.content);
39925
40049
  const to = oldState.doc.content.findDiffEnd(state.doc.content);
40050
+ // stop if there is no changed range
39926
40051
  if (!isNumber$1(from) || !to || from === to.b) {
39927
40052
  return;
39928
40053
  }
39929
- // build a chainable state
39930
- // so we can use a single transaction for all paste rules
39931
- const tr = state.tr;
39932
- const chainableState = createChainableState({
39933
- state,
39934
- transaction: tr,
39935
- });
39936
- const handler = run$2({
39937
- editor,
39938
- state: chainableState,
39939
- from: Math.max(from - 1, 0),
39940
- to: to.b - 1,
40054
+ return processEvent({
39941
40055
  rule,
39942
- pasteEvent,
39943
- dropEvent,
40056
+ state,
40057
+ from,
40058
+ to,
40059
+ pasteEvt: pasteEvent,
39944
40060
  });
39945
- // stop if there are no changes
39946
- if (!handler || !tr.steps.length) {
39947
- return;
39948
- }
39949
- dropEvent = typeof DragEvent !== 'undefined' ? new DragEvent('drop') : null;
39950
- pasteEvent = typeof ClipboardEvent !== 'undefined' ? new ClipboardEvent('paste') : null;
39951
- return tr;
39952
40061
  },
39953
40062
  });
39954
40063
  });
@@ -40292,8 +40401,10 @@
40292
40401
  range,
40293
40402
  });
40294
40403
  }
40404
+ // do not descend into child nodes when there exists a serializer
40405
+ return false;
40295
40406
  }
40296
- else if (node.isText) {
40407
+ if (node.isText) {
40297
40408
  text += (_a = node === null || node === void 0 ? void 0 : node.text) === null || _a === void 0 ? void 0 : _a.slice(Math.max(from, pos) - pos, to - pos); // eslint-disable-line
40298
40409
  separated = false;
40299
40410
  }
@@ -40313,6 +40424,11 @@
40313
40424
 
40314
40425
  const ClipboardTextSerializer = Extension.create({
40315
40426
  name: 'clipboardTextSerializer',
40427
+ addOptions() {
40428
+ return {
40429
+ blockSeparator: undefined,
40430
+ };
40431
+ },
40316
40432
  addProseMirrorPlugins() {
40317
40433
  return [
40318
40434
  new Plugin({
@@ -40328,6 +40444,9 @@
40328
40444
  const textSerializers = getTextSerializersFromSchema(schema);
40329
40445
  const range = { from, to };
40330
40446
  return getTextBetween(doc, range, {
40447
+ ...(this.options.blockSeparator !== undefined
40448
+ ? { blockSeparator: this.options.blockSeparator }
40449
+ : {}),
40331
40450
  textSerializers,
40332
40451
  });
40333
40452
  },
@@ -40734,6 +40853,8 @@
40734
40853
  options = {
40735
40854
  parseOptions: {},
40736
40855
  updateSelection: true,
40856
+ applyInputRules: false,
40857
+ applyPasteRules: false,
40737
40858
  ...options,
40738
40859
  };
40739
40860
  const content = createNodeFromContent(value, editor.schema, {
@@ -40769,28 +40890,37 @@
40769
40890
  to += 1;
40770
40891
  }
40771
40892
  }
40893
+ let newContent;
40772
40894
  // if there is only plain text we have to use `insertText`
40773
40895
  // because this will keep the current marks
40774
40896
  if (isOnlyTextContent) {
40775
40897
  // if value is string, we can use it directly
40776
40898
  // otherwise if it is an array, we have to join it
40777
40899
  if (Array.isArray(value)) {
40778
- tr.insertText(value.map(v => v.text || '').join(''), from, to);
40900
+ newContent = value.map(v => v.text || '').join('');
40779
40901
  }
40780
40902
  else if (typeof value === 'object' && !!value && !!value.text) {
40781
- tr.insertText(value.text, from, to);
40903
+ newContent = value.text;
40782
40904
  }
40783
40905
  else {
40784
- tr.insertText(value, from, to);
40906
+ newContent = value;
40785
40907
  }
40908
+ tr.insertText(newContent, from, to);
40786
40909
  }
40787
40910
  else {
40788
- tr.replaceWith(from, to, content);
40911
+ newContent = content;
40912
+ tr.replaceWith(from, to, newContent);
40789
40913
  }
40790
40914
  // set cursor at end of inserted content
40791
40915
  if (options.updateSelection) {
40792
40916
  selectionToInsertionEnd(tr, tr.steps.length - 1, -1);
40793
40917
  }
40918
+ if (options.applyInputRules) {
40919
+ tr.setMeta('applyInputRules', { from, text: newContent });
40920
+ }
40921
+ if (options.applyPasteRules) {
40922
+ tr.setMeta('applyPasteRules', { from, text: newContent });
40923
+ }
40794
40924
  }
40795
40925
  return true;
40796
40926
  };
@@ -42117,7 +42247,7 @@
42117
42247
  const { selection, doc } = tr;
42118
42248
  const { empty, $anchor } = selection;
42119
42249
  const { pos, parent } = $anchor;
42120
- const $parentPos = $anchor.parent.isTextblock ? tr.doc.resolve(pos - 1) : $anchor;
42250
+ const $parentPos = $anchor.parent.isTextblock && pos > 0 ? tr.doc.resolve(pos - 1) : $anchor;
42121
42251
  const parentIsIsolating = $parentPos.parent.type.spec.isolating;
42122
42252
  const parentPos = $anchor.pos - $anchor.parentOffset;
42123
42253
  const isAtStart = (parentIsIsolating && $parentPos.parent.childCount === 1)
@@ -42233,16 +42363,6 @@
42233
42363
  },
42234
42364
  });
42235
42365
 
42236
- var extensions = /*#__PURE__*/Object.freeze({
42237
- __proto__: null,
42238
- ClipboardTextSerializer: ClipboardTextSerializer,
42239
- Commands: Commands,
42240
- Editable: Editable,
42241
- FocusEvents: FocusEvents,
42242
- Keymap: Keymap,
42243
- Tabindex: Tabindex
42244
- });
42245
-
42246
42366
  class NodePos {
42247
42367
  constructor(pos, editor, isBlock = false, node = null) {
42248
42368
  this.currentNode = null;
@@ -42337,7 +42457,7 @@
42337
42457
  const children = [];
42338
42458
  this.node.content.forEach((node, offset) => {
42339
42459
  const isBlock = node.isBlock && !node.isTextblock;
42340
- const targetPos = this.pos + offset + (isBlock ? 0 : 1);
42460
+ const targetPos = this.pos + offset + 1;
42341
42461
  const $pos = this.resolvedPos.doc.resolve(targetPos);
42342
42462
  if (!isBlock && $pos.depth <= this.depth) {
42343
42463
  return;
@@ -42386,7 +42506,7 @@
42386
42506
  querySelectorAll(selector, attributes = {}, firstItemOnly = false) {
42387
42507
  let nodes = [];
42388
42508
  // iterate through children recursively finding all nodes which match the selector with the node name
42389
- if (this.isBlock || !this.children || this.children.length === 0) {
42509
+ if (!this.children || this.children.length === 0) {
42390
42510
  return nodes;
42391
42511
  }
42392
42512
  this.children.forEach(childPos => {
@@ -42523,6 +42643,7 @@ img.ProseMirror-separator {
42523
42643
  editable: true,
42524
42644
  editorProps: {},
42525
42645
  parseOptions: {},
42646
+ coreExtensionOptions: {},
42526
42647
  enableInputRules: true,
42527
42648
  enablePasteRules: true,
42528
42649
  enableCoreExtensions: true,
@@ -42668,7 +42789,17 @@ img.ProseMirror-separator {
42668
42789
  * Creates an extension manager.
42669
42790
  */
42670
42791
  createExtensionManager() {
42671
- const coreExtensions = this.options.enableCoreExtensions ? Object.values(extensions) : [];
42792
+ var _a, _b;
42793
+ const coreExtensions = this.options.enableCoreExtensions ? [
42794
+ Editable,
42795
+ ClipboardTextSerializer.configure({
42796
+ blockSeparator: (_b = (_a = this.options.coreExtensionOptions) === null || _a === void 0 ? void 0 : _a.clipboardTextSerializer) === null || _b === void 0 ? void 0 : _b.blockSeparator,
42797
+ }),
42798
+ Commands,
42799
+ FocusEvents,
42800
+ Keymap,
42801
+ Tabindex,
42802
+ ] : [];
42672
42803
  const allExtensions = [...coreExtensions, ...this.options.extensions].filter(extension => {
42673
42804
  return ['extension', 'node', 'mark'].includes(extension === null || extension === void 0 ? void 0 : extension.type);
42674
42805
  });
@@ -45272,7 +45403,7 @@ img.ProseMirror-separator {
45272
45403
 
45273
45404
  // Currently without astral characters support.
45274
45405
  function isPunctChar (ch) {
45275
- return P.test(ch)
45406
+ return P.test(ch) || regex.test(ch)
45276
45407
  }
45277
45408
 
45278
45409
  // Markdown ASCII punctuation characters.
@@ -45461,7 +45592,6 @@ img.ProseMirror-separator {
45461
45592
  const result = {
45462
45593
  ok: false,
45463
45594
  pos: 0,
45464
- lines: 0,
45465
45595
  str: ''
45466
45596
  };
45467
45597
 
@@ -45532,52 +45662,66 @@ img.ProseMirror-separator {
45532
45662
  //
45533
45663
 
45534
45664
 
45535
- function parseLinkTitle (str, start, max) {
45536
- let code, marker;
45537
- let lines = 0;
45665
+ // Parse link title within `str` in [start, max] range,
45666
+ // or continue previous parsing if `prev_state` is defined (equal to result of last execution).
45667
+ //
45668
+ function parseLinkTitle (str, start, max, prev_state) {
45669
+ let code;
45538
45670
  let pos = start;
45539
45671
 
45540
- const result = {
45672
+ const state = {
45673
+ // if `true`, this is a valid link title
45541
45674
  ok: false,
45675
+ // if `true`, this link can be continued on the next line
45676
+ can_continue: false,
45677
+ // if `ok`, it's the position of the first character after the closing marker
45542
45678
  pos: 0,
45543
- lines: 0,
45544
- str: ''
45679
+ // if `ok`, it's the unescaped title
45680
+ str: '',
45681
+ // expected closing marker character code
45682
+ marker: 0
45545
45683
  };
45546
45684
 
45547
- if (pos >= max) { return result }
45685
+ if (prev_state) {
45686
+ // this is a continuation of a previous parseLinkTitle call on the next line,
45687
+ // used in reference links only
45688
+ state.str = prev_state.str;
45689
+ state.marker = prev_state.marker;
45690
+ } else {
45691
+ if (pos >= max) { return state }
45548
45692
 
45549
- marker = str.charCodeAt(pos);
45693
+ let marker = str.charCodeAt(pos);
45694
+ if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return state }
45550
45695
 
45551
- if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result }
45696
+ start++;
45697
+ pos++;
45552
45698
 
45553
- pos++;
45699
+ // if opening marker is "(", switch it to closing marker ")"
45700
+ if (marker === 0x28) { marker = 0x29; }
45554
45701
 
45555
- // if opening marker is "(", switch it to closing marker ")"
45556
- if (marker === 0x28) { marker = 0x29; }
45702
+ state.marker = marker;
45703
+ }
45557
45704
 
45558
45705
  while (pos < max) {
45559
45706
  code = str.charCodeAt(pos);
45560
- if (code === marker) {
45561
- result.pos = pos + 1;
45562
- result.lines = lines;
45563
- result.str = unescapeAll(str.slice(start + 1, pos));
45564
- result.ok = true;
45565
- return result
45566
- } else if (code === 0x28 /* ( */ && marker === 0x29 /* ) */) {
45567
- return result
45568
- } else if (code === 0x0A) {
45569
- lines++;
45707
+ if (code === state.marker) {
45708
+ state.pos = pos + 1;
45709
+ state.str += unescapeAll(str.slice(start, pos));
45710
+ state.ok = true;
45711
+ return state
45712
+ } else if (code === 0x28 /* ( */ && state.marker === 0x29 /* ) */) {
45713
+ return state
45570
45714
  } else if (code === 0x5C /* \ */ && pos + 1 < max) {
45571
45715
  pos++;
45572
- if (str.charCodeAt(pos) === 0x0A) {
45573
- lines++;
45574
- }
45575
45716
  }
45576
45717
 
45577
45718
  pos++;
45578
45719
  }
45579
45720
 
45580
- return result
45721
+ // no closing marker found, but this link title may continue on the next line (for references)
45722
+ state.can_continue = true;
45723
+ state.str += unescapeAll(str.slice(start, pos));
45724
+ return state
45581
45725
  }
45582
45726
 
45583
45727
  // Just a shortcut for bulk export
@@ -45727,7 +45871,7 @@ img.ProseMirror-separator {
45727
45871
  * }
45728
45872
  * ```
45729
45873
  *
45730
- * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
45874
+ * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.mjs)
45731
45875
  * for more details and examples.
45732
45876
  **/
45733
45877
  this.rules = assign$2({}, default_rules);
@@ -47240,6 +47384,14 @@ img.ProseMirror-separator {
47240
47384
  // GFM table, https://github.github.com/gfm/#tables-extension-
47241
47385
 
47242
47386
 
47387
+ // Limit the amount of empty autocompleted cells in a table,
47388
+ // see https://github.com/markdown-it/markdown-it/issues/1000,
47389
+ //
47390
+ // Both pulldown-cmark and commonmark-hs limit the number of cells this way to ~200k.
47391
+ // We set it to 65k, which can expand user input by a factor of x370
47392
+ // (256x256 square is 1.8kB expanded into 650kB).
47393
+ const MAX_AUTOCOMPLETED_CELLS = 0x10000;
47394
+
47243
47395
  function getLine (state, line) {
47244
47396
  const pos = state.bMarks[line] + state.tShift[line];
47245
47397
  const max = state.eMarks[line];
@@ -47395,6 +47547,7 @@ img.ProseMirror-separator {
47395
47547
  state.push('thead_close', 'thead', -1);
47396
47548
 
47397
47549
  let tbodyLines;
47550
+ let autocompletedCells = 0;
47398
47551
 
47399
47552
  for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
47400
47553
  if (state.sCount[nextLine] < state.blkIndent) { break }
@@ -47415,6 +47568,11 @@ img.ProseMirror-separator {
47415
47568
  if (columns.length && columns[0] === '') columns.shift();
47416
47569
  if (columns.length && columns[columns.length - 1] === '') columns.pop();
47417
47570
 
47571
+ // note: autocomplete count can be negative if user specifies more columns than header,
47572
+ // but that does not affect intended use (which is limiting expansion)
47573
+ autocompletedCells += columnCount - columns.length;
47574
+ if (autocompletedCells > MAX_AUTOCOMPLETED_CELLS) { break }
47575
+
47418
47576
  if (nextLine === startLine + 2) {
47419
47577
  const token_tbo = state.push('tbody_open', 'tbody', 1);
47420
47578
  token_tbo.map = tbodyLines = [startLine + 2, 0];
@@ -48158,8 +48316,6 @@ img.ProseMirror-separator {
48158
48316
  }
48159
48317
 
48160
48318
  function reference (state, startLine, _endLine, silent) {
48161
- let lines = 0;
48162
-
48163
48319
  let pos = state.bMarks[startLine] + state.tShift[startLine];
48164
48320
  let max = state.eMarks[startLine];
48165
48321
  let nextLine = startLine + 1;
@@ -48169,45 +48325,53 @@ img.ProseMirror-separator {
48169
48325
 
48170
48326
  if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false }
48171
48327
 
48172
- // Simple check to quickly interrupt scan on [link](url) at the start of line.
48173
- // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
48174
- while (++pos < max) {
48175
- if (state.src.charCodeAt(pos) === 0x5D /* ] */ &&
48176
- state.src.charCodeAt(pos - 1) !== 0x5C/* \ */) {
48177
- if (pos + 1 === max) { return false }
48178
- if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false }
48179
- break
48180
- }
48181
- }
48182
-
48183
- const endLine = state.lineMax;
48328
+ function getNextLine (nextLine) {
48329
+ const endLine = state.lineMax;
48184
48330
 
48185
- // jump line-by-line until empty one or EOF
48186
- const terminatorRules = state.md.block.ruler.getRules('reference');
48331
+ if (nextLine >= endLine || state.isEmpty(nextLine)) {
48332
+ // empty line or end of input
48333
+ return null
48334
+ }
48187
48335
 
48188
- const oldParentType = state.parentType;
48189
- state.parentType = 'reference';
48336
+ let isContinuation = false;
48190
48337
 
48191
- for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
48192
48338
  // this would be a code block normally, but after paragraph
48193
48339
  // it's considered a lazy continuation regardless of what's there
48194
- if (state.sCount[nextLine] - state.blkIndent > 3) { continue }
48340
+ if (state.sCount[nextLine] - state.blkIndent > 3) { isContinuation = true; }
48195
48341
 
48196
48342
  // quirk for blockquotes, this line should already be checked by that rule
48197
- if (state.sCount[nextLine] < 0) { continue }
48343
+ if (state.sCount[nextLine] < 0) { isContinuation = true; }
48344
+
48345
+ if (!isContinuation) {
48346
+ const terminatorRules = state.md.block.ruler.getRules('reference');
48347
+ const oldParentType = state.parentType;
48348
+ state.parentType = 'reference';
48349
+
48350
+ // Some tags can terminate paragraph without empty line.
48351
+ let terminate = false;
48352
+ for (let i = 0, l = terminatorRules.length; i < l; i++) {
48353
+ if (terminatorRules[i](state, nextLine, endLine, true)) {
48354
+ terminate = true;
48355
+ break
48356
+ }
48357
+ }
48198
48358
 
48199
- // Some tags can terminate paragraph without empty line.
48200
- let terminate = false;
48201
- for (let i = 0, l = terminatorRules.length; i < l; i++) {
48202
- if (terminatorRules[i](state, nextLine, endLine, true)) {
48203
- terminate = true;
48204
- break
48359
+ state.parentType = oldParentType;
48360
+ if (terminate) {
48361
+ // terminated by another block
48362
+ return null
48205
48363
  }
48206
48364
  }
48207
- if (terminate) { break }
48365
+
48366
+ const pos = state.bMarks[nextLine] + state.tShift[nextLine];
48367
+ const max = state.eMarks[nextLine];
48368
+
48369
+ // max + 1 explicitly includes the newline
48370
+ return state.src.slice(pos, max + 1)
48208
48371
  }
48209
48372
 
48210
- const str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
48373
+ let str = state.src.slice(pos, max + 1);
48374
+
48211
48375
  max = str.length;
48212
48376
  let labelEnd = -1;
48213
48377
 
@@ -48219,11 +48383,21 @@ img.ProseMirror-separator {
48219
48383
  labelEnd = pos;
48220
48384
  break
48221
48385
  } else if (ch === 0x0A /* \n */) {
48222
- lines++;
48386
+ const lineContent = getNextLine(nextLine);
48387
+ if (lineContent !== null) {
48388
+ str += lineContent;
48389
+ max = str.length;
48390
+ nextLine++;
48391
+ }
48223
48392
  } else if (ch === 0x5C /* \ */) {
48224
48393
  pos++;
48225
48394
  if (pos < max && str.charCodeAt(pos) === 0x0A) {
48226
- lines++;
48395
+ const lineContent = getNextLine(nextLine);
48396
+ if (lineContent !== null) {
48397
+ str += lineContent;
48398
+ max = str.length;
48399
+ nextLine++;
48400
+ }
48227
48401
  }
48228
48402
  }
48229
48403
  }
@@ -48235,7 +48409,12 @@ img.ProseMirror-separator {
48235
48409
  for (pos = labelEnd + 2; pos < max; pos++) {
48236
48410
  const ch = str.charCodeAt(pos);
48237
48411
  if (ch === 0x0A) {
48238
- lines++;
48412
+ const lineContent = getNextLine(nextLine);
48413
+ if (lineContent !== null) {
48414
+ str += lineContent;
48415
+ max = str.length;
48416
+ nextLine++;
48417
+ }
48239
48418
  } else if (isSpace(ch)) ; else {
48240
48419
  break
48241
48420
  }
@@ -48250,11 +48429,10 @@ img.ProseMirror-separator {
48250
48429
  if (!state.md.validateLink(href)) { return false }
48251
48430
 
48252
48431
  pos = destRes.pos;
48253
- lines += destRes.lines;
48254
48432
 
48255
48433
  // save cursor state, we could require to rollback later
48256
48434
  const destEndPos = pos;
48257
- const destEndLineNo = lines;
48435
+ const destEndLineNo = nextLine;
48258
48436
 
48259
48437
  // [label]: destination 'title'
48260
48438
  // ^^^ skipping those spaces
@@ -48262,7 +48440,12 @@ img.ProseMirror-separator {
48262
48440
  for (; pos < max; pos++) {
48263
48441
  const ch = str.charCodeAt(pos);
48264
48442
  if (ch === 0x0A) {
48265
- lines++;
48443
+ const lineContent = getNextLine(nextLine);
48444
+ if (lineContent !== null) {
48445
+ str += lineContent;
48446
+ max = str.length;
48447
+ nextLine++;
48448
+ }
48266
48449
  } else if (isSpace(ch)) ; else {
48267
48450
  break
48268
48451
  }
@@ -48270,17 +48453,25 @@ img.ProseMirror-separator {
48270
48453
 
48271
48454
  // [label]: destination 'title'
48272
48455
  // ^^^^^^^ parse this
48273
- const titleRes = state.md.helpers.parseLinkTitle(str, pos, max);
48456
+ let titleRes = state.md.helpers.parseLinkTitle(str, pos, max);
48457
+ while (titleRes.can_continue) {
48458
+ const lineContent = getNextLine(nextLine);
48459
+ if (lineContent === null) break
48460
+ str += lineContent;
48461
+ pos = max;
48462
+ max = str.length;
48463
+ nextLine++;
48464
+ titleRes = state.md.helpers.parseLinkTitle(str, pos, max, titleRes);
48465
+ }
48274
48466
  let title;
48275
48467
 
48276
48468
  if (pos < max && start !== pos && titleRes.ok) {
48277
48469
  title = titleRes.str;
48278
48470
  pos = titleRes.pos;
48279
- lines += titleRes.lines;
48280
48471
  } else {
48281
48472
  title = '';
48282
48473
  pos = destEndPos;
48283
- lines = destEndLineNo;
48474
+ nextLine = destEndLineNo;
48284
48475
  }
48285
48476
 
48286
48477
  // skip trailing spaces until the rest of the line
@@ -48296,7 +48487,7 @@ img.ProseMirror-separator {
48296
48487
  // but it could still be a valid reference if we roll back
48297
48488
  title = '';
48298
48489
  pos = destEndPos;
48299
- lines = destEndLineNo;
48490
+ nextLine = destEndLineNo;
48300
48491
  while (pos < max) {
48301
48492
  const ch = str.charCodeAt(pos);
48302
48493
  if (!isSpace(ch)) { break }
@@ -48327,9 +48518,7 @@ img.ProseMirror-separator {
48327
48518
  state.env.references[label] = { title, href };
48328
48519
  }
48329
48520
 
48330
- state.parentType = oldParentType;
48331
-
48332
- state.line = startLine + lines + 1;
48521
+ state.line = nextLine;
48333
48522
  return true
48334
48523
  }
48335
48524
 
@@ -48386,8 +48575,8 @@ img.ProseMirror-separator {
48386
48575
  'option',
48387
48576
  'p',
48388
48577
  'param',
48578
+ 'search',
48389
48579
  'section',
48390
- 'source',
48391
48580
  'summary',
48392
48581
  'table',
48393
48582
  'tbody',
@@ -48416,9 +48605,9 @@ img.ProseMirror-separator {
48416
48605
  const open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>';
48417
48606
 
48418
48607
  const close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>';
48419
- const comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';
48608
+ const comment = '<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->';
48420
48609
  const processing = '<[?][\\s\\S]*?[?]>';
48421
- const declaration = '<![A-Z]+\\s+[^>]*>';
48610
+ const declaration = '<![A-Za-z][^>]*>';
48422
48611
  const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';
48423
48612
 
48424
48613
  const HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +
@@ -48879,9 +49068,6 @@ img.ProseMirror-separator {
48879
49068
  // - canSplitWord - determine if these markers can be found inside a word
48880
49069
  //
48881
49070
  StateInline.prototype.scanDelims = function (start, canSplitWord) {
48882
- let can_open, can_close;
48883
- let left_flanking = true;
48884
- let right_flanking = true;
48885
49071
  const max = this.posMax;
48886
49072
  const marker = this.src.charCodeAt(start);
48887
49073
 
@@ -48902,29 +49088,13 @@ img.ProseMirror-separator {
48902
49088
  const isLastWhiteSpace = isWhiteSpace(lastChar);
48903
49089
  const isNextWhiteSpace = isWhiteSpace(nextChar);
48904
49090
 
48905
- if (isNextWhiteSpace) {
48906
- left_flanking = false;
48907
- } else if (isNextPunctChar) {
48908
- if (!(isLastWhiteSpace || isLastPunctChar)) {
48909
- left_flanking = false;
48910
- }
48911
- }
48912
-
48913
- if (isLastWhiteSpace) {
48914
- right_flanking = false;
48915
- } else if (isLastPunctChar) {
48916
- if (!(isNextWhiteSpace || isNextPunctChar)) {
48917
- right_flanking = false;
48918
- }
48919
- }
49091
+ const left_flanking =
49092
+ !isNextWhiteSpace && (!isNextPunctChar || isLastWhiteSpace || isLastPunctChar);
49093
+ const right_flanking =
49094
+ !isLastWhiteSpace && (!isLastPunctChar || isNextWhiteSpace || isNextPunctChar);
48920
49095
 
48921
- if (!canSplitWord) {
48922
- can_open = left_flanking && (!right_flanking || isLastPunctChar);
48923
- can_close = right_flanking && (!left_flanking || isNextPunctChar);
48924
- } else {
48925
- can_open = left_flanking;
48926
- can_close = right_flanking;
48927
- }
49096
+ const can_open = left_flanking && (canSplitWord || !right_flanking || isLastPunctChar);
49097
+ const can_close = right_flanking && (canSplitWord || !left_flanking || isNextPunctChar);
48928
49098
 
48929
49099
  return { can_open, can_close, length: count }
48930
49100
  };
@@ -48992,7 +49162,7 @@ img.ProseMirror-separator {
48992
49162
  // Alternative implementation, for memory.
48993
49163
  //
48994
49164
  // It costs 10% of performance, but allows extend terminators list, if place it
48995
- // to `ParcerInline` property. Probably, will switch to it sometime, such
49165
+ // to `ParserInline` property. Probably, will switch to it sometime, such
48996
49166
  // flexibility required.
48997
49167
 
48998
49168
  /*
@@ -51916,12 +52086,12 @@ img.ProseMirror-separator {
51916
52086
  * MarkdownIt provides named presets as a convenience to quickly
51917
52087
  * enable/disable active syntax rules and options for common use cases.
51918
52088
  *
51919
- * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
52089
+ * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.mjs) -
51920
52090
  * configures parser to strict [CommonMark](http://commonmark.org/) mode.
51921
- * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
52091
+ * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.mjs) -
51922
52092
  * similar to GFM, used when no preset name given. Enables all available rules,
51923
52093
  * but still without html, typographer & autolinker.
51924
- * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
52094
+ * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.mjs) -
51925
52095
  * all rules disabled. Useful to quickly setup your config via `.enable()`.
51926
52096
  * For example, when you need only `bold` and `italic` markup and nothing else.
51927
52097
  *
@@ -51938,7 +52108,7 @@ img.ProseMirror-separator {
51938
52108
  * Can be useful for external highlighters.
51939
52109
  * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
51940
52110
  * - __typographer__ - `false`. Set `true` to enable [some language-neutral
51941
- * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
52111
+ * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.mjs) +
51942
52112
  * quotes beautification (smartquotes).
51943
52113
  * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
51944
52114
  * pairs, when typographer enabled and smartquotes on. For example, you can
@@ -52064,7 +52234,7 @@ img.ProseMirror-separator {
52064
52234
  * md.renderer.rules['my_token'] = myToken
52065
52235
  * ```
52066
52236
  *
52067
- * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
52237
+ * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.mjs).
52068
52238
  **/
52069
52239
  this.renderer = new Renderer();
52070
52240
 
@@ -52072,7 +52242,7 @@ img.ProseMirror-separator {
52072
52242
  * MarkdownIt#linkify -> LinkifyIt
52073
52243
  *
52074
52244
  * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
52075
- * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
52245
+ * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.mjs)
52076
52246
  * rule.
52077
52247
  **/
52078
52248
  this.linkify = new LinkifyIt();
@@ -53413,22 +53583,16 @@ img.ProseMirror-separator {
53413
53583
  */
53414
53584
  class MentionInternals {
53415
53585
  constructor(options, mentionUpdateEmitter) {
53416
- /**
53417
- * Whether this mention has a valid configuration.
53418
- */
53419
- this.validConfiguration = true;
53420
53586
  this.iconTemplate = html `<${options.icon} slot="start"></${options.icon}>`;
53421
53587
  this.character = options.character;
53422
53588
  this.viewElement = options.viewElement;
53589
+ this.validator = options.validator;
53423
53590
  this.mentionUpdateEmitter = mentionUpdateEmitter;
53424
53591
  }
53425
53592
  }
53426
53593
  __decorate$1([
53427
53594
  observable
53428
53595
  ], MentionInternals.prototype, "mappingConfigs", void 0);
53429
- __decorate$1([
53430
- observable
53431
- ], MentionInternals.prototype, "validConfiguration", void 0);
53432
53596
  __decorate$1([
53433
53597
  observable
53434
53598
  ], MentionInternals.prototype, "pattern", void 0);
@@ -53449,8 +53613,6 @@ img.ProseMirror-separator {
53449
53613
  this.emitMentionUpdate(filter);
53450
53614
  });
53451
53615
  /** @internal */
53452
- this.validator = this.createValidator();
53453
- /** @internal */
53454
53616
  this.mappingNotifiers = [];
53455
53617
  /** @internal */
53456
53618
  this.mappingElements = [];
@@ -53459,13 +53621,13 @@ img.ProseMirror-separator {
53459
53621
  * @public
53460
53622
  */
53461
53623
  checkValidity() {
53462
- return this.mentionInternals.validConfiguration;
53624
+ return this.mentionInternals.validator.isValid();
53463
53625
  }
53464
53626
  /**
53465
53627
  * @public
53466
53628
  */
53467
53629
  get validity() {
53468
- return this.validator.getValidity();
53630
+ return this.mentionInternals.validator.getValidity();
53469
53631
  }
53470
53632
  /**
53471
53633
  * @internal
@@ -53499,8 +53661,8 @@ img.ProseMirror-separator {
53499
53661
  return mappingConfigs;
53500
53662
  }
53501
53663
  updateMappingConfigs() {
53502
- this.validator.validate(this.mappingElements, this.pattern);
53503
- this.mentionInternals.mappingConfigs = this.validator.isValid()
53664
+ this.mentionInternals.validator.validate(this.mappingElements, this.pattern);
53665
+ this.mentionInternals.mappingConfigs = this.mentionInternals.validator.isValid()
53504
53666
  ? this.getMappingConfigs()
53505
53667
  : undefined;
53506
53668
  }
@@ -53509,7 +53671,7 @@ img.ProseMirror-separator {
53509
53671
  this.observeMappingElements();
53510
53672
  }
53511
53673
  patternChanged() {
53512
- this.validator.validate(this.mappingElements, this.pattern);
53674
+ this.mentionInternals.validator.validate(this.mappingElements, this.pattern);
53513
53675
  this.mentionInternals.pattern = this.pattern;
53514
53676
  }
53515
53677
  buttonLabelChanged() {
@@ -53573,7 +53735,7 @@ img.ProseMirror-separator {
53573
53735
  constructor(mentionElements) {
53574
53736
  this.parserMentionConfig = [];
53575
53737
  this.isValid = true;
53576
- this.isValid = mentionElements.every(mentionElement => mentionElement.mentionInternals.validConfiguration);
53738
+ this.isValid = mentionElements.every(mentionElement => mentionElement.mentionInternals.validator.isValid());
53577
53739
  this.parserMentionConfig = this.isValid
53578
53740
  ? mentionElements.map(mentionElement => new MarkdownParserMentionConfiguration(mentionElement.mentionInternals))
53579
53741
  : [];
@@ -53714,7 +53876,7 @@ img.ProseMirror-separator {
53714
53876
  this.validateMentionConfigurations(mentions);
53715
53877
  }
53716
53878
  validateMentionConfigurations(mentions) {
53717
- this.invalidMentionConfiguration = mentions.some(x => !x.mentionInternals.validConfiguration);
53879
+ this.invalidMentionConfiguration = mentions.some(x => !x.mentionInternals.validator.isValid());
53718
53880
  return !this.invalidMentionConfiguration;
53719
53881
  }
53720
53882
  validateDuplicateMentionConfigurations(mentions) {
@@ -53819,10 +53981,10 @@ img.ProseMirror-separator {
53819
53981
  observable
53820
53982
  ], RichText.prototype, "configuration", void 0);
53821
53983
 
53822
- const starInputRegex$1 = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/;
53823
- const starPasteRegex$1 = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g;
53824
- const underscoreInputRegex$1 = /(?:^|\s)((?:__)((?:[^__]+))(?:__))$/;
53825
- const underscorePasteRegex$1 = /(?:^|\s)((?:__)((?:[^__]+))(?:__))/g;
53984
+ const starInputRegex$1 = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;
53985
+ const starPasteRegex$1 = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;
53986
+ const underscoreInputRegex$1 = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;
53987
+ const underscorePasteRegex$1 = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;
53826
53988
  const Bold = Mark.create({
53827
53989
  name: 'bold',
53828
53990
  addOptions() {
@@ -54550,16 +54712,16 @@ img.ProseMirror-separator {
54550
54712
  }
54551
54713
  // Apply the latest event from one branch to the document and shift the event
54552
54714
  // onto the other branch.
54553
- function histTransaction(history, state, dispatch, redo) {
54715
+ function histTransaction(history, state, redo) {
54554
54716
  let preserveItems = mustPreserveItems(state);
54555
54717
  let histOptions = historyKey.get(state).spec.config;
54556
54718
  let pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);
54557
54719
  if (!pop)
54558
- return;
54720
+ return null;
54559
54721
  let selection = pop.selection.resolve(pop.transform.doc);
54560
54722
  let added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
54561
54723
  let newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0, -1);
54562
- dispatch(pop.transform.setSelection(selection).setMeta(historyKey, { redo, historyState: newHist }).scrollIntoView());
54724
+ return pop.transform.setSelection(selection).setMeta(historyKey, { redo, historyState: newHist });
54563
54725
  }
54564
54726
  let cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
54565
54727
  // Check whether any plugin in the given state has a
@@ -54618,28 +54780,27 @@ img.ProseMirror-separator {
54618
54780
  }
54619
54781
  });
54620
54782
  }
54783
+ function buildCommand(redo, scroll) {
54784
+ return (state, dispatch) => {
54785
+ let hist = historyKey.getState(state);
54786
+ if (!hist || (redo ? hist.undone : hist.done).eventCount == 0)
54787
+ return false;
54788
+ if (dispatch) {
54789
+ let tr = histTransaction(hist, state, redo);
54790
+ if (tr)
54791
+ dispatch(scroll ? tr.scrollIntoView() : tr);
54792
+ }
54793
+ return true;
54794
+ };
54795
+ }
54621
54796
  /**
54622
54797
  A command function that undoes the last change, if any.
54623
54798
  */
54624
- const undo = (state, dispatch) => {
54625
- let hist = historyKey.getState(state);
54626
- if (!hist || hist.done.eventCount == 0)
54627
- return false;
54628
- if (dispatch)
54629
- histTransaction(hist, state, dispatch, false);
54630
- return true;
54631
- };
54799
+ const undo = buildCommand(false, true);
54632
54800
  /**
54633
54801
  A command function that redoes the last undone change, if any.
54634
54802
  */
54635
- const redo = (state, dispatch) => {
54636
- let hist = historyKey.getState(state);
54637
- if (!hist || hist.undone.eventCount == 0)
54638
- return false;
54639
- if (dispatch)
54640
- histTransaction(hist, state, dispatch, true);
54641
- return true;
54642
- };
54803
+ const redo = buildCommand(true, true);
54643
54804
 
54644
54805
  const History = Extension.create({
54645
54806
  name: 'history',
@@ -54676,10 +54837,10 @@ img.ProseMirror-separator {
54676
54837
  },
54677
54838
  });
54678
54839
 
54679
- const starInputRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))$/;
54680
- const starPasteRegex = /(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/g;
54681
- const underscoreInputRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))$/;
54682
- const underscorePasteRegex = /(?:^|\s)((?:_)((?:[^_]+))(?:_))/g;
54840
+ const starInputRegex = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/;
54841
+ const starPasteRegex = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g;
54842
+ const underscoreInputRegex = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/;
54843
+ const underscorePasteRegex = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;
54683
54844
  const Italic = Mark.create({
54684
54845
  name: 'italic',
54685
54846
  addOptions() {
@@ -56495,6 +56656,25 @@ img.ProseMirror-separator {
56495
56656
  return filtered;
56496
56657
  }
56497
56658
 
56659
+ /**
56660
+ * Check if the provided tokens form a valid link structure, which can either be a single link token
56661
+ * or a link token surrounded by parentheses or square brackets.
56662
+ *
56663
+ * This ensures that only complete and valid text is hyperlinked, preventing cases where a valid
56664
+ * top-level domain (TLD) is immediately followed by an invalid character, like a number. For
56665
+ * example, with the `find` method from Linkify, entering `example.com1` would result in
56666
+ * `example.com` being linked and the trailing `1` left as plain text. By using the `tokenize`
56667
+ * method, we can perform more comprehensive validation on the input text.
56668
+ */
56669
+ function isValidLinkStructure(tokens) {
56670
+ if (tokens.length === 1) {
56671
+ return tokens[0].isLink;
56672
+ }
56673
+ if (tokens.length === 3 && tokens[1].isLink) {
56674
+ return ['()', '[]'].includes(tokens[0].value + tokens[2].value);
56675
+ }
56676
+ return false;
56677
+ }
56498
56678
  function autolink(options) {
56499
56679
  return new Plugin({
56500
56680
  key: new PluginKey('autolink'),
@@ -56533,7 +56713,11 @@ img.ProseMirror-separator {
56533
56713
  if (!lastWordBeforeSpace) {
56534
56714
  return false;
56535
56715
  }
56536
- find$1(lastWordBeforeSpace)
56716
+ const linksBeforeSpace = tokenize(lastWordBeforeSpace).map(t => t.toObject());
56717
+ if (!isValidLinkStructure(linksBeforeSpace)) {
56718
+ return false;
56719
+ }
56720
+ linksBeforeSpace
56537
56721
  .filter(link => link.isLink)
56538
56722
  // Calculate link position.
56539
56723
  .map(link => ({
@@ -56580,6 +56764,9 @@ img.ProseMirror-separator {
56580
56764
  props: {
56581
56765
  handleClick: (view, pos, event) => {
56582
56766
  var _a, _b;
56767
+ if (options.whenNotEditable && view.editable) {
56768
+ return false;
56769
+ }
56583
56770
  if (event.button !== 0) {
56584
56771
  return false;
56585
56772
  }
@@ -56754,6 +56941,7 @@ img.ProseMirror-separator {
56754
56941
  if (this.options.openOnClick) {
56755
56942
  plugins.push(clickHandler({
56756
56943
  type: this.type,
56944
+ whenNotEditable: this.options.openOnClick === 'whenNotEditable',
56757
56945
  }));
56758
56946
  }
56759
56947
  if (this.options.linkOnPaste) {
@@ -57129,7 +57317,7 @@ img.ProseMirror-separator {
57129
57317
  text: state.text,
57130
57318
  items: [],
57131
57319
  command: commandProps => {
57132
- command({
57320
+ return command({
57133
57321
  editor,
57134
57322
  range: state.range,
57135
57323
  props: commandProps,
@@ -57283,11 +57471,12 @@ img.ProseMirror-separator {
57283
57471
  var _a;
57284
57472
  return `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`;
57285
57473
  },
57474
+ deleteTriggerWithBackspace: false,
57286
57475
  renderHTML({ options, node }) {
57287
57476
  var _a;
57288
57477
  return [
57289
57478
  'span',
57290
- this.HTMLAttributes,
57479
+ mergeAttributes(this.HTMLAttributes, options.HTMLAttributes),
57291
57480
  `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`,
57292
57481
  ];
57293
57482
  },
@@ -57379,8 +57568,10 @@ img.ProseMirror-separator {
57379
57568
  }),
57380
57569
  ];
57381
57570
  }
57571
+ const mergedOptions = { ...this.options };
57572
+ mergedOptions.HTMLAttributes = mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes);
57382
57573
  const html = this.options.renderHTML({
57383
- options: this.options,
57574
+ options: mergedOptions,
57384
57575
  node,
57385
57576
  });
57386
57577
  if (typeof html === 'string') {
@@ -57417,7 +57608,7 @@ img.ProseMirror-separator {
57417
57608
  state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
57418
57609
  if (node.type.name === this.name) {
57419
57610
  isMention = true;
57420
- tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize);
57611
+ tr.insertText(this.options.deleteTriggerWithBackspace ? '' : this.options.suggestion.char || '', pos, pos + node.nodeSize);
57421
57612
  return false;
57422
57613
  }
57423
57614
  });
@@ -60020,6 +60211,31 @@ img.ProseMirror-separator {
60020
60211
  *
60021
60212
  * @license MIT
60022
60213
  */
60214
+ // type Person = {
60215
+ // firstName: string
60216
+ // lastName: string
60217
+ // age: number
60218
+ // visits: number
60219
+ // status: string
60220
+ // progress: number
60221
+ // createdAt: Date
60222
+ // nested: {
60223
+ // foo: [
60224
+ // {
60225
+ // bar: 'bar'
60226
+ // }
60227
+ // ]
60228
+ // bar: { subBar: boolean }[]
60229
+ // baz: {
60230
+ // foo: 'foo'
60231
+ // bar: {
60232
+ // baz: 'baz'
60233
+ // }
60234
+ // }
60235
+ // }
60236
+ // }
60237
+
60238
+
60023
60239
  // Is this type a tuple?
60024
60240
 
60025
60241
  // If this type is a tuple, what indices are allowed?
@@ -60107,6 +60323,32 @@ img.ProseMirror-separator {
60107
60323
  };
60108
60324
  }
60109
60325
 
60326
+ function createCell(table, row, column, columnId) {
60327
+ const getRenderValue = () => {
60328
+ var _cell$getValue;
60329
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
60330
+ };
60331
+ const cell = {
60332
+ id: `${row.id}_${column.id}`,
60333
+ row,
60334
+ column,
60335
+ getValue: () => row.getValue(columnId),
60336
+ renderValue: getRenderValue,
60337
+ getContext: memo$1(() => [table, column, row, cell], (table, column, row, cell) => ({
60338
+ table,
60339
+ column,
60340
+ row,
60341
+ cell: cell,
60342
+ getValue: cell.getValue,
60343
+ renderValue: cell.renderValue
60344
+ }), getMemoOptions(table.options, 'debugCells', 'cell.getContext'))
60345
+ };
60346
+ table._features.forEach(feature => {
60347
+ feature.createCell == null || feature.createCell(cell, column, row, table);
60348
+ }, {});
60349
+ return cell;
60350
+ }
60351
+
60110
60352
  function createColumn(table, columnDef, depth, parent) {
60111
60353
  var _ref, _resolvedColumnDef$id;
60112
60354
  const defaultColumn = table._getDefaultColumnDef();
@@ -60166,7 +60408,7 @@ img.ProseMirror-separator {
60166
60408
  feature.createColumn == null || feature.createColumn(column, table);
60167
60409
  }
60168
60410
 
60169
- // Yes, we have to convert table to uknown, because we know more than the compiler here.
60411
+ // Yes, we have to convert table to unknown, because we know more than the compiler here.
60170
60412
  return column;
60171
60413
  }
60172
60414
 
@@ -60423,92 +60665,803 @@ img.ProseMirror-separator {
60423
60665
  return headerGroups;
60424
60666
  }
60425
60667
 
60426
- //
60668
+ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
60669
+ let row = {
60670
+ id,
60671
+ index: rowIndex,
60672
+ original,
60673
+ depth,
60674
+ parentId,
60675
+ _valuesCache: {},
60676
+ _uniqueValuesCache: {},
60677
+ getValue: columnId => {
60678
+ if (row._valuesCache.hasOwnProperty(columnId)) {
60679
+ return row._valuesCache[columnId];
60680
+ }
60681
+ const column = table.getColumn(columnId);
60682
+ if (!(column != null && column.accessorFn)) {
60683
+ return undefined;
60684
+ }
60685
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
60686
+ return row._valuesCache[columnId];
60687
+ },
60688
+ getUniqueValues: columnId => {
60689
+ if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
60690
+ return row._uniqueValuesCache[columnId];
60691
+ }
60692
+ const column = table.getColumn(columnId);
60693
+ if (!(column != null && column.accessorFn)) {
60694
+ return undefined;
60695
+ }
60696
+ if (!column.columnDef.getUniqueValues) {
60697
+ row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
60698
+ return row._uniqueValuesCache[columnId];
60699
+ }
60700
+ row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
60701
+ return row._uniqueValuesCache[columnId];
60702
+ },
60703
+ renderValue: columnId => {
60704
+ var _row$getValue;
60705
+ return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
60706
+ },
60707
+ subRows: subRows != null ? subRows : [],
60708
+ getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
60709
+ getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
60710
+ getParentRows: () => {
60711
+ let parentRows = [];
60712
+ let currentRow = row;
60713
+ while (true) {
60714
+ const parentRow = currentRow.getParentRow();
60715
+ if (!parentRow) break;
60716
+ parentRows.push(parentRow);
60717
+ currentRow = parentRow;
60718
+ }
60719
+ return parentRows.reverse();
60720
+ },
60721
+ getAllCells: memo$1(() => [table.getAllLeafColumns()], leafColumns => {
60722
+ return leafColumns.map(column => {
60723
+ return createCell(table, row, column, column.id);
60724
+ });
60725
+ }, getMemoOptions(table.options, 'debugRows', 'getAllCells')),
60726
+ _getAllCellsByColumnId: memo$1(() => [row.getAllCells()], allCells => {
60727
+ return allCells.reduce((acc, cell) => {
60728
+ acc[cell.column.id] = cell;
60729
+ return acc;
60730
+ }, {});
60731
+ }, getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId'))
60732
+ };
60733
+ for (let i = 0; i < table._features.length; i++) {
60734
+ const feature = table._features[i];
60735
+ feature == null || feature.createRow == null || feature.createRow(row, table);
60736
+ }
60737
+ return row;
60738
+ };
60427
60739
 
60428
60740
  //
60429
60741
 
60430
- const defaultColumnSizing = {
60431
- size: 150,
60432
- minSize: 20,
60433
- maxSize: Number.MAX_SAFE_INTEGER
60742
+ const ColumnFaceting = {
60743
+ createColumn: (column, table) => {
60744
+ column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
60745
+ column.getFacetedRowModel = () => {
60746
+ if (!column._getFacetedRowModel) {
60747
+ return table.getPreFilteredRowModel();
60748
+ }
60749
+ return column._getFacetedRowModel();
60750
+ };
60751
+ column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
60752
+ column.getFacetedUniqueValues = () => {
60753
+ if (!column._getFacetedUniqueValues) {
60754
+ return new Map();
60755
+ }
60756
+ return column._getFacetedUniqueValues();
60757
+ };
60758
+ column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
60759
+ column.getFacetedMinMaxValues = () => {
60760
+ if (!column._getFacetedMinMaxValues) {
60761
+ return undefined;
60762
+ }
60763
+ return column._getFacetedMinMaxValues();
60764
+ };
60765
+ }
60434
60766
  };
60435
- const getDefaultColumnSizingInfoState = () => ({
60436
- startOffset: null,
60437
- startSize: null,
60438
- deltaOffset: null,
60439
- deltaPercentage: null,
60440
- isResizingColumn: false,
60441
- columnSizingStart: []
60442
- });
60443
- const ColumnSizing = {
60767
+
60768
+ const includesString = (row, columnId, filterValue) => {
60769
+ var _row$getValue;
60770
+ const search = filterValue.toLowerCase();
60771
+ return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
60772
+ };
60773
+ includesString.autoRemove = val => testFalsey(val);
60774
+ const includesStringSensitive = (row, columnId, filterValue) => {
60775
+ var _row$getValue2;
60776
+ return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
60777
+ };
60778
+ includesStringSensitive.autoRemove = val => testFalsey(val);
60779
+ const equalsString = (row, columnId, filterValue) => {
60780
+ var _row$getValue3;
60781
+ return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
60782
+ };
60783
+ equalsString.autoRemove = val => testFalsey(val);
60784
+ const arrIncludes = (row, columnId, filterValue) => {
60785
+ var _row$getValue4;
60786
+ return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
60787
+ };
60788
+ arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
60789
+ const arrIncludesAll = (row, columnId, filterValue) => {
60790
+ return !filterValue.some(val => {
60791
+ var _row$getValue5;
60792
+ return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
60793
+ });
60794
+ };
60795
+ arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
60796
+ const arrIncludesSome = (row, columnId, filterValue) => {
60797
+ return filterValue.some(val => {
60798
+ var _row$getValue6;
60799
+ return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
60800
+ });
60801
+ };
60802
+ arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
60803
+ const equals = (row, columnId, filterValue) => {
60804
+ return row.getValue(columnId) === filterValue;
60805
+ };
60806
+ equals.autoRemove = val => testFalsey(val);
60807
+ const weakEquals = (row, columnId, filterValue) => {
60808
+ return row.getValue(columnId) == filterValue;
60809
+ };
60810
+ weakEquals.autoRemove = val => testFalsey(val);
60811
+ const inNumberRange = (row, columnId, filterValue) => {
60812
+ let [min, max] = filterValue;
60813
+ const rowValue = row.getValue(columnId);
60814
+ return rowValue >= min && rowValue <= max;
60815
+ };
60816
+ inNumberRange.resolveFilterValue = val => {
60817
+ let [unsafeMin, unsafeMax] = val;
60818
+ let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
60819
+ let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
60820
+ let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
60821
+ let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
60822
+ if (min > max) {
60823
+ const temp = min;
60824
+ min = max;
60825
+ max = temp;
60826
+ }
60827
+ return [min, max];
60828
+ };
60829
+ inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
60830
+
60831
+ // Export
60832
+
60833
+ const filterFns = {
60834
+ includesString,
60835
+ includesStringSensitive,
60836
+ equalsString,
60837
+ arrIncludes,
60838
+ arrIncludesAll,
60839
+ arrIncludesSome,
60840
+ equals,
60841
+ weakEquals,
60842
+ inNumberRange
60843
+ };
60844
+ // Utils
60845
+
60846
+ function testFalsey(val) {
60847
+ return val === undefined || val === null || val === '';
60848
+ }
60849
+
60850
+ //
60851
+
60852
+ const ColumnFiltering = {
60444
60853
  getDefaultColumnDef: () => {
60445
- return defaultColumnSizing;
60854
+ return {
60855
+ filterFn: 'auto'
60856
+ };
60446
60857
  },
60447
60858
  getInitialState: state => {
60448
60859
  return {
60449
- columnSizing: {},
60450
- columnSizingInfo: getDefaultColumnSizingInfoState(),
60860
+ columnFilters: [],
60451
60861
  ...state
60452
60862
  };
60453
60863
  },
60454
60864
  getDefaultOptions: table => {
60455
60865
  return {
60456
- columnResizeMode: 'onEnd',
60457
- columnResizeDirection: 'ltr',
60458
- onColumnSizingChange: makeStateUpdater('columnSizing', table),
60459
- onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table)
60866
+ onColumnFiltersChange: makeStateUpdater('columnFilters', table),
60867
+ filterFromLeafRows: false,
60868
+ maxLeafRowFilterDepth: 100
60460
60869
  };
60461
60870
  },
60462
60871
  createColumn: (column, table) => {
60463
- column.getSize = () => {
60464
- var _column$columnDef$min, _ref, _column$columnDef$max;
60465
- const columnSize = table.getState().columnSizing[column.id];
60466
- return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
60467
- };
60468
- column.getStart = memo$1(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getStart'));
60469
- column.getAfter = memo$1(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getAfter'));
60470
- column.resetSize = () => {
60471
- table.setColumnSizing(_ref2 => {
60472
- let {
60473
- [column.id]: _,
60474
- ...rest
60475
- } = _ref2;
60476
- return rest;
60477
- });
60872
+ column.getAutoFilterFn = () => {
60873
+ const firstRow = table.getCoreRowModel().flatRows[0];
60874
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
60875
+ if (typeof value === 'string') {
60876
+ return filterFns.includesString;
60877
+ }
60878
+ if (typeof value === 'number') {
60879
+ return filterFns.inNumberRange;
60880
+ }
60881
+ if (typeof value === 'boolean') {
60882
+ return filterFns.equals;
60883
+ }
60884
+ if (value !== null && typeof value === 'object') {
60885
+ return filterFns.equals;
60886
+ }
60887
+ if (Array.isArray(value)) {
60888
+ return filterFns.arrIncludes;
60889
+ }
60890
+ return filterFns.weakEquals;
60478
60891
  };
60479
- column.getCanResize = () => {
60480
- var _column$columnDef$ena, _table$options$enable;
60481
- return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
60892
+ column.getFilterFn = () => {
60893
+ var _table$options$filter, _table$options$filter2;
60894
+ return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : // @ts-ignore
60895
+ (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
60482
60896
  };
60483
- column.getIsResizing = () => {
60484
- return table.getState().columnSizingInfo.isResizingColumn === column.id;
60897
+ column.getCanFilter = () => {
60898
+ var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
60899
+ return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
60485
60900
  };
60486
- },
60487
- createHeader: (header, table) => {
60488
- header.getSize = () => {
60489
- let sum = 0;
60490
- const recurse = header => {
60491
- if (header.subHeaders.length) {
60492
- header.subHeaders.forEach(recurse);
60493
- } else {
60494
- var _header$column$getSiz;
60495
- sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
60496
- }
60497
- };
60498
- recurse(header);
60499
- return sum;
60901
+ column.getIsFiltered = () => column.getFilterIndex() > -1;
60902
+ column.getFilterValue = () => {
60903
+ var _table$getState$colum;
60904
+ return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
60500
60905
  };
60501
- header.getStart = () => {
60502
- if (header.index > 0) {
60503
- const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
60504
- return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
60505
- }
60506
- return 0;
60906
+ column.getFilterIndex = () => {
60907
+ var _table$getState$colum2, _table$getState$colum3;
60908
+ return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) != null ? _table$getState$colum2 : -1;
60507
60909
  };
60508
- header.getResizeHandler = _contextDocument => {
60509
- const column = table.getColumn(header.column.id);
60510
- const canResize = column == null ? void 0 : column.getCanResize();
60511
- return e => {
60910
+ column.setFilterValue = value => {
60911
+ table.setColumnFilters(old => {
60912
+ const filterFn = column.getFilterFn();
60913
+ const previousFilter = old == null ? void 0 : old.find(d => d.id === column.id);
60914
+ const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : undefined);
60915
+
60916
+ //
60917
+ if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
60918
+ var _old$filter;
60919
+ return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
60920
+ }
60921
+ const newFilterObj = {
60922
+ id: column.id,
60923
+ value: newFilter
60924
+ };
60925
+ if (previousFilter) {
60926
+ var _old$map;
60927
+ return (_old$map = old == null ? void 0 : old.map(d => {
60928
+ if (d.id === column.id) {
60929
+ return newFilterObj;
60930
+ }
60931
+ return d;
60932
+ })) != null ? _old$map : [];
60933
+ }
60934
+ if (old != null && old.length) {
60935
+ return [...old, newFilterObj];
60936
+ }
60937
+ return [newFilterObj];
60938
+ });
60939
+ };
60940
+ },
60941
+ createRow: (row, _table) => {
60942
+ row.columnFilters = {};
60943
+ row.columnFiltersMeta = {};
60944
+ },
60945
+ createTable: table => {
60946
+ table.setColumnFilters = updater => {
60947
+ const leafColumns = table.getAllLeafColumns();
60948
+ const updateFn = old => {
60949
+ var _functionalUpdate;
60950
+ return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
60951
+ const column = leafColumns.find(d => d.id === filter.id);
60952
+ if (column) {
60953
+ const filterFn = column.getFilterFn();
60954
+ if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
60955
+ return false;
60956
+ }
60957
+ }
60958
+ return true;
60959
+ });
60960
+ };
60961
+ table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
60962
+ };
60963
+ table.resetColumnFilters = defaultState => {
60964
+ var _table$initialState$c, _table$initialState;
60965
+ table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
60966
+ };
60967
+ table.getPreFilteredRowModel = () => table.getCoreRowModel();
60968
+ table.getFilteredRowModel = () => {
60969
+ if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
60970
+ table._getFilteredRowModel = table.options.getFilteredRowModel(table);
60971
+ }
60972
+ if (table.options.manualFiltering || !table._getFilteredRowModel) {
60973
+ return table.getPreFilteredRowModel();
60974
+ }
60975
+ return table._getFilteredRowModel();
60976
+ };
60977
+ }
60978
+ };
60979
+ function shouldAutoRemoveFilter(filterFn, value, column) {
60980
+ return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
60981
+ }
60982
+
60983
+ const sum = (columnId, _leafRows, childRows) => {
60984
+ // It's faster to just add the aggregations together instead of
60985
+ // process leaf nodes individually
60986
+ return childRows.reduce((sum, next) => {
60987
+ const nextValue = next.getValue(columnId);
60988
+ return sum + (typeof nextValue === 'number' ? nextValue : 0);
60989
+ }, 0);
60990
+ };
60991
+ const min = (columnId, _leafRows, childRows) => {
60992
+ let min;
60993
+ childRows.forEach(row => {
60994
+ const value = row.getValue(columnId);
60995
+ if (value != null && (min > value || min === undefined && value >= value)) {
60996
+ min = value;
60997
+ }
60998
+ });
60999
+ return min;
61000
+ };
61001
+ const max = (columnId, _leafRows, childRows) => {
61002
+ let max;
61003
+ childRows.forEach(row => {
61004
+ const value = row.getValue(columnId);
61005
+ if (value != null && (max < value || max === undefined && value >= value)) {
61006
+ max = value;
61007
+ }
61008
+ });
61009
+ return max;
61010
+ };
61011
+ const extent = (columnId, _leafRows, childRows) => {
61012
+ let min;
61013
+ let max;
61014
+ childRows.forEach(row => {
61015
+ const value = row.getValue(columnId);
61016
+ if (value != null) {
61017
+ if (min === undefined) {
61018
+ if (value >= value) min = max = value;
61019
+ } else {
61020
+ if (min > value) min = value;
61021
+ if (max < value) max = value;
61022
+ }
61023
+ }
61024
+ });
61025
+ return [min, max];
61026
+ };
61027
+ const mean = (columnId, leafRows) => {
61028
+ let count = 0;
61029
+ let sum = 0;
61030
+ leafRows.forEach(row => {
61031
+ let value = row.getValue(columnId);
61032
+ if (value != null && (value = +value) >= value) {
61033
+ ++count, sum += value;
61034
+ }
61035
+ });
61036
+ if (count) return sum / count;
61037
+ return;
61038
+ };
61039
+ const median = (columnId, leafRows) => {
61040
+ if (!leafRows.length) {
61041
+ return;
61042
+ }
61043
+ const values = leafRows.map(row => row.getValue(columnId));
61044
+ if (!isNumberArray$1(values)) {
61045
+ return;
61046
+ }
61047
+ if (values.length === 1) {
61048
+ return values[0];
61049
+ }
61050
+ const mid = Math.floor(values.length / 2);
61051
+ const nums = values.sort((a, b) => a - b);
61052
+ return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
61053
+ };
61054
+ const unique = (columnId, leafRows) => {
61055
+ return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
61056
+ };
61057
+ const uniqueCount = (columnId, leafRows) => {
61058
+ return new Set(leafRows.map(d => d.getValue(columnId))).size;
61059
+ };
61060
+ const count = (_columnId, leafRows) => {
61061
+ return leafRows.length;
61062
+ };
61063
+ const aggregationFns = {
61064
+ sum,
61065
+ min,
61066
+ max,
61067
+ extent,
61068
+ mean,
61069
+ median,
61070
+ unique,
61071
+ uniqueCount,
61072
+ count
61073
+ };
61074
+
61075
+ //
61076
+
61077
+ const ColumnGrouping = {
61078
+ getDefaultColumnDef: () => {
61079
+ return {
61080
+ aggregatedCell: props => {
61081
+ var _toString, _props$getValue;
61082
+ return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
61083
+ },
61084
+ aggregationFn: 'auto'
61085
+ };
61086
+ },
61087
+ getInitialState: state => {
61088
+ return {
61089
+ grouping: [],
61090
+ ...state
61091
+ };
61092
+ },
61093
+ getDefaultOptions: table => {
61094
+ return {
61095
+ onGroupingChange: makeStateUpdater('grouping', table),
61096
+ groupedColumnMode: 'reorder'
61097
+ };
61098
+ },
61099
+ createColumn: (column, table) => {
61100
+ column.toggleGrouping = () => {
61101
+ table.setGrouping(old => {
61102
+ // Find any existing grouping for this column
61103
+ if (old != null && old.includes(column.id)) {
61104
+ return old.filter(d => d !== column.id);
61105
+ }
61106
+ return [...(old != null ? old : []), column.id];
61107
+ });
61108
+ };
61109
+ column.getCanGroup = () => {
61110
+ var _column$columnDef$ena, _table$options$enable;
61111
+ return ((_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGrouping) != null ? _table$options$enable : true) && (!!column.accessorFn || !!column.columnDef.getGroupingValue);
61112
+ };
61113
+ column.getIsGrouped = () => {
61114
+ var _table$getState$group;
61115
+ return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
61116
+ };
61117
+ column.getGroupedIndex = () => {
61118
+ var _table$getState$group2;
61119
+ return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
61120
+ };
61121
+ column.getToggleGroupingHandler = () => {
61122
+ const canGroup = column.getCanGroup();
61123
+ return () => {
61124
+ if (!canGroup) return;
61125
+ column.toggleGrouping();
61126
+ };
61127
+ };
61128
+ column.getAutoAggregationFn = () => {
61129
+ const firstRow = table.getCoreRowModel().flatRows[0];
61130
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
61131
+ if (typeof value === 'number') {
61132
+ return aggregationFns.sum;
61133
+ }
61134
+ if (Object.prototype.toString.call(value) === '[object Date]') {
61135
+ return aggregationFns.extent;
61136
+ }
61137
+ };
61138
+ column.getAggregationFn = () => {
61139
+ var _table$options$aggreg, _table$options$aggreg2;
61140
+ if (!column) {
61141
+ throw new Error();
61142
+ }
61143
+ return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
61144
+ };
61145
+ },
61146
+ createTable: table => {
61147
+ table.setGrouping = updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
61148
+ table.resetGrouping = defaultState => {
61149
+ var _table$initialState$g, _table$initialState;
61150
+ table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
61151
+ };
61152
+ table.getPreGroupedRowModel = () => table.getFilteredRowModel();
61153
+ table.getGroupedRowModel = () => {
61154
+ if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
61155
+ table._getGroupedRowModel = table.options.getGroupedRowModel(table);
61156
+ }
61157
+ if (table.options.manualGrouping || !table._getGroupedRowModel) {
61158
+ return table.getPreGroupedRowModel();
61159
+ }
61160
+ return table._getGroupedRowModel();
61161
+ };
61162
+ },
61163
+ createRow: (row, table) => {
61164
+ row.getIsGrouped = () => !!row.groupingColumnId;
61165
+ row.getGroupingValue = columnId => {
61166
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) {
61167
+ return row._groupingValuesCache[columnId];
61168
+ }
61169
+ const column = table.getColumn(columnId);
61170
+ if (!(column != null && column.columnDef.getGroupingValue)) {
61171
+ return row.getValue(columnId);
61172
+ }
61173
+ row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
61174
+ return row._groupingValuesCache[columnId];
61175
+ };
61176
+ row._groupingValuesCache = {};
61177
+ },
61178
+ createCell: (cell, column, row, table) => {
61179
+ cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
61180
+ cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
61181
+ cell.getIsAggregated = () => {
61182
+ var _row$subRows;
61183
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
61184
+ };
61185
+ }
61186
+ };
61187
+ function orderColumns(leafColumns, grouping, groupedColumnMode) {
61188
+ if (!(grouping != null && grouping.length) || !groupedColumnMode) {
61189
+ return leafColumns;
61190
+ }
61191
+ const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
61192
+ if (groupedColumnMode === 'remove') {
61193
+ return nonGroupingColumns;
61194
+ }
61195
+ const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
61196
+ return [...groupingColumns, ...nonGroupingColumns];
61197
+ }
61198
+
61199
+ //
61200
+
61201
+ const ColumnOrdering = {
61202
+ getInitialState: state => {
61203
+ return {
61204
+ columnOrder: [],
61205
+ ...state
61206
+ };
61207
+ },
61208
+ getDefaultOptions: table => {
61209
+ return {
61210
+ onColumnOrderChange: makeStateUpdater('columnOrder', table)
61211
+ };
61212
+ },
61213
+ createColumn: (column, table) => {
61214
+ column.getIndex = memo$1(position => [_getVisibleLeafColumns(table, position)], columns => columns.findIndex(d => d.id === column.id), getMemoOptions(table.options, 'debugColumns', 'getIndex'));
61215
+ column.getIsFirstColumn = position => {
61216
+ var _columns$;
61217
+ const columns = _getVisibleLeafColumns(table, position);
61218
+ return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
61219
+ };
61220
+ column.getIsLastColumn = position => {
61221
+ var _columns;
61222
+ const columns = _getVisibleLeafColumns(table, position);
61223
+ return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
61224
+ };
61225
+ },
61226
+ createTable: table => {
61227
+ table.setColumnOrder = updater => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
61228
+ table.resetColumnOrder = defaultState => {
61229
+ var _table$initialState$c;
61230
+ table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
61231
+ };
61232
+ table._getOrderColumnsFn = memo$1(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
61233
+ // Sort grouped columns to the start of the column list
61234
+ // before the headers are built
61235
+ let orderedColumns = [];
61236
+
61237
+ // If there is no order, return the normal columns
61238
+ if (!(columnOrder != null && columnOrder.length)) {
61239
+ orderedColumns = columns;
61240
+ } else {
61241
+ const columnOrderCopy = [...columnOrder];
61242
+
61243
+ // If there is an order, make a copy of the columns
61244
+ const columnsCopy = [...columns];
61245
+
61246
+ // And make a new ordered array of the columns
61247
+
61248
+ // Loop over the columns and place them in order into the new array
61249
+ while (columnsCopy.length && columnOrderCopy.length) {
61250
+ const targetColumnId = columnOrderCopy.shift();
61251
+ const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
61252
+ if (foundIndex > -1) {
61253
+ orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
61254
+ }
61255
+ }
61256
+
61257
+ // If there are any columns left, add them to the end
61258
+ orderedColumns = [...orderedColumns, ...columnsCopy];
61259
+ }
61260
+ return orderColumns(orderedColumns, grouping, groupedColumnMode);
61261
+ }, getMemoOptions(table.options, 'debugTable', '_getOrderColumnsFn'));
61262
+ }
61263
+ };
61264
+
61265
+ //
61266
+
61267
+ const getDefaultColumnPinningState = () => ({
61268
+ left: [],
61269
+ right: []
61270
+ });
61271
+ const ColumnPinning = {
61272
+ getInitialState: state => {
61273
+ return {
61274
+ columnPinning: getDefaultColumnPinningState(),
61275
+ ...state
61276
+ };
61277
+ },
61278
+ getDefaultOptions: table => {
61279
+ return {
61280
+ onColumnPinningChange: makeStateUpdater('columnPinning', table)
61281
+ };
61282
+ },
61283
+ createColumn: (column, table) => {
61284
+ column.pin = position => {
61285
+ const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
61286
+ table.setColumnPinning(old => {
61287
+ var _old$left3, _old$right3;
61288
+ if (position === 'right') {
61289
+ var _old$left, _old$right;
61290
+ return {
61291
+ left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
61292
+ right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
61293
+ };
61294
+ }
61295
+ if (position === 'left') {
61296
+ var _old$left2, _old$right2;
61297
+ return {
61298
+ left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
61299
+ right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
61300
+ };
61301
+ }
61302
+ return {
61303
+ left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
61304
+ right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
61305
+ };
61306
+ });
61307
+ };
61308
+ column.getCanPin = () => {
61309
+ const leafColumns = column.getLeafColumns();
61310
+ return leafColumns.some(d => {
61311
+ var _d$columnDef$enablePi, _ref, _table$options$enable;
61312
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
61313
+ });
61314
+ };
61315
+ column.getIsPinned = () => {
61316
+ const leafColumnIds = column.getLeafColumns().map(d => d.id);
61317
+ const {
61318
+ left,
61319
+ right
61320
+ } = table.getState().columnPinning;
61321
+ const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
61322
+ const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
61323
+ return isLeft ? 'left' : isRight ? 'right' : false;
61324
+ };
61325
+ column.getPinnedIndex = () => {
61326
+ var _table$getState$colum, _table$getState$colum2;
61327
+ const position = column.getIsPinned();
61328
+ return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
61329
+ };
61330
+ },
61331
+ createRow: (row, table) => {
61332
+ row.getCenterVisibleCells = memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
61333
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
61334
+ return allCells.filter(d => !leftAndRight.includes(d.column.id));
61335
+ }, getMemoOptions(table.options, 'debugRows', 'getCenterVisibleCells'));
61336
+ row.getLeftVisibleCells = memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
61337
+ const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
61338
+ ...d,
61339
+ position: 'left'
61340
+ }));
61341
+ return cells;
61342
+ }, getMemoOptions(table.options, 'debugRows', 'getLeftVisibleCells'));
61343
+ row.getRightVisibleCells = memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
61344
+ const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
61345
+ ...d,
61346
+ position: 'right'
61347
+ }));
61348
+ return cells;
61349
+ }, getMemoOptions(table.options, 'debugRows', 'getRightVisibleCells'));
61350
+ },
61351
+ createTable: table => {
61352
+ table.setColumnPinning = updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
61353
+ table.resetColumnPinning = defaultState => {
61354
+ var _table$initialState$c, _table$initialState;
61355
+ return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
61356
+ };
61357
+ table.getIsSomeColumnsPinned = position => {
61358
+ var _pinningState$positio;
61359
+ const pinningState = table.getState().columnPinning;
61360
+ if (!position) {
61361
+ var _pinningState$left, _pinningState$right;
61362
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
61363
+ }
61364
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
61365
+ };
61366
+ table.getLeftLeafColumns = memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
61367
+ return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
61368
+ }, getMemoOptions(table.options, 'debugColumns', 'getLeftLeafColumns'));
61369
+ table.getRightLeafColumns = memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
61370
+ return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
61371
+ }, getMemoOptions(table.options, 'debugColumns', 'getRightLeafColumns'));
61372
+ table.getCenterLeafColumns = memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
61373
+ const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
61374
+ return allColumns.filter(d => !leftAndRight.includes(d.id));
61375
+ }, getMemoOptions(table.options, 'debugColumns', 'getCenterLeafColumns'));
61376
+ }
61377
+ };
61378
+
61379
+ //
61380
+
61381
+ //
61382
+
61383
+ const defaultColumnSizing = {
61384
+ size: 150,
61385
+ minSize: 20,
61386
+ maxSize: Number.MAX_SAFE_INTEGER
61387
+ };
61388
+ const getDefaultColumnSizingInfoState = () => ({
61389
+ startOffset: null,
61390
+ startSize: null,
61391
+ deltaOffset: null,
61392
+ deltaPercentage: null,
61393
+ isResizingColumn: false,
61394
+ columnSizingStart: []
61395
+ });
61396
+ const ColumnSizing = {
61397
+ getDefaultColumnDef: () => {
61398
+ return defaultColumnSizing;
61399
+ },
61400
+ getInitialState: state => {
61401
+ return {
61402
+ columnSizing: {},
61403
+ columnSizingInfo: getDefaultColumnSizingInfoState(),
61404
+ ...state
61405
+ };
61406
+ },
61407
+ getDefaultOptions: table => {
61408
+ return {
61409
+ columnResizeMode: 'onEnd',
61410
+ columnResizeDirection: 'ltr',
61411
+ onColumnSizingChange: makeStateUpdater('columnSizing', table),
61412
+ onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table)
61413
+ };
61414
+ },
61415
+ createColumn: (column, table) => {
61416
+ column.getSize = () => {
61417
+ var _column$columnDef$min, _ref, _column$columnDef$max;
61418
+ const columnSize = table.getState().columnSizing[column.id];
61419
+ return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
61420
+ };
61421
+ column.getStart = memo$1(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getStart'));
61422
+ column.getAfter = memo$1(position => [position, _getVisibleLeafColumns(table, position), table.getState().columnSizing], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, 'debugColumns', 'getAfter'));
61423
+ column.resetSize = () => {
61424
+ table.setColumnSizing(_ref2 => {
61425
+ let {
61426
+ [column.id]: _,
61427
+ ...rest
61428
+ } = _ref2;
61429
+ return rest;
61430
+ });
61431
+ };
61432
+ column.getCanResize = () => {
61433
+ var _column$columnDef$ena, _table$options$enable;
61434
+ return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
61435
+ };
61436
+ column.getIsResizing = () => {
61437
+ return table.getState().columnSizingInfo.isResizingColumn === column.id;
61438
+ };
61439
+ },
61440
+ createHeader: (header, table) => {
61441
+ header.getSize = () => {
61442
+ let sum = 0;
61443
+ const recurse = header => {
61444
+ if (header.subHeaders.length) {
61445
+ header.subHeaders.forEach(recurse);
61446
+ } else {
61447
+ var _header$column$getSiz;
61448
+ sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
61449
+ }
61450
+ };
61451
+ recurse(header);
61452
+ return sum;
61453
+ };
61454
+ header.getStart = () => {
61455
+ if (header.index > 0) {
61456
+ const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
61457
+ return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
61458
+ }
61459
+ return 0;
61460
+ };
61461
+ header.getResizeHandler = _contextDocument => {
61462
+ const column = table.getColumn(header.column.id);
61463
+ const canResize = column == null ? void 0 : column.getCanResize();
61464
+ return e => {
60512
61465
  if (!column || !canResize) {
60513
61466
  return;
60514
61467
  }
@@ -60676,424 +61629,90 @@ img.ProseMirror-separator {
60676
61629
 
60677
61630
  //
60678
61631
 
60679
- const Expanding = {
61632
+ const ColumnVisibility = {
60680
61633
  getInitialState: state => {
60681
61634
  return {
60682
- expanded: {},
61635
+ columnVisibility: {},
60683
61636
  ...state
60684
61637
  };
60685
61638
  },
60686
61639
  getDefaultOptions: table => {
60687
61640
  return {
60688
- onExpandedChange: makeStateUpdater('expanded', table),
60689
- paginateExpandedRows: true
61641
+ onColumnVisibilityChange: makeStateUpdater('columnVisibility', table)
60690
61642
  };
60691
61643
  },
60692
- createTable: table => {
60693
- let registered = false;
60694
- let queued = false;
60695
- table._autoResetExpanded = () => {
60696
- var _ref, _table$options$autoRe;
60697
- if (!registered) {
60698
- table._queue(() => {
60699
- registered = true;
60700
- });
60701
- return;
60702
- }
60703
- if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
60704
- if (queued) return;
60705
- queued = true;
60706
- table._queue(() => {
60707
- table.resetExpanded();
60708
- queued = false;
60709
- });
60710
- }
60711
- };
60712
- table.setExpanded = updater => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
60713
- table.toggleAllRowsExpanded = expanded => {
60714
- if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
60715
- table.setExpanded(true);
60716
- } else {
60717
- table.setExpanded({});
61644
+ createColumn: (column, table) => {
61645
+ column.toggleVisibility = value => {
61646
+ if (column.getCanHide()) {
61647
+ table.setColumnVisibility(old => ({
61648
+ ...old,
61649
+ [column.id]: value != null ? value : !column.getIsVisible()
61650
+ }));
60718
61651
  }
60719
61652
  };
60720
- table.resetExpanded = defaultState => {
60721
- var _table$initialState$e, _table$initialState;
60722
- table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
61653
+ column.getIsVisible = () => {
61654
+ var _ref, _table$getState$colum;
61655
+ const childColumns = column.columns;
61656
+ return (_ref = childColumns.length ? childColumns.some(c => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
60723
61657
  };
60724
- table.getCanSomeRowsExpand = () => {
60725
- return table.getPrePaginationRowModel().flatRows.some(row => row.getCanExpand());
61658
+ column.getCanHide = () => {
61659
+ var _column$columnDef$ena, _table$options$enable;
61660
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
60726
61661
  };
60727
- table.getToggleAllRowsExpandedHandler = () => {
61662
+ column.getToggleVisibilityHandler = () => {
60728
61663
  return e => {
60729
- e.persist == null || e.persist();
60730
- table.toggleAllRowsExpanded();
61664
+ column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
60731
61665
  };
60732
61666
  };
60733
- table.getIsSomeRowsExpanded = () => {
60734
- const expanded = table.getState().expanded;
60735
- return expanded === true || Object.values(expanded).some(Boolean);
60736
- };
60737
- table.getIsAllRowsExpanded = () => {
60738
- const expanded = table.getState().expanded;
60739
-
60740
- // If expanded is true, save some cycles and return true
60741
- if (typeof expanded === 'boolean') {
60742
- return expanded === true;
60743
- }
60744
- if (!Object.keys(expanded).length) {
60745
- return false;
60746
- }
60747
-
60748
- // If any row is not expanded, return false
60749
- if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
60750
- return false;
60751
- }
60752
-
60753
- // They must all be expanded :shrug:
60754
- return true;
60755
- };
60756
- table.getExpandedDepth = () => {
60757
- let maxDepth = 0;
60758
- const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
60759
- rowIds.forEach(id => {
60760
- const splitId = id.split('.');
60761
- maxDepth = Math.max(maxDepth, splitId.length);
60762
- });
60763
- return maxDepth;
60764
- };
60765
- table.getPreExpandedRowModel = () => table.getSortedRowModel();
60766
- table.getExpandedRowModel = () => {
60767
- if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
60768
- table._getExpandedRowModel = table.options.getExpandedRowModel(table);
60769
- }
60770
- if (table.options.manualExpanding || !table._getExpandedRowModel) {
60771
- return table.getPreExpandedRowModel();
60772
- }
60773
- return table._getExpandedRowModel();
60774
- };
60775
61667
  },
60776
61668
  createRow: (row, table) => {
60777
- row.toggleExpanded = expanded => {
60778
- table.setExpanded(old => {
60779
- var _expanded;
60780
- const exists = old === true ? true : !!(old != null && old[row.id]);
60781
- let oldExpanded = {};
60782
- if (old === true) {
60783
- Object.keys(table.getRowModel().rowsById).forEach(rowId => {
60784
- oldExpanded[rowId] = true;
60785
- });
60786
- } else {
60787
- oldExpanded = old;
60788
- }
60789
- expanded = (_expanded = expanded) != null ? _expanded : !exists;
60790
- if (!exists && expanded) {
60791
- return {
60792
- ...oldExpanded,
60793
- [row.id]: true
60794
- };
60795
- }
60796
- if (exists && !expanded) {
60797
- const {
60798
- [row.id]: _,
60799
- ...rest
60800
- } = oldExpanded;
60801
- return rest;
60802
- }
60803
- return old;
60804
- });
60805
- };
60806
- row.getIsExpanded = () => {
60807
- var _table$options$getIsR;
60808
- const expanded = table.getState().expanded;
60809
- return !!((_table$options$getIsR = table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) != null ? _table$options$getIsR : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
60810
- };
60811
- row.getCanExpand = () => {
60812
- var _table$options$getRow, _table$options$enable, _row$subRows;
60813
- return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
60814
- };
60815
- row.getIsAllParentsExpanded = () => {
60816
- let isFullyExpanded = true;
60817
- let currentRow = row;
60818
- while (isFullyExpanded && currentRow.parentId) {
60819
- currentRow = table.getRow(currentRow.parentId, true);
60820
- isFullyExpanded = currentRow.getIsExpanded();
60821
- }
60822
- return isFullyExpanded;
60823
- };
60824
- row.getToggleExpandedHandler = () => {
60825
- const canExpand = row.getCanExpand();
60826
- return () => {
60827
- if (!canExpand) return;
60828
- row.toggleExpanded();
60829
- };
60830
- };
60831
- }
60832
- };
60833
-
60834
- const includesString = (row, columnId, filterValue) => {
60835
- var _row$getValue;
60836
- const search = filterValue.toLowerCase();
60837
- return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
60838
- };
60839
- includesString.autoRemove = val => testFalsey(val);
60840
- const includesStringSensitive = (row, columnId, filterValue) => {
60841
- var _row$getValue2;
60842
- return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
60843
- };
60844
- includesStringSensitive.autoRemove = val => testFalsey(val);
60845
- const equalsString = (row, columnId, filterValue) => {
60846
- var _row$getValue3;
60847
- return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
60848
- };
60849
- equalsString.autoRemove = val => testFalsey(val);
60850
- const arrIncludes = (row, columnId, filterValue) => {
60851
- var _row$getValue4;
60852
- return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
60853
- };
60854
- arrIncludes.autoRemove = val => testFalsey(val) || !(val != null && val.length);
60855
- const arrIncludesAll = (row, columnId, filterValue) => {
60856
- return !filterValue.some(val => {
60857
- var _row$getValue5;
60858
- return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
60859
- });
60860
- };
60861
- arrIncludesAll.autoRemove = val => testFalsey(val) || !(val != null && val.length);
60862
- const arrIncludesSome = (row, columnId, filterValue) => {
60863
- return filterValue.some(val => {
60864
- var _row$getValue6;
60865
- return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
60866
- });
60867
- };
60868
- arrIncludesSome.autoRemove = val => testFalsey(val) || !(val != null && val.length);
60869
- const equals = (row, columnId, filterValue) => {
60870
- return row.getValue(columnId) === filterValue;
60871
- };
60872
- equals.autoRemove = val => testFalsey(val);
60873
- const weakEquals = (row, columnId, filterValue) => {
60874
- return row.getValue(columnId) == filterValue;
60875
- };
60876
- weakEquals.autoRemove = val => testFalsey(val);
60877
- const inNumberRange = (row, columnId, filterValue) => {
60878
- let [min, max] = filterValue;
60879
- const rowValue = row.getValue(columnId);
60880
- return rowValue >= min && rowValue <= max;
60881
- };
60882
- inNumberRange.resolveFilterValue = val => {
60883
- let [unsafeMin, unsafeMax] = val;
60884
- let parsedMin = typeof unsafeMin !== 'number' ? parseFloat(unsafeMin) : unsafeMin;
60885
- let parsedMax = typeof unsafeMax !== 'number' ? parseFloat(unsafeMax) : unsafeMax;
60886
- let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
60887
- let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
60888
- if (min > max) {
60889
- const temp = min;
60890
- min = max;
60891
- max = temp;
60892
- }
60893
- return [min, max];
60894
- };
60895
- inNumberRange.autoRemove = val => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
60896
-
60897
- // Export
60898
-
60899
- const filterFns = {
60900
- includesString,
60901
- includesStringSensitive,
60902
- equalsString,
60903
- arrIncludes,
60904
- arrIncludesAll,
60905
- arrIncludesSome,
60906
- equals,
60907
- weakEquals,
60908
- inNumberRange
60909
- };
60910
- // Utils
60911
-
60912
- function testFalsey(val) {
60913
- return val === undefined || val === null || val === '';
60914
- }
60915
-
60916
- //
60917
-
60918
- const Filters = {
60919
- getDefaultColumnDef: () => {
60920
- return {
60921
- filterFn: 'auto'
60922
- };
60923
- },
60924
- getInitialState: state => {
60925
- return {
60926
- columnFilters: [],
60927
- globalFilter: undefined,
60928
- // filtersProgress: 1,
60929
- // facetProgress: {},
60930
- ...state
60931
- };
60932
- },
60933
- getDefaultOptions: table => {
60934
- return {
60935
- onColumnFiltersChange: makeStateUpdater('columnFilters', table),
60936
- onGlobalFilterChange: makeStateUpdater('globalFilter', table),
60937
- filterFromLeafRows: false,
60938
- maxLeafRowFilterDepth: 100,
60939
- globalFilterFn: 'auto',
60940
- getColumnCanGlobalFilter: column => {
60941
- var _table$getCoreRowMode;
60942
- const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
60943
- return typeof value === 'string' || typeof value === 'number';
60944
- }
60945
- };
60946
- },
60947
- createColumn: (column, table) => {
60948
- column.getAutoFilterFn = () => {
60949
- const firstRow = table.getCoreRowModel().flatRows[0];
60950
- const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
60951
- if (typeof value === 'string') {
60952
- return filterFns.includesString;
60953
- }
60954
- if (typeof value === 'number') {
60955
- return filterFns.inNumberRange;
60956
- }
60957
- if (typeof value === 'boolean') {
60958
- return filterFns.equals;
60959
- }
60960
- if (value !== null && typeof value === 'object') {
60961
- return filterFns.equals;
60962
- }
60963
- if (Array.isArray(value)) {
60964
- return filterFns.arrIncludes;
60965
- }
60966
- return filterFns.weakEquals;
60967
- };
60968
- column.getFilterFn = () => {
60969
- var _table$options$filter, _table$options$filter2;
60970
- return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : // @ts-ignore
60971
- (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
60972
- };
60973
- column.getCanFilter = () => {
60974
- var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
60975
- return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
60976
- };
60977
- column.getCanGlobalFilter = () => {
60978
- var _column$columnDef$ena2, _table$options$enable3, _table$options$enable4, _table$options$getCol;
60979
- return ((_column$columnDef$ena2 = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena2 : true) && ((_table$options$enable3 = table.options.enableGlobalFilter) != null ? _table$options$enable3 : true) && ((_table$options$enable4 = table.options.enableFilters) != null ? _table$options$enable4 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
60980
- };
60981
- column.getIsFiltered = () => column.getFilterIndex() > -1;
60982
- column.getFilterValue = () => {
60983
- var _table$getState$colum;
60984
- return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find(d => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
60985
- };
60986
- column.getFilterIndex = () => {
60987
- var _table$getState$colum2, _table$getState$colum3;
60988
- return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex(d => d.id === column.id)) != null ? _table$getState$colum2 : -1;
60989
- };
60990
- column.setFilterValue = value => {
60991
- table.setColumnFilters(old => {
60992
- const filterFn = column.getFilterFn();
60993
- const previousfilter = old == null ? void 0 : old.find(d => d.id === column.id);
60994
- const newFilter = functionalUpdate(value, previousfilter ? previousfilter.value : undefined);
60995
-
60996
- //
60997
- if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
60998
- var _old$filter;
60999
- return (_old$filter = old == null ? void 0 : old.filter(d => d.id !== column.id)) != null ? _old$filter : [];
61000
- }
61001
- const newFilterObj = {
61002
- id: column.id,
61003
- value: newFilter
61004
- };
61005
- if (previousfilter) {
61006
- var _old$map;
61007
- return (_old$map = old == null ? void 0 : old.map(d => {
61008
- if (d.id === column.id) {
61009
- return newFilterObj;
61010
- }
61011
- return d;
61012
- })) != null ? _old$map : [];
61013
- }
61014
- if (old != null && old.length) {
61015
- return [...old, newFilterObj];
61016
- }
61017
- return [newFilterObj];
61018
- });
61019
- };
61020
- column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
61021
- column.getFacetedRowModel = () => {
61022
- if (!column._getFacetedRowModel) {
61023
- return table.getPreFilteredRowModel();
61024
- }
61025
- return column._getFacetedRowModel();
61026
- };
61027
- column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
61028
- column.getFacetedUniqueValues = () => {
61029
- if (!column._getFacetedUniqueValues) {
61030
- return new Map();
61031
- }
61032
- return column._getFacetedUniqueValues();
61033
- };
61034
- column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
61035
- column.getFacetedMinMaxValues = () => {
61036
- if (!column._getFacetedMinMaxValues) {
61037
- return undefined;
61038
- }
61039
- return column._getFacetedMinMaxValues();
61040
- };
61041
- // () => [column.getFacetedRowModel()],
61042
- // facetedRowModel => getRowModelMinMaxValues(facetedRowModel, column.id),
61043
- },
61044
- createRow: (row, table) => {
61045
- row.columnFilters = {};
61046
- row.columnFiltersMeta = {};
61669
+ row._getAllVisibleCells = memo$1(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
61670
+ return cells.filter(cell => cell.column.getIsVisible());
61671
+ }, getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells'));
61672
+ row.getVisibleCells = memo$1(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, 'debugRows', 'getVisibleCells'));
61047
61673
  },
61048
61674
  createTable: table => {
61049
- table.getGlobalAutoFilterFn = () => {
61050
- return filterFns.includesString;
61051
- };
61052
- table.getGlobalFilterFn = () => {
61053
- var _table$options$filter3, _table$options$filter4;
61054
- const {
61055
- globalFilterFn: globalFilterFn
61056
- } = table.options;
61057
- return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : // @ts-ignore
61058
- (_table$options$filter3 = (_table$options$filter4 = table.options.filterFns) == null ? void 0 : _table$options$filter4[globalFilterFn]) != null ? _table$options$filter3 : filterFns[globalFilterFn];
61059
- };
61060
- table.setColumnFilters = updater => {
61061
- const leafColumns = table.getAllLeafColumns();
61062
- const updateFn = old => {
61063
- var _functionalUpdate;
61064
- return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter(filter => {
61065
- const column = leafColumns.find(d => d.id === filter.id);
61066
- if (column) {
61067
- const filterFn = column.getFilterFn();
61068
- if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {
61069
- return false;
61070
- }
61071
- }
61072
- return true;
61073
- });
61074
- };
61075
- table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
61076
- };
61077
- table.setGlobalFilter = updater => {
61078
- table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
61079
- };
61080
- table.resetGlobalFilter = defaultState => {
61081
- table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
61675
+ const makeVisibleColumnsMethod = (key, getColumns) => {
61676
+ return memo$1(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
61677
+ return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
61678
+ }, getMemoOptions(table.options, 'debugColumns', key));
61082
61679
  };
61083
- table.resetColumnFilters = defaultState => {
61084
- var _table$initialState$c, _table$initialState;
61085
- table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
61680
+ table.getVisibleFlatColumns = makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns());
61681
+ table.getVisibleLeafColumns = makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns());
61682
+ table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => table.getLeftLeafColumns());
61683
+ table.getRightVisibleLeafColumns = makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => table.getRightLeafColumns());
61684
+ table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns());
61685
+ table.setColumnVisibility = updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
61686
+ table.resetColumnVisibility = defaultState => {
61687
+ var _table$initialState$c;
61688
+ table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
61086
61689
  };
61087
- table.getPreFilteredRowModel = () => table.getCoreRowModel();
61088
- table.getFilteredRowModel = () => {
61089
- if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {
61090
- table._getFilteredRowModel = table.options.getFilteredRowModel(table);
61091
- }
61092
- if (table.options.manualFiltering || !table._getFilteredRowModel) {
61093
- return table.getPreFilteredRowModel();
61094
- }
61095
- return table._getFilteredRowModel();
61690
+ table.toggleAllColumnsVisible = value => {
61691
+ var _value;
61692
+ value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
61693
+ table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
61694
+ ...obj,
61695
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
61696
+ }), {}));
61697
+ };
61698
+ table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible()));
61699
+ table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible());
61700
+ table.getToggleAllColumnsVisibilityHandler = () => {
61701
+ return e => {
61702
+ var _target;
61703
+ table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
61704
+ };
61096
61705
  };
61706
+ }
61707
+ };
61708
+ function _getVisibleLeafColumns(table, position) {
61709
+ return !position ? table.getVisibleLeafColumns() : position === 'center' ? table.getCenterVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
61710
+ }
61711
+
61712
+ //
61713
+
61714
+ const GlobalFaceting = {
61715
+ createTable: table => {
61097
61716
  table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
61098
61717
  table.getGlobalFacetedRowModel = () => {
61099
61718
  if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
@@ -61117,289 +61736,207 @@ img.ProseMirror-separator {
61117
61736
  };
61118
61737
  }
61119
61738
  };
61120
- function shouldAutoRemoveFilter(filterFn, value, column) {
61121
- return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
61122
- }
61123
-
61124
- const sum = (columnId, _leafRows, childRows) => {
61125
- // It's faster to just add the aggregations together instead of
61126
- // process leaf nodes individually
61127
- return childRows.reduce((sum, next) => {
61128
- const nextValue = next.getValue(columnId);
61129
- return sum + (typeof nextValue === 'number' ? nextValue : 0);
61130
- }, 0);
61131
- };
61132
- const min = (columnId, _leafRows, childRows) => {
61133
- let min;
61134
- childRows.forEach(row => {
61135
- const value = row.getValue(columnId);
61136
- if (value != null && (min > value || min === undefined && value >= value)) {
61137
- min = value;
61138
- }
61139
- });
61140
- return min;
61141
- };
61142
- const max = (columnId, _leafRows, childRows) => {
61143
- let max;
61144
- childRows.forEach(row => {
61145
- const value = row.getValue(columnId);
61146
- if (value != null && (max < value || max === undefined && value >= value)) {
61147
- max = value;
61148
- }
61149
- });
61150
- return max;
61151
- };
61152
- const extent = (columnId, _leafRows, childRows) => {
61153
- let min;
61154
- let max;
61155
- childRows.forEach(row => {
61156
- const value = row.getValue(columnId);
61157
- if (value != null) {
61158
- if (min === undefined) {
61159
- if (value >= value) min = max = value;
61160
- } else {
61161
- if (min > value) min = value;
61162
- if (max < value) max = value;
61163
- }
61164
- }
61165
- });
61166
- return [min, max];
61167
- };
61168
- const mean = (columnId, leafRows) => {
61169
- let count = 0;
61170
- let sum = 0;
61171
- leafRows.forEach(row => {
61172
- let value = row.getValue(columnId);
61173
- if (value != null && (value = +value) >= value) {
61174
- ++count, sum += value;
61175
- }
61176
- });
61177
- if (count) return sum / count;
61178
- return;
61179
- };
61180
- const median = (columnId, leafRows) => {
61181
- if (!leafRows.length) {
61182
- return;
61183
- }
61184
- const values = leafRows.map(row => row.getValue(columnId));
61185
- if (!isNumberArray$1(values)) {
61186
- return;
61187
- }
61188
- if (values.length === 1) {
61189
- return values[0];
61190
- }
61191
- const mid = Math.floor(values.length / 2);
61192
- const nums = values.sort((a, b) => a - b);
61193
- return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
61194
- };
61195
- const unique = (columnId, leafRows) => {
61196
- return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
61197
- };
61198
- const uniqueCount = (columnId, leafRows) => {
61199
- return new Set(leafRows.map(d => d.getValue(columnId))).size;
61200
- };
61201
- const count = (_columnId, leafRows) => {
61202
- return leafRows.length;
61203
- };
61204
- const aggregationFns = {
61205
- sum,
61206
- min,
61207
- max,
61208
- extent,
61209
- mean,
61210
- median,
61211
- unique,
61212
- uniqueCount,
61213
- count
61214
- };
61215
61739
 
61216
61740
  //
61217
61741
 
61218
- const Grouping = {
61219
- getDefaultColumnDef: () => {
61220
- return {
61221
- aggregatedCell: props => {
61222
- var _toString, _props$getValue;
61223
- return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
61224
- },
61225
- aggregationFn: 'auto'
61226
- };
61227
- },
61742
+ const GlobalFiltering = {
61228
61743
  getInitialState: state => {
61229
61744
  return {
61230
- grouping: [],
61745
+ globalFilter: undefined,
61231
61746
  ...state
61232
61747
  };
61233
61748
  },
61234
61749
  getDefaultOptions: table => {
61235
61750
  return {
61236
- onGroupingChange: makeStateUpdater('grouping', table),
61237
- groupedColumnMode: 'reorder'
61751
+ onGlobalFilterChange: makeStateUpdater('globalFilter', table),
61752
+ globalFilterFn: 'auto',
61753
+ getColumnCanGlobalFilter: column => {
61754
+ var _table$getCoreRowMode;
61755
+ const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
61756
+ return typeof value === 'string' || typeof value === 'number';
61757
+ }
61238
61758
  };
61239
61759
  },
61240
61760
  createColumn: (column, table) => {
61241
- column.toggleGrouping = () => {
61242
- table.setGrouping(old => {
61243
- // Find any existing grouping for this column
61244
- if (old != null && old.includes(column.id)) {
61245
- return old.filter(d => d !== column.id);
61246
- }
61247
- return [...(old != null ? old : []), column.id];
61248
- });
61249
- };
61250
- column.getCanGroup = () => {
61251
- var _ref, _ref2, _ref3, _column$columnDef$ena;
61252
- return (_ref = (_ref2 = (_ref3 = (_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) != null ? _ref3 : table.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
61253
- };
61254
- column.getIsGrouped = () => {
61255
- var _table$getState$group;
61256
- return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
61257
- };
61258
- column.getGroupedIndex = () => {
61259
- var _table$getState$group2;
61260
- return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
61261
- };
61262
- column.getToggleGroupingHandler = () => {
61263
- const canGroup = column.getCanGroup();
61264
- return () => {
61265
- if (!canGroup) return;
61266
- column.toggleGrouping();
61267
- };
61268
- };
61269
- column.getAutoAggregationFn = () => {
61270
- const firstRow = table.getCoreRowModel().flatRows[0];
61271
- const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
61272
- if (typeof value === 'number') {
61273
- return aggregationFns.sum;
61274
- }
61275
- if (Object.prototype.toString.call(value) === '[object Date]') {
61276
- return aggregationFns.extent;
61277
- }
61278
- };
61279
- column.getAggregationFn = () => {
61280
- var _table$options$aggreg, _table$options$aggreg2;
61281
- if (!column) {
61282
- throw new Error();
61283
- }
61284
- return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
61761
+ column.getCanGlobalFilter = () => {
61762
+ var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
61763
+ return ((_column$columnDef$ena = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGlobalFilter) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
61285
61764
  };
61286
61765
  },
61287
61766
  createTable: table => {
61288
- table.setGrouping = updater => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
61289
- table.resetGrouping = defaultState => {
61290
- var _table$initialState$g, _table$initialState;
61291
- table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
61767
+ table.getGlobalAutoFilterFn = () => {
61768
+ return filterFns.includesString;
61292
61769
  };
61293
- table.getPreGroupedRowModel = () => table.getFilteredRowModel();
61294
- table.getGroupedRowModel = () => {
61295
- if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {
61296
- table._getGroupedRowModel = table.options.getGroupedRowModel(table);
61297
- }
61298
- if (table.options.manualGrouping || !table._getGroupedRowModel) {
61299
- return table.getPreGroupedRowModel();
61300
- }
61301
- return table._getGroupedRowModel();
61770
+ table.getGlobalFilterFn = () => {
61771
+ var _table$options$filter, _table$options$filter2;
61772
+ const {
61773
+ globalFilterFn: globalFilterFn
61774
+ } = table.options;
61775
+ return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
61302
61776
  };
61303
- },
61304
- createRow: (row, table) => {
61305
- row.getIsGrouped = () => !!row.groupingColumnId;
61306
- row.getGroupingValue = columnId => {
61307
- if (row._groupingValuesCache.hasOwnProperty(columnId)) {
61308
- return row._groupingValuesCache[columnId];
61309
- }
61310
- const column = table.getColumn(columnId);
61311
- if (!(column != null && column.columnDef.getGroupingValue)) {
61312
- return row.getValue(columnId);
61313
- }
61314
- row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
61315
- return row._groupingValuesCache[columnId];
61777
+ table.setGlobalFilter = updater => {
61778
+ table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
61316
61779
  };
61317
- row._groupingValuesCache = {};
61318
- },
61319
- createCell: (cell, column, row, table) => {
61320
- cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
61321
- cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
61322
- cell.getIsAggregated = () => {
61323
- var _row$subRows;
61324
- return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
61780
+ table.resetGlobalFilter = defaultState => {
61781
+ table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
61325
61782
  };
61326
61783
  }
61327
61784
  };
61328
- function orderColumns(leafColumns, grouping, groupedColumnMode) {
61329
- if (!(grouping != null && grouping.length) || !groupedColumnMode) {
61330
- return leafColumns;
61331
- }
61332
- const nonGroupingColumns = leafColumns.filter(col => !grouping.includes(col.id));
61333
- if (groupedColumnMode === 'remove') {
61334
- return nonGroupingColumns;
61335
- }
61336
- const groupingColumns = grouping.map(g => leafColumns.find(col => col.id === g)).filter(Boolean);
61337
- return [...groupingColumns, ...nonGroupingColumns];
61338
- }
61339
61785
 
61340
61786
  //
61341
61787
 
61342
- const Ordering = {
61788
+ const RowExpanding = {
61343
61789
  getInitialState: state => {
61344
61790
  return {
61345
- columnOrder: [],
61791
+ expanded: {},
61346
61792
  ...state
61347
61793
  };
61348
61794
  },
61349
61795
  getDefaultOptions: table => {
61350
61796
  return {
61351
- onColumnOrderChange: makeStateUpdater('columnOrder', table)
61352
- };
61353
- },
61354
- createColumn: (column, table) => {
61355
- column.getIndex = memo$1(position => [_getVisibleLeafColumns(table, position)], columns => columns.findIndex(d => d.id === column.id), getMemoOptions(table.options, 'debugColumns', 'getIndex'));
61356
- column.getIsFirstColumn = position => {
61357
- var _columns$;
61358
- const columns = _getVisibleLeafColumns(table, position);
61359
- return ((_columns$ = columns[0]) == null ? void 0 : _columns$.id) === column.id;
61360
- };
61361
- column.getIsLastColumn = position => {
61362
- var _columns;
61363
- const columns = _getVisibleLeafColumns(table, position);
61364
- return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
61797
+ onExpandedChange: makeStateUpdater('expanded', table),
61798
+ paginateExpandedRows: true
61365
61799
  };
61366
61800
  },
61367
61801
  createTable: table => {
61368
- table.setColumnOrder = updater => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
61369
- table.resetColumnOrder = defaultState => {
61370
- var _table$initialState$c;
61371
- table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
61802
+ let registered = false;
61803
+ let queued = false;
61804
+ table._autoResetExpanded = () => {
61805
+ var _ref, _table$options$autoRe;
61806
+ if (!registered) {
61807
+ table._queue(() => {
61808
+ registered = true;
61809
+ });
61810
+ return;
61811
+ }
61812
+ if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
61813
+ if (queued) return;
61814
+ queued = true;
61815
+ table._queue(() => {
61816
+ table.resetExpanded();
61817
+ queued = false;
61818
+ });
61819
+ }
61372
61820
  };
61373
- table._getOrderColumnsFn = memo$1(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
61374
- // Sort grouped columns to the start of the column list
61375
- // before the headers are built
61376
- let orderedColumns = [];
61377
-
61378
- // If there is no order, return the normal columns
61379
- if (!(columnOrder != null && columnOrder.length)) {
61380
- orderedColumns = columns;
61821
+ table.setExpanded = updater => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
61822
+ table.toggleAllRowsExpanded = expanded => {
61823
+ if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) {
61824
+ table.setExpanded(true);
61381
61825
  } else {
61382
- const columnOrderCopy = [...columnOrder];
61826
+ table.setExpanded({});
61827
+ }
61828
+ };
61829
+ table.resetExpanded = defaultState => {
61830
+ var _table$initialState$e, _table$initialState;
61831
+ table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
61832
+ };
61833
+ table.getCanSomeRowsExpand = () => {
61834
+ return table.getPrePaginationRowModel().flatRows.some(row => row.getCanExpand());
61835
+ };
61836
+ table.getToggleAllRowsExpandedHandler = () => {
61837
+ return e => {
61838
+ e.persist == null || e.persist();
61839
+ table.toggleAllRowsExpanded();
61840
+ };
61841
+ };
61842
+ table.getIsSomeRowsExpanded = () => {
61843
+ const expanded = table.getState().expanded;
61844
+ return expanded === true || Object.values(expanded).some(Boolean);
61845
+ };
61846
+ table.getIsAllRowsExpanded = () => {
61847
+ const expanded = table.getState().expanded;
61383
61848
 
61384
- // If there is an order, make a copy of the columns
61385
- const columnsCopy = [...columns];
61849
+ // If expanded is true, save some cycles and return true
61850
+ if (typeof expanded === 'boolean') {
61851
+ return expanded === true;
61852
+ }
61853
+ if (!Object.keys(expanded).length) {
61854
+ return false;
61855
+ }
61386
61856
 
61387
- // And make a new ordered array of the columns
61857
+ // If any row is not expanded, return false
61858
+ if (table.getRowModel().flatRows.some(row => !row.getIsExpanded())) {
61859
+ return false;
61860
+ }
61388
61861
 
61389
- // Loop over the columns and place them in order into the new array
61390
- while (columnsCopy.length && columnOrderCopy.length) {
61391
- const targetColumnId = columnOrderCopy.shift();
61392
- const foundIndex = columnsCopy.findIndex(d => d.id === targetColumnId);
61393
- if (foundIndex > -1) {
61394
- orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
61395
- }
61862
+ // They must all be expanded :shrug:
61863
+ return true;
61864
+ };
61865
+ table.getExpandedDepth = () => {
61866
+ let maxDepth = 0;
61867
+ const rowIds = table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded);
61868
+ rowIds.forEach(id => {
61869
+ const splitId = id.split('.');
61870
+ maxDepth = Math.max(maxDepth, splitId.length);
61871
+ });
61872
+ return maxDepth;
61873
+ };
61874
+ table.getPreExpandedRowModel = () => table.getSortedRowModel();
61875
+ table.getExpandedRowModel = () => {
61876
+ if (!table._getExpandedRowModel && table.options.getExpandedRowModel) {
61877
+ table._getExpandedRowModel = table.options.getExpandedRowModel(table);
61878
+ }
61879
+ if (table.options.manualExpanding || !table._getExpandedRowModel) {
61880
+ return table.getPreExpandedRowModel();
61881
+ }
61882
+ return table._getExpandedRowModel();
61883
+ };
61884
+ },
61885
+ createRow: (row, table) => {
61886
+ row.toggleExpanded = expanded => {
61887
+ table.setExpanded(old => {
61888
+ var _expanded;
61889
+ const exists = old === true ? true : !!(old != null && old[row.id]);
61890
+ let oldExpanded = {};
61891
+ if (old === true) {
61892
+ Object.keys(table.getRowModel().rowsById).forEach(rowId => {
61893
+ oldExpanded[rowId] = true;
61894
+ });
61895
+ } else {
61896
+ oldExpanded = old;
61396
61897
  }
61397
-
61398
- // If there are any columns left, add them to the end
61399
- orderedColumns = [...orderedColumns, ...columnsCopy];
61898
+ expanded = (_expanded = expanded) != null ? _expanded : !exists;
61899
+ if (!exists && expanded) {
61900
+ return {
61901
+ ...oldExpanded,
61902
+ [row.id]: true
61903
+ };
61904
+ }
61905
+ if (exists && !expanded) {
61906
+ const {
61907
+ [row.id]: _,
61908
+ ...rest
61909
+ } = oldExpanded;
61910
+ return rest;
61911
+ }
61912
+ return old;
61913
+ });
61914
+ };
61915
+ row.getIsExpanded = () => {
61916
+ var _table$options$getIsR;
61917
+ const expanded = table.getState().expanded;
61918
+ return !!((_table$options$getIsR = table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) != null ? _table$options$getIsR : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
61919
+ };
61920
+ row.getCanExpand = () => {
61921
+ var _table$options$getRow, _table$options$enable, _row$subRows;
61922
+ return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
61923
+ };
61924
+ row.getIsAllParentsExpanded = () => {
61925
+ let isFullyExpanded = true;
61926
+ let currentRow = row;
61927
+ while (isFullyExpanded && currentRow.parentId) {
61928
+ currentRow = table.getRow(currentRow.parentId, true);
61929
+ isFullyExpanded = currentRow.getIsExpanded();
61400
61930
  }
61401
- return orderColumns(orderedColumns, grouping, groupedColumnMode);
61402
- }, getMemoOptions(table.options, 'debugTable', '_getOrderColumnsFn'));
61931
+ return isFullyExpanded;
61932
+ };
61933
+ row.getToggleExpandedHandler = () => {
61934
+ const canExpand = row.getCanExpand();
61935
+ return () => {
61936
+ if (!canExpand) return;
61937
+ row.toggleExpanded();
61938
+ };
61939
+ };
61403
61940
  }
61404
61941
  };
61405
61942
 
@@ -61411,7 +61948,7 @@ img.ProseMirror-separator {
61411
61948
  pageIndex: defaultPageIndex,
61412
61949
  pageSize: defaultPageSize
61413
61950
  });
61414
- const Pagination = {
61951
+ const RowPagination = {
61415
61952
  getInitialState: state => {
61416
61953
  return {
61417
61954
  ...state,
@@ -61558,88 +62095,34 @@ img.ProseMirror-separator {
61558
62095
 
61559
62096
  //
61560
62097
 
61561
- const getDefaultColumnPinningState = () => ({
61562
- left: [],
61563
- right: []
61564
- });
61565
62098
  const getDefaultRowPinningState = () => ({
61566
62099
  top: [],
61567
62100
  bottom: []
61568
62101
  });
61569
- const Pinning = {
62102
+ const RowPinning = {
61570
62103
  getInitialState: state => {
61571
62104
  return {
61572
- columnPinning: getDefaultColumnPinningState(),
61573
62105
  rowPinning: getDefaultRowPinningState(),
61574
62106
  ...state
61575
62107
  };
61576
62108
  },
61577
62109
  getDefaultOptions: table => {
61578
62110
  return {
61579
- onColumnPinningChange: makeStateUpdater('columnPinning', table),
61580
62111
  onRowPinningChange: makeStateUpdater('rowPinning', table)
61581
62112
  };
61582
62113
  },
61583
- createColumn: (column, table) => {
61584
- column.pin = position => {
61585
- const columnIds = column.getLeafColumns().map(d => d.id).filter(Boolean);
61586
- table.setColumnPinning(old => {
61587
- var _old$left3, _old$right3;
61588
- if (position === 'right') {
61589
- var _old$left, _old$right;
61590
- return {
61591
- left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter(d => !(columnIds != null && columnIds.includes(d))),
61592
- right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds]
61593
- };
61594
- }
61595
- if (position === 'left') {
61596
- var _old$left2, _old$right2;
61597
- return {
61598
- left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter(d => !(columnIds != null && columnIds.includes(d))), ...columnIds],
61599
- right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
61600
- };
61601
- }
61602
- return {
61603
- left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter(d => !(columnIds != null && columnIds.includes(d))),
61604
- right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter(d => !(columnIds != null && columnIds.includes(d)))
61605
- };
61606
- });
61607
- };
61608
- column.getCanPin = () => {
61609
- const leafColumns = column.getLeafColumns();
61610
- return leafColumns.some(d => {
61611
- var _d$columnDef$enablePi, _ref, _table$options$enable;
61612
- return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
61613
- });
61614
- };
61615
- column.getIsPinned = () => {
61616
- const leafColumnIds = column.getLeafColumns().map(d => d.id);
61617
- const {
61618
- left,
61619
- right
61620
- } = table.getState().columnPinning;
61621
- const isLeft = leafColumnIds.some(d => left == null ? void 0 : left.includes(d));
61622
- const isRight = leafColumnIds.some(d => right == null ? void 0 : right.includes(d));
61623
- return isLeft ? 'left' : isRight ? 'right' : false;
61624
- };
61625
- column.getPinnedIndex = () => {
61626
- var _table$getState$colum, _table$getState$colum2;
61627
- const position = column.getIsPinned();
61628
- return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
61629
- };
61630
- },
61631
62114
  createRow: (row, table) => {
61632
62115
  row.pin = (position, includeLeafRows, includeParentRows) => {
61633
- const leafRowIds = includeLeafRows ? row.getLeafRows().map(_ref2 => {
62116
+ const leafRowIds = includeLeafRows ? row.getLeafRows().map(_ref => {
61634
62117
  let {
61635
62118
  id
61636
- } = _ref2;
62119
+ } = _ref;
61637
62120
  return id;
61638
62121
  }) : [];
61639
- const parentRowIds = includeParentRows ? row.getParentRows().map(_ref3 => {
62122
+ const parentRowIds = includeParentRows ? row.getParentRows().map(_ref2 => {
61640
62123
  let {
61641
62124
  id
61642
- } = _ref3;
62125
+ } = _ref2;
61643
62126
  return id;
61644
62127
  }) : [];
61645
62128
  const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds]);
@@ -61666,7 +62149,7 @@ img.ProseMirror-separator {
61666
62149
  });
61667
62150
  };
61668
62151
  row.getCanPin = () => {
61669
- var _ref4;
62152
+ var _ref3;
61670
62153
  const {
61671
62154
  enableRowPinning,
61672
62155
  enablePinning
@@ -61674,7 +62157,7 @@ img.ProseMirror-separator {
61674
62157
  if (typeof enableRowPinning === 'function') {
61675
62158
  return enableRowPinning(row);
61676
62159
  }
61677
- return (_ref4 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref4 : true;
62160
+ return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
61678
62161
  };
61679
62162
  row.getIsPinned = () => {
61680
62163
  const rowIds = [row.id];
@@ -61690,71 +62173,29 @@ img.ProseMirror-separator {
61690
62173
  var _table$_getPinnedRows, _visiblePinnedRowIds$;
61691
62174
  const position = row.getIsPinned();
61692
62175
  if (!position) return -1;
61693
- const visiblePinnedRowIds = (_table$_getPinnedRows = table._getPinnedRows(position)) == null ? void 0 : _table$_getPinnedRows.map(_ref5 => {
62176
+ const visiblePinnedRowIds = (_table$_getPinnedRows = table._getPinnedRows(position)) == null ? void 0 : _table$_getPinnedRows.map(_ref4 => {
61694
62177
  let {
61695
62178
  id
61696
- } = _ref5;
62179
+ } = _ref4;
61697
62180
  return id;
61698
62181
  });
61699
62182
  return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
61700
62183
  };
61701
- row.getCenterVisibleCells = memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
61702
- const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
61703
- return allCells.filter(d => !leftAndRight.includes(d.column.id));
61704
- }, getMemoOptions(table.options, 'debugRows', 'getCenterVisibleCells'));
61705
- row.getLeftVisibleCells = memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
61706
- const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
61707
- ...d,
61708
- position: 'left'
61709
- }));
61710
- return cells;
61711
- }, getMemoOptions(table.options, 'debugRows', 'getLeftVisibleCells'));
61712
- row.getRightVisibleCells = memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
61713
- const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
61714
- ...d,
61715
- position: 'right'
61716
- }));
61717
- return cells;
61718
- }, getMemoOptions(table.options, 'debugRows', 'getRightVisibleCells'));
61719
62184
  },
61720
62185
  createTable: table => {
61721
- table.setColumnPinning = updater => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
61722
- table.resetColumnPinning = defaultState => {
61723
- var _table$initialState$c, _table$initialState;
61724
- return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
61725
- };
61726
- table.getIsSomeColumnsPinned = position => {
61727
- var _pinningState$positio;
61728
- const pinningState = table.getState().columnPinning;
61729
- if (!position) {
61730
- var _pinningState$left, _pinningState$right;
61731
- return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
61732
- }
61733
- return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
61734
- };
61735
- table.getLeftLeafColumns = memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
61736
- return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
61737
- }, getMemoOptions(table.options, 'debugColumns', 'getLeftLeafColumns'));
61738
- table.getRightLeafColumns = memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
61739
- return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
61740
- }, getMemoOptions(table.options, 'debugColumns', 'getRightLeafColumns'));
61741
- table.getCenterLeafColumns = memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
61742
- const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
61743
- return allColumns.filter(d => !leftAndRight.includes(d.id));
61744
- }, getMemoOptions(table.options, 'debugColumns', 'getCenterLeafColumns'));
61745
62186
  table.setRowPinning = updater => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
61746
62187
  table.resetRowPinning = defaultState => {
61747
- var _table$initialState$r, _table$initialState2;
61748
- return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState2 = table.initialState) == null ? void 0 : _table$initialState2.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
62188
+ var _table$initialState$r, _table$initialState;
62189
+ return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
61749
62190
  };
61750
62191
  table.getIsSomeRowsPinned = position => {
61751
- var _pinningState$positio2;
62192
+ var _pinningState$positio;
61752
62193
  const pinningState = table.getState().rowPinning;
61753
62194
  if (!position) {
61754
62195
  var _pinningState$top, _pinningState$bottom;
61755
62196
  return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
61756
62197
  }
61757
- return Boolean((_pinningState$positio2 = pinningState[position]) == null ? void 0 : _pinningState$positio2.length);
62198
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
61758
62199
  };
61759
62200
  table._getPinnedRows = memo$1(position => [table.getRowModel().rows, table.getState().rowPinning[position], position], (visibleRows, pinnedRowIds, position) => {
61760
62201
  var _table$options$keepPi;
@@ -62260,7 +62701,7 @@ img.ProseMirror-separator {
62260
62701
 
62261
62702
  //
62262
62703
 
62263
- const Sorting = {
62704
+ const RowSorting = {
62264
62705
  getInitialState: state => {
62265
62706
  return {
62266
62707
  sorting: [],
@@ -62467,99 +62908,24 @@ img.ProseMirror-separator {
62467
62908
  }
62468
62909
  };
62469
62910
 
62470
- //
62471
-
62472
- const Visibility = {
62473
- getInitialState: state => {
62474
- return {
62475
- columnVisibility: {},
62476
- ...state
62477
- };
62478
- },
62479
- getDefaultOptions: table => {
62480
- return {
62481
- onColumnVisibilityChange: makeStateUpdater('columnVisibility', table)
62482
- };
62483
- },
62484
- createColumn: (column, table) => {
62485
- column.toggleVisibility = value => {
62486
- if (column.getCanHide()) {
62487
- table.setColumnVisibility(old => ({
62488
- ...old,
62489
- [column.id]: value != null ? value : !column.getIsVisible()
62490
- }));
62491
- }
62492
- };
62493
- column.getIsVisible = () => {
62494
- var _ref, _table$getState$colum;
62495
- const childColumns = column.columns;
62496
- return (_ref = childColumns.length ? childColumns.some(c => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
62497
- };
62498
- column.getCanHide = () => {
62499
- var _column$columnDef$ena, _table$options$enable;
62500
- return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
62501
- };
62502
- column.getToggleVisibilityHandler = () => {
62503
- return e => {
62504
- column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
62505
- };
62506
- };
62507
- },
62508
- createRow: (row, table) => {
62509
- row._getAllVisibleCells = memo$1(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
62510
- return cells.filter(cell => cell.column.getIsVisible());
62511
- }, getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells'));
62512
- row.getVisibleCells = memo$1(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], getMemoOptions(table.options, 'debugRows', 'getVisibleCells'));
62513
- },
62514
- createTable: table => {
62515
- const makeVisibleColumnsMethod = (key, getColumns) => {
62516
- return memo$1(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
62517
- return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
62518
- }, getMemoOptions(table.options, 'debugColumns', key));
62519
- };
62520
- table.getVisibleFlatColumns = makeVisibleColumnsMethod('getVisibleFlatColumns', () => table.getAllFlatColumns());
62521
- table.getVisibleLeafColumns = makeVisibleColumnsMethod('getVisibleLeafColumns', () => table.getAllLeafColumns());
62522
- table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod('getLeftVisibleLeafColumns', () => table.getLeftLeafColumns());
62523
- table.getRightVisibleLeafColumns = makeVisibleColumnsMethod('getRightVisibleLeafColumns', () => table.getRightLeafColumns());
62524
- table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod('getCenterVisibleLeafColumns', () => table.getCenterLeafColumns());
62525
- table.setColumnVisibility = updater => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
62526
- table.resetColumnVisibility = defaultState => {
62527
- var _table$initialState$c;
62528
- table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
62529
- };
62530
- table.toggleAllColumnsVisible = value => {
62531
- var _value;
62532
- value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
62533
- table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
62534
- ...obj,
62535
- [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
62536
- }), {}));
62537
- };
62538
- table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some(column => !(column.getIsVisible != null && column.getIsVisible()));
62539
- table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some(column => column.getIsVisible == null ? void 0 : column.getIsVisible());
62540
- table.getToggleAllColumnsVisibilityHandler = () => {
62541
- return e => {
62542
- var _target;
62543
- table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
62544
- };
62545
- };
62546
- }
62547
- };
62548
- function _getVisibleLeafColumns(table, position) {
62549
- return !position ? table.getVisibleLeafColumns() : position === 'center' ? table.getCenterVisibleLeafColumns() : position === 'left' ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
62550
- }
62551
-
62552
- const features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing];
62911
+ const builtInFeatures = [Headers, ColumnVisibility, ColumnOrdering, ColumnPinning, ColumnFaceting, ColumnFiltering, GlobalFaceting,
62912
+ //depends on ColumnFaceting
62913
+ GlobalFiltering,
62914
+ //depends on ColumnFiltering
62915
+ RowSorting, ColumnGrouping,
62916
+ //depends on RowSorting
62917
+ RowExpanding, RowPagination, RowPinning, RowSelection, ColumnSizing];
62553
62918
 
62554
62919
  //
62555
62920
 
62556
62921
  function createTable(options) {
62557
- var _options$initialState;
62558
- if (options.debugAll || options.debugTable) {
62922
+ var _options$_features, _options$initialState;
62923
+ if ((options.debugAll || options.debugTable)) {
62559
62924
  console.info('Creating Table Instance...');
62560
62925
  }
62926
+ const _features = [...builtInFeatures, ...((_options$_features = options._features) != null ? _options$_features : [])];
62561
62927
  let table = {
62562
- _features: features
62928
+ _features
62563
62929
  };
62564
62930
  const defaultOptions = table._features.reduce((obj, feature) => {
62565
62931
  return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
@@ -62585,7 +62951,7 @@ img.ProseMirror-separator {
62585
62951
  const queued = [];
62586
62952
  let queuedTimeout = false;
62587
62953
  const coreInstance = {
62588
- _features: features,
62954
+ _features,
62589
62955
  options: {
62590
62956
  ...defaultOptions,
62591
62957
  ...options
@@ -62721,104 +63087,6 @@ img.ProseMirror-separator {
62721
63087
  return table;
62722
63088
  }
62723
63089
 
62724
- function createCell(table, row, column, columnId) {
62725
- const getRenderValue = () => {
62726
- var _cell$getValue;
62727
- return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
62728
- };
62729
- const cell = {
62730
- id: `${row.id}_${column.id}`,
62731
- row,
62732
- column,
62733
- getValue: () => row.getValue(columnId),
62734
- renderValue: getRenderValue,
62735
- getContext: memo$1(() => [table, column, row, cell], (table, column, row, cell) => ({
62736
- table,
62737
- column,
62738
- row,
62739
- cell: cell,
62740
- getValue: cell.getValue,
62741
- renderValue: cell.renderValue
62742
- }), getMemoOptions(table.options, 'debugCells', 'cell.getContext'))
62743
- };
62744
- table._features.forEach(feature => {
62745
- feature.createCell == null || feature.createCell(cell, column, row, table);
62746
- }, {});
62747
- return cell;
62748
- }
62749
-
62750
- const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
62751
- let row = {
62752
- id,
62753
- index: rowIndex,
62754
- original,
62755
- depth,
62756
- parentId,
62757
- _valuesCache: {},
62758
- _uniqueValuesCache: {},
62759
- getValue: columnId => {
62760
- if (row._valuesCache.hasOwnProperty(columnId)) {
62761
- return row._valuesCache[columnId];
62762
- }
62763
- const column = table.getColumn(columnId);
62764
- if (!(column != null && column.accessorFn)) {
62765
- return undefined;
62766
- }
62767
- row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
62768
- return row._valuesCache[columnId];
62769
- },
62770
- getUniqueValues: columnId => {
62771
- if (row._uniqueValuesCache.hasOwnProperty(columnId)) {
62772
- return row._uniqueValuesCache[columnId];
62773
- }
62774
- const column = table.getColumn(columnId);
62775
- if (!(column != null && column.accessorFn)) {
62776
- return undefined;
62777
- }
62778
- if (!column.columnDef.getUniqueValues) {
62779
- row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
62780
- return row._uniqueValuesCache[columnId];
62781
- }
62782
- row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
62783
- return row._uniqueValuesCache[columnId];
62784
- },
62785
- renderValue: columnId => {
62786
- var _row$getValue;
62787
- return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
62788
- },
62789
- subRows: subRows != null ? subRows : [],
62790
- getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
62791
- getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
62792
- getParentRows: () => {
62793
- let parentRows = [];
62794
- let currentRow = row;
62795
- while (true) {
62796
- const parentRow = currentRow.getParentRow();
62797
- if (!parentRow) break;
62798
- parentRows.push(parentRow);
62799
- currentRow = parentRow;
62800
- }
62801
- return parentRows.reverse();
62802
- },
62803
- getAllCells: memo$1(() => [table.getAllLeafColumns()], leafColumns => {
62804
- return leafColumns.map(column => {
62805
- return createCell(table, row, column, column.id);
62806
- });
62807
- }, getMemoOptions(table.options, 'debugRows', 'getAllCells')),
62808
- _getAllCellsByColumnId: memo$1(() => [row.getAllCells()], allCells => {
62809
- return allCells.reduce((acc, cell) => {
62810
- acc[cell.column.id] = cell;
62811
- return acc;
62812
- }, {});
62813
- }, getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId'))
62814
- };
62815
- for (let i = 0; i < table._features.length; i++) {
62816
- const feature = table._features[i];
62817
- feature == null || feature.createRow == null || feature.createRow(row, table);
62818
- }
62819
- return row;
62820
- };
62821
-
62822
63090
  function getCoreRowModel() {
62823
63091
  return table => memo$1(() => [table.options.data], data => {
62824
63092
  const rowModel = {
@@ -62867,87 +63135,33 @@ img.ProseMirror-separator {
62867
63135
  }, getMemoOptions(table.options, 'debugTable', 'getRowModel', () => table._autoResetPageIndex()));
62868
63136
  }
62869
63137
 
62870
- function getSortedRowModel() {
62871
- return table => memo$1(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
62872
- if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
63138
+ function getExpandedRowModel() {
63139
+ return table => memo$1(() => [table.getState().expanded, table.getPreExpandedRowModel(), table.options.paginateExpandedRows], (expanded, rowModel, paginateExpandedRows) => {
63140
+ if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
62873
63141
  return rowModel;
62874
63142
  }
62875
- const sortingState = table.getState().sorting;
62876
- const sortedFlatRows = [];
62877
-
62878
- // Filter out sortings that correspond to non existing columns
62879
- const availableSorting = sortingState.filter(sort => {
62880
- var _table$getColumn;
62881
- return (_table$getColumn = table.getColumn(sort.id)) == null ? void 0 : _table$getColumn.getCanSort();
62882
- });
62883
- const columnInfoById = {};
62884
- availableSorting.forEach(sortEntry => {
62885
- const column = table.getColumn(sortEntry.id);
62886
- if (!column) return;
62887
- columnInfoById[sortEntry.id] = {
62888
- sortUndefined: column.columnDef.sortUndefined,
62889
- invertSorting: column.columnDef.invertSorting,
62890
- sortingFn: column.getSortingFn()
62891
- };
62892
- });
62893
- const sortData = rows => {
62894
- // This will also perform a stable sorting using the row index
62895
- // if needed.
62896
- const sortedData = rows.map(row => ({
62897
- ...row
62898
- }));
62899
- sortedData.sort((rowA, rowB) => {
62900
- for (let i = 0; i < availableSorting.length; i += 1) {
62901
- var _sortEntry$desc;
62902
- const sortEntry = availableSorting[i];
62903
- const columnInfo = columnInfoById[sortEntry.id];
62904
- const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
62905
- let sortInt = 0;
62906
-
62907
- // All sorting ints should always return in ascending order
62908
- if (columnInfo.sortUndefined) {
62909
- const aValue = rowA.getValue(sortEntry.id);
62910
- const bValue = rowB.getValue(sortEntry.id);
62911
- const aUndefined = aValue === undefined;
62912
- const bUndefined = bValue === undefined;
62913
- if (aUndefined || bUndefined) {
62914
- sortInt = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
62915
- }
62916
- }
62917
- if (sortInt === 0) {
62918
- sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
62919
- }
62920
-
62921
- // If sorting is non-zero, take care of desc and inversion
62922
- if (sortInt !== 0) {
62923
- if (isDesc) {
62924
- sortInt *= -1;
62925
- }
62926
- if (columnInfo.invertSorting) {
62927
- sortInt *= -1;
62928
- }
62929
- return sortInt;
62930
- }
62931
- }
62932
- return rowA.index - rowB.index;
62933
- });
62934
-
62935
- // If there are sub-rows, sort them
62936
- sortedData.forEach(row => {
62937
- var _row$subRows;
62938
- sortedFlatRows.push(row);
62939
- if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
62940
- row.subRows = sortData(row.subRows);
62941
- }
62942
- });
62943
- return sortedData;
62944
- };
62945
- return {
62946
- rows: sortData(rowModel.rows),
62947
- flatRows: sortedFlatRows,
62948
- rowsById: rowModel.rowsById
62949
- };
62950
- }, getMemoOptions(table.options, 'debugTable', 'getSortedRowModel', () => table._autoResetPageIndex()));
63143
+ if (!paginateExpandedRows) {
63144
+ // Only expand rows at this point if they are being paginated
63145
+ return rowModel;
63146
+ }
63147
+ return expandRows(rowModel);
63148
+ }, getMemoOptions(table.options, 'debugTable', 'getExpandedRowModel'));
63149
+ }
63150
+ function expandRows(rowModel) {
63151
+ const expandedRows = [];
63152
+ const handleRow = row => {
63153
+ var _row$subRows;
63154
+ expandedRows.push(row);
63155
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
63156
+ row.subRows.forEach(handleRow);
63157
+ }
63158
+ };
63159
+ rowModel.rows.forEach(handleRow);
63160
+ return {
63161
+ rows: expandedRows,
63162
+ flatRows: rowModel.flatRows,
63163
+ rowsById: rowModel.rowsById
63164
+ };
62951
63165
  }
62952
63166
 
62953
63167
  function getGroupedRowModel() {
@@ -63083,33 +63297,90 @@ img.ProseMirror-separator {
63083
63297
  }, groupMap);
63084
63298
  }
63085
63299
 
63086
- function getExpandedRowModel() {
63087
- return table => memo$1(() => [table.getState().expanded, table.getPreExpandedRowModel(), table.options.paginateExpandedRows], (expanded, rowModel, paginateExpandedRows) => {
63088
- if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded != null ? expanded : {}).length) {
63089
- return rowModel;
63090
- }
63091
- if (!paginateExpandedRows) {
63092
- // Only expand rows at this point if they are being paginated
63300
+ function getSortedRowModel() {
63301
+ return table => memo$1(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
63302
+ if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
63093
63303
  return rowModel;
63094
63304
  }
63095
- return expandRows(rowModel);
63096
- }, getMemoOptions(table.options, 'debugTable', 'getExpandedRowModel'));
63097
- }
63098
- function expandRows(rowModel) {
63099
- const expandedRows = [];
63100
- const handleRow = row => {
63101
- var _row$subRows;
63102
- expandedRows.push(row);
63103
- if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
63104
- row.subRows.forEach(handleRow);
63105
- }
63106
- };
63107
- rowModel.rows.forEach(handleRow);
63108
- return {
63109
- rows: expandedRows,
63110
- flatRows: rowModel.flatRows,
63111
- rowsById: rowModel.rowsById
63112
- };
63305
+ const sortingState = table.getState().sorting;
63306
+ const sortedFlatRows = [];
63307
+
63308
+ // Filter out sortings that correspond to non existing columns
63309
+ const availableSorting = sortingState.filter(sort => {
63310
+ var _table$getColumn;
63311
+ return (_table$getColumn = table.getColumn(sort.id)) == null ? void 0 : _table$getColumn.getCanSort();
63312
+ });
63313
+ const columnInfoById = {};
63314
+ availableSorting.forEach(sortEntry => {
63315
+ const column = table.getColumn(sortEntry.id);
63316
+ if (!column) return;
63317
+ columnInfoById[sortEntry.id] = {
63318
+ sortUndefined: column.columnDef.sortUndefined,
63319
+ invertSorting: column.columnDef.invertSorting,
63320
+ sortingFn: column.getSortingFn()
63321
+ };
63322
+ });
63323
+ const sortData = rows => {
63324
+ // This will also perform a stable sorting using the row index
63325
+ // if needed.
63326
+ const sortedData = rows.map(row => ({
63327
+ ...row
63328
+ }));
63329
+ sortedData.sort((rowA, rowB) => {
63330
+ for (let i = 0; i < availableSorting.length; i += 1) {
63331
+ var _sortEntry$desc;
63332
+ const sortEntry = availableSorting[i];
63333
+ const columnInfo = columnInfoById[sortEntry.id];
63334
+ const sortUndefined = columnInfo.sortUndefined;
63335
+ const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
63336
+ let sortInt = 0;
63337
+
63338
+ // All sorting ints should always return in ascending order
63339
+ if (sortUndefined) {
63340
+ const aValue = rowA.getValue(sortEntry.id);
63341
+ const bValue = rowB.getValue(sortEntry.id);
63342
+ const aUndefined = aValue === undefined;
63343
+ const bUndefined = bValue === undefined;
63344
+ if (aUndefined || bUndefined) {
63345
+ if (sortUndefined === 'first') return aUndefined ? -1 : 1;
63346
+ if (sortUndefined === 'last') return aUndefined ? 1 : -1;
63347
+ sortInt = aUndefined && bUndefined ? 0 : aUndefined ? sortUndefined : -sortUndefined;
63348
+ }
63349
+ }
63350
+ if (sortInt === 0) {
63351
+ sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
63352
+ }
63353
+
63354
+ // If sorting is non-zero, take care of desc and inversion
63355
+ if (sortInt !== 0) {
63356
+ if (isDesc) {
63357
+ sortInt *= -1;
63358
+ }
63359
+ if (columnInfo.invertSorting) {
63360
+ sortInt *= -1;
63361
+ }
63362
+ return sortInt;
63363
+ }
63364
+ }
63365
+ return rowA.index - rowB.index;
63366
+ });
63367
+
63368
+ // If there are sub-rows, sort them
63369
+ sortedData.forEach(row => {
63370
+ var _row$subRows;
63371
+ sortedFlatRows.push(row);
63372
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
63373
+ row.subRows = sortData(row.subRows);
63374
+ }
63375
+ });
63376
+ return sortedData;
63377
+ };
63378
+ return {
63379
+ rows: sortData(rowModel.rows),
63380
+ flatRows: sortedFlatRows,
63381
+ rowsById: rowModel.rowsById
63382
+ };
63383
+ }, getMemoOptions(table.options, 'debugTable', 'getSortedRowModel', () => table._autoResetPageIndex()));
63113
63384
  }
63114
63385
 
63115
63386
  const TableRecordDelayedHierarchyState = {
@@ -65073,6 +65344,7 @@ img.ProseMirror-separator {
65073
65344
  measureElement,
65074
65345
  initialRect: { width: 0, height: 0 },
65075
65346
  scrollMargin: 0,
65347
+ gap: 0,
65076
65348
  scrollingDelay: 150,
65077
65349
  indexAttribute: "data-index",
65078
65350
  initialMeasurementsCache: [],
@@ -65216,7 +65488,7 @@ img.ProseMirror-separator {
65216
65488
  for (let i = min; i < count; i++) {
65217
65489
  const key = getItemKey(i);
65218
65490
  const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
65219
- const start = furthestMeasurement ? furthestMeasurement.end : paddingStart + scrollMargin;
65491
+ const start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
65220
65492
  const measuredSize = itemSizeCache.get(key);
65221
65493
  const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
65222
65494
  const end = start + size;
@@ -65308,7 +65580,7 @@ img.ProseMirror-separator {
65308
65580
  const itemSize = this.itemSizeCache.get(item.key) ?? item.size;
65309
65581
  const delta = size - itemSize;
65310
65582
  if (delta !== 0) {
65311
- if (item.start < this.scrollOffset + this.scrollAdjustments) {
65583
+ if (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.scrollOffset + this.scrollAdjustments) {
65312
65584
  if (this.options.debug) {
65313
65585
  console.info("correction", delta);
65314
65586
  }
@@ -65476,7 +65748,7 @@ img.ProseMirror-separator {
65476
65748
  };
65477
65749
  this.setOptions(opts);
65478
65750
  this.scrollRect = this.options.initialRect;
65479
- this.scrollOffset = this.options.initialOffset;
65751
+ this.scrollOffset = typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset;
65480
65752
  this.measurementsCache = this.options.initialMeasurementsCache;
65481
65753
  this.measurementsCache.forEach((item) => {
65482
65754
  this.itemSizeCache.set(item.key, item.size);