AK-21/Graphite-Industrial-Intelligence
0
1/*! *****************************************************************************2Copyright (c) Microsoft Corporation. All rights reserved.3Licensed under the Apache License, Version 2.0 (the "License"); you may not use4this file except in compliance with the License. You may obtain a copy of the5License at http://www.apache.org/licenses/LICENSE-2.06 7THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY8KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED9WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,10MERCHANTABILITY OR NON-INFRINGEMENT.11 12See the Apache Version 2.0 License for specific language governing permissions13and limitations under the License.14***************************************************************************** */15 16 17/// <reference lib="es2018.intl" />18declare namespace Intl {19 /**20 * A string that is a valid [Unicode BCP 47 Locale Identifier](https://unicode.org/reports/tr35/#Unicode_locale_identifier).21 *22 * For example: "fa", "es-MX", "zh-Hant-TW".23 *24 * See [MDN - Intl - locales argument](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).25 */26 type UnicodeBCP47LocaleIdentifier = string;27 28 /**29 * Unit to use in the relative time internationalized message.30 *31 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format#Parameters).32 */33 type RelativeTimeFormatUnit =34 | "year"35 | "years"36 | "quarter"37 | "quarters"38 | "month"39 | "months"40 | "week"41 | "weeks"42 | "day"43 | "days"44 | "hour"45 | "hours"46 | "minute"47 | "minutes"48 | "second"49 | "seconds";50 51 /**52 * Value of the `unit` property in objects returned by53 * `Intl.RelativeTimeFormat.prototype.formatToParts()`. `formatToParts` and54 * `format` methods accept either singular or plural unit names as input,55 * but `formatToParts` only outputs singular (e.g. "day") not plural (e.g.56 * "days").57 *58 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts).59 */60 type RelativeTimeFormatUnitSingular =61 | "year"62 | "quarter"63 | "month"64 | "week"65 | "day"66 | "hour"67 | "minute"68 | "second";69 70 /**71 * The locale matching algorithm to use.72 *73 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).74 */75 type RelativeTimeFormatLocaleMatcher = "lookup" | "best fit";76 77 /**78 * The format of output message.79 *80 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).81 */82 type RelativeTimeFormatNumeric = "always" | "auto";83 84 /**85 * The length of the internationalized message.86 *87 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).88 */89 type RelativeTimeFormatStyle = "long" | "short" | "narrow";90 91 /**92 * The locale or locales to use93 *94 * See [MDN - Intl - locales argument](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).95 */96 type LocalesArgument = UnicodeBCP47LocaleIdentifier | Locale | readonly (UnicodeBCP47LocaleIdentifier | Locale)[] | undefined;97 98 /**99 * An object with some or all of properties of `options` parameter100 * of `Intl.RelativeTimeFormat` constructor.101 *102 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters).103 */104 interface RelativeTimeFormatOptions {105 /** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */106 localeMatcher?: RelativeTimeFormatLocaleMatcher;107 /** The format of output message. */108 numeric?: RelativeTimeFormatNumeric;109 /** The length of the internationalized message. */110 style?: RelativeTimeFormatStyle;111 }112 113 /**114 * An object with properties reflecting the locale115 * and formatting options computed during initialization116 * of the `Intl.RelativeTimeFormat` object117 *118 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions#Description).119 */120 interface ResolvedRelativeTimeFormatOptions {121 locale: UnicodeBCP47LocaleIdentifier;122 style: RelativeTimeFormatStyle;123 numeric: RelativeTimeFormatNumeric;124 numberingSystem: string;125 }126 127 /**128 * An object representing the relative time format in parts129 * that can be used for custom locale-aware formatting.130 *131 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts#Using_formatToParts).132 */133 type RelativeTimeFormatPart =134 | {135 type: "literal";136 value: string;137 }138 | {139 type: Exclude<NumberFormatPartTypes, "literal">;140 value: string;141 unit: RelativeTimeFormatUnitSingular;142 };143 144 interface RelativeTimeFormat {145 /**146 * Formats a value and a unit according to the locale147 * and formatting options of the given148 * [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)149 * object.150 *151 * While this method automatically provides the correct plural forms,152 * the grammatical form is otherwise as neutral as possible.153 *154 * It is the caller's responsibility to handle cut-off logic155 * such as deciding between displaying "in 7 days" or "in 1 week".156 * This API does not support relative dates involving compound units.157 * e.g "in 5 days and 4 hours".158 *159 * @param value - Numeric value to use in the internationalized relative time message160 *161 * @param unit - [Unit](https://tc39.es/ecma402/#sec-singularrelativetimeunit) to use in the relative time internationalized message.162 *163 * @throws `RangeError` if `unit` was given something other than `unit` possible values164 *165 * @returns {string} Internationalized relative time message as string166 *167 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/format).168 */169 format(value: number, unit: RelativeTimeFormatUnit): string;170 171 /**172 * Returns an array of objects representing the relative time format in parts that can be used for custom locale-aware formatting.173 *174 * @param value - Numeric value to use in the internationalized relative time message175 *176 * @param unit - [Unit](https://tc39.es/ecma402/#sec-singularrelativetimeunit) to use in the relative time internationalized message.177 *178 * @throws `RangeError` if `unit` was given something other than `unit` possible values179 *180 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/formatToParts).181 */182 formatToParts(value: number, unit: RelativeTimeFormatUnit): RelativeTimeFormatPart[];183 184 /**185 * Provides access to the locale and options computed during initialization of this `Intl.RelativeTimeFormat` object.186 *187 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions).188 */189 resolvedOptions(): ResolvedRelativeTimeFormatOptions;190 }191 192 /**193 * The [`Intl.RelativeTimeFormat`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)194 * object is a constructor for objects that enable language-sensitive relative time formatting.195 *196 * [Compatibility](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat#Browser_compatibility).197 */198 const RelativeTimeFormat: {199 /**200 * Creates [Intl.RelativeTimeFormat](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) objects201 *202 * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.203 * For the general form and interpretation of the locales argument,204 * see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).205 *206 * @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters)207 * with some or all of options of `RelativeTimeFormatOptions`.208 *209 * @returns [Intl.RelativeTimeFormat](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) object.210 *211 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat).212 */213 new (214 locales?: LocalesArgument,215 options?: RelativeTimeFormatOptions,216 ): RelativeTimeFormat;217 218 /**219 * Returns an array containing those of the provided locales220 * that are supported in date and time formatting221 * without having to fall back to the runtime's default locale.222 *223 * @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.224 * For the general form and interpretation of the locales argument,225 * see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).226 *227 * @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat#Parameters)228 * with some or all of options of the formatting.229 *230 * @returns An array containing those of the provided locales231 * that are supported in date and time formatting232 * without having to fall back to the runtime's default locale.233 *234 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/supportedLocalesOf).235 */236 supportedLocalesOf(237 locales?: LocalesArgument,238 options?: RelativeTimeFormatOptions,239 ): UnicodeBCP47LocaleIdentifier[];240 };241 242 interface NumberFormatOptionsStyleRegistry {243 unit: never;244 }245 246 interface NumberFormatOptionsCurrencyDisplayRegistry {247 narrowSymbol: never;248 }249 250 interface NumberFormatOptionsSignDisplayRegistry {251 auto: never;252 never: never;253 always: never;254 exceptZero: never;255 }256 257 type NumberFormatOptionsSignDisplay = keyof NumberFormatOptionsSignDisplayRegistry;258 259 interface NumberFormatOptions {260 numberingSystem?: string | undefined;261 compactDisplay?: "short" | "long" | undefined;262 notation?: "standard" | "scientific" | "engineering" | "compact" | undefined;263 signDisplay?: NumberFormatOptionsSignDisplay | undefined;264 unit?: string | undefined;265 unitDisplay?: "short" | "long" | "narrow" | undefined;266 currencySign?: "standard" | "accounting" | undefined;267 }268 269 interface ResolvedNumberFormatOptions {270 compactDisplay?: "short" | "long";271 notation: "standard" | "scientific" | "engineering" | "compact";272 signDisplay: NumberFormatOptionsSignDisplay;273 unit?: string;274 unitDisplay?: "short" | "long" | "narrow";275 currencySign?: "standard" | "accounting";276 }277 278 interface NumberFormatPartTypeRegistry {279 compact: never;280 exponentInteger: never;281 exponentMinusSign: never;282 exponentSeparator: never;283 unit: never;284 unknown: never;285 }286 287 interface DateTimeFormatOptions {288 calendar?: string | undefined;289 dayPeriod?: "narrow" | "short" | "long" | undefined;290 numberingSystem?: string | undefined;291 292 dateStyle?: "full" | "long" | "medium" | "short" | undefined;293 timeStyle?: "full" | "long" | "medium" | "short" | undefined;294 hourCycle?: "h11" | "h12" | "h23" | "h24" | undefined;295 }296 297 type LocaleHourCycleKey = "h12" | "h23" | "h11" | "h24";298 type LocaleCollationCaseFirst = "upper" | "lower" | "false";299 300 interface LocaleOptions {301 /** A string containing the language, and the script and region if available. */302 baseName?: string;303 /** The part of the Locale that indicates the locale's calendar era. */304 calendar?: string;305 /** Flag that defines whether case is taken into account for the locale's collation rules. */306 caseFirst?: LocaleCollationCaseFirst;307 /** The collation type used for sorting */308 collation?: string;309 /** The time keeping format convention used by the locale. */310 hourCycle?: LocaleHourCycleKey;311 /** The primary language subtag associated with the locale. */312 language?: string;313 /** The numeral system used by the locale. */314 numberingSystem?: string;315 /** Flag that defines whether the locale has special collation handling for numeric characters. */316 numeric?: boolean;317 /** The region of the world (usually a country) associated with the locale. Possible values are region codes as defined by ISO 3166-1. */318 region?: string;319 /** The script used for writing the particular language used in the locale. Possible values are script codes as defined by ISO 15924. */320 script?: string;321 }322 323 interface Locale extends LocaleOptions {324 /** A string containing the language, and the script and region if available. */325 baseName: string;326 /** The primary language subtag associated with the locale. */327 language: string;328 /** Gets the most likely values for the language, script, and region of the locale based on existing values. */329 maximize(): Locale;330 /** Attempts to remove information about the locale that would be added by calling `Locale.maximize()`. */331 minimize(): Locale;332 /** Returns the locale's full locale identifier string. */333 toString(): UnicodeBCP47LocaleIdentifier;334 }335 336 /**337 * Constructor creates [Intl.Locale](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)338 * objects339 *340 * @param tag - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646).341 * For the general form and interpretation of the locales argument,342 * see the [`Intl` page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).343 *344 * @param options - An [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/Locale#Parameters) with some or all of options of the locale.345 *346 * @returns [Intl.Locale](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale) object.347 *348 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale).349 */350 const Locale: {351 new (tag: UnicodeBCP47LocaleIdentifier | Locale, options?: LocaleOptions): Locale;352 };353 354 type DisplayNamesFallback =355 | "code"356 | "none";357 358 type DisplayNamesType =359 | "language"360 | "region"361 | "script"362 | "calendar"363 | "dateTimeField"364 | "currency";365 366 type DisplayNamesLanguageDisplay =367 | "dialect"368 | "standard";369 370 interface DisplayNamesOptions {371 localeMatcher?: RelativeTimeFormatLocaleMatcher;372 style?: RelativeTimeFormatStyle;373 type: DisplayNamesType;374 languageDisplay?: DisplayNamesLanguageDisplay;375 fallback?: DisplayNamesFallback;376 }377 378 interface ResolvedDisplayNamesOptions {379 locale: UnicodeBCP47LocaleIdentifier;380 style: RelativeTimeFormatStyle;381 type: DisplayNamesType;382 fallback: DisplayNamesFallback;383 languageDisplay?: DisplayNamesLanguageDisplay;384 }385 386 interface DisplayNames {387 /**388 * Receives a code and returns a string based on the locale and options provided when instantiating389 * [`Intl.DisplayNames()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)390 *391 * @param code The `code` to provide depends on the `type` passed to display name during creation:392 * - If the type is `"region"`, code should be either an [ISO-3166 two letters region code](https://www.iso.org/iso-3166-country-codes.html),393 * or a [three digits UN M49 Geographic Regions](https://unstats.un.org/unsd/methodology/m49/).394 * - If the type is `"script"`, code should be an [ISO-15924 four letters script code](https://unicode.org/iso15924/iso15924-codes.html).395 * - If the type is `"language"`, code should be a `languageCode` ["-" `scriptCode`] ["-" `regionCode` ] *("-" `variant` )396 * subsequence of the unicode_language_id grammar in [UTS 35's Unicode Language and Locale Identifiers grammar](https://unicode.org/reports/tr35/#Unicode_language_identifier).397 * `languageCode` is either a two letters ISO 639-1 language code or a three letters ISO 639-2 language code.398 * - If the type is `"currency"`, code should be a [3-letter ISO 4217 currency code](https://www.iso.org/iso-4217-currency-codes.html).399 *400 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/of).401 */402 of(code: string): string | undefined;403 /**404 * Returns a new object with properties reflecting the locale and style formatting options computed during the construction of the current405 * [`Intl/DisplayNames`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames) object.406 *407 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/resolvedOptions).408 */409 resolvedOptions(): ResolvedDisplayNamesOptions;410 }411 412 /**413 * The [`Intl.DisplayNames()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)414 * object enables the consistent translation of language, region and script display names.415 *416 * [Compatibility](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames#browser_compatibility).417 */418 const DisplayNames: {419 prototype: DisplayNames;420 421 /**422 * @param locales A string with a BCP 47 language tag, or an array of such strings.423 * For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)424 * page.425 *426 * @param options An object for setting up a display name.427 *428 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames).429 */430 new (locales: LocalesArgument, options: DisplayNamesOptions): DisplayNames;431 432 /**433 * Returns an array containing those of the provided locales that are supported in display names without having to fall back to the runtime's default locale.434 *435 * @param locales A string with a BCP 47 language tag, or an array of such strings.436 * For the general form and interpretation of the `locales` argument, see the [Intl](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation)437 * page.438 *439 * @param options An object with a locale matcher.440 *441 * @returns An array of strings representing a subset of the given locale tags that are supported in display names without having to fall back to the runtime's default locale.442 *443 * [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/supportedLocalesOf).444 */445 supportedLocalesOf(locales?: LocalesArgument, options?: { localeMatcher?: RelativeTimeFormatLocaleMatcher; }): UnicodeBCP47LocaleIdentifier[];446 };447 448 interface CollatorConstructor {449 new (locales?: LocalesArgument, options?: CollatorOptions): Collator;450 (locales?: LocalesArgument, options?: CollatorOptions): Collator;451 supportedLocalesOf(locales: LocalesArgument, options?: CollatorOptions): string[];452 }453 454 interface DateTimeFormatConstructor {455 new (locales?: LocalesArgument, options?: DateTimeFormatOptions): DateTimeFormat;456 (locales?: LocalesArgument, options?: DateTimeFormatOptions): DateTimeFormat;457 supportedLocalesOf(locales: LocalesArgument, options?: DateTimeFormatOptions): string[];458 }459 460 interface NumberFormatConstructor {461 new (locales?: LocalesArgument, options?: NumberFormatOptions): NumberFormat;462 (locales?: LocalesArgument, options?: NumberFormatOptions): NumberFormat;463 supportedLocalesOf(locales: LocalesArgument, options?: NumberFormatOptions): string[];464 }465 466 interface PluralRulesConstructor {467 new (locales?: LocalesArgument, options?: PluralRulesOptions): PluralRules;468 (locales?: LocalesArgument, options?: PluralRulesOptions): PluralRules;469 470 supportedLocalesOf(locales: LocalesArgument, options?: { localeMatcher?: "lookup" | "best fit"; }): string[];471 }472}473 