@ni/nimble-components 35.13.3 → 35.14.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.
@@ -13867,7 +13867,7 @@
13867
13867
  "privacy": "private",
13868
13868
  "return": {
13869
13869
  "type": {
13870
- "text": "Intl.DateTimeFormat | undefined"
13870
+ "text": "DateTextFormatter | undefined"
13871
13871
  }
13872
13872
  }
13873
13873
  },
@@ -13877,7 +13877,7 @@
13877
13877
  "privacy": "private",
13878
13878
  "return": {
13879
13879
  "type": {
13880
- "text": "Intl.DateTimeFormatOptions"
13880
+ "text": "SupportedIntlDateTimeFormatOptions"
13881
13881
  }
13882
13882
  }
13883
13883
  }
@@ -14078,6 +14078,15 @@
14078
14078
  },
14079
14079
  "default": "{ default: undefined, custom: 'custom' }",
14080
14080
  "description": "Formatting scheme for the date-text table column"
14081
+ },
14082
+ {
14083
+ "kind": "variable",
14084
+ "name": "supportedIntlDateTimeFormatOptionNames",
14085
+ "type": {
14086
+ "text": "[\n 'localeMatcher',\n 'weekday',\n 'era',\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second',\n 'dayPeriod',\n 'timeZoneName',\n 'formatMatcher',\n 'hour12',\n 'timeZone',\n 'calendar',\n 'numberingSystem',\n 'dateStyle',\n 'timeStyle',\n 'hourCycle'\n]"
14087
+ },
14088
+ "default": "[ 'localeMatcher', 'weekday', 'era', 'year', 'month', 'day', 'hour', 'minute', 'second', 'dayPeriod', 'timeZoneName', 'formatMatcher', 'hour12', 'timeZone', 'calendar', 'numberingSystem', 'dateStyle', 'timeStyle', 'hourCycle' ]",
14089
+ "description": "The `Intl.DateTimeFormatOptions` properties supported by the date-text column and `DateTextFormatter`."
14081
14090
  }
14082
14091
  ],
14083
14092
  "exports": [
@@ -14088,6 +14097,14 @@
14088
14097
  "name": "DateTextFormat",
14089
14098
  "module": "src/table-column/date-text/types.ts"
14090
14099
  }
14100
+ },
14101
+ {
14102
+ "kind": "js",
14103
+ "name": "supportedIntlDateTimeFormatOptionNames",
14104
+ "declaration": {
14105
+ "name": "supportedIntlDateTimeFormatOptionNames",
14106
+ "module": "src/table-column/date-text/types.ts"
14107
+ }
14091
14108
  }
14092
14109
  ]
14093
14110
  },
@@ -16169,17 +16186,17 @@
16169
16186
  },
