@strapi/admin 4.6.0-alpha.0 → 4.6.0-beta.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 (132) hide show
  1. package/admin/src/content-manager/components/ComponentInitializer/index.js +1 -7
  2. package/admin/src/content-manager/components/{RepeatableComponent/DragPreview.js → DragLayer/ComponentDragPreview.js} +25 -12
  3. package/admin/src/content-manager/components/DragLayer/RelationDragPreview.js +75 -0
  4. package/admin/src/content-manager/components/DragLayer/index.js +23 -7
  5. package/admin/src/content-manager/components/DynamicZone/components/DynamicComponent.js +130 -84
  6. package/admin/src/content-manager/components/DynamicZone/index.js +99 -24
  7. package/admin/src/content-manager/components/DynamicZone/utils/select.js +9 -5
  8. package/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +76 -14
  9. package/admin/src/content-manager/components/EditViewDataManagerProvider/reducer.js +23 -23
  10. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/cleanData.js +24 -5
  11. package/admin/src/content-manager/components/EditViewDataManagerProvider/utils/recursivelyFindPathsBasedOnCondition.js +8 -1
  12. package/admin/src/content-manager/components/Inputs/index.js +5 -19
  13. package/admin/src/content-manager/components/NonRepeatableComponent/index.js +4 -0
  14. package/admin/src/content-manager/components/RelationInput/RelationInput.js +203 -63
  15. package/admin/src/content-manager/components/RelationInput/components/RelationItem.js +134 -21
  16. package/admin/src/content-manager/components/RelationInput/components/RelationList.js +1 -2
  17. package/admin/src/content-manager/components/RelationInput/constants.js +1 -0
  18. package/admin/src/content-manager/components/RelationInputDataManager/RelationInputDataManager.js +132 -10
  19. package/admin/src/content-manager/components/RepeatableComponent/components/Accordion.js +77 -0
  20. package/admin/src/content-manager/components/RepeatableComponent/components/Component.js +262 -0
  21. package/admin/src/content-manager/components/RepeatableComponent/{DraggedItem → components}/Preview.js +0 -0
  22. package/admin/src/content-manager/components/RepeatableComponent/index.js +147 -87
  23. package/admin/src/content-manager/components/RepeatableComponent/utils/getComponentErrorKeys.js +1 -1
  24. package/admin/src/content-manager/components/SingleTypeFormWrapper/index.js +1 -1
  25. package/admin/src/content-manager/components/Wysiwyg/Editor.js +1 -1
  26. package/admin/src/content-manager/hooks/index.js +2 -0
  27. package/admin/src/content-manager/hooks/useDragAndDrop.js +120 -0
  28. package/admin/src/content-manager/hooks/useKeyboardDragAndDrop.js +98 -0
  29. package/admin/src/content-manager/hooks/useLazyComponents/index.js +69 -0
  30. package/admin/src/content-manager/pages/CollectionTypeRecursivePath/components/ErrorFallback.js +13 -0
  31. package/admin/src/content-manager/pages/CollectionTypeRecursivePath/index.js +2 -1
  32. package/admin/src/content-manager/pages/EditView/GridRow/index.js +62 -0
  33. package/admin/src/content-manager/pages/EditView/index.js +74 -154
  34. package/admin/src/content-manager/pages/EditView/selectors.js +14 -0
  35. package/admin/src/content-manager/pages/EditView/utils/createAttributesLayout.js +11 -6
  36. package/admin/src/content-manager/pages/EditView/utils/getCustomFieldUidsFromLayout.js +18 -0
  37. package/admin/src/content-manager/pages/EditView/utils/index.js +1 -0
  38. package/admin/src/content-manager/pages/EditViewLayoutManager/index.js +1 -1
  39. package/admin/src/content-manager/sharedReducers/crudReducer/actions.js +5 -0
  40. package/admin/src/content-manager/sharedReducers/crudReducer/constants.js +2 -0
  41. package/admin/src/content-manager/sharedReducers/crudReducer/reducer.js +7 -0
  42. package/admin/src/content-manager/utils/ItemTypes.js +1 -1
  43. package/admin/src/content-manager/utils/composeRefs.js +28 -0
  44. package/admin/src/content-manager/utils/getMaxTempKey.js +1 -1
  45. package/admin/src/content-manager/utils/index.js +7 -0
  46. package/admin/src/core/utils/axiosInstance.js +4 -2
  47. package/admin/src/hooks/index.js +1 -0
  48. package/admin/src/hooks/useFetchClient/index.js +23 -0
  49. package/admin/src/pages/HomePage/SocialLinks.js +4 -4
  50. package/admin/src/pages/SettingsPage/pages/Users/ListPage/ModalForm/index.js +23 -18
  51. package/admin/src/translations/en.json +6 -0
  52. package/admin/src/translations/ru.json +789 -489
  53. package/admin/src/utils/fetchClient.js +45 -0
  54. package/admin/src/utils/getFetchClient.js +10 -0
  55. package/build/4306.df40a798.chunk.js +98 -0
  56. package/build/{4318.daf31770.chunk.js → 4318.80bdf035.chunk.js} +2 -2
  57. package/build/5057.195a59ff.chunk.js +65 -0
  58. package/build/{805.a1894307.chunk.js → 805.e991a370.chunk.js} +6 -6
  59. package/build/{4986.3820d11d.chunk.js → 8176.b19bc128.chunk.js} +32 -32
  60. package/build/{1233.32d6888d.chunk.js → 8186.55910742.chunk.js} +94 -94
  61. package/build/{8633.8da5488a.chunk.js → 8633.59223842.chunk.js} +1 -1
  62. package/build/8881.c693411a.chunk.js +245 -0
  63. package/build/9161.4a0ab137.chunk.js +2119 -0
  64. package/build/9279.6290c87a.chunk.js +117 -0
  65. package/build/9707.a0cc4ad8.chunk.js +70 -0
  66. package/build/Admin-authenticatedApp.f9e74dc0.chunk.js +80 -0
  67. package/build/{Admin_homePage.b4db4df8.chunk.js → Admin_homePage.8945f71a.chunk.js} +5 -5
  68. package/build/{Admin_marketplace.fa51405b.chunk.js → Admin_marketplace.ed754a4a.chunk.js} +1 -1
  69. package/build/{Admin_pluginsPage.14d2840f.chunk.js → Admin_pluginsPage.3c872de7.chunk.js} +1 -1
  70. package/build/{Admin_profilePage.6c2c8398.chunk.js → Admin_profilePage.c07bdf08.chunk.js} +1 -1
  71. package/build/{Admin_settingsPage.5e740514.chunk.js → Admin_settingsPage.50a8765b.chunk.js} +5 -5
  72. package/build/admin-app.2861b6d2.chunk.js +112 -0
  73. package/build/{admin-edit-roles-page.c7c338b3.chunk.js → admin-edit-roles-page.f407538c.chunk.js} +1 -1
  74. package/build/{admin-edit-users.d254c128.chunk.js → admin-edit-users.85231e4c.chunk.js} +1 -1
  75. package/build/{admin-users.7c423e41.chunk.js → admin-users.a2707644.chunk.js} +2 -2
  76. package/build/api-tokens-create-page.dd4ddfcb.chunk.js +1 -0
  77. package/build/api-tokens-edit-page.821c5a6c.chunk.js +1 -0
  78. package/build/{api-tokens-list-page.fe994b6b.chunk.js → api-tokens-list-page.700e575f.chunk.js} +1 -1
  79. package/build/content-manager.ee948f75.chunk.js +1186 -0
  80. package/build/content-type-builder-list-view.4412efc3.chunk.js +201 -0
  81. package/build/content-type-builder.b132b5f4.chunk.js +145 -0
  82. package/build/email-settings-page.db0d98d1.chunk.js +15 -0
  83. package/build/{en-json.7dd57947.chunk.js → en-json.4a56dca7.chunk.js} +1 -1
  84. package/build/index.html +1 -1
  85. package/build/main.faac89ee.js +2025 -0
  86. package/build/ru-json.8830286f.chunk.js +1 -0
  87. package/build/{runtime~main.6e7d95b9.js → runtime~main.75a15b8e.js} +1 -1
  88. package/build/{sso-settings-page.eb30a02e.chunk.js → sso-settings-page.adb12ac3.chunk.js} +1 -1
  89. package/build/upload-settings.450cab1a.chunk.js +18 -0
  90. package/build/upload.e2034370.chunk.js +64 -0
  91. package/build/users-advanced-settings-page.0c0b8230.chunk.js +13 -0
  92. package/build/users-email-settings-page.3126ff8c.chunk.js +28 -0
  93. package/build/users-providers-settings-page.b7b602e2.chunk.js +33 -0
  94. package/build/users-roles-settings-page.ce5b582d.chunk.js +30 -0
  95. package/build/webhook-edit-page.1215a6b7.chunk.js +75 -0
  96. package/build/{webhook-list-page.42533b59.chunk.js → webhook-list-page.b87821f2.chunk.js} +1 -1
  97. package/ee/server/services/passport/provider-registry.js +1 -1
  98. package/package.json +15 -15
  99. package/utils/get-plugins-path.js +17 -3
  100. package/admin/src/content-manager/components/RepeatableComponent/AccordionGroupCustom/index.js +0 -122
  101. package/admin/src/content-manager/components/RepeatableComponent/AddFieldButton.js +0 -58
  102. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/DraggingSibling.js +0 -72
  103. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/IconButtonCustoms.js +0 -32
  104. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/index.js +0 -322
  105. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/connect.js +0 -11
  106. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/index.js +0 -2
  107. package/admin/src/content-manager/components/RepeatableComponent/DraggedItem/utils/select.js +0 -30
  108. package/admin/src/content-manager/components/RepeatableComponent/utils/connect.js +0 -11
  109. package/admin/src/content-manager/components/RepeatableComponent/utils/select.js +0 -12
  110. package/admin/src/content-manager/hooks/__test__/usePrev.test.js +0 -26
  111. package/build/2438.afe24949.chunk.js +0 -2525
  112. package/build/2517.5cc235ba.chunk.js +0 -117
  113. package/build/4306.53359960.chunk.js +0 -98
  114. package/build/8881.bfdb6877.chunk.js +0 -245
  115. package/build/9707.932a3c12.chunk.js +0 -70
  116. package/build/Admin-authenticatedApp.cfc3b4c9.chunk.js +0 -80
  117. package/build/admin-app.ee1211cb.chunk.js +0 -112
  118. package/build/api-tokens-create-page.4ca2778d.chunk.js +0 -1
  119. package/build/api-tokens-edit-page.70a791c2.chunk.js +0 -1
  120. package/build/content-manager.794d3373.chunk.js +0 -1200
  121. package/build/content-type-builder-list-view.95012cf0.chunk.js +0 -201
  122. package/build/content-type-builder.95b9d6a2.chunk.js +0 -145
  123. package/build/email-settings-page.4bb3606f.chunk.js +0 -15
  124. package/build/main.a6470578.js +0 -2031
  125. package/build/ru-json.d7cfc2ff.chunk.js +0 -1
  126. package/build/upload-settings.3010911f.chunk.js +0 -18
  127. package/build/upload.9f19f2e8.chunk.js +0 -64
  128. package/build/users-advanced-settings-page.9df41d67.chunk.js +0 -13
  129. package/build/users-email-settings-page.56d82eaf.chunk.js +0 -28
  130. package/build/users-providers-settings-page.96bb7da0.chunk.js +0 -33
  131. package/build/users-roles-settings-page.445e5e16.chunk.js +0 -30
  132. package/build/webhook-edit-page.c5efc08b.chunk.js +0 -75
