@webority/mobile-ui 0.147.0 → 0.149.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.
- package/dist/canvas-kit/kit.js +4744 -4512
- package/dist/canvas-kit/manifest.json +8 -1
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
- package/lib/commonjs/components/AuthedImage/imageStore.js +1 -1
- package/lib/commonjs/components/AuthedImage/imageStore.web.js +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js +1 -1
- package/lib/commonjs/components/BarChart/BarChart.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Box/Box.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
- package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/commonjs/components/FileViewer/useFileViewerZoom.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/ListItem/ListItem.js +1 -1
- package/lib/commonjs/components/Markdown/Markdown.js +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +1 -1
- package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
- package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/commonjs/components/SignaturePad/writePng.js +1 -1
- package/lib/commonjs/components/SignaturePad/writePng.web.js +1 -1
- package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/commonjs/components/Slider/Slider.js +1 -1
- package/lib/commonjs/components/SortableList/SortableList.js +1 -1
- package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
- package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
- package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/navigation/NavigationScreen.js +1 -1
- package/lib/commonjs/theme/Gradient.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
- package/lib/module/components/AuthedImage/imageStore.js +1 -1
- package/lib/module/components/AuthedImage/imageStore.web.js +1 -1
- package/lib/module/components/Avatar/Avatar.js +1 -1
- package/lib/module/components/BarChart/BarChart.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/Box/Box.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/FieldBase/FieldBase.js +1 -1
- package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/module/components/FileViewer/useFileViewerZoom.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/ListItem/ListItem.js +1 -1
- package/lib/module/components/Markdown/Markdown.js +1 -1
- package/lib/module/components/MessageList/MessageList.js +1 -1
- package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
- package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/module/components/SignaturePad/writePng.js +1 -1
- package/lib/module/components/SignaturePad/writePng.web.js +1 -1
- package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/module/components/Slider/Slider.js +1 -1
- package/lib/module/components/SortableList/SortableList.js +1 -1
- package/lib/module/components/Swipeable/Swipeable.js +1 -1
- package/lib/module/components/WheelPicker/Wheel.js +1 -1
- package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/module/hooks/useDragToDismiss.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/navigation/NavigationScreen.js +1 -1
- package/lib/module/theme/Gradient.js +1 -1
- package/lib/typescript/commonjs/canvasKit/index.d.ts +15 -6
- package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +3 -2
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +2 -2
- package/lib/typescript/commonjs/components/AuthedImage/imageStore.d.ts +1 -1
- package/lib/typescript/commonjs/components/AuthedImage/imageStore.web.d.ts +1 -1
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +2 -2
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +2 -2
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +2 -2
- package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +2 -2
- package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +2 -2
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +3 -4
- package/lib/typescript/commonjs/components/Box/Box.d.ts +4 -4
- package/lib/typescript/commonjs/components/Button/Button.d.ts +3 -2
- package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +3 -2
- package/lib/typescript/commonjs/components/Calendar/calendarStyles.d.ts +25 -116
- package/lib/typescript/commonjs/components/Card/Card.d.ts +2 -2
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +2 -2
- package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +2 -2
- package/lib/typescript/commonjs/components/Composer/Composer.d.ts +2 -3
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +3 -2
- package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/Divider/Divider.d.ts +3 -2
- package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +1 -1
- package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +2 -2
- package/lib/typescript/commonjs/components/FileViewer/useFileViewerZoom.d.ts +14 -22
- package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +3 -2
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +2 -2
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +2 -2
- package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +3 -2
- package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +3 -2
- package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +2 -2
- package/lib/typescript/commonjs/components/Input/Input.d.ts +2 -3
- package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +4 -3
- package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +3 -1
- package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +2 -2
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +3 -3
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -2
- package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +2 -2
- package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +2 -2
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +4 -4
- package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +2 -2
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -3
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +2 -2
- package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +2 -2
- package/lib/typescript/commonjs/components/Screen/Screen.d.ts +2 -2
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +3 -3
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -3
- package/lib/typescript/commonjs/components/Select/Select.d.ts +2 -2
- package/lib/typescript/commonjs/components/SignaturePad/writePng.d.ts +1 -1
- package/lib/typescript/commonjs/components/SignaturePad/writePng.web.d.ts +1 -1
- package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +2 -2
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +2 -2
- package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +2 -2
- package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +3 -2
- package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +2 -2
- package/lib/typescript/commonjs/components/SquircleView/SquircleView.d.ts +3 -2
- package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +3 -3
- package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +2 -2
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +2 -2
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +1 -1
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -3
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -3
- package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/Text/Text.d.ts +2 -2
- package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +3 -3
- package/lib/typescript/commonjs/components/Tour/Tour.d.ts +2 -2
- package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +5 -5
- package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +5 -5
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/Gradient.d.ts +5 -1
- package/lib/typescript/commonjs/theme/makeStyles.d.ts +4 -2
- package/lib/typescript/module/canvasKit/index.d.ts +15 -6
- package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +3 -2
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +2 -2
- package/lib/typescript/module/components/AuthedImage/imageStore.d.ts +1 -1
- package/lib/typescript/module/components/AuthedImage/imageStore.web.d.ts +1 -1
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +2 -2
- package/lib/typescript/module/components/Badge/Badge.d.ts +2 -2
- package/lib/typescript/module/components/Banner/Banner.d.ts +2 -2
- package/lib/typescript/module/components/BarChart/BarChart.d.ts +2 -2
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +2 -2
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +3 -4
- package/lib/typescript/module/components/Box/Box.d.ts +4 -4
- package/lib/typescript/module/components/Button/Button.d.ts +3 -2
- package/lib/typescript/module/components/Calendar/Calendar.d.ts +3 -2
- package/lib/typescript/module/components/Calendar/calendarStyles.d.ts +25 -116
- package/lib/typescript/module/components/Card/Card.d.ts +2 -2
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/typescript/module/components/Chip/Chip.d.ts +2 -2
- package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +2 -2
- package/lib/typescript/module/components/Composer/Composer.d.ts +2 -3
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +3 -2
- package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +3 -2
- package/lib/typescript/module/components/Divider/Divider.d.ts +3 -2
- package/lib/typescript/module/components/Drawer/Drawer.d.ts +1 -1
- package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +2 -2
- package/lib/typescript/module/components/FileViewer/useFileViewerZoom.d.ts +14 -22
- package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +3 -2
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +2 -2
- package/lib/typescript/module/components/FormField/FormField.d.ts +2 -2
- package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +3 -2
- package/lib/typescript/module/components/IconButton/IconButton.d.ts +3 -2
- package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +2 -2
- package/lib/typescript/module/components/Input/Input.d.ts +2 -3
- package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +4 -3
- package/lib/typescript/module/components/Markdown/Markdown.d.ts +3 -1
- package/lib/typescript/module/components/Menu/useContextMenu.d.ts +2 -2
- package/lib/typescript/module/components/Modal/Modal.d.ts +3 -3
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -2
- package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +2 -2
- package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +2 -2
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +4 -4
- package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +2 -2
- package/lib/typescript/module/components/Radio/Radio.d.ts +3 -3
- package/lib/typescript/module/components/Rating/Rating.d.ts +2 -2
- package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +2 -2
- package/lib/typescript/module/components/Screen/Screen.d.ts +2 -2
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +3 -3
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -3
- package/lib/typescript/module/components/Select/Select.d.ts +2 -2
- package/lib/typescript/module/components/SignaturePad/writePng.d.ts +1 -1
- package/lib/typescript/module/components/SignaturePad/writePng.web.d.ts +1 -1
- package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +2 -2
- package/lib/typescript/module/components/Slider/Slider.d.ts +2 -2
- package/lib/typescript/module/components/SliderField/SliderField.d.ts +2 -2
- package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +3 -2
- package/lib/typescript/module/components/Spinner/Spinner.d.ts +2 -2
- package/lib/typescript/module/components/SquircleView/SquircleView.d.ts +3 -2
- package/lib/typescript/module/components/StatTile/StatTile.d.ts +3 -3
- package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +2 -2
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +2 -2
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +1 -1
- package/lib/typescript/module/components/Switch/Switch.d.ts +3 -3
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -3
- package/lib/typescript/module/components/TagInput/TagInput.d.ts +3 -2
- package/lib/typescript/module/components/Text/Text.d.ts +2 -2
- package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +3 -3
- package/lib/typescript/module/components/Tour/Tour.d.ts +2 -2
- package/lib/typescript/module/hooks/useDragToDismiss.d.ts +5 -5
- package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +5 -5
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/theme/Gradient.d.ts +5 -1
- package/lib/typescript/module/theme/makeStyles.d.ts +4 -2
- package/package.json +31 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Pressable,StatusBar,StyleSheet,TextInput,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useKeyboardState}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const SEARCH_ICON_SIZE=18;export const DEFAULT_OPTION_SHEET_LABELS=Object.freeze({searchPlaceholder:"Search…",empty:"No options",done:"Done",closePicker:"Close picker",fallbackName:"Options",searchOptions:"Search options",clearSearch:"Clear search",jumpToLetter:"Jump to letter",jumpTo:e=>`Jump to ${e}`});const selectOptionLabel=e=>e.label,selectOptionValue=e=>e.value,selectOptionDescription=e=>e.description,selectOptionDisabled=e=>!0===e.disabled,selectOptionIcon=e=>e.icon,hostStyle=StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:o,options:s,sections:i,renderSectionHeader:r,renderOption:l,alphabetIndex:n=!1,labels:a,getOptionLabel:c,getOptionValue:d,getOptionDescription:p,isOptionDisabled:u,getOptionIcon:h,destructiveOf:m,value:b,onChange:g,multi:x=!1,searchable:y=!1,searchSelectionColor:f,accessibilityLabel:S,optionStyle:T,selectedOptionStyle:j,optionTextStyle:w,selectedOptionTextStyle:C,testID:_}=e,k=c??selectOptionLabel,L=d??selectOptionValue,I=p??selectOptionDescription,O=u??selectOptionDisabled,R=h??selectOptionIcon,V=useTheme(),D=useSafeAreaInsets(),v=useMemo(()=>buildStyles(V),[V]),[P,H]=useState(""),M=Dimensions.get("window").height,B=Math.round(.7*M),A=useRef(createAnimatedValue(0)).current,{handleGesture:E,opacity:F}=useDragToDismiss({drag:A,travel:B,onDismiss:t}),z=useMemo(()=>Gesture.Native(),[]),W=useKeyboardState(e=>e.height),N=Math.max(0,Math.round(W)),G=Math.max(D.top,StatusBar.currentHeight??0)+V.space.sm,U=N>0,$=U?Math.max(0,Math.min(B,M-N-G)):B,J=useMemo(()=>{const e=y?P.trim().toLowerCase():"",matches=t=>0===e.length||k(t).toLowerCase().includes(e)||(I(t)??"").toLowerCase().includes(e);if(!i)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return i.forEach((e,o)=>{const s=e.options.filter(matches);if(0!==s.length){t.push({kind:"header",title:e.title});for(const e of s)t.push({kind:"option",option:e,section:o})}}),t},[y,P,s,i,k,I]),K=useCallback(()=>{t()},[t]),Y=useRef(null),Z=useMemo(()=>{const e=new Map;if(!n)return e;let t=0;if(i)for(const[e,o]of J.entries())"header"===o.kind&&(t=e+1);for(const[o,s]of J.entries()){if(o<t||"option"!==s.kind)continue;const i=k(s.option).trim().charAt(0).toUpperCase(),r=/^[A-Z]$/.test(i)?i:"#";e.has(r)||e.set(r,o)}return e},[n,J,i,k]),Q=n&&Z.size>0&&0===P.trim().length,X=useMemo(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Z.has("#")?["#"]:[]],[Z]),q=useCallback(e=>{const t=Z.get(e);void 0!==t&&Y.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Z]),ee=useRef(null),te=useCallback(()=>{null!==ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),oe=useCallback(e=>{Y.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),te(),ee.current=setTimeout(()=>{ee.current=null,Y.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[te]);useEffect(()=>te,[te]);return _jsx(GestureHandlerRootView,{style:v.gestureRoot,children:_jsxs(Animated.View,{testID:_,accessibilityViewIsModal:!0,accessibilityLabel:S??o??a.fallbackName,style:[v.sheet,{maxHeight:$,marginBottom:N,paddingBottom:U?V.space.lg:D.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,...smoothCorners,opacity:F,transform:[{translateY:A}],...V.shadow.modal}],children:[_jsx(GestureDetector,{gesture:E,children:_jsxs(View,{children:[_jsx(View,{style:v.sheetHandleRow,children:_jsx(View,{style:[v.sheetHandle,{backgroundColor:V.colors.border}]})}),o?_jsx(Text,{variant:"title",style:[v.sheetTitle,{paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:o}):null]})}),y?_jsx(View,{style:[v.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:_jsxs(View,{style:[v.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,...smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),_jsx(TextInput,{value:P,onChangeText:H,placeholder:a.searchPlaceholder,placeholderTextColor:V.colors["text-subtle"],selectionColor:f??V.colors["focus-ring"],accessibilityLabel:a.searchOptions,style:[v.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),P.length>0?_jsx(Pressable,{onPress:()=>H(""),hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:a.clearSearch,children:(V.settings.icons.close??defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,_jsxs(View,{style:[v.listWrap,Q?v.listRow:null],children:[_jsx(GestureDetector,{gesture:z,children:_jsx(FlatList,{ref:Y,data:J,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(L(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return _jsx(View,{accessible:!0,accessibilityRole:"header",style:[v.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:r?r(e.title):_jsx(Text,{variant:"caption",weight:"semibold",color:"tertiary",style:v.sectionTitle,children:e.title.toUpperCase()})});const o=e.option,s=k(o),i=L(o),n=I(o),a=R(o),c=(d=i,Array.isArray(b)?b.some(e=>String(e)===String(d)):null!=b&&String(b)===String(d));var d;const p=O(o),u=m?.(o)??!1;return _jsxs(Pressable,{onPress:()=>g(i,o),disabled:p,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{selected:c,disabled:p},"aria-selected":c,"aria-disabled":p,style:({pressed:e})=>[v.optionRow,{backgroundColor:c?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:p?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},T,c?j:null],children:[l?_jsx(View,{style:v.optionTextWrap,children:l({option:o,selected:c,disabled:p,index:t})}):_jsxs(_Fragment,{children:[a?_jsx(View,{style:v.optionIcon,children:a}):null,_jsxs(View,{style:v.optionTextWrap,children:[_jsx(Text,{variant:"body",weight:c?"semibold":"medium",color:u?"danger":c?"brand":void 0,style:[v.optionLabel,w,c?C:null],children:s}),n?_jsx(Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:v.optionDescription,children:n}):null]})]}),x?_jsx(View,{style:[v.checkbox,{borderColor:c?V.colors.primary:V.colors.border,backgroundColor:c?V.colors.primary:"transparent"}],children:c?_jsx(View,{style:v.checkboxTick}):null}):c?"icon"===V.settings.components["option-sheet"]?.selectedMarker?_jsx(View,{style:v.singleSelectedIcon,children:(V.settings.icons.selectedTick??defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):_jsx(View,{style:[v.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:oe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!Q,style:Q?v.listBesideRail:null,ListEmptyComponent:_jsx(Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:V.space.xl},children:a.empty})})}),Q?_jsx(View,{style:[v.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:a.jumpToLetter,testID:"option-sheet-alphabet",children:X.map(e=>{const t=Z.has(e);return _jsx(Pressable,{onPress:()=>q(e),disabled:!t,hitSlop:{left:8,right:8},...hitSlopMarker({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:a.jumpTo(e),accessibilityState:{disabled:!t},"aria-disabled":!t,style:v.railLetter,children:_jsx(Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[v.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),x?_jsx(View,{style:[v.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:_jsx(Pressable,{onPress:K,accessibilityRole:"button",accessibilityLabel:a.done,style:({pressed:e})=>[v.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,...smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:_jsx(Text,{variant:"body",weight:"semibold",style:{color:V.colors["on-primary"]},children:a.done})})}):null]})})}export function OptionSheet(e){const{open:t,onOpenChange:o,onAfterClose:s,labels:i,onClose:r,haptic:l,...n}=e,a=useMemo(()=>({...DEFAULT_OPTION_SHEET_LABELS,...i}),[i]),c=useRef(o);c.current=o;const d=useRef(!1);return useEffect(()=>{d.current!==t&&(d.current=t,c.current?.(t))},[t]),_jsx(Modal,{open:t,onClose:r,presentation:"bottom",onDismissed:s,haptic:l,contentStyle:hostStyle,labels:{close:a.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??a.fallbackName,children:_jsx(OptionSheetPanel,{...n,onClose:r,labels:a})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,...smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});export default OptionSheet;
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Pressable,StatusBar,StyleSheet,TextInput,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture}from"react-native-gesture-handler";import{useKeyboardState}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const SEARCH_ICON_SIZE=18;export const DEFAULT_OPTION_SHEET_LABELS=Object.freeze({searchPlaceholder:"Search…",empty:"No options",done:"Done",closePicker:"Close picker",fallbackName:"Options",searchOptions:"Search options",clearSearch:"Clear search",jumpToLetter:"Jump to letter",jumpTo:e=>`Jump to ${e}`});const selectOptionLabel=e=>e.label,selectOptionValue=e=>e.value,selectOptionDescription=e=>e.description,selectOptionDisabled=e=>!0===e.disabled,selectOptionIcon=e=>e.icon,hostStyle=StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:o,options:s,sections:i,renderSectionHeader:r,renderOption:l,alphabetIndex:n=!1,labels:a,getOptionLabel:c,getOptionValue:d,getOptionDescription:p,isOptionDisabled:u,getOptionIcon:h,destructiveOf:m,value:b,onChange:g,multi:x=!1,searchable:y=!1,searchSelectionColor:f,accessibilityLabel:S,optionStyle:T,selectedOptionStyle:j,optionTextStyle:w,selectedOptionTextStyle:C,testID:_}=e,k=c??selectOptionLabel,L=d??selectOptionValue,I=p??selectOptionDescription,O=u??selectOptionDisabled,R=h??selectOptionIcon,V=useTheme(),D=useSafeAreaInsets(),v=useMemo(()=>buildStyles(V),[V]),[P,H]=useState(""),M=Dimensions.get("window").height,B=Math.round(.7*M),A=useRef(createAnimatedValue(0)).current,{handleGesture:E,opacity:F}=useDragToDismiss({drag:A,travel:B,onDismiss:t}),z=useNativeGesture(),W=useKeyboardState(e=>e.height),N=Math.max(0,Math.round(W)),G=Math.max(D.top,StatusBar.currentHeight??0)+V.space.sm,U=N>0,$=U?Math.max(0,Math.min(B,M-N-G)):B,J=useMemo(()=>{const e=y?P.trim().toLowerCase():"",matches=t=>0===e.length||k(t).toLowerCase().includes(e)||(I(t)??"").toLowerCase().includes(e);if(!i)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return i.forEach((e,o)=>{const s=e.options.filter(matches);if(0!==s.length){t.push({kind:"header",title:e.title});for(const e of s)t.push({kind:"option",option:e,section:o})}}),t},[y,P,s,i,k,I]),K=useCallback(()=>{t()},[t]),Y=useRef(null),Z=useMemo(()=>{const e=new Map;if(!n)return e;let t=0;if(i)for(const[e,o]of J.entries())"header"===o.kind&&(t=e+1);for(const[o,s]of J.entries()){if(o<t||"option"!==s.kind)continue;const i=k(s.option).trim().charAt(0).toUpperCase(),r=/^[A-Z]$/.test(i)?i:"#";e.has(r)||e.set(r,o)}return e},[n,J,i,k]),Q=n&&Z.size>0&&0===P.trim().length,X=useMemo(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Z.has("#")?["#"]:[]],[Z]),q=useCallback(e=>{const t=Z.get(e);void 0!==t&&Y.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Z]),ee=useRef(null),te=useCallback(()=>{null!==ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),oe=useCallback(e=>{Y.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),te(),ee.current=setTimeout(()=>{ee.current=null,Y.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[te]);useEffect(()=>te,[te]);return _jsx(GestureHandlerRootView,{style:v.gestureRoot,children:_jsxs(Animated.View,{testID:_,accessibilityViewIsModal:!0,accessibilityLabel:S??o??a.fallbackName,style:[v.sheet,{maxHeight:$,marginBottom:N,paddingBottom:U?V.space.lg:D.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,...smoothCorners,opacity:F,transform:[{translateY:A}],...V.shadow.modal}],children:[_jsx(GestureDetector,{gesture:E,children:_jsxs(View,{children:[_jsx(View,{style:v.sheetHandleRow,children:_jsx(View,{style:[v.sheetHandle,{backgroundColor:V.colors.border}]})}),o?_jsx(Text,{variant:"title",style:[v.sheetTitle,{paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:o}):null]})}),y?_jsx(View,{style:[v.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:_jsxs(View,{style:[v.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,...smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),_jsx(TextInput,{value:P,onChangeText:H,placeholder:a.searchPlaceholder,placeholderTextColor:V.colors["text-subtle"],selectionColor:f??V.colors["focus-ring"],accessibilityLabel:a.searchOptions,style:[v.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),P.length>0?_jsx(Pressable,{onPress:()=>H(""),hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:a.clearSearch,children:(V.settings.icons.close??defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,_jsxs(View,{style:[v.listWrap,Q?v.listRow:null],children:[_jsx(GestureDetector,{gesture:z,children:_jsx(FlatList,{ref:Y,data:J,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(L(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return _jsx(View,{accessible:!0,accessibilityRole:"header",style:[v.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:r?r(e.title):_jsx(Text,{variant:"caption",weight:"semibold",color:"tertiary",style:v.sectionTitle,children:e.title.toUpperCase()})});const o=e.option,s=k(o),i=L(o),n=I(o),a=R(o),c=(d=i,Array.isArray(b)?b.some(e=>String(e)===String(d)):null!=b&&String(b)===String(d));var d;const p=O(o),u=m?.(o)??!1;return _jsxs(Pressable,{onPress:()=>g(i,o),disabled:p,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{selected:c,disabled:p},"aria-selected":c,"aria-disabled":p,style:({pressed:e})=>[v.optionRow,{backgroundColor:c?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:p?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},T,c?j:null],children:[l?_jsx(View,{style:v.optionTextWrap,children:l({option:o,selected:c,disabled:p,index:t})}):_jsxs(_Fragment,{children:[a?_jsx(View,{style:v.optionIcon,children:a}):null,_jsxs(View,{style:v.optionTextWrap,children:[_jsx(Text,{variant:"body",weight:c?"semibold":"medium",color:u?"danger":c?"brand":void 0,style:[v.optionLabel,w,c?C:null],children:s}),n?_jsx(Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:v.optionDescription,children:n}):null]})]}),x?_jsx(View,{style:[v.checkbox,{borderColor:c?V.colors.primary:V.colors.border,backgroundColor:c?V.colors.primary:"transparent"}],children:c?_jsx(View,{style:v.checkboxTick}):null}):c?"icon"===V.settings.components["option-sheet"]?.selectedMarker?_jsx(View,{style:v.singleSelectedIcon,children:(V.settings.icons.selectedTick??defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):_jsx(View,{style:[v.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:oe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!Q,style:Q?v.listBesideRail:null,ListEmptyComponent:_jsx(Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:V.space.xl},children:a.empty})})}),Q?_jsx(View,{style:[v.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:a.jumpToLetter,testID:"option-sheet-alphabet",children:X.map(e=>{const t=Z.has(e);return _jsx(Pressable,{onPress:()=>q(e),disabled:!t,hitSlop:{left:8,right:8},...hitSlopMarker({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:a.jumpTo(e),accessibilityState:{disabled:!t},"aria-disabled":!t,style:v.railLetter,children:_jsx(Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[v.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),x?_jsx(View,{style:[v.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:_jsx(Pressable,{onPress:K,accessibilityRole:"button",accessibilityLabel:a.done,style:({pressed:e})=>[v.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,...smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:_jsx(Text,{variant:"body",weight:"semibold",style:{color:V.colors["on-primary"]},children:a.done})})}):null]})})}export function OptionSheet(e){const{open:t,onOpenChange:o,onAfterClose:s,labels:i,onClose:r,haptic:l,...n}=e,a=useMemo(()=>({...DEFAULT_OPTION_SHEET_LABELS,...i}),[i]),c=useRef(o);c.current=o;const d=useRef(!1);return useEffect(()=>{d.current!==t&&(d.current=t,c.current?.(t))},[t]),_jsx(Modal,{open:t,onClose:r,presentation:"bottom",onDismissed:s,haptic:l,contentStyle:hostStyle,labels:{close:a.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??a.fallbackName,children:_jsx(OptionSheetPanel,{...n,onClose:r,labels:a})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,...smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});export default OptionSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,Gradient,setNativeValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"});const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=tintOf(e,0,"transparent"),r=tintOf(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=forwardRef((e,t)=>{const r=useTheme(),s=useReducedMotion(),{progress:
|
|
1
|
+
"use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,Gradient,setNativeValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"});const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=tintOf(e,0,"transparent"),r=tintOf(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=forwardRef((e,t)=>{const r=useTheme(),s=useReducedMotion(),{progress:i,label:n,showPercent:a=!1,valueLabel:o,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:m,barColor:g,gradient:p,segments:f,animated:h=!0,style:y,containerStyle:b,barStyle:w,accessibilityLabel:x,labels:R,testID:A}=e;assertValidValue("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const j=useMemo(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...R}),[R]),v=l??"number"!=typeof i,_=clampProgress(i),V=useRef(createAnimatedValue(_)).current,E=useRef(createAnimatedValue(0)).current,O=useRef(createAnimatedValue(0)).current,S=useRef(0),T=useMemo(()=>buildStyles(r),[r]),N=c??r.radius.pill,D=m??r.colors["surface-disabled"],B=g??toneColor(r,d),L=useMemo(()=>{if(null==p)return null;if("string"!=typeof p)return p;const e=r.settings.gradients[p];if(void 0===e){const e=Object.keys(r.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <ProgressBar> received gradient="${p}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}return e},[p,r.settings.gradients]),I=useMemo(()=>glowOf(B),[B]),P=Array.isArray(f)&&f.length>0;useEffect(()=>{v||(h?Animated.timing(V,{toValue:_,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():V.setValue(_))},[h,_,V,v,r]),useEffect(()=>{if(!v)return;setNativeValue(E,0);const e=Animated.loop(Animated.timing(E,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver}));return e.start(),()=>{e.stop()}},[v,E]);const C=V.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),M=E.interpolate({inputRange:[0,1],outputRange:[-1,1]}),k=E.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=a&&!v&&!P,F=null!=n||G||null!=o,$=_jsx(View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:x??("string"==typeof n?n:void 0),accessibilityValue:v?{text:j.loading}:{min:0,max:100,now:Math.round(100*_)},testID:A,onLayout:e=>{const t=e.nativeEvent.layout.width;S.current=t,setNativeValue(O,t)},style:[T.track,{height:u,borderRadius:N,...smoothCorners,backgroundColor:D},b,y],children:P?_jsx(View,{style:[T.segments,{height:u}],children:(f??[]).map((e,t)=>_jsx(View,{style:{width:100*clampProgress(e.value)+"%",height:u,backgroundColor:e.color??toneColor(r,e.tone??"primary")}},t))}):_jsx(Animated.View,v?{style:[T.indeterminateBar,{height:u,width:s?"100%":"30%",opacity:s?k:1,transform:s?[]:[{translateX:Animated.multiply(M,O)}]},w],children:_jsx(Gradient,{gradient:I,style:StyleSheet.absoluteFill})}:{style:[T.determinateBar,{height:u,borderRadius:N,...smoothCorners,backgroundColor:L?"transparent":B,width:C,overflow:L?"hidden":void 0},w],children:L?_jsx(Gradient,{gradient:L,style:StyleSheet.absoluteFill}):null})});return F?_jsxs(View,{style:T.wrapper,children:[_jsxs(View,{style:[T.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof n||"number"==typeof n?_jsx(Text,{variant:"label",color:"primary",style:T.label,children:n}):_jsx(View,{style:T.label,children:n}),null!=o?"string"==typeof o||"number"==typeof o?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:o}):o:G?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*_)}%`}):null]}),$]}):$});ProgressBar.displayName="ProgressBar";const buildStyles=e=>StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});export{ProgressBar};export default ProgressBar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{applyMarkdownAction,normalizeSelection}from"./markdownActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_RICH_TEXT_EDITOR_LABELS=Object.freeze({bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",code:"Inline code",link:"Link",heading1:"Heading 1",heading2:"Heading 2",bulletList:"Bulleted list",numberedList:"Numbered list",quote:"Quote"});const ACTION_GLYPH={bold:"B",italic:"I",strikethrough:"S",code:"</>",link:"link",heading1:"H1",heading2:"H2",bulletList:"•",numberedList:"1.",quote:">"},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5;export const RichTextEditor=forwardRef((e,t)=>{const{value:o,onChangeText:i,placeholder:s,actions:l=DEFAULT_ACTIONS,disabled:r=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:d=!1,accessibilityLabel:c,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),S=useMemo(()=>u?{...DEFAULT_RICH_TEXT_EDITOR_LABELS,...u}:DEFAULT_RICH_TEXT_EDITOR_LABELS,[u]),y=o??"",[_,k]=useState({start:0,end:0}),[f,L]=useState(!1),[I,E]=useState(null),j=useCallback(e=>{k(e.nativeEvent.selection),E(null)},[]),C=useCallback(e=>{E(null),i?.(e)},[i]),H=useCallback(e=>{if(r)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:y,selection:normalizeSelection(_,y.length)},e);k(o.selection),E(o.selection),i?.(o.text)},[r,h,i,_,y]);return n?_jsx(RichTextEditorSkeleton,{actionCount:l.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:f?g.colors["focus-ring"]:g.colors.border,opacity:r?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:l.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:r,onPress:H,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:y,onChangeText:C,onSelectionChange:j,onFocus:()=>L(!0),onBlur:()=>L(!1),selection:I??void 0,editable:!r,autoFocus:d,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:c,style:[T.input,{minHeight:a},p],testID:x?`${x}-input`:void 0})]})});RichTextEditor.displayName="RichTextEditor";const ToolbarButton=({action:e,label:t,disabled:o,onPress:i,styles:s,theme:l,testID:r})=>{const n={color:o?l.colors["text-disabled"]:l.colors["text-body"]
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{applyMarkdownAction,normalizeSelection}from"./markdownActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_RICH_TEXT_EDITOR_LABELS=Object.freeze({bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",code:"Inline code",link:"Link",heading1:"Heading 1",heading2:"Heading 2",bulletList:"Bulleted list",numberedList:"Numbered list",quote:"Quote"});const ACTION_GLYPH={bold:"B",italic:"I",strikethrough:"S",code:"</>",link:"link",heading1:"H1",heading2:"H2",bulletList:"•",numberedList:"1.",quote:">"},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5;export const RichTextEditor=forwardRef((e,t)=>{const{value:o,onChangeText:i,placeholder:s,actions:l=DEFAULT_ACTIONS,disabled:r=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:d=!1,accessibilityLabel:c,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),S=useMemo(()=>u?{...DEFAULT_RICH_TEXT_EDITOR_LABELS,...u}:DEFAULT_RICH_TEXT_EDITOR_LABELS,[u]),y=o??"",[_,k]=useState({start:0,end:0}),[f,L]=useState(!1),[I,E]=useState(null),j=useCallback(e=>{k(e.nativeEvent.selection),E(null)},[]),C=useCallback(e=>{E(null),i?.(e)},[i]),H=useCallback(e=>{if(r)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:y,selection:normalizeSelection(_,y.length)},e);k(o.selection),E(o.selection),i?.(o.text)},[r,h,i,_,y]);return n?_jsx(RichTextEditorSkeleton,{actionCount:l.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:f?g.colors["focus-ring"]:g.colors.border,opacity:r?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:l.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:r,onPress:H,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:y,onChangeText:C,onSelectionChange:j,onFocus:()=>L(!0),onBlur:()=>L(!1),selection:I??void 0,editable:!r,autoFocus:d,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:c,style:[T.input,{minHeight:a},p],testID:x?`${x}-input`:void 0})]})});RichTextEditor.displayName="RichTextEditor";const ToolbarButton=({action:e,label:t,disabled:o,onPress:i,styles:s,theme:l,testID:r})=>{const n={color:o?l.colors["text-disabled"]:l.colors["text-body"],..."bold"===e?{fontWeight:l.weight.bold}:{},..."italic"===e?{fontStyle:"italic"}:{},..."strikethrough"===e?{textDecorationLine:"line-through"}:{}};return _jsx(Pressable,{onPress:()=>i(e),disabled:o,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:o},"aria-disabled":o,hitSlop:4,...hitSlopMarker(4),testID:r,style:({pressed:e})=>[s.button,{backgroundColor:e?l.colors["surface-pressed"]:l.colors["bg-subtle"]}],children:_jsx(Text,{variant:"body",maxFontSizeMultiplier:Math.min(l.settings.maxFontSizeMultiplier??1.5,1.5),style:[s.buttonLabel,n],children:ACTION_GLYPH[e]})})};ToolbarButton.displayName="RichTextEditorToolbarButton";const RichTextEditorSkeleton=({actionCount:e,minHeight:t,style:o,testID:i})=>{const s=useTheme(),l=useMemo(()=>buildStyles(s),[s]),r=Array.from({length:Math.max(1,e)},(e,t)=>t);return _jsxs(View,{testID:i,style:[l.container,o],children:[_jsx(View,{style:l.toolbar,children:r.map(e=>_jsx(Skeleton,{width:34,height:30,radius:"sm"},e))}),_jsxs(View,{style:[l.skeletonBody,{minHeight:t}],children:[_jsx(Skeleton,{shape:"text",width:"94%",height:14}),_jsx(Skeleton,{shape:"text",width:"100%",height:14}),_jsx(Skeleton,{shape:"text",width:"72%",height:14})]})]})};RichTextEditorSkeleton.displayName="RichTextEditorSkeleton";const buildStyles=e=>StyleSheet.create({container:{borderWidth:e.size.border,borderColor:e.colors.border,borderRadius:e.radius.md,...smoothCorners,backgroundColor:e.colors.bg,overflow:"hidden"},toolbar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,padding:e.space.xs,borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors["border-subtle"],backgroundColor:e.colors["bg-subtle"]},button:{minWidth:34,height:30,paddingHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,alignItems:"center",justifyContent:"center"},buttonLabel:{...fontFor(e,"medium"),fontSize:e.text.sm.size},input:{...fontFor(e,"normal"),color:e.colors["text-body"],fontSize:e.text.base.size,lineHeight:1.5*e.text.base.size,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},skeletonBody:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.sm}});export default RichTextEditor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{formatDateTime}from"@webority/mobile-core";import{forwardRef,memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SIGNATURE_PAD_LABELS=Object.freeze({pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first.",expand:"Expand",done:"Done",close:"Close"});const STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,EXPANDED_CHROME=200,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:a,fontFamily:r,width:o,height:i})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:i*BASELINE_RATIO,fontSize:typedFontSize(o,n),fontFamily:r,textAnchor:"middle",fill:a,children:n}):null,SignaturePadSurface=forwardRef((e,t)=>{const{expandable:n,initialStrokes:a,onChange:r,initialTypedName:o="",onTypedNameChange:i,defaultMode:s="draw",onModeChange:l,onEmptyChange:d,allowTyped:c=!0,signedBy:u,signedAt:p,height:m=DEFAULT_HEIGHT,maxNameLength:h=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x="selection",disabled:T=!1,style:w,testID:b}=e;assertValidValue("SignaturePad","defaultMode",e.defaultMode,["draw","type"]);const _=useTheme(),E=void 0===g&&void 0===y,A=E?_.colors["text-body"]:g??lightTheme.colors["text-body"],C=E?_.colors.surface:y??lightTheme.colors.surface,v=E?lightTheme.colors["text-body"]:A,R=E?lightTheme.colors.surface:C,I=v!==A||R!==C,j=f??defaultScriptFont(),P=useMemo(()=>({...DEFAULT_SIGNATURE_PAD_LABELS,...S}),[S]),D=useScreenReader(),k=useRef(null),L=useRef(null),[F,M]=useState(0),[G,N]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),B=useRef(G),O=useRef(G.length),H=useRef(null),V=useRef(null),[Y,$]=useState(c?s:"draw"),[z,U]=useState(o),[W,K]=useState(null),X=useRef(!1),{height:q}=useWindowDimensions(),[J,Q]=useState(!1),[Z,ee]=useState([]),te=useRef({onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d});useEffect(()=>{te.current={onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d}});const ne="draw"===Y&&!T,ae="draw"===Y?0===G.length:0===z.trim().length,re=useRef(null);useEffect(()=>{re.current!==ae&&(re.current=ae,te.current.onEmptyChange?.(ae))},[ae]);const oe=useCallback(e=>{B.current=e,N(e)},[]),ie=useCallback(()=>{K(Date.now()),te.current.onChange?.(B.current.map(e=>e.points))},[]),se=useMemo(()=>{const pan=e=>Gesture.Pan().enabled(ne).runOnJS(!0).onBegin(e=>{H.current=pointOf(e.x,e.y)}).onStart(t=>{V.current=e,O.current+=1;const n=pointOf(t.x,t.y);oe([...B.current,{id:O.current,points:[H.current??n,n]}])}).onUpdate(t=>{if(V.current!==e)return;const n=B.current[B.current.length-1];if(void 0===n)throw new Error("The stroke being drawn is missing.");const a=pointOf(t.x,t.y),r=n.points[n.points.length-1];if(void 0===r)throw new Error("A drawn stroke has no points.");distanceBetween(r,a)<.8||oe([...B.current.slice(0,-1),{...n,points:[...n.points,a]}])}).onFinalize(()=>{V.current===e&&(V.current=null,ie())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return Gesture.Race(e,t)},[ne,oe,ie]),le=useCallback(e=>{$(e),te.current.onModeChange?.(e),announce("type"===e?P.typingAnnouncement:P.drawingAnnouncement)},[P.typingAnnouncement,P.drawingAnnouncement]);useEffect(()=>{D&&c&&!X.current&&"draw"===Y&&0===B.current.length&&le("type")},[D,c,Y,le]);const de=useCallback(()=>{X.current=!0,le("draw"===Y?"type":"draw")},[Y,le]),ce=useCallback(e=>{U(e),K(Date.now()),te.current.onTypedNameChange?.(e)},[]),ue=useCallback(()=>{"type"===Y?ce(""):(oe([]),ie()),announce(P.clearedAnnouncement)},[Y,ce,oe,ie,P.clearedAnnouncement]),pe=useCallback(()=>{"draw"===Y&&0!==B.current.length&&(oe(B.current.slice(0,-1)),ie(),announce(P.undoneAnnouncement))},[Y,oe,ie,P.undoneAnnouncement]),me=useCallback(()=>{ee(B.current.map(e=>e.points)),Q(!0)},[]),he=useCallback(()=>{Q(!1)},[]),ge=useCallback(()=>{oe(Z.map(e=>(O.current+=1,{id:O.current,points:[...e]}))),ie(),Q(!1)},[Z,oe,ie]),ye=F||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(ae)return void t(new Error(P.emptyError));const n=I?L.current:k.current;if(!n)return void t(new Error("The signature pad is not on screen."));const a=Math.min(3,Math.max(1,PixelRatio.get()));n.toDataURL(n=>{try{e(writePng(n))}catch(e){t(e)}},{width:ye*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:ye,height:m,mode:Y,strokes:G.map(e=>e.points),typedName:z,ink:v,paper:R,strokeWidth:2.5,fontFamily:cssFontStack(j)}),clear:ue,undo:pe,isEmpty:()=>ae}),[ae,P.emptyError,ye,m,Y,G,z,I,v,R,j,ue,pe]);const fe=useMemo(()=>[{name:"undo",label:P.undo},{name:"clear",label:P.clear},...c?[{name:"toggleMode",label:"draw"===Y?P.typeInstead:P.drawInstead}]:[]],[P.undo,P.clear,P.typeInstead,P.drawInstead,c,Y]),Se=useCallback(e=>{if(T)return;const{actionName:t}=e.nativeEvent;"undo"===t?pe():"clear"===t?ue():"toggleMode"===t&&c&&de()},[T,pe,ue,de,c]),xe=useCallback(e=>{M(e.nativeEvent.layout.width)},[]),Te=useMemo(()=>StyleSheet.create({root:{gap:_.space.sm},pad:{height:m,borderWidth:_.size.border,borderColor:_.colors.border,borderRadius:_.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:C,opacity:T?.5:1},baseline:{position:"absolute",left:_.space.md,right:_.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:_.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:_.space.xs},expandedRoot:{flex:1,padding:_.space.md,gap:_.space.sm,backgroundColor:_.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[_,m,C,A,T]),we=z.trim(),be=p??W,Ee=u&&!ae?`Signed by ${u}${be?`, ${formatDateTime(be)}`:""}`:null,Ae="type"===Y&&we?`${P.pad}. ${we}`:P.pad;return _jsxs(View,{style:[Te.root,w],testID:b,children:[_jsx(GestureDetector,{gesture:se,children:_jsxs(View,{style:Te.pad,onLayout:xe,accessible:!0,accessibilityRole:"image",accessibilityLabel:Ae,accessibilityHint:"draw"===Y?P.padHint:void 0,accessibilityValue:{text:ae?P.empty:P.signed},accessibilityState:{disabled:T},"aria-disabled":T,accessibilityActions:fe,onAccessibilityAction:Se,children:[I?_jsxs(Svg,{ref:L,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:R}),_jsx(Marks,{mode:Y,strokes:G,name:we,color:v,fontFamily:j,width:ye,height:m})]}):null,_jsxs(Svg,{ref:k,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:C}),_jsx(Marks,{mode:Y,strokes:G,name:we,color:A,fontFamily:j,width:ye,height:m})]}),_jsx(View,{pointerEvents:"none",style:Te.baseline})]})}),"type"===Y?_jsx(Input,{label:P.typedLabel,placeholder:P.typedPlaceholder,value:z,onChangeText:ce,maxLength:h,disabled:T,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:b?`${b}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===Y?P.caption:P.typedCaption}),_jsxs(View,{style:Te.actions,children:[c?_jsx(Button,{label:"draw"===Y?P.typeInstead:P.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:de,testID:b?`${b}-mode`:void 0}):_jsx(View,{}),"draw"===Y?_jsxs(View,{style:Te.trailing,children:[G.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:P.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:pe,testID:b?`${b}-undo`:void 0}),_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:b?`${b}-clear`:void 0})]}):null,n?_jsx(Button,{label:P.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:me,testID:b?`${b}-expand`:void 0}):null]}):null,"type"===Y&&we?_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:b?`${b}-clear`:void 0}):null]}),Ee?_jsx(Text,{variant:"caption",color:"secondary",children:Ee}):null,n?_jsx(Modal,{visible:J,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:he,children:_jsxs(ExpandedRoot,{style:Te.expandedRoot,children:[_jsxs(View,{style:Te.expandedBar,children:[_jsx(Button,{label:P.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:he,testID:b?`${b}-close`:void 0}),_jsx(Button,{label:P.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:ge,testID:b?`${b}-done`:void 0})]}),J?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:Z,onChange:ee,height:Math.max(DEFAULT_HEIGHT,q-200),inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x,testID:b?`${b}-expanded`:void 0}):null]})}):null]})});SignaturePadSurface.displayName="SignaturePadSurface";const ExpandedRoot="android"===Platform.OS?GestureHandlerRootView:View,SignaturePad=forwardRef((e,t)=>_jsx(SignaturePadSurface,{...e,expandable:!0,ref:t}));SignaturePad.displayName="SignaturePad";export{SignaturePad};export default SignaturePad;
|
|
1
|
+
"use strict";import{formatDateTime}from"@webority/mobile-core";import{forwardRef,memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useCompetingGestures,usePanGesture}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SIGNATURE_PAD_LABELS=Object.freeze({pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first.",expand:"Expand",done:"Done",close:"Close"});const STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,EXPANDED_CHROME=200,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:a,fontFamily:r,width:o,height:s})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:s*BASELINE_RATIO,fontSize:typedFontSize(o,n),fontFamily:r,textAnchor:"middle",fill:a,children:n}):null,SignaturePadSurface=forwardRef((e,t)=>{const{expandable:n,initialStrokes:a,onChange:r,initialTypedName:o="",onTypedNameChange:s,defaultMode:i="draw",onModeChange:l,onEmptyChange:d,allowTyped:u=!0,signedBy:c,signedAt:p,height:m=DEFAULT_HEIGHT,maxNameLength:h=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x="selection",disabled:w=!1,style:T,testID:b}=e;assertValidValue("SignaturePad","defaultMode",e.defaultMode,["draw","type"]);const _=useTheme(),E=void 0===g&&void 0===y,A=E?_.colors["text-body"]:g??lightTheme.colors["text-body"],C=E?_.colors.surface:y??lightTheme.colors.surface,v=E?lightTheme.colors["text-body"]:A,R=E?lightTheme.colors.surface:C,I=v!==A||R!==C,j=f??defaultScriptFont(),P=useMemo(()=>({...DEFAULT_SIGNATURE_PAD_LABELS,...S}),[S]),D=useScreenReader(),k=useRef(null),L=useRef(null),[F,M]=useState(0),[G,N]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),B=useRef(G),O=useRef(G.length),H=useRef(null),V=useRef(null),[Y,$]=useState(u?i:"draw"),[z,U]=useState(o),[W,K]=useState(null),X=useRef(!1),{height:q}=useWindowDimensions(),[J,Q]=useState(!1),[Z,ee]=useState([]),te=useRef({onChange:r,onTypedNameChange:s,onModeChange:l,onEmptyChange:d});useEffect(()=>{te.current={onChange:r,onTypedNameChange:s,onModeChange:l,onEmptyChange:d}});const ne="draw"===Y&&!w,ae="draw"===Y?0===G.length:0===z.trim().length,re=useRef(null);useEffect(()=>{re.current!==ae&&(re.current=ae,te.current.onEmptyChange?.(ae))},[ae]);const oe=useCallback(e=>{B.current=e,N(e)},[]),se=useCallback(()=>{K(Date.now()),te.current.onChange?.(B.current.map(e=>e.points))},[]),ie=useMemo(()=>{const pan=e=>({enabled:ne,runOnJS:!0,onBegin:e=>{H.current=pointOf(e.x,e.y)},onActivate:t=>{V.current=e,O.current+=1;const n=pointOf(t.x,t.y);oe([...B.current,{id:O.current,points:[H.current??n,n]}])},onUpdate:t=>{if(V.current!==e)return;const n=B.current[B.current.length-1];if(void 0===n)throw new Error("The stroke being drawn is missing.");const a=pointOf(t.x,t.y),r=n.points[n.points.length-1];if(void 0===r)throw new Error("A drawn stroke has no points.");distanceBetween(r,a)<.8||oe([...B.current.slice(0,-1),{...n,points:[...n.points,a]}])},onFinalize:()=>{V.current===e&&(V.current=null,se())}});return{sidewaysConfig:{...pan("sideways"),activeOffsetX:[-6,6],failOffsetY:[-8,8]},restedConfig:{...pan("rested"),activateAfterLongPress:200}}},[ne,oe,se]),le=usePanGesture(ie.sidewaysConfig),de=usePanGesture(ie.restedConfig),ue=useCompetingGestures(le,de),ce=useCallback(e=>{$(e),te.current.onModeChange?.(e),announce("type"===e?P.typingAnnouncement:P.drawingAnnouncement)},[P.typingAnnouncement,P.drawingAnnouncement]);useEffect(()=>{D&&u&&!X.current&&"draw"===Y&&0===B.current.length&&ce("type")},[D,u,Y,ce]);const pe=useCallback(()=>{X.current=!0,ce("draw"===Y?"type":"draw")},[Y,ce]),me=useCallback(e=>{U(e),K(Date.now()),te.current.onTypedNameChange?.(e)},[]),he=useCallback(()=>{"type"===Y?me(""):(oe([]),se()),announce(P.clearedAnnouncement)},[Y,me,oe,se,P.clearedAnnouncement]),ge=useCallback(()=>{"draw"===Y&&0!==B.current.length&&(oe(B.current.slice(0,-1)),se(),announce(P.undoneAnnouncement))},[Y,oe,se,P.undoneAnnouncement]),ye=useCallback(()=>{ee(B.current.map(e=>e.points)),Q(!0)},[]),fe=useCallback(()=>{Q(!1)},[]),Se=useCallback(()=>{oe(Z.map(e=>(O.current+=1,{id:O.current,points:[...e]}))),se(),Q(!1)},[Z,oe,se]),xe=F||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(ae)return void t(new Error(P.emptyError));const n=I?L.current:k.current;if(!n)return void t(new Error("The signature pad is not on screen."));const a=Math.min(3,Math.max(1,PixelRatio.get()));n.toDataURL(n=>{writePng(n).then(e,t)},{width:xe*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:xe,height:m,mode:Y,strokes:G.map(e=>e.points),typedName:z,ink:v,paper:R,strokeWidth:2.5,fontFamily:cssFontStack(j)}),clear:he,undo:ge,isEmpty:()=>ae}),[ae,P.emptyError,xe,m,Y,G,z,I,v,R,j,he,ge]);const we=useMemo(()=>[{name:"undo",label:P.undo},{name:"clear",label:P.clear},...u?[{name:"toggleMode",label:"draw"===Y?P.typeInstead:P.drawInstead}]:[]],[P.undo,P.clear,P.typeInstead,P.drawInstead,u,Y]),Te=useCallback(e=>{if(w)return;const{actionName:t}=e.nativeEvent;"undo"===t?ge():"clear"===t?he():"toggleMode"===t&&u&&pe()},[w,ge,he,pe,u]),be=useCallback(e=>{M(e.nativeEvent.layout.width)},[]),Ee=useMemo(()=>StyleSheet.create({root:{gap:_.space.sm},pad:{height:m,borderWidth:_.size.border,borderColor:_.colors.border,borderRadius:_.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:C,opacity:w?.5:1},baseline:{position:"absolute",left:_.space.md,right:_.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:_.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:_.space.xs},expandedRoot:{flex:1,padding:_.space.md,gap:_.space.sm,backgroundColor:_.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[_,m,C,A,w]),Ae=z.trim(),Ce=p??W,ve=c&&!ae?`Signed by ${c}${Ce?`, ${formatDateTime(Ce)}`:""}`:null,Re="type"===Y&&Ae?`${P.pad}. ${Ae}`:P.pad;return _jsxs(View,{style:[Ee.root,T],testID:b,children:[_jsx(GestureDetector,{gesture:ue,children:_jsxs(View,{style:Ee.pad,onLayout:be,accessible:!0,accessibilityRole:"image",accessibilityLabel:Re,accessibilityHint:"draw"===Y?P.padHint:void 0,accessibilityValue:{text:ae?P.empty:P.signed},accessibilityState:{disabled:w},"aria-disabled":w,accessibilityActions:we,onAccessibilityAction:Te,children:[I?_jsxs(Svg,{ref:L,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:R}),_jsx(Marks,{mode:Y,strokes:G,name:Ae,color:v,fontFamily:j,width:xe,height:m})]}):null,_jsxs(Svg,{ref:k,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:C}),_jsx(Marks,{mode:Y,strokes:G,name:Ae,color:A,fontFamily:j,width:xe,height:m})]}),_jsx(View,{pointerEvents:"none",style:Ee.baseline})]})}),"type"===Y?_jsx(Input,{label:P.typedLabel,placeholder:P.typedPlaceholder,value:z,onChangeText:me,maxLength:h,disabled:w,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:b?`${b}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===Y?P.caption:P.typedCaption}),_jsxs(View,{style:Ee.actions,children:[u?_jsx(Button,{label:"draw"===Y?P.typeInstead:P.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:w,onPress:pe,testID:b?`${b}-mode`:void 0}):_jsx(View,{}),"draw"===Y?_jsxs(View,{style:Ee.trailing,children:[G.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:P.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:w,onPress:ge,testID:b?`${b}-undo`:void 0}),_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:w,onPress:he,testID:b?`${b}-clear`:void 0})]}):null,n?_jsx(Button,{label:P.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:w,onPress:ye,testID:b?`${b}-expand`:void 0}):null]}):null,"type"===Y&&Ae?_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:w,onPress:he,testID:b?`${b}-clear`:void 0}):null]}),ve?_jsx(Text,{variant:"caption",color:"secondary",children:ve}):null,n?_jsx(Modal,{visible:J,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:fe,children:_jsxs(ExpandedRoot,{style:Ee.expandedRoot,children:[_jsxs(View,{style:Ee.expandedBar,children:[_jsx(Button,{label:P.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:fe,testID:b?`${b}-close`:void 0}),_jsx(Button,{label:P.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:Se,testID:b?`${b}-done`:void 0})]}),J?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:Z,onChange:ee,height:Math.max(DEFAULT_HEIGHT,q-200),inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x,testID:b?`${b}-expanded`:void 0}):null]})}):null]})});SignaturePadSurface.displayName="SignaturePadSurface";const ExpandedRoot="android"===Platform.OS?GestureHandlerRootView:View,SignaturePad=forwardRef((e,t)=>_jsx(SignaturePadSurface,{...e,expandable:!0,ref:t}));SignaturePad.displayName="SignaturePad";export{SignaturePad};export default SignaturePad;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const writePng=e=>{const{File:t,Paths:r}=require("expo-file-system"),i=new t(r.cache,`signature-${Date.now().toString(36)}.png`);return i.create({intermediates:!0,overwrite:!0}),i.write(e,{encoding:"base64"}),i.uri};
|
|
1
|
+
"use strict";export const writePng=async e=>{const{File:t,Paths:r}=require("expo-file-system"),i=new t(r.cache,`signature-${Date.now().toString(36)}.png`);return i.create({intermediates:!0,overwrite:!0}),await i.write(e,{encoding:"base64"}),i.uri};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const writePng=t=>`data:image/png;base64,${t}`;
|
|
1
|
+
"use strict";export const writePng=async t=>`data:image/png;base64,${t}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{
|
|
1
|
+
"use strict";import React,{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SLIDE_TO_CONFIRM_LABELS=Object.freeze({slide:"Slide to confirm",confirmed:"Confirmed",confirmAction:"Confirm"});const SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>_jsx(View,{style:{width:0,height:0,borderTopWidth:.4*t,borderBottomWidth:.4*t,borderLeftWidth:.55*t,borderTopColor:"transparent",borderBottomColor:"transparent",borderLeftColor:e,marginLeft:.2*t}}),SlideToConfirm=forwardRef((e,t)=>{const{onConfirm:i,label:a,tone:r="primary",size:o="md",disabled:s=!1,threshold:n=.9,resetAfter:l=!1,haptic:c,icon:u,labels:d,style:m,trackStyle:h,handleStyle:f,labelStyle:p,testID:b}=e;assertValidValue("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SlideToConfirm","size",e.size,["sm","md","lg"]);const g=useMemo(()=>({...DEFAULT_SLIDE_TO_CONFIRM_LABELS,...d}),[d]),S=useMemo(()=>[{name:"activate",label:g.confirmAction},{name:"increment",label:g.confirmAction}],[g.confirmAction]),v=useTheme(),y=SIZE_MAP[o],C=v.space[y.pad],x=y.height-2*C,A=useMemo(()=>buildStyles(v,y),[v,y]),w=v.colors[r],[T,j]=useState(!1),_=useSharedValue(0),V=useSharedValue(0),E=useSharedValue(0),k=useRef(null),L=useCallback(()=>{const e=resolveHaptic(c,"notificationSuccess");e&&triggerHaptic(e)},[c]),M=useCallback(()=>{j(!1),_.value=withSpring(0,{damping:18,stiffness:160,mass:1})},[_]),R=useCallback(()=>{j(!0),L(),i(),!1!==l&&(k.current&&clearTimeout(k.current),k.current=setTimeout(M,l))},[L,i,l,M]),D=useCallback(e=>{if(s||T)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||R()},[s,T,R]);React.useEffect(()=>()=>{cancelAnimation(_),k.current&&clearTimeout(k.current)},[_]);const I=useCallback(e=>{V.value=Math.max(0,e.nativeEvent.layout.width-x-2*C)},[V,x,C]),O=useMemo(()=>{const e=n,t={damping:18,stiffness:160,mass:1},i={duration:v.motion.duration.fast,easing:Easing.out(Easing.cubic)};return{enabled:!s&&!T,minDistance:0,onActivate:()=>{"worklet";E.value=_.value},onUpdate:e=>{"worklet";_.value=Math.min(Math.max(E.value+e.translationX,0),V.value)},onDeactivate:()=>{"worklet";V.value>0&&_.value>=V.value*e?(_.value=withTiming(V.value,i),runOnJS(R)()):_.value=withSpring(0,t)}}},[s,T,n,_,V,E,R,v.motion.duration.fast]),z=usePanGesture(O),F=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),P=useAnimatedStyle(()=>({width:_.value+x+C}),[_,x,C]),W=useAnimatedStyle(()=>{const e=V.value>0?V.value:1;return{opacity:Math.max(0,1-_.value/(.6*e))}},[V,_]);return _jsxs(View,{ref:t,style:[A.track,{backgroundColor:v.colors["bg-subtle"]},h,m],onLayout:I,testID:b,accessibilityRole:"adjustable",accessibilityLabel:T?g.confirmed:a??g.slide,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityActions:S,onAccessibilityAction:D,children:[_jsx(Animated.View,{style:[A.fill,{backgroundColor:w,opacity:s?.5:1},P],pointerEvents:"none"}),_jsx(Animated.View,{style:[A.labelWrap,W],pointerEvents:"none",children:_jsx(Text,{variant:"body",style:[A.label,{color:v.colors["text-muted"]},p],numberOfLines:1,children:T?g.confirmed:a??g.slide})}),_jsx(GestureDetector,{gesture:z,children:_jsx(Animated.View,{style:[A.handle,{width:x,height:x,borderRadius:v.radius.pill,...smoothCorners,backgroundColor:v.colors.surface,opacity:s?.5:1,...v.shadow.card},f,F],children:u??_jsx(Chevron,{color:w,size:.5*x})})})]})});SlideToConfirm.displayName="SlideToConfirm";const buildStyles=(e,t)=>StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,...smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,...smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});export{SlideToConfirm};export default SlideToConfirm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Platform,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useControllableState}from"../../hooks/index.js";import{resolveSliderSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{sliderToneInk}from"./valueText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,s=String(i).split(".")[1]?.length??0,n=s>0?Number(r.toFixed(s)):r;return clamp(n,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=forwardRef((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:s=!1,tone:n="primary",size:o="md",variant:l="default",showLabel:u=!1,snapThumb:c=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:p,containerStyle:f,trackStyle:g,fillStyle:v,thumbStyle:w,labelStyle:y,thumbPressScale:S,labelShowDuration:k,labelOpacity:C,testID:x}=e;assertValidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",e.size,["sm","md","lg"]),assertValidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const V=useTheme(),A=useMemo(()=>{const e=resolveSliderSize(V,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[V,o]),j=useMemo(()=>"default"===l?A:VARIANT_SIZE_MAP[l][o],[A,o,l]),M="inset"===l?j.trackHeight/2:0,_=V.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,H=k??V.motion.duration.fast,E=C??1,O=useMemo(()=>buildStyles(V,j),[V,j]),T=useMemo(()=>({damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass}),[V.motion.spring.snappy]),[R,I]=useState(0),W=V.colors[n],L=sliderToneInk(V,n),N=!0===e.range,[P,X]=useControllableState({value:e.value,defaultValue:e.defaultValue??(N?[a,i]:a),onChange:e.onChange}),B=useSharedValue(0),F=useSharedValue(0),z=useSharedValue(N?P[0]:P),G=useSharedValue(N?P[1]:P),J=useSharedValue(0),U=useSharedValue(0),Z=useSharedValue(1),$=useSharedValue(1),q="always"===u,K=useSharedValue(q?1:0),Q=useSharedValue(q?1:0),Y=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(B),cancelAnimation(F),cancelAnimation(Z),cancelAnimation($),cancelAnimation(K),cancelAnimation(Q)},[B,F,Z,$,K,Q]);const ee=useCallback((e,t)=>{const r=t-2*M;return i===a||r<=0?M:M+(e-a)/(i-a)*r},[a,i,M]),te=useCallback((e,t)=>{const s=t-2*M;if(s<=0)return a;const n=clamp((e-M)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,M]),ae=useRef(!1),ie=V.motion.duration.fast,re=useRef(P);re.current=P;const se=useRef(R);se.current=R;const ne=useCallback((e=!1)=>{const t=se.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:ie,easing:Easing.out(Easing.cubic)}):t,a=re.current;if(N){const[e,i]=a,r=Math.min(e,i),s=Math.max(e,i);z.value=r,G.value=s,B.value=place(ee(r,t)),F.value=place(ee(s,t))}else{const e=a;z.value=e,G.value=e,B.value=place(ee(e,t))}},[N,ee,z,G,B,F,ie]),[oe,le]=useState(0),ue=useRef(!1),ce=useCallback(e=>{ae.current=e,e||(ue.current=!0,le(e=>e+1))},[]);useEffect(()=>{if(ae.current)return;const e=ue.current;ue.current=!1,ne(e)},[JSON.stringify(P),R,oe,ne]);const de=useCallback(e=>{const t=e.nativeEvent.layout.width;U.value=t,I(t)},[U]),me=useCallback((e,t)=>{X(N?[e,t]:e)},[N,X]),he=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),be=useRef(me);be.current=me;const pe=useRef(he);pe.current=he;const fe=useCallback((e,t)=>be.current(e,t),[]),ge=useCallback(()=>pe.current(),[]),ve=Math.max(0,(44-j.thumbDiameter)/2),we=ve>0?ve:void 0,ye=useCallback(e=>{const t="low"===e?B:F,n="low"===e?z:G,o="low"===e?G:z,l="low"===e?Z:$,d="low"===e?K:Q,m="low"===e,h=a,b=i,p=r,f=Y,g=N,v=D,w=_,y=!0===u,S=c,k=E,C=H,x=T,V=M,follow=e=>{"worklet";const a=U.value-2*V;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(J.value+e,V),U.value-V);let r=h+(i-V)/a*(b-h);p>0&&(r=Math.round((r-h)/p)*p+h,r=Math.round(r*f)/f),r=Math.min(Math.max(r,h),b),g&&(m&&r>o.value&&(r=o.value),!m&&r<o.value&&(r=o.value)),t.value=S||b===h?b===h?V:V+(r-h)/(b-h)*a:g?m?Math.min(i,F.value):Math.max(i,B.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||runOnJS(ge)(),runOnJS(fe)(z.value,G.value))},A=Gesture.Pan().enabled(!s).minDistance(0);return(void 0===we?A:A.hitSlop(we)).onStart(()=>{"worklet";runOnJS(ce)(!0),J.value=t.value,w&&(l.value=withSpring(v,x)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),runOnJS(ge)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,x)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))}).onFinalize(()=>{"worklet";runOnJS(ce)(!1)})},[s,a,i,r,Y,N,D,_,u,c,E,H,T,M,we,fe,ge,ce,B,F,z,G,Z,$,K,Q,J,U]),Se=useMemo(()=>ye("low"),[ye]),ke=useMemo(()=>ye("high"),[ye]),Ce=useCallback(e=>{if(s||N||R<=0)return;const t=clamp(e.nativeEvent.locationX,0,R),a=te(t,R);a!==z.value&&(he(),z.value=a,B.value=withTiming(ee(a,R),{duration:V.motion.duration.fast,easing:Easing.out(Easing.cubic)}),me(a,a))},[s,N,R,te,ee,me,he,B,z,V.motion.duration.fast]),xe=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*Y)/Y:t;if(N){const e=Math.round((z.value+n)*Y)/Y,t=clamp(e,a,G.value);t!==z.value&&(z.value=t,B.value=ee(t,R),he(),me(t,G.value))}else{const e=Math.round((z.value+n)*Y)/Y,t=clamp(e,a,i);t!==z.value&&(z.value=t,B.value=ee(t,R),he(),me(t,t))}},[s,r,Y,N,a,i,ee,R,B,z,G,me,he]),Ve=j.thumbDiameter/2,Ae=s?V.colors["surface-disabled"]:W,je="inset"===l?{backgroundColor:Ae,borderColor:V.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Ae,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:V.colors.surface,borderColor:Ae},Me=useAnimatedStyle(()=>{const e=U.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=s?.55:1;if(N){const a=Math.max(0,F.value-B.value+2*M);return{opacity:t,transform:[{translateX:B.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:B.value+M-e},{scaleX:1}]}},[U,s,N,F,B,M]),De=useAnimatedStyle(()=>({transform:[{translateX:B.value-Ve},{scale:Z.value}]}),[B,Ve,Z]),He=useAnimatedStyle(()=>({transform:[{translateX:F.value-Ve},{scale:$.value}]}),[F,Ve,$]),Ee=useAnimatedStyle(()=>({opacity:K.value}),[K]),Oe=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),clampDisplay=e=>clamp(e,a,i),Te=clampDisplay(N?Math.min(...P):P),Re=clampDisplay(N?Math.max(...P):P);return _jsx(View,{ref:t,style:[O.container,f,p],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:N?{min:a,max:i,now:Te,text:`${Te} to ${Re}`}:{min:a,max:i,now:Te},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:xe,children:_jsx(Pressable,{onPress:Ce,disabled:s||N,style:O.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:O.trackWrap,onLayout:de,children:[_jsxs(View,{style:O.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[O.track,{backgroundColor:s?V.colors["surface-disabled"]:V.colors.border},g]}),_jsx(Animated.View,{style:[O.fill,{backgroundColor:s?V.colors["surface-disabled"]:W},v,Me]})]}),_jsx(GestureDetector,{gesture:Se,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Ve,...smoothCorners,opacity:s?.55:1},je,w,De],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Ee],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Te):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:L},y],numberOfLines:1,children:d(Te)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}),N?_jsx(GestureDetector,{gesture:ke,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Ve,...smoothCorners,opacity:s?.55:1},je,w,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Oe],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Re):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:L},y],numberOfLines:1,children:d(Re)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,...smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,...smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,...smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,...smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,...smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",...Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};export{Slider};export default Slider;
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Platform,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useControllableState}from"../../hooks/index.js";import{resolveSliderSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{sliderToneInk}from"./valueText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,s=String(i).split(".")[1]?.length??0,n=s>0?Number(r.toFixed(s)):r;return clamp(n,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=forwardRef((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:s=!1,tone:n="primary",size:o="md",variant:l="default",showLabel:u=!1,snapThumb:c=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:p,containerStyle:f,trackStyle:g,fillStyle:v,thumbStyle:w,labelStyle:y,thumbPressScale:S,labelShowDuration:k,labelOpacity:C,testID:x}=e;assertValidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",e.size,["sm","md","lg"]),assertValidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const V=useTheme(),A=useMemo(()=>{const e=resolveSliderSize(V,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[V,o]),j=useMemo(()=>"default"===l?A:VARIANT_SIZE_MAP[l][o],[A,o,l]),M="inset"===l?j.trackHeight/2:0,_=V.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,H=k??V.motion.duration.fast,E=C??1,O=useMemo(()=>buildStyles(V,j),[V,j]),T=useMemo(()=>({damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass}),[V.motion.spring.snappy]),[R,I]=useState(0),W=V.colors[n],P=sliderToneInk(V,n),L=!0===e.range,[N,X]=useControllableState({value:e.value,defaultValue:e.defaultValue??(L?[a,i]:a),onChange:e.onChange}),B=useSharedValue(0),F=useSharedValue(0),G=useSharedValue(L?N[0]:N),z=useSharedValue(L?N[1]:N),J=useSharedValue(0),U=useSharedValue(0),Z=useSharedValue(1),$=useSharedValue(1),q="always"===u,K=useSharedValue(q?1:0),Q=useSharedValue(q?1:0),Y=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(B),cancelAnimation(F),cancelAnimation(Z),cancelAnimation($),cancelAnimation(K),cancelAnimation(Q)},[B,F,Z,$,K,Q]);const ee=useCallback((e,t)=>{const r=t-2*M;return i===a||r<=0?M:M+(e-a)/(i-a)*r},[a,i,M]),te=useCallback((e,t)=>{const s=t-2*M;if(s<=0)return a;const n=clamp((e-M)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,M]),ae=useRef(!1),ie=V.motion.duration.fast,re=useRef(N);re.current=N;const se=useRef(R);se.current=R;const ne=useCallback((e=!1)=>{const t=se.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:ie,easing:Easing.out(Easing.cubic)}):t,a=re.current;if(L){const[e,i]=a,r=Math.min(e,i),s=Math.max(e,i);G.value=r,z.value=s,B.value=place(ee(r,t)),F.value=place(ee(s,t))}else{const e=a;G.value=e,z.value=e,B.value=place(ee(e,t))}},[L,ee,G,z,B,F,ie]),[oe,le]=useState(0),ue=useRef(!1),ce=useCallback(e=>{ae.current=e,e||(ue.current=!0,le(e=>e+1))},[]);useEffect(()=>{if(ae.current)return;const e=ue.current;ue.current=!1,ne(e)},[JSON.stringify(N),R,oe,ne]);const de=useCallback(e=>{const t=e.nativeEvent.layout.width;U.value=t,I(t)},[U]),me=useCallback((e,t)=>{X(L?[e,t]:e)},[L,X]),he=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),be=useRef(me);be.current=me;const pe=useRef(he);pe.current=he;const fe=useCallback((e,t)=>be.current(e,t),[]),ge=useCallback(()=>pe.current(),[]),ve=Math.max(0,(44-j.thumbDiameter)/2),we=ve>0?ve:void 0,ye=useCallback(e=>{const t="low"===e?B:F,n="low"===e?G:z,o="low"===e?z:G,l="low"===e?Z:$,d="low"===e?K:Q,m="low"===e,h=a,b=i,p=r,f=Y,g=L,v=D,w=_,y=!0===u,S=c,k=E,C=H,x=T,V=M,follow=e=>{"worklet";const a=U.value-2*V;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(J.value+e,V),U.value-V);let r=h+(i-V)/a*(b-h);p>0&&(r=Math.round((r-h)/p)*p+h,r=Math.round(r*f)/f),r=Math.min(Math.max(r,h),b),g&&(m&&r>o.value&&(r=o.value),!m&&r<o.value&&(r=o.value)),t.value=S||b===h?b===h?V:V+(r-h)/(b-h)*a:g?m?Math.min(i,F.value):Math.max(i,B.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||runOnJS(ge)(),runOnJS(fe)(G.value,z.value))};return{enabled:!s,minDistance:0,...void 0===we?{}:{hitSlop:we},onActivate:()=>{"worklet";runOnJS(ce)(!0),J.value=t.value,w&&(l.value=withSpring(v,x)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),runOnJS(ge)()},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,x)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))},onFinalize:()=>{"worklet";runOnJS(ce)(!1)}}},[s,a,i,r,Y,L,D,_,u,c,E,H,T,M,we,fe,ge,ce,B,F,G,z,Z,$,K,Q,J,U]),Se=useMemo(()=>ye("low"),[ye]),ke=useMemo(()=>ye("high"),[ye]),Ce=usePanGesture(Se),xe=usePanGesture(ke),Ve=useCallback(e=>{if(s||L||R<=0)return;const t=clamp(e.nativeEvent.locationX,0,R),a=te(t,R);a!==G.value&&(he(),G.value=a,B.value=withTiming(ee(a,R),{duration:V.motion.duration.fast,easing:Easing.out(Easing.cubic)}),me(a,a))},[s,L,R,te,ee,me,he,B,G,V.motion.duration.fast]),Ae=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*Y)/Y:t;if(L){const e=Math.round((G.value+n)*Y)/Y,t=clamp(e,a,z.value);t!==G.value&&(G.value=t,B.value=ee(t,R),he(),me(t,z.value))}else{const e=Math.round((G.value+n)*Y)/Y,t=clamp(e,a,i);t!==G.value&&(G.value=t,B.value=ee(t,R),he(),me(t,t))}},[s,r,Y,L,a,i,ee,R,B,G,z,me,he]),je=j.thumbDiameter/2,Me=s?V.colors["surface-disabled"]:W,De="inset"===l?{backgroundColor:Me,borderColor:V.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Me,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:V.colors.surface,borderColor:Me},He=useAnimatedStyle(()=>{const e=U.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=s?.55:1;if(L){const a=Math.max(0,F.value-B.value+2*M);return{opacity:t,transform:[{translateX:B.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:B.value+M-e},{scaleX:1}]}},[U,s,L,F,B,M]),Ee=useAnimatedStyle(()=>({transform:[{translateX:B.value-je},{scale:Z.value}]}),[B,je,Z]),Oe=useAnimatedStyle(()=>({transform:[{translateX:F.value-je},{scale:$.value}]}),[F,je,$]),Te=useAnimatedStyle(()=>({opacity:K.value}),[K]),Re=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),clampDisplay=e=>clamp(e,a,i),Ie=clampDisplay(L?Math.min(...N):N),We=clampDisplay(L?Math.max(...N):N);return _jsx(View,{ref:t,style:[O.container,f,p],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:L?{min:a,max:i,now:Ie,text:`${Ie} to ${We}`}:{min:a,max:i,now:Ie},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Ae,children:_jsx(Pressable,{onPress:Ve,disabled:s||L,style:O.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:O.trackWrap,onLayout:de,children:[_jsxs(View,{style:O.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[O.track,{backgroundColor:s?V.colors["surface-disabled"]:V.colors.border},g]}),_jsx(Animated.View,{style:[O.fill,{backgroundColor:s?V.colors["surface-disabled"]:W},v,He]})]}),_jsx(GestureDetector,{gesture:Ce,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},De,w,Ee],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Te],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Ie):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:P},y],numberOfLines:1,children:d(Ie)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}),L?_jsx(GestureDetector,{gesture:xe,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},De,w,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Re],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(We):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:P},y],numberOfLines:1,children:d(We)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,...smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,...smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,...smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,...smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,...smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",...Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};export{Slider};export default Slider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,measure,runOnJS,scrollTo,useAnimatedRef,useAnimatedScrollHandler,useAnimatedStyle,useFrameCallback,useSharedValue,withSpring}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{useScrollHost}from"../Screen/ScrollHost.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"});const LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};export function moveItem(e,t,a){const l=e.slice();if(t<0||t>=l.length)return l;const[o]=l.splice(t,1);return l.splice(a,0,o),l}export function topOf(e,t){"worklet";let a=0;for(let l=0;l<t;l++)a+=e[l]??0;return a}export function slotTop(e,t,a){"worklet";let l=0,o=0;for(let r=0;r<e.length&&o<a;r++)r!==t&&(l+=e[r]??0,o++);return l}export function dropIndex(e,t,a){"worklet";const l=topOf(e,t)+(e[t]??0)/2+a;let o=0,r=0;for(let a=0;a<e.length;a++){const s=e[a]??0;a!==t&&r+s/2<l&&o++,r+=s}return o}export function rowShifts(e,t,a){const l=[];let o=0;for(const t of e)l.push(o),o+=t;const r=e.map(()=>0),s=moveItem(e.map((e,t)=>t),t,a);let n=0;for(const t of s)r[t]=n-(l[t]??0),n+=e[t]??0;return r}const buildStyles=e=>StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:l,isActive:o,dragging:r,handle:s,disabled:n,shared:u,callbacks:i,labels:c,children:d}){const m=useTheme(),v=useMemo(()=>buildStyles(m),[m]),h=useSharedValue(0);useEffect(()=>{h.value=r&&!o?withSpring(l,SPRING_CONFIG):l},[r,o,l,h]),useEffect(()=>()=>{cancelAnimation(h)},[h]);const S=useAnimatedStyle(()=>({transform:[{translateY:o?u.dragY.value:h.value}],zIndex:o?1:0}),[o,u,h]),f=useMemo(()=>{const{dragIndex:e,dropTo:a,dragY:l,translation:o,absoluteY:r,scrollY:c,scrollStart:d,hostOffset:m,hostStart:v,hostTarget:h,heights:S}=u,{onLift:f,onDrop:g,onSettled:p}=i;return{enabled:!n,activateAfterLongPress:s?void 0:350,onActivate:s=>{"worklet";r.value=s.absoluteY,e.value=t,a.value=t,d.value=c.value,v.value=m.value,h.value=m.value,o.value=0,l.value=0,runOnJS(f)(t)},onUpdate:a=>{"worklet";e.value===t&&(o.value=a.translationY,r.value=a.absoluteY)},onFinalize:()=>{"worklet";if(e.value!==t)return;const o=a.value,r=S.value;e.value=-1,l.value=topOf(r,t)+l.value-slotTop(r,t,o),l.value=withSpring(0,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(p)()}),runOnJS(g)(t,o)}}},[n,s,t,i,u]),g=usePanGesture(f),p=n?[]:[...t>0?[{name:"moveUp",label:c.moveUp}]:[],...t<a-1?[{name:"moveDown",label:c.moveDown}]:[]];return _jsx(Animated.View,{style:S,onLayout:t=>i.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:p,onAccessibilityAction:e=>{if(n)return;const l=t+(ACTION_STEP[e.nativeEvent.actionName]??0);l!==t&&l>=0&&l<a&&i.onMove(t,l)},testID:`sortable-row-${e}`,children:s?_jsxs(View,{style:v.handleRow,children:[_jsx(GestureDetector,{gesture:g,children:_jsxs(View,{style:v.handle,children:[_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar})]})}),_jsx(View,{style:v.body,children:d})]}):_jsx(GestureDetector,{gesture:g,children:_jsx(View,{children:d})})})}export function SortableList(e){const{data:t,keyExtractor:a,renderItem:l,onReorder:o,handle:r=!1,disabled:s=!1,accessibilityLabel:n,labels:u,testID:i}=e,c=useMemo(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...u}),[u]),d=useMemo(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),m=useMemo(()=>d.map(e=>e.key),[d]),v=useAnimatedRef(),h=useSharedValue(0),S=useSharedValue(0),f=useSharedValue(0),g=useScrollHost(),p=useSharedValue(0),b=null!==g,x=g?.top??p,w=g?.bottom??p,y=g?.offset??p,_=g?.maxOffset??p,k=g?.scrollTo??noop,A=useSharedValue(0),L=useSharedValue(0),O=useSharedValue(0),V=useSharedValue(0),I=useSharedValue(-1),T=useSharedValue(-1),C=useSharedValue(0),E=useSharedValue([]),j=useRef(new Map),M=useRef(m),[R,D]=useState(null),Y=useCallback(()=>{E.value=M.current.map(e=>j.current.get(e)??0)},[E]);useEffect(()=>{M.current=m,Y()},[m,Y]),useEffect(()=>()=>{cancelAnimation(C)},[C]);const P=useCallback(e=>{D(t=>t?.dragging?{...t,to:e}:t)},[]),G=useFrameCallback(()=>{"worklet";const e=I.value;if(e<0)return;const t=measure(v);if(t){const e=b?Math.max(t.pageY,x.value):t.pageY,a=b?Math.min(t.pageY+t.height,w.value):t.pageY+t.height,l=Math.max(0,f.value-t.height-1);V.value<e+48?h.value>1?scrollTo(v,0,Math.max(0,h.value-12),!1):b&&L.value>0&&(L.value=Math.max(0,L.value-12),runOnJS(k)(L.value)):V.value>a-48&&(h.value<l?scrollTo(v,0,Math.min(l,h.value+12),!1):b&&L.value<_.value&&(L.value=Math.min(_.value,L.value+12),runOnJS(k)(L.value)))}C.value=O.value+h.value-S.value+y.value-A.value;const a=dropIndex(E.value,e,C.value);a!==T.value&&(T.value=a,runOnJS(P)(a))},!1),N=useCallback(e=>{triggerHaptic("longPress"),G.setActive(!0),D({key:m[e]??"",from:e,to:e,dragging:!0})},[G,m]),H=useCallback((e,t)=>{G.setActive(!1),D(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&o(moveItem(m,e,t))},[G,m,o]),F=useCallback(()=>{D(e=>e&&!e.dragging?null:e)},[]),J=useCallback((e,t)=>{o(moveItem(m,e,t))},[m,o]),U=useCallback((e,t)=>{j.current.set(e,t),Y()},[Y]),z=useAnimatedScrollHandler({onScroll:e=>{"worklet";h.value=e.contentOffset.y}}),B=useCallback((e,t)=>{f.value=t},[f]),K=useMemo(()=>({scrollRef:v,scrollY:h,scrollStart:S,hostOffset:y,hostStart:A,hostTarget:L,translation:O,absoluteY:V,dragIndex:I,dropTo:T,dragY:C,heights:E}),[v,h,S,y,A,L,O,V,I,T,C,E]),X=useMemo(()=>({onLift:N,onDrop:H,onSettled:F,onMove:J,onHeight:U}),[N,H,F,J,U]),$=!0===R?.dragging,q=$&&R?rowShifts(m.map(e=>j.current.get(e)??0),R.from,R.to):null;return _jsx(Animated.ScrollView,{ref:v,onScroll:z,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!$,accessibilityLabel:n,testID:i,children:d.map((e,t)=>{const a=R?.key===e.key;return _jsx(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:q?.[t]??0,isActive:a,dragging:$,handle:r,disabled:s,shared:K,callbacks:X,labels:c,children:l({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";export default SortableList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useRef}from"react";import{Dimensions,Pressable,StyleSheet,View}from"react-native";import{
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef}from"react";import{Dimensions,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,runOnJS,useAnimatedStyle,useSharedValue,withSpring}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:n,rightActions:i,threshold:s,fullSwipeThreshold:o,onSwipeOpen:r,onSwipeClose:a,disabled:l=!1,haptic:c,containerStyle:u,contentStyle:d,actionStyle:m,accessibilityLabel:h,testID:p}=e,S=useTheme(),b=s??80,f=o??200,g=useMemo(()=>buildStyles(S),[S]),w=useMemo(()=>buildActionStyles(S),[S]),y=!!n&&n.length>0,v=!!i&&i.length>0,x=Dimensions.get("window").width,A=y?b*(n?.length??0):0,I=v?b*(i?.length??0):0,_=useSharedValue(0),C=useSharedValue(0),O=useRef(null);useEffect(()=>()=>{cancelAnimation(_),cancelAnimation(C)},[_,C]);const j=useCallback(e=>{O.current!==e&&(O.current=e,r?.(e))},[r]),G=useCallback(()=>{null!==O.current&&(O.current=null,a?.())},[a]),N=useCallback(e=>{const t="left"===e?n:i,s=t?.[0];s&&(!1!==c&&triggerHaptic("notificationSuccess"),s.onPress(),_.value=withSpring(0,SPRING_CONFIG),O.current=null,a?.())},[n,i,_,a,c]),R=useCallback(()=>{_.value=withSpring(0,SPRING_CONFIG),G()},[_,G]),P=useCallback(e=>{const t=resolveHaptic(c,"selection");t&&triggerHaptic(t),e.onPress(),R()},[R,c]),k=useMemo(()=>{const e=A,t=I,n=f,i=-f,s=x,o=-x,r=b,a=y,c=v;return{enabled:!l,testID:p?`${p}-gesture`:"swipeable-gesture",activeOffsetX:[-10,10],failOffsetY:[-15,15],onActivate:()=>{"worklet";C.value=_.value},onUpdate:n=>{"worklet";const i=C.value+n.translationX;_.value=i>0&&!a||i<0&&!c?0:i>e&&a?e+.35*(i-e):i<-t&&c?.35*(i+t)-t:i},onDeactivate:()=>{"worklet";const l=_.value;return a&&l>=n?(_.value=withSpring(s,SPRING_CONFIG),void runOnJS(N)("left")):c&&l<=i?(_.value=withSpring(o,SPRING_CONFIG),void runOnJS(N)("right")):a&&l>=r?(_.value=withSpring(e,SPRING_CONFIG),void runOnJS(j)("left")):c&&l<=-r?(_.value=withSpring(-t,SPRING_CONFIG),void runOnJS(j)("right")):(_.value=withSpring(0,SPRING_CONFIG),void runOnJS(G)())}}},[l,C,N,f,y,v,A,G,j,I,x,b,_,p]),T=usePanGesture(k),V=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),F=useAnimatedStyle(()=>({opacity:A>0?Math.min(1,Math.max(0,_.value/A)):0}),[A,_]),D=useAnimatedStyle(()=>({opacity:I>0?Math.min(1,Math.max(0,-_.value/I)):0}),[I,_]),E=useMemo(()=>{const e=[];return n?.forEach(t=>{e.push({name:t.key,label:t.label})}),i?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[n,i]),B=useCallback(e=>{const t=e.nativeEvent.actionName,s=[...n??[],...i??[]].find(e=>e.key===t);s&&(!1!==c&&triggerHaptic("selection"),s.onPress())},[n,i,c]);return y||v?_jsxs(View,{style:[g.root,u],testID:p,accessibilityLabel:h,accessibilityActions:E,onAccessibilityAction:B,children:[y?_jsx(Animated.View,{style:[g.actionsRow,g.actionsLeft,{width:A},m,F],pointerEvents:"box-none",children:n?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:w,width:b,onPress:P},e.key))}):null,v?_jsx(Animated.View,{style:[g.actionsRow,g.actionsRight,{width:I},m,D],pointerEvents:"box-none",children:i?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:w,width:b,onPress:P},e.key))}):null,_jsx(GestureDetector,{gesture:T,children:_jsx(Animated.View,{style:[g.content,d,V],children:t})})]}):_jsx(View,{style:u,testID:p,children:t})};Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:n,width:i,onPress:s})=>{assertValidValue("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const o=e.tone??"neutral",r=toneToBg(t,o),a=renderSlotIcon(e.icon,{color:toneToOnColor(t,o),size:20,disabled:!1});return _jsxs(Pressable,{onPress:()=>s(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[n.button,{width:i,backgroundColor:r,paddingHorizontal:t.space.sm}],children:[a?_jsx(View,{style:n.icon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:a}):null,_jsx(Text,{variant:"bodySmall",weight:"semibold",style:[n.label,{color:toneToOnColor(t,o)}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>StyleSheet.create({root:{position:"relative",overflow:"hidden"},content:{backgroundColor:"transparent"},actionsRow:{position:"absolute",top:0,bottom:0,flexDirection:"row"},actionsLeft:{left:0},actionsRight:{right:0,justifyContent:"flex-end"}});export{Swipeable};export default Swipeable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Fragment,memo,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Platform,Pressable,StyleSheet,TextInput,View}from"react-native";import{createAnimatedValue,setNativeValue}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const WHEEL_VISIBLE_ITEMS=5;export const WHEEL_CENTER_OFFSET=Math.floor(2.5);const HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=memo(({label:e,index:t,scrollY:n,itemHeight:
|
|
1
|
+
"use strict";import{Fragment,memo,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Platform,Pressable,StyleSheet,TextInput,View}from"react-native";import{createAnimatedValue,setNativeValue}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const WHEEL_VISIBLE_ITEMS=5;export const WHEEL_CENTER_OFFSET=Math.floor(2.5);const HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=memo(({label:e,index:t,scrollY:n,itemHeight:r,selected:a,theme:i,reducedMotion:s,onPress:l,editor:c})=>{const{opacity:o,scale:u}=useMemo(()=>{const e=Animated.subtract(Animated.divide(n,r),t);return{opacity:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),scale:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"})}},[n,r,t]),m=_jsx(Text,{variant:"h3",weight:a?"semibold":"medium",color:a?"primary":"secondary",numberOfLines:1,maxFontSizeMultiplier:1.5,style:{letterSpacing:i["letter-spacing"].normal},children:e});return _jsx(Animated.View,{style:[styles.row,{height:r},s?{opacity:o}:{opacity:o,transform:[{scale:u}]}],accessible:!1,importantForAccessibility:"no",children:c??(l?_jsx(Pressable,{focusable:!1,accessible:!1,onPress:()=>l(t),style:styles.rowPress,children:m}):m)})});export const Wheel=({label:e,items:t,selectedIndex:n,onIndexChange:r,itemHeight:a,width:i,theme:s,haptic:l,disabled:c,reducedMotion:o,typeable:u,testID:m})=>{const d="web"===Platform.OS,[b,f]=useState(null),y=useRef(!1),h=useRef(null),p=useRef(createAnimatedValue(n*a)).current,x=useRef(n*a),v=useRef(n*a),g=useRef(n),S=useRef(0),E=useRef(null),T=useRef(()=>{}),w=t.length-1;useEffect(()=>{g.current=n;const e=n*a;if(v.current===e)return;if(v.current=e,Math.abs(x.current-e)<1)return;x.current=e,d||setNativeValue(p,e);const t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[n,a,p,d]),useEffect(()=>{const e=x.current,t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[]),useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const M=useCallback((e,a)=>{if(!(e===n||e<0||e>w)){if("accessibility"===a){const e=resolveHaptic(l,"denseTick");e&&triggerHaptic(e)}if("keyboard"!==a){const n=t[e];n&&announce(n.accessibilityLabel??n.label)}r(e)}},[n,w,t,l,r]),A=useCallback(()=>{!c&&u&&(y.current=!0,f(String(t[n]?.value??"")))},[c,u,t,n]),_=useCallback(e=>{if(!y.current)return;y.current=!1,f(null);const n=e.trim();if(!/^\d+$/.test(n))return;const r=Number(n),a=t.findIndex(e=>e.value===r);a>=0&&M(a,"keyboard")},[t,M]);T.current=()=>{E.current=null;const e=Math.max(0,Math.min(w,Math.round(x.current/a))),t=e*a;Math.abs(x.current-t)>=1&&h.current?.scrollTo({y:t,animated:!o}),M(e,"scroll")};const j=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:p}}}],{useNativeDriver:nativeDriver,listener:e=>{const t=e.nativeEvent.contentOffset.y;x.current=t;const n=Math.round(t/a);if(n!==g.current&&n>=0&&n<=w){const e=Date.now();if(e-S.current>=35){const t=resolveHaptic(l,"denseTick");t&&triggerHaptic(t),S.current=e}g.current=n}d&&(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>T.current(),120))}}),[p,a,w,l,d]),C=useCallback(e=>{const t=e.nativeEvent.contentOffset.y;M(Math.max(0,Math.min(w,Math.round(t/a))),"scroll")},[M,w,a]),R=useCallback(e=>{if(c)return;const t=e.nativeEvent.actionName;"increment"===t?M(Math.min(w,n+1),"accessibility"):"decrement"===t&&M(Math.max(0,n-1),"accessibility")},[c,M,w,n]),F=useCallback(e=>{c||h.current?.scrollTo({y:e*a,animated:!o})},[c,a,o]),k=useCallback(({item:t,index:r})=>{const i=r===n,l=i&&null!==b;return _jsx(WheelRow,{label:t.label,index:r,scrollY:p,itemHeight:a,selected:i,theme:s,reducedMotion:o,onPress:i&&u?A:d?F:void 0,editor:l?_jsx(TextInput,{autoFocus:!0,selectTextOnFocus:!0,keyboardType:"number-pad",returnKeyType:"done",accessibilityLabel:e,value:b,onChangeText:f,onSubmitEditing:()=>_(b),onBlur:()=>_(b),style:{width:"100%",padding:s.space.none,textAlign:"center",fontSize:s.text.xl.size,color:s.colors["text-body"],fontWeight:s.weight.semibold,letterSpacing:s["letter-spacing"].normal}}):void 0})},[p,a,n,s,o,d,F,u,A,b,_,e]),I=useCallback((e,t)=>`${String(e.value)}-${t}`,[]),L=t[n]?t[n].accessibilityLabel??t[n].label:"",P=d?{focusable:!0,role:"spinbutton","aria-label":e,"aria-valuetext":L,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":w,"aria-disabled":c,onKeyDown:e=>{if(c)return;const t={ArrowDown:Math.min(w,n+1),PageDown:Math.min(w,n+1),ArrowUp:Math.max(0,n-1),PageUp:Math.max(0,n-1),Home:0,End:w}[e.nativeEvent.key];void 0!==t&&(e.preventDefault(),M(t,"keyboard"))}}:void 0;return _jsxs(View,{style:[void 0===i?styles.columnFlex:{width:i},{height:5*a},styles.column,c?styles.disabled:null],testID:m,...P,children:[d?null:_jsx(View,{pointerEvents:"none",style:styles.a11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:e,accessibilityValue:{text:L},accessibilityState:{disabled:Boolean(c)},"aria-disabled":Boolean(c),accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:R}),_jsx(Animated.ScrollView,{ref:h,showsVerticalScrollIndicator:!1,snapToInterval:a,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEnabled:!c,nestedScrollEnabled:!0,scrollEventThrottle:16,onScroll:j,onMomentumScrollEnd:C,contentOffset:{x:0,y:n*a},contentContainerStyle:{paddingVertical:a*WHEEL_CENTER_OFFSET},style:[styles.list,{height:5*a}],importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:t.map((e,t)=>_jsx(Fragment,{children:k({item:e,index:t})},I(e,t)))})]})};const styles=StyleSheet.create({column:{overflow:"hidden"},columnFlex:{flex:1},disabled:{opacity:.5},list:{flexGrow:0},row:{alignItems:"center",justifyContent:"center"},rowPress:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",flex:1},a11yLayer:{...StyleSheet.absoluteFill,zIndex:2}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo}from"react";import{StyleSheet}from"react-native";import{
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo}from"react";import{StyleSheet}from"react-native";import{GestureDetector,useCompetingGestures,usePanGesture,usePinchGesture,useTapGesture}from"react-native-gesture-handler";import Animated,{runOnJS,useAnimatedStyle,useSharedValue,withSpring}from"react-native-reanimated";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_MAX_SCALE=4,DEFAULT_MIN_SCALE=1,DEFAULT_DOUBLE_TAP_SCALE=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1};export const ZoomableImage=({children:e,maxScale:a=4,minScale:t=1,doubleTapScale:l=2,disabled:u=!1,haptic:i,style:s,accessibilityLabel:r,testID:n})=>{const o=useSharedValue(1),v=useSharedValue(1),c=useSharedValue(0),S=useSharedValue(0),m=useSharedValue(0),d=useSharedValue(0),p=useCallback(()=>{o.value=withSpring(1,SPRING_CONFIG),v.value=1,c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),m.value=0,d.value=0},[o,v,c,S,m,d]);useEffect(()=>{u&&p()},[u,p]);const h=useCallback(()=>{const e=resolveHaptic(i,"impactLight");e&&triggerHaptic(e)},[i]),G=useMemo(()=>({enabled:!u,onActivate:()=>{"worklet";v.value=o.value},onUpdate:e=>{"worklet";const l=v.value*e.scale;o.value=l<t?t+.3*(l-t):l>a?a+.2*(l-a):l},onDeactivate:()=>{"worklet";return o.value<t?(o.value=withSpring(t,SPRING_CONFIG),c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),v.value=t,m.value=0,void(d.value=0)):o.value>a?(o.value=withSpring(a,SPRING_CONFIG),void(v.value=a)):void(v.value=o.value)}}),[u,o,v,c,S,m,d,t,a]),I=usePinchGesture(G),g=useMemo(()=>({enabled:!u,minPointers:1,maxPointers:1,onActivate:()=>{"worklet";m.value=c.value,d.value=S.value},onUpdate:e=>{"worklet";o.value<=1||(c.value=m.value+e.translationX,S.value=d.value+e.translationY)},onDeactivate:()=>{"worklet";m.value=c.value,d.value=S.value}}),[u,o,c,S,m,d]),N=usePanGesture(g),w=useMemo(()=>({enabled:!u,numberOfTaps:2,onDeactivate:()=>{"worklet";runOnJS(h)(),o.value>1?(o.value=withSpring(1,SPRING_CONFIG),c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),v.value=1,m.value=0,d.value=0):(o.value=withSpring(l,SPRING_CONFIG),v.value=l)}}),[u,o,v,c,S,m,d,h,l]),_=useTapGesture(w),C=useCompetingGestures(I,N,_),b=useAnimatedStyle(()=>({transform:[{translateX:c.value},{translateY:S.value},{scale:o.value}]}),[c,S,o]);return _jsx(GestureDetector,{gesture:C,children:_jsx(Animated.View,{style:[styles.container,s],testID:n,accessibilityLabel:r,accessibilityState:{disabled:u},"aria-disabled":u,children:_jsx(Animated.View,{style:[styles.content,b],children:e})})})};ZoomableImage.displayName="ZoomableImage";const styles=StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center",overflow:"hidden"},content:{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"}});export default ZoomableImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo,useRef}from"react";import{Animated,Easing}from"react-native";import{
|
|
1
|
+
"use strict";import{useMemo,useRef}from"react";import{Animated,Easing}from"react-native";import{usePanGesture}from"react-native-gesture-handler";import{createAnimatedValue,setNativeValue,useTheme}from"../theme/index.js";import{nativeDriver}from"../utils/nativeDriver.js";import{usePresenceMotion}from"./usePresenceMotion.js";export const DRAG_DISMISS_DISTANCE=100;export const DRAG_DISMISS_VELOCITY=.5;export const createDragToDismissController=({drag:e,travel:t,onDismiss:a,opacity:i},r,s)=>{const{snappy:n}=r.spring,springBack=()=>Animated.spring(e,{toValue:0,damping:n.damping,stiffness:n.stiffness,mass:n.mass,useNativeDriver:nativeDriver}).start(),o=!0===s?.reduced?i:void 0,u=s?.duration("default")??r.duration.default;return{move:t=>{setNativeValue(e,Math.max(0,t))},release:(i,s)=>{if(i>100||s>.5){if(o)return void Animated.timing(o,{toValue:0,duration:u,easing:Easing.bezier(...r.ease.accelerate),useNativeDriver:nativeDriver}).start(()=>a());Animated.timing(e,{toValue:"function"==typeof t?t():t,duration:r.duration.fast,easing:Easing.bezier(...r.ease.accelerate),useNativeDriver:nativeDriver}).start(()=>a())}else springBack()},cancel:springBack}};export const useDragToDismiss=e=>{const{drag:t,travel:a,onDismiss:i,contentAtTop:r,scrollGesture:s}=e,{motion:n}=useTheme(),o=usePresenceMotion(),u=useRef(createAnimatedValue(1)).current,c=useMemo(()=>createDragToDismissController({drag:t,travel:a,onDismiss:i,opacity:u},n,o),[t,a,i,u,n,o]),l=useMemo(()=>({runOnJS:!0,activeOffsetY:6,failOffsetX:[-12,12],onUpdate:e=>c.move(e.translationY),onDeactivate:e=>c.release(e.translationY,e.velocityY/1e3),onFinalize:e=>{e.canceled&&c.cancel()}}),[c]),m=usePanGesture(l),v=useMemo(()=>{let e=0,t=!1;return{runOnJS:!0,activeOffsetY:8,failOffsetX:[-12,12],simultaneousWith:s,onBegin:()=>{e=0,t=!1},onUpdate:a=>{if(!t){if(r&&!r())return;t=!0,e=a.translationY}c.move(a.translationY-e)},onDeactivate:a=>{t&&c.release(a.translationY-e,a.velocityY/1e3)},onFinalize:e=>{e.canceled&&t&&c.cancel()}}},[c,r,s]),f=usePanGesture(v);return useMemo(()=>({handleGesture:m,sheetGesture:f,opacity:u}),[m,f,u])};
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{PHONE_CHROME_INSETS}from"./canvasKit/index.js";export{Accordion,AccordionGroup,ALL_CALLING_CODES,AmountSlider,AnimatePresence,AppBar,AppLockOverlay,AsyncBlock,AuthedImage,Autocomplete,Avatar,AvatarGroup,authedImageCacheStats,Badge,Banner,BarChart,BottomNavigation,BottomSheet,Box,Button,buttonLabelInk,Calendar,Card,Carousel,Checkbox,Chip,ChoiceGroup,Composer,Confetti,ConfirmHost,clearAuthedImageCache,confirm,DatePicker,DateRangePicker,DateSeparator,DEFAULT_CALLING_CODES,DecimalInput,Descriptions,Dialog,Divider,Drawer,defineStatusMap,EmptyState,ErrorBoundary,FilePicker,FileViewer,FilterChipRow,FloatingActionButton,FloatingActionButtonGroup,ForceUpdateDialog,FormField,formatE164,formatFileSize,getAuthedImageCacheLimit,IconBadge,IconButton,ImageGallery,InlineSelect,Input,KeyboardAwareScrollView,KeyboardToolbar,ListItem,ListSection,LoaderOverlay,loader,Markdown,Menu,MessageBubble,MessageList,MODAL_DISMISS_GRACE_MS,Modal,NumberInput,OnboardingPager,OptionSheet,OTPInput,OTPResendRow,PagedListFooter,PermissionPrompt,PhoneNumberInput,PickerTrigger,ProfileCompletion,ProfilePicker,ProgressBar,ProgressRing,Radio,RadioDot,RadioGroup,Rating,Repeater,RichTextEditor,Row,ScannerOverlay,Screen,SearchBar,SectionHeader,SegmentedControl,Select,SignaturePad,Skeleton,SkeletonCircle,SkeletonClockProvider,SkeletonContent,SkeletonList,SkeletonProvider,SkeletonSkip,SkeletonText,Slider,SliderField,SlideToConfirm,SortableList,Spacer,Sparkline,Spinner,SquircleImage,SquircleView,Stack,StatTile,StatusBadge,Stepper,Swipeable,Switch,setAuthedImageCacheLimit,Tabs,TagInput,Text,TextInkContext,Timeline,TimePicker,Toast,ToastHost,ToastProvider,Tooltip,Tour,TypingIndicator,toast,useBottomSheet,useErrorHandler,useRecentSearches,useTextInk,useToast,WheelPicker,withErrorBoundary,ZoomableImage}from"./components/index.js";export{AppIcon}from"./components/AppIcon/index.js";export{HookFormField,useHookFormField}from"./form/index.js";export{useDebounce,useFieldChain,useReducedMotion,useRefreshControl,useScrollDirection}from"./hooks/index.js";export{NetworkStatusBanner}from"./network/index.js";export{KitThemeBridge,lightTheme,makeStyles,radiusOf,ThemeProvider,useTheme,useThemeMode}from"./theme/index.js";export{announce,isHapticsEnabled,setHapticImplementation,setHapticsEnabled,triggerHaptic}from"./utils/index.js";
|
|
1
|
+
"use strict";export{PHONE_CHROME_INSETS}from"./canvasKit/index.js";export{Accordion,AccordionGroup,ALL_CALLING_CODES,AmountSlider,AnimatePresence,AppBar,AppLockOverlay,AsyncBlock,AuthedImage,Autocomplete,Avatar,AvatarGroup,authedImageCacheStats,Badge,Banner,BarChart,BottomNavigation,BottomSheet,Box,Button,buttonLabelInk,Calendar,Card,Carousel,Checkbox,Chip,ChoiceGroup,Composer,Confetti,ConfirmHost,clearAuthedImageCache,confirm,DatePicker,DateRangePicker,DateSeparator,DEFAULT_CALLING_CODES,DecimalInput,Descriptions,Dialog,Divider,Drawer,defineStatusMap,EmptyState,ErrorBoundary,FilePicker,FileViewer,FilterChipRow,FloatingActionButton,FloatingActionButtonGroup,ForceUpdateDialog,FormField,formatE164,formatFileSize,getAuthedImageCacheLimit,IconBadge,IconButton,ImageGallery,InlineSelect,Input,KeyboardAwareScrollView,KeyboardToolbar,ListItem,ListSection,LoaderOverlay,loader,Markdown,Menu,MessageBubble,MessageList,MODAL_DISMISS_GRACE_MS,Modal,NumberInput,OnboardingPager,OptionSheet,OTPInput,OTPResendRow,PagedListFooter,PermissionPrompt,PhoneNumberInput,PickerTrigger,ProfileCompletion,ProfilePicker,ProgressBar,ProgressRing,Radio,RadioDot,RadioGroup,Rating,Repeater,RichTextEditor,Row,ScannerOverlay,Screen,SearchBar,SectionHeader,SegmentedControl,Select,SignaturePad,Skeleton,SkeletonCircle,SkeletonClockProvider,SkeletonContent,SkeletonList,SkeletonProvider,SkeletonSkip,SkeletonText,Slider,SliderField,SlideToConfirm,SortableList,Spacer,Sparkline,Spinner,SquircleImage,SquircleView,Stack,StatTile,StatusBadge,Stepper,Swipeable,Switch,setAuthedImageCacheLimit,Tabs,TagInput,Text,TextInkContext,Timeline,TimePicker,Toast,ToastHost,ToastProvider,Tooltip,Tour,TypingIndicator,toast,useBottomSheet,useErrorHandler,useRecentSearches,useTextInk,useToast,WheelPicker,withErrorBoundary,ZoomableImage}from"./components/index.js";export{AppIcon}from"./components/AppIcon/index.js";export{HookFormField,useHookFormField}from"./form/index.js";export{useDebounce,useFieldChain,useReducedMotion,useRefreshControl,useScrollDirection}from"./hooks/index.js";export{NetworkStatusBanner}from"./network/index.js";export{fontFor,KitThemeBridge,lightTheme,makeStyles,radiusOf,ThemeProvider,useTheme,useThemeMode}from"./theme/index.js";export{announce,isHapticsEnabled,setHapticImplementation,setHapticsEnabled,triggerHaptic}from"./utils/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{useNavigation}from"@react-navigation/native";import{createContext,useContext}from"react";import{Screen}from"../components/Screen/index.js";import{useTheme}from"../theme/index.js";import{jsx as _jsx}from"react/jsx-runtime";const TabBarHeightContext=(()=>{try{return require("@react-navigation/bottom-tabs").BottomTabBarHeightContext}catch{return createContext(void 0)}})(),TAB_EDGES=["top"];export function NavigationScreen({kind:t="pushed",appBar:e=!0,onBack:o,...i}){const r=useNavigation(),n=useContext(TabBarHeightContext),a=!0===useTheme().settings.components.screen?.tabBarFloats,s=e?i:{...i,title:void 0,subtitle:void 0,leading:void 0,trailing:void 0,rightActions:void 0};return _jsx(Screen,"tab"===t?{...s,largeTitle:!1,edges:TAB_EDGES,bottomInset:a?n??0:0}:{...s,largeTitle:!1,onBack:"root"!==t&&e?o??r.goBack:void 0})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_START={x:.5,y:0},DEFAULT_END={x:.5,y:1},round=t=>Math.round(1e3*t)/1e3;export const gradientAngle=(t=DEFAULT_START,
|
|
1
|
+
"use strict";import{View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_START={x:.5,y:0},DEFAULT_END={x:.5,y:1},round=t=>Math.round(1e3*t)/1e3;export const gradientAngle=(t=DEFAULT_START,r=DEFAULT_END)=>{const e=180*Math.atan2(r.x-t.x,t.y-r.y)/Math.PI;return round((e%360+360)%360)};export const toBackgroundImage=t=>{const r=t.colors.length-1;return{type:"linear-gradient",direction:`${gradientAngle(t.start,t.end)}deg`,colorStops:t.colors.map((e,o)=>{const n=t.locations?.[o]??(0===r?0:o/r);return{color:e,positions:[`${round(100*n)}%`]}})}};export const Gradient=({gradient:t,style:r,children:e})=>_jsx(View,{style:[{experimental_backgroundImage:[toBackgroundImage(t)]},r],children:e});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
2
|
import type { ColorMode } from "../theme/types";
|
|
4
3
|
export type PhoneChromeOs = "Ios" | "Android";
|
|
5
4
|
export declare const PHONE_CHROME_INSETS: {
|
|
@@ -22,29 +21,39 @@ export interface StatusBarProps {
|
|
|
22
21
|
/** Battery level in percent, 0 to 100. */
|
|
23
22
|
battery?: number;
|
|
24
23
|
}
|
|
25
|
-
export declare const StatusBar: ({ os, colorMode, time, signal, battery }: StatusBarProps) => import("react").
|
|
24
|
+
export declare const StatusBar: ({ os, colorMode, time, signal, battery }: StatusBarProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
|
|
25
|
+
ref?: React.Ref<import("react-native").ViewInstance> | undefined;
|
|
26
|
+
}>;
|
|
26
27
|
export interface HomeIndicatorProps {
|
|
27
28
|
os: PhoneChromeOs;
|
|
28
29
|
colorMode?: ColorMode;
|
|
29
30
|
}
|
|
30
|
-
export declare const HomeIndicator: ({ os, colorMode }: HomeIndicatorProps) => import("react").
|
|
31
|
+
export declare const HomeIndicator: ({ os, colorMode }: HomeIndicatorProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
|
|
32
|
+
ref?: React.Ref<import("react-native").ViewInstance> | undefined;
|
|
33
|
+
}>;
|
|
31
34
|
export interface NavigationBarProps {
|
|
32
35
|
os: PhoneChromeOs;
|
|
33
36
|
colorMode?: ColorMode;
|
|
34
37
|
}
|
|
35
|
-
export declare const NavigationBar: ({ os, colorMode }: NavigationBarProps) => import("react").
|
|
38
|
+
export declare const NavigationBar: ({ os, colorMode }: NavigationBarProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
|
|
39
|
+
ref?: React.Ref<import("react-native").ViewInstance> | undefined;
|
|
40
|
+
}> | null;
|
|
36
41
|
export interface SafeAreaProps {
|
|
37
42
|
os: PhoneChromeOs;
|
|
38
43
|
children?: ReactNode;
|
|
39
44
|
}
|
|
40
|
-
export declare const SafeArea: ({ os, children }: SafeAreaProps) => import("react").
|
|
45
|
+
export declare const SafeArea: ({ os, children }: SafeAreaProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
|
|
46
|
+
ref?: React.Ref<import("react-native").ViewInstance> | undefined;
|
|
47
|
+
}>;
|
|
41
48
|
export type KeyboardPreviewOs = "ios" | "android";
|
|
42
49
|
export interface KeyboardFrameProps {
|
|
43
50
|
colorMode?: ColorMode;
|
|
44
51
|
previewOs?: KeyboardPreviewOs;
|
|
45
52
|
children?: ReactNode;
|
|
46
53
|
}
|
|
47
|
-
export declare const KeyboardFrame: ({ colorMode, previewOs, children }: KeyboardFrameProps) => import("react").
|
|
54
|
+
export declare const KeyboardFrame: ({ colorMode, previewOs, children }: KeyboardFrameProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
|
|
55
|
+
ref?: React.Ref<import("react-native").ViewInstance> | undefined;
|
|
56
|
+
}>;
|
|
48
57
|
export interface PhoneChromeManifestProp {
|
|
49
58
|
name: string;
|
|
50
59
|
type: "enum" | "string" | "number";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type NumberGrouping } from "@webority/mobile-core";
|
|
2
|
-
import
|
|
2
|
+
import { type ForwardRefExoticComponent, type RefAttributes } from "react";
|
|
3
|
+
import type { HostInstance, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
4
|
import type { HapticType } from "../../utils";
|
|
4
5
|
import type { SliderSize, SliderTone, SliderVariant } from "../Slider";
|
|
5
6
|
export interface AmountSliderLabels {
|
|
@@ -61,7 +62,7 @@ interface Scaled {
|
|
|
61
62
|
type ScaleUnits = Exclude<NumberGrouping, "none">;
|
|
62
63
|
/** Splits a value into the number and unit the header shows. */
|
|
63
64
|
export declare const scaleAmount: (value: number, units: ScaleUnits, labels?: AmountSliderLabels) => Scaled;
|
|
64
|
-
declare const AmountSlider:
|
|
65
|
+
declare const AmountSlider: ForwardRefExoticComponent<AmountSliderProps & RefAttributes<HostInstance>>;
|
|
65
66
|
export { AmountSlider };
|
|
66
67
|
export default AmountSlider;
|
|
67
68
|
//# sourceMappingURL=AmountSlider.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HostInstance, StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
import { Animated } from "react-native";
|
|
4
4
|
import type { HapticType } from "../../utils/hapticUtils";
|
|
5
5
|
import type { MenuItem } from "../Menu";
|
|
@@ -128,7 +128,7 @@ export interface AppBarProps {
|
|
|
128
128
|
haptic?: HapticType | false;
|
|
129
129
|
testID?: string;
|
|
130
130
|
}
|
|
131
|
-
declare const AppBar: React.ForwardRefExoticComponent<AppBarProps & React.RefAttributes<
|
|
131
|
+
declare const AppBar: React.ForwardRefExoticComponent<AppBarProps & React.RefAttributes<HostInstance>>;
|
|
132
132
|
export { AppBar };
|
|
133
133
|
export default AppBar;
|
|
134
134
|
//# sourceMappingURL=AppBar.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const writeImage: (fileName: string, bytes: Uint8Array<ArrayBuffer>, _contentType: string) => string
|
|
1
|
+
export declare const writeImage: (fileName: string, bytes: Uint8Array<ArrayBuffer>, _contentType: string) => Promise<string>;
|
|
2
2
|
export declare const imageUri: (fileName: string) => string;
|
|
3
3
|
export declare const imageExists: (fileName: string) => boolean;
|
|
4
4
|
export declare const deleteImage: (fileName: string) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const writeImage: (fileName: string, bytes: Uint8Array<ArrayBuffer>, contentType: string) => string
|
|
1
|
+
export declare const writeImage: (fileName: string, bytes: Uint8Array<ArrayBuffer>, contentType: string) => Promise<string>;
|
|
2
2
|
export declare const imageUri: (fileName: string) => string;
|
|
3
3
|
export declare const imageExists: (fileName: string) => boolean;
|
|
4
4
|
export declare const deleteImage: (fileName: string) => void;
|