@aehrc/smart-forms-renderer 0.8.1 → 0.9.1

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 (355) hide show
  1. package/README.md +4 -2
  2. package/lib/components/FormComponents/BooleanItem/BooleanItem.d.ts +2 -2
  3. package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.d.ts +2 -2
  4. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.d.ts +3 -3
  5. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +12 -12
  6. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
  7. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.d.ts +3 -3
  8. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +12 -12
  9. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
  10. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.d.ts +3 -4
  11. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js +3 -3
  12. package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js.map +1 -1
  13. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.d.ts +2 -2
  14. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.d.ts +2 -2
  15. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.d.ts +2 -2
  16. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.d.ts +2 -2
  17. package/lib/components/FormComponents/CustomDateItem/CustomDateField2.d.ts +18 -0
  18. package/lib/components/FormComponents/CustomDateItem/CustomDateField2.js +31 -0
  19. package/lib/components/FormComponents/CustomDateItem/CustomDateField2.js.map +1 -0
  20. package/lib/components/FormComponents/CustomDateItem/CustomDateItem.d.ts +9 -0
  21. package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js +68 -0
  22. package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js.map +1 -0
  23. package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.d.ts +9 -0
  24. package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.js +75 -0
  25. package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.js.map +1 -0
  26. package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.d.ts +9 -0
  27. package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.js +75 -0
  28. package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.js.map +1 -0
  29. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.d.ts +18 -0
  30. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.js +33 -0
  31. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.js.map +1 -0
  32. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.d.ts +11 -0
  33. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.js +55 -0
  34. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.js.map +1 -0
  35. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.d.ts +9 -0
  36. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.js +13 -0
  37. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.js.map +1 -0
  38. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.d.ts +5 -0
  39. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.js +20 -0
  40. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.js.map +1 -0
  41. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.d.ts +5 -0
  42. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js +27 -0
  43. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js.map +1 -0
  44. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/index.d.ts +1 -0
  45. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/index.js +18 -0
  46. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/index.js.map +1 -0
  47. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.d.ts +1 -0
  48. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.js +18 -0
  49. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.js.map +1 -0
  50. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.d.ts +9 -0
  51. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.js +121 -0
  52. package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.js.map +1 -0
  53. package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.d.ts +9 -0
  54. package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.js +71 -0
  55. package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.js.map +1 -0
  56. package/lib/components/FormComponents/CustomDateItem/index.d.ts +1 -0
  57. package/lib/components/FormComponents/CustomDateItem/index.js +18 -0
  58. package/lib/components/FormComponents/CustomDateItem/index.js.map +1 -0
  59. package/lib/components/FormComponents/DateItem/DateItem.d.ts +3 -4
  60. package/lib/components/FormComponents/DateTimeItem/DateTimeItem.d.ts +2 -2
  61. package/lib/components/FormComponents/DecimalItem/DecimalItem.d.ts +2 -2
  62. package/lib/components/FormComponents/DecimalItem/DecimalItem.js +2 -3
  63. package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
  64. package/lib/components/FormComponents/DisplayItem/DisplayBox.d.ts +0 -0
  65. package/lib/components/FormComponents/DisplayItem/DisplayBox.js +2 -0
  66. package/lib/components/FormComponents/DisplayItem/DisplayBox.js.map +1 -0
  67. package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.d.ts +4 -0
  68. package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.js +35 -0
  69. package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.js.map +1 -0
  70. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.d.ts +2 -1
  71. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.js.map +1 -1
  72. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.styles.js +0 -1
  73. package/lib/components/FormComponents/DisplayItem/DisplayInstructions.styles.js.map +1 -1
  74. package/lib/components/FormComponents/GridGroup/GridGroup.d.ts +3 -3
  75. package/lib/components/FormComponents/GridGroup/GridGroup.js +13 -8
  76. package/lib/components/FormComponents/GridGroup/GridGroup.js.map +1 -1
  77. package/lib/components/FormComponents/GridGroup/GridRow.d.ts +3 -4
  78. package/lib/components/FormComponents/GridGroup/GridRow.js +3 -3
  79. package/lib/components/FormComponents/GridGroup/GridRow.js.map +1 -1
  80. package/lib/components/FormComponents/GridGroup/GridTable.d.ts +3 -3
  81. package/lib/components/FormComponents/GridGroup/GridTable.js +9 -4
  82. package/lib/components/FormComponents/GridGroup/GridTable.js.map +1 -1
  83. package/lib/components/FormComponents/GridGroup/index.d.ts +1 -0
  84. package/lib/components/FormComponents/GridGroup/index.js +18 -0
  85. package/lib/components/FormComponents/GridGroup/index.js.map +1 -0
  86. package/lib/components/FormComponents/GroupItem/GroupItem.d.ts +2 -2
  87. package/lib/components/FormComponents/GroupItem/GroupItem.js +2 -2
  88. package/lib/components/FormComponents/GroupItem/GroupItem.js.map +1 -1
  89. package/lib/components/FormComponents/GroupItem/GroupItem.styles.d.ts +1 -1
  90. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.d.ts +2 -2
  91. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js +5 -6
  92. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js.map +1 -1
  93. package/lib/components/FormComponents/IntegerItem/IntegerItem.d.ts +2 -2
  94. package/lib/components/FormComponents/IntegerItem/IntegerItem.js +2 -3
  95. package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
  96. package/lib/components/FormComponents/IntegerItem/SliderItem.d.ts +9 -0
  97. package/lib/components/FormComponents/IntegerItem/SliderItem.js +75 -0
  98. package/lib/components/FormComponents/IntegerItem/SliderItem.js.map +1 -0
  99. package/lib/components/FormComponents/ItemParts/FadingCheckIcon.js +2 -2
  100. package/lib/components/FormComponents/ItemParts/FadingCheckIcon.js.map +1 -1
  101. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.d.ts +2 -2
  102. package/lib/components/FormComponents/Lists.styles.d.ts +1 -1
  103. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.d.ts +2 -2
  104. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.d.ts +3 -3
  105. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +12 -12
  106. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
  107. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.d.ts +3 -3
  108. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js +2 -2
  109. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js.map +1 -1
  110. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.d.ts +2 -2
  111. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.d.ts +2 -2
  112. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.d.ts +2 -2
  113. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.d.ts +2 -2
  114. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +15 -4
  115. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
  116. package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.d.ts +2 -2
  117. package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.js +2 -2
  118. package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.js.map +1 -1
  119. package/lib/components/FormComponents/RepeatItem/RepeatField.d.ts +3 -3
  120. package/lib/components/FormComponents/RepeatItem/RepeatField.js +3 -3
  121. package/lib/components/FormComponents/RepeatItem/RepeatField.js.map +1 -1
  122. package/lib/components/FormComponents/RepeatItem/RepeatItem.d.ts +3 -2
  123. package/lib/components/FormComponents/RepeatItem/RepeatItem.js +11 -2
  124. package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
  125. package/lib/components/FormComponents/RepeatItem/index.d.ts +1 -0
  126. package/lib/components/FormComponents/RepeatItem/index.js +18 -0
  127. package/lib/components/FormComponents/RepeatItem/index.js.map +1 -0
  128. package/lib/components/FormComponents/SingleItem/SingleItem.d.ts +3 -3
  129. package/lib/components/FormComponents/SingleItem/SingleItem.js +2 -2
  130. package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
  131. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.d.ts +3 -3
  132. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js +12 -7
  133. package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js.map +1 -1
  134. package/lib/components/FormComponents/SliderItem/DisplayBox.styles.d.ts +4 -0
  135. package/lib/components/FormComponents/SliderItem/DisplayBox.styles.js +35 -0
  136. package/lib/components/FormComponents/SliderItem/DisplayBox.styles.js.map +1 -0
  137. package/lib/components/FormComponents/SliderItem/Slider.styles.d.ts +6 -0
  138. package/lib/components/FormComponents/SliderItem/Slider.styles.js +33 -0
  139. package/lib/components/FormComponents/SliderItem/Slider.styles.js.map +1 -0
  140. package/lib/components/FormComponents/SliderItem/SliderDisplayValue.d.ts +8 -0
  141. package/lib/components/FormComponents/SliderItem/SliderDisplayValue.js +28 -0
  142. package/lib/components/FormComponents/SliderItem/SliderDisplayValue.js.map +1 -0
  143. package/lib/components/FormComponents/SliderItem/SliderField.d.ts +16 -0
  144. package/lib/components/FormComponents/SliderItem/SliderField.js +41 -0
  145. package/lib/components/FormComponents/SliderItem/SliderField.js.map +1 -0
  146. package/lib/components/FormComponents/SliderItem/SliderItem.d.ts +9 -0
  147. package/lib/components/FormComponents/SliderItem/SliderItem.js +56 -0
  148. package/lib/components/FormComponents/SliderItem/SliderItem.js.map +1 -0
  149. package/lib/components/FormComponents/SliderItem/SliderLabels.d.ts +7 -0
  150. package/lib/components/FormComponents/SliderItem/SliderLabels.js +32 -0
  151. package/lib/components/FormComponents/SliderItem/SliderLabels.js.map +1 -0
  152. package/lib/components/FormComponents/StringItem/StringItem.d.ts +2 -2
  153. package/lib/components/FormComponents/Tables/GroupTable.d.ts +3 -2
  154. package/lib/components/FormComponents/Tables/GroupTable.js +18 -1
  155. package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
  156. package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +3 -4
  157. package/lib/components/FormComponents/Tables/GroupTableRow.js +3 -3
  158. package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -1
  159. package/lib/components/FormComponents/TextItem/TextItem.d.ts +2 -2
  160. package/lib/components/FormComponents/TimeItem/TimeItem.d.ts +2 -2
  161. package/lib/components/FormComponents/UrlItem/UrlItem.d.ts +2 -2
  162. package/lib/components/FormComponents/index.d.ts +3 -0
  163. package/lib/components/FormComponents/index.js +3 -0
  164. package/lib/components/FormComponents/index.js.map +1 -1
  165. package/lib/components/Lists.styles.d.ts +1 -1
  166. package/lib/components/Renderer/BaseRenderer.js +3 -5
  167. package/lib/components/Renderer/BaseRenderer.js.map +1 -1
  168. package/lib/components/Renderer/FormBodyCollapsible.d.ts +2 -2
  169. package/lib/components/Renderer/FormBodyCollapsible.js +6 -5
  170. package/lib/components/Renderer/FormBodyCollapsible.js.map +1 -1
  171. package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.d.ts +2 -2
  172. package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.js.map +1 -1
  173. package/lib/components/Renderer/FormBodyTabbed.d.ts +2 -2
  174. package/lib/components/Renderer/FormBodyTabbed.js +6 -5
  175. package/lib/components/Renderer/FormBodyTabbed.js.map +1 -1
  176. package/lib/components/Renderer/FormTopLevelItem.d.ts +2 -2
  177. package/lib/components/Renderer/FormTopLevelItem.js +3 -1
  178. package/lib/components/Renderer/FormTopLevelItem.js.map +1 -1
  179. package/lib/components/Renderer/SmartFormsRenderer.js +1 -1
  180. package/lib/components/Renderer/SmartFormsRenderer.js.map +1 -1
  181. package/lib/hooks/useDateSeparatorValidation.d.ts +2 -0
  182. package/lib/hooks/useDateSeparatorValidation.js +25 -0
  183. package/lib/hooks/useDateSeparatorValidation.js.map +1 -0
  184. package/lib/hooks/useDateValidation.d.ts +2 -0
  185. package/lib/hooks/useDateValidation.js +61 -0
  186. package/lib/hooks/useDateValidation.js.map +1 -0
  187. package/lib/hooks/useDecimalCalculatedExpression.d.ts +0 -1
  188. package/lib/hooks/useDecimalCalculatedExpression.js +3 -3
  189. package/lib/hooks/useDecimalCalculatedExpression.js.map +1 -1
  190. package/lib/hooks/useInitialiseRepeatAnswers.d.ts +1 -1
  191. package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -1
  192. package/lib/hooks/useIntegerCalculatedExpression.d.ts +0 -1
  193. package/lib/hooks/useIntegerCalculatedExpression.js +3 -3
  194. package/lib/hooks/useIntegerCalculatedExpression.js.map +1 -1
  195. package/lib/hooks/useSliderExtensions.d.ts +10 -0
  196. package/lib/hooks/useSliderExtensions.js +37 -0
  197. package/lib/hooks/useSliderExtensions.js.map +1 -0
  198. package/lib/hooks/useTerminologyServerQuery.js +0 -1
  199. package/lib/hooks/useTerminologyServerQuery.js.map +1 -1
  200. package/lib/index.d.ts +3 -3
  201. package/lib/index.js +15 -6
  202. package/lib/index.js.map +1 -1
  203. package/lib/interfaces/index.d.ts +2 -0
  204. package/lib/interfaces/index.js +18 -0
  205. package/lib/interfaces/index.js.map +1 -0
  206. package/lib/interfaces/questionnaireStore.interface.d.ts +1 -0
  207. package/lib/interfaces/renderProps.interface.d.ts +4 -3
  208. package/lib/stores/useQuestionnaireStore.d.ts +1 -0
  209. package/lib/stores/useQuestionnaireStore.js +28 -12
  210. package/lib/stores/useQuestionnaireStore.js.map +1 -1
  211. package/lib/test.d.ts +4 -0
  212. package/lib/test.js +18 -0
  213. package/lib/test.js.map +1 -0
  214. package/lib/theme/customGlobalStyles.js +2 -5
  215. package/lib/theme/customGlobalStyles.js.map +1 -1
  216. package/lib/theme/typography.js +9 -9
  217. package/lib/theme/typography.js.map +1 -1
  218. package/lib/utils/calculatedExpression.d.ts +5 -1
  219. package/lib/utils/calculatedExpression.js +21 -16
  220. package/lib/utils/calculatedExpression.js.map +1 -1
  221. package/lib/utils/dayjsExtend.d.ts +1 -0
  222. package/lib/utils/dayjsExtend.js +22 -0
  223. package/lib/utils/dayjsExtend.js.map +1 -0
  224. package/lib/utils/enableWhenExpression.d.ts +5 -1
  225. package/lib/utils/enableWhenExpression.js +26 -21
  226. package/lib/utils/enableWhenExpression.js.map +1 -1
  227. package/lib/utils/fhirpath.d.ts +3 -1
  228. package/lib/utils/fhirpath.js +25 -15
  229. package/lib/utils/fhirpath.js.map +1 -1
  230. package/lib/utils/index.d.ts +1 -0
  231. package/lib/utils/index.js +1 -0
  232. package/lib/utils/index.js.map +1 -1
  233. package/lib/utils/initialiseForm.d.ts +2 -0
  234. package/lib/utils/initialiseForm.js +13 -5
  235. package/lib/utils/initialiseForm.js.map +1 -1
  236. package/lib/utils/itemControl.d.ts +12 -0
  237. package/lib/utils/itemControl.js +30 -0
  238. package/lib/utils/itemControl.js.map +1 -1
  239. package/lib/utils/launchContext.d.ts +0 -0
  240. package/lib/utils/launchContext.js +2 -0
  241. package/lib/utils/launchContext.js.map +1 -0
  242. package/lib/utils/mapItem.d.ts +1 -1
  243. package/lib/utils/populateContexts.d.ts +2 -12
  244. package/lib/utils/populateContexts.js +0 -36
  245. package/lib/utils/populateContexts.js.map +1 -1
  246. package/lib/utils/qrItem.d.ts +1 -7
  247. package/lib/utils/qrItem.js +1 -12
  248. package/lib/utils/qrItem.js.map +1 -1
  249. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js +4 -2
  250. package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js.map +1 -1
  251. package/lib/utils/removeHidden.js +2 -1
  252. package/lib/utils/removeHidden.js.map +1 -1
  253. package/lib/utils/repopulateIntoResponse.js +90 -29
  254. package/lib/utils/repopulateIntoResponse.js.map +1 -1
  255. package/lib/utils/repopulateItems.d.ts +14 -1
  256. package/lib/utils/repopulateItems.js +251 -70
  257. package/lib/utils/repopulateItems.js.map +1 -1
  258. package/lib/utils/repopulateRepeatGroup.js +9 -1
  259. package/lib/utils/repopulateRepeatGroup.js.map +1 -1
  260. package/lib/utils/slider.d.ts +28 -0
  261. package/lib/utils/slider.js +89 -0
  262. package/lib/utils/slider.js.map +1 -0
  263. package/package.json +18 -15
  264. package/src/components/FormComponents/BooleanItem/BooleanItem.tsx +2 -2
  265. package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +2 -2
  266. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +33 -33
  267. package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +35 -35
  268. package/src/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.tsx +8 -8
  269. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +2 -2
  270. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +2 -2
  271. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +2 -2
  272. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +2 -2
  273. package/src/components/FormComponents/CustomDateItem/CustomDateItem.tsx +140 -0
  274. package/src/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.tsx +96 -0
  275. package/src/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.tsx +81 -0
  276. package/src/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.tsx +33 -0
  277. package/src/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.ts +22 -0
  278. package/src/components/FormComponents/CustomDateItem/customDateTimePicker/index.ts +18 -0
  279. package/src/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.ts +18 -0
  280. package/src/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.ts +154 -0
  281. package/src/components/FormComponents/CustomDateItem/index.ts +18 -0
  282. package/src/components/FormComponents/DateItem/DateItem.tsx +3 -3
  283. package/src/components/FormComponents/DateTimeItem/DateTimeItem.tsx +2 -2
  284. package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +4 -5
  285. package/src/components/FormComponents/DisplayItem/DisplayInstructions.styles.ts +0 -1
  286. package/src/components/FormComponents/DisplayItem/DisplayInstructions.tsx +2 -1
  287. package/src/components/FormComponents/GridGroup/GridGroup.tsx +41 -15
  288. package/src/components/FormComponents/GridGroup/GridRow.tsx +10 -9
  289. package/src/components/FormComponents/GridGroup/GridTable.tsx +29 -9
  290. package/src/components/FormComponents/GridGroup/index.ts +18 -0
  291. package/src/components/FormComponents/GroupItem/GroupItem.tsx +5 -6
  292. package/src/components/FormComponents/GroupItem/GroupItemSwitcher.tsx +7 -8
  293. package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +4 -5
  294. package/src/components/FormComponents/ItemParts/FadingCheckIcon.tsx +2 -2
  295. package/src/components/FormComponents/ItemParts/ItemFieldGrid.tsx +2 -2
  296. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +2 -2
  297. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +43 -43
  298. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.tsx +6 -6
  299. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +2 -2
  300. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx +2 -2
  301. package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +2 -2
  302. package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +49 -6
  303. package/src/components/FormComponents/RepeatGroup/RepeatGroupItem.tsx +13 -8
  304. package/src/components/FormComponents/RepeatItem/RepeatField.tsx +15 -9
  305. package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +33 -3
  306. package/src/components/FormComponents/RepeatItem/index.ts +18 -0
  307. package/src/components/FormComponents/SingleItem/SingleItem.tsx +6 -6
  308. package/src/components/FormComponents/SingleItem/SingleItemSwitcher.tsx +27 -11
  309. package/src/components/FormComponents/SliderItem/Slider.styles.ts +34 -0
  310. package/src/components/FormComponents/SliderItem/SliderDisplayValue.tsx +43 -0
  311. package/src/components/FormComponents/SliderItem/SliderField.tsx +88 -0
  312. package/src/components/FormComponents/SliderItem/SliderItem.tsx +115 -0
  313. package/src/components/FormComponents/SliderItem/SliderLabels.tsx +53 -0
  314. package/src/components/FormComponents/StringItem/StringItem.tsx +2 -2
  315. package/src/components/FormComponents/Tables/GroupTable.tsx +55 -3
  316. package/src/components/FormComponents/Tables/GroupTableRow.tsx +10 -9
  317. package/src/components/FormComponents/TextItem/TextItem.tsx +2 -2
  318. package/src/components/FormComponents/TimeItem/TimeItem.tsx +2 -2
  319. package/src/components/FormComponents/UrlItem/UrlItem.tsx +2 -2
  320. package/src/components/FormComponents/index.ts +3 -0
  321. package/src/components/Renderer/BaseRenderer.tsx +5 -12
  322. package/src/components/Renderer/FormBodyCollapsible.tsx +9 -7
  323. package/src/components/Renderer/FormBodySingleCollapsibleWrapper.tsx +2 -3
  324. package/src/components/Renderer/FormBodyTabbed.tsx +9 -7
  325. package/src/components/Renderer/FormTopLevelItem.tsx +14 -11
  326. package/src/components/Renderer/SmartFormsRenderer.tsx +2 -1
  327. package/src/hooks/useDateValidation.tsx +79 -0
  328. package/src/hooks/useDecimalCalculatedExpression.ts +3 -4
  329. package/src/hooks/useInitialiseRepeatAnswers.ts +1 -1
  330. package/src/hooks/useIntegerCalculatedExpression.ts +3 -4
  331. package/src/hooks/useSliderExtensions.ts +50 -0
  332. package/src/hooks/useTerminologyServerQuery.ts +0 -2
  333. package/src/index.ts +12 -9
  334. package/src/interfaces/questionnaireStore.interface.ts +1 -0
  335. package/src/interfaces/renderProps.interface.ts +4 -3
  336. package/src/stores/useQuestionnaireStore.ts +39 -16
  337. package/src/theme/customGlobalStyles.tsx +2 -5
  338. package/src/theme/typography.ts +9 -9
  339. package/src/utils/calculatedExpression.ts +41 -28
  340. package/src/utils/dayjsExtend.ts +23 -0
  341. package/src/utils/enableWhenExpression.ts +49 -34
  342. package/src/utils/fhirpath.ts +50 -31
  343. package/src/utils/index.ts +1 -0
  344. package/src/utils/initialiseForm.ts +15 -5
  345. package/src/utils/itemControl.ts +32 -0
  346. package/src/utils/mapItem.ts +1 -1
  347. package/src/utils/populateContexts.ts +2 -61
  348. package/src/utils/qrItem.ts +1 -16
  349. package/src/utils/questionnaireStoreUtils/createQuestionaireModel.ts +4 -2
  350. package/src/utils/removeHidden.ts +2 -1
  351. package/src/utils/repopulateIntoResponse.ts +134 -43
  352. package/src/utils/repopulateItems.ts +379 -101
  353. package/src/utils/slider.ts +112 -0
  354. package/src/utils/populateInputParams.ts +0 -242
  355. package/src/utils/repopulateRepeatGroup.ts +0 -68
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import React, { useState } from 'react';
18
+ import useReadOnly from '../../../hooks/useReadOnly';
19
+ import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
20
+ import { FullWidthFormComponentBox } from '../../Box.styles';
21
+ import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
22
+ import useParseDates from './customDateTimePicker/hooks/useParseDates';
23
+ import CustomDateField from './customDateTimePicker/CustomDateField';
24
+ import { parseDisplayDateToFhirDate, parseFhirDateToDisplayDate, replaceMonthNameWithNumber } from './customDateTimePicker/utils/parseDates';
25
+ import { createEmptyQrItem } from '../../../utils/qrItem';
26
+ function CustomDateTimePickerText(props) {
27
+ const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
28
+ const readOnly = useReadOnly(qItem, parentIsReadOnly);
29
+ const { displayPrompt, displayInstructions, entryFormat } = useRenderingExtensions(qItem);
30
+ const qrDate = qrItem !== null && qrItem !== void 0 ? qrItem : createEmptyQrItem(qItem);
31
+ // Init input value
32
+ let valueDate = '';
33
+ if (qrDate.answer) {
34
+ if (qrDate.answer[0].valueDate) {
35
+ valueDate = qrDate.answer[0].valueDate;
36
+ }
37
+ else if (qrDate.answer[0].valueDateTime) {
38
+ valueDate = qrDate.answer[0].valueDateTime;
39
+ }
40
+ }
41
+ valueDate = parseFhirDateToDisplayDate(valueDate);
42
+ const selectedDateToDisplay = valueDate.length === 0 ? 'N/A' : valueDate;
43
+ const [input, setInput] = useState(valueDate);
44
+ const [focused, setFocused] = useState(false);
45
+ let options = [];
46
+ const { dateOptions, seperator } = useParseDates(input);
47
+ if (dateOptions) {
48
+ options = dateOptions;
49
+ }
50
+ function handleValueChange(newDateString) {
51
+ onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseDisplayDateToFhirDate(newDateString, seperator) }] }));
52
+ }
53
+ function handleUnfocus() {
54
+ // set answer to current input when text field is unfocused
55
+ if (!valueDate && input !== '') {
56
+ const replacedInput = replaceMonthNameWithNumber(input);
57
+ const matchedOption = options.find((option) => replacedInput === option);
58
+ if (matchedOption) {
59
+ const newDateString = matchedOption.split(seperator).join('/');
60
+ onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseDisplayDateToFhirDate(newDateString, seperator) }] }));
61
+ }
62
+ }
63
+ setFocused(false);
64
+ }
65
+ if (isRepeated) {
66
+ return (React.createElement(CustomDateField, { valueDate: valueDate, input: input, isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: (newInput) => setInput(newInput), onValueChange: handleValueChange, onUnfocus: handleUnfocus }));
67
+ }
68
+ return (React.createElement(FullWidthFormComponentBox, { "data-test": "q-item-date-box" },
69
+ React.createElement(ItemFieldGrid, { qItem: qItem, displayInstructions: displayInstructions.length > 0 ? (displayInstructions) : (React.createElement(React.Fragment, null,
70
+ "Selected date: ",
71
+ React.createElement("b", null, selectedDateToDisplay))), readOnly: readOnly },
72
+ React.createElement(CustomDateField, { valueDate: valueDate, input: input, isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: (newInput) => setInput(newInput), onValueChange: handleValueChange, onUnfocus: handleUnfocus }))));
73
+ }
74
+ export default CustomDateTimePickerText;
75
+ //# sourceMappingURL=CustomDateTimePickerText2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomDateTimePickerText2.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ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C,CAAC;IACpB,CAAC;IAED,IAAI,UAAU,EAAE;QACd,OAAO,CACL,oBAAC,eAAe,IACd,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAC/C,aAAa,EAAE,iBAAiB,EAChC,SAAS,EAAE,aAAa,GACxB,CACH,CAAC;KACH;IAED,OAAO,CACL,oBAAC,yBAAyB,iBAAW,iBAAiB;QACpD,oBAAC,aAAa,IACZ,KAAK,EAAE,KAAK,EACZ,mBAAmB,EACjB,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B,mBAAmB,CACpB,CAAC,CAAC,CAAC,CACF;;gBACiB,+BAAI,qBAAqB,CAAK,CAC5C,CACJ,EAEH,QAAQ,EAAE,QAAQ;YAClB,oBAAC,eAAe,IACd,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAC/C,aAAa,EAAE,iBAAiB,EAChC,SAAS,EAAE,aAAa,GACxB,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Dispatch, SetStateAction } from 'react';
2
+ import React from 'react';
3
+ import type { PropsWithIsTabledAttribute } from '../../../../interfaces/renderProps.interface';
4
+ interface CustomDateFieldProps extends PropsWithIsTabledAttribute {
5
+ linkId: string;
6
+ valueDate: string;
7
+ input: string;
8
+ feedback: string;
9
+ isFocused: boolean;
10
+ displayPrompt: string;
11
+ entryFormat: string;
12
+ readOnly: boolean;
13
+ setFocused: Dispatch<SetStateAction<boolean>>;
14
+ onInputChange: (newInput: string) => void;
15
+ onSelectDate: (newDateValue: string) => void;
16
+ }
17
+ declare function CustomDateField(props: CustomDateFieldProps): React.JSX.Element;
18
+ export default CustomDateField;
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import React, { useRef } from 'react';
18
+ import { StandardTextField } from '../../Textfield.styles';
19
+ import DatePicker from './DatePicker';
20
+ import Tooltip from '@mui/material/Tooltip';
21
+ function CustomDateField(props) {
22
+ const { linkId, valueDate, input, feedback, isFocused, displayPrompt, entryFormat, readOnly, isTabled, setFocused, onInputChange, onSelectDate } = props;
23
+ const anchorRef = useRef(null);
24
+ return (React.createElement(Tooltip, { title: isTabled ? feedback : '' },
25
+ React.createElement(StandardTextField, { id: linkId, ref: anchorRef, fullWidth: true, isTabled: isTabled, value: input, error: !!feedback, onChange: (e) => onInputChange(e.target.value), label: displayPrompt, placeholder: entryFormat !== '' ? entryFormat : 'DD/MM/YYYY', disabled: readOnly, size: "small", focused: isFocused, onFocus: () => setFocused(true), onBlur: () => setFocused(false), InputProps: {
26
+ endAdornment: (React.createElement(React.Fragment, null,
27
+ React.createElement(DatePicker, { valueString: valueDate, readOnly: readOnly, anchorEl: anchorRef.current, onSelectDate: (valueDayjs) => {
28
+ onSelectDate(valueDayjs.format('DD/MM/YYYY'));
29
+ }, onFocus: (focus) => setFocused(focus) })))
30
+ }, helperText: isTabled ? '' : feedback })));
31
+ }
32
+ export default CustomDateField;
33
+ //# sourceMappingURL=CustomDateField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomDateField.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAgB5C,SAAS,eAAe,CAAC,KAA2B;IAClD,MAAM,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,YAAY,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,SAAS,GAA8B,MAAM,CAAC,IAAI,CAAC,CAAC;IAE1D,OAAO,CACL,oBAAC,OAAO,IAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;QACtC,oBAAC,iBAAiB,IAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,SAAS,EACd,SAAS,QACT,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,CAAC,CAAC,QAAQ,EACjB,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC7E,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAC5D,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAC/B,UAAU,EAAE;gBACV,YAAY,EAAE,CACZ;oBACE,oBAAC,UAAU,IACT,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,SAAS,CAAC,OAAO,EAC3B,YAAY,EAAE,CAAC,UAAiB,EAAE,EAAE;4BAClC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;wBAChD,CAAC,EACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GACrC,CACD,CACJ;aACF,EACD,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,GACpC,CACM,CACX,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { Dayjs } from 'dayjs';
3
+ interface DatePickerProps {
4
+ valueString: string;
5
+ readOnly: boolean;
6
+ anchorEl: HTMLElement | null;
7
+ onSelectDate: (newValueDayjs: Dayjs) => void;
8
+ onFocus: (focus: boolean) => void;
9
+ }
10
+ declare function DatePicker(props: DatePickerProps): React.JSX.Element;
11
+ export default DatePicker;
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import React, { useState } from 'react';
18
+ import dayjs from 'dayjs';
19
+ import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
20
+ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
21
+ import MuiDatePicker from './MuiDatePicker';
22
+ // import { DatePicker as MuiDatePicker, LocalizationProvider } from '@mui/x-date-pickers';
23
+ import DatePickerButton from './DatePickerButton';
24
+ function DatePicker(props) {
25
+ const { valueString, readOnly, anchorEl, onSelectDate, onFocus } = props;
26
+ const [open, setOpen] = useState(false);
27
+ const valueDayJs = valueString ? dayjs(valueString, 'DD/MM/YYYY') : null;
28
+ return (React.createElement(LocalizationProvider, { dateAdapter: AdapterDayjs },
29
+ React.createElement(MuiDatePicker, { value: valueDayJs !== null && valueDayJs !== void 0 ? valueDayJs : null, disabled: readOnly, slots: { field: DatePickerButton }, slotProps: {
30
+ field: {
31
+ onOpen: () => {
32
+ setOpen(!open);
33
+ onFocus(true);
34
+ },
35
+ readOnly: readOnly
36
+ },
37
+ textField: {
38
+ size: 'small'
39
+ },
40
+ popper: {
41
+ anchorEl: () => anchorEl
42
+ }
43
+ }, open: open, onClose: () => {
44
+ setOpen(false);
45
+ onFocus(false);
46
+ }, onChange: (newValue) => {
47
+ if (!newValue) {
48
+ return;
49
+ }
50
+ onSelectDate(newValue);
51
+ onFocus(false);
52
+ } })));
53
+ }
54
+ export default DatePicker;
55
+ //# sourceMappingURL=DatePicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.tsx"],"names":[],"mapp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EAAE;gBACZ,OAAO,CAAC,KAAK,CAAC,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,EACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACrB,IAAI,CAAC,QAAQ,EAAE;oBACb,OAAO;iBACR;gBAED,YAAY,CAAC,QAAQ,CAAC,CAAC;gBACvB,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,GACD,CACmB,CACxB,CAAC;AACJ,CAAC;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { BaseSingleInputFieldProps, DateValidationError, FieldSection } from '@mui/x-date-pickers/models';
3
+ import type { Dayjs } from 'dayjs';
4
+ interface DatePickerButtonProps extends BaseSingleInputFieldProps<Dayjs | null, Dayjs, FieldSection, DateValidationError> {
5
+ onOpen?: () => void;
6
+ readOnly?: boolean;
7
+ }
8
+ declare function DatePickerButton(props: DatePickerButtonProps): React.JSX.Element;
9
+ export default DatePickerButton;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import IconButton from '@mui/material/IconButton';
3
+ import EventIcon from '@mui/icons-material/Event';
4
+ function DatePickerButton(props) {
5
+ const { onOpen, readOnly } = props;
6
+ return (React.createElement(IconButton, { sx: { height: 24, width: 24 }, disabled: readOnly, onClick: (e) => {
7
+ e.stopPropagation();
8
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
9
+ } },
10
+ React.createElement(EventIcon, { fontSize: "small" })));
11
+ }
12
+ export default DatePickerButton;
13
+ //# sourceMappingURL=DatePickerButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatePickerButton.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAQlD,SAAS,gBAAgB,CAAC,KAA4B;IACpD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEnC,OAAO,CACL,oBAAC,UAAU,IACT,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAC7B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,CAAC,CAAC,eAAe,EAAE,CAAC;YACpB,MAAM,aAAN,MAAM,uBAAN,MAAM,EAAI,CAAC;QACb,CAAC;QACD,oBAAC,SAAS,IAAC,QAAQ,EAAC,OAAO,GAAG,CACnB,CACd,CAAC;AACJ,CAAC;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ declare const MuiDatePicker: (<TDate>(props: import("@mui/x-date-pickers/DatePicker").DatePickerProps<TDate> & import("react").RefAttributes<HTMLDivElement>) => import("react").JSX.Element) & {
3
+ propTypes?: any;
4
+ };
5
+ export default MuiDatePicker;
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
18
+ const MuiDatePicker = DatePicker;
19
+ export default MuiDatePicker;
20
+ //# sourceMappingURL=MuiDatePicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MuiDatePicker.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC,eAAe,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare function useParseDates(input: string): {
2
+ dateOptions: string[];
3
+ seperator: string;
4
+ };
5
+ export default useParseDates;
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { parseInputToDateOptions } from '../utils/parseDates';
18
+ function useParseDates(input) {
19
+ // No options displayed when input is empty or search term is less than 2 characters
20
+ if (input.length === 0 || (input.length < 2 && input.length > 0)) {
21
+ return { dateOptions: [], seperator: '' };
22
+ }
23
+ const { dateOptions, seperator } = parseInputToDateOptions(input);
24
+ return { dateOptions, seperator };
25
+ }
26
+ export default useParseDates;
27
+ //# sourceMappingURL=useParseDates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useParseDates.js","sourceRoot":"","sources":["../../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,SAAS,aAAa,CAAC,KAAa;IAIlC,oFAAoF;IACpF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;QAChE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;KAC3C;IAED,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAElE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACpC,CAAC;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './utils';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ export { parseFhirDateToDisplayDate } from './parseDates';
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export { parseFhirDateToDisplayDate } from './parseDates';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare function validateInput(input: string): boolean;
2
+ export declare function validateTwoMatches(monthInput: string, yearInput: string): boolean;
3
+ export declare function validateThreeMatches(dayInput: string, monthInput: string, yearInput: string): boolean;
4
+ export declare function getNumOfSeparators(valueDate: string, seperator: string): number;
5
+ export declare function parseFhirDateToDisplayDate(fhirDate: string): {
6
+ displayDate: string;
7
+ parseFail?: boolean;
8
+ };
9
+ export declare function parseInputDateToFhirDate(displayDate: string): string;
@@ -0,0 +1,121 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import dayjs from 'dayjs';
18
+ const inputMatchRegex = /(\d{4}|\d{3}|\d{2})/g;
19
+ export function validateInput(input) {
20
+ const matches = input.match(inputMatchRegex);
21
+ if (!matches) {
22
+ return false;
23
+ }
24
+ const seperator = input.includes('/') ? '/' : null;
25
+ if (matches.length === 1) {
26
+ // seperator not supposed to be present if only one match present
27
+ if (seperator) {
28
+ return false;
29
+ }
30
+ return matches[0].length === 4;
31
+ }
32
+ // Invalid if seperator is not present
33
+ if (!seperator) {
34
+ return false;
35
+ }
36
+ // Invalid if num of slots don't match the number of regex matches
37
+ const slotsMatched = input.split(seperator);
38
+ if (slotsMatched.length != matches.length) {
39
+ return false;
40
+ }
41
+ // Handle MM/YYYY format
42
+ if (matches.length === 2) {
43
+ return validateTwoMatches(matches[0], matches[1]);
44
+ }
45
+ // Handle DD/MM/YYYY format
46
+ if (matches.length === 3) {
47
+ return validateThreeMatches(matches[0], matches[1], matches[2]);
48
+ }
49
+ return false;
50
+ }
51
+ export function validateTwoMatches(monthInput, yearInput) {
52
+ const monthNum = parseInt(monthInput, 10);
53
+ if (monthNum < 1 || monthNum > 12) {
54
+ return false;
55
+ }
56
+ return (monthInput.length === 1 || monthInput.length === 2) && yearInput.length === 4;
57
+ }
58
+ export function validateThreeMatches(dayInput, monthInput, yearInput) {
59
+ const dayNum = parseInt(dayInput, 10);
60
+ if (dayNum < 1 || dayNum > 31) {
61
+ return false;
62
+ }
63
+ const monthNum = parseInt(monthInput, 10);
64
+ if (monthNum < 1 || monthNum > 12) {
65
+ return false;
66
+ }
67
+ return ((dayInput.length === 1 || dayInput.length === 2) &&
68
+ (monthInput.length === 1 || monthInput.length === 2) &&
69
+ yearInput.length === 4);
70
+ }
71
+ export function getNumOfSeparators(valueDate, seperator) {
72
+ const regex = new RegExp(seperator, 'g');
73
+ return [...valueDate.matchAll(regex)].length;
74
+ }
75
+ export function parseFhirDateToDisplayDate(fhirDate) {
76
+ if (fhirDate.length === 0) {
77
+ return { displayDate: '' };
78
+ }
79
+ const numOfSeparators = getNumOfSeparators(fhirDate, '-');
80
+ if (numOfSeparators === 2) {
81
+ const threeMatchesDate = dayjs(fhirDate, `YYYY-MM-DD`);
82
+ if (threeMatchesDate.isValid()) {
83
+ return { displayDate: threeMatchesDate.format('DD/MM/YYYY') };
84
+ }
85
+ }
86
+ if (numOfSeparators === 1) {
87
+ const twoMatchesDate = dayjs(fhirDate, `YYYY-MM`);
88
+ if (twoMatchesDate.isValid()) {
89
+ return { displayDate: twoMatchesDate.format('MM/YYYY') };
90
+ }
91
+ }
92
+ const oneMatchDate = dayjs(fhirDate, `YYYY`);
93
+ if (oneMatchDate.isValid()) {
94
+ return { displayDate: oneMatchDate.format('YYYY') };
95
+ }
96
+ return { displayDate: fhirDate, parseFail: true };
97
+ }
98
+ export function parseInputDateToFhirDate(displayDate) {
99
+ const numOfSeparators = getNumOfSeparators(displayDate, '/');
100
+ if (numOfSeparators === 2) {
101
+ const threeMatchesDate = dayjs(displayDate, `DD/MM/YYYY`);
102
+ if (threeMatchesDate.isValid()) {
103
+ return threeMatchesDate.format('YYYY-MM-DD');
104
+ }
105
+ }
106
+ if (numOfSeparators === 1) {
107
+ const twoMatchesDate = dayjs(displayDate, `MM/YYYY`);
108
+ if (twoMatchesDate.isValid()) {
109
+ return twoMatchesDate.format('YYYY-MM');
110
+ }
111
+ }
112
+ if (displayDate.length === 4) {
113
+ const oneMatchDate = dayjs(displayDate, 'YYYY');
114
+ if (oneMatchDate.isValid()) {
115
+ return displayDate;
116
+ }
117
+ }
118
+ // Default to YYYY-MM-DD format if all else fails
119
+ return dayjs(displayDate).format('YYYY-MM-DD');
120
+ }
121
+ //# sourceMappingURL=parseDates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseDates.js","sourceRoot":"","sources":["../../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAE/C,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,IAAI,cAAc,CAAC,OAAO,EAAE,EAAE;YAC5B,OAAO,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SACzC;KACF;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAChD,IAAI,YAAY,CAAC,OAAO,EAAE,EAAE;YAC1B,OAAO,WAAW,CAAC;SACpB;KACF;IAED,iDAAiD;IACjD,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { PropsWithIsRepeatedAttribute, PropsWithIsTabledAttribute, PropsWithParentIsReadOnlyAttribute, PropsWithQrItemChangeHandler } from '../../../interfaces/renderProps.interface';
3
+ import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
4
+ interface CustomDateTimePickerTextProps extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>, PropsWithIsRepeatedAttribute, PropsWithIsTabledAttribute, PropsWithParentIsReadOnlyAttribute {
5
+ qItem: QuestionnaireItem;
6
+ qrItem: QuestionnaireResponseItem;
7
+ }
8
+ declare function CustomDateTimePickerText(props: CustomDateTimePickerTextProps): React.JSX.Element;
9
+ export default CustomDateTimePickerText;
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import React, { useState } from 'react';
18
+ import useReadOnly from '../../../hooks/useReadOnly';
19
+ import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
20
+ import { FullWidthFormComponentBox } from '../../Box.styles';
21
+ import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
22
+ import { parseFhirDateToDisplayDate, parseInputDateToFhirDate, validateInput } from './customDateTimePicker/utils/parseDates';
23
+ import { createEmptyQrItem } from '../../../utils/qrItem';
24
+ import useDateValidation from '../../../hooks/useDateValidation';
25
+ import CustomDateField2 from './CustomDateField2';
26
+ function CustomDateTimePickerText(props) {
27
+ const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
28
+ const readOnly = useReadOnly(qItem, parentIsReadOnly);
29
+ const { displayPrompt, displayInstructions, entryFormat } = useRenderingExtensions(qItem);
30
+ const qrDate = qrItem !== null && qrItem !== void 0 ? qrItem : createEmptyQrItem(qItem);
31
+ // Init input value
32
+ let valueDate = '';
33
+ if (qrDate.answer) {
34
+ if (qrDate.answer[0].valueDate) {
35
+ valueDate = qrDate.answer[0].valueDate;
36
+ }
37
+ else if (qrDate.answer[0].valueDateTime) {
38
+ valueDate = qrDate.answer[0].valueDateTime;
39
+ }
40
+ }
41
+ const { displayDate, parseFail } = parseFhirDateToDisplayDate(valueDate);
42
+ const [input, setInput] = useState(displayDate);
43
+ const [focused, setFocused] = useState(false);
44
+ // Perform validation checks
45
+ const errorFeedback = useDateValidation(input, parseFail);
46
+ function handleSelectDate(selectedDate) {
47
+ setInput(selectedDate);
48
+ onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseInputDateToFhirDate(selectedDate) }] }));
49
+ }
50
+ function handleInputChange(newInput) {
51
+ setInput(newInput);
52
+ if (newInput === '') {
53
+ onQrItemChange(createEmptyQrItem(qItem));
54
+ }
55
+ if (!validateInput(newInput)) {
56
+ return;
57
+ }
58
+ onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseInputDateToFhirDate(newInput) }] }));
59
+ }
60
+ if (isRepeated) {
61
+ return (React.createElement(CustomDateField2, { linkId: qItem.linkId, valueDate: displayDate, input: input, feedback: errorFeedback !== null && errorFeedback !== void 0 ? errorFeedback : '', isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: handleInputChange, onSelectDate: handleSelectDate }));
62
+ }
63
+ return (React.createElement(FullWidthFormComponentBox, { "data-test": "q-item-date-box" },
64
+ React.createElement(ItemFieldGrid, { qItem: qItem, displayInstructions: displayInstructions, readOnly: readOnly },
65
+ React.createElement(CustomDateField2, { linkId: qItem.linkId, valueDate: displayDate, input: input, feedback: errorFeedback !== null && errorFeedback !== void 0 ? errorFeedback : '', isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: handleInputChange, onSelectDate: handleSelectDate }),
66
+ React.createElement(React.Fragment, null,
67
+ "Verify date: ",
68
+ displayDate))));
69
+ }
70
+ export default CustomDateTimePickerText;
71
+ //# sourceMappingURL=CustomDateTimePickerText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomDateTimePickerText.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/CustomDateItem/CustomDateTimePickerText.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,sBAAsB,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,aAAa,EACd,MAAM,yCAAyC,CAAC;AACj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,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,EAC7B,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,iBAAiB,EAChC,YAAY,EAAE,gBAAgB,GAC9B;YACF;;gBAAgB,WAAW,CAAI,CACjB,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './customDateTimePicker';
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2023 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './customDateTimePicker';
18
+ //# sourceMappingURL=index.js.map