@leav/ui 0.3.6-ac37a84 → 0.3.6-af10514

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 (244) hide show
  1. package/dist/__mocks__/common/attribute.js +1 -0
  2. package/dist/__mocks__/common/attribute.js.map +1 -1
  3. package/dist/__mocks__/common/form.d.ts +1 -0
  4. package/dist/__mocks__/common/form.js +15 -0
  5. package/dist/__mocks__/common/form.js.map +1 -1
  6. package/dist/__mocks__/common/value.js +1 -0
  7. package/dist/__mocks__/common/value.js.map +1 -1
  8. package/dist/_gqlTypes/index.d.ts +392 -25
  9. package/dist/_gqlTypes/index.js +213 -33
  10. package/dist/_gqlTypes/index.js.map +1 -1
  11. package/dist/_queries/attributes/getAttributesByLib.js +7 -5
  12. package/dist/_queries/attributes/getAttributesByLib.js.map +1 -1
  13. package/dist/_queries/records/getRecordColumnsValues.d.ts +1 -1
  14. package/dist/_queries/records/getRecordsFromLibraryQuery.js +1 -0
  15. package/dist/_queries/records/getRecordsFromLibraryQuery.js.map +1 -1
  16. package/dist/_queries/records/recordFormAttributeFragment.js +1 -0
  17. package/dist/_queries/records/recordFormAttributeFragment.js.map +1 -1
  18. package/dist/_utils/attributeType.d.ts +3 -0
  19. package/dist/_utils/attributeType.js +7 -0
  20. package/dist/_utils/attributeType.js.map +1 -0
  21. package/dist/antdTheme/index.d.ts +0 -3
  22. package/dist/antdTheme/index.js +3 -42
  23. package/dist/antdTheme/index.js.map +1 -1
  24. package/dist/components/Explorer/DataView.d.ts +6 -1
  25. package/dist/components/Explorer/DataView.js +66 -18
  26. package/dist/components/Explorer/DataView.js.map +1 -1
  27. package/dist/components/Explorer/Explorer.d.ts +7 -4
  28. package/dist/components/Explorer/Explorer.js +66 -23
  29. package/dist/components/Explorer/Explorer.js.map +1 -1
  30. package/dist/components/Explorer/ExplorerTitle.d.ts +2 -0
  31. package/dist/components/Explorer/ExplorerTitle.js +28 -11
  32. package/dist/components/Explorer/ExplorerTitle.js.map +1 -1
  33. package/dist/components/Explorer/ExplorerToolbar.d.ts +5 -0
  34. package/dist/components/Explorer/ExplorerToolbar.js +45 -0
  35. package/dist/components/Explorer/ExplorerToolbar.js.map +1 -0
  36. package/dist/components/Explorer/TableCell.js +15 -6
  37. package/dist/components/Explorer/TableCell.js.map +1 -1
  38. package/dist/components/Explorer/_constants.d.ts +1 -0
  39. package/dist/components/Explorer/_constants.js +1 -0
  40. package/dist/components/Explorer/_constants.js.map +1 -1
  41. package/dist/components/Explorer/_queries/prepareFiltersForRequest.d.ts +4 -0
  42. package/dist/components/Explorer/_queries/prepareFiltersForRequest.js +99 -0
  43. package/dist/components/Explorer/_queries/prepareFiltersForRequest.js.map +1 -0
  44. package/dist/components/Explorer/_queries/useExplorerData.d.ts +13 -7
  45. package/dist/components/Explorer/_queries/useExplorerData.js +71 -82
  46. package/dist/components/Explorer/_queries/useExplorerData.js.map +1 -1
  47. package/dist/components/Explorer/_types.d.ts +62 -8
  48. package/dist/components/Explorer/_types.js +7 -1
  49. package/dist/components/Explorer/_types.js.map +1 -1
  50. package/dist/components/Explorer/{nullValuesConditions.d.ts → conditionsHelper.d.ts} +1 -0
  51. package/dist/components/Explorer/{nullValuesConditions.js → conditionsHelper.js} +3 -1
  52. package/dist/components/Explorer/conditionsHelper.js.map +1 -0
  53. package/dist/components/Explorer/manage-view-settings/_shared/CommonFilterItem.d.ts +3 -2
  54. package/dist/components/Explorer/manage-view-settings/_shared/CommonFilterItem.js +1 -1
  55. package/dist/components/Explorer/manage-view-settings/_shared/CommonFilterItem.js.map +1 -1
  56. package/dist/components/Explorer/manage-view-settings/_shared/useAttributeDetailsData.d.ts +3 -1
  57. package/dist/components/Explorer/manage-view-settings/_shared/useAttributeDetailsData.js +9 -3
  58. package/dist/components/Explorer/manage-view-settings/_shared/useAttributeDetailsData.js.map +1 -1
  59. package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js +13 -3
  60. package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js.map +1 -1
  61. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/BooleanAttributeDropdown.d.ts +2 -2
  62. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/BooleanAttributeDropdown.js +16 -31
  63. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/BooleanAttributeDropdown.js.map +1 -1
  64. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/ColorAttributeDropDown.d.ts +3 -0
  65. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/ColorAttributeDropDown.js +11 -0
  66. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/ColorAttributeDropDown.js.map +1 -0
  67. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/DateAttributeDropDown.d.ts +2 -2
  68. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/DateAttributeDropDown.js +13 -37
  69. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/DateAttributeDropDown.js.map +1 -1
  70. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/DateRangeAttributeDropDown.d.ts +3 -0
  71. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/DateRangeAttributeDropDown.js +11 -0
  72. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/DateRangeAttributeDropDown.js.map +1 -0
  73. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/EncryptedAttributeDropDown.d.ts +3 -0
  74. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/EncryptedAttributeDropDown.js +11 -0
  75. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/EncryptedAttributeDropDown.js.map +1 -0
  76. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/ExtendedAttributeDropDown.d.ts +3 -0
  77. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/ExtendedAttributeDropDown.js +11 -0
  78. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/ExtendedAttributeDropDown.js.map +1 -0
  79. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropDown.d.ts +1 -1
  80. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropDown.js +32 -20
  81. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropDown.js.map +1 -1
  82. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropdownContent.d.ts +7 -0
  83. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropdownContent.js +40 -0
  84. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropdownContent.js.map +1 -0
  85. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/FilterValueList.js.map +1 -1
  86. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/LinkAttributeDropdown.d.ts +3 -0
  87. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/LinkAttributeDropdown.js +79 -0
  88. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/LinkAttributeDropdown.js.map +1 -0
  89. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/NumericAttributeDropDown.d.ts +2 -2
  90. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/NumericAttributeDropDown.js +7 -32
  91. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/NumericAttributeDropDown.js.map +1 -1
  92. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/TextAttributeDropDown.d.ts +2 -2
  93. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/TextAttributeDropDown.js +7 -32
  94. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/TextAttributeDropDown.js.map +1 -1
  95. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/_types.d.ts +10 -0
  96. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/_types.js +2 -0
  97. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/_types.js.map +1 -0
  98. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/useConditionOptionsByType.d.ts +6 -4
  99. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/useConditionOptionsByType.js +17 -19
  100. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
  101. package/dist/components/Explorer/manage-view-settings/open-view-settings/SidePanel.js +1 -1
  102. package/dist/components/Explorer/manage-view-settings/open-view-settings/SidePanel.js.map +1 -1
  103. package/dist/components/Explorer/manage-view-settings/router-menu/SettingsPanel.js +14 -7
  104. package/dist/components/Explorer/manage-view-settings/router-menu/SettingsPanel.js.map +1 -1
  105. package/dist/components/Explorer/manage-view-settings/sort-items/SortItems.js +6 -2
  106. package/dist/components/Explorer/manage-view-settings/sort-items/SortItems.js.map +1 -1
  107. package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsInitialState.js +6 -0
  108. package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsInitialState.js.map +1 -1
  109. package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsReducer.d.ts +24 -8
  110. package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsReducer.js +50 -7
  111. package/dist/components/Explorer/manage-view-settings/store-view-settings/viewSettingsReducer.js.map +1 -1
  112. package/dist/components/Explorer/useColumnWidth.d.ts +6 -0
  113. package/dist/components/Explorer/useColumnWidth.js +48 -0
  114. package/dist/components/Explorer/useColumnWidth.js.map +1 -0
  115. package/dist/components/Explorer/useCreateAction.d.ts +4 -2
  116. package/dist/components/Explorer/useCreateAction.js +35 -2
  117. package/dist/components/Explorer/useCreateAction.js.map +1 -1
  118. package/dist/components/Explorer/useDeactivateMassAction.d.ts +27 -0
  119. package/dist/components/Explorer/useDeactivateMassAction.js +71 -0
  120. package/dist/components/Explorer/useDeactivateMassAction.js.map +1 -0
  121. package/dist/components/Explorer/useEditAction.js +3 -3
  122. package/dist/components/Explorer/useEditAction.js.map +1 -1
  123. package/dist/components/Explorer/useMassActions.d.ts +27 -0
  124. package/dist/components/Explorer/useMassActions.js +109 -0
  125. package/dist/components/Explorer/useMassActions.js.map +1 -0
  126. package/dist/components/Explorer/usePrimaryActions.js +14 -7
  127. package/dist/components/Explorer/usePrimaryActions.js.map +1 -1
  128. package/dist/components/Explorer/useRemoveAction.d.ts +23 -0
  129. package/dist/components/Explorer/useRemoveAction.js +109 -0
  130. package/dist/components/Explorer/useRemoveAction.js.map +1 -0
  131. package/dist/components/Explorer/useSearchInput.d.ts +10 -4
  132. package/dist/components/Explorer/useSearchInput.js +9 -1
  133. package/dist/components/Explorer/useSearchInput.js.map +1 -1
  134. package/dist/components/Explorer/useViewSettingsReducer.d.ts +2 -2
  135. package/dist/components/Explorer/useViewSettingsReducer.js +159 -54
  136. package/dist/components/Explorer/useViewSettingsReducer.js.map +1 -1
  137. package/dist/components/LibraryItemsList/LibraryItemsListTable/Cell/StandardCell/StandardCell.js +7 -2
  138. package/dist/components/LibraryItemsList/LibraryItemsListTable/Cell/StandardCell/StandardCell.js.map +1 -1
  139. package/dist/components/LibraryItemsList/LibraryItemsListTable/Header/Header.js +1 -1
  140. package/dist/components/LibraryItemsList/LibraryItemsListTable/Header/Header.js.map +1 -1
  141. package/dist/components/RecordEdition/EditRecord/EditRecord.js +58 -61
  142. package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
  143. package/dist/components/RecordEdition/EditRecordContent/EditRecordContent.js +4 -4
  144. package/dist/components/RecordEdition/EditRecordContent/EditRecordContent.js.map +1 -1
  145. package/dist/components/RecordEdition/EditRecordContent/_types.d.ts +1 -1
  146. package/dist/components/RecordEdition/EditRecordContent/helpers/extractFormElements/extractFormElements.d.ts +3 -1
  147. package/dist/components/RecordEdition/EditRecordContent/helpers/extractFormElements/extractFormElements.js +8 -2
  148. package/dist/components/RecordEdition/EditRecordContent/helpers/extractFormElements/extractFormElements.js.map +1 -1
  149. package/dist/components/RecordEdition/EditRecordContent/hooks/useExecuteSaveValueBatchMutation.js.map +1 -1
  150. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js +2 -2
  151. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js.map +1 -1
  152. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/ComputeIndicator.js +2 -4
  153. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/ComputeIndicator.js.map +1 -1
  154. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js +81 -25
  155. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js.map +1 -1
  156. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSBooleanWrapper.js +2 -1
  157. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSBooleanWrapper.js.map +1 -1
  158. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSColorPickerWrapper.js +47 -4
  159. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSColorPickerWrapper.js.map +1 -1
  160. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSDatePickerWrapper.js +9 -3
  161. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSDatePickerWrapper.js.map +1 -1
  162. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputEncryptedWrapper.js +16 -8
  163. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputEncryptedWrapper.js.map +1 -1
  164. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputNumberWrapper.js +6 -2
  165. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputNumberWrapper.js.map +1 -1
  166. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputWrapper.js +7 -14
  167. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputWrapper.js.map +1 -1
  168. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRangePickerWrapper.js +9 -3
  169. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRangePickerWrapper.js.map +1 -1
  170. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js +6 -6
  171. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js.map +1 -1
  172. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.d.ts +2 -2
  173. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.js +4 -15
  174. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.js.map +1 -1
  175. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/DSListSelect.js +5 -2
  176. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/DSListSelect.js.map +1 -1
  177. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/_types.d.ts +1 -1
  178. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/calculatedInheritedFlags.js +3 -2
  179. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/calculatedInheritedFlags.js.map +1 -1
  180. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/useGetPresentationValues.js +0 -5
  181. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/useGetPresentationValues.js.map +1 -1
  182. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +10 -4
  183. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
  184. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/AttributeSummary.d.ts +7 -0
  185. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/AttributeSummary.js +9 -0
  186. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/AttributeSummary.js.map +1 -0
  187. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/index.d.ts +2 -0
  188. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/index.js +6 -0
  189. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/index.js.map +1 -0
  190. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/useAttributeInformations.d.ts +2 -0
  191. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/useAttributeInformations.js +25 -0
  192. package/dist/components/RecordEdition/EditRecordSidebar/AttributeSummary/useAttributeInformations.js.map +1 -0
  193. package/dist/components/RecordEdition/EditRecordSidebar/Breacrumb/Breadcrumb.d.ts +3 -0
  194. package/dist/components/RecordEdition/EditRecordSidebar/Breacrumb/Breadcrumb.js +53 -0
  195. package/dist/components/RecordEdition/EditRecordSidebar/Breacrumb/Breadcrumb.js.map +1 -0
  196. package/dist/components/RecordEdition/EditRecordSidebar/Breacrumb/index.d.ts +2 -0
  197. package/dist/components/RecordEdition/EditRecordSidebar/Breacrumb/index.js +6 -0
  198. package/dist/components/RecordEdition/EditRecordSidebar/Breacrumb/index.js.map +1 -0
  199. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.d.ts +1 -0
  200. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js +35 -17
  201. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js.map +1 -1
  202. package/dist/components/RecordEdition/EditRecordSidebar/PropertiesList/PropertiesList.d.ts +4 -7
  203. package/dist/components/RecordEdition/EditRecordSidebar/PropertiesList/PropertiesList.js +6 -8
  204. package/dist/components/RecordEdition/EditRecordSidebar/PropertiesList/PropertiesList.js.map +1 -1
  205. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.d.ts +9 -0
  206. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js +42 -0
  207. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js.map +1 -0
  208. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.d.ts +6 -0
  209. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.js +35 -0
  210. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.js.map +1 -0
  211. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.d.ts +2 -281
  212. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.js +25 -56
  213. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.js.map +1 -1
  214. package/dist/components/RecordEdition/EditRecordSidebar/ValueDetails/ValueDetails.js +1 -13
  215. package/dist/components/RecordEdition/EditRecordSidebar/ValueDetails/ValueDetails.js.map +1 -1
  216. package/dist/components/RecordEdition/{EditRecordContent → EditRecordSkeleton}/EditRecordSkeleton.d.ts +1 -1
  217. package/dist/components/RecordEdition/{EditRecordContent → EditRecordSkeleton}/EditRecordSkeleton.js +2 -2
  218. package/dist/components/RecordEdition/EditRecordSkeleton/EditRecordSkeleton.js.map +1 -0
  219. package/dist/components/RecordEdition/EditRecordSkeleton/index.d.ts +2 -0
  220. package/dist/components/RecordEdition/EditRecordSkeleton/index.js +6 -0
  221. package/dist/components/RecordEdition/EditRecordSkeleton/index.js.map +1 -0
  222. package/dist/components/RecordEdition/index.d.ts +1 -0
  223. package/dist/components/RecordEdition/index.js +1 -0
  224. package/dist/components/RecordEdition/index.js.map +1 -1
  225. package/dist/constants.d.ts +3 -0
  226. package/dist/constants.js +3 -0
  227. package/dist/constants.js.map +1 -1
  228. package/dist/locales/en/shared.json +42 -10
  229. package/dist/locales/fr/shared.json +44 -12
  230. package/package.json +2 -2
  231. package/dist/components/Explorer/display-view-filters/ExplorerToolBar.d.ts +0 -4
  232. package/dist/components/Explorer/display-view-filters/ExplorerToolBar.js +0 -47
  233. package/dist/components/Explorer/display-view-filters/ExplorerToolBar.js.map +0 -1
  234. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/SimpleFilterDropDown.d.ts +0 -3
  235. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/SimpleFilterDropDown.js +0 -72
  236. package/dist/components/Explorer/manage-view-settings/filter-items/filter-type/SimpleFilterDropDown.js.map +0 -1
  237. package/dist/components/Explorer/nullValuesConditions.js.map +0 -1
  238. package/dist/components/Explorer/useDeactivateAction.d.ts +0 -12
  239. package/dist/components/Explorer/useDeactivateAction.js +0 -52
  240. package/dist/components/Explorer/useDeactivateAction.js.map +0 -1
  241. package/dist/components/RecordEdition/EditRecordContent/EditRecordSkeleton.js.map +0 -1
  242. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/useValueDetailsButton.d.ts +0 -8
  243. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/useValueDetailsButton.js +0 -23
  244. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/useValueDetailsButton.js.map +0 -1
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
+ // This file is released under LGPL V3
4
+ // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
+ import { closeKitSnackBar, KitCheckbox, KitDropDown, KitSpace, openKitSnackBar } from 'aristid-ds';
6
+ import { useCallback, useEffect } from 'react';
7
+ import { FaChevronDown } from 'react-icons/fa';
8
+ import { RecordFilterCondition, RecordFilterOperator } from '../../_gqlTypes';
9
+ import { useSharedTranslation } from '../../hooks/useSharedTranslation';
10
+ import { interleaveElement } from '../../_utils/interleaveElement';
11
+ import { MASS_SELECTION_ALL } from './_constants';
12
+ import { ViewSettingsActionTypes } from './manage-view-settings';
13
+ import { prepareFiltersForRequest } from './_queries/prepareFiltersForRequest';
14
+ /**
15
+ * Hook used to manage mass selection as the snackbar and all kind of selection (manual, all in page, all in filters)
16
+ *
17
+ * @param isEnabled - whether the selection is present
18
+ * @param view - represent the current view
19
+ * @param dispatch - method to change the current view
20
+ * @param totalCount - used for display purpose only
21
+ * @param allVisibleKeys - list of all ids currently selected
22
+ * @param massActions - array of all actions available on mass selection
23
+ */
24
+ export const useMassActions = ({ isEnabled, store: { dispatch, view }, totalCount, allVisibleKeys, massActions }) => {
25
+ const { t } = useSharedTranslation();
26
+ useEffect(() => {
27
+ if (view.massSelection === MASS_SELECTION_ALL || view.massSelection.length !== 0) {
28
+ openKitSnackBar({
29
+ duration: 0,
30
+ closable: true,
31
+ onClose: () => _setSelectedKeys([]),
32
+ message: t('explorer.massAction.selectedItems', {
33
+ count: view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length
34
+ }),
35
+ actions: massActions.map(({ label, icon, callback }, index) => ({
36
+ key: index,
37
+ label,
38
+ icon,
39
+ onClick: async () => {
40
+ await callback(view.massSelection === MASS_SELECTION_ALL
41
+ ? prepareFiltersForRequest(view.filters)
42
+ : interleaveElement({ operator: RecordFilterOperator.OR }, view.massSelection.map(key => [
43
+ {
44
+ field: 'id',
45
+ condition: RecordFilterCondition.EQUAL,
46
+ value: key
47
+ }
48
+ ])));
49
+ dispatch({
50
+ type: ViewSettingsActionTypes.SET_SELECTED_KEYS,
51
+ payload: []
52
+ });
53
+ }
54
+ }))
55
+ });
56
+ }
57
+ else {
58
+ closeKitSnackBar();
59
+ }
60
+ }, [view.massSelection, view.filters, totalCount]);
61
+ const isOnePage = view.pageSize > totalCount;
62
+ const hasSelectedAllAvailableItems = view.massSelection === MASS_SELECTION_ALL || view.massSelection.length === totalCount;
63
+ const hasSelectedSomeItems = view.massSelection !== MASS_SELECTION_ALL &&
64
+ view.massSelection.length > 0 &&
65
+ view.massSelection.length < totalCount;
66
+ const _selectAllButton = isOnePage ? (_jsx(KitCheckbox, { indeterminate: hasSelectedSomeItems, checked: hasSelectedAllAvailableItems, onChange: _ => {
67
+ if (hasSelectedAllAvailableItems) {
68
+ _setSelectedKeys([]);
69
+ }
70
+ else {
71
+ _setSelectedKeys(allVisibleKeys);
72
+ }
73
+ }, children: t('explorer.massAction.itemsTotal', { count: totalCount }) })) : (_jsx(KitDropDown, { trigger: ['click'], menu: {
74
+ items: [
75
+ hasSelectedAllAvailableItems
76
+ ? null
77
+ : {
78
+ key: 'toggle_page_selection',
79
+ label: t('explorer.massAction.toggle_selection.select_page', { count: view.pageSize }),
80
+ onClick: () => {
81
+ _setSelectedKeys([...new Set([...view.massSelection, ...allVisibleKeys])]);
82
+ }
83
+ },
84
+ {
85
+ key: 'toggle_all_selection',
86
+ label: hasSelectedAllAvailableItems
87
+ ? t('explorer.massAction.toggle_selection.deselect_all', { count: totalCount })
88
+ : t('explorer.massAction.toggle_selection.select_all', { count: totalCount }),
89
+ onClick: async () => {
90
+ if (hasSelectedAllAvailableItems) {
91
+ _setSelectedKeys([]);
92
+ }
93
+ else {
94
+ _setSelectedKeys(MASS_SELECTION_ALL);
95
+ }
96
+ }
97
+ }
98
+ ]
99
+ }, children: _jsx(KitCheckbox, { indeterminate: hasSelectedSomeItems, checked: hasSelectedAllAvailableItems, children: _jsxs(KitSpace, { size: "s", children: [t('explorer.massAction.itemsTotal', { count: totalCount }), _jsx(FaChevronDown, {})] }) }) }));
100
+ const _setSelectedKeys = useCallback((keys) => dispatch({
101
+ type: ViewSettingsActionTypes.SET_SELECTED_KEYS,
102
+ payload: keys
103
+ }), [dispatch]);
104
+ return {
105
+ selectAllButton: isEnabled ? _selectAllButton : null,
106
+ setSelectedKeys: isEnabled ? _setSelectedKeys : null
107
+ };
108
+ };
109
+ //# sourceMappingURL=useMassActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMassActions.js","sourceRoot":"","sources":["../../../src/components/Explorer/useMassActions.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,W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BAAkB,CAAC,CAAC;wBACzC,CAAC;oBACL,CAAC;iBACJ;aACJ;SACJ,YAED,KAAC,WAAW,IAAC,aAAa,EAAE,oBAAoB,EAAE,OAAO,EAAE,4BAA4B,YACnF,MAAC,QAAQ,IAAC,IAAI,EAAC,GAAG,aACb,CAAC,CAAC,gCAAgC,EAAE,EAAC,KAAK,EAAE,UAAU,EAAC,CAAC,EACzD,KAAC,aAAa,KAAG,IACV,GACD,GACJ,CACjB,CAAC;IAEF,MAAM,gBAAgB,GAAG,WAAW,CAChC,CAAC,IAAmB,EAAE,EAAE,CACpB,QAAQ,CAAC;QACL,IAAI,EAAE,uBAAuB,CAAC,iBAAiB;QAC/C,OAAO,EAAE,IAAI;KAChB,CAAC,EACN,CAAC,QAAQ,CAAC,CACb,CAAC;IAEF,OAAO;QACH,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;QACpD,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI;KACvD,CAAC;AACN,CAAC,CAAC"}
@@ -1,5 +1,9 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { KitButton, KitSpace } from 'aristid-ds';
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
+ // This file is released under LGPL V3
4
+ // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
+ import { FaEllipsisV } from 'react-icons/fa';
6
+ import { KitButton, KitDropDown, KitSpace } from 'aristid-ds';
3
7
  /**
4
8
  * Hook used to get the primary actions for `<DataView />` component.
5
9
  *
@@ -11,11 +15,14 @@ import { KitButton, KitSpace } from 'aristid-ds';
11
15
  export const usePrimaryActionsButton = (actions) => {
12
16
  const [firstAction, ...dropdownActions] = actions;
13
17
  return {
14
- primaryButton: actions.length === 0 ? null : (_jsx(KitButton, { type: "primary", icon: firstAction.icon, onClick: firstAction.callback, items: dropdownActions.map((action, index) => ({
15
- key: index,
16
- label: (_jsxs(KitSpace, { size: 8, children: [action.icon, " ", action.label] })),
17
- onClick: action.callback
18
- })), children: firstAction.label }))
18
+ primaryButton: actions.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx(KitButton, { type: "primary", icon: firstAction.icon, disabled: firstAction.disabled, onClick: firstAction.callback, children: firstAction.label }), dropdownActions.length > 0 && (_jsx(KitDropDown, { trigger: ['click'], menu: {
19
+ items: dropdownActions.map((action, index) => ({
20
+ key: index,
21
+ label: (_jsxs(KitSpace, { size: 8, children: [action.icon, " ", action.label] })),
22
+ disabled: action.disabled,
23
+ onClick: action.callback
24
+ }))
25
+ }, children: _jsx(KitButton, { "data-testid": "actions-dropdown", type: "secondary", icon: _jsx(FaEllipsisV, {}) }) }))] }))
19
26
  };
20
27
  };
21
28
  //# sourceMappingURL=usePrimaryActions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePrimaryActions.js","sourceRoot":"","sources":["../../../src/components/Explorer/usePrimaryActions.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAyB,EAAE,EAAE;IACjE,MAAM,CAAC,WAAW,EAAE,GAAG,eAAe,CAAC,GAAG,OAAO,CAAC;IAElD,OAAO;QACH,aAAa,EACT,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC1B,KAAC,SAAS,IACN,IAAI,EAAC,SAAS,EACd,IAAI,EAAE,WAAW,CAAC,IAAI,EACtB,OAAO,EAAE,WAAW,CAAC,QAAQ,EAC7B,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC3C,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,EAAE,CAAC,aACZ,MAAM,CAAC,IAAI,OAAG,MAAM,CAAC,KAAK,IACpB,CACd;4BACD,QAAQ,EAAE,MAAM,CAAC,QAAQ;4BACzB,OAAO,EAAE,MAAM,CAAC,QAAQ;yBAC3B,CAAC,CAAC;qBACN,YAED,KAAC,SAAS,mBAAa,kBAAkB,EAAC,IAAI,EAAC,WAAW,EAAC,IAAI,EAAE,KAAC,WAAW,KAAG,GAAI,GAC1E,CACjB,IACF,CACN;KACR,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Dispatch } from 'react';
2
+ import { ActionHook, Entrypoint, IItemAction } from './_types';
3
+ import { IViewSettingsAction, IViewSettingsState } from '../../components/Explorer/manage-view-settings';
4
+ /**
5
+ * Hook used to get the action for `<DataView />` component.
6
+ *
7
+ * When the mutation for removing is done, the Apollo cache will be clean (`Record` and `RecordIdentity`)
8
+ * from removed record.
9
+ *
10
+ * @param isEnabled - whether the action is present
11
+ * @param view - represent the current view
12
+ * @param dispatch - method to change the current view
13
+ * @param entrypoint - represent the current entrypoint
14
+ */
15
+ export declare const useRemoveAction: ({ isEnabled, store: { view, dispatch }, entrypoint }: ActionHook<{
16
+ store: {
17
+ view: IViewSettingsState;
18
+ dispatch: Dispatch<IViewSettingsAction>;
19
+ };
20
+ entrypoint: Entrypoint;
21
+ }>) => {
22
+ removeAction: IItemAction;
23
+ };
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
+ // This file is released under LGPL V3
4
+ // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
+ import { useMemo } from 'react';
6
+ import { FaTrash } from 'react-icons/fa';
7
+ import { KitModal } from 'aristid-ds';
8
+ import { useDeactivateRecordsMutation, useDeleteValueMutation } from '../../_gqlTypes';
9
+ import { useSharedTranslation } from '../../hooks/useSharedTranslation';
10
+ import { useValuesCacheUpdate } from '../../hooks/useValuesCacheUpdate';
11
+ import { ViewSettingsActionTypes } from '../../components/Explorer/manage-view-settings';
12
+ import { MASS_SELECTION_ALL } from '../../components/Explorer/_constants';
13
+ /**
14
+ * Hook used to get the action for `<DataView />` component.
15
+ *
16
+ * When the mutation for removing is done, the Apollo cache will be clean (`Record` and `RecordIdentity`)
17
+ * from removed record.
18
+ *
19
+ * @param isEnabled - whether the action is present
20
+ * @param view - represent the current view
21
+ * @param dispatch - method to change the current view
22
+ * @param entrypoint - represent the current entrypoint
23
+ */
24
+ export const useRemoveAction = ({ isEnabled, store: { view, dispatch }, entrypoint }) => {
25
+ const { t } = useSharedTranslation();
26
+ const updateValuesCache = useValuesCacheUpdate();
27
+ const [deactivateRecordsMutation] = useDeactivateRecordsMutation({
28
+ update(cache, deactivatedRecords) {
29
+ deactivatedRecords.data?.deactivateRecords.forEach(record => {
30
+ cache.evict({
31
+ id: cache.identify(record)
32
+ });
33
+ });
34
+ cache.modify({
35
+ fields: {
36
+ records: prev => ({
37
+ ...prev,
38
+ totalCount: prev.totalCount - 1
39
+ })
40
+ },
41
+ broadcast: false
42
+ });
43
+ cache.gc();
44
+ }
45
+ });
46
+ const [deleteRecordLinkMutation] = useDeleteValueMutation({
47
+ update: (_, deletedRecord) => {
48
+ const parentRecord = {
49
+ id: entrypoint.parentRecordId,
50
+ library: {
51
+ id: entrypoint.parentLibraryId
52
+ }
53
+ };
54
+ updateValuesCache(parentRecord, deletedRecord.data?.deleteValue ?? []);
55
+ }
56
+ });
57
+ const _removeAction = useMemo(() => ({
58
+ label: entrypoint.type === 'library' ? t('explorer.deactivate-item') : t('explorer.delete-item'),
59
+ icon: _jsx(FaTrash, {}),
60
+ isDanger: true,
61
+ callback: ({ itemId, libraryId, id_value }) => {
62
+ KitModal.confirm({
63
+ type: 'confirm',
64
+ dangerConfirm: true,
65
+ content: entrypoint.type === 'library'
66
+ ? t('records_deactivation.confirm_one')
67
+ : t('record_edition.delete_link_confirm'),
68
+ okText: t('global.submit') ?? undefined,
69
+ cancelText: t('global.cancel') ?? undefined,
70
+ onOk: async () => {
71
+ switch (entrypoint.type) {
72
+ case 'library':
73
+ const res = await deactivateRecordsMutation({
74
+ variables: {
75
+ libraryId,
76
+ recordsIds: [itemId]
77
+ }
78
+ });
79
+ if (view.massSelection !== MASS_SELECTION_ALL) {
80
+ dispatch({
81
+ type: ViewSettingsActionTypes.SET_SELECTED_KEYS,
82
+ payload: view.massSelection.filter(key => key !== itemId)
83
+ });
84
+ }
85
+ return res;
86
+ case 'link':
87
+ return deleteRecordLinkMutation({
88
+ variables: {
89
+ library: entrypoint.parentLibraryId,
90
+ attribute: entrypoint.linkAttributeId,
91
+ recordId: entrypoint.parentRecordId,
92
+ value: {
93
+ payload: itemId,
94
+ id_value
95
+ }
96
+ }
97
+ });
98
+ default:
99
+ return;
100
+ }
101
+ }
102
+ });
103
+ }
104
+ }), [t, deactivateRecordsMutation, deleteRecordLinkMutation, entrypoint.type, view.massSelection, dispatch]);
105
+ return {
106
+ removeAction: isEnabled ? _removeAction : null
107
+ };
108
+ };
109
+ //# sourceMappingURL=useRemoveAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRemoveAction.js","sourceRoot":"","sources":["../../../src/components/Explorer/useRemoveAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAW,OAAO,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,4BAA4B,EAAE,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAGH,uBAAuB,EAC1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EA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AO,wBAAwB,CAAC;gCAC5B,SAAS,EAAE;oCACP,OAAO,EAAE,UAAU,CAAC,eAAe;oCACnC,SAAS,EAAE,UAAU,CAAC,eAAe;oCACrC,QAAQ,EAAE,UAAU,CAAC,cAAc;oCACnC,KAAK,EAAE;wCACH,OAAO,EAAE,MAAM;wCACf,QAAQ;qCACX;iCACJ;6BACJ,CAAC,CAAC;wBACP;4BACI,OAAO;oBACf,CAAC;gBACL,CAAC;aACJ,CAAC,CAAC;QACP,CAAC;KACJ,CAAC,EACF,CAAC,CAAC,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAC1G,CAAC;IAEF,OAAO;QACH,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI;KACjD,CAAC;AACN,CAAC,CAAC"}
@@ -1,10 +1,16 @@
1
1
  import { Dispatch } from 'react';
