@draftbit/core 49.3.2-dd8f44.2 → 49.4.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.
Files changed (71) hide show
  1. package/lib/commonjs/components/PinInput/PinInput.js +1 -1
  2. package/lib/commonjs/components/SimpleStyleScrollables/SimpleStyleFlashList.js +1 -1
  3. package/lib/commonjs/components/SimpleStyleScrollables/SimpleStyleFlatList.js +1 -1
  4. package/lib/commonjs/components/SimpleStyleScrollables/SimpleStyleKeyboardAwareScrollView.js +1 -1
  5. package/lib/commonjs/components/SimpleStyleScrollables/SimpleStyleMasonryFlashList.js +1 -1
  6. package/lib/commonjs/components/SimpleStyleScrollables/SimpleStyleScrollView.js +1 -1
  7. package/lib/commonjs/components/SimpleStyleScrollables/SimpleStyleSectionList.js +1 -1
  8. package/lib/commonjs/components/SimpleStyleScrollables/SimpleStyleSwipeableList.js +1 -1
  9. package/lib/commonjs/components/SimpleStyleScrollables/useSplitContentContainerStyles.js +1 -0
  10. package/lib/commonjs/components/TextInput.js +1 -1
  11. package/lib/typescript/src/components/PinInput/PinInput.js +5 -2
  12. package/lib/typescript/src/components/PinInput/PinInput.js.map +1 -1
  13. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleFlashList.js +8 -3
  14. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleFlashList.js.map +1 -1
  15. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleFlatList.js +8 -3
  16. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleFlatList.js.map +1 -1
  17. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleKeyboardAwareScrollView.js +8 -3
  18. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleKeyboardAwareScrollView.js.map +1 -1
  19. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleMasonryFlashList.js +8 -3
  20. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleMasonryFlashList.js.map +1 -1
  21. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleScrollView.js +8 -3
  22. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleScrollView.js.map +1 -1
  23. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleSectionList.js +8 -3
  24. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleSectionList.js.map +1 -1
  25. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleSwipeableList.js +8 -3
  26. package/lib/typescript/src/components/SimpleStyleScrollables/SimpleStyleSwipeableList.js.map +1 -1
  27. package/lib/typescript/src/components/SimpleStyleScrollables/useSplitContentContainerStyles.d.ts +8 -0
  28. package/lib/typescript/src/components/SimpleStyleScrollables/useSplitContentContainerStyles.js +43 -0
  29. package/lib/typescript/src/components/SimpleStyleScrollables/useSplitContentContainerStyles.js.map +1 -0
  30. package/lib/typescript/src/components/TextInput.d.ts +1 -0
  31. package/lib/typescript/src/components/TextInput.js +7 -3
  32. package/lib/typescript/src/components/TextInput.js.map +1 -1
  33. package/lib/typescript/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +4 -4
  35. package/src/components/PinInput/PinInput.js +5 -2
  36. package/src/components/PinInput/PinInput.js.map +1 -1
  37. package/src/components/PinInput/PinInput.tsx +5 -0
  38. package/src/components/SimpleStyleScrollables/SimpleStyleFlashList.js +8 -3
  39. package/src/components/SimpleStyleScrollables/SimpleStyleFlashList.js.map +1 -1
  40. package/src/components/SimpleStyleScrollables/SimpleStyleFlashList.tsx +13 -3
  41. package/src/components/SimpleStyleScrollables/SimpleStyleFlatList.js +8 -3
  42. package/src/components/SimpleStyleScrollables/SimpleStyleFlatList.js.map +1 -1
  43. package/src/components/SimpleStyleScrollables/SimpleStyleFlatList.tsx +13 -3
  44. package/src/components/SimpleStyleScrollables/SimpleStyleKeyboardAwareScrollView.js +8 -3
  45. package/src/components/SimpleStyleScrollables/SimpleStyleKeyboardAwareScrollView.js.map +1 -1
  46. package/src/components/SimpleStyleScrollables/SimpleStyleKeyboardAwareScrollView.tsx +13 -3
  47. package/src/components/SimpleStyleScrollables/SimpleStyleMasonryFlashList.js +8 -3
  48. package/src/components/SimpleStyleScrollables/SimpleStyleMasonryFlashList.js.map +1 -1
  49. package/src/components/SimpleStyleScrollables/SimpleStyleMasonryFlashList.tsx +13 -3
  50. package/src/components/SimpleStyleScrollables/SimpleStyleScrollView.js +8 -3
  51. package/src/components/SimpleStyleScrollables/SimpleStyleScrollView.js.map +1 -1
  52. package/src/components/SimpleStyleScrollables/SimpleStyleScrollView.tsx +13 -3
  53. package/src/components/SimpleStyleScrollables/SimpleStyleSectionList.js +8 -3
  54. package/src/components/SimpleStyleScrollables/SimpleStyleSectionList.js.map +1 -1
  55. package/src/components/SimpleStyleScrollables/SimpleStyleSectionList.tsx +13 -3
  56. package/src/components/SimpleStyleScrollables/SimpleStyleSwipeableList.js +8 -3
  57. package/src/components/SimpleStyleScrollables/SimpleStyleSwipeableList.js.map +1 -1
  58. package/src/components/SimpleStyleScrollables/SimpleStyleSwipeableList.tsx +13 -3
  59. package/src/components/SimpleStyleScrollables/useSplitContentContainerStyles.js +43 -0
  60. package/src/components/SimpleStyleScrollables/useSplitContentContainerStyles.js.map +1 -0
  61. package/src/components/SimpleStyleScrollables/useSplitContentContainerStyles.ts +60 -0
  62. package/src/components/TextInput.js +7 -3
  63. package/src/components/TextInput.js.map +1 -1
  64. package/src/components/TextInput.tsx +18 -1
  65. package/lib/commonjs/components/SimpleStyleScrollables/splitContentContainerStyles.js +0 -1
  66. package/lib/typescript/src/components/SimpleStyleScrollables/splitContentContainerStyles.d.ts +0 -6
  67. package/lib/typescript/src/components/SimpleStyleScrollables/splitContentContainerStyles.js +0 -34
  68. package/lib/typescript/src/components/SimpleStyleScrollables/splitContentContainerStyles.js.map +0 -1
  69. package/src/components/SimpleStyleScrollables/splitContentContainerStyles.js +0 -34
  70. package/src/components/SimpleStyleScrollables/splitContentContainerStyles.js.map +0 -1
  71. package/src/components/SimpleStyleScrollables/splitContentContainerStyles.ts +0 -40
