@akemona-org/strapi-plugin-content-manager 3.7.0

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 (401) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +27 -0
  3. package/admin/src/InjectedComponents/ContentTypeBuilder/ConfigureViewButton/index.js +78 -0
  4. package/admin/src/assets/images/background_input.svg +1 -0
  5. package/admin/src/assets/images/icon-cross-blue.svg +1 -0
  6. package/admin/src/assets/images/icon_remove.svg +19 -0
  7. package/admin/src/assets/images/logo.svg +1 -0
  8. package/admin/src/components/AddDropdown/components.js +113 -0
  9. package/admin/src/components/AddDropdown/index.js +76 -0
  10. package/admin/src/components/Block/components.js +28 -0
  11. package/admin/src/components/Block/index.js +45 -0
  12. package/admin/src/components/ComponentInitializer/P.js +9 -0
  13. package/admin/src/components/ComponentInitializer/index.js +43 -0
  14. package/admin/src/components/Container/index.js +7 -0
  15. package/admin/src/components/CustomInputCheckbox/components.js +77 -0
  16. package/admin/src/components/CustomInputCheckbox/index.js +53 -0
  17. package/admin/src/components/CustomTable/ActionCollapse/Delete.js +14 -0
  18. package/admin/src/components/CustomTable/ActionCollapse/DeleteAll.js +18 -0
  19. package/admin/src/components/CustomTable/ActionCollapse/Wrapper.js +20 -0
  20. package/admin/src/components/CustomTable/ActionCollapse/index.js +38 -0
  21. package/admin/src/components/CustomTable/Headers/Header.js +59 -0
  22. package/admin/src/components/CustomTable/Headers/Thead.js +35 -0
  23. package/admin/src/components/CustomTable/Headers/index.js +46 -0
  24. package/admin/src/components/CustomTable/Row/ActionContainer.js +19 -0
  25. package/admin/src/components/CustomTable/Row/Cell.js +55 -0
  26. package/admin/src/components/CustomTable/Row/index.js +112 -0
  27. package/admin/src/components/CustomTable/index.js +162 -0
  28. package/admin/src/components/CustomTable/styledComponents.js +85 -0
  29. package/admin/src/components/DragLayer/index.js +102 -0
  30. package/admin/src/components/DraggedField/Close/index.js +10 -0
  31. package/admin/src/components/DraggedField/GrabWrapper.js +38 -0
  32. package/admin/src/components/DraggedField/Link.js +17 -0
  33. package/admin/src/components/DraggedField/NameWrapper.js +29 -0
  34. package/admin/src/components/DraggedField/RemoveWrapper.js +32 -0
  35. package/admin/src/components/DraggedField/SubWrapper.js +36 -0
  36. package/admin/src/components/DraggedField/Wrapper.js +134 -0
  37. package/admin/src/components/DraggedField/index.js +196 -0
  38. package/admin/src/components/DraggedField/utils/getColor.js +12 -0
  39. package/admin/src/components/DraggedField/utils/getHeight.js +3 -0
  40. package/admin/src/components/DraggedFieldWithPreview/Carret.js +24 -0
  41. package/admin/src/components/DraggedFieldWithPreview/DynamicComponent.js +70 -0
  42. package/admin/src/components/DraggedFieldWithPreview/DynamicZoneWrapper.js +10 -0
  43. package/admin/src/components/DraggedFieldWithPreview/Tooltip.js +19 -0
  44. package/admin/src/components/DraggedFieldWithPreview/Wrapper.js +24 -0
  45. package/admin/src/components/DraggedFieldWithPreview/index.js +194 -0
  46. package/admin/src/components/DynamicComponentCard/Wrapper.js +63 -0
  47. package/admin/src/components/DynamicComponentCard/index.js +49 -0
  48. package/admin/src/components/DynamicZone/BaselineAlignement.js +11 -0
  49. package/admin/src/components/DynamicZone/Button.js +31 -0
  50. package/admin/src/components/DynamicZone/Component/RoundCTA.js +45 -0
  51. package/admin/src/components/DynamicZone/Component/index.js +79 -0
  52. package/admin/src/components/DynamicZone/ComponentWrapper.js +44 -0
  53. package/admin/src/components/DynamicZone/DynamicZoneWrapper.js +12 -0
  54. package/admin/src/components/DynamicZone/Label.js +42 -0
  55. package/admin/src/components/DynamicZone/Picker/Category/Banner/Wrapper.js +78 -0
  56. package/admin/src/components/DynamicZone/Picker/Category/Banner/index.js +33 -0
  57. package/admin/src/components/DynamicZone/Picker/Category/index.js +53 -0
  58. package/admin/src/components/DynamicZone/Picker/Wrapper.js +32 -0
  59. package/admin/src/components/DynamicZone/Picker/index.js +88 -0
  60. package/admin/src/components/DynamicZone/Wrapper.js +34 -0
  61. package/admin/src/components/DynamicZone/index.js +238 -0
  62. package/admin/src/components/DynamicZone/utils/connect.js +12 -0
  63. package/admin/src/components/DynamicZone/utils/select.js +49 -0
  64. package/admin/src/components/FieldComponent/ComponentIcon.js +44 -0
  65. package/admin/src/components/FieldComponent/EmptyComponent.js +19 -0
  66. package/admin/src/components/FieldComponent/Label.js +10 -0
  67. package/admin/src/components/FieldComponent/ResetComponent.js +41 -0
  68. package/admin/src/components/FieldComponent/Wrapper.js +18 -0
  69. package/admin/src/components/FieldComponent/index.js +171 -0
  70. package/admin/src/components/FieldComponent/utils/connect.js +12 -0
  71. package/admin/src/components/FieldComponent/utils/select.js +123 -0
  72. package/admin/src/components/FieldsReorder/Item.js +249 -0
  73. package/admin/src/components/FieldsReorder/components.js +8 -0
  74. package/admin/src/components/FieldsReorder/index.js +102 -0
  75. package/admin/src/components/FilterOptionsCTA/index.js +14 -0
  76. package/admin/src/components/FilterPicker/components.js +56 -0
  77. package/admin/src/components/FilterPicker/index.js +258 -0
  78. package/admin/src/components/FilterPicker/init.js +25 -0
  79. package/admin/src/components/FilterPicker/reducer.js +58 -0
  80. package/admin/src/components/FilterPickerOption/Input.js +58 -0
  81. package/admin/src/components/FilterPickerOption/Option.js +18 -0
  82. package/admin/src/components/FilterPickerOption/components.js +60 -0
  83. package/admin/src/components/FilterPickerOption/index.js +101 -0
  84. package/admin/src/components/FormTitle/index.js +26 -0
  85. package/admin/src/components/FormWrapper/index.js +20 -0
  86. package/admin/src/components/InputJSON/components.js +30 -0
  87. package/admin/src/components/InputJSON/index.js +184 -0
  88. package/admin/src/components/InputJSON/jsonlint.js +424 -0
  89. package/admin/src/components/InputJSONWithErrors/Wrapper.js +32 -0
  90. package/admin/src/components/InputJSONWithErrors/index.js +168 -0
  91. package/admin/src/components/InputUID/InputUID.js +26 -0
  92. package/admin/src/components/InputUID/Options/Option.js +22 -0
  93. package/admin/src/components/InputUID/Options/OptionsTitle.js +12 -0
  94. package/admin/src/components/InputUID/Options/RightOptionLabel.js +10 -0
  95. package/admin/src/components/InputUID/Options/index.js +34 -0
  96. package/admin/src/components/InputUID/Options/wrapper.js +13 -0
  97. package/admin/src/components/InputUID/RegenerateButton.js +18 -0
  98. package/admin/src/components/InputUID/RightContent.js +14 -0
  99. package/admin/src/components/InputUID/RightContentLabel.js +10 -0
  100. package/admin/src/components/InputUID/RightLabel.js +42 -0
  101. package/admin/src/components/InputUID/SubLabel.js +9 -0
  102. package/admin/src/components/InputUID/Wrapper.js +8 -0
  103. package/admin/src/components/InputUID/index.js +325 -0
  104. package/admin/src/components/InputUID/regex.js +3 -0
  105. package/admin/src/components/Inputs/index.js +283 -0
  106. package/admin/src/components/Inputs/utils/VALIDATIONS_TO_OMIT.js +12 -0
  107. package/admin/src/components/Inputs/utils/connect.js +12 -0
  108. package/admin/src/components/Inputs/utils/generateOptions.js +19 -0
  109. package/admin/src/components/Inputs/utils/getInputType.js +44 -0
  110. package/admin/src/components/Inputs/utils/getStep.js +15 -0
  111. package/admin/src/components/Inputs/utils/index.js +6 -0
  112. package/admin/src/components/Inputs/utils/select.js +38 -0
  113. package/admin/src/components/LayoutTitle/index.js +19 -0
  114. package/admin/src/components/MediaPreviewList/StyledMediaPreviewList.js +171 -0
  115. package/admin/src/components/MediaPreviewList/index.js +110 -0
  116. package/admin/src/components/NonRepeatableComponent/index.js +73 -0
  117. package/admin/src/components/NonRepeatableWrapper/index.js +73 -0
  118. package/admin/src/components/PlusButton/index.js +52 -0
  119. package/admin/src/components/PopupForm/index.js +93 -0
  120. package/admin/src/components/PreviewCarret/components.js +27 -0
  121. package/admin/src/components/PreviewCarret/index.js +22 -0
  122. package/admin/src/components/PreviewWysiwyg/Wrapper.js +133 -0
  123. package/admin/src/components/PreviewWysiwyg/index.js +34 -0
  124. package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +72 -0
  125. package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +16 -0
  126. package/admin/src/components/RelationPreviewList/CountWrapper.js +7 -0
  127. package/admin/src/components/RelationPreviewList/RelationPreviewTooltip.js +117 -0
  128. package/admin/src/components/RelationPreviewList/index.js +111 -0
  129. package/admin/src/components/RepeatableComponent/AddFieldButton.js +64 -0
  130. package/admin/src/components/RepeatableComponent/Banner.js +112 -0
  131. package/admin/src/components/RepeatableComponent/BannerWrapper.js +194 -0
  132. package/admin/src/components/RepeatableComponent/CarretTop.js +14 -0
  133. package/admin/src/components/RepeatableComponent/DraggedItem/index.js +245 -0
  134. package/admin/src/components/RepeatableComponent/DraggedItem/utils/connect.js +11 -0
  135. package/admin/src/components/RepeatableComponent/DraggedItem/utils/index.js +2 -0
  136. package/admin/src/components/RepeatableComponent/DraggedItem/utils/select.js +30 -0
  137. package/admin/src/components/RepeatableComponent/EmptyComponent.js +27 -0
  138. package/admin/src/components/RepeatableComponent/FormWrapper.js +27 -0
  139. package/admin/src/components/RepeatableComponent/index.js +187 -0
  140. package/admin/src/components/RepeatableComponent/reducer.js +73 -0
  141. package/admin/src/components/RepeatableComponent/utils/connect.js +11 -0
  142. package/admin/src/components/RepeatableComponent/utils/select.js +12 -0
  143. package/admin/src/components/Search/index.js +88 -0
  144. package/admin/src/components/SectionTitle/Title.js +11 -0
  145. package/admin/src/components/SectionTitle/index.js +29 -0
  146. package/admin/src/components/SelectMany/ListItem.js +107 -0
  147. package/admin/src/components/SelectMany/Relation.js +106 -0
  148. package/admin/src/components/SelectMany/components.js +153 -0
  149. package/admin/src/components/SelectMany/index.js +159 -0
  150. package/admin/src/components/SelectOne/SingleValue.js +58 -0
  151. package/admin/src/components/SelectOne/index.js +71 -0
  152. package/admin/src/components/SelectWrapper/ClearIndicator.js +15 -0
  153. package/admin/src/components/SelectWrapper/IndicatorSeparator.js +3 -0
  154. package/admin/src/components/SelectWrapper/Option.js +76 -0
  155. package/admin/src/components/SelectWrapper/components.js +14 -0
  156. package/admin/src/components/SelectWrapper/index.js +393 -0
  157. package/admin/src/components/SelectWrapper/utils/connect.js +12 -0
  158. package/admin/src/components/SelectWrapper/utils/index.js +3 -0
  159. package/admin/src/components/SelectWrapper/utils/select.js +45 -0
  160. package/admin/src/components/SelectWrapper/utils/styles.js +105 -0
  161. package/admin/src/components/Separator/index.js +9 -0
  162. package/admin/src/components/SettingFormWrapper/index.js +9 -0
  163. package/admin/src/components/SettingsViewWrapper/index.js +283 -0
  164. package/admin/src/components/SortWrapper/index.js +9 -0
  165. package/admin/src/components/SortableList/Item.js +126 -0
  166. package/admin/src/components/SortableList/index.js +60 -0
  167. package/admin/src/components/State/Wrapper.js +30 -0
  168. package/admin/src/components/State/index.js +26 -0
  169. package/admin/src/components/Truncate/index.js +5 -0
  170. package/admin/src/components/Truncated/index.js +10 -0
  171. package/admin/src/components/Wysiwyg/EditorWrapper.js +122 -0
  172. package/admin/src/components/Wysiwyg/MediaLib.js +71 -0
  173. package/admin/src/components/Wysiwyg/PreviewControlWrapper.js +30 -0
  174. package/admin/src/components/Wysiwyg/SelectWrapper.js +24 -0
  175. package/admin/src/components/Wysiwyg/ToggleModeWrapper.js +30 -0
  176. package/admin/src/components/Wysiwyg/constants.js +98 -0
  177. package/admin/src/components/Wysiwyg/customSelect.js +39 -0
  178. package/admin/src/components/Wysiwyg/helpers.js +116 -0
  179. package/admin/src/components/Wysiwyg/index.js +819 -0
  180. package/admin/src/components/Wysiwyg/previewControl.js +29 -0
  181. package/admin/src/components/Wysiwyg/toggleMode.js +44 -0
  182. package/admin/src/components/Wysiwyg/utils.js +70 -0
  183. package/admin/src/components/WysiwygBottomControls/components.js +44 -0
  184. package/admin/src/components/WysiwygBottomControls/index.js +33 -0
  185. package/admin/src/components/WysiwygDropUpload/Label.js +16 -0
  186. package/admin/src/components/WysiwygDropUpload/index.js +18 -0
  187. package/admin/src/components/WysiwygEditor/index.js +26 -0
  188. package/admin/src/components/WysiwygInlineControls/Button.js +77 -0
  189. package/admin/src/components/WysiwygInlineControls/StyledButton.js +54 -0
  190. package/admin/src/components/WysiwygInlineControls/Wrapper.js +25 -0
  191. package/admin/src/components/WysiwygInlineControls/index.js +66 -0
  192. package/admin/src/components/WysiwygWithErrors/Wrapper.js +38 -0
  193. package/admin/src/components/WysiwygWithErrors/index.js +158 -0
  194. package/admin/src/containers/CollectionTypeFormWrapper/index.js +376 -0
  195. package/admin/src/containers/CollectionTypeFormWrapper/utils/getRequestUrl.js +5 -0
  196. package/admin/src/containers/CollectionTypeFormWrapper/utils/index.js +2 -0
  197. package/admin/src/containers/CollectionTypeRecursivePath/index.js +125 -0
  198. package/admin/src/containers/ComponentSetttingsView/index.js +55 -0
  199. package/admin/src/containers/EditSettingsView/index.js +408 -0
  200. package/admin/src/containers/EditSettingsView/init.js +18 -0
  201. package/admin/src/containers/EditSettingsView/reducer.js +126 -0
  202. package/admin/src/containers/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +26 -0
  203. package/admin/src/containers/EditSettingsView/utils/getInputProps.js +30 -0
  204. package/admin/src/containers/EditSettingsView/utils/index.js +2 -0
  205. package/admin/src/containers/EditSettingsView/utils/layout.js +98 -0
  206. package/admin/src/containers/EditView/DeleteLink/index.js +94 -0
  207. package/admin/src/containers/EditView/DeleteLink/utils/connect.js +12 -0
  208. package/admin/src/containers/EditView/DeleteLink/utils/index.js +2 -0
  209. package/admin/src/containers/EditView/DeleteLink/utils/select.js +21 -0
  210. package/admin/src/containers/EditView/Header/index.js +258 -0
  211. package/admin/src/containers/EditView/Header/utils/connect.js +12 -0
  212. package/admin/src/containers/EditView/Header/utils/getDraftRelations.js +62 -0
  213. package/admin/src/containers/EditView/Header/utils/index.js +3 -0
  214. package/admin/src/containers/EditView/Header/utils/select.js +31 -0
  215. package/admin/src/containers/EditView/InformationCard.js +100 -0
  216. package/admin/src/containers/EditView/components.js +74 -0
  217. package/admin/src/containers/EditView/index.js +297 -0
  218. package/admin/src/containers/EditView/utils/createAttributesLayout.js +39 -0
  219. package/admin/src/containers/EditView/utils/getFieldsActionMatchingPermissions.js +23 -0
  220. package/admin/src/containers/EditView/utils/index.js +3 -0
  221. package/admin/src/containers/EditViewDataManagerProvider/index.js +519 -0
  222. package/admin/src/containers/EditViewDataManagerProvider/reducer.js +218 -0
  223. package/admin/src/containers/EditViewDataManagerProvider/utils/cleanData.js +88 -0
  224. package/admin/src/containers/EditViewDataManagerProvider/utils/getYupInnerErrors.js +17 -0
  225. package/admin/src/containers/EditViewDataManagerProvider/utils/index.js +3 -0
  226. package/admin/src/containers/EditViewDataManagerProvider/utils/schema.js +368 -0
  227. package/admin/src/containers/EditViewLayoutManager/Permissions.js +30 -0
  228. package/admin/src/containers/EditViewLayoutManager/actions.js +9 -0
  229. package/admin/src/containers/EditViewLayoutManager/constants.js +2 -0
  230. package/admin/src/containers/EditViewLayoutManager/index.js +44 -0
  231. package/admin/src/containers/EditViewLayoutManager/reducer.js +30 -0
  232. package/admin/src/containers/EditViewLayoutManager/selectors.js +5 -0
  233. package/admin/src/containers/LayoutDndProvider/index.js +75 -0
  234. package/admin/src/containers/ListSettingsView/DragWrapper.js +21 -0
  235. package/admin/src/containers/ListSettingsView/DropdownButton.js +8 -0
  236. package/admin/src/containers/ListSettingsView/Label.js +91 -0
  237. package/admin/src/containers/ListSettingsView/MenuDropdown.js +41 -0
  238. package/admin/src/containers/ListSettingsView/Toggle.js +51 -0
  239. package/admin/src/containers/ListSettingsView/forms.json +64 -0
  240. package/admin/src/containers/ListSettingsView/index.js +298 -0
  241. package/admin/src/containers/ListSettingsView/init.js +11 -0
  242. package/admin/src/containers/ListSettingsView/reducer.js +77 -0
  243. package/admin/src/containers/ListView/FieldPicker/ConfigureLink/StyledLink.js +28 -0
  244. package/admin/src/containers/ListView/FieldPicker/ConfigureLink/Wrapper.js +8 -0
  245. package/admin/src/containers/ListView/FieldPicker/ConfigureLink/index.js +29 -0
  246. package/admin/src/containers/ListView/FieldPicker/Field/Wrapper.js +15 -0
  247. package/admin/src/containers/ListView/FieldPicker/Field/index.js +24 -0
  248. package/admin/src/containers/ListView/FieldPicker/Fields/Wrapper.js +18 -0
  249. package/admin/src/containers/ListView/FieldPicker/Fields/index.js +27 -0
  250. package/admin/src/containers/ListView/FieldPicker/Header/Reset.js +8 -0
  251. package/admin/src/containers/ListView/FieldPicker/Header/index.js +42 -0
  252. package/admin/src/containers/ListView/FieldPicker/Wrapper.js +9 -0
  253. package/admin/src/containers/ListView/FieldPicker/index.js +46 -0
  254. package/admin/src/containers/ListView/Filter.js +83 -0
  255. package/admin/src/containers/ListView/Footer.js +60 -0
  256. package/admin/src/containers/ListView/actions.js +91 -0
  257. package/admin/src/containers/ListView/components.js +138 -0
  258. package/admin/src/containers/ListView/constants.js +16 -0
  259. package/admin/src/containers/ListView/index.js +573 -0
  260. package/admin/src/containers/ListView/reducer.js +182 -0
  261. package/admin/src/containers/ListView/selectors.js +24 -0
  262. package/admin/src/containers/ListView/utils/buildQueryString.js +26 -0
  263. package/admin/src/containers/ListView/utils/createPluginsFilter.js +13 -0
  264. package/admin/src/containers/ListView/utils/getAllAllowedHeaders.js +17 -0
  265. package/admin/src/containers/ListView/utils/getFirstSortableHeader.js +14 -0
  266. package/admin/src/containers/ListView/utils/index.js +3 -0
  267. package/admin/src/containers/ListViewLayoutManager/Permissions.js +29 -0
  268. package/admin/src/containers/ListViewLayoutManager/index.js +60 -0
  269. package/admin/src/containers/ListViewProvider/index.js +16 -0
  270. package/admin/src/containers/Main/actions.js +13 -0
  271. package/admin/src/containers/Main/constants.js +3 -0
  272. package/admin/src/containers/Main/index.js +100 -0
  273. package/admin/src/containers/Main/reducer.js +37 -0
  274. package/admin/src/containers/Main/selectors.js +20 -0
  275. package/admin/src/containers/RBACManager/actions.js +14 -0
  276. package/admin/src/containers/RBACManager/constants.js +2 -0
  277. package/admin/src/containers/RBACManager/reducer.js +32 -0
  278. package/admin/src/containers/RBACManager/useSyncRbac.js +28 -0
  279. package/admin/src/containers/SingleTypeFormWrapper/index.js +317 -0
  280. package/admin/src/containers/SingleTypeFormWrapper/utils/getRequestUrl.js +5 -0
  281. package/admin/src/containers/SingleTypeFormWrapper/utils/index.js +2 -0
  282. package/admin/src/containers/SingleTypeRecursivePath/index.js +84 -0
  283. package/admin/src/containers/WysiwygProvider/index.js +16 -0
  284. package/admin/src/contexts/ContentTypeLayout.js +5 -0
  285. package/admin/src/contexts/LayoutDnd.js +5 -0
  286. package/admin/src/contexts/ListView.js +5 -0
  287. package/admin/src/contexts/Wysiwyg.js +5 -0
  288. package/admin/src/contexts/index.js +4 -0
  289. package/admin/src/hooks/index.js +6 -0
  290. package/admin/src/hooks/useContentTypeLayout/index.js +19 -0
  291. package/admin/src/hooks/useFetchContentTypeLayout/index.js +83 -0
  292. package/admin/src/hooks/useFetchContentTypeLayout/reducer.js +56 -0
  293. package/admin/src/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +235 -0
  294. package/admin/src/hooks/useFindRedirectionLink/index.js +14 -0
  295. package/admin/src/hooks/useFindRedirectionLink/selectors.js +7 -0
  296. package/admin/src/hooks/useFindRedirectionLink/utils/getRedirectionLink.js +45 -0
  297. package/admin/src/hooks/useLayoutDnd.js +6 -0
  298. package/admin/src/hooks/useListView.js +6 -0
  299. package/admin/src/hooks/useWysiwyg.js +6 -0
  300. package/admin/src/icons/Bold/index.js +22 -0
  301. package/admin/src/icons/Code/index.js +13 -0
  302. package/admin/src/icons/Cross/index.js +33 -0
  303. package/admin/src/icons/Italic/index.js +23 -0
  304. package/admin/src/icons/Link/index.js +21 -0
  305. package/admin/src/icons/Media/index.js +14 -0
  306. package/admin/src/icons/Na/index.js +58 -0
  307. package/admin/src/icons/Ol/index.js +13 -0
  308. package/admin/src/icons/Quote/index.js +13 -0
  309. package/admin/src/icons/Striked/index.js +24 -0
  310. package/admin/src/icons/Ul/index.js +15 -0
  311. package/admin/src/icons/Underline/index.js +22 -0
  312. package/admin/src/index.js +52 -0
  313. package/admin/src/lifecycles.js +19 -0
  314. package/admin/src/permissions.js +27 -0
  315. package/admin/src/pluginId.js +5 -0
  316. package/admin/src/reducers.js +16 -0
  317. package/admin/src/selectors.js +6 -0
  318. package/admin/src/sharedReducers/crudReducer/actions.js +44 -0
  319. package/admin/src/sharedReducers/crudReducer/constants.js +7 -0
  320. package/admin/src/sharedReducers/crudReducer/reducer.js +75 -0
  321. package/admin/src/sharedReducers/crudReducer/selectors.js +5 -0
  322. package/admin/src/testUtils/data.js +305 -0
  323. package/admin/src/testUtils/index.js +4 -0
  324. package/admin/src/translations/ar.json +94 -0
  325. package/admin/src/translations/cs.json +130 -0
  326. package/admin/src/translations/de.json +177 -0
  327. package/admin/src/translations/dk.json +180 -0
  328. package/admin/src/translations/en.json +177 -0
  329. package/admin/src/translations/es.json +177 -0
  330. package/admin/src/translations/fr.json +162 -0
  331. package/admin/src/translations/id.json +175 -0
  332. package/admin/src/translations/index.js +53 -0
  333. package/admin/src/translations/it.json +177 -0
  334. package/admin/src/translations/ja.json +94 -0
  335. package/admin/src/translations/ko.json +110 -0
  336. package/admin/src/translations/ms.json +148 -0
  337. package/admin/src/translations/nl.json +94 -0
  338. package/admin/src/translations/pl.json +142 -0
  339. package/admin/src/translations/pt-BR.json +94 -0
  340. package/admin/src/translations/pt.json +94 -0
  341. package/admin/src/translations/ru.json +177 -0
  342. package/admin/src/translations/sk.json +172 -0
  343. package/admin/src/translations/th.json +155 -0
  344. package/admin/src/translations/tr.json +177 -0
  345. package/admin/src/translations/uk.json +148 -0
  346. package/admin/src/translations/vi.json +110 -0
  347. package/admin/src/translations/zh-Hans.json +177 -0
  348. package/admin/src/translations/zh.json +94 -0
  349. package/admin/src/utils/ItemTypes.js +7 -0
  350. package/admin/src/utils/checkIfAttributeIsDisplayable.js +13 -0
  351. package/admin/src/utils/createDefaultForm.js +50 -0
  352. package/admin/src/utils/dateFormats.js +18 -0
  353. package/admin/src/utils/formatFiltersFromQuery.js +55 -0
  354. package/admin/src/utils/formatFiltersToQuery.js +27 -0
  355. package/admin/src/utils/formatLayoutToApi.js +44 -0
  356. package/admin/src/utils/generatePermissionsObject.js +20 -0
  357. package/admin/src/utils/getComponents.js +50 -0
  358. package/admin/src/utils/getDisplayedValue.js +61 -0
  359. package/admin/src/utils/getFieldName.js +6 -0
  360. package/admin/src/utils/getMaxTempKey.js +12 -0
  361. package/admin/src/utils/getRequestUrl.js +5 -0
  362. package/admin/src/utils/getTrad.js +5 -0
  363. package/admin/src/utils/index.js +17 -0
  364. package/admin/src/utils/mergeMetasWithSchema.js +20 -0
  365. package/admin/src/utils/removeKeyInObject.js +45 -0
  366. package/admin/src/utils/removePasswordFieldsFromData.js +54 -0
  367. package/config/admin.json +5 -0
  368. package/config/functions/bootstrap.js +9 -0
  369. package/config/policies/has-draft-and-publish.js +19 -0
  370. package/config/policies/hasPermissions.js +34 -0
  371. package/config/policies/routing.js +27 -0
  372. package/config/routes.json +275 -0
  373. package/controllers/collection-types.js +282 -0
  374. package/controllers/components.js +66 -0
  375. package/controllers/content-types.js +112 -0
  376. package/controllers/relations.js +63 -0
  377. package/controllers/single-types.js +170 -0
  378. package/controllers/uid.js +41 -0
  379. package/controllers/validation/index.js +104 -0
  380. package/controllers/validation/model-configuration.js +114 -0
  381. package/oas.yml +757 -0
  382. package/package.json +77 -0
  383. package/services/components.js +92 -0
  384. package/services/configuration.js +79 -0
  385. package/services/content-types.js +73 -0
  386. package/services/data-mapper.js +98 -0
  387. package/services/entity-manager.js +140 -0
  388. package/services/metrics.js +34 -0
  389. package/services/permission-checker.js +69 -0
  390. package/services/permission.js +95 -0
  391. package/services/uid.js +63 -0
  392. package/services/utils/configuration/attributes.js +175 -0
  393. package/services/utils/configuration/index.js +43 -0
  394. package/services/utils/configuration/layouts.js +185 -0
  395. package/services/utils/configuration/metadatas.js +142 -0
  396. package/services/utils/configuration/settings.js +52 -0
  397. package/services/utils/store.js +93 -0
  398. package/utils/index.js +16 -0
  399. package/utils/pick-writable-attributes.js +6 -0
  400. package/utils/wrap-bad-request.js +15 -0
  401. package/validation/policies/hasPermissions.js +17 -0
