@ni/nimble-components 17.0.5 → 17.0.7

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.
@@ -25098,45 +25098,47 @@
25098
25098
  */
25099
25099
  class TableValidator {
25100
25100
  constructor() {
25101
- this.duplicateRowId = false;
25102
- this.missingRowId = false;
25103
- this.invalidRowId = false;
25101
+ this.duplicateRecordId = false;
25102
+ this.missingRecordId = false;
25103
+ this.invalidRecordId = false;
25104
25104
  }
25105
25105
  getValidity() {
25106
25106
  return {
25107
- duplicateRowId: this.duplicateRowId,
25108
- missingRowId: this.missingRowId,
25109
- invalidRowId: this.invalidRowId
25107
+ duplicateRecordId: this.duplicateRecordId,
25108
+ missingRecordId: this.missingRecordId,
25109
+ invalidRecordId: this.invalidRecordId
25110
25110
  };
25111
25111
  }
25112
25112
  isValid() {
25113
25113
  return Object.values(this.getValidity()).every(x => x === false);
25114
25114
  }
25115
- validateDataIds(data, idFieldName) {
25115
+ validateRecordIds(data, idFieldName) {
25116
25116
  // Start off by assuming all IDs are valid.
25117
- this.duplicateRowId = false;
25118
- this.missingRowId = false;
25119
- this.invalidRowId = false;
25120
- if (idFieldName == null) {
25117
+ this.duplicateRecordId = false;
25118
+ this.missingRecordId = false;
25119
+ this.invalidRecordId = false;
25120
+ if (idFieldName === undefined || idFieldName === null) {
25121
25121
  return true;
25122
25122
  }
25123
25123
  const ids = new Set();
25124
25124
  for (const record of data) {
25125
25125
  if (!Object.prototype.hasOwnProperty.call(record, idFieldName)) {
25126
- this.missingRowId = true;
25126
+ this.missingRecordId = true;
25127
25127
  continue;
25128
25128
  }
25129
25129
  const id = record[idFieldName];
25130
- if (typeof id !== 'string' || id === '') {
25131
- this.invalidRowId = true;
25130
+ if (typeof id !== 'string') {
25131
+ this.invalidRecordId = true;
25132
25132
  continue;
25133
25133
  }
25134
25134
  if (ids.has(id)) {
25135
- this.duplicateRowId = true;
25135
+ this.duplicateRecordId = true;
25136
25136
  }
25137
25137
  ids.add(id);
25138
25138
  }
25139
- return !this.missingRowId && !this.invalidRowId && !this.duplicateRowId;
25139
+ return (!this.missingRecordId
25140
+ && !this.invalidRecordId
25141
+ && !this.duplicateRecordId);
25140
25142
  }
25141
25143
  }
25142
25144
 
@@ -25359,6 +25361,9 @@
25359
25361
  return keys.every(key => key !== undefined);
25360
25362
  }
25361
25363
  }
25364
+ __decorate$1([
25365
+ attr({ attribute: 'record-id' })
25366
+ ], TableRow.prototype, "recordId", void 0);
25362
25367
  __decorate$1([
25363
25368
  observable
25364
25369
  ], TableRow.prototype, "dataRecord", void 0);
@@ -25402,6 +25407,7 @@
25402
25407
  ${repeat(x => x.tableData, html `
25403
25408
  <${DesignSystem.tagFor(TableRow)}
25404
25409
  class="row"
25410
+ record-id="${x => x.id}"
25405
25411
  :dataRecord="${x => x.record}"
25406
25412
  :columns="${(_, c) => c.parent.columns}"
25407
25413
  >
@@ -25445,13 +25451,6 @@
25445
25451
  data: [],
25446
25452
  onStateChange: (_) => { },
25447
25453
  getCoreRowModel: getCoreRowModel(),
25448
- getRowId: record => {
25449
- if (this.idFieldName) {
25450
- return record[this.idFieldName];
25451
- }
25452
- // Return a falsey value to use the default ID from TanStack.
25453
- return '';
25454
- },
25455
25454
  columns: [],
25456
25455
  state: {},
25457
25456
  renderFallbackValue: null,
@@ -25481,18 +25480,22 @@
25481
25480
  return this.tableValidator.isValid();
25482
25481
  }
25483
25482
  trySetData(newData) {
25484
- const areIdsValid = this.tableValidator.validateDataIds(newData, this.idFieldName);
25485
- if (areIdsValid) {
25486
- this.updateTableOptions({ data: newData });
25487
- }
25488
- else {
25489
- this.updateTableOptions({ data: [] });
25490
- }
25483
+ const areIdsValid = this.tableValidator.validateRecordIds(newData, this.idFieldName);
25484
+ const getRowIdFunction = this.idFieldName === null || this.idFieldName === undefined
25485
+ ? undefined
25486
+ : (record) => record[this.idFieldName];
25487
+ this.updateTableOptions({
25488
+ data: areIdsValid ? newData : [],
25489
+ getRowId: getRowIdFunction
25490
+ });
25491
25491
  }
25492
25492
  refreshRows() {
25493
25493
  const rows = this.table.getRowModel().rows;
25494
25494
  this.tableData = rows.map(row => {
25495
- const rowState = { record: row.original };
25495
+ const rowState = {
25496
+ record: row.original,
25497
+ id: row.id
25498
+ };
25496
25499
  return rowState;
25497
25500
  });
25498
25501
  }
@@ -26751,11 +26754,11 @@ Instead styling against the role which is more general and likely a better appro
26751
26754
  version="1.1"
26752
26755
  x="0px"
26753
26756
  y="0px"
26754
- viewBox="1 .45 20 21"
26757
+ viewBox="0 0 41 41"
26755
26758
  >
26756
26759
  <path
26757
26760
  class="circle-drawing-path"
26758
- d="m 21 12 a 10 10 330 1 1 0 -1.98 a 1 1 0 0 0 0 2"
26761
+ d="m 40.5 21 a 20 20 1 1 1 0 -1 a 0.5 0.5 0 0 0 0 1"
26759
26762
  />
26760
26763
  </svg>
26761
26764
  </g>
@@ -26789,13 +26792,6 @@ Instead styling against the role which is more general and likely a better appro
26789
26792
  position: absolute;
26790
26793
  }
26791
26794
 
26792
- .circle-base {
26793
- width: 100%;
26794
- height: 100%;
26795
- position: absolute;
26796
- fill: white;
26797
- }
26798
-
26799
26795
  .notch {
26800
26796
  transform-origin: center center;
26801
26797
  }
@@ -26826,7 +26822,7 @@ Instead styling against the role which is more general and likely a better appro
26826
26822
  width: 100%;
26827
26823
  height: 100%;
26828
26824
  position: absolute;
26829
- fill: transparent;
26825
+ fill: white;
26830
26826
  }
26831
26827
 
26832
26828
  .circle-drawing-path {
@@ -29868,25 +29864,57 @@ Instead styling against the role which is more general and likely a better appro
29868
29864
  */
29869
29865
  class RenderingModule {
29870
29866
  constructor(waferData, canvas) {
29871
- this.waferData = waferData;
29872
29867
  this.context = canvas.getContext('2d');
29868
+ this.dies = waferData.diesRenderInfo;
29869
+ this.dimensions = waferData.dieDimensions;
29870
+ this.labelFontSize = waferData.labelsFontSize;
29873
29871
  }
29874
- drawWafer() {
29875
- const dies = this.waferData.diesRenderInfo;
29876
- const dimensions = this.waferData.dieDimensions;
29877
- for (const die of dies) {
29878
- this.context.fillStyle = die.fillStyle;
29879
- this.context?.fillRect(die.x, die.y, dimensions.width, dimensions.height);
29880
- this.context.font = this.waferData.labelsFontSize.toString();
29881
- this.context.fillStyle = '#ffffff';
29882
- this.context.textAlign = 'center';
29883
- const aproxTextHeight = this.context.measureText('M');
29884
- this.context.fillText(die.text, die.x + dimensions.width / 2, die.y + dimensions.height / 2 + aproxTextHeight.width / 2);
29885
- }
29872
+ drawWafer(transform) {
29873
+ this.renderDies(transform);
29874
+ this.renderText(transform);
29886
29875
  }
29887
29876
  clearCanvas(width, height) {
29888
29877
  this.context.clearRect(0, 0, width, height);
29889
29878
  }
29879
+ renderDies(transform) {
29880
+ this.dieSize = this.dimensions.width * this.dimensions.height * (transform || 1);
29881
+ this.dies.sort((a, b) => {
29882
+ if (a.fillStyle > b.fillStyle) {
29883
+ return 1;
29884
+ }
29885
+ if (b.fillStyle > a.fillStyle) {
29886
+ return -1;
29887
+ }
29888
+ return 0;
29889
+ });
29890
+ let prev;
29891
+ for (const die of this.dies) {
29892
+ if (!prev) {
29893
+ this.context.fillStyle = die.fillStyle;
29894
+ }
29895
+ if (prev && die.fillStyle !== prev.fillStyle && die.fillStyle) {
29896
+ this.context.fillStyle = die.fillStyle;
29897
+ }
29898
+ this.context.fillRect(die.x, die.y, this.dimensions.width, this.dimensions.height);
29899
+ prev = die;
29900
+ }
29901
+ }
29902
+ renderText(transform) {
29903
+ this.dieSize = this.dimensions.width * this.dimensions.height * (transform || 1);
29904
+ const fontsize = this.labelFontSize;
29905
+ this.context.font = `${fontsize.toString()}px sans-serif`;
29906
+ this.context.fillStyle = '#ffffff';
29907
+ this.context.textAlign = 'center';
29908
+ this.context.lineCap = 'butt';
29909
+ const aproxTextHeight = this.context.measureText('M');
29910
+ if (this.dieSize >= 50) {
29911
+ for (const die of this.dies) {
29912
+ this.context.fillText(die.text, die.x + this.dimensions.width / 2, die.y
29913
+ + this.dimensions.height / 2
29914
+ + aproxTextHeight.width / 2, this.dimensions.width - (this.dimensions.width / 100) * 20);
29915
+ }
29916
+ }
29917
+ }
29890
29918
  }
29891
29919
 
29892
29920
  var xhtml = "http://www.w3.org/1999/xhtml";
@@ -32486,7 +32514,7 @@ Instead styling against the role which is more general and likely a better appro
32486
32514
  this.zoomTransform = identity;
32487
32515
  this.clearCanvas(canvasContext, this.canvasLength, this.canvasLength);
32488
32516
  this.scaleCanvas(canvasContext, identity.x, identity.y, identity.k);
32489
- this.renderingModule.drawWafer();
32517
+ this.renderingModule.drawWafer(this.zoomTransform.k);
32490
32518
  this.zoomBehavior?.transform(select(this.canvas), identity);
32491
32519
  }
32492
32520
  createZoomBehavior() {
@@ -32518,14 +32546,14 @@ Instead styling against the role which is more general and likely a better appro
32518
32546
  this.zoomTransform = identity;
32519
32547
  this.clearCanvas(canvasContext, this.canvasLength, this.canvasLength);
32520
32548
  this.scaleCanvas(canvasContext, identity.x, identity.y, identity.k);
32521
- this.renderingModule.drawWafer();
32549
+ this.renderingModule.drawWafer(this.zoomTransform.k);
32522
32550
  zoomBehavior.transform(select(this.canvas), identity);
32523
32551
  }
32524
32552
  else {
32525
32553
  this.zoomTransform = transform;
32526
32554
  this.clearCanvas(canvasContext, this.canvasLength * this.zoomTransform.k, this.canvasLength * this.zoomTransform.k);
32527
32555
  this.scaleCanvas(canvasContext, transform.x, transform.y, transform.k);
32528
- this.renderingModule.drawWafer();
32556
+ this.renderingModule.drawWafer(this.zoomTransform.k);
32529
32557
  }
32530
32558
  canvasContext.restore();
32531
32559
  this.zoomContainer.setAttribute('transform', this.zoomTransform.toString());