@@ -0,0 +1,60 @@
1
+ import { StyleProp, ViewStyle, StyleSheet } from "react-native";
2
+ import { pick, omit } from "lodash";
3
+ import { useDeepCompareMemo } from "../../utilities";
4
+
5
+ interface Styles {
6
+ style?: StyleProp<ViewStyle>;
7
+ contentContainerStyle?: StyleProp<ViewStyle>;
8
+ }
9
+
10
+ export const contentContainerStyleNames = [
11
+ "padding",
12
+ "paddingBottom",
13
+ "paddingEnd",
14
+ "paddingHorizontal",
15
+ "paddingLeft",
16
+ "paddingRight",
17
+ "paddingStart",
18
+ "paddingTop",
19
+ "paddingVertical",
20
+ "justifyContent",
21
+ "alignItems",
22
+ "alignContent",
23
+ "flexDirection",
24
+ "flexWrap",
25
+ ];
26
+
27
+ export default function useSplitContentContainerStyles(
28
+ originalStyle: StyleProp<ViewStyle>,
29
+ measuredWidth?: number,
30
+ measuredHeight?: number
31
+ ) {
32
+ return useDeepCompareMemo<Styles>(() => {
33
+ const flattenedStyle = StyleSheet.flatten(originalStyle);
34
+
35
+ let contentContainerStyle = pick(
36
+ flattenedStyle,
37
+ contentContainerStyleNames
38
+ );
39
+
40
+ // contentContainerStyle should always at least fill the parent to ensure sizing changes reflects properly on component and children
41
+ if (measuredWidth) {
42
+ contentContainerStyle.minWidth = measuredWidth;
43
+ }
44
+ if (measuredHeight) {
45
+ contentContainerStyle.minHeight = measuredHeight;
46
+ }
47
+
48
+ let style = omit(flattenedStyle, contentContainerStyleNames);
49
+
50
+ // ScrollView's implementation defaults flexGrow to 1, which prevents the ability to set a static size or use a flex larger than 1
51
+ // See: https://github.com/facebook/react-native/issues/3422
52
+ if (style.flex === undefined) {
53
+ style = { flexGrow: 0, ...style };
54
+ } else if (style.flexGrow === undefined) {
55
+ style = { flexGrow: style.flex, ...style };
56
+ }
57
+
58
+ return { style, contentContainerStyle };
59
+ }, [originalStyle, measuredWidth, measuredHeight]);
60
+ }
@@ -1,14 +1,18 @@
1
1
  import React from "react";
