@icure/form 1.1.0 → 1.1.14

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 (339) hide show
  1. package/components/common/field-with-options.d.ts +9 -0
  2. package/components/common/field-with-options.js +50 -0
  3. package/components/common/field-with-options.js.map +1 -0
  4. package/components/common/field.d.ts +46 -0
  5. package/components/common/field.js +107 -0
  6. package/components/common/field.js.map +1 -0
  7. package/components/common/index.d.ts +1 -0
  8. package/components/{iqr-form-loader → common}/index.js +1 -3
  9. package/components/common/index.js.map +1 -0
  10. package/components/{iqr-text-field → common}/styles/paths.d.ts +3 -0
  11. package/components/{iqr-text-field → common}/styles/paths.js +28 -5
  12. package/components/common/styles/paths.js.map +1 -0
  13. package/components/common/utils.d.ts +8 -0
  14. package/components/common/utils.js +42 -0
  15. package/components/common/utils.js.map +1 -0
  16. package/components/icure-button-group/index.d.ts +12 -0
  17. package/components/icure-button-group/index.js +1140 -0
  18. package/components/icure-button-group/index.js.map +1 -0
  19. package/components/icure-date-picker/index.d.ts +16 -0
  20. package/components/icure-date-picker/index.js +1140 -0
  21. package/components/icure-date-picker/index.js.map +1 -0
  22. package/components/icure-dropdown-field/index.d.ts +16 -0
  23. package/components/icure-dropdown-field/index.js +1153 -0
  24. package/components/icure-dropdown-field/index.js.map +1 -0
  25. package/components/icure-form/fields/button-group/checkbox.d.ts +6 -0
  26. package/components/icure-form/fields/button-group/checkbox.js +61 -0
  27. package/components/icure-form/fields/button-group/checkbox.js.map +1 -0
  28. package/components/icure-form/fields/button-group/index.d.ts +2 -0
  29. package/components/icure-form/fields/button-group/index.js +19 -0
  30. package/components/icure-form/fields/button-group/index.js.map +1 -0
  31. package/components/icure-form/fields/button-group/radio-button.d.ts +6 -0
  32. package/components/icure-form/fields/button-group/radio-button.js +61 -0
  33. package/components/icure-form/fields/button-group/radio-button.js.map +1 -0
  34. package/components/icure-form/fields/date-picker/date-picker.d.ts +4 -0
  35. package/components/icure-form/fields/date-picker/date-picker.js +29 -0
  36. package/components/icure-form/fields/date-picker/date-picker.js.map +1 -0
  37. package/components/icure-form/fields/date-picker/date-time-picker.d.ts +4 -0
  38. package/components/icure-form/fields/date-picker/date-time-picker.js +29 -0
  39. package/components/icure-form/fields/date-picker/date-time-picker.js.map +1 -0
  40. package/components/icure-form/fields/date-picker/index.d.ts +3 -0
  41. package/components/icure-form/fields/date-picker/index.js +20 -0
  42. package/components/icure-form/fields/date-picker/index.js.map +1 -0
  43. package/components/icure-form/fields/date-picker/time-picker.d.ts +4 -0
  44. package/components/icure-form/fields/date-picker/time-picker.js +29 -0
  45. package/components/icure-form/fields/date-picker/time-picker.js.map +1 -0
  46. package/components/icure-form/fields/dropdown/dropdown-field.d.ts +11 -0
  47. package/components/icure-form/fields/dropdown/dropdown-field.js +65 -0
  48. package/components/icure-form/fields/dropdown/dropdown-field.js.map +1 -0
  49. package/components/icure-form/fields/dropdown/index.d.ts +1 -0
  50. package/components/icure-form/fields/dropdown/index.js +18 -0
  51. package/components/icure-form/fields/dropdown/index.js.map +1 -0
  52. package/components/icure-form/fields/index.d.ts +9 -0
  53. package/components/icure-form/fields/index.js +26 -0
  54. package/components/icure-form/fields/index.js.map +1 -0
  55. package/components/icure-form/fields/items-list-field/index.d.ts +1 -0
  56. package/components/icure-form/fields/items-list-field/index.js +18 -0
  57. package/components/icure-form/fields/items-list-field/index.js.map +1 -0
  58. package/components/icure-form/fields/items-list-field/items-list-field.d.ts +6 -0
  59. package/components/icure-form/fields/items-list-field/items-list-field.js +49 -0
  60. package/components/icure-form/fields/items-list-field/items-list-field.js.map +1 -0
  61. package/components/icure-form/fields/label/index.d.ts +1 -0
  62. package/components/icure-form/fields/label/index.js +18 -0
  63. package/components/icure-form/fields/label/index.js.map +1 -0
  64. package/components/{iqr-form/fields/multipleChoice.d.ts → icure-form/fields/label/label.d.ts} +5 -4
  65. package/components/{iqr-form/fields/multipleChoice.js → icure-form/fields/label/label.js} +18 -15
  66. package/components/icure-form/fields/label/label.js.map +1 -0
  67. package/components/icure-form/fields/measure-field/index.d.ts +1 -0
  68. package/components/icure-form/fields/measure-field/index.js +18 -0
  69. package/components/icure-form/fields/measure-field/index.js.map +1 -0
  70. package/components/icure-form/fields/measure-field/measure-field.d.ts +4 -0
  71. package/components/icure-form/fields/measure-field/measure-field.js +31 -0
  72. package/components/icure-form/fields/measure-field/measure-field.js.map +1 -0
  73. package/components/icure-form/fields/number-field/index.d.ts +1 -0
  74. package/components/icure-form/fields/number-field/index.js +18 -0
  75. package/components/icure-form/fields/number-field/index.js.map +1 -0
  76. package/components/icure-form/fields/number-field/number-field.d.ts +4 -0
  77. package/components/icure-form/fields/number-field/number-field.js +29 -0
  78. package/components/icure-form/fields/number-field/number-field.js.map +1 -0
  79. package/components/icure-form/fields/text-field/index.d.ts +1 -0
  80. package/components/icure-form/fields/text-field/index.js +18 -0
  81. package/components/icure-form/fields/text-field/index.js.map +1 -0
  82. package/components/icure-form/fields/text-field/text-field.d.ts +28 -0
  83. package/components/icure-form/fields/text-field/text-field.js +123 -0
  84. package/components/icure-form/fields/text-field/text-field.js.map +1 -0
  85. package/components/icure-form/fields/token-field/index.d.ts +1 -0
  86. package/components/icure-form/fields/token-field/index.js +18 -0
  87. package/components/icure-form/fields/token-field/index.js.map +1 -0
  88. package/components/icure-form/fields/token-field/token-field.d.ts +6 -0
  89. package/components/{iqr-form/fields/datePicker.js → icure-form/fields/token-field/token-field.js} +26 -34
  90. package/components/icure-form/fields/token-field/token-field.js.map +1 -0
  91. package/components/icure-form/fields/utils/index.d.ts +11 -0
  92. package/components/icure-form/fields/utils/index.js +48 -0
  93. package/components/icure-form/fields/utils/index.js.map +1 -0
  94. package/components/icure-form/index.d.ts +23 -0
  95. package/components/icure-form/index.js +1127 -0
  96. package/components/icure-form/index.js.map +1 -0
  97. package/components/icure-form/renderer/form/form-selection-button.d.ts +9 -0
  98. package/components/icure-form/renderer/form/form-selection-button.js +108 -0
  99. package/components/icure-form/renderer/form/form-selection-button.js.map +1 -0
  100. package/components/icure-form/renderer/form/form.d.ts +3 -0
  101. package/components/icure-form/renderer/form/form.js +399 -0
  102. package/components/icure-form/renderer/form/form.js.map +1 -0
  103. package/components/icure-form/renderer/index.d.ts +11 -0
  104. package/components/icure-form/renderer/index.js.map +1 -0
  105. package/components/icure-label/index.d.ts +8 -0
  106. package/components/icure-label/index.js +1072 -0
  107. package/components/icure-label/index.js.map +1 -0
  108. package/components/icure-text-field/index.d.ts +69 -0
  109. package/components/icure-text-field/index.js +1739 -0
  110. package/components/icure-text-field/index.js.map +1 -0
  111. package/components/icure-text-field/plugin/caret-fix-plugin.js.map +1 -0
  112. package/components/{iqr-text-field → icure-text-field}/plugin/has-content-class-plugin.d.ts +1 -1
  113. package/components/icure-text-field/plugin/has-content-class-plugin.js.map +1 -0
  114. package/components/icure-text-field/plugin/mask-plugin.js.map +1 -0
  115. package/components/icure-text-field/plugin/regexp-plugin.js.map +1 -0
  116. package/components/icure-text-field/prosemirror-commands.js.map +1 -0
  117. package/components/{iqr-text-field → icure-text-field}/prosemirror-utils.d.ts +1 -1
  118. package/components/icure-text-field/prosemirror-utils.js.map +1 -0
  119. package/components/icure-text-field/schema/common-marks.js.map +1 -0
  120. package/components/{iqr-text-field → icure-text-field}/schema/date-time-schema.d.ts +3 -3
  121. package/components/icure-text-field/schema/date-time-schema.js.map +1 -0
  122. package/components/{iqr-text-field → icure-text-field}/schema/decimal-schema.d.ts +1 -1
  123. package/components/icure-text-field/schema/decimal-schema.js.map +1 -0
  124. package/components/icure-text-field/schema/index.d.ts +6 -0
  125. package/components/{iqr-text-field → icure-text-field}/schema/index.js +6 -3
  126. package/components/icure-text-field/schema/index.js.map +1 -0
  127. package/components/icure-text-field/schema/items-list-schema.d.ts +3 -0
  128. package/components/icure-text-field/schema/items-list-schema.js +28 -0
  129. package/components/icure-text-field/schema/items-list-schema.js.map +1 -0
  130. package/components/icure-text-field/schema/items-list.d.ts +3 -0
  131. package/components/icure-text-field/schema/items-list.js +31 -0
  132. package/components/icure-text-field/schema/items-list.js.map +1 -0
  133. package/components/{iqr-text-field → icure-text-field}/schema/markdown-schema.d.ts +3 -3
  134. package/components/icure-text-field/schema/markdown-schema.js.map +1 -0
  135. package/components/icure-text-field/schema/measure-schema.d.ts +7 -0
  136. package/components/icure-text-field/schema/measure-schema.js +81 -0
  137. package/components/icure-text-field/schema/measure-schema.js.map +1 -0
  138. package/components/{iqr-text-field → icure-text-field}/schema/token-schema.d.ts +1 -1
  139. package/components/{iqr-text-field → icure-text-field}/schema/token-schema.js +3 -6
  140. package/components/icure-text-field/schema/token-schema.js.map +1 -0
  141. package/components/icure-text-field/schema/utils.js.map +1 -0
  142. package/components/icure-text-field/selection-companion.js.map +1 -0
  143. package/components/{iqr-text-field → icure-text-field}/suggestion-palette.d.ts +1 -6
  144. package/components/icure-text-field/suggestion-palette.js.map +1 -0
  145. package/components/index.d.ts +5 -2
  146. package/components/index.js +5 -2
  147. package/components/index.js.map +1 -1
  148. package/components/model/index.d.ts +782 -0
  149. package/components/model/index.js +632 -0
  150. package/components/model/index.js.map +1 -0
  151. package/components/themes/default/index.d.ts +1 -0
  152. package/components/themes/default/index.js +28 -0
  153. package/components/themes/default/index.js.map +1 -0
  154. package/components/themes/ehr-lite/index.d.ts +1 -0
  155. package/components/themes/ehr-lite/index.js +321 -0
  156. package/components/themes/ehr-lite/index.js.map +1 -0
  157. package/components/themes/kendo/index.d.ts +1 -0
  158. package/components/themes/kendo/index.js +285 -0
  159. package/components/themes/kendo/index.js.map +1 -0
  160. package/conversion/ckmeans-grouping.d.ts +4 -0
  161. package/conversion/ckmeans-grouping.js +53 -0
  162. package/conversion/ckmeans-grouping.js.map +1 -0
  163. package/conversion/ckmeans.d.ts +44 -0
  164. package/conversion/ckmeans.js +287 -0
  165. package/conversion/ckmeans.js.map +1 -0
  166. package/conversion/icure-convert.d.ts +3 -0
  167. package/conversion/icure-convert.js +165 -0
  168. package/conversion/icure-convert.js.map +1 -0
  169. package/generic/index.d.ts +1 -0
  170. package/generic/index.js +18 -0
  171. package/generic/index.js.map +1 -0
  172. package/generic/model.d.ts +39 -0
  173. package/{components/iqr-form-loader/models.js → generic/model.js} +1 -1
  174. package/generic/model.js.map +1 -0
  175. package/icure/form-values-container.d.ts +83 -0
  176. package/icure/form-values-container.js +445 -0
  177. package/icure/form-values-container.js.map +1 -0
  178. package/icure/index.d.ts +2 -0
  179. package/icure/index.js +19 -0
  180. package/icure/index.js.map +1 -0
  181. package/icure/model.d.ts +10 -0
  182. package/icure/model.js +3 -0
  183. package/icure/model.js.map +1 -0
  184. package/package.json +21 -16
  185. package/utils/code-utils.d.ts +18 -0
  186. package/utils/code-utils.js +36 -0
  187. package/utils/code-utils.js.map +1 -0
  188. package/utils/fields-values-provider.d.ts +18 -0
  189. package/utils/fields-values-provider.js +50 -0
  190. package/utils/fields-values-provider.js.map +1 -0
  191. package/utils/form-value-container.d.ts +3 -0
  192. package/utils/form-value-container.js +45 -0
  193. package/utils/form-value-container.js.map +1 -0
  194. package/utils/icure-utils.d.ts +8 -11
  195. package/utils/icure-utils.js +47 -48
  196. package/utils/icure-utils.js.map +1 -1
  197. package/utils/interpreter.d.ts +4 -0
  198. package/utils/interpreter.js +52 -0
  199. package/utils/interpreter.js.map +1 -0
  200. package/utils/languages.d.ts +3 -1
  201. package/utils/languages.js +4 -4
  202. package/utils/languages.js.map +1 -1
  203. package/utils/markdown.d.ts +8 -0
  204. package/utils/markdown.js +58 -0
  205. package/utils/markdown.js.map +1 -0
  206. package/utils/primitive.d.ts +7 -0
  207. package/utils/primitive.js +123 -0
  208. package/utils/primitive.js.map +1 -0
  209. package/components/iqr-form/fields/datePicker.d.ts +0 -10
  210. package/components/iqr-form/fields/datePicker.js.map +0 -1
  211. package/components/iqr-form/fields/dateTimePicker.d.ts +0 -10
  212. package/components/iqr-form/fields/dateTimePicker.js +0 -49
  213. package/components/iqr-form/fields/dateTimePicker.js.map +0 -1
  214. package/components/iqr-form/fields/measureField.d.ts +0 -8
  215. package/components/iqr-form/fields/measureField.js +0 -44
  216. package/components/iqr-form/fields/measureField.js.map +0 -1
  217. package/components/iqr-form/fields/multipleChoice.js.map +0 -1
  218. package/components/iqr-form/fields/numberField.d.ts +0 -8
  219. package/components/iqr-form/fields/numberField.js +0 -44
  220. package/components/iqr-form/fields/numberField.js.map +0 -1
  221. package/components/iqr-form/fields/textfield.d.ts +0 -1
  222. package/components/iqr-form/fields/textfield.js +0 -143
  223. package/components/iqr-form/fields/textfield.js.map +0 -1
  224. package/components/iqr-form/fields/timePicker.d.ts +0 -10
  225. package/components/iqr-form/fields/timePicker.js +0 -49
  226. package/components/iqr-form/fields/timePicker.js.map +0 -1
  227. package/components/iqr-form/index.d.ts +0 -7
  228. package/components/iqr-form/index.js +0 -147
  229. package/components/iqr-form/index.js.map +0 -1
  230. package/components/iqr-form/legacy/Content.d.ts +0 -28
  231. package/components/iqr-form/legacy/Content.js +0 -30
  232. package/components/iqr-form/legacy/Content.js.map +0 -1
  233. package/components/iqr-form/legacy/Data.d.ts +0 -14
  234. package/components/iqr-form/legacy/Data.js +0 -21
  235. package/components/iqr-form/legacy/Data.js.map +0 -1
  236. package/components/iqr-form/legacy/Editor.d.ts +0 -34
  237. package/components/iqr-form/legacy/Editor.js +0 -19
  238. package/components/iqr-form/legacy/Editor.js.map +0 -1
  239. package/components/iqr-form/legacy/FormColumn.d.ts +0 -18
  240. package/components/iqr-form/legacy/FormColumn.js +0 -10
  241. package/components/iqr-form/legacy/FormColumn.js.map +0 -1
  242. package/components/iqr-form/legacy/FormDataOption.d.ts +0 -16
  243. package/components/iqr-form/legacy/FormDataOption.js +0 -21
  244. package/components/iqr-form/legacy/FormDataOption.js.map +0 -1
  245. package/components/iqr-form/legacy/FormLayout.d.ts +0 -25
  246. package/components/iqr-form/legacy/FormLayout.js +0 -10
  247. package/components/iqr-form/legacy/FormLayout.js.map +0 -1
  248. package/components/iqr-form/legacy/FormLayoutData.d.ts +0 -42
  249. package/components/iqr-form/legacy/FormLayoutData.js +0 -10
  250. package/components/iqr-form/legacy/FormLayoutData.js.map +0 -1
  251. package/components/iqr-form/legacy/FormPlanning.d.ts +0 -22
  252. package/components/iqr-form/legacy/FormPlanning.js +0 -21
  253. package/components/iqr-form/legacy/FormPlanning.js.map +0 -1
  254. package/components/iqr-form/legacy/FormSection.d.ts +0 -19
  255. package/components/iqr-form/legacy/FormSection.js +0 -10
  256. package/components/iqr-form/legacy/FormSection.js.map +0 -1
  257. package/components/iqr-form/legacy/Formula.d.ts +0 -27
  258. package/components/iqr-form/legacy/Formula.js +0 -32
  259. package/components/iqr-form/legacy/Formula.js.map +0 -1
  260. package/components/iqr-form/legacy/GuiCode.d.ts +0 -16
  261. package/components/iqr-form/legacy/GuiCode.js +0 -21
  262. package/components/iqr-form/legacy/GuiCode.js.map +0 -1
  263. package/components/iqr-form/legacy/GuiCodeType.d.ts +0 -15
  264. package/components/iqr-form/legacy/GuiCodeType.js +0 -21
  265. package/components/iqr-form/legacy/GuiCodeType.js.map +0 -1
  266. package/components/iqr-form/legacy/Suggest.d.ts +0 -19
  267. package/components/iqr-form/legacy/Suggest.js +0 -21
  268. package/components/iqr-form/legacy/Suggest.js.map +0 -1
  269. package/components/iqr-form/legacy/Tag.d.ts +0 -16
  270. package/components/iqr-form/legacy/Tag.js +0 -21
  271. package/components/iqr-form/legacy/Tag.js.map +0 -1
  272. package/components/iqr-form/model/index.d.ts +0 -96
  273. package/components/iqr-form/model/index.js +0 -120
  274. package/components/iqr-form/model/index.js.map +0 -1
  275. package/components/iqr-form/renderer/cards.d.ts +0 -2
  276. package/components/iqr-form/renderer/cards.js +0 -55
  277. package/components/iqr-form/renderer/cards.js.map +0 -1
  278. package/components/iqr-form/renderer/form.d.ts +0 -2
  279. package/components/iqr-form/renderer/form.js +0 -93
  280. package/components/iqr-form/renderer/form.js.map +0 -1
  281. package/components/iqr-form/renderer/index.d.ts +0 -6
  282. package/components/iqr-form/renderer/index.js.map +0 -1
  283. package/components/iqr-form/utils.d.ts +0 -5
  284. package/components/iqr-form/utils.js +0 -91
  285. package/components/iqr-form/utils.js.map +0 -1
  286. package/components/iqr-form-loader/fieldsValuesProviders.d.ts +0 -13
  287. package/components/iqr-form-loader/fieldsValuesProviders.js +0 -49
  288. package/components/iqr-form-loader/fieldsValuesProviders.js.map +0 -1
  289. package/components/iqr-form-loader/formValuesContainer.d.ts +0 -33
  290. package/components/iqr-form-loader/formValuesContainer.js +0 -111
  291. package/components/iqr-form-loader/formValuesContainer.js.map +0 -1
  292. package/components/iqr-form-loader/index.d.ts +0 -3
  293. package/components/iqr-form-loader/index.js.map +0 -1
  294. package/components/iqr-form-loader/models.d.ts +0 -14
  295. package/components/iqr-form-loader/models.js.map +0 -1
  296. package/components/iqr-text-field/index.d.ts +0 -26
  297. package/components/iqr-text-field/index.js +0 -1242
  298. package/components/iqr-text-field/index.js.map +0 -1
  299. package/components/iqr-text-field/plugin/caret-fix-plugin.js.map +0 -1
  300. package/components/iqr-text-field/plugin/has-content-class-plugin.js.map +0 -1
  301. package/components/iqr-text-field/plugin/mask-plugin.js.map +0 -1
  302. package/components/iqr-text-field/plugin/regexp-plugin.js.map +0 -1
  303. package/components/iqr-text-field/prosemirror-commands.js.map +0 -1
  304. package/components/iqr-text-field/prosemirror-utils.js.map +0 -1
  305. package/components/iqr-text-field/schema/common-marks.js.map +0 -1
  306. package/components/iqr-text-field/schema/date-time-schema.js.map +0 -1
  307. package/components/iqr-text-field/schema/decimal-schema.js.map +0 -1
  308. package/components/iqr-text-field/schema/index.d.ts +0 -11
  309. package/components/iqr-text-field/schema/index.js.map +0 -1
  310. package/components/iqr-text-field/schema/markdown-schema.js.map +0 -1
  311. package/components/iqr-text-field/schema/measure-schema.d.ts +0 -3
  312. package/components/iqr-text-field/schema/measure-schema.js +0 -36
  313. package/components/iqr-text-field/schema/measure-schema.js.map +0 -1
  314. package/components/iqr-text-field/schema/token-schema.js.map +0 -1
  315. package/components/iqr-text-field/schema/utils.js.map +0 -1
  316. package/components/iqr-text-field/selection-companion.js.map +0 -1
  317. package/components/iqr-text-field/styles/paths.js.map +0 -1
  318. package/components/iqr-text-field/suggestion-palette.js.map +0 -1
  319. /package/components/{iqr-form → icure-form}/renderer/index.js +0 -0
  320. /package/components/{iqr-text-field → icure-text-field}/plugin/caret-fix-plugin.d.ts +0 -0
  321. /package/components/{iqr-text-field → icure-text-field}/plugin/caret-fix-plugin.js +0 -0
  322. /package/components/{iqr-text-field → icure-text-field}/plugin/has-content-class-plugin.js +0 -0
  323. /package/components/{iqr-text-field → icure-text-field}/plugin/mask-plugin.d.ts +0 -0
  324. /package/components/{iqr-text-field → icure-text-field}/plugin/mask-plugin.js +0 -0
  325. /package/components/{iqr-text-field → icure-text-field}/plugin/regexp-plugin.d.ts +0 -0
  326. /package/components/{iqr-text-field → icure-text-field}/plugin/regexp-plugin.js +0 -0
  327. /package/components/{iqr-text-field → icure-text-field}/prosemirror-commands.d.ts +0 -0
  328. /package/components/{iqr-text-field → icure-text-field}/prosemirror-commands.js +0 -0
  329. /package/components/{iqr-text-field → icure-text-field}/prosemirror-utils.js +0 -0
  330. /package/components/{iqr-text-field → icure-text-field}/schema/common-marks.d.ts +0 -0
  331. /package/components/{iqr-text-field → icure-text-field}/schema/common-marks.js +0 -0
  332. /package/components/{iqr-text-field → icure-text-field}/schema/date-time-schema.js +0 -0
  333. /package/components/{iqr-text-field → icure-text-field}/schema/decimal-schema.js +0 -0
  334. /package/components/{iqr-text-field → icure-text-field}/schema/markdown-schema.js +0 -0
  335. /package/components/{iqr-text-field → icure-text-field}/schema/utils.d.ts +0 -0
  336. /package/components/{iqr-text-field → icure-text-field}/schema/utils.js +0 -0
  337. /package/components/{iqr-text-field → icure-text-field}/selection-companion.d.ts +0 -0
  338. /package/components/{iqr-text-field → icure-text-field}/selection-companion.js +0 -0
  339. /package/components/{iqr-text-field → icure-text-field}/suggestion-palette.js +0 -0
