@draftbit/core 50.4.1-3391d5.2 → 50.5.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.
- package/lib/commonjs/components/DeckSwiper/DeckSwiper.js +1 -1
- package/lib/commonjs/components/DeckSwiper/index.js +1 -1
- package/lib/typescript/src/components/DeckSwiper/DeckSwiper.d.ts +4 -1
- package/lib/typescript/src/components/DeckSwiper/DeckSwiper.js +26 -5
- package/lib/typescript/src/components/DeckSwiper/DeckSwiper.js.map +1 -1
- package/lib/typescript/src/components/DeckSwiper/index.d.ts +1 -1
- package/lib/typescript/src/components/DeckSwiper/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/DeckSwiper/DeckSwiper.js +26 -5
- package/src/components/DeckSwiper/DeckSwiper.js.map +1 -1
- package/src/components/DeckSwiper/DeckSwiper.tsx +157 -127
- package/src/components/DeckSwiper/index.js.map +1 -1
- package/src/components/DeckSwiper/index.tsx +1 -1
- package/src/index.js.map +1 -1
- package/src/index.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "50.
|
|
3
|
+
"version": "50.5.0",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"types": "lib/typescript/src/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@dotlottie/react-player": "1.6.1",
|
|
44
44
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
45
|
-
"@draftbit/theme": "
|
|
45
|
+
"@draftbit/theme": "50.5.0",
|
|
46
46
|
"@expo/vector-icons": "^14.0.0",
|
|
47
47
|
"@gorhom/bottom-sheet": "5.0.0-alpha.7",
|
|
48
48
|
"@lottiefiles/react-lottie-player": "3.5.3",
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
],
|
|
123
123
|
"testEnvironment": "node"
|
|
124
124
|
},
|
|
125
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "4c953d49c10c15e33fb71ceeab04e9aac25887d5"
|
|
126
126
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { StyleSheet, View } from "react-native";
|
|
3
3
|
import DeckSwiperComponent from "react-native-deck-swiper";
|
|
4
|
-
const DeckSwiper = ({ onStartSwipe, onEndSwipe, onSwipe, onSwipedLeft, onSwipedRight, onSwipedUp, onSwipedDown, onIndexChanged, onEndReached, startCardIndex = 0, infiniteSwiping = false, verticalEnabled = true, horizontalEnabled = true, visibleCardCount = 1, data, keyExtractor, renderItem, style, children, }) => {
|
|
4
|
+
const DeckSwiper = React.forwardRef(({ onStartSwipe, onEndSwipe, onSwipe, onSwipedLeft, onSwipedRight, onSwipedUp, onSwipedDown, onIndexChanged, onEndReached, startCardIndex = 0, infiniteSwiping = false, verticalEnabled = true, horizontalEnabled = true, visibleCardCount = 1, data, keyExtractor, renderItem, style, children, }, ref) => {
|
|
5
5
|
//Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
|
|
6
6
|
if ((data && !renderItem) || (renderItem && !data)) {
|
|
7
7
|
throw new Error("'renderItem' and 'data' need to both be provided to lazily render. Either remove them entirley or include both");
|
|
@@ -37,13 +37,34 @@ const DeckSwiper = ({ onStartSwipe, onEndSwipe, onSwipe, onSwipedLeft, onSwipedR
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
/*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
react-native-deck-swiper does not re-render cards when parent state changes
|
|
41
|
+
This forces an update on every re-render to reflect any parent state changes
|
|
42
|
+
*/
|
|
43
43
|
React.useEffect(() => {
|
|
44
44
|
var _a;
|
|
45
45
|
(_a = deckSwiperRef.current) === null || _a === void 0 ? void 0 : _a.forceUpdate();
|
|
46
46
|
});
|
|
47
|
+
React.useImperativeHandle(ref, () => ({
|
|
48
|
+
swipeCard: (direction) => {
|
|
49
|
+
var _a, _b, _c, _d, _e;
|
|
50
|
+
switch (direction) {
|
|
51
|
+
case "left":
|
|
52
|
+
(_a = deckSwiperRef.current) === null || _a === void 0 ? void 0 : _a.swipeLeft();
|
|
53
|
+
break;
|
|
54
|
+
case "right":
|
|
55
|
+
(_b = deckSwiperRef.current) === null || _b === void 0 ? void 0 : _b.swipeRight();
|
|
56
|
+
break;
|
|
57
|
+
case "top":
|
|
58
|
+
(_c = deckSwiperRef.current) === null || _c === void 0 ? void 0 : _c.swipeTop();
|
|
59
|
+
break;
|
|
60
|
+
case "bottom":
|
|
61
|
+
(_d = deckSwiperRef.current) === null || _d === void 0 ? void 0 : _d.swipeBottom();
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
(_e = deckSwiperRef.current) === null || _e === void 0 ? void 0 : _e.swipeLeft();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
}));
|
|
47
68
|
/**
|
|
48
69
|
* By default react-native-deck-swiper positions everything with absolute position.
|
|
49
70
|
* To overcome this, it is wrapped in a View to be able to add the component in any layout structure.
|
|
@@ -72,7 +93,7 @@ const DeckSwiper = ({ onStartSwipe, onEndSwipe, onSwipe, onSwipedLeft, onSwipedR
|
|
|
72
93
|
dragStart: onStartSwipe,
|
|
73
94
|
//@ts-ignore
|
|
74
95
|
dragEnd: onEndSwipe })));
|
|
75
|
-
};
|
|
96
|
+
});
|
|
76
97
|
const styles = StyleSheet.create({
|
|
77
98
|
cardsContainer: {
|
|
78
99
|
position: "absolute",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeckSwiper.js","sourceRoot":"","sources":["DeckSwiper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,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P,OAAO,uBAAP,OAAO,CAAG,KAAK,CAAC,CAAC;YACnB,CAAC,EACD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;gBACvB,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,CAAC;gBACvB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,KAAK,CAAC,CAAC;YACnB,CAAC,EACD,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;gBACrB,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,KAAK,CAAC,CAAC;gBACpB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,KAAK,CAAC,CAAC;YACnB,CAAC,EACD,cAAc,EAAE,CAAC,KAAK,EAAE,EAAE;gBACxB,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,KAAK,CAAC,CAAC;gBACtB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,KAAK,CAAC,CAAC;YACnB,CAAC;YACD,oDAAoD;YACpD,SAAS,EAAE,YAAY;YACvB,YAAY;YACZ,OAAO,EAAE,UAAU,GACnB,CACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,cAAc,EAAE;QACd,QAAQ,EAAE,UAAU;KACrB;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACf;IACD,qBAAqB,EAAE;QACrB,OAAO,EAAE,GAAG;KACb;CACF,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -2,6 +2,10 @@ import React from "react";
|
|
|
2
2
|
import { StyleProp, ViewStyle, StyleSheet, View } from "react-native";
|
|
3
3
|
import DeckSwiperComponent from "react-native-deck-swiper";
|
|
4
4
|
|
|
5
|
+
export interface DeckSwiperRef {
|
|
6
|
+
swipeCard: (direction: "left" | "right" | "top" | "bottom") => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
export interface DeckSwiperProps<T> {
|
|
6
10
|
onStartSwipe?: () => void;
|
|
7
11
|
onEndSwipe?: () => void;
|
|
@@ -23,145 +27,171 @@ export interface DeckSwiperProps<T> {
|
|
|
23
27
|
style?: StyleProp<ViewStyle>;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
const DeckSwiper = <
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
const DeckSwiper = React.forwardRef<DeckSwiperRef, DeckSwiperProps<any>>(
|
|
31
|
+
<T extends object>(
|
|
32
|
+
{
|
|
33
|
+
onStartSwipe,
|
|
34
|
+
onEndSwipe,
|
|
35
|
+
onSwipe,
|
|
36
|
+
onSwipedLeft,
|
|
37
|
+
onSwipedRight,
|
|
38
|
+
onSwipedUp,
|
|
39
|
+
onSwipedDown,
|
|
40
|
+
onIndexChanged,
|
|
41
|
+
onEndReached,
|
|
42
|
+
startCardIndex = 0,
|
|
43
|
+
infiniteSwiping = false,
|
|
44
|
+
verticalEnabled = true,
|
|
45
|
+
horizontalEnabled = true,
|
|
46
|
+
visibleCardCount = 1,
|
|
47
|
+
data,
|
|
48
|
+
keyExtractor,
|
|
49
|
+
renderItem,
|
|
50
|
+
style,
|
|
51
|
+
children,
|
|
52
|
+
}: React.PropsWithChildren<DeckSwiperProps<T>>,
|
|
53
|
+
ref: React.Ref<DeckSwiperRef>
|
|
54
|
+
) => {
|
|
55
|
+
//Both 'renderItem' and 'data' are optional to allow direct children. But if one is included, both need to be included
|
|
56
|
+
if ((data && !renderItem) || (renderItem && !data)) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"'renderItem' and 'data' need to both be provided to lazily render. Either remove them entirley or include both"
|
|
59
|
+
);
|
|
60
|
+
}
|
|
53
61
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
if (data && renderItem && children) {
|
|
63
|
+
console.warn(
|
|
64
|
+
"'children' of DeckSwiper ignored due to usage of 'data' and 'renderItem'"
|
|
65
|
+
);
|
|
66
|
+
}
|
|
59
67
|
|
|
60
|
-
|
|
68
|
+
const deckSwiperRef = React.useRef<DeckSwiperComponent<T>>(null);
|
|
61
69
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
const childrenArray = React.useMemo(
|
|
71
|
+
() => React.Children.toArray(children),
|
|
72
|
+
[children]
|
|
73
|
+
);
|
|
66
74
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
// an array of indices based on children count
|
|
76
|
+
const cardsFillerData = React.useMemo(
|
|
77
|
+
() => Array.from(Array(childrenArray.length).keys()),
|
|
78
|
+
[childrenArray]
|
|
79
|
+
);
|
|
72
80
|
|
|
73
|
-
|
|
81
|
+
const cardsData = Array.isArray(data) ? data : cardsFillerData;
|
|
74
82
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
const renderCard = (card: any, index: number): JSX.Element => {
|
|
84
|
+
if (renderItem) {
|
|
85
|
+
return renderItem({ item: card, index });
|
|
86
|
+
} else {
|
|
87
|
+
return <>{childrenArray[index]}</>;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
82
90
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const cardKeyExtractor = (card: any) => {
|
|
91
|
-
if (keyExtractor) {
|
|
92
|
-
return keyExtractor(card);
|
|
93
|
-
} else {
|
|
94
|
-
return card?.toString();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
91
|
+
const renderFirstCard = (): JSX.Element | undefined => {
|
|
92
|
+
if (cardsData.length) {
|
|
93
|
+
return renderCard(cardsData[0], 0);
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
};
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
const cardKeyExtractor = (card: any) => {
|
|
99
|
+
if (keyExtractor) {
|
|
100
|
+
return keyExtractor(card);
|
|
101
|
+
} else {
|
|
102
|
+
return card?.toString();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/*
|
|
99
107
|
react-native-deck-swiper does not re-render cards when parent state changes
|
|
100
108
|
This forces an update on every re-render to reflect any parent state changes
|
|
101
109
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
keyExtractor={cardKeyExtractor}
|
|
124
|
-
containerStyle={
|
|
125
|
-
StyleSheet.flatten([styles.cardsContainer, style]) as
|
|
126
|
-
| object
|
|
127
|
-
| undefined
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
deckSwiperRef.current?.forceUpdate();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
React.useImperativeHandle(ref, () => ({
|
|
115
|
+
swipeCard: (direction: "left" | "right" | "top" | "bottom") => {
|
|
116
|
+
switch (direction) {
|
|
117
|
+
case "left":
|
|
118
|
+
deckSwiperRef.current?.swipeLeft();
|
|
119
|
+
break;
|
|
120
|
+
case "right":
|
|
121
|
+
deckSwiperRef.current?.swipeRight();
|
|
122
|
+
break;
|
|
123
|
+
case "top":
|
|
124
|
+
deckSwiperRef.current?.swipeTop();
|
|
125
|
+
break;
|
|
126
|
+
case "bottom":
|
|
127
|
+
deckSwiperRef.current?.swipeBottom();
|
|
128
|
+
break;
|
|
129
|
+
default:
|
|
130
|
+
deckSwiperRef.current?.swipeLeft();
|
|
128
131
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
132
|
+
},
|
|
133
|
+
}));
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* By default react-native-deck-swiper positions everything with absolute position.
|
|
137
|
+
* To overcome this, it is wrapped in a View to be able to add the component in any layout structure.
|
|
138
|
+
*
|
|
139
|
+
*
|
|
140
|
+
* Since all children of that View are absolutley positioned, the View does not have a height and still looks and behaves weird.
|
|
141
|
+
* To fix/mitage this without setting a static height, the first card is rendered in invisible state to take up space.
|
|
142
|
+
* This effectivley makes the default height of the container be the height of the first card.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<View>
|
|
147
|
+
<View style={styles.containerHeightFiller}>{renderFirstCard()}</View>
|
|
148
|
+
<DeckSwiperComponent
|
|
149
|
+
ref={deckSwiperRef}
|
|
150
|
+
cards={cardsData as any[]}
|
|
151
|
+
renderCard={renderCard}
|
|
152
|
+
keyExtractor={cardKeyExtractor}
|
|
153
|
+
containerStyle={
|
|
154
|
+
StyleSheet.flatten([styles.cardsContainer, style]) as
|
|
155
|
+
| object
|
|
156
|
+
| undefined
|
|
157
|
+
}
|
|
158
|
+
cardStyle={styles.card as object | undefined}
|
|
159
|
+
onSwiped={onIndexChanged}
|
|
160
|
+
onSwipedAll={onEndReached}
|
|
161
|
+
cardIndex={startCardIndex}
|
|
162
|
+
infinite={infiniteSwiping}
|
|
163
|
+
verticalSwipe={verticalEnabled}
|
|
164
|
+
horizontalSwipe={horizontalEnabled}
|
|
165
|
+
showSecondCard={visibleCardCount > 1}
|
|
166
|
+
stackSize={visibleCardCount}
|
|
167
|
+
backgroundColor="transparent"
|
|
168
|
+
cardVerticalMargin={0}
|
|
169
|
+
cardHorizontalMargin={0}
|
|
170
|
+
onSwipedLeft={(index) => {
|
|
171
|
+
onSwipedLeft?.(index);
|
|
172
|
+
onSwipe?.(index);
|
|
173
|
+
}}
|
|
174
|
+
onSwipedRight={(index) => {
|
|
175
|
+
onSwipedRight?.(index);
|
|
176
|
+
onSwipe?.(index);
|
|
177
|
+
}}
|
|
178
|
+
onSwipedTop={(index) => {
|
|
179
|
+
onSwipedUp?.(index);
|
|
180
|
+
onSwipe?.(index);
|
|
181
|
+
}}
|
|
182
|
+
onSwipedBottom={(index) => {
|
|
183
|
+
onSwipedDown?.(index);
|
|
184
|
+
onSwipe?.(index);
|
|
185
|
+
}}
|
|
186
|
+
//@ts-ignore Not typed, but is implemented and works
|
|
187
|
+
dragStart={onStartSwipe}
|
|
188
|
+
//@ts-ignore
|
|
189
|
+
dragEnd={onEndSwipe}
|
|
190
|
+
/>
|
|
191
|
+
</View>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
);
|
|
165
195
|
|
|
166
196
|
const styles = StyleSheet.create({
|
|
167
197
|
cardsContainer: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAiB,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as DeckSwiper } from "./DeckSwiper";
|
|
1
|
+
export { default as DeckSwiper, DeckSwiperRef } from "./DeckSwiper";
|
|
2
2
|
export { default as DeckSwiperCard } from "./DeckSwiperCard";
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,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OAAO,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,MAAM,IAAI,gBAAgB,EAC1B,MAAM,IAAI,gBAAgB,EAC1B,GAAG,EACH,KAAK,GACN,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AACrG,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,2CAA2C,CAAC"}
|
package/src/index.tsx
CHANGED
|
@@ -34,6 +34,7 @@ export {
|
|
|
34
34
|
} from "./components/RadioButton/index";
|
|
35
35
|
export { default as Shadow } from "./components/Shadow";
|
|
36
36
|
export { DeckSwiper, DeckSwiperCard } from "./components/DeckSwiper";
|
|
37
|
+
export type { DeckSwiperRef } from "./components/DeckSwiper";
|
|
37
38
|
export { TabView, TabViewItem } from "./components/TabView";
|
|
38
39
|
export { default as Markdown } from "./components/Markdown";
|
|
39
40
|
export { BottomSheet } from "./components/BottomSheet";
|