@ni/nimble-components 20.10.0 → 20.10.2

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.
@@ -16288,7 +16288,7 @@
16288
16288
 
16289
16289
  /**
16290
16290
  * Do not edit directly
16291
- * Generated on Mon, 23 Oct 2023 13:57:47 GMT
16291
+ * Generated on Thu, 26 Oct 2023 17:57:28 GMT
16292
16292
  */
16293
16293
 
16294
16294
  const Information100DarkUi = "#a46eff";
@@ -63078,7 +63078,7 @@ img.ProseMirror-separator {
63078
63078
  },
63079
63079
  subRows: subRows != null ? subRows : [],
63080
63080
  getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
63081
- getParentRow: () => row.parentId ? table.getRow(row.parentId) : undefined,
63081
+ getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
63082
63082
  getParentRows: () => {
63083
63083
  let parentRows = [];
63084
63084
  let currentRow = row;
@@ -63204,7 +63204,9 @@ img.ProseMirror-separator {
63204
63204
  const sortData = rows => {
63205
63205
  // This will also perform a stable sorting using the row index
63206
63206
  // if needed.
63207
- const sortedData = [...rows];
63207
+ const sortedData = rows.map(row => ({
63208
+ ...row
63209
+ }));
63208
63210
  sortedData.sort((rowA, rowB) => {
63209
63211
  for (let i = 0; i < availableSorting.length; i += 1) {
63210
63212
  var _sortEntry$desc;
@@ -65283,10 +65285,7 @@ img.ProseMirror-separator {
65283
65285
  }
65284
65286
  };
65285
65287
  }();
65286
- this.range = {
65287
- startIndex: 0,
65288
- endIndex: 0
65289
- };
65288
+ this.range = null;
65290
65289
  this.setOptions = function (opts) {
65291
65290
  Object.entries(opts).forEach(function (_ref3) {
65292
65291
  var key = _ref3[0],
@@ -65317,9 +65316,21 @@ img.ProseMirror-separator {
65317
65316
  lanes: 1
65318
65317
  }, opts);
65319
65318
  };
65320
- this.notify = function () {
65321
- _this.options.onChange == null ? void 0 : _this.options.onChange(_this);
65319
+ this.notify = function (sync) {
65320
+ _this.options.onChange == null ? void 0 : _this.options.onChange(_this, sync);
65322
65321
  };
65322
+ this.maybeNotify = memo(function () {
65323
+ _this.calculateRange();
65324
+ return [_this.isScrolling, _this.range ? _this.range.startIndex : null, _this.range ? _this.range.endIndex : null];
65325
+ }, function (isScrolling) {
65326
+ _this.notify(isScrolling);
65327
+ }, {
65328
+ key: 'maybeNotify',
65329
+ debug: function debug() {
65330
+ return _this.options.debug;
65331
+ },
65332
+ initialDeps: [this.isScrolling, this.range ? this.range.startIndex : null, this.range ? this.range.endIndex : null]
65333
+ });
65323
65334
  this.cleanup = function () {
65324
65335
  _this.unsubs.filter(Boolean).forEach(function (d) {
65325
65336
  return d();
@@ -65344,11 +65355,8 @@ img.ProseMirror-separator {
65344
65355
  behavior: undefined
65345
65356
  });
65346
65357
  _this.unsubs.push(_this.options.observeElementRect(_this, function (rect) {
65347
- var prev = _this.scrollRect;
65348
65358
  _this.scrollRect = rect;
65349
- if (_this.options.horizontal ? rect.width !== prev.width : rect.height !== prev.height) {
65350
- _this.maybeNotify();
65351
- }
65359
+ _this.maybeNotify();
65352
65360
  }));
65353
65361
  _this.unsubs.push(_this.options.observeElementOffset(_this, function (offset) {
65354
65362
  _this.scrollAdjustments = 0;
@@ -65448,33 +65456,21 @@ img.ProseMirror-separator {
65448
65456
  this.calculateRange = memo(function () {
65449
65457
  return [_this.getMeasurements(), _this.getSize(), _this.scrollOffset];
65450
65458
  }, function (measurements, outerSize, scrollOffset) {
65451
- return _this.range = calculateRange({
65459
+ return _this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
65452
65460
  measurements: measurements,
65453
65461
  outerSize: outerSize,
65454
65462
  scrollOffset: scrollOffset
65455
- });
65463
+ }) : null;
65456
65464
  }, {
65457
65465
  key: 'calculateRange',
65458
65466
  debug: function debug() {
65459
65467
  return _this.options.debug;
65460
65468
  }
65461
65469
  });
65462
- this.maybeNotify = memo(function () {
65463
- var range = _this.calculateRange();
65464
- return [range.startIndex, range.endIndex, _this.isScrolling];
65465
- }, function () {
65466
- _this.notify();
65467
- }, {
65468
- key: 'maybeNotify',
65469
- debug: function debug() {
65470
- return _this.options.debug;
65471
- },
65472
- initialDeps: [this.range.startIndex, this.range.endIndex, this.isScrolling]
65473
- });
65474
65470
  this.getIndexes = memo(function () {
65475
65471
  return [_this.options.rangeExtractor, _this.calculateRange(), _this.options.overscan, _this.options.count];
65476
65472
  }, function (rangeExtractor, range, overscan, count) {
65477
- return rangeExtractor(_extends({}, range, {
65473
+ return range === null ? [] : rangeExtractor(_extends({}, range, {
65478
65474
  overscan: overscan,
65479
65475
  count: count
65480
65476
  }));
@@ -65495,7 +65491,7 @@ img.ProseMirror-separator {
65495
65491
  };
65496
65492
  this._measureElement = function (node, entry) {
65497
65493
  var item = _this.measurementsCache[_this.indexFromElement(node)];
65498
- if (!item) {
65494
+ if (!item || !node.isConnected) {
65499
65495
  _this.measureElementCache.forEach(function (cached, key) {
65500
65496
  if (cached === node) {
65501
65497
  _this.observer.unobserve(node);
@@ -65505,13 +65501,6 @@ img.ProseMirror-separator {
65505
65501
  return;
65506
65502
  }
65507
65503
  var prevNode = _this.measureElementCache.get(item.key);
65508
- if (!node.isConnected) {
65509
- if (prevNode) {
65510
- _this.observer.unobserve(prevNode);
65511
- _this.measureElementCache["delete"](item.key);
65512
- }
65513
- return;
65514
- }
65515
65504
  if (prevNode !== node) {
65516
65505
  if (prevNode) {
65517
65506
  _this.observer.unobserve(prevNode);
@@ -65538,7 +65527,7 @@ img.ProseMirror-separator {
65538
65527
  }
65539
65528
  _this.pendingMeasuredCacheIndexes.push(item.index);
65540
65529
  _this.itemSizeCache = new Map(_this.itemSizeCache.set(item.key, size));
65541
- _this.notify();
65530
+ _this.notify(false);
65542
65531
  }
65543
65532
  };
65544
65533
  this.measureElement = function (node) {
@@ -65698,7 +65687,7 @@ img.ProseMirror-separator {
65698
65687
  };
65699
65688
  this.measure = function () {
65700
65689
  _this.itemSizeCache = new Map();
65701
- _this.notify();
65690
+ _this.notify(false);
65702
65691
  };
65703
65692
  this.setOptions(_opts);
65704
65693
  this.scrollRect = this.options.initialRect;
@@ -68205,6 +68194,191 @@ img.ProseMirror-separator {
68205
68194
  .register(nimbleTableColumnDateText());
68206
68195
  DesignSystem.tagFor(TableColumnDateText);
68207
68196
 
68197
+ /**
68198
+ * A cell view for displaying duration fields as text
68199
+ */
68200
+ class TableColumnDurationTextCellView extends TableColumnTextCellViewBase {
68201
+ columnConfigChanged() {
68202
+ this.updateText();
68203
+ }
68204
+ cellRecordChanged() {
68205
+ this.updateText();
68206
+ }
68207
+ updateText() {
68208
+ this.text = this.columnConfig?.formatter.format(this.cellRecord?.value) ?? '';
68209
+ }
68210
+ }
68211
+ const durationTextCellView = TableColumnDurationTextCellView.compose({
68212
+ baseName: 'table-column-duration-text-cell-view',
68213
+ template: template$8,
68214
+ styles: styles$a
68215
+ });
68216
+ DesignSystem.getOrCreate()
68217
+ .withPrefix('nimble')
68218
+ .register(durationTextCellView());
68219
+ const tableColumnDurationTextCellViewTag = DesignSystem.tagFor(TableColumnDurationTextCellView);
68220
+
68221
+ /**
68222
+ * A class for formatting a numeric value in the unit of milliseconds into a display value representing its
68223
+ * days, hours, minutes, and seconds.
68224
+ */
68225
+ class DurationFormatter {
68226
+ constructor(lang) {
68227
+ this.lang = lang;
68228
+ this.daysFormatter = new Intl.NumberFormat(this.lang, {
68229
+ style: 'unit',
68230
+ unit: 'day'
68231
+ });
68232
+ this.hoursFormatter = new Intl.NumberFormat(this.lang, {
68233
+ style: 'unit',
68234
+ unit: 'hour'
68235
+ });
68236
+ this.minutesFormatter = new Intl.NumberFormat(this.lang, {
68237
+ style: 'unit',
68238
+ unit: 'minute'
68239
+ });
68240
+ this.secondsFormatter = new Intl.NumberFormat(this.lang, {
68241
+ style: 'unit',
68242
+ unit: 'second'
68243
+ });
68244
+ this.scientificSecondsFormatter = new Intl.NumberFormat(this.lang, {
68245
+ style: 'unit',
68246
+ unit: 'second',
68247
+ notation: 'scientific',
68248
+ maximumFractionDigits: 3
68249
+ });
68250
+ }
68251
+ format(milliseconds) {
68252
+ if (typeof milliseconds !== 'number'
68253
+ || milliseconds < 0
68254
+ || !Number.isFinite(milliseconds)) {
68255
+ return '';
68256
+ }
68257
+ const result = [];
68258
+ const millisecondsPerSecond = 1000;
68259
+ const millisecondsPerMinute = millisecondsPerSecond * 60;
68260
+ const millisecondsPerHour = millisecondsPerMinute * 60;
68261
+ const millisecondsPerDay = millisecondsPerHour * 24;
68262
+ const fractionalDays = milliseconds / millisecondsPerDay;
68263
+ const maximumDays = 999;
68264
+ let remainingTime = milliseconds;
68265
+ const days = Math.floor(fractionalDays);
68266
+ if (days <= maximumDays && days > 0) {
68267
+ const formattedDays = this.daysFormatter.format(days);
68268
+ result.push(formattedDays);
68269
+ remainingTime -= days * millisecondsPerDay;
68270
+ }
68271
+ else if (days > maximumDays) {
68272
+ return this.scientificSecondsFormatter.format(milliseconds / millisecondsPerSecond);
68273
+ }
68274
+ const hours = Math.floor((milliseconds / millisecondsPerHour) % 24);
68275
+ remainingTime -= hours * millisecondsPerHour;
68276
+ if (hours) {
68277
+ const formattedHours = this.hoursFormatter.format(hours);
68278
+ result.push(formattedHours);
68279
+ }
68280
+ const minutes = Math.floor((milliseconds / millisecondsPerMinute) % 60);
68281
+ remainingTime -= minutes * millisecondsPerMinute;
68282
+ if (minutes) {
68283
+ const formattedMinutes = this.minutesFormatter.format(minutes);
68284
+ result.push(formattedMinutes);
68285
+ }
68286
+ const valueInSeconds = remainingTime / millisecondsPerSecond;
68287
+ // if -0, coerce to 0
68288
+ const seconds = valueInSeconds === 0 ? 0 : valueInSeconds % 60;
68289
+ if (milliseconds < 1 && valueInSeconds !== 0) {
68290
+ return this.scientificSecondsFormatter.format(valueInSeconds);
68291
+ }
68292
+ if (seconds >= 0.0005 || (seconds === 0 && result.length === 0)) {
68293
+ const formattedSeconds = this.secondsFormatter.format(seconds);
68294
+ result.push(formattedSeconds);
68295
+ }
68296
+ return result.join(', ');
68297
+ }
68298
+ }
68299
+
68300
+ /**
68301
+ * The group header view for displaying duration fields as text.
68302
+ */
68303
+ class TableColumnDurationTextGroupHeaderView extends TableColumnTextGroupHeaderViewBase {
68304
+ columnConfigChanged() {
68305
+ this.updateText();
68306
+ }
68307
+ groupHeaderValueChanged() {
68308
+ this.updateText();
68309
+ }
68310
+ updateText() {
68311
+ if (this.columnConfig) {
68312
+ this.text = this.columnConfig.formatter.format(this.groupHeaderValue);
68313
+ }
68314
+ else {
68315
+ this.text = '';
68316
+ }
68317
+ }
68318
+ }
68319
+ const tableColumnDurationTextGroupHeaderView = TableColumnDurationTextGroupHeaderView.compose({
68320
+ baseName: 'table-column-duration-text-group-header-view',
68321
+ template: template$9,
68322
+ styles: styles$b
68323
+ });
68324
+ DesignSystem.getOrCreate()
68325
+ .withPrefix('nimble')
68326
+ .register(tableColumnDurationTextGroupHeaderView());
68327
+ const tableColumnDurationTextGroupHeaderViewTag = DesignSystem.tagFor(TableColumnDurationTextGroupHeaderView);
68328
+
68329
+ /**
68330
+ * The table column for displaying a duration value as text.
68331
+ */
68332
+ class TableColumnDurationText extends TableColumnTextBase {
68333
+ constructor() {
68334
+ super(...arguments);
68335
+ this.langSubscriber = {
68336
+ handleChange: () => {
68337
+ this.updateColumnConfig();
68338
+ }
68339
+ };
68340
+ }
68341
+ connectedCallback() {
68342
+ super.connectedCallback();
68343
+ lang$1.subscribe(this.langSubscriber, this);
68344
+ this.updateColumnConfig();
68345
+ }
68346
+ disconnectedCallback() {
68347
+ super.disconnectedCallback();
68348
+ lang$1.unsubscribe(this.langSubscriber, this);
68349
+ }
68350
+ getColumnInternalsOptions() {
68351
+ return {
68352
+ cellRecordFieldNames: ['value'],
68353
+ cellViewTag: tableColumnDurationTextCellViewTag,
68354
+ groupHeaderViewTag: tableColumnDurationTextGroupHeaderViewTag,
68355
+ delegatedEvents: [],
68356
+ sortOperation: TableColumnSortOperation.basic
68357
+ };
68358
+ }
68359
+ updateColumnConfig() {
68360
+ const formatter = new DurationFormatter(lang$1.getValueFor(this));
68361
+ if (formatter) {
68362
+ const columnConfig = {
68363
+ formatter
68364
+ };
68365
+ this.columnInternals.columnConfig = columnConfig;
68366
+ }
68367
+ else {
68368
+ this.columnInternals.columnConfig = undefined;
68369
+ }
68370
+ }
68371
+ }
68372
+ const nimbleTableColumnDurationText = TableColumnDurationText.compose({
68373
+ baseName: 'table-column-duration-text',
68374
+ template: template$b,
68375
+ styles: styles$d
68376
+ });
68377
+ DesignSystem.getOrCreate()
68378
+ .withPrefix('nimble')
68379
+ .register(nimbleTableColumnDurationText());
68380
+ DesignSystem.tagFor(TableColumnDurationText);
68381
+
68208
68382
  /**
68209
68383
  * Converts a Mapping key (which is a string when configured in HTML) to the
68210
68384
  * given keyType. The converted value can then be used to compare against