@ni/nimble-components 20.1.11 → 20.1.12

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 Fri, 18 Aug 2023 11:17:54 GMT
16291
+ * Generated on Mon, 21 Aug 2023 22:22:53 GMT
16292
16292
  */
16293
16293
 
16294
16294
  const Information100DarkUi = "#a46eff";
@@ -63904,6 +63904,416 @@ img.ProseMirror-separator {
63904
63904
  .register(nimbleTableColumnAnchor());
63905
63905
  DesignSystem.tagFor(TableColumnAnchor);
63906
63906
 
63907
+ /**
63908
+ * The base class for table columns that display fields of any type as text.
63909
+ */
63910
+ class TableColumnTextBase extends mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(TableColumn)) {
63911
+ fieldNameChanged() {
63912
+ this.columnInternals.dataRecordFieldNames = [this.fieldName];
63913
+ this.columnInternals.operandDataRecordFieldName = this.fieldName;
63914
+ }
63915
+ }
63916
+ __decorate$1([
63917
+ attr({ attribute: 'field-name' })
63918
+ ], TableColumnTextBase.prototype, "fieldName", void 0);
63919
+
63920
+ function formatNumericDate(formatter, date) {
63921
+ if (typeof date === 'number') {
63922
+ try {
63923
+ return formatter.format(date);
63924
+ }
63925
+ catch (e) {
63926
+ return '';
63927
+ }
63928
+ }
63929
+ else {
63930
+ return '';
63931
+ }
63932
+ }
63933
+
63934
+ /**
63935
+ * The group header view for displaying date/time fields as text.
63936
+ */
63937
+ class TableColumnDateTextGroupHeaderView extends TableColumnTextGroupHeaderViewBase {
63938
+ columnConfigChanged() {
63939
+ this.updateText();
63940
+ }
63941
+ groupHeaderValueChanged() {
63942
+ this.updateText();
63943
+ }
63944
+ updateText() {
63945
+ if (this.columnConfig?.formatter) {
63946
+ this.text = formatNumericDate(this.columnConfig.formatter, this.groupHeaderValue);
63947
+ }
63948
+ else {
63949
+ this.text = '';
63950
+ }
63951
+ }
63952
+ }
63953
+ const tableColumnDateTextGroupHeaderView = TableColumnDateTextGroupHeaderView.compose({
63954
+ baseName: 'table-column-date-text-group-header-view',
63955
+ template: template$7,
63956
+ styles: styles$a
63957
+ });
63958
+ DesignSystem.getOrCreate()
63959
+ .withPrefix('nimble')
63960
+ .register(tableColumnDateTextGroupHeaderView());
63961
+ const tableColumnDateTextGroupHeaderViewTag = DesignSystem.tagFor(TableColumnDateTextGroupHeaderView);
63962
+
63963
+ const template$6 = html `
63964
+ <span
63965
+ ${overflow('hasOverflow')}
63966
+ title=${x => (x.hasOverflow && x.text ? x.text : null)}
63967
+ >
63968
+ ${x => x.text}
63969
+ </span>
63970
+ `;
63971
+
63972
+ const styles$9 = css `
63973
+ span {
63974
+ font: ${bodyFont};
63975
+ color: ${bodyFontColor};
63976
+ white-space: nowrap;
63977
+ overflow: hidden;
63978
+ text-overflow: ellipsis;
63979
+ }
63980
+ `;
63981
+
63982
+ /**
63983
+ * The cell view base class for displaying fields of any type as text.
63984
+ */
63985
+ class TableColumnTextCellViewBase extends TableCellView {
63986
+ constructor() {
63987
+ super(...arguments);
63988
+ /** @internal */
63989
+ this.hasOverflow = false;
63990
+ /**
63991
+ * Text to render in the cell.
63992
+ */
63993
+ this.text = '';
63994
+ }
63995
+ }
63996
+ __decorate$1([
63997
+ observable
63998
+ ], TableColumnTextCellViewBase.prototype, "hasOverflow", void 0);
63999
+ __decorate$1([
64000
+ observable
64001
+ ], TableColumnTextCellViewBase.prototype, "text", void 0);
64002
+
64003
+ /**
64004
+ * A cell view for displaying date/time fields as text
64005
+ */
64006
+ class TableColumnDateTextCellView extends TableColumnTextCellViewBase {
64007
+ columnConfigChanged() {
64008
+ this.updateText();
64009
+ }
64010
+ cellRecordChanged() {
64011
+ this.updateText();
64012
+ }
64013
+ updateText() {
64014
+ if (this.columnConfig?.formatter) {
64015
+ this.text = formatNumericDate(this.columnConfig.formatter, this.cellRecord?.value);
64016
+ }
64017
+ else {
64018
+ this.text = '';
64019
+ }
64020
+ }
64021
+ }
64022
+ const dateTextCellView = TableColumnDateTextCellView.compose({
64023
+ baseName: 'table-column-date-text-cell-view',
64024
+ template: template$6,
64025
+ styles: styles$9
64026
+ });
64027
+ DesignSystem.getOrCreate().withPrefix('nimble').register(dateTextCellView());
64028
+ const tableColumnDateTextCellViewTag = DesignSystem.tagFor(TableColumnDateTextCellView);
64029
+
64030
+ /**
64031
+ * Generic Validator Utility extends Tracker Utility for validation purposes
64032
+ */
64033
+ class Validator extends Tracker {
64034
+ isValid() {
64035
+ return this.noneTracked();
64036
+ }
64037
+ getValidationFlags() {
64038
+ return this.getTrackedItems();
64039
+ }
64040
+ }
64041
+
64042
+ /**
64043
+ * Base column validator
64044
+ */
64045
+ class ColumnValidator extends Validator {
64046
+ constructor(columnInternals, configValidityKeys) {
64047
+ super(configValidityKeys);
64048
+ this.columnInternals = columnInternals;
64049
+ }
64050
+ /**
64051
+ * @returns whether the entire column configuration is valid
64052
+ */
64053
+ isValidColumn() {
64054
+ return this.isValid();
64055
+ }
64056
+ /**
64057
+ * @returns an object containing flags for various ways the configuation can be invalid
64058
+ */
64059
+ getValidity() {
64060
+ return this.getValidationFlags();
64061
+ }
64062
+ /**
64063
+ * Sets a particular validity condition flag's value, e.g. "hasInvalidFooValue" = true
64064
+ */
64065
+ setConditionValue(name, isInvalid) {
64066
+ if (isInvalid) {
64067
+ this.track(name);
64068
+ }
64069
+ else {
64070
+ this.untrack(name);
64071
+ }
64072
+ this.updateColumnInternalsFlag();
64073
+ }
64074
+ updateColumnInternalsFlag() {
64075
+ this.columnInternals.validConfiguration = this.isValid();
64076
+ }
64077
+ }
64078
+
64079
+ const dateTextValidityFlagNames = ['invalidCustomOptionsCombination'];
64080
+ /**
64081
+ * Validator for TableColumnDateText.
64082
+ */
64083
+ class TableColumnDateTextValidator extends ColumnValidator {
64084
+ constructor(columnInternals) {
64085
+ super(columnInternals, dateTextValidityFlagNames);
64086
+ }
64087
+ setCustomOptionsValidity(valid) {
64088
+ this.setConditionValue('invalidCustomOptionsCombination', !valid);
64089
+ }
64090
+ }
64091
+
64092
+ // Should be used for attributes that are optional booleans, where true, false, and undefined all
64093
+ // have separate meanings and must have distinct representations.
64094
+ const optionalBooleanConverter = {
64095
+ toView(value) {
64096
+ return typeof value === 'boolean' ? value.toString() : null;
64097
+ },
64098
+ fromView(value) {
64099
+ if (value === 'true' || value === true) {
64100
+ return true;
64101
+ }
64102
+ if (value === 'false' || value === false) {
64103
+ return false;
64104
+ }
64105
+ return undefined;
64106
+ }
64107
+ };
64108
+
64109
+ /**
64110
+ * The table column for displaying dates/times as text.
64111
+ */
64112
+ class TableColumnDateText extends TableColumnTextBase {
64113
+ constructor() {
64114
+ super(...arguments);
64115
+ /** @internal */
64116
+ this.validator = new TableColumnDateTextValidator(this.columnInternals);
64117
+ }
64118
+ connectedCallback() {
64119
+ super.connectedCallback();
64120
+ this.updateColumnConfig();
64121
+ }
64122
+ get validity() {
64123
+ return this.validator.getValidity();
64124
+ }
64125
+ getColumnInternalsOptions() {
64126
+ return {
64127
+ cellRecordFieldNames: ['value'],
64128
+ cellViewTag: tableColumnDateTextCellViewTag,
64129
+ groupHeaderViewTag: tableColumnDateTextGroupHeaderViewTag,
64130
+ delegatedEvents: [],
64131
+ sortOperation: TableColumnSortOperation.basic
64132
+ };
64133
+ }
64134
+ formatChanged() {
64135
+ this.updateColumnConfig();
64136
+ }
64137
+ customLocaleMatcherChanged() {
64138
+ this.updateColumnConfig();
64139
+ }
64140
+ customWeekdayChanged() {
64141
+ this.updateColumnConfig();
64142
+ }
64143
+ customEraChanged() {
64144
+ this.updateColumnConfig();
64145
+ }
64146
+ customYearChanged() {
64147
+ this.updateColumnConfig();
64148
+ }
64149
+ customMonthChanged() {
64150
+ this.updateColumnConfig();
64151
+ }
64152
+ customDayChanged() {
64153
+ this.updateColumnConfig();
64154
+ }
64155
+ customHourChanged() {
64156
+ this.updateColumnConfig();
64157
+ }
64158
+ customMinuteChanged() {
64159
+ this.updateColumnConfig();
64160
+ }
64161
+ customSecondChanged() {
64162
+ this.updateColumnConfig();
64163
+ }
64164
+ customTimeZoneNameChanged() {
64165
+ this.updateColumnConfig();
64166
+ }
64167
+ customFormatMatcherChanged() {
64168
+ this.updateColumnConfig();
64169
+ }
64170
+ customHour12Changed() {
64171
+ this.updateColumnConfig();
64172
+ }
64173
+ customTimeZoneChanged() {
64174
+ this.updateColumnConfig();
64175
+ }
64176
+ customCalendarChanged() {
64177
+ this.updateColumnConfig();
64178
+ }
64179
+ customDayPeriodChanged() {
64180
+ this.updateColumnConfig();
64181
+ }
64182
+ customNumberingSystemChanged() {
64183
+ this.updateColumnConfig();
64184
+ }
64185
+ customDateStyleChanged() {
64186
+ this.updateColumnConfig();
64187
+ }
64188
+ customTimeStyleChanged() {
64189
+ this.updateColumnConfig();
64190
+ }
64191
+ customHourCycleChanged() {
64192
+ this.updateColumnConfig();
64193
+ }
64194
+ updateColumnConfig() {
64195
+ const columnConfig = {
64196
+ formatter: this.createFormatter()
64197
+ };
64198
+ this.columnInternals.columnConfig = columnConfig;
64199
+ this.validator.setCustomOptionsValidity(columnConfig.formatter !== undefined);
64200
+ }
64201
+ createFormatter() {
64202
+ let options;
64203
+ if (!this.format) {
64204
+ options = {
64205
+ dateStyle: 'medium',
64206
+ timeStyle: 'medium'
64207
+ };
64208
+ }
64209
+ else {
64210
+ options = this.getCustomFormattingOptions();
64211
+ }
64212
+ try {
64213
+ return new Intl.DateTimeFormat(undefined, options);
64214
+ }
64215
+ catch (e) {
64216
+ return undefined;
64217
+ }
64218
+ }
64219
+ getCustomFormattingOptions() {
64220
+ // There's a FAST bug (https://github.com/microsoft/fast/issues/6630) where removing
64221
+ // attributes sets their values to null instead of undefined. To work around this,
64222
+ // translate null values to undefined.
64223
+ const options = {
64224
+ localeMatcher: this.customLocaleMatcher ?? undefined,
64225
+ weekday: this.customWeekday ?? undefined,
64226
+ era: this.customEra ?? undefined,
64227
+ year: this.customYear ?? undefined,
64228
+ month: this.customMonth ?? undefined,
64229
+ day: this.customDay ?? undefined,
64230
+ hour: this.customHour ?? undefined,
64231
+ minute: this.customMinute ?? undefined,
64232
+ second: this.customSecond ?? undefined,
64233
+ timeZoneName: this.customTimeZoneName ?? undefined,
64234
+ formatMatcher: this.customFormatMatcher ?? undefined,
64235
+ hour12: this.customHour12 ?? undefined,
64236
+ timeZone: this.customTimeZone ?? undefined,
64237
+ calendar: this.customCalendar ?? undefined,
64238
+ dayPeriod: this.customDayPeriod ?? undefined,
64239
+ numberingSystem: this.customNumberingSystem ?? undefined,
64240
+ dateStyle: this.customDateStyle ?? undefined,
64241
+ timeStyle: this.customTimeStyle ?? undefined,
64242
+ hourCycle: this.customHourCycle ?? undefined
64243
+ };
64244
+ return options;
64245
+ }
64246
+ }
64247
+ __decorate$1([
64248
+ attr
64249
+ ], TableColumnDateText.prototype, "format", void 0);
64250
+ __decorate$1([
64251
+ attr({ attribute: 'custom-locale-matcher' })
64252
+ ], TableColumnDateText.prototype, "customLocaleMatcher", void 0);
64253
+ __decorate$1([
64254
+ attr({ attribute: 'custom-weekday' })
64255
+ ], TableColumnDateText.prototype, "customWeekday", void 0);
64256
+ __decorate$1([
64257
+ attr({ attribute: 'custom-era' })
64258
+ ], TableColumnDateText.prototype, "customEra", void 0);
64259
+ __decorate$1([
64260
+ attr({ attribute: 'custom-year' })
64261
+ ], TableColumnDateText.prototype, "customYear", void 0);
64262
+ __decorate$1([
64263
+ attr({ attribute: 'custom-month' })
64264
+ ], TableColumnDateText.prototype, "customMonth", void 0);
64265
+ __decorate$1([
64266
+ attr({ attribute: 'custom-day' })
64267
+ ], TableColumnDateText.prototype, "customDay", void 0);
64268
+ __decorate$1([
64269
+ attr({ attribute: 'custom-hour' })
64270
+ ], TableColumnDateText.prototype, "customHour", void 0);
64271
+ __decorate$1([
64272
+ attr({ attribute: 'custom-minute' })
64273
+ ], TableColumnDateText.prototype, "customMinute", void 0);
64274
+ __decorate$1([
64275
+ attr({ attribute: 'custom-second' })
64276
+ ], TableColumnDateText.prototype, "customSecond", void 0);
64277
+ __decorate$1([
64278
+ attr({ attribute: 'custom-time-zone-name' })
64279
+ ], TableColumnDateText.prototype, "customTimeZoneName", void 0);
64280
+ __decorate$1([
64281
+ attr({ attribute: 'custom-format-matcher' })
64282
+ ], TableColumnDateText.prototype, "customFormatMatcher", void 0);
64283
+ __decorate$1([
64284
+ attr({ attribute: 'custom-hour12', converter: optionalBooleanConverter })
64285
+ ], TableColumnDateText.prototype, "customHour12", void 0);
64286
+ __decorate$1([
64287
+ attr({ attribute: 'custom-time-zone' })
64288
+ ], TableColumnDateText.prototype, "customTimeZone", void 0);
64289
+ __decorate$1([
64290
+ attr({ attribute: 'custom-calendar' })
64291
+ ], TableColumnDateText.prototype, "customCalendar", void 0);
64292
+ __decorate$1([
64293
+ attr({ attribute: 'custom-day-period' })
64294
+ ], TableColumnDateText.prototype, "customDayPeriod", void 0);
64295
+ __decorate$1([
64296
+ attr({ attribute: 'custom-numbering-system' })
64297
+ ], TableColumnDateText.prototype, "customNumberingSystem", void 0);
64298
+ __decorate$1([
64299
+ attr({ attribute: 'custom-date-style' })
64300
+ ], TableColumnDateText.prototype, "customDateStyle", void 0);
64301
+ __decorate$1([
64302
+ attr({ attribute: 'custom-time-style' })
64303
+ ], TableColumnDateText.prototype, "customTimeStyle", void 0);
64304
+ __decorate$1([
64305
+ attr({ attribute: 'custom-hour-cycle' })
64306
+ ], TableColumnDateText.prototype, "customHourCycle", void 0);
64307
+ const nimbleTableColumnDateText = TableColumnDateText.compose({
64308
+ baseName: 'table-column-date-text',
64309
+ template: template$9,
64310
+ styles: styles$c
64311
+ });
64312
+ DesignSystem.getOrCreate()
64313
+ .withPrefix('nimble')
64314
+ .register(nimbleTableColumnDateText());
64315
+ DesignSystem.tagFor(TableColumnDateText);
64316
+
63907
64317
  /**
63908
64318
  * Converts a Mapping key (which is a string when configured in HTML) to the
63909
64319
  * given keyType. The converted value can then be used to compare against
@@ -64011,7 +64421,7 @@ img.ProseMirror-separator {
64011
64421
  attr({ attribute: 'key-type' })
64012
64422
  ], TableColumnEnumBase.prototype, "keyType", void 0);
64013
64423
 
64014
- const styles$9 = css `
64424
+ const styles$8 = css `
64015
64425
  ${styles$c}
64016
64426
 
64017
64427
  slot[name='mapping'] {
@@ -64019,56 +64429,7 @@ img.ProseMirror-separator {
64019
64429
  }
64020
64430
  `;
64021
64431
 
64022
- const template$6 = html `${template$9}<slot ${slotted('mappings')} name="mapping"></slot>`;
64023
-
64024
- /**
64025
- * Generic Validator Utility extends Tracker Utility for validation purposes
64026
- */
64027
- class Validator extends Tracker {
64028
- isValid() {
64029
- return this.noneTracked();
64030
- }
64031
- getValidationFlags() {
64032
- return this.getTrackedItems();
64033
- }
64034
- }
64035
-
64036
- /**
64037
- * Base column validator
64038
- */
64039
- class ColumnValidator extends Validator {
64040
- constructor(columnInternals, configValidityKeys) {
64041
- super(configValidityKeys);
64042
- this.columnInternals = columnInternals;
64043
- }
64044
- /**
64045
- * @returns whether the entire column configuration is valid
64046
- */
64047
- isValidColumn() {
64048
- return this.isValid();
64049
- }
64050
- /**
64051
- * @returns an object containing flags for various ways the configuation can be invalid
64052
- */
64053
- getValidity() {
64054
- return this.getValidationFlags();
64055
- }
64056
- /**
64057
- * Sets a particular validity condition flag's value, e.g. "hasInvalidFooValue" = true
64058
- */
64059
- setConditionValue(name, isInvalid) {
64060
- if (isInvalid) {
64061
- this.track(name);
64062
- }
64063
- else {
64064
- this.untrack(name);
64065
- }
64066
- this.updateColumnInternalsFlag();
64067
- }
64068
- updateColumnInternalsFlag() {
64069
- this.columnInternals.validConfiguration = this.isValid();
64070
- }
64071
- }
64432
+ const template$5 = html `${template$9}<slot ${slotted('mappings')} name="mapping"></slot>`;
64072
64433
 
