@finos/legend-query-builder 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (329) hide show
  1. package/lib/components/QueryBuilder.d.ts.map +1 -1
  2. package/lib/components/QueryBuilder.js +1 -1
  3. package/lib/components/QueryBuilder.js.map +1 -1
  4. package/lib/components/QueryBuilderComponentTestUtils.d.ts.map +1 -1
  5. package/lib/components/QueryBuilderComponentTestUtils.js +1 -3
  6. package/lib/components/QueryBuilderComponentTestUtils.js.map +1 -1
  7. package/lib/components/QueryBuilderDiffPanel.js +1 -2
  8. package/lib/components/QueryBuilderDiffPanel.js.map +1 -1
  9. package/lib/components/QueryBuilderParametersPanel.d.ts +1 -1
  10. package/lib/components/QueryBuilderParametersPanel.d.ts.map +1 -1
  11. package/lib/components/QueryBuilderParametersPanel.js +10 -7
  12. package/lib/components/QueryBuilderParametersPanel.js.map +1 -1
  13. package/lib/components/QueryBuilderPropertyExpressionEditor.d.ts.map +1 -1
  14. package/lib/components/QueryBuilderPropertyExpressionEditor.js +11 -8
  15. package/lib/components/QueryBuilderPropertyExpressionEditor.js.map +1 -1
  16. package/lib/components/QueryBuilderResultPanel.d.ts.map +1 -1
  17. package/lib/components/QueryBuilderResultPanel.js +6 -4
  18. package/lib/components/QueryBuilderResultPanel.js.map +1 -1
  19. package/lib/components/QueryBuilderTextEditor.js +2 -2
  20. package/lib/components/QueryBuilderTextEditor.js.map +1 -1
  21. package/lib/components/QueryBuilder_TestID.d.ts +1 -0
  22. package/lib/components/QueryBuilder_TestID.d.ts.map +1 -1
  23. package/lib/components/QueryBuilder_TestID.js +1 -0
  24. package/lib/components/QueryBuilder_TestID.js.map +1 -1
  25. package/lib/components/explorer/QueryBuilderExplorerPanel.js +2 -2
  26. package/lib/components/explorer/QueryBuilderExplorerPanel.js.map +1 -1
  27. package/lib/components/explorer/QueryBuilderMilestoningEditor.d.ts.map +1 -1
  28. package/lib/components/explorer/QueryBuilderMilestoningEditor.js +5 -4
  29. package/lib/components/explorer/QueryBuilderMilestoningEditor.js.map +1 -1
  30. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.d.ts.map +1 -1
  31. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js +4 -2
  32. package/lib/components/fetch-structure/QueryBuilderPostFilterPanel.js.map +1 -1
  33. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js +1 -1
  34. package/lib/components/fetch-structure/QueryBuilderResultModifierPanel.js.map +1 -1
  35. package/lib/components/filter/QueryBuilderFilterPanel.d.ts.map +1 -1
  36. package/lib/components/filter/QueryBuilderFilterPanel.js +7 -4
  37. package/lib/components/filter/QueryBuilderFilterPanel.js.map +1 -1
  38. package/lib/components/shared/BasicValueSpecificationEditor.d.ts +53 -0
  39. package/lib/components/shared/BasicValueSpecificationEditor.d.ts.map +1 -0
  40. package/lib/components/shared/BasicValueSpecificationEditor.js +323 -0
  41. package/lib/components/shared/BasicValueSpecificationEditor.js.map +1 -0
  42. package/lib/components/shared/CustomDatePicker.d.ts +39 -0
  43. package/lib/components/shared/CustomDatePicker.d.ts.map +1 -0
  44. package/lib/components/shared/CustomDatePicker.js +622 -0
  45. package/lib/components/shared/CustomDatePicker.js.map +1 -0
  46. package/lib/components/shared/LambdaEditor.d.ts +92 -0
  47. package/lib/components/shared/LambdaEditor.d.ts.map +1 -0
  48. package/lib/components/shared/LambdaEditor.js +432 -0
  49. package/lib/components/shared/LambdaEditor.js.map +1 -0
  50. package/lib/{graphManager/protocol/pure/v1/V1_QueryBuilder_PropertyExpressionTypeInferenceBuilder.d.ts → components/shared/LambdaParameterValuesEditor.d.ts} +11 -3
  51. package/lib/components/shared/LambdaParameterValuesEditor.d.ts.map +1 -0
  52. package/lib/components/shared/LambdaParameterValuesEditor.js +52 -0
  53. package/lib/components/shared/LambdaParameterValuesEditor.js.map +1 -0
  54. package/lib/components/shared/QueryBuilderLambdaEditor.d.ts +1 -1
  55. package/lib/components/shared/QueryBuilderLambdaEditor.d.ts.map +1 -1
  56. package/lib/components/shared/QueryBuilderLambdaEditor.js +3 -2
  57. package/lib/components/shared/QueryBuilderLambdaEditor.js.map +1 -1
  58. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.d.ts.map +1 -1
  59. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js +1 -2
  60. package/lib/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.js.map +1 -1
  61. package/lib/graphManager/protocol/pure/v1/{V1_QueryBuilder_FunctionExpressionBuilder.d.ts → V1_QueryValueSpecificationBuilderHelper.d.ts} +3 -2
  62. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.d.ts.map +1 -0
  63. package/lib/graphManager/protocol/pure/v1/{V1_QueryBuilder_FunctionExpressionBuilder.js → V1_QueryValueSpecificationBuilderHelper.js} +7 -6
  64. package/lib/graphManager/protocol/pure/v1/V1_QueryValueSpecificationBuilderHelper.js.map +1 -0
  65. package/lib/index.css +2 -2
  66. package/lib/index.css.map +1 -1
  67. package/lib/index.d.ts +7 -0
  68. package/lib/index.d.ts.map +1 -1
  69. package/lib/index.js +8 -0
  70. package/lib/index.js.map +1 -1
  71. package/lib/package.json +7 -10
  72. package/lib/stores/QueryBuilderMilestoningState.d.ts.map +1 -1
  73. package/lib/stores/QueryBuilderMilestoningState.js +6 -6
  74. package/lib/stores/QueryBuilderMilestoningState.js.map +1 -1
  75. package/lib/stores/QueryBuilderParametersState.d.ts +1 -1
  76. package/lib/stores/QueryBuilderParametersState.d.ts.map +1 -1
  77. package/lib/stores/QueryBuilderParametersState.js +1 -1
  78. package/lib/stores/QueryBuilderParametersState.js.map +1 -1
  79. package/lib/stores/QueryBuilderPropertyEditorState.d.ts.map +1 -1
  80. package/lib/stores/QueryBuilderPropertyEditorState.js +35 -38
  81. package/lib/stores/QueryBuilderPropertyEditorState.js.map +1 -1
  82. package/lib/stores/QueryBuilderResultState.d.ts.map +1 -1
  83. package/lib/stores/QueryBuilderResultState.js +2 -1
  84. package/lib/stores/QueryBuilderResultState.js.map +1 -1
  85. package/lib/stores/QueryBuilderState.d.ts +2 -2
  86. package/lib/stores/QueryBuilderState.d.ts.map +1 -1
  87. package/lib/stores/QueryBuilderState.js +7 -6
  88. package/lib/stores/QueryBuilderState.js.map +1 -1
  89. package/lib/stores/QueryBuilderStateBuilder.js +1 -1
  90. package/lib/stores/QueryBuilderStateBuilder.js.map +1 -1
  91. package/lib/stores/QueryBuilderTextEditorState.d.ts +1 -1
  92. package/lib/stores/QueryBuilderTextEditorState.d.ts.map +1 -1
  93. package/lib/stores/QueryBuilderTextEditorState.js +2 -1
  94. package/lib/stores/QueryBuilderTextEditorState.js.map +1 -1
  95. package/lib/stores/QueryBuilderValueSpecificationBuilder.d.ts.map +1 -1
  96. package/lib/stores/QueryBuilderValueSpecificationBuilder.js +2 -2
  97. package/lib/stores/QueryBuilderValueSpecificationBuilder.js.map +1 -1
  98. package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.d.ts.map +1 -1
  99. package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.js +23 -20
  100. package/lib/stores/QueryBuilderValueSpecificationBuilderHelper.js.map +1 -1
  101. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts +1 -1
  102. package/lib/stores/QueryBuilderValueSpecificationHelper.d.ts.map +1 -1
  103. package/lib/stores/QueryBuilderValueSpecificationHelper.js +10 -9
  104. package/lib/stores/QueryBuilderValueSpecificationHelper.js.map +1 -1
  105. package/lib/stores/explorer/QueryBuilderExplorerState.d.ts.map +1 -1
  106. package/lib/stores/explorer/QueryBuilderExplorerState.js +4 -3
  107. package/lib/stores/explorer/QueryBuilderExplorerState.js.map +1 -1
  108. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js +1 -1
  109. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.js.map +1 -1
  110. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js +1 -1
  111. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js.map +1 -1
  112. package/lib/stores/fetch-structure/graph-fetch/{QueryBuilderGraphFetchValueSpecificationBuilder.d.ts → QueryBuilderGraphFetchTreeValueSpecificationBuilder.d.ts} +1 -1
  113. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.d.ts.map +1 -0
  114. package/lib/stores/fetch-structure/graph-fetch/{QueryBuilderGraphFetchValueSpecificationBuilder.js → QueryBuilderGraphFetchTreeValueSpecificationBuilder.js} +1 -1
  115. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeValueSpecificationBuilder.js.map +1 -0
  116. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionColumnState.d.ts +1 -1
  117. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionColumnState.d.ts.map +1 -1
  118. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionColumnState.js +3 -3
  119. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionColumnState.js.map +1 -1
  120. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionState.js +1 -1
  121. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionState.js.map +1 -1
  122. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionStateBuilder.js +4 -4
  123. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionStateBuilder.js.map +1 -1
  124. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionValueSpecificationBuilder.d.ts.map +1 -1
  125. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionValueSpecificationBuilder.js +13 -13
  126. package/lib/stores/fetch-structure/projection/QueryBuilderProjectionValueSpecificationBuilder.js.map +1 -1
  127. package/lib/stores/fetch-structure/projection/aggregation/operators/{QueryBuilderAggregateOperatorHelper.d.ts → QueryBuilderAggregateOperatorValueSpecificationBuilder.d.ts} +2 -2
  128. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperatorValueSpecificationBuilder.d.ts.map +1 -0
  129. package/lib/stores/fetch-structure/projection/aggregation/operators/{QueryBuilderAggregateOperatorHelper.js → QueryBuilderAggregateOperatorValueSpecificationBuilder.js} +2 -2
  130. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperatorValueSpecificationBuilder.js.map +1 -0
  131. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Average.js +3 -3
  132. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Average.js.map +1 -1
  133. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Count.js +3 -3
  134. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Count.js.map +1 -1
  135. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Distinct.js +3 -3
  136. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Distinct.js.map +1 -1
  137. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.js +1 -1
  138. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.js.map +1 -1
  139. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_JoinString.js +1 -1
  140. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_JoinString.js.map +1 -1
  141. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Max.js +5 -5
  142. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Max.js.map +1 -1
  143. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Min.js +5 -5
  144. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Min.js.map +1 -1
  145. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_StdDev_Population.js +3 -3
  146. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_StdDev_Population.js.map +1 -1
  147. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_StdDev_Sample.js +3 -3
  148. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_StdDev_Sample.js.map +1 -1
  149. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Sum.js +3 -3
  150. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Sum.js.map +1 -1
  151. package/lib/stores/fetch-structure/projection/post-filter/QueryBuilderPostFilterStateBuilder.js +2 -2
  152. package/lib/stores/fetch-structure/projection/post-filter/QueryBuilderPostFilterStateBuilder.js.map +1 -1
  153. package/lib/stores/fetch-structure/projection/post-filter/QueryBuilderPostFilterValueSpecificationBuilder.d.ts +1 -1
  154. package/lib/stores/fetch-structure/projection/post-filter/QueryBuilderPostFilterValueSpecificationBuilder.d.ts.map +1 -1
  155. package/lib/stores/fetch-structure/projection/post-filter/QueryBuilderPostFilterValueSpecificationBuilder.js +10 -10
  156. package/lib/stores/fetch-structure/projection/post-filter/QueryBuilderPostFilterValueSpecificationBuilder.js.map +1 -1
  157. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorHelper.d.ts +1 -4
  158. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorHelper.d.ts.map +1 -1
  159. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorHelper.js +3 -46
  160. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorHelper.js.map +1 -1
  161. package/{src/graphManager/protocol/pure/v1/V1_QueryBuilder_PropertyExpressionTypeInferenceBuilder.ts → lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts} +5 -13
  162. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.d.ts.map +1 -0
  163. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js +61 -0
  164. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.js.map +1 -0
  165. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_Contain.d.ts.map +1 -1
  166. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js +5 -4
  167. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_Contain.js.map +1 -1
  168. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.d.ts.map +1 -1
  169. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js +5 -4
  170. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.js.map +1 -1
  171. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_Equal.d.ts.map +1 -1
  172. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js +10 -8
  173. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_Equal.js.map +1 -1
  174. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.d.ts.map +1 -1
  175. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js +5 -4
  176. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.js.map +1 -1
  177. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js +3 -3
  178. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.js.map +1 -1
  179. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_In.js +3 -3
  180. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_In.js.map +1 -1
  181. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js +1 -1
  182. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.js.map +1 -1
  183. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.d.ts.map +1 -1
  184. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js +5 -4
  185. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.js.map +1 -1
  186. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js +3 -3
  187. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.js.map +1 -1
  188. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.d.ts.map +1 -1
  189. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js +5 -4
  190. package/lib/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.js.map +1 -1
  191. package/lib/stores/filter/operators/{QueryBuilderFilterOperatorHelper.d.ts → QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts} +1 -1
  192. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.d.ts.map +1 -0
  193. package/lib/stores/filter/operators/{QueryBuilderFilterOperatorHelper.js → QueryBuilderFilterOperatorValueSpecificationBuilder.js} +11 -13
  194. package/lib/stores/filter/operators/QueryBuilderFilterOperatorValueSpecificationBuilder.js.map +1 -0
  195. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.d.ts.map +1 -1
  196. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js +7 -6
  197. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Contain.js.map +1 -1
  198. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.d.ts.map +1 -1
  199. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js +7 -6
  200. package/lib/stores/filter/operators/QueryBuilderFilterOperator_EndWith.js.map +1 -1
  201. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.d.ts.map +1 -1
  202. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js +13 -11
  203. package/lib/stores/filter/operators/QueryBuilderFilterOperator_Equal.js.map +1 -1
  204. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.d.ts.map +1 -1
  205. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js +8 -7
  206. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.js.map +1 -1
  207. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.d.ts.map +1 -1
  208. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js +8 -7
  209. package/lib/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.js.map +1 -1
  210. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js +6 -6
  211. package/lib/stores/filter/operators/QueryBuilderFilterOperator_In.js.map +1 -1
  212. package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js +4 -4
  213. package/lib/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.js.map +1 -1
  214. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.d.ts.map +1 -1
  215. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js +8 -7
  216. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThan.js.map +1 -1
  217. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.d.ts.map +1 -1
  218. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js +8 -7
  219. package/lib/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.js.map +1 -1
  220. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.d.ts.map +1 -1
  221. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js +7 -6
  222. package/lib/stores/filter/operators/QueryBuilderFilterOperator_StartWith.js.map +1 -1
  223. package/lib/stores/shared/LambdaEditorState.d.ts +40 -0
  224. package/lib/stores/shared/LambdaEditorState.d.ts.map +1 -0
  225. package/lib/stores/shared/LambdaEditorState.js +81 -0
  226. package/lib/stores/shared/LambdaEditorState.js.map +1 -0
  227. package/lib/stores/shared/LambdaParameterState.d.ts +62 -0
  228. package/lib/stores/shared/LambdaParameterState.d.ts.map +1 -0
  229. package/lib/stores/shared/LambdaParameterState.js +157 -0
  230. package/lib/stores/shared/LambdaParameterState.js.map +1 -0
  231. package/lib/{graphManager/protocol/pure/v1/V1_QueryBuilder_PropertyExpressionTypeInferenceBuilder.js → stores/shared/ValueSpecificationEditorHelper.d.ts} +5 -3
  232. package/lib/stores/shared/ValueSpecificationEditorHelper.d.ts.map +1 -0
  233. package/lib/stores/shared/ValueSpecificationEditorHelper.js +77 -0
  234. package/lib/stores/shared/ValueSpecificationEditorHelper.js.map +1 -0
  235. package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts +33 -0
  236. package/lib/stores/shared/ValueSpecificationModifierHelper.d.ts.map +1 -0
  237. package/lib/stores/shared/ValueSpecificationModifierHelper.js +71 -0
  238. package/lib/stores/shared/ValueSpecificationModifierHelper.js.map +1 -0
  239. package/package.json +14 -17
  240. package/src/components/QueryBuilder.tsx +4 -1
  241. package/src/components/QueryBuilderComponentTestUtils.tsx +2 -2
  242. package/src/components/QueryBuilderDiffPanel.tsx +1 -1
  243. package/src/components/QueryBuilderParametersPanel.tsx +9 -9
  244. package/src/components/QueryBuilderPropertyExpressionEditor.tsx +15 -12
  245. package/src/components/QueryBuilderResultPanel.tsx +8 -6
  246. package/src/components/QueryBuilderTextEditor.tsx +2 -2
  247. package/src/components/QueryBuilder_TestID.ts +2 -0
  248. package/src/components/explorer/QueryBuilderExplorerPanel.tsx +2 -2
  249. package/src/components/explorer/QueryBuilderMilestoningEditor.tsx +5 -3
  250. package/src/components/fetch-structure/QueryBuilderPostFilterPanel.tsx +6 -4
  251. package/src/components/fetch-structure/QueryBuilderResultModifierPanel.tsx +1 -1
  252. package/src/components/filter/QueryBuilderFilterPanel.tsx +9 -6
  253. package/src/components/shared/BasicValueSpecificationEditor.tsx +837 -0
  254. package/src/components/shared/CustomDatePicker.tsx +1363 -0
  255. package/src/components/shared/LambdaEditor.tsx +858 -0
  256. package/src/components/shared/LambdaParameterValuesEditor.tsx +121 -0
  257. package/src/components/shared/QueryBuilderLambdaEditor.tsx +5 -5
  258. package/src/graphManager/protocol/pure/QueryBuilder_PureProtocolProcessorPlugin.ts +2 -2
  259. package/src/graphManager/protocol/pure/v1/{V1_QueryBuilder_FunctionExpressionBuilder.ts → V1_QueryValueSpecificationBuilderHelper.ts} +12 -5
  260. package/src/index.ts +11 -0
  261. package/src/stores/QueryBuilderMilestoningState.ts +7 -7
  262. package/src/stores/QueryBuilderParametersState.ts +4 -4
  263. package/src/stores/QueryBuilderPropertyEditorState.ts +49 -56
  264. package/src/stores/QueryBuilderResultState.ts +2 -4
  265. package/src/stores/QueryBuilderState.ts +7 -6
  266. package/src/stores/QueryBuilderStateBuilder.ts +1 -1
  267. package/src/stores/QueryBuilderTextEditorState.ts +2 -1
  268. package/src/stores/QueryBuilderValueSpecificationBuilder.ts +5 -2
  269. package/src/stores/QueryBuilderValueSpecificationBuilderHelper.ts +30 -42
  270. package/src/stores/QueryBuilderValueSpecificationHelper.ts +13 -8
  271. package/src/stores/explorer/QueryBuilderExplorerState.ts +12 -2
  272. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeState.ts +1 -1
  273. package/src/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.ts +3 -3
  274. package/src/stores/fetch-structure/graph-fetch/{QueryBuilderGraphFetchValueSpecificationBuilder.ts → QueryBuilderGraphFetchTreeValueSpecificationBuilder.ts} +0 -1
  275. package/src/stores/fetch-structure/projection/QueryBuilderProjectionColumnState.ts +3 -3
  276. package/src/stores/fetch-structure/projection/QueryBuilderProjectionState.ts +1 -1
  277. package/src/stores/fetch-structure/projection/QueryBuilderProjectionStateBuilder.ts +4 -4
  278. package/src/stores/fetch-structure/projection/QueryBuilderProjectionValueSpecificationBuilder.ts +16 -19
  279. package/src/stores/fetch-structure/projection/aggregation/operators/{QueryBuilderAggregateOperatorHelper.ts → QueryBuilderAggregateOperatorValueSpecificationBuilder.ts} +1 -1
  280. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Average.ts +3 -3
  281. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Count.ts +3 -3
  282. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Distinct.ts +3 -3
  283. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_DistinctCount.ts +1 -1
  284. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_JoinString.ts +1 -1
  285. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Max.ts +5 -5
  286. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Min.ts +5 -5
  287. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_StdDev_Population.ts +3 -3
  288. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_StdDev_Sample.ts +3 -3
  289. package/src/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperator_Sum.ts +3 -3
  290. package/src/stores/fetch-structure/projection/post-filter/QueryBuilderPostFilterStateBuilder.ts +2 -2
  291. package/src/stores/fetch-structure/projection/post-filter/QueryBuilderPostFilterValueSpecificationBuilder.ts +12 -10
  292. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorHelper.ts +2 -86
  293. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperatorValueSpecificationBuilder.ts +104 -0
  294. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_Contain.ts +3 -3
  295. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_EndWith.ts +3 -3
  296. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_Equal.ts +8 -7
  297. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThan.ts +4 -4
  298. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_GreaterThanEqual.ts +3 -3
  299. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_In.ts +2 -2
  300. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_IsEmpty.ts +1 -1
  301. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_LessThan.ts +4 -4
  302. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_LessThanEqual.ts +3 -3
  303. package/src/stores/fetch-structure/projection/post-filter/operators/QueryBuilderPostFilterOperator_StartWith.ts +3 -3
  304. package/src/stores/filter/operators/{QueryBuilderFilterOperatorHelper.ts → QueryBuilderFilterOperatorValueSpecificationBuilder.ts} +10 -11
  305. package/src/stores/filter/operators/QueryBuilderFilterOperator_Contain.ts +5 -5
  306. package/src/stores/filter/operators/QueryBuilderFilterOperator_EndWith.ts +5 -5
  307. package/src/stores/filter/operators/QueryBuilderFilterOperator_Equal.ts +11 -10
  308. package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThan.ts +7 -7
  309. package/src/stores/filter/operators/QueryBuilderFilterOperator_GreaterThanEqual.ts +7 -7
  310. package/src/stores/filter/operators/QueryBuilderFilterOperator_In.ts +5 -5
  311. package/src/stores/filter/operators/QueryBuilderFilterOperator_IsEmpty.ts +3 -3
  312. package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThan.ts +7 -7
  313. package/src/stores/filter/operators/QueryBuilderFilterOperator_LessThanEqual.ts +7 -7
  314. package/src/stores/filter/operators/QueryBuilderFilterOperator_StartWith.ts +5 -5
  315. package/src/stores/shared/LambdaEditorState.ts +118 -0
  316. package/src/stores/shared/LambdaParameterState.ts +259 -0
  317. package/src/stores/shared/ValueSpecificationEditorHelper.ts +143 -0
  318. package/src/stores/shared/ValueSpecificationModifierHelper.ts +177 -0
  319. package/tsconfig.json +14 -7
  320. package/lib/graphManager/protocol/pure/v1/V1_QueryBuilder_FunctionExpressionBuilder.d.ts.map +0 -1
  321. package/lib/graphManager/protocol/pure/v1/V1_QueryBuilder_FunctionExpressionBuilder.js.map +0 -1
  322. package/lib/graphManager/protocol/pure/v1/V1_QueryBuilder_PropertyExpressionTypeInferenceBuilder.d.ts.map +0 -1
  323. package/lib/graphManager/protocol/pure/v1/V1_QueryBuilder_PropertyExpressionTypeInferenceBuilder.js.map +0 -1
  324. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchValueSpecificationBuilder.d.ts.map +0 -1
  325. package/lib/stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchValueSpecificationBuilder.js.map +0 -1
  326. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperatorHelper.d.ts.map +0 -1
  327. package/lib/stores/fetch-structure/projection/aggregation/operators/QueryBuilderAggregateOperatorHelper.js.map +0 -1
  328. package/lib/stores/filter/operators/QueryBuilderFilterOperatorHelper.d.ts.map +0 -1
  329. package/lib/stores/filter/operators/QueryBuilderFilterOperatorHelper.js.map +0 -1
