@ni/nimble-components 16.1.8 → 17.0.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.
Files changed (41) hide show
  1. package/dist/all-components-bundle.js +112 -19
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +1192 -1187
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/dialog/styles.js +2 -2
  6. package/dist/esm/dialog/styles.js.map +1 -1
  7. package/dist/esm/drawer/styles.js +3 -5
  8. package/dist/esm/drawer/styles.js.map +1 -1
  9. package/dist/esm/menu/styles.js +2 -2
  10. package/dist/esm/menu/styles.js.map +1 -1
  11. package/dist/esm/patterns/dropdown/styles.js +2 -2
  12. package/dist/esm/patterns/dropdown/styles.js.map +1 -1
  13. package/dist/esm/table/index.d.ts +12 -1
  14. package/dist/esm/table/index.js +49 -2
  15. package/dist/esm/table/index.js.map +1 -1
  16. package/dist/esm/table/models/table-validator.d.ts +13 -0
  17. package/dist/esm/table/models/table-validator.js +48 -0
  18. package/dist/esm/table/models/table-validator.js.map +1 -0
  19. package/dist/esm/table/models/table-validator.spec.d.ts +1 -0
  20. package/dist/esm/table/models/table-validator.spec.js +218 -0
  21. package/dist/esm/table/models/table-validator.spec.js.map +1 -0
  22. package/dist/esm/table/template.d.ts +1 -2
  23. package/dist/esm/table/template.js +2 -2
  24. package/dist/esm/table/template.js.map +1 -1
  25. package/dist/esm/table/types.d.ts +8 -0
  26. package/dist/esm/theme-provider/design-token-comments.js +4 -2
  27. package/dist/esm/theme-provider/design-token-comments.js.map +1 -1
  28. package/dist/esm/theme-provider/design-token-names.d.ts +1 -1
  29. package/dist/esm/theme-provider/design-token-names.js +5 -2
  30. package/dist/esm/theme-provider/design-token-names.js.map +1 -1
  31. package/dist/esm/theme-provider/design-tokens.d.ts +3 -1
  32. package/dist/esm/theme-provider/design-tokens.js +5 -2
  33. package/dist/esm/theme-provider/design-tokens.js.map +1 -1
  34. package/dist/esm/tooltip/styles.js +2 -2
  35. package/dist/esm/tooltip/styles.js.map +1 -1
  36. package/dist/esm/wafer-map/index.d.ts +4 -1
  37. package/dist/esm/wafer-map/index.js +1 -4
  38. package/dist/esm/wafer-map/index.js.map +1 -1
  39. package/dist/tokens-internal.scss +18 -6
  40. package/dist/tokens.scss +9 -3
  41. package/package.json +1 -1
@@ -15395,7 +15395,6 @@
15395
15395
  const Pass100DarkUi = "#00c12b";
15396
15396
  const Fail100LightUi = "#c4000c";
15397
15397
  const Fail100DarkUi = "#ff4646";
15398
- const Black75 = "#818386";
15399
15398
  const Black15 = "#f1f1f2";
15400
15399
  const Black7 = "#f5f5f5";
15401
15400
  const White = "#ffffff";
@@ -15533,7 +15532,6 @@
15533
15532
  borderHoverColor: 'border-hover-color',
15534
15533
  iconColor: 'icon-color',
15535
15534
  modalBackdropColor: 'modal-backdrop-color',
15536
- popupBoxShadowColor: 'popup-box-shadow-color',
15537
15535
  popupBorderColor: 'popup-border-color',
15538
15536
  controlHeight: 'control-height',
15539
15537
  smallPadding: 'small-padding',
@@ -15707,7 +15705,10 @@
15707
15705
  errorTextFontWeight: 'error-text-font-weight',
15708
15706
  errorTextFontLineHeight: 'error-text-font-line-height',
15709
15707
  errorTextFallbackFontFamily: 'error-text-fallback-font-family',
15710
- tableRowBorderColor: 'table-row-border-color'
15708
+ tableRowBorderColor: 'table-row-border-color',
15709
+ elevation1BoxShadow: 'elevation-1-box-shadow',
15710
+ elevation2BoxShadow: 'elevation-2-box-shadow',
15711
+ elevation3BoxShadow: 'elevation-3-box-shadow'
15711
15712
  };
15712
15713
  const prefix = 'ni-nimble';
15713
15714
  const styleNameFromTokenName = (tokenName) => `${prefix}-${tokenName}`;
@@ -15798,7 +15799,6 @@
15798
15799
  // Component Color Tokens
