@vertigis/arcgis-extensions 47.0.1 → 47.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/AccessDeniedError.js +1 -1
  2. package/AppConfig.schema.json +6 -2
  3. package/NotFoundError.js +1 -1
  4. package/data/ArcGISServiceTableExtension.js +1 -1
  5. package/data/Feature.d.ts +7 -7
  6. package/data/Feature.js +1 -1
  7. package/data/FeatureList.js +1 -1
  8. package/data/FeatureSaveError.js +1 -1
  9. package/data/FieldExtension.js +1 -1
  10. package/data/Schema.js +1 -1
  11. package/data/convert.d.ts +6 -2
  12. package/data/convert.js +1 -1
  13. package/docs/html/assets/navigation.js +1 -1
  14. package/docs/html/assets/search.js +1 -1
  15. package/docs/html/classes/data_Feature.Feature.html +6 -6
  16. package/docs/html/classes/support_FormatSettings.FormatSettings.html +10 -5
  17. package/docs/html/classes/support_Serializable.SerializableBase.html +1 -1
  18. package/docs/html/classes/utilities_Time.Time.html +11 -0
  19. package/docs/html/classes/{utilities_date.DateFormatter.html → utilities_format_date.DateFormatter.html} +57 -56
  20. package/docs/html/classes/{utilities_number.NumberFormatter.html → utilities_format_number.NumberFormatter.html} +54 -54
  21. package/docs/html/classes/utilities_format_string.StringFormatter.html +49 -0
  22. package/docs/html/classes/utilities_format_time.TimeFormatter.html +137 -0
  23. package/docs/html/enums/{utilities_date.DateFormat.html → utilities_format_formats.DateFormat.html} +12 -11
  24. package/docs/html/enums/{utilities_number.NumberFormat.html → utilities_format_formats.NumberFormat.html} +9 -8
  25. package/docs/html/enums/utilities_format_formats.TimeFormat.html +16 -0
  26. package/docs/html/functions/utilities_field.isNumericFieldType.html +1 -0
  27. package/docs/html/functions/{utilities_date.ERR_TIME_ZONE_INVALID.html → utilities_format_date.ERR_TIME_ZONE_INVALID.html} +1 -1
  28. package/docs/html/functions/{utilities_date.esriFormatToGeocortexFormat.html → utilities_format_date.esriFormatToGeocortexFormat.html} +2 -2
  29. package/docs/html/functions/{utilities_date.format.html → utilities_format_date.format.html} +3 -3
  30. package/docs/html/functions/{utilities_date.isValid.html → utilities_format_date.isValid.html} +1 -1
  31. package/docs/html/functions/{utilities_date.isValidTimeZone.html → utilities_format_date.isValidTimeZone.html} +1 -1
  32. package/docs/html/functions/{utilities_date.parse.html → utilities_format_date.parse.html} +3 -3
  33. package/docs/html/functions/{utilities_date.parseUtc.html → utilities_format_date.parseUtc.html} +3 -3
  34. package/docs/html/functions/{utilities_number.format.html → utilities_format_number.format.html} +3 -3
  35. package/docs/html/functions/{utilities_number.parse.html → utilities_format_number.parse.html} +3 -3
  36. package/docs/html/functions/{utilities_string.format.html → utilities_format_string.format.html} +3 -3
  37. package/docs/html/functions/utilities_format_time.esriFormatToGeocortexFormat.html +5 -0
  38. package/docs/html/functions/utilities_format_time.format.html +9 -0
  39. package/docs/html/functions/utilities_format_time.parse.html +15 -0
  40. package/docs/html/hierarchy.html +1 -1
  41. package/docs/html/interfaces/data_Feature.FormatOptions.html +21 -13
  42. package/docs/html/interfaces/data_convert.FromCsvOptions.html +6 -3
  43. package/docs/html/interfaces/data_convert.FromShapefileOptions.html +6 -3
  44. package/docs/html/interfaces/data_convert.FromXLSXOptions.html +6 -3
  45. package/docs/html/interfaces/data_convert.ToCsvOptions.html +6 -3
  46. package/docs/html/interfaces/data_convert.ToShapefileOptions.html +6 -3
  47. package/docs/html/interfaces/data_convert.ToXLSXOptions.html +6 -3
  48. package/docs/html/interfaces/data_convert.UploadDataOptions.html +6 -3
  49. package/docs/html/interfaces/json_FeatureLayerJson.FeatureLayerJson.html +2 -2
  50. package/docs/html/interfaces/json_StreamLayerJson.StreamLayerJson.html +2 -2
  51. package/docs/html/interfaces/mapping_FeatureLayerExtension.FeatureLayerProperties.html +2 -2
  52. package/docs/html/interfaces/mapping_FeatureLayerExtensionBase.FeatureLayerBaseProperties.html +2 -2
  53. package/docs/html/interfaces/support_FormatSettings.FormatSettingsProperties.html +10 -6
  54. package/docs/html/interfaces/utilities_format_FormatSettings.FormatSettings.html +21 -0
  55. package/docs/html/interfaces/{utilities_date.DateFormatterProperties.html → utilities_format_date.DateFormatterProperties.html} +12 -11
  56. package/docs/html/interfaces/{utilities_date.DateSettings.html → utilities_format_date.DateSettings.html} +6 -5
  57. package/docs/html/interfaces/utilities_format_date.FormatOptions.html +12 -0
  58. package/docs/html/interfaces/utilities_format_date.ParseOptions.html +14 -0
  59. package/docs/html/interfaces/{utilities_number.FormatOptions.html → utilities_format_number.FormatOptions.html} +9 -8
  60. package/docs/html/interfaces/{utilities_number.NumberFormatterProperties.html → utilities_format_number.NumberFormatterProperties.html} +13 -13
  61. package/docs/html/interfaces/{utilities_number.NumberSettings.html → utilities_format_number.NumberSettings.html} +7 -7
  62. package/docs/html/interfaces/{utilities_number.ParseOptions.html → utilities_format_number.ParseOptions.html} +4 -4
  63. package/docs/html/interfaces/utilities_format_string.FormatOptions.html +30 -0
  64. package/docs/html/interfaces/utilities_format_time.FormatOptions.html +7 -0
  65. package/docs/html/interfaces/utilities_format_time.ParseOptions.html +9 -0
  66. package/docs/html/interfaces/utilities_format_time.TimeFormatterProperties.html +14 -0
  67. package/docs/html/interfaces/utilities_format_time.TimeSettings.html +10 -0
  68. package/docs/html/interfaces/utilities_log.LogOptions.html +16 -12
  69. package/docs/html/modules/utilities_FormatSettings.html +3 -3
  70. package/docs/html/modules/utilities_Time.html +2 -0
  71. package/docs/html/modules/utilities_date.html +18 -18
  72. package/docs/html/modules/utilities_format_FormatSettings.html +3 -0
  73. package/docs/html/modules/utilities_format__utils.html +1 -0
  74. package/docs/html/modules/utilities_format_date.html +16 -0
  75. package/docs/html/modules/utilities_format_formats.html +4 -0
  76. package/docs/html/modules/utilities_format_number.html +9 -0
  77. package/docs/html/modules/utilities_format_string.html +5 -0
  78. package/docs/html/modules/utilities_format_time.html +11 -0
  79. package/docs/html/modules/utilities_number.html +11 -11
  80. package/docs/html/modules/utilities_string.html +5 -5
  81. package/docs/html/types/json_FieldJson.FieldJsonType.html +1 -1
  82. package/docs/html/types/json_PopupInfoJson.DateFormatJsonType.html +1 -1
  83. package/docs/html/variables/utilities_format_FormatSettings.settings.html +3 -0
  84. package/docs/html/variables/{utilities_date.DEFAULT_PARSING_FORMATS.html → utilities_format_date.DEFAULT_PARSING_FORMATS.html} +1 -1
  85. package/docs/html/variables/{utilities_date.INVALID_DATE.html → utilities_format_date.INVALID_DATE.html} +1 -1
  86. package/docs/html/variables/{utilities_date.settings.html → utilities_format_date.settings.html} +1 -1
  87. package/docs/html/variables/{utilities_FormatSettings.settings.html → utilities_format_number.settings.html} +1 -2
  88. package/docs/html/variables/utilities_format_time.DEFAULT_PARSING_FORMATS.html +2 -0
  89. package/docs/html/variables/{utilities_number.settings.html → utilities_format_time.settings.html} +1 -1
  90. package/docs/html/variables/version.version.html +1 -1
  91. package/json/FieldJson.d.ts +1 -1
  92. package/json/PopupInfoJson.d.ts +1 -1
  93. package/locale/language.d.ts +1 -1
  94. package/locale/language.js +1 -1
  95. package/mapping/ArcGISSublayerExtension.js +1 -1
  96. package/mapping/FeatureLayerExtensionBase.js +1 -1
  97. package/mapping/SubtypeGroupLayerExtension.js +1 -1
  98. package/mapping/SubtypeSublayerExtension.js +1 -1
  99. package/mapping/_SublayerExtension.js +1 -1
  100. package/mapping/support/featureService.js +1 -1
  101. package/package.json +3 -2
  102. package/portal/Field.d.ts +1 -1
  103. package/portal/Field.js +1 -1
  104. package/portal/Format.d.ts +2 -2
  105. package/support/FormatSettings.d.ts +21 -7
  106. package/support/FormatSettings.js +1 -1
  107. package/support/InitializeError.js +1 -1
  108. package/tasks/identify/IdentifyError.js +1 -1
  109. package/tasks/query/QueryError.js +1 -1
  110. package/tasks/search/SearchError.js +1 -1
  111. package/tasks/search/_utilities.js +1 -1
  112. package/tasks/search/support/_querySearchProviderUtils.js +1 -1
  113. package/utilities/FormatSettings.d.ts +6 -31
  114. package/utilities/FormatSettings.js +1 -1
  115. package/utilities/GeometryServiceError.js +1 -1
  116. package/utilities/Time.d.ts +22 -0
  117. package/utilities/Time.js +1 -0
  118. package/utilities/_wkt.js +1 -1
  119. package/utilities/date.d.ts +35 -349
  120. package/utilities/date.js +1 -1
  121. package/utilities/field.d.ts +2 -0
  122. package/utilities/field.js +1 -1
  123. package/utilities/format/FormatSettings.d.ts +41 -0
  124. package/utilities/format/FormatSettings.js +1 -0
  125. package/utilities/format/_utils.d.ts +1 -0
  126. package/utilities/format/_utils.js +1 -0
  127. package/utilities/format/date.d.ts +336 -0
  128. package/utilities/format/date.js +1 -0
  129. package/utilities/format/formats.d.ts +127 -0
  130. package/utilities/format/formats.js +1 -0
  131. package/utilities/format/number.d.ts +193 -0
  132. package/utilities/format/number.js +1 -0
  133. package/utilities/format/string.d.ts +96 -0
  134. package/utilities/format/string.js +1 -0
  135. package/utilities/format/time.d.ts +206 -0
  136. package/utilities/format/time.js +1 -0
  137. package/utilities/log.d.ts +2 -2
  138. package/utilities/number.d.ts +25 -218
  139. package/utilities/number.js +1 -1
  140. package/utilities/string.d.ts +16 -81
  141. package/utilities/string.js +1 -1
  142. package/version.d.ts +1 -1
  143. package/version.js +1 -1
  144. package/docs/html/classes/utilities_string.StringFormatter.html +0 -42
  145. package/docs/html/interfaces/utilities_FormatSettings.FormatSettings.html +0 -17
  146. package/docs/html/interfaces/utilities_date.FormatOptions.html +0 -9
  147. package/docs/html/interfaces/utilities_date.ParseOptions.html +0 -11
  148. package/docs/html/interfaces/utilities_string.FormatOptions.html +0 -22