package/icure/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./model"), exports);
18
+ __exportStar(require("./form-values-container"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../tmp/icure/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,0DAAuC","sourcesContent":["export * from './model'\nexport * from './form-values-container'\n"]}
@@ -0,0 +1,10 @@
1
+ import { CodeStub } from '@icure/api';
2
+ export interface ServiceMetadata {
3
+ label: string;
4
+ index?: number;
5
+ valueDate?: number;
6
+ owner?: string;
7
+ responsible?: string;
8
+ codes?: CodeStub[];
9
+ tags?: CodeStub[];
10
+ }
package/icure/model.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../tmp/icure/model.ts"],"names":[],"mappings":"","sourcesContent":["import { CodeStub } from '@icure/api'\n\nexport interface ServiceMetadata {\n\tlabel: string\n\tindex?: number\n\tvalueDate?: number\n\towner?: string\n\tresponsible?: string\n\tcodes?: CodeStub[]\n\ttags?: CodeStub[]\n}\n"]}
package/package.json CHANGED
@@ -1,27 +1,32 @@
1
1
  {
2
2
  "name": "@icure/form",
3
- "version": "1.1.0",
3
+ "version": "1.1.14",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
- "types": null,
6
+ "types": "./lib/index.d.ts",
7
7
  "dependencies": {
8
- "@webcomponents/webcomponentsjs": "^2.6.0",
8
+ "@types/node": "^18.16.3",
9
+ "@webcomponents/webcomponentsjs": "^2.7.0",
10
+ "app-datepicker": "^6.0.0-rc.33",
9
11
  "fast-deep-equal": "^3.1.3",
10
- "lit": "^2.0.2",
11
- "prosemirror-commands": "1.2.2",
12
- "prosemirror-history": "1.1.3",
13
- "prosemirror-keymap": "1.1.5",
14
- "prosemirror-markdown": "1.8.0",
15
- "prosemirror-model": "1.16.1",
16
- "prosemirror-schema-basic": "1.1.2",
17
- "prosemirror-schema-list": "1.1.6",
18
- "prosemirror-state": "1.3.4",
19
- "prosemirror-view": "1.23.13",
20
- "simple-statistics": "^7.7.0",
21
- "yaml": "^1.10.2"
12
+ "lit": "^3.1.0",
13
+ "markdown-it": "^14.0.0",
14
+ "orderedmap": "2.1.1",
15
+ "prosemirror-commands": "1.5.2",
16
+ "prosemirror-history": "1.3.2",
17
+ "prosemirror-keymap": "1.2.2",
18
+ "prosemirror-markdown": "1.12.0",
19
+ "prosemirror-model": "1.19.4",
20
+ "prosemirror-schema-basic": "1.2.2",
21
+ "prosemirror-schema-list": "1.3.0",
22
+ "prosemirror-state": "1.4.3",
23
+ "prosemirror-transform": "1.8.0",
24
+ "prosemirror-view": "1.32.7",
25
+ "uuid": "^9.0.1",
26
+ "yaml": "2.3.4"
22
27
  },
23
28
  "author": "",
24
29
  "license": "GPL-3.0",
25
30
  "bugs": null,
26
31
  "homepage": null
27
- }
32
+ }
@@ -0,0 +1,18 @@
1
+ import { Field, Code, SortOptions } from '../components/model';
2
+ import { CodeStub } from '@icure/api';
3
+ /**
4
+ * Maps the options defined in a field into a list of codes
5
+ *
6
+ * @param language
7
+ * @param field
8
+ * @param translationProvider
9
+ */
10
+ export declare const optionMapper: (language: string, field: Field, translationProvider?: ((language: string, text: string) => string) | undefined) => Code[];
11
+ export declare const sortCodes: (codes: Code[], language: string, sortOptions?: SortOptions) => Code[];
12
+ export declare const filerAndSortOptionsFromFieldDefinition: (language: string, fg: Field, translationProvider: ((language: string, text: string) => string) | undefined, searchTerms: string | undefined) => Promise<Code[]>;
13
+ export declare const codeStubToCode: (c: CodeStub) => {
14
+ id: string;
15
+ label: {
16
+ [key: string]: string;
17
+ };
18
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.codeStubToCode = exports.filerAndSortOptionsFromFieldDefinition = exports.sortCodes = exports.optionMapper = void 0;
4
+ const utils_1 = require("../components/common/utils");
5
+ /**
6
+ * Maps the options defined in a field into a list of codes
7
+ *
8
+ * @param language
9
+ * @param field
10
+ * @param translationProvider
11
+ */
12
+ const optionMapper = (language, field, translationProvider) => {
13
+ var _a;
14
+ return Object.keys((_a = field === null || field === void 0 ? void 0 : field.options) !== null && _a !== void 0 ? _a : []).map((optionKey) => {
15
+ var _a, _b;
16
+ const text = (_b = (_a = field === null || field === void 0 ? void 0 : field.options) === null || _a === void 0 ? void 0 : _a[optionKey]) !== null && _b !== void 0 ? _b : '';
17
+ return {
18
+ id: optionKey,
19
+ label: { [language]: translationProvider ? translationProvider(language, text) : text },
20
+ };
21
+ });
22
+ };
23
+ exports.optionMapper = optionMapper;
24
+ const sortCodes = (codes, language, sortOptions) => (sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sort) && (sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sort) !== 'natural'
25
+ ? codes.sort((0, utils_1.defaultCodesComparator)(language, (sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.sort) === 'asc', (sortOptions === null || sortOptions === void 0 ? void 0 : sortOptions.promotions) ? (0, utils_1.makePromoter)(sortOptions.promotions.split(/ ?, ?/)) : utils_1.defaultCodePromoter))
26
+ : codes;
27
+ exports.sortCodes = sortCodes;
28
+ const filerAndSortOptionsFromFieldDefinition = (language, fg, translationProvider, searchTerms) => Promise.resolve((0, exports.sortCodes)((0, exports.optionMapper)(language, fg, translationProvider).filter((x) => !searchTerms ||
29
+ searchTerms
30
+ .split(/\s+/)
31
+ .map((st) => st.toLowerCase())
32
+ .every((st) => x.label[language].toLowerCase().includes(st))), language, fg.sortOptions));
33
+ exports.filerAndSortOptionsFromFieldDefinition = filerAndSortOptionsFromFieldDefinition;
34
+ const codeStubToCode = (c) => { var _a, _b; return ({ id: (_a = c.id) !== null && _a !== void 0 ? _a : `${c.type}|${c.code}|${c.version}`, label: (_b = c.label) !== null && _b !== void 0 ? _b : {} }); };
35
+ exports.codeStubToCode = codeStubToCode;
36
+ //# sourceMappingURL=code-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-utils.js","sourceRoot":"","sources":["../../tmp/utils/code-utils.ts"],"names":[],"mappings":";;;AAEA,sDAAsG;AAEtG;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,KAAY,EAAE,mBAAgE,EAAU,EAAE;;IACxI,OAAA,MAAM,CAAC,IAAI,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;;QACnD,MAAM,IAAI,GAAW,MAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAG,SAAS,CAAY,mCAAI,EAAE,CAAA;QAClE,OAAO;YACN,EAAE,EAAE,SAAS;YACb,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;SACvF,CAAA;IACF,CAAC,CAAC,CAAA;CAAA,CAAA;AAPU,QAAA,YAAY,gBAOtB;AAEI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A,CAAC,EAAE,EAAE,EAAE,MAAA,CAAC,CAAC,EAAE,mCAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAA,CAAC,CAAC,KAAK,mCAAI,EAAE,EAAE,CAAC,CAAA,EAAA,CAAA;AAA5G,QAAA,cAAc,kBAA8F","sourcesContent":["import { Field, Code, SortOptions } from '../components/model'\nimport { CodeStub } from '@icure/api'\nimport { defaultCodePromoter, defaultCodesComparator, makePromoter } from '../components/common/utils'\n\n/**\n * Maps the options defined in a field into a list of codes\n *\n * @param language\n * @param field\n * @param translationProvider\n */\nexport const optionMapper = (language: string, field: Field, translationProvider?: (language: string, text: string) => string): Code[] =>\n\tObject.keys(field?.options ?? []).map((optionKey) => {\n\t\tconst text: string = (field?.options?.[optionKey] as string) ?? ''\n\t\treturn {\n\t\t\tid: optionKey,\n\t\t\tlabel: { [language]: translationProvider ? translationProvider(language, text) : text },\n\t\t}\n\t})\n\nexport const sortCodes = (codes: Code[], language: string, sortOptions?: SortOptions) =>\n\tsortOptions?.sort && sortOptions?.sort !== 'natural'\n\t\t? codes.sort(defaultCodesComparator(language, sortOptions?.sort === 'asc', sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\t\t: codes\n\nexport const filerAndSortOptionsFromFieldDefinition = (\n\tlanguage: string,\n\tfg: Field,\n\ttranslationProvider: ((language: string, text: string) => string) | undefined,\n\tsearchTerms: string | undefined,\n) =>\n\tPromise.resolve(\n\t\tsortCodes(\n\t\t\toptionMapper(language, fg, translationProvider).filter(\n\t\t\t\t(x) =>\n\t\t\t\t\t!searchTerms ||\n\t\t\t\t\tsearchTerms\n\t\t\t\t\t\t.split(/\\s+/)\n\t\t\t\t\t\t.map((st) => st.toLowerCase())\n\t\t\t\t\t\t.every((st) => x.label[language].toLowerCase().includes(st)),\n\t\t\t),\n\t\t\tlanguage,\n\t\t\tfg.sortOptions,\n\t\t),\n\t)\nexport const codeStubToCode = (c: CodeStub) => ({ id: c.id ?? `${c.type}|${c.code}|${c.version}`, label: c.label ?? {} })\n"]}
@@ -0,0 +1,18 @@
1
+ import { Field, FieldMetadata, FieldValue } from '../components/model';
2
+ import { FormValuesContainer, VersionedData } from '../generic';
3
+ export declare const fieldValuesProvider: (formValuesContainer: FormValuesContainer<FieldValue, FieldMetadata>, field: Field) => (() => VersionedData<FieldValue>);
4
+ export declare function makeMetadata(field: Field, owner?: string, index?: number): {
5
+ label: string;
6
+ valueDate: number;
7
+ owner: string | undefined;
8
+ index: number | undefined;
9
+ tags: {
10
+ id: string;
11
+ label: {};
12
+ }[] | undefined;
13
+ };
14
+ export declare const handleValueChanged: (formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>, field?: Field, owner?: string) => (label: string, language: string, value?: FieldValue, id?: string, index?: number) => {
15
+ result: string;
16
+ formValuesContainer: FormValuesContainer<FieldValue, FieldMetadata>;
17
+ } | undefined;
18
+ export declare const handleMetadataChanged: (formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>) => (label: string, metadata: FieldMetadata, id?: string) => ((formsValueContainer: FormValuesContainer<FieldValue, FieldMetadata>) => import("../generic").FormValuesContainerMutation<FieldValue, FieldMetadata, FormValuesContainer<FieldValue, FieldMetadata>, string>) | undefined;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleMetadataChanged = exports.handleValueChanged = exports.makeMetadata = exports.fieldValuesProvider = void 0;
4
+ const api_1 = require("@icure/api");
5
+ const icure_utils_1 = require("./icure-utils");
6
+ function getRevisionsFilter(field) {
7
+ return (id, history) => history
8
+ .filter((fmd) => { var _a, _b; return (((_a = field.tags) === null || _a === void 0 ? void 0 : _a.length) ? field.tags.every((t) => { var _a, _b; return (_b = (_a = fmd === null || fmd === void 0 ? void 0 : fmd.value) === null || _a === void 0 ? void 0 : _a.tags) === null || _b === void 0 ? void 0 : _b.some((tt) => (0, api_1.normalizeCode)(tt).id === t); }) : ((_b = fmd === null || fmd === void 0 ? void 0 : fmd.value) === null || _b === void 0 ? void 0 : _b.label) === field.label()); })
9
+ .map((fmd) => fmd.revision)
10
+ .filter((r) => r !== undefined); //null is used as a new revision indicator
11
+ }
12
+ const fieldValuesProvider = (formValuesContainer, field) => () => formValuesContainer.getValues(getRevisionsFilter(field));
13
+ exports.fieldValuesProvider = fieldValuesProvider;
14
+ function makeMetadata(field, owner, index) {
15
+ var _a;
16
+ return {
17
+ label: field.label(),
18
+ valueDate: (0, icure_utils_1.dateToFuzzyDate)(new Date()),
19
+ owner: owner,
20
+ index: index,
21
+ tags: (_a = field.tags) === null || _a === void 0 ? void 0 : _a.map((t) => ({
22
+ id: t,
23
+ label: {},
24
+ })),
25
+ };
26
+ }
27
+ exports.makeMetadata = makeMetadata;
28
+ const handleValueChanged = (formsValueContainer, field, owner) => {
29
+ const wrapper = formsValueContainer ? [formsValueContainer] : [];
30
+ return (label, language, value, id, index) => {
31
+ const fvc = wrapper[0];
32
+ if (fvc) {
33
+ const { result, formValuesContainer: newFvc } = fvc.setValue(label, language, value, id, !id && field // If the id is not set, we are creating a new value. In this case, we set the metadata.
34
+ ? makeMetadata(field, owner)
35
+ : undefined);
36
+ wrapper[0] = newFvc;
37
+ return { result, formValuesContainer: newFvc };
38
+ }
39
+ return undefined;
40
+ };
41
+ };
42
+ exports.handleValueChanged = handleValueChanged;
43
+ const handleMetadataChanged = (formsValueContainer) => (label, metadata, id) => {
44
+ if (formsValueContainer) {
45
+ return (formsValueContainer) => formsValueContainer === null || formsValueContainer === void 0 ? void 0 : formsValueContainer.setMetadata(label, metadata, id);
46
+ }
47
+ return undefined;
48
+ };
49
+ exports.handleMetadataChanged = handleMetadataChanged;
50
+ //# sourceMappingURL=fields-values-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields-values-provider.js","sourceRoot":"","sources":["../../tmp/utils/fields-values-provider.ts"],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BAAmB,uBAAnB,mBAAmB,CAAE,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;KACrI;IACD,OAAO,SAAS,CAAA;AACjB,CAAC,CAAA;AALY,QAAA,qBAAqB,yBAKjC","sourcesContent":["import { normalizeCode } from '@icure/api'\nimport { Field, FieldMetadata, FieldValue } from '../components/model'\nimport { FormValuesContainer, Version, VersionedData } from '../generic'\nimport { dateToFuzzyDate } from './icure-utils'\n\nfunction getRevisionsFilter(field: Field): (id: string, history: Version<FieldMetadata>[]) => string[] {\n\treturn (id, history) =>\n\t\thistory\n\t\t\t.filter((fmd) => (field.tags?.length ? field.tags.every((t) => fmd?.value?.tags?.some((tt) => normalizeCode(tt).id === t)) : fmd?.value?.label === field.label()))\n\t\t\t.map((fmd) => fmd.revision)\n\t\t\t.filter((r) => r !== undefined) as string[] //null is used as a new revision indicator\n}\n\nexport const fieldValuesProvider =\n\t(formValuesContainer: FormValuesContainer<FieldValue, FieldMetadata>, field: Field): (() => VersionedData<FieldValue>) =>\n\t() =>\n\t\tformValuesContainer.getValues(getRevisionsFilter(field))\n\nexport function makeMetadata(field: Field, owner?: string, index?: number) {\n\treturn {\n\t\tlabel: field.label(),\n\t\tvalueDate: dateToFuzzyDate(new Date()),\n\t\towner: owner,\n\t\tindex: index,\n\t\ttags: field.tags?.map((t) => ({\n\t\t\tid: t,\n\t\t\tlabel: {},\n\t\t})),\n\t}\n}\n\nexport const handleValueChanged = (formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>, field?: Field, owner?: string) => {\n\tconst wrapper = formsValueContainer ? [formsValueContainer] : []\n\treturn (label: string, language: string, value?: FieldValue, id?: string, index?: number) => {\n\t\tconst fvc = wrapper[0]\n\t\tif (fvc) {\n\t\t\tconst { result, formValuesContainer: newFvc } = fvc.setValue(\n\t\t\t\tlabel,\n\t\t\t\tlanguage,\n\t\t\t\tvalue,\n\t\t\t\tid,\n\t\t\t\t!id && field // If the id is not set, we are creating a new value. In this case, we set the metadata.\n\t\t\t\t\t? makeMetadata(field, owner)\n\t\t\t\t\t: undefined,\n\t\t\t)\n\t\t\twrapper[0] = newFvc\n\t\t\treturn { result, formValuesContainer: newFvc }\n\t\t}\n\t\treturn undefined\n\t}\n}\n\nexport const handleMetadataChanged = (formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>) => (label: string, metadata: FieldMetadata, id?: string) => {\n\tif (formsValueContainer) {\n\t\treturn (formsValueContainer: FormValuesContainer<FieldValue, FieldMetadata>) => formsValueContainer?.setMetadata(label, metadata, id)\n\t}\n\treturn undefined\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { FieldMetadata, FieldValue, Form } from '../components/model';
2
+ import { FormValuesContainer } from '../generic';
3
+ export declare const initializeWithFormDefaultValues: (formValuesContainer: FormValuesContainer<FieldValue, FieldMetadata>, form: Form, language?: string, owner?: string) => FormValuesContainer<FieldValue, FieldMetadata>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeWithFormDefaultValues = void 0;
4
+ const fields_values_provider_1 = require("./fields-values-provider");
5
+ const initializeWithFormDefaultValues = (formValuesContainer, form, language, owner) => {
6
+ const fvc = [formValuesContainer];
7
+ const extractDefaultValues = (fgs, language) => {
8
+ if (fvc[0]) {
9
+ fgs.forEach((fg) => {
10
+ var _a, _b, _c, _d, _e, _f;
11
+ if (fg.clazz === 'group' && ((_a = fg.fields) === null || _a === void 0 ? void 0 : _a.length)) {
12
+ extractDefaultValues(fg.fields, language);
13
+ }
14
+ else if (fg.clazz === 'field') {
15
+ //Check that no value already exists
16
+ if (!Object.keys((_b = (0, fields_values_provider_1.fieldValuesProvider)(fvc[0], fg)()) !== null && _b !== void 0 ? _b : {}).length) {
17
+ if ((_c = fg.computedProperties) === null || _c === void 0 ? void 0 : _c.defaultValue) {
18
+ const value = (_d = fvc[0]) === null || _d === void 0 ? void 0 : _d.compute((_e = fg.computedProperties) === null || _e === void 0 ? void 0 : _e.defaultValue);
19
+ if (value !== undefined) {
20
+ const lng = language !== null && language !== void 0 ? language : 'en';
21
+ if (!value.content[lng] && value.content['*']) {
22
+ value.content[lng] = value.content['*'];
23
+ }
24
+ //TODO support batch changes
25
+ (_f = fvc[0]) === null || _f === void 0 ? void 0 : _f.setValue(fg.label(), lng, value, undefined, (0, fields_values_provider_1.makeMetadata)(fg, owner));
26
+ }
27
+ }
28
+ }
29
+ }
30
+ });
31
+ }
32
+ };
33
+ const listener = (newValue) => {
34
+ fvc[0] = newValue;
35
+ };
36
+ fvc[0].registerChangeListener(listener);
37
+ form === null || form === void 0 ? void 0 : form.sections.forEach((section) => {
38
+ var _a;
39
+ extractDefaultValues((_a = section.fields) !== null && _a !== void 0 ? _a : [], language);
40
+ });
41
+ fvc[0].unregisterChangeListener(listener);
42
+ return fvc[0];
43
+ };
44
+ exports.initializeWithFormDefaultValues = initializeWithFormDefaultValues;
45
+ //# sourceMappingURL=form-value-container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-value-container.js","sourceRoot":"","sources":["../../tmp/utils/form-value-container.ts"],"names":[],"mappings":";;;AACA,qEAA4E;AAGrE,MAAM,+BAA+B,GAAG,CAC9C,mBAAmE,EACnE,IAAU,EACV,QAAiB,EACjB,KAAc,EACmC,EAAE;IACnD,MAAM,GAAG,GAAG,CAAC,mBAAmB,CAAC,CAAA;IAEjC,MAAM,oBAAoB,GAAG,CAAC,GAAmC,EAAE,QAAiB,EAAE,EAAE;QACvF,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;YACX,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;;gBAClB,IAAI,EAAE,CAAC,KAAK,KAAK,OAAO,KAAI,MAAA,EAAE,CAAC,MAAM,0CAAE,MAAM,CAAA,EAAE;oBAC9C,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;iBACzC;qBAAM,IAAI,EAAE,CAAC,KAAK,KAAK,O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AE;;QAClC,oBAAoB,CAAC,MAAA,OAAO,CAAC,MAAM,mCAAI,EAAE,EAAE,QAAQ,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;IAEF,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAA;IACzC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAA;AACd,CAAC,CAAA;AA5CY,QAAA,+BAA+B,mCA4C3C","sourcesContent":["import { Field, FieldMetadata, FieldValue, Form, Group, Subform } from '../components/model'\nimport { fieldValuesProvider, makeMetadata } from './fields-values-provider'\nimport { FormValuesContainer } from '../generic'\n\nexport const initializeWithFormDefaultValues = (\n\tformValuesContainer: FormValuesContainer<FieldValue, FieldMetadata>,\n\tform: Form,\n\tlanguage?: string,\n\towner?: string,\n): FormValuesContainer<FieldValue, FieldMetadata> => {\n\tconst fvc = [formValuesContainer]\n\n\tconst extractDefaultValues = (fgs: Array<Field | Group | Subform>, language?: string) => {\n\t\tif (fvc[0]) {\n\t\t\tfgs.forEach((fg) => {\n\t\t\t\tif (fg.clazz === 'group' && fg.fields?.length) {\n\t\t\t\t\textractDefaultValues(fg.fields, language)\n\t\t\t\t} else if (fg.clazz === 'field') {\n\t\t\t\t\t//Check that no value already exists\n\t\t\t\t\tif (!Object.keys(fieldValuesProvider(fvc[0], fg)() ?? {}).length) {\n\t\t\t\t\t\tif (fg.computedProperties?.defaultValue) {\n\t\t\t\t\t\t\tconst value: FieldValue | undefined = fvc[0]?.compute(fg.computedProperties?.defaultValue)\n\t\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\t\tconst lng = language ?? 'en'\n\t\t\t\t\t\t\t\tif (!value.content[lng] && value.content['*']) {\n\t\t\t\t\t\t\t\t\tvalue.content[lng] = value.content['*']\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t//TODO support batch changes\n\t\t\t\t\t\t\t\tfvc[0]?.setValue((fg as Field).label(), lng, value, undefined, makeMetadata(fg, owner))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\n\tconst listener = (newValue: FormValuesContainer<FieldValue, FieldMetadata>) => {\n\t\tfvc[0] = newValue\n\t}\n\tfvc[0].registerChangeListener(listener)\n\n\tform?.sections.forEach((section) => {\n\t\textractDefaultValues(section.fields ?? [], language)\n\t})\n\n\tfvc[0].unregisterChangeListener(listener)\n\treturn fvc[0]\n}\n"]}
@@ -1,19 +1,16 @@
1
- import { CodeStub, Contact, Content, Service } from '@icure/api';
2
- import { Field } from '../components/iqr-form/model';
3
- import { ServicesHistory } from '../components/iqr-form-loader';
4
- import { FormValuesContainer } from '../components/iqr-form-loader';
5
- import { VersionedMeta, VersionedValue } from '../components';
6
- export declare function fuzzyDate(epochOrLongCalendar?: number): Date | undefined;
1
+ import { CodeStub, Content, Service } from '@icure/api';
2
+ export declare function anyDateToDate(dateOrEpochOrLongCalendar?: Date | number): Date | undefined;
3
+ export declare function dateToFuzzyDate(date: Date): number;
4
+ export declare function anyDateToFuzzyDate(dateOrEpochOrLongCalendar: Date | number): number | undefined;
5
+ export declare function currentTime(): string;
6
+ export declare function currentDate(): string;
7
+ export declare function currentDateTime(): string;
7
8
  export declare function isCodeEqual(c1: CodeStub, c2: CodeStub): boolean;
8
9
  export declare function areCodesEqual(c1s: CodeStub[], c2s: CodeStub[]): boolean;
9
10
  export declare function isServiceEqual(svc1: Service, svc2: Service): boolean;
10
- export declare function isContentEqual(content1: Content, content2: Content): boolean;
11
+ export declare function isContentEqual(content1: Content | undefined, content2: Content | undefined): boolean;
11
12
  export declare function isServiceContentEqual(content1: {
12
13
  [language: string]: Content;
13
14
  }, content2: {
14
15
  [language: string]: Content;
15
16
  }): boolean;
16
- export declare function convertServicesToVersionedValues(versions: ServicesHistory, extractValueFromContent: (content: Content) => string): VersionedValue[];
17
- export declare function convertServicesToVersionedMetas(versions: ServicesHistory): VersionedMeta[];
18
- export declare function getVersions(formsValueContainer: FormValuesContainer, field: Field): ServicesHistory;
19
- export declare function setServices(ctc: Contact, newServices: Service[], modifiedServices: Service[]): Contact;
@@ -3,24 +3,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setServices = exports.getVersions = exports.convertServicesToVersionedMetas = exports.convertServicesToVersionedValues = exports.isServiceContentEqual = exports.isContentEqual = exports.isServiceEqual = exports.areCodesEqual = exports.isCodeEqual = exports.fuzzyDate = void 0;
6
+ exports.isServiceContentEqual = exports.isContentEqual = exports.isServiceEqual = exports.areCodesEqual = exports.isCodeEqual = exports.currentDateTime = exports.currentDate = exports.currentTime = exports.anyDateToFuzzyDate = exports.dateToFuzzyDate = exports.anyDateToDate = void 0;
7
7
  const parse_1 = __importDefault(require("date-fns/parse"));
8
- const api_1 = require("@icure/api");
9
- function fuzzyDate(epochOrLongCalendar) {
10
- if (!epochOrLongCalendar && epochOrLongCalendar !== 0) {
8
+ function anyDateToDate(dateOrEpochOrLongCalendar) {
9
+ if (dateOrEpochOrLongCalendar instanceof Date) {
10
+ return anyDateToDate(+dateOrEpochOrLongCalendar);
11
+ }
12
+ if (!dateOrEpochOrLongCalendar && dateOrEpochOrLongCalendar !== 0) {
11
13
  return undefined;
12
14
  }
13
- if (epochOrLongCalendar >= 18000101 && epochOrLongCalendar < 25400000) {
14
- return (0, parse_1.default)('' + epochOrLongCalendar, 'YYYYMMDD', new Date());
15
+ if (dateOrEpochOrLongCalendar >= 18000101 && dateOrEpochOrLongCalendar < 25400000) {
16
+ return (0, parse_1.default)('' + dateOrEpochOrLongCalendar, 'yyyyMMdd', new Date());
15
17
  }
16
- else if (epochOrLongCalendar >= 18000101000000) {
17
- return (0, parse_1.default)('' + epochOrLongCalendar, 'YYYYMMDDHHmmss', new Date());
18
+ else if (dateOrEpochOrLongCalendar >= 18000101000000) {
19
+ return (0, parse_1.default)('' + dateOrEpochOrLongCalendar, 'yyyyMMddHHmmss', new Date());
18
20
  }
19
21
  else {
20
- return new Date(epochOrLongCalendar);
22
+ return new Date(dateOrEpochOrLongCalendar);
21
23
  }
22
24
  }
23
- exports.fuzzyDate = fuzzyDate;
25
+ exports.anyDateToDate = anyDateToDate;
26
+ function dateToFuzzyDate(date) {
27
+ return parseInt(`${date.getFullYear()}${(date.getMonth() + 1).toString().padStart(2, '0')}${date.getDate().toString().padStart(2, '0')}${date.getHours().toString().padStart(2, '0')}:${date
28
+ .getMinutes()
29
+ .toString()
30
+ .padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`);
31
+ }
32
+ exports.dateToFuzzyDate = dateToFuzzyDate;
33
+ function anyDateToFuzzyDate(dateOrEpochOrLongCalendar) {
34
+ const date = anyDateToDate(dateOrEpochOrLongCalendar);
35
+ if (!date) {
36
+ return undefined;
37
+ }
38
+ return dateToFuzzyDate(date);
39
+ }
40
+ exports.anyDateToFuzzyDate = anyDateToFuzzyDate;
41
+ function currentTime() {
42
+ const now = new Date();
43
+ return `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`;
44
+ }
45
+ exports.currentTime = currentTime;
46
+ function currentDate() {
47
+ const now = new Date();
48
+ return `${now.getDate().toString().padStart(2, '0')}/${(now.getMonth() + 1).toString().padStart(2, '0')}/${now.getFullYear()}`;
49
+ }
50
+ exports.currentDate = currentDate;
51
+ function currentDateTime() {
52
+ return `${currentDate()} ${currentTime()}`;
53
+ }
54
+ exports.currentDateTime = currentDateTime;
24
55
  function isCodeEqual(c1, c2) {
25
56
  var _a, _b;
26
57
  const idParts1 = (_a = c1.id) === null || _a === void 0 ? void 0 : _a.split('|');
@@ -44,6 +75,12 @@ function isServiceEqual(svc1, svc2) {
44
75
  exports.isServiceEqual = isServiceEqual;
45
76
  function isContentEqual(content1, content2) {
46
77
  var _a, _b;
78
+ if (!content1 && !content2) {
79
+ return true;
80
+ }
81
+ if (!content1 || !content2) {
82
+ return false;
83
+ }
47
84
  return (((!content1.binaryValue && !content2.binaryValue) || content1.binaryValue === content2.binaryValue) &&
48
85
  (((content1.booleanValue === null || content1.booleanValue === undefined) && (content2.booleanValue === null || content2.booleanValue === undefined)) ||
49
86
  content1.booleanValue === content2.booleanValue) &&
@@ -65,42 +102,4 @@ function isServiceContentEqual(content1, content2) {
65
102
  return Object.keys(content1).reduce((isEqual, lng) => isEqual && isContentEqual(content1[lng], content2[lng]), true);
66
103
  }
67
104
  exports.isServiceContentEqual = isServiceContentEqual;
68
- function convertServicesToVersionedValues(versions, extractValueFromContent) {
69
- return Object.entries(versions).map(([key, value]) => ({
70
- id: key,
71
- versions: value.map((s) => {
72
- var _a, _b, _c;
73
- return ({
74
- revision: '' + ((_a = s.service) === null || _a === void 0 ? void 0 : _a.modified),
75
- modified: ((_b = s.service) === null || _b === void 0 ? void 0 : _b.modified) || 0,
76
- value: Object.entries(((_c = s.service) === null || _c === void 0 ? void 0 : _c.content) || {}).reduce((acc, [lng, content]) => (Object.assign(Object.assign({}, acc), { [lng]: extractValueFromContent(content) })), {}),
77
- });
78
- }),
79
- }));
80
- }
81
- exports.convertServicesToVersionedValues = convertServicesToVersionedValues;
82
- function convertServicesToVersionedMetas(versions) {
83
- return Object.entries(versions).map(([key, value]) => ({
84
- id: key,
85
- metas: value.map((s) => {
86
- var _a, _b, _c, _d, _e;
87
- return ({
88
- revision: '' + ((_a = s.service) === null || _a === void 0 ? void 0 : _a.modified),
89
- modified: ((_b = s.service) === null || _b === void 0 ? void 0 : _b.modified) || 0,
90
- valueDate: (_c = s.service) === null || _c === void 0 ? void 0 : _c.valueDate,
91
- owner: ((_d = s.service) === null || _d === void 0 ? void 0 : _d.responsible) ? { id: (_e = s.service) === null || _e === void 0 ? void 0 : _e.responsible } : undefined,
92
- });
93
- }),
94
- }));
95
- }
96
- exports.convertServicesToVersionedMetas = convertServicesToVersionedMetas;
97
- function getVersions(formsValueContainer, field) {
98
- return ((formsValueContainer === null || formsValueContainer === void 0 ? void 0 : formsValueContainer.getVersions((svc) => { var _a; return ((_a = field.tags) === null || _a === void 0 ? void 0 : _a.length) ? field.tags.every((t) => (svc.tags || []).some((tt) => (0, api_1.normalizeCode)(tt).id === t)) : svc.label === field.label(); })) || {});
99
- }
100
- exports.getVersions = getVersions;
101
- function setServices(ctc, newServices, modifiedServices) {
102
- var _a;
103
- return new api_1.Contact(Object.assign(Object.assign({}, ctc), { services: newServices.concat(((_a = ctc.services) === null || _a === void 0 ? void 0 : _a.map((s) => modifiedServices.find((r) => r.id === s.id) || s)) || []) }));
104
- }
105
- exports.setServices = setServices;
106
105
  //# sourceMappingURL=icure-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icure-utils.js","sourceRoot":"","sources":["../../tmp/utils/icure-utils.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAkC;AAClC,oCAA+E;AAM/E,SAAgB,SAAS,CAAC,mBAA4B;IACrD,IAAI,CAAC,mBAAmB,IAAI,mBAAmB,KAAK,CAAC,EAAE;QACtD,OAAO,SAAS,CAAA;KAChB;IACD,IAAI,mBAAmB,IAAI,QAAQ,IAAI,mBAAmB,GAAG,QAAQ,EAAE;QACtE,OAAO,IAAA,eAAK,EAAC,EAAE,GAAG,mBAAmB,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;KAC9D;SAAM,IAAI,mBAAmB,IAAI,cAAc,EAAE;QACjD,OAAO,IAAA,eAAK,EAAC,EAAE,GAAG,mBAAmB,EAAE,gBAAgB,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;KACpE;SAAM;QACN,OAAO,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAA;KACpC;AACF,CAAC;AAXD,8BAWC;AAED,SAAgB,WAAW,CAAC,EAAY,EAAE,EAAY;;IACrD,MAAM,QAAQ,GAAG,MAAA,EAAE,CAAC,EAAE,0CAAE,KAAK,CAAC,GAAG,CAAC,CA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AAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAA,mBAAa,EAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE,CAAA,EAAA,CACrI,KAAI,EAAE,CACP,CAAA;AACF,CAAC;AAND,kCAMC;AAED,SAAgB,WAAW,CAAC,GAAY,EAAE,WAAsB,EAAE,gBAA2B;;IAC5F,OAAO,IAAI,aAAO,iCACd,GAAG,KACN,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA,MAAA,GAAG,CAAC,QAAQ,0CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAI,EAAE,CAAC,IAC7G,CAAA;AACH,CAAC;AALD,kCAKC","sourcesContent":["import parse from 'date-fns/parse'\nimport { CodeStub, Contact, Content, normalizeCode, Service } from '@icure/api'\nimport { Field } from '../components/iqr-form/model'\nimport { ServicesHistory } from '../components/iqr-form-loader'\nimport { FormValuesContainer } from '../components/iqr-form-loader'\nimport { VersionedMeta, VersionedValue } from '../components'\n\nexport function fuzzyDate(epochOrLongCalendar?: number): Date | undefined {\n\tif (!epochOrLongCalendar && epochOrLongCalendar !== 0) {\n\t\treturn undefined\n\t}\n\tif (epochOrLongCalendar >= 18000101 && epochOrLongCalendar < 25400000) {\n\t\treturn parse('' + epochOrLongCalendar, 'YYYYMMDD', new Date())\n\t} else if (epochOrLongCalendar >= 18000101000000) {\n\t\treturn parse('' + epochOrLongCalendar, 'YYYYMMDDHHmmss', new Date())\n\t} else {\n\t\treturn new Date(epochOrLongCalendar)\n\t}\n}\n\nexport function isCodeEqual(c1: CodeStub, c2: CodeStub): boolean {\n\tconst idParts1 = c1.id?.split('|')\n\tconst idParts2 = c2.id?.split('|')\n\tconst type1 = c1.type || idParts1?.[0]\n\tconst type2 = c2.type || idParts2?.[0]\n\tconst code1 = c1.code || idParts1?.[1]\n\tconst code2 = c2.code || idParts2?.[1]\n\tconst version1 = c1.version || idParts1?.[2]\n\tconst version2 = c2.version || idParts2?.[2]\n\treturn type1 === type2 && code1 === code2 && version1 === version2\n}\n\nexport function areCodesEqual(c1s: CodeStub[], c2s: CodeStub[]): boolean {\n\treturn c1s.every((c1) => c2s.some((c2) => isCodeEqual(c1, c2)) || false) && c2s.every((c2) => c1s.some((c1) => isCodeEqual(c1, c2)) || false)\n}\n\nexport function isServiceEqual(svc1: Service, svc2: Service): boolean {\n\treturn (\n\t\tsvc1.id === svc2.id && svc1.valueDate === svc2.valueDate && areCodesEqual(svc1.codes || [], svc2.codes || []) && isServiceContentEqual(svc1.content || {}, svc2.content || {})\n\t)\n}\n\nexport function isContentEqual(content1: Content, content2: Content): boolean {\n\treturn (\n\t\t((!content1.binaryValue && !content2.binaryValue) || content1.binaryValue === content2.binaryValue) &&\n\t\t(((content1.booleanValue === null || content1.booleanValue === undefined) && (content2.booleanValue === null || content2.booleanValue === undefined)) ||\n\t\t\tcontent1.booleanValue === content2.booleanValue) &&\n\t\t((!content1.documentId && !content2.documentId) || content1.documentId === content2.documentId) &&\n\t\t(((content1.fuzzyDateValue === null || content1.fuzzyDateValue === undefined) && (content2.fuzzyDateValue === null || content2.fuzzyDateValue === undefined)) ||\n\t\t\tcontent1.fuzzyDateValue === content2.fuzzyDateValue) &&\n\t\t((!content1.instantValue && !content2.instantValue) || content1.instantValue === content2.instantValue) &&\n\t\t((!content1.measureValue && !content2.measureValue) || content1.measureValue === content2.measureValue) &&\n\t\t((!content1.medicationValue && !content2.medicationValue) || content1.medicationValue === content2.medicationValue) &&\n\t\t((!content1.stringValue && !content2.stringValue) || content1.stringValue === content2.stringValue) &&\n\t\t(((content1.numberValue === null || content1.numberValue === undefined) && (content2.numberValue === null || content2.numberValue === undefined)) ||\n\t\t\tcontent1.numberValue === content2.numberValue) &&\n\t\t((!content1.compoundValue && !content2.compoundValue) ||\n\t\t\t((content1.compoundValue?.every((s1) => content2.compoundValue?.some((s2) => isServiceEqual(s1, s2))) || false) &&\n\t\t\t\t(content2?.compoundValue?.every((s2) => content1?.compoundValue?.some((s1) => isServiceEqual(s1, s2))) || false)))\n\t)\n}\n\nexport function isServiceContentEqual(content1: { [language: string]: Content }, content2: { [language: string]: Content }): boolean {\n\treturn Object.keys(content1).reduce((isEqual, lng) => isEqual && isContentEqual(content1[lng], content2[lng]), true as boolean)\n}\n\nexport function convertServicesToVersionedValues(versions: ServicesHistory, extractValueFromContent: (content: Content) => string): VersionedValue[] {\n\treturn Object.entries(versions).map(([key, value]) => ({\n\t\tid: key,\n\t\tversions: value.map((s) => ({\n\t\t\trevision: '' + s.service?.modified,\n\t\t\tmodified: s.service?.modified || 0,\n\t\t\tvalue: Object.entries(s.service?.content || {}).reduce((acc, [lng, content]) => ({ ...acc, [lng]: extractValueFromContent(content) }), {}),\n\t\t})),\n\t}))\n}\n\nexport function convertServicesToVersionedMetas(versions: ServicesHistory): VersionedMeta[] {\n\treturn Object.entries(versions).map(([key, value]) => ({\n\t\tid: key,\n\t\tmetas: value.map((s) => ({\n\t\t\trevision: '' + s.service?.modified,\n\t\t\tmodified: s.service?.modified || 0,\n\t\t\tvalueDate: s.service?.valueDate,\n\t\t\towner: s.service?.responsible ? { id: s.service?.responsible } : undefined,\n\t\t})),\n\t}))\n}\n\nexport function getVersions(formsValueContainer: FormValuesContainer, field: Field): ServicesHistory {\n\treturn (\n\t\tformsValueContainer?.getVersions((svc) =>\n\t\t\tfield.tags?.length ? field.tags.every((t) => (svc.tags || []).some((tt) => normalizeCode(tt).id === t)) : svc.label === field.label(),\n\t\t) || {}\n\t)\n}\n\nexport function setServices(ctc: Contact, newServices: Service[], modifiedServices: Service[]): Contact {\n\treturn new Contact({\n\t\t...ctc,\n\t\tservices: newServices.concat(ctc.services?.map((s) => modifiedServices.find((r) => r.id === s.id) || s) || []),\n\t})\n}\n"]}
1
+ {"version":3,"file":"icure-utils.js","sourceRoot":"","sources":["../../tmp/utils/icure-utils.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAkC;AAGlC,SAAgB,aAAa,CAAC,yBAAyC;IACtE,IAAI,yBAAyB,YAAY,IAAI,EAAE;QAC9C,OAAO,aAAa,CAAC,CAAC,yBAAyB,CAAC,CAAA;KAChD;IACD,IAAI,CAAC,yBAAyB,IAAI,yBAAyB,KAAK,CAAC,EAAE;QAClE,OAAO,SAAS,CAAA;KAChB;IACD,IAAI,yBAAyB,IAAI,QAAQ,IAAI,yBAAyB,GAAG,QAAQ,EAAE;QAClF,OAAO,IAAA,eAAK,EAAC,EAAE,GAAG,yBAAyB,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;KACpE;SAAM,IAAI,yBAAyB,IAAI,cAAc,EAAE;QACvD,OAAO,IAAA,eAAK,EAAC,EAAE,GAAG,yBAAyB,EAAE,gBAAgB,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;KAC1E;SAAM;QACN,OAAO,IAAI,IAAI,CAAC,yBAAyB,CAAC,CAAA;KAC1C;AACF,CAAC;AAdD,sCAcC;AAED,SAAgB,eAAe,CAAC,IAAU;IACzC,OAAO,QAAQ,CACd,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI;SAC1K,UAAU,EAAE;SACZ,QAAQ,EAAE;SACV,QAA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AC;YACpD,CAAC,CAAC,CAAA,MAAA,QAAQ,CAAC,aAAa,0CAAE,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,WAAC,OAAA,MAAA,QAAQ,CAAC,aAAa,0CAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA,EAAA,CAAC,KAAI,KAAK,CAAC;gBAC9G,CAAC,CAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,0CAAE,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,WAAC,OAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,0CAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA,EAAA,CAAC,KAAI,KAAK,CAAC,CAAC,CAAC,CACpH,CAAA;AACF,CAAC;AAxBD,wCAwBC;AAED,SAAgB,qBAAqB,CAAC,QAAyC,EAAE,QAAyC;IACzH,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,IAAe,CAAC,CAAA;AAChI,CAAC;AAFD,sDAEC","sourcesContent":["import parse from 'date-fns/parse'\nimport { CodeStub, Content, Service } from '@icure/api'\n\nexport function anyDateToDate(dateOrEpochOrLongCalendar?: Date | number): Date | undefined {\n\tif (dateOrEpochOrLongCalendar instanceof Date) {\n\t\treturn anyDateToDate(+dateOrEpochOrLongCalendar)\n\t}\n\tif (!dateOrEpochOrLongCalendar && dateOrEpochOrLongCalendar !== 0) {\n\t\treturn undefined\n\t}\n\tif (dateOrEpochOrLongCalendar >= 18000101 && dateOrEpochOrLongCalendar < 25400000) {\n\t\treturn parse('' + dateOrEpochOrLongCalendar, 'yyyyMMdd', new Date())\n\t} else if (dateOrEpochOrLongCalendar >= 18000101000000) {\n\t\treturn parse('' + dateOrEpochOrLongCalendar, 'yyyyMMddHHmmss', new Date())\n\t} else {\n\t\treturn new Date(dateOrEpochOrLongCalendar)\n\t}\n}\n\nexport function dateToFuzzyDate(date: Date): number {\n\treturn parseInt(\n\t\t`${date.getFullYear()}${(date.getMonth() + 1).toString().padStart(2, '0')}${date.getDate().toString().padStart(2, '0')}${date.getHours().toString().padStart(2, '0')}:${date\n\t\t\t.getMinutes()\n\t\t\t.toString()\n\t\t\t.padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`,\n\t)\n}\n\nexport function anyDateToFuzzyDate(dateOrEpochOrLongCalendar: Date | number) {\n\tconst date = anyDateToDate(dateOrEpochOrLongCalendar)\n\tif (!date) {\n\t\treturn undefined\n\t}\n\treturn dateToFuzzyDate(date)\n}\n\nexport function currentTime() {\n\tconst now = new Date()\n\treturn `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`\n}\n\nexport function currentDate() {\n\tconst now = new Date()\n\treturn `${now.getDate().toString().padStart(2, '0')}/${(now.getMonth() + 1).toString().padStart(2, '0')}/${now.getFullYear()}`\n}\n\nexport function currentDateTime() {\n\treturn `${currentDate()} ${currentTime()}`\n}\n\nexport function isCodeEqual(c1: CodeStub, c2: CodeStub): boolean {\n\tconst idParts1 = c1.id?.split('|')\n\tconst idParts2 = c2.id?.split('|')\n\tconst type1 = c1.type || idParts1?.[0]\n\tconst type2 = c2.type || idParts2?.[0]\n\tconst code1 = c1.code || idParts1?.[1]\n\tconst code2 = c2.code || idParts2?.[1]\n\tconst version1 = c1.version || idParts1?.[2]\n\tconst version2 = c2.version || idParts2?.[2]\n\treturn type1 === type2 && code1 === code2 && version1 === version2\n}\n\nexport function areCodesEqual(c1s: CodeStub[], c2s: CodeStub[]): boolean {\n\treturn c1s.every((c1) => c2s.some((c2) => isCodeEqual(c1, c2)) || false) && c2s.every((c2) => c1s.some((c1) => isCodeEqual(c1, c2)) || false)\n}\n\nexport function isServiceEqual(svc1: Service, svc2: Service): boolean {\n\treturn (\n\t\tsvc1.id === svc2.id && svc1.valueDate === svc2.valueDate && areCodesEqual(svc1.codes || [], svc2.codes || []) && isServiceContentEqual(svc1.content || {}, svc2.content || {})\n\t)\n}\n\nexport function isContentEqual(content1: Content | undefined, content2: Content | undefined): boolean {\n\tif (!content1 && !content2) {\n\t\treturn true\n\t}\n\tif (!content1 || !content2) {\n\t\treturn false\n\t}\n\treturn (\n\t\t((!content1.binaryValue && !content2.binaryValue) || content1.binaryValue === content2.binaryValue) &&\n\t\t(((content1.booleanValue === null || content1.booleanValue === undefined) && (content2.booleanValue === null || content2.booleanValue === undefined)) ||\n\t\t\tcontent1.booleanValue === content2.booleanValue) &&\n\t\t((!content1.documentId && !content2.documentId) || content1.documentId === content2.documentId) &&\n\t\t(((content1.fuzzyDateValue === null || content1.fuzzyDateValue === undefined) && (content2.fuzzyDateValue === null || content2.fuzzyDateValue === undefined)) ||\n\t\t\tcontent1.fuzzyDateValue === content2.fuzzyDateValue) &&\n\t\t((!content1.instantValue && !content2.instantValue) || content1.instantValue === content2.instantValue) &&\n\t\t((!content1.measureValue && !content2.measureValue) || content1.measureValue === content2.measureValue) &&\n\t\t((!content1.medicationValue && !content2.medicationValue) || content1.medicationValue === content2.medicationValue) &&\n\t\t((!content1.stringValue && !content2.stringValue) || content1.stringValue === content2.stringValue) &&\n\t\t(((content1.numberValue === null || content1.numberValue === undefined) && (content2.numberValue === null || content2.numberValue === undefined)) ||\n\t\t\tcontent1.numberValue === content2.numberValue) &&\n\t\t((!content1.compoundValue && !content2.compoundValue) ||\n\t\t\t((content1.compoundValue?.every((s1) => content2.compoundValue?.some((s2) => isServiceEqual(s1, s2))) || false) &&\n\t\t\t\t(content2?.compoundValue?.every((s2) => content1?.compoundValue?.some((s1) => isServiceEqual(s1, s2))) || false)))\n\t)\n}\n\nexport function isServiceContentEqual(content1: { [language: string]: Content }, content2: { [language: string]: Content }): boolean {\n\treturn Object.keys(content1).reduce((isEqual, lng) => isEqual && isContentEqual(content1[lng], content2[lng]), true as boolean)\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare const makeInterpreter: () => <T, S extends {
2
+ [key: string]: unknown;
3
+ [key: symbol]: unknown;
4
+ }>(formula: string, sandbox: S) => T | undefined;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeInterpreter = void 0;
4
+ const makeInterpreter = () => {
5
+ const sb = new Map();
6
+ const cs = new Map();
7
+ return (formula, sandbox) => {
8
+ function compileCode(src) {
9
+ if (cs.has(src)) {
10
+ return cs.get(src);
11
+ }
12
+ src = 'with (sandbox) {' + src + '}';
13
+ const code = new Function('sandbox', src);
14
+ const wrapper = function (sandbox) {
15
+ if (!sb.has(sandbox)) {
16
+ const sandboxProxy = new Proxy(sandbox, { has, get });
17
+ sb.set(sandbox, sandboxProxy);
18
+ }
19
+ const result = code(sb.get(sandbox));
20
+ return result;
21
+ };
22
+ cs.set(src, wrapper);
23
+ return wrapper;
24
+ }
25
+ function has() {
26
+ return true;
27
+ }
28
+ function get(target, key) {
29
+ if (key === Symbol.unscopables)
30
+ return undefined;
31
+ return target[key];
32
+ }
33
+ let compiledCode;
34
+ try {
35
+ compiledCode = compileCode(formula);
36
+ }
37
+ catch (e) {
38
+ console.info('Invalid Formula: ' + formula);
39
+ return undefined;
40
+ }
41
+ try {
42
+ const result = compiledCode(sandbox);
43
+ return result;
44
+ }
45
+ catch (e) {
46
+ console.info('Error while executing formula: ' + formula, e);
47
+ return undefined;
48
+ }
49
+ };
50
+ };
51
+ exports.makeInterpreter = makeInterpreter;
52
+ //# sourceMappingURL=interpreter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interpreter.js","sourceRoot":"","sources":["../../tmp/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ACH,YAAY,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;SACnC;QAAC,OAAO,CAAC,EAAE;YACX,OAAO,CAAC,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,CAAA;YAC3C,OAAO,SAAS,CAAA;SAChB;QACD,IAAI;YACH,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;YACpC,OAAO,MAAM,CAAA;SACb;QAAC,OAAO,CAAC,EAAE;YACX,OAAO,CAAC,IAAI,CAAC,iCAAiC,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;YAC5D,OAAO,SAAS,CAAA;SAChB;IACF,CAAC,CAAA;AACF,CAAC,CAAA;AAnDY,QAAA,eAAe,mBAmD3B","sourcesContent":["export const makeInterpreter = () => {\n\tconst sb = new Map()\n\tconst cs: Map<string, any> = new Map()\n\n\treturn <T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox: S): T | undefined => {\n\t\tfunction compileCode(src: string) {\n\t\t\tif (cs.has(src)) {\n\t\t\t\treturn cs.get(src)\n\t\t\t}\n\n\t\t\tsrc = 'with (sandbox) {' + src + '}'\n\t\t\tconst code = new Function('sandbox', src)\n\n\t\t\tconst wrapper = function (sandbox: S) {\n\t\t\t\tif (!sb.has(sandbox)) {\n\t\t\t\t\tconst sandboxProxy = new Proxy<S>(sandbox, { has, get })\n\t\t\t\t\tsb.set(sandbox, sandboxProxy)\n\t\t\t\t}\n\t\t\t\tconst result = code(sb.get(sandbox))\n\t\t\t\treturn result\n\t\t\t}\n\n\t\t\tcs.set(src, wrapper)\n\n\t\t\treturn wrapper\n\t\t}\n\n\t\tfunction has() {\n\t\t\treturn true\n\t\t}\n\n\t\tfunction get(target: S, key: string | symbol) {\n\t\t\tif (key === Symbol.unscopables) return undefined\n\t\t\treturn target[key]\n\t\t}\n\n\t\tlet compiledCode: any\n\t\ttry {\n\t\t\tcompiledCode = compileCode(formula)\n\t\t} catch (e) {\n\t\t\tconsole.info('Invalid Formula: ' + formula)\n\t\t\treturn undefined\n\t\t}\n\t\ttry {\n\t\t\tconst result = compiledCode(sandbox)\n\t\t\treturn result\n\t\t} catch (e) {\n\t\t\tconsole.info('Error while executing formula: ' + formula, e)\n\t\t\treturn undefined\n\t\t}\n\t}\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { TranslationTable } from '../components/model';
1
2
  export declare const languages: {
2
3
  en: string;
3
4
  fr: string;
@@ -5,4 +6,5 @@ export declare const languages: {
5
6
  nl: string;
6
7
  de: string;
7
8
  };
8
- export declare function languageName(iso: string): string;
9
+ export declare const languageName: (iso: string) => string;
10
+ export declare const defaultTranslationProvider: (translations: TranslationTable[]) => (language: string, text: string) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.languageName = exports.languages = void 0;
3
+ exports.defaultTranslationProvider = exports.languageName = exports.languages = void 0;
4
4
  exports.languages = {
5
5
  en: 'English',
6
6
  fr: 'French',
@@ -8,8 +8,8 @@ exports.languages = {
8
8
  nl: 'Dutch',
9
9
  de: 'German',
10
10
  };
11
- function languageName(iso) {
12
- return exports.languages[iso] || iso;
13
- }
11
+ const languageName = (iso) => exports.languages[iso] || iso;
14
12
  exports.languageName = languageName;
13
+ const defaultTranslationProvider = (translations) => (language, text) => { var _a, _b, _c; return (_c = (_b = (_a = translations === null || translations === void 0 ? void 0 : translations.find((tt) => tt.language === language)) === null || _a === void 0 ? void 0 : _a.translations) === null || _b === void 0 ? void 0 : _b[text]) !== null && _c !== void 0 ? _c : text; };
14
+ exports.defaultTranslationProvider = defaultTranslationProvider;
15
15
  //# sourceMappingURL=languages.js.map