@ni/spright-components 6.4.21 → 6.4.23

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.
@@ -46336,9 +46336,15 @@ ${renderedContent}
46336
46336
  return attrs;
46337
46337
  }
46338
46338
  const filtered = {};
46339
- allowedAttributes.forEach((key) => {
46340
- if (key in attrs) {
46341
- filtered[key] = attrs[key];
46339
+ allowedAttributes.forEach((attr) => {
46340
+ const attrName = typeof attr === "string" ? attr : attr.name;
46341
+ const skipIfDefault = typeof attr === "string" ? void 0 : attr.skipIfDefault;
46342
+ if (attrName in attrs) {
46343
+ const value = attrs[attrName];
46344
+ if (skipIfDefault !== void 0 && value === skipIfDefault) {
46345
+ return;
46346
+ }
46347
+ filtered[attrName] = value;
46342
46348
  }
46343
46349
  });
46344
46350
  return filtered;
@@ -59348,32 +59354,36 @@ ${renderedContent}
59348
59354
  if (!view.editable) {
59349
59355
  return false;
59350
59356
  }
59351
- let link = null;
59352
- if (event.target instanceof HTMLAnchorElement) {
59353
- link = event.target;
59354
- } else {
59355
- let a = event.target;
59356
- const els = [];
59357
- while (a.nodeName !== "DIV") {
59358
- els.push(a);
59359
- a = a.parentNode;
59360
- }
59361
- link = els.find((value) => value.nodeName === "A");
59362
- }
59363
- if (!link) {
59364
- return false;
59365
- }
59366
- const attrs = getAttributes(view.state, options.type.name);
59367
- const href = (_a = link == null ? void 0 : link.href) != null ? _a : attrs.href;
59368
- const target = (_b = link == null ? void 0 : link.target) != null ? _b : attrs.target;
59357
+ let handled = false;
59369
59358
  if (options.enableClickSelection) {
59370
- options.editor.commands.extendMarkRange(options.type.name);
59359
+ const commandResult = options.editor.commands.extendMarkRange(options.type.name);
59360
+ handled = commandResult;
59371
59361
  }
59372
- if (link && href) {
59373
- window.open(href, target);
59374
- return true;
59362
+ if (options.openOnClick) {
59363
+ let link = null;
59364
+ if (event.target instanceof HTMLAnchorElement) {
59365
+ link = event.target;
59366
+ } else {
59367
+ let a = event.target;
59368
+ const els = [];
59369
+ while (a.nodeName !== "DIV") {
59370
+ els.push(a);
59371
+ a = a.parentNode;
59372
+ }
59373
+ link = els.find((value) => value.nodeName === "A");
59374
+ }
59375
+ if (!link) {
59376
+ return handled;
59377
+ }
59378
+ const attrs = getAttributes(view.state, options.type.name);
59379
+ const href = (_a = link == null ? void 0 : link.href) != null ? _a : attrs.href;
59380
+ const target = (_b = link == null ? void 0 : link.target) != null ? _b : attrs.target;
59381
+ if (link && href) {
59382
+ window.open(href, target);
59383
+ handled = true;
59384
+ }
59375
59385
  }
59376
- return false;
59386
+ return handled;
59377
59387
  }
59378
59388
  }
59379
59389
  });
@@ -59614,15 +59624,14 @@ ${renderedContent}
59614
59624
  })
59615
59625
  );
59616
59626
  }
