@ni/nimble-components 18.5.3 → 18.5.4

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 (29) hide show
  1. package/dist/all-components-bundle.js +183 -31
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +575 -534
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/table/components/row/styles.js +0 -1
  6. package/dist/esm/table/components/row/styles.js.map +1 -1
  7. package/dist/esm/wafer-map/index.d.ts +25 -4
  8. package/dist/esm/wafer-map/index.js +45 -4
  9. package/dist/esm/wafer-map/index.js.map +1 -1
  10. package/dist/esm/wafer-map/modules/data-manager.d.ts +3 -1
  11. package/dist/esm/wafer-map/modules/data-manager.js +4 -0
  12. package/dist/esm/wafer-map/modules/data-manager.js.map +1 -1
  13. package/dist/esm/wafer-map/modules/event-coordinator.d.ts +1 -1
  14. package/dist/esm/wafer-map/modules/event-coordinator.js +6 -12
  15. package/dist/esm/wafer-map/modules/event-coordinator.js.map +1 -1
  16. package/dist/esm/wafer-map/modules/hover-handler.d.ts +12 -0
  17. package/dist/esm/wafer-map/modules/hover-handler.js +56 -0
  18. package/dist/esm/wafer-map/modules/hover-handler.js.map +1 -0
  19. package/dist/esm/wafer-map/modules/rendering.d.ts +2 -1
  20. package/dist/esm/wafer-map/modules/rendering.js +38 -15
  21. package/dist/esm/wafer-map/modules/rendering.js.map +1 -1
  22. package/dist/esm/wafer-map/styles.js +27 -0
  23. package/dist/esm/wafer-map/styles.js.map +1 -1
  24. package/dist/esm/wafer-map/template.js +8 -0
  25. package/dist/esm/wafer-map/template.js.map +1 -1
  26. package/dist/esm/wafer-map/types.d.ts +9 -0
  27. package/dist/esm/wafer-map/types.js +4 -0
  28. package/dist/esm/wafer-map/types.js.map +1 -1
  29. package/package.json +10 -6
@@ -27121,7 +27121,6 @@
27121
27121
  --ni-private-table-cell-action-menu-display: block;
27122
27122
  }
27123
27123
 
27124
- :host(.hover) nimble-table-cell,
27125
27124
  :host(:hover) nimble-table-cell {
27126
27125
  --ni-private-table-cell-action-menu-display: block;
27127
27126
  }
@@ -32901,6 +32900,14 @@ Instead styling against the role which is more general and likely a better appro
32901
32900
  </g>
32902
32901
  </svg>
32903
32902
  <canvas class="wafer-map-canvas" ${ref('canvas')}></canvas>
32903
+ <svg class="hover-layer">
32904
+ <rect
32905
+ class="hover-rect ${x => x.hoverOpacity}"
32906
+ transform="${x => x.hoverTransform}"
32907
+ width="${x => x.hoverWidth}"
32908
+ height="${x => x.hoverHeight}"
32909
+ />
32910
+ </svg>
32904
32911
  </div>
32905
32912
  `;
32906
32913
 
@@ -32961,6 +32968,32 @@ Instead styling against the role which is more general and likely a better appro
32961
32968
  display: inline-block;
32962
32969
  position: absolute;
32963
32970
  }
32971
+
32972
+ .hover-layer {
32973
+ position: absolute;
32974
+ pointer-events: none;
32975
+ width: 100%;
32976
+ height: 100%;
32977
+ }
32978
+
32979
+ .hover-rect {
32980
+ fill: transparent;
32981
+ stroke: white;
32982
+ outline-style: solid;
32983
+ outline-color: ${DigitalGreenLight};
32984
+ }
32985
+
32986
+ .hover-rect.show {
32987
+ opacity: 1;
32988
+ stroke-width: 2px;
32989
+ outline-width: 2px;
32990
+ }
32991
+
32992
+ .hover-rect.hide {
32993
+ opacity: 0;
32994
+ stroke-width: 0px;
32995
+ outline-width: 0px;
32996
+ }
32964
32997
  `;
