lightning-base-components 1.15.1-alpha → 1.15.4-alpha

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 (336) hide show
  1. package/metadata/raptor.json +64 -2
  2. package/package.json +64 -2
  3. package/scopedImports/@salesforce-i18n-calendarData.js +1 -0
  4. package/scopedImports/@salesforce-i18n-common.calendarData.js +1 -0
  5. package/scopedImports/@salesforce-i18n-common.digits.js +1 -0
  6. package/scopedImports/@salesforce-i18n-dateTime.longDateTimeFormat.js +1 -0
  7. package/scopedImports/@salesforce-i18n-defaultCalendar.js +1 -0
  8. package/scopedImports/@salesforce-i18n-defaultNumberingSystem.js +1 -0
  9. package/scopedImports/@salesforce-i18n-number.exponentialSign.js +1 -0
  10. package/scopedImports/@salesforce-i18n-number.infinity.js +1 -0
  11. package/scopedImports/@salesforce-i18n-number.minusSign.js +1 -0
  12. package/scopedImports/@salesforce-i18n-number.nan.js +1 -0
  13. package/scopedImports/@salesforce-i18n-number.perMilleSign.js +1 -0
  14. package/scopedImports/@salesforce-i18n-number.percentSign.js +1 -0
  15. package/scopedImports/@salesforce-i18n-number.plusSign.js +1 -0
  16. package/scopedImports/@salesforce-i18n-number.superscriptingExponentSign.js +1 -0
  17. package/scopedImports/@salesforce-label-LightningMap.defaultTitle.js +1 -0
  18. package/src/lightning/alert/__docs__/alert.md +4 -6
  19. package/src/lightning/baseCombobox/baseCombobox.html +3 -1
  20. package/src/lightning/baseCombobox/baseCombobox.js +44 -7
  21. package/src/lightning/button/button.js +22 -1
  22. package/src/lightning/buttonIcon/buttonIcon.js +0 -3
  23. package/src/lightning/calendar/calendar.html +2 -1
  24. package/src/lightning/calendar/calendar.js +2 -2
  25. package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
  26. package/src/lightning/checkboxGroup/checkboxGroup.js +9 -5
  27. package/src/lightning/combobox/__docs__/combobox.md +3 -1
  28. package/src/lightning/combobox/combobox.html +1 -1
  29. package/src/lightning/combobox/combobox.js +7 -2
  30. package/src/lightning/configProvider/defaultLocalizationConfig.js +43 -6
  31. package/src/lightning/confirm/__docs__/confirm.md +2 -4
  32. package/src/lightning/datatable/__examples__/basic/basic.js +3 -4
  33. package/src/lightning/datatable/__examples__/basic/generateData.js +13 -0
  34. package/src/lightning/datatable/__examples__/withInfiniteLoading/generateDataWithDelay.js +18 -0
  35. package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.js +3 -3
  36. package/src/lightning/datatable/__examples__/withInlineEdit/generateData.js +13 -0
  37. package/src/lightning/datatable/__examples__/withInlineEdit/withInlineEdit.js +3 -4
  38. package/src/lightning/datatable/__examples__/withRowActions/generateData.js +13 -0
  39. package/src/lightning/datatable/__examples__/withRowActions/withRowActions.js +3 -4
  40. package/src/lightning/datatable/__examples__/withRowNumbers/generateData.js +13 -0
  41. package/src/lightning/datatable/__examples__/withRowNumbers/withRowNumbers.js +3 -4
  42. package/src/lightning/datatable/__wdio__/utam/utam.html +15 -0
  43. package/src/lightning/datatable/__wdio__/utam/utam.spec.js +208 -183
  44. package/src/lightning/datatable/datatable.js +13 -7
  45. package/src/lightning/datatable/inlineEdit.js +0 -5
  46. package/src/lightning/datatable/inlineEditShared.js +4 -2
  47. package/src/lightning/datatable/keyboard.js +13 -5
  48. package/src/lightning/datatable/rowSelection.js +8 -2
  49. package/src/lightning/datatable/state.js +1 -0
  50. package/src/lightning/datatable/templates/table/table.html +2 -2
  51. package/src/lightning/datatable/utils.js +11 -0
  52. package/src/lightning/datatable/virtualization.js +2 -2
  53. package/src/lightning/datatable/wrapText.js +1 -0
  54. package/src/lightning/datepicker/datepicker.html +5 -4
  55. package/src/lightning/datepicker/datepicker.js +35 -77
  56. package/src/lightning/datetimepicker/datetimepicker.html +3 -1
  57. package/src/lightning/datetimepicker/datetimepicker.js +44 -8
  58. package/src/lightning/dualListbox/dualListbox.html +1 -1
  59. package/src/lightning/dualListbox/dualListbox.js +8 -1
  60. package/src/lightning/fileDownload/fileDownload.js +15 -0
  61. package/src/lightning/fileDownload/fileDownload.js-meta.xml +5 -0
  62. package/src/lightning/fileDownload/resourceResolver.js +58 -0
  63. package/src/lightning/formattedAddress/__docs__/formattedAddress.md +3 -0
  64. package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.html +22 -0
  65. package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.js +3 -0
  66. package/src/lightning/formattedAddress/formattedAddress.js +7 -1
  67. package/src/lightning/formattedDateTime/formattedDateTime.js +1 -1
  68. package/src/lightning/formattedLookup/events.js +19 -0
  69. package/src/lightning/formattedLookup/formattedLookup.js +7 -0
  70. package/src/lightning/formattedRichText/__docs__/formattedRichText.md +9 -7
  71. package/src/lightning/formattedRichText/__examples__disabled/basic/basic.html +1 -1
  72. package/src/lightning/formattedTime/formattedTime.js +2 -1
  73. package/src/lightning/groupedCombobox/groupedCombobox.html +3 -2
  74. package/src/lightning/groupedCombobox/groupedCombobox.js +26 -4
  75. package/src/lightning/helptext/helptext.html +1 -0
  76. package/src/lightning/helptext/helptext.js +29 -2
  77. package/src/lightning/i18nCldrOptions/all-locales.js +1 -0
  78. package/src/lightning/i18nCldrOptions/i18nCldrOptions.js +4 -0
  79. package/src/lightning/i18nService/i18nService.js +1810 -0
  80. package/src/lightning/iconSvgTemplates/buildTemplates/action/scan_disabled.html +7 -0
  81. package/src/lightning/iconSvgTemplates/buildTemplates/action/scan_enabled.html +7 -0
  82. package/src/lightning/iconSvgTemplates/buildTemplates/standard/ai_accelerator_card.html +7 -0
  83. package/src/lightning/iconSvgTemplates/buildTemplates/standard/connect_wallet.html +9 -0
  84. package/src/lightning/iconSvgTemplates/buildTemplates/standard/contract_line_outcome.html +7 -0
  85. package/src/lightning/iconSvgTemplates/buildTemplates/standard/contract_line_outcome_data.html +7 -0
  86. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_category_wallet_group.html +7 -0
  87. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_product.html +7 -0
  88. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_product_category_wallet_role.html +9 -0
  89. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_transaction.html +9 -0
  90. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_transaction_envelope.html +8 -0
  91. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_transaction_envelope_item.html +7 -0
  92. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_wallet.html +8 -0
  93. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_wallet_group.html +9 -0
  94. package/src/lightning/iconSvgTemplates/buildTemplates/standard/crypto_wallet_group_item.html +8 -0
  95. package/src/lightning/iconSvgTemplates/buildTemplates/standard/customer.html +10 -0
  96. package/src/lightning/iconSvgTemplates/buildTemplates/standard/customer_workspace.html +11 -0
  97. package/src/lightning/iconSvgTemplates/buildTemplates/standard/learner_program.html +7 -0
  98. package/src/lightning/iconSvgTemplates/buildTemplates/standard/nft_settings.html +8 -0
  99. package/src/lightning/iconSvgTemplates/buildTemplates/standard/nft_studio.html +7 -0
  100. package/src/lightning/iconSvgTemplates/buildTemplates/standard/prompt.html +7 -0
  101. package/src/lightning/iconSvgTemplates/buildTemplates/standard/setup_modal.html +11 -0
  102. package/src/lightning/iconSvgTemplates/buildTemplates/standard/snippet_alt.html +7 -0
  103. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tax_policy.html +8 -0
  104. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tax_rate.html +8 -0
  105. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tax_treatment.html +8 -0
  106. package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
  107. package/src/lightning/iconSvgTemplates/buildTemplates/standard/water.html +7 -0
  108. package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +48 -1
  109. package/src/lightning/iconSvgTemplates/buildTemplates/utility/captions.html +7 -0
  110. package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_line_outcome.html +7 -0
  111. package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_line_outcome_data.html +7 -0
  112. package/src/lightning/iconSvgTemplates/buildTemplates/utility/customer.html +10 -0
  113. package/src/lightning/iconSvgTemplates/buildTemplates/utility/customer_workspace.html +11 -0
  114. package/src/lightning/iconSvgTemplates/buildTemplates/utility/detach.html +7 -0
  115. package/src/lightning/iconSvgTemplates/buildTemplates/utility/hazmat_equipment.html +7 -0
  116. package/src/lightning/iconSvgTemplates/buildTemplates/utility/label.html +7 -0
  117. package/src/lightning/iconSvgTemplates/buildTemplates/utility/labels.html +8 -0
  118. package/src/lightning/iconSvgTemplates/buildTemplates/utility/record_alt.html +8 -0
  119. package/src/lightning/iconSvgTemplates/buildTemplates/utility/segments.html +8 -0
  120. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tax_policy.html +8 -0
  121. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tax_rate.html +8 -0
  122. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tax_treatment.html +8 -0
  123. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tollways.html +8 -0
  124. package/src/lightning/iconSvgTemplates/buildTemplates/utility/transport_bicycle.html +7 -0
  125. package/src/lightning/iconSvgTemplates/buildTemplates/utility/transport_heavy_truck.html +7 -0
  126. package/src/lightning/iconSvgTemplates/buildTemplates/utility/transport_light_truck.html +7 -0
  127. package/src/lightning/iconSvgTemplates/buildTemplates/utility/transport_walking.html +7 -0
  128. package/src/lightning/iconSvgTemplates/buildTemplates/utility/water.html +7 -0
  129. package/src/lightning/iconSvgTemplatesAction/buildTemplates/action/scan_disabled.html +7 -0
  130. package/src/lightning/iconSvgTemplatesAction/buildTemplates/action/scan_enabled.html +7 -0
  131. package/src/lightning/iconSvgTemplatesAction/buildTemplates/templates.js +3 -1
  132. package/src/lightning/iconSvgTemplatesActionRtl/buildTemplates/action/scan_disabled.html +7 -0
  133. package/src/lightning/iconSvgTemplatesActionRtl/buildTemplates/action/scan_enabled.html +7 -0
  134. package/src/lightning/iconSvgTemplatesActionRtl/buildTemplates/templates.js +3 -1
  135. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/action/scan_disabled.html +7 -0
  136. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/action/scan_enabled.html +7 -0
  137. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/ai_accelerator_card.html +7 -0
  138. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/connect_wallet.html +9 -0
  139. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/contract_line_outcome.html +7 -0
  140. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/contract_line_outcome_data.html +7 -0
  141. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_category_wallet_group.html +7 -0
  142. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_product.html +7 -0
  143. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_product_category_wallet_role.html +9 -0
  144. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_transaction.html +9 -0
  145. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_transaction_envelope.html +8 -0
  146. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_transaction_envelope_item.html +7 -0
  147. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_wallet.html +8 -0
  148. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_wallet_group.html +9 -0
  149. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/crypto_wallet_group_item.html +8 -0
  150. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/customer.html +10 -0
  151. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/customer_workspace.html +11 -0
  152. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/learner_program.html +7 -0
  153. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/nft_settings.html +8 -0
  154. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/nft_studio.html +7 -0
  155. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/prompt.html +7 -0
  156. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/setup_modal.html +11 -0
  157. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/snippet_alt.html +7 -0
  158. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tax_policy.html +8 -0
  159. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tax_rate.html +8 -0
  160. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tax_treatment.html +8 -0
  161. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
  162. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/water.html +7 -0
  163. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +48 -1
  164. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/captions.html +7 -0
  165. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_line_outcome.html +7 -0
  166. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_line_outcome_data.html +7 -0
  167. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/customer.html +10 -0
  168. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/customer_workspace.html +11 -0
  169. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/detach.html +7 -0
  170. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/hazmat_equipment.html +7 -0
  171. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/label.html +7 -0
  172. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/labels.html +8 -0
  173. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/record_alt.html +8 -0
  174. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/segments.html +8 -0
  175. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tax_policy.html +8 -0
  176. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tax_rate.html +8 -0
  177. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tax_treatment.html +8 -0
  178. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tollways.html +8 -0
  179. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/transport_bicycle.html +7 -0
  180. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/transport_heavy_truck.html +7 -0
  181. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/transport_light_truck.html +7 -0
  182. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/transport_walking.html +7 -0
  183. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/water.html +7 -0
  184. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/ai_accelerator_card.html +7 -0
  185. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/connect_wallet.html +9 -0
  186. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/contract_line_outcome.html +7 -0
  187. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/contract_line_outcome_data.html +7 -0
  188. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_category_wallet_group.html +7 -0
  189. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_product.html +7 -0
  190. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_product_category_wallet_role.html +9 -0
  191. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_transaction.html +9 -0
  192. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_transaction_envelope.html +8 -0
  193. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_transaction_envelope_item.html +7 -0
  194. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_wallet.html +8 -0
  195. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_wallet_group.html +9 -0
  196. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/crypto_wallet_group_item.html +8 -0
  197. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/customer.html +10 -0
  198. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/customer_workspace.html +11 -0
  199. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/learner_program.html +7 -0
  200. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/nft_settings.html +8 -0
  201. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/nft_studio.html +7 -0
  202. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/prompt.html +7 -0
  203. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/setup_modal.html +11 -0
  204. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/snippet_alt.html +7 -0
  205. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tax_policy.html +8 -0
  206. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tax_rate.html +8 -0
  207. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tax_treatment.html +8 -0
  208. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
  209. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/water.html +7 -0
  210. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +26 -1
  211. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/ai_accelerator_card.html +7 -0
  212. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/connect_wallet.html +9 -0
  213. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/contract_line_outcome.html +7 -0
  214. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/contract_line_outcome_data.html +7 -0
  215. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_category_wallet_group.html +7 -0
  216. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_product.html +7 -0
  217. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_product_category_wallet_role.html +9 -0
  218. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_transaction.html +9 -0
  219. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_transaction_envelope.html +8 -0
  220. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_transaction_envelope_item.html +7 -0
  221. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_wallet.html +8 -0
  222. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_wallet_group.html +9 -0
  223. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/crypto_wallet_group_item.html +8 -0
  224. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/customer.html +10 -0
  225. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/customer_workspace.html +11 -0
  226. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/learner_program.html +7 -0
  227. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/nft_settings.html +8 -0
  228. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/nft_studio.html +7 -0
  229. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/prompt.html +7 -0
  230. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/setup_modal.html +11 -0
  231. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/snippet_alt.html +7 -0
  232. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tax_policy.html +8 -0
  233. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tax_rate.html +8 -0
  234. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tax_treatment.html +8 -0
  235. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
  236. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/water.html +7 -0
  237. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +26 -1
  238. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +21 -1
  239. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/captions.html +7 -0
  240. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_line_outcome.html +7 -0
  241. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_line_outcome_data.html +7 -0
  242. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/customer.html +10 -0
  243. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/customer_workspace.html +11 -0
  244. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/detach.html +7 -0
  245. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/hazmat_equipment.html +7 -0
  246. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/label.html +7 -0
  247. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/labels.html +8 -0
  248. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/record_alt.html +8 -0
  249. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/segments.html +8 -0
  250. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tax_policy.html +8 -0
  251. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tax_rate.html +8 -0
  252. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tax_treatment.html +8 -0
  253. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tollways.html +8 -0
  254. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/transport_bicycle.html +7 -0
  255. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/transport_heavy_truck.html +7 -0
  256. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/transport_light_truck.html +7 -0
  257. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/transport_walking.html +7 -0
  258. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/water.html +7 -0
  259. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +21 -1
  260. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/captions.html +7 -0
  261. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_line_outcome.html +7 -0
  262. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_line_outcome_data.html +7 -0
  263. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/customer.html +10 -0
  264. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/customer_workspace.html +11 -0
  265. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/detach.html +7 -0
  266. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/hazmat_equipment.html +7 -0
  267. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/label.html +7 -0
  268. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/labels.html +8 -0
  269. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/record_alt.html +8 -0
  270. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/segments.html +8 -0
  271. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tax_policy.html +8 -0
  272. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tax_rate.html +8 -0
  273. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tax_treatment.html +8 -0
  274. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tollways.html +8 -0
  275. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/transport_bicycle.html +7 -0
  276. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/transport_heavy_truck.html +7 -0
  277. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/transport_light_truck.html +7 -0
  278. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/transport_walking.html +7 -0
  279. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/water.html +7 -0
  280. package/src/lightning/input/dateTimeUtil.js +2 -2
  281. package/src/lightning/input/input.html +6 -0
  282. package/src/lightning/input/input.js +2 -1
  283. package/src/lightning/inputAddress/__docs__/inputAddress.md +5 -0
  284. package/src/lightning/inputAddress/__examples__/customLocale/customLocale.html +12 -0
  285. package/src/lightning/inputAddress/__examples__/customLocale/customLocale.js +3 -0
  286. package/src/lightning/inputAddress/inputAddress.html +3 -1
  287. package/src/lightning/inputAddress/inputAddress.js +33 -4
  288. package/src/lightning/inputLocation/inputLocation.html +1 -1
  289. package/src/lightning/inputLocation/inputLocation.js +7 -1
  290. package/src/lightning/inputName/__docs__/inputName.md +2 -0
  291. package/src/lightning/inputName/inputName.html +5 -2
  292. package/src/lightning/inputName/inputName.js +7 -1
  293. package/src/lightning/inputUtils/inputUtils.js +11 -0
  294. package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +1 -0
  295. package/src/lightning/internationalizationLibrary/datetime/dateTimeOptions.js +16 -29
  296. package/src/lightning/internationalizationLibrary/datetime/dateTimeUtils.js +524 -135
  297. package/src/lightning/internationalizationLibrary/datetime/intlFormat.js +92 -72
  298. package/src/lightning/internationalizationLibrary/internationalizationLibrary.js +9 -4
  299. package/src/lightning/internationalizationLibrary/localizationService.js +1 -0
  300. package/src/lightning/internationalizationLibrary/number/NumberFormat.js +17 -11
  301. package/src/lightning/internationalizationLibrary/number/numberFormatFallback.js +3 -2
  302. package/src/lightning/internationalizationLibrary/number/numberOptions.js +22 -26
  303. package/src/lightning/internationalizationLibrary/number/utils.js +134 -131
  304. package/src/lightning/internationalizationLibrary/utils.js +14 -0
  305. package/src/lightning/iso8601Utils/iso8601Utils.js +1 -0
  306. package/src/lightning/modalBase/modalBase.css +0 -4
  307. package/src/lightning/modalBase/modalBase.html +1 -1
  308. package/src/lightning/modalBase/modalBase.js +0 -14
  309. package/src/lightning/navigation/__docs__/navigation.md +0 -2
  310. package/src/lightning/overlayContainer/overlayContainer.html +2 -2
  311. package/src/lightning/overlayContainer/overlayContainer.js +217 -49
  312. package/src/lightning/overlayManager/overlayManager.js +378 -28
  313. package/src/lightning/overlayManager/overlayManager.js-meta.xml +5 -0
  314. package/src/lightning/picklist/picklist.js +6 -1
  315. package/src/lightning/primitiveCellFactory/primitiveCellFactory.js +1 -11
  316. package/src/lightning/prompt/__docs__/prompt.md +2 -4
  317. package/src/lightning/radioGroup/radioGroup.js +9 -0
  318. package/src/lightning/select/select.html +4 -2
  319. package/src/lightning/select/select.js +12 -2
  320. package/src/lightning/tabBar/tabBar.html +3 -2
  321. package/src/lightning/tabBar/tabBar.js +15 -0
  322. package/src/lightning/textarea/textarea.html +2 -1
  323. package/src/lightning/textarea/textarea.js +12 -1
  324. package/src/lightning/timepicker/timepicker.html +4 -2
  325. package/src/lightning/timepicker/timepicker.js +49 -86
  326. package/src/lightning/utils/labelUtils.js +4 -1
  327. package/src/lightning/utilsPrivate/animation.js +0 -4
  328. package/src/lightning/utilsPrivate/aria.js +26 -0
  329. package/src/lightning/utilsPrivate/linkify.js +1 -1
  330. package/src/lightning/utilsPrivate/utilsPrivate.js +7 -1
  331. package/src/lightning/datatable/__examples__/basic/fetchDataHelper.js +0 -21
  332. package/src/lightning/datatable/__examples__/withInfiniteLoading/fetchDataHelper.js +0 -21
  333. package/src/lightning/datatable/__examples__/withInlineEdit/fetchDataHelper.js +0 -21
  334. package/src/lightning/datatable/__examples__/withRowActions/fetchDataHelper.js +0 -21
  335. package/src/lightning/datatable/__examples__/withRowNumbers/fetchDataHelper.js +0 -21
  336. package/src/lightning/icon/__component__/icon-spirite.spec.js +0 -59
