@talxis/base-controls 1.2406.2

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 (352) hide show
  1. package/.env +1 -0
  2. package/.eslintrc +117 -0
  3. package/.npmgitignore +9 -0
  4. package/.vscode/settings.json +3 -0
  5. package/.yalcignore +2 -0
  6. package/README.md +18 -0
  7. package/azure-pipelines.yml +44 -0
  8. package/dist/Lookup-eb1505b3.js +1 -0
  9. package/dist/NumeralPCF-a609b7be.js +1 -0
  10. package/dist/components/DateTime/DateTime.d.ts +3 -0
  11. package/dist/components/DateTime/DateTime.js +1 -0
  12. package/dist/components/DateTime/components/Calendar.d.ts +12 -0
  13. package/dist/components/DateTime/hooks/useDateTime.d.ts +6 -0
  14. package/dist/components/DateTime/index.d.ts +2 -0
  15. package/dist/components/DateTime/interfaces.d.ts +31 -0
  16. package/dist/components/DateTime/styles.d.ts +34 -0
  17. package/dist/components/DateTime/translations.d.ts +3 -0
  18. package/dist/components/Decimal/Decimal.d.ts +3 -0
  19. package/dist/components/Decimal/Decimal.js +1 -0
  20. package/dist/components/Decimal/index.d.ts +2 -0
  21. package/dist/components/Decimal/interfaces.d.ts +13 -0
  22. package/dist/components/Duration/Duration.d.ts +3 -0
  23. package/dist/components/Duration/Duration.js +1 -0
  24. package/dist/components/Duration/index.d.ts +2 -0
  25. package/dist/components/Duration/interfaces.d.ts +31 -0
  26. package/dist/components/Duration/translations.d.ts +2 -0
  27. package/dist/components/Grid/Grid.d.ts +5 -0
  28. package/dist/components/Grid/Grid.js +10 -0
  29. package/dist/components/Grid/core/components/AgGrid/AgGrid.d.ts +2 -0
  30. package/dist/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/EmptyRecords.d.ts +2 -0
  31. package/dist/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/styles.d.ts +18 -0
  32. package/dist/components/Grid/core/components/AgGrid/components/LoadingOverlay/LoadingOverlay.d.ts +2 -0
  33. package/dist/components/Grid/core/components/AgGrid/controllers/useAgGridController.d.ts +12 -0
  34. package/dist/components/Grid/core/components/AgGrid/model/AgGrid.d.ts +13 -0
  35. package/dist/components/Grid/core/components/AgGrid/styles.d.ts +69 -0
  36. package/dist/components/Grid/core/components/Cell/Commands/Commands.d.ts +7 -0
  37. package/dist/components/Grid/core/components/Cell/Commands/Icon.d.ts +7 -0
  38. package/dist/components/Grid/core/components/Cell/Commands/styles.d.ts +19 -0
  39. package/dist/components/Grid/core/components/Cell/Commands/useCommands.d.ts +5 -0
  40. package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.d.ts +10 -0
  41. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.d.ts +11 -0
  42. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.d.ts +10 -0
  43. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.d.ts +22 -0
  44. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.d.ts +47 -0
  45. package/dist/components/Grid/core/components/ColumnHeader/ColumnHeader.d.ts +6 -0
  46. package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.d.ts +2 -0
  47. package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.d.ts +13 -0
  48. package/dist/components/Grid/core/components/ColumnHeader/styles.d.ts +37 -0
  49. package/dist/components/Grid/core/components/Component/Component.d.ts +11 -0
  50. package/dist/components/Grid/core/components/Component/controller/useComponentController.d.ts +9 -0
  51. package/dist/components/Grid/core/components/Component/model/Component.d.ts +10 -0
  52. package/dist/components/Grid/core/components/Dialog/Constants.d.ts +2 -0
  53. package/dist/components/Grid/core/components/Dialog/Styles.d.ts +2 -0
  54. package/dist/components/Grid/core/components/Dialog/index.d.ts +4 -0
  55. package/dist/components/Grid/core/components/Save/Save.d.ts +2 -0
  56. package/dist/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.d.ts +3 -0
  57. package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.d.ts +7 -0
  58. package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/styles.d.ts +48 -0
  59. package/dist/components/Grid/core/components/Save/components/ChangeEditor/styles.d.ts +31 -0
  60. package/dist/components/Grid/core/components/Save/hooks/useSave.d.ts +12 -0
  61. package/dist/components/Grid/core/components/Save/styles.d.ts +37 -0
  62. package/dist/components/Grid/core/controllers/useGridController.d.ts +9 -0
  63. package/dist/components/Grid/core/enums/ConditionOperator.d.ts +46 -0
  64. package/dist/components/Grid/core/enums/DataType.d.ts +24 -0
  65. package/dist/components/Grid/core/hooks/useGridInstance.d.ts +2 -0
  66. package/dist/components/Grid/core/hooks/useRefreshCallback.d.ts +2 -0
  67. package/dist/components/Grid/core/hooks/useRerender.d.ts +1 -0
  68. package/dist/components/Grid/core/interfaces/IGridColumn.d.ts +18 -0
  69. package/dist/components/Grid/core/interfaces/IGridContext.d.ts +4 -0
  70. package/dist/components/Grid/core/model/Grid.d.ts +51 -0
  71. package/dist/components/Grid/core/model/GridDependency.d.ts +13 -0
  72. package/dist/components/Grid/core/model/Metadata.d.ts +7 -0
  73. package/dist/components/Grid/core/services/RecordUpdateService/controllers/useRecordUpdateServiceController.d.ts +14 -0
  74. package/dist/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.d.ts +30 -0
  75. package/dist/components/Grid/filtering/components/FilterCallout/FilterCallout.d.ts +8 -0
  76. package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionOperator/ConditionOperator.d.ts +7 -0
  77. package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.d.ts +7 -0
  78. package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.d.ts +30 -0
  79. package/dist/components/Grid/filtering/components/FilterCallout/styles.d.ts +35 -0
  80. package/dist/components/Grid/filtering/constants.d.ts +5 -0
  81. package/dist/components/Grid/filtering/controller/useColumnFilterConditionController.d.ts +19 -0
  82. package/dist/components/Grid/filtering/model/Condition.d.ts +47 -0
  83. package/dist/components/Grid/filtering/model/Filtering.d.ts +11 -0
  84. package/dist/components/Grid/filtering/utils/FilteringUtilts.d.ts +34 -0
  85. package/dist/components/Grid/interfaces.d.ts +254 -0
  86. package/dist/components/Grid/paging/components/Paging/Paging.d.ts +2 -0
  87. package/dist/components/Grid/paging/components/Paging/styles.d.ts +35 -0
  88. package/dist/components/Grid/paging/controllers/usePagingController.d.ts +16 -0
  89. package/dist/components/Grid/paging/model/Paging.d.ts +15 -0
  90. package/dist/components/Grid/selection/controllers/useSelectionController.d.ts +11 -0
  91. package/dist/components/Grid/selection/model/Selection.d.ts +13 -0
  92. package/dist/components/Grid/sorting/Sorting.d.ts +9 -0
  93. package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.d.ts +8 -0
  94. package/dist/components/Grid/sorting/components/SortingContextualMenu/styles.d.ts +9 -0
  95. package/dist/components/Grid/sorting/controllers/useColumnSortingController.d.ts +8 -0
  96. package/dist/components/Grid/translations.d.ts +2 -0
  97. package/dist/components/Grid/validation/controllers/useRecordValidationController.d.ts +8 -0
  98. package/dist/components/Grid/validation/model/ColumnValidation.d.ts +11 -0
  99. package/dist/components/Lookup/Lookup.d.ts +3 -0
  100. package/dist/components/Lookup/Lookup.js +1 -0
  101. package/dist/components/Lookup/components/RecordCreator.d.ts +10 -0
  102. package/dist/components/Lookup/components/TargetSelector.d.ts +10 -0
  103. package/dist/components/Lookup/hooks/useFetchXml.d.ts +3 -0
  104. package/dist/components/Lookup/hooks/useLoadedEntities.d.ts +6 -0
  105. package/dist/components/Lookup/hooks/useLookup.d.ts +8 -0
  106. package/dist/components/Lookup/index.d.ts +2 -0
  107. package/dist/components/Lookup/interfaces.d.ts +52 -0
  108. package/dist/components/Lookup/lib.d.ts +1164 -0
  109. package/dist/components/Lookup/styles.d.ts +90 -0
  110. package/dist/components/Lookup/translations.d.ts +2 -0
  111. package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.d.ts +3 -0
  112. package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.js +1 -0
  113. package/dist/components/MultiSelectOptionSet/index.d.ts +2 -0
  114. package/dist/components/MultiSelectOptionSet/interfaces.d.ts +11 -0
  115. package/dist/components/OptionSet/OptionSet.d.ts +3 -0
  116. package/dist/components/OptionSet/OptionSet.js +1 -0
  117. package/dist/components/OptionSet/index.d.ts +2 -0
  118. package/dist/components/OptionSet/interfaces.d.ts +13 -0
  119. package/dist/components/TextField/TextField.d.ts +3 -0
  120. package/dist/components/TextField/TextField.js +1 -0
  121. package/dist/components/TextField/hooks/useTextField.d.ts +2 -0
  122. package/dist/components/TextField/index.d.ts +2 -0
  123. package/dist/components/TextField/interfaces.d.ts +15 -0
  124. package/dist/components/TwoOptions/TwoOptions.d.ts +3 -0
  125. package/dist/components/TwoOptions/TwoOptions.js +1 -0
  126. package/dist/components/TwoOptions/index.d.ts +2 -0
  127. package/dist/components/TwoOptions/interfaces.d.ts +13 -0
  128. package/dist/hooks/index.d.ts +1 -0
  129. package/dist/hooks/index.js +1 -0
  130. package/dist/hooks/useComponent.d.ts +7 -0
  131. package/dist/hooks/useComponent.js +1 -0
  132. package/dist/hooks/useFocusIn.d.ts +1 -0
  133. package/dist/hooks/useFocusIn.js +1 -0
  134. package/dist/hooks/useInputBasedComponent.d.ts +32 -0
  135. package/dist/hooks/useInputBasedComponent.js +1 -0
  136. package/dist/hooks/useMouseOver.d.ts +1 -0
  137. package/dist/hooks/useMouseOver.js +1 -0
  138. package/dist/index.d.ts +40 -0
  139. package/dist/interfaces/context.d.ts +20 -0
  140. package/dist/interfaces/index.d.ts +9 -0
  141. package/dist/interfaces/parameters.d.ts +23 -0
  142. package/dist/interfaces/property.d.ts +100 -0
  143. package/dist/types/index.d.ts +3 -0
  144. package/dist/utils/NumeralPCF.d.ts +6 -0
  145. package/examples/Currency/Currency/ControlManifest.Input.xml +53 -0
  146. package/examples/Currency/Currency/index.ts +66 -0
  147. package/examples/Currency/Currency.pcfproj +46 -0
  148. package/examples/Currency/package-lock.json +15900 -0
  149. package/examples/Currency/package.json +29 -0
  150. package/examples/Currency/pcfconfig.json +3 -0
  151. package/examples/Currency/tsconfig.json +7 -0
  152. package/examples/DateTime/DateTime/ControlManifest.Input.xml +58 -0
  153. package/examples/DateTime/DateTime/index.ts +69 -0
  154. package/examples/DateTime/DateTime.pcfproj +46 -0
  155. package/examples/DateTime/package-lock.json +15900 -0
  156. package/examples/DateTime/package.json +29 -0
  157. package/examples/DateTime/pcfconfig.json +3 -0
  158. package/examples/DateTime/tsconfig.json +7 -0
  159. package/examples/Decimal/Decimal/ControlManifest.Input.xml +66 -0
  160. package/examples/Decimal/Decimal/index.ts +66 -0
  161. package/examples/Decimal/Decimal.pcfproj +46 -0
  162. package/examples/Decimal/package-lock.json +15900 -0
  163. package/examples/Decimal/package.json +28 -0
  164. package/examples/Decimal/pcfconfig.json +3 -0
  165. package/examples/Decimal/tsconfig.json +7 -0
  166. package/examples/Duration/Duration/ControlManifest.Input.xml +53 -0
  167. package/examples/Duration/Duration/index.ts +66 -0
  168. package/examples/Duration/Duration.pcfproj +46 -0
  169. package/examples/Duration/package-lock.json +15900 -0
  170. package/examples/Duration/package.json +29 -0
  171. package/examples/Duration/pcfconfig.json +3 -0
  172. package/examples/Duration/tsconfig.json +7 -0
  173. package/examples/Grid/Grid/ControlManifest.Input.xml +28 -0
  174. package/examples/Grid/Grid/index.ts +100 -0
  175. package/examples/Grid/Grid.pcfproj +46 -0
  176. package/examples/Grid/package-lock.json +15901 -0
  177. package/examples/Grid/package.json +30 -0
  178. package/examples/Grid/pcfconfig.json +3 -0
  179. package/examples/Grid/tsconfig.json +7 -0
  180. package/examples/Lookup/Lookup/ControlManifest.Input.xml +51 -0
  181. package/examples/Lookup/Lookup/index.ts +90 -0
  182. package/examples/Lookup/Lookup.pcfproj +46 -0
  183. package/examples/Lookup/package-lock.json +15900 -0
  184. package/examples/Lookup/package.json +29 -0
  185. package/examples/Lookup/pcfconfig.json +3 -0
  186. package/examples/Lookup/tsconfig.json +8 -0
  187. package/examples/MultiSelectOptionSet/MultiSelectOptionSet/ControlManifest.Input.xml +53 -0
  188. package/examples/MultiSelectOptionSet/MultiSelectOptionSet/index.ts +86 -0
  189. package/examples/MultiSelectOptionSet/MultiSelectOptionSet.pcfproj +46 -0
  190. package/examples/MultiSelectOptionSet/package-lock.json +15900 -0
  191. package/examples/MultiSelectOptionSet/package.json +31 -0
  192. package/examples/MultiSelectOptionSet/pcfconfig.json +3 -0
  193. package/examples/MultiSelectOptionSet/tsconfig.json +7 -0
  194. package/examples/OptionSet/OptionSet/ControlManifest.Input.xml +53 -0
  195. package/examples/OptionSet/OptionSet/index.ts +70 -0
  196. package/examples/OptionSet/OptionSet.pcfproj +46 -0
  197. package/examples/OptionSet/package-lock.json +15900 -0
  198. package/examples/OptionSet/package.json +29 -0
  199. package/examples/OptionSet/pcfconfig.json +3 -0
  200. package/examples/OptionSet/tsconfig.json +7 -0
  201. package/examples/TwoOptions/TwoOptions/ControlManifest.Input.xml +53 -0
  202. package/examples/TwoOptions/TwoOptions/index.ts +69 -0
  203. package/examples/TwoOptions/TwoOptions.pcfproj +46 -0
  204. package/examples/TwoOptions/package-lock.json +15900 -0
  205. package/examples/TwoOptions/package.json +29 -0
  206. package/examples/TwoOptions/pcfconfig.json +3 -0
  207. package/examples/TwoOptions/tsconfig.json +7 -0
  208. package/package.json +94 -0
  209. package/public/index.html +43 -0
  210. package/public/manifest.json +25 -0
  211. package/rollup.config.js +44 -0
  212. package/src/components/DateTime/DateTime.tsx +97 -0
  213. package/src/components/DateTime/components/Calendar.tsx +80 -0
  214. package/src/components/DateTime/hooks/useDateTime.ts +144 -0
  215. package/src/components/DateTime/index.ts +2 -0
  216. package/src/components/DateTime/interfaces.ts +22 -0
  217. package/src/components/DateTime/styles.ts +37 -0
  218. package/src/components/DateTime/translations.ts +18 -0
  219. package/src/components/Decimal/Decimal.tsx +120 -0
  220. package/src/components/Decimal/index.ts +2 -0
  221. package/src/components/Decimal/interfaces.ts +20 -0
  222. package/src/components/Duration/Duration.tsx +143 -0
  223. package/src/components/Duration/index.ts +2 -0
  224. package/src/components/Duration/interfaces.ts +22 -0
  225. package/src/components/Duration/translations.ts +30 -0
  226. package/src/components/Grid/Grid.tsx +24 -0
  227. package/src/components/Grid/core/components/AgGrid/AgGrid.tsx +206 -0
  228. package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/EmptyRecords.tsx +16 -0
  229. package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/styles.ts +20 -0
  230. package/src/components/Grid/core/components/AgGrid/components/LoadingOverlay/LoadingOverlay.tsx +7 -0
  231. package/src/components/Grid/core/components/AgGrid/controllers/useAgGridController.ts +68 -0
  232. package/src/components/Grid/core/components/AgGrid/model/AgGrid.ts +100 -0
  233. package/src/components/Grid/core/components/AgGrid/styles.ts +72 -0
  234. package/src/components/Grid/core/components/Cell/Commands/Commands.tsx +32 -0
  235. package/src/components/Grid/core/components/Cell/Commands/Icon.tsx +17 -0
  236. package/src/components/Grid/core/components/Cell/Commands/styles.ts +21 -0
  237. package/src/components/Grid/core/components/Cell/Commands/useCommands.tsx +53 -0
  238. package/src/components/Grid/core/components/Cell/EditableCell/EditableCell.tsx +140 -0
  239. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.tsx +176 -0
  240. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.tsx +67 -0
  241. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.ts +24 -0
  242. package/src/components/Grid/core/components/Cell/ReadOnlyCell/styles.ts +56 -0
  243. package/src/components/Grid/core/components/ColumnHeader/ColumnHeader.tsx +71 -0
  244. package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.tsx +31 -0
  245. package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.ts +16 -0
  246. package/src/components/Grid/core/components/ColumnHeader/styles.ts +40 -0
  247. package/src/components/Grid/core/components/Component/Component.tsx +59 -0
  248. package/src/components/Grid/core/components/Component/controller/useComponentController.ts +39 -0
  249. package/src/components/Grid/core/components/Component/model/Component.ts +251 -0
  250. package/src/components/Grid/core/components/Dialog/Constants.tsx +8 -0
  251. package/src/components/Grid/core/components/Dialog/Styles.tsx +61 -0
  252. package/src/components/Grid/core/components/Dialog/index.tsx +22 -0
  253. package/src/components/Grid/core/components/Dialog/interfaces/index.d.ts +7 -0
  254. package/src/components/Grid/core/components/Save/Save.tsx +74 -0
  255. package/src/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.tsx +63 -0
  256. package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.tsx +153 -0
  257. package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/styles.ts +52 -0
  258. package/src/components/Grid/core/components/Save/components/ChangeEditor/styles.ts +34 -0
  259. package/src/components/Grid/core/components/Save/hooks/useSave.ts +59 -0
  260. package/src/components/Grid/core/components/Save/styles.ts +41 -0
  261. package/src/components/Grid/core/controllers/useGridController.ts +46 -0
  262. package/src/components/Grid/core/enums/ConditionOperator.ts +46 -0
  263. package/src/components/Grid/core/enums/DataType.ts +25 -0
  264. package/src/components/Grid/core/hooks/useGridInstance.ts +7 -0
  265. package/src/components/Grid/core/hooks/useRefreshCallback.ts +20 -0
  266. package/src/components/Grid/core/hooks/useRerender.ts +15 -0
  267. package/src/components/Grid/core/interfaces/IGridColumn.ts +19 -0
  268. package/src/components/Grid/core/interfaces/IGridContext.ts +7 -0
  269. package/src/components/Grid/core/model/Grid.ts +250 -0
  270. package/src/components/Grid/core/model/GridDependency.ts +34 -0
  271. package/src/components/Grid/core/model/Metadata.ts +20 -0
  272. package/src/components/Grid/core/services/RecordUpdateService/controllers/useRecordUpdateServiceController.ts +36 -0
  273. package/src/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.ts +222 -0
  274. package/src/components/Grid/filtering/components/FilterCallout/FilterCallout.tsx +83 -0
  275. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionOperator/ConditionOperator.tsx +66 -0
  276. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.tsx +48 -0
  277. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.ts +120 -0
  278. package/src/components/Grid/filtering/components/FilterCallout/styles.ts +37 -0
  279. package/src/components/Grid/filtering/constants.ts +48 -0
  280. package/src/components/Grid/filtering/controller/useColumnFilterConditionController.ts +63 -0
  281. package/src/components/Grid/filtering/model/Condition.ts +309 -0
  282. package/src/components/Grid/filtering/model/Filtering.ts +78 -0
  283. package/src/components/Grid/filtering/utils/FilteringUtilts.ts +190 -0
  284. package/src/components/Grid/interfaces.ts +109 -0
  285. package/src/components/Grid/paging/components/Paging/Paging.tsx +76 -0
  286. package/src/components/Grid/paging/components/Paging/styles.ts +38 -0
  287. package/src/components/Grid/paging/controllers/usePagingController.ts +34 -0
  288. package/src/components/Grid/paging/model/Paging.ts +49 -0
  289. package/src/components/Grid/selection/controllers/useSelectionController.ts +25 -0
  290. package/src/components/Grid/selection/model/Selection.ts +60 -0
  291. package/src/components/Grid/sorting/Sorting.ts +30 -0
  292. package/src/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.tsx +126 -0
  293. package/src/components/Grid/sorting/components/SortingContextualMenu/styles.ts +12 -0
  294. package/src/components/Grid/sorting/controllers/useColumnSortingController.ts +26 -0
  295. package/src/components/Grid/translations.ts +80 -0
  296. package/src/components/Grid/validation/controllers/useRecordValidationController.ts +31 -0
  297. package/src/components/Grid/validation/model/ColumnValidation.ts +81 -0
  298. package/src/components/Lookup/Lookup.tsx +199 -0
  299. package/src/components/Lookup/components/RecordCreator.tsx +53 -0
  300. package/src/components/Lookup/components/TargetSelector.tsx +43 -0
  301. package/src/components/Lookup/hooks/useFetchXml.ts +31 -0
  302. package/src/components/Lookup/hooks/useLoadedEntities.ts +23 -0
  303. package/src/components/Lookup/hooks/useLookup.ts +126 -0
  304. package/src/components/Lookup/index.ts +2 -0
  305. package/src/components/Lookup/interfaces.ts +45 -0
  306. package/src/components/Lookup/lib.ts +3110 -0
  307. package/src/components/Lookup/styles.ts +106 -0
  308. package/src/components/Lookup/translations.ts +28 -0
  309. package/src/components/MultiSelectOptionSet/MultiSelectOptionSet.tsx +83 -0
  310. package/src/components/MultiSelectOptionSet/index.ts +2 -0
  311. package/src/components/MultiSelectOptionSet/interfaces.ts +14 -0
  312. package/src/components/OptionSet/OptionSet.tsx +67 -0
  313. package/src/components/OptionSet/index.ts +2 -0
  314. package/src/components/OptionSet/interfaces.ts +17 -0
  315. package/src/components/TextField/TextField.tsx +58 -0
  316. package/src/components/TextField/hooks/useTextField.ts +42 -0
  317. package/src/components/TextField/index.ts +2 -0
  318. package/src/components/TextField/interfaces.ts +20 -0
  319. package/src/components/TwoOptions/TwoOptions.tsx +43 -0
  320. package/src/components/TwoOptions/index.ts +2 -0
  321. package/src/components/TwoOptions/interfaces.ts +17 -0
  322. package/src/hooks/index.ts +1 -0
  323. package/src/hooks/useComponent.ts +83 -0
  324. package/src/hooks/useFocusIn.ts +23 -0
  325. package/src/hooks/useInputBasedComponent.ts +71 -0
  326. package/src/hooks/useMouseOver.ts +23 -0
  327. package/src/index.tsx +12 -0
  328. package/src/interfaces/context.ts +21 -0
  329. package/src/interfaces/index.ts +12 -0
  330. package/src/interfaces/parameters.ts +26 -0
  331. package/src/interfaces/property.ts +111 -0
  332. package/src/sandbox/index.tsx +137 -0
  333. package/src/sandbox/mock/Context.ts +18 -0
  334. package/src/sandbox/mock/Formatting.ts +186 -0
  335. package/src/sandbox/mock/Mode.ts +25 -0
  336. package/src/sandbox/mock/UserSettings.ts +31 -0
  337. package/src/sandbox/mock/Utility.ts +14 -0
  338. package/src/sandbox/shared/durationList.tsx +24 -0
  339. package/src/sandbox/shared/multiSelectOptionList.tsx +5 -0
  340. package/src/sandbox/shared/optionList.tsx +5 -0
  341. package/src/stories/Introduction.stories.mdx +122 -0
  342. package/src/stories/assets/code-brackets.svg +1 -0
  343. package/src/stories/assets/colors.svg +1 -0
  344. package/src/stories/assets/comments.svg +1 -0
  345. package/src/stories/assets/direction.svg +1 -0
  346. package/src/stories/assets/flow.svg +1 -0
  347. package/src/stories/assets/plugin.svg +1 -0
  348. package/src/stories/assets/repo.svg +1 -0
  349. package/src/stories/assets/stackalt.svg +1 -0
  350. package/src/types/index.ts +3 -0
  351. package/src/utils/NumeralPCF.ts +62 -0
  352. package/tsconfig.json +28 -0
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "pcf-project",
3
+ "version": "1.2406.2",
4
+ "description": "Project containing your PowerApps Component Framework (PCF) control.",
5
+ "scripts": {
6
+ "build": "pcf-scripts build",
7
+ "clean": "pcf-scripts clean",
8
+ "lint": "pcf-scripts lint",
9
+ "lint:fix": "pcf-scripts lint fix",
10
+ "rebuild": "pcf-scripts rebuild",
11
+ "start": "pcf-scripts start",
12
+ "start:watch": "pcf-scripts start watch",
13
+ "refreshTypes": "pcf-scripts refreshTypes"
14
+ },
15
+ "devDependencies": {
16
+ "@microsoft/eslint-plugin-power-apps": "^0.2.6",
17
+ "@types/node": "^18.8.2",
18
+ "@types/powerapps-component-framework": "^1.3.4",
19
+ "@typescript-eslint/eslint-plugin": "^5.39.0",
20
+ "@typescript-eslint/parser": "^5.39.0",
21
+ "eslint": "^8.24.0",
22
+ "eslint-plugin-import": "^2.26.0",
23
+ "eslint-plugin-node": "^11.1.0",
24
+ "eslint-plugin-promise": "^6.0.1",
25
+ "pcf-scripts": "^1",
26
+ "pcf-start": "^1",
27
+ "typescript": "^4.9.5"
28
+ }
29
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "outDir": "./out/controls"
3
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./node_modules/pcf-scripts/tsconfig_base.json",
3
+ "compilerOptions": {
4
+ "allowSyntheticDefaultImports": true,
5
+ "typeRoots": ["node_modules/@types"]
6
+ }
7
+ }
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@talxis/base-controls",
3
+ "version": "1.2406.2",
4
+ "description": "Set of React components that natively work with Power Apps Component Framework API's",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "license": "MIT",
8
+ "types": "dist/index.d.ts",
9
+ "devDependencies": {
10
+ "@babel/core": "^7.16.12",
11
+ "@rollup/plugin-commonjs": "^21.0.1",
12
+ "@rollup/plugin-node-resolve": "^13.0.6",
13
+ "@rollup/plugin-typescript": "^8.3.0",
14
+ "@testing-library/jest-dom": "^5.16.1",
15
+ "@testing-library/react": "^12.1.2",
16
+ "@testing-library/user-event": "^13.5.0",
17
+ "@types/color": "^3.0.6",
18
+ "@types/jest": "^27.4.0",
19
+ "@types/lodash.clonedeep": "^4.5.7",
20
+ "@types/node": "^17.0.14",
21
+ "@types/numeral": "^2.0.5",
22
+ "@types/powerapps-component-framework": "^1.3.5",
23
+ "@types/react": "^17.0.38",
24
+ "@types/react-dom": "^17.0.11",
25
+ "babel-loader": "^8.2.3",
26
+ "esbuild": "^0.13.9",
27
+ "postcss": "^8.3.11",
28
+ "react-scripts": "5.0.0",
29
+ "rollup": "^2.58.1",
30
+ "rollup-plugin-delete": "^2.0.0",
31
+ "rollup-plugin-dts": "^4.0.0",
32
+ "rollup-plugin-esbuild": "^4.6.0",
33
+ "rollup-plugin-multi-input": "^1.3.1",
34
+ "rollup-plugin-peer-deps-external": "^2.2.4",
35
+ "rollup-plugin-postcss": "^4.0.1",
36
+ "rollup-plugin-terser": "^7.0.2",
37
+ "typescript": "^4.5.2",
38
+ "web-vitals": "^2.1.4",
39
+ "webpack": "^5.68.0",
40
+ "@types/validator": "^13.11.9"
41
+ },
42
+ "peerDependencies": {
43
+ "@fluentui/react": "8.51.0 || 8.29.0",
44
+ "@talxis/client-libraries": "^1.2402.3",
45
+ "color": "^4.2.3",
46
+ "dayjs": "^1.11.10",
47
+ "external-svg-loader": "^1.7.1",
48
+ "fast-deep-equal": "^3.1.3",
49
+ "humanize-duration": "^3.32.0",
50
+ "liquidjs": "^9.43.0",
51
+ "lodash.clonedeep": "^4.5.0",
52
+ "merge-anything": "^5.1.7",
53
+ "numeral": "^2.0.6",
54
+ "react": "^16.8.6 || ^17.0.2",
55
+ "react-dom": "^16.8.6 || ^17.0.2",
56
+ "use-debounce": "^10.0.1",
57
+ "validator": "^13.11.9",
58
+ "@talxis/react-components": "^1.2404.1"
59
+ },
60
+ "scripts": {
61
+ "build": "rollup -c",
62
+ "test": "react-scripts test",
63
+ "eject": "react-scripts eject",
64
+ "documentation": "start-storybook -p 6006",
65
+ "sandbox": "react-scripts start",
66
+ "build-documentation": "build-storybook",
67
+ "lint": "eslint \"./src/**\"",
68
+ "lint:fix": "eslint \"./src/**\" --fix"
69
+ },
70
+ "eslintConfig": {
71
+ "extends": [
72
+ "react-app",
73
+ "react-app/jest"
74
+ ]
75
+ },
76
+ "browserslist": {
77
+ "production": [
78
+ ">0.2%",
79
+ "not dead",
80
+ "not op_mini all"
81
+ ],
82
+ "development": [
83
+ "last 1 chrome version",
84
+ "last 1 firefox version",
85
+ "last 1 safari version"
86
+ ]
87
+ },
88
+ "dependencies": {
89
+ "@ag-grid-community/client-side-row-model": "^31.3.2",
90
+ "@ag-grid-community/core": "^31.3.2",
91
+ "@ag-grid-community/react": "^31.3.2",
92
+ "@ag-grid-community/styles": "^31.3.2"
93
+ }
94
+ }
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
@@ -0,0 +1,25 @@
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
@@ -0,0 +1,44 @@
1
+ import commonjs from '@rollup/plugin-commonjs';
2
+ import typescript from '@rollup/plugin-typescript';
3
+ import { terser } from 'rollup-plugin-terser';
4
+ import peerDepsExternal from 'rollup-plugin-peer-deps-external';
5
+ import postcss from 'rollup-plugin-postcss';
6
+ import dts from 'rollup-plugin-dts';
7
+ import resolve from '@rollup/plugin-node-resolve';
8
+ import multiInput from 'rollup-plugin-multi-input';
9
+ import del from 'rollup-plugin-delete';
10
+
11
+ export default [
12
+ {
13
+ input: [
14
+ 'src/components/*/*.tsx',
15
+ 'src/hooks/*.ts'
16
+ ],
17
+ output: [
18
+ {
19
+ dir: 'dist',
20
+ format: 'esm',
21
+ }
22
+ ],
23
+ plugins: [
24
+ commonjs(),
25
+ peerDepsExternal('./package.json'),
26
+ resolve(),
27
+ typescript({
28
+ tsconfig: './tsconfig.json',
29
+ }),
30
+ postcss(),
31
+ multiInput(),
32
+ terser()
33
+ ],
34
+ },
35
+ {
36
+ input: ['dist/index.d.ts'],
37
+ output: [{ file: 'dist/index.d.ts', format: "esm"}],
38
+ external: [/\.css$/],
39
+ plugins: [
40
+ dts(),
41
+ del({ hook: "buildEnd", targets: ['dist/stories', 'dist/sandbox'] })
42
+ ],
43
+ },
44
+ ];
@@ -0,0 +1,97 @@
1
+
2
+ import { IDateTime } from "./interfaces";
3
+ import { IDatePicker, useTheme } from "@fluentui/react";
4
+ import { useEffect, useRef } from "react";
5
+ import { getDateTimeStyles } from "./styles";
6
+ import { useDateTime } from "./hooks/useDateTime";
7
+ import dayjs from 'dayjs';
8
+ import { Calendar } from "./components/Calendar";
9
+ import { DatePicker } from "@talxis/react-components/dist/components/DatePicker";
10
+ import React from 'react';
11
+
12
+ export const DateTime = (componentProps: IDateTime) => {
13
+ const ref = useRef<HTMLDivElement>(null);
14
+ const datePickerRef = useRef<IDatePicker>(null);
15
+ const theme = useTheme();
16
+ const styles = getDateTimeStyles(theme);
17
+ const context = componentProps.context;
18
+ const parameters = componentProps.parameters;
19
+ const [date, stringDate, isDateTime, patterns, labels, setStringDate, selectDate, clearDate] = useDateTime(componentProps, ref);
20
+
21
+ useEffect(() => {
22
+ if(componentProps.parameters.AutoFocus?.raw === true) {
23
+ datePickerRef.current?.showDatePickerPopup();
24
+ }
25
+ }, []);
26
+ return (
27
+ <div ref={ref}>
28
+ <DatePicker
29
+ className={styles.datePicker}
30
+ componentRef={datePickerRef}
31
+ keepCalendarOpenAfterDaySelect={isDateTime}
32
+ allowTextInput
33
+ calendarProps={{
34
+ //needs to be here as the internal picker does not call the function passed in calendarAs
35
+ onSelectDate: (date) => selectDate(date),
36
+ }}
37
+ // Lowest date supported by CDS: https://learn.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/dn996866(v=crm.8)?redirectedfrom=MSDN
38
+ minDate={new Date('1753-01-01T00:00:00.000Z')}
39
+ firstDayOfWeek={componentProps.context.userSettings.dateFormattingInfo.firstDayOfWeek}
40
+ calendarAs={(props) =>
41
+ <Calendar {...props}
42
+ strings={{
43
+ goToToday: labels.goToToday(),
44
+ days: JSON.parse(labels.days()),
45
+ months: JSON.parse(labels.months()),
46
+ shortDays: JSON.parse(labels.shortDays()),
47
+ shortMonths: JSON.parse(labels.shortMonths())
48
+ }}
49
+ timePickerProps={{
50
+ autoComplete: "off",
51
+ autoCapitalize: "off",
52
+ timeFormat: patterns.shortTimePattern,
53
+ label: labels.time(),
54
+ visible: isDateTime && !parameters.value.errorMessage,
55
+ useHour12: patterns.shortTimePattern.endsWith('A'),
56
+ onChange: (e, date) => selectDate(undefined, dayjs(date).format('HH:mm')),
57
+ defaultValue: date
58
+ }} />
59
+ }
60
+ textField={{
61
+ value: stringDate ?? "",
62
+ onChange: (e, value) => setStringDate(value),
63
+ placeholder: '---',
64
+ onNotifyValidationResult: () => null,
65
+ noValidate: true,
66
+ borderless: parameters.EnableBorder?.raw === false,
67
+ errorMessage: parameters.value.errorMessage,
68
+ styles:{
69
+ fieldGroup: {
70
+ height: context.mode.allocatedHeight || undefined,
71
+ width: context.mode.allocatedWidth || undefined
72
+ }
73
+ },
74
+ //@ts-ignore - TODO: fix types in shared components
75
+ deleteButtonProps: parameters.EnableDeleteButton?.raw === true ? {
76
+ key: 'Delete',
77
+ onClick: clearDate,
78
+ showOnlyOnHover: true,
79
+ iconProps: {
80
+ iconName: 'Cancel'
81
+ }
82
+ } : undefined,
83
+ clickToCopyProps: parameters.EnableCopyButton?.raw === true ? {
84
+ key: 'copy',
85
+ showOnlyOnHover: true,
86
+ iconProps: {
87
+ iconName: 'Copy'
88
+ }
89
+ } : undefined
90
+ }
91
+ }
92
+ //undefined will break the calendar => it wont reflect date change in it's UI
93
+ value={date ?? new Date()}
94
+ />
95
+ </div>
96
+ );
97
+ };
@@ -0,0 +1,80 @@
1
+ import { ICalendarProps } from "@fluentui/react/lib/components/Calendar/Calendar.types";
2
+ import { IAutofill } from "@fluentui/react/lib/components/pickers/AutoFill/BaseAutoFill.types";
3
+ import { ITimePickerProps } from "@fluentui/react/lib/components/TimePicker/TimePicker.types";
4
+ import { useTheme } from "@fluentui/react/lib/utilities/ThemeProvider/useTheme";
5
+ import { Calendar as CalendarBase } from '@fluentui/react/lib/Calendar';
6
+ import { useEffect, useRef, useState } from "react";
7
+ import { getDateTimeStyles } from "../styles";
8
+ import { TimePicker } from "@talxis/react-components/dist/components/TimePicker";
9
+ import { Text } from '@fluentui/react/lib/Text';
10
+ import dayjs from "dayjs";
11
+ import React from 'react';
12
+ import { FocusTrapZone } from "@fluentui/react";
13
+
14
+ interface IInternalTimePickerProps extends ITimePickerProps {
15
+ visible: boolean;
16
+ timeFormat: string;
17
+ }
18
+
19
+ interface IInternalCalendarProps extends ICalendarProps {
20
+ timePickerProps: IInternalTimePickerProps;
21
+ }
22
+
23
+ export const Calendar = (props: IInternalCalendarProps) => {
24
+ const theme = useTheme();
25
+ const styles = getDateTimeStyles(theme);
26
+ const timePickerRef = useRef<IAutofill>(null);
27
+ const [isTimePickerControlled, setIsTimePickerControlled] = useState<boolean>(true);
28
+ useEffect(() => {
29
+ //@ts-ignore - we need to use the internal method to display exact time, otherwise the shown value would always get rounded to the next 15 min
30
+ timePickerRef.current?._updateValue(getFormattedTime());
31
+ setIsTimePickerControlled(false);
32
+
33
+ }, [props.timePickerProps.defaultValue]);
34
+
35
+ const getFormattedTime = () => {
36
+ return dayjs(props.timePickerProps.defaultValue).format(props.timePickerProps.timeFormat);
37
+ };
38
+
39
+ useEffect(() => {
40
+ //hack to focus the selected date for keyboard support
41
+ const day = document.querySelector('.ms-CalendarDay-daySelected') as HTMLButtonElement;
42
+ day?.focus();
43
+ }, [props]);
44
+
45
+ return (
46
+ <div className={styles.calendarCallout}>
47
+ <CalendarBase {...props} />
48
+ <hr />
49
+ {props.timePickerProps.visible &&
50
+ <TimePicker
51
+ {...props.timePickerProps}
52
+ onChange={(e, time) => {
53
+ setIsTimePickerControlled(true);
54
+ props.timePickerProps.onChange!(e, time);
55
+ }}
56
+ defaultValue={dayjs(new Date()).startOf('day').toDate()}
57
+ useComboBoxAsMenuWidth
58
+ styles={{
59
+ callout: {
60
+ maxHeight: '300px !important'
61
+ }
62
+ }}
63
+ autofill={{
64
+ componentRef: timePickerRef,
65
+ //hack to prevent blinking on prop updates
66
+ value: isTimePickerControlled ? getFormattedTime() : undefined
67
+ }}
68
+ buttonIconProps={{
69
+ iconName: 'Clock'
70
+ }}
71
+ onRenderOption={(option) => {
72
+ //the timepicker displays 24 instead of 00 during the option displaying for some reason
73
+ return <Text>{option?.text.replace('24', '00')}</Text>;
74
+ }}
75
+ increments={15}
76
+ allowFreeform />
77
+ }
78
+ </div>
79
+ );
80
+ };
@@ -0,0 +1,144 @@
1
+ import { useEffect, useMemo } from "react";
2
+ import { useInputBasedComponent } from "../../../hooks/useInputBasedComponent";
3
+ import { IDateTime, IDateTimeOutputs, IDateTimeParameters, IDateTimeTranslations } from "../interfaces";
4
+ import dayjs from 'dayjs';
5
+ import utc from 'dayjs/plugin/utc';
6
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
7
+ import { getDefaultDateTimeTranslations } from "../translations";
8
+ import { StringProps } from "../../../types";
9
+ dayjs.extend(customParseFormat);
10
+ dayjs.extend(utc);
11
+
12
+ export const useDateTime = (props: IDateTime, ref: React.RefObject<HTMLDivElement>): [
13
+ Date | undefined,
14
+ string | undefined,
15
+ boolean,
16
+ {
17
+ shortDatePattern: string
18
+ shortTimePattern: string;
19
+ },
20
+ Required<StringProps<IDateTimeTranslations>>,
21
+ (value: string | undefined) => void,
22
+ (date: Date | undefined, time?: string) => void,
23
+ () => void
24
+
25
+ ] => {
26
+
27
+ const boundValue = props.parameters.value;
28
+ const context = props.context;
29
+ const behavior = boundValue.attributes.Behavior;
30
+ const format = boundValue.attributes.Format;
31
+ const dateFormattingInfo = context.userSettings.dateFormattingInfo;
32
+
33
+ const isDateTime = (() => {
34
+ switch (format) {
35
+ case 'DateAndTime':
36
+ case 'Date and Time':
37
+ case 'DateAndTime.DateAndTime':
38
+ case 'datetime': {
39
+ return true;
40
+ }
41
+ default: {
42
+ return false;
43
+ }
44
+ }
45
+ })();
46
+
47
+ //MS returns the pattern without correct separator and they do this during formatting
48
+ const shortDatePattern = dateFormattingInfo.shortDatePattern.replace(/\//g, dateFormattingInfo.dateSeparator).toUpperCase();
49
+ const shortTimePattern = dateFormattingInfo.shortTimePattern.replace(/:/g, dateFormattingInfo.timeSeparator).replace('tt', 'A');
50
+ const formatting = (() => {
51
+ if (isDateTime) {
52
+ return `${shortDatePattern} ${shortTimePattern}`;
53
+ }
54
+ return shortDatePattern;
55
+ })();
56
+
57
+ const formatDate = (date: Date | undefined | null | string): string | undefined => {
58
+ if (date == undefined) {
59
+ return undefined;
60
+ }
61
+ if (typeof date === 'string') {
62
+ const dayjsDate = dayjs(date, formatting);
63
+ //error situation
64
+ if (!dayjsDate.isValid()) {
65
+ return date;
66
+ }
67
+ date = dayjsDate.toDate();
68
+ }
69
+ if (isDateTime) {
70
+ //should handle the time zone conversion
71
+ return context.formatting.formatTime(date, behavior);
72
+ }
73
+ return context.formatting.formatDateShort(date);
74
+ };
75
+
76
+ const [dateStringValue, labels, setDateStringValue, notifyOutputChanged] = useInputBasedComponent<string | undefined, IDateTimeParameters, IDateTimeOutputs, IDateTimeTranslations>('DateTime', props, {
77
+ formatter: formatDate,
78
+ defaultTranslations: getDefaultDateTimeTranslations(props.context.userSettings.dateFormattingInfo)
79
+ });
80
+
81
+ useEffect(() => {
82
+ const onBlur = () => {
83
+ if (formatDate(boundValue.raw) === dateStringValue) {
84
+ return;
85
+ }
86
+ notifyOutputChanged({
87
+ value: dateExtractor(dateStringValue!) as any
88
+ });
89
+ };
90
+ const input = ref.current?.querySelector('input');
91
+ input?.addEventListener('blur', onBlur);
92
+ return () => {
93
+ input?.removeEventListener('blur', onBlur);
94
+ };
95
+ }, [dateStringValue]);
96
+
97
+ const getDate = (): Date | undefined => {
98
+ if (boundValue.raw instanceof Date) {
99
+ if (behavior === 3) {
100
+ //the date in javascript gets automatically adjusted to local time zone
101
+ //this will make it think that the date already came in local time, thus not adjusting the time
102
+ const date = new Date(boundValue.raw.toISOString().replace('Z', ''));
103
+ return date;
104
+ }
105
+ return boundValue.raw;
106
+ }
107
+ //this scenario should only happen in cases of error or null value
108
+ return undefined;
109
+ };
110
+
111
+ const dateExtractor = (value: string | Date): Date | string => {
112
+ if (value instanceof Date) {
113
+ return value;
114
+ }
115
+ const dayjsDate = dayjs(value, formatting);
116
+ if (!dayjsDate.isValid()) {
117
+ return value;
118
+ }
119
+ return dayjsDate.toDate();
120
+ };
121
+
122
+ const clearDate = () => {
123
+ notifyOutputChanged({
124
+ value: undefined
125
+ });
126
+ };
127
+
128
+ const selectDate = (date?: Date, time?: string) => {
129
+ let dayjsDate = dayjs(date ?? getDate());
130
+ let _time = time;
131
+ //date selected from calendar, keep the original time
132
+ if (!_time) {
133
+ _time = dayjs(getDate()).format('HH:mm');
134
+ }
135
+ const [hours, minutes] = _time.split(':');
136
+ dayjsDate = dayjsDate.hour(parseInt(hours));
137
+ dayjsDate = dayjsDate.minute(parseInt(minutes));
138
+ notifyOutputChanged({
139
+ value: dayjsDate.toDate()
140
+ });
141
+ };
142
+
143
+ return [getDate(), dateStringValue, isDateTime, { shortDatePattern, shortTimePattern }, labels, setDateStringValue, selectDate, clearDate];
144
+ };
@@ -0,0 +1,2 @@
1
+ export * from './DateTime';
2
+ export * from './interfaces';
@@ -0,0 +1,22 @@
1
+ import { IDateTimeProperty } from "../../interfaces";
2
+ import { IComponent, IOutputs, ITranslations } from "../../interfaces/context";
3
+ import { IBaseParameters, IInputParameters } from "../../interfaces/parameters";
4
+
5
+ export interface IDateTime extends IComponent<IDateTimeParameters, IDateTimeOutputs, IDateTimeTranslations> {
6
+ }
7
+
8
+ export interface IDateTimeParameters extends IInputParameters {
9
+ value: IDateTimeProperty;
10
+ }
11
+
12
+ export interface IDateTimeOutputs extends IOutputs {
13
+ value?: Date;
14
+ }
15
+ export interface IDateTimeTranslations extends ITranslations {
16
+ time?: {[LCID: number]: string}
17
+ goToToday?: {[LCID: number]: string}
18
+ days?: {[LCID: number]: string[]} | string[];
19
+ months?: {[LCID: number]: string[]} | string[];
20
+ shortDays?: {[LCID: number]: string[]} | string[];
21
+ shortMonths?: {[LCID: number]: string[]} | string[];
22
+ }
@@ -0,0 +1,37 @@
1
+ import { ITheme, mergeStyleSets } from "@fluentui/react";
2
+
3
+ export const getDateTimeStyles = (theme: ITheme) => {
4
+ return mergeStyleSets({
5
+ datePicker: {
6
+ '[class^="statusMessage"]': {
7
+ display: 'none'
8
+ }
9
+ },
10
+ calendarCallout: {
11
+ '.TALXIS__timepicker__root': {
12
+ padding: 12,
13
+ 'label': {
14
+ paddingTop: 0
15
+ },
16
+ 'i': {
17
+ fontSize: 16
18
+ }
19
+ },
20
+ 'hr': {
21
+ margin: 0,
22
+ border: 'none',
23
+ height: 1,
24
+ backgroundColor: theme.semanticColors.bodyDivider
25
+ },
26
+ '[class^="monthAndYear"], [class*="weekDayLabelCell"]': {
27
+ animationDuration: '0s'
28
+ },
29
+ '[class^="dayCell"]:focus': {
30
+ outline: `solid 1px !important`
31
+ },
32
+ '.ms-DatePicker': {
33
+ animationDuration: '0s'
34
+ }
35
+ }
36
+ });
37
+ };
@@ -0,0 +1,18 @@
1
+ import { IDateTimeTranslations } from "./interfaces";
2
+
3
+ export const getDefaultDateTimeTranslations = (dateFormattingInfo: ComponentFramework.UserSettingApi.DateFormattingInfo): Required<IDateTimeTranslations> => {
4
+ return {
5
+ time: {
6
+ 1029: 'Čas',
7
+ 1033: 'Time'
8
+ },
9
+ goToToday: {
10
+ 1029: 'Přejít na dnešek',
11
+ 1033: 'Go to today'
12
+ },
13
+ days: dateFormattingInfo.dayNames,
14
+ months: dateFormattingInfo.monthNames,
15
+ shortDays: dateFormattingInfo.shortestDayNames,
16
+ shortMonths: dateFormattingInfo.abbreviatedMonthNames,
17
+ };
18
+ };