16170
16187
  {
16171
16188
  "kind": "javascript-module",
16172
- "path": "src/unit/fahrenheit/index.ts",
16189
+ "path": "src/unit/celsius/index.ts",
16173
16190
  "declarations": [
16174
16191
  {
16175
16192
  "kind": "class",
16176
- "description": "Element representing degrees Fahrenheit unit",
16177
- "name": "UnitFahrenheit",
16193
+ "description": "Element representing degrees Celsius unit",
16194
+ "name": "UnitCelsius",
16178
16195
  "members": [
16179
16196
  {
16180
16197
  "kind": "field",
16181
16198
  "name": "resolvedUnitScale",
16182
- "default": "unitScaleFahrenheit"
16199
+ "default": "unitScaleCelsius"
16183
16200
  }
16184
16201
  ],
16185
16202
  "superclass": {
@@ -16189,45 +16206,45 @@
16189
16206
  },
16190
16207
  {
16191
16208
  "kind": "variable",
16192
- "name": "unitFahrenheitTag",
16209
+ "name": "unitCelsiusTag",
16193
16210
  "type": {
16194
16211
  "text": "string"
16195
16212
  },
16196
- "default": "'nimble-unit-fahrenheit'"
16213
+ "default": "'nimble-unit-celsius'"
16197
16214
  }
16198
16215
  ],
16199
16216
  "exports": [
16200
16217
  {
16201
16218
  "kind": "js",
16202
- "name": "UnitFahrenheit",
16219
+ "name": "UnitCelsius",
16203
16220
  "declaration": {
16204
- "name": "UnitFahrenheit",
16205
- "module": "src/unit/fahrenheit/index.ts"
16221
+ "name": "UnitCelsius",
16222
+ "module": "src/unit/celsius/index.ts"
16206
16223
  }
16207
16224
  },
16208
16225
  {
16209
16226
  "kind": "js",
16210
- "name": "unitFahrenheitTag",
16227
+ "name": "unitCelsiusTag",
16211
16228
  "declaration": {
16212
- "name": "unitFahrenheitTag",
16213
- "module": "src/unit/fahrenheit/index.ts"
16229
+ "name": "unitCelsiusTag",
16230
+ "module": "src/unit/celsius/index.ts"
16214
16231
  }
16215
16232
  }
16216
16233
  ]
16217
16234
  },
16218
16235
  {
16219
16236
  "kind": "javascript-module",
16220
- "path": "src/unit/celsius/index.ts",
16237
+ "path": "src/unit/fahrenheit/index.ts",
16221
16238
  "declarations": [
16222
16239
  {
16223
16240
  "kind": "class",
16224
- "description": "Element representing degrees Celsius unit",
16225
- "name": "UnitCelsius",
16241
+ "description": "Element representing degrees Fahrenheit unit",
16242
+ "name": "UnitFahrenheit",
16226
16243
  "members": [
16227
16244
  {
16228
16245
  "kind": "field",
16229
16246
  "name": "resolvedUnitScale",
16230
- "default": "unitScaleCelsius"
16247
+ "default": "unitScaleFahrenheit"
16231
16248
  }
16232
16249
  ],
16233
16250
  "superclass": {
@@ -16237,28 +16254,28 @@
16237
16254
  },
16238
16255
  {
16239
16256
  "kind": "variable",
16240
- "name": "unitCelsiusTag",
16257
+ "name": "unitFahrenheitTag",
16241
16258
  "type": {
16242
16259
  "text": "string"
16243
16260
  },
16244
- "default": "'nimble-unit-celsius'"
16261
+ "default": "'nimble-unit-fahrenheit'"
16245
16262
  }
16246
16263
  ],
16247
16264
  "exports": [
16248
16265
  {
16249
16266
  "kind": "js",
16250
- "name": "UnitCelsius",
16267
+ "name": "UnitFahrenheit",
16251
16268
  "declaration": {
16252
- "name": "UnitCelsius",
16253
- "module": "src/unit/celsius/index.ts"
16269
+ "name": "UnitFahrenheit",
16270
+ "module": "src/unit/fahrenheit/index.ts"
16254
16271
  }
16255
16272
  },
16256
16273
  {
16257
16274
  "kind": "js",
16258
- "name": "unitCelsiusTag",
16275
+ "name": "unitFahrenheitTag",
16259
16276
  "declaration": {
16260
- "name": "unitCelsiusTag",
16261
- "module": "src/unit/celsius/index.ts"
16277
+ "name": "unitFahrenheitTag",
16278
+ "module": "src/unit/fahrenheit/index.ts"
16262
16279
  }
16263
16280
  }
16264
16281
  ]
@@ -2216,7 +2216,7 @@
2216
2216
 
2217
2217
  <hr/>
2218
2218
 
2219
- ## class: `UnitFahrenheit`
2219
+ ## class: `UnitCelsius`
2220
2220
 
2221
2221
  ### Superclass
2222
2222
 
@@ -2226,13 +2226,13 @@
2226
2226
 
2227
2227
  ### Fields
2228
2228
 
2229
- | Name | Privacy | Type | Default | Description | Inherited From |
2230
- | ------------------- | ------- | ---- | --------------------- | ----------- | -------------- |
2231
- | `resolvedUnitScale` | | | `unitScaleFahrenheit` | | |
2229
+ | Name | Privacy | Type | Default | Description | Inherited From |
2230
+ | ------------------- | ------- | ---- | ------------------ | ----------- | -------------- |
2231
+ | `resolvedUnitScale` | | | `unitScaleCelsius` | | |
2232
2232
 
2233
2233
  <hr/>
2234
2234
 
2235
- ## class: `UnitCelsius`
2235
+ ## class: `UnitFahrenheit`
2236
2236
 
2237
2237
  ### Superclass
2238
2238
 
@@ -2242,9 +2242,9 @@
2242
2242
 
2243
2243
  ### Fields
2244
2244
 
2245
- | Name | Privacy | Type | Default | Description | Inherited From |
2246
- | ------------------- | ------- | ---- | ------------------ | ----------- | -------------- |
2247
- | `resolvedUnitScale` | | | `unitScaleCelsius` | | |
2245
+ | Name | Privacy | Type | Default | Description | Inherited From |
2246
+ | ------------------- | ------- | ---- | --------------------- | ----------- | -------------- |
2247
+ | `resolvedUnitScale` | | | `unitScaleFahrenheit` | | |
2248
2248
 
2249
2249
  <hr/>
2250
2250
 
@@ -2,14 +2,13 @@ import { DesignSystem } from '@ni/fast-foundation';
2
2
  import { template } from '../../text-base/cell-view/template';
3
3
  import { styles } from '../../text-base/cell-view/styles';
4
4
  import { TableColumnTextCellViewBase } from '../../text-base/cell-view';
5
- import { formatNumericDate } from '../models/format-helper';
6
5
  /**
7
6
  * A cell view for displaying date/time fields as text
8
7
  */
9
8
  export class TableColumnDateTextCellView extends TableColumnTextCellViewBase {
10
9
  updateText() {
11
10
  if (this.columnConfig) {
12
- this.text = formatNumericDate(this.columnConfig.formatter, this.cellRecord?.value);
11
+ this.text = this.columnConfig.formatter.format(this.cellRecord?.value);
13
12
  }
14
13
  else {
15
14
  this.text = '';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/table-column/date-text/cell-view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAK9D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAQ5D;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,2BAGhD;IACa,UAAU;QAChB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CACzB,IAAI,CAAC,YAAY,CAAC,SAAS,EAC3B,IAAI,CAAC,UAAU,EAAE,KAAK,CACzB,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;IACL,CAAC;CACJ;AAED,MAAM,gBAAgB,GAAG,2BAA2B,CAAC,OAAO,CAAC;IACzD,QAAQ,EAAE,kCAAkC;IAC5C,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AACH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,8BAA8B,GAAG,yCAAyC,CAAC","sourcesContent":["import { DesignSystem } from '@ni/fast-foundation';\nimport { template } from '../../text-base/cell-view/template';\nimport type {\n TableColumnDateTextCellRecord,\n TableColumnDateTextColumnConfig\n} from '..';\nimport { styles } from '../../text-base/cell-view/styles';\nimport { TableColumnTextCellViewBase } from '../../text-base/cell-view';\nimport { formatNumericDate } from '../models/format-helper';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-table-column-date-text-cell-view': TableColumnDateTextCellView;\n }\n}\n\n/**\n * A cell view for displaying date/time fields as text\n */\nexport class TableColumnDateTextCellView extends TableColumnTextCellViewBase<\n TableColumnDateTextCellRecord,\n TableColumnDateTextColumnConfig\n> {\n protected updateText(): void {\n if (this.columnConfig) {\n this.text = formatNumericDate(\n this.columnConfig.formatter,\n this.cellRecord?.value\n );\n } else {\n this.text = '';\n }\n }\n}\n\nconst dateTextCellView = TableColumnDateTextCellView.compose({\n baseName: 'table-column-date-text-cell-view',\n template,\n styles\n});\nDesignSystem.getOrCreate().withPrefix('nimble').register(dateTextCellView());\nexport const tableColumnDateTextCellViewTag = 'nimble-table-column-date-text-cell-view';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/table-column/date-text/cell-view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAK9D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAQxE;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,2BAGhD;IACa,UAAU;QAChB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC3E,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;IACL,CAAC;CACJ;AAED,MAAM,gBAAgB,GAAG,2BAA2B,CAAC,OAAO,CAAC;IACzD,QAAQ,EAAE,kCAAkC;IAC5C,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AACH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,8BAA8B,GAAG,yCAAyC,CAAC","sourcesContent":["import { DesignSystem } from '@ni/fast-foundation';\nimport { template } from '../../text-base/cell-view/template';\nimport type {\n TableColumnDateTextCellRecord,\n TableColumnDateTextColumnConfig\n} from '..';\nimport { styles } from '../../text-base/cell-view/styles';\nimport { TableColumnTextCellViewBase } from '../../text-base/cell-view';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-table-column-date-text-cell-view': TableColumnDateTextCellView;\n }\n}\n\n/**\n * A cell view for displaying date/time fields as text\n */\nexport class TableColumnDateTextCellView extends TableColumnTextCellViewBase<\n TableColumnDateTextCellRecord,\n TableColumnDateTextColumnConfig\n> {\n protected updateText(): void {\n if (this.columnConfig) {\n this.text = this.columnConfig.formatter.format(this.cellRecord?.value);\n } else {\n this.text = '';\n }\n }\n}\n\nconst dateTextCellView = TableColumnDateTextCellView.compose({\n baseName: 'table-column-date-text-cell-view',\n template,\n styles\n});\nDesignSystem.getOrCreate().withPrefix('nimble').register(dateTextCellView());\nexport const tableColumnDateTextCellViewTag = 'nimble-table-column-date-text-cell-view';\n"]}
@@ -2,14 +2,13 @@ import { DesignSystem } from '@ni/fast-foundation';
2
2
  import { TableColumnTextGroupHeaderViewBase } from '../../text-base/group-header-view';
3
3
  import { template } from '../../text-base/group-header-view/template';
4
4
  import { styles } from '../../text-base/group-header-view/styles';
5
- import { formatNumericDate } from '../models/format-helper';
6
5
  /**
7
6
  * The group header view for displaying date/time fields as text.
8
7
  */
9
8
  export class TableColumnDateTextGroupHeaderView extends TableColumnTextGroupHeaderViewBase {
10
9
  updateText() {
11
10
  if (this.columnConfig) {
12
- this.text = formatNumericDate(this.columnConfig.formatter, this.groupHeaderValue);
11
+ this.text = this.columnConfig.formatter.format(this.groupHeaderValue);
13
12
  }
14
13
  else {
15
14
  this.text = '';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/table-column/date-text/group-header-view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAO5D;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,kCAGvD;IACa,UAAU;QAChB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CACzB,IAAI,CAAC,YAAY,CAAC,SAAS,EAC3B,IAAI,CAAC,gBAAgB,CACxB,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;IACL,CAAC;CACJ;AAED,MAAM,kCAAkC,GAAG,kCAAkC,CAAC,OAAO,CAAC;IAClF,QAAQ,EAAE,0CAA0C;IACpD,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AACH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,kCAAkC,EAAE,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,qCAAqC,GAAG,iDAAiD,CAAC","sourcesContent":["import { DesignSystem } from '@ni/fast-foundation';\nimport type { TableNumberFieldValue } from '../../../table/types';\nimport { TableColumnTextGroupHeaderViewBase } from '../../text-base/group-header-view';\nimport { template } from '../../text-base/group-header-view/template';\nimport { styles } from '../../text-base/group-header-view/styles';\nimport type { TableColumnDateTextColumnConfig } from '..';\nimport { formatNumericDate } from '../models/format-helper';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-table-column-date-text-group-header': TableColumnDateTextGroupHeaderView;\n }\n}\n/**\n * The group header view for displaying date/time fields as text.\n */\nexport class TableColumnDateTextGroupHeaderView extends TableColumnTextGroupHeaderViewBase<\n TableNumberFieldValue,\n TableColumnDateTextColumnConfig\n> {\n protected updateText(): void {\n if (this.columnConfig) {\n this.text = formatNumericDate(\n this.columnConfig.formatter,\n this.groupHeaderValue\n );\n } else {\n this.text = '';\n }\n }\n}\n\nconst tableColumnDateTextGroupHeaderView = TableColumnDateTextGroupHeaderView.compose({\n baseName: 'table-column-date-text-group-header-view',\n template,\n styles\n});\nDesignSystem.getOrCreate()\n .withPrefix('nimble')\n .register(tableColumnDateTextGroupHeaderView());\nexport const tableColumnDateTextGroupHeaderViewTag = 'nimble-table-column-date-text-group-header-view';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/table-column/date-text/group-header-view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAQlE;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,kCAGvD;IACa,UAAU;QAChB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC1E,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;IACL,CAAC;CACJ;AAED,MAAM,kCAAkC,GAAG,kCAAkC,CAAC,OAAO,CAAC;IAClF,QAAQ,EAAE,0CAA0C;IACpD,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AACH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,kCAAkC,EAAE,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,qCAAqC,GAAG,iDAAiD,CAAC","sourcesContent":["import { DesignSystem } from '@ni/fast-foundation';\nimport type { TableNumberFieldValue } from '../../../table/types';\nimport { TableColumnTextGroupHeaderViewBase } from '../../text-base/group-header-view';\nimport { template } from '../../text-base/group-header-view/template';\nimport { styles } from '../../text-base/group-header-view/styles';\nimport type { TableColumnDateTextColumnConfig } from '..';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-table-column-date-text-group-header': TableColumnDateTextGroupHeaderView;\n }\n}\n/**\n * The group header view for displaying date/time fields as text.\n */\nexport class TableColumnDateTextGroupHeaderView extends TableColumnTextGroupHeaderViewBase<\n TableNumberFieldValue,\n TableColumnDateTextColumnConfig\n> {\n protected updateText(): void {\n if (this.columnConfig) {\n this.text = this.columnConfig.formatter.format(this.groupHeaderValue);\n } else {\n this.text = '';\n }\n }\n}\n\nconst tableColumnDateTextGroupHeaderView = TableColumnDateTextGroupHeaderView.compose({\n baseName: 'table-column-date-text-group-header-view',\n template,\n styles\n});\nDesignSystem.getOrCreate()\n .withPrefix('nimble')\n .register(tableColumnDateTextGroupHeaderView());\nexport const tableColumnDateTextGroupHeaderViewTag = 'nimble-table-column-date-text-group-header-view';\n"]}
@@ -5,9 +5,10 @@ import { DateTextFormat } from './types';
5
5
  import type { LocaleMatcherAlgorithm, EraFormat, YearFormat, DayFormat, HourFormat, MinuteFormat, SecondFormat, TimeZoneNameFormat, FormatMatcherAlgorithm, DayPeriodFormat, DateStyle, TimeStyle, HourCycleFormat, MonthFormat, WeekdayFormat } from './types';
6
6
  import { TableColumnDateTextValidator } from './models/table-column-date-text-validator';
7
7
  import type { TableColumnTextBaseColumnConfig } from '../text-base/cell-view';
8
+ import { DateTextFormatter } from './models/date-text-formatter';
8
9
  export type TableColumnDateTextCellRecord = TableNumberField<'value'>;
9
10
  export interface TableColumnDateTextColumnConfig extends TableColumnTextBaseColumnConfig {
10
- formatter: Intl.DateTimeFormat;
11
+ formatter: DateTextFormatter;
11
12
  }
12
13
  declare global {
13
14
  interface HTMLElementTagNameMap {
@@ -11,6 +11,7 @@ import { DateTextFormat } from './types';
11
11
  import { TableColumnDateTextValidator } from './models/table-column-date-text-validator';
12
12
  import { lang } from '../../theme-provider';
13
13
  import { optionalBooleanConverter } from '../../utilities/models/converter';
14
+ import { DateTextFormatter } from './models/date-text-formatter';
14
15
  /**
15
16
  * The table column for displaying dates/times as text.
16
17
  */
@@ -121,18 +122,11 @@ export class TableColumnDateText extends mixinTextBase((TableColumnTextBase)) {
121
122
  }
122
123
  }
123
124
  createFormatter() {
124
- let options;
125
- if (this.format === DateTextFormat.default) {
126
- options = {
127
- dateStyle: 'medium',
128
- timeStyle: 'medium'
129
- };
130
- }
131
- else {
132
- options = this.getCustomFormattingOptions();
133
- }
125
+ const options = this.format === DateTextFormat.default
126
+ ? undefined
127
+ : this.getCustomFormattingOptions();
134
128
  try {
135
- return new Intl.DateTimeFormat(lang.getValueFor(this), options);
129
+ return new DateTextFormatter(lang.getValueFor(this), options);
136
130
  }
137
131
  catch (_e) {
138
132
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table-column/date-text/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAA8B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,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C;uDACL;AAGvB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;yDACH;AAG3B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;yDACH;AAG3B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;+DACC;AAGvC;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;gEACM;AAM5C;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;yDAC5C;AAGvB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;2DACT;AAGxB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;2DACR;AAGxB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;4DACD;AAGjC;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC;kEACT;AAG/B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;4DACP;AAG3B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;4DACP;AAG3B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;4DACD;AAgL5C,MAAM,yBAAyB,GAAG,mBAAmB,CAAC,OAAO,CAAC;IAC1D,QAAQ,EAAE,wBAAwB;IAClC,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,yBAAyB,EAAE,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,+BAA+B,CAAC","sourcesContent":["import { DesignSystem, type DesignTokenSubscriber } from '@ni/fast-foundation';\nimport { attr } from '@ni/fast-element';\nimport { styles } from '../base/styles';\nimport { template } from '../base/template';\nimport type { TableNumberField } from '../../table/types';\nimport { TableColumnTextBase, mixinTextBase } from '../text-base';\nimport { TableColumnSortOperation } from '../base/types';\nimport { tableColumnDateTextGroupHeaderViewTag } from './group-header-view';\nimport { tableColumnDateTextCellViewTag } from './cell-view';\nimport type { ColumnInternalsOptions } from '../base/models/column-internals';\nimport { DateTextFormat } from './types';\nimport type {\n LocaleMatcherAlgorithm,\n EraFormat,\n YearFormat,\n DayFormat,\n HourFormat,\n MinuteFormat,\n SecondFormat,\n TimeZoneNameFormat,\n FormatMatcherAlgorithm,\n DayPeriodFormat,\n DateStyle,\n TimeStyle,\n HourCycleFormat,\n MonthFormat,\n WeekdayFormat\n} from './types';\nimport { TableColumnDateTextValidator } from './models/table-column-date-text-validator';\nimport { lang } from '../../theme-provider';\nimport { optionalBooleanConverter } from '../../utilities/models/converter';\nimport type { TableColumnTextBaseColumnConfig } from '../text-base/cell-view';\n\nexport type TableColumnDateTextCellRecord = TableNumberField<'value'>;\nexport interface TableColumnDateTextColumnConfig extends TableColumnTextBaseColumnConfig {\n formatter: Intl.DateTimeFormat;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-table-column-date-text': TableColumnDateText;\n }\n}\n\n/**\n * The table column for displaying dates/times as text.\n */\nexport class TableColumnDateText extends mixinTextBase(\n TableColumnTextBase<\n TableColumnDateTextColumnConfig,\n TableColumnDateTextValidator\n >\n) {\n @attr\n public format: DateTextFormat;\n\n @attr({ attribute: 'custom-locale-matcher' })\n public customLocaleMatcher: LocaleMatcherAlgorithm;\n\n @attr({ attribute: 'custom-weekday' })\n public customWeekday: WeekdayFormat;\n\n @attr({ attribute: 'custom-era' })\n public customEra: EraFormat;\n\n @attr({ attribute: 'custom-year' })\n public customYear: YearFormat;\n\n @attr({ attribute: 'custom-month' })\n public customMonth: MonthFormat;\n\n @attr({ attribute: 'custom-day' })\n public customDay: DayFormat;\n\n @attr({ attribute: 'custom-hour' })\n public customHour: HourFormat;\n\n @attr({ attribute: 'custom-minute' })\n public customMinute: MinuteFormat;\n\n @attr({ attribute: 'custom-second' })\n public customSecond: SecondFormat;\n\n @attr({ attribute: 'custom-time-zone-name' })\n public customTimeZoneName: TimeZoneNameFormat;\n\n @attr({ attribute: 'custom-format-matcher' })\n public customFormatMatcher: FormatMatcherAlgorithm;\n\n // Later versions of FAST (than the legacy branch we're on) have a nullableBooleanConverter.\n // We should replace our converter with that one when it is available to us.\n // See issue related to adopting FastElement 2.0: https://github.com/ni/nimble/issues/572\n @attr({ attribute: 'custom-hour12', converter: optionalBooleanConverter })\n public customHour12?: boolean;\n\n @attr({ attribute: 'custom-time-zone' })\n public customTimeZone?: string;\n\n @attr({ attribute: 'custom-calendar' })\n public customCalendar?: string;\n\n @attr({ attribute: 'custom-day-period' })\n public customDayPeriod: DayPeriodFormat;\n\n @attr({ attribute: 'custom-numbering-system' })\n public customNumberingSystem?: string;\n\n @attr({ attribute: 'custom-date-style' })\n public customDateStyle: DateStyle;\n\n @attr({ attribute: 'custom-time-style' })\n public customTimeStyle: TimeStyle;\n\n @attr({ attribute: 'custom-hour-cycle' })\n public customHourCycle: HourCycleFormat;\n\n private readonly langSubscriber: DesignTokenSubscriber<typeof lang> = {\n handleChange: () => {\n this.updateColumnConfig();\n }\n };\n\n public override connectedCallback(): void {\n super.connectedCallback();\n lang.subscribe(this.langSubscriber, this);\n this.updateColumnConfig();\n }\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n lang.unsubscribe(this.langSubscriber, this);\n }\n\n public placeholderChanged(): void {\n this.updateColumnConfig();\n }\n\n protected override getColumnInternalsOptions(): ColumnInternalsOptions<TableColumnDateTextValidator> {\n return {\n cellRecordFieldNames: ['value'],\n cellViewTag: tableColumnDateTextCellViewTag,\n groupHeaderViewTag: tableColumnDateTextGroupHeaderViewTag,\n delegatedEvents: [],\n sortOperation: TableColumnSortOperation.basic,\n validator: new TableColumnDateTextValidator()\n };\n }\n\n protected formatChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customLocaleMatcherChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customWeekdayChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customEraChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customYearChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customMonthChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customDayChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customHourChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customMinuteChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customSecondChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customTimeZoneNameChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customFormatMatcherChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customHour12Changed(): void {\n this.updateColumnConfig();\n }\n\n protected customTimeZoneChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customCalendarChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customDayPeriodChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customNumberingSystemChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customDateStyleChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customTimeStyleChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customHourCycleChanged(): void {\n this.updateColumnConfig();\n }\n\n private updateColumnConfig(): void {\n const formatter = this.createFormatter();\n\n if (formatter) {\n const columnConfig: TableColumnDateTextColumnConfig = {\n formatter,\n placeholder: this.placeholder\n };\n this.columnInternals.columnConfig = columnConfig;\n this.columnInternals.validator.setCustomOptionsValidity(true);\n } else {\n this.columnInternals.columnConfig = undefined;\n this.columnInternals.validator.setCustomOptionsValidity(false);\n }\n }\n\n private createFormatter(): Intl.DateTimeFormat | undefined {\n let options: Intl.DateTimeFormatOptions;\n if (this.format === DateTextFormat.default) {\n options = {\n dateStyle: 'medium',\n timeStyle: 'medium'\n };\n } else {\n options = this.getCustomFormattingOptions();\n }\n try {\n return new Intl.DateTimeFormat(lang.getValueFor(this), options);\n } catch (_e) {\n return undefined;\n }\n }\n\n private getCustomFormattingOptions(): Intl.DateTimeFormatOptions {\n // There's a FAST bug (https://github.com/microsoft/fast/issues/6630) where removing\n // attributes sets their values to null instead of undefined. To work around this,\n // translate null values to undefined.\n const options: Intl.DateTimeFormatOptions = {\n localeMatcher: this.customLocaleMatcher ?? undefined,\n weekday: this.customWeekday ?? undefined,\n era: this.customEra ?? undefined,\n year: this.customYear ?? undefined,\n month: this.customMonth ?? undefined,\n day: this.customDay ?? undefined,\n hour: this.customHour ?? undefined,\n minute: this.customMinute ?? undefined,\n second: this.customSecond ?? undefined,\n timeZoneName: this.customTimeZoneName ?? undefined,\n formatMatcher: this.customFormatMatcher ?? undefined,\n hour12: this.customHour12 ?? undefined,\n timeZone: this.customTimeZone ?? undefined,\n calendar: this.customCalendar ?? undefined,\n dayPeriod: this.customDayPeriod ?? undefined,\n numberingSystem: this.customNumberingSystem ?? undefined,\n dateStyle: this.customDateStyle ?? undefined,\n timeStyle: this.customTimeStyle ?? undefined,\n hourCycle: this.customHourCycle ?? undefined\n };\n return options;\n }\n}\n\nconst nimbleTableColumnDateText = TableColumnDateText.compose({\n baseName: 'table-column-date-text',\n template,\n styles\n});\n\nDesignSystem.getOrCreate()\n .withPrefix('nimble')\n .register(nimbleTableColumnDateText());\nexport const tableColumnDateTextTag = 'nimble-table-column-date-text';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table-column/date-text/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAA8B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAA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AAa,EAAE,CAAC;uDACL;AAGvB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;yDACH;AAG3B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;yDACH;AAG3B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;+DACC;AAGvC;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;gEACM;AAG5C;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC;yDAC5C;AAGvB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;2DACT;AAGxB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;2DACR;AAGxB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;4DACD;AAGjC;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC;kEACT;AAG/B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;4DACP;AAG3B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;4DACP;AAG3B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;4DACD;AA0K5C,MAAM,yBAAyB,GAAG,mBAAmB,CAAC,OAAO,CAAC;IAC1D,QAAQ,EAAE,wBAAwB;IAClC,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,yBAAyB,EAAE,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,+BAA+B,CAAC","sourcesContent":["import { DesignSystem, type DesignTokenSubscriber } from '@ni/fast-foundation';\nimport { attr } from '@ni/fast-element';\nimport { styles } from '../base/styles';\nimport { template } from '../base/template';\nimport type { TableNumberField } from '../../table/types';\nimport { TableColumnTextBase, mixinTextBase } from '../text-base';\nimport { TableColumnSortOperation } from '../base/types';\nimport { tableColumnDateTextGroupHeaderViewTag } from './group-header-view';\nimport { tableColumnDateTextCellViewTag } from './cell-view';\nimport type { ColumnInternalsOptions } from '../base/models/column-internals';\nimport { DateTextFormat } from './types';\nimport type {\n LocaleMatcherAlgorithm,\n EraFormat,\n YearFormat,\n DayFormat,\n HourFormat,\n MinuteFormat,\n SecondFormat,\n TimeZoneNameFormat,\n FormatMatcherAlgorithm,\n DayPeriodFormat,\n DateStyle,\n TimeStyle,\n HourCycleFormat,\n MonthFormat,\n WeekdayFormat,\n SupportedIntlDateTimeFormatOptions,\n supportedIntlDateTimeFormatOptionNames\n} from './types';\nimport { TableColumnDateTextValidator } from './models/table-column-date-text-validator';\nimport { lang } from '../../theme-provider';\nimport { optionalBooleanConverter } from '../../utilities/models/converter';\nimport type { TableColumnTextBaseColumnConfig } from '../text-base/cell-view';\nimport { DateTextFormatter } from './models/date-text-formatter';\n\nexport type TableColumnDateTextCellRecord = TableNumberField<'value'>;\nexport interface TableColumnDateTextColumnConfig extends TableColumnTextBaseColumnConfig {\n formatter: DateTextFormatter;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-table-column-date-text': TableColumnDateText;\n }\n}\n\ntype AllSupportedIntlDateTimeFormatOptions = {\n [Key in (typeof supportedIntlDateTimeFormatOptionNames)[number]]: Intl.DateTimeFormatOptions[Key]\n};\n\n/**\n * The table column for displaying dates/times as text.\n */\nexport class TableColumnDateText extends mixinTextBase(\n TableColumnTextBase<\n TableColumnDateTextColumnConfig,\n TableColumnDateTextValidator\n >\n) {\n @attr\n public format: DateTextFormat;\n\n @attr({ attribute: 'custom-locale-matcher' })\n public customLocaleMatcher: LocaleMatcherAlgorithm;\n\n @attr({ attribute: 'custom-weekday' })\n public customWeekday: WeekdayFormat;\n\n @attr({ attribute: 'custom-era' })\n public customEra: EraFormat;\n\n @attr({ attribute: 'custom-year' })\n public customYear: YearFormat;\n\n @attr({ attribute: 'custom-month' })\n public customMonth: MonthFormat;\n\n @attr({ attribute: 'custom-day' })\n public customDay: DayFormat;\n\n @attr({ attribute: 'custom-hour' })\n public customHour: HourFormat;\n\n @attr({ attribute: 'custom-minute' })\n public customMinute: MinuteFormat;\n\n @attr({ attribute: 'custom-second' })\n public customSecond: SecondFormat;\n\n @attr({ attribute: 'custom-time-zone-name' })\n public customTimeZoneName: TimeZoneNameFormat;\n\n @attr({ attribute: 'custom-format-matcher' })\n public customFormatMatcher: FormatMatcherAlgorithm;\n\n @attr({ attribute: 'custom-hour12', converter: optionalBooleanConverter })\n public customHour12?: boolean;\n\n @attr({ attribute: 'custom-time-zone' })\n public customTimeZone?: string;\n\n @attr({ attribute: 'custom-calendar' })\n public customCalendar?: string;\n\n @attr({ attribute: 'custom-day-period' })\n public customDayPeriod: DayPeriodFormat;\n\n @attr({ attribute: 'custom-numbering-system' })\n public customNumberingSystem?: string;\n\n @attr({ attribute: 'custom-date-style' })\n public customDateStyle: DateStyle;\n\n @attr({ attribute: 'custom-time-style' })\n public customTimeStyle: TimeStyle;\n\n @attr({ attribute: 'custom-hour-cycle' })\n public customHourCycle: HourCycleFormat;\n\n private readonly langSubscriber: DesignTokenSubscriber<typeof lang> = {\n handleChange: () => {\n this.updateColumnConfig();\n }\n };\n\n public override connectedCallback(): void {\n super.connectedCallback();\n lang.subscribe(this.langSubscriber, this);\n this.updateColumnConfig();\n }\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n lang.unsubscribe(this.langSubscriber, this);\n }\n\n public placeholderChanged(): void {\n this.updateColumnConfig();\n }\n\n protected override getColumnInternalsOptions(): ColumnInternalsOptions<TableColumnDateTextValidator> {\n return {\n cellRecordFieldNames: ['value'],\n cellViewTag: tableColumnDateTextCellViewTag,\n groupHeaderViewTag: tableColumnDateTextGroupHeaderViewTag,\n delegatedEvents: [],\n sortOperation: TableColumnSortOperation.basic,\n validator: new TableColumnDateTextValidator()\n };\n }\n\n protected formatChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customLocaleMatcherChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customWeekdayChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customEraChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customYearChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customMonthChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customDayChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customHourChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customMinuteChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customSecondChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customTimeZoneNameChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customFormatMatcherChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customHour12Changed(): void {\n this.updateColumnConfig();\n }\n\n protected customTimeZoneChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customCalendarChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customDayPeriodChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customNumberingSystemChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customDateStyleChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customTimeStyleChanged(): void {\n this.updateColumnConfig();\n }\n\n protected customHourCycleChanged(): void {\n this.updateColumnConfig();\n }\n\n private updateColumnConfig(): void {\n const formatter = this.createFormatter();\n\n if (formatter) {\n const columnConfig: TableColumnDateTextColumnConfig = {\n formatter,\n placeholder: this.placeholder\n };\n this.columnInternals.columnConfig = columnConfig;\n this.columnInternals.validator.setCustomOptionsValidity(true);\n } else {\n this.columnInternals.columnConfig = undefined;\n this.columnInternals.validator.setCustomOptionsValidity(false);\n }\n }\n\n private createFormatter(): DateTextFormatter | undefined {\n const options = this.format === DateTextFormat.default\n ? undefined\n : this.getCustomFormattingOptions();\n try {\n return new DateTextFormatter(lang.getValueFor(this), options);\n } catch (_e) {\n return undefined;\n }\n }\n\n private getCustomFormattingOptions(): SupportedIntlDateTimeFormatOptions {\n // There's a FAST bug (https://github.com/microsoft/fast/issues/6630) where removing\n // attributes sets their values to null instead of undefined. To work around this,\n // translate null values to undefined.\n const options: AllSupportedIntlDateTimeFormatOptions = {\n localeMatcher: this.customLocaleMatcher ?? undefined,\n weekday: this.customWeekday ?? undefined,\n era: this.customEra ?? undefined,\n year: this.customYear ?? undefined,\n month: this.customMonth ?? undefined,\n day: this.customDay ?? undefined,\n hour: this.customHour ?? undefined,\n minute: this.customMinute ?? undefined,\n second: this.customSecond ?? undefined,\n timeZoneName: this.customTimeZoneName ?? undefined,\n formatMatcher: this.customFormatMatcher ?? undefined,\n hour12: this.customHour12 ?? undefined,\n timeZone: this.customTimeZone ?? undefined,\n calendar: this.customCalendar ?? undefined,\n dayPeriod: this.customDayPeriod ?? undefined,\n numberingSystem: this.customNumberingSystem ?? undefined,\n dateStyle: this.customDateStyle ?? undefined,\n timeStyle: this.customTimeStyle ?? undefined,\n hourCycle: this.customHourCycle ?? undefined\n };\n return options;\n }\n}\n\nconst nimbleTableColumnDateText = TableColumnDateText.compose({\n baseName: 'table-column-date-text',\n template,\n styles\n});\n\nDesignSystem.getOrCreate()\n .withPrefix('nimble')\n .register(nimbleTableColumnDateText());\nexport const tableColumnDateTextTag = 'nimble-table-column-date-text';\n"]}
@@ -0,0 +1,15 @@
1
+ import { type SupportedIntlDateTimeFormatOptions } from '../types';
2
+ /**
3
+ * A class for formatting date values using the provided locale and options.
4
+ */
5
+ export declare class DateTextFormatter {
6
+ private static readonly defaultOptions;
7
+ private readonly formatter;
8
+ private readonly options;
9
+ constructor(lang: string, options?: SupportedIntlDateTimeFormatOptions);
10
+ format(value: Date | number | null | undefined): string;
11
+ optionsMatch(targetOptions?: SupportedIntlDateTimeFormatOptions): boolean;
12
+ private parseValue;
13
+ private resolveOptions;
14
+ private resolveOption;
15
+ }
@@ -0,0 +1,60 @@
1
+ import { supportedIntlDateTimeFormatOptionNames } from '../types';
2
+ /**
3
+ * A class for formatting date values using the provided locale and options.
4
+ */
5
+ export class DateTextFormatter {
6
+ constructor(lang, options) {
7
+ this.options = this.resolveOptions(options);
8
+ this.formatter = new Intl.DateTimeFormat(lang, this.options);
9
+ }
10
+ format(value) {
11
+ const milliseconds = this.parseValue(value);
12
+ if (milliseconds === undefined || !Number.isFinite(milliseconds)) {
13
+ return '';
14
+ }
15
+ try {
16
+ return this.formatter.format(milliseconds);
17
+ }
18
+ catch (_e) {
19
+ return '';
20
+ }
21
+ }
22
+ optionsMatch(targetOptions) {
23
+ const resolvedTargetOptions = targetOptions ?? DateTextFormatter.defaultOptions;
24
+ for (const name of supportedIntlDateTimeFormatOptionNames) {
25
+ if (this.options[name] !== resolvedTargetOptions[name]) {
26
+ return false;
27
+ }
28
+ }
29
+ return true;
30
+ }
31
+ parseValue(value) {
32
+ if (value instanceof Date) {
33
+ return value.getTime();
34
+ }
35
+ if (typeof value === 'number') {
36
+ return value;
37
+ }
38
+ return undefined;
39
+ }
40
+ resolveOptions(options) {
41
+ if (options === undefined) {
42
+ return DateTextFormatter.defaultOptions;
43
+ }
44
+ const supportedOptions = {};
45
+ for (const name of supportedIntlDateTimeFormatOptionNames) {
46
+ this.resolveOption(supportedOptions, options, name);
47
+ }
48
+ return supportedOptions;
49
+ }
50
+ resolveOption(target, source, name) {
51
+ if (source[name] !== undefined) {
52
+ target[name] = source[name];
53
+ }
54
+ }
55
+ }
56
+ DateTextFormatter.defaultOptions = {
57
+ dateStyle: 'medium',
58
+ timeStyle: 'medium'
59
+ };
60
+ //# sourceMappingURL=date-text-formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-text-formatter.js","sourceRoot":"","sources":["../../../../../src/table-column/date-text/models/date-text-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,sCAAsC,EAEzC,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAS1B,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ACxB,OAAO,iBAAiB,CAAC,cAAc,CAAC;QAC5C,CAAC;QACD,MAAM,gBAAgB,GAAuC,EAAE,CAAC;QAChE,KAAK,MAAM,IAAI,IAAI,sCAAsC,EAAE,CAAC;YACxD,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAEO,aAAa,CAGjB,MAA0C,EAC1C,MAA0C,EAC1C,IAAU;QAEV,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;IACL,CAAC;;AAxEuB,gCAAc,GAAuC;IACzE,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,QAAQ;CACb,CAAC","sourcesContent":["import {\n supportedIntlDateTimeFormatOptionNames,\n type SupportedIntlDateTimeFormatOptions\n} from '../types';\n\n/**\n * A class for formatting date values using the provided locale and options.\n */\nexport class DateTextFormatter {\n private static readonly defaultOptions: SupportedIntlDateTimeFormatOptions = {\n dateStyle: 'medium',\n timeStyle: 'medium'\n } as const;\n\n private readonly formatter: Intl.DateTimeFormat;\n private readonly options: SupportedIntlDateTimeFormatOptions;\n\n public constructor(\n lang: string,\n options?: SupportedIntlDateTimeFormatOptions\n ) {\n this.options = this.resolveOptions(options);\n this.formatter = new Intl.DateTimeFormat(lang, this.options);\n }\n\n public format(value: Date | number | null | undefined): string {\n const milliseconds = this.parseValue(value);\n if (milliseconds === undefined || !Number.isFinite(milliseconds)) {\n return '';\n }\n\n try {\n return this.formatter.format(milliseconds);\n } catch (_e) {\n return '';\n }\n }\n\n public optionsMatch(targetOptions?: SupportedIntlDateTimeFormatOptions): boolean {\n const resolvedTargetOptions = targetOptions ?? DateTextFormatter.defaultOptions;\n for (const name of supportedIntlDateTimeFormatOptionNames) {\n if (this.options[name] !== resolvedTargetOptions[name]) {\n return false;\n }\n }\n return true;\n }\n\n private parseValue(value: Date | number | null | undefined): number | undefined {\n if (value instanceof Date) {\n return value.getTime();\n }\n if (typeof value === 'number') {\n return value;\n }\n return undefined;\n }\n\n private resolveOptions(\n options: SupportedIntlDateTimeFormatOptions | undefined\n ): SupportedIntlDateTimeFormatOptions {\n if (options === undefined) {\n return DateTextFormatter.defaultOptions;\n }\n const supportedOptions: SupportedIntlDateTimeFormatOptions = {};\n for (const name of supportedIntlDateTimeFormatOptionNames) {\n this.resolveOption(supportedOptions, options, name);\n }\n return supportedOptions;\n }\n\n private resolveOption<\n TKey extends keyof SupportedIntlDateTimeFormatOptions\n >(\n target: SupportedIntlDateTimeFormatOptions,\n source: SupportedIntlDateTimeFormatOptions,\n name: TKey\n ): void {\n if (source[name] !== undefined) {\n target[name] = source[name];\n }\n }\n}\n"]}
@@ -21,3 +21,8 @@ export type DayPeriodFormat = Intl.DateTimeFormatOptions['dayPeriod'];
21
21
  export type DateStyle = Intl.DateTimeFormatOptions['dateStyle'];
22
22
  export type TimeStyle = Intl.DateTimeFormatOptions['timeStyle'];
23
23
  export type HourCycleFormat = Intl.DateTimeFormatOptions['hourCycle'];
24
+ /**
25
+ * The `Intl.DateTimeFormatOptions` properties supported by the date-text column and `DateTextFormatter`.
26
+ */
27
+ export declare const supportedIntlDateTimeFormatOptionNames: readonly ["localeMatcher", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "dayPeriod", "timeZoneName", "formatMatcher", "hour12", "timeZone", "calendar", "numberingSystem", "dateStyle", "timeStyle", "hourCycle"];
28
+ export type SupportedIntlDateTimeFormatOptions = Pick<Intl.DateTimeFormatOptions, (typeof supportedIntlDateTimeFormatOptionNames)[number]>;
@@ -5,4 +5,28 @@ export const DateTextFormat = {
5
5
  default: undefined,
6
6
  custom: 'custom'
7
7
  };
8
+ /**
9
+ * The `Intl.DateTimeFormatOptions` properties supported by the date-text column and `DateTextFormatter`.
10
+ */
11
+ export const supportedIntlDateTimeFormatOptionNames = [
12
+ 'localeMatcher',
13
+ 'weekday',
14
+ 'era',
15
+ 'year',
16
+ 'month',
17
+ 'day',
18
+ 'hour',
19
+ 'minute',
20
+ 'second',
21
+ 'dayPeriod',
22
+ 'timeZoneName',
23
+ 'formatMatcher',
24
+ 'hour12',
25
+ 'timeZone',
26
+ 'calendar',
27
+ 'numberingSystem',
28
+ 'dateStyle',
29
+ 'timeStyle',
30
+ 'hourCycle'
31
+ ];
8
32
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/table-column/date-text/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACV,CAAC","sourcesContent":["/**\n * Formatting scheme for the date-text table column\n */\nexport const DateTextFormat = {\n default: undefined,\n custom: 'custom'\n} as const;\nexport type DateTextFormat = (typeof DateTextFormat)[keyof typeof DateTextFormat];\n\nexport type LocaleMatcherAlgorithm = Intl.DateTimeFormatOptions['localeMatcher'];\nexport type WeekdayFormat = Intl.DateTimeFormatOptions['weekday'];\nexport type EraFormat = Intl.DateTimeFormatOptions['era'];\nexport type YearFormat = Intl.DateTimeFormatOptions['year'];\nexport type MonthFormat = Intl.DateTimeFormatOptions['month'];\nexport type DayFormat = Intl.DateTimeFormatOptions['day'];\nexport type HourFormat = Intl.DateTimeFormatOptions['hour'];\nexport type MinuteFormat = Intl.DateTimeFormatOptions['minute'];\nexport type SecondFormat = Intl.DateTimeFormatOptions['second'];\nexport type TimeZoneNameFormat = Intl.DateTimeFormatOptions['timeZoneName'];\nexport type FormatMatcherAlgorithm = Intl.DateTimeFormatOptions['formatMatcher'];\nexport type DayPeriodFormat = Intl.DateTimeFormatOptions['dayPeriod'];\nexport type DateStyle = Intl.DateTimeFormatOptions['dateStyle'];\nexport type TimeStyle = Intl.DateTimeFormatOptions['timeStyle'];\nexport type HourCycleFormat = Intl.DateTimeFormatOptions['hourCycle'];\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/table-column/date-text/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACV,CAAC;AAmBX;;GAEG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG;IAClD,eAAe;IACf,SAAS;IACT,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,cAAc;IACd,eAAe;IACf,QAAQ;IACR,UAAU;IACV,UAAU;IACV,iBAAiB;IACjB,WAAW;IACX,WAAW;IACX,WAAW;CACL,CAAC","sourcesContent":["/**\n * Formatting scheme for the date-text table column\n */\nexport const DateTextFormat = {\n default: undefined,\n custom: 'custom'\n} as const;\nexport type DateTextFormat = (typeof DateTextFormat)[keyof typeof DateTextFormat];\n\nexport type LocaleMatcherAlgorithm = Intl.DateTimeFormatOptions['localeMatcher'];\nexport type WeekdayFormat = Intl.DateTimeFormatOptions['weekday'];\nexport type EraFormat = Intl.DateTimeFormatOptions['era'];\nexport type YearFormat = Intl.DateTimeFormatOptions['year'];\nexport type MonthFormat = Intl.DateTimeFormatOptions['month'];\nexport type DayFormat = Intl.DateTimeFormatOptions['day'];\nexport type HourFormat = Intl.DateTimeFormatOptions['hour'];\nexport type MinuteFormat = Intl.DateTimeFormatOptions['minute'];\nexport type SecondFormat = Intl.DateTimeFormatOptions['second'];\nexport type TimeZoneNameFormat = Intl.DateTimeFormatOptions['timeZoneName'];\nexport type FormatMatcherAlgorithm = Intl.DateTimeFormatOptions['formatMatcher'];\nexport type DayPeriodFormat = Intl.DateTimeFormatOptions['dayPeriod'];\nexport type DateStyle = Intl.DateTimeFormatOptions['dateStyle'];\nexport type TimeStyle = Intl.DateTimeFormatOptions['timeStyle'];\nexport type HourCycleFormat = Intl.DateTimeFormatOptions['hourCycle'];\n\n/**\n * The `Intl.DateTimeFormatOptions` properties supported by the date-text column and `DateTextFormatter`.\n */\nexport const supportedIntlDateTimeFormatOptionNames = [\n 'localeMatcher',\n 'weekday',\n 'era',\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second',\n 'dayPeriod',\n 'timeZoneName',\n 'formatMatcher',\n 'hour12',\n 'timeZone',\n 'calendar',\n 'numberingSystem',\n 'dateStyle',\n 'timeStyle',\n 'hourCycle'\n] as const;\n\nexport type SupportedIntlDateTimeFormatOptions = Pick<\n Intl.DateTimeFormatOptions,\n (typeof supportedIntlDateTimeFormatOptionNames)[number]\n>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ni/nimble-components",
3
- "version": "35.13.3",
3
+ "version": "35.14.1",
4
4
  "description": "Styled web components for the NI Nimble Design System",
5
5
  "scripts": {
6
6
  "build": "npm run build:icons && npm run build:workers && npm run build:components && npm run build:scss && npm run build:cem",
@@ -51,7 +51,7 @@
51
51
  "@ni/fast-foundation": "^10.3.0",
52
52
  "@ni/fast-web-utilities": "^10.1.0",
53
53
  "@ni/nimble-tokens": "^8.19.2",
54
- "@ni/unit-format": "^1.0.7",
54
+ "@ni/unit-format": "^1.0.8",
55
55
  "@tanstack/table-core": "^8.19.3",
56
56
  "@tanstack/virtual-core": "^3.14.0",
57
57
  "@tiptap/core": "^3.27.1",
@@ -91,7 +91,7 @@
91
91
  "@custom-elements-manifest/to-markdown": "^0.1.0",
92
92
  "@ni-private/eslint-config-nimble": "*",
93
93
  "@ni-private/jasmine-extensions": "^0.0.1",
94
- "@ni/jasmine-parameterized": "^1.0.12",
94
+ "@ni/jasmine-parameterized": "^1.0.13",
95
95
  "@rollup/plugin-commonjs": "^29.0.0",
96
96
  "@rollup/plugin-node-resolve": "^16.0.0",
97
97
  "@rollup/plugin-replace": "^6.0.0",
@@ -1,2 +0,0 @@
1
- import type { TableNumberFieldValue } from '../../../table/types';
2
- export declare function formatNumericDate(formatter: Intl.DateTimeFormat, date: TableNumberFieldValue): string;
@@ -1,14 +0,0 @@
1
- export function formatNumericDate(formatter, date) {
2
- if (typeof date === 'number') {
3
- try {
4
- return formatter.format(date);
5
- }
6
- catch (_e) {
7
- return '';
8
- }
9
- }
10
- else {
11
- return '';
12
- }
13
- }
14
- //# sourceMappingURL=format-helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-helper.js","sourceRoot":"","sources":["../../../../../src/table-column/date-text/models/format-helper.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAC7B,SAA8B,EAC9B,IAA2B;IAE3B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,IAAI,CAAC;YACD,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC","sourcesContent":["import type { TableNumberFieldValue } from '../../../table/types';\n\nexport function formatNumericDate(\n formatter: Intl.DateTimeFormat,\n date: TableNumberFieldValue\n): string {\n if (typeof date === 'number') {\n try {\n return formatter.format(date);\n } catch (_e) {\n return '';\n }\n } else {\n return '';\n }\n}\n"]}