@@ -0,0 +1,218 @@
1
+ import { fromJS } from 'immutable';
2
+ import { getMaxTempKey } from '../../utils';
3
+
4
+ const initialState = fromJS({
5
+ componentsDataStructure: {},
6
+ contentTypeDataStructure: {},
7
+ formErrors: {},
8
+ initialData: {},
9
+ modifiedData: {},
10
+ shouldCheckErrors: false,
11
+ modifiedDZName: null,
12
+ });
13
+
14
+ const reducer = (state, action) => {
15
+ switch (action.type) {
16
+ case 'ADD_NON_REPEATABLE_COMPONENT_TO_FIELD':
17
+ return state.updateIn(['modifiedData', ...action.keys], () => {
18
+ const defaultDataStructure = state.getIn(['componentsDataStructure', action.componentUid]);
19
+
20
+ return fromJS(defaultDataStructure);
21
+ });
22
+ case 'ADD_REPEATABLE_COMPONENT_TO_FIELD': {
23
+ return state
24
+ .updateIn(['modifiedData', ...action.keys], list => {
25
+ const defaultDataStructure = state
26
+ .getIn(['componentsDataStructure', action.componentUid])
27
+ .set('__temp_key__', getMaxTempKey(list ? list.toJS() : []) + 1);
28
+
29
+ if (list) {
30
+ return list.push(defaultDataStructure);
31
+ }
32
+
33
+ return fromJS([defaultDataStructure]);
34
+ })
35
+ .update('shouldCheckErrors', v => {
36
+ if (action.shouldCheckErrors === true) {
37
+ return !v;
38
+ }
39
+
40
+ return v;
41
+ });
42
+ }
43
+ case 'ADD_COMPONENT_TO_DYNAMIC_ZONE':
44
+ return state
45
+ .updateIn(['modifiedData', ...action.keys], list => {
46
+ const defaultDataStructure = state
47
+ .getIn(['componentsDataStructure', action.componentUid])
48
+ .set('__component', action.componentUid);
49
+
50
+ if (list) {
51
+ return list.push(defaultDataStructure);
52
+ }
53
+
54
+ return fromJS([defaultDataStructure]);
55
+ })
56
+ .update('modifiedDZName', () => action.keys[0])
57
+ .update('shouldCheckErrors', v => {
58
+ if (action.shouldCheckErrors === true) {
59
+ return !v;
60
+ }
61
+
62
+ return v;
63
+ });
64
+ case 'ADD_RELATION':
65
+ return state.updateIn(['modifiedData', ...action.keys], list => {
66
+ if (!Array.isArray(action.value) || !action.value.length) {
67
+ return list;
68
+ }
69
+
70
+ const el = action.value[0].value;
71
+
72
+ if (list) {
73
+ return list.push(fromJS(el));
74
+ }
75
+
76
+ return fromJS([el]);
77
+ });
78
+ case 'INIT_FORM': {
79
+ return state
80
+ .update('formErrors', () => fromJS({}))
81
+ .update('initialData', () => fromJS(action.initialValues))
82
+ .update('modifiedData', () => fromJS(action.initialValues))
83
+ .update('modifiedDZName', () => null)
84
+ .update('shouldCheckErrors', () => false);
85
+ }
86
+ case 'MOVE_COMPONENT_FIELD':
87
+ return state.updateIn(['modifiedData', ...action.pathToComponent], list => {
88
+ return list
89
+ .delete(action.dragIndex)
90
+ .insert(
91
+ action.hoverIndex,
92
+ state.getIn(['modifiedData', ...action.pathToComponent, action.dragIndex])
93
+ );
94
+ });
95
+ case 'MOVE_COMPONENT_UP':
96
+ return state
97
+ .update('shouldCheckErrors', v => {
98
+ if (action.shouldCheckErrors) {
99
+ return !v;
100
+ }
101
+
102
+ return v;
103
+ })
104
+ .updateIn(['modifiedData', action.dynamicZoneName], list => {
105
+ return list
106
+ .delete(action.currentIndex)
107
+ .insert(
108
+ action.currentIndex - 1,
109
+ state.getIn(['modifiedData', action.dynamicZoneName, action.currentIndex])
110
+ );
111
+ });
112
+ case 'MOVE_COMPONENT_DOWN':
113
+ return state
114
+ .update('shouldCheckErrors', v => {
115
+ if (action.shouldCheckErrors) {
116
+ return !v;
117
+ }
118
+
119
+ return v;
120
+ })
121
+ .updateIn(['modifiedData', action.dynamicZoneName], list => {
122
+ return list
123
+ .delete(action.currentIndex)
124
+ .insert(
125
+ action.currentIndex + 1,
126
+ state.getIn(['modifiedData', action.dynamicZoneName, action.currentIndex])
127
+ );
128
+ });
129
+ case 'MOVE_FIELD':
130
+ return state.updateIn(['modifiedData', ...action.keys], list => {
131
+ return list.delete(action.dragIndex).insert(action.overIndex, list.get(action.dragIndex));
132
+ });
133
+ case 'ON_CHANGE': {
134
+ let newState = state;
135
+ const [nonRepeatableComponentKey] = action.keys;
136
+
137
+ // This is used to set the initialData for inputs
138
+ // that needs an asynchronous initial value like the UID field
139
+ // This is just a temporary patch.
140
+ // TODO : Refactor the default form creation (workflow) to accept async default values.
141
+ if (action.shouldSetInitialValue) {
142
+ newState = state.updateIn(['initialData', ...action.keys], () => {
143
+ return action.value;
144
+ });
145
+ }
146
+
147
+ if (
148
+ action.keys.length === 2 &&
149
+ state.getIn(['modifiedData', nonRepeatableComponentKey]) === null
150
+ ) {
151
+ newState = newState.updateIn(['modifiedData', nonRepeatableComponentKey], () => fromJS({}));
152
+ }
153
+
154
+ return newState.updateIn(['modifiedData', ...action.keys], () => {
155
+ return action.value;
156
+ });
157
+ }
158
+ case 'REMOVE_COMPONENT_FROM_DYNAMIC_ZONE':
159
+ return state
160
+ .update('shouldCheckErrors', v => {
161
+ if (action.shouldCheckErrors) {
162
+ return !v;
163
+ }
164
+
165
+ return v;
166
+ })
167
+ .deleteIn(['modifiedData', action.dynamicZoneName, action.index]);
168
+ case 'REMOVE_COMPONENT_FROM_FIELD': {
169
+ const componentPathToRemove = ['modifiedData', ...action.keys];
170
+
171
+ return state.updateIn(componentPathToRemove, () => null);
172
+ }
173
+ case 'REMOVE_PASSWORD_FIELD': {
174
+ return state.removeIn(['modifiedData', ...action.keys]);
175
+ }
176
+ case 'REMOVE_REPEATABLE_FIELD': {
177
+ const componentPathToRemove = ['modifiedData', ...action.keys];
178
+
179
+ return state
180
+ .update('shouldCheckErrors', v => {
181
+ const hasErrors = state.get('formErrors').keySeq().size > 0;
182
+
183
+ if (hasErrors) {
184
+ return !v;
185
+ }
186
+
187
+ return v;
188
+ })
189
+ .deleteIn(componentPathToRemove);
190
+ }
191
+ case 'REMOVE_RELATION':
192
+ return state.removeIn(['modifiedData', ...action.keys.split('.')]);
193
+ case 'SET_DEFAULT_DATA_STRUCTURES':
194
+ return state
195
+ .update('componentsDataStructure', () => fromJS(action.componentsDataStructure))
196
+ .update('contentTypeDataStructure', () => fromJS(action.contentTypeDataStructure));
197
+ case 'SET_FORM_ERRORS': {
198
+ return state
199
+ .update('modifiedDZName', () => null)
200
+ .update('formErrors', () => fromJS(action.errors));
201
+ }
202
+ case 'TRIGGER_FORM_VALIDATION':
203
+ return state.update('shouldCheckErrors', v => {
204
+ const hasErrors = state.get('formErrors').keySeq().size > 0;
205
+
206
+ if (hasErrors) {
207
+ return !v;
208
+ }
209
+
210
+ return v;
211
+ });
212
+ default:
213
+ return state;
214
+ }
215
+ };
216
+
217
+ export default reducer;
218
+ export { initialState };
@@ -0,0 +1,88 @@
1
+ import { get, isArray, isObject } from 'lodash';
2
+
3
+ /* eslint-disable indent */
4
+
5
+ const cleanData = (retrievedData, currentSchema, componentsSchema) => {
6
+ const getType = (schema, attrName) => get(schema, ['attributes', attrName, 'type'], '');
7
+ const getOtherInfos = (schema, arr) => get(schema, ['attributes', ...arr], '');
8
+
9
+ const recursiveCleanData = (data, schema) => {
10
+ return Object.keys(data).reduce((acc, current) => {
11
+ const attrType = getType(schema, current);
12
+ const value = get(data, current);
13
+ const component = getOtherInfos(schema, [current, 'component']);
14
+ const isRepeatable = getOtherInfos(schema, [current, 'repeatable']);
15
+ let cleanedData;
16
+
17
+ switch (attrType) {
18
+ case 'json':
19
+ try {
20
+ cleanedData = JSON.parse(value);
21
+ } catch (err) {
22
+ cleanedData = value;
23
+ }
24
+
25
+ break;
26
+ case 'date':
27
+ cleanedData =
28
+ value && value._isAMomentObject === true ? value.format('YYYY-MM-DD') : value;
29
+ break;
30
+ case 'datetime':
31
+ cleanedData = value && value._isAMomentObject === true ? value.toISOString() : value;
32
+ break;
33
+ case 'media':
34
+ if (getOtherInfos(schema, [current, 'multiple']) === true) {
35
+ cleanedData = value ? value.filter(file => !(file instanceof File)) : null;
36
+ } else {
37
+ cleanedData = get(value, 0) instanceof File ? null : get(value, 'id', null);
38
+ }
39
+ break;
40
+ case 'component':
41
+ if (isRepeatable) {
42
+ cleanedData = value
43
+ ? value.map(data => {
44
+ const subCleanedData = recursiveCleanData(data, componentsSchema[component]);
45
+
46
+ return subCleanedData;
47
+ })
48
+ : value;
49
+ } else {
50
+ cleanedData = value ? recursiveCleanData(value, componentsSchema[component]) : value;
51
+ }
52
+ break;
53
+ case 'dynamiczone':
54
+ cleanedData = value.map(componentData => {
55
+ const subCleanedData = recursiveCleanData(
56
+ componentData,
57
+ componentsSchema[componentData.__component]
58
+ );
59
+
60
+ return subCleanedData;
61
+ });
62
+ break;
63
+ default:
64
+ // The helper is mainly used for the relations in order to just send the id
65
+ cleanedData = helperCleanData(value, 'id');
66
+ }
67
+
68
+ acc[current] = cleanedData;
69
+
70
+ return acc;
71
+ }, {});
72
+ };
73
+
74
+ return recursiveCleanData(retrievedData, currentSchema);
75
+ };
76
+
77
+ export const helperCleanData = (value, key) => {
78
+ if (isArray(value)) {
79
+ return value.map(obj => (obj[key] ? obj[key] : obj));
80
+ }
81
+ if (isObject(value)) {
82
+ return value[key];
83
+ }
84
+
85
+ return value;
86
+ };
87
+
88
+ export default cleanData;
@@ -0,0 +1,17 @@
1
+ import { get } from 'lodash';
2
+
3
+ const getYupInnerErrors = error => {
4
+ return get(error, 'inner', []).reduce((acc, curr) => {
5
+ acc[
6
+ curr.path
7
+ .split('[')
8
+ .join('.')
9
+ .split(']')
10
+ .join('')
11
+ ] = { id: curr.message };
12
+
13
+ return acc;
14
+ }, {});
15
+ };
16
+
17
+ export default getYupInnerErrors;
@@ -0,0 +1,3 @@
1
+ export { default as cleanData } from './cleanData';
2
+ export { default as getYupInnerErrors } from './getYupInnerErrors';
3
+ export { default as createYupSchema } from './schema';
@@ -0,0 +1,368 @@
1
+ import {
2
+ get,
3
+ isBoolean,
4
+ isNumber,
5
+ isNull,
6
+ isObject,
7
+ isArray,
8
+ isEmpty,
9
+ isNaN,
10
+ toNumber,
11
+ } from 'lodash';
12
+ import moment from 'moment';
13
+ import * as yup from 'yup';
14
+ import { translatedErrors as errorsTrads } from 'strapi-helper-plugin';
15
+
16
+ yup.addMethod(yup.mixed, 'defined', function() {
17
+ return this.test('defined', errorsTrads.required, value => value !== undefined);
18
+ });
19
+
20
+ yup.addMethod(yup.array, 'notEmptyMin', function(min) {
21
+ return this.test('notEmptyMin', errorsTrads.min, value => {
22
+ if (isEmpty(value)) {
23
+ return true;
24
+ }
25
+
26
+ return value.length >= min;
27
+ });
28
+ });
29
+
30
+ yup.addMethod(yup.string, 'isInferior', function(message, max) {
31
+ return this.test('isInferior', message, function(value) {
32
+ if (!value) {
33
+ return true;
34
+ }
35
+
36
+ if (Number.isNaN(toNumber(value))) {
37
+ return true;
38
+ }
39
+
40
+ return toNumber(max) >= toNumber(value);
41
+ });
42
+ });
43
+
44
+ yup.addMethod(yup.string, 'isSuperior', function(message, min) {
45
+ return this.test('isSuperior', message, function(value) {
46
+ if (!value) {
47
+ return true;
48
+ }
49
+
50
+ if (Number.isNaN(toNumber(value))) {
51
+ return true;
52
+ }
53
+
54
+ return toNumber(value) >= toNumber(min);
55
+ });
56
+ });
57
+
58
+ const getAttributes = data => get(data, ['attributes'], {});
59
+
60
+ const createYupSchema = (
61
+ model,
62
+ { components },
63
+ options = { isCreatingEntry: true, isDraft: true, isFromComponent: false }
64
+ ) => {
65
+ const attributes = getAttributes(model);
66
+
67
+ return yup.object().shape(
68
+ Object.keys(attributes).reduce((acc, current) => {
69
+ const attribute = attributes[current];
70
+
71
+ if (
72
+ attribute.type !== 'relation' &&
73
+ attribute.type !== 'component' &&
74
+ attribute.type !== 'dynamiczone'
75
+ ) {
76
+ const formatted = createYupSchemaAttribute(attribute.type, attribute, options);
77
+ acc[current] = formatted;
78
+ }
79
+
80
+ if (attribute.type === 'relation') {
81
+ acc[current] = [
82
+ 'oneWay',
83
+ 'oneToOne',
84
+ 'manyToOne',
85
+ 'oneToManyMorph',
86
+ 'oneToOneMorph',
87
+ ].includes(attribute.relationType)
88
+ ? yup.object().nullable()
89
+ : yup.array().nullable();
90
+ }
91
+
92
+ if (attribute.type === 'component') {
93
+ const componentFieldSchema = createYupSchema(
94
+ components[attribute.component],
95
+ {
96
+ components,
97
+ },
98
+ { ...options, isFromComponent: true }
99
+ );
100
+
101
+ if (attribute.repeatable === true) {
102
+ const { min, max, required } = attribute;
103
+ let componentSchema = yup.lazy(value => {
104
+ let baseSchema = yup.array().of(componentFieldSchema);
105
+
106
+ if (min && !options.isDraft) {
107
+ if (required) {
108
+ baseSchema = baseSchema.min(min, errorsTrads.min);
109
+ } else if (required !== true && isEmpty(value)) {
110
+ baseSchema = baseSchema.nullable();
111
+ } else {
112
+ baseSchema = baseSchema.min(min, errorsTrads.min);
113
+ }
114
+ }
115
+
116
+ if (max) {
117
+ baseSchema = baseSchema.max(max, errorsTrads.max);
118
+ }
119
+
120
+ return baseSchema;
121
+ });
122
+
123
+ acc[current] = componentSchema;
124
+
125
+ return acc;
126
+ }
127
+ const componentSchema = yup.lazy(obj => {
128
+ if (obj !== undefined) {
129
+ return attribute.required === true && !options.isDraft
130
+ ? componentFieldSchema.defined()
131
+ : componentFieldSchema.nullable();
132
+ }
133
+
134
+ return attribute.required === true ? yup.object().defined() : yup.object().nullable();
135
+ });
136
+
137
+ acc[current] = componentSchema;
138
+
139
+ return acc;
140
+ }
141
+
142
+ if (attribute.type === 'dynamiczone') {
143
+ let dynamicZoneSchema = yup.array().of(
144
+ yup.lazy(({ __component }) => {
145
+ return createYupSchema(
146
+ components[__component],
147
+ { components },
148
+ { ...options, isFromComponent: true }
149
+ );
150
+ })
151
+ );
152
+
153
+ const { max, min } = attribute;
154
+
155
+ if (attribute.required && !options.isDraft) {
156
+ dynamicZoneSchema = dynamicZoneSchema.test('required', errorsTrads.required, value => {
157
+ if (options.isCreatingEntry) {
158
+ return value !== null || value !== undefined;
159
+ }
160
+
161
+ if (value === undefined) {
162
+ return true;
163
+ }
164
+
165
+ return value !== null;
166
+ });
167
+
168
+ if (min) {
169
+ dynamicZoneSchema = dynamicZoneSchema
170
+ .test('min', errorsTrads.min, value => {
171
+ if (options.isCreatingEntry) {
172
+ return value && value.length > 0;
173
+ }
174
+
175
+ if (value === undefined) {
176
+ return true;
177
+ }
178
+
179
+ return value !== null && value.length > 0;
180
+ })
181
+ .test('required', errorsTrads.required, value => {
182
+ if (options.isCreatingEntry) {
183
+ return value !== null || value !== undefined;
184
+ }
185
+
186
+ if (value === undefined) {
187
+ return true;
188
+ }
189
+
190
+ return value !== null;
191
+ });
192
+ }
193
+ } else {
194
+ // eslint-disable-next-line no-lonely-if
195
+ if (min) {
196
+ dynamicZoneSchema = dynamicZoneSchema.notEmptyMin(min);
197
+ }
198
+ }
199
+
200
+ if (max) {
201
+ dynamicZoneSchema = dynamicZoneSchema.max(max, errorsTrads.max);
202
+ }
203
+
204
+ acc[current] = dynamicZoneSchema;
205
+ }
206
+
207
+ return acc;
208
+ }, {})
209
+ );
210
+ };
211
+
212
+ const createYupSchemaAttribute = (type, validations, options) => {
213
+ let schema = yup.mixed();
214
+
215
+ if (['string', 'uid', 'text', 'richtext', 'email', 'password', 'enumeration'].includes(type)) {
216
+ schema = yup.string();
217
+ }
218
+
219
+ if (type === 'json') {
220
+ schema = yup
221
+ .mixed(errorsTrads.json)
222
+ .test('isJSON', errorsTrads.json, value => {
223
+ if (value === undefined) {
224
+ return true;
225
+ }
226
+
227
+ if (isNumber(value) || isNull(value) || isObject(value) || isArray(value)) {
228
+ return true;
229
+ }
230
+
231
+ try {
232
+ JSON.parse(value);
233
+
234
+ return true;
235
+ } catch (err) {
236
+ return false;
237
+ }
238
+ })
239
+ .nullable();
240
+ }
241
+
242
+ if (type === 'email') {
243
+ schema = schema.email(errorsTrads.email);
244
+ }
245
+
246
+ if (['number', 'integer', 'biginteger', 'float', 'decimal'].includes(type)) {
247
+ schema = yup
248
+ .number()
249
+ .transform(cv => (isNaN(cv) ? undefined : cv))
250
+ .typeError();
251
+ }
252
+
253
+ if (['date', 'datetime'].includes(type)) {
254
+ schema = yup.date();
255
+ }
256
+
257
+ if (type === 'biginteger') {
258
+ schema = yup.string().matches(/^\d*$/);
259
+ }
260
+
261
+ Object.keys(validations).forEach(validation => {
262
+ const validationValue = validations[validation];
263
+
264
+ if (
265
+ !!validationValue ||
266
+ (!isBoolean(validationValue) && Number.isInteger(Math.floor(validationValue))) ||
267
+ validationValue === 0
268
+ ) {
269
+ switch (validation) {
270
+ case 'required': {
271
+ if (!options.isDraft) {
272
+ if (type === 'password' && options.isCreatingEntry) {
273
+ schema = schema.required(errorsTrads.required);
274
+ }
275
+
276
+ if (type !== 'password') {
277
+ if (options.isCreatingEntry) {
278
+ schema = schema.required(errorsTrads.required);
279
+ } else {
280
+ schema = schema.test('required', errorsTrads.required, value => {
281
+ // Field is not touched and the user is editing the entry
282
+ if (value === undefined && !options.isFromComponent) {
283
+ return true;
284
+ }
285
+
286
+ if (['number', 'integer', 'biginteger', 'float', 'decimal'].includes(type)) {
287
+ if (value === 0) {
288
+ return true;
289
+ }
290
+
291
+ return !!value;
292
+ }
293
+
294
+ if (['date', 'datetime'].includes(type)) {
295
+ return moment(value)._isValid === true;
296
+ }
297
+
298
+ if (type === 'boolean') {
299
+ return value !== null;
300
+ }
301
+
302
+ return !isEmpty(value);
303
+ });
304
+ }
305
+ }
306
+ }
307
+
308
+ break;
309
+ }
310
+
311
+ case 'max': {
312
+ if (type === 'biginteger') {
313
+ schema = schema.isInferior(errorsTrads.max, validationValue);
314
+ } else {
315
+ schema = schema.max(validationValue, errorsTrads.max);
316
+ }
317
+ break;
318
+ }
319
+ case 'maxLength':
320
+ schema = schema.max(validationValue, errorsTrads.maxLength);
321
+ break;
322
+ case 'min': {
323
+ if (type === 'biginteger') {
324
+ schema = schema.isSuperior(errorsTrads.min, validationValue);
325
+ } else {
326
+ schema = schema.min(validationValue, errorsTrads.min);
327
+ }
328
+ break;
329
+ }
330
+ case 'minLength': {
331
+ if (!options.isDraft) {
332
+ schema = schema.min(validationValue, errorsTrads.minLength);
333
+ }
334
+ break;
335
+ }
336
+ case 'regex':
337
+ schema = schema.matches(new RegExp(validationValue), errorsTrads.regex);
338
+ break;
339
+ case 'lowercase':
340
+ if (['text', 'textarea', 'email', 'string'].includes(type)) {
341
+ schema = schema.strict().lowercase();
342
+ }
343
+ break;
344
+ case 'uppercase':
345
+ if (['text', 'textarea', 'email', 'string'].includes(type)) {
346
+ schema = schema.strict().uppercase();
347
+ }
348
+ break;
349
+ case 'positive':
350
+ if (['number', 'integer', 'bigint', 'float', 'decimal'].includes(type)) {
351
+ schema = schema.positive();
352
+ }
353
+ break;
354
+ case 'negative':
355
+ if (['number', 'integer', 'bigint', 'float', 'decimal'].includes(type)) {
356
+ schema = schema.negative();
357
+ }
358
+ break;
359
+ default:
360
+ schema = schema.nullable();
361
+ }
362
+ }
363
+ });
364
+
365
+ return schema;
366
+ };
367
+
368
+ export default createYupSchema;