@ni/nimble-components 35.13.3 → 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.
- package/dist/all-components-bundle.js +89 -27
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +1193 -1187
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/custom-elements.json +126 -109
- package/dist/custom-elements.md +32 -32
- package/dist/esm/table-column/date-text/cell-view/index.js +1 -2
- package/dist/esm/table-column/date-text/cell-view/index.js.map +1 -1
- package/dist/esm/table-column/date-text/group-header-view/index.js +1 -2
- package/dist/esm/table-column/date-text/group-header-view/index.js.map +1 -1
- package/dist/esm/table-column/date-text/index.d.ts +2 -1
- package/dist/esm/table-column/date-text/index.js +5 -11
- package/dist/esm/table-column/date-text/index.js.map +1 -1
- package/dist/esm/table-column/date-text/models/date-text-formatter.d.ts +15 -0
- package/dist/esm/table-column/date-text/models/date-text-formatter.js +60 -0
- package/dist/esm/table-column/date-text/models/date-text-formatter.js.map +1 -0
- package/dist/esm/table-column/date-text/types.d.ts +5 -0
- package/dist/esm/table-column/date-text/types.js +24 -0
- package/dist/esm/table-column/date-text/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/table-column/date-text/models/format-helper.d.ts +0 -2
- package/dist/esm/table-column/date-text/models/format-helper.js +0 -14
- package/dist/esm/table-column/date-text/models/format-helper.js.map +0 -1
|
@@ -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-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AAO,KAAK,CAAC;QACjB,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAEO,cAAc,CAClB,OAAuD;QAEvD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,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.
|
|
3
|
+
"version": "35.14.0",
|
|
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",
|
|
@@ -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"]}
|