@@ -0,0 +1,1363 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ type SelectComponent,
19
+ BasePopover,
20
+ BaseRadioGroup,
21
+ CustomSelectorInput,
22
+ } from '@finos/legend-art';
23
+ import {
24
+ type PureModel,
25
+ type Enum,
26
+ type Type,
27
+ type ValueSpecification,
28
+ PRIMITIVE_TYPE,
29
+ SimpleFunctionExpression,
30
+ InstanceValue,
31
+ GenericType,
32
+ PrimitiveInstanceValue,
33
+ GenericTypeExplicitReference,
34
+ EnumValueExplicitReference,
35
+ EnumValueInstanceValue,
36
+ matchFunctionName,
37
+ TYPICAL_MULTIPLICITY_TYPE,
38
+ SUPPORTED_FUNCTIONS,
39
+ DAY_OF_WEEK,
40
+ DURATION_UNIT,
41
+ type ObserverContext,
42
+ } from '@finos/legend-graph';
43
+ import {
44
+ guaranteeNonNullable,
45
+ parseNumber,
46
+ returnUndefOnError,
47
+ UnsupportedOperationError,
48
+ } from '@finos/legend-shared';
49
+ import { useEffect, useRef, useState } from 'react';
50
+ import { buildPrimitiveInstanceValue } from '../../stores/shared/ValueSpecificationEditorHelper.js';
51
+ import {
52
+ functionExpression_addParameterValue,
53
+ instanceValue_setValue,
54
+ instanceValue_setValues,
55
+ valueSpecification_setGenericType,
56
+ } from '../../stores/shared/ValueSpecificationModifierHelper.js';
57
+
58
+ enum CUSTOM_DATE_PICKER_OPTION {
59
+ ABSOLUTE_DATE = 'Absolute Date',
60
+ ABSOLUTE_TIME = 'Absolute Time',
61
+ TODAY = 'Today',
62
+ NOW = 'Now',
63
+ YESTERDAY = 'Yesterday',
64
+ ONE_YEAR_AGO = 'One Year Ago',
65
+ ONE_MONTH_AGO = 'One Month Ago',
66
+ ONE_WEEK_AGO = 'One Week Ago',
67
+ CUSTOM_DATE = 'Custom Date',
68
+ PREVIOUS_DAY_OF_WEEK = 'Previous ... of Week',
69
+ FIRST_DAY_OF = 'First day of...',
70
+ LATEST_DATE = 'Latest Date',
71
+ }
72
+
73
+ enum CUSTOM_DATE_OPTION_UNIT {
74
+ DAYS = 'Day(s)',
75
+ WEEKS = 'Week(s)',
76
+ MONTHS = 'Month(s)',
77
+ YEARS = 'Year(s)',
78
+ }
79
+
80
+ enum CUSTOM_DATE_FIRST_DAY_OF_UNIT {
81
+ WEEK = 'Week',
82
+ MONTH = 'Month',
83
+ QUARTER = 'Quarter',
84
+ YEAR = 'Year',
85
+ }
86
+
87
+ enum CUSTOM_DATE_DAY_OF_WEEK {
88
+ MONDAY = 'Monday',
89
+ TUESDAY = 'Tuesday',
90
+ WENDNESDAY = 'Wednesday',
91
+ THURSDAY = 'Thursday',
92
+ FRIDAY = 'Friday',
93
+ SATURDAY = 'Saturday',
94
+ SUNDAY = 'Sunday',
95
+ }
96
+
97
+ enum CUSTOM_DATE_OPTION_DIRECTION {
98
+ BEFORE = 'Before',
99
+ AFTER = 'After',
100
+ }
101
+
102
+ enum CUSTOM_DATE_OPTION_REFERENCE_MOMENT {
103
+ TODAY = 'Today',
104
+ NOW = 'Now',
105
+ FIRST_DAY_OF_YEAR = 'Start of Year',
106
+ FIRST_DAY_OF_QUARTER = 'Start of Quarter',
107
+ FIRST_DAY_OF_MONTH = 'Start of Month',
108
+ FIRST_DAY_OF_WEEK = 'Start of Week',
109
+ }
110
+
111
+ /**
112
+ * DatePickerOption is the base class being used to display and generate the corresponding pure date function.
113
+ */
114
+ class DatePickerOption {
115
+ /**
116
+ * label is the text that shows up in the valueSpecification box.
117
+ */
118
+ label: string;
119
+ /**
120
+ * value is the selected date option in date-dropdown.
121
+ */
122
+ value: string;
123
+
124
+ constructor(label: string, value: string) {
125
+ this.label = label;
126
+ this.value = value;
127
+ }
128
+ }
129
+
130
+ class CustomDateOption extends DatePickerOption {
131
+ /**
132
+ * duration is the amount of time span that will be adjusted.
133
+ */
134
+ duration: number;
135
+ /**
136
+ * unit represents the time duration unit, e.g. year, week, etc.
137
+ */
138
+ unit: CUSTOM_DATE_OPTION_UNIT | undefined;
139
+ /**
140
+ * direction means the direction in which time adjustment will go to.
141
+ */
142
+ direction: CUSTOM_DATE_OPTION_DIRECTION | undefined;
143
+ /**
144
+ * referenceMoment is the date which adjustment starts from.
145
+ */
146
+ referenceMoment: CUSTOM_DATE_OPTION_REFERENCE_MOMENT | undefined;
147
+
148
+ constructor(
149
+ label: string,
150
+ value: string,
151
+ duration: number,
152
+ unit: CUSTOM_DATE_OPTION_UNIT | undefined,
153
+ direction: CUSTOM_DATE_OPTION_DIRECTION | undefined,
154
+ referenceMoment: CUSTOM_DATE_OPTION_REFERENCE_MOMENT | undefined,
155
+ ) {
156
+ super(label, value);
157
+ this.duration = duration;
158
+ this.unit = unit;
159
+ this.direction = direction;
160
+ this.referenceMoment = referenceMoment;
161
+ }
162
+
163
+ generateDisplayLabel(): string {
164
+ return [
165
+ this.duration,
166
+ this.unit,
167
+ this.direction,
168
+ this.referenceMoment,
169
+ ].join(' ');
170
+ }
171
+
172
+ updateLabel(): void {
173
+ this.label = this.generateDisplayLabel();
174
+ }
175
+ }
176
+
177
+ class CustomFirstDayOfOption extends DatePickerOption {
178
+ /**
179
+ * unit: time unit, e.g. Week, Month, etc.
180
+ */
181
+ unit: CUSTOM_DATE_FIRST_DAY_OF_UNIT | undefined;
182
+
183
+ constructor(label: string, unit: CUSTOM_DATE_FIRST_DAY_OF_UNIT | undefined) {
184
+ super(label, CUSTOM_DATE_PICKER_OPTION.FIRST_DAY_OF);
185
+ this.unit = unit;
186
+ }
187
+ }
188
+
189
+ class CustomPreviousDayOfWeekOption extends DatePickerOption {
190
+ /**
191
+ * day: which day in the week will be selected.
192
+ */
193
+ day: CUSTOM_DATE_DAY_OF_WEEK;
194
+
195
+ constructor(label: string, day: CUSTOM_DATE_DAY_OF_WEEK) {
196
+ super(label, CUSTOM_DATE_PICKER_OPTION.PREVIOUS_DAY_OF_WEEK);
197
+ this.day = day;
198
+ }
199
+ }
200
+
201
+ const reservedCustomDateOptions: CustomDateOption[] = [
202
+ new CustomDateOption(
203
+ 'Yesterday',
204
+ CUSTOM_DATE_PICKER_OPTION.YESTERDAY,
205
+ 1,
206
+ CUSTOM_DATE_OPTION_UNIT.DAYS,
207
+ CUSTOM_DATE_OPTION_DIRECTION.BEFORE,
208
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.TODAY,
209
+ ),
210
+ new CustomDateOption(
211
+ 'One Week Ago',
212
+ CUSTOM_DATE_PICKER_OPTION.ONE_WEEK_AGO,
213
+ 1,
214
+ CUSTOM_DATE_OPTION_UNIT.WEEKS,
215
+ CUSTOM_DATE_OPTION_DIRECTION.BEFORE,
216
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.TODAY,
217
+ ),
218
+ new CustomDateOption(
219
+ 'One Month Ago',
220
+ CUSTOM_DATE_PICKER_OPTION.ONE_MONTH_AGO,
221
+ 1,
222
+ CUSTOM_DATE_OPTION_UNIT.MONTHS,
223
+ CUSTOM_DATE_OPTION_DIRECTION.BEFORE,
224
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.TODAY,
225
+ ),
226
+ new CustomDateOption(
227
+ 'One Year Ago',
228
+ CUSTOM_DATE_PICKER_OPTION.ONE_YEAR_AGO,
229
+ 1,
230
+ CUSTOM_DATE_OPTION_UNIT.YEARS,
231
+ CUSTOM_DATE_OPTION_DIRECTION.BEFORE,
232
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.TODAY,
233
+ ),
234
+ ];
235
+
236
+ /**
237
+ * Generate pure date functions based on the DatePickerOption.
238
+ */
239
+ const buildPureDateFunctionExpression = (
240
+ datePickerOption: DatePickerOption,
241
+ graph: PureModel,
242
+ observerContext: ObserverContext,
243
+ ): SimpleFunctionExpression => {
244
+ const multiplicityOne = graph.getTypicalMultiplicity(
245
+ TYPICAL_MULTIPLICITY_TYPE.ONE,
246
+ );
247
+ const strictDate = graph.getPrimitiveType(PRIMITIVE_TYPE.STRICTDATE);
248
+ const date = graph.getPrimitiveType(PRIMITIVE_TYPE.DATE);
249
+ const dateTime = graph.getPrimitiveType(PRIMITIVE_TYPE.DATETIME);
250
+ if (datePickerOption instanceof CustomPreviousDayOfWeekOption) {
251
+ const previousFridaySFE = new SimpleFunctionExpression(
252
+ SUPPORTED_FUNCTIONS.PREVIOUS_DAY_OF_WEEK,
253
+ multiplicityOne,
254
+ );
255
+ valueSpecification_setGenericType(
256
+ previousFridaySFE,
257
+ GenericTypeExplicitReference.create(new GenericType(date)),
258
+ );
259
+ const dayOfWeekEnumIntanceValue = new EnumValueInstanceValue(
260
+ GenericTypeExplicitReference.create(
261
+ new GenericType(graph.getType(DAY_OF_WEEK)),
262
+ ),
263
+ multiplicityOne,
264
+ );
265
+ instanceValue_setValues(dayOfWeekEnumIntanceValue, [
266
+ ...dayOfWeekEnumIntanceValue.values,
267
+ EnumValueExplicitReference.create(
268
+ guaranteeNonNullable(
269
+ graph
270
+ .getEnumeration(DAY_OF_WEEK)
271
+ .values.filter((e) => e.name === datePickerOption.day)[0],
272
+ ),
273
+ ),
274
+ ]);
275
+ functionExpression_addParameterValue(
276
+ previousFridaySFE,
277
+ dayOfWeekEnumIntanceValue,
278
+ observerContext,
279
+ );
280
+ return previousFridaySFE;
281
+ } else if (datePickerOption instanceof CustomFirstDayOfOption) {
282
+ switch (datePickerOption.unit) {
283
+ case CUSTOM_DATE_FIRST_DAY_OF_UNIT.YEAR: {
284
+ const firstDayOfYearSFE = new SimpleFunctionExpression(
285
+ SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR,
286
+ multiplicityOne,
287
+ );
288
+ valueSpecification_setGenericType(
289
+ firstDayOfYearSFE,
290
+ GenericTypeExplicitReference.create(new GenericType(date)),
291
+ );
292
+ return firstDayOfYearSFE;
293
+ }
294
+ case CUSTOM_DATE_FIRST_DAY_OF_UNIT.QUARTER: {
295
+ const firstDayOfQuarterSFE = new SimpleFunctionExpression(
296
+ SUPPORTED_FUNCTIONS.FIRST_DAY_OF_QUARTER,
297
+ multiplicityOne,
298
+ );
299
+ valueSpecification_setGenericType(
300
+ firstDayOfQuarterSFE,
301
+ GenericTypeExplicitReference.create(new GenericType(strictDate)),
302
+ );
303
+ return firstDayOfQuarterSFE;
304
+ }
305
+ case CUSTOM_DATE_FIRST_DAY_OF_UNIT.MONTH: {
306
+ const firstDayOfMonthSFE = new SimpleFunctionExpression(
307
+ SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH,
308
+ multiplicityOne,
309
+ );
310
+ valueSpecification_setGenericType(
311
+ firstDayOfMonthSFE,
312
+ GenericTypeExplicitReference.create(new GenericType(date)),
313
+ );
314
+ return firstDayOfMonthSFE;
315
+ }
316
+ case CUSTOM_DATE_FIRST_DAY_OF_UNIT.WEEK: {
317
+ const firstDayOfWeekSFE = new SimpleFunctionExpression(
318
+ SUPPORTED_FUNCTIONS.FIRST_DAY_OF_WEEK,
319
+ multiplicityOne,
320
+ );
321
+ valueSpecification_setGenericType(
322
+ firstDayOfWeekSFE,
323
+ GenericTypeExplicitReference.create(new GenericType(date)),
324
+ );
325
+ return firstDayOfWeekSFE;
326
+ }
327
+ default:
328
+ throw new UnsupportedOperationError(
329
+ `Can't build expression for 'First Day Of ...' date picker option for unit '${datePickerOption.unit}'`,
330
+ );
331
+ }
332
+ } else {
333
+ switch (datePickerOption.value) {
334
+ case CUSTOM_DATE_PICKER_OPTION.TODAY: {
335
+ const todaySFE = new SimpleFunctionExpression(
336
+ SUPPORTED_FUNCTIONS.TODAY,
337
+ multiplicityOne,
338
+ );
339
+ valueSpecification_setGenericType(
340
+ todaySFE,
341
+ GenericTypeExplicitReference.create(new GenericType(strictDate)),
342
+ );
343
+ return todaySFE;
344
+ }
345
+ case CUSTOM_DATE_PICKER_OPTION.NOW: {
346
+ const nowSFE = new SimpleFunctionExpression(
347
+ SUPPORTED_FUNCTIONS.NOW,
348
+ multiplicityOne,
349
+ );
350
+ valueSpecification_setGenericType(
351
+ nowSFE,
352
+ GenericTypeExplicitReference.create(new GenericType(dateTime)),
353
+ );
354
+ return nowSFE;
355
+ }
356
+ case CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_YEAR: {
357
+ const firstDayOfYearSFE = new SimpleFunctionExpression(
358
+ SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR,
359
+ multiplicityOne,
360
+ );
361
+ valueSpecification_setGenericType(
362
+ firstDayOfYearSFE,
363
+ GenericTypeExplicitReference.create(new GenericType(date)),
364
+ );
365
+ return firstDayOfYearSFE;
366
+ }
367
+ case CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_QUARTER: {
368
+ const firstDayOfQuarterSFE = new SimpleFunctionExpression(
369
+ SUPPORTED_FUNCTIONS.FIRST_DAY_OF_QUARTER,
370
+ multiplicityOne,
371
+ );
372
+ valueSpecification_setGenericType(
373
+ firstDayOfQuarterSFE,
374
+ GenericTypeExplicitReference.create(new GenericType(strictDate)),
375
+ );
376
+ return firstDayOfQuarterSFE;
377
+ }
378
+ case CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_MONTH: {
379
+ const firstDayOfMonthSFE = new SimpleFunctionExpression(
380
+ SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH,
381
+ multiplicityOne,
382
+ );
383
+ valueSpecification_setGenericType(
384
+ firstDayOfMonthSFE,
385
+ GenericTypeExplicitReference.create(new GenericType(date)),
386
+ );
387
+ return firstDayOfMonthSFE;
388
+ }
389
+ case CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_WEEK: {
390
+ const firstDayOfWeekSFE = new SimpleFunctionExpression(
391
+ SUPPORTED_FUNCTIONS.FIRST_DAY_OF_WEEK,
392
+ multiplicityOne,
393
+ );
394
+ valueSpecification_setGenericType(
395
+ firstDayOfWeekSFE,
396
+ GenericTypeExplicitReference.create(new GenericType(date)),
397
+ );
398
+ return firstDayOfWeekSFE;
399
+ }
400
+ default:
401
+ throw new UnsupportedOperationError(
402
+ `Can't build expression for date picker option '${datePickerOption.value}'`,
403
+ );
404
+ }
405
+ }
406
+ };
407
+
408
+ /**
409
+ * Generate the enum value of type Pure Enum, DURATION_UNIT, based on the input string.
410
+ */
411
+ const buildPureDurationEnumValue = (
412
+ unitString: string,
413
+ graph: PureModel,
414
+ ): Enum => {
415
+ const durationUnitEnum = graph.getEnumeration(DURATION_UNIT);
416
+ const targetPureDurationEnumValue = durationUnitEnum.values.filter(
417
+ (e) =>
418
+ e.name ===
419
+ Object.keys(CUSTOM_DATE_OPTION_UNIT).filter(
420
+ (key) =>
421
+ CUSTOM_DATE_OPTION_UNIT[
422
+ key as keyof typeof CUSTOM_DATE_OPTION_UNIT
423
+ ] === unitString,
424
+ )[0],
425
+ )[0];
426
+ return (
427
+ targetPureDurationEnumValue ??
428
+ guaranteeNonNullable(durationUnitEnum.values[0])
429
+ );
430
+ };
431
+
432
+ /**
433
+ * Generate the pure date ajust() function based on the CustomDateOption.
434
+ */
435
+ const buildPureAdjustDateFunction = (
436
+ customDateOption: CustomDateOption,
437
+ graph: PureModel,
438
+ observerContext: ObserverContext,
439
+ ): SimpleFunctionExpression => {
440
+ const multiplicityOne = graph.getTypicalMultiplicity(
441
+ TYPICAL_MULTIPLICITY_TYPE.ONE,
442
+ );
443
+ const dateAdjustSimpleFunctionExpression = new SimpleFunctionExpression(
444
+ SUPPORTED_FUNCTIONS.ADJUST,
445
+ multiplicityOne,
446
+ );
447
+ functionExpression_addParameterValue(
448
+ dateAdjustSimpleFunctionExpression,
449
+ buildPureDateFunctionExpression(
450
+ new DatePickerOption(
451
+ guaranteeNonNullable(customDateOption.referenceMoment),
452
+ guaranteeNonNullable(customDateOption.referenceMoment),
453
+ ),
454
+ graph,
455
+ observerContext,
456
+ ),
457
+ observerContext,
458
+ );
459
+ if (customDateOption.direction === CUSTOM_DATE_OPTION_DIRECTION.BEFORE) {
460
+ const minusFunc = new SimpleFunctionExpression(
461
+ SUPPORTED_FUNCTIONS.MINUS,
462
+ multiplicityOne,
463
+ );
464
+ functionExpression_addParameterValue(
465
+ minusFunc,
466
+ buildPrimitiveInstanceValue(
467
+ graph,
468
+ PRIMITIVE_TYPE.INTEGER,
469
+ customDateOption.duration,
470
+ ),
471
+ observerContext,
472
+ );
473
+ functionExpression_addParameterValue(
474
+ dateAdjustSimpleFunctionExpression,
475
+ minusFunc,
476
+ observerContext,
477
+ );
478
+ } else {
479
+ const adjustmentInstanceValue = buildPrimitiveInstanceValue(
480
+ graph,
481
+ PRIMITIVE_TYPE.INTEGER,
482
+ customDateOption.duration,
483
+ );
484
+ functionExpression_addParameterValue(
485
+ dateAdjustSimpleFunctionExpression,
486
+ adjustmentInstanceValue,
487
+ observerContext,
488
+ );
489
+ }
490
+ const durationUnitEnumIntanceValue = new EnumValueInstanceValue(
491
+ GenericTypeExplicitReference.create(
492
+ new GenericType(graph.getType(DURATION_UNIT)),
493
+ ),
494
+ multiplicityOne,
495
+ );
496
+ instanceValue_setValues(durationUnitEnumIntanceValue, [
497
+ ...durationUnitEnumIntanceValue.values,
498
+ EnumValueExplicitReference.create(
499
+ guaranteeNonNullable(
500
+ buildPureDurationEnumValue(
501
+ guaranteeNonNullable(customDateOption.unit),
502
+ graph,
503
+ ),
504
+ ),
505
+ ),
506
+ ]);
507
+ functionExpression_addParameterValue(
508
+ dateAdjustSimpleFunctionExpression,
509
+ durationUnitEnumIntanceValue,
510
+ observerContext,
511
+ );
512
+ valueSpecification_setGenericType(
513
+ dateAdjustSimpleFunctionExpression,
514
+ GenericTypeExplicitReference.create(
515
+ new GenericType(graph.getPrimitiveType(PRIMITIVE_TYPE.DATE)),
516
+ ),
517
+ );
518
+ return dateAdjustSimpleFunctionExpression;
519
+ };
520
+
521
+ /**
522
+ * Generate the value of CustomDateOption.duration from the pure date adjust() function.
523
+ */
524
+ const buildCustomDateOptionDurationValue = (
525
+ pureDateAdjustFunction: SimpleFunctionExpression,
526
+ ): number => {
527
+ const durationParam = pureDateAdjustFunction.parametersValues[1];
528
+ return durationParam instanceof PrimitiveInstanceValue
529
+ ? (durationParam.values[0] as number)
530
+ : durationParam instanceof SimpleFunctionExpression &&
531
+ matchFunctionName(durationParam.functionName, SUPPORTED_FUNCTIONS.MINUS)
532
+ ? durationParam.parametersValues[0] instanceof PrimitiveInstanceValue
533
+ ? (durationParam.parametersValues[0].values[0] as number)
534
+ : 0
535
+ : 0;
536
+ };
537
+
538
+ /**
539
+ * Generate the value of CustomDateOption.direction from the pure date adjust() function.
540
+ */
541
+ const buildCustomDateOptionDirectionValue = (
542
+ pureDateAdjustFunction: SimpleFunctionExpression,
543
+ ): CUSTOM_DATE_OPTION_DIRECTION =>
544
+ pureDateAdjustFunction.parametersValues[1] instanceof
545
+ SimpleFunctionExpression &&
546
+ matchFunctionName(
547
+ pureDateAdjustFunction.parametersValues[1].functionName,
548
+ SUPPORTED_FUNCTIONS.MINUS,
549
+ )
550
+ ? CUSTOM_DATE_OPTION_DIRECTION.BEFORE
551
+ : CUSTOM_DATE_OPTION_DIRECTION.AFTER;
552
+
553
+ /**
554
+ * Generate the value of CustomDateOption.unit from the pure date adjust() function.
555
+ */
556
+ const buildCustomDateOptionUnitValue = (
557
+ valueSpecification: SimpleFunctionExpression,
558
+ ): CUSTOM_DATE_OPTION_UNIT =>
559
+ guaranteeNonNullable(
560
+ Object.keys(CUSTOM_DATE_OPTION_UNIT)
561
+ .filter(
562
+ (key) =>
563
+ key ===
564
+ (valueSpecification.parametersValues[2] as EnumValueInstanceValue)
565
+ .values[0]?.value.name,
566
+ )
567
+ .map(
568
+ (key) =>
569
+ CUSTOM_DATE_OPTION_UNIT[key as keyof typeof CUSTOM_DATE_OPTION_UNIT],
570
+ )[0],
571
+ );
572
+
573
+ /**
574
+ * Generate the value of CustomDateOption.moment from the pure date adjust() function.
575
+ */
576
+ const buildCustomDateOptionReferenceMomentValue = (
577
+ pureDateAjustFunction: SimpleFunctionExpression,
578
+ ): CUSTOM_DATE_OPTION_REFERENCE_MOMENT => {
579
+ const funcName = (
580
+ pureDateAjustFunction.parametersValues[0] as SimpleFunctionExpression
581
+ ).functionName;
582
+ switch (funcName) {
583
+ case SUPPORTED_FUNCTIONS.TODAY:
584
+ return CUSTOM_DATE_OPTION_REFERENCE_MOMENT.TODAY;
585
+ case SUPPORTED_FUNCTIONS.NOW:
586
+ return CUSTOM_DATE_OPTION_REFERENCE_MOMENT.NOW;
587
+ case SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR:
588
+ return CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_YEAR;
589
+ case SUPPORTED_FUNCTIONS.FIRST_DAY_OF_QUARTER:
590
+ return CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_QUARTER;
591
+ case SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH:
592
+ return CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_MONTH;
593
+ case SUPPORTED_FUNCTIONS.FIRST_DAY_OF_WEEK:
594
+ return CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_WEEK;
595
+ default:
596
+ throw new UnsupportedOperationError(
597
+ `Can't build custom date option reference moment '${funcName}'`,
598
+ );
599
+ }
600
+ };
601
+
602
+ /**
603
+ * Build CustomDateOption based on the pure date adjust() function.
604
+ * Transform CustomDateOption if it matches any preserved custom adjust date functions. e.g. One Month Ago..
605
+ */
606
+ const buildCustomDateOption = (
607
+ valueSpecification: SimpleFunctionExpression | PrimitiveInstanceValue,
608
+ ): CustomDateOption => {
609
+ if (
610
+ valueSpecification instanceof SimpleFunctionExpression &&
611
+ matchFunctionName(
612
+ valueSpecification.functionName,
613
+ SUPPORTED_FUNCTIONS.ADJUST,
614
+ )
615
+ ) {
616
+ const customDateOption = new CustomDateOption(
617
+ '',
618
+ CUSTOM_DATE_PICKER_OPTION.CUSTOM_DATE,
619
+ buildCustomDateOptionDurationValue(valueSpecification),
620
+ buildCustomDateOptionUnitValue(valueSpecification),
621
+ buildCustomDateOptionDirectionValue(valueSpecification),
622
+ buildCustomDateOptionReferenceMomentValue(valueSpecification),
623
+ );
624
+ const matchedPreservedCustomAdjustDates = reservedCustomDateOptions.filter(
625
+ (t) =>
626
+ t.generateDisplayLabel() === customDateOption.generateDisplayLabel(),
627
+ );
628
+ if (matchedPreservedCustomAdjustDates.length > 0) {
629
+ customDateOption.label = guaranteeNonNullable(
630
+ matchedPreservedCustomAdjustDates[0]?.label,
631
+ );
632
+ customDateOption.value = guaranteeNonNullable(
633
+ matchedPreservedCustomAdjustDates[0]?.value,
634
+ );
635
+ return customDateOption;
636
+ }
637
+ customDateOption.updateLabel();
638
+ return customDateOption;
639
+ }
640
+ return new CustomDateOption('', '', 0, undefined, undefined, undefined);
641
+ };
642
+
643
+ /**
644
+ * Build DatePickerOption from pure date functions or PrimitiveInstanceValue
645
+ */
646
+ const buildDatePickerOption = (
647
+ valueSpecification: SimpleFunctionExpression | PrimitiveInstanceValue,
648
+ ): DatePickerOption => {
649
+ if (valueSpecification instanceof SimpleFunctionExpression) {
650
+ switch (valueSpecification.functionName) {
651
+ case SUPPORTED_FUNCTIONS.TODAY:
652
+ return new DatePickerOption(
653
+ CUSTOM_DATE_PICKER_OPTION.TODAY,
654
+ CUSTOM_DATE_PICKER_OPTION.TODAY,
655
+ );
656
+ case SUPPORTED_FUNCTIONS.NOW:
657
+ return new DatePickerOption(
658
+ CUSTOM_DATE_PICKER_OPTION.NOW,
659
+ CUSTOM_DATE_PICKER_OPTION.NOW,
660
+ );
661
+ case SUPPORTED_FUNCTIONS.FIRST_DAY_OF_YEAR:
662
+ return new CustomFirstDayOfOption(
663
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_YEAR,
664
+ CUSTOM_DATE_FIRST_DAY_OF_UNIT.YEAR,
665
+ );
666
+ case SUPPORTED_FUNCTIONS.FIRST_DAY_OF_QUARTER:
667
+ return new CustomFirstDayOfOption(
668
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_QUARTER,
669
+ CUSTOM_DATE_FIRST_DAY_OF_UNIT.QUARTER,
670
+ );
671
+ case SUPPORTED_FUNCTIONS.FIRST_DAY_OF_MONTH:
672
+ return new CustomFirstDayOfOption(
673
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_MONTH,
674
+ CUSTOM_DATE_FIRST_DAY_OF_UNIT.MONTH,
675
+ );
676
+ case SUPPORTED_FUNCTIONS.FIRST_DAY_OF_WEEK:
677
+ return new CustomFirstDayOfOption(
678
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.FIRST_DAY_OF_WEEK,
679
+ CUSTOM_DATE_FIRST_DAY_OF_UNIT.WEEK,
680
+ );
681
+ case SUPPORTED_FUNCTIONS.PREVIOUS_DAY_OF_WEEK:
682
+ return new CustomPreviousDayOfWeekOption(
683
+ `Previous ${
684
+ (valueSpecification.parametersValues[0] as EnumValueInstanceValue)
685
+ .values[0]?.value.name
686
+ }`,
687
+ (valueSpecification.parametersValues[0] as EnumValueInstanceValue)
688
+ .values[0]?.value.name as CUSTOM_DATE_DAY_OF_WEEK,
689
+ );
690
+
691
+ case SUPPORTED_FUNCTIONS.ADJUST:
692
+ return buildCustomDateOption(valueSpecification);
693
+ default:
694
+ return new DatePickerOption('', '');
695
+ }
696
+ } else {
697
+ return valueSpecification.genericType.value.rawType.path ===
698
+ PRIMITIVE_TYPE.LATESTDATE
699
+ ? new DatePickerOption(
700
+ CUSTOM_DATE_PICKER_OPTION.LATEST_DATE,
701
+ CUSTOM_DATE_PICKER_OPTION.LATEST_DATE,
702
+ )
703
+ : new DatePickerOption(
704
+ valueSpecification.values[0] as string,
705
+ valueSpecification.genericType.value.rawType.path ===
706
+ PRIMITIVE_TYPE.DATETIME
707
+ ? CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_TIME
708
+ : CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_DATE,
709
+ );
710
+ }
711
+ };
712
+
713
+ const AbsoluteDateValueSpecificationEditor: React.FC<{
714
+ valueSpecification: SimpleFunctionExpression | PrimitiveInstanceValue;
715
+ graph: PureModel;
716
+ setValueSpecification: (val: ValueSpecification) => void;
717
+ setDatePickerOption: (datePickerOption: DatePickerOption) => void;
718
+ }> = (props) => {
719
+ const {
720
+ valueSpecification,
721
+ graph,
722
+ setValueSpecification,
723
+ setDatePickerOption,
724
+ } = props;
725
+ const inputRef = useRef<HTMLInputElement>(null);
726
+ const absoluteDateValue =
727
+ valueSpecification instanceof SimpleFunctionExpression
728
+ ? ''
729
+ : (valueSpecification.values[0] as string);
730
+ const updateAbsoluteDateValue: React.ChangeEventHandler<HTMLInputElement> = (
731
+ event,
732
+ ) => {
733
+ if (valueSpecification instanceof SimpleFunctionExpression) {
734
+ setValueSpecification(
735
+ buildPrimitiveInstanceValue(
736
+ graph,
737
+ PRIMITIVE_TYPE.STRICTDATE,
738
+ event.target.value,
739
+ ),
740
+ );
741
+ } else if (valueSpecification instanceof InstanceValue) {
742
+ instanceValue_setValue(valueSpecification, event.target.value, 0);
743
+ if (
744
+ valueSpecification.genericType.value.rawType.path !==
745
+ PRIMITIVE_TYPE.STRICTDATE
746
+ ) {
747
+ valueSpecification_setGenericType(
748
+ valueSpecification,
749
+ GenericTypeExplicitReference.create(
750
+ new GenericType(graph.getPrimitiveType(PRIMITIVE_TYPE.STRICTDATE)),
751
+ ),
752
+ );
753
+ }
754
+ setValueSpecification(valueSpecification);
755
+ }
756
+ setDatePickerOption(
757
+ new DatePickerOption(
758
+ event.target.value,
759
+ CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_DATE,
760
+ ),
761
+ );
762
+ };
763
+
764
+ useEffect(() => {
765
+ inputRef.current?.focus();
766
+ }, []);
767
+
768
+ return (
769
+ <div className="value-spec-editor__date-picker__absolute-date">
770
+ <input
771
+ ref={inputRef}
772
+ className="panel__content__form__section__input value-spec-editor__date-picker__absolute-date__input input--dark"
773
+ type="date"
774
+ spellCheck={false}
775
+ value={absoluteDateValue}
776
+ onChange={updateAbsoluteDateValue}
777
+ />
778
+ </div>
779
+ );
780
+ };
781
+
782
+ const AbsoluteTimeValueSpecificationEditor: React.FC<{
783
+ valueSpecification: SimpleFunctionExpression | PrimitiveInstanceValue;
784
+ graph: PureModel;
785
+ setValueSpecification: (val: ValueSpecification) => void;
786
+ setDatePickerOption: (datePickerOption: DatePickerOption) => void;
787
+ }> = (props) => {
788
+ const {
789
+ valueSpecification,
790
+ graph,
791
+ setValueSpecification,
792
+ setDatePickerOption,
793
+ } = props;
794
+ const inputRef = useRef<HTMLInputElement>(null);
795
+ const absoluteTimeValue =
796
+ valueSpecification instanceof SimpleFunctionExpression
797
+ ? ''
798
+ : (valueSpecification.values[0] as string);
799
+ const updateAbsoluteTimeValue: React.ChangeEventHandler<HTMLInputElement> = (
800
+ event,
801
+ ) => {
802
+ if (valueSpecification instanceof SimpleFunctionExpression) {
803
+ setValueSpecification(
804
+ buildPrimitiveInstanceValue(
805
+ graph,
806
+ PRIMITIVE_TYPE.DATETIME,
807
+ event.target.value,
808
+ ),
809
+ );
810
+ } else {
811
+ instanceValue_setValue(valueSpecification, event.target.value, 0);
812
+ if (
813
+ valueSpecification.genericType.value.rawType.path !==
814
+ PRIMITIVE_TYPE.DATETIME
815
+ ) {
816
+ valueSpecification_setGenericType(
817
+ valueSpecification,
818
+ GenericTypeExplicitReference.create(
819
+ new GenericType(graph.getPrimitiveType(PRIMITIVE_TYPE.DATETIME)),
820
+ ),
821
+ );
822
+ }
823
+ setValueSpecification(valueSpecification);
824
+ }
825
+ setDatePickerOption(
826
+ new DatePickerOption(
827
+ event.target.value,
828
+ CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_TIME,
829
+ ),
830
+ );
831
+ };
832
+
833
+ useEffect(() => {
834
+ inputRef.current?.focus();
835
+ }, []);
836
+
837
+ return (
838
+ <div className="value-spec-editor__date-picker__absolute-date">
839
+ <input
840
+ ref={inputRef}
841
+ className="panel__content__form__section__input value-spec-editor__date-picker__absolute-date__input input--dark"
842
+ // Despite its name this would actually allow us to register time in UTC
843
+ // See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local#setting_timezones
844
+ type="datetime-local"
845
+ spellCheck={false}
846
+ value={absoluteTimeValue}
847
+ onChange={updateAbsoluteTimeValue}
848
+ />
849
+ </div>
850
+ );
851
+ };
852
+
853
+ const CustomDateInstanceValueEditor: React.FC<{
854
+ customDateOptionValue: CustomDateOption;
855
+ graph: PureModel;
856
+ observerContext: ObserverContext;
857
+ setValueSpecification: (val: ValueSpecification) => void;
858
+ setDatePickerOption: (datePickerOption: DatePickerOption) => void;
859
+ }> = (props) => {
860
+ const {
861
+ customDateOptionValue,
862
+ graph,
863
+ setValueSpecification,
864
+ setDatePickerOption,
865
+ observerContext,
866
+ } = props;
867
+ const inputRef = useRef<HTMLInputElement>(null);
868
+ const [durationValue, setDurationValue] = useState(
869
+ customDateOptionValue.duration,
870
+ );
871
+ const [unitValue, setUnitValue] = useState(
872
+ customDateOptionValue.unit ?? CUSTOM_DATE_OPTION_UNIT.DAYS,
873
+ );
874
+ const [directionValue, setDirectionValue] = useState(
875
+ customDateOptionValue.direction ?? CUSTOM_DATE_OPTION_DIRECTION.BEFORE,
876
+ );
877
+ const [referenceMomentValue, setReferenceMomentValueValue] = useState(
878
+ customDateOptionValue.referenceMoment ??
879
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT.TODAY,
880
+ );
881
+ const changeValue = (
882
+ latestDurationValue: number,
883
+ latestUnitValue: string,
884
+ latestDirectionValue: string,
885
+ latestReferenceMomentValue: string,
886
+ ): void => {
887
+ if (
888
+ latestDurationValue !== 0 &&
889
+ latestUnitValue !== '' &&
890
+ latestDirectionValue !== '' &&
891
+ latestReferenceMomentValue !== ''
892
+ ) {
893
+ const dateOption = new CustomDateOption(
894
+ CUSTOM_DATE_PICKER_OPTION.CUSTOM_DATE,
895
+ CUSTOM_DATE_PICKER_OPTION.CUSTOM_DATE,
896
+ latestDurationValue,
897
+ latestUnitValue as CUSTOM_DATE_OPTION_UNIT,
898
+ latestDirectionValue as CUSTOM_DATE_OPTION_DIRECTION,
899
+ latestReferenceMomentValue as CUSTOM_DATE_OPTION_REFERENCE_MOMENT,
900
+ );
901
+ setValueSpecification(
902
+ buildPureAdjustDateFunction(dateOption, graph, observerContext),
903
+ );
904
+ const matchedPreservedCustomAdjustDates =
905
+ reservedCustomDateOptions.filter(
906
+ (t) => t.generateDisplayLabel() === dateOption.generateDisplayLabel(),
907
+ );
908
+ if (matchedPreservedCustomAdjustDates.length > 0) {
909
+ dateOption.label = guaranteeNonNullable(
910
+ matchedPreservedCustomAdjustDates[0]?.label,
911
+ );
912
+ dateOption.value = guaranteeNonNullable(
913
+ matchedPreservedCustomAdjustDates[0]?.value,
914
+ );
915
+ } else {
916
+ dateOption.updateLabel();
917
+ }
918
+ setDatePickerOption(dateOption);
919
+ }
920
+ };
921
+ const changeDurationValue: React.ChangeEventHandler<HTMLInputElement> = (
922
+ event,
923
+ ) => {
924
+ const duration =
925
+ event.target.value !== ''
926
+ ? returnUndefOnError(() => parseNumber(event.target.value)) ?? 0
927
+ : 0;
928
+ setDurationValue(duration);
929
+ changeValue(duration, unitValue, directionValue, referenceMomentValue);
930
+ };
931
+
932
+ useEffect(() => {
933
+ inputRef.current?.focus();
934
+ }, []);
935
+
936
+ return (
937
+ <div className="value-spec-editor__date-picker__custom-date">
938
+ <div className="value-spec-editor__date-picker__custom-date__input">
939
+ <input
940
+ ref={inputRef}
941
+ className="value-spec-editor__date-picker__custom-date__input-text-editor input--dark"
942
+ spellCheck={false}
943
+ value={durationValue}
944
+ type="number"
945
+ onChange={changeDurationValue}
946
+ />
947
+ </div>
948
+ <div className="value-spec-editor__date-picker__custom-date__input">
949
+ <CustomSelectorInput
950
+ placeholder="Unit"
951
+ className="value-spec-editor__date-picker__custom-date__input-dropdown"
952
+ options={Object.values(CUSTOM_DATE_OPTION_UNIT).map((t) => ({
953
+ value: t.toString(),
954
+ label: t.toString(),
955
+ }))}
956
+ onChange={(val: {
957
+ label: string;
958
+ value: CUSTOM_DATE_OPTION_UNIT;
959
+ }): void => {
960
+ setUnitValue(val.value);
961
+ changeValue(
962
+ durationValue,
963
+ val.value,
964
+ directionValue,
965
+ referenceMomentValue,
966
+ );
967
+ }}
968
+ value={{ value: unitValue, label: unitValue }}
969
+ darkMode={true}
970
+ />
971
+ </div>
972
+ <div className="value-spec-editor__date-picker__custom-date__input">
973
+ <CustomSelectorInput
974
+ className="value-spec-editor__date-picker__custom-date__input-dropdown"
975
+ options={Object.values(CUSTOM_DATE_OPTION_DIRECTION).map((t) => ({
976
+ value: t.toString(),
977
+ label: t.toString(),
978
+ }))}
979
+ onChange={(val: {
980
+ label: string;
981
+ value: CUSTOM_DATE_OPTION_DIRECTION;
982
+ }): void => {
983
+ setDirectionValue(val.value);
984
+ changeValue(
985
+ durationValue,
986
+ unitValue,
987
+ val.value,
988
+ referenceMomentValue,
989
+ );
990
+ }}
991
+ value={{ value: directionValue, label: directionValue }}
992
+ darkMode={true}
993
+ />
994
+ </div>
995
+ <div className="value-spec-editor__date-picker__custom-date__input">
996
+ <CustomSelectorInput
997
+ className="value-spec-editor__date-picker__custom-date__input-dropdown"
998
+ options={Object.values(CUSTOM_DATE_OPTION_REFERENCE_MOMENT).map(
999
+ (t) => ({
1000
+ value: t.toString(),
1001
+ label: t.toString(),
1002
+ }),
1003
+ )}
1004
+ onChange={(val: {
1005
+ label: string;
1006
+ value: CUSTOM_DATE_OPTION_REFERENCE_MOMENT;
1007
+ }): void => {
1008
+ setReferenceMomentValueValue(val.value);
1009
+ changeValue(durationValue, unitValue, directionValue, val.value);
1010
+ }}
1011
+ value={{ value: referenceMomentValue, label: referenceMomentValue }}
1012
+ darkMode={true}
1013
+ />
1014
+ </div>
1015
+ </div>
1016
+ );
1017
+ };
1018
+
1019
+ const CustomFirstDayOfValueSpecificationEditor: React.FC<{
1020
+ customDateAdjustOptionValue: DatePickerOption;
1021
+ graph: PureModel;
1022
+ observerContext: ObserverContext;
1023
+ setValueSpecification: (val: ValueSpecification) => void;
1024
+ setDatePickerOption: (datePickerOption: DatePickerOption) => void;
1025
+ }> = (props) => {
1026
+ const {
1027
+ customDateAdjustOptionValue,
1028
+ graph,
1029
+ observerContext,
1030
+ setValueSpecification,
1031
+ setDatePickerOption,
1032
+ } = props;
1033
+ const selectorRef = useRef<SelectComponent>(null);
1034
+ const [unitValue, setUnitValue] = useState(
1035
+ customDateAdjustOptionValue instanceof CustomFirstDayOfOption
1036
+ ? (customDateAdjustOptionValue.unit as string)
1037
+ : null,
1038
+ );
1039
+ const changeValue = (latestUnitValue: string): void => {
1040
+ if (latestUnitValue !== '') {
1041
+ const targetUnitValue = Object.values(
1042
+ CUSTOM_DATE_OPTION_REFERENCE_MOMENT,
1043
+ ).filter((moment) => moment.toString().includes(latestUnitValue));
1044
+ const startDayOfDateOption =
1045
+ targetUnitValue.length > 0
1046
+ ? new CustomFirstDayOfOption(
1047
+ guaranteeNonNullable(targetUnitValue[0]?.toString()),
1048
+ latestUnitValue as CUSTOM_DATE_FIRST_DAY_OF_UNIT,
1049
+ )
1050
+ : new CustomFirstDayOfOption('', undefined);
1051
+ setValueSpecification(
1052
+ buildPureDateFunctionExpression(
1053
+ startDayOfDateOption,
1054
+ graph,
1055
+ observerContext,
1056
+ ),
1057
+ );
1058
+ setDatePickerOption(startDayOfDateOption);
1059
+ }
1060
+ };
1061
+
1062
+ useEffect(() => {
1063
+ selectorRef.current?.focus();
1064
+ }, []);
1065
+
1066
+ return (
1067
+ <div className="value-spec-editor__date-picker__custom-date">
1068
+ <div className="value-spec-editor__date-picker__custom-date__input">
1069
+ <CustomSelectorInput
1070
+ ref={selectorRef}
1071
+ placeholder="Choose a unit..."
1072
+ className="value-spec-editor__date-picker__custom-date__input-dropdown value-spec-editor__date-picker__custom-date__input-dropdown--full"
1073
+ options={Object.values(CUSTOM_DATE_FIRST_DAY_OF_UNIT).map((t) => ({
1074
+ value: t.toString(),
1075
+ label: t.toString(),
1076
+ }))}
1077
+ onChange={(val: { label: string; value: string } | null): void => {
1078
+ if (val) {
1079
+ setUnitValue(val.value);
1080
+ changeValue(val.value);
1081
+ }
1082
+ }}
1083
+ value={unitValue ? { value: unitValue, label: unitValue } : null}
1084
+ darkMode={true}
1085
+ />
1086
+ </div>
1087
+ </div>
1088
+ );
1089
+ };
1090
+
1091
+ const CustomPreviousDayOfWeekValueSpecificationEditor: React.FC<{
1092
+ customDateAdjustOptionValue: DatePickerOption;
1093
+ graph: PureModel;
1094
+ observerContext: ObserverContext;
1095
+ setValueSpecification: (val: ValueSpecification) => void;
1096
+ setDatePickerOption: (datePickerOption: DatePickerOption) => void;
1097
+ }> = (props) => {
1098
+ const {
1099
+ customDateAdjustOptionValue,
1100
+ graph,
1101
+ observerContext,
1102
+ setValueSpecification,
1103
+ setDatePickerOption,
1104
+ } = props;
1105
+ const selectorRef = useRef<SelectComponent>(null);
1106
+ const [dayOfWeekValue, setDayOfWeekValue] = useState(
1107
+ customDateAdjustOptionValue instanceof CustomPreviousDayOfWeekOption
1108
+ ? (customDateAdjustOptionValue.day as string)
1109
+ : null,
1110
+ );
1111
+ const changeValue = (latestDurationUnitValue: string): void => {
1112
+ if (latestDurationUnitValue !== '') {
1113
+ const previousDayOfWeekDateOption = new CustomPreviousDayOfWeekOption(
1114
+ `Previous ${latestDurationUnitValue}`,
1115
+ latestDurationUnitValue as CUSTOM_DATE_DAY_OF_WEEK,
1116
+ );
1117
+ setValueSpecification(
1118
+ buildPureDateFunctionExpression(
1119
+ previousDayOfWeekDateOption,
1120
+ graph,
1121
+ observerContext,
1122
+ ),
1123
+ );
1124
+ setDatePickerOption(previousDayOfWeekDateOption);
1125
+ }
1126
+ };
1127
+
1128
+ useEffect(() => {
1129
+ selectorRef.current?.focus();
1130
+ }, []);
1131
+
1132
+ return (
1133
+ <div className="value-spec-editor__date-picker__custom-date">
1134
+ <div className="value-spec-editor__date-picker__custom-date__input">
1135
+ <CustomSelectorInput
1136
+ ref={selectorRef}
1137
+ placeholder="Choose a day..."
1138
+ className="value-spec-editor__date-picker__custom-date__input-dropdown value-spec-editor__date-picker__custom-date__input-dropdown--full"
1139
+ options={Object.values(CUSTOM_DATE_DAY_OF_WEEK).map((t) => ({
1140
+ value: t.toString(),
1141
+ label: t.toString(),
1142
+ }))}
1143
+ onChange={(val: { label: string; value: string } | null): void => {
1144
+ if (val) {
1145
+ setDayOfWeekValue(val.value);
1146
+ changeValue(val.value);
1147
+ }
1148
+ }}
1149
+ value={
1150
+ dayOfWeekValue
1151
+ ? { value: dayOfWeekValue, label: dayOfWeekValue }
1152
+ : null
1153
+ }
1154
+ darkMode={true}
1155
+ />
1156
+ </div>
1157
+ </div>
1158
+ );
1159
+ };
1160
+
1161
+ export const CustomDatePicker: React.FC<{
1162
+ valueSpecification: PrimitiveInstanceValue | SimpleFunctionExpression;
1163
+ graph: PureModel;
1164
+ observerContext: ObserverContext;
1165
+ typeCheckOption: {
1166
+ expectedType: Type;
1167
+ /**
1168
+ * Indicates if a strict type-matching will happen.
1169
+ * Sometimes, auto-boxing allow some rooms to wiggle,
1170
+ * for example we can assign a Float to an Integer, a
1171
+ * Date to a DateTime. With this flag set to `true`
1172
+ * we will not allow this.
1173
+ *
1174
+ * For example, if `match=true`, it means that options in the
1175
+ * date-capability-dropdown which are not returning type DateTime
1176
+ * will be filtered out.
1177
+ */
1178
+ match?: boolean;
1179
+ };
1180
+ setValueSpecification: (val: ValueSpecification) => void;
1181
+ }> = (props) => {
1182
+ const {
1183
+ valueSpecification,
1184
+ setValueSpecification,
1185
+ graph,
1186
+ observerContext,
1187
+ typeCheckOption,
1188
+ } = props;
1189
+ // For some cases where types need to be matched strictly.
1190
+ // Some options need to be filtered out for DateTime.
1191
+ const targetDateOptionsEnum = typeCheckOption.match
1192
+ ? Object.values([
1193
+ CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_TIME,
1194
+ CUSTOM_DATE_PICKER_OPTION.NOW,
1195
+ ])
1196
+ : Object.values(CUSTOM_DATE_PICKER_OPTION);
1197
+ const [datePickerOption, setDatePickerOption] = useState(
1198
+ buildDatePickerOption(valueSpecification),
1199
+ );
1200
+
1201
+ const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
1202
+ const openCustomDatePickerPopover = (
1203
+ event: React.MouseEvent<HTMLButtonElement>,
1204
+ ): void => {
1205
+ setAnchorEl(event.currentTarget);
1206
+ };
1207
+ const handleEnter = (): void => {
1208
+ setDatePickerOption(buildDatePickerOption(valueSpecification));
1209
+ };
1210
+ const closeCustomDatePickerPopover = (): void => {
1211
+ setDatePickerOption(buildDatePickerOption(valueSpecification));
1212
+ setAnchorEl(null);
1213
+ };
1214
+ const handleDatePickerOptionChange = (
1215
+ event: React.ChangeEvent<HTMLInputElement>,
1216
+ ): void => {
1217
+ const chosenDatePickerOption = new DatePickerOption(
1218
+ (event.target as HTMLInputElement).value,
1219
+ (event.target as HTMLInputElement).value,
1220
+ );
1221
+ if (
1222
+ CUSTOM_DATE_PICKER_OPTION.LATEST_DATE === chosenDatePickerOption.value
1223
+ ) {
1224
+ setValueSpecification(
1225
+ buildPrimitiveInstanceValue(
1226
+ graph,
1227
+ PRIMITIVE_TYPE.LATESTDATE,
1228
+ event.target.value,
1229
+ ),
1230
+ );
1231
+ } else if (
1232
+ // Elements in this list will trigger children date components
1233
+ ![
1234
+ CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_DATE,
1235
+ CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_TIME,
1236
+ CUSTOM_DATE_PICKER_OPTION.CUSTOM_DATE,
1237
+ CUSTOM_DATE_PICKER_OPTION.FIRST_DAY_OF,
1238
+ CUSTOM_DATE_PICKER_OPTION.PREVIOUS_DAY_OF_WEEK,
1239
+ ].includes(chosenDatePickerOption.value as CUSTOM_DATE_PICKER_OPTION)
1240
+ ) {
1241
+ const theReservedCustomDateOption = reservedCustomDateOptions.filter(
1242
+ (d) => d.value === chosenDatePickerOption.value,
1243
+ );
1244
+ theReservedCustomDateOption.length > 0
1245
+ ? setValueSpecification(
1246
+ buildPureAdjustDateFunction(
1247
+ guaranteeNonNullable(theReservedCustomDateOption[0]),
1248
+ graph,
1249
+ observerContext,
1250
+ ),
1251
+ )
1252
+ : setValueSpecification(
1253
+ buildPureDateFunctionExpression(
1254
+ chosenDatePickerOption,
1255
+ graph,
1256
+ observerContext,
1257
+ ),
1258
+ );
1259
+ }
1260
+ setDatePickerOption(chosenDatePickerOption);
1261
+ };
1262
+ const renderChildrenDateComponents = (): React.ReactNode => {
1263
+ switch (datePickerOption.value) {
1264
+ case CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_DATE:
1265
+ return (
1266
+ <AbsoluteDateValueSpecificationEditor
1267
+ graph={graph}
1268
+ valueSpecification={valueSpecification}
1269
+ setValueSpecification={setValueSpecification}
1270
+ setDatePickerOption={setDatePickerOption}
1271
+ />
1272
+ );
1273
+ case CUSTOM_DATE_PICKER_OPTION.ABSOLUTE_TIME:
1274
+ return (
1275
+ <AbsoluteTimeValueSpecificationEditor
1276
+ graph={graph}
1277
+ valueSpecification={valueSpecification}
1278
+ setValueSpecification={setValueSpecification}
1279
+ setDatePickerOption={setDatePickerOption}
1280
+ />
1281
+ );
1282
+ case CUSTOM_DATE_PICKER_OPTION.CUSTOM_DATE:
1283
+ return (
1284
+ <CustomDateInstanceValueEditor
1285
+ graph={graph}
1286
+ observerContext={observerContext}
1287
+ customDateOptionValue={buildCustomDateOption(valueSpecification)}
1288
+ setValueSpecification={setValueSpecification}
1289
+ setDatePickerOption={setDatePickerOption}
1290
+ />
1291
+ );
1292
+ case CUSTOM_DATE_PICKER_OPTION.FIRST_DAY_OF:
1293
+ return (
1294
+ <CustomFirstDayOfValueSpecificationEditor
1295
+ graph={graph}
1296
+ observerContext={observerContext}
1297
+ customDateAdjustOptionValue={buildDatePickerOption(
1298
+ valueSpecification,
1299
+ )}
1300
+ setValueSpecification={setValueSpecification}
1301
+ setDatePickerOption={setDatePickerOption}
1302
+ />
1303
+ );
1304
+ case CUSTOM_DATE_PICKER_OPTION.PREVIOUS_DAY_OF_WEEK:
1305
+ return (
1306
+ <CustomPreviousDayOfWeekValueSpecificationEditor
1307
+ graph={graph}
1308
+ observerContext={observerContext}
1309
+ customDateAdjustOptionValue={buildDatePickerOption(
1310
+ valueSpecification,
1311
+ )}
1312
+ setValueSpecification={setValueSpecification}
1313
+ setDatePickerOption={setDatePickerOption}
1314
+ />
1315
+ );
1316
+ default:
1317
+ return null;
1318
+ }
1319
+ };
1320
+
1321
+ // make sure the date picker label is updated when the value is reset or changed somehow
1322
+ useEffect(() => {
1323
+ setDatePickerOption(buildDatePickerOption(valueSpecification));
1324
+ }, [valueSpecification]);
1325
+
1326
+ return (
1327
+ <>
1328
+ <button
1329
+ className="value-spec-editor__date-picker__trigger"
1330
+ title="Click to edit and pick from more date options"
1331
+ onClick={openCustomDatePickerPopover}
1332
+ >
1333
+ {datePickerOption.label}
1334
+ </button>
1335
+ <BasePopover
1336
+ open={Boolean(anchorEl)}
1337
+ TransitionProps={{
1338
+ onEnter: handleEnter,
1339
+ }}
1340
+ anchorEl={anchorEl}
1341
+ onClose={closeCustomDatePickerPopover}
1342
+ anchorOrigin={{
1343
+ vertical: 'bottom',
1344
+ horizontal: 'center',
1345
+ }}
1346
+ transformOrigin={{
1347
+ vertical: 'top',
1348
+ horizontal: 'center',
1349
+ }}
1350
+ >
1351
+ <BaseRadioGroup
1352
+ className="value-spec-editor__date-picker__options"
1353
+ value={datePickerOption.value}
1354
+ onChange={handleDatePickerOptionChange}
1355
+ row={true}
1356
+ options={targetDateOptionsEnum}
1357
+ size={2}
1358
+ />
1359
+ {renderChildrenDateComponents()}
1360
+ </BasePopover>
1361
+ </>
1362
+ );
1363
+ };