@ni/nimble-components 35.13.2 → 35.14.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.
@@ -19359,7 +19359,7 @@ Defines an interaction area clip-path that leaves out the severity text so it is
19359
19359
  };
19360
19360
  const systemlink16X16 = {
19361
19361
  name: 'systemlink_16_x_16',
19362
- data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M7.357 9.143H4.786V6.79c0-.927.442-1.714 1.262-2.211C6.674 4.2 7.505 4 8.451 4h5.335v2.571H8.69c-.911.124-1.262.548-1.333 1.267z" class="cls-1"/><path d="M8.643 7.857h2.571v2.352c0 .927-.442 1.714-1.262 2.211-.626.38-1.457.58-2.403.58H2.214v-2.571H7.31c.911-.124 1.262-.548 1.333-1.267z" class="cls-1"/></svg>`,
19362
+ data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M7.249 2.55a1.06 1.06 0 0 1 1.498 0 1.06 1.06 0 0 1-.295 1.703v1.86a2.42 2.42 0 0 1 1.672 1.215l1.768-.573q.023-.176.106-.344a1.059 1.059 0 1 1 .176 1.208l-1.768.574a2.42 2.42 0 0 1-.638 1.964l1.093 1.504q.175-.033.36-.005a1.058 1.058 0 1 1-1.095.54l-1.093-1.503a2.43 2.43 0 0 1-2.066 0l-1.093 1.503q.085.155.117.34a1.058 1.058 0 1 1-.852-.875l1.093-1.504a2.42 2.42 0 0 1-.638-1.964l-1.768-.574a1.054 1.054 0 0 1-1.71-.247 1.059 1.059 0 1 1 1.992-.617l1.768.573q.161-.295.41-.547c.358-.358.8-.58 1.262-.668v-1.86a1.06 1.06 0 0 1-.294-1.704Zm2.072 9.704c-.42.148-.865.224-1.323.224s-.904-.076-1.324-.224l.566-.779q.37.094.758.094c.388 0 .512-.033.757-.094zM11.98 8.4l.002.097c0 .886-.288 1.727-.82 2.419l-.566-.778c.274-.43.434-.923.467-1.44l.914-.298Zm-7.046.298c.033.502.189.998.466 1.438l-.566.779A3.97 3.97 0 0 1 4.018 8.4zM6.86 5.644c-.377.15-.731.377-1.035.681q-.1.1-.19.209l-.915-.298q.202-.292.46-.554A3.96 3.96 0 0 1 6.86 4.68v.965Zm2.275-.964a3.96 3.96 0 0 1 2.14 1.556l-.915.298a3.075 3.075 0 0 0-1.224-.89z" class="cls-1"/></svg>`,
19363
19363
  };
19364
19364
  const t16X16 = {
19365
19365
  name: 't_16_x_16',
@@ -81798,27 +81798,13 @@ focus outline in that case.
81798
81798
  return mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(mixinColumnWithPlaceholderAPI(mixinSortableColumnAPI(base))));
81799
81799
  }
81800
81800
 
81801
- function formatNumericDate(formatter, date) {
81802
- if (typeof date === 'number') {
81803
- try {
81804
- return formatter.format(date);
81805
- }
81806
- catch (_e) {
81807
- return '';
81808
- }
81809
- }
81810
- else {
81811
- return '';
81812
- }
81813
- }
81814
-
81815
81801
  /**
81816
81802
  * The group header view for displaying date/time fields as text.
81817
81803
  */