64073
64434
  const enumBaseValidityFlagNames = [
64074
64435
  'invalidMappingKeyValueForType',
@@ -64131,46 +64492,6 @@ img.ProseMirror-separator {
64131
64492
  }
64132
64493
  }
64133
64494
 
64134
- const styles$8 = css `
64135
- span {
64136
- font: ${bodyFont};
64137
- color: ${bodyFontColor};
64138
- white-space: nowrap;
64139
- overflow: hidden;
64140
- text-overflow: ellipsis;
64141
- }
64142
- `;
64143
-
64144
- const template$5 = html `
64145
- <span
64146
- ${overflow('hasOverflow')}
64147
- title=${x => (x.hasOverflow && x.text ? x.text : null)}
64148
- >
64149
- ${x => x.text}
64150
- </span>
64151
- `;
64152
-
64153
- /**
64154
- * The cell view base class for displaying fields of any type as text.
64155
- */
64156
- class TableColumnTextCellViewBase extends TableCellView {
64157
- constructor() {
64158
- super(...arguments);
64159
- /** @internal */
64160
- this.hasOverflow = false;
64161
- /**
64162
- * Text to render in the cell.
64163
- */
64164
- this.text = '';
64165
- }
64166
- }
64167
- __decorate$1([
64168
- observable
64169
- ], TableColumnTextCellViewBase.prototype, "hasOverflow", void 0);
64170
- __decorate$1([
64171
- observable
64172
- ], TableColumnTextCellViewBase.prototype, "text", void 0);
64173
-
64174
64495
  /**
64175
64496
  * Common state shared across Mapping Config
64176
64497
  */