15799
15800
  const iconColor = DesignToken.create(styleNameFromTokenName(tokenNames.iconColor)).withDefault((element) => getColorForTheme(element, Black91, Black15, White));
15800
15801
  DesignToken.create(styleNameFromTokenName(tokenNames.modalBackdropColor)).withDefault((element) => getModalBackdropForTheme(element));
15801
- const popupBoxShadowColor = DesignToken.create(styleNameFromTokenName(tokenNames.popupBoxShadowColor)).withDefault((element) => hexToRgbaCssColor(getColorForTheme(element, Black75, Black85, Black85), 0.3));
15802
15802
  const popupBorderColor = DesignToken.create(styleNameFromTokenName(tokenNames.popupBorderColor)).withDefault((element) => hexToRgbaCssColor(getColorForTheme(element, Black91, Black15, White), 0.3));
15803
15803
  DesignToken.create(styleNameFromTokenName(tokenNames.tooltipBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black85, ForestGreen));
15804
15804
  const tableRowBorderColor = DesignToken.create(styleNameFromTokenName(tokenNames.tableRowBorderColor)).withDefault((element) => getColorForTheme(element, Black15, Black88, ForestGreen));
@@ -15810,6 +15810,10 @@
15810
15810
  const borderWidth = DesignToken.create(styleNameFromTokenName(tokenNames.borderWidth)).withDefault('1px');
15811
15811
  const iconSize = DesignToken.create(styleNameFromTokenName(tokenNames.iconSize)).withDefault('16px');
15812
15812
  const drawerWidth = DesignToken.create(styleNameFromTokenName(tokenNames.drawerWidth)).withDefault('784px');
15813
+ // Drop Shadow Tokens
15814
+ DesignToken.create(styleNameFromTokenName(tokenNames.elevation1BoxShadow)).withDefault((element) => `0px 1px 4px ${hexToRgbaCssColor(getColorForTheme(element, Black, Black, Black), 0.16)}`);
15815
+ const elevation2BoxShadow = DesignToken.create(styleNameFromTokenName(tokenNames.elevation2BoxShadow)).withDefault((element) => `0px 2px 4px ${hexToRgbaCssColor(getColorForTheme(element, Black, Black, Black), 0.16)}`);
15816
+ const elevation3BoxShadow = DesignToken.create(styleNameFromTokenName(tokenNames.elevation3BoxShadow)).withDefault((element) => `0px 4px 8px ${hexToRgbaCssColor(getColorForTheme(element, Black, Black, Black), 0.3)}`);
15813
15817
  // Font Tokens
15814
15818
  createFontTokens(tokenNames.headlineFont, (element) => getDefaultFontColorForTheme(element), (element) => hexToRgbaCssColor(getDefaultFontColorForTheme(element), 0.3), Headline1Family, Headline1Weight, Headline1Size, Headline1LineHeight, 'serif');
15815
15819
  createFontTokens(tokenNames.headlinePlus1Font, (element) => getDefaultFontColorForTheme(element), (element) => hexToRgbaCssColor(getDefaultFontColorForTheme(element), 0.3), Headline2Family, Headline2Weight, Headline2Size, Headline2LineHeight, 'serif');
@@ -18058,7 +18062,7 @@
18058
18062
  );
18059
18063
  z-index: 1;
18060
18064
  padding: var(--ni-private-listbox-padding);
18061
- box-shadow: 0px 3px 3px ${popupBoxShadowColor};
18065
+ box-shadow: ${elevation2BoxShadow};
18062
18066
  border: 1px solid ${popupBorderColor};
18063
18067
  background-color: ${applicationBackgroundColor};
18064
18068
  background-clip: padding-box;
@@ -18494,7 +18498,7 @@
18494
18498
  flex-direction: column;
18495
18499
  background-color: ${applicationBackgroundColor};
18496
18500
  border: none;
18497
- box-shadow: 0px 4px 8px #0000004d;
18501
+ box-shadow: ${elevation3BoxShadow};
18498
18502
  padding: 0px;
18499
18503
  width: 400px;
18500
18504
  max-height: 600px;
@@ -18802,8 +18806,7 @@
18802
18806
  }
18803
18807
 
18804
18808
  :host([location='left']) .dialog-contents {
18805
- border-right: ${borderWidth} solid ${popupBoxShadowColor};
18806
- box-shadow: 3px 0px 8px ${popupBoxShadowColor};
18809
+ box-shadow: 3px 0px 8px #00000033;
18807
18810
  }
