@ni/nimble-components 35.6.1 → 35.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14764,6 +14764,7 @@
14764
14764
  const tokenNames = {
14765
14765
  actionRgbPartialColor: 'action-rgb-partial-color',
14766
14766
  applicationBackgroundColor: 'application-background-color',
14767
+ containerBackgroundColor: 'container-background-color',
14767
14768
  dividerBackgroundColor: 'divider-background-color',
14768
14769
  dividerBackgroundDynamicColor: 'divider-background-dynamic-color',
14769
14770
  headerBackgroundColor: 'header-background-color',
@@ -16301,6 +16302,7 @@
16301
16302
  const tokenValues = {
16302
16303
  actionRgbPartialColor: hexToRgbPartialThemeColor(createThemeColor(Black91, Black15, White)),
16303
16304
  applicationBackgroundColor: createThemeColor(White, Black85, ForestGreen),
16305
+ containerBackgroundColor: hexToRgbaCssThemeColor(createThemeColor(Black91, Black15, White), 0.07, 0.1, 0.1),
16304
16306
  headerBackgroundColor: createThemeColor(Black7, Black88, ForestGreen),
16305
16307
  sectionBackgroundColor: createThemeColor(Black15, Black80, ForestGreen),
16306
16308
  sectionBackgroundImage: createThemeColor(`linear-gradient(${Black15}, ${hexToRgbaCssColor(Black15, 0)})`, `linear-gradient(${Black82}, ${hexToRgbaCssColor(Black82, 0)})`, `linear-gradient(${ForestGreen}, ${hexToRgbaCssColor(ForestGreen, 0)})`),
@@ -16474,6 +16476,7 @@
16474
16476
  // #region color tokens
16475
16477
  const actionRgbPartialColor = createThemeColorToken(tokenNames.actionRgbPartialColor, tokenValues.actionRgbPartialColor);
16476
16478
  const applicationBackgroundColor = createThemeColorToken(tokenNames.applicationBackgroundColor, tokenValues.applicationBackgroundColor);
16479
+ createThemeColorToken(tokenNames.containerBackgroundColor, tokenValues.containerBackgroundColor);
16477
16480
  createThemeColorToken(tokenNames.headerBackgroundColor, tokenValues.headerBackgroundColor);
16478
16481
  createThemeColorToken(tokenNames.sectionBackgroundColor, tokenValues.sectionBackgroundColor);
16479
16482
  createThemeColorToken(tokenNames.sectionBackgroundImage, tokenValues.sectionBackgroundImage);
@@ -39620,8 +39623,8 @@ so this becomes the fallback color for the slot */ ''}
39620
39623
  this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
39621
39624
  let { selection } = view.state;
39622
39625
  if (event.button == 0 &&
39623
- targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
39624
- selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
39626
+ (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
39627
+ selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos))
39625
39628
  this.mightDrag = {
39626
39629
  node: targetNode,
39627
39630
  pos: targetPos,
@@ -39970,8 +39973,9 @@ so this becomes the fallback color for the slot */ ''}
39970
39973
  }
39971
39974
  const dragCopyModifier = mac$2 ? "altKey" : "ctrlKey";
39972
39975
  function dragMoves(view, event) {
39973
- let moves = view.someProp("dragCopies", test => !test(event));
39974
- return moves != null ? moves : !event[dragCopyModifier];
39976
+ let copy;
39977
+ view.someProp("dragCopies", test => { copy = copy || test(event); });
39978
+ return copy != null ? !copy : !event[dragCopyModifier];
39975
39979
  }
39976
39980
  handlers.dragstart = (view, _event) => {
39977
39981
  let event = _event;
@@ -39998,7 +40002,7 @@ so this becomes the fallback color for the slot */ ''}
39998
40002
  if (!event.dataTransfer.files.length || !chrome || chrome_version > 120)
39999
40003
  event.dataTransfer.clearData();
40000
40004
  event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
40001
- // See https://github.com/ProseMirror/prosemirror/issues/1156
40005
+ // See https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1156
40002
40006
  event.dataTransfer.effectAllowed = "copyMove";
40003
40007
  if (!brokenClipboardAPI)
40004
40008
  event.dataTransfer.setData("text/plain", text);
@@ -41623,7 +41627,7 @@ so this becomes the fallback color for the slot */ ''}
41623
41627
  this.pluginViews = [];
