@draftbit/core 48.4.7 → 48.4.8-41fa1b.2
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/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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _TextInput=_interopRequireDefault(require("../TextInput"));var _reactNativeConfirmationCodeField=require("react-native-confirmation-code-field");var _theming=require("../../theming");var _PinInputText=_interopRequireDefault(require("./PinInputText"));var _utilities=require("../../utilities");var _jsxRuntime=require("react/jsx-runtime");var _excluded=["theme","onInputFull","cellCount","clearOnCellFocus","blurOnFull","renderItem","value","onChangeText","focusedBorderColor","
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _TextInput=_interopRequireDefault(require("../TextInput"));var _reactNativeConfirmationCodeField=require("react-native-confirmation-code-field");var _theming=require("../../theming");var _PinInputText=_interopRequireDefault(require("./PinInputText"));var _utilities=require("../../utilities");var _jsxRuntime=require("react/jsx-runtime");var _excluded=["theme","onInputFull","cellCount","clearOnCellFocus","blurOnFull","renderItem","value","onChangeText","focusedBorderColor","focusedBackgroundColor","focusedBorderWidth","focusedTextColor","style"];var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/PinInput/PinInput.tsx";var PinInput=_react.default.forwardRef(function(_ref,ref){var theme=_ref.theme,onInputFull=_ref.onInputFull,_ref$cellCount=_ref.cellCount,cellCount=_ref$cellCount===void 0?4:_ref$cellCount,_ref$clearOnCellFocus=_ref.clearOnCellFocus,clearOnCellFocus=_ref$clearOnCellFocus===void 0?true:_ref$clearOnCellFocus,_ref$blurOnFull=_ref.blurOnFull,blurOnFull=_ref$blurOnFull===void 0?true:_ref$blurOnFull,renderItem=_ref.renderItem,value=_ref.value,onChangeText=_ref.onChangeText,focusedBorderColor=_ref.focusedBorderColor,focusedBackgroundColor=_ref.focusedBackgroundColor,focusedBorderWidth=_ref.focusedBorderWidth,focusedTextColor=_ref.focusedTextColor,style=_ref.style,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var newPinInputRef=_react.default.useRef(null);var pinInputRef=ref?ref:newPinInputRef;var _extractStyles=(0,_utilities.extractStyles)(style),viewStyles=_extractStyles.viewStyles,textStyles=_extractStyles.textStyles;var _useClearByFocusCell=(0,_reactNativeConfirmationCodeField.useClearByFocusCell)({value:value,setValue:function setValue(text){return onChangeText==null?void 0:onChangeText(text);}}),_useClearByFocusCell2=(0,_slicedToArray2.default)(_useClearByFocusCell,2),codeFieldProps=_useClearByFocusCell2[0],getCellOnLayout=_useClearByFocusCell2[1];_react.default.useEffect(function(){if((value==null?void 0:value.length)===cellCount){if(blurOnFull){var _pinInputRef$current;(_pinInputRef$current=pinInputRef.current)==null?void 0:_pinInputRef$current.blur();}onInputFull==null?void 0:onInputFull(value);}},[value,cellCount,blurOnFull,pinInputRef]);return(0,_jsxRuntime.jsx)(_reactNativeConfirmationCodeField.CodeField,Object.assign({ref:pinInputRef},clearOnCellFocus?codeFieldProps:{},{value:value,onChangeText:onChangeText,textInputStyle:{height:"100%"},InputComponent:_TextInput.default,cellCount:cellCount,renderCell:function renderCell(_ref2){var cellValue=_ref2.symbol,index=_ref2.index,isFocused=_ref2.isFocused;return(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:clearOnCellFocus?getCellOnLayout(index):undefined,style:{flex:1},children:(renderItem==null?void 0:renderItem({cellValue:cellValue,index:index,isFocused:isFocused}))||(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"default-code-input-cell",style:[styles.cell,{borderColor:theme.colors.disabled},viewStyles,isFocused&&focusedBorderWidth?{borderWidth:focusedBorderWidth}:undefined,isFocused&&focusedBorderColor?{borderColor:focusedBorderColor}:undefined,isFocused&&focusedBackgroundColor?{backgroundColor:focusedBackgroundColor}:undefined],children:(0,_jsxRuntime.jsx)(_PinInputText.default,{style:[styles.cellText,{color:theme.colors.strong},textStyles,isFocused&&focusedTextColor?{color:focusedTextColor}:undefined],isFocused:isFocused,children:cellValue})})},index);}},rest));});var styles=_reactNative.StyleSheet.create({cell:{marginStart:5,marginEnd:5,padding:5,borderRadius:5,justifyContent:"center",alignItems:"center",aspectRatio:1,maxWidth:70,maxHeight:70,borderWidth:1},cellText:{fontSize:25}});var _default=(0,_theming.withTheme)(PinInput);exports.default=_default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleProp, ViewStyle, TextInput as NativeTextInput } from "react-native";
|
|
2
|
+
import { StyleProp, ViewStyle, TextStyle, TextInput as NativeTextInput } from "react-native";
|
|
3
3
|
import { TextInputProps } from "../TextInput";
|
|
4
4
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
5
5
|
interface CellItem {
|
|
@@ -14,14 +14,10 @@ interface PinInputProps extends TextInputProps {
|
|
|
14
14
|
blurOnFull?: boolean;
|
|
15
15
|
renderItem?: ({ cellValue, index, isFocused }: CellItem) => JSX.Element;
|
|
16
16
|
focusedBorderColor?: string;
|
|
17
|
-
unFocusedBorderColor?: string;
|
|
18
17
|
focusedBackgroundColor?: string;
|
|
19
|
-
unFocusedBackgroundColor?: string;
|
|
20
18
|
focusedBorderWidth?: number;
|
|
21
|
-
unFocusedBorderWidth?: number;
|
|
22
19
|
focusedTextColor?: string;
|
|
23
|
-
|
|
24
|
-
style?: StyleProp<ViewStyle>;
|
|
20
|
+
style?: StyleProp<ViewStyle | TextStyle>;
|
|
25
21
|
theme: Theme;
|
|
26
22
|
}
|
|
27
23
|
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<PinInputProps & React.RefAttributes<NativeTextInput>, "theme"> & {
|
|
@@ -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":["../../../../../src/components/PinInput/PinInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"PinInput.js","sourceRoot":"","sources":["../../../../../src/components/PinInput/PinInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAKL,IAAI,EACJ,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,SAA6B,MAAM,cAAc,CAAC;AACzD,OAAO,EACL,SAAS,EACT,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAsBhD,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAC/B,CACE,EACE,KAAK,EACL,WAAW,EACX,SAAS,GAAG,CAAC,EACb,gBAAgB,GAAG,IAAI,EACvB,UAAU,GAAG,IAAI,EACjB,UAAU,EACV,KAAK,EACL,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACL,GAAG,IAAI,EACR,EACD,GAAG,EACH,EAAE;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAkB,IAAI,CAAC,CAAC;IAE3D,+DAA+D;IAC/D,MAAM,WAAW,GAAG,GAAG;QACrB,CAAC,CAAE,GAAwC;QAC3C,CAAC,CAAC,cAAc,CAAC;IAEnB,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC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