@ni/nimble-components 21.0.4 → 21.1.0
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 +300 -132
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +1276 -1265
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/rich-text/base/index.d.ts +19 -3
- package/dist/esm/rich-text/base/index.js +40 -14
- package/dist/esm/rich-text/base/index.js.map +1 -1
- package/dist/esm/rich-text/base/types.d.ts +5 -0
- package/dist/esm/rich-text/base/types.js +2 -0
- package/dist/esm/rich-text/base/types.js.map +1 -0
- package/dist/esm/rich-text/editor/index.d.ts +2 -6
- package/dist/esm/rich-text/editor/index.js +12 -16
- package/dist/esm/rich-text/editor/index.js.map +1 -1
- package/dist/esm/rich-text/models/markdown-parser-mention-configuration.d.ts +0 -1
- package/dist/esm/rich-text/models/markdown-parser-mention-configuration.js +0 -4
- package/dist/esm/rich-text/models/markdown-parser-mention-configuration.js.map +1 -1
- package/dist/esm/rich-text/models/mention-extension-configuration.d.ts +0 -1
- package/dist/esm/rich-text/models/mention-extension-configuration.js +0 -3
- package/dist/esm/rich-text/models/mention-extension-configuration.js.map +1 -1
- package/dist/esm/rich-text/models/rich-text-tracker.d.ts +19 -0
- package/dist/esm/rich-text/models/rich-text-tracker.js +59 -0
- package/dist/esm/rich-text/models/rich-text-tracker.js.map +1 -0
- package/dist/esm/rich-text/models/rich-text-validator.d.ts +15 -0
- package/dist/esm/rich-text/models/rich-text-validator.js +33 -0
- package/dist/esm/rich-text/models/rich-text-validator.js.map +1 -0
- package/dist/esm/table-column/number-text/index.js +9 -23
- package/dist/esm/table-column/number-text/index.js.map +1 -1
- package/dist/esm/table-column/number-text/models/number-text-unit-format.d.ts +23 -0
- package/dist/esm/table-column/number-text/models/number-text-unit-format.js +82 -0
- package/dist/esm/table-column/number-text/models/number-text-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/decimal-unit-format.d.ts +2 -3
- package/dist/esm/utilities/unit-format/default-unit-format.d.ts +6 -2
- package/dist/esm/utilities/unit-format/default-unit-format.js.map +1 -1
- package/package.json +1 -1
|
@@ -16301,7 +16301,7 @@
|
|
|
16301
16301
|
|
|
16302
16302
|
/**
|
|
16303
16303
|
* Do not edit directly
|
|
16304
|
-
* Generated on
|
|
16304
|
+
* Generated on Wed, 31 Jan 2024 20:08:27 GMT
|
|
16305
16305
|
*/
|
|
16306
16306
|
|
|
16307
16307
|
const Information100DarkUi = "#a46eff";
|
|
@@ -52346,10 +52346,6 @@ img.ProseMirror-separator {
|
|
|
52346
52346
|
this.mappingConfigs = mentionInternals.mappingConfigs;
|
|
52347
52347
|
this.viewElement = mentionInternals.viewElement;
|
|
52348
52348
|
}
|
|
52349
|
-
static isObservedMentionInternalsProperty(arg) {
|
|
52350
|
-
return (typeof arg === 'string'
|
|
52351
|
-
&& ['pattern', 'mappingConfigs'].includes(arg));
|
|
52352
|
-
}
|
|
52353
52349
|
isValidMentionHref(mentionHref) {
|
|
52354
52350
|
return this.regexPattern.test(mentionHref);
|
|
52355
52351
|
}
|
|
@@ -52380,6 +52376,150 @@ img.ProseMirror-separator {
|
|
|
52380
52376
|
}
|
|
52381
52377
|
}
|
|
52382
52378
|
|
|
52379
|
+
/**
|
|
52380
|
+
* Generic Tracker which sets or resets provided flags
|
|
52381
|
+
*/
|
|
52382
|
+
class Tracker {
|
|
52383
|
+
constructor(trackedItemsList) {
|
|
52384
|
+
this.trackedItems = {};
|
|
52385
|
+
this.trackedItems = trackedItemsList.reduce((r, key) => {
|
|
52386
|
+
return {
|
|
52387
|
+
...r,
|
|
52388
|
+
[key]: false
|
|
52389
|
+
};
|
|
52390
|
+
}, this.trackedItems);
|
|
52391
|
+
}
|
|
52392
|
+
getTrackedItems() {
|
|
52393
|
+
return { ...this.trackedItems };
|
|
52394
|
+
}
|
|
52395
|
+
isTracked(key) {
|
|
52396
|
+
return this.trackedItems[key];
|
|
52397
|
+
}
|
|
52398
|
+
track(key) {
|
|
52399
|
+
this.trackedItems[key] = true;
|
|
52400
|
+
}
|
|
52401
|
+
untrack(key) {
|
|
52402
|
+
this.trackedItems[key] = false;
|
|
52403
|
+
}
|
|
52404
|
+
trackAll() {
|
|
52405
|
+
this.setAllKeys(true);
|
|
52406
|
+
}
|
|
52407
|
+
untrackAll() {
|
|
52408
|
+
this.setAllKeys(false);
|
|
52409
|
+
}
|
|
52410
|
+
allTracked() {
|
|
52411
|
+
return Object.values(this.trackedItems).every(x => x);
|
|
52412
|
+
}
|
|
52413
|
+
anyTracked() {
|
|
52414
|
+
return Object.values(this.trackedItems).some(x => x);
|
|
52415
|
+
}
|
|
52416
|
+
noneTracked() {
|
|
52417
|
+
return Object.values(this.trackedItems).every(x => !x);
|
|
52418
|
+
}
|
|
52419
|
+
setAllKeys(value) {
|
|
52420
|
+
this.trackedItems = Object.keys(this.trackedItems).reduce((r, key) => {
|
|
52421
|
+
return {
|
|
52422
|
+
...r,
|
|
52423
|
+
[key]: value
|
|
52424
|
+
};
|
|
52425
|
+
}, this.trackedItems);
|
|
52426
|
+
}
|
|
52427
|
+
}
|
|
52428
|
+
|
|
52429
|
+
/**
|
|
52430
|
+
* Generic Update Tracker Utility which extends Tracker Utility with update logic
|
|
52431
|
+
*/
|
|
52432
|
+
class UpdateTracker extends Tracker {
|
|
52433
|
+
}
|
|
52434
|
+
|
|
52435
|
+
const trackedItems$2 = ['pattern', 'mappingConfigs', 'buttonLabel'];
|
|
52436
|
+
/**
|
|
52437
|
+
* Helper class to track what updates are needed to the rich text components based on configuration
|
|
52438
|
+
* changes.
|
|
52439
|
+
*/
|
|
52440
|
+
class RichTextUpdateTracker extends UpdateTracker {
|
|
52441
|
+
constructor(richText) {
|
|
52442
|
+
super(trackedItems$2);
|
|
52443
|
+
this.richText = richText;
|
|
52444
|
+
this.updateQueued = false;
|
|
52445
|
+
}
|
|
52446
|
+
get updatePattern() {
|
|
52447
|
+
return this.isTracked('pattern');
|
|
52448
|
+
}
|
|
52449
|
+
get updateMappingConfigs() {
|
|
52450
|
+
return this.isTracked('mappingConfigs');
|
|
52451
|
+
}
|
|
52452
|
+
get updateButtonLabel() {
|
|
52453
|
+
return this.isTracked('buttonLabel');
|
|
52454
|
+
}
|
|
52455
|
+
trackMentionInternalsPropertyChanged(changedMentionInternalsProperty) {
|
|
52456
|
+
switch (changedMentionInternalsProperty) {
|
|
52457
|
+
case 'mappingConfigs':
|
|
52458
|
+
this.track('mappingConfigs');
|
|
52459
|
+
break;
|
|
52460
|
+
case 'pattern':
|
|
52461
|
+
this.track('pattern');
|
|
52462
|
+
break;
|
|
52463
|
+
case 'buttonLabel':
|
|
52464
|
+
this.track('buttonLabel');
|
|
52465
|
+
break;
|
|
52466
|
+
}
|
|
52467
|
+
this.queueUpdate();
|
|
52468
|
+
}
|
|
52469
|
+
trackMentionElementsInstancesChanged() {
|
|
52470
|
+
this.track('pattern');
|
|
52471
|
+
this.track('mappingConfigs');
|
|
52472
|
+
this.track('buttonLabel');
|
|
52473
|
+
this.queueUpdate();
|
|
52474
|
+
}
|
|
52475
|
+
queueUpdate() {
|
|
52476
|
+
if (!this.richText.$fastController.isConnected) {
|
|
52477
|
+
return;
|
|
52478
|
+
}
|
|
52479
|
+
if (!this.updateQueued) {
|
|
52480
|
+
this.updateQueued = true;
|
|
52481
|
+
DOM.queueUpdate(() => {
|
|
52482
|
+
this.richText.createConfig();
|
|
52483
|
+
this.untrackAll();
|
|
52484
|
+
this.updateQueued = false;
|
|
52485
|
+
});
|
|
52486
|
+
}
|
|
52487
|
+
}
|
|
52488
|
+
}
|
|
52489
|
+
|
|
52490
|
+
/**
|
|
52491
|
+
* Helper class for the nimble rich text components to validate that the configuration
|
|
52492
|
+
* is valid and report which aspects of the configuration are valid or invalid.
|
|
52493
|
+
*/
|
|
52494
|
+
class RichTextValidator {
|
|
52495
|
+
constructor() {
|
|
52496
|
+
this.invalidMentionConfiguration = false;
|
|
52497
|
+
this.duplicateMentionConfiguration = false;
|
|
52498
|
+
}
|
|
52499
|
+
getValidity() {
|
|
52500
|
+
return {
|
|
52501
|
+
invalidMentionConfiguration: this.invalidMentionConfiguration,
|
|
52502
|
+
duplicateMentionConfiguration: this.duplicateMentionConfiguration
|
|
52503
|
+
};
|
|
52504
|
+
}
|
|
52505
|
+
isValid() {
|
|
52506
|
+
return Object.values(this.getValidity()).every(x => x === false);
|
|
52507
|
+
}
|
|
52508
|
+
validate(mentions) {
|
|
52509
|
+
this.validateDuplicateMentionConfigurations(mentions);
|
|
52510
|
+
this.validateMentionConfigurations(mentions);
|
|
52511
|
+
}
|
|
52512
|
+
validateMentionConfigurations(mentions) {
|
|
52513
|
+
this.invalidMentionConfiguration = mentions.some(x => !x.mentionInternals.validConfiguration);
|
|
52514
|
+
return !this.invalidMentionConfiguration;
|
|
52515
|
+
}
|
|
52516
|
+
validateDuplicateMentionConfigurations(mentions) {
|
|
52517
|
+
const mentionChars = mentions.map(mention => mention.mentionInternals.character);
|
|
52518
|
+
this.duplicateMentionConfiguration = mentionChars.length !== new Set(mentionChars).size;
|
|
52519
|
+
return !this.duplicateMentionConfiguration;
|
|
52520
|
+
}
|
|
52521
|
+
}
|
|
52522
|
+
|
|
52383
52523
|
async function waitUntilCustomElementsDefinedAsync(elements) {
|
|
52384
52524
|
const definedElements = elements.map(async (item) => (item.matches(':not(:defined)')
|
|
52385
52525
|
? customElements.whenDefined(item.localName)
|
|
@@ -52401,29 +52541,57 @@ img.ProseMirror-separator {
|
|
|
52401
52541
|
* @internal
|
|
52402
52542
|
*/
|
|
52403
52543
|
this.childItems = [];
|
|
52544
|
+
this.richTextUpdateTracker = new RichTextUpdateTracker(this);
|
|
52545
|
+
this.richTextValidator = new RichTextValidator();
|
|
52546
|
+
}
|
|
52547
|
+
/**
|
|
52548
|
+
* @public
|
|
52549
|
+
*/
|
|
52550
|
+
get validity() {
|
|
52551
|
+
return this.richTextValidator.getValidity();
|
|
52552
|
+
}
|
|
52553
|
+
/**
|
|
52554
|
+
* @public
|
|
52555
|
+
*/
|
|
52556
|
+
checkValidity() {
|
|
52557
|
+
return this.richTextValidator.isValid();
|
|
52404
52558
|
}
|
|
52405
52559
|
/**
|
|
52406
52560
|
* @internal
|
|
52407
52561
|
*/
|
|
52408
52562
|
handleChange(source, args) {
|
|
52409
|
-
if (source instanceof MentionInternals
|
|
52410
|
-
|
|
52411
|
-
this.configuration = this.createConfig();
|
|
52563
|
+
if (source instanceof MentionInternals && typeof args === 'string') {
|
|
52564
|
+
this.richTextUpdateTracker.trackMentionInternalsPropertyChanged(args);
|
|
52412
52565
|
}
|
|
52413
52566
|
}
|
|
52414
|
-
|
|
52415
|
-
|
|
52416
|
-
|
|
52417
|
-
}
|
|
52567
|
+
/**
|
|
52568
|
+
* @internal
|
|
52569
|
+
*/
|
|
52418
52570
|
createConfig() {
|
|
52419
|
-
|
|
52571
|
+
this.validate();
|
|
52572
|
+
if (this.richTextValidator.isValid()) {
|
|
52573
|
+
if (this.richTextUpdateTracker.updateMappingConfigs
|
|
52574
|
+
|| this.richTextUpdateTracker.updatePattern) {
|
|
52575
|
+
this.configuration = new Configuration(this.mentionElements);
|
|
52576
|
+
}
|
|
52577
|
+
}
|
|
52578
|
+
else {
|
|
52579
|
+
this.configuration = undefined;
|
|
52580
|
+
}
|
|
52420
52581
|
}
|
|
52421
|
-
|
|
52422
|
-
|
|
52582
|
+
validate() {
|
|
52583
|
+
this.richTextValidator.validate(this.mentionElements);
|
|
52584
|
+
}
|
|
52585
|
+
childItemsChanged(prev, _next) {
|
|
52586
|
+
if (prev !== undefined) {
|
|
52587
|
+
void this.updateMentionElementsFromChildItems();
|
|
52588
|
+
}
|
|
52423
52589
|
}
|
|
52424
52590
|
async updateMentionElementsFromChildItems() {
|
|
52425
52591
|
await waitUntilCustomElementsDefinedAsync(this.childItems);
|
|
52426
52592
|
this.mentionElements = this.childItems.filter((x) => x instanceof RichTextMention);
|
|
52593
|
+
this.observeMentionInternals();
|
|
52594
|
+
this.richTextUpdateTracker.trackMentionElementsInstancesChanged();
|
|
52427
52595
|
}
|
|
52428
52596
|
observeMentionInternals() {
|
|
52429
52597
|
this.removeMentionInternalsObservers();
|
|
@@ -52443,36 +52611,10 @@ img.ProseMirror-separator {
|
|
|
52443
52611
|
__decorate$1([
|
|
52444
52612
|
observable
|
|
52445
52613
|
], RichText.prototype, "childItems", void 0);
|
|
52446
|
-
__decorate$1([
|
|
52447
|
-
observable
|
|
52448
|
-
], RichText.prototype, "mentionElements", void 0);
|
|
52449
52614
|
__decorate$1([
|
|
52450
52615
|
observable
|
|
52451
52616
|
], RichText.prototype, "configuration", void 0);
|
|
52452
52617
|
|
|
52453
|
-
/**
|
|
52454
|
-
* A configuration object for a Mention extension, to be used by the editor for loading mention plugins in tiptap.
|
|
52455
|
-
* This object maintains the necessary internal values for loading mention extension.
|
|
52456
|
-
*/
|
|
52457
|
-
class MentionExtensionConfiguration {
|
|
52458
|
-
constructor(mentionInternals) {
|
|
52459
|
-
MentionExtensionConfiguration.instance += 1;
|
|
52460
|
-
const key = `${mentionPluginPrefix}${MentionExtensionConfiguration.instance}`;
|
|
52461
|
-
this.name = key;
|
|
52462
|
-
this.key = key;
|
|
52463
|
-
this.viewElement = mentionInternals.viewElement;
|
|
52464
|
-
this.character = mentionInternals.character;
|
|
52465
|
-
this.mappingConfigs = mentionInternals.mappingConfigs;
|
|
52466
|
-
this.iconTemplate = mentionInternals.iconTemplate;
|
|
52467
|
-
this.buttonLabel = mentionInternals.buttonLabel ?? '';
|
|
52468
|
-
this.mentionUpdateEmitter = mentionInternals.mentionUpdateEmitter;
|
|
52469
|
-
}
|
|
52470
|
-
static isObservedMentionInternalsProperty(arg) {
|
|
52471
|
-
return typeof arg === 'string' && ['buttonLabel'].includes(arg);
|
|
52472
|
-
}
|
|
52473
|
-
}
|
|
52474
|
-
MentionExtensionConfiguration.instance = 0;
|
|
52475
|
-
|
|
52476
52618
|
const starInputRegex$1 = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))$/;
|
|
52477
52619
|
const starPasteRegex$1 = /(?:^|\s)((?:\*\*)((?:[^*]+))(?:\*\*))/g;
|
|
52478
52620
|
const underscoreInputRegex$1 = /(?:^|\s)((?:__)((?:[^__]+))(?:__))$/;
|
|
@@ -56317,6 +56459,26 @@ img.ProseMirror-separator {
|
|
|
56317
56459
|
return Fragment.fromArray(updatedNodes);
|
|
56318
56460
|
}
|
|
56319
56461
|
|
|
56462
|
+
/**
|
|
56463
|
+
* A configuration object for a Mention extension, to be used by the editor for loading mention plugins in tiptap.
|
|
56464
|
+
* This object maintains the necessary internal values for loading mention extension.
|
|
56465
|
+
*/
|
|
56466
|
+
class MentionExtensionConfiguration {
|
|
56467
|
+
constructor(mentionInternals) {
|
|
56468
|
+
MentionExtensionConfiguration.instance += 1;
|
|
56469
|
+
const key = `${mentionPluginPrefix}${MentionExtensionConfiguration.instance}`;
|
|
56470
|
+
this.name = key;
|
|
56471
|
+
this.key = key;
|
|
56472
|
+
this.viewElement = mentionInternals.viewElement;
|
|
56473
|
+
this.character = mentionInternals.character;
|
|
56474
|
+
this.mappingConfigs = mentionInternals.mappingConfigs;
|
|
56475
|
+
this.iconTemplate = mentionInternals.iconTemplate;
|
|
56476
|
+
this.buttonLabel = mentionInternals.buttonLabel ?? '';
|
|
56477
|
+
this.mentionUpdateEmitter = mentionInternals.mentionUpdateEmitter;
|
|
56478
|
+
}
|
|
56479
|
+
}
|
|
56480
|
+
MentionExtensionConfiguration.instance = 0;
|
|
56481
|
+
|
|
56320
56482
|
/**
|
|
56321
56483
|
* EditorConfiguration which will hold mentionExtensionConfig for configuring editor's mention extension and RichTextMarkdownSerializer
|
|
56322
56484
|
*/
|
|
@@ -56619,18 +56781,6 @@ img.ProseMirror-separator {
|
|
|
56619
56781
|
});
|
|
56620
56782
|
}
|
|
56621
56783
|
}
|
|
56622
|
-
/**
|
|
56623
|
-
* @internal
|
|
56624
|
-
*/
|
|
56625
|
-
handleChange(source, args) {
|
|
56626
|
-
if (source instanceof MentionInternals
|
|
56627
|
-
&& MentionExtensionConfiguration.isObservedMentionInternalsProperty(args)) {
|
|
56628
|
-
this.configuration = this.createConfig();
|
|
56629
|
-
}
|
|
56630
|
-
else {
|
|
56631
|
-
super.handleChange(source, args);
|
|
56632
|
-
}
|
|
56633
|
-
}
|
|
56634
56784
|
/**
|
|
56635
56785
|
* @internal
|
|
56636
56786
|
*/
|
|
@@ -56641,14 +56791,24 @@ img.ProseMirror-separator {
|
|
|
56641
56791
|
this.mentionListbox?.close();
|
|
56642
56792
|
}
|
|
56643
56793
|
createConfig() {
|
|
56644
|
-
|
|
56794
|
+
this.validate();
|
|
56795
|
+
if (this.richTextValidator.isValid()) {
|
|
56796
|
+
if (this.richTextUpdateTracker.updateButtonLabel
|
|
56797
|
+
|| this.richTextUpdateTracker.updateMappingConfigs
|
|
56798
|
+
|| this.richTextUpdateTracker.updatePattern) {
|
|
56799
|
+
this.configuration = new EditorConfiguration(this.mentionElements);
|
|
56800
|
+
}
|
|
56801
|
+
}
|
|
56802
|
+
else {
|
|
56803
|
+
this.configuration = undefined;
|
|
56804
|
+
}
|
|
56645
56805
|
}
|
|
56646
56806
|
isMentionExtensionConfigUnchanged(prev, next) {
|
|
56647
56807
|
const prevConfigCharacters = prev?.mentionExtensionConfig
|
|
56648
56808
|
.map(config => config.character)
|
|
56649
56809
|
.sort((a, b) => a.localeCompare(b))
|
|
56650
56810
|
.toString();
|
|
56651
|
-
const nextConfigCharacters = next
|
|
56811
|
+
const nextConfigCharacters = next?.mentionExtensionConfig
|
|
56652
56812
|
.map(config => config.character)
|
|
56653
56813
|
.sort((a, b) => a.localeCompare(b))
|
|
56654
56814
|
.toString();
|
|
@@ -63844,62 +64004,6 @@ img.ProseMirror-separator {
|
|
|
63844
64004
|
observable
|
|
63845
64005
|
], TableLayoutManager.prototype, "activeColumnIndex", void 0);
|
|
63846
64006
|
|
|
63847
|
-
/**
|
|
63848
|
-
* Generic Tracker which sets or resets provided flags
|
|
63849
|
-
*/
|
|
63850
|
-
class Tracker {
|
|
63851
|
-
constructor(trackedItemsList) {
|
|
63852
|
-
this.trackedItems = {};
|
|
63853
|
-
this.trackedItems = trackedItemsList.reduce((r, key) => {
|
|
63854
|
-
return {
|
|
63855
|
-
...r,
|
|
63856
|
-
[key]: false
|
|
63857
|
-
};
|
|
63858
|
-
}, this.trackedItems);
|
|
63859
|
-
}
|
|
63860
|
-
getTrackedItems() {
|
|
63861
|
-
return { ...this.trackedItems };
|
|
63862
|
-
}
|
|
63863
|
-
isTracked(key) {
|
|
63864
|
-
return this.trackedItems[key];
|
|
63865
|
-
}
|
|
63866
|
-
track(key) {
|
|
63867
|
-
this.trackedItems[key] = true;
|
|
63868
|
-
}
|
|
63869
|
-
untrack(key) {
|
|
63870
|
-
this.trackedItems[key] = false;
|
|
63871
|
-
}
|
|
63872
|
-
trackAll() {
|
|
63873
|
-
this.setAllKeys(true);
|
|
63874
|
-
}
|
|
63875
|
-
untrackAll() {
|
|
63876
|
-
this.setAllKeys(false);
|
|
63877
|
-
}
|
|
63878
|
-
allTracked() {
|
|
63879
|
-
return Object.values(this.trackedItems).every(x => x);
|
|
63880
|
-
}
|
|
63881
|
-
anyTracked() {
|
|
63882
|
-
return Object.values(this.trackedItems).some(x => x);
|
|
63883
|
-
}
|
|
63884
|
-
noneTracked() {
|
|
63885
|
-
return Object.values(this.trackedItems).every(x => !x);
|
|
63886
|
-
}
|
|
63887
|
-
setAllKeys(value) {
|
|
63888
|
-
this.trackedItems = Object.keys(this.trackedItems).reduce((r, key) => {
|
|
63889
|
-
return {
|
|
63890
|
-
...r,
|
|
63891
|
-
[key]: value
|
|
63892
|
-
};
|
|
63893
|
-
}, this.trackedItems);
|
|
63894
|
-
}
|
|
63895
|
-
}
|
|
63896
|
-
|
|
63897
|
-
/**
|
|
63898
|
-
* Generic Update Tracker Utility which extends Tracker Utility with update logic
|
|
63899
|
-
*/
|
|
63900
|
-
class UpdateTracker extends Tracker {
|
|
63901
|
-
}
|
|
63902
|
-
|
|
63903
64007
|
const isColumnProperty = (changedProperty, ...args) => {
|
|
63904
64008
|
for (const arg of args) {
|
|
63905
64009
|
if (changedProperty === arg) {
|
|
@@ -66988,6 +67092,83 @@ img.ProseMirror-separator {
|
|
|
66988
67092
|
}
|
|
66989
67093
|
}
|
|
66990
67094
|
|
|
67095
|
+
/**
|
|
67096
|
+
* Format for numbers (with optional units) in a number-text table column.
|
|
67097
|
+
*/
|
|
67098
|
+
class NumberTextUnitFormat extends UnitFormat {
|
|
67099
|
+
constructor(locale, options) {
|
|
67100
|
+
super();
|
|
67101
|
+
this._resolvedOptions = this.resolveOptions(options);
|
|
67102
|
+
this.resolvedUnitFormat = this.resolveUnitFormat(locale, this._resolvedOptions);
|
|
67103
|
+
}
|
|
67104
|
+
resolvedOptions() {
|
|
67105
|
+
return { ...this._resolvedOptions };
|
|
67106
|
+
}
|
|
67107
|
+
optionsMatch(targetOptions) {
|
|
67108
|
+
const targetResolvedOptions = this.resolveOptions(targetOptions);
|
|
67109
|
+
return (this._resolvedOptions.decimalDigits
|
|
67110
|
+
=== targetResolvedOptions.decimalDigits
|
|
67111
|
+
&& this._resolvedOptions.decimalMaximumDigits
|
|
67112
|
+
=== targetResolvedOptions.decimalMaximumDigits
|
|
67113
|
+
&& this._resolvedOptions.numberTextFormat
|
|
67114
|
+
=== targetResolvedOptions.numberTextFormat
|
|
67115
|
+
&& this._resolvedOptions.unitScale === targetResolvedOptions.unitScale);
|
|
67116
|
+
}
|
|
67117
|
+
tryFormat(number) {
|
|
67118
|
+
return this.resolvedUnitFormat.format(number);
|
|
67119
|
+
}
|
|
67120
|
+
resolveUnitFormat(locale, options) {
|
|
67121
|
+
const { numberTextFormat, decimalMaximumDigits, decimalDigits, unitScale } = options;
|
|
67122
|
+
if (numberTextFormat === NumberTextFormat.default) {
|
|
67123
|
+
return new DefaultUnitFormat(locale, {
|
|
67124
|
+
unitScale
|
|
67125
|
+
});
|
|
67126
|
+
}
|
|
67127
|
+
if (typeof decimalDigits === 'number') {
|
|
67128
|
+
return new DecimalUnitFormat(locale, {
|
|
67129
|
+
minimumFractionDigits: decimalDigits,
|
|
67130
|
+
maximumFractionDigits: decimalDigits,
|
|
67131
|
+
unitScale
|
|
67132
|
+
});
|
|
67133
|
+
}
|
|
67134
|
+
return new DecimalUnitFormat(locale, {
|
|
67135
|
+
minimumFractionDigits: 0,
|
|
67136
|
+
maximumFractionDigits: decimalMaximumDigits,
|
|
67137
|
+
unitScale
|
|
67138
|
+
});
|
|
67139
|
+
}
|
|
67140
|
+
resolveOptions(options) {
|
|
67141
|
+
if (!options || options.numberTextFormat === NumberTextFormat.default) {
|
|
67142
|
+
return {
|
|
67143
|
+
numberTextFormat: NumberTextFormat.default,
|
|
67144
|
+
decimalDigits: undefined,
|
|
67145
|
+
decimalMaximumDigits: undefined,
|
|
67146
|
+
unitScale: options?.unitScale ?? passthroughUnitScale
|
|
67147
|
+
};
|
|
67148
|
+
}
|
|
67149
|
+
const hasDecimalDigits = typeof options.decimalDigits === 'number';
|
|
67150
|
+
const hasDecimalMaximumDigits = typeof options.decimalMaximumDigits === 'number';
|
|
67151
|
+
if (hasDecimalDigits && hasDecimalMaximumDigits) {
|
|
67152
|
+
throw new Error('decimalDigits and decimalMaximumDigits are mutually exclusive. Do not specify both.');
|
|
67153
|
+
}
|
|
67154
|
+
if (!hasDecimalDigits && !hasDecimalMaximumDigits) {
|
|
67155
|
+
return {
|
|
67156
|
+
numberTextFormat: NumberTextFormat.decimal,
|
|
67157
|
+
decimalDigits: NumberTextUnitFormat.defaultDecimalDigits,
|
|
67158
|
+
decimalMaximumDigits: undefined,
|
|
67159
|
+
unitScale: options.unitScale ?? passthroughUnitScale
|
|
67160
|
+
};
|
|
67161
|
+
}
|
|
67162
|
+
return {
|
|
67163
|
+
numberTextFormat: NumberTextFormat.decimal,
|
|
67164
|
+
decimalDigits: options.decimalDigits,
|
|
67165
|
+
decimalMaximumDigits: options.decimalMaximumDigits,
|
|
67166
|
+
unitScale: options.unitScale ?? passthroughUnitScale
|
|
67167
|
+
};
|
|
67168
|
+
}
|
|
67169
|
+
}
|
|
67170
|
+
NumberTextUnitFormat.defaultDecimalDigits = 2;
|
|
67171
|
+
|
|
66991
67172
|
const numberTextValidityFlagNames = [
|
|
66992
67173
|
'invalidDecimalDigits',
|
|
66993
67174
|
'invalidDecimalMaximumDigits',
|
|
@@ -67048,7 +67229,6 @@ img.ProseMirror-separator {
|
|
|
67048
67229
|
observable
|
|
67049
67230
|
], Unit.prototype, "resolvedUnitScale", void 0);
|
|
67050
67231
|
|
|
67051
|
-
const defaultDecimalDigits = 2;
|
|
67052
67232
|
/**
|
|
67053
67233
|
* The table column for displaying numbers as text.
|
|
67054
67234
|
*/
|
|
@@ -67144,26 +67324,14 @@ img.ProseMirror-separator {
|
|
|
67144
67324
|
}
|
|
67145
67325
|
createFormatter() {
|
|
67146
67326
|
const unitScale = this.unit?.resolvedUnitScale;
|
|
67147
|
-
|
|
67148
|
-
|
|
67149
|
-
|
|
67150
|
-
|
|
67151
|
-
|
|
67152
|
-
|
|
67153
|
-
|
|
67154
|
-
|
|
67155
|
-
return new DecimalUnitFormat(lang.getValueFor(this), {
|
|
67156
|
-
minimumFractionDigits,
|
|
67157
|
-
maximumFractionDigits,
|
|
67158
|
-
unitScale
|
|
67159
|
-
});
|
|
67160
|
-
}
|
|
67161
|
-
default: {
|
|
67162
|
-
return new DefaultUnitFormat(lang.getValueFor(this), {
|
|
67163
|
-
unitScale
|
|
67164
|
-
});
|
|
67165
|
-
}
|
|
67166
|
-
}
|
|
67327
|
+
return new NumberTextUnitFormat(lang.getValueFor(this), {
|
|
67328
|
+
// Attribute values sometimes resolve to either null or undefined
|
|
67329
|
+
// See https://github.com/microsoft/fast/issues/6630
|
|
67330
|
+
numberTextFormat: this.format ?? undefined,
|
|
67331
|
+
decimalDigits: this.decimalDigits ?? undefined,
|
|
67332
|
+
decimalMaximumDigits: this.decimalMaximumDigits ?? undefined,
|
|
67333
|
+
unitScale
|
|
67334
|
+
});
|
|
67167
67335
|
}
|
|
67168
67336
|
determineCellContentAlignment() {
|
|
67169
67337
|
if (this.alignment === NumberTextAlignment.left) {
|