@@ -1,6 +1,22 @@
1
+ // TODO: When migrating off Aura, consider removing 'asserts'; consider
2
+ // consider using console.error, throwing Error and/or sticking with
3
+ // default behavior for handling invalid inputs in i18nService
1
4
  import { assert } from 'lightning/utilsPrivate';
5
+ import locale from '@salesforce/i18n/locale';
6
+ import shortDateFormat from '@salesforce/i18n/dateTime.shortDateFormat';
2
7
  import mediumDateFormat from '@salesforce/i18n/dateTime.mediumDateFormat';
8
+ import longDateFormat from '@salesforce/i18n/dateTime.longDateFormat';
9
+ import shortTimeFormat from '@salesforce/i18n/dateTime.shortTimeFormat';
3
10
  import mediumTimeFormat from '@salesforce/i18n/dateTime.mediumTimeFormat';
11
+ import shortDateTimeFormat from '@salesforce/i18n/dateTime.shortDateTimeFormat';
12
+ import mediumDateTimeFormat from '@salesforce/i18n/dateTime.mediumDateTimeFormat';
13
+ import longDateTimeFormat from '@salesforce/i18n/dateTime.longDateTimeFormat';
14
+ import { formattingOptions } from 'lightning/i18nCldrOptions';
15
+ import {
16
+ getDateTimeFormat,
17
+ getDateTimeISO8601Parser,
18
+ getDateTimeCLDRParser,
19
+ } from 'lightning/i18nService';
4
20
  import {
5
21
  isValidISODateTimeString,
6
22
  isValidISOTimeString,
@@ -21,201 +37,574 @@ import {
21
37
  toOtherCalendar,
22
38
  fromOtherCalendar,
23
39
  } from '../localizationService';
40
+ import { isAuraL10NAvailable, getDateTimeErrorMessage } from '../utils';
24
41
 
25
- export function normalizeISODate(value, format) {
26
- const dateValue = typeof value === 'string' ? value.trim() : value;
27
- if (!dateValue) {
28
- return {
29
- isoValue: null,
30
- displayValue: value || '',
31
- };
42
+ // set long time format to medium time format since
43
+ // lightning-input currently treats a 'long' time-style
44
+ // the same way as a 'medium' time-style
45
+ formattingOptions.longTimeFormat = formattingOptions.mediumTimeFormat;
46
+
47
+ const ISO_FORMAT = "yyyy-MM-dd'T'hh:mm:ss.SSS'Z'";
48
+ const LATN = 'latn';
49
+ const utcTimeZone = { timeZone: 'UTC' };
50
+
51
+ /**
52
+ * HELPER FUNCTIONS
53
+ */
54
+
55
+ /**
56
+ * Checks if a value contains a time zone offset by checking
57
+ * for a '+' or '-' character in string and null otherwise
58
+ *
59
+ * @param {any} value
60
+ * @returns
61
+ */
62
+ const hasTimeZoneOffset = (value) => {
63
+ if (typeof value === 'string') {
64
+ return value.indexOf('+') !== -1 || value.indexOf('-') !== -1;
32
65
  }
66
+ return false;
67
+ };
68
+
69
+ /**
70
+ * If provided a string returns trimmed string, otherwise
71
+ * returns provided value exactly as-is
72
+ *
73
+ * @param {any} value
74
+ * @returns {any}
75
+ */
76
+ const getTrimmedValue = (value) => {
77
+ return typeof value === 'string' ? value.trim() : value;
78
+ };
33
79
 
34
- // if value is an ISO string, only fetch the date part
35
- const dateOnlyString =
36
- (typeof dateValue === 'string' && dateValue.split(TIME_SEPARATOR)[0]) ||
37
- dateValue;
80
+ /**
81
+ * Returns part of a provided string before 'T', representing
82
+ * date portion of ISO string. If provided value is not a string
83
+ * simply returns the value exactly as-is
84
+ *
85
+ * @param {any} value - value to get date for
86
+ * @returns {any}
87
+ */
88
+ const getDateOnly = (value) => {
89
+ return typeof value === 'string' ? value.split(TIME_SEPARATOR)[0] : value;
90
+ };
38
91
 
39
- assert(
40
- isValidISODateTimeString(dateOnlyString),
41
- `datetime component: The value attribute accepts a valid ISO8601 formatted string ` +
42
- `with timezone offset. but we are getting the ${typeof value} value "${value}" instead.`
92
+ /**
93
+ * Returns true if provided value is a Date object, false otherwise
94
+ *
95
+ * @param {any} value - value to check if Date object or not
96
+ * @returns {boolean}
97
+ */
98
+ export function isDate(value) {
99
+ return (
100
+ Object.prototype.toString.call(value) === '[object Date]' &&
101
+ !isNaN(value.getTime())
43
102
  );
103
+ }
44
104
 
45
- const parsedDate = parseDateTime(dateOnlyString, STANDARD_DATE_FORMAT);
46
- if (!parsedDate) {
47
- return {
48
- isoValue: null,
49
- displayValue: value || '',
50
- };
105
+ /**
106
+ * @returns YYYY-MM-DD string for system time zone
107
+ */
108
+ export function getCurrentDateString() {
109
+ const today = getTodayBasedOnTimezone();
110
+ return getISODateString(today);
111
+ }
112
+
113
+ /**
114
+ * Returns ISO date string corresponding to provided date in local time zone
115
+ *
116
+ * @param {Date} date - date to get ISO date string for
117
+ * @returns 'YYYY-MM-DD' string representing provided date in local time zone
118
+ */
119
+ export function getISODateString(date) {
120
+ if (!isDate(date)) {
121
+ return null;
51
122
  }
123
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(
124
+ date.getDate()
125
+ )}`;
126
+ }
52
127
 
53
- // convert from Gregorian to Buddhist Calendar if necessary
54
- const civilDate = toOtherCalendar(parsedDate);
128
+ /**
129
+ * Returns ISO time string without any time zone indicator
130
+ * corresponding to provided date in local time zone
131
+ *
132
+ * @param {Date} date - date to get ISO time string in local time zone for
133
+ * @returns 'HH:mm:ss.SSS' string representing the provided
134
+ * date time in local time zone
135
+ */
136
+ export function getISOTimeString(date) {
137
+ if (!isDate(date)) {
138
+ return null;
139
+ }
140
+ return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(
141
+ date.getSeconds()
142
+ )}.${doublePad(date.getMilliseconds())}`;
143
+ }
55
144
 
56
- return {
57
- isoValue: dateOnlyString,
58
- displayValue: formatDate(civilDate, format),
59
- };
145
+ /**
146
+ * Returns ISO time string without any time zone indicator
147
+ * corresponding to provided date in UTC time zone
148
+ *
149
+ * @param {Date} date - date to get ISO time string in UTC for
150
+ * @returns 'HH:mm:ss.SSS' string representing the provided
151
+ * date time in UTC time zone
152
+ */
153
+ function getISOTimeStringUTC(date) {
154
+ if (!isDate(date)) {
155
+ return null;
156
+ }
157
+ return `${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(
158
+ date.getUTCSeconds()
159
+ )}.${doublePad(date.getUTCMilliseconds())}`;
60
160
  }
61
161
 
62
- export function normalizeISOTime(value, format) {
63
- // We are not converting the time to the user's timezone. All values are displayed and saved as UTC time values
64
- const normalizedValue = removeTimeZoneSuffix(value);
162
+ /**
163
+ * Gets current time in provided timezone in hours and minutes
164
+ *
165
+ * @param {string} timezone - timezone to get time for
166
+ * @returns time in HH:mm format
167
+ */
168
+ export function getCurrentTimeString(timezone) {
169
+ const today = getTodayBasedOnTimezone(timezone);
170
+ return `${pad(today.getHours())}:${pad(today.getMinutes())}`;
171
+ }
65
172
 
66
- const timeValue =
67
- typeof normalizedValue === 'string'
68
- ? normalizedValue.trim()
69
- : normalizedValue;
70
- if (!timeValue) {
71
- return {
72
- isoValue: null,
73
- displayValue: value || '',
74
- };
173
+ /**
174
+ * Gets offset between provided timezone and either
175
+ * system timezone or UTC timezone at current date
176
+ *
177
+ * @param {Date} date - date used when determining offset
178
+ * @param {string} timeZone - time zone to get offset for
179
+ * @returns {Number} offset in milliseconds
180
+ */
181
+ function getOffsetForTimezone(date, timeZone, shouldAddUTCOffset) {
182
+ const time1 = getDateTimeCLDRParser({
183
+ pattern: ISO_FORMAT,
184
+ timeZone,
185
+ numberingSystem: LATN,
186
+ }).parse(date.toISOString());
187
+ const extraOffset = shouldAddUTCOffset ? date.getTimezoneOffset() : 0;
188
+ // need to subtract milliseconds since CLDR seems to reset milliseconds to zero
189
+ const time2 =
190
+ date.getTime() - date.getMilliseconds() + extraOffset * 60 * 1000;
191
+ return time2 - time1;
192
+ }
193
+
194
+ /**
195
+ * Adjust provided date by offset from either system time zone or UTC
196
+ *
197
+ * @param {Date} date - initial date to adjust
198
+ * @param {string} timeZone - time zone to adjust date based on
199
+ * @param {boolean} shouldAddUTCOffset - adjust by UTC instead of local offset if true
200
+ *
201
+ * @returns {Date} date adjusted by either system time zone or UTC
202
+ * e.g., if the date corresponds to 2pm in provided time zone and calculated
203
+ * offset is +4 hours, returns date corresponding to 6pm in provided time zone
204
+ */
205
+ function adjustDateByOffset(date, timeZone, shouldAddUTCOffset) {
206
+ const offset = getOffsetForTimezone(date, timeZone, shouldAddUTCOffset);
207
+ const timestamp = date.getTime() + offset;
208
+ return new Date(timestamp);
209
+ }
210
+
211
+ /**
212
+ * Get current date moved by offset between provided timezone
213
+ * (or system time zone if none provided) and UTC
214
+ *
215
+ * @param {string} timeZone - optional time zone to get current date for
216
+ * @returns {Date} current date adjusted by offset between provided
217
+ * time zone and UTC; e.g., if current time is 6pm in UTC and 2pm
218
+ * locally, returns date corresponding to 6pm locally and 10pm UTC
219
+ */
220
+ function getTodayBasedOnTimezone(timeZone) {
221
+ const today = new Date();
222
+ if (isAuraL10NAvailable) {
223
+ // time in UTC
224
+ today.setTime(today.getTime() + today.getTimezoneOffset() * 60 * 1000);
225
+ // localization service will use $Locale.timezone when no timezone provided
226
+ return syncUTCToWallTime(today, timeZone);
75
227
  }
228
+ return adjustDateByOffset(today, timeZone, true);
229
+ }
76
230
 
77
- assert(
78
- isValidISOTimeString(timeValue),
79
- `datetime component: The value attribute accepts a valid ISO8601 formatted string. ` +
80
- `but we are getting the ${typeof value} value "${value}" instead.`
81
- );
231
+ function pad(n) {
232
+ return Number(n) < 10 ? '0' + n : n;
233
+ }
82
234
 
83
- const parsedTime = parseTime(timeValue);
84
- if (!parsedTime) {
235
+ function doublePad(n) {
236
+ const number = Number(n);
237
+ if (number < 10) {
238
+ return '00' + n;
239
+ } else if (number < 100) {
240
+ return '0' + n;
241
+ }
242
+ return n;
243
+ }
244
+
245
+ /**
246
+ * STYLE-TO-FORMAT MAPPING
247
+ */
248
+
249
+ const DATE = 'date';
250
+ const TIME = 'time';
251
+ const DATETIME = 'datetime';
252
+ const DATETIME_STYLES = {
253
+ SHORT: 'short',
254
+ MEDIUM: 'medium',
255
+ LONG: 'long',
256
+ };
257
+ // mapping of type/style of formats to use when
258
+ // getting format based on provided type/style
259
+ const DATETIME_FORMATS = {
260
+ [DATE]: {
261
+ [DATETIME_STYLES.SHORT]: shortDateFormat,
262
+ [DATETIME_STYLES.MEDIUM]: mediumDateFormat,
263
+ [DATETIME_STYLES.LONG]: longDateFormat,
264
+ name: 'DateFormat',
265
+ },
266
+ [TIME]: {
267
+ [DATETIME_STYLES.SHORT]: shortTimeFormat,
268
+ [DATETIME_STYLES.MEDIUM]: mediumTimeFormat,
269
+ [DATETIME_STYLES.LONG]: mediumTimeFormat,
270
+ name: 'TimeFormat',
271
+ },
272
+ [DATETIME]: {
273
+ [DATETIME_STYLES.SHORT]: shortDateTimeFormat,
274
+ [DATETIME_STYLES.MEDIUM]: mediumDateTimeFormat,
275
+ [DATETIME_STYLES.LONG]: longDateTimeFormat,
276
+ name: 'DateTimeFormat',
277
+ },
278
+ };
279
+
280
+ /**
281
+ * Returns short/medium/long format for date/time/datetime
282
+ * in CLDR format or options for datetime formatter
283
+ *
284
+ * Always returns CLDR in Aura, otherwise returns
285
+ * formatting object if isCldr is falsy
286
+ *
287
+ * @param {string} type - date/time/datetime
288
+ * @param {string} style - short/medium/long
289
+ * @param {boolean} isCldr - true if getting cldr format
290
+ * @returns {string|Object}
291
+ */
292
+ const getFormatFromStyle = (type, style, isCldr) => {
293
+ if (isAuraL10NAvailable || isCldr) {
294
+ return DATETIME_FORMATS[type][style];
295
+ }
296
+ const path = `${style}${DATETIME_FORMATS[type].name}`;
297
+ return formattingOptions[path];
298
+ };
299
+
300
+ export const getDateFormatFromStyle = (dateStyle, isCldr) => {
301
+ return getFormatFromStyle(DATE, dateStyle, isCldr);
302
+ };
303
+
304
+ export const getTimeFormatFromStyle = (timeStyle, isCldr) => {
305
+ return getFormatFromStyle(TIME, timeStyle, isCldr);
306
+ };
307
+
308
+ export const getDateTimeFormatFromStyle = (datetimeStyle, isCldr) => {
309
+ return getFormatFromStyle(DATETIME, datetimeStyle, isCldr);
310
+ };
311
+
312
+ /**
313
+ * NORMALIZE ISO DATETIMES
314
+ */
315
+
316
+ /**
317
+ * Normalizes ISO date string to localized short,
318
+ * medium, or long date string. Uses Aura on core
319
+ * and localizer off-core.
320
+ *
321
+ * @param {string} value - ISO date to normalize
322
+ * @param {string} dateStyle - style date should be in
323
+ * eg., style 'short' may correspond to 'dd/mm/yy'
324
+ *
325
+ * @returns {Object} with ISO value and localized display value
326
+ */
327
+ export function normalizeISODate(value, dateStyle) {
328
+ const format = getDateFormatFromStyle(dateStyle);
329
+ const isoValue = getDateOnly(getTrimmedValue(value));
330
+
331
+ let parsedDate, displayValue;
332
+ if (isoValue) {
333
+ assert(
334
+ isValidISODateTimeString(isoValue),
335
+ getDateTimeErrorMessage(value)
336
+ );
337
+ if (isAuraL10NAvailable) {
338
+ parsedDate = parseDateTime(isoValue, STANDARD_DATE_FORMAT);
339
+ // converts to Buddhist calendar if necessary
340
+ const civilDate = toOtherCalendar(parsedDate);
341
+ displayValue = formatDate(civilDate, format);
342
+ } else {
343
+ parsedDate = getDateTimeISO8601Parser().parse(isoValue);
344
+ const formatOptions = Object.assign({}, utcTimeZone, format);
345
+ displayValue = getDateTimeFormat(locale, formatOptions).format(
346
+ parsedDate
347
+ );
348
+ }
349
+ }
350
+
351
+ if (!parsedDate) {
85
352
  return {
86
353
  isoValue: null,
87
354
  displayValue: value || '',
88
355
  };
89
356
  }
90
- return {
91
- isoValue: getISOTimeString(parsedTime),
92
- displayValue: formatTime(parsedTime, format),
93
- };
357
+
358
+ return { isoValue, displayValue };
94
359
  }
95
360
 
96
- export function normalizeISODateTime(value, timezone, format) {
97
- const dateTimeValue = typeof value === 'string' ? value.trim() : value;
98
- if (!dateTimeValue) {
361
+ /**
362
+ * Normalizes ISO time string to localized format
363
+ * Used in formattedTime and timepicker components
364
+ *
365
+ * @param {string} value - ISO time to normalize
366
+ * @param {string} timeStyle - style time should be in
367
+ * eg., style 'short' may correspond to 'HH:mm'
368
+ *
369
+ * @returns {Object} with ISO value, parsed Date value and localized display value
370
+ */
371
+ export function normalizeISOTime(value, timeStyle) {
372
+ const format = getTimeFormatFromStyle(timeStyle);
373
+ const timeValue = getTrimmedValue(removeTimeZoneSuffix(value));
374
+
375
+ let parsedValue, displayValue, getISO;
376
+ if (timeValue) {
377
+ assert(isValidISOTimeString(timeValue), getDateTimeErrorMessage(value));
378
+ if (isAuraL10NAvailable) {
379
+ parsedValue = parseTime(timeValue);
380
+ displayValue = formatTime(parsedValue, format);
381
+ getISO = getISOTimeString;
382
+ } else {
383
+ parsedValue = getDateTimeISO8601Parser().parse(timeValue);
384
+ const formatOptions = Object.assign({}, utcTimeZone, format);
385
+ displayValue = getDateTimeFormat(locale, formatOptions).format(
386
+ parsedValue
387
+ );
388
+ getISO = getISOTimeStringUTC;
389
+ }
390
+ }
391
+
392
+ if (!parsedValue) {
99
393
  return {
100
394
  isoValue: null,
395
+ parsedValue: null,
101
396
  displayValue: value || '',
102
397
  };
398
+ } else if (hasTimeZoneOffset(value)) {
399
+ // log warning to avoid confusion when time zone offset is ignored
400
+ console.warn(
401
+ 'lightning-formatted-time does not support non-UTC time zones and will ignore any time zone offsets.'
402
+ );
103
403
  }
404
+ const isoValue = getISO(parsedValue);
405
+ return { isoValue, parsedValue, displayValue };
406
+ }
104
407
 
105
- assert(
106
- isValidISODateTimeString(dateTimeValue),
107
- `datetime component: The value attribute accepts a valid ISO8601 formatted string ` +
108
- `with timezone offset. but we are getting the ${typeof value} value "${value}" instead.`
109
- );
408
+ /**
409
+ * Normalizes ISO datetime string to localized format
410
+ * Used in datetimepicker component
411
+ *
412
+ * @param {string} value - ISO datetime to normalize
413
+ * @param {string} timeZone - IANA time zone to adjust value to
414
+ *
415
+ * @returns {Object} with ISO value, and localized/time zone adjusted display value
416
+ */
417
+ export function normalizeISODateTime(value, timeZone) {
418
+ const dateTimeValue = getTrimmedValue(value);
419
+
420
+ let parsedDate, displayValue;
421
+ if (dateTimeValue) {
422
+ assert(
423
+ isValidISODateTimeString(dateTimeValue),
424
+ getDateTimeErrorMessage(value)
425
+ );
426
+ if (isAuraL10NAvailable) {
427
+ parsedDate = syncUTCToWallTime(
428
+ parseDateTimeISO8601(dateTimeValue),
429
+ timeZone
430
+ );
431
+ displayValue = formatDateTimeUTC(parsedDate);
432
+ } else {
433
+ const utcDate = getDateTimeISO8601Parser().parse(dateTimeValue);
434
+ parsedDate = adjustDateByOffset(utcDate, timeZone);
435
+ const defaultDateFormat = formattingOptions.mediumDateFormat;
436
+ const defaultTimeFormat = formattingOptions.mediumTimeFormat;
437
+ const formatOptions = Object.assign(
438
+ {},
439
+ utcTimeZone,
440
+ defaultDateFormat,
441
+ defaultTimeFormat
442
+ );
443
+ displayValue = getDateTimeFormat(locale, formatOptions).format(
444
+ parsedDate
445
+ );
446
+ }
447
+ }
110
448
 
111
- const parsedDate = parseDateTimeISO8601(dateTimeValue);
112
449
  if (!parsedDate) {
113
450
  return {
114
451
  isoValue: null,
115
452
  displayValue: value || '',
116
453
  };
117
454
  }
118
-
119
- const convertedDate = syncUTCToWallTime(parsedDate, timezone);
120
455
  return {
121
- // We are passing the ISO value without a timezone designator.
122
- // the native input type='datetime-local' who calls this does not accept timezone offset
123
- isoValue: removeTimeZoneSuffix(convertedDate.toISOString()),
124
- displayValue: formatDateTimeUTC(convertedDate, format),
456
+ isoValue: removeTimeZoneSuffix(parsedDate.toISOString()),
457
+ displayValue,
125
458
  };
126
459
  }
127
460
 
128
- export function normalizeFormattedDate(value, format) {
129
- const dateValue = typeof value === 'string' ? value.trim() : value;
130
- if (!dateValue) {
461
+ /**
462
+ * NORMALIZE FORMATTED DATETIMES
463
+ */
464
+
465
+ /**
466
+ * Attempts to parse provided string into Date assuming string
467
+ * is provided date style (short, medium, long) and returns string
468
+ * in YYYY-MM-DD format. If parsing unsuccessful returns null.
469
+ *
470
+ * @param {string} value - formatted date string to parse into date
471
+ * @param {string} dateStyle - date style to parse string as (short/medium/long)
472
+ * @returns {string|null}
473
+ */
474
+ export function normalizeFormattedDate(value, dateStyle) {
475
+ const dateValue = getTrimmedValue(value);
476
+ const format = getDateFormatFromStyle(dateStyle, true);
477
+
478
+ let parsedDate;
479
+ try {
480
+ if (dateValue) {
481
+ if (isAuraL10NAvailable) {
482
+ parsedDate = fromOtherCalendar(
483
+ parseDateTime(dateValue, format, true)
484
+ );
485
+ } else {
486
+ // doesn't work as expected for th-TH
487
+ parsedDate = getDateTimeCLDRParser({
488
+ pattern: format,
489
+ }).parse(dateValue);
490
+ }
491
+ }
492
+ } catch (error) {
131
493
  return null;
132
494
  }
133
-
134
- const parsedDate = parseDateTime(
135
- dateValue,
136
- format || mediumDateFormat,
137
- true
138
- );
139
495
  if (!parsedDate) {
140
496
  return null;
141
497
  }
142
-
143
- const gregorianDate = fromOtherCalendar(parsedDate);
144
- return getISODateString(gregorianDate);
498
+ return getISODateString(parsedDate);
145
499
  }
146
500
 
147
- export function normalizeFormattedTime(value, format) {
148
- const timeValue = typeof value === 'string' ? value.trim() : value;
149
- if (!timeValue) {
501
+ /**
502
+ * Attempts to parse provided string into Date assuming string
503
+ * is provided time style (short, medium, long) and returns string
504
+ * in HH:mm:ss.SSS format. If parsing unsuccessful returns null.
505
+ *
506
+ * @param {string} value - formatted time string to parse into date
507
+ * @param {string} timeStyle - time style to parse string as (short/medium/long)
508
+ * @returns {string|null}
509
+ */
510
+ export function normalizeFormattedTime(value, timeStyle) {
511
+ const timeValue = getTrimmedValue(value);
512
+ const format = getTimeFormatFromStyle(timeStyle, true);
513
+
514
+ let parsedTime;
515
+ try {
516
+ if (timeValue) {
517
+ if (isAuraL10NAvailable) {
518
+ parsedTime = parseTime(
519
+ timeValue,
520
+ format || mediumTimeFormat,
521
+ true
522
+ );
523
+ } else {
524
+ parsedTime = getDateTimeCLDRParser({
525
+ pattern: format,
526
+ }).parse(timeValue);
527
+ }
528
+ }
529
+ } catch (error) {
150
530
  return null;
151
531
  }
152
-
153
- const parsedDate = parseTime(timeValue, format || mediumTimeFormat, true);
154
- if (!parsedDate) {
532
+ if (!parsedTime) {
155
533
  return null;
156
534
  }
157
-
158
- return getISOTimeString(parsedDate);
535
+ return getISOTimeString(parsedTime);
159
536
  }
160
537
 
161
- // The value here isn't really formatted, it's always an ISO string in the form isoDate + T + isoTime (without Z).
162
- export function normalizeFormattedDateTime(value, timezone, format) {
163
- const datetimeValue = typeof value === 'string' ? value.trim() : value;
164
- if (!datetimeValue) {
538
+ /**
539
+ * Converts ISO date time string without time zone indicator in given
540
+ * time zone to the equivalent ISO date time string in UTC time zone
541
+ *
542
+ * @param {string} value - ISO datetime string without time zone indicator
543
+ * @param {string} timeZone - IANA time zone that corresponds to value
544
+ * @returns Equivalent ISO date string in UTC
545
+ */
546
+ export function normalizeFormattedDateTime(value, timeZone) {
547
+ const datetimeValue = getTrimmedValue(value);
548
+
549
+ let parsedDate;
550
+ try {
551
+ if (datetimeValue) {
552
+ if (isAuraL10NAvailable) {
553
+ // given that value is an ISO string without Z, the parseDateTimeUTC
554
+ // call below is equivalent to parseDateTimeISO8601(value + 'Z')
555
+ parsedDate = syncWallTimeToUTC(
556
+ parseDateTimeUTC(datetimeValue),
557
+ timeZone
558
+ );
559
+ } else {
560
+ // no time zone in value so UTC time zone is assumed
561
+ const utcDate = getDateTimeISO8601Parser().parse(datetimeValue);
562
+ parsedDate = getDateTimeCLDRParser({
563
+ pattern: ISO_FORMAT,
564
+ timeZone,
565
+ numberingSystem: LATN,
566
+ }).parse(utcDate.toISOString());
567
+ }
568
+ }
569
+ } catch (error) {
165
570
  return null;
166
571
  }
167
-
168
- // given that value is an ISO string without Z, the method below is equivalent to parseDateTimeISO8601(value + 'Z')
169
- // However, parseDateTimeUTC is more concise and doesn't need any manipulation of the input (adding Z).
170
- const parsedDate = parseDateTimeUTC(datetimeValue, format);
171
572
  if (!parsedDate) {
172
573
  return null;
173
574
  }
174
-
175
- const convertedDate = syncWallTimeToUTC(parsedDate, timezone);
176
- return convertedDate.toISOString();
575
+ return parsedDate.toISOString();
177
576
  }
178
577
 
179
- export function getToday() {
180
- const today = getTodayBasedOnTimezone();
181
- return getISODateString(today);
182
- }
183
-
184
- export function getISODateString(date) {
185
- return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(
186
- date.getDate()
187
- )}`;
188
- }
578
+ /**
579
+ * Checks if normalization function recognizes provided value for any styles
580
+ * returning the style recognized and the value as an ISO string
581
+ * Used to allow user's to input a date/time in any style and have it
582
+ * recognized as valid even though the picker defaults to a specific style
583
+ *
584
+ * @param {Function} normalizeFormattedValue - function to normalize formatted string to ISO string
585
+ * @param {string} displayValue - string to format, generally input by user
586
+ * @returns {Object} object with style of displayValue and displayValue normalized to ISO string
587
+ */
588
+ const parseFormattedValue = (normalizeFormattedValue, displayValue) => {
589
+ const allowedStyles = Object.values(DATETIME_STYLES);
590
+ let value = null,
591
+ style = null;
189
592
 
190
- export function getISOTimeString(date) {
191
- return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(
192
- date.getSeconds()
193
- )}.${doublePad(date.getMilliseconds())}`;
194
- }
195
-
196
- export function getCurrentTime(timezone) {
197
- const today = getTodayBasedOnTimezone(timezone);
198
- return pad(today.getHours()) + ':' + pad(today.getMinutes());
199
- }
200
-
201
- function getTodayBasedOnTimezone(timezone) {
202
- const today = new Date();
203
- today.setTime(today.getTime() + today.getTimezoneOffset() * 60 * 1000); // time in UTC
593
+ for (let i = 0; i < allowedStyles.length; i++) {
594
+ value = normalizeFormattedValue(displayValue, allowedStyles[i]);
595
+ if (value) {
596
+ style = allowedStyles[i];
597
+ break;
598
+ }
599
+ }
204
600
 
205
- // localization service will use $Locale.timezone when no timezone provided
206
- return syncUTCToWallTime(today, timezone);
207
- }
601
+ return { value, style };
602
+ };
208
603
 
209
- function pad(n) {
210
- return Number(n) < 10 ? '0' + n : n;
211
- }
604
+ export const parseFormattedTime = (value) => {
605
+ return parseFormattedValue(normalizeFormattedTime, value);
606
+ };
212
607
 
213
- function doublePad(n) {
214
- const number = Number(n);
215
- if (number < 10) {
216
- return '00' + n;
217
- } else if (number < 100) {
218
- return '0' + n;
219
- }
220
- return n;
221
- }
608
+ export const parseFormattedDate = (value) => {
609
+ return parseFormattedValue(normalizeFormattedDate, value);
610
+ };