@draftbit/core 50.2.3-ad4d9d.2 → 50.2.3
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/BottomSheet/BottomSheet.js +1 -1
- package/lib/typescript/src/components/BottomSheet/BottomSheet.d.ts +0 -2
- package/lib/typescript/src/components/BottomSheet/BottomSheet.js +5 -3
- package/lib/typescript/src/components/BottomSheet/BottomSheet.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/BottomSheet/BottomSheet.js +5 -3
- package/src/components/BottomSheet/BottomSheet.js.map +1 -1
- package/src/components/BottomSheet/BottomSheet.tsx +6 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["
|
|
1
|
+
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["snapPoints","topSnapPosition","middleSnapPosition","bottomSnapPosition","initialSnapIndex","initialSnapPosition","showHandle","handleColor","topBorderRadius","borderWidth","borderColor","onSettle","style","children"];var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/BottomSheet/BottomSheet.tsx";import React from"react";import{StyleSheet,Dimensions}from"react-native";import BottomSheetComponent,{BottomSheetScrollView}from"@gorhom/bottom-sheet";import{useTheme}from"@draftbit/theme";import{useDeepCompareMemo}from"../../utilities";import{jsx as _jsx}from"react/jsx-runtime";var windowHeight=Dimensions.get("window").height;var BottomSheet=React.forwardRef(function(_ref,ref){var snapPointsProp=_ref.snapPoints,_ref$topSnapPosition=_ref.topSnapPosition,topSnapPosition=_ref$topSnapPosition===void 0?"10%":_ref$topSnapPosition,_ref$middleSnapPositi=_ref.middleSnapPosition,middleSnapPosition=_ref$middleSnapPositi===void 0?"50%":_ref$middleSnapPositi,_ref$bottomSnapPositi=_ref.bottomSnapPosition,bottomSnapPosition=_ref$bottomSnapPositi===void 0?"80%":_ref$bottomSnapPositi,initialSnapIndex=_ref.initialSnapIndex,_ref$initialSnapPosit=_ref.initialSnapPosition,initialSnapPosition=_ref$initialSnapPosit===void 0?"bottom":_ref$initialSnapPosit,_ref$showHandle=_ref.showHandle,showHandle=_ref$showHandle===void 0?true:_ref$showHandle,handleColor=_ref.handleColor,_ref$topBorderRadius=_ref.topBorderRadius,topBorderRadius=_ref$topBorderRadius===void 0?20:_ref$topBorderRadius,_ref$borderWidth=_ref.borderWidth,borderWidth=_ref$borderWidth===void 0?1:_ref$borderWidth,borderColor=_ref.borderColor,onSettle=_ref.onSettle,style=_ref.style,children=_ref.children,rest=_objectWithoutProperties(_ref,_excluded);var theme=useTheme();var backgroundColor=(style==null?void 0:style.backgroundColor)||theme.colors.background.brand;var snapPoints=snapPointsProp!=null?snapPointsProp:[topSnapPosition,middleSnapPosition,bottomSnapPosition];var mappedSnapPoints=useDeepCompareMemo(function(){return convertSnapPointsForNewImplementation(snapPoints);},snapPoints);var getSnapIndexFromPosition=function getSnapIndexFromPosition(position){switch(position){case"bottom":return 0;case"middle":return 1;case"top":return 2;}};return _jsx(BottomSheetComponent,{ref:ref,snapPoints:mappedSnapPoints,index:initialSnapIndex!==undefined?mappedSnapPoints.length-initialSnapIndex-1:getSnapIndexFromPosition(initialSnapPosition),handleIndicatorStyle:[{backgroundColor:handleColor!=null?handleColor:theme.colors.border.brand},!showHandle?{display:"none"}:{}],backgroundStyle:{backgroundColor:backgroundColor,borderTopLeftRadius:topBorderRadius,borderTopRightRadius:topBorderRadius,borderWidth:borderWidth,borderColor:borderColor!=null?borderColor:theme.colors.border.brand},onChange:function onChange(index){return onSettle==null?void 0:onSettle(mappedSnapPoints.length-index-1);},children:_jsx(BottomSheetScrollView,Object.assign({contentContainerStyle:[styles.contentContainerStyle,style]},rest,{children:children}))});});function convertSnapPointsForNewImplementation(snapPoints){var reversedSnapPoints=_toConsumableArray(snapPoints).reverse();return reversedSnapPoints.map(function(point){if(typeof point==="string"){var percentNumber=extractPercentNumber(point);if(percentNumber!==undefined){return`${100-percentNumber}%`;}return point;}else if(typeof point==="number"){return windowHeight-point;}else{return point;}});}function extractPercentNumber(percentString){var percentRegex=/(\d+)?%/;var matches=percentString.match(percentRegex);if(matches!=null&&matches.length){var percentNumber=Number(matches[1]);if(!isNaN(percentNumber)){return percentNumber;}}return undefined;}var styles=StyleSheet.create({contentContainerStyle:{paddingHorizontal:16,paddingVertical:10}});export default BottomSheet;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { StyleProp, ViewStyle, ScrollViewProps } from "react-native";
|
|
3
|
-
import type { ReadTheme } from "@draftbit/theme";
|
|
4
3
|
declare type SnapPosition = "top" | "middle" | "bottom";
|
|
5
4
|
export interface BottomSheetProps extends ScrollViewProps {
|
|
6
5
|
topSnapPosition?: string | number;
|
|
@@ -22,7 +21,6 @@ export interface BottomSheetProps extends ScrollViewProps {
|
|
|
22
21
|
borderColor?: string;
|
|
23
22
|
onSettle?: (index: number) => void;
|
|
24
23
|
style?: StyleProp<ViewStyle>;
|
|
25
|
-
theme: ReadTheme;
|
|
26
24
|
}
|
|
27
25
|
declare const BottomSheet: React.ForwardRefExoticComponent<BottomSheetProps & React.RefAttributes<import("@gorhom/bottom-sheet/lib/typescript/types").BottomSheetMethods>>;
|
|
28
26
|
export default BottomSheet;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { StyleSheet, Dimensions, } from "react-native";
|
|
3
3
|
import BottomSheetComponent, { BottomSheetScrollView, } from "@gorhom/bottom-sheet";
|
|
4
|
+
import { useTheme } from "@draftbit/theme";
|
|
4
5
|
import { useDeepCompareMemo } from "../../utilities";
|
|
5
6
|
const windowHeight = Dimensions.get("window").height;
|
|
6
7
|
// Clarification:
|
|
7
8
|
// Input of snap points is sorted top -> bottom where each value represents distance from top
|
|
8
9
|
// Implementation using `@gorhom/bottom-sheet` is sorted bottom -> top where each value represents distance from bottom
|
|
9
|
-
const BottomSheet = React.forwardRef(({
|
|
10
|
+
const BottomSheet = React.forwardRef(({ snapPoints: snapPointsProp, topSnapPosition = "10%", middleSnapPosition = "50%", bottomSnapPosition = "80%", initialSnapIndex, initialSnapPosition = "bottom", showHandle = true, handleColor, topBorderRadius = 20, borderWidth = 1, borderColor, onSettle, style, children, ...rest }, ref) => {
|
|
11
|
+
const theme = useTheme();
|
|
10
12
|
const backgroundColor = (style === null || style === void 0 ? void 0 : style.backgroundColor) || theme.colors.background.brand;
|
|
11
13
|
const snapPoints = snapPointsProp !== null && snapPointsProp !== void 0 ? snapPointsProp : [
|
|
12
14
|
topSnapPosition,
|
|
@@ -27,14 +29,14 @@ const BottomSheet = React.forwardRef(({ theme, snapPoints: snapPointsProp, topSn
|
|
|
27
29
|
return (React.createElement(BottomSheetComponent, { ref: ref, snapPoints: mappedSnapPoints, index: initialSnapIndex !== undefined
|
|
28
30
|
? mappedSnapPoints.length - initialSnapIndex - 1
|
|
29
31
|
: getSnapIndexFromPosition(initialSnapPosition), handleIndicatorStyle: [
|
|
30
|
-
{ backgroundColor: handleColor },
|
|
32
|
+
{ backgroundColor: handleColor !== null && handleColor !== void 0 ? handleColor : theme.colors.border.brand },
|
|
31
33
|
!showHandle ? { display: "none" } : {},
|
|
32
34
|
], backgroundStyle: {
|
|
33
35
|
backgroundColor,
|
|
34
36
|
borderTopLeftRadius: topBorderRadius,
|
|
35
37
|
borderTopRightRadius: topBorderRadius,
|
|
36
38
|
borderWidth,
|
|
37
|
-
borderColor,
|
|
39
|
+
borderColor: borderColor !== null && borderColor !== void 0 ? borderColor : theme.colors.border.brand,
|
|
38
40
|
}, onChange: (index) => onSettle === null || onSettle === void 0 ? void 0 : onSettle(mappedSnapPoints.length - index - 1) },
|
|
39
41
|
React.createElement(BottomSheetScrollView, { contentContainerStyle: [styles.contentContainerStyle, style], ...rest }, children)));
|
|
40
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheet.js","sourceRoot":"","sources":["../../../../../src/components/BottomSheet/BottomSheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,UAAU,EAIV,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,oBAAoB,EAAE,EAC3B,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"BottomSheet.js","sourceRoot":"","sources":["../../../../../src/components/BottomSheet/BottomSheet.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,UAAU,EAIV,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,oBAAoB,EAAE,EAC3B,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIrD,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;AAwBrD,iBAAiB;AACjB,6FAA6F;AAC7F,uHAAuH;AACvH,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAClC,CACE,EACE,UAAU,EAAE,cAAc,EAC1B,eAAe,GAAG,KAAK,EACvB,kBAAkB,GAAG,KAAK,EAC1B,kBAAkB,GAAG,KAAK,EAC1B,gBAAgB,EAChB,mBAAmB,GAAG,QAAQ,EAC9B,UAAU,GAAG,IAAI,EACjB,WAAW,EACX,eAAe,GAAG,EAAE,EACpB,WAAW,GAAG,CAAC,EACf,WAAW,EACX,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACR,EACD,GAAG,EACH,EAAE;IACF,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;I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