@draftbit/core 48.4.8-fb2b2b.2 → 48.4.8
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/PinInput/PinInput.js +1 -1
- package/lib/commonjs/components/SectionList/SectionList.js +1 -1
- package/lib/typescript/src/components/PinInput/PinInput.d.ts +2 -6
- package/lib/typescript/src/components/PinInput/PinInput.js +16 -15
- package/lib/typescript/src/components/PinInput/PinInput.js.map +1 -1
- package/lib/typescript/src/components/SectionList/SectionList.d.ts +2 -1
- package/lib/typescript/src/components/SectionList/SectionList.js +13 -3
- package/lib/typescript/src/components/SectionList/SectionList.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/PinInput/PinInput.js +16 -15
- package/src/components/PinInput/PinInput.js.map +1 -1
- package/src/components/PinInput/PinInput.tsx +20 -26
- package/src/components/SectionList/SectionList.js +13 -3
- package/src/components/SectionList/SectionList.js.map +1 -1
- package/src/components/SectionList/SectionList.tsx +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "48.4.8
|
|
3
|
+
"version": "48.4.8",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"types": "lib/typescript/src/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "
|
|
44
|
+
"@draftbit/types": "48.3.0",
|
|
45
45
|
"@expo/vector-icons": "^13.0.0",
|
|
46
46
|
"@material-ui/core": "^4.11.0",
|
|
47
47
|
"@material-ui/pickers": "^3.2.10",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
],
|
|
101
101
|
"testEnvironment": "node"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "fb0c93b813658dcd8915c77b447cb4259f2b411f"
|
|
104
104
|
}
|
|
@@ -5,7 +5,7 @@ import { CodeField, useClearByFocusCell, } from "react-native-confirmation-code-
|
|
|
5
5
|
import { withTheme } from "../../theming";
|
|
6
6
|
import PinInputText from "./PinInputText";
|
|
7
7
|
import { extractStyles } from "../../utilities";
|
|
8
|
-
const PinInput = React.forwardRef(({ theme, onInputFull, cellCount = 4, clearOnCellFocus = true, blurOnFull = true, renderItem, value, onChangeText, focusedBorderColor
|
|
8
|
+
const PinInput = React.forwardRef(({ theme, onInputFull, cellCount = 4, clearOnCellFocus = true, blurOnFull = true, renderItem, value, onChangeText, focusedBorderColor, focusedBackgroundColor, focusedBorderWidth, focusedTextColor, style, ...rest }, ref) => {
|
|
9
9
|
const newPinInputRef = React.useRef(null);
|
|
10
10
|
// Use the provided ref or default to new ref when not provided
|
|
11
11
|
const pinInputRef = ref
|
|
@@ -29,25 +29,25 @@ const PinInput = React.forwardRef(({ theme, onInputFull, cellCount = 4, clearOnC
|
|
|
29
29
|
}, [value, cellCount, blurOnFull, pinInputRef]);
|
|
30
30
|
return (React.createElement(CodeField, { ref: pinInputRef, ...(clearOnCellFocus ? codeFieldProps : {}), value: value, onChangeText: onChangeText, textInputStyle: { height: "100%" }, InputComponent: TextInput, cellCount: cellCount, renderCell: ({ symbol: cellValue, index, isFocused }) => (React.createElement(View, { key: index, onLayout: clearOnCellFocus ? getCellOnLayout(index) : undefined, style: { flex: 1 } }, (renderItem === null || renderItem === void 0 ? void 0 : renderItem({ cellValue, index, isFocused })) || (React.createElement(View, { testID: "default-code-input-cell", style: [
|
|
31
31
|
styles.cell,
|
|
32
|
-
{
|
|
33
|
-
borderWidth: isFocused
|
|
34
|
-
? focusedBorderWidth
|
|
35
|
-
: unFocusedBorderWidth,
|
|
36
|
-
borderColor: isFocused
|
|
37
|
-
? focusedBorderColor
|
|
38
|
-
: unFocusedBorderColor,
|
|
39
|
-
backgroundColor: isFocused
|
|
40
|
-
? focusedBackgroundColor
|
|
41
|
-
: unFocusedBackgroundColor,
|
|
42
|
-
},
|
|
32
|
+
{ borderColor: theme.colors.disabled },
|
|
43
33
|
viewStyles,
|
|
34
|
+
isFocused && focusedBorderWidth
|
|
35
|
+
? { borderWidth: focusedBorderWidth }
|
|
36
|
+
: undefined,
|
|
37
|
+
isFocused && focusedBorderColor
|
|
38
|
+
? { borderColor: focusedBorderColor }
|
|
39
|
+
: undefined,
|
|
40
|
+
isFocused && focusedBackgroundColor
|
|
41
|
+
? { backgroundColor: focusedBackgroundColor }
|
|
42
|
+
: undefined,
|
|
44
43
|
] },
|
|
45
44
|
React.createElement(PinInputText, { style: [
|
|
46
45
|
styles.cellText,
|
|
47
|
-
{
|
|
48
|
-
color: isFocused ? focusedTextColor : unFocusedTextColor,
|
|
49
|
-
},
|
|
46
|
+
{ color: theme.colors.strong },
|
|
50
47
|
textStyles,
|
|
48
|
+
isFocused && focusedTextColor
|
|
49
|
+
? { color: focusedTextColor }
|
|
50
|
+
: undefined,
|
|
51
51
|
], isFocused: isFocused }, cellValue))))), ...rest }));
|
|
52
52
|
});
|
|
53
53
|
const styles = StyleSheet.create({
|
|
@@ -61,6 +61,7 @@ const styles = StyleSheet.create({
|
|
|
61
61
|
aspectRatio: 1,
|
|
62
62
|
maxWidth: 70,
|
|
63
63
|
maxHeight: 70,
|
|
64
|
+
borderWidth: 1,
|
|
64
65
|
},
|
|
65
66
|
cellText: {
|
|
66
67
|
fontSize: 25,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinInput.js","sourceRoot":"","sources":["PinInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"PinInput.js","sourceRoot":"","sources":["PinInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,C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S;gBACb,SAAS,IAAI,sBAAsB;oBACjC,CAAC,CAAC,EAAE,eAAe,EAAE,sBAAsB,EAAE;oBAC7C,CAAC,CAAC,SAAS;aACd;YAED,oBAAC,YAAY,IACX,KAAK,EAAE;oBACL,MAAM,CAAC,QAAQ;oBACf,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;oBAC9B,UAAU;oBACV,SAAS,IAAI,gBAAgB;wBAC3B,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE;wBAC7B,CAAC,CAAC,SAAS;iBACd,EACD,SAAS,EAAE,SAAS,IAEnB,SAAS,CACG,CACV,CACR,CACI,CACR,KACG,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,CAAC;QACf,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;QACpB,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,CAAC;KACf;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,EAAE;KACb;CACF,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
StyleProp,
|
|
4
4
|
ViewStyle,
|
|
5
|
+
TextStyle,
|
|
5
6
|
TextInput as NativeTextInput,
|
|
6
7
|
View,
|
|
7
8
|
StyleSheet,
|
|
@@ -29,14 +30,10 @@ interface PinInputProps extends TextInputProps {
|
|
|
29
30
|
blurOnFull?: boolean;
|
|
30
31
|
renderItem?: ({ cellValue, index, isFocused }: CellItem) => JSX.Element;
|
|
31
32
|
focusedBorderColor?: string;
|
|
32
|
-
unFocusedBorderColor?: string;
|
|
33
33
|
focusedBackgroundColor?: string;
|
|
34
|
-
unFocusedBackgroundColor?: string;
|
|
35
34
|
focusedBorderWidth?: number;
|
|
36
|
-
unFocusedBorderWidth?: number;
|
|
37
35
|
focusedTextColor?: string;
|
|
38
|
-
|
|
39
|
-
style?: StyleProp<ViewStyle>;
|
|
36
|
+
style?: StyleProp<ViewStyle | TextStyle>;
|
|
40
37
|
theme: Theme;
|
|
41
38
|
}
|
|
42
39
|
|
|
@@ -51,14 +48,10 @@ const PinInput = React.forwardRef<NativeTextInput, PinInputProps>(
|
|
|
51
48
|
renderItem,
|
|
52
49
|
value,
|
|
53
50
|
onChangeText,
|
|
54
|
-
focusedBorderColor
|
|
55
|
-
unFocusedBorderColor = theme.colors.disabled,
|
|
51
|
+
focusedBorderColor,
|
|
56
52
|
focusedBackgroundColor,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
unFocusedBorderWidth = 1,
|
|
60
|
-
focusedTextColor = theme.colors.strong,
|
|
61
|
-
unFocusedTextColor = focusedTextColor,
|
|
53
|
+
focusedBorderWidth,
|
|
54
|
+
focusedTextColor,
|
|
62
55
|
style,
|
|
63
56
|
...rest
|
|
64
57
|
},
|
|
@@ -109,27 +102,27 @@ const PinInput = React.forwardRef<NativeTextInput, PinInputProps>(
|
|
|
109
102
|
testID="default-code-input-cell"
|
|
110
103
|
style={[
|
|
111
104
|
styles.cell,
|
|
112
|
-
{
|
|
113
|
-
borderWidth: isFocused
|
|
114
|
-
? focusedBorderWidth
|
|
115
|
-
: unFocusedBorderWidth,
|
|
116
|
-
borderColor: isFocused
|
|
117
|
-
? focusedBorderColor
|
|
118
|
-
: unFocusedBorderColor,
|
|
119
|
-
backgroundColor: isFocused
|
|
120
|
-
? focusedBackgroundColor
|
|
121
|
-
: unFocusedBackgroundColor,
|
|
122
|
-
},
|
|
105
|
+
{ borderColor: theme.colors.disabled },
|
|
123
106
|
viewStyles,
|
|
107
|
+
isFocused && focusedBorderWidth
|
|
108
|
+
? { borderWidth: focusedBorderWidth }
|
|
109
|
+
: undefined,
|
|
110
|
+
isFocused && focusedBorderColor
|
|
111
|
+
? { borderColor: focusedBorderColor }
|
|
112
|
+
: undefined,
|
|
113
|
+
isFocused && focusedBackgroundColor
|
|
114
|
+
? { backgroundColor: focusedBackgroundColor }
|
|
115
|
+
: undefined,
|
|
124
116
|
]}
|
|
125
117
|
>
|
|
126
118
|
<PinInputText
|
|
127
119
|
style={[
|
|
128
120
|
styles.cellText,
|
|
129
|
-
{
|
|
130
|
-
color: isFocused ? focusedTextColor : unFocusedTextColor,
|
|
131
|
-
},
|
|
121
|
+
{ color: theme.colors.strong },
|
|
132
122
|
textStyles,
|
|
123
|
+
isFocused && focusedTextColor
|
|
124
|
+
? { color: focusedTextColor }
|
|
125
|
+
: undefined,
|
|
133
126
|
]}
|
|
134
127
|
isFocused={isFocused}
|
|
135
128
|
>
|
|
@@ -156,6 +149,7 @@ const styles = StyleSheet.create({
|
|
|
156
149
|
aspectRatio: 1,
|
|
157
150
|
maxWidth: 70,
|
|
158
151
|
maxHeight: 70,
|
|
152
|
+
borderWidth: 1,
|
|
159
153
|
},
|
|
160
154
|
cellText: {
|
|
161
155
|
fontSize: 25,
|
|
@@ -4,7 +4,7 @@ import { FlatList } from "react-native";
|
|
|
4
4
|
import SectionHeader, { DefaultSectionHeader } from "./SectionHeader";
|
|
5
5
|
import { flattenReactFragments } from "../../utilities";
|
|
6
6
|
export const DEFAULT_SECTION = "Uncategorized";
|
|
7
|
-
const SectionList = ({ sectionKey, stickyHeader = false, listComponent = "FlatList", data: dataProp, renderItem: renderItemProp, ...rest }) => {
|
|
7
|
+
const SectionList = ({ sectionKey, stickyHeader = false, listComponent = "FlatList", data: dataProp, renderItem: renderItemProp, keyExtractor: keyExtractorProp, ...rest }) => {
|
|
8
8
|
const data = React.useMemo(() => (Array.isArray(dataProp) ? dataProp : []), [dataProp]);
|
|
9
9
|
const dataWithSections = React.useMemo(() => {
|
|
10
10
|
var _a;
|
|
@@ -90,11 +90,21 @@ const SectionList = ({ sectionKey, stickyHeader = false, listComponent = "FlatLi
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
+
const keyExtractor = (item, index) => {
|
|
94
|
+
switch (item.type) {
|
|
95
|
+
case "SECTION_ITEM": {
|
|
96
|
+
return `section_${index.toString()}`;
|
|
97
|
+
}
|
|
98
|
+
case "DATA_ITEM": {
|
|
99
|
+
return (keyExtractorProp === null || keyExtractorProp === void 0 ? void 0 : keyExtractorProp(item.data, index)) || index.toString();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
93
103
|
switch (listComponent) {
|
|
94
104
|
case "FlatList":
|
|
95
|
-
return (React.createElement(FlatList, { stickyHeaderIndices: sectionHeaderIndicies, ...rest, data: dataWithSections, renderItem: renderItem }));
|
|
105
|
+
return (React.createElement(FlatList, { stickyHeaderIndices: sectionHeaderIndicies, ...rest, data: dataWithSections, renderItem: renderItem, keyExtractor: keyExtractor }));
|
|
96
106
|
case "FlashList":
|
|
97
|
-
return (React.createElement(FlashList, { stickyHeaderIndices: sectionHeaderIndicies, ...rest, data: dataWithSections, renderItem: renderItem }));
|
|
107
|
+
return (React.createElement(FlashList, { stickyHeaderIndices: sectionHeaderIndicies, ...rest, data: dataWithSections, renderItem: renderItem, keyExtractor: keyExtractor }));
|
|
98
108
|
}
|
|
99
109
|
};
|
|
100
110
|
export default SectionList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionList.js","sourceRoot":"","sources":["SectionList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAkB,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,aAAa,EAAE,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,qBAAqB,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JSX.Element;
|
|
17
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
17
18
|
listComponent?: ListComponentType;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -43,6 +44,7 @@ const SectionList = <T extends { [key: string]: any }>({
|
|
|
43
44
|
listComponent = "FlatList",
|
|
44
45
|
data: dataProp,
|
|
45
46
|
renderItem: renderItemProp,
|
|
47
|
+
keyExtractor: keyExtractorProp,
|
|
46
48
|
...rest
|
|
47
49
|
}: FlatListSectionListProps<T> | FlashListSectionListProps<T>) => {
|
|
48
50
|
const data = React.useMemo(
|
|
@@ -165,6 +167,17 @@ const SectionList = <T extends { [key: string]: any }>({
|
|
|
165
167
|
}
|
|
166
168
|
};
|
|
167
169
|
|
|
170
|
+
const keyExtractor = (item: SectionListItem<T>, index: number) => {
|
|
171
|
+
switch (item.type) {
|
|
172
|
+
case "SECTION_ITEM": {
|
|
173
|
+
return `section_${index.toString()}`;
|
|
174
|
+
}
|
|
175
|
+
case "DATA_ITEM": {
|
|
176
|
+
return keyExtractorProp?.(item.data, index) || index.toString();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
168
181
|
switch (listComponent) {
|
|
169
182
|
case "FlatList":
|
|
170
183
|
return (
|
|
@@ -173,6 +186,7 @@ const SectionList = <T extends { [key: string]: any }>({
|
|
|
173
186
|
{...(rest as FlatListProps<SectionListItem<T>>)}
|
|
174
187
|
data={dataWithSections}
|
|
175
188
|
renderItem={renderItem}
|
|
189
|
+
keyExtractor={keyExtractor}
|
|
176
190
|
/>
|
|
177
191
|
);
|
|
178
192
|
case "FlashList":
|
|
@@ -182,6 +196,7 @@ const SectionList = <T extends { [key: string]: any }>({
|
|
|
182
196
|
{...(rest as FlashListProps<SectionListItem<T>>)}
|
|
183
197
|
data={dataWithSections}
|
|
184
198
|
renderItem={renderItem}
|
|
199
|
+
keyExtractor={keyExtractor}
|
|
185
200
|
/>
|
|
186
201
|
);
|
|
187
202
|
}
|