41624
41628
  /**
41625
41629
  Holds `true` when a hack node is needed in Firefox to prevent the
41626
- [space is eaten issue](https://github.com/ProseMirror/prosemirror/issues/651)
41630
+ [space is eaten issue](https://code.haverbeke.berlin/prosemirror/prosemirror/issues/651)
41627
41631
  @internal
41628
41632
  */
41629
41633
  this.requiresGeckoHackNode = false;
@@ -43164,7 +43168,7 @@ so this becomes the fallback color for the slot */ ''}
43164
43168
  const fromSelectionAtStart = $from.parentOffset === 0;
43165
43169
  const isTextSelection2 = $fromNode.isText || $fromNode.isTextblock;
43166
43170
  const hasContent = $fromNode.content.size > 0;
43167
- if (fromSelectionAtStart && isTextSelection2 && hasContent) {
43171
+ if (fromSelectionAtStart && isTextSelection2 && hasContent && isOnlyBlockContent) {
43168
43172
  from = Math.max(0, from - 1);
43169
43173
  }
43170
43174
  tr.replaceWith(from, to, newContent);
@@ -44781,6 +44785,16 @@ so this becomes the fallback color for the slot */ ''}
44781
44785
  tr.join(after);
44782
44786
  return true;
44783
44787
  };
44788
+ function createInnerSelectionForWholeDocList(tr) {
44789
+ const doc = tr.doc;
44790
+ const list = doc.firstChild;
44791
+ if (!list) {
44792
+ return null;
44793
+ }
44794
+ const $start = doc.resolve(1);
44795
+ const $end = doc.resolve(list.nodeSize - 1);
44796
+ return TextSelection.between($start, $end);
44797
+ }
44784
44798
  var toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr, state, dispatch, chain, commands, can }) => {
44785
44799
  const { extensions, splittableMarks } = editor.extensionManager;
44786
44800
  const listType = getNodeType(listTypeOrName, state.schema);
@@ -44793,13 +44807,35 @@ so this becomes the fallback color for the slot */ ''}
44793
44807
  return false;
44794
44808
  }
44795
44809
  const parentList = findParentNode((node) => isList(node.type.name, extensions))(selection);