32965
32998
 
32966
32999
  function ascending(a, b) {
@@ -33849,6 +33882,10 @@ Instead styling against the role which is more general and likely a better appro
33849
33882
  left: 'left',
33850
33883
  right: 'right'
33851
33884
  };
33885
+ const HoverDieOpacity = {
33886
+ show: 'show',
33887
+ hide: 'hide'
33888
+ };
33852
33889
  const WaferMapColorScaleMode = {
33853
33890
  linear: 'linear',
33854
33891
  ordinal: 'ordinal'
@@ -34070,6 +34107,7 @@ Instead styling against the role which is more general and likely a better appro
34070
34107
  constructor(wafermap) {
34071
34108
  this.computations = new Computations(wafermap);
34072
34109
  this.prerendering = new Prerendering(wafermap, this.horizontalScale, this.verticalScale, this.dieDimensions, this.margin);
34110
+ this.dataMap = new Map(wafermap.dies.map(die => [`${die.x}_${die.y}`, die]));
34073
34111
  }
34074
34112
  get containerDimensions() {
34075
34113
  return this.computations.containerDimensions;
@@ -34095,6 +34133,9 @@ Instead styling against the role which is more general and likely a better appro
34095
34133
  get diesRenderInfo() {
34096
34134
  return this.prerendering.diesRenderInfo;
34097
34135
  }
34136
+ getWaferMapDie(point) {
34137
+ return this.dataMap.get(`${point.x}_${point.y}`);
34138
+ }
34098
34139
  }
34099
34140
 
34100
34141
  /**
@@ -34103,18 +34144,40 @@ Instead styling against the role which is more general and likely a better appro
34103
34144
  class RenderingModule {
34104
34145
  constructor(wafermap) {
34105
34146
  this.wafermap = wafermap;
34106
- this.context = wafermap.canvas.getContext('2d');
34107
34147
  this.dies = wafermap.dataManager.diesRenderInfo;
34108
34148
  this.dimensions = wafermap.dataManager.dieDimensions;
34109
34149
  this.labelFontSize = wafermap.dataManager.labelsFontSize;
34110
34150
  }
34111
34151
  drawWafer() {
34112
- this.context.save();
34152
+ this.wafermap.canvasContext.save();
34113
34153
  this.clearCanvas();
34114
34154
  this.scaleCanvas();
34115
34155
  this.renderDies();
34116
34156
  this.renderText();
34117
- this.context.restore();
34157
+ this.wafermap.canvasContext.restore();
34158
+ this.renderHover();
34159
+ }
34160
+ renderHover() {
34161
+ this.wafermap.hoverWidth = this.wafermap.dataManager.dieDimensions.width
34162
+ * this.wafermap.transform.k;
34163
+ this.wafermap.hoverHeight = this.wafermap.dataManager.dieDimensions.height
34164
+ * this.wafermap.transform.k;
34165
+ this.wafermap.hoverOpacity = this.wafermap.hoverDie === undefined
34166
+ ? HoverDieOpacity.hide
34167
+ : HoverDieOpacity.show;
34168
+ this.wafermap.hoverTransform = this.calculateHoverTransform();
34169
+ }
34170
+ calculateHoverTransform() {
34171
+ if (this.wafermap.hoverDie !== undefined) {
34172
+ const scaledX = this.wafermap.dataManager.horizontalScale(this.wafermap.hoverDie.x);
34173
+ const scaledY = this.wafermap.dataManager.verticalScale(this.wafermap.hoverDie.y);
34174
+ const transformedPoint = this.wafermap.transform.apply([
34175
+ scaledX + this.wafermap.dataManager.margin.left,
34176
+ scaledY + this.wafermap.dataManager.margin.top
34177
+ ]);
34178
+ return `translate(${transformedPoint[0]}, ${transformedPoint[1]})`;
34179
+ }
34180
+ return '';
34118
34181
  }
34119
34182
  renderDies() {
34120
34183
  this.dies.sort((a, b) => {
@@ -34129,12 +34192,12 @@ Instead styling against the role which is more general and likely a better appro
34129
34192
  let prev;
34130
34193
  for (const die of this.dies) {
34131
34194
  if (!prev) {
34132
- this.context.fillStyle = die.fillStyle;
34195
+ this.wafermap.canvasContext.fillStyle = die.fillStyle;
34133
34196
  }
34134
34197
  if (prev && die.fillStyle !== prev.fillStyle && die.fillStyle) {
34135
- this.context.fillStyle = die.fillStyle;
34198
+ this.wafermap.canvasContext.fillStyle = die.fillStyle;
34136
34199
  }
34137
- this.context.fillRect(die.x, die.y, this.dimensions.width, this.dimensions.height);
34200
+ this.wafermap.canvasContext.fillRect(die.x, die.y, this.dimensions.width, this.dimensions.height);
34138
34201
  prev = die;
34139
34202
  }
34140
34203
  }
@@ -34143,25 +34206,25 @@ Instead styling against the role which is more general and likely a better appro
34143
34206
  * this.dimensions.height
34144
34207
  * (this.wafermap.transform.k || 1);
34145
34208
  const fontsize = this.labelFontSize;
34146
- this.context.font = `${fontsize.toString()}px sans-serif`;
34147
- this.context.fillStyle = '#ffffff';
34148
- this.context.textAlign = 'center';
34149
- this.context.lineCap = 'butt';
34150
- const approxTextHeight = this.context.measureText('M');
34209
+ this.wafermap.canvasContext.font = `${fontsize.toString()}px sans-serif`;
34210
+ this.wafermap.canvasContext.fillStyle = '#ffffff';
34211
+ this.wafermap.canvasContext.textAlign = 'center';
34212
+ this.wafermap.canvasContext.lineCap = 'butt';
34213
+ const approxTextHeight = this.wafermap.canvasContext.measureText('M');
34151
34214
  if (dieSize >= 50) {
34152
34215
  for (const die of this.dies) {
34153
- this.context.fillText(die.text, die.x + this.dimensions.width / 2, die.y
34216
+ this.wafermap.canvasContext.fillText(die.text, die.x + this.dimensions.width / 2, die.y
34154
34217
  + this.dimensions.height / 2
34155
34218
  + approxTextHeight.width / 2, this.dimensions.width - (this.dimensions.width / 100) * 20);
34156
34219
  }
34157
34220
  }
34158
34221
  }
34159
34222
  clearCanvas() {
34160
- this.context.clearRect(0, 0, this.wafermap.canvasWidth * this.wafermap.transform.k, this.wafermap.canvasHeight * this.wafermap.transform.k);
34223
+ this.wafermap.canvasContext.clearRect(0, 0, this.wafermap.canvasWidth * this.wafermap.transform.k, this.wafermap.canvasHeight * this.wafermap.transform.k);
34161
34224
  }
34162
34225
  scaleCanvas() {
34163
- this.context.translate(this.wafermap.transform.x, this.wafermap.transform.y);
34164
- this.context.scale(this.wafermap.transform.k, this.wafermap.transform.k);
34226
+ this.wafermap.canvasContext.translate(this.wafermap.transform.x, this.wafermap.transform.y);
34227
+ this.wafermap.canvasContext.scale(this.wafermap.transform.k, this.wafermap.transform.k);
34165
34228
  }
34166
34229
  }
34167
34230
 
@@ -34220,6 +34283,61 @@ Instead styling against the role which is more general and likely a better appro
34220
34283
  }
34221
34284
  }
34222
34285
 
34286
+ /**
34287
+ * HoverHandler deals with user interactions and events like hovering
34288
+ */
34289
+ class HoverHandler {
34290
+ constructor(wafermap) {
34291
+ this.wafermap = wafermap;
34292
+ }
34293
+ mousemove(event) {
34294
+ const mousePosition = {
34295
+ x: event.offsetX,
34296
+ y: event.offsetY
34297
+ };
34298
+ if (!this.hoversOverDie(mousePosition)) {
34299
+ this.wafermap.hoverDie = undefined;
34300
+ return;
34301
+ }
34302
+ // get original mouse position in case we are in zoom.
34303
+ const invertedPoint = this.wafermap.transform.invert([
34304
+ mousePosition.x,
34305
+ mousePosition.y
34306
+ ]);
34307
+ const dieCoordinates = this.calculateDieCoordinates({
34308
+ x: invertedPoint[0],
34309
+ y: invertedPoint[1]
34310
+ });
34311
+ this.wafermap.hoverDie = this.wafermap.dataManager.getWaferMapDie(dieCoordinates);
34312
+ }
34313
+ mouseout(_event) {
34314
+ this.wafermap.hoverDie = undefined;
34315
+ }
34316
+ calculateDieCoordinates(mousePosition) {
34317
+ const axisLocation = this.wafermap.quadrant;
34318
+ const xRoundFunction = axisLocation === WaferMapQuadrant.bottomLeft
34319
+ || axisLocation === WaferMapQuadrant.topLeft
34320
+ ? Math.floor
34321
+ : Math.ceil;
34322
+ const yRoundFunction = axisLocation === WaferMapQuadrant.topLeft
34323
+ || axisLocation === WaferMapQuadrant.topRight
34324
+ ? Math.floor
34325
+ : Math.ceil;
34326
+ // go to x and y scale to get the x,y values of the die.
34327
+ const x = xRoundFunction(this.wafermap.dataManager.horizontalScale.invert(mousePosition.x - this.wafermap.dataManager.margin.left));
34328
+ const y = yRoundFunction(this.wafermap.dataManager.verticalScale.invert(mousePosition.y - this.wafermap.dataManager.margin.top));
34329
+ return { x, y };
34330
+ }
34331
+ hoversOverDie(mousePosition) {
34332
+ const rgba = this.wafermap.canvasContext.getImageData(mousePosition.x, mousePosition.y, 1, 1).data;
34333
+ let rgbaSum = 0;
34334
+ for (const color of rgba) {
34335
+ rgbaSum += color;
34336
+ }
34337
+ return rgbaSum > 0;
34338
+ }
34339
+ }
34340
+
34223
34341
  /**
34224
34342
  * EventCoordinator deals with user interactions and events
34225
34343
  */
@@ -34229,21 +34347,16 @@ Instead styling against the role which is more general and likely a better appro
34229
34347
  this.onWheelMove = (event) => {
34230
34348
  event.preventDefault();
34231
34349
  };
34232
- this.onMouseMove = () => {
34233
- // TODO HoverHandler - mousemove(e) callback
34350
+ this.onMouseMove = (event) => {
34351
+ this.hoverHandler.mousemove(event);
34234
34352
  };
34235
- this.onMouseOut = () => {
34236
- // TODO HoverHandler - mouseout() callback
34353
+ this.onMouseOut = (event) => {
34354
+ this.hoverHandler.mouseout(event);
34237
34355
  };
34238
34356
  this.zoomHandler = new ZoomHandler(wafermap);
34239
- // TODO HoverHandler - initialization
34240
- // TODO HoverHandler - create a hoverDie element
34357
+ this.hoverHandler = new HoverHandler(wafermap);
34241
34358
  this.attachEvents();
34242
34359
  }
34243
- get selectedDie() {
34244
- // TODO HoverHandler - return the last selected die when called
34245
- return undefined;
34246
- }
34247
34360
  detachEvents() {
34248
34361
  this.wafermap.removeEventListener('mousemove', this.onMouseMove);
34249
34362
  this.wafermap.removeEventListener('mouseout', this.onMouseOut);
@@ -34255,8 +34368,6 @@ Instead styling against the role which is more general and likely a better appro
34255
34368
  this.wafermap.canvas.addEventListener('wheel', this.onWheelMove, {
34256
34369
  passive: false
34257
34370
  });
34258
- // Wafermap callbacks
34259
- // TODO HoverHandler - configure the callback to be fired from HoverHandler when a new die is selected
34260
34371
  }
34261
34372
  }
34262
34373
 
@@ -34280,18 +34391,34 @@ Instead styling against the role which is more general and likely a better appro
34280
34391
  * @internal
34281
34392
  */
34282
34393
  this.transform = identity$2;
34394
+ /**
34395
+ * @internal
34396
+ */
34397
+ this.hoverTransform = '';
34398
+ /**
34399
+ * @internal
34400
+ */
34401
+ this.hoverOpacity = HoverDieOpacity.hide;
34402
+ /**
34403
+ * @internal
34404
+ */
34405
+ this.hoverWidth = 0;
34406
+ /**
34407
+ * @internal
34408
+ */
34409
+ this.hoverHeight = 0;
34283
34410
  this.highlightedValues = [];
34284
34411
  this.dies = [];
34285
34412
  this.colorScale = {
34286
34413
  colors: [],
34287
34414
  values: []
34288
34415
  };
34289
- this.emitDieSelected = (die) => {
34290
- this.$emit('die-selected', { detail: { die } });
34291
- };
34292
34416
  }