18808
18811
 
18809
18812
  :host([location='left']) dialog.animating .dialog-contents {
@@ -18822,8 +18825,7 @@
18822
18825
 
18823
18826
  :host([location='right']) .dialog-contents {
18824
18827
  right: 0px;
18825
- border-left: ${borderWidth} solid ${popupBoxShadowColor};
18826
- box-shadow: -3px 0px 8px ${popupBoxShadowColor};
18828
+ box-shadow: -3px 0px 8px #00000033;
18827
18829
  }
18828
18830
 
18829
18831
  :host([location='right']) dialog.animating .dialog-contents {
@@ -20731,7 +20733,7 @@
20731
20733
  padding: 4px;
20732
20734
  min-width: 168px;
20733
20735
  width: max-content;
20734
- box-shadow: 0px 2px 3px ${popupBoxShadowColor};
20736
+ box-shadow: ${elevation2BoxShadow};
20735
20737
  }
20736
20738
  :host([slot='submenu']) {
20737
20739
  margin: 0 calc(${smallPadding} * 2);
@@ -25078,6 +25080,54 @@
25078
25080
  });
25079
25081
  }
25080
25082
 
25083
+ /**
25084
+ * Helper class for the nimble-table to validate that the table's configuration
25085
+ * is valid and report which aspects of the configuration are valid or invalid.
25086
+ */
25087
+ class TableValidator {
25088
+ constructor() {
25089
+ this.duplicateRowId = false;
25090
+ this.missingRowId = false;
25091
+ this.invalidRowId = false;
25092
+ }
25093
+ getValidity() {
25094
+ return {
25095
+ duplicateRowId: this.duplicateRowId,
25096
+ missingRowId: this.missingRowId,
25097
+ invalidRowId: this.invalidRowId
25098
+ };
25099
+ }
25100
+ isValid() {
25101
+ return Object.values(this.getValidity()).every(x => x === false);
25102
+ }
25103
+ validateDataIds(data, idFieldName) {
25104
+ // Start off by assuming all IDs are valid.
25105
+ this.duplicateRowId = false;
25106
+ this.missingRowId = false;
25107
+ this.invalidRowId = false;
25108
+ if (idFieldName == null) {
25109
+ return true;
25110
+ }
25111
+ const ids = new Set();
25112
+ for (const record of data) {
25113
+ if (!Object.prototype.hasOwnProperty.call(record, idFieldName)) {
25114
+ this.missingRowId = true;
25115
+ continue;
25116
+ }
25117
+ const id = record[idFieldName];
25118
+ if (typeof id !== 'string' || id === '') {
25119
+ this.invalidRowId = true;
25120
+ continue;
25121
+ }
25122
+ if (ids.has(id)) {
25123
+ this.duplicateRowId = true;
25124
+ }
25125
+ ids.add(id);
25126
+ }
25127
+ return !this.missingRowId && !this.invalidRowId && !this.duplicateRowId;
25128
+ }
25129
+ }
25130
+
25081
25131
  const styles$c = css `
25082
25132
  ${display('flex')}
25083
25133
 
@@ -25243,9 +25293,9 @@
25243
25293
  </div>
25244
25294
  </div>
25245
25295
  <div class="table-viewport" role="rowgroup">
25246
- ${repeat(x => x.data, html `
25296
+ ${repeat(x => x.tableData, html `
25247
25297
  <${DesignSystem.tagFor(TableRow)}
25248
- :data="${x => x}"
25298
+ :data="${x => x.data}"
25249
25299
  :columns="${(_, c) => c.parent.columns}"
25250
25300
  >
25251
25301
  </${DesignSystem.tagFor(TableRow)}>
@@ -25262,12 +25312,17 @@
25262
25312
  constructor() {
25263
25313
  super();
25264
25314
  this.data = [];
25315
+ /**
25316
+ * @internal
25317
+ */
25318
+ this.tableData = [];
25265
25319
  // TODO: Temporarily expose the columns as a string array. This will ultimately be
25266
25320
  // column definitions provided by slotted elements.
25267
25321
  this.columns = [];
25268
25322
  // TODO: Temporarily expose the column headers as a string array.
25269
25323
  this.columnHeaders = [];
25270
25324
  this.tableInitialized = false;
25325
+ this.tableValidator = new TableValidator();
25271
25326
  this.update = (state) => {
25272
25327
  this.table.setOptions(prev => ({
25273
25328
  ...prev,
@@ -25285,6 +25340,13 @@
25285
25340
  data: [],
25286
25341
  onStateChange: (_) => { },
25287
25342
  getCoreRowModel: getCoreRowModel(),
25343
+ getRowId: record => {
25344
+ if (this.idFieldName) {
25345
+ return record[this.idFieldName];
25346
+ }
25347
+ // Return a falsey value to use the default ID from TanStack.
25348
+ return '';
25349
+ },
25288
25350
  columns: [],
25289
25351
  state: {},
25290
25352
  renderFallbackValue: null,
@@ -25293,18 +25355,46 @@
25293
25355
  this.table = createTable(this.options);
25294
25356
  this.tableInitialized = true;
25295
25357
  }
25358
+ get validity() {
25359
+ return this.tableValidator.getValidity();
25360
+ }
25361
+ idFieldNameChanged(_prev, _next) {
25362
+ // Force TanStack to detect a data update because a row's ID is only
25363
+ // generated when creating a new row model.
25364
+ this.trySetData([...this.data]);
25365
+ }
25296
25366
  dataChanged(prev, next) {
25297
25367
  if ((!prev || prev.length === 0) && next && next.length > 0) {
25298
25368
  this.generateColumns();
25299
25369
  }
25300
25370
  // Ignore any updates that occur prior to the TanStack table being initialized.
25301
25371
  if (this.tableInitialized) {
25302
- this.updateTableOptions({ data: this.data });
25372
+ this.trySetData(this.data);
25373
+ }
25374
+ }
25375
+ checkValidity() {
25376
+ return this.tableValidator.isValid();
25377
+ }
25378
+ trySetData(newData) {
25379
+ const areIdsValid = this.tableValidator.validateDataIds(newData, this.idFieldName);
25380
+ if (areIdsValid) {
25381
+ this.updateTableOptions({ data: newData });
25382
+ }
25383
+ else {
25384
+ this.updateTableOptions({ data: [] });
25303
25385
  }
25304
25386
  }
25387
+ refreshRows() {
25388
+ const rows = this.table.getRowModel().rows;
25389
+ this.tableData = rows.map(row => {
25390
+ const rowState = { data: row.original };
25391
+ return rowState;
25392
+ });
25393
+ }
25305
25394
  updateTableOptions(updatedOptions) {
25306
25395
  this.options = { ...this.options, ...updatedOptions };
25307
25396
  this.update(this.table.initialState);
25397
+ this.refreshRows();
25308
25398
  }
25309
25399
  // Temporarily auto-detect the keys in TData to make columns.
25310
25400
  // TODO: Remove this logic when another way to specify columns is provided.
@@ -25327,9 +25417,15 @@
25327
25417
  this.columns = this.columnHeaders;
25328
25418
  }
25329
25419
  }
25420
+ __decorate$1([
25421
+ attr({ attribute: 'id-field-name' })
25422
+ ], Table.prototype, "idFieldName", void 0);
25330
25423
  __decorate$1([
25331
25424
  observable
25332
25425
  ], Table.prototype, "data", void 0);
25426
+ __decorate$1([
25427
+ observable
25428
+ ], Table.prototype, "tableData", void 0);
25333
25429
  __decorate$1([
25334
25430
  observable
25335
25431
  ], Table.prototype, "columns", void 0);
@@ -25921,7 +26017,7 @@
25921
26017
  box-sizing: border-box;
25922
26018
  flex-shrink: 0;
25923
26019
  max-width: 440px;
25924
- box-shadow: 0px 3px 4px ${popupBoxShadowColor};
26020
+ box-shadow: ${elevation2BoxShadow};
25925
26021
  display: inline-flex;
25926
26022
  border: ${borderWidth} solid var(--ni-private-tooltip-border-color);
25927
26023
  background-color: var(--ni-private-tooltip-background-color);
@@ -29558,13 +29654,10 @@ Instead styling against the role which is more general and likely a better appro
29558
29654
  attr({
29559
29655
  attribute: 'color-scale-mode'
29560
29656
  })
29561
- ], WaferMap.prototype, "canvas", void 0);
29657
+ ], WaferMap.prototype, "colorScaleMode", void 0);
29562
29658
  __decorate$1([
29563
29659
  observable
29564
29660
  ], WaferMap.prototype, "canvasSideLength", void 0);
29565
- __decorate$1([
29566
- observable
29567
- ], WaferMap.prototype, "colorScaleMode", void 0);
29568
29661
  __decorate$1([
29569
29662
  observable
29570
29663
  ], WaferMap.prototype, "highlightedValues", void 0);