81818
81804
  class TableColumnDateTextGroupHeaderView extends TableColumnTextGroupHeaderViewBase {
81819
81805
  updateText() {
81820
81806
  if (this.columnConfig) {
81821
- this.text = formatNumericDate(this.columnConfig.formatter, this.groupHeaderValue);
81807
+ this.text = this.columnConfig.formatter.format(this.groupHeaderValue);
81822
81808
  }
81823
81809
  else {
81824
81810
  this.text = '';
@@ -81944,7 +81930,7 @@ focus outline in that case.
81944
81930
  class TableColumnDateTextCellView extends TableColumnTextCellViewBase {
81945
81931
  updateText() {
81946
81932
  if (this.columnConfig) {
81947
- this.text = formatNumericDate(this.columnConfig.formatter, this.cellRecord?.value);
81933
+ this.text = this.columnConfig.formatter.format(this.cellRecord?.value);
81948
81934
  }
81949
81935
  else {
81950
81936
  this.text = '';
@@ -81964,6 +81950,30 @@ focus outline in that case.
81964
81950
  */
81965
81951
  const DateTextFormat = {
81966
81952
  default: undefined};
81953
+ /**
81954
+ * The `Intl.DateTimeFormatOptions` properties supported by the date-text column and `DateTextFormatter`.
81955
+ */
81956
+ const supportedIntlDateTimeFormatOptionNames = [
81957
+ 'localeMatcher',
81958
+ 'weekday',
81959
+ 'era',
81960
+ 'year',
81961
+ 'month',
81962
+ 'day',
81963
+ 'hour',
81964
+ 'minute',
81965
+ 'second',
81966
+ 'dayPeriod',
81967
+ 'timeZoneName',
81968
+ 'formatMatcher',
81969
+ 'hour12',
81970
+ 'timeZone',
81971
+ 'calendar',
81972
+ 'numberingSystem',
81973
+ 'dateStyle',
81974
+ 'timeStyle',
81975
+ 'hourCycle'
81976
+ ];
81967
81977
 
81968
81978
  const dateTextValidityFlagNames = ['invalidCustomOptionsCombination'];
81969
81979
  /**
@@ -81995,6 +82005,65 @@ focus outline in that case.
81995
82005
  }
81996
82006
  };
81997
82007
 
82008
+ /**
82009
+ * A class for formatting date values using the provided locale and options.
82010
+ */
82011
+ class DateTextFormatter {
82012
+ constructor(lang, options) {
82013
+ this.options = this.resolveOptions(options);
82014
+ this.formatter = new Intl.DateTimeFormat(lang, this.options);
82015
+ }
82016
+ format(value) {
82017
+ const milliseconds = this.parseValue(value);
82018
+ if (milliseconds === undefined || !Number.isFinite(milliseconds)) {
82019
+ return '';
82020
+ }
82021
+ try {
82022
+ return this.formatter.format(milliseconds);
82023
+ }
82024
+ catch (_e) {
82025
+ return '';
82026
+ }
82027
+ }
82028
+ optionsMatch(targetOptions) {
82029
+ const resolvedTargetOptions = targetOptions ?? DateTextFormatter.defaultOptions;
82030
+ for (const name of supportedIntlDateTimeFormatOptionNames) {
82031
+ if (this.options[name] !== resolvedTargetOptions[name]) {
82032
+ return false;
82033
+ }
82034
+ }
82035
+ return true;
82036
+ }
82037
+ parseValue(value) {
82038
+ if (value instanceof Date) {
82039
+ return value.getTime();
82040
+ }
82041
+ if (typeof value === 'number') {
82042
+ return value;
82043
+ }
82044
+ return undefined;
82045
+ }
82046
+ resolveOptions(options) {
82047
+ if (options === undefined) {
82048
+ return DateTextFormatter.defaultOptions;
82049
+ }
82050
+ const supportedOptions = {};
82051
+ for (const name of supportedIntlDateTimeFormatOptionNames) {
82052
+ this.resolveOption(supportedOptions, options, name);
82053
+ }
82054
+ return supportedOptions;
82055
+ }
82056
+ resolveOption(target, source, name) {
82057
+ if (source[name] !== undefined) {
82058
+ target[name] = source[name];
82059
+ }
82060
+ }
82061
+ }
82062
+ DateTextFormatter.defaultOptions = {
82063
+ dateStyle: 'medium',
82064
+ timeStyle: 'medium'
82065
+ };
82066
+
81998
82067
  /**
81999
82068
  * The table column for displaying dates/times as text.
82000
82069
  */
@@ -82105,18 +82174,11 @@ focus outline in that case.
82105
82174
  }
82106
82175
  }
82107
82176
  createFormatter() {
82108
- let options;
82109
- if (this.format === DateTextFormat.default) {
82110
- options = {
82111
- dateStyle: 'medium',
82112
- timeStyle: 'medium'
82113
- };
82114
- }
82115
- else {
82116
- options = this.getCustomFormattingOptions();
82117
- }
82177
+ const options = this.format === DateTextFormat.default
82178
+ ? undefined
82179
+ : this.getCustomFormattingOptions();
82118
82180
  try {
82119
- return new Intl.DateTimeFormat(lang.getValueFor(this), options);
82181
+ return new DateTextFormatter(lang.getValueFor(this), options);
82120
82182
  }
82121
82183
  catch (_e) {
82122
82184
  return undefined;