34293
34417
  connectedCallback() {
34294
34418
  super.connectedCallback();
34419
+ this.canvasContext = this.canvas.getContext('2d', {
34420
+ willReadFrequently: true
34421
+ });
34295
34422
  this.resizeObserver = this.createResizeObserver();
34296
34423
  }
34297
34424
  disconnectedCallback() {
@@ -34315,6 +34442,12 @@ Instead styling against the role which is more general and likely a better appro
34315
34442
  DOM.queueUpdate(() => this.render());
34316
34443
  }
34317
34444
  }
34445
+ queueRenderHover() {
34446
+ if (!this.$fastController.isConnected) {
34447
+ return;
34448
+ }
34449
+ DOM.queueUpdate(() => this.renderer?.renderHover());
34450
+ }
34318
34451
  initializeInternalModules() {
34319
34452
  this.eventCoordinator?.detachEvents();
34320
34453
  this.dataManager = new DataManager(this);
@@ -34374,6 +34507,10 @@ Instead styling against the role which is more general and likely a better appro
34374
34507
  canvasHeightChanged() {
34375
34508
  this.queueRender();
34376
34509
  }
34510
+ hoverDieChanged() {
34511
+ this.$emit('die-hover', { currentDie: this.hoverDie });
34512
+ this.queueRenderHover();
34513
+ }
34377
34514
  }
34378
34515
  __decorate$1([
34379
34516
  attr
@@ -34412,6 +34549,21 @@ Instead styling against the role which is more general and likely a better appro
34412
34549
  __decorate$1([
34413
34550
  observable
34414
34551
  ], WaferMap.prototype, "transform", void 0);
34552
+ __decorate$1([
34553
+ observable
34554
+ ], WaferMap.prototype, "hoverTransform", void 0);
34555
+ __decorate$1([
34556
+ observable
34557
+ ], WaferMap.prototype, "hoverOpacity", void 0);
34558
+ __decorate$1([
34559
+ observable
34560
+ ], WaferMap.prototype, "hoverWidth", void 0);
34561
+ __decorate$1([
34562
+ observable
34563
+ ], WaferMap.prototype, "hoverHeight", void 0);
34564
+ __decorate$1([
34565
+ observable
34566
+ ], WaferMap.prototype, "hoverDie", void 0);
34415
34567
  __decorate$1([
34416
34568
  observable
34417
34569
  ], WaferMap.prototype, "highlightedValues", void 0);