@icure/form 1.1.0 → 1.1.10

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 (251) hide show
  1. package/.eslintrc +34 -0
  2. package/.prettierrc +8 -0
  3. package/.yarn/plugins/@yarnpkg/plugin-version.cjs +550 -0
  4. package/.yarn/versions/76a58acc.yml +0 -0
  5. package/.yarn/versions/c3ca09e7.yml +0 -0
  6. package/lib/components/common/index.d.ts +4 -0
  7. package/lib/components/common/index.js.map +1 -0
  8. package/lib/components/common/labelizedField.d.ts +8 -0
  9. package/{components/iqr-form/fields/multipleChoice.js → lib/components/common/labelizedField.js} +24 -24
  10. package/lib/components/common/labelizedField.js.map +1 -0
  11. package/lib/components/common/optionsField.d.ts +10 -0
  12. package/lib/components/common/optionsField.js +56 -0
  13. package/lib/components/common/optionsField.js.map +1 -0
  14. package/lib/components/common/stylizedField.d.ts +4 -0
  15. package/lib/components/common/stylizedField.js +801 -0
  16. package/lib/components/common/stylizedField.js.map +1 -0
  17. package/lib/components/common/translatedField.d.ts +8 -0
  18. package/{components/iqr-form/fields/timePicker.js → lib/components/common/translatedField.js} +22 -27
  19. package/lib/components/common/translatedField.js.map +1 -0
  20. package/lib/components/common/valuedField.d.ts +10 -0
  21. package/{components/iqr-form/fields/numberField.js → lib/components/common/valuedField.js} +18 -26
  22. package/lib/components/common/valuedField.js.map +1 -0
  23. package/lib/components/index.d.ts +6 -0
  24. package/{components → lib/components}/index.js +4 -0
  25. package/lib/components/index.js.map +1 -0
  26. package/lib/components/iqr-dropdown/index.d.ts +1 -0
  27. package/lib/components/iqr-dropdown/index.js +129 -0
  28. package/lib/components/iqr-dropdown/index.js.map +1 -0
  29. package/lib/components/iqr-form/fields/checkbox.d.ts +8 -0
  30. package/lib/components/iqr-form/fields/checkbox.js +50 -0
  31. package/lib/components/iqr-form/fields/checkbox.js.map +1 -0
  32. package/lib/components/iqr-form/fields/datePicker.d.ts +24 -0
  33. package/lib/components/iqr-form/fields/datePicker.js +101 -0
  34. package/lib/components/iqr-form/fields/datePicker.js.map +1 -0
  35. package/lib/components/iqr-form/fields/dateTimePicker.d.ts +24 -0
  36. package/lib/components/iqr-form/fields/dateTimePicker.js +100 -0
  37. package/lib/components/iqr-form/fields/dateTimePicker.js.map +1 -0
  38. package/lib/components/iqr-form/fields/dropdown.d.ts +10 -0
  39. package/lib/components/iqr-form/fields/dropdown.js +64 -0
  40. package/lib/components/iqr-form/fields/dropdown.js.map +1 -0
  41. package/lib/components/iqr-form/fields/label.d.ts +7 -0
  42. package/lib/components/iqr-form/fields/label.js +23 -0
  43. package/lib/components/iqr-form/fields/label.js.map +1 -0
  44. package/lib/components/iqr-form/fields/measureField.d.ts +25 -0
  45. package/lib/components/iqr-form/fields/measureField.js +107 -0
  46. package/lib/components/iqr-form/fields/measureField.js.map +1 -0
  47. package/lib/components/iqr-form/fields/multipleChoice.d.ts +15 -0
  48. package/lib/components/iqr-form/fields/multipleChoice.js +87 -0
  49. package/lib/components/iqr-form/fields/multipleChoice.js.map +1 -0
  50. package/lib/components/iqr-form/fields/numberField.d.ts +24 -0
  51. package/lib/components/iqr-form/fields/numberField.js +100 -0
  52. package/lib/components/iqr-form/fields/numberField.js.map +1 -0
  53. package/lib/components/iqr-form/fields/radioButton.d.ts +8 -0
  54. package/lib/components/iqr-form/fields/radioButton.js +50 -0
  55. package/lib/components/iqr-form/fields/radioButton.js.map +1 -0
  56. package/{components → lib/components}/iqr-form/fields/textfield.js +66 -37
  57. package/lib/components/iqr-form/fields/textfield.js.map +1 -0
  58. package/lib/components/iqr-form/fields/timePicker.d.ts +15 -0
  59. package/lib/components/iqr-form/fields/timePicker.js +90 -0
  60. package/lib/components/iqr-form/fields/timePicker.js.map +1 -0
  61. package/{components → lib/components}/iqr-form/index.d.ts +4 -0
  62. package/{components → lib/components}/iqr-form/index.js +40 -37
  63. package/lib/components/iqr-form/index.js.map +1 -0
  64. package/lib/components/iqr-form/model/index.d.ts +130 -0
  65. package/lib/components/iqr-form/model/index.js +164 -0
  66. package/lib/components/iqr-form/model/index.js.map +1 -0
  67. package/{components → lib/components}/iqr-form/renderer/cards.js +23 -9
  68. package/lib/components/iqr-form/renderer/cards.js.map +1 -0
  69. package/{components → lib/components}/iqr-form/renderer/form.d.ts +1 -0
  70. package/lib/components/iqr-form/renderer/form.js +240 -0
  71. package/lib/components/iqr-form/renderer/form.js.map +1 -0
  72. package/lib/components/iqr-form/renderer/index.d.ts +7 -0
  73. package/lib/components/iqr-form/renderer/index.js +3 -0
  74. package/lib/components/iqr-form/renderer/index.js.map +1 -0
  75. package/lib/components/iqr-form-loader/fieldsMapper.d.ts +3 -0
  76. package/lib/components/iqr-form-loader/fieldsMapper.js +16 -0
  77. package/lib/components/iqr-form-loader/fieldsMapper.js.map +1 -0
  78. package/lib/components/iqr-form-loader/fieldsValuesProviders.d.ts +38 -0
  79. package/lib/components/iqr-form-loader/fieldsValuesProviders.js +122 -0
  80. package/lib/components/iqr-form-loader/fieldsValuesProviders.js.map +1 -0
  81. package/{components → lib/components}/iqr-form-loader/formValuesContainer.d.ts +12 -4
  82. package/{components → lib/components}/iqr-form-loader/formValuesContainer.js +52 -3
  83. package/lib/components/iqr-form-loader/formValuesContainer.js.map +1 -0
  84. package/{components → lib/components}/iqr-form-loader/models.d.ts +1 -1
  85. package/lib/components/iqr-label/index.d.ts +1 -0
  86. package/lib/components/iqr-label/index.js +16 -0
  87. package/lib/components/iqr-label/index.js.map +1 -0
  88. package/lib/components/iqr-label/utils.d.ts +4 -0
  89. package/lib/components/iqr-label/utils.js +19 -0
  90. package/lib/components/iqr-label/utils.js.map +1 -0
  91. package/lib/components/iqr-radio-button-group/index.d.ts +1 -0
  92. package/lib/components/iqr-radio-button-group/index.js +807 -0
  93. package/lib/components/iqr-radio-button-group/index.js.map +1 -0
  94. package/{components → lib/components}/iqr-text-field/index.d.ts +10 -0
  95. package/{components → lib/components}/iqr-text-field/index.js +295 -191
  96. package/lib/components/iqr-text-field/index.js.map +1 -0
  97. package/{components → lib/components}/iqr-text-field/plugin/has-content-class-plugin.d.ts +1 -1
  98. package/{components → lib/components}/iqr-text-field/plugin/mask-plugin.js.map +1 -1
  99. package/{components → lib/components}/iqr-text-field/prosemirror-utils.d.ts +1 -1
  100. package/{components → lib/components}/iqr-text-field/prosemirror-utils.js.map +1 -1
  101. package/{components → lib/components}/iqr-text-field/schema/date-time-schema.d.ts +3 -3
  102. package/{components → lib/components}/iqr-text-field/schema/decimal-schema.d.ts +1 -1
  103. package/{components → lib/components}/iqr-text-field/schema/index.d.ts +1 -1
  104. package/{components → lib/components}/iqr-text-field/schema/markdown-schema.d.ts +3 -3
  105. package/{components → lib/components}/iqr-text-field/schema/measure-schema.d.ts +1 -1
  106. package/{components → lib/components}/iqr-text-field/schema/measure-schema.js +2 -1
  107. package/lib/components/iqr-text-field/schema/measure-schema.js.map +1 -0
  108. package/{components → lib/components}/iqr-text-field/schema/token-schema.d.ts +1 -1
  109. package/{components → lib/components}/iqr-text-field/styles/paths.d.ts +2 -0
  110. package/{components → lib/components}/iqr-text-field/styles/paths.js +7 -1
  111. package/lib/components/iqr-text-field/styles/paths.js.map +1 -0
  112. package/{components → lib/components}/iqr-text-field/suggestion-palette.d.ts +1 -1
  113. package/lib/package.json +32 -0
  114. package/{utils → lib/utils}/icure-utils.d.ts +3 -0
  115. package/{utils → lib/utils}/icure-utils.js +15 -1
  116. package/lib/utils/icure-utils.js.map +1 -0
  117. package/package.json +96 -19
  118. package/stats.json +1 -0
  119. package/tsconfig.tmp.json +39 -0
  120. package/components/index.d.ts +0 -2
  121. package/components/index.js.map +0 -1
  122. package/components/iqr-form/fields/datePicker.d.ts +0 -10
  123. package/components/iqr-form/fields/datePicker.js +0 -57
  124. package/components/iqr-form/fields/datePicker.js.map +0 -1
  125. package/components/iqr-form/fields/dateTimePicker.d.ts +0 -10
  126. package/components/iqr-form/fields/dateTimePicker.js +0 -49
  127. package/components/iqr-form/fields/dateTimePicker.js.map +0 -1
  128. package/components/iqr-form/fields/measureField.d.ts +0 -8
  129. package/components/iqr-form/fields/measureField.js +0 -44
  130. package/components/iqr-form/fields/measureField.js.map +0 -1
  131. package/components/iqr-form/fields/multipleChoice.d.ts +0 -8
  132. package/components/iqr-form/fields/multipleChoice.js.map +0 -1
  133. package/components/iqr-form/fields/numberField.d.ts +0 -8
  134. package/components/iqr-form/fields/numberField.js.map +0 -1
  135. package/components/iqr-form/fields/textfield.js.map +0 -1
  136. package/components/iqr-form/fields/timePicker.d.ts +0 -10
  137. package/components/iqr-form/fields/timePicker.js.map +0 -1
  138. package/components/iqr-form/index.js.map +0 -1
  139. package/components/iqr-form/model/index.d.ts +0 -96
  140. package/components/iqr-form/model/index.js +0 -120
  141. package/components/iqr-form/model/index.js.map +0 -1
  142. package/components/iqr-form/renderer/cards.js.map +0 -1
  143. package/components/iqr-form/renderer/form.js +0 -93
  144. package/components/iqr-form/renderer/form.js.map +0 -1
  145. package/components/iqr-form/renderer/index.d.ts +0 -6
  146. package/components/iqr-form/renderer/index.js.map +0 -1
  147. package/components/iqr-form-loader/fieldsValuesProviders.d.ts +0 -13
  148. package/components/iqr-form-loader/fieldsValuesProviders.js +0 -49
  149. package/components/iqr-form-loader/fieldsValuesProviders.js.map +0 -1
  150. package/components/iqr-form-loader/formValuesContainer.js.map +0 -1
  151. package/components/iqr-text-field/index.js.map +0 -1
  152. package/components/iqr-text-field/schema/measure-schema.js.map +0 -1
  153. package/components/iqr-text-field/styles/paths.js.map +0 -1
  154. package/utils/icure-utils.js.map +0 -1
  155. /package/{components/iqr-form/renderer → lib/components/common}/index.js +0 -0
  156. /package/{components → lib/components}/iqr-form/fields/textfield.d.ts +0 -0
  157. /package/{components → lib/components}/iqr-form/legacy/Content.d.ts +0 -0
  158. /package/{components → lib/components}/iqr-form/legacy/Content.js +0 -0
  159. /package/{components → lib/components}/iqr-form/legacy/Content.js.map +0 -0
  160. /package/{components → lib/components}/iqr-form/legacy/Data.d.ts +0 -0
  161. /package/{components → lib/components}/iqr-form/legacy/Data.js +0 -0
  162. /package/{components → lib/components}/iqr-form/legacy/Data.js.map +0 -0
  163. /package/{components → lib/components}/iqr-form/legacy/Editor.d.ts +0 -0
  164. /package/{components → lib/components}/iqr-form/legacy/Editor.js +0 -0
  165. /package/{components → lib/components}/iqr-form/legacy/Editor.js.map +0 -0
  166. /package/{components → lib/components}/iqr-form/legacy/FormColumn.d.ts +0 -0
  167. /package/{components → lib/components}/iqr-form/legacy/FormColumn.js +0 -0
  168. /package/{components → lib/components}/iqr-form/legacy/FormColumn.js.map +0 -0
  169. /package/{components → lib/components}/iqr-form/legacy/FormDataOption.d.ts +0 -0
  170. /package/{components → lib/components}/iqr-form/legacy/FormDataOption.js +0 -0
  171. /package/{components → lib/components}/iqr-form/legacy/FormDataOption.js.map +0 -0
  172. /package/{components → lib/components}/iqr-form/legacy/FormLayout.d.ts +0 -0
  173. /package/{components → lib/components}/iqr-form/legacy/FormLayout.js +0 -0
  174. /package/{components → lib/components}/iqr-form/legacy/FormLayout.js.map +0 -0
  175. /package/{components → lib/components}/iqr-form/legacy/FormLayoutData.d.ts +0 -0
  176. /package/{components → lib/components}/iqr-form/legacy/FormLayoutData.js +0 -0
  177. /package/{components → lib/components}/iqr-form/legacy/FormLayoutData.js.map +0 -0
  178. /package/{components → lib/components}/iqr-form/legacy/FormPlanning.d.ts +0 -0
  179. /package/{components → lib/components}/iqr-form/legacy/FormPlanning.js +0 -0
  180. /package/{components → lib/components}/iqr-form/legacy/FormPlanning.js.map +0 -0
  181. /package/{components → lib/components}/iqr-form/legacy/FormSection.d.ts +0 -0
  182. /package/{components → lib/components}/iqr-form/legacy/FormSection.js +0 -0
  183. /package/{components → lib/components}/iqr-form/legacy/FormSection.js.map +0 -0
  184. /package/{components → lib/components}/iqr-form/legacy/Formula.d.ts +0 -0
  185. /package/{components → lib/components}/iqr-form/legacy/Formula.js +0 -0
  186. /package/{components → lib/components}/iqr-form/legacy/Formula.js.map +0 -0
  187. /package/{components → lib/components}/iqr-form/legacy/GuiCode.d.ts +0 -0
  188. /package/{components → lib/components}/iqr-form/legacy/GuiCode.js +0 -0
  189. /package/{components → lib/components}/iqr-form/legacy/GuiCode.js.map +0 -0
  190. /package/{components → lib/components}/iqr-form/legacy/GuiCodeType.d.ts +0 -0
  191. /package/{components → lib/components}/iqr-form/legacy/GuiCodeType.js +0 -0
  192. /package/{components → lib/components}/iqr-form/legacy/GuiCodeType.js.map +0 -0
  193. /package/{components → lib/components}/iqr-form/legacy/Suggest.d.ts +0 -0
  194. /package/{components → lib/components}/iqr-form/legacy/Suggest.js +0 -0
  195. /package/{components → lib/components}/iqr-form/legacy/Suggest.js.map +0 -0
  196. /package/{components → lib/components}/iqr-form/legacy/Tag.d.ts +0 -0
  197. /package/{components → lib/components}/iqr-form/legacy/Tag.js +0 -0
  198. /package/{components → lib/components}/iqr-form/legacy/Tag.js.map +0 -0
  199. /package/{components → lib/components}/iqr-form/renderer/cards.d.ts +0 -0
  200. /package/{components → lib/components}/iqr-form/utils.d.ts +0 -0
  201. /package/{components → lib/components}/iqr-form/utils.js +0 -0
  202. /package/{components → lib/components}/iqr-form/utils.js.map +0 -0
  203. /package/{components → lib/components}/iqr-form-loader/index.d.ts +0 -0
  204. /package/{components → lib/components}/iqr-form-loader/index.js +0 -0
  205. /package/{components → lib/components}/iqr-form-loader/index.js.map +0 -0
  206. /package/{components → lib/components}/iqr-form-loader/models.js +0 -0
  207. /package/{components → lib/components}/iqr-form-loader/models.js.map +0 -0
  208. /package/{components → lib/components}/iqr-text-field/plugin/caret-fix-plugin.d.ts +0 -0
  209. /package/{components → lib/components}/iqr-text-field/plugin/caret-fix-plugin.js +0 -0
  210. /package/{components → lib/components}/iqr-text-field/plugin/caret-fix-plugin.js.map +0 -0
  211. /package/{components → lib/components}/iqr-text-field/plugin/has-content-class-plugin.js +0 -0
  212. /package/{components → lib/components}/iqr-text-field/plugin/has-content-class-plugin.js.map +0 -0
  213. /package/{components → lib/components}/iqr-text-field/plugin/mask-plugin.d.ts +0 -0
  214. /package/{components → lib/components}/iqr-text-field/plugin/mask-plugin.js +0 -0
  215. /package/{components → lib/components}/iqr-text-field/plugin/regexp-plugin.d.ts +0 -0
  216. /package/{components → lib/components}/iqr-text-field/plugin/regexp-plugin.js +0 -0
  217. /package/{components → lib/components}/iqr-text-field/plugin/regexp-plugin.js.map +0 -0
  218. /package/{components → lib/components}/iqr-text-field/prosemirror-commands.d.ts +0 -0
  219. /package/{components → lib/components}/iqr-text-field/prosemirror-commands.js +0 -0
  220. /package/{components → lib/components}/iqr-text-field/prosemirror-commands.js.map +0 -0
  221. /package/{components → lib/components}/iqr-text-field/prosemirror-utils.js +0 -0
  222. /package/{components → lib/components}/iqr-text-field/schema/common-marks.d.ts +0 -0
  223. /package/{components → lib/components}/iqr-text-field/schema/common-marks.js +0 -0
  224. /package/{components → lib/components}/iqr-text-field/schema/common-marks.js.map +0 -0
  225. /package/{components → lib/components}/iqr-text-field/schema/date-time-schema.js +0 -0
  226. /package/{components → lib/components}/iqr-text-field/schema/date-time-schema.js.map +0 -0
  227. /package/{components → lib/components}/iqr-text-field/schema/decimal-schema.js +0 -0
  228. /package/{components → lib/components}/iqr-text-field/schema/decimal-schema.js.map +0 -0
  229. /package/{components → lib/components}/iqr-text-field/schema/index.js +0 -0
  230. /package/{components → lib/components}/iqr-text-field/schema/index.js.map +0 -0
  231. /package/{components → lib/components}/iqr-text-field/schema/markdown-schema.js +0 -0
  232. /package/{components → lib/components}/iqr-text-field/schema/markdown-schema.js.map +0 -0
  233. /package/{components → lib/components}/iqr-text-field/schema/token-schema.js +0 -0
  234. /package/{components → lib/components}/iqr-text-field/schema/token-schema.js.map +0 -0
  235. /package/{components → lib/components}/iqr-text-field/schema/utils.d.ts +0 -0
  236. /package/{components → lib/components}/iqr-text-field/schema/utils.js +0 -0
  237. /package/{components → lib/components}/iqr-text-field/schema/utils.js.map +0 -0
  238. /package/{components → lib/components}/iqr-text-field/selection-companion.d.ts +0 -0
  239. /package/{components → lib/components}/iqr-text-field/selection-companion.js +0 -0
  240. /package/{components → lib/components}/iqr-text-field/selection-companion.js.map +0 -0
  241. /package/{components → lib/components}/iqr-text-field/suggestion-palette.js +0 -0
  242. /package/{components → lib/components}/iqr-text-field/suggestion-palette.js.map +0 -0
  243. /package/{index.d.ts → lib/index.d.ts} +0 -0
  244. /package/{index.js → lib/index.js} +0 -0
  245. /package/{index.js.map → lib/index.js.map} +0 -0
  246. /package/{utils → lib/utils}/languages.d.ts +0 -0
  247. /package/{utils → lib/utils}/languages.js +0 -0
  248. /package/{utils → lib/utils}/languages.js.map +0 -0
  249. /package/{utils → lib/utils}/no-lodash.d.ts +0 -0
  250. /package/{utils → lib/utils}/no-lodash.js +0 -0
  251. /package/{utils → lib/utils}/no-lodash.js.map +0 -0