44796
- if (range.depth >= 1 && parentList && range.depth - parentList.depth <= 1) {
44797
- if (parentList.node.type === listType) {
44810
+ const isAllSelection = selection.from === 0 && selection.to === state.doc.content.size;
44811
+ const topLevelNodes = state.doc.content.content;
44812
+ const soleTopLevelNode = topLevelNodes.length === 1 ? topLevelNodes[0] : null;
44813
+ const allSelectionList = isAllSelection && soleTopLevelNode && isList(soleTopLevelNode.type.name, extensions) ? {
44814
+ node: soleTopLevelNode,
44815
+ pos: 0} : null;
44816
+ const currentList = parentList != null ? parentList : allSelectionList;
44817
+ const isInsideExistingList = !!parentList && range.depth >= 1 && range.depth - parentList.depth <= 1;
44818
+ const hasWholeDocSelectedList = !!allSelectionList;
44819
+ if ((isInsideExistingList || hasWholeDocSelectedList) && currentList) {
44820
+ if (currentList.node.type === listType) {
44821
+ if (isAllSelection && hasWholeDocSelectedList) {
44822
+ return chain().command(({ tr: trx, dispatch: disp }) => {
44823
+ const nextSelection = createInnerSelectionForWholeDocList(trx);
44824
+ if (!nextSelection) {
44825
+ return false;
44826
+ }
44827
+ trx.setSelection(nextSelection);
44828
+ if (disp) {
44829
+ disp(trx);
44830
+ }
44831
+ return true;
44832
+ }).liftListItem(itemType).run();
44833
+ }
44798
44834
  return commands.liftListItem(itemType);
44799
44835
  }
44800
- if (isList(parentList.node.type.name, extensions) && listType.validContent(parentList.node.content) && dispatch) {
44836
+ if (isList(currentList.node.type.name, extensions) && listType.validContent(currentList.node.content)) {
44801
44837
  return chain().command(() => {
44802
- tr.setNodeMarkup(parentList.pos, listType);
44838
+ tr.setNodeMarkup(currentList.pos, listType);
44803
44839
  return true;
44804
44840
  }).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();
44805
44841
  }
@@ -47880,7 +47916,10 @@ ${indentedChild}`;
47880
47916
  }
47881
47917
  markEnd = range.from + startSpaces + captureGroup.length;
47882
47918
  tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
47883
- tr.removeStoredMark(config.type);
47919
+ const isMatchAtEndOfText = match.index !== void 0 && match.input !== void 0 && match.index + match[0].length >= match.input.length;
47920
+ if (!isMatchAtEndOfText) {
47921
+ tr.removeStoredMark(config.type);
47922
+ }
47884
47923
  }
47885
47924
  }
47886
47925
  });
@@ -61407,6 +61446,36 @@ ${indentedChild}`;
61407
61446
  // src/ordered-list/utils.ts
61408
61447
  var ORDERED_LIST_ITEM_REGEX = /^(\s*)(\d+)\.\s+(.*)$/;
61409
61448
  var INDENTED_LINE_REGEX = /^\s/;
61449
+ function isBlockContentLine(line) {
61450
+ const trimmedLine = line.trimStart();
61451
+ return /^[-+*]\s+/.test(trimmedLine) || /^\d+\.\s+/.test(trimmedLine) || /^>\s?/.test(trimmedLine) || /^```/.test(trimmedLine) || /^~~~/.test(trimmedLine);
61452
+ }
61453
+ function splitItemContent(contentLines) {
61454
+ const paragraphLines = [];
61455
+ const blockLines = [];
61456
+ let reachedBlockBoundary = false;
61457
+ contentLines.forEach((line) => {
61458
+ if (reachedBlockBoundary) {
61459
+ blockLines.push(line);
61460
+ return;
61461
+ }
61462
+ if (line.trim() === "") {
61463
+ reachedBlockBoundary = true;
61464
+ blockLines.push(line);
61465
+ return;
61466
+ }
61467
+ if (paragraphLines.length > 0 && isBlockContentLine(line)) {
61468
+ reachedBlockBoundary = true;
61469
+ blockLines.push(line);
61470
+ return;
61471
+ }
61472
+ paragraphLines.push(line);
61473
+ });
61474
+ return {
61475
+ paragraphLines,
61476
+ blockLines
61477
+ };
61478
+ }
61410
61479
  function collectOrderedListItems(lines) {
61411
61480
  const listItems = [];
61412
61481
  let currentLineIndex = 0;
@@ -61419,9 +61488,10 @@ ${indentedChild}`;
61419
61488
  }
61420
61489
  const [, indent, number, content] = match;
61421
61490
  const indentLevel = indent.length;
61422
- let itemContent = content;
61491
+ const itemContentLines = [content];
61423
61492
  let nextLineIndex = currentLineIndex + 1;
61424
61493
  const itemLines = [line];
61494
+ let sawBlankLine = false;
61425
61495
  while (nextLineIndex < lines.length) {
61426
61496
  const nextLine = lines[nextLineIndex];
61427
61497
  const nextMatch = nextLine.match(ORDERED_LIST_ITEM_REGEX);
@@ -61430,21 +61500,27 @@ ${indentedChild}`;
61430
61500
  }
61431
61501
  if (nextLine.trim() === "") {
61432
61502
  itemLines.push(nextLine);
61433
- itemContent += "\n";
61503
+ itemContentLines.push("");
61504
+ sawBlankLine = true;
61434
61505
  nextLineIndex += 1;
61435
61506
  } else if (nextLine.match(INDENTED_LINE_REGEX)) {
61436
61507
  itemLines.push(nextLine);
61437
- itemContent += `
61438
- ${nextLine.slice(indentLevel + 2)}`;
61508
+ itemContentLines.push(nextLine.slice(indentLevel + 2));
61439
61509
  nextLineIndex += 1;
61440
61510
  } else {
61441
- break;
61511
+ if (sawBlankLine) {
61512
+ break;
61513
+ }
61514
+ itemLines.push(nextLine);
61515
+ itemContentLines.push(nextLine);
61516
+ nextLineIndex += 1;
61442
61517
  }
61443
61518
  }
61444
61519
  listItems.push({
61445
61520
  indent: indentLevel,
61446
61521
  number: parseInt(number, 10),
61447
- content: itemContent.trim(),
61522
+ content: itemContentLines.join("\n").trim(),
61523
+ contentLines: itemContentLines,
61448
61524
  raw: itemLines.join("\n")
61449
61525
  });
61450
61526
  consumed = nextLineIndex;
@@ -61453,14 +61529,13 @@ ${nextLine.slice(indentLevel + 2)}`;
61453
61529
  return [listItems, consumed];
61454
61530
  }
61455
61531
  function buildNestedStructure(items, baseIndent, lexer) {
61456
- var _a;
61457
61532
  const result = [];
61458
61533
  let currentIndex = 0;
61459
61534
  while (currentIndex < items.length) {
61460
61535
  const item = items[currentIndex];
61461
61536
  if (item.indent === baseIndent) {
61462
- const contentLines = item.content.split("\n");
61463
- const mainText = ((_a = contentLines[0]) == null ? void 0 : _a.trim()) || "";
61537
+ const { paragraphLines, blockLines } = splitItemContent(item.contentLines);
61538
+ const mainText = paragraphLines.join("\n").trim();
61464
61539
  const tokens = [];
61465
61540
  if (mainText) {
61466
61541
  tokens.push({
@@ -61469,7 +61544,7 @@ ${nextLine.slice(indentLevel + 2)}`;
61469
61544
  tokens: lexer.inlineTokens(mainText)
61470
61545
  });
61471
61546
  }
61472
- const additionalContent = contentLines.slice(1).join("\n").trim();
61547
+ const additionalContent = blockLines.join("\n").trim();
61473
61548
  if (additionalContent) {
61474
61549
  const blockTokens = lexer.blockTokens(additionalContent);
61475
61550
  tokens.push(...blockTokens);
@@ -72941,6 +73016,7 @@ focus outline in that case.
72941
73016
  isRtl: false,
72942
73017
  useScrollendEvent: false,
72943
73018
  useAnimationFrameWithResizeObserver: false,
73019
+ laneAssignmentMode: "estimate",
72944
73020
  ...opts2
72945
73021
  };
72946
73022
  };
@@ -73080,9 +73156,10 @@ focus outline in that case.
73080
73156
  this.options.scrollMargin,
73081
73157
  this.options.getItemKey,
73082
73158
  this.options.enabled,
73083
- this.options.lanes
73159
+ this.options.lanes,
73160
+ this.options.laneAssignmentMode
73084
73161
  ],
73085
- (count, paddingStart, scrollMargin, getItemKey, enabled, lanes) => {
73162
+ (count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode) => {
73086
73163
  const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
73087
73164
  if (lanesChanged) {
73088
73165
  this.lanesChangedFlag = true;
@@ -73095,7 +73172,8 @@ focus outline in that case.
73095
73172
  scrollMargin,
73096
73173
  getItemKey,
73097
73174
  enabled,
73098
- lanes
73175
+ lanes,
73176
+ laneAssignmentMode
73099
73177
  };
73100
73178
  },
73101
73179
  {
@@ -73104,7 +73182,15 @@ focus outline in that case.
73104
73182
  );
73105
73183
  this.getMeasurements = memo(
73106
73184
  () => [this.getMeasurementOptions(), this.itemSizeCache],
73107
- ({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes }, itemSizeCache) => {
73185
+ ({
73186
+ count,
73187
+ paddingStart,
73188
+ scrollMargin,
73189
+ getItemKey,
73190
+ enabled,
73191
+ lanes,
73192
+ laneAssignmentMode
73193
+ }, itemSizeCache) => {
73108
73194
  if (!enabled) {
73109
73195
  this.measurementsCache = [];
73110
73196
  this.itemSizeCache.clear();
@@ -73152,6 +73238,7 @@ focus outline in that case.
73152
73238
  const cachedLane = this.laneAssignments.get(i);
73153
73239
  let lane;
73154
73240
  let start;
73241
+ const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
73155
73242
  if (cachedLane !== void 0 && this.options.lanes > 1) {
73156
73243
  lane = cachedLane;
73157
73244
  const prevIndex = laneLastIndex[lane];
@@ -73161,7 +73248,7 @@ focus outline in that case.
73161
73248
  const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
73162
73249
  start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
73163
73250
  lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
73164
- if (this.options.lanes > 1) {
73251
+ if (this.options.lanes > 1 && shouldCacheLane) {
73165
73252
  this.laneAssignments.set(i, lane);
73166
73253
  }
73167
73254
  }