@fountain-ui/lab 2.0.0-beta.87 → 3.0.0-alpha.1

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 (34) hide show
  1. package/build/commonjs/BottomSheet/BottomSheetNative.js +30 -91
  2. package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
  3. package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
  4. package/build/commonjs/BottomSheet/BottomSheetWeb.js +31 -82
  5. package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
  6. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js +23 -9
  7. package/build/commonjs/BottomSheet/useDynamicSnapPoints.js.map +1 -1
  8. package/build/commonjs/DateTimePicker/DateTimePicker.js +2 -2
  9. package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
  10. package/build/commonjs/DateTimePicker/YearPicker.js +2 -2
  11. package/build/commonjs/DateTimePicker/YearPicker.js.map +1 -1
  12. package/build/module/BottomSheet/BottomSheetNative.js +30 -84
  13. package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
  14. package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
  15. package/build/module/BottomSheet/BottomSheetWeb.js +34 -85
  16. package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
  17. package/build/module/BottomSheet/useDynamicSnapPoints.js +22 -9
  18. package/build/module/BottomSheet/useDynamicSnapPoints.js.map +1 -1
  19. package/build/module/DateTimePicker/DateTimePicker.js +2 -2
  20. package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
  21. package/build/module/DateTimePicker/YearPicker.js +2 -2
  22. package/build/module/DateTimePicker/YearPicker.js.map +1 -1
  23. package/build/typescript/BottomSheet/BottomSheetProps.d.ts +1 -14
  24. package/build/typescript/BottomSheet/useDynamicSnapPoints.d.ts +3 -2
  25. package/build/typescript/Carousel/Carousel.d.ts +1 -1
  26. package/build/typescript/ViewPager/ViewPager.d.ts +1 -1
  27. package/build/typescript/ViewPager/ViewPager.native.d.ts +1 -1
  28. package/package.json +5 -5
  29. package/src/BottomSheet/BottomSheetNative.tsx +26 -95
  30. package/src/BottomSheet/BottomSheetProps.ts +1 -17
  31. package/src/BottomSheet/BottomSheetWeb.tsx +34 -110
  32. package/src/BottomSheet/useDynamicSnapPoints.ts +24 -10
  33. package/src/DateTimePicker/DateTimePicker.tsx +2 -2
  34. package/src/DateTimePicker/YearPicker.tsx +2 -2
