@ni/nimble-components 20.1.22 → 20.2.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.
@@ -16288,7 +16288,7 @@
16288
16288
 
16289
16289
  /**
16290
16290
  * Do not edit directly
16291
- * Generated on Fri, 01 Sep 2023 07:07:38 GMT
16291
+ * Generated on Fri, 01 Sep 2023 19:18:16 GMT
16292
16292
  */
16293
16293
 
16294
16294
  const Information100DarkUi = "#a46eff";
@@ -16679,6 +16679,45 @@
16679
16679
  }
16680
16680
  `;
16681
16681
 
16682
+ /**
16683
+ * Observable class to subscribe to changes in the page's lang attribute
16684
+ */
16685
+ class DocumentElementLang {
16686
+ constructor() {
16687
+ this.lang = document.documentElement.lang;
16688
+ const observer = new MutationObserver(mutations => {
16689
+ for (const mutation of mutations) {
16690
+ if (mutation.type === 'attributes'
16691
+ && mutation.attributeName === 'lang') {
16692
+ this.lang = mutation.target.lang;
16693
+ }
16694
+ }
16695
+ });
16696
+ observer.observe(document.documentElement, {
16697
+ attributeFilter: ['lang']
16698
+ });
16699
+ }
16700
+ }
16701
+ __decorate$1([
16702
+ observable
16703
+ ], DocumentElementLang.prototype, "lang", void 0);
16704
+ const documentElementLang = new DocumentElementLang();
16705
+
16706
+ function isValidLang(value) {
16707
+ try {
16708
+ // We are relying on the Locale constructor to validate the value
16709
+ // eslint-disable-next-line no-new
16710
+ new Intl.Locale(value);
16711
+ return true;
16712
+ }
16713
+ catch (e) {
16714
+ return false;
16715
+ }
16716
+ }
16717
+ const lang$1 = DesignToken.create({
16718
+ name: 'lang',
16719
+ cssCustomPropertyName: null
16720
+ }).withDefault(() => (isValidLang(documentElementLang.lang) ? documentElementLang.lang : 'en-US'));
16682
16721
  // Not represented as a CSS Custom Property, instead available
16683
16722
  // as an attribute of theme provider.
16684
16723
  const direction = DesignToken.create({
@@ -16697,8 +16736,31 @@
16697
16736
  class ThemeProvider extends FoundationElement {
16698
16737
  constructor() {
16699
16738
  super(...arguments);
16700
- this.direction = Direction.ltr;
16701
16739
  this.theme = Theme.light;
16740
+ this.langIsInvalid = false;
16741
+ }
16742
+ get validity() {
16743
+ return {
16744
+ invalidLang: this.langIsInvalid
16745
+ };
16746
+ }
16747
+ checkValidity() {
16748
+ return !this.langIsInvalid;
16749
+ }
16750
+ langChanged(_prev, next) {
16751
+ if (next === null || next === undefined) {
16752
+ lang$1.deleteValueFor(this);
16753
+ this.langIsInvalid = false;
16754
+ return;
16755
+ }
16756
+ if (isValidLang(next)) {
16757
+ lang$1.setValueFor(this, next);
16758
+ this.langIsInvalid = false;
16759
+ }
16760
+ else {
16761
+ lang$1.deleteValueFor(this);
16762
+ this.langIsInvalid = true;
16763
+ }
16702
16764
  }
16703
16765
  directionChanged(_prev, next) {
16704
16766
  if (next !== undefined && next !== null) {
@@ -16718,14 +16780,13 @@
16718
16780
  }
16719
16781
  }
16720
16782
  __decorate$1([
16721
- attr({
16722
- attribute: 'direction'
16723
- })
16783
+ attr()
16784
+ ], ThemeProvider.prototype, "lang", void 0);
16785
+ __decorate$1([
16786
+ attr()
16724
16787
  ], ThemeProvider.prototype, "direction", void 0);
16725
16788
  __decorate$1([
16726
- attr({
16727
- attribute: 'theme'
16728
- })
16789
+ attr()
16729
16790
  ], ThemeProvider.prototype, "theme", void 0);
16730
16791
  const nimbleDesignSystemProvider = ThemeProvider.compose({
16731
16792
  baseName: 'theme-provider',
@@ -65148,11 +65209,21 @@ img.ProseMirror-separator {
65148
65209
  super(...arguments);
65149
65210
  /** @internal */
65150
65211
  this.validator = new TableColumnDateTextValidator(this.columnInternals);
65212
+ this.langSubscriber = {
65213
+ handleChange: () => {
65214
+ this.updateColumnConfig();
65215
+ }
65216
+ };
65151
65217
  }
65152
65218
  connectedCallback() {
65153
65219
  super.connectedCallback();
65220
+ lang$1.subscribe(this.langSubscriber, this);
65154
65221
  this.updateColumnConfig();
65155
65222
  }
65223
+ disconnectedCallback() {
65224
+ super.disconnectedCallback();
65225
+ lang$1.unsubscribe(this.langSubscriber, this);
65226
+ }
65156
65227
  get validity() {
65157
65228
  return this.validator.getValidity();
65158
65229
  }
@@ -65251,7 +65322,7 @@ img.ProseMirror-separator {
65251
65322
  options = this.getCustomFormattingOptions();
65252
65323
  }
65253
65324
  try {
65254
- return new Intl.DateTimeFormat(undefined, options);
65325
+ return new Intl.DateTimeFormat(lang$1.getValueFor(this), options);
65255
65326
  }
65256
65327
  catch (e) {
65257
65328
  return undefined;