59617
- if (this.options.openOnClick === true) {
59618
- plugins.push(
59619
- clickHandler({
59620
- type: this.type,
59621
- editor: this.editor,
59622
- enableClickSelection: this.options.enableClickSelection
59623
- })
59624
- );
59625
- }
59627
+ plugins.push(
59628
+ clickHandler({
59629
+ type: this.type,
59630
+ editor: this.editor,
59631
+ openOnClick: this.options.openOnClick === "whenNotEditable" ? true : this.options.openOnClick,
59632
+ enableClickSelection: this.options.enableClickSelection
59633
+ })
59634
+ );
59626
59635
  if (this.options.linkOnPaste) {
59627
59636
  plugins.push(
59628
59637
  pasteHandler({
@@ -61143,7 +61152,25 @@ ${nextLine.slice(indentLevel + 2)}`;
61143
61152
  nodeName: "mention",
61144
61153
  name: "@",
61145
61154
  selfClosing: true,
61146
- allowedAttributes: ["id", "label"]
61155
+ allowedAttributes: ["id", "label", { name: "mentionSuggestionChar", skipIfDefault: "@" }],
61156
+ parseAttributes: (attrString) => {
61157
+ const attrs = {};
61158
+ const regex = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
61159
+ let match = regex.exec(attrString);
61160
+ while (match !== null) {
61161
+ const [, key, doubleQuoted, singleQuoted] = match;
61162
+ const value = doubleQuoted != null ? doubleQuoted : singleQuoted;
61163
+ attrs[key === "char" ? "mentionSuggestionChar" : key] = value;
61164
+ match = regex.exec(attrString);
61165
+ }
61166
+ return attrs;
61167
+ },
61168
+ serializeAttributes: (attrs) => {
61169
+ return Object.entries(attrs).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => {
61170
+ const serializedKey = key === "mentionSuggestionChar" ? "char" : key;
61171
+ return `${serializedKey}="${value}"`;
61172
+ }).join(" ");
61173
+ }
61147
61174
  }),
61148
61175
  renderText({ node }) {
61149
61176
  const args = {
@@ -70801,8 +70828,9 @@ focus outline in that case.
70801
70828
  function memo(getDeps, fn, opts) {
70802
70829
  let deps = opts.initialDeps ?? [];
70803
70830
  let result;
70831
+ let isInitial = true;
70804
70832
  function memoizedFunction() {
70805
- var _a, _b, _c, _d;
70833
+ var _a, _b, _c;
70806
70834
  let depTime;
70807
70835
  if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
70808
70836
  const newDeps = getDeps();
@@ -70837,7 +70865,10 @@ focus outline in that case.
70837
70865
  opts == null ? void 0 : opts.key
70838
70866
  );
70839
70867
  }
70840
- (_d = opts == null ? void 0 : opts.onChange) == null ? void 0 : _d.call(opts, result);
70868
+ if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) {
70869
+ opts.onChange(result);
70870
+ }
70871
+ isInitial = false;
70841
70872
  return result;
70842
70873
  }
70843
70874
  memoizedFunction.updateDeps = (newDeps) => {
@@ -70985,7 +71016,11 @@ focus outline in that case.
70985
71016
  this.isScrolling = false;
70986
71017
  this.measurementsCache = [];
70987
71018
  this.itemSizeCache = /* @__PURE__ */ new Map();
71019
+ this.laneAssignments = /* @__PURE__ */ new Map();
70988
71020
  this.pendingMeasuredCacheIndexes = [];
71021
+ this.prevLanes = void 0;
71022
+ this.lanesChangedFlag = false;
71023
+ this.lanesSettling = false;
70989
71024
  this.scrollRect = null;
70990
71025
  this.scrollOffset = null;
70991
71026
  this.scrollDirection = null;
@@ -71184,47 +71219,99 @@ focus outline in that case.
71184
71219
  this.options.paddingStart,
71185
71220
  this.options.scrollMargin,
71186
71221
  this.options.getItemKey,
71187
- this.options.enabled
71222
+ this.options.enabled,
71223
+ this.options.lanes
71188
71224
  ],
71189
- (count, paddingStart, scrollMargin, getItemKey, enabled) => {
71225
+ (count, paddingStart, scrollMargin, getItemKey, enabled, lanes) => {
71226
+ const lanesChanged = this.prevLanes !== void 0 && this.prevLanes !== lanes;
71227
+ if (lanesChanged) {
71228
+ this.lanesChangedFlag = true;
71229
+ }
71230
+ this.prevLanes = lanes;
71190
71231
  this.pendingMeasuredCacheIndexes = [];
71191
71232
  return {
71192
71233
  count,
71193
71234
  paddingStart,
71194
71235
  scrollMargin,
71195
71236
  getItemKey,
71196
- enabled
71237
+ enabled,
71238
+ lanes
71197
71239
  };
71198
71240
  },
71199
71241
  {
71200
- key: false
71242
+ key: false,
71243
+ skipInitialOnChange: true,
71244
+ onChange: () => {
71245
+ this.notify(this.isScrolling);
71246
+ }
71201
71247
  }
71202
71248
  );
71203
71249
  this.getMeasurements = memo(
71204
71250
  () => [this.getMeasurementOptions(), this.itemSizeCache],
71205
- ({ count, paddingStart, scrollMargin, getItemKey, enabled }, itemSizeCache) => {
71251
+ ({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes }, itemSizeCache) => {
71206
71252
  if (!enabled) {
71207
71253
  this.measurementsCache = [];
71208
71254
  this.itemSizeCache.clear();
71255
+ this.laneAssignments.clear();
71209
71256
  return [];
71210
71257
  }
71258
+ if (this.laneAssignments.size > count) {
71259
+ for (const index of this.laneAssignments.keys()) {
71260
+ if (index >= count) {
71261
+ this.laneAssignments.delete(index);
71262
+ }
71263
+ }
71264
+ }
71265
+ if (this.lanesChangedFlag) {
71266
+ this.lanesChangedFlag = false;
71267
+ this.lanesSettling = true;
71268
+ this.measurementsCache = [];
71269
+ this.itemSizeCache.clear();
71270
+ this.laneAssignments.clear();
71271
+ this.pendingMeasuredCacheIndexes = [];
71272
+ }
71211
71273
  if (this.measurementsCache.length === 0) {
71212
71274
  this.measurementsCache = this.options.initialMeasurementsCache;
71213
71275
  this.measurementsCache.forEach((item) => {
71214
71276
  this.itemSizeCache.set(item.key, item.size);
71215
71277
  });
71216
71278
  }
71217
- const min = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
71279
+ const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
71218
71280
  this.pendingMeasuredCacheIndexes = [];
71281
+ if (this.lanesSettling && this.measurementsCache.length === count) {
71282
+ this.lanesSettling = false;
71283
+ }
71219
71284
  const measurements = this.measurementsCache.slice(0, min);
71285
+ const laneLastIndex = new Array(lanes).fill(
71286
+ void 0
71287
+ );
71288
+ for (let m = 0; m < min; m++) {
71289
+ const item = measurements[m];
71290
+ if (item) {
71291
+ laneLastIndex[item.lane] = m;
71292
+ }
71293
+ }
71220
71294
  for (let i = min; i < count; i++) {
71221
71295
  const key = getItemKey(i);
71222
- const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
71223
- const start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
71296
+ const cachedLane = this.laneAssignments.get(i);
71297
+ let lane;
71298
+ let start;
71299
+ if (cachedLane !== void 0 && this.options.lanes > 1) {
71300
+ lane = cachedLane;
71301
+ const prevIndex = laneLastIndex[lane];
71302
+ const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
71303
+ start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
71304
+ } else {
71305
+ const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
71306
+ start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
71307
+ lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
71308
+ if (this.options.lanes > 1) {
71309
+ this.laneAssignments.set(i, lane);
71310
+ }
71311
+ }
71224
71312
  const measuredSize = itemSizeCache.get(key);
71225
71313
  const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
71226
71314
  const end = start + size;
71227
- const lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
71228
71315
  measurements[i] = {
71229
71316
  index: i,
71230
71317
  start,
@@ -71233,6 +71320,7 @@ focus outline in that case.
71233
71320
  key,
71234
71321
  lane
71235
71322
  };
71323
+ laneLastIndex[lane] = i;
71236
71324
  }
71237
71325
  this.measurementsCache = measurements;
71238
71326
  return measurements;
@@ -71526,6 +71614,7 @@ focus outline in that case.
71526
71614
  };
71527
71615
  this.measure = () => {
71528
71616
  this.itemSizeCache = /* @__PURE__ */ new Map();
71617
+ this.laneAssignments = /* @__PURE__ */ new Map();
71529
71618
  this.notify(false);
71530
71619
  };
71531
71620
  this.setOptions(opts);
@@ -83118,28 +83207,33 @@ focus outline in that case.
83118
83207
  return this.bytes_.length;
83119
83208
  }
83120
83209
  readInt8(offset) {
83121
- return this.readUint8(offset) << 24 >> 24;
83210
+ return (this.readUint8(offset) << 24) >> 24;
83122
83211
  }
83123
83212
  readUint8(offset) {
83124
83213
  return this.bytes_[offset];
83125
83214
  }
83126
83215
  readInt16(offset) {
83127
- return this.readUint16(offset) << 16 >> 16;
83216
+ return (this.readUint16(offset) << 16) >> 16;
83128
83217
  }
83129
83218
  readUint16(offset) {
83130
- return this.bytes_[offset] | this.bytes_[offset + 1] << 8;
83219
+ return this.bytes_[offset] | (this.bytes_[offset + 1] << 8);
83131
83220
  }
83132
83221
  readInt32(offset) {
83133
- return this.bytes_[offset] | this.bytes_[offset + 1] << 8 | this.bytes_[offset + 2] << 16 | this.bytes_[offset + 3] << 24;
83222
+ return (this.bytes_[offset] |
83223
+ (this.bytes_[offset + 1] << 8) |
83224
+ (this.bytes_[offset + 2] << 16) |
83225
+ (this.bytes_[offset + 3] << 24));
83134
83226
  }
83135
83227
  readUint32(offset) {
83136
83228
  return this.readInt32(offset) >>> 0;
83137
83229
  }
83138
83230
  readInt64(offset) {
83139
- return BigInt.asIntN(64, BigInt(this.readUint32(offset)) + (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
83231
+ return BigInt.asIntN(64, BigInt(this.readUint32(offset)) +
83232
+ (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
83140
83233
  }
83141
83234
  readUint64(offset) {
83142
- return BigInt.asUintN(64, BigInt(this.readUint32(offset)) + (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
83235
+ return BigInt.asUintN(64, BigInt(this.readUint32(offset)) +
83236
+ (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
83143
83237
  }
83144
83238
  readFloat32(offset) {
83145
83239
  int32[0] = this.readInt32(offset);
@@ -83199,11 +83293,11 @@ focus outline in that case.
83199
83293
  * start of a the root vtable).
83200
83294
  */
83201
83295
  getBufferIdentifier() {
83202
- if (this.bytes_.length < this.position_ + SIZEOF_INT +
83203
- FILE_IDENTIFIER_LENGTH) {
83296
+ if (this.bytes_.length <
83297
+ this.position_ + SIZEOF_INT + FILE_IDENTIFIER_LENGTH) {
83204
83298
  throw new Error('FlatBuffers: ByteBuffer is too short to contain an identifier.');
83205
83299
  }
83206
- let result = "";
83300
+ let result = '';
83207
83301
  for (let i = 0; i < FILE_IDENTIFIER_LENGTH; i++) {
83208
83302
  result += String.fromCharCode(this.readInt8(this.position_ + SIZEOF_INT + i));
83209
83303
  }
@@ -83215,7 +83309,9 @@ focus outline in that case.
83215
83309
  */
83216
83310
  __offset(bb_pos, vtable_offset) {
83217
83311
  const vtable = bb_pos - this.readInt32(bb_pos);
83218
- return vtable_offset < this.readInt16(vtable) ? this.readInt16(vtable + vtable_offset) : 0;
83312
+ return vtable_offset < this.readInt16(vtable)
83313
+ ? this.readInt16(vtable + vtable_offset)
83314
+ : 0;
83219
83315
  }
83220
83316
  /**
83221
83317
  * Initialize any Table-derived type to point to the union at the given offset.
@@ -83279,8 +83375,7 @@ focus outline in that case.
83279
83375
  }
83280
83376
  __has_identifier(ident) {
83281
83377
  if (ident.length != FILE_IDENTIFIER_LENGTH) {
83282
- throw new Error('FlatBuffers: file identifier must be length ' +
83283
- FILE_IDENTIFIER_LENGTH);
83378
+ throw new Error('FlatBuffers: file identifier must be length ' + FILE_IDENTIFIER_LENGTH);
83284
83379
  }
83285
83380
  for (let i = 0; i < FILE_IDENTIFIER_LENGTH; i++) {
83286
83381
  if (ident.charCodeAt(i) != this.readInt8(this.position() + SIZEOF_INT + i)) {
@@ -83393,7 +83488,9 @@ focus outline in that case.
83393
83488
  * called finish().
83394
83489
  */
83395
83490
  asUint8Array() {
83396
- return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());
83491
+ return this.bb
83492
+ .bytes()
83493
+ .subarray(this.bb.position(), this.bb.position() + this.offset());
83397
83494
  }
83398
83495
  /**
83399
83496
  * Prepare to write an element of `size` after `additional_bytes` have been
@@ -83411,7 +83508,7 @@ focus outline in that case.
83411
83508
  }
83412
83509
  // Find the amount of alignment needed such that `size` is properly
83413
83510
  // aligned after `additional_bytes`
83414
- const align_size = ((~(this.bb.capacity() - this.space + additional_bytes)) + 1) & (size - 1);
83511
+ const align_size = (~(this.bb.capacity() - this.space + additional_bytes) + 1) & (size - 1);
83415
83512
  // Reallocate the buffer if needed.
83416
83513
  while (this.space < align_size + size + additional_bytes) {
83417
83514
  const old_buf_size = this.bb.capacity();
@@ -83426,22 +83523,22 @@ focus outline in that case.
83426
83523
  }
83427
83524
  }
83428
83525
  writeInt8(value) {
83429
- this.bb.writeInt8(this.space -= 1, value);
83526
+ this.bb.writeInt8((this.space -= 1), value);
83430
83527
  }
83431
83528
  writeInt16(value) {
83432
- this.bb.writeInt16(this.space -= 2, value);
83529
+ this.bb.writeInt16((this.space -= 2), value);
83433
83530
  }
83434
83531
  writeInt32(value) {
83435
- this.bb.writeInt32(this.space -= 4, value);
83532
+ this.bb.writeInt32((this.space -= 4), value);
83436
83533
  }
83437
83534
  writeInt64(value) {
83438
- this.bb.writeInt64(this.space -= 8, value);
83535
+ this.bb.writeInt64((this.space -= 8), value);
83439
83536
  }
83440
83537
  writeFloat32(value) {
83441
- this.bb.writeFloat32(this.space -= 4, value);
83538
+ this.bb.writeFloat32((this.space -= 4), value);
83442
83539
  }
83443
83540
  writeFloat64(value) {
83444
- this.bb.writeFloat64(this.space -= 8, value);
83541
+ this.bb.writeFloat64((this.space -= 8), value);
83445
83542
  }
83446
83543
  /**
83447
83544
  * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
@@ -83589,7 +83686,7 @@ focus outline in that case.
83589
83686
  static growByteBuffer(bb) {
83590
83687
  const old_buf_size = bb.capacity();
83591
83688
  // Ensure we don't grow beyond what fits in an int.
83592
- if (old_buf_size & 0xC0000000) {
83689
+ if (old_buf_size & 0xc0000000) {
83593
83690
  throw new Error('FlatBuffers: cannot grow buffer beyond 2 gigabytes.');
83594
83691
  }
83595
83692
  const new_buf_size = old_buf_size << 1;
@@ -83688,8 +83785,7 @@ focus outline in that case.
83688
83785
  const size_prefix = opt_size_prefix ? SIZE_PREFIX_LENGTH : 0;
83689
83786
  if (opt_file_identifier) {
83690
83787
  const file_identifier = opt_file_identifier;
83691
- this.prep(this.minalign, SIZEOF_INT +
83692
- FILE_IDENTIFIER_LENGTH + size_prefix);
83788
+ this.prep(this.minalign, SIZEOF_INT + FILE_IDENTIFIER_LENGTH + size_prefix);
83693
83789
  if (file_identifier.length != FILE_IDENTIFIER_LENGTH) {
83694
83790
  throw new TypeError('FlatBuffers: file identifier must be length ' +
83695
83791
  FILE_IDENTIFIER_LENGTH);
@@ -83792,7 +83888,7 @@ focus outline in that case.
83792
83888
  }
83793
83889
  this.addInt8(0);
83794
83890
  this.startVector(1, utf8.length, 1);
83795
- this.bb.setPosition(this.space -= utf8.length);
83891
+ this.bb.setPosition((this.space -= utf8.length));
83796
83892
  this.bb.bytes().set(utf8, this.space);
83797
83893
  return this.endVector();
83798
83894
  }
@@ -83807,7 +83903,7 @@ focus outline in that case.
83807
83903
  return 0;
83808
83904
  }
83809
83905
  this.startVector(1, v.length, 1);
83810
- this.bb.setPosition(this.space -= v.length);
83906
+ this.bb.setPosition((this.space -= v.length));
83811
83907
  this.bb.bytes().set(v, this.space);
83812
83908
  return this.endVector();
83813
83909
  }