This repository was archived by the owner on Apr 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +86
-5
lines changed Expand file tree Collapse file tree 4 files changed +86
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import type { FC } from 'react';
3
3
4
4
import { Provider , createStore , useStoreApi } from '../store' ;
5
5
6
- const SortableListWrapper : FC = ( { children } ) => {
6
+ const StoreWrapper : FC = ( { children } ) => {
7
7
let isWrapped = true ;
8
8
9
9
try {
@@ -21,4 +21,4 @@ const SortableListWrapper: FC = ({ children }) => {
21
21
return < Provider createStore = { createStore } > { children } </ Provider > ;
22
22
} ;
23
23
24
- export default SortableListWrapper ;
24
+ export default StoreWrapper ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import {
16
16
17
17
import { Sortable } from './App' ;
18
18
import type { SortableItemList , SortableListProps } from '../types' ;
19
- import SortableListWrapper from './Wrapper' ;
19
+ import StoreWrapper from './Wrapper' ;
20
20
import StoreUpdater from './StoreUpdater' ;
21
21
22
22
const defaultDropAnimationConfig : DropAnimation = {
@@ -77,7 +77,7 @@ function SortableList<T extends SortableItemList = SortableItemList>({
77
77
} , [ direction , getModifiers ] ) ;
78
78
79
79
return (
80
- < SortableListWrapper >
80
+ < StoreWrapper >
81
81
< Sortable
82
82
direction = { direction }
83
83
dropAnimation = { defaultDropAnimationConfig }
@@ -90,7 +90,7 @@ function SortableList<T extends SortableItemList = SortableItemList>({
90
90
gap = { gap }
91
91
/>
92
92
< StoreUpdater onDataChange = { onChange } data = { dataSource } />
93
- </ SortableListWrapper >
93
+ </ StoreWrapper >
94
94
) ;
95
95
}
96
96
Original file line number Diff line number Diff line change 1
1
// Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
3
+ exports [` SortableList 有数据 1` ] = `
4
+ <div >
5
+ <div
6
+ class = " sc-bdvvtL jXutGz avx-sortable-list layoutkit-flexbox"
7
+ >
8
+ <li
9
+ class = " avx-sortable-item-container"
10
+ >
11
+ <div
12
+ aria-describedby = " DndDescribedBy-1"
13
+ aria-roledescription = " sortable"
14
+ class = " avx-sortable-item"
15
+ data-id = " 1"
16
+ data-index = " 0"
17
+ role = " button"
18
+ tabindex = " 0"
19
+ >
20
+ 1
21
+ <span
22
+ class = " avx-sortable-action"
23
+ >
24
+ <button
25
+ class = " avx-sortable-action-remove"
26
+ tabindex = " 0"
27
+ >
28
+ <svg
29
+ viewBox = " 0 0 22 22"
30
+ width = " 8"
31
+ xmlns = " http://www.w3.org/2000/svg"
32
+ >
33
+ <path
34
+ d = " M2.99998 -0.000206962C2.7441 -0.000206962 2.48794 0.0972617 2.29294 0.292762L0.292945 2.29276C-0.0980552 2.68376 -0.0980552 3.31682 0.292945 3.70682L7.58591 10.9998L0.292945 18.2928C-0.0980552 18.6838 -0.0980552 19.3168 0.292945 19.7068L2.29294 21.7068C2.68394 22.0978 3.31701 22.0978 3.70701 21.7068L11 14.4139L18.2929 21.7068C18.6829 22.0978 19.317 22.0978 19.707 21.7068L21.707 19.7068C22.098 19.3158 22.098 18.6828 21.707 18.2928L14.414 10.9998L21.707 3.70682C22.098 3.31682 22.098 2.68276 21.707 2.29276L19.707 0.292762C19.316 -0.0982383 18.6829 -0.0982383 18.2929 0.292762L11 7.58573L3.70701 0.292762C3.51151 0.0972617 3.25585 -0.000206962 2.99998 -0.000206962Z"
35
+ />
36
+ </svg >
37
+ </button >
38
+ </span >
39
+ </div >
40
+ </li >
41
+ <li
42
+ class = " avx-sortable-item-container"
43
+ >
44
+ <div
45
+ aria-describedby = " DndDescribedBy-1"
46
+ aria-roledescription = " sortable"
47
+ class = " avx-sortable-item"
48
+ data-id = " 2"
49
+ data-index = " 1"
50
+ role = " button"
51
+ tabindex = " 0"
52
+ >
53
+ 2
54
+ <span
55
+ class = " avx-sortable-action"
56
+ >
57
+ <button
58
+ class = " avx-sortable-action-remove"
59
+ tabindex = " 0"
60
+ >
61
+ <svg
62
+ viewBox = " 0 0 22 22"
63
+ width = " 8"
64
+ xmlns = " http://www.w3.org/2000/svg"
65
+ >
66
+ <path
67
+ d = " M2.99998 -0.000206962C2.7441 -0.000206962 2.48794 0.0972617 2.29294 0.292762L0.292945 2.29276C-0.0980552 2.68376 -0.0980552 3.31682 0.292945 3.70682L7.58591 10.9998L0.292945 18.2928C-0.0980552 18.6838 -0.0980552 19.3168 0.292945 19.7068L2.29294 21.7068C2.68394 22.0978 3.31701 22.0978 3.70701 21.7068L11 14.4139L18.2929 21.7068C18.6829 22.0978 19.317 22.0978 19.707 21.7068L21.707 19.7068C22.098 19.3158 22.098 18.6828 21.707 18.2928L14.414 10.9998L21.707 3.70682C22.098 3.31682 22.098 2.68276 21.707 2.29276L19.707 0.292762C19.316 -0.0982383 18.6829 -0.0982383 18.2929 0.292762L11 7.58573L3.70701 0.292762C3.51151 0.0972617 3.25585 -0.000206962 2.99998 -0.000206962Z"
68
+ />
69
+ </svg >
70
+ </button >
71
+ </span >
72
+ </div >
73
+ </li >
74
+ </div >
75
+ </div >
76
+ ` ;
77
+
3
78
exports [` SortableList 默认状态 1` ] = `
4
79
<div >
5
80
<div
Original file line number Diff line number Diff line change @@ -8,4 +8,10 @@ describe('SortableList', () => {
8
8
const { container } = render ( < SortableList /> ) ;
9
9
expect ( container ) . toMatchSnapshot ( ) ;
10
10
} ) ;
11
+ it ( '有数据' , ( ) => {
12
+ const { container } = render (
13
+ < SortableList dataSource = { [ { id : '1' } , { id : '2' } ] } /> ,
14
+ ) ;
15
+ expect ( container ) . toMatchSnapshot ( ) ;
16
+ } ) ;
11
17
} ) ;
You can’t perform that action at this time.
0 commit comments