2
- import { TextInput as NativeTextInput, } from "react-native";
2
+ import { TextInput as NativeTextInput, Platform, } from "react-native";
3
3
  import { useDebounce, useOnUpdate } from "../hooks";
4
- const TextInput = React.forwardRef(({ onChangeTextDelayed, changeTextDelay = 500, value, ...rest }, ref) => {
4
+ const TextInput = React.forwardRef(({ onChangeTextDelayed, changeTextDelay = 500, webShowOutline = true, style, value, ...rest }, ref) => {
5
5
  const delayedValue = useDebounce(value, changeTextDelay);
6
6
  useOnUpdate(() => {
7
7
  if (delayedValue !== undefined) {
8
8
  onChangeTextDelayed === null || onChangeTextDelayed === void 0 ? void 0 : onChangeTextDelayed(delayedValue);
9
9
  }
10
10
  }, [delayedValue]);
11
- return (React.createElement(NativeTextInput, { testID: "native-text-input", ref: ref, value: value, ...rest }));
11
+ return (React.createElement(NativeTextInput, { testID: "native-text-input", ref: ref, value: value, style: [
12
+ //@ts-ignore Web specific prop. Removes default blue outline that appears on the hidden TextInput
13
+ Platform.OS === "web" && !webShowOutline ? { outlineWidth: 0 } : {},
14
+ style,
15
+ ], ...rest }));
12
16
  });
13
17
  export default TextInput;
14
18
  //# sourceMappingURL=TextInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextInput.js","sourceRoot":"","sources":["TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,SAAS,IAAI,eAAe,GAE7B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAOpD,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAChC,CAAC,EAAE,mBAAmB,EAAE,eAAe,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE;IACtE,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAEzD,WAAW,CAAC,GAAG,EAAE;QACf,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,YAAY,CAAC,CAAC;SACrC;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,oBAAC,eAAe,IACd,MAAM,EAAC,mBAAmB,EAC1B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,KACR,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"TextInput.js","sourceRoot":"","sources":["TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,SAAS,IAAI,eAAe,EAE5B,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAQpD,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAChC,CACE,EACE,mBAAmB,EACnB,eAAe,GAAG,GAAG,EACrB,cAAc,GAAG,IAAI,EACrB,KAAK,EACL,KAAK,EACL,GAAG,IAAI,EACR,EACD,GAAG,EACH,EAAE;IACF,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAEzD,WAAW,CAAC,GAAG,EAAE;QACf,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,YAAY,CAAC,CAAC;SACrC;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,oBAAC,eAAe,IACd,MAAM,EAAC,mBAAmB,EAC1B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE;YACL,iGAAiG;YACjG,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;YACnE,KAAK;SACN,KACG,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -2,16 +2,28 @@ import React from "react";
2
2
  import {
3
3
  TextInput as NativeTextInput,
4
4
  TextInputProps as NativeTextInputProps,
5
+ Platform,
5
6
  } from "react-native";
6
7
  import { useDebounce, useOnUpdate } from "../hooks";
7
8
 
8
9
  export interface TextInputProps extends NativeTextInputProps {
10
+ webShowOutline?: boolean;
9
11
  onChangeTextDelayed?: (text: string) => void;
10
12
  changeTextDelay?: number;
11
13
  }
12
14
 
13
15
  const TextInput = React.forwardRef<NativeTextInput, TextInputProps>(
14
- ({ onChangeTextDelayed, changeTextDelay = 500, value, ...rest }, ref) => {
16
+ (
17
+ {
18
+ onChangeTextDelayed,
19
+ changeTextDelay = 500,
20
+ webShowOutline = true,
21
+ style,
22
+ value,
23
+ ...rest
24
+ },
25
+ ref
26
+ ) => {
15
27
  const delayedValue = useDebounce(value, changeTextDelay);
16
28
 
17
29
  useOnUpdate(() => {
@@ -25,6 +37,11 @@ const TextInput = React.forwardRef<NativeTextInput, TextInputProps>(
25
37
  testID="native-text-input"
26
38
  ref={ref}
27
39
  value={value}
40
+ style={[
41
+ //@ts-ignore Web specific prop. Removes default blue outline that appears on the hidden TextInput
42
+ Platform.OS === "web" && !webShowOutline ? { outlineWidth: 0 } : {},
43
+ style,
44
+ ]}
28
45
  {...rest}
29
46
  />
30
47
  );
@@ -1 +0,0 @@
1
- import{StyleSheet}from"react-native";import{pick,omit}from"lodash";export var contentContainerStyleNames=["padding","paddingBottom","paddingEnd","paddingHorizontal","paddingLeft","paddingRight","paddingStart","paddingTop","paddingVertical","justifyContent","alignItems","alignContent","flexDirection","flexWrap"];export default function splitContentContainerStyles(originalStyle){var flattenedStyle=StyleSheet.flatten(originalStyle);var contentContainerStyle=pick(flattenedStyle,contentContainerStyleNames);contentContainerStyle=Object.assign({minHeight:"100%",minWidth:"100%"},contentContainerStyle);var style=omit(flattenedStyle,contentContainerStyleNames);style=Object.assign({flexGrow:0},style);return{style:style,contentContainerStyle:contentContainerStyle};}
@@ -1,6 +0,0 @@
1
- import { StyleProp, ViewStyle } from "react-native";
2
- export declare const contentContainerStyleNames: string[];
3
- export default function splitContentContainerStyles(originalStyle: StyleProp<ViewStyle>): {
4
- style: Partial<ViewStyle>;
5
- contentContainerStyle: Partial<ViewStyle>;
6
- };
@@ -1,34 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { pick, omit } from "lodash";
3
- export const contentContainerStyleNames = [
4
- "padding",
5
- "paddingBottom",
6
- "paddingEnd",
7
- "paddingHorizontal",
8
- "paddingLeft",
9
- "paddingRight",
10
- "paddingStart",
11
- "paddingTop",
12
- "paddingVertical",
13
- "justifyContent",
14
- "alignItems",
15
- "alignContent",
16
- "flexDirection",
17
- "flexWrap",
18
- ];
19
- export default function splitContentContainerStyles(originalStyle) {
20
- const flattenedStyle = StyleSheet.flatten(originalStyle);
21
- let contentContainerStyle = pick(flattenedStyle, contentContainerStyleNames);
22
- // contentContainerStyle should always at least fill the parent to ensure sizing changes reflects properly on component and children
23
- contentContainerStyle = {
24
- minHeight: "100%",
25
- minWidth: "100%",
26
- ...contentContainerStyle,
27
- };
28
- let style = omit(flattenedStyle, contentContainerStyleNames);
29
- // ScrollView's implementation defaults flexGrow to 1, which prevents the ability to set a static size
30
- // See: https://github.com/facebook/react-native/issues/3422
31
- style = { flexGrow: 0, ...style };
32
- return { style, contentContainerStyle };
33
- }
34
- //# sourceMappingURL=splitContentContainerStyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"splitContentContainerStyles.js","sourceRoot":"","sources":["../../../../../src/components/SimpleStyleScrollables/splitContentContainerStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,SAAS;IACT,eAAe;IACf,YAAY;IACZ,mBAAmB;IACnB,aAAa;IACb,cAAc;IACd,cAAc;IACd,YAAY;IACZ,iBAAiB;IACjB,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,eAAe;IACf,UAAU;CACX,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,2BAA2B,CACjD,aAAmC;IAEnC,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEzD,IAAI,qBAAqB,GAAG,IAAI,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;IAC7E,oIAAoI;IACpI,qBAAqB,GAAG;QACtB,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE,MAAM;QAChB,GAAG,qBAAqB;KACzB,CAAC;IAEF,IAAI,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;IAC7D,sGAAsG;IACtG,4DAA4D;IAC5D,KAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAElC,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;AAC1C,CAAC"}
@@ -1,34 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { pick, omit } from "lodash";
3
- export const contentContainerStyleNames = [
4
- "padding",
5
- "paddingBottom",
6
- "paddingEnd",
7
- "paddingHorizontal",
8
- "paddingLeft",
9
- "paddingRight",
10
- "paddingStart",
11
- "paddingTop",
12
- "paddingVertical",
13
- "justifyContent",
14
- "alignItems",
15
- "alignContent",
16
- "flexDirection",
17
- "flexWrap",
18
- ];
19
- export default function splitContentContainerStyles(originalStyle) {
20
- const flattenedStyle = StyleSheet.flatten(originalStyle);
21
- let contentContainerStyle = pick(flattenedStyle, contentContainerStyleNames);
22
- // contentContainerStyle should always at least fill the parent to ensure sizing changes reflects properly on component and children
23
- contentContainerStyle = {
24
- minHeight: "100%",
25
- minWidth: "100%",
26
- ...contentContainerStyle,
27
- };
28
- let style = omit(flattenedStyle, contentContainerStyleNames);
29
- // ScrollView's implementation defaults flexGrow to 1, which prevents the ability to set a static size
30
- // See: https://github.com/facebook/react-native/issues/3422
31
- style = { flexGrow: 0, ...style };
32
- return { style, contentContainerStyle };
33
- }
34
- //# sourceMappingURL=splitContentContainerStyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"splitContentContainerStyles.js","sourceRoot":"","sources":["splitContentContainerStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,SAAS;IACT,eAAe;IACf,YAAY;IACZ,mBAAmB;IACnB,aAAa;IACb,cAAc;IACd,cAAc;IACd,YAAY;IACZ,iBAAiB;IACjB,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,eAAe;IACf,UAAU;CACX,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,2BAA2B,CACjD,aAAmC;IAEnC,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEzD,IAAI,qBAAqB,GAAG,IAAI,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;IAC7E,oIAAoI;IACpI,qBAAqB,GAAG;QACtB,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE,MAAM;QAChB,GAAG,qBAAqB;KACzB,CAAC;IAEF,IAAI,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;IAC7D,sGAAsG;IACtG,4DAA4D;IAC5D,KAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAElC,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;AAC1C,CAAC"}
@@ -1,40 +0,0 @@
1
- import { StyleProp, ViewStyle, StyleSheet } from "react-native";
2
- import { pick, omit } from "lodash";
3
-
4
- export const contentContainerStyleNames = [
5
- "padding",
6
- "paddingBottom",
7
- "paddingEnd",
8
- "paddingHorizontal",
9
- "paddingLeft",
10
- "paddingRight",
11
- "paddingStart",
12
- "paddingTop",
13
- "paddingVertical",
14
- "justifyContent",
15
- "alignItems",
16
- "alignContent",
17
- "flexDirection",
18
- "flexWrap",
19
- ];
20
-
21
- export default function splitContentContainerStyles(
22
- originalStyle: StyleProp<ViewStyle>
23
- ) {
24
- const flattenedStyle = StyleSheet.flatten(originalStyle);
25
-
26
- let contentContainerStyle = pick(flattenedStyle, contentContainerStyleNames);
27
- // contentContainerStyle should always at least fill the parent to ensure sizing changes reflects properly on component and children
28
- contentContainerStyle = {
29
- minHeight: "100%",
30
- minWidth: "100%",
31
- ...contentContainerStyle,
32
- };
33
-
34
- let style = omit(flattenedStyle, contentContainerStyleNames);
35
- // ScrollView's implementation defaults flexGrow to 1, which prevents the ability to set a static size
36
- // See: https://github.com/facebook/react-native/issues/3422
37
- style = { flexGrow: 0, ...style };
38
-
39
- return { style, contentContainerStyle };
40
- }