@@ -1 +1 @@
1
- {"version":3,"names":["useDateTimePicker","React","useContext","DateTimePickerContext","DateTimePicker","props","currentMonth","Date","locale","markedDate","markedDateProp","maxDate","minDate","onDayPress","onYearPress","onYearPressProp","theme","useTheme","textDayFontStyle","createFontStyle","selector","typo","body2","yearPickerVisible","setYearPickerVisible","useState","locales","LeftArrow","RightArrow","date","LocaleConfig","defaultLocale","format","direction","selected","disableTouchEvent","selectedColor","palette","primary","main","selectedTextColor","contrastTextColor","formatDate","toDate","backgroundColor","paper","default","calendarBackground","dayTextColor","text","textDisabledColor","hint","textDayFontFamily","fontFamily","textDayFontSize","fontSize","textDayFontWeight","fontWeight","textDayHeaderFontFamily","textDayHeaderFontSize","textDayHeaderFontWeight"],"sources":["DateTimePicker.tsx"],"sourcesContent":["import React from 'react';\nimport { format } from 'date-fns';\n//@ts-ignore\nimport { Calendar, LocaleConfig } from 'react-native-calendars';\nimport { Button, createFontStyle, Typography } from '@fountain-ui/core';\nimport { useTheme } from '@fountain-ui/styles';\nimport YearPicker from './YearPicker';\nimport { DateTimePickerContext } from './DateTimePickerProvider';\nimport type DateTimePickerProps from './DateTimePickerProps';\nimport { formatDate } from './utils';\n\nconst useDateTimePicker = () => {\n return React.useContext(DateTimePickerContext);\n};\n\nexport default function DateTimePicker(props: DateTimePickerProps) {\n const {\n currentMonth = new Date(),\n locale,\n markedDate: markedDateProp,\n maxDate,\n minDate,\n onDayPress,\n onYearPress: onYearPressProp,\n } = props;\n\n const theme = useTheme();\n\n const textDayFontStyle = createFontStyle(theme, { selector: (typo) => typo.body2 });\n\n const [yearPickerVisible, setYearPickerVisible] = React.useState(false);\n const { locales } = useDateTimePicker();\n\n //TODO: Need to update arrow components\n const LeftArrow = <Typography children={'<'} color={'textPrimary'}/>;\n const RightArrow = <Typography children={'>'} color={'textPrimary'}/>;\n\n const onYearPress = (date: Date) => {\n setYearPickerVisible(false);\n onYearPressProp && onYearPressProp(date);\n };\n\n if (locale) {\n LocaleConfig.locales = locales;\n LocaleConfig.defaultLocale = locale;\n }\n\n const markedDate = markedDateProp ? format(markedDateProp, 'yyyy-MM-dd') : '';\n\n if (yearPickerVisible) {\n return (\n <YearPicker\n date={currentMonth}\n locale={locale}\n maxDate={maxDate}\n minDate={minDate}\n onYearPress={onYearPress}\n />\n );\n }\n\n return (\n <Calendar\n current={currentMonth}\n onDayPress={onDayPress}\n maxDate={maxDate}\n minDate={minDate}\n renderArrow={(direction: string) => direction === 'left' ? LeftArrow : RightArrow}\n markedDates={{\n [markedDate]: {\n selected: true,\n disableTouchEvent: true,\n selectedColor: theme.palette.primary.main,\n selectedTextColor: theme.palette.primary.contrastTextColor,\n },\n }}\n // @ts-ignore\n renderHeader={(date) => (\n <Button\n children={formatDate(date.toDate(), locale)}\n variant={'text'}\n size={'small'}\n onPress={() => setYearPickerVisible(true)}\n />\n )}\n theme={{\n backgroundColor: theme.palette.paper.default,\n calendarBackground: theme.palette.paper.default,\n dayTextColor: theme.palette.text.primary,\n textDisabledColor: theme.palette.text.hint,\n textDayFontFamily: textDayFontStyle.fontFamily,\n textDayFontSize: textDayFontStyle.fontSize,\n textDayFontWeight: textDayFontStyle.fontWeight,\n textDayHeaderFontFamily: textDayFontStyle.fontFamily,\n textDayHeaderFontSize: textDayFontStyle.fontSize,\n textDayHeaderFontWeight: textDayFontStyle.fontWeight,\n }}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;AAPA;AASA,MAAMA,iBAAiB,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qC,QAN/B;MAOHC,iBAAiB,EAAEtC,gBAAgB,CAACuC,UAPjC;MAQHC,uBAAuB,EAAExC,gBAAgB,CAACmC,UARvC;MASHM,qBAAqB,EAAEzC,gBAAgB,CAACqC,QATrC;MAUHK,uBAAuB,EAAE1C,gBAAgB,CAACuC;IAVvC;EAvBX,EADJ;AAsCH;;AAAA"}
1
+ {"version":3,"names":["useDateTimePicker","React","useContext","DateTimePickerContext","DateTimePicker","props","currentMonth","Date","locale","markedDate","markedDateProp","maxDate","minDate","onDayPress","onYearPress","onYearPressProp","theme","useTheme","textDayFontStyle","createFontStyle","selector","typo","body2","yearPickerVisible","setYearPickerVisible","useState","locales","LeftArrow","RightArrow","date","LocaleConfig","defaultLocale","format","direction","selected","disableTouchEvent","selectedColor","palette","primary","main","selectedTextColor","contrastTextColor","formatDate","toDate","backgroundColor","paper","default","calendarBackground","dayTextColor","text","textDisabledColor","hint","textDayFontFamily","fontFamily","textDayFontSize","fontSize","textDayFontWeight","fontWeight","textDayHeaderFontFamily","textDayHeaderFontSize","textDayHeaderFontWeight"],"sources":["DateTimePicker.tsx"],"sourcesContent":["import React from 'react';\nimport { format } from 'date-fns';\n//@ts-ignore\nimport { Calendar, LocaleConfig } from 'react-native-calendars';\nimport { Button, createFontStyle, Typography } from '@fountain-ui/core';\nimport { useTheme } from '@fountain-ui/styles';\nimport YearPicker from './YearPicker';\nimport { DateTimePickerContext } from './DateTimePickerProvider';\nimport type DateTimePickerProps from './DateTimePickerProps';\nimport { formatDate } from './utils';\n\nconst useDateTimePicker = () => {\n return React.useContext(DateTimePickerContext);\n};\n\nexport default function DateTimePicker(props: DateTimePickerProps) {\n const {\n currentMonth = new Date(),\n locale,\n markedDate: markedDateProp,\n maxDate,\n minDate,\n onDayPress,\n onYearPress: onYearPressProp,\n } = props;\n\n const theme = useTheme();\n\n const textDayFontStyle = createFontStyle(theme, { selector: (typo) => typo.body2 });\n\n const [yearPickerVisible, setYearPickerVisible] = React.useState(false);\n const { locales } = useDateTimePicker();\n\n //TODO: Need to update arrow components\n const LeftArrow = <Typography children={'<'} color={'strong'}/>;\n const RightArrow = <Typography children={'>'} color={'strong'}/>;\n\n const onYearPress = (date: Date) => {\n setYearPickerVisible(false);\n onYearPressProp && onYearPressProp(date);\n };\n\n if (locale) {\n LocaleConfig.locales = locales;\n LocaleConfig.defaultLocale = locale;\n }\n\n const markedDate = markedDateProp ? format(markedDateProp, 'yyyy-MM-dd') : '';\n\n if (yearPickerVisible) {\n return (\n <YearPicker\n date={currentMonth}\n locale={locale}\n maxDate={maxDate}\n minDate={minDate}\n onYearPress={onYearPress}\n />\n );\n }\n\n return (\n <Calendar\n current={currentMonth}\n onDayPress={onDayPress}\n maxDate={maxDate}\n minDate={minDate}\n renderArrow={(direction: string) => direction === 'left' ? LeftArrow : RightArrow}\n markedDates={{\n [markedDate]: {\n selected: true,\n disableTouchEvent: true,\n selectedColor: theme.palette.primary.main,\n selectedTextColor: theme.palette.primary.contrastTextColor,\n },\n }}\n // @ts-ignore\n renderHeader={(date) => (\n <Button\n children={formatDate(date.toDate(), locale)}\n variant={'text'}\n size={'small'}\n onPress={() => setYearPickerVisible(true)}\n />\n )}\n theme={{\n backgroundColor: theme.palette.paper.default,\n calendarBackground: theme.palette.paper.default,\n dayTextColor: theme.palette.text.primary,\n textDisabledColor: theme.palette.text.hint,\n textDayFontFamily: textDayFontStyle.fontFamily,\n textDayFontSize: textDayFontStyle.fontSize,\n textDayFontWeight: textDayFontStyle.fontWeight,\n textDayHeaderFontFamily: textDayFontStyle.fontFamily,\n textDayHeaderFontSize: textDayFontStyle.fontSize,\n textDayHeaderFontWeight: textDayFontStyle.fontWeight,\n }}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;AAPA;AASA,MAAMA,iBAAiB,GAAG,MAAM;EAC5B,OAAOC,cAAA,CAAMC,UAAN,CAAiBC,6CAAjB,CAAP;AACH,CAFD;;AAIe,SA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CAACmC,UARvC;MASHM,qBAAqB,EAAEzC,gBAAgB,CAACqC,QATrC;MAUHK,uBAAuB,EAAE1C,gBAAgB,CAACuC;IAVvC;EAvBX,EADJ;AAsCH;;AAAA"}
@@ -63,8 +63,8 @@ const YearPicker = _ref => {
63
63
 
64
64
  return /*#__PURE__*/_react.default.createElement(_core.Column, null, /*#__PURE__*/_react.default.createElement(_core.Typography, {
65
65
  children: (0, _utils.formatDate)(date, locale),
66
- color: 'textPrimary',
67
- variant: 'subtitle2'
66
+ color: 'strong',
67
+ variant: 'body3'
68
68
  }), /*#__PURE__*/_react.default.createElement(_reactNative.FlatList, {
69
69
  data: years,
70
70
  keyExtractor: item => item.toString(),
@@ -1 +1 @@
1
- {"version":3,"names":["initYear","itemHeight","useStyles","theme","useTheme","list","marginTop","spacing","maxHeight","YearPicker","date","locale","maxDate","minDate","onYearPress","styles","ref","React","useRef","minYear","getYear","maxYear","Date","years","Array","fill","map","v","i","useEffect","current","scrollToItem","animated","item","getItemLayout","data","index","length","offset","formatDate","toString","newDate","setYear"],"sources":["YearPicker.tsx"],"sourcesContent":["import React from 'react';\nimport { FlatList } from 'react-native';\nimport { getYear, setYear } from 'date-fns';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { Button, Column, Typography, useTheme } from '@fountain-ui/core';\nimport { formatDate } from './utils';\n\nconst initYear = 1901;\nconst itemHeight = 40;\n\ninterface YearPickerProps {\n date: Date;\n locale?: string,\n maxDate?: Date;\n minDate?: Date;\n onYearPress: (date: Date) => void;\n}\n\ntype YearPickerStyles = NamedStylesStringUnion<'list'>;\n\nconst useStyles: UseStyles<YearPickerStyles> = function (): YearPickerStyles {\n const theme = useTheme();\n\n return {\n list: {\n marginTop: theme.spacing(1),\n maxHeight: 270,\n },\n };\n};\n\nconst YearPicker = ({\n date,\n locale,\n maxDate,\n minDate,\n onYearPress,\n}: YearPickerProps) => {\n const styles = useStyles();\n\n const ref = React.useRef<FlatList | null>(null);\n\n const minYear = minDate ? getYear(minDate) : initYear;\n const maxYear = maxDate ? getYear(maxDate) : getYear(new Date());\n const years = Array(maxYear - minYear + 1).fill(minYear).map((v, i) => v + i);\n\n React.useEffect(() => {\n ref.current?.scrollToItem({\n animated: false,\n item: getYear(date),\n });\n }, [date]);\n\n const getItemLayout = (data: Array<number> | null | undefined, index: number) => ({\n length: itemHeight,\n offset: itemHeight * index,\n index,\n });\n\n return (\n <Column>\n <Typography\n children={formatDate(date, locale)}\n color={'textPrimary'}\n variant={'subtitle2'}\n />\n <FlatList\n data={years}\n keyExtractor={item => item.toString()}\n renderItem={({ item }) => (\n <Button\n children={item.toString()}\n variant={'text'}\n onPress={() => {\n const newDate = setYear(date, item);\n onYearPress(newDate);\n }}\n />\n )}\n getItemLayout={getItemLayout}\n style={styles.list}\n ref={ref}\n />\n </Column>\n );\n};\n\nexport default YearPicker;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAMA,QAAQ,GAAG,IAAjB;AACA,MAAMC,UAAU,GAAG,EAAnB;;AAYA,MAAMC,SAAsC,GAAG,YAA8B;EACzE,MAAMC,KAAK,GAAG,IAAAC,cAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,SAAS,EAAEH,KAAK,CAACI,OAAN,CAAc,CAAd,CADT;MAEFC,SAAS,EAAE;IAFT;EADH,CAAP;AAMH,CATD;;AAWA,MAAMC,UAAU,GAAG,QAMI;EAAA,IANH;IAChBC,IADgB;IAEhBC,MAFgB;IAGhBC,OAHgB;IAIhBC,OAJgB;IAKhBC;EALgB,CAMG;EACnB,MAAMC,MAAM,GAAGb,SAAS,EAAxB;;EAEA,MAAMc,GAAG,GAAGC,cAAA,CAAMC,MAAN,CAA8B,IAA9B,CAAZ;;EAEA,MAAMC,OAAO,GAAGN,OAAO,GAAG,IAAAO,gBAAA,EAAQP,OAAR,CAAH,GAAsBb,QAA7C;EACA,MAAMqB,OAAO,GAAGT,OAAO,GAAG,IAAA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,CAHhB;IAaI,aAAa,EAAEP,aAbnB;IAcI,KAAK,EAAEnB,MAAM,CAACV,IAdlB;IAeI,GAAG,EAAEW;EAfT,EANJ,CADJ;AA0BH,CAtDD;;eAwDeP,U"}
1
+ {"version":3,"names":["initYear","itemHeight","useStyles","theme","useTheme","list","marginTop","spacing","maxHeight","YearPicker","date","locale","maxDate","minDate","onYearPress","styles","ref","React","useRef","minYear","getYear","maxYear","Date","years","Array","fill","map","v","i","useEffect","current","scrollToItem","animated","item","getItemLayout","data","index","length","offset","formatDate","toString","newDate","setYear"],"sources":["YearPicker.tsx"],"sourcesContent":["import React from 'react';\nimport { FlatList } from 'react-native';\nimport { getYear, setYear } from 'date-fns';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { Button, Column, Typography, useTheme } from '@fountain-ui/core';\nimport { formatDate } from './utils';\n\nconst initYear = 1901;\nconst itemHeight = 40;\n\ninterface YearPickerProps {\n date: Date;\n locale?: string,\n maxDate?: Date;\n minDate?: Date;\n onYearPress: (date: Date) => void;\n}\n\ntype YearPickerStyles = NamedStylesStringUnion<'list'>;\n\nconst useStyles: UseStyles<YearPickerStyles> = function (): YearPickerStyles {\n const theme = useTheme();\n\n return {\n list: {\n marginTop: theme.spacing(1),\n maxHeight: 270,\n },\n };\n};\n\nconst YearPicker = ({\n date,\n locale,\n maxDate,\n minDate,\n onYearPress,\n}: YearPickerProps) => {\n const styles = useStyles();\n\n const ref = React.useRef<FlatList | null>(null);\n\n const minYear = minDate ? getYear(minDate) : initYear;\n const maxYear = maxDate ? getYear(maxDate) : getYear(new Date());\n const years = Array(maxYear - minYear + 1).fill(minYear).map((v, i) => v + i);\n\n React.useEffect(() => {\n ref.current?.scrollToItem({\n animated: false,\n item: getYear(date),\n });\n }, [date]);\n\n const getItemLayout = (data: Array<number> | null | undefined, index: number) => ({\n length: itemHeight,\n offset: itemHeight * index,\n index,\n });\n\n return (\n <Column>\n <Typography\n children={formatDate(date, locale)}\n color={'strong'}\n variant={'body3'}\n />\n <FlatList\n data={years}\n keyExtractor={item => item.toString()}\n renderItem={({ item }) => (\n <Button\n children={item.toString()}\n variant={'text'}\n onPress={() => {\n const newDate = setYear(date, item);\n onYearPress(newDate);\n }}\n />\n )}\n getItemLayout={getItemLayout}\n style={styles.list}\n ref={ref}\n />\n </Column>\n );\n};\n\nexport default YearPicker;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAMA,QAAQ,GAAG,IAAjB;AACA,MAAMC,UAAU,GAAG,EAAnB;;AAYA,MAAMC,SAAsC,GAAG,YAA8B;EACzE,MAAMC,KAAK,GAAG,IAAAC,cAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,SAAS,EAAEH,KAAK,CAACI,OAAN,CAAc,CAAd,CADT;MAEFC,SAAS,EAAE;IAFT;EADH,CAAP;AAMH,CATD;;AAWA,MAAMC,UAAU,GAAG,QAMI;EAAA,IANH;IAChBC,IADgB;IAEhBC,MAFgB;IAGhBC,OAHgB;IAIhBC,OAJgB;IAKhBC;EALgB,CAMG;EACnB,MAAMC,MAAM,GAAGb,SAAS,EAAxB;;EAEA,MAAMc,GAAG,GAAGC,cAAA,CAAMC,MAAN,CAA8B,IAA9B,CAAZ;;EAEA,MAAMC,OAAO,GAAGN,OAAO,GAAG,IAAAO,gBAAA,EAAQP,OAAR,CAAH,GAAsBb,QAA7C;EACA,MAAMqB,OAAO,GAAGT,OAAO,GAAG,IAAAQ,gBAAA,EAAQR,OAAR,CAAH,GAAsB,IAAAQ,gBAAA,EAAQ,IAAIE,IAAJ,EAAR,CAA7C;EACA,MAAMC,KAAK,GAAGC,KAAK,CAACH,OAAO,GAAGF,OAAV,GAAoB,CAArB,CAAL,CAA6BM,IAA7B,CAAkCN,OAAlC,EAA2CO,GAA3C,CAA+C,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,GAAGC,CAA7D,CAAd;;EAEAX,cAAA,CAAMY,SAAN,CAAgB,MAAM;IAAA;;IAClB,gBAAAb,GAAG,CAACc,OAAJ,8DAAaC,YAAb,CAA0B;MACtBC,QAAQ,EAAE,KADY;MAEtBC,IAAI,EAAE,IAAAb,gBAAA,EAAQV,IAAR;IAFgB,CAA1B;EAIH,CALD,EAKG,CAACA,IAAD,CALH;;EAOA,MAAMwB,aAAa,GAAG,CAACC,IAAD,EAAyCC,KAAzC,MAA4D;IAC9EC,MAAM,EAAEpC,UADsE;IAE9EqC,MAAM,EAAErC,UAAU,GAAGmC,KAFyD;IAG9EA;EAH8E,CAA5D,CAAtB;;EAMA,oBACI,6BAAC,YAAD,qBACI,6BAAC,gBAAD;IACI,QAAQ,EAAE,IAAAG,iBAAA,EAAW7B,IAAX,EAAiBC,MAAjB,CADd;IAEI,KAAK,EAAE,QAFX;IAGI,OAAO,EAAE;EAHb,EADJ,eAMI,6BAAC,qBAAD;IACI,IAAI,EAAEY,KADV;IAEI,YAAY,EAAEU,IAAI,IAAIA,IAAI,CAACO,QAAL,EAF1B;IAGI,UAAU,EAAE;MAAA,IAAC;QAAEP;MAAF,CAAD;MAAA,oBACR,6BAAC,YAAD;QACI,QAAQ,EAAEA,IAAI,CAACO,QAAL,EADd;QAEI,OAAO,EAAE,MAFb;QAGI,OAAO,EAAE,MAAM;UACX,MAAMC,OAAO,GAAG,IAAAC,gBAAA,EAAQhC,IAAR,EAAcuB,IAAd,CAAhB;UACAnB,WAAW,CAAC2B,OAAD,CAAX;QACH;MANL,EADQ;IAAA,CAHhB;IAaI,aAAa,EAAEP,aAbnB;IAcI,KAAK,EAAEnB,MAAM,CAACV,IAdlB;IAeI,GAAG,EAAEW;EAfT,EANJ,CADJ;AA0BH,CAtDD;;eAwDeP,U"}
@@ -1,60 +1,52 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React from 'react';
4
- import { Animated, Platform, useWindowDimensions, View } from 'react-native';
5
- import { BottomSheetBackdrop, BottomSheetFooter, BottomSheetModal, BottomSheetModalProvider, BottomSheetScrollView } from '@gorhom/bottom-sheet';
6
- import { Column, isNotAndroid12, useAnimatedValue, useElevationStyle } from '@fountain-ui/core';
3
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
4
+ import { Animated, useWindowDimensions } from 'react-native';
5
+ import { BottomSheetBackdrop, BottomSheetModal, BottomSheetModalProvider, BottomSheetView } from '@gorhom/bottom-sheet';
6
+ import { Column, isNotAndroid12, useAnimatedValue } from '@fountain-ui/core';
7
7
  import { useTheme } from '@fountain-ui/styles';
8
8
  import TransparentBackdrop from './TransparentBackdrop';
9
9
 
10
10
  const NoHandle = () => null;
11
11
 
12
- const createHeightLayoutHandler = setHeight => {
13
- return event => {
14
- const {
15
- height
16
- } = event.nativeEvent.layout;
17
- setHeight(height);
18
- };
19
- };
20
-
21
12
  export default function BottomSheet(props) {
22
13
  const {
23
14
  backdropOpacity = 0.5,
24
15
  borderRadius: borderRadiusProp,
25
16
  children,
26
17
  enableDynamicSizing = true,
27
- header,
28
- stickyBottomElement,
29
18
  topElement,
30
19
  index,
31
- maxHeightNormalizedRatio = 0.9,
20
+ maxHeightNormalizedRatio = 0.8,
32
21
  onChange,
33
- snapPoints = [],
34
- enableScrollableHeaderBorder = false
22
+ snapPoints = []
35
23
  } = props;
36
- const indexRef = React.useRef(-1);
37
- const bottomSheetRef = React.useRef(null);
24
+ const indexRef = useRef(-1);
25
+ const bottomSheetRef = useRef(null);
38
26
  const {
39
27
  height: windowHeight
40
28
  } = useWindowDimensions();
41
- const [isScrollable, setIsScrollable] = React.useState(false);
42
- const [topElementHeight, setTopElementHeight] = React.useState(0);
43
- const [stickyBottomElementHeight, setStickyBottomElementHeight] = React.useState(0);
29
+ const [topElementHeight, setTopElementHeight] = useState(0);
44
30
  const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;
45
- const handleTopElementLayout = createHeightLayoutHandler(setTopElementHeight);
46
- const handleStickyBottomElementLayout = createHeightLayoutHandler(setStickyBottomElementHeight);
47
- const handleChange = React.useCallback(newIndex => {
31
+
32
+ const handleTopElementLayout = event => {
33
+ const {
34
+ height
35
+ } = event.nativeEvent.layout;
36
+ setTopElementHeight(height);
37
+ };
38
+
39
+ const handleChange = useCallback(newIndex => {
48
40
  indexRef.current = newIndex;
49
41
 
50
42
  if (onChange) {
51
43
  onChange(newIndex);
52
44
  }
53
45
  }, [onChange]);
54
- const handleDismiss = React.useCallback(() => {
46
+ const handleDismiss = useCallback(() => {
55
47
  handleChange(-1);
56
48
  }, [handleChange]);
57
- React.useEffect(() => {
49
+ useEffect(() => {
58
50
  if (index === indexRef.current) {
59
51
  return;
60
52
  }
@@ -75,29 +67,19 @@ export default function BottomSheet(props) {
75
67
  }
76
68
  }, [index]);
77
69
  const theme = useTheme();
78
- const shadow = theme.shadow[12];
79
- const borderRadius = borderRadiusProp ?? theme.shape.roundnessExtra;
80
- const modalStyle = {
81
- backgroundColor: '#ffffff00',
82
- borderTopLeftRadius: borderRadius,
83
- borderTopRightRadius: borderRadius,
84
- ...Platform.select({
85
- android: shadow === null || shadow === void 0 ? void 0 : shadow.elevation,
86
- ios: shadow === null || shadow === void 0 ? void 0 : shadow.shadow,
87
- web: shadow === null || shadow === void 0 ? void 0 : shadow.boxShadow
88
- })
89
- };
90
- const backgroundColor = theme.palette.paper.default;
70
+ const borderRadius = borderRadiusProp ?? theme.shape.radius.xxl;
91
71
  const backgroundStyle = {
92
- backgroundColor,
72
+ backgroundColor: theme.palette.surface.base,
93
73
  borderTopLeftRadius: borderRadius,
94
74
  borderTopRightRadius: borderRadius
95
75
  };
96
76
  const contentWrapperStyle = {
97
77
  flex: 1,
98
- borderTopLeftRadius: borderRadius,
99
- borderTopRightRadius: borderRadius,
100
- overflow: 'hidden'
78
+ maxHeight: maxDynamicContentSize,
79
+ minHeight: 300,
80
+ overflow: 'hidden',
81
+ paddingBottom: theme.spacing(6),
82
+ paddingTop: theme.spacing(5.5)
101
83
  };
102
84
  const isBackdropTransparent = backdropOpacity <= 0;
103
85
 
@@ -127,32 +109,6 @@ export default function BottomSheet(props) {
127
109
  }).start();
128
110
  };
129
111
 
130
- const handleContentSizeChange = (_, contentHeight) => {
131
- setIsScrollable(contentHeight > maxDynamicContentSize);
132
- };
133
-
134
- const headerStyle = {
135
- backgroundColor,
136
- ...(isScrollable && enableScrollableHeaderBorder ? {
137
- borderBottomWidth: 0.5,
138
- borderBottomColor: theme.palette.divider
139
- } : {})
140
- };
141
- const childrenStyle = {
142
- backgroundColor,
143
- paddingBottom: stickyBottomElementHeight
144
- };
145
- const stickyBottomElementShadow = useElevationStyle(8);
146
- const stickyBottomElementStyle = {
147
- backgroundColor: theme.palette.paper.default,
148
- ...(isScrollable ? stickyBottomElementShadow : {})
149
- };
150
-
151
- const renderFooter = props => /*#__PURE__*/React.createElement(BottomSheetFooter, props, /*#__PURE__*/React.createElement(View, {
152
- onLayout: handleStickyBottomElementLayout,
153
- style: stickyBottomElementStyle
154
- }, stickyBottomElement));
155
-
156
112
  return /*#__PURE__*/React.createElement(BottomSheetModalProvider, null, /*#__PURE__*/React.createElement(BottomSheetModal, {
157
113
  backdropComponent: isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop // @ts-ignore
158
114
  ,
@@ -163,29 +119,19 @@ export default function BottomSheet(props) {
163
119
  onDismiss: handleDismiss,
164
120
  ref: bottomSheetRef,
165
121
  snapPoints: snapPoints,
166
- style: modalStyle,
167
122
  enablePanDownToClose: Boolean(onChange),
168
123
  enableDynamicSizing: enableDynamicSizing,
169
124
  maxDynamicContentSize: maxDynamicContentSize,
170
125
  detached: Boolean(topElement),
171
- onAnimate: topElement ? onAnimate : undefined,
172
- footerComponent: stickyBottomElement ? renderFooter : undefined
126
+ onAnimate: topElement ? onAnimate : undefined
173
127
  }, topElement ? /*#__PURE__*/React.createElement(Animated.View, {
174
128
  style: topElementAnimationStyle
175
129
  }, /*#__PURE__*/React.createElement(Column, {
176
130
  onLayout: handleTopElementLayout,
177
131
  style: topElementLocationStyle
178
- }, topElement)) : null, /*#__PURE__*/React.createElement(View, {
132
+ }, topElement)) : null, /*#__PURE__*/React.createElement(BottomSheetView, {
179
133
  style: contentWrapperStyle
180
- }, /*#__PURE__*/React.createElement(BottomSheetScrollView, {
181
- bounces: false,
182
- stickyHeaderIndices: header ? [0] : undefined,
183
- onContentSizeChange: handleContentSizeChange
184
- }, /*#__PURE__*/React.createElement(View, {
185
- style: headerStyle
186
- }, header), /*#__PURE__*/React.createElement(View, {
187
- style: childrenStyle
188
- }, children)))));
134
+ }, children)));
189
135
  }
190
136
  ;
191
137
  //# sourceMappingURL=BottomSheetNative.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","Animated","Platform","useWindowDimensions","View","BottomSheetBackdrop","BottomSheetFooter","BottomSheetModal","BottomSheetModalProvider","BottomSheetScrollView","Column","isNotAndroid12","useAnimatedValue","useElevationStyle","useTheme","TransparentBackdrop","NoHandle","createHeightLayoutHandler","setHeight","event","height","nativeEvent","layout","BottomSheet","props","backdropOpacity","borderRadius","borderRadiusProp","children","enableDynamicSizing","header","stickyBottomElement","topElement","index","maxHeightNormalizedRatio","onChange","snapPoints","enableScrollableHeaderBorder","indexRef","useRef","bottomSheetRef","windowHeight","isScrollable","setIsScrollable","useState","topElementHeight","setTopElementHeight","stickyBottomElementHeight","setStickyBottomElementHeight","maxDynamicContentSize","Math","round","handleTopElementLayout","handleStickyBottomElementLayout","handleChange","useCallback","newIndex","current","handleDismiss","useEffect","present","dismiss","snapToIndex","theme","shadow","shape","roundnessExtra","modalStyle","backgroundColor","borderTopLeftRadius","borderTopRightRadius","select","android","elevation","ios","web","boxShadow","palette","paper","default","backgroundStyle","contentWrapperStyle","flex","overflow","isBackdropTransparent","OpacityAwareBackdrop","topElementOpacity","topElementAnimationStyle","opacity","topElementLocationStyle","position","width","bottom","onAnimate","fromIndex","toIndex","isVisible","timing","toValue","duration","useNativeDriver","start","handleContentSizeChange","_","contentHeight","headerStyle","borderBottomWidth","borderBottomColor","divider","childrenStyle","paddingBottom","stickyBottomElementShadow","stickyBottomElementStyle","renderFooter","Boolean","undefined"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React from 'react';\nimport { Animated, LayoutChangeEvent, Platform, useWindowDimensions, View, ViewStyle } from 'react-native';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetFooter,\n BottomSheetFooterProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport { Column, ExtendedStyle, isNotAndroid12, useAnimatedValue, useElevationStyle } from '@fountain-ui/core';\nimport { useTheme } from '@fountain-ui/styles';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\n\nconst NoHandle = () => null;\n\nconst createHeightLayoutHandler = (setHeight: React.Dispatch<React.SetStateAction<number>>) => {\n return (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setHeight(height);\n };\n}\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n borderRadius: borderRadiusProp,\n children,\n enableDynamicSizing = true,\n header,\n stickyBottomElement,\n topElement,\n index,\n maxHeightNormalizedRatio = 0.9,\n onChange,\n snapPoints = [],\n enableScrollableHeaderBorder = false,\n } = props;\n\n const indexRef = React.useRef<number>(-1);\n const bottomSheetRef = React.useRef<BottomSheetModal | null>(null);\n\n const { height: windowHeight } = useWindowDimensions();\n const [isScrollable, setIsScrollable] = React.useState(false);\n const [topElementHeight, setTopElementHeight] = React.useState(0);\n const [stickyBottomElementHeight, setStickyBottomElementHeight] = React.useState(0);\n\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;\n\n const handleTopElementLayout = createHeightLayoutHandler(setTopElementHeight);\n const handleStickyBottomElementLayout = createHeightLayoutHandler(setStickyBottomElementHeight);\n\n const handleChange = React.useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = React.useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n React.useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n const shadow = theme.shadow[12];\n const borderRadius = borderRadiusProp ?? theme.shape.roundnessExtra;\n const modalStyle = {\n backgroundColor: '#ffffff00',\n borderTopLeftRadius: borderRadius,\n borderTopRightRadius: borderRadius,\n ...Platform.select<object>({\n android: shadow?.elevation,\n ios: shadow?.shadow,\n web: shadow?.boxShadow,\n }),\n };\n const backgroundColor = theme.palette.paper.default;\n const backgroundStyle = {\n backgroundColor,\n borderTopLeftRadius: borderRadius,\n borderTopRightRadius: borderRadius,\n };\n const contentWrapperStyle: ViewStyle = {\n flex: 1,\n borderTopLeftRadius: borderRadius,\n borderTopRightRadius: borderRadius,\n overflow: 'hidden',\n };\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n pressBehavior={onChange ? 'close' : 'none'}\n />\n );\n\n const topElementOpacity = useAnimatedValue(0);\n const topElementAnimationStyle: Animated.WithAnimatedValue<ExtendedStyle> = { opacity: topElementOpacity };\n const topElementLocationStyle: ExtendedStyle = {\n position: 'absolute',\n width: '100%',\n bottom: 0,\n };\n const onAnimate = (fromIndex: number, toIndex: number) => {\n const isVisible = toIndex > -1;\n\n Animated.timing(topElementOpacity, {\n toValue: isVisible ? 1 : 0,\n duration: 0,\n useNativeDriver: isNotAndroid12,\n }).start();\n };\n\n const handleContentSizeChange = (_: number, contentHeight: number) => {\n setIsScrollable(contentHeight > maxDynamicContentSize);\n };\n\n const headerStyle = {\n backgroundColor,\n ...(isScrollable && enableScrollableHeaderBorder ? {\n borderBottomWidth: 0.5,\n borderBottomColor: theme.palette.divider,\n }: {})\n }\n\n const childrenStyle = {\n backgroundColor,\n paddingBottom: stickyBottomElementHeight,\n }\n\n const stickyBottomElementShadow = useElevationStyle(8);\n\n const stickyBottomElementStyle = {\n backgroundColor: theme.palette.paper.default,\n ...(isScrollable ? stickyBottomElementShadow : {}),\n }\n\n const renderFooter = (props: BottomSheetFooterProps) => (\n <BottomSheetFooter {...props}>\n <View\n onLayout={handleStickyBottomElementLayout}\n style={stickyBottomElementStyle}\n >\n {stickyBottomElement}\n </View>\n </BottomSheetFooter>\n );\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n snapPoints={snapPoints}\n style={modalStyle}\n enablePanDownToClose={Boolean(onChange)}\n enableDynamicSizing={enableDynamicSizing}\n maxDynamicContentSize={maxDynamicContentSize}\n detached={Boolean(topElement)}\n onAnimate={topElement ? onAnimate : undefined}\n footerComponent={stickyBottomElement ? renderFooter : undefined}\n >\n {topElement ? (\n <Animated.View style={topElementAnimationStyle}>\n <Column\n onLayout={handleTopElementLayout}\n style={topElementLocationStyle}\n >\n {topElement}\n </Column>\n </Animated.View>\n ) : null}\n\n <View style={contentWrapperStyle}>\n <BottomSheetScrollView\n bounces={false}\n stickyHeaderIndices={header ? [0] : undefined}\n onContentSizeChange={handleContentSizeChange}\n >\n <View style={headerStyle}>\n {header}\n </View>\n\n <View style={childrenStyle}>\n {children}\n </View>\n </Bott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,CA7BJ,CADJ,CADJ;AAiDH;AAAA"}
1
+ {"version":3,"names":["React","useCallback","useEffect","useRef","useState","Animated","useWindowDimensions","BottomSheetBackdrop","BottomSheetModal","BottomSheetModalProvider","BottomSheetView","Column","isNotAndroid12","useAnimatedValue","useTheme","TransparentBackdrop","NoHandle","BottomSheet","props","backdropOpacity","borderRadius","borderRadiusProp","children","enableDynamicSizing","topElement","index","maxHeightNormalizedRatio","onChange","snapPoints","indexRef","bottomSheetRef","height","windowHeight","topElementHeight","setTopElementHeight","maxDynamicContentSize","Math","round","handleTopElementLayout","event","nativeEvent","layout","handleChange","newIndex","current","handleDismiss","present","dismiss","snapToIndex","theme","shape","radius","xxl","backgroundStyle","backgroundColor","palette","surface","base","borderTopLeftRadius","borderTopRightRadius","contentWrapperStyle","flex","maxHeight","minHeight","overflow","paddingBottom","spacing","paddingTop","isBackdropTransparent","OpacityAwareBackdrop","topElementOpacity","topElementAnimationStyle","opacity","topElementLocationStyle","position","width","bottom","onAnimate","fromIndex","toIndex","isVisible","timing","toValue","duration","useNativeDriver","start","Boolean","undefined"],"sources":["BottomSheetNative.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Animated, LayoutChangeEvent, useWindowDimensions, ViewStyle } from 'react-native';\nimport {\n BottomSheetBackdrop,\n BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetModalProvider,\n BottomSheetView,\n} from '@gorhom/bottom-sheet';\nimport { Column, ExtendedStyle, isNotAndroid12, useAnimatedValue } from '@fountain-ui/core';\nimport { useTheme } from '@fountain-ui/styles';\nimport type BottomSheetProps from './BottomSheetProps';\nimport TransparentBackdrop from './TransparentBackdrop';\n\nconst NoHandle = () => null;\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity = 0.5,\n borderRadius: borderRadiusProp,\n children,\n enableDynamicSizing = true,\n topElement,\n index,\n maxHeightNormalizedRatio = 0.8,\n onChange,\n snapPoints = [],\n } = props;\n\n const indexRef = useRef<number>(-1);\n const bottomSheetRef = useRef<BottomSheetModal | null>(null);\n\n const { height: windowHeight } = useWindowDimensions();\n const [topElementHeight, setTopElementHeight] = useState(0);\n\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;\n\n const handleTopElementLayout = (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setTopElementHeight(height);\n };\n\n const handleChange = useCallback((newIndex: number) => {\n indexRef.current = newIndex;\n\n if (onChange) {\n onChange(newIndex);\n }\n }, [onChange]);\n\n const handleDismiss = useCallback(() => {\n handleChange(-1);\n }, [handleChange]);\n\n useEffect(() => {\n if (index === indexRef.current) {\n return;\n }\n\n if (indexRef.current < 0 && index >= 0) {\n bottomSheetRef.current?.present();\n } else if (indexRef.current >= 0 && index < 0) {\n bottomSheetRef.current?.dismiss();\n } else {\n // @ts-ignore\n bottomSheetRef.current?.snapToIndex(index);\n }\n }, [index]);\n\n const theme = useTheme();\n\n const borderRadius = borderRadiusProp ?? theme.shape.radius.xxl;\n const backgroundStyle = {\n backgroundColor: theme.palette.surface.base,\n borderTopLeftRadius: borderRadius,\n borderTopRightRadius: borderRadius,\n };\n\n const contentWrapperStyle: ViewStyle = {\n flex: 1,\n maxHeight: maxDynamicContentSize,\n minHeight: 300,\n overflow: 'hidden',\n paddingBottom: theme.spacing(6),\n paddingTop: theme.spacing(5.5),\n };\n\n const isBackdropTransparent = backdropOpacity <= 0;\n\n const OpacityAwareBackdrop = (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={backdropOpacity}\n pressBehavior={onChange ? 'close' : 'none'}\n />\n );\n\n const topElementOpacity = useAnimatedValue(0);\n const topElementAnimationStyle: Animated.WithAnimatedValue<ExtendedStyle> = { opacity: topElementOpacity };\n const topElementLocationStyle: ExtendedStyle = {\n position: 'absolute',\n width: '100%',\n bottom: 0,\n };\n const onAnimate = (fromIndex: number, toIndex: number) => {\n const isVisible = toIndex > -1;\n\n Animated.timing(topElementOpacity, {\n toValue: isVisible ? 1 : 0,\n duration: 0,\n useNativeDriver: isNotAndroid12,\n }).start();\n };\n\n return (\n <BottomSheetModalProvider>\n <BottomSheetModal\n backdropComponent={isBackdropTransparent ? TransparentBackdrop : OpacityAwareBackdrop}\n // @ts-ignore\n backgroundStyle={backgroundStyle}\n index={index}\n handleComponent={NoHandle}\n onChange={handleChange}\n onDismiss={handleDismiss}\n ref={bottomSheetRef}\n snapPoints={snapPoints}\n enablePanDownToClose={Boolean(onChange)}\n enableDynamicSizing={enableDynamicSizing}\n maxDynamicContentSize={maxDynamicContentSize}\n detached={Boolean(topElement)}\n onAnimate={topElement ? onAnimate : undefined}\n >\n {topElement ? (\n <Animated.View style={topElementAnimationStyle}>\n <Column\n onLayout={handleTopElementLayout}\n style={topElementLocationStyle}\n >\n {topElement}\n </Column>\n </Animated.View>\n ) : null}\n\n <BottomSheetView style={contentWrapperStyle}>\n {children}\n </BottomSheetView>\n </BottomSheetModal>\n </BottomSheetModalProvider>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,MAAxC,EAAgDC,QAAhD,QAAgE,OAAhE;AACA,SAASC,QAAT,EAAsCC,mBAAtC,QAA4E,cAA5E;AACA,SACIC,mBADJ,EAGIC,gBAHJ,EAIIC,wBAJJ,EAKIC,eALJ,QAMO,sBANP;AAOA,SAASC,MAAT,EAAgCC,cAAhC,EAAgDC,gBAAhD,QAAwE,mBAAxE;AACA,SAASC,QAAT,QAAyB,qBAAzB;AAEA,OAAOC,mBAAP,MAAgC,uBAAhC;;AAEA,MAAMC,QAAQ,GAAG,MAAM,IAAvB;;AAEA,eAAe,SAASC,WAAT,CAAqBC,KAArB,EAA8C;EACzD,MAAM;IACFC,eAAe,GAAG,GADhB;IAEFC,YAAY,EAAEC,gBAFZ;IAGFC,QAHE;IAIFC,mBAAmB,GAAG,IAJpB;IAK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Content":["import React from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface BottomSheetProps extends ComponentProps<{\n /**\n * Opacity for BackdropComponent\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * Border radius for bottom sheet\n */\n borderRadius?: number;\n\n /**\n * BottomSheet children, usually the included sub-components.\n */\n children?: React.ReactNode;\n\n /**\n * Enable dynamic sizing for content size.\n * @default true\n */\n enableDynamicSizing?: boolean;\n\n /**\n * Area to be fixed on the top of the bottom sheet.\n */\n header?: React.ReactNode;\n\n /**\n * If set to true, a border will be applied to the header area when the bottom sheet content is scrollable.\n * This visually separates the header from the scrollable content.\n */\n enableScrollableHeaderBorder?: boolean;\n\n /**\n * Area to be fixed on the bottom of the bottom sheet.\n */\n stickyBottomElement?: React.ReactNode;\n\n /**\n * Top element for displaying additional information on the bottom sheet.\n */\n topElement?: React.ReactNode;\n\n /**\n * Snap index. You could also provide -1 to bottom sheet in closed state.\n */\n index: number;\n\n /**\n * Maximum height(normalized value) of dialog\n * ex. 30% => 0.3 / 90% => 0.9\n * @default 0.9\n */\n maxHeightNormalizedRatio?: number;\n\n /**\n * Callback fired when the index is changed.\n * Important! Use memoized value.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * Points for the bottom sheet to snap to, points should be sorted from bottom to top.\n * Important! Use memoized value.\n * Only number type or string type(~% format) can be used.\n * @default []\n */\n snapPoints?: Array<number | string>;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["BottomSheetProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport default interface BottomSheetProps extends ComponentProps<{\n /**\n * Opacity for BackdropComponent\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * Border radius for bottom sheet\n */\n borderRadius?: number;\n\n /**\n * BottomSheet children, usually the included sub-components.\n */\n children?: React.ReactNode;\n\n /**\n * Enable dynamic sizing for content size.\n * @default true\n */\n enableDynamicSizing?: boolean;\n\n /**\n * Top element for displaying additional information on the bottom sheet.\n */\n topElement?: React.ReactNode;\n\n /**\n * Snap index. You could also provide -1 to bottom sheet in closed state.\n */\n index: number;\n\n /**\n * Maximum height(normalized value) of dialog\n * ex. 30% => 0.3 / 90% => 0.9\n * @default 0.8\n */\n maxHeightNormalizedRatio?: number;\n\n /**\n * Callback fired when the index is changed.\n * Important! Use memoized value.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * Points for the bottom sheet to snap to, points should be sorted from bottom to top.\n * Important! Use memoized value.\n * Only number type or string type(~% format) can be used.\n * @default []\n */\n snapPoints?: Array<number | string>;\n}> {}\n"],"mappings":""}
@@ -1,21 +1,11 @@
1
- import React, { useLayoutEffect, useMemo, useState } from 'react';
2
- import { ScrollView, useWindowDimensions, View } from 'react-native';
3
- import { Column, css, Modal, Paper, StyleSheet, useElevationStyle, useTheme } from '@fountain-ui/core';
1
+ import React, { useState } from 'react';
2
+ import { useWindowDimensions, View } from 'react-native';
3
+ import { Column, css, Modal, StyleSheet, useTheme } from '@fountain-ui/core';
4
4
  import AnimatedY from '../AnimatedY';
5
5
  import useDynamicSnapPoints from './useDynamicSnapPoints';
6
6
 
7
- const createHeightLayoutHandler = setHeight => {
8
- return event => {
9
- const {
10
- height
11
- } = event.nativeEvent.layout;
12
- setHeight(height);
13
- };
14
- };
15
-
16
7
  const useStyles = function () {
17
8
  const theme = useTheme();
18
- const stickyBottomElementShadow = useElevationStyle(8);
19
9
  return {
20
10
  root: {
21
11
  justifyContent: 'flex-end',
@@ -27,33 +17,20 @@ const useStyles = function () {
27
17
  width: '100%'
28
18
  },
29
19
  paper: {
30
- borderTopLeftRadius: theme.shape.roundnessExtra,
31
- borderTopRightRadius: theme.shape.roundnessExtra,
32
- borderBottomLeftRadius: 0,
33
- borderBottomRightRadius: 0,
20
+ backgroundColor: theme.palette.surface.base,
21
+ borderTopLeftRadius: theme.shape.radius.xxl,
22
+ borderTopRightRadius: theme.shape.radius.xxl,
34
23
  flexGrow: 1,
35
- overflow: 'hidden'
24
+ minHeight: 300,
25
+ overflow: 'hidden',
26
+ paddingBottom: theme.spacing(6),
27
+ paddingTop: theme.spacing(5.5)
36
28
  },
37
29
  topElementLocation: {
38
30
  position: 'absolute',
39
31
  bottom: 0,
40
32
  width: '100%'
41
- },
42
- headerContainer: {
43
- backgroundColor: theme.palette.paper.default
44
- },
45
- headerBorder: {
46
- borderBottomWidth: 0.5,
47
- borderBottomColor: theme.palette.divider
48
- },
49
- stickyBottomElement: {
50
- position: 'absolute',
51
- bottom: 0,
52
- left: 0,
53
- right: 0,
54
- backgroundColor: theme.palette.paper.default
55
- },
56
- stickyBottomElementShadow
33
+ }
57
34
  };
58
35
  };
59
36
 
@@ -63,26 +40,25 @@ export default function BottomSheet(props) {
63
40
  borderRadius,
64
41
  children,
65
42
  enableDynamicSizing = true,
66
- header,
67
- stickyBottomElement,
68
43
  topElement,
69
44
  index,
70
- maxHeightNormalizedRatio = 0.9,
45
+ maxHeightNormalizedRatio = 0.8,
71
46
  onChange,
72
- snapPoints = [],
73
- enableScrollableHeaderBorder = false
47
+ snapPoints = []
74
48
  } = props;
75
49
  const styles = useStyles();
76
50
  const {
77
51
  height: windowHeight
78
52
  } = useWindowDimensions();
79
53
  const [topElementHeight, setTopElementHeight] = useState(0);
80
- const [stickyBottomElementHeight, setStickyBottomElementHeight] = useState(0);
81
- const [contentHeight, setContentHeight] = useState(0);
82
- const [isScrollable, setIsScrollable] = useState(false);
83
54
  const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;
84
- const handleTopElementLayout = createHeightLayoutHandler(setTopElementHeight);
85
- const handleStickyBottomElementLayout = createHeightLayoutHandler(setStickyBottomElementHeight);
55
+
56
+ const handleTopElementLayout = event => {
57
+ const {
58
+ height
59
+ } = event.nativeEvent.layout;
60
+ setTopElementHeight(height);
61
+ };
86
62
 
87
63
  const handleClose = () => {
88
64
  if (onChange) {
@@ -92,64 +68,37 @@ export default function BottomSheet(props) {
92
68
 
93
69
  const {
94
70
  convertedSnapPoints,
95
- handleContentSizeChange,
71
+ handleLayout,
96
72
  highestSnapPoint
97
73
  } = useDynamicSnapPoints({
98
74
  enableDynamicSizing,
99
- maxHeightNormalizedRatio,
75
+ maxDynamicContentSize,
100
76
  snapPoints
101
77
  });
102
78
  const translateY = highestSnapPoint - (convertedSnapPoints[index] ?? 0);
103
- const adjustedContentHeight = useMemo(() => {
104
- const adjustedHighestSnapPoint = highestSnapPoint + stickyBottomElementHeight;
105
- return Math.min(maxDynamicContentSize, adjustedHighestSnapPoint);
106
- }, [highestSnapPoint, stickyBottomElementHeight]);
107
- const contentStyles = [styles.paper, borderRadius ? {
108
- borderTopLeftRadius: borderRadius,
109
- borderTopRightRadius: borderRadius
110
- } : {}, {
111
- height: adjustedContentHeight,
79
+ const contentStyles = css([styles.paper, { ...(borderRadius ? {
80
+ borderTopLeftRadius: borderRadius,
81
+ borderTopRightRadius: borderRadius
82
+ } : {}),
83
+ ...(highestSnapPoint !== maxDynamicContentSize ? {
84
+ height: highestSnapPoint
85
+ } : {}),
112
86
  maxHeight: maxDynamicContentSize
113
- }];
114
- const headerStyles = [styles.headerContainer, isScrollable && enableScrollableHeaderBorder ? styles.headerBorder : {}];
115
- const stickyBottomElementStyles = [styles.stickyBottomElement, isScrollable ? styles.stickyBottomElementShadow : {}];
116
- useLayoutEffect(() => {
117
- if (contentHeight === 0 || highestSnapPoint === 0) {
118
- return;
119
- }
120
-
121
- const adjustedHighestSnapPoint = highestSnapPoint + stickyBottomElementHeight;
122
- setIsScrollable(adjustedHighestSnapPoint > maxDynamicContentSize);
123
- }, [contentHeight, highestSnapPoint, stickyBottomElementHeight, maxDynamicContentSize]);
87
+ }]);
124
88
  return /*#__PURE__*/React.createElement(Modal, {
125
89
  backdropOpacity: backdropOpacity,
126
90
  onClose: handleClose,
127
91
  visible: index >= 0,
128
92
  style: css([StyleSheet.absoluteFill, styles.root])
129
93
  }, /*#__PURE__*/React.createElement(AnimatedY, {
130
- style: styles.animated,
131
94
  translateY: translateY
132
- }, topElement ? /*#__PURE__*/React.createElement(Column, null, /*#__PURE__*/React.createElement(Column, {
95
+ }, topElement ? /*#__PURE__*/React.createElement(Column, {
133
96
  onLayout: handleTopElementLayout,
134
97
  style: styles.topElementLocation
135
- }, topElement)) : null, /*#__PURE__*/React.createElement(Paper, {
136
- elevation: 12,
98
+ }, topElement) : null, /*#__PURE__*/React.createElement(View, {
99
+ onLayout: handleLayout,
137
100
  style: contentStyles
138
- }, /*#__PURE__*/React.createElement(ScrollView, {
139
- onContentSizeChange: (contentWidth, contentHeight) => {
140
- setContentHeight(contentHeight);
141
- handleContentSizeChange(contentWidth, contentHeight);
142
- },
143
- stickyHeaderIndices: header ? [0] : undefined,
144
- style: {
145
- paddingBottom: stickyBottomElementHeight
146
- }
147
- }, header ? /*#__PURE__*/React.createElement(View, {
148
- style: headerStyles
149
- }, header) : null, children), stickyBottomElement ? /*#__PURE__*/React.createElement(Column, {
150
- style: stickyBottomElementStyles,
151
- onLayout: handleStickyBottomElementLayout
152
- }, stickyBottomElement) : null)));
101
+ }, children)));
153
102
  }
154
103
  ;
155
104
  //# sourceMappingURL=BottomSheetWeb.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useLayoutEffect","useMemo","useState","ScrollView","useWindowDimensions","View","Column","css","Modal","Paper","StyleSheet","useElevationStyle","useTheme","AnimatedY","useDynamicSnapPoints","createHeightLayoutHandler","setHeight","event","height","nativeEvent","layout","useStyles","theme","stickyBottomElementShadow","root","justifyContent","zIndex","dialog","animated","alignSelf","maxWidth","width","paper","borderTopLeftRadius","shape","roundnessExtra","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","flexGrow","overflow","topElementLocation","position","bottom","headerContainer","backgroundColor","palette","default","headerBorder","borderBottomWidth","borderBottomColor","divider","stickyBottomElement","left","right","BottomSheet","props","backdropOpacity","borderRadius","children","enableDynamicSizing","header","topElement","index","maxHeightNormalizedRatio","onChange","snapPoints","enableScrollableHeaderBorder","styles","windowHeight","topElementHeight","setTopElementHeight","stickyBottomElementHeight","setStickyBottomElementHeight","contentHeight","setContentHeight","isScrollable","setIsScrollable","maxDynamicContentSize","Math","round","handleTopElementLayout","handleStickyBottomElementLayout","handleClose","convertedSnapPoints","handleContentSizeChange","highestSnapPoint","translateY","adjustedContentHeight","adjustedHighestSnapPoint","min","contentStyles","maxHeight","headerStyles","stickyBottomElementStyles","absoluteFill","contentWidth","undefined","paddingBottom"],"sources":["BottomSheetWeb.tsx"],"sourcesContent":["import React, { useLayoutEffect, useMemo, useState } from 'react';\nimport { LayoutChangeEvent, ScrollView, useWindowDimensions, View } from 'react-native';\nimport { Column, css, Modal, Paper, StyleSheet, useElevationStyle, useTheme } from '@fountain-ui/core';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport AnimatedY from '../AnimatedY';\nimport type BottomSheetProps from './BottomSheetProps';\nimport useDynamicSnapPoints from './useDynamicSnapPoints';\n\nconst createHeightLayoutHandler = (setHeight: React.Dispatch<React.SetStateAction<number>>) => {\n return (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setHeight(height);\n };\n}\n\ntype BottomSheetStyles = NamedStylesStringUnion<'root' | 'animated' | 'paper' | 'topElementLocation' | 'headerContainer' | 'headerBorder' | 'stickyBottomElement' | 'stickyBottomElementShadow'>;\n\nconst useStyles: UseStyles<BottomSheetStyles> = function (): BottomSheetStyles {\n const theme = useTheme();\n const stickyBottomElementShadow = useElevationStyle(8);\n\n return {\n root: {\n justifyContent: 'flex-end',\n zIndex: theme.zIndex.dialog,\n },\n animated: {\n alignSelf: 'center',\n maxWidth: 720,\n width: '100%',\n },\n paper: {\n borderTopLeftRadius: theme.shape.roundnessExtra,\n borderTopRightRadius: theme.shape.roundnessExtra,\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n flexGrow: 1,\n overflow: 'hidden',\n },\n topElementLocation: {\n position: 'absolute',\n bottom: 0,\n width: '100%',\n },\n headerContainer: {\n backgroundColor: theme.palette.paper.default,\n },\n headerBorder: {\n borderBottomWidth: 0.5,\n borderBottomColor: theme.palette.divider,\n },\n stickyBottomElement: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n backgroundColor: theme.palette.paper.default,\n },\n stickyBottomElementShadow,\n };\n};\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity,\n borderRadius,\n children,\n enableDynamicSizing = true,\n header,\n stickyBottomElement,\n topElement,\n index,\n maxHeightNormalizedRatio = 0.9,\n onChange,\n snapPoints = [],\n enableScrollableHeaderBorder = false,\n } = props;\n\n const styles = useStyles();\n\n const { height: windowHeight } = useWindowDimensions();\n\n const [topElementHeight, setTopElementHeight] = useState(0);\n const [stickyBottomElementHeight, setStickyBottomElementHeight] = useState(0);\n const [contentHeight, setContentHeight] = useState(0);\n const [isScrollable, setIsScrollable] = useState(false);\n\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;\n\n const handleTopElementLayout = createHeightLayoutHandler(setTopElementHeight);\n const handleStickyBottomElementLayout = createHeightLayoutHandler(setStickyBottomElementHeight);\n\n const handleClose = () => {\n if (onChange) {\n onChange(-1);\n }\n };\n\n const {\n convertedSnapPoints,\n handleContentSizeChange,\n highestSnapPoint,\n } = useDynamicSnapPoints({\n enableDynamicSizing,\n maxHeightNormalizedRatio,\n snapPoints,\n });\n\n const translateY = highestSnapPoint - (convertedSnapPoints[index] ?? 0);\n\n const adjustedContentHeight = useMemo(() => {\n const adjustedHighestSnapPoint = highestSnapPoint + stickyBottomElementHeight;\n\n return Math.min(maxDynamicContentSize, adjustedHighestSnapPoint);\n }, [highestSnapPoint, stickyBottomElementHeight]);\n\n const contentStyles = [\n styles.paper,\n borderRadius ? { borderTopLeftRadius: borderRadius, borderTopRightRadius: borderRadius } : {},\n { height: adjustedContentHeight, maxHeight: maxDynamicContentSize },\n ];\n\n const headerStyles = [\n styles.headerContainer,\n isScrollable && enableScrollableHeaderBorder ? styles.headerBorder : {},\n ];\n\n const stickyBottomElementStyles = [\n styles.stickyBottomElement,\n isScrollable ? styles.stickyBottomElementShadow : {},\n ];\n\n useLayoutEffect(() => {\n if (contentHeight === 0 || highestSnapPoint === 0) {\n return;\n }\n\n const adjustedHighestSnapPoint = highestSnapPoint + stickyBottomElementHeight;\n setIsScrollable(adjustedHighestSnapPoint > maxDynamicContentSize);\n }, [contentHeight, highestSnapPoint, stickyBottomElementHeight, maxDynamicContentSize]);\n\n return (\n <Modal\n backdropOpacity={backdropOpacity}\n onClose={handleClose}\n visible={index >= 0}\n style={css([StyleSheet.absoluteFill, styles.root])}\n >\n <AnimatedY\n style={styles.animated}\n translateY={translateY}\n >\n {topElement ? (\n <Column>\n <Column\n onLayout={handleTopElementLayout}\n style={styles.topElementLocation}\n >\n {topElement}\n </Column>\n </Column>\n ) : null}\n\n <Paper\n elevation={12}\n style={contentStyles}\n >\n <ScrollView\n onContentSizeChange={(contentWidth: number, contentHeight: number) => {\n setContentHeight(contentHeight);\n handleContentSizeChange(contentWidth, contentHeight);\n }}\n stickyHeaderIndices={header ? [0] : undefined}\n style={{ paddingBottom: stickyBottomElementHeight }}\n >\n {header ? (\n <View style={headerStyles}>\n {header}\n </View>\n ): null}\n\n {children}\n </ScrollView>\n\n {stickyBottomElement ? (\n <Column\n style={stickyBottomElementStyles}\n onLayout={handleStickyBottomElementLayout}\n >\n {stickyBottomElement}\n </Column>\n ): null}\n </Paper>\n </AnimatedY>\n </Modal>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,eAAhB,EAAiCC,OAAjC,EAA0CC,QAA1C,QAA0D,OAA1D;AACA,SAA4BC,UAA5B,EAAwCC,mBAAxC,EAA6DC,IAA7D,QAAyE,cAAzE;AACA,SAASC,MAAT,EAAiBC,GAAjB,EAAsBC,KAAtB,EAA6BC,KAA7B,EAAoCC,UAApC,EAAgDC,iBAAhD,EAAmEC,QAAnE,QAAmF,mBAAnF;AAEA,OAAOC,SAAP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AC,KAAD;IACI,eAAe,EAAErB,eADrB;IAEI,OAAO,EAAE0B,WAFb;IAGI,OAAO,EAAEpB,KAAK,IAAI,CAHtB;IAII,KAAK,EAAExD,GAAG,CAAC,CAACG,UAAU,CAACqF,YAAZ,EAA0B3B,MAAM,CAAC5C,IAAjC,CAAD;EAJd,gBAMI,oBAAC,SAAD;IACI,KAAK,EAAE4C,MAAM,CAACxC,QADlB;IAEI,UAAU,EAAE2D;EAFhB,GAIKzB,UAAU,gBACP,oBAAC,MAAD,qBACI,oBAAC,MAAD;IACI,QAAQ,EAAEmB,sBADd;IAEI,KAAK,EAAEb,MAAM,CAAC3B;EAFlB,GAIKqB,UAJL,CADJ,CADO,GASP,IAbR,eAeI,oBAAC,KAAD;IACI,SAAS,EAAE,EADf;IAEI,KAAK,EAAE6B;EAFX,gBAII,oBAAC,UAAD;IACI,mBAAmB,EAAE,CAACK,YAAD,EAAuBtB,aAAvB,KAAiD;MAClEC,gBAAgB,CAACD,aAAD,CAAhB;MACAW,uBAAuB,CAACW,YAAD,EAAetB,aAAf,CAAvB;IACH,CAJL;IAKI,mBAAmB,EAAEb,MAAM,GAAG,CAAC,CAAD,CAAH,GAASoC,SALxC;IAMI,KAAK,EAAE;MAAEC,aAAa,EAAE1B;IAAjB;EANX,GAQKX,MAAM,gBACH,oBAAC,IAAD;IAAM,KAAK,EAAEgC;EAAb,GACKhC,MADL,CADG,GAIJ,IAZP,EAcKF,QAdL,CAJJ,EAqBKP,mBAAmB,gBAChB,oBAAC,MAAD;IACI,KAAK,EAAE0C,yBADX;IAEI,QAAQ,EAAEZ;EAFd,GAIK9B,mBAJL,CADgB,GAOjB,IA5BP,CAfJ,CANJ,CADJ;AAuDH;AAAA"}
1
+ {"version":3,"names":["React","useState","useWindowDimensions","View","Column","css","Modal","StyleSheet","useTheme","AnimatedY","useDynamicSnapPoints","useStyles","theme","root","justifyContent","zIndex","dialog","animated","alignSelf","maxWidth","width","paper","backgroundColor","palette","surface","base","borderTopLeftRadius","shape","radius","xxl","borderTopRightRadius","flexGrow","minHeight","overflow","paddingBottom","spacing","paddingTop","topElementLocation","position","bottom","BottomSheet","props","backdropOpacity","borderRadius","children","enableDynamicSizing","topElement","index","maxHeightNormalizedRatio","onChange","snapPoints","styles","height","windowHeight","topElementHeight","setTopElementHeight","maxDynamicContentSize","Math","round","handleTopElementLayout","event","nativeEvent","layout","handleClose","convertedSnapPoints","handleLayout","highestSnapPoint","translateY","contentStyles","maxHeight","absoluteFill"],"sources":["BottomSheetWeb.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { LayoutChangeEvent, useWindowDimensions, View } from 'react-native';\nimport { Column, css, Modal, StyleSheet, useTheme } from '@fountain-ui/core';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport AnimatedY from '../AnimatedY';\nimport type BottomSheetProps from './BottomSheetProps';\nimport useDynamicSnapPoints from './useDynamicSnapPoints';\n\ntype BottomSheetStyles = NamedStylesStringUnion<'root' | 'animated' | 'paper' | 'topElementLocation'>;\n\nconst useStyles: UseStyles<BottomSheetStyles> = function (): BottomSheetStyles {\n const theme = useTheme();\n\n return {\n root: {\n justifyContent: 'flex-end',\n zIndex: theme.zIndex.dialog,\n },\n animated: {\n alignSelf: 'center',\n maxWidth: 720,\n width: '100%',\n },\n paper: {\n backgroundColor: theme.palette.surface.base,\n borderTopLeftRadius: theme.shape.radius.xxl,\n borderTopRightRadius: theme.shape.radius.xxl,\n flexGrow: 1,\n minHeight: 300,\n overflow: 'hidden',\n paddingBottom: theme.spacing(6),\n paddingTop: theme.spacing(5.5),\n },\n topElementLocation: {\n position: 'absolute',\n bottom: 0,\n width: '100%',\n },\n };\n};\n\nexport default function BottomSheet(props: BottomSheetProps) {\n const {\n backdropOpacity,\n borderRadius,\n children,\n enableDynamicSizing = true,\n topElement,\n index,\n maxHeightNormalizedRatio = 0.8,\n onChange,\n snapPoints = [],\n } = props;\n\n const styles = useStyles();\n\n const { height: windowHeight } = useWindowDimensions();\n\n const [topElementHeight, setTopElementHeight] = useState(0);\n\n const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio) - topElementHeight;\n\n const handleTopElementLayout = (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setTopElementHeight(height);\n };\n\n const handleClose = () => {\n if (onChange) {\n onChange(-1);\n }\n };\n\n const {\n convertedSnapPoints,\n handleLayout,\n highestSnapPoint,\n } = useDynamicSnapPoints({\n enableDynamicSizing,\n maxDynamicContentSize,\n snapPoints,\n });\n\n const translateY = highestSnapPoint - (convertedSnapPoints[index] ?? 0);\n\n const contentStyles = css([\n styles.paper,\n {\n ...(borderRadius ? { borderTopLeftRadius: borderRadius, borderTopRightRadius: borderRadius } : {}),\n ...(highestSnapPoint !== maxDynamicContentSize ? { height: highestSnapPoint } : {}),\n maxHeight: maxDynamicContentSize,\n },\n ]);\n\n return (\n <Modal\n backdropOpacity={backdropOpacity}\n onClose={handleClose}\n visible={index >= 0}\n style={css([StyleSheet.absoluteFill, styles.root])}\n >\n <AnimatedY translateY={translateY}>\n {topElement ? (\n <Column\n onLayout={handleTopElementLayout}\n style={styles.topElementLocation}\n >\n {topElement}\n </Column>\n ) : null}\n\n <View\n onLayout={handleLayout}\n style={contentStyles}\n >\n {children}\n </View>\n </AnimatedY>\n </Modal>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAA4BC,mBAA5B,EAAiDC,IAAjD,QAA6D,cAA7D;AACA,SAASC,MAAT,EAAiBC,GAAjB,EAAsBC,KAAtB,EAA6BC,UAA7B,EAAyCC,QAAzC,QAAyD,mBAAzD;AAEA,OAAOC,SAAP,MAAsB,cAAtB;AAEA,OAAOC,oBAAP,MAAiC,wBAAjC;;AAIA,MAAMC,SAAuC,GAAG,YAA+B;EAC3E,MAAMC,KAAK,GAAGJ,QAAQ,EAAtB;EAEA,OAAO;IACHK,IAAI,EAAE;MACFC,cAAc,EAAE,UADd;MAEFC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,EAAEmB,YADd;IAEI,KAAK,EAAEG;EAFX,GAIKxB,QAJL,CAVJ,CANJ,CADJ;AA0BH;AAAA"}
@@ -1,6 +1,7 @@
1
- import * as R from 'ramda';
2
- import { useCallback, useMemo, useState } from 'react';
1
+ import { useCallback, useMemo, useRef, useState } from 'react';
3
2
  import { useWindowDimensions } from 'react-native';
3
+ import * as R from 'ramda';
4
+ const INITIAL_CONTAINER_HEIGHT = -999;
4
5
 
5
6
  const convertSnapPoint = (snapPoint, windowHeight, maxDynamicContentSize) => {
6
7
  if (typeof snapPoint === 'number') {
@@ -20,15 +21,19 @@ const convertSnapPoint = (snapPoint, windowHeight, maxDynamicContentSize) => {
20
21
  export default function useDynamicSnapPoints(params) {
21
22
  const {
22
23
  enableDynamicSizing,
23
- maxHeightNormalizedRatio,
24
+ maxDynamicContentSize,
24
25
  snapPoints
25
26
  } = params;
26
27
  const {
27
28
  height: windowHeight
28
29
  } = useWindowDimensions();
29
- const [contentHeight, setContentHeight] = useState(0);
30
+ const [contentHeight, setContentHeight] = useState(INITIAL_CONTAINER_HEIGHT);
31
+ const hasMeasureRef = useRef(false);
30
32
  const convertedSnapPoints = useMemo(() => {
31
- const maxDynamicContentSize = Math.round(windowHeight * maxHeightNormalizedRatio);
33
+ if (contentHeight === INITIAL_CONTAINER_HEIGHT) {
34
+ return [];
35
+ }
36
+
32
37
  const convertedSnapPoints = snapPoints.map(snapPoint => {
33
38
  return convertSnapPoint(snapPoint, windowHeight, maxDynamicContentSize);
34
39
  });
@@ -38,14 +43,22 @@ export default function useDynamicSnapPoints(params) {
38
43
  }
39
44
 
40
45
  return Array.from(new Set(convertedSnapPoints)).sort((a, b) => a - b);
41
- }, [contentHeight, snapPoints, windowHeight]);
42
- const highestSnapPoint = R.last(convertedSnapPoints) ?? 0;
43
- const handleContentSizeChange = useCallback((_, height) => {
46
+ }, [contentHeight, enableDynamicSizing, maxDynamicContentSize, snapPoints, windowHeight]);
47
+ const highestSnapPoint = R.last(convertedSnapPoints) ?? maxDynamicContentSize;
48
+ const handleLayout = useCallback(event => {
49
+ if (hasMeasureRef.current) {
50
+ return;
51
+ }
52
+
53
+ hasMeasureRef.current = true;
54
+ const {
55
+ height
56
+ } = event.nativeEvent.layout;
44
57
  setContentHeight(height);
45
58
  }, []);
46
59
  return {
47
60
  convertedSnapPoints,
48
- handleContentSizeChange,
61
+ handleLayout,
49
62
  highestSnapPoint
50
63
  };
51
64
  }