@@ -0,0 +1 @@
1
+ import{__decorate as t}from"tslib";import{getMatchingLocales as r,get as e,INVARIANT as i}from"../../locale.js";import{serializable as a,SerializableBase as n}from"../../support/Serializable.js";import{checkArg as s}from"../checkArg.js";import{settings as o}from"./FormatSettings.js";import{NumberFormat as m}from"./formats.js";const c=[" ",String.fromCharCode(160),String.fromCharCode(8239)],l=/[%٪%٪]/g,u=/₩|¥|元|レイ|₾|₽|₼|₺|₹|₸|₴|₲|₱|₮|₭|€|₫|₪|₩|₧|₦|₤IT|₡|‎CN¥‎|​PTE|​|៛|የቻይና ዩዋን|ብር|ლ|฿|සිෆ්එ|රු\.|ಲೀ|રૂ\.|৳|लेई|रू|नेरू|ل\.ل\.‏|ل\.س\.‏|ریال|ر\.ي\.‏|ر\.ق\.‏|ر\.ع\.‏|ر\.س\.‏|ر\.إ\.|د\.م\.‏|د\.ل\.‏|د\.ك\.‏|د\.ع\.‏|د\.س\.‏|د\.ج\.‏|د\.ت\.‏|د\.ب\.‏|د\.إ\.‏|د\.أ\.‏|ج\.م\.‏|ج\.س\.|أ\.م\.‏|؋|ל״י|֏|щ\.д\.|сом|руб\.|руб|р\.|лв\.|крб\.|кр|ден|ТМТ|КМ|Δρχ|öS|Íkr|¥CN|¥|£MT|£LB|£L|£IL|£IE|£GI|£GB|£FK|£E|£CY|£|zł|zl|soʻm|rb|r\.|p\.|mk|ley|leu|lej|lei|kr\.|kr|kn|din\.|den|Zł|ZWR|ZWL|ZWD|ZRZ|ZRN|ZMW|ZMK|ZK|ZAR|ZAL|YUR|YUN|YUM|YUD|YER|YDD|XXXX|XXX|XUA|XTS|XSU|XRE|XPT|XPF|XPD|XOF|XFU|XFO|XEU|XDR|XCD|XBD|XBC|XBB|XBA|XAU|XAG|XAF|WST|WS\$|VUV|VT|VNN|VND|VEF|VEB|UZS|UYU|UYP|UYI|UY\$|USh|USS|USN|USD|US\$|UM|UK£|UGX|UGS|UAK|UAH|Tk|TZS|TWD|TTD|TT\$|TSh|TRY|TRL|TPE|TOP|TND|TMT|TMM|TK|TJS|TJR|THB|T\$|S£|SZL|SYP|SVC|SUR|STN|STD|SSP|SRG|SRD|SR\$|SR|SOS|SLL|SKK|SIT|SI\$|SHP|SGD|SEK|SD£|SDP|SDG|SDD|SCR|SBD|SB\$|SAR|S\/|S\$|S|Rs\.|Rs|Rp|RWF|RUR|RUB|RSD|RON|ROL|RM|RHD|RF|RD\$|R\$|R|QAR|Q|PYG|PTE|PLZ|PLN|PKR|PHP|PGK|PES|PEN|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BRB|BR\$|BOV|BOP|BOL|BOB|BND|BN\$|BMD|BM\$|BIF|BHD|BGO|BGN|BGM|BGL|BGK|BGJ|BEL|BEF|BEC|BDT|BD\$|BBD|BB\$|BAN|BAM|BAD|B\/\.|B\$|Ar|Afl\.|Afl|AZN|AZM|AWG|AUD\$|AUD|AU\$|ATS|ARS|ARP|ARM|ARL|ARA|AR\$|AOR|AON|AOK|AOA|ANG|AMD|ALL|ALK|AFN|AFA|AED|ADP|A\$|\*\*\*|\$ US|\$ SG|\$ NZ|\$ HK|\$ AU|\$b|\$UY|\$US|\$U|\$TT|\$SR|\$SG|\$SB|\$RH|\$NZ|\$NA|\$MX|\$MN|\$HK|\$FJ|\$EC|\$CO|\$CL|\$CA|\$C|\$BZ|\$BS|\$BN|\$BM|\$AU|\$AR|\$/g,D=t=>(Array.isArray(t)?t:[t]).map((t=>t===i?"en":t));export function format(...t){return S.format(...t)}export function parse(...t){return S.parse(...t)}let N=class extends n{get defaultFormat(){return this._defaultFormat}set defaultFormat(t){this._defaultFormat=t}get defaultParseFormat(){return this._defaultParseFormat}set defaultParseFormat(t){this._defaultParseFormat=t}get currency(){return this._currency}set currency(t){this._currency=t}get fractionalDigits(){return this._fractionalDigits}set fractionalDigits(t){this._fractionalDigits=t}locale;_defaultFormat;_defaultParseFormat;_currency;_fractionalDigits;format(...t){let i,a;if(1===t.length?(i=t[0],a={}):arguments.length>=2&&(i=t[1],a="string"==typeof t[0]?{format:t[0]}:t[0],s("options",a).isNotMissing()),null==i||isNaN(i))return"";let n=a.format||this.defaultFormat||m.DEFAULT;if(n===m.ROUND_TRIP)return i.toString();const o=n.toLowerCase();if(o===m.CURRENCY||o===m.ACCOUNTING){const t=a.currency||this.currency||"USD";n=o,n+=a.fractionalDigits??this.fractionalDigits??"",n+=t?`$${t}`:""}else o!==m.NUMBER&&o!==m.FIXED_POINT&&o!==m.PERCENT||(n=o,n+=a.fractionalDigits??this.fractionalDigits??"");a.locale=a.locale||this.locale;const c=r(a.locale||e()),l=`${c.join(";")}|${n}`;let u=R.get(l);if(!u){u=[];const t=n.split(";",3);1===t.length?(u[0]=this._createNumberFormatter(c,t[0]),u[1]=u[0],u[2]=u[0]):2===t.length?(u[0]=this._createNumberFormatter(c,t[0]),u[1]=this._createNumberFormatter(c,t[1]),u[2]=u[0]):3===t.length&&(u[0]=this._createNumberFormatter(c,t[0]),u[1]=this._createNumberFormatter(c,t[1]),u[2]=this._createNumberFormatter(c,t[2])),R.set(l,u)}return i>0?u[0](i):i<0?u[1](i):u[2](i)}parse(...t){let i,a;if(1===t.length?(i=t[0],a={}):t.length>=2&&(i=t[1],a="string"==typeof t[0]||Array.isArray(t[0])?{format:t[0]}:t[0]),"number"==typeof i)return i;if("boolean"==typeof i)return i?1:0;if(null==i)return NaN;let n=i.toString().trim();a.locale=a.locale||this.locale;const s=r(a.locale||e()),o=s.join(";");let c=f.get(o);c||(c=this._createNumberParser(s),f.set(o,c));let D,N=1;n?.startsWith("(")&&n.endsWith(")")&&(N=-1,n=n.slice(1,-1));let F=!1;const R="string"==typeof n&&!!n.match(l);R?D=n.replace(l,"").trim():a.format?.includes(m.CURRENCY)&&(D=n.replace(u,"").replace(/\s/g,""),F=D!==n);let S=c(D??n);if(isNaN(S)&&(S=parseFloat(D??n)),isNaN(S))return S;if(R&&(S/=100),S*=N,F)return S;const C=a.format||this.defaultParseFormat,g=[].concat(C||[]),B=!g.length||g.some((t=>{if(t===m.ROUND_TRIP)return S===parseFloat(S.toString());const r=this._createNumberFormatter(s,t,{minimumFractionDigits:0,maximumFractionDigits:20});if(n===r(S))return!0;const e=t.match($);if(e&&""===e[2])for(let r=0;r<=20;r++){const e=this._createNumberFormatter(s,t,{minimumFractionDigits:r,maximumFractionDigits:r});if(n===e(S))return!0}return!1}));return B?S:NaN}_getSerializableProperties(){return{defaultFormat:"initial",defaultParseFormat:"initial",fractionalDigits:"initial",currency:"initial",locale:"initial"}}_createNumberFormatter(t,r,e){const i=e||{},a=D(t);let n=r.match($);if(n){const t=n[1].toLowerCase(),r=Math.min(20,parseInt(n[2]));let e=n[3];t===m.CURRENCY||t===m.ACCOUNTING?e=(e||this.currency||"USD").toUpperCase():(e="",void 0===i.minimumFractionDigits&&(i.minimumFractionDigits=0),void 0===i.maximumFractionDigits&&(i.maximumFractionDigits=Math.max(4,i.minimumFractionDigits))),t===m.PERCENT?i.style="percent":t===m.ACCOUNTING?i.currencySign="accounting":t===m.FIXED_POINT&&(i.useGrouping=!1),isNaN(r)||(i.minimumFractionDigits=r,i.maximumFractionDigits=r);const s=e?new Intl.NumberFormat(a,{style:"currency",currency:e,...i}):new Intl.NumberFormat(a,i);return t=>s.format(t)}n=r.match(/[0#]+|\.|,|%|\\.|(["'])[^\1]+\1|[^0#.,\\'"]+/g);let s=!1,o="",c="",l="",u="";i.minimumFractionDigits=0,i.maximumFractionDigits=0,i.useGrouping=!1;for(let t of n)switch(t[0]){case".":s=!0;break;case",":i.useGrouping=!0;break;case"%":i.style="percent";break;case"0":case"#":s?c+=t:o+=t;break;default:t.startsWith('"')||t.startsWith("'")?t=t.slice(1,-1):t.startsWith("\\")&&(t=t.slice(1)),o||c?u+=t:l+=t}if(o){const t=o.indexOf("0");t>=0&&(i.minimumIntegerDigits=o.length-t)}if(c){const t=c.lastIndexOf("0");i.minimumFractionDigits=t>=0?t+1:0,i.maximumFractionDigits=Math.min(20,c.length)}if(o||c){const t=new Intl.NumberFormat(a,i);return r=>`${l}${t.format(r)}${u}`}return()=>l+u}_createNumberParser(t){const r=D(t),e=new Intl.NumberFormat(r),i=e.formatToParts(12345.6),a=[...new Intl.NumberFormat(r,{useGrouping:!1}).format(9876543210)].reverse(),n=new Map(a.map(((t,r)=>[t,r]))),s=t=>n.get(t).toString();let o=i.find((t=>"group"===t.type)).value;c.some((t=>t===o))&&(o=`${c.join("|")}`);const m=new RegExp(`[${o}]`,"g"),l=new RegExp(`[${i.find((t=>"decimal"===t.type)).value}]`),u=new RegExp(`[${a.join("")}]`,"g"),N=e.format(-1/0),F=e.format(1/0);return t=>{if(t===F)return Number.POSITIVE_INFINITY;if(t===N)return Number.NEGATIVE_INFINITY;const r=t.trim().replace(m,"").replace(l,".").replace(u,s);return r?+r:NaN}}};N=t([a],N);export{N as NumberFormatter};let F=class extends N{get defaultFormat(){return o.numberFormat}set defaultFormat(t){o.numberFormat=t}get currency(){return o.currency}set currency(t){o.currency=t}get fractionalDigits(){return o.fractionalDigits}set fractionalDigits(t){o.fractionalDigits=t}};F=t([a],F);const R=new Map,f=new Map,$=/^([acfnp])(\d*)(?:\$([a-zA-Z]{3}))?$/i,S=new F;export const settings=S;
@@ -0,0 +1,96 @@
1
+ import type { FormatSettings } from "./FormatSettings.js";
2
+ /**
3
+ * Options supported by {@link format}.
4
+ */
5
+ export interface FormatOptions extends FormatSettings {
6
+ /**
7
+ * The string format. See
8
+ * {@link utilities/format/string!StringFormatter.format}.
9
+ */
10
+ format: string;
11
+ /**
12
+ * The locale to use when formatting numbers and dates. If not specified,
13
+ * the current locale is used (see locale module).
14
+ */
15
+ locale?: string;
16
+ /**
17
+ * Indicates if a formatted date should be formatted without the time
18
+ * component even if the format suggests to include a time.
19
+ */
20
+ isDateOnly?: boolean;
21
+ }
22
+ /**
23
+ * Default settings that affect how strings are formatted.
24
+ */
25
+ export { settings } from "./FormatSettings.js";
26
+ /**
27
+ * See {@link utilities/format/string!StringFormatter.format}.
28
+ *
29
+ * @param format See {@link utilities/format/string!StringFormatter.format}.
30
+ * @param args See {@link utilities/format/string!StringFormatter.format}.
31
+ */
32
+ export declare function format(format: string | FormatOptions, ...args: unknown[]): string;
33
+ /**
34
+ * A helper class for formatting strings.
35
+ */
36
+ export declare class StringFormatter implements FormatSettings {
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ get numberFormat(): string;
41
+ set numberFormat(numberFormat: string);
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ get dateFormat(): string;
46
+ set dateFormat(dateFormat: string);
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ get timeFormat(): string;
51
+ set timeFormat(timeFormat: string);
52
+ /**
53
+ * @inheritDoc
54
+ */
55
+ get currency(): string;
56
+ set currency(currency: string);
57
+ /**
58
+ * @inheritDoc
59
+ */
60
+ get fractionalDigits(): number;
61
+ set fractionalDigits(fractionalDigits: number);
62
+ /**
63
+ * @inheritDoc
64
+ */
65
+ get timeZone(): string;
66
+ /**
67
+ * @inheritDoc
68
+ */
69
+ set timeZone(value: string);
70
+ private _numberFormat;
71
+ private _dateFormat;
72
+ private _timeFormat;
73
+ private _currency;
74
+ private _fractionalDigits;
75
+ private _timeZone;
76
+ private readonly _numberFormatter;
77
+ private readonly _dateFormatter;
78
+ private readonly _timeFormatter;
79
+ /**
80
+ * Converts the value of objects to strings based on the formats specified
81
+ * and inserts them into another string.
82
+ *
83
+ * @param formatOrOptions The format string that acts as a template. The
84
+ * format string can contain one or more format items, which have this
85
+ * syntax: `{index[:format]}`. The index is the zero-based index of the
86
+ * argument whose string representation is to be included at this position
87
+ * in the string. The optional format is a format string that controls how
88
+ * the argument is converted into a string, if the argument is a Date
89
+ * object or number. To include a literal `{` or `}` character in the
90
+ * output, escape the character by repeating it twice in the format
91
+ * string. This argument can also be a format options object instead.
92
+ * @param args The values to substitute into the format string. Null and
93
+ * undefined values will be converted into empty strings.
94
+ */
95
+ format(formatOrOptions: string | FormatOptions, ...args: unknown[]): string;
96
+ }
@@ -0,0 +1 @@
1
+ import{Time as t}from"../Time.js";import{checkArg as e}from"../checkArg.js";import{settings as r}from"./FormatSettings.js";import{DateFormatter as o,isValidTimeZone as i,ERR_TIME_ZONE_INVALID as a}from"./date.js";import{NumberFormatter as m}from"./number.js";import{TimeFormatter as n}from"./time.js";export{settings}from"./FormatSettings.js";export function format(t,...e){return s.format(t,...e)}export class StringFormatter{get numberFormat(){return this._numberFormat}set numberFormat(t){this._numberFormat=t}get dateFormat(){return this._dateFormat}set dateFormat(t){this._dateFormat=t}get timeFormat(){return this._timeFormat}set timeFormat(t){this._timeFormat=t}get currency(){return this._currency}set currency(t){this._currency=t}get fractionalDigits(){return this._fractionalDigits}set fractionalDigits(t){this._fractionalDigits=t}get timeZone(){return this._timeZone}set timeZone(t){e("timezone",t).satisfies((t=>i(t)),a(t)),this._timeZone=t}_numberFormat;_dateFormat;_timeFormat;_currency;_fractionalDigits;_timeZone;_numberFormatter=new m;_dateFormatter=new o;_timeFormatter=new n;format(r,...o){const i="string"==typeof r?{format:r}:r;e("options",i).isNotMissing();let{format:a}=i;e("format",a).isNotMissing(),a=a.replace(u,g);return a.replace(c,((r,a,m)=>{const n=parseInt(a);let s,c;try{e(`token ${a}`,a).isInRange(0,o.length-1),s=o[n]}catch(t){const e=parseInt(a,10);if(isNaN(e)||e<0)throw t;console.warn(`Error encountered while formatting string: ${t.message}`)}if("number"==typeof s){const t={locale:i.locale,format:m||i.numberFormat||this.numberFormat,currency:i.currency||this.currency,fractionalDigits:i.fractionalDigits??this.fractionalDigits};c=this._numberFormatter.format(t,s)}else if(s instanceof Date){const t={locale:i.locale,format:m||i.dateFormat||this.dateFormat,timeZone:i.timeZone||this.timeZone,isDateOnly:i.isDateOnly};c=this._dateFormatter.format(t,s)}else if(s instanceof t){const t={locale:i.locale,format:m||i.timeFormat||this.timeFormat};c=this._timeFormatter.format(t,s)}else c=null==s?"":String(s);return c})).replace(F,"{").replace("}}","}")}}const s=new class extends StringFormatter{get numberFormat(){return r.numberFormat}set numberFormat(t){r.numberFormat=t}get dateFormat(){return r.dateFormat}set dateFormat(t){r.dateFormat=t}get timeFormat(){return r.timeFormat}set timeFormat(t){r.timeFormat=t}get timeZone(){return r.timeZone}set timeZone(t){r.timeZone=t}get currency(){return r.currency}set currency(t){r.currency=t}get fractionalDigits(){return r.fractionalDigits}set fractionalDigits(t){r.fractionalDigits=t}},c=/\{([-\d]+)(?::([^}]*))?\}/g,u=/{{/g,g="\0MAGIC\0",F=new RegExp(g,"g");
@@ -0,0 +1,206 @@
1
+ import type { PropertyDefs } from "../../support/Serializable.js";
2
+ import { SerializableBase } from "../../support/Serializable.js";
3
+ import { Time } from "../Time.js";
4
+ /**
5
+ * The default set of formats used for parsing time values.
6
+ */
7
+ export declare const DEFAULT_PARSING_FORMATS: string[];
8
+ /**
9
+ * Default settings that affect how times are formatted and parsed.
10
+ */
11
+ export interface TimeSettings {
12
+ /**
13
+ * The default format for formatting times. See
14
+ * {@link utilities/format/time!TimeFormatter.format}.
15
+ */
16
+ defaultFormat?: string;
17
+ /**
18
+ * Either a single format, or one of several possible formats that the input
19
+ * is expected to be in. If specified, the input must _exactly_ match. The
20
+ * syntax is the same as for
21
+ * {@link utilities/format/time!TimeFormatter.format}.
22
+ */
23
+ defaultParseFormat?: string | string[];
24
+ }
25
+ /**
26
+ * Options supported by {@link format}.
27
+ */
28
+ export interface FormatOptions {
29
+ /**
30
+ * The locale to use when formatting the time. If not specified, the current
31
+ * locale is used (see locale module).
32
+ */
33
+ locale?: string;
34
+ /**
35
+ * The time format. See {@link utilities/format/time!TimeFormatter.format}.
36
+ */
37
+ format?: string;
38
+ }
39
+ /**
40
+ * Options supported by {@link parse}.
41
+ */
42
+ export interface ParseOptions {
43
+ /**
44
+ * The locale to use when parsing the time. If not specified, the current
45
+ * locale is used (see locale module).
46
+ */
47
+ locale?: string;
48
+ /**
49
+ * Either a single format, or one of several possible formats that the input
50
+ * is expected to be in. If specified, the input must _exactly_ match. See
51
+ * {@link utilities/format/time!TimeFormatter.format}.
52
+ */
53
+ format?: string | string[];
54
+ }
55
+ /**
56
+ * Formats a time object representing a specific time.
57
+ *
58
+ * @param time The time to format.
59
+ */
60
+ export declare function format(time: Time): string;
61
+ /**
62
+ * Formats a time object representing a specific time for display.
63
+ *
64
+ * @param format See {@link utilities/format/time!TimeFormatter.format}.
65
+ * @param time The time to format.
66
+ */
67
+ export declare function format(format: string, time: Time): string;
68
+ /**
69
+ * Formats a time object representing a specific time for display.
70
+ *
71
+ * @param options Specifies the format settings to use.
72
+ * @param time The time to format.
73
+ */
74
+ export declare function format(options: FormatOptions, time: Time): string;
75
+ /**
76
+ * Parses a value into a Time object.
77
+ *
78
+ * @param input The input to parse.
79
+ * @returns A Time object corresponding to the input. If unable to parse
80
+ * successfully, will return an invalid Time.
81
+ */
82
+ export declare function parse(input: unknown): Time;
83
+ /**
84
+ * Parses a value into a Time object.
85
+ *
86
+ * @param format See {@link ParseOptions.format}.
87
+ * @param input The input to parse.
88
+ * @returns A Time object corresponding to the input. If unable to parse
89
+ * successfully, will return an invalid Time.
90
+ */
91
+ export declare function parse(format: string | string[], input: unknown): Time;
92
+ /**
93
+ * Parses a value into a Time object.
94
+ *
95
+ * @param options The options to use for parsing.
96
+ * @param input The input to parse.
97
+ * @returns A Time object corresponding to the input. If unable to parse
98
+ * successfully, will return an invalid Time.
99
+ */
100
+ export declare function parse(options: ParseOptions, input: unknown): Time;
101
+ /**
102
+ * Converts an Esri-style date format constant for a time (e.g.
103
+ * "short-date-short-time") to a format string that can be used with
104
+ * {@link format} and {@link parse}.
105
+ *
106
+ * @param format The Esri-style format constant to convert.
107
+ */
108
+ export declare function esriFormatToGeocortexFormat(format: string): string;
109
+ /**
110
+ * Properties that can be passed into the constructor for
111
+ * {@link utilities/format/time!TimeFormatter}.
112
+ */
113
+ export interface TimeFormatterProperties extends TimeSettings {
114
+ /**
115
+ * The locale to use when formatting & parsing the number. If not specified,
116
+ * the current locale is used (see locale module).
117
+ */
118
+ locale?: string;
119
+ }
120
+ /**
121
+ * A helper class for formatting and parsing times.
122
+ */
123
+ export declare class TimeFormatter extends SerializableBase<TimeFormatterProperties> implements TimeSettings {
124
+ /**
125
+ * @inheritDoc
126
+ */
127
+ get defaultFormat(): string | undefined;
128
+ /**
129
+ * @inheritDoc
130
+ */
131
+ set defaultFormat(value: string | undefined);
132
+ /**
133
+ * @inheritDoc
134
+ */
135
+ defaultParseFormat: string | undefined;
136
+ /**
137
+ * The locale to use when formatting & parsing the time. If not specified,
138
+ * the current locale is used (see locale module).
139
+ */
140
+ locale: string | undefined;
141
+ private _defaultFormat;
142
+ /**
143
+ * Formats a time for display.
144
+ *
145
+ * @param time The time to format.
146
+ */
147
+ format(time: Time): string;
148
+ /**
149
+ * Formats a time for display.
150
+ *
151
+ * @param time The time to format.
152
+ * @param format The format for presenting times. One of the
153
+ * {@link utilities/format/formats!TimeFormat} constants, or a custom
154
+ * format string. The format string syntax is similar to
155
+ * {@link https://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx}, with the
156
+ * following exceptions:
157
+ *
158
+ * - ":" is treated as a literal character.
159
+ * - "t" is treated the same as "tt".
160
+ * - "F", "FF", "FFF" etc. will behave the same as "f", "ff", "fff", etc.
161
+ * Additionally, a maximum of 3 digits (milliseconds) is supported.
162
+ * Longer formatters like "fffff" are truncated to 3 digits, rather
163
+ * than padded with zeros.
164
+ * - "K" is not supported at all and will be ignored. If not specified, it
165
+ * will default to TIME_SHORT.
166
+ */
167
+ format(format: string, time: Time): string;
168
+ /**
169
+ * Formats a time for display.
170
+ *
171
+ * @param time The time to format.
172
+ * @param options Options that control how the time is formatted.
173
+ */
174
+ format(options: FormatOptions, time: Time): string;
175
+ /**
176
+ * Parses a value into a Time object.
177
+ *
178
+ * @param input The input to parse.
179
+ * @returns A Time object corresponding to the input. If unable to parse
180
+ * successfully, will return an invalid Time.
181
+ */
182
+ parse(input: unknown): Time;
183
+ /**
184
+ * Parses a value into a Time object.
185
+ *
186
+ * @param input The input to parse.
187
+ * @param format See {@link ParseOptions.format}.
188
+ * @returns A Time object corresponding to the input. If unable to parse
189
+ * successfully, will return an invalid Time.
190
+ */
191
+ parse(format: string | string[], input: unknown): Time;
192
+ /**
193
+ * Parses a value into a Time object.
194
+ *
195
+ * @param input The input to parse.
196
+ * @param options The options to use for parsing.
197
+ * @returns A Time object corresponding to the input. If unable to parse
198
+ * successfully, will return an invalid Time.
199
+ */
200
+ parse(options: ParseOptions, input: unknown): Time;
201
+ protected _getSerializableProperties(): PropertyDefs<TimeFormatterProperties>;
202
+ }
203
+ /**
204
+ * Default settings used for formatting and parsing times.
205
+ */
206
+ export declare const settings: TimeSettings;
@@ -0,0 +1 @@
1
+ import{__decorate as t}from"tslib";import{DateTime as e}from"luxon";import{get as o,INVARIANT as r}from"../../locale.js";import{serializable as a,SerializableBase as s}from"../../support/Serializable.js";import{Time as n}from"../Time.js";import{settings as i}from"./FormatSettings.js";import{gcxDateTimeFormatToLuxonFormat as m}from"./_utils.js";import{TimeFormat as l}from"./formats.js";export const DEFAULT_PARSING_FORMATS=[l.ISO_8601,l.TIME_SHORT,l.TIME_LONG];export function format(...t){return d.format(...t)}export function parse(...t){return d.parse(...t)}export function esriFormatToGeocortexFormat(t){switch(t){case"short-date-short-time":case"short-date-le-short-time":case"long-month-day-year-short-time":case"day-short-month-year-short-time":case"long-date-short-time":return"t";case"short-date-short-time-24":case"short-date-le-short-time-24":case"long-month-day-year-short-time-24":case"long-date-short-time-24":case"day-short-month-year-short-time-24":return"εσρι H:mm";case"short-date-long-time":case"short-date-le-long-time":case"long-month-day-year-long-time":case"long-date-long-time":case"day-short-month-year-long-time":return"T";case"short-date-long-time-24":case"short-date-le-long-time-24":case"long-month-day-year-long-time-24":case"long-date-long-time-24":case"day-short-month-year-long-time-24":return"εσρι H:mm:ss";default:throw new Error(`Unrecognized time format constant: ${t}`)}}let c=class extends s{get defaultFormat(){return this._defaultFormat}set defaultFormat(t){this._defaultFormat=t}defaultParseFormat;locale;_defaultFormat;format(t,a){let s=a,i={};t instanceof n?s=t:i="string"==typeof t?{format:t}:t;const c=s.toDate();if(isNaN(c.getTime()))return"";const f=i.format||this.defaultFormat||l.DEFAULT,d=m(f);if("ISO-8601"===d)return s.toString();let u=i.locale||this.locale||o();u===r&&(u="en");return e.fromJSDate(c).setLocale(u).toFormat(d)}parse(t,r){let a,s=r;if(null==r?(s=t,a={}):a="string"==typeof t||Array.isArray(t)?{format:t}:t,s instanceof n)return s;if("string"!=typeof s)return new n(new Date(NaN));const i=a.format??this.defaultParseFormat??DEFAULT_PARSING_FORMATS,l=[].concat(i),c={locale:a.locale??this.locale??o()};for(const t of l){const o=m(t);if("ISO-8601"===o){const t=new n(s);if(t.isValid)return t}else{const t=e.fromFormat(s,o,c);if(t.isValid){const e=t.toJSDate();return new n(`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}`)}}}return new n(new Date(NaN))}_getSerializableProperties(){return{defaultFormat:"initial",defaultParseFormat:"initial",locale:"initial"}}};c=t([a],c);export{c as TimeFormatter};let f=class extends c{get defaultFormat(){return i.timeFormat}set defaultFormat(t){i.timeFormat=t}};f=t([a],f);const d=new f;export const settings=d;
@@ -22,8 +22,8 @@ export type LoggerFactory = (name: string, logManager: LogManager) => Logger;
22
22
  export interface LogOptions extends FormatSettings {
23
23
  /**
24
24
  * A string representing the log message. The format is the same as the
25
- * syntax for {@link utilities/string!StringFormatter.format}, allowing for
26
- * positional arguments.
25
+ * syntax for {@link utilities/format/string!StringFormatter.format},
26
+ * allowing for positional arguments.
27
27
  */
28
28
  message?: string;
29
29
  /**
@@ -1,239 +1,46 @@
1
- import type { PropertyDefs } from "../support/Serializable.js";
2
- import { SerializableBase } from "../support/Serializable.js";
1
+ export type {
3
2
  /**
4
- * Pre-defined format specifiers for use with format().
3
+ * @deprecated Use {@link utilities/format/number!NumberSettings}.
5
4
  */
6
- export declare enum NumberFormat {
7
- /**
8
- * A localized representation of a number with a decimal separator and group
9
- * separators (e.g. "12,345.67", "-42" for en-US locale).
10
- */
11
- NUMBER = "n",
12
- /**
13
- * A localized representation of a number with a decimal separator (e.g.
14
- * "12345.67", "-42" for en-US locale).
15
- */
16
- FIXED_POINT = "f",
17
- /**
18
- * A localized representation of a monetary amount in a specific currency
19
- * (e.g. "$123.45" for USD, "£123.45" for GBP for en-US locale).
20
- */
21
- CURRENCY = "c",
22
- /**
23
- * Same as CURRENCY, except that negative values are displayed in
24
- * parentheses instead of using a "-" sign.
25
- */
26
- ACCOUNTING = "a",
27
- /**
28
- * A localized representation of a percentage (e.g. 0.99 -> "99%" in the
29
- * en-US locale).
30
- */
31
- PERCENT = "p",
32
- /**
33
- * An invariant representation of a number (e.g. "12345.67"). Guarantees
34
- * that the number can be parsed back into the same number, regardless of
35
- * locale.
36
- */
37
- ROUND_TRIP = "r",
38
- /**
39
- * The default representation for number values (equivalent to FIXED_POINT).
40
- */
41
- DEFAULT = "f"
42
- }
5
+ NumberSettings,
43
6
  /**
44
- * Default settings that affect how numbers are formatted and parsed.
7
+ * @deprecated Use {@link utilities/format/number!FormatOptions}.
45
8
  */
46
- export interface NumberSettings {
47
- /**
48
- * The default format for formatting numbers. See
49
- * {@link utilities/number!NumberFormatter.format}.
50
- */
51
- defaultFormat?: string;
52
- /**
53
- * Either a single format, or one of several possible formats that the input
54
- * is expected to be in. If specified, the input must _exactly_ match. The
55
- * syntax is the same as for
56
- * {@link utilities/number!NumberFormatter.format}.
57
- */
58
- defaultParseFormat?: string | string[];
59
- /**
60
- * The 3-letter ISO 4217 currency code (e.g "USD", "CAD"). Required when
61
- * formatting a number using NumberFormat.CURRENCY or
62
- * NumberFormat.ACCOUNTING.
63
- */
64
- currency?: string;
65
- /**
66
- * The number of digits to show after the decimal point. If unspecified, an
67
- * appropriate value is determined based on the locale and currency.
68
- */
69
- fractionalDigits?: number;
70
- }
9
+ FormatOptions,
71
10
  /**
72
- * Options supported by {@link format}.
11
+ * @deprecated Use {@link utilities/format/number!ParseOptions}.
73
12
  */
74
- export interface FormatOptions {
75
- /**
76
- * The locale to use when formatting the number. If not specified, the
77
- * current locale is used (see locale module).
78
- */
79
- locale?: string;
80
- /**
81
- * The number format. See {@link utilities/number!NumberFormatter.format}.
82
- */
83
- format?: string;
84
- /**
85
- * See {@link NumberSettings.currency}.
86
- */
87
- currency?: string;
88
- /**
89
- * See {@link NumberSettings.fractionalDigits}.
90
- */
91
- fractionalDigits?: number;
92
- }
13
+ ParseOptions,
93
14
  /**
94
- * Options supported by {@link parse}.
15
+ * @deprecated Use {@link utilities/format/number!NumberFormatterProperties}.
95
16
  */
96
- export interface ParseOptions {
97
- /**
98
- * The locale to use when parsing the number. If not specified, the current
99
- * locale is used (see locale module).
100
- */
101
- locale?: string;
102
- /**
103
- * Either a single format, or one of several possible formats that the input
104
- * is expected to be in. If specified, the input must _exactly_ match. See
105
- * {@link NumberFormatter.format}.
106
- */
107
- format?: string | string[];
108
- }
17
+ NumberFormatterProperties, } from "./format/number.js";
18
+ export {
109
19
  /**
110
- * Determines whether a value is numeric, i.e. a number or a numeric string.
111
- *
112
- * @param value The value to check.
113
- * @param locale The locale to use when parsing string values.
20
+ * @deprecated Use {@link utilities/format/number!format}.
114
21
  */
115
- export declare function isNumeric(value: unknown, locale?: string): boolean;
22
+ format,
116
23
  /**
117
- * Formats a number for display in the current locale.
118
- *
119
- * @param num The number to format.
24
+ * @deprecated Use {@link utilities/format/number!parse}.
120
25
  */
121
- export declare function format(num: number): string;
26
+ parse,
122
27
  /**
123
- * Formats a number for display.
124
- *
125
- * @param format See {@link utilities/number!NumberFormatter.format}.
126
- * @param num The number to format.
28
+ * @deprecated Use {@link utilities/format/number!NumberFormatter}.
127
29
  */
128
- export declare function format(format: string, num: number): string;
30
+ NumberFormatter,
129
31
  /**
130
- * Formats a number for display.
131
- *
132
- * @param options Specifies the format settings to use.
133
- * @param num The number to format.
134
- */
135
- export declare function format(options: FormatOptions, num: number): string;
136
- /**
137
- * Parses a value into a number.
138
- *
139
- * @param input The input to parse.
140
- * @returns A number corresponding to the input, or NaN if the input can't be
141
- * parsed.
32
+ * @deprecated Use {@link utilities/format/number!settings}.
142
33
  */
143
- export declare function parse(input: unknown): number;
34
+ settings, } from "./format/number.js";
35
+ export {
144
36
  /**
145
- * Parses a value into a number.
146
- *
147
- * @param format See {@link ParseOptions.format}.
148
- * @param input The input to parse.
149
- * @returns A number corresponding to the input, or NaN if the input can't be
150
- * parsed.
37
+ * @deprecated Use {@link utilities/format/formats!NumberFormat}.
151
38
  */
152
- export declare function parse(format: string | string[], input: unknown): number;
39
+ NumberFormat, } from "./format/formats.js";
153
40
  /**
154
- * Parses a value into a number.
41
+ * Determines whether a value is numeric, i.e. a number or a numeric string.
155
42
  *
156
- * @param options The options to use for parsing.
157
- * @param input The input to parse.
158
- * @returns A number corresponding to the input, or NaN if the input can't be
159
- * parsed.
160
- */
161
- export declare function parse(options: ParseOptions, input: unknown): number;
162
- /**
163
- * Properties that can be passed into the constructor for
164
- * {@link utilities/number!NumberFormatter}.
165
- */
166
- export interface NumberFormatterProperties extends NumberSettings {
167
- /**
168
- * The locale to use when formatting & parsing the number. If not specified,
169
- * the current locale is used (see locale module).
170
- */
171
- locale?: string;
172
- }
173
- /**
174
- * A helper class for formatting and parsing numbers.
175
- */
176
- export declare class NumberFormatter extends SerializableBase<NumberFormatterProperties> implements NumberSettings {
177
- /**
178
- * @inheritDoc
179
- */
180
- get defaultFormat(): string;
181
- set defaultFormat(defaultFormat: string);
182
- /**
183
- * @inheritDoc
184
- */
185
- get defaultParseFormat(): string;
186
- set defaultParseFormat(defaultParseFormat: string);
187
- /**
188
- * @inheritDoc
189
- */
190
- get currency(): string;
191
- set currency(currency: string);
192
- /**
193
- * @inheritDoc
194
- */
195
- get fractionalDigits(): number;
196
- set fractionalDigits(fractionalDigits: number);
197
- /**
198
- * The locale to use when formatting & parsing the number. If not specified,
199
- * the current locale is used (see locale module).
200
- */
201
- locale: string;
202
- private _defaultFormat;
203
- private _defaultParseFormat;
204
- private _currency;
205
- private _fractionalDigits;
206
- /**
207
- * See {@link format}.
208
- */
209
- format(format: string, num: number): string;
210
- format(options: FormatOptions, num: number): string;
211
- format(num: number): string;
212
- /**
213
- * See {@link parse}.
214
- */
215
- parse(input: unknown): number;
216
- parse(format: string | string[], input: unknown): number;
217
- parse(options: ParseOptions, input: unknown): number;
218
- protected _getSerializableProperties(): PropertyDefs<NumberFormatterProperties>;
219
- /**
220
- * Converts a format string accepted by formatNumber() to formatter
221
- * function.
222
- *
223
- * @param inputLocales The locale.
224
- * @param format The format to use.
225
- * @param defaultOptions Options that control how values are formatted.
226
- */
227
- private _createNumberFormatter;
228
- /**
229
- * Create a numeric parser function for a set of locales.
230
- *
231
- * @param inputLocales An ordered array of locales to be used for parsing
232
- * sorted in order of precedence.
233
- */
234
- private _createNumberParser;
235
- }
236
- /**
237
- * Default settings used for formatting and parsing numbers.
43
+ * @param value The value to check.
44
+ * @param locale The locale to use when parsing string values.
238
45
  */
239
- export declare const settings: NumberSettings;
46
+ export declare function isNumeric(value: unknown, locale?: string): boolean;
@@ -1 +1 @@
1
- import{__decorate as t}from"tslib";import{getMatchingLocales as r,get as e,INVARIANT as i}from"../locale.js";import{serializable as a,SerializableBase as n}from"../support/Serializable.js";import{settings as o}from"./FormatSettings.js";import{isNumericInvariant as s}from"./_number.js";import{checkArg as m}from"./checkArg.js";const c=[" ",String.fromCharCode(160),String.fromCharCode(8239)],u=/[%٪%٪]/g,N=/₩|¥|元|レイ|₾|₽|₼|₺|₹|₸|₴|₲|₱|₮|₭|€|₫|₪|₩|₧|₦|₤IT|₡|‎CN¥‎|​PTE|​|៛|የቻይና ዩዋን|ብር|ლ|฿|සිෆ්එ|රු\.|ಲೀ|રૂ\.|৳|लेई|रू|नेरू|ل\.ل\.‏|ل\.س\.‏|ریال|ر\.ي\.‏|ر\.ق\.‏|ر\.ع\.‏|ر\.س\.‏|ر\.إ\.|د\.م\.‏|د\.ل\.‏|د\.ك\.‏|د\.ع\.‏|د\.س\.‏|د\.ج\.‏|د\.ت\.‏|د\.ب\.‏|د\.إ\.‏|د\.أ\.‏|ج\.م\.‏|ج\.س\.|أ\.م\.‏|؋|ל״י|֏|щ\.д\.|сом|руб\.|руб|р\.|лв\.|крб\.|кр|ден|ТМТ|КМ|Δρχ|öS|Íkr|¥CN|¥|£MT|£LB|£L|£IL|£IE|£GI|£GB|£FK|£E|£CY|£|zł|zl|soʻm|rb|r\.|p\.|mk|ley|leu|lej|lei|kr\.|kr|kn|din\.|den|Zł|ZWR|ZWL|ZWD|ZRZ|ZRN|ZMW|ZMK|ZK|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ENT="p",t.ROUND_TRIP="r",t.DEFAULT="f"}(NumberFormat||(NumberFormat={}));export function isNumeric(t,r="inv"){return r&&"inv"!==r&&"string"==typeof t?!isNaN(parse({locale:r},t)):s(t)}export function format(...t){return S.format(...t)}export function parse(...t){return S.parse(...t)}let F=class extends n{get defaultFormat(){return this._defaultFormat}set defaultFormat(t){this._defaultFormat=t}get defaultParseFormat(){return this._defaultParseFormat}set defaultParseFormat(t){this._defaultParseFormat=t}get currency(){return this._currency}set currency(t){this._currency=t}get fractionalDigits(){return this._fractionalDigits}set fractionalDigits(t){this._fractionalDigits=t}locale;_defaultFormat;_defaultParseFormat;_currency;_fractionalDigits;format(...t){let i,a;if(1===t.length?(i=t[0],a={}):arguments.length>=2&&(i=t[1],a="string"==typeof t[0]?{format:t[0]}:t[0],m("options",a).isNotMissing()),null==i||isNaN(i))return"";let n=a.format||this.defaultFormat||NumberFormat.DEFAULT;if(n===NumberFormat.ROUND_TRIP)return i.toString();const o=n.toLowerCase();if(o===NumberFormat.CURRENCY||o===NumberFormat.ACCOUNTING){const t=a.currency||this.currency||"USD";n=o,n+=a.fractionalDigits??this.fractionalDigits??"",n+=t?`$${t}`:""}else o!==NumberFormat.NUMBER&&o!==NumberFormat.FIXED_POINT&&o!==NumberFormat.PERCENT||(n=o,n+=a.fractionalDigits??this.fractionalDigits??"");a.locale=a.locale||this.locale;const s=r(a.locale||e()),c=`${s.join(";")}|${n}`;let u=R.get(c);if(!u){u=[];const t=n.split(";",3);1===t.length?(u[0]=this._createNumberFormatter(s,t[0]),u[1]=u[0],u[2]=u[0]):2===t.length?(u[0]=this._createNumberFormatter(s,t[0]),u[1]=this._createNumberFormatter(s,t[1]),u[2]=u[0]):3===t.length&&(u[0]=this._createNumberFormatter(s,t[0]),u[1]=this._createNumberFormatter(s,t[1]),u[2]=this._createNumberFormatter(s,t[2])),R.set(c,u)}return i>0?u[0](i):i<0?u[1](i):u[2](i)}parse(...t){let i,a;if(1===t.length?(i=t[0],a={}):t.length>=2&&(i=t[1],a="string"==typeof t[0]||Array.isArray(t[0])?{format:t[0]}:t[0]),"number"==typeof i)return i;if("boolean"==typeof i)return i?1:0;if(null==i)return NaN;let n=i.toString().trim();a.locale=a.locale||this.locale;const o=r(a.locale||e()),s=o.join(";");let m=f.get(s);m||(m=this._createNumberParser(o),f.set(s,m));let c,l=1;n?.startsWith("(")&&n.endsWith(")")&&(l=-1,n=n.slice(1,-1));let F=!1;const D="string"==typeof n&&!!n.match(u);D?c=n.replace(u,"").trim():a.format?.includes(NumberFormat.CURRENCY)&&(c=n.replace(N,"").replace(/\s/g,""),F=c!==n);let R=m(c??n);if(isNaN(R)&&(R=parseFloat(c??n)),isNaN(R))return R;if(D&&(R/=100),R*=l,F)return R;const S=a.format||this.defaultParseFormat,C=[].concat(S||[]),g=!C.length||C.some((t=>{if(t===NumberFormat.ROUND_TRIP)return R===parseFloat(R.toString());const r=this._createNumberFormatter(o,t,{minimumFractionDigits:0,maximumFractionDigits:20});if(n===r(R))return!0;const e=t.match($);if(e&&""===e[2])for(let r=0;r<=20;r++){const e=this._createNumberFormatter(o,t,{minimumFractionDigits:r,maximumFractionDigits:r});if(n===e(R))return!0}return!1}));return g?R:NaN}_getSerializableProperties(){return{defaultFormat:"initial",defaultParseFormat:"initial",fractionalDigits:"initial",currency:"initial",locale:"initial"}}_createNumberFormatter(t,r,e){const i=e||{},a=l(t);let n=r.match($);if(n){const t=n[1].toLowerCase(),r=Math.min(20,parseInt(n[2]));let e=n[3];t===NumberFormat.CURRENCY||t===NumberFormat.ACCOUNTING?e=(e||this.currency||"USD").toUpperCase():(e="",void 0===i.minimumFractionDigits&&(i.minimumFractionDigits=0),void 0===i.maximumFractionDigits&&(i.maximumFractionDigits=Math.max(4,i.minimumFractionDigits))),t===NumberFormat.PERCENT?i.style="percent":t===NumberFormat.ACCOUNTING?i.currencySign="accounting":t===NumberFormat.FIXED_POINT&&(i.useGrouping=!1),isNaN(r)||(i.minimumFractionDigits=r,i.maximumFractionDigits=r);const o=e?new Intl.NumberFormat(a,{style:"currency",currency:e,...i}):new Intl.NumberFormat(a,i);return t=>o.format(t)}n=r.match(/[0#]+|\.|,|%|\\.|(["'])[^\1]+\1|[^0#.,\\'"]+/g);let o=!1,s="",m="",c="",u="";i.minimumFractionDigits=0,i.maximumFractionDigits=0,i.useGrouping=!1;for(let t of n)switch(t[0]){case".":o=!0;break;case",":i.useGrouping=!0;break;case"%":i.style="percent";break;case"0":case"#":o?m+=t:s+=t;break;default:t.startsWith('"')||t.startsWith("'")?t=t.slice(1,-1):t.startsWith("\\")&&(t=t.slice(1)),s||m?u+=t:c+=t}if(s){const t=s.indexOf("0");t>=0&&(i.minimumIntegerDigits=s.length-t)}if(m){const t=m.lastIndexOf("0");i.minimumFractionDigits=t>=0?t+1:0,i.maximumFractionDigits=Math.min(20,m.length)}if(s||m){const t=new Intl.NumberFormat(a,i);return r=>`${c}${t.format(r)}${u}`}return()=>c+u}_createNumberParser(t){const r=l(t),e=new Intl.NumberFormat(r),i=e.formatToParts(12345.6),a=[...new Intl.NumberFormat(r,{useGrouping:!1}).format(9876543210)].reverse(),n=new Map(a.map(((t,r)=>[t,r]))),o=t=>n.get(t).toString();let s=i.find((t=>"group"===t.type)).value;c.some((t=>t===s))&&(s=`${c.join("|")}`);const m=new RegExp(`[${s}]`,"g"),u=new RegExp(`[${i.find((t=>"decimal"===t.type)).value}]`),N=new RegExp(`[${a.join("")}]`,"g"),F=e.format(-1/0),D=e.format(1/0);return t=>{if(t===D)return Number.POSITIVE_INFINITY;if(t===F)return Number.NEGATIVE_INFINITY;const r=t.trim().replace(m,"").replace(u,".").replace(N,o);return r?+r:NaN}}};F=t([a],F);export{F as NumberFormatter};let D=class extends F{get defaultFormat(){return o.numberFormat}set defaultFormat(t){o.numberFormat=t}get currency(){return o.currency}set currency(t){o.currency=t}get fractionalDigits(){return o.fractionalDigits}set fractionalDigits(t){o.fractionalDigits=t}};D=t([a],D);const R=new Map,f=new Map,$=/^([acfnp])(\d*)(?:\$([a-zA-Z]{3}))?$/i,S=new D;export const settings=S;
1
+ import{isNumericInvariant as r}from"./_number.js";import{parse as m}from"./format/number.js";export{format,parse,NumberFormatter,settings}from"./format/number.js";export{NumberFormat}from"./format/formats.js";export function isNumeric(o,t="inv"){return t&&"inv"!==t&&"string"==typeof o?!isNaN(m({locale:t},o)):r(o)}