@ni/nimble-components 20.10.0 → 20.10.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.
- package/dist/all-components-bundle.js +186 -1
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +398 -375
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/all-components.d.ts +1 -0
- package/dist/esm/all-components.js +1 -0
- package/dist/esm/all-components.js.map +1 -1
- package/package.json +1 -1
|
@@ -16288,7 +16288,7 @@
|
|
|
16288
16288
|
|
|
16289
16289
|
/**
|
|
16290
16290
|
* Do not edit directly
|
|
16291
|
-
* Generated on
|
|
16291
|
+
* Generated on Thu, 26 Oct 2023 00:07:00 GMT
|
|
16292
16292
|
*/
|
|
16293
16293
|
|
|
16294
16294
|
const Information100DarkUi = "#a46eff";
|
|
@@ -68205,6 +68205,191 @@ img.ProseMirror-separator {
|
|
|
68205
68205
|
.register(nimbleTableColumnDateText());
|
|
68206
68206
|
DesignSystem.tagFor(TableColumnDateText);
|
|
68207
68207
|
|
|
68208
|
+
/**
|
|
68209
|
+
* A cell view for displaying duration fields as text
|
|
68210
|
+
*/
|
|
68211
|
+
class TableColumnDurationTextCellView extends TableColumnTextCellViewBase {
|
|
68212
|
+
columnConfigChanged() {
|
|
68213
|
+
this.updateText();
|
|
68214
|
+
}
|
|
68215
|
+
cellRecordChanged() {
|
|
68216
|
+
this.updateText();
|
|
68217
|
+
}
|
|
68218
|
+
updateText() {
|
|
68219
|
+
this.text = this.columnConfig?.formatter.format(this.cellRecord?.value) ?? '';
|
|
68220
|
+
}
|
|
68221
|
+
}
|
|
68222
|
+
const durationTextCellView = TableColumnDurationTextCellView.compose({
|
|
68223
|
+
baseName: 'table-column-duration-text-cell-view',
|
|
68224
|
+
template: template$8,
|
|
68225
|
+
styles: styles$a
|
|
68226
|
+
});
|
|
68227
|
+
DesignSystem.getOrCreate()
|
|
68228
|
+
.withPrefix('nimble')
|
|
68229
|
+
.register(durationTextCellView());
|
|
68230
|
+
const tableColumnDurationTextCellViewTag = DesignSystem.tagFor(TableColumnDurationTextCellView);
|
|
68231
|
+
|
|
68232
|
+
/**
|
|
68233
|
+
* A class for formatting a numeric value in the unit of milliseconds into a display value representing its
|
|
68234
|
+
* days, hours, minutes, and seconds.
|
|
68235
|
+
*/
|
|
68236
|
+
class DurationFormatter {
|
|
68237
|
+
constructor(lang) {
|
|
68238
|
+
this.lang = lang;
|
|
68239
|
+
this.daysFormatter = new Intl.NumberFormat(this.lang, {
|
|
68240
|
+
style: 'unit',
|
|
68241
|
+
unit: 'day'
|
|
68242
|
+
});
|
|
68243
|
+
this.hoursFormatter = new Intl.NumberFormat(this.lang, {
|
|
68244
|
+
style: 'unit',
|
|
68245
|
+
unit: 'hour'
|
|
68246
|
+
});
|
|
68247
|
+
this.minutesFormatter = new Intl.NumberFormat(this.lang, {
|
|
68248
|
+
style: 'unit',
|
|
68249
|
+
unit: 'minute'
|
|
68250
|
+
});
|
|
68251
|
+
this.secondsFormatter = new Intl.NumberFormat(this.lang, {
|
|
68252
|
+
style: 'unit',
|
|
68253
|
+
unit: 'second'
|
|
68254
|
+
});
|
|
68255
|
+
this.scientificSecondsFormatter = new Intl.NumberFormat(this.lang, {
|
|
68256
|
+
style: 'unit',
|
|
68257
|
+
unit: 'second',
|
|
68258
|
+
notation: 'scientific',
|
|
68259
|
+
maximumFractionDigits: 3
|
|
68260
|
+
});
|
|
68261
|
+
}
|
|
68262
|
+
format(milliseconds) {
|
|
68263
|
+
if (typeof milliseconds !== 'number'
|
|
68264
|
+
|| milliseconds < 0
|
|
68265
|
+
|| !Number.isFinite(milliseconds)) {
|
|
68266
|
+
return '';
|
|
68267
|
+
}
|
|
68268
|
+
const result = [];
|
|
68269
|
+
const millisecondsPerSecond = 1000;
|
|
68270
|
+
const millisecondsPerMinute = millisecondsPerSecond * 60;
|
|
68271
|
+
const millisecondsPerHour = millisecondsPerMinute * 60;
|
|
68272
|
+
const millisecondsPerDay = millisecondsPerHour * 24;
|
|
68273
|
+
const fractionalDays = milliseconds / millisecondsPerDay;
|
|
68274
|
+
const maximumDays = 999;
|
|
68275
|
+
let remainingTime = milliseconds;
|
|
68276
|
+
const days = Math.floor(fractionalDays);
|
|
68277
|
+
if (days <= maximumDays && days > 0) {
|
|
68278
|
+
const formattedDays = this.daysFormatter.format(days);
|
|
68279
|
+
result.push(formattedDays);
|
|
68280
|
+
remainingTime -= days * millisecondsPerDay;
|
|
68281
|
+
}
|
|
68282
|
+
else if (days > maximumDays) {
|
|
68283
|
+
return this.scientificSecondsFormatter.format(milliseconds / millisecondsPerSecond);
|
|
68284
|
+
}
|
|
68285
|
+
const hours = Math.floor((milliseconds / millisecondsPerHour) % 24);
|
|
68286
|
+
remainingTime -= hours * millisecondsPerHour;
|
|
68287
|
+
if (hours) {
|
|
68288
|
+
const formattedHours = this.hoursFormatter.format(hours);
|
|
68289
|
+
result.push(formattedHours);
|
|
68290
|
+
}
|
|
68291
|
+
const minutes = Math.floor((milliseconds / millisecondsPerMinute) % 60);
|
|
68292
|
+
remainingTime -= minutes * millisecondsPerMinute;
|
|
68293
|
+
if (minutes) {
|
|
68294
|
+
const formattedMinutes = this.minutesFormatter.format(minutes);
|
|
68295
|
+
result.push(formattedMinutes);
|
|
68296
|
+
}
|
|
68297
|
+
const valueInSeconds = remainingTime / millisecondsPerSecond;
|
|
68298
|
+
// if -0, coerce to 0
|
|
68299
|
+
const seconds = valueInSeconds === 0 ? 0 : valueInSeconds % 60;
|
|
68300
|
+
if (milliseconds < 1 && valueInSeconds !== 0) {
|
|
68301
|
+
return this.scientificSecondsFormatter.format(valueInSeconds);
|
|
68302
|
+
}
|
|
68303
|
+
if (seconds >= 0.0005 || (seconds === 0 && result.length === 0)) {
|
|
68304
|
+
const formattedSeconds = this.secondsFormatter.format(seconds);
|
|
68305
|
+
result.push(formattedSeconds);
|
|
68306
|
+
}
|
|
68307
|
+
return result.join(', ');
|
|
68308
|
+
}
|
|
68309
|
+
}
|
|
68310
|
+
|
|
68311
|
+
/**
|
|
68312
|
+
* The group header view for displaying duration fields as text.
|
|
68313
|
+
*/
|
|
68314
|
+
class TableColumnDurationTextGroupHeaderView extends TableColumnTextGroupHeaderViewBase {
|
|
68315
|
+
columnConfigChanged() {
|
|
68316
|
+
this.updateText();
|
|
68317
|
+
}
|
|
68318
|
+
groupHeaderValueChanged() {
|
|
68319
|
+
this.updateText();
|
|
68320
|
+
}
|
|
68321
|
+
updateText() {
|
|
68322
|
+
if (this.columnConfig) {
|
|
68323
|
+
this.text = this.columnConfig.formatter.format(this.groupHeaderValue);
|
|
68324
|
+
}
|
|
68325
|
+
else {
|
|
68326
|
+
this.text = '';
|
|
68327
|
+
}
|
|
68328
|
+
}
|
|
68329
|
+
}
|
|
68330
|
+
const tableColumnDurationTextGroupHeaderView = TableColumnDurationTextGroupHeaderView.compose({
|
|
68331
|
+
baseName: 'table-column-duration-text-group-header-view',
|
|
68332
|
+
template: template$9,
|
|
68333
|
+
styles: styles$b
|
|
68334
|
+
});
|
|
68335
|
+
DesignSystem.getOrCreate()
|
|
68336
|
+
.withPrefix('nimble')
|
|
68337
|
+
.register(tableColumnDurationTextGroupHeaderView());
|
|
68338
|
+
const tableColumnDurationTextGroupHeaderViewTag = DesignSystem.tagFor(TableColumnDurationTextGroupHeaderView);
|
|
68339
|
+
|
|
68340
|
+
/**
|
|
68341
|
+
* The table column for displaying a duration value as text.
|
|
68342
|
+
*/
|
|
68343
|
+
class TableColumnDurationText extends TableColumnTextBase {
|
|
68344
|
+
constructor() {
|
|
68345
|
+
super(...arguments);
|
|
68346
|
+
this.langSubscriber = {
|
|
68347
|
+
handleChange: () => {
|
|
68348
|
+
this.updateColumnConfig();
|
|
68349
|
+
}
|
|
68350
|
+
};
|
|
68351
|
+
}
|
|
68352
|
+
connectedCallback() {
|
|
68353
|
+
super.connectedCallback();
|
|
68354
|
+
lang$1.subscribe(this.langSubscriber, this);
|
|
68355
|
+
this.updateColumnConfig();
|
|
68356
|
+
}
|
|
68357
|
+
disconnectedCallback() {
|
|
68358
|
+
super.disconnectedCallback();
|
|
68359
|
+
lang$1.unsubscribe(this.langSubscriber, this);
|
|
68360
|
+
}
|
|
68361
|
+
getColumnInternalsOptions() {
|
|
68362
|
+
return {
|
|
68363
|
+
cellRecordFieldNames: ['value'],
|
|
68364
|
+
cellViewTag: tableColumnDurationTextCellViewTag,
|
|
68365
|
+
groupHeaderViewTag: tableColumnDurationTextGroupHeaderViewTag,
|
|
68366
|
+
delegatedEvents: [],
|
|
68367
|
+
sortOperation: TableColumnSortOperation.basic
|
|
68368
|
+
};
|
|
68369
|
+
}
|
|
68370
|
+
updateColumnConfig() {
|
|
68371
|
+
const formatter = new DurationFormatter(lang$1.getValueFor(this));
|
|
68372
|
+
if (formatter) {
|
|
68373
|
+
const columnConfig = {
|
|
68374
|
+
formatter
|
|
68375
|
+
};
|
|
68376
|
+
this.columnInternals.columnConfig = columnConfig;
|
|
68377
|
+
}
|
|
68378
|
+
else {
|
|
68379
|
+
this.columnInternals.columnConfig = undefined;
|
|
68380
|
+
}
|
|
68381
|
+
}
|
|
68382
|
+
}
|
|
68383
|
+
const nimbleTableColumnDurationText = TableColumnDurationText.compose({
|
|
68384
|
+
baseName: 'table-column-duration-text',
|
|
68385
|
+
template: template$b,
|
|
68386
|
+
styles: styles$d
|
|
68387
|
+
});
|
|
68388
|
+
DesignSystem.getOrCreate()
|
|
68389
|
+
.withPrefix('nimble')
|
|
68390
|
+
.register(nimbleTableColumnDurationText());
|
|
68391
|
+
DesignSystem.tagFor(TableColumnDurationText);
|
|
68392
|
+
|
|
68208
68393
|
/**
|
|
68209
68394
|
* Converts a Mapping key (which is a string when configured in HTML) to the
|
|
68210
68395
|
* given keyType. The converted value can then be used to compare against
|