@@ -64208,8 +64529,8 @@ img.ProseMirror-separator {
64208
64529
  }
64209
64530
  const enumTextCellView = TableColumnEnumTextCellView.compose({
64210
64531
  baseName: 'table-column-enum-text-cell-view',
64211
- template: template$5,
64212
- styles: styles$8
64532
+ template: template$6,
64533
+ styles: styles$9
64213
64534
  });
64214
64535
  DesignSystem.getOrCreate().withPrefix('nimble').register(enumTextCellView());
64215
64536
  const tableColumnEnumTextCellViewTag = DesignSystem.tagFor(TableColumnEnumTextCellView);
@@ -64281,27 +64602,14 @@ img.ProseMirror-separator {
64281
64602
  }
64282
64603
  const nimbleTableColumnEnumText = TableColumnEnumText.compose({
64283
64604
  baseName: 'table-column-enum-text',
64284
- template: template$6,
64285
- styles: styles$9
64605
+ template: template$5,
64606
+ styles: styles$8
64286
64607
  });
64287
64608
  DesignSystem.getOrCreate()
64288
64609
  .withPrefix('nimble')
64289
64610
  .register(nimbleTableColumnEnumText());
64290
64611
  DesignSystem.tagFor(TableColumnEnumText);
64291
64612
 
64292
- /**
64293
- * The base class for table columns that display fields of any type as text.
64294
- */
64295
- class TableColumnTextBase extends mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(TableColumn)) {
64296
- fieldNameChanged() {
64297
- this.columnInternals.dataRecordFieldNames = [this.fieldName];
64298
- this.columnInternals.operandDataRecordFieldName = this.fieldName;
64299
- }
64300
- }
64301
- __decorate$1([
64302
- attr({ attribute: 'field-name' })
64303
- ], TableColumnTextBase.prototype, "fieldName", void 0);
64304
-
64305
64613
  /**
64306
64614
  * A cell view for displaying string fields as text
64307
64615
  */
@@ -64314,8 +64622,8 @@ img.ProseMirror-separator {
64314
64622
  }
64315
64623
  const textCellView = TableColumnTextCellView.compose({
64316
64624
  baseName: 'table-column-text-cell-view',
64317
- template: template$5,
64318
- styles: styles$8
64625
+ template: template$6,
64626
+ styles: styles$9
64319
64627
  });
64320
64628
  DesignSystem.getOrCreate().withPrefix('nimble').register(textCellView());
64321
64629
  const tableColumnTextCellViewTag = DesignSystem.tagFor(TableColumnTextCellView);