2
2
  import { IViewSettingsAction, IViewSettingsState } from './manage-view-settings/store-view-settings/viewSettingsReducer';
3
- interface IUseSearchInputParams {
3
+ /**
4
+ * Hook used to handle a full search text in a library
5
+ *
6
+ * > The feature is hidden on a link entrypoint.
7
+ *
8
+ * @param view - represent the current view
9
+ * @param dispatch - method to change the current view
10
+ */
11
+ export declare const useSearchInput: ({ view, dispatch }: {
4
12
  view: IViewSettingsState;
5
13
  dispatch: Dispatch<IViewSettingsAction>;
6
- }
7
- export declare const useSearchInput: ({ view, dispatch }: IUseSearchInputParams) => {
14
+ }) => {
8
15
  searchInput: JSX.Element;
9
16
  };
10
- export {};
@@ -8,6 +8,14 @@ import { useState } from 'react';
8
8
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
9
  import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons';
10
10
  import { ViewSettingsActionTypes } from './manage-view-settings/store-view-settings/viewSettingsReducer';
11
+ /**
12
+ * Hook used to handle a full search text in a library
13
+ *
14
+ * > The feature is hidden on a link entrypoint.
15
+ *
16
+ * @param view - represent the current view
17
+ * @param dispatch - method to change the current view
18
+ */
11
19
  export const useSearchInput = ({ view, dispatch }) => {
12
20
  const { t } = useSharedTranslation();
13
21
  const [search, setSearch] = useState(view.fulltextSearch);
@@ -25,7 +33,7 @@ export const useSearchInput = ({ view, dispatch }) => {
25
33
  dispatch({ type: ViewSettingsActionTypes.CHANGE_FULLTEXT_SEARCH, payload: { search } });
26
34
  };
27
35
  return {
28
- searchInput: (_jsx("form", { onSubmit: _handleSubmit, children: _jsx(KitInput, { prefix: _jsx(FontAwesomeIcon, { icon: faMagnifyingGlass }), title: String(t('global.search')), placeholder: String(t('global.search')), value: search ?? '', onChange: _handleChange }) }))
36
+ searchInput: view.entrypoint.type === 'library' ? (_jsx("form", { onSubmit: _handleSubmit, children: _jsx(KitInput, { prefix: _jsx(FontAwesomeIcon, { icon: faMagnifyingGlass }), title: String(t('global.search')), placeholder: String(t('global.search')), value: search ?? '', onChange: _handleChange }) })) : null
29
37
  };
30
38
  };
31
39
  //# sourceMappingURL=useSearchInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSearchInput.js","sourceRoot":"","sources":["../../../src/components/Explorer/useSearchInput.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAA0C,QAAQ,EAAC,MAAM,OAAO,CAAC;AACxE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAGH,uBAAuB,EAC1B,MAAM,gEAAgE,CAAC;AAOxE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAwB,EAAE,EAAE;IACtE,MAAM,EAA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BAAiB,GAAI,EACpD,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,EACjC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,EACvC,KAAK,EAAE,MAAM,IAAI,EAAE,EACnB,QAAQ,EAAE,aAAa,GACzB,GACC,CACV,CAAC,CAAC,CAAC,IAAI;KACf,CAAC;AACN,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
- import { DefaultViewSettings } from './_types';
1
+ import { DefaultViewSettings, Entrypoint } from './_types';
2
2
  import { IViewSettingsState } from './manage-view-settings';
3
- export declare const useViewSettingsReducer: (library: string, defaultViewSettings?: DefaultViewSettings) => {
3
+ export declare const useViewSettingsReducer: (entrypoint: Entrypoint, defaultViewSettings?: DefaultViewSettings) => {
4
4
  loading: boolean;
5
5
  error: import("@apollo/client").ApolloError;
6
6
  view: IViewSettingsState;
@@ -1,82 +1,187 @@
1
1
  // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
2
2
  // This file is released under LGPL V3
3
3
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
4
- import { useExplorerAttributesQuery, useGetViewsListQuery } from '../../_gqlTypes';
4
+ import { useExplorerAttributesQuery, useExplorerLinkAttributeQuery, useGetViewsListQuery } from '../../_gqlTypes';
5
5
  import { localizedTranslation } from '@leav/utils';
6
6
  import { useLang } from '../../hooks';
7
- import { useEffect, useMemo, useReducer } from 'react';
7
+ import { useEffect, useMemo, useReducer, useState } from 'react';
8
8
  import { v4 as uuid } from 'uuid';
9
- import { viewSettingsReducer, viewSettingsInitialState } from './manage-view-settings';
9
+ import { viewSettingsInitialState, viewSettingsReducer } from './manage-view-settings';
10
10
  import { mapViewTypeFromLegacyToExplorer } from './_constants';
11
- const _isValidFieldFilter = (filter) => !!filter.field && !!filter.condition;
12
- export const useViewSettingsReducer = (library, defaultViewSettings = {}) => {
11
+ import { ThroughConditionFilter } from '../../types';
12
+ import { isLinkAttribute, isStandardAttribute } from '../../_utils/attributeType';
13
+ const _isValidFieldFilter = (filter) => !!filter.field;
14
+ const _isValidFieldFilterThrough = (filter) => filter.condition === ThroughConditionFilter.THROUGH && !!filter.subCondition && !!filter.subField;
15
+ const _isLinkAttributeDetails = (linkAttributeData) => 'linked_library' in linkAttributeData;
16
+ const _entrypointsAreEqual = (entrypoint1, entrypoint2) => Object.keys(entrypoint1).every(key => entrypoint1[key] === entrypoint2[key]);
17
+ export const useViewSettingsReducer = (entrypoint, defaultViewSettings = {}) => {
13
18
  const { lang } = useLang();
19
+ const [loading, setLoading] = useState(true);
20
+ const [libraryId, setLibraryId] = useState(entrypoint.type === 'library' ? entrypoint.libraryId : null);
14
21
  const [view, dispatch] = useReducer(viewSettingsReducer, viewSettingsInitialState);
22
+ const entrypointsAreEqual = _entrypointsAreEqual(entrypoint, view.entrypoint);
23
+ useExplorerLinkAttributeQuery({
24
+ skip: entrypoint.type !== 'link',
25
+ variables: {
26
+ id: entrypoint.linkAttributeId
27
+ },
28
+ onCompleted: data => {
29
+ const attributeData = data?.attributes?.list?.[0];
30
+ if (!attributeData) {
31
+ throw new Error('Unknown link attribute');
32
+ }
33
+ setLibraryId(_isLinkAttributeDetails(attributeData) ? (attributeData.linked_library?.id ?? '') : null);
34
+ }
35
+ });
15
36
  const { data: viewData, loading: viewsLoading, error: viewError } = useGetViewsListQuery({
37
+ skip: entrypointsAreEqual || libraryId === null,
38
+ fetchPolicy: 'network-only',
16
39
  variables: {
17
- libraryId: library
40
+ libraryId: libraryId
18
41
  }
19
42
  });
20
43
  // Take the last view from the array
21
44
  const userView = viewData?.views?.list?.at(-1);
22
- const userViewFilters = userView?.filters
23
- ?.filter(filter => _isValidFieldFilter(filter))
24
- .map(filter => ({
25
- field: filter.field,
26
- value: filter.value ?? null,
27
- condition: filter.condition
28
- })) ?? [];
45
+ const userViewFilters = userView?.filters?.reduce((acc, filter) => {
46
+ if (!_isValidFieldFilter(filter)) {
47
+ return acc;
48
+ }
49
+ const _isThroughFilter = filter.field.includes('.');
50
+ if (_isThroughFilter) {
51
+ const [field, subField] = filter.field.split('.');
52
+ const throughFilter = {
53
+ field,
54
+ subField,
55
+ value: filter.value ?? null,
56
+ condition: ThroughConditionFilter.THROUGH,
57
+ subCondition: filter.condition
58
+ };
59
+ acc.push(throughFilter);
60
+ }
61
+ else {
62
+ acc.push(filter);
63
+ }
64
+ return acc;
65
+ }, []) ?? [];
66
+ const preparedDefaultFilters = defaultViewSettings.filters?.reduce((acc, filter) => {
67
+ if (!_isValidFieldFilter(filter)) {
68
+ return acc;
69
+ }
70
+ const _isThroughFilter = filter.field.includes('.');
71
+ const [field, subField] = filter.field.split('.');
72
+ if (_isThroughFilter) {
73
+ const throughFilter = {
74
+ field,
75
+ subField,
76
+ value: filter.value ?? null,
77
+ condition: ThroughConditionFilter.THROUGH,
78
+ subCondition: filter.condition
79
+ };
80
+ acc.push(throughFilter);
81
+ }
82
+ else {
83
+ acc.push(filter);
84
+ }
85
+ return acc;
86
+ }, []) ?? [];
29
87
  const attributesToHydrate = [
30
88
  ...new Set([
31
- ...(defaultViewSettings.filters?.map(filter => filter.field) ?? []),
32
- ...(defaultViewSettings.sort?.map(sort => sort.field) ?? []),
33
- ...userViewFilters.map(filter => String(filter.field)),
34
- ...(userView?.sort?.map(sort => sort.field) ?? [])
35
- ])
89
+ ...(preparedDefaultFilters ?? []),
90
+ ...(defaultViewSettings.sort ?? []),
91
+ ...userViewFilters,
92
+ ...(userView?.sort ?? [])
93
+ ].map(({ field }) => field))
36
94
  ];
37
95
  const { data: attributesData, loading: attributesLoading, error: attributesError } = useExplorerAttributesQuery({
38
96
  variables: {
39
97
  ids: attributesToHydrate
40
98
  },
41
- skip: viewsLoading || !attributesToHydrate.length
99
+ skip: libraryId === null || viewsLoading || attributesToHydrate.length === 0
42
100
  });
43
101
  const attributesDataById = useMemo(() => (attributesData?.attributes?.list ?? []).reduce((acc, attr) => {
44
102
  acc[attr.id] = attr;
45
103
  return acc;
46
104
  }, {}), [attributesData]);
47
- const hydratedSettings = useMemo(() => ({
48
- ...viewSettingsInitialState,
49
- viewId: userView?.id,
50
- attributesIds: (userView?.attributes ?? []).map(attr => attr.id),
51
- viewType: userView?.display
52
- ? mapViewTypeFromLegacyToExplorer[userView.display.type]
53
- : viewSettingsInitialState.viewType,
54
- ...defaultViewSettings,
55
- sort: [...(defaultViewSettings?.sort ?? []), ...(userView?.sort ?? [])].map(s => ({
56
- field: s.field,
57
- order: s.order
58
- })),
59
- filters: [...(defaultViewSettings?.filters ?? []), ...userViewFilters].reduce((acc, filter) => {
60
- if (!attributesDataById[filter.field]) {
61
- console.warn(`Attribute ${filter.field} from defaultViewSettings or user view not found in database.`);
62
- return acc;
63
- }
64
- return [
65
- ...acc,
66
- {
67
- ...filter,
68
- value: filter.value ?? null,
69
- id: uuid(),
70
- attribute: {
105
+ useEffect(() => {
106
+ setLoading(true);
107
+ setLibraryId(entrypoint.type === 'library' ? entrypoint.libraryId : null);
108
+ }, [entrypoint]);
109
+ useEffect(() => {
110
+ if (libraryId !== null && !viewsLoading && !attributesLoading) {
111
+ const allFilters = [...preparedDefaultFilters, ...userViewFilters];
112
+ const hydratedSettings = {
113
+ ...viewSettingsInitialState,
114
+ entrypoint,
115
+ libraryId,
116
+ viewId: userView?.id,
117
+ viewType: userView?.display
118
+ ? mapViewTypeFromLegacyToExplorer[userView.display.type]
119
+ : viewSettingsInitialState.viewType,
120
+ ...defaultViewSettings,
121
+ attributesIds: [
122
+ ...(userView?.attributes ?? []).map(attr => attr.id),
123
+ ...(defaultViewSettings?.attributesIds ?? [])
124
+ ],
125
+ sort: [...(defaultViewSettings?.sort ?? []), ...(userView?.sort ?? [])].map(s => ({
126
+ field: s.field,
127
+ order: s.order
128
+ })),
129
+ filters: allFilters.reduce((acc, filter) => {
130
+ if (!attributesDataById[filter.field]) {
131
+ console.warn(`Attribute ${filter.field} from defaultViewSettings or user view not found in database.`);
132
+ return acc;
133
+ }
134
+ const filterAttributeBase = {
71
135
  label: localizedTranslation(attributesDataById[filter.field].label, lang),
72
- format: attributesDataById[filter.field].format
136
+ type: attributesDataById[filter.field].type
137
+ };
138
+ // filter is standardFilter
139
+ if (isStandardAttribute(filterAttributeBase.type)) {
140
+ const newFilter = {
141
+ field: filter.field,
142
+ value: filter.value ?? null,
143
+ id: uuid(),
144
+ condition: filter.condition ?? null,
145
+ attribute: {
146
+ ...filterAttributeBase,
147
+ format: attributesDataById[filter.field].format
148
+ }
149
+ };
150
+ acc.push(newFilter);
73
151
  }
74
- }
75
- ];
76
- }, [])
77
- }), [defaultViewSettings, attributesDataById, userView, userViewFilters, lang]);
78
- useEffect(() => {
79
- if (!attributesLoading) {
152
+ if (isLinkAttribute(filterAttributeBase.type)) {
153
+ if (_isValidFieldFilterThrough(filter)) {
154
+ const newFilter = {
155
+ field: filter.field,
156
+ value: filter.value ?? null,
157
+ id: uuid(),
158
+ condition: filter.condition,
159
+ attribute: {
160
+ ...filterAttributeBase,
161
+ linkedLibrary: attributesDataById[filter.field].linked_library
162
+ },
163
+ subCondition: filter.subCondition ?? null,
164
+ subField: filter.subField
165
+ };
166
+ acc.push(newFilter);
167
+ }
168
+ else {
169
+ const newFilter = {
170
+ field: filter.field,
171
+ value: filter.value ?? null,
172
+ id: uuid(),
173
+ condition: filter.condition,
174
+ attribute: {
175
+ ...filterAttributeBase,
176
+ linkedLibrary: attributesDataById[filter.field].linked_library
177
+ }
178
+ };
179
+ acc.push(newFilter);
180
+ }
181
+ }
182
+ return acc;
183
+ }, [])
184
+ };
80
185
  dispatch({
81
186
  type: 'RESET',
82
187
  payload: {
@@ -90,14 +195,14 @@ export const useViewSettingsReducer = (library, defaultViewSettings = {}) => {
90
195
  }
91
196
  }
92
197
  });
198
+ setLoading(false);
93
199
  }
94
- }, [attributesLoading]);
95
- const res = {
96
- loading: attributesLoading || viewsLoading,
200
+ }, [attributesLoading, viewsLoading, libraryId]);
201
+ return {
202
+ loading,
97
203
  error: viewError ?? attributesError,
98
204
  view,
99
205
  dispatch
100
206
  };
101
- return res;
102
207
  };
103
208
  //# sourceMappingURL=useViewSettingsReducer.js.map