@@ -1,322 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import React, { memo, useEffect, useRef, useState } from 'react';
3
- import PropTypes from 'prop-types';
4
- import { useDrag, useDrop } from 'react-dnd';
5
- import { getEmptyImage } from 'react-dnd-html5-backend';
6
- import styled from 'styled-components';
7
- import { useIntl } from 'react-intl';
8
- import toString from 'lodash/toString';
9
- import { Accordion, AccordionToggle, AccordionContent } from '@strapi/design-system/Accordion';
10
- import { Grid, GridItem } from '@strapi/design-system/Grid';
11
- import { Stack } from '@strapi/design-system/Stack';
12
- import { Box } from '@strapi/design-system/Box';
13
- import { Tooltip } from '@strapi/design-system/Tooltip';
14
- import Trash from '@strapi/icons/Trash';
15
- import Drag from '@strapi/icons/Drag';
16
- import ItemTypes from '../../../utils/ItemTypes';
17
- import getTrad from '../../../utils/getTrad';
18
- import Inputs from '../../Inputs';
19
- import FieldComponent from '../../FieldComponent';
20
- import Preview from './Preview';
21
- import DraggingSibling from './DraggingSibling';
22
- import { CustomIconButton } from './IconButtonCustoms';
23
- import { connect, select } from './utils';
24
-
25
- const DragButton = styled.span`
26
- display: flex;
27
- align-items: center;
28
- height: ${({ theme }) => theme.spaces[7]};
29
-
30
- padding: 0 ${({ theme }) => theme.spaces[3]};
31
- cursor: all-scroll;
32
-
33
- svg {
34
- width: ${12 / 16}rem;
35
- height: ${12 / 16}rem;
36
- }
37
- `;
38
-
39
- /* eslint-disable react/no-array-index-key */
40
-
41
- // Issues:
42
- // https://github.com/react-dnd/react-dnd/issues/1368
43
- // https://github.com/frontend-collective/react-sortable-tree/issues/490
44
-
45
- const DraggedItem = ({
46
- componentFieldName,
47
- componentUid,
48
- // Errors are retrieved from the AccordionGroupCustom cloneElement
49
- hasErrorMessage,
50
- hasErrors,
51
- isDraggingSibling,
52
- isOpen,
53
- isReadOnly,
54
- onClickToggle,
55
- schema,
56
- toggleCollapses,
57
- // Retrieved from the select function
58
- moveComponentField,
59
- removeRepeatableField,
60
- setIsDraggingSibling,
61
- triggerFormValidation,
62
- // checkFormErrors,
63
- displayedValue,
64
- }) => {
65
- const dragRef = useRef(null);
66
- const dropRef = useRef(null);
67
- const [, forceRerenderAfterDnd] = useState(false);
68
- const { formatMessage } = useIntl();
69
-
70
- const fields = schema.layouts.edit;
71
-
72
- const [, drop] = useDrop({
73
- accept: ItemTypes.COMPONENT,
74
- canDrop() {
75
- return false;
76
- },
77
- hover(item, monitor) {
78
- if (!dropRef.current) {
79
- return;
80
- }
81
-
82
- const dragPath = item.originalPath;
83
- const hoverPath = componentFieldName;
84
- const fullPathToComponentArray = dragPath.split('.');
85
- const dragIndexString = fullPathToComponentArray.slice().splice(-1).join('');
86
- const hoverIndexString = hoverPath.split('.').splice(-1).join('');
87
- const pathToComponentArray = fullPathToComponentArray.slice(
88
- 0,
89
- fullPathToComponentArray.length - 1
90
- );
91
- const dragIndex = parseInt(dragIndexString, 10);
92
- const hoverIndex = parseInt(hoverIndexString, 10);
93
-
94
- // Don't replace items with themselves
95
- if (dragIndex === hoverIndex) {
96
- return;
97
- }
98
-
99
- // Determine rectangle on screen
100
- const hoverBoundingRect = dropRef.current.getBoundingClientRect();
101
- // Get vertical middle
102
- const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
103
- // Determine mouse position
104
- const clientOffset = monitor.getClientOffset();
105
- // Get pixels to the top
106
- const hoverClientY = clientOffset.y - hoverBoundingRect.top;
107
-
108
- // Only perform the move when the mouse has crossed half of the items height
109
- // When dragging downwards, only move when the cursor is below 50%
110
- // When dragging upwards, only move when the cursor is above 50%
111
- // Dragging downwards
112
- if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
113
- return;
114
- }
115
- // Dragging upwards
116
- if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
117
- return;
118
- }
119
- // If They are not in the same level, should not move
120
- if (dragPath.split('.').length !== hoverPath.split('.').length) {
121
- return;
122
- }
123
- // Time to actually perform the action in the data
124
- moveComponentField(pathToComponentArray, dragIndex, hoverIndex);
125
-
126
- item.originalPath = hoverPath;
127
- },
128
- });
129
- const [{ isDragging }, drag, preview] = useDrag({
130
- type: ItemTypes.COMPONENT,
131
- item() {
132
- // Close all collapses
133
- toggleCollapses(-1);
134
-
135
- return {
136
- displayedValue,
137
- originalPath: componentFieldName,
138
- };
139
- },
140
- end() {
141
- // Update the errors
142
- triggerFormValidation();
143
- setIsDraggingSibling(false);
144
- },
145
- collect: (monitor) => ({
146
- isDragging: monitor.isDragging(),
147
- }),
148
- });
149
-
150
- useEffect(() => {
151
- preview(getEmptyImage(), { captureDraggingState: false });
152
- }, [preview]);
153
-
154
- useEffect(() => {
155
- if (isDragging) {
156
- setIsDraggingSibling(true);
157
- }
158
- }, [isDragging, setIsDraggingSibling]);
159
-
160
- // Effect in order to force a rerender after reordering the components
161
- // Since we are removing the Accordion when doing the DnD we are losing the dragRef, therefore the replaced element cannot be dragged
162
- // anymore, this hack forces a rerender in order to apply the dragRef
163
- useEffect(() => {
164
- if (!isDraggingSibling) {
165
- forceRerenderAfterDnd((prev) => !prev);
166
- }
167
- }, [isDraggingSibling]);
168
-
169
- // Create the refs
170
- // We need 1 for the drop target
171
- // 1 for the drag target
172
- const refs = {
173
- dragRef: drag(dragRef),
174
- dropRef: drop(dropRef),
175
- };
176
-
177
- const accordionTitle = toString(displayedValue);
178
- const accordionHasError = hasErrors ? 'error' : undefined;
179
-
180
- return (
181
- <Box ref={refs ? refs.dropRef : null}>
182
- {isDragging && <Preview />}
183
- {!isDragging && isDraggingSibling && (
184
- <DraggingSibling displayedValue={accordionTitle} componentFieldName={componentFieldName} />
185
- )}
186
-
187
- {!isDragging && !isDraggingSibling && (
188
- <Accordion
189
- error={accordionHasError}
190
- hasErrorMessage={hasErrorMessage}
191
- expanded={isOpen}
192
- onToggle={onClickToggle}
193
- id={componentFieldName}
194
- size="S"
195
- >
196
- <AccordionToggle
197
- action={
198
- isReadOnly ? null : (
199
- <Stack horizontal spacing={0}>
200
- <CustomIconButton
201
- expanded={isOpen}
202
- noBorder
203
- onClick={() => {
204
- removeRepeatableField(componentFieldName);
205
- toggleCollapses();
206
- }}
207
- label={formatMessage({
208
- id: getTrad('containers.Edit.delete'),
209
- defaultMessage: 'Delete',
210
- })}
211
- icon={<Trash />}
212
- />
213
- {/* react-dnd is broken in firefox with our IconButton, maybe a ref issue */}
214
- <Tooltip
215
- description={formatMessage({
216
- id: getTrad('components.DragHandle-label'),
217
- defaultMessage: 'Drag',
218
- })}
219
- >
220
- <DragButton
221
- role="button"
222
- tabIndex={-1}
223
- ref={refs.dragRef}
224
- onClick={(e) => e.stopPropagation()}
225
- >
226
- <Drag />
227
- </DragButton>
228
- </Tooltip>
229
- </Stack>
230
- )
231
- }
232
- title={accordionTitle}
233
- togglePosition="left"
234
- />
235
- <AccordionContent>
236
- <Stack background="neutral100" padding={6} spacing={6}>
237
- {fields.map((fieldRow, key) => {
238
- return (
239
- <Grid gap={4} key={key}>
240
- {fieldRow.map(({ name, fieldSchema, metadatas, queryInfos, size }) => {
241
- const isComponent = fieldSchema.type === 'component';
242
- const keys = `${componentFieldName}.${name}`;
243
-
244
- if (isComponent) {
245
- const componentUid = fieldSchema.component;
246
-
247
- return (
248
- <GridItem col={size} s={12} xs={12} key={name}>
249
- <FieldComponent
250
- componentUid={componentUid}
251
- intlLabel={{
252
- id: metadatas.label,
253
- defaultMessage: metadatas.label,
254
- }}
255
- isRepeatable={fieldSchema.repeatable}
256
- isNested
257
- name={keys}
258
- max={fieldSchema.max}
259
- min={fieldSchema.min}
260
- required={fieldSchema.required}
261
- />
262
- </GridItem>
263
- );
264
- }
265
-
266
- return (
267
- <GridItem key={keys} col={size} s={12} xs={12}>
268
- <Inputs
269
- componentUid={componentUid}
270
- fieldSchema={fieldSchema}
271
- keys={keys}
272
- metadatas={metadatas}
273
- // onBlur={hasErrors ? checkFormErrors : null}
274
- queryInfos={queryInfos}
275
- size={size}
276
- />
277
- </GridItem>
278
- );
279
- })}
280
- </Grid>
281
- );
282
- })}
283
- </Stack>
284
- </AccordionContent>
285
- </Accordion>
286
- )}
287
- </Box>
288
- );
289
- };
290
-
291
- DraggedItem.defaultProps = {
292
- componentUid: undefined,
293
- isDraggingSibling: false,
294
- isOpen: false,
295
- setIsDraggingSibling() {},
296
- toggleCollapses() {},
297
- };
298
-
299
- DraggedItem.propTypes = {
300
- componentFieldName: PropTypes.string.isRequired,
301
- componentUid: PropTypes.string,
302
- hasErrorMessage: PropTypes.bool.isRequired,
303
- hasErrors: PropTypes.bool.isRequired,
304
- isDraggingSibling: PropTypes.bool,
305
- isOpen: PropTypes.bool,
306
- isReadOnly: PropTypes.bool.isRequired,
307
- onClickToggle: PropTypes.func.isRequired,
308
- schema: PropTypes.object.isRequired,
309
- toggleCollapses: PropTypes.func,
310
- moveComponentField: PropTypes.func.isRequired,
311
- removeRepeatableField: PropTypes.func.isRequired,
312
- setIsDraggingSibling: PropTypes.func,
313
- triggerFormValidation: PropTypes.func.isRequired,
314
- // checkFormErrors: PropTypes.func.isRequired,
315
- displayedValue: PropTypes.string.isRequired,
316
- };
317
-
318
- const Memoized = memo(DraggedItem);
319
-
320
- export default connect(Memoized, select);
321
-
322
- export { DraggedItem };
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
-
3
- function connect(WrappedComponent, select) {
4
- return (props) => {
5
- const selectors = select(props);
6
-
7
- return <WrappedComponent {...props} {...selectors} />;
8
- };
9
- }
10
-
11
- export default connect;
@@ -1,2 +0,0 @@
1
- export { default as connect } from './connect';
2
- export { default as select } from './select';
@@ -1,30 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { get, toString } from 'lodash';
3
- import { useCMEditViewDataManager } from '@strapi/helper-plugin';
4
-
5
- function useSelect({ schema, componentFieldName }) {
6
- const {
7
- checkFormErrors,
8
- modifiedData,
9
- moveComponentField,
10
- removeRepeatableField,
11
- triggerFormValidation,
12
- } = useCMEditViewDataManager();
13
-
14
- const mainField = useMemo(() => get(schema, ['settings', 'mainField'], 'id'), [schema]);
15
- const displayedValue = toString(
16
- get(modifiedData, [...componentFieldName.split('.'), mainField], '')
17
- );
18
-
19
- return {
20
- displayedValue,
21
- mainField,
22
- checkFormErrors,
23
- moveComponentField,
24
- removeRepeatableField,
25
- schema,
26
- triggerFormValidation,
27
- };
28
- }
29
-
30
- export default useSelect;
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
-
3
- function connect(WrappedComponent, select) {
4
- return (props) => {
5
- const selectors = select(props);
6
-
7
- return <WrappedComponent {...props} {...selectors} />;
8
- };
9
- }
10
-
11
- export default connect;
@@ -1,12 +0,0 @@
1
- import { useCMEditViewDataManager } from '@strapi/helper-plugin';
2
-
3
- function useSelect() {
4
- const { addRepeatableComponentToField, formErrors } = useCMEditViewDataManager();
5
-
6
- return {
7
- addRepeatableComponentToField,
8
- formErrors,
9
- };
10
- }
11
-
12
- export default useSelect;
@@ -1,26 +0,0 @@
1
- import { renderHook } from '@testing-library/react-hooks';
2
-
3
- import { usePrev } from '../usePrev';
4
-
5
- describe('usePrev', () => {
6
- const setup = () => renderHook(({ state }) => usePrev(state), { initialProps: { state: 0 } });
7
-
8
- it('should return undefined on initial render', () => {
9
- const { result } = setup();
10
-
11
- expect(result.current).toBeUndefined();
12
- });
13
-
14
- it('should always return previous state after each update', () => {
15
- const { result, rerender } = setup();
16
-
17
- rerender({ state: 2 });
18
- expect(result.current).toBe(0);
19
-
20
- rerender({ state: 4 });
21
- expect(result.current).toBe(2);
22
-
23
- rerender({ state: 6 });
24
- expect(result.current).toBe(4);
25
- });
26
- });