@@ -21,6 +21,8 @@ function withLabel(label) {
21
21
  exports.withLabel = withLabel;
22
22
  class ICureFormValuesContainer {
23
23
  constructor(currentContact, contact, contactsHistory, serviceFactory) {
24
+ this.sandboxProxies = new WeakMap();
25
+ this.codeSnippets = new Map();
24
26
  if (!contactsHistory.includes(contact) && contact !== currentContact) {
25
27
  throw new Error('Illegal argument, the history must contain the contact');
26
28
  }
@@ -61,7 +63,7 @@ class ICureFormValuesContainer {
61
63
  setResponsible(serviceId, responsible) {
62
64
  return this.setServiceProperty(serviceId, responsible, (s) => s.author, (s) => new api_1.Service(Object.assign(Object.assign({}, s), { responsible })));
63
65
  }
64
- setValue(serviceId, language, content, codes) {
66
+ setValue(label, serviceId, language, content, codes, tags) {
65
67
  const swcs = this.getServicesInHistory((s) => s.id === serviceId);
66
68
  if (swcs.length) {
67
69
  const previousContent = swcs[0].service.content;
@@ -69,14 +71,14 @@ class ICureFormValuesContainer {
69
71
  // Omit end of life
70
72
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
71
73
  const _a = Object.assign(Object.assign({}, swcs[0].service), { content: Object.assign(Object.assign({}, previousContent), { [language]: content }), codes: codes, modified: +new Date() }), { endOfLife } = _a, modifiedServiceValues = __rest(_a, ["endOfLife"]);
72
- return this.copy((0, icure_utils_1.setServices)(this.currentContact, [], [new api_1.Service(modifiedServiceValues)]));
74
+ return this.copy((0, icure_utils_1.setServices)(Object.assign(Object.assign({}, this.currentContact), { services: this.currentContact.services }), [], [new api_1.Service(modifiedServiceValues)]));
73
75
  }
74
76
  else {
75
77
  return this;
76
78
  }
77
79
  }
78
80
  else {
79
- return this.copy((0, icure_utils_1.setServices)(this.currentContact, [this.serviceFactory(language, content)], []));
81
+ return this.copy((0, icure_utils_1.setServices)(this.currentContact, [this.serviceFactory(label, serviceId, language, content, codes, tags)], []));
80
82
  }
81
83
  }
82
84
  delete(serviceId) {
@@ -92,6 +94,53 @@ class ICureFormValuesContainer {
92
94
  return this;
93
95
  }
94
96
  }
97
+ compute(formula, sandbox = new Proxy({}, {
98
+ has: (target, key) => { var _a; return Object.keys((_a = this.getVersions((s) => s.label === key)) !== null && _a !== void 0 ? _a : {}).length > 0; },
99
+ get: (target, key) => Object.values(this.getVersions((s) => s.label === key)),
100
+ })) {
101
+ const sb = this.sandboxProxies;
102
+ const cs = this.codeSnippets;
103
+ function compileCode(src) {
104
+ if (cs.has(src)) {
105
+ return cs.get(src);
106
+ }
107
+ src = 'with (sandbox) {' + src + '}';
108
+ const code = new Function('sandbox', src);
109
+ const result = function (sandbox) {
110
+ if (!sb.has(sandbox)) {
111
+ const sandboxProxy = new Proxy(sandbox, { has, get });
112
+ sb.set(sandbox, sandboxProxy);
113
+ }
114
+ return code(sb.get(sandbox));
115
+ };
116
+ cs.set(src, result);
117
+ return result;
118
+ }
119
+ function has() {
120
+ return true;
121
+ }
122
+ function get(target, key) {
123
+ if (key === Symbol.unscopables)
124
+ return undefined;
125
+ return target[key];
126
+ }
127
+ let compiledCode;
128
+ try {
129
+ compiledCode = compileCode(formula);
130
+ }
131
+ catch (e) {
132
+ console.info('Invalid Formula: ' + formula);
133
+ return undefined;
134
+ }
135
+ try {
136
+ const result = compiledCode(sandbox);
137
+ return result;
138
+ }
139
+ catch (e) {
140
+ console.info('Error while executing formula: ' + formula, e);
141
+ return undefined;
142
+ }
143
+ }
95
144
  /** returns all services in history that match a selector
96
145
  *
97
146
  * @param selector a function used to select the services of interest, usually : withLabel("someLabel")
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formValuesContainer.js","sourceRoot":"","sources":["../../../tmp/components/iqr-form-loader/formValuesContainer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oCAAgE;AAChE,qDAAyD;AACzD,yDAAuF;AAGvF,SAAgB,SAAS,CAAC,KAAa;IACtC,OAAO,CAAC,GAAY,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAA;AAC7C,CAAC;AAFD,8BAEC;AAaD,MAAa,wBAAwB;IASpC,YACC,cAAuB,EACvB,OAAgB,EAChB,eAA0B,EAC1B,cAAsI;QATvI,mBAAc,GAAG,IAAI,OAAO,EAAE,CAAA;QAC9B,iBAAY,GAAG,IAAI,GAAG,EAAe,CAAA;QAUpC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,KAAK,cAAc,EAAE;YACrE,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;SACzE;QACD,IAAI,eAAe,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YAC7C,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;SACpF;QACD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,eAAe,GAAG,IAAA,oBAAQ,EAAC,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;QACnE,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;IACrC,CAAC;IAED,IAAI,CAAC,cAAuB;QAC3B,OAAO,IAAI,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI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AED,SAAS,GAAG;YACX,OAAO,IAAI,CAAA;QACZ,CAAC;QAED,SAAS,GAAG,CAAC,MAAS,EAAE,GAAoB;YAC3C,IAAI,GAAG,KAAK,MAAM,CAAC,WAAW;gBAAE,OAAO,SAAS,CAAA;YAChD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC;QAED,IAAI,YAAiB,CAAA;QACrB,IAAI;YACH,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;IAED;;;;OAIG;IACK,oBAAoB,CAAC,QAAmC;QAC/D,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,OAAO,CAChE,CAAC,GAAG,EAAE,EAAE;;YACP,OAAA,CAAA,MAAA,MAAA,GAAG,CAAC,QAAQ,0CAAE,MAAM,CAAC,QAAQ,CAAC,0CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC3C,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;aACZ,CAAC,CAAC,KAAI,EAAE,CAAA;SAAA,CACV,CAAA;IACF,CAAC;CACD;AAlMD,4DAkMC","sourcesContent":["import { CodeStub, Contact, Content, Service } from '@icure/api'\nimport { groupBy, sortedBy } from '../../utils/no-lodash'\nimport { fuzzyDate, isServiceContentEqual, setServices } from '../../utils/icure-utils'\nimport { ServicesHistory, ServiceWithContact } from './models'\n\nexport function withLabel(label: string): (svc: Service) => boolean {\n\treturn (svc: Service) => svc.label === label\n}\n\nexport interface FormValuesContainer {\n\tcopy(currentContact: Contact): FormValuesContainer\n\tgetVersions(selector: (svc: Service) => boolean): ServicesHistory\n\tsetValue(label: string, serviceId: string, language: string, content: Content, codes: CodeStub[], tags: CodeStub[]): FormValuesContainer\n\tsetValueDate(serviceId: string, fuzzyDate: number | null): FormValuesContainer\n\tsetAuthor(serviceId: string, author: string | null): FormValuesContainer\n\tsetResponsible(serviceId: string, responsible: string | null): FormValuesContainer\n\tdelete(serviceId: string): FormValuesContainer\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox?: S): T | undefined\n}\n\nexport class ICureFormValuesContainer implements FormValuesContainer {\n\tcurrentContact: Contact //The contact of the day, used to record modifications\n\tcontact: Contact //The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day\n\tcontactsHistory: Contact[] //Must be sorted (most recent first), does not include currentContent but must include contact (except if contact is currentContact)\n\tsandboxProxies = new WeakMap()\n\tcodeSnippets = new Map<string, any>()\n\n\tserviceFactory: (label: string, serviceId: string, language: string, content: Content, codes: CodeStub[], tags: CodeStub[]) => Service\n\n\tconstructor(\n\t\tcurrentContact: Contact,\n\t\tcontact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId: string, language: string, content: Content, codes: CodeStub[], tags: CodeStub[]) => Service,\n\t) {\n\t\tif (!contactsHistory.includes(contact) && contact !== currentContact) {\n\t\t\tthrow new Error('Illegal argument, the history must contain the contact')\n\t\t}\n\t\tif (contactsHistory.includes(currentContact)) {\n\t\t\tthrow new Error('Illegal argument, the history must not contain the currentContact')\n\t\t}\n\t\tthis.currentContact = currentContact\n\t\tthis.contact = contact\n\t\tthis.contactsHistory = sortedBy(contactsHistory, 'created', 'desc')\n\t\tthis.serviceFactory = serviceFactory\n\t}\n\n\tcopy(currentContact: Contact): ICureFormValuesContainer {\n\t\treturn new ICureFormValuesContainer(currentContact, this.contact, this.contactsHistory, this.serviceFactory)\n\t}\n\n\tgetVersions(selector: (svc: Service) => boolean): ServicesHistory {\n\t\treturn groupBy(\n\t\t\tthis.getServicesInHistory(selector).filter((swc) => +(fuzzyDate(swc.contact.created) || 0) <= +(fuzzyDate(this.contact.created) || 0)),\n\t\t\t(swc) => swc.service.id || '',\n\t\t)\n\t}\n\n\tprivate setServiceProperty<K>(serviceId: string, newValue: K, getter: (svc: Service) => K, setter: (svc: Service, value: K) => Service): FormValuesContainer {\n\t\tconst swcs = this.getServicesInHistory((s) => s.id === serviceId)\n\t\tif (swcs.length) {\n\t\t\tif (newValue !== getter(swcs[0].service)) {\n\t\t\t\treturn this.copy(setServices(this.currentContact, [], [setter(swcs[0].service, newValue)]))\n\t\t\t} else {\n\t\t\t\treturn this\n\t\t\t}\n\t\t} else {\n\t\t\treturn this\n\t\t}\n\t}\n\n\tsetValueDate(serviceId: string, fuzzyDate: number | null): FormValuesContainer {\n\t\treturn this.setServiceProperty(\n\t\t\tserviceId,\n\t\t\tfuzzyDate,\n\t\t\t(s) => s.valueDate,\n\t\t\t(s) => new Service({ ...s, valueDate: fuzzyDate }),\n\t\t)\n\t}\n\n\tsetAuthor(serviceId: string, author: string | null): FormValuesContainer {\n\t\treturn this.setServiceProperty(\n\t\t\tserviceId,\n\t\t\tauthor,\n\t\t\t(s) => s.author,\n\t\t\t(s) => new Service({ ...s, author }),\n\t\t)\n\t}\n\n\tsetResponsible(serviceId: string, responsible: string | null): FormValuesContainer {\n\t\treturn this.setServiceProperty(\n\t\t\tserviceId,\n\t\t\tresponsible,\n\t\t\t(s) => s.author,\n\t\t\t(s) => new Service({ ...s, responsible }),\n\t\t)\n\t}\n\n\tsetValue(label: string, serviceId: string, language: string, content: Content, codes: CodeStub[], tags: CodeStub[]): FormValuesContainer {\n\t\tconst swcs = this.getServicesInHistory((s) => s.id === serviceId)\n\t\tif (swcs.length) {\n\t\t\tconst previousContent = swcs[0].service.content\n\n\t\t\tif (!previousContent || !isServiceContentEqual({ [language]: content }, previousContent)) {\n\t\t\t\t// Omit end of life\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\t\tconst { endOfLife, ...modifiedServiceValues } = {\n\t\t\t\t\t...swcs[0].service,\n\t\t\t\t\tcontent: { ...previousContent, [language]: content },\n\t\t\t\t\tcodes: codes,\n\t\t\t\t\tmodified: +new Date(),\n\t\t\t\t}\n\t\t\t\treturn this.copy(setServices({ ...this.currentContact, services: this.currentContact.services }, [], [new Service(modifiedServiceValues)]))\n\t\t\t} else {\n\t\t\t\treturn this\n\t\t\t}\n\t\t} else {\n\t\t\treturn this.copy(setServices(this.currentContact, [this.serviceFactory(label, serviceId, language, content, codes, tags)], []))\n\t\t}\n\t}\n\n\tdelete(serviceId: string): FormValuesContainer {\n\t\tconst swcs = this.getServicesInHistory((s) => s.id === serviceId)\n\t\tif (swcs.length) {\n\t\t\t//Omit end of life\n\t\t\tconst now = +new Date()\n\t\t\treturn this.copy(\n\t\t\t\tsetServices(\n\t\t\t\t\tthis.currentContact,\n\t\t\t\t\t[],\n\t\t\t\t\t[\n\t\t\t\t\t\tnew Service({\n\t\t\t\t\t\t\t...swcs[0].service,\n\t\t\t\t\t\t\tcontent: {},\n\t\t\t\t\t\t\tmodified: now,\n\t\t\t\t\t\t\tendOfLife: now,\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} else {\n\t\t\treturn this\n\t\t}\n\t}\n\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(\n\t\tformula: string,\n\t\tsandbox: S = new Proxy({} as S, {\n\t\t\thas: (target: S, key: string | symbol) => Object.keys(this.getVersions((s) => s.label === key) ?? {}).length > 0,\n\t\t\tget: (target: S, key: string | symbol) => Object.values(this.getVersions((s) => s.label === key)),\n\t\t}),\n\t): T | undefined {\n\t\tconst sb = this.sandboxProxies\n\t\tconst cs = this.codeSnippets\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 result = 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\treturn code(sb.get(sandbox))\n\t\t\t}\n\n\t\t\tcs.set(src, result)\n\n\t\t\treturn result\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\t/** returns all services in history that match a selector\n\t *\n\t * @param selector a function used to select the services of interest, usually : withLabel(\"someLabel\")\n\t * @private\n\t */\n\tprivate getServicesInHistory(selector: (svc: Service) => boolean): ServiceWithContact[] {\n\t\treturn [this.currentContact].concat(this.contactsHistory).flatMap(\n\t\t\t(ctc) =>\n\t\t\t\tctc.services?.filter(selector)?.map((s) => ({\n\t\t\t\t\tservice: s,\n\t\t\t\t\tcontact: ctc,\n\t\t\t\t})) || [],\n\t\t)\n\t}\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Contact, Form, Service } from '@icure/api';
2
2
  import { FormValuesContainer } from './formValuesContainer';
3
- export declare type ServicesHistory = {
3
+ export type ServicesHistory = {
4
4
  [id: string]: ServiceWithContact[];
5
5
  };
6
6
  export interface FormHierarchy {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lit_1 = require("lit");
4
+ const utils_1 = require("./utils");
5
+ const labelizedField_1 = require("../common/labelizedField");
6
+ class IqrLabel extends labelizedField_1.LabelizedField {
7
+ constructor() {
8
+ super();
9
+ }
10
+ render() {
11
+ var _a, _b;
12
+ return (0, lit_1.html) `${(0, utils_1.generateLabel)((_a = this.label) !== null && _a !== void 0 ? _a : '', (_b = this.labelPosition) !== null && _b !== void 0 ? _b : 'float')}`;
13
+ }
14
+ }
15
+ customElements.define('iqr-label', IqrLabel);
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../tmp/components/iqr-label/index.ts"],"names":[],"mappings":";;AAAA,6BAA0B;AAC1B,mCAAuC;AACvC,6DAAyD;AAEzD,MAAM,QAAS,SAAQ,+BAAc;IACpC;QACC,KAAK,EAAE,CAAA;IACR,CAAC;IAED,MAAM;;QACL,OAAO,IAAA,UAAI,EAAA,GAAG,IAAA,qBAAa,EAAC,MAAA,IAAI,CAAC,KAAK,mCAAI,EAAE,EAAE,MAAA,IAAI,CAAC,aAAa,mCAAI,OAAO,CAAC,EAAE,CAAA;IAC/E,CAAC;CACD;AACD,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import { html } from 'lit'\nimport { generateLabel } from './utils'\nimport { LabelizedField } from '../common/labelizedField'\n\nclass IqrLabel extends LabelizedField {\n\tconstructor() {\n\t\tsuper()\n\t}\n\n\trender() {\n\t\treturn html`${generateLabel(this.label ?? '', this.labelPosition ?? 'float')}`\n\t}\n}\ncustomElements.define('iqr-label', IqrLabel)\n"]}
@@ -0,0 +1,4 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { Labels } from '../iqr-text-field';
3
+ export declare function generateLabels(labels: Labels, translationProvider?: (text: string) => string): TemplateResult[];
4
+ export declare function generateLabel(label: string, labelPosition: string, translationProvider?: (text: string) => string): TemplateResult;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateLabel = exports.generateLabels = void 0;
4
+ const lit_1 = require("lit");
5
+ function generateLabels(labels, translationProvider = (text) => text) {
6
+ return Object.keys(labels).map((position) => generateLabel(labels[position], position, translationProvider));
7
+ }
8
+ exports.generateLabels = generateLabels;
9
+ function generateLabel(label, labelPosition, translationProvider = (text) => text) {
10
+ switch (labelPosition) {
11
+ case 'right':
12
+ case 'left':
13
+ return (0, lit_1.html) ` <label class="iqr-label side above ${labelPosition}"><span>${translationProvider(label)}</span></iqr-label> `;
14
+ default:
15
+ return (0, lit_1.html) ` <label class="iqr-label ${labelPosition}"><span>${translationProvider(label)}</span></iqr-label> `;
16
+ }
17
+ }
18
+ exports.generateLabel = generateLabel;
19
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../tmp/components/iqr-label/utils.ts"],"names":[],"mappings":";;;AAAA,6BAA0C;AAG1C,SAAgB,cAAc,CAAC,MAAc,EAAE,sBAAgD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI;IAC5G,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAC7G,CAAC;AAFD,wCAEC;AAED,SAAgB,aAAa,CAAC,KAAa,EAAE,aAAqB,EAAE,sBAAgD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI;IACjI,QAAQ,aAAa,EAAE;QACtB,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACV,OAAO,IAAA,UAAI,EAAA,uCAAuC,aAAa,WAAW,mBAAmB,CAAC,KAAK,CAAC,sBAAsB,CAAA;QAC3H;YACC,OAAO,IAAA,UAAI,EAAA,4BAA4B,aAAa,WAAW,mBAAmB,CAAC,KAAK,CAAC,sBAAsB,CAAA;KAChH;AACF,CAAC;AARD,sCAQC","sourcesContent":["import { html, TemplateResult } from 'lit'\nimport { Labels } from '../iqr-text-field'\n\nexport function generateLabels(labels: Labels, translationProvider: (text: string) => string = (text) => text): TemplateResult[] {\n\treturn Object.keys(labels).map((position) => generateLabel(labels[position], position, translationProvider))\n}\n\nexport function generateLabel(label: string, labelPosition: string, translationProvider: (text: string) => string = (text) => text): TemplateResult {\n\tswitch (labelPosition) {\n\t\tcase 'right':\n\t\tcase 'left':\n\t\t\treturn html` <label class=\"iqr-label side above ${labelPosition}\"><span>${translationProvider(label)}</span></iqr-label> `\n\t\tdefault:\n\t\t\treturn html` <label class=\"iqr-label ${labelPosition}\"><span>${translationProvider(label)}</span></iqr-label> `\n\t}\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};