@webority/mobile-ui 0.9.0 → 0.10.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/lib/commonjs/components/BarChart/BarChart.js +1 -0
- package/lib/commonjs/components/BarChart/index.js +1 -0
- package/lib/commonjs/components/BarChart/scale.js +1 -0
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/commonjs/components/BottomNavigation/useScreenReaderEnabled.js +1 -0
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/BottomSheet/index.js +1 -1
- package/lib/commonjs/components/BottomSheet/useSheetSwap.js +1 -0
- package/lib/commonjs/components/Card/Card.js +1 -1
- package/lib/commonjs/components/Composer/Composer.js +1 -0
- package/lib/commonjs/components/Composer/index.js +1 -0
- package/lib/commonjs/components/DateSeparator/DateSeparator.js +1 -0
- package/lib/commonjs/components/DateSeparator/index.js +1 -0
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.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/Menu/Menu.js +1 -0
- package/lib/commonjs/components/Menu/MenuSurface.js +1 -0
- package/lib/commonjs/components/Menu/focusHost.js +1 -0
- package/lib/commonjs/components/Menu/index.js +1 -0
- package/lib/commonjs/components/Menu/menuModel.js +1 -0
- package/lib/commonjs/components/Menu/useContextMenu.js +1 -0
- package/lib/commonjs/components/Menu/webOnly.js +1 -0
- package/lib/commonjs/components/MessageBubble/MessageBubble.js +1 -0
- package/lib/commonjs/components/MessageBubble/index.js +1 -0
- package/lib/commonjs/components/MessageList/MessageList.js +1 -0
- package/lib/commonjs/components/MessageList/index.js +1 -0
- package/lib/commonjs/components/OnboardingPager/OnboardingPager.js +1 -0
- package/lib/commonjs/components/OnboardingPager/index.js +1 -0
- package/lib/commonjs/components/PaymentResult/PaymentResult.js +1 -0
- package/lib/commonjs/components/PaymentResult/index.js +1 -0
- package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -0
- package/lib/commonjs/components/ScannerOverlay/index.js +1 -0
- package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
- package/lib/commonjs/components/SearchBar/SearchPanel.js +1 -0
- package/lib/commonjs/components/SearchBar/highlight.js +1 -0
- package/lib/commonjs/components/SearchBar/index.js +1 -1
- package/lib/commonjs/components/SearchBar/useRecentSearches.js +1 -0
- package/lib/commonjs/components/Select/Select.js +1 -1
- package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -0
- package/lib/commonjs/components/SignaturePad/index.js +1 -0
- package/lib/commonjs/components/SignaturePad/signatureGeometry.js +1 -0
- package/lib/commonjs/components/SignaturePad/writePng.js +1 -0
- package/lib/commonjs/components/SignaturePad/writePng.web.js +1 -0
- package/lib/commonjs/components/Sparkline/Sparkline.js +1 -0
- package/lib/commonjs/components/Sparkline/geometry.js +1 -0
- package/lib/commonjs/components/Sparkline/index.js +1 -0
- package/lib/commonjs/components/Spinner/Spinner.js +1 -1
- package/lib/commonjs/components/StatTile/StatTile.js +1 -1
- package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
- package/lib/commonjs/components/Toast/Toast.js +1 -1
- package/lib/commonjs/components/Toast/ToastProvider.js +1 -1
- package/lib/commonjs/components/Tooltip/RichTooltipBody.js +1 -0
- package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
- package/lib/commonjs/components/Tooltip/tooltipPosition.js +1 -0
- package/lib/commonjs/components/TypingIndicator/TypingIndicator.js +1 -0
- package/lib/commonjs/components/TypingIndicator/index.js +1 -0
- package/lib/commonjs/components/WheelPicker/Wheel.js +1 -0
- package/lib/commonjs/components/WheelPicker/WheelPicker.js +1 -0
- package/lib/commonjs/components/WheelPicker/index.js +1 -0
- package/lib/commonjs/components/index.js +1 -1
- package/lib/commonjs/hooks/index.js +1 -1
- package/lib/commonjs/hooks/useRefreshControl.js +1 -0
- package/lib/commonjs/hooks/useScrollDirection.js +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/utils/announce.js +1 -0
- package/lib/commonjs/utils/hapticUtils.js +1 -1
- package/lib/commonjs/utils/index.js +1 -1
- package/lib/commonjs/utils/placement.js +1 -0
- package/lib/module/components/BarChart/BarChart.js +1 -0
- package/lib/module/components/BarChart/index.js +1 -0
- package/lib/module/components/BarChart/scale.js +1 -0
- package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/module/components/BottomNavigation/useScreenReaderEnabled.js +1 -0
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/BottomSheet/index.js +1 -1
- package/lib/module/components/BottomSheet/useSheetSwap.js +1 -0
- package/lib/module/components/Card/Card.js +1 -1
- package/lib/module/components/Composer/Composer.js +1 -0
- package/lib/module/components/Composer/index.js +1 -0
- package/lib/module/components/DateSeparator/DateSeparator.js +1 -0
- package/lib/module/components/DateSeparator/index.js +1 -0
- package/lib/module/components/FloatingActionButton/FloatingActionButton.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/Menu/Menu.js +1 -0
- package/lib/module/components/Menu/MenuSurface.js +1 -0
- package/lib/module/components/Menu/focusHost.js +1 -0
- package/lib/module/components/Menu/index.js +1 -0
- package/lib/module/components/Menu/menuModel.js +1 -0
- package/lib/module/components/Menu/useContextMenu.js +1 -0
- package/lib/module/components/Menu/webOnly.js +1 -0
- package/lib/module/components/MessageBubble/MessageBubble.js +1 -0
- package/lib/module/components/MessageBubble/index.js +1 -0
- package/lib/module/components/MessageList/MessageList.js +1 -0
- package/lib/module/components/MessageList/index.js +1 -0
- package/lib/module/components/OnboardingPager/OnboardingPager.js +1 -0
- package/lib/module/components/OnboardingPager/index.js +1 -0
- package/lib/module/components/PaymentResult/PaymentResult.js +1 -0
- package/lib/module/components/PaymentResult/index.js +1 -0
- package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -0
- package/lib/module/components/ScannerOverlay/index.js +1 -0
- package/lib/module/components/SearchBar/SearchBar.js +1 -1
- package/lib/module/components/SearchBar/SearchPanel.js +1 -0
- package/lib/module/components/SearchBar/highlight.js +1 -0
- package/lib/module/components/SearchBar/index.js +1 -1
- package/lib/module/components/SearchBar/useRecentSearches.js +1 -0
- package/lib/module/components/Select/Select.js +1 -1
- package/lib/module/components/SignaturePad/SignaturePad.js +1 -0
- package/lib/module/components/SignaturePad/index.js +1 -0
- package/lib/module/components/SignaturePad/signatureGeometry.js +1 -0
- package/lib/module/components/SignaturePad/writePng.js +1 -0
- package/lib/module/components/SignaturePad/writePng.web.js +1 -0
- package/lib/module/components/Sparkline/Sparkline.js +1 -0
- package/lib/module/components/Sparkline/geometry.js +1 -0
- package/lib/module/components/Sparkline/index.js +1 -0
- package/lib/module/components/Spinner/Spinner.js +1 -1
- package/lib/module/components/StatTile/StatTile.js +1 -1
- package/lib/module/components/TimePicker/TimePicker.js +1 -1
- package/lib/module/components/Toast/Toast.js +1 -1
- package/lib/module/components/Toast/ToastProvider.js +1 -1
- package/lib/module/components/Tooltip/RichTooltipBody.js +1 -0
- package/lib/module/components/Tooltip/Tooltip.js +1 -1
- package/lib/module/components/Tooltip/tooltipPosition.js +1 -0
- package/lib/module/components/TypingIndicator/TypingIndicator.js +1 -0
- package/lib/module/components/TypingIndicator/index.js +1 -0
- package/lib/module/components/WheelPicker/Wheel.js +1 -0
- package/lib/module/components/WheelPicker/WheelPicker.js +1 -0
- package/lib/module/components/WheelPicker/index.js +1 -0
- package/lib/module/components/index.js +1 -1
- package/lib/module/hooks/index.js +1 -1
- package/lib/module/hooks/useRefreshControl.js +1 -0
- package/lib/module/hooks/useScrollDirection.js +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/utils/announce.js +1 -0
- package/lib/module/utils/hapticUtils.js +1 -1
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/placement.js +1 -0
- package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +62 -0
- package/lib/typescript/commonjs/components/BarChart/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/BarChart/scale.d.ts +15 -0
- package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +32 -0
- package/lib/typescript/commonjs/components/BottomNavigation/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/BottomNavigation/useScreenReaderEnabled.d.ts +8 -0
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +34 -3
- package/lib/typescript/commonjs/components/BottomSheet/index.d.ts +2 -0
- package/lib/typescript/commonjs/components/BottomSheet/useSheetSwap.d.ts +24 -0
- package/lib/typescript/commonjs/components/Card/Card.d.ts +9 -0
- package/lib/typescript/commonjs/components/Composer/Composer.d.ts +61 -0
- package/lib/typescript/commonjs/components/Composer/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/DateSeparator/DateSeparator.d.ts +37 -0
- package/lib/typescript/commonjs/components/DateSeparator/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +3 -1
- package/lib/typescript/commonjs/components/Input/Input.d.ts +2 -2
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +9 -0
- package/lib/typescript/commonjs/components/Menu/Menu.d.ts +46 -0
- package/lib/typescript/commonjs/components/Menu/MenuSurface.d.ts +30 -0
- package/lib/typescript/commonjs/components/Menu/focusHost.d.ts +9 -0
- package/lib/typescript/commonjs/components/Menu/index.d.ts +5 -0
- package/lib/typescript/commonjs/components/Menu/menuModel.d.ts +68 -0
- package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +58 -0
- package/lib/typescript/commonjs/components/Menu/webOnly.d.ts +7 -0
- package/lib/typescript/commonjs/components/MessageBubble/MessageBubble.d.ts +87 -0
- package/lib/typescript/commonjs/components/MessageBubble/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +68 -0
- package/lib/typescript/commonjs/components/MessageList/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/OnboardingPager/OnboardingPager.d.ts +53 -0
- package/lib/typescript/commonjs/components/OnboardingPager/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/PaymentResult/PaymentResult.d.ts +71 -0
- package/lib/typescript/commonjs/components/PaymentResult/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +74 -0
- package/lib/typescript/commonjs/components/ScannerOverlay/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +35 -0
- package/lib/typescript/commonjs/components/SearchBar/SearchPanel.d.ts +49 -0
- package/lib/typescript/commonjs/components/SearchBar/highlight.d.ts +14 -0
- package/lib/typescript/commonjs/components/SearchBar/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/SearchBar/useRecentSearches.d.ts +24 -0
- package/lib/typescript/commonjs/components/Select/Select.d.ts +2 -1
- package/lib/typescript/commonjs/components/SignaturePad/SignaturePad.d.ts +94 -0
- package/lib/typescript/commonjs/components/SignaturePad/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/SignaturePad/signatureGeometry.d.ts +36 -0
- package/lib/typescript/commonjs/components/SignaturePad/writePng.d.ts +7 -0
- package/lib/typescript/commonjs/components/SignaturePad/writePng.web.d.ts +3 -0
- package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +41 -0
- package/lib/typescript/commonjs/components/Sparkline/geometry.d.ts +20 -0
- package/lib/typescript/commonjs/components/Sparkline/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +7 -1
- package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +24 -1
- package/lib/typescript/commonjs/components/StatTile/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/Toast/Toast.d.ts +21 -0
- package/lib/typescript/commonjs/components/Toast/ToastProvider.d.ts +21 -0
- package/lib/typescript/commonjs/components/Toast/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +27 -0
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +24 -0
- package/lib/typescript/commonjs/components/Tooltip/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/Tooltip/tooltipPosition.d.ts +35 -0
- package/lib/typescript/commonjs/components/TypingIndicator/TypingIndicator.d.ts +21 -0
- package/lib/typescript/commonjs/components/TypingIndicator/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/WheelPicker/Wheel.d.ts +34 -0
- package/lib/typescript/commonjs/components/WheelPicker/WheelPicker.d.ts +73 -0
- package/lib/typescript/commonjs/components/WheelPicker/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/index.d.ts +34 -8
- package/lib/typescript/commonjs/hooks/index.d.ts +4 -0
- package/lib/typescript/commonjs/hooks/useRefreshControl.d.ts +75 -0
- package/lib/typescript/commonjs/hooks/useScrollDirection.d.ts +21 -0
- package/lib/typescript/commonjs/index.d.ts +4 -4
- package/lib/typescript/commonjs/utils/announce.d.ts +14 -0
- package/lib/typescript/commonjs/utils/hapticUtils.d.ts +1 -1
- package/lib/typescript/commonjs/utils/index.d.ts +2 -0
- package/lib/typescript/commonjs/utils/placement.d.ts +55 -0
- package/lib/typescript/module/components/BarChart/BarChart.d.ts +62 -0
- package/lib/typescript/module/components/BarChart/index.d.ts +3 -0
- package/lib/typescript/module/components/BarChart/scale.d.ts +15 -0
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +32 -0
- package/lib/typescript/module/components/BottomNavigation/index.d.ts +1 -1
- package/lib/typescript/module/components/BottomNavigation/useScreenReaderEnabled.d.ts +8 -0
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +34 -3
- package/lib/typescript/module/components/BottomSheet/index.d.ts +2 -0
- package/lib/typescript/module/components/BottomSheet/useSheetSwap.d.ts +24 -0
- package/lib/typescript/module/components/Card/Card.d.ts +9 -0
- package/lib/typescript/module/components/Composer/Composer.d.ts +61 -0
- package/lib/typescript/module/components/Composer/index.d.ts +3 -0
- package/lib/typescript/module/components/DateSeparator/DateSeparator.d.ts +37 -0
- package/lib/typescript/module/components/DateSeparator/index.d.ts +3 -0
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +3 -1
- package/lib/typescript/module/components/Input/Input.d.ts +2 -2
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +9 -0
- package/lib/typescript/module/components/Menu/Menu.d.ts +46 -0
- package/lib/typescript/module/components/Menu/MenuSurface.d.ts +30 -0
- package/lib/typescript/module/components/Menu/focusHost.d.ts +9 -0
- package/lib/typescript/module/components/Menu/index.d.ts +5 -0
- package/lib/typescript/module/components/Menu/menuModel.d.ts +68 -0
- package/lib/typescript/module/components/Menu/useContextMenu.d.ts +58 -0
- package/lib/typescript/module/components/Menu/webOnly.d.ts +7 -0
- package/lib/typescript/module/components/MessageBubble/MessageBubble.d.ts +87 -0
- package/lib/typescript/module/components/MessageBubble/index.d.ts +3 -0
- package/lib/typescript/module/components/MessageList/MessageList.d.ts +68 -0
- package/lib/typescript/module/components/MessageList/index.d.ts +3 -0
- package/lib/typescript/module/components/OnboardingPager/OnboardingPager.d.ts +53 -0
- package/lib/typescript/module/components/OnboardingPager/index.d.ts +3 -0
- package/lib/typescript/module/components/PaymentResult/PaymentResult.d.ts +71 -0
- package/lib/typescript/module/components/PaymentResult/index.d.ts +3 -0
- package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +74 -0
- package/lib/typescript/module/components/ScannerOverlay/index.d.ts +3 -0
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +35 -0
- package/lib/typescript/module/components/SearchBar/SearchPanel.d.ts +49 -0
- package/lib/typescript/module/components/SearchBar/highlight.d.ts +14 -0
- package/lib/typescript/module/components/SearchBar/index.d.ts +3 -0
- package/lib/typescript/module/components/SearchBar/useRecentSearches.d.ts +24 -0
- package/lib/typescript/module/components/Select/Select.d.ts +2 -1
- package/lib/typescript/module/components/SignaturePad/SignaturePad.d.ts +94 -0
- package/lib/typescript/module/components/SignaturePad/index.d.ts +4 -0
- package/lib/typescript/module/components/SignaturePad/signatureGeometry.d.ts +36 -0
- package/lib/typescript/module/components/SignaturePad/writePng.d.ts +7 -0
- package/lib/typescript/module/components/SignaturePad/writePng.web.d.ts +3 -0
- package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +41 -0
- package/lib/typescript/module/components/Sparkline/geometry.d.ts +20 -0
- package/lib/typescript/module/components/Sparkline/index.d.ts +3 -0
- package/lib/typescript/module/components/Spinner/Spinner.d.ts +7 -1
- package/lib/typescript/module/components/StatTile/StatTile.d.ts +24 -1
- package/lib/typescript/module/components/StatTile/index.d.ts +1 -1
- package/lib/typescript/module/components/Toast/Toast.d.ts +21 -0
- package/lib/typescript/module/components/Toast/ToastProvider.d.ts +21 -0
- package/lib/typescript/module/components/Toast/index.d.ts +1 -1
- package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +27 -0
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +24 -0
- package/lib/typescript/module/components/Tooltip/index.d.ts +1 -1
- package/lib/typescript/module/components/Tooltip/tooltipPosition.d.ts +35 -0
- package/lib/typescript/module/components/TypingIndicator/TypingIndicator.d.ts +21 -0
- package/lib/typescript/module/components/TypingIndicator/index.d.ts +3 -0
- package/lib/typescript/module/components/WheelPicker/Wheel.d.ts +34 -0
- package/lib/typescript/module/components/WheelPicker/WheelPicker.d.ts +73 -0
- package/lib/typescript/module/components/WheelPicker/index.d.ts +3 -0
- package/lib/typescript/module/components/index.d.ts +34 -8
- package/lib/typescript/module/hooks/index.d.ts +4 -0
- package/lib/typescript/module/hooks/useRefreshControl.d.ts +75 -0
- package/lib/typescript/module/hooks/useScrollDirection.d.ts +21 -0
- package/lib/typescript/module/index.d.ts +4 -4
- package/lib/typescript/module/utils/announce.d.ts +14 -0
- package/lib/typescript/module/utils/hapticUtils.d.ts +1 -1
- package/lib/typescript/module/utils/index.d.ts +2 -0
- package/lib/typescript/module/utils/placement.d.ts +55 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{useReducedMotion}from"../../hooks/index.js";import{createAnimatedValue,fontFor,setNativeValue,useTheme}from"../../theme/index.js";import{mergeRefs,triggerHaptic}from"../../utils/index.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Button}from"../Button/index.js";import{FieldBase,FieldErrorGlyph,FieldLabel,fieldTextAsString,hasFieldText,RequiredPlaceholder,resolveFieldSize,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const multilineMinHeightMap={sm:72,md:92,lg:110},Input=forwardRef((e,t)=>{const{label:i,help:
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{useReducedMotion}from"../../hooks/index.js";import{createAnimatedValue,fontFor,setNativeValue,useTheme}from"../../theme/index.js";import{mergeRefs,triggerHaptic}from"../../utils/index.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Button}from"../Button/index.js";import{FieldBase,FieldErrorGlyph,FieldLabel,fieldTextAsString,hasFieldText,RequiredPlaceholder,resolveFieldSize,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{NotationInkContext}from"../Notation/Notation.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const multilineMinHeightMap={sm:72,md:92,lg:110},Input=forwardRef((e,t)=>{const{label:i,help:o,placeholder:n,value:l,onChangeText:r,error:s,helperText:a,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:f=!1,multiline:p=!1,leftIcon:g,rightIcon:m,unit:x,unitStyle:h,prefix:y,prefixStyle:S,readOnly:b=!1,action:v,actionStyle:j,size:F="md",variant:w,labelMode:z,required:T=!1,maxLength:I,showCounter:R=!0,textAlign:V,format:_,parse:A,style:k,containerStyle:C,inputStyle:N,labelStyle:D,messageStyle:H,borderRadius:L,onFocus:E,onBlur:M,accessibilityLabel:P,testID:B,editable:O,...G}=e,q=useTheme(),W=useMemo(()=>buildStyles(q),[q]),$=resolveFieldSize(q,F),X=multilineMinHeightMap[F],J=Math.round(1.4*$.fontSize),K=w??q.components.input?.defaultVariant??q.components.field?.defaultVariant??"outlined",Q=z??q.components.input?.defaultLabelMode??"top",[U,Y]=useState(!1),[Z,ee]=useState(!1),te="password"===d||u||c,ie="password"===d||u,oe="textarea"===d||p,ne=oe?Math.round(.1*$.fontSize):0,le="string"==typeof l&&l.length>0,re=hasFieldText(s),se=!0===s||re,ae=hasFieldText(a),de=re||!se&&ae,ce=hasFieldText(i),ue=hasFieldText(y),fe=!f&&!1!==O,pe=U||le||ue,ge=useRef(null),me=useMemo(()=>mergeRefs(ge,t),[t]),xe=useCallback(()=>{fe&&ge.current?.focus()},[fe]),he=ce&&"float"===Q,ye=useRef(createAnimatedValue(0)).current,Se=useRef(createAnimatedValue(de?1:0)).current;useEffect(()=>{const e=Animated.timing(Se,{toValue:de?1:0,duration:q.motion.duration.fast,easing:Easing.bezier(...q.motion.easing.standard),useNativeDriver:!0});return e.start(),()=>e.stop()},[de,Se,q.motion.duration.fast,q.motion.easing.standard]);const be=useReducedMotion(),ve=q.components.input?.shakeOnError??!1,je=useRef(se);useEffect(()=>{if(!ve)return void(je.current=se);let e;return se&&!je.current&&(be||(setNativeValue(ye,0),e=Animated.sequence([Animated.timing(ye,{toValue:1,duration:50,useNativeDriver:!0}),Animated.timing(ye,{toValue:-1,duration:50,useNativeDriver:!0}),Animated.timing(ye,{toValue:1,duration:50,useNativeDriver:!0}),Animated.timing(ye,{toValue:-1,duration:50,useNativeDriver:!0}),Animated.timing(ye,{toValue:0,duration:100,useNativeDriver:!0})]),e.start()),triggerHaptic("notificationError")),je.current=se,()=>e?.stop()},[se,ye,ve,be]);const Fe=useCallback(e=>{Y(!0),E?.(e)},[E]),we=useCallback(e=>{Y(!1),M?.(e)},[M]),ze=useCallback(()=>{triggerHaptic("selection"),ee(e=>!e)},[]),Te=useMemo(()=>{const e=q.components.input?.fillColors?.[K];if(!e)return;const t={};return void 0!==e.idleEmpty&&(t.backgroundIdleEmpty=e.idleEmpty),void 0!==e.idleFilled&&(t.backgroundIdleFilled=e.idleFilled),void 0!==e.focus&&(t.backgroundFocused=e.focus),void 0!==e.error&&(t.backgroundError=e.error),void 0!==e.disabled&&(t.backgroundDisabled=e.disabled),Object.keys(t).length>0?t:void 0},[q.components.input?.fillColors,K]),Ie=q.colors.field.caret,Re=L??q.components.input?.borderRadius,Ve=q.components.input?.tintLabelOnFocus??!1,_e=U&&Ve?q.colors.field.borderFocused:q.colors.field.label,Ae=ye.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),ke=Boolean(m)||Boolean(x)||ie,Ce="underline"===K,Ne=g?$.iconSize+q.spacing.md+1+q.spacing.md:0,De=useFloatingLabel({label:i,enabled:he,floated:pe,required:T,variant:K,sizeTokens:$,leadingOffset:Ne,trailingOffset:ke?$.iconSize+q.spacing.sm:0,textAlign:V,paddingLeft:Ce?0:$.paddingHorizontal,lineHeight:oe?J:void 0,restNudge:ne,floatTrim:oe?2:0,color:_e,style:D}),He=resolveFieldTextStyle(q,{disabled:f}),Le=He.color,Ee=He.placeholderColor,Me=T&&!ce&&!le&&"string"==typeof n&&n.length>0,Pe=se?s:a,Be=R&&"number"==typeof I&&"string"==typeof l?`${l.length} / ${I}`:null,Oe=se?q.colors.field.message:q.colors.text.secondary,Ge=P??fieldTextAsString(i)??n,qe=q.colors.field,We=f?qe.iconDisabled:U?qe.iconFocused:qe.icon,$e={focused:U,disabled:f,error:se,color:We,size:$.iconSize},renderSlot=e=>renderSlotIcon(e,$e),Xe=(()=>{if(ie){const e=(Z?q.icons?.eyeOff:q.icons?.eye)??(Z?defaultIcons.eyeOff:defaultIcons.eye);return _jsx(Pressable,{onPress:ze,disabled:!fe,hitSlop:8,accessibilityRole:"button",accessibilityLabel:Z?"Hide password":"Show password",children:e({size:$.iconSize,color:We})})}const e=x?_jsx(Text,{style:[W.unit,{fontSize:$.fontSize,color:Ee},h],children:x}):null,t=m?_jsx(View,{children:renderSlot(m)}):null;return e&&t?_jsxs(View,{style:W.trailingRow,children:[e,t]}):e??t})(),Je=g?_jsx(View,{children:renderSlot(g)}):null,Ke=StyleSheet.flatten(S),Qe=Ke?.fontSize??$.fontSize,Ue=Ke?.color??Ee,Ye=useMemo(()=>({fontSize:Qe,color:Ue}),[Qe,Ue]),Ze=ue?"string"==typeof y||"number"==typeof y?_jsx(Text,{style:[W.prefix,{fontSize:$.fontSize,color:Ee,marginRight:q.spacing.xs,lineHeight:oe?J:void 0,paddingTop:oe?ne:void 0},S],children:y}):_jsx(View,{style:[W.prefixNode,{marginRight:q.spacing.xs,minHeight:oe?J:void 0,justifyContent:"center",paddingTop:oe?ne:void 0}],children:_jsx(Text,{style:[W.prefix,{fontSize:$.fontSize,color:Ee,lineHeight:oe?J:void 0},S],children:_jsx(NotationInkContext.Provider,{value:Ye,children:y})})}):null,et=v?_jsx(Button,{variant:v.variant??"outline",tone:v.tone??"primary",size:F,title:v.label,leftIcon:v.icon,loading:v.loading,disabled:f||v.disabled,onPress:v.onPress,pressAnimation:!1,testID:v.testID,style:[W.action,{minHeight:$.minHeight,alignSelf:oe?"flex-start":"stretch"},j]}):null;return _jsxs(Animated.View,{style:[W.container,{transform:[{translateX:Ae}]},k],children:[ce&&!he?_jsx(FieldLabel,{size:F,required:T,help:o,color:_e,style:D,children:i}):null,_jsxs(View,{style:[W.fieldRow,{columnGap:q.spacing.sm,alignItems:oe?"flex-start":"stretch"}],children:[_jsxs(View,{style:W.fieldWrapper,children:[_jsxs(FieldBase,{size:F,variant:K,focused:U,disabled:f,error:se,filled:le,minHeight:oe?X:void 0,borderRadius:Re,fillOverrides:Te,leading:Je,leadingDivider:null!=g,paddingLeft:Ce?0:void 0,trailing:Xe,slotAlign:oe?"top":"center",slotLineHeight:oe?J:void 0,topNotch:De.topNotch,onPress:xe,pressFeedback:!1,style:C,children:[Ze,_jsxs(View,{style:W.inputWrap,children:[_jsx(TextInput,{ref:me,style:[W.input,{color:Le,fontSize:$.fontSize,...He.weightStyle,paddingLeft:Ce?0:void 0,minHeight:oe?X-2*$.paddingVertical:void 0,lineHeight:oe?J:void 0,paddingTop:oe?ne:void 0,textAlignVertical:oe?"top":"center"},N],textAlign:V,placeholder:he&&!pe||Me?void 0:n,placeholderTextColor:Ee,value:_&&null!=l?_(l):l,onChangeText:e=>{r&&r(A?A(e):e)},onFocus:Fe,onBlur:we,editable:fe,readOnly:b,secureTextEntry:te&&!Z,multiline:oe,autoCapitalize:te?"none":void 0,autoCorrect:!te&&void 0,maxLength:I,selectionColor:Ie,accessibilityLabel:Ge,accessibilityState:{disabled:f},"aria-disabled":f,testID:B,...G}),Me?_jsx(RequiredPlaceholder,{text:n,color:Ee,fontSize:$.fontSize,weightStyle:He.weightStyle,align:oe?"top":"center",paddingTop:oe?ne:void 0,textAlign:V}):null]})]}),De.node]}),et]}),de||Be?_jsxs(View,{style:[W.footerRow,{marginTop:$.messageGap}],children:[de?_jsxs(Animated.View,{style:[W.messageRow,{columnGap:q.spacing.xs+2,opacity:Se}],accessibilityLiveRegion:se?"polite":"none",children:[se?_jsx(FieldErrorGlyph,{size:$.messageFontSize,color:Oe}):null,_jsx(Text,{style:[W.messageText,{color:Oe,fontSize:$.messageFontSize,...fontFor(q,"normal")},H],children:Pe})]}):_jsx(View,{style:W.footerSpacer}),Be?_jsx(Text,{style:[W.counterText,{color:q.colors.text.tertiary,fontSize:$.messageFontSize,...fontFor(q,"normal")}],children:Be}):null]}):null]})});Input.displayName="Input";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},fieldRow:{flexDirection:"row"},fieldWrapper:{position:"relative",overflow:"visible",flex:1},action:{flexShrink:0},input:{padding:0,margin:0,includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"},unit:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center",columnGap:8},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:8},footerSpacer:{flex:1},messageRow:{flex:1,flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1},counterText:{flexShrink:0,includeFontPadding:!1}});export{Input};export default Input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,Text,useWindowDimensions,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Button}from"../Button/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Swipeable}from"../Swipeable/index.js";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SIZE_FALLBACK={sm:{paddingVertical:"sm",titleFontSize:"sm",subtitleFontSize:"xs",minHeight:44},md:{paddingVertical:"md",titleFontSize:"base",subtitleFontSize:"sm",minHeight:56},lg:{paddingVertical:"lg",titleFontSize:"lg",subtitleFontSize:"sm",minHeight:72}},sizeFor=(e,t)=>{const i={...SIZE_FALLBACK[t],...e.components.listItem?.[t]??{}};return{paddingVertical:e.spacing[i.paddingVertical],titleSize:e.typography.fontSize[i.titleFontSize],subtitleSize:e.typography.fontSize[i.subtitleFontSize],minHeight:i.minHeight}},Chevron=({color:e})=>{const t=useTheme();return _jsx(_Fragment,{children:(t.icons?.chevronRight??defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,DEFAULT_BOX_SIZE=20,SelectionBox=({checked:e,disabled:t})=>{const i=useTheme(),s=i.components.checkbox?.md?.boxSize??20,
|
|
1
|
+
"use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,Text,useWindowDimensions,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Button}from"../Button/index.js";import{IconBadge}from"../IconBadge/index.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton}from"../Skeleton/index.js";import{Swipeable}from"../Swipeable/index.js";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SIZE_FALLBACK={sm:{paddingVertical:"sm",titleFontSize:"sm",subtitleFontSize:"xs",minHeight:44},md:{paddingVertical:"md",titleFontSize:"base",subtitleFontSize:"sm",minHeight:56},lg:{paddingVertical:"lg",titleFontSize:"lg",subtitleFontSize:"sm",minHeight:72}},sizeFor=(e,t)=>{const i={...SIZE_FALLBACK[t],...e.components.listItem?.[t]??{}};return{paddingVertical:e.spacing[i.paddingVertical],titleSize:e.typography.fontSize[i.titleFontSize],subtitleSize:e.typography.fontSize[i.subtitleFontSize],minHeight:i.minHeight}},Chevron=({color:e})=>{const t=useTheme();return _jsx(_Fragment,{children:(t.icons?.chevronRight??defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,DEFAULT_BOX_SIZE=20,SelectionBox=({checked:e,disabled:t})=>{const i=useTheme(),s=i.components.checkbox?.md?.boxSize??20,o=Math.round(.72*s);return _jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.colors.border.width,borderRadius:i.radius.xs,...smoothCorners,borderColor:e?i.colors.primary:i.colors.border.primary,backgroundColor:e?i.colors.primary:t?i.colors.surface.disabled:"transparent"},children:e?_jsx(Svg,{width:o,height:o,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors.onPrimary,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})}):null})},isActionList=e=>Array.isArray(e)&&e.length>0&&e.every(e=>null!=e&&"object"==typeof e&&!React.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>_jsx(Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,title:e.label,onPress:e.onPress},e.label)):e,ListItem=forwardRef((e,t)=>{const{title:i,loading:s=!1,subtitle:o,description:n,titleLines:r=1,subtitleLines:l=1,left:a,icon:c,iconTone:d="primary",right:m,rightPlacement:h="auto",selectable:u=!1,checked:g=!1,onCheckedChange:p,actions:x,onPress:b,haptic:f,selected:y=!1,disabled:S=!1,size:j="md",divider:_=!1,chevron:w=!1,leftActions:I,rightActions:L,contextMenu:v,accessibilityLabel:k,accessibilityHint:z,style:V,containerStyle:F,titleStyle:A,subtitleStyle:C,descriptionStyle:B,leftSlotStyle:H,rightSlotStyle:R,testID:D}=e,P=useTheme(),T=useMemo(()=>sizeFor(P,j),[P,j]),E=useMemo(()=>buildStyles(P),[P]),{fontScale:M}=useWindowDimensions(),W=!!m&&("below"===h||"auto"===h&&M>1.2),O=useContextMenu(S?void 0:v,{haptic:f,testID:D}),G=useMemo(()=>mergeRefs(t,O.hostRef),[t,O.hostRef]),Z=u||!!b,N=Z||O.enabled,K=N&&!S,{scale:U,pressIn:X,pressOut:q}=usePressAnimation({enabled:K}),J=useFlickGuard(),Q=k??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,Y=a??(void 0===c?null:_jsx(IconBadge,{icon:c,tone:d,size:BADGE_SIZE[j]})),$=u?_jsxs(View,{style:E.selectionLead,children:[_jsx(SelectionBox,{checked:g,disabled:S}),Y?_jsx(View,{style:E.selectionLeadContent,children:Y}):null]}):Y,ee=null!=x&&!1!==x&&!(Array.isArray(x)&&0===x.length),te=_&&!ee,ie=_jsxs(View,{style:[E.row,{paddingVertical:T.paddingVertical,minHeight:T.minHeight,backgroundColor:y?P.colors.surface.selected:"transparent"},te?E.divider:null,S?E.disabled:null,F],children:[$?_jsx(View,{style:[E.leftSlot,H],children:$}):null,_jsxs(View,{style:E.middle,children:[null==i||isText(i)?_jsx(Text,{style:[E.title,{fontSize:T.titleSize,...fontFor(P,"medium"),color:S?P.colors.text.disabled:P.colors.text.primary},A],numberOfLines:r,children:i??" "}):i,null==o||""===o?null:isText(o)?_jsx(Text,{style:[E.subtitle,{fontSize:T.subtitleSize,color:S?P.colors.text.disabled:P.colors.text.secondary},C],numberOfLines:l,children:o}):o,n?_jsx(Text,{style:[E.description,{fontSize:T.subtitleSize,color:S?P.colors.text.disabled:P.colors.text.tertiary},B],numberOfLines:2,children:n}):null,W?_jsx(View,{style:[E.rightBelow,R],children:m}):null]}),m&&!W||w?_jsxs(View,{style:[E.rightSlot,W?null:R],children:[W?null:m,w?_jsx(View,{style:m&&!W?E.chevronWithRight:null,children:_jsx(Chevron,{color:S?P.colors.text.disabled:P.colors.text.tertiary})}):null]}):null]}),se=N?_jsx(Animated.View,{style:[{transform:[{scale:U}]},V],children:_jsx(Pressable,{ref:G,onPress:e=>{if(!K||!Z||J.isFlick(e))return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),u?p?.(!g):b?.(e)},onPressIn:e=>{J.onPressIn(e),X()},onPressOut:q,disabled:!K,accessibilityRole:u?"checkbox":b?"button":void 0,accessibilityLabel:Q,accessibilityHint:z,accessibilityState:u?{checked:g,disabled:!K}:{selected:y,disabled:!K},"aria-disabled":!K,...u?{"aria-checked":g}:{"aria-selected":y},testID:D,android_ripple:{color:P.colors.surface.pressed,borderless:!1},style:({pressed:e})=>e?E.pressed:null,...O.hostProps,children:ie})}):_jsx(View,{ref:t,accessibilityRole:"none",accessibilityLabel:Q,accessibilityHint:z,accessibilityState:{selected:y,disabled:S},"aria-selected":y,"aria-disabled":S,testID:D,style:V,children:ie}),oe=I&&I.length>0||L&&L.length>0,ne=ee?_jsxs(View,{style:[y?{backgroundColor:P.colors.surface.selected}:null,_?E.divider:null],children:[se,_jsx(View,{style:E.actions,children:renderActions(x)})]}):se,re=oe?_jsx(Swipeable,{leftActions:I,rightActions:L,accessibilityLabel:Q,children:ne}):ne;return s?_jsx(ListItemSkeleton,{...e}):O.enabled?_jsxs(_Fragment,{children:[re,O.renderSurface(_jsx(View,{style:E.preview,children:ie}))]}):re});ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,left:i,icon:s,right:o,chevron:n,size:r="md",containerStyle:l,style:a})=>{const c=useTheme(),d=sizeFor(c,r),m=Math.round(1.15*d.titleSize),h=Math.round(1.15*d.subtitleSize);return _jsxs(View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.spacing.md,paddingVertical:d.paddingVertical,minHeight:d.minHeight},l,a],children:[void 0!==i||void 0!==s?_jsx(View,{style:{marginRight:c.spacing.sm},children:_jsx(Skeleton,{shape:"circle",width:40,height:40})}):null,_jsxs(View,{style:{flex:1},children:[_jsx(Skeleton,{shape:"text",width:"70%",height:m,style:{marginBottom:c.spacing.xs}}),void 0!==e?_jsx(Skeleton,{shape:"text",width:"50%",height:h,style:void 0!==t?{marginBottom:c.spacing.xs}:void 0}):null,void 0!==t?_jsx(Skeleton,{shape:"text",width:"85%",height:h}):null]}),void 0!==o||n?_jsx(View,{style:{marginLeft:c.spacing.sm},children:_jsx(Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.spacing.md},divider:{borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors.border.primary},pressed:{backgroundColor:e.colors.surface.pressed},disabled:{opacity:.55},leftSlot:{marginRight:e.spacing.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.spacing.sm},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.spacing.xs},rightSlot:{marginLeft:e.spacing.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.spacing.sm,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.md},chevronWithRight:{marginLeft:e.spacing.xs},preview:{flex:1,backgroundColor:e.colors.background.elevated,borderRadius:e.radius.md,...smoothCorners,overflow:"hidden"},title:{letterSpacing:e.typography.letterSpacing.normal},subtitle:{marginTop:2,...fontFor(e,"normal")},description:{marginTop:2,...fontFor(e,"normal")}});export{ListItem};export default ListItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import React,{useCallback,useEffect,useMemo,useRef,useState}from"react";import{View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{MenuSurface}from"./MenuSurface.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const Menu=e=>{const{items:t,trigger:s,title:a,topActions:l,placement:r="bottom",presentation:n="auto",unavailable:o="disable",open:u,onOpenChange:c,haptic:i,accessibilityLabel:m,closeLabel:f="Close menu",backLabel:p="Back",testID:b}=e,[x,g]=useControllableState({value:u,defaultValue:!1,onChange:c}),[h,j]=useState(null),[C,d]=useState(x),S=useRef(null),M=useRef(null);useEffect(()=>{x?(d(!0),S.current?.measureInWindow((e,t,s,a)=>{j({x:e,y:t,width:s,height:a})})):j(null)},[x]);const R=useCallback(()=>g(!1),[g]),k=useCallback(()=>M.current??S.current,[]),_=s.props,L=_.ref,v={ref:useMemo(()=>mergeRefs(L,M),[L]),"aria-expanded":x,onPress:e=>{_.onPress?.(e),g(!0)}};return _jsxs(_Fragment,{children:[_jsx(View,{ref:S,collapsable:!1,testID:b,children:React.cloneElement(s,v)}),C?_jsx(MenuSurface,{open:x,anchor:h,items:t,title:a,topActions:l,placement:r,presentation:n,unavailable:o,onClose:R,restoreFocusTo:k,haptic:i,accessibilityLabel:m,closeLabel:f,backLabel:p,testID:b}):null]})};export{Menu};export default Menu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Modal,Platform,Pressable,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{claimAnchoredSurface,computePlacement,PLACEMENT_MARGIN,placementRoom}from"../../utils/placement.js";import{Breakpoints}from"../../utils/responsive.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Divider}from"../Divider/index.js";import{OptionSheet}from"../OptionSheet/index.js";import{Text}from"../Text/index.js";import{ToastHost}from"../Toast/ToastProvider.js";import{FOCUS_DELAY_MS,focusHost}from"./focusHost.js";import{visibleGroups,visibleTopActions,wantsSheet}from"./menuModel.js";import{webOnly}from"./webOnly.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MENU_MIN_WIDTH=180,MENU_MAX_WIDTH=280,ROW_MIN_HEIGHT=48,TOP_ACTION_MIN_HEIGHT=64,ICON_SIZE=20,PREVIEW_LIFT=1.02,BACK_KEY="__menu-back",TOP_PREFIX="__menu-top:",WEB_CHECKABLE_ROLE=webOnly({role:"menuitemcheckbox"});export const MenuSurface=e=>{const{open:t,anchor:s,items:i,title:o,topActions:r,placement:n,presentation:l,unavailable:a,context:c=!1,preview:u,onClose:d,restoreFocusTo:m,haptic:p,accessibilityLabel:b,closeLabel:f,backLabel:h,testID:y}=e,x=useTheme(),g=useMemo(()=>buildStyles(x),[x]),_=useSafeAreaInsets(),v=useWindowDimensions(),w=useReducedMotion(),j=useMemo(()=>visibleGroups(i,a),[i,a]),A=useMemo(()=>visibleTopActions(r,a),[r,a]),k="sheet"===l||"auto"===l&&v.width<Breakpoints.lg&&wantsSheet(j,A),[I,S]=useState(null),[E,R]=useState(null),T=useRef(d);T.current=d;const C=useRef(m);C.current=m;const L=useRef(null),D=useRef(!1),M=useRef(!1),O=useRef(new Map),P=useRef(null),H=useCallback(()=>{if(!D.current)return;D.current=!1;const e=L.current;L.current=null,e?e():focusHost(C.current?.())},[]);useEffect(()=>{if(t)return M.current=!0,D.current=!1,L.current=null,claimAnchoredSurface(()=>T.current());M.current&&(M.current=!1,D.current=!0,S(null),R(null),k||"ios"===Platform.OS||H())},[t]);const V=useCallback(e=>{if(e.disabled)return;const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),e.key!==BACK_KEY?e.submenu?S(e):(L.current=e.onPress??null,T.current()):S(null)},[p]),B=useMemo(()=>({width:v.width,height:v.height,insets:_}),[v.width,v.height,_]),N=useMemo(()=>{if(!s||!E)return null;const e=s.x+s.width/2>B.width/2?"end":"start";return computePlacement(s,E,B,n,{align:e})},[s,E,B,n]);let F=B.height-_.top-_.bottom-2*PLACEMENT_MARGIN;if(s&&N){const e=placementRoom(s,B);F="top"===N.placement?e.above:e.below}const K=Math.min(280,B.width-_.left-_.right-2*PLACEMENT_MARGIN),W=t&&null!==N,G=useRef(createAnimatedValue(0)).current,z=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!W)return setNativeValue(G,0),void setNativeValue(z,1);const e=[Animated.timing(G,{toValue:1,duration:x.motion.duration.fast,easing:Easing.bezier(...x.motion.easing.decelerate),useNativeDriver:!0})];c&&!w&&e.push(Animated.spring(z,{toValue:1.02,damping:x.motion.spring.snappy.damping,stiffness:x.motion.spring.snappy.stiffness,mass:x.motion.spring.snappy.mass,useNativeDriver:!0}));const t=Animated.parallel(e);return t.start(),()=>t.stop()},[W,c,w,G,z,x.motion]);const $=useCallback(e=>{const{width:t,height:s}=e.nativeEvent.layout;R(e=>e&&e.width===t&&e.height===s?e:{width:t,height:s})},[]),Y=c&&"top"===N?.placement,U=I?.submenu?[I.submenu]:j,X=Y?[...U].reverse().map(e=>[...e].reverse()):U,q=[];if(I)q.push({key:BACK_KEY,label:I.label});else for(const e of A)q.push({key:`${TOP_PREFIX}${e.key}`,label:e.label,item:e});for(const e of X)for(const t of e)q.push({key:t.key,label:t.label,item:t});const Z=q[0]?.key;useEffect(()=>{if(!W||k||!Z)return;const e=setTimeout(()=>focusHost(O.current.get(Z)),FOCUS_DELAY_MS);return()=>clearTimeout(e)},[W,k,Z]);const setItemRef=e=>t=>{t?O.current.set(e,t):O.current.delete(e)},J=webOnly({onKeyDown:e=>{const t=e.key??e.nativeEvent?.key??"",s=q.length,i=q.findIndex(e=>e.key===P.current);let o=-1;if("ArrowDown"===t)o=(i+1)%s;else if("ArrowUp"===t)o=i<=0?s-1:i-1;else if("Home"===t)o=0;else if("End"===t)o=s-1;else{if("ArrowLeft"===t&&I)return e.preventDefault?.(),void S(null);if("ArrowRight"===t&&q[i]?.item?.submenu)return e.preventDefault?.(),void V(q[i].item);if(1===t.length&&""!==t.trim()){const e=t.toLowerCase();for(let t=1;t<=s;t+=1){const r=(i+t)%s;if(q[r].label.toLowerCase().startsWith(e)){o=r;break}}}}o>=0&&(e.preventDefault?.(),(e=>{const t=q[e];t&&focusHost(O.current.get(t.key))})(o))}});if(k){const e=I?.submenu?[{key:BACK_KEY,label:h,icon:"chevron-left"},...I.submenu]:[...A,...j.flat()],s=new Set(e.filter(e=>e.checked).map(e=>e.key));return _jsx(OptionSheet,{open:t,onClose:d,onAfterClose:H,title:I?.label??o,options:e,labelOf:e=>e.label,getValue:e=>e.key,disabledOf:e=>Boolean(e.disabled),destructiveOf:e=>Boolean(e.destructive),descriptionOf:e=>e.description,iconOf:e=>{const t=e;return renderSlotIcon(t.icon,{color:t.destructive?x.colors.toneText.error:x.colors.text.secondary,size:20,disabled:Boolean(t.disabled)})},isSelected:e=>s.has(String(e)),onSelect:e=>V(e),accessibilityLabel:b??o,testID:y?`${y}-sheet`:void 0})}const inkFor=e=>e.disabled?x.colors.text.disabled:e.destructive?x.colors.toneText.error:x.colors.text.primary,Q=_jsxs(_Fragment,I?{children:[_jsxs(Pressable,{ref:setItemRef(BACK_KEY),onPress:()=>S(null),onFocus:()=>{P.current=BACK_KEY},accessibilityRole:"menuitem",accessibilityLabel:`${h}, ${I.label}`,android_ripple:{color:x.colors.surface.pressed,borderless:!1},style:({pressed:e})=>[g.row,e?g.pressed:null],children:[_jsx(View,{style:g.icon,children:_jsx(AppIcon,{name:"chevron-left",size:20,color:x.colors.text.secondary})}),_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:1,style:g.labels,children:I.label})]}),_jsx(Divider,{spacing:"none"})]}:{children:[o?_jsx(Text,{variant:"caption",color:"secondary",accessibilityRole:"header",numberOfLines:2,style:g.title,children:o}):null,A.length>0?_jsxs(_Fragment,{children:[_jsx(View,{style:g.topRow,children:A.map(e=>{const t=`${TOP_PREFIX}${e.key}`,s=Boolean(e.disabled),i=inkFor(e);return _jsxs(Pressable,{ref:setItemRef(t),onPress:()=>V(e),onFocus:()=>{P.current=t},disabled:s,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityState:{disabled:s},"aria-disabled":s,testID:e.testID,style:({pressed:e})=>[g.topAction,e?g.pressed:null],children:[renderSlotIcon(e.icon,{color:i,size:20,disabled:s}),_jsx(Text,{variant:"caption",color:i,numberOfLines:1,children:e.label})]},t)})}),_jsx(Divider,{spacing:"none"})]}):null]});return _jsxs(Modal,{visible:t,transparent:!0,statusBarTranslucent:!0,presentationStyle:"overFullScreen",animationType:"none",onRequestClose:d,onDismiss:H,children:[_jsx(Pressable,{style:[StyleSheet.absoluteFill,c?g.scrim:null],onPress:d,accessibilityRole:"button",accessibilityLabel:f,testID:y?`${y}-scrim`:void 0}),c&&u&&s?_jsx(Animated.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[g.preview,{left:s.x,top:s.y,width:s.width,height:s.height,transform:[{scale:z}]}],children:u}):null,_jsx(Animated.View,{accessibilityRole:"menu",accessibilityLabel:I?.label??b??o,onLayout:$,testID:y?`${y}-menu`:void 0,...J,style:[g.anchored,{left:N?.x??0,top:N?.y??0,maxWidth:K,opacity:W?G:0}],children:_jsx(View,{style:g.surface,children:_jsxs(View,{style:[g.clip,{maxHeight:F}],children:[Q,_jsx(ScrollView,{style:g.scroll,bounces:!1,keyboardShouldPersistTaps:"handled",children:X.map((e,t)=>{const s=e.some(e=>null!=e.icon);return _jsxs(View,{children:[t>0?_jsx(Divider,{spacing:"none"}):null,e.map(e=>((e,t)=>{const s=Boolean(e.disabled),i=inkFor(e);return _jsxs(Pressable,{ref:setItemRef(e.key),onPress:()=>V(e),onFocus:()=>{P.current=e.key},disabled:s,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityState:{disabled:s,checked:e.checked},"aria-disabled":s,"aria-checked":e.checked,...void 0!==e.checked?WEB_CHECKABLE_ROLE:null,android_ripple:{color:x.colors.surface.pressed,borderless:!1},testID:e.testID,style:({pressed:e})=>[g.row,e?g.pressed:null],children:[t?_jsx(View,{style:g.icon,children:renderSlotIcon(e.icon,{color:i,size:20,disabled:s})}):null,_jsxs(View,{style:g.labels,children:[_jsx(Text,{variant:"body",color:i,numberOfLines:2,children:e.label}),e.description?_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:2,children:e.description}):null]}),e.detail?_jsx(Text,{variant:"caption",color:"tertiary",children:e.detail}):null,e.checked?_jsx(AppIcon,{name:"check",size:20,color:x.colors.primary}):null,e.submenu?_jsx(AppIcon,{name:"chevron-right",size:20,color:x.colors.text.tertiary}):null]},e.key)})(e,s))]},e[0].key)})})]})})}),_jsx(ToastHost,{})]})};const buildStyles=e=>StyleSheet.create({scrim:{backgroundColor:e.colors.background.overlay},preview:{position:"absolute"},anchored:{position:"absolute",minWidth:180},surface:{backgroundColor:e.colors.background.elevated,borderRadius:e.radius.md,...smoothCorners,...e.shadows.lg},clip:{borderRadius:e.radius.md,...smoothCorners,overflow:"hidden"},scroll:{flexGrow:0,flexShrink:1},title:{paddingHorizontal:e.spacing.md,paddingTop:e.spacing.sm,paddingBottom:e.spacing.xs},row:{flexDirection:"row",alignItems:"center",gap:e.spacing.md,minHeight:48,paddingHorizontal:e.spacing.md,paddingVertical:e.spacing.sm},pressed:{backgroundColor:e.colors.surface.pressed},icon:{width:20,alignItems:"center"},labels:{flexGrow:1,flexShrink:1},topRow:{flexDirection:"row",padding:e.spacing.xs,gap:e.spacing.xs},topAction:{flexGrow:1,flexBasis:0,alignItems:"center",justifyContent:"center",gap:e.spacing.xs,minHeight:64,borderRadius:e.radius.sm,...smoothCorners}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{AccessibilityInfo,Platform}from"react-native";export const FOCUS_DELAY_MS=150;const isHost=s=>null!=s&&"function"==typeof s.measureInWindow;export const focusHost=s=>{"web"!==Platform.OS?isHost(s)&&AccessibilityInfo.sendAccessibilityEvent(s,"focus"):s?.focus?.()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{default,Menu}from"./Menu.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Logger}from"@webority/mobile-core";export const MAX_GROUPS=3;export const MAX_TOP_ACTIONS=3;export const SHEET_ITEM_THRESHOLD=7;export const ACTION_PREFIX="menu:";const isGrouped=e=>e.length>0&&Array.isArray(e[0]),isShown=(e,t)=>!(e.hidden||"hide"===t&&e.disabled),visibleItem=(e,t)=>{if(!isShown(e,t))return null;if(!e.submenu)return e;const o=e.submenu.filter(e=>isShown(e,t));return o.length>0?{...e,submenu:o}:null};export const visibleGroups=(e,t)=>{const o=isGrouped(e)?e:[e];__DEV__&&o.length>3&&Logger.warn(`[Menu] ${o.length} groups given; a menu keeps to 3.`);const n=[];for(const e of o){const o=[];for(const n of e){const e=visibleItem(n,t);e&&o.push(e)}o.length>0&&n.push(o)}return n};export const visibleTopActions=(e,t)=>{if(!e)return[];__DEV__&&e.length>3&&Logger.warn("[Menu] topActions takes at most 3; the rest are not shown.");return e.slice(0,3).filter(e=>isShown(e,t)&&!e.submenu)};export const wantsSheet=(e,t)=>{let o=t.length;for(const t of e)for(const e of t)if(o+=1,e.description)return!0;return o>7};export const menuActions=(e,t)=>{const o=[],add=(e,t)=>{if(e.disabled)return;if(e.submenu){for(const t of e.submenu)add(t,e);return}const n=e.accessibilityLabel??e.label;o.push({name:`menu:${t?`${t.key}/`:""}${e.key}`,label:t?`${t.label}, ${n}`:n,item:e})};for(const e of t)add(e);for(const t of e)for(const e of t)add(e);return o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{MenuSurface}from"./MenuSurface.js";import{menuActions,visibleGroups,visibleTopActions}from"./menuModel.js";import{webOnly}from"./webOnly.js";import{jsx as _jsx}from"react/jsx-runtime";export const useContextMenu=(e,t={})=>{const s=useRef(null),[n,i]=useState(!1),[o,c]=useState(!1),[a,r]=useState(null),l=e?.unavailable??"hide",u=e?.items,p=e?.topActions,m=useMemo(()=>u?visibleGroups(u,l):[],[u,l]),b=useMemo(()=>visibleTopActions(p,l),[p,l]),f=useMemo(()=>menuActions(m,b),[m,b]),v=m.length>0||b.length>0,h=useRef(e);h.current=e;const A=useRef(t);A.current=t;const g=useRef(f);g.current=f;const C=useCallback(e=>{e&&c(!0),i(e),h.current?.onOpenChange?.(e)},[]);useEffect(()=>{!v&&n&&C(!1)},[v,n,C]);const M=useCallback(()=>{s.current?.measureInWindow((e,t,s,n)=>{r({x:e,y:t,width:s,height:n}),C(!0)})},[C]),d=useCallback(()=>{const e=resolveHaptic(A.current.haptic,"longPress");e&&triggerHaptic(e),M()},[M]),k=useCallback(e=>{const t=g.current.find(t=>t.name===e.nativeEvent.actionName);if(!t)return void A.current.onAccessibilityAction?.(e);const s=resolveHaptic(A.current.haptic,"selection");s&&triggerHaptic(s),t.item.onPress?.()},[]),x=t.accessibilityActions,y=useMemo(()=>[...x??[],...f.map(e=>({name:e.name,label:e.label}))],[x,f]),j=useMemo(()=>v?{onLongPress:d,accessibilityActions:y,onAccessibilityAction:k,...webOnly({onContextMenu:e=>{e.preventDefault?.(),M()}})}:{},[v,d,y,k,M]),w=useCallback(()=>C(!1),[C]),S=useCallback(()=>s.current,[]);return{enabled:v,hostRef:s,hostProps:j,renderSurface:s=>e&&v&&o?_jsx(MenuSurface,{open:n,anchor:a,items:e.items,title:e.title,topActions:e.topActions,placement:e.placement??"bottom",presentation:e.presentation??"auto",unavailable:l,context:!0,preview:!1===e.preview?void 0:e.preview??s,onClose:w,restoreFocusTo:S,haptic:t.haptic,accessibilityLabel:e.accessibilityLabel,closeLabel:e.closeLabel??"Close menu",backLabel:e.backLabel??"Back",testID:t.testID?`${t.testID}-context`:void 0}):null}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Platform}from"react-native";export const webOnly=t=>"web"===Platform.OS?t:null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatTime}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef}from"react";import{Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{Markdown}from"../Markdown/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_MESSAGE_BUBBLE_LABELS=Object.freeze({you:"You",sending:"Sending",sent:"Sent",delivered:"Delivered",read:"Read",failed:"Not sent",retry:"Try again",replyTo:e=>e?`Reply to ${e}`:"Reply"});const RUN_GAP=2,MAX_WIDTH="85%",STATUS_ICON=14,statusIcon=e=>{switch(e){case"sending":return"clock";case"sent":return"check";case"failed":return"alert-circle";default:return"check-check"}},statusColour=(e,t)=>{switch(t){case"read":return e.colors.toneText.info;case"failed":return e.colors.toneText.error;default:return e.colors.text.tertiary}};export const MessageBubble=({side:e,text:t,children:s,markdown:r=!1,groupPosition:o="single",author:n,time:i,status:a,replyTo:l,streaming:c=!1,error:d,onRetry:u,actions:m,onLongPress:p,footer:b,labels:x,haptic:f,style:y,testID:g})=>{const h=useTheme(),T=useMemo(()=>buildStyles(h),[h]),j=x?{...DEFAULT_MESSAGE_BUBBLE_LABELS,...x}:DEFAULT_MESSAGE_BUBBLE_LABELS,_="mine"===e,L="single"===o||"first"===o,S="single"===o||"last"===o,B=null==i?"":formatTime(i),A=("failed"===a||Boolean(d))&&Boolean(u),E=_?j.you:n??"",v=useMemo(()=>{const e=m?[...m]:[];return l?.onPress&&e.push({name:"openReply",label:j.replyTo(l.author),onPress:l.onPress}),A&&u&&e.push({name:"retry",label:j.retry,onPress:u}),e},[m,l,A,u,j]),P=!s||(m?.length??0)>0,I=a&&_?j[a]:"",M=[E,B,t,l?`${j.replyTo(l.author)}: ${l.text}`:"",I].filter(Boolean).join(", "),R=useRef(c);useEffect(()=>{R.current&&!c&&!d&&t&&announce(E?`${E}, ${t}`:t),R.current=c},[c,d,t,E]);const k=useRef(d);useEffect(()=>{d&&d!==k.current&&announce(d,{polite:!1}),k.current=d},[d]);const w=useCallback(()=>{const e=resolveHaptic(f,"longPress");e&&triggerHaptic(e),p?.()},[f,p]),C=useCallback(e=>{v.find(t=>t.name===e.nativeEvent.actionName)?.onPress()},[v]),D=h.radius.xl,$=h.radius.xs,H=_?{borderTopRightRadius:L?D:$,borderBottomRightRadius:S?D:$}:{borderTopLeftRadius:L?D:$,borderBottomLeftRadius:S?D:$},U=s??(r?_jsx(Markdown,{children:t}):_jsx(Text,{variant:"body",children:t})),z=l?_jsxs(Pressable,{onPress:l.onPress,disabled:!l.onPress,accessibilityRole:l.onPress?"button":void 0,accessibilityLabel:`${j.replyTo(l.author)}: ${l.text}`,style:T.quote,children:[l.author?_jsx(Text,{variant:"caption",weight:"semibold",color:"link",numberOfLines:1,children:l.author}):null,_jsx(Text,{variant:"bodySmall",color:"secondary",numberOfLines:2,children:l.text})]}):null,V=[T.bubble,_?T.mine:T.theirs,H],F=P?{accessible:!0,accessibilityLabel:M,accessibilityState:{busy:c},"aria-busy":c,accessibilityActions:v.map(({name:e,label:t})=>({name:e,label:t})),onAccessibilityAction:C}:{accessible:!1},O=(m?.length??0)>0?_jsxs(Pressable,{onLongPress:w,delayLongPress:350,style:V,testID:g?`${g}-bubble`:void 0,...F,children:[z,U]}):_jsxs(View,{style:V,testID:g?`${g}-bubble`:void 0,...F,children:[z,U]}),G=S&&(""!==B||_&&a);return _jsxs(View,{style:[T.root,_?T.rootMine:T.rootTheirs,{marginTop:L?h.spacing.sm:2},y],testID:g,children:[!_&&L&&n?_jsx(Text,{variant:"caption",color:"secondary",style:T.author,numberOfLines:1,importantForAccessibility:P?"no-hide-descendants":"auto",accessibilityElementsHidden:P,children:n}):null,O,G?_jsxs(View,{style:[T.meta,_?T.metaMine:null],importantForAccessibility:P?"no-hide-descendants":"auto",accessibilityElementsHidden:P,children:[B?_jsx(Text,{variant:"caption",color:"tertiary",children:B}):null,_&&a?_jsx(AppIcon,{name:statusIcon(a),size:14,color:statusColour(h,a),accessibilityLabel:j[a],testID:g?`${g}-status-${a}`:void 0}):null]}):null,d?_jsx(Text,{variant:"bodySmall",color:"error",style:_?T.endText:null,children:d}):null,A?_jsx(Button,{title:j.retry,variant:"link",size:"sm",leftIcon:"refresh-cw",onPress:u,testID:g?`${g}-retry`:void 0}):null,b]})};const buildStyles=e=>StyleSheet.create({root:{maxWidth:"85%",gap:e.spacing.xs},rootMine:{alignSelf:"flex-end",alignItems:"flex-end"},rootTheirs:{alignSelf:"flex-start",alignItems:"flex-start"},author:{paddingHorizontal:e.spacing.md},bubble:{borderRadius:e.radius.xl,...smoothCorners,paddingHorizontal:e.spacing.md,paddingVertical:e.spacing.sm,gap:e.spacing.xs},mine:{backgroundColor:e.colors.primaryMuted},theirs:{backgroundColor:e.colors.background.secondary},quote:{borderLeftWidth:3,borderLeftColor:e.colors.primary,paddingLeft:e.spacing.sm,paddingVertical:e.spacing.xs},meta:{flexDirection:"row",alignItems:"center",gap:e.spacing.xs,paddingHorizontal:e.spacing.xs},metaMine:{justifyContent:"flex-end"},endText:{textAlign:"right"}});export default MessageBubble;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{DEFAULT_MESSAGE_BUBBLE_LABELS,default,MessageBubble}from"./MessageBubble.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatDate}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{FlatList,StyleSheet,View}from"react-native";import{KeyboardChatScrollView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{Badge}from"../Badge/index.js";import{DateSeparator,dayLabel}from"../DateSeparator/index.js";import{IconButton}from"../IconButton/index.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"});const JUMP_AT=160,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:160},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";export function MessageList({messages:e,keyExtractor:t,renderMessage:o,getAuthorKey:n,getDate:s,firstUnreadKey:r,onLoadOlder:a,loadingOlder:l=!1,hasOlder:i=!0,typing:d,empty:u,getAnnouncement:c,followNew:m,keyboardAware:p=!0,keyboardOffset:f,labels:g,now:y,onScroll:x,contentContainerStyle:b,style:j,testID:S,...h}){const _=useTheme(),w=useSafeAreaInsets(),L=useReducedMotion(),E=useMemo(()=>buildStyles(_),[_]),C=useMemo(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...g}),[g]),v=f??w.bottom,I=useRef(null),T=useRef(!1),[k,M]=useState(!1),[O,D]=useState(0),A=useMemo(()=>{const o=s?e.map(e=>formatDate(s(e))):null,a=n?e.map(n):null,l=void 0===r?-1:e.findIndex(e=>t(e)===r);return e.map((t,n)=>{const r=n===e.length-1,i=null!==o&&(r||o[n]!==o[n+1]),d=null!==a&&!r&&a[n+1]===a[n]&&!i&&n!==l,u=null!==a&&n>0&&a[n-1]===a[n]&&(null===o||o[n-1]===o[n])&&n-1!==l;return{groupPosition:positionOf(d,u),day:i&&s?dayLabel(s(t),{now:y,labels:C}):null,unread:n===l}})},[e,s,n,r,t,y,C]),V=useCallback(()=>{I.current?.scrollToOffset({offset:0,animated:!L}),D(0)},[L]),F=e.length>0?t(e[0]):null,P=useRef(F);useEffect(()=>{const o=P.current;if(P.current=F,null===o||null===F||o===F)return;const n=e.findIndex(e=>t(e)===o);if(-1===n)return void D(0);const s=e.slice(0,n).reverse();for(const e of s){const t=c?.(e);t&&announce(t)}m&&s.some(m)?V():T.current&&D(e=>e+s.length)},[F]);const R=useCallback(e=>{const t=e.nativeEvent.contentOffset.y>160;t!==T.current&&(T.current=t,M(t),t||D(0)),x?.(e)},[x]),B=useCallback(()=>{i&&!l&&a?.()},[i,l,a]),K=useCallback(({item:e,index:t})=>{const n=A[t];return _jsxs(_Fragment,{children:[n?.day?_jsx(DateSeparator,{label:n.day}):null,n?.unread?_jsx(DateSeparator,{label:C.unread,emphasis:!0}):null,o({item:e,index:t,groupPosition:n?.groupPosition??"single"})]})},[A,C.unread,o]),z=useCallback(e=>t(e),[t]),N=useCallback(e=>_jsx(KeyboardChatScrollView,{...e,inverted:!0,offset:v}),[v]),U=O>0?`${C.newMessages(O)}. ${C.jumpToLatest}`:C.jumpToLatest;return _jsxs(View,{style:[E.root,j],children:[_jsx(FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...h,ref:I,data:e,renderItem:K,keyExtractor:z,inverted:!0,onScroll:R,onEndReached:a?B:void 0,ListHeaderComponent:d?_jsx(_Fragment,{children:d}):null,ListFooterComponent:l?_jsx(Spinner,{size:"sm",accessibilityLabel:C.loadingOlder,style:E.older}):null,ListEmptyComponent:u?_jsx(View,{style:E.fill,children:u}):null,renderScrollComponent:p?N:void 0,contentContainerStyle:[E.content,0===e.length?E.grow:null,b],testID:S}),k?_jsxs(View,{style:E.jump,pointerEvents:"box-none",children:[_jsx(View,{style:E.jumpDisc,children:_jsx(IconButton,{icon:"arrow-down",accessibilityLabel:U,variant:"ghost",tone:"neutral",onPress:V,testID:S?`${S}-jump`:void 0})}),O>0?_jsx(View,{style:E.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:_jsx(Badge,{value:O,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>StyleSheet.create({root:{flex:1},content:{paddingHorizontal:e.spacing.md,paddingVertical:e.spacing.sm},grow:{flexGrow:1},fill:{flex:1},older:{paddingVertical:e.spacing.md},jump:{position:"absolute",right:e.spacing.md,bottom:e.spacing.md},jumpDisc:{borderRadius:e.radius.full,...smoothCorners,backgroundColor:e.colors.background.elevated,...e.shadows.md},count:{position:"absolute",top:-e.spacing.xs,right:-e.spacing.xs}});export default MessageList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{DEFAULT_MESSAGE_LIST_LABELS,default,MessageList}from"./MessageList.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,ScrollView,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Carousel}from"../Carousel/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ONBOARDING_MAX_PAGES=6,CONTROL_HEIGHT=44,DOT_SIZE=8,DOT_ACTIVE_WIDTH=24,defaultStep=(e,t)=>`Step ${e} of ${t}`,OnboardingPager=({pages:e,onDone:t,onSkip:o,doneLabel:n="Get started",labels:s,safeArea:i=!0,haptic:a,testID:r})=>{const l=useTheme(),c=useSafeAreaInsets(),d=useReducedMotion(),u=useMemo(()=>buildStyles(l),[l]),m=useMemo(()=>e.slice(0,6),[e]),p=m.length,g=s?.step??defaultStep,b=useRef(null),[x,f]=useState(0),y=x>=p-1,h=useCallback(e=>{e<0||e>=p||b.current?.scrollTo(e,!d)},[p,d]),j=useCallback(e=>h(x+e),[h,x]),S=useCallback(()=>{y?t():h(x+1)},[y,t,h,x]),_=useRef(x);useEffect(()=>{if(_.current===x)return;_.current=x;const e=m[x];e&&announce(`${g(x+1,p)}, ${e.title}`)},[x,m,p,g]);const C=useCallback((e,t)=>_jsx(ScrollView,{style:u.page,contentContainerStyle:u.pageContent,showsVerticalScrollIndicator:!1,bounces:!1,children:_jsxs(View,{accessible:!0,accessibilityLabel:`${g(t+1,p)}, ${e.title}. ${e.body}`,style:u.pageGroup,children:[e.art?_jsx(View,{style:u.art,children:e.art}):null,_jsx(Text,{variant:"h2",align:"center",children:e.title}),_jsx(Text,{variant:"body",color:"secondary",align:"center",children:e.body})]})}),[u,g,p]);return 0===p?null:_jsxs(View,{style:[u.root,i?{paddingTop:c.top,paddingBottom:c.bottom}:null],testID:r,children:[_jsx(View,{style:u.skipRow,children:_jsx(Button,{title:s?.skip??"Skip",variant:"ghost",tone:"neutral",hitSlop:{top:2,bottom:2,left:8,right:8},haptic:a,onPress:o,testID:r?`${r}-skip`:void 0})}),_jsx(Carousel,{ref:b,data:m,renderItem:C,keyExtractor:e=>e.key,onIndexChange:f,showPagination:!1,containerStyle:u.carousel,testID:r?`${r}-pages`:void 0}),_jsxs(View,{style:u.footer,children:[p>1?_jsx(PageControl,{keys:m.map(e=>e.key),index:x,label:s?.pageControl??"Page",valueText:g(x+1,p),reduceMotion:d,theme:l,onStep:j,testID:r?`${r}-dots`:void 0}):null,_jsx(Button,{title:y?n:s?.next??"Next",size:"lg",fullWidth:!0,haptic:a,onPress:S,testID:r?`${r}-next`:void 0})]})]})};OnboardingPager.displayName="OnboardingPager";const PageControl=({keys:e,index:t,label:o,valueText:n,reduceMotion:s,theme:i,onStep:a,testID:r})=>{const l=useCallback(e=>{"increment"===e.nativeEvent.actionName?a(1):"decrement"===e.nativeEvent.actionName&&a(-1)},[a]);return _jsxs(View,{accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:o,accessibilityValue:{min:0,max:e.length-1,now:t,text:n},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:l,style:controlStyles.control,testID:r,children:[_jsx(View,{style:controlStyles.dots,pointerEvents:"none",children:e.map((e,o)=>_jsx(Dot,{active:o===t,reduceMotion:s,theme:i},e))}),_jsx(Pressable,{accessible:!1,importantForAccessibility:"no",style:controlStyles.back,onPress:()=>a(-1),testID:r?`${r}-back`:void 0}),_jsx(Pressable,{accessible:!1,importantForAccessibility:"no",style:controlStyles.forward,onPress:()=>a(1),testID:r?`${r}-forward`:void 0})]})},Dot=({active:e,reduceMotion:t,theme:o})=>{const n=useRef(createAnimatedValue(e?1:0)).current;return useEffect(()=>{const s=Animated.timing(n,{toValue:e?1:0,duration:t?0:o.motion.duration.normal,easing:Easing.bezier(...o.motion.easing.standard),useNativeDriver:!1});return s.start(),()=>s.stop()},[e,t,n,o]),_jsx(Animated.View,{style:{width:n.interpolate({inputRange:[0,1],outputRange:[8,24]}),height:8,marginHorizontal:o.spacing.xs,borderRadius:4,...smoothCorners,backgroundColor:n.interpolate({inputRange:[0,1],outputRange:[o.colors.border.primary,o.colors.primary]})}})},controlStyles=StyleSheet.create({control:{alignSelf:"center",height:44,minWidth:88,alignItems:"center",justifyContent:"center"},dots:{flexDirection:"row",alignItems:"center"},back:{position:"absolute",top:0,bottom:0,start:0,width:"50%"},forward:{position:"absolute",top:0,bottom:0,end:0,width:"50%"}}),buildStyles=e=>StyleSheet.create({root:{flex:1,backgroundColor:e.colors.background.primary},skipRow:{minHeight:44,paddingHorizontal:e.spacing.lg,alignItems:"flex-end",justifyContent:"center"},carousel:{flex:1},page:{flex:1},pageContent:{flexGrow:1,justifyContent:"center",paddingHorizontal:e.spacing.xl,paddingVertical:e.spacing.lg},pageGroup:{alignItems:"center",gap:e.spacing.md},art:{alignItems:"center",marginBottom:e.spacing.xl},footer:{paddingHorizontal:e.spacing.lg,paddingBottom:e.spacing.lg,gap:e.spacing.sm}});export{OnboardingPager};export default OnboardingPager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{default,OnboardingPager}from"./OnboardingPager.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatDateTime,formatMinor}from"@webority/mobile-core";import{useEffect,useMemo,useRef}from"react";import{StyleSheet,View}from"react-native";import Animated,{cancelAnimation,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{Confetti}from"../Confetti/index.js";import{Descriptions}from"../Descriptions/index.js";import{StatusBadge}from"../StatusBadge/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const STATUS={success:{icon:"check-circle",badge:"Success",tone:"success",title:"Payment successful"},pending:{icon:"clock",badge:"Pending",tone:"neutral",title:"Payment pending"},failed:{icon:"x-circle",badge:"Failed",tone:"error",title:"Payment failed"},refunded:{icon:"refresh-cw",badge:"Refunded",tone:"info",title:"Payment refunded"}},MARK_SIZE=72,ICON_SIZE=36,TINT_OPACITY=.14,DEFAULT_REFUND_DAYS=5,CONFETTI_PIECES=60,SETTLE_WINDOW="Most payments confirm in a few minutes. Your bank can take up to 48 hours.",REFRESH_HINT="Tap Check status to see the latest.",PENDING_WARNING="Do not pay again. If money has left your account, it will either complete or come back to you.",istStamp=e=>formatDateTime(e,{zone:"IST",zoneLabel:!0}),markColors=(e,t)=>{const{colors:n}=e;switch(t){case"success":return{fill:tintOf(n.success,.14,n.background.secondary),ink:n.toneText.success};case"failed":return{fill:tintOf(n.error,.14,n.background.secondary),ink:n.toneText.error};case"refunded":return{fill:tintOf(n.info,.14,n.background.secondary),ink:n.toneText.info};default:return{fill:n.background.tertiary,ink:n.text.secondary}}},failedLead=(e,t,n,r)=>{if(!0===e){return`${t} will return to your account within ${n} working days.${r?` Reference ${r}.`:""}`}return!1===e?"No money was taken from your account. You can try again.":"We could not confirm whether money left your account. Check your bank statement before you try again."},leadFor=(e,t,n)=>{switch(e){case"success":return"Your payment has been received. Keep this receipt for your records.";case"pending":return"Your bank has not confirmed this payment yet.";case"refunded":return`${t} has been returned to your account.`;default:return n}},renderAction=e=>_jsx(Button,{title:e.title,size:"lg",fullWidth:!0,variant:e.variant,tone:e.tone,leftIcon:e.icon,loading:e.loading,onPress:e.onPress},e.key);export const PaymentResult=({status:e,amount:t,currency:n="INR",payee:r,reference:o,paidAt:i,method:a,rows:s,debited:l,refundDays:c=5,settlesBy:u,title:d,message:m,onShare:f,onDownload:p,onDone:h,onRetry:y,onRefresh:g,refreshing:b=!1,celebrate:x=!0,haptic:k=!0,style:j,testID:S})=>{const T=useTheme(),v=useReducedMotion(),w=useMemo(()=>buildStyles(T),[T]),_=useRef(null),I=useRef(null),A=STATUS[e],R=useMemo(()=>markColors(T,e),[T,e]),D=d??A.title,E=formatMinor(t,{currency:n,dropZeroDecimals:!0}),C=failedLead(l,E,c,o),P=m??leadFor(e,E,C),N=`${D}, ${E}${r&&"refunded"!==e?` to ${r}`:""}`,V=void 0===u?SETTLE_WINDOW:`Expected to settle by ${istStamp(u)}.`;useEffect(()=>{I.current!==e&&(I.current=e,announce(N,{polite:"failed"!==e}),k&&("success"===e?triggerHaptic("confirm"):"failed"===e&&triggerHaptic("reject")),"success"===e&&x&&_.current?.start())},[e]);const M=useSharedValue(.9),$=useSharedValue(0),W=T.motion.duration.normal;useEffect(()=>(v?(M.value=1,$.value=1):"success"===e?($.value=0,$.value=withTiming(1,{duration:W}),M.value=.6,M.value=withSpring(1,{damping:12,stiffness:160})):($.value=0,$.value=withTiming(1,{duration:W}),M.value=.9,M.value=withTiming(1,{duration:W})),()=>{cancelAnimation(M),cancelAnimation($)}),[e,v,M,$,W]);const F=useAnimatedStyle(()=>({opacity:$.value,transform:[{scale:M.value}]})),H=useMemo(()=>{const e=[];if(r&&e.push({key:"payee",label:"Paid to",value:r}),a&&e.push({key:"method",label:"Method",value:a}),o){const t=/^\d+$/.test(o);e.push({key:"reference",label:"Reference",value:_jsx(Text,{selectable:!0,accessibilityLabel:t?o.split("").join(" "):void 0,style:w.tabular,children:o})})}void 0!==i&&e.push({key:"paidAt",label:"Date and time",value:istStamp(i)});for(const t of s??[])void 0!==t.value&&null!==t.value&&""!==t.value&&e.push(t);return e},[r,a,o,i,s,w.tabular]),O="pending"===e&&g?{key:"refresh",title:"Check status",onPress:g,icon:"refresh-cw",loading:b}:null,B=h?{key:"done",title:"Done",onPress:h}:null,L=("failed"===e&&!1===l&&y?{key:"retry",title:"Try again",onPress:y,icon:"refresh-cw"}:null)??O??B,Y=B&&L!==B?{...B,variant:"ghost",tone:"neutral"}:null,z=[];return f&&z.push({key:"share",title:"Share receipt",onPress:f,icon:"share",variant:"outline",tone:"neutral"}),p&&z.push({key:"download",title:"Download",onPress:p,icon:"download",variant:"outline",tone:"neutral"}),_jsxs(View,{style:[w.root,j],testID:S,accessibilityRole:"summary",children:[_jsxs(View,{style:w.header,children:[_jsx(Animated.View,{style:[w.mark,{backgroundColor:R.fill},F],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsx(AppIcon,{name:A.icon,size:36,color:R.ink})}),_jsx(StatusBadge,{label:A.badge,tone:A.tone}),_jsx(Text,{variant:"h3",align:"center",children:D}),_jsx(Text,{variant:"h1",align:"center",style:w.tabular,children:E}),_jsx(Text,{variant:"body",color:"secondary",align:"center",children:P})]}),"pending"===e?_jsxs(View,{style:w.note,children:[_jsx(Text,{variant:"bodySmall",color:"secondary",children:V}),_jsx(Text,{variant:"bodySmall",weight:"semibold",children:PENDING_WARNING}),O?_jsx(Text,{variant:"bodySmall",color:"secondary",children:REFRESH_HINT}):null]}):null,H.length>0?_jsx(View,{style:w.receipt,children:_jsx(Descriptions,{items:H,columns:2,bordered:!0})}):null,L||z.length>0?_jsxs(View,{style:w.actions,children:[L?renderAction(L):null,z.length>0?_jsx(View,{style:w.pair,children:z.map(e=>_jsx(View,{style:w.pairItem,children:renderAction(e)},e.key))}):null,Y?renderAction(Y):null]}):null,"success"===e&&x?_jsx(Confetti,{ref:_,count:60,preset:"pop"}):null]})};const buildStyles=e=>StyleSheet.create({root:{gap:e.spacing.lg},header:{alignItems:"center",gap:e.spacing.sm},mark:{width:72,height:72,borderRadius:36,alignItems:"center",justifyContent:"center",marginBottom:e.spacing.xs,...smoothCorners},tabular:{fontVariant:["tabular-nums"]},note:{gap:e.spacing.xs,padding:e.spacing.md,borderRadius:e.radius.md,backgroundColor:e.colors.background.secondary,...smoothCorners},receipt:{paddingHorizontal:e.spacing.md,borderRadius:e.radius.lg,borderWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border.secondary,backgroundColor:e.colors.background.primary,...smoothCorners},actions:{gap:e.spacing.sm},pair:{flexDirection:"row",gap:e.spacing.sm},pairItem:{flex:1}});export default PaymentResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{default,PaymentResult}from"./PaymentResult.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{EmptyState}from"../EmptyState/index.js";import{IconButton}from"../IconButton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,LIFT=.06,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}],DEFAULT_LABELS={found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."},ScannerOverlay=forwardRef((e,t)=>{const{children:o,state:n="scanning",hint:i="Point the camera at the code",labels:r,torch:s=!1,onTorchChange:a,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:m=DEFAULT_FRAME,haptic:u,style:h,testID:f}=e,p=useTheme(),g=useSafeAreaInsets(),y=useReducedMotion(),b=useMemo(()=>buildStyles(p),[p]),x={...DEFAULT_LABELS,...r},[j,v]=useState({width:0,height:0}),S="scanning"===n||"found"===n||"invalid"===n,w=useRef(createAnimatedValue(1)).current,A=p.motion.duration.slower,E=p.motion.duration.normal;useEffect(()=>{if(w.setValue(1),y)return;let e;return"scanning"===n&&A>0?e=Animated.loop(Animated.sequence([Animated.timing(w,{toValue:1.03,duration:2*A,useNativeDriver:!0}),Animated.timing(w,{toValue:1,duration:2*A,useNativeDriver:!0})])):"found"===n&&E>0&&(w.setValue(1.08),e=Animated.timing(w,{toValue:1,duration:E,useNativeDriver:!0})),e?.start(),()=>e?.stop()},[n,y,A,E,w]);const _=useRef(n);useEffect(()=>{_.current!==n&&(_.current=n,!1!==u&&("found"===n?triggerHaptic("notificationSuccess"):"invalid"===n&&triggerHaptic("notificationError")))},[n,u]);const{found:V,invalid:C}=x,{noPermissionTitle:R,noPermissionMessage:M}=x,{noCameraTitle:k,noCameraMessage:I}=x;useEffect(()=>{switch(n){case"scanning":announce(i);break;case"found":announce(V);break;case"invalid":announce(C,{polite:!1});break;case"noPermission":announce(`${R}. ${M}`);break;case"noCamera":announce(`${k}. ${I}`)}},[n,i,V,C,R,M,k,I]);const L=Math.max(240,Math.min(m,j.width-2*p.spacing.xl)),P=(j.width-L)/2,F=Math.max(p.spacing.md,(j.height-L)/2-.06*j.height),B=j.width>0&&j.height>0,O={borderColor:"found"===n?p.colors.success:"invalid"===n?p.colors.error:p.colors.onOverlay,width:32,height:32},N="found"===n||"invalid"===n?_jsx(View,{style:[b.pill,{backgroundColor:"found"===n?p.colors.success:p.colors.error}],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",color:"found"===n?p.colors.onSuccess:p.colors.onError,children:"found"===n?V:C})}):_jsx(Text,{variant:"bodySmall",align:"center",color:p.colors.onOverlay,children:i}),D=S&&null!=a,H=S?"glass":"outline";return _jsxs(View,{ref:t,testID:f,onLayout:e=>{const{width:t,height:o}=e.nativeEvent.layout;v(e=>e.width===t&&e.height===o?e:{width:t,height:o})},style:[b.root,!S&&{backgroundColor:p.colors.background.primary},h],children:[S?_jsx(View,{style:StyleSheet.absoluteFill,children:o}):null,S&&B?_jsxs(_Fragment,{children:[_jsxs(View,{pointerEvents:"none",style:StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[_jsx(View,{style:[b.scrim,{left:0,right:0,top:0,height:F}]}),_jsx(View,{style:[b.scrim,{left:0,right:0,top:F+L,bottom:0}]}),_jsx(View,{style:[b.scrim,{left:0,width:P,top:F,height:L}]}),_jsx(View,{style:[b.scrim,{left:P+L,right:0,top:F,height:L}]}),_jsx(Animated.View,{style:{position:"absolute",left:P,top:F,width:L,height:L,transform:[{scale:w}]},children:CORNERS.map(e=>_jsx(View,{style:[b.mark,O,e.style]},e.key))})]}),_jsx(View,{pointerEvents:"none",style:[b.message,{top:F+L+p.spacing.md}],children:N})]}):null,S?null:_jsx(View,{style:b.panel,children:_jsx(EmptyState,{fill:!0,icon:_jsx(AppIcon,{name:"noPermission"===n?"camera":"camera-slash",size:48,color:p.colors.text.tertiary}),title:"noPermission"===n?R:k,description:"noPermission"===n?M:I,action:"noPermission"===n&&d?{label:x.permissionAction,onPress:d}:void 0})}),_jsxs(View,{pointerEvents:"box-none",style:[b.bar,{paddingBottom:Math.max(g.bottom,p.spacing.md)}],children:[D?_jsx(IconButton,{icon:s?"flash":"flash-slash",variant:"glass",size:"lg",active:s,haptic:u,accessibilityLabel:s?x.torchOff:x.torchOn,onPress:()=>a?.(!s)}):null,c?_jsx(Button,{title:x.gallery,leftIcon:"gallery",variant:H,tone:"neutral",size:"lg",haptic:u,onPress:c}):null,l?_jsx(Button,{title:x.manualEntry,leftIcon:"keyboard",variant:H,tone:"neutral",size:"lg",haptic:u,onPress:l}):null]})]})});ScannerOverlay.displayName="ScannerOverlay";const buildStyles=e=>StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.background.overlay},mark:{position:"absolute"},message:{position:"absolute",left:0,right:0,alignItems:"center",paddingHorizontal:e.spacing.xl},pill:{paddingHorizontal:e.spacing.md,paddingVertical:e.spacing.xs,borderRadius:e.radius.full,...smoothCorners},panel:{...StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.spacing.sm,paddingHorizontal:e.spacing.md}});export{ScannerOverlay};export default ScannerOverlay;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{default,ScannerOverlay}from"./ScannerOverlay.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useDebounce}from"../../hooks/useDebounce.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldBase,FieldLabel,resolveFieldSize,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SearchBar=forwardRef((e,
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{useDebounce}from"../../hooks/useDebounce.js";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldBase,FieldLabel,resolveFieldSize,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{normalizeSuggestion,SearchRecents,SearchScopeBar,SearchSuggestions}from"./SearchPanel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=forwardRef((e,l)=>{const{value:o,onChangeText:s,onSubmit:t,onFocus:a,onBlur:i,placeholder:n="Search…",autoFocus:r=!1,disabled:c=!1,onClear:u,leftIcon:d,debounceMs:b,size:f="md",variant:p,borderRadius:S,label:m,labelMode:g="top",labelStyle:h,scopes:v,scope:x,onScopeChange:C,recents:R,recentsTitle:y="Recent searches",maxRecents:j=DEFAULT_PANEL_ROWS,onSelectRecent:F,onRemoveRecent:k,onClearRecents:_,suggestions:z,maxSuggestions:L=DEFAULT_PANEL_ROWS,onSelectSuggestion:B,haptic:T,style:E,inputStyle:I,accessibilityLabel:H,testID:w,...D}=e,A=useTheme(),P=p??A.components.searchBar?.defaultVariant??A.components.field?.defaultVariant??"filled",V="underline"===P,M=resolveFieldSize(A,f),N={...M,...A.components.searchBar?.[f]??{}},O=resolveFieldTextStyle(A,{disabled:c}),W=useRef(null),U=useMemo(()=>mergeRefs(W,l),[l]),$=useCallback(()=>{c||W.current?.focus()},[c]),q=useMemo(()=>buildStyles(A),[A]),K="string"==typeof o?o:"",[G,J]=useState(!1),Q=useCallback(e=>{J(!0),a?.(e)},[a]),X=useCallback(e=>{J(!1),i?.(e)},[i]),[Y,Z]=useState(K),ee=useDebounce(Y,b??0);useEffect(()=>{void 0!==b&&K!==Y&&Z(K)},[K,b]);const le=useRef(K);useEffect(()=>{void 0!==b&&ee!==le.current&&(le.current=ee,s(ee))},[ee,b,s]);const oe=useCallback(e=>{void 0===b?s(e):Z(e)},[b,s]),se=useCallback(()=>{const e=resolveHaptic(T,"selection");e&&triggerHaptic(e),void 0!==b&&(Z(""),le.current=""),s(""),u?.()},[T,b,s,u]),te=useCallback(()=>{t?.(void 0!==b?Y:K)},[t,b,Y,K]),ae=void 0!==b?Y:K,ie=ae.length>0,[ne,re]=useControllableState({value:x,defaultValue:v?.[0]?.value??"",onChange:C}),ce=useCallback(e=>{re(e);const l=v?.find(l=>l.value===e)?.label;l&&announce(`Searching ${l}`)},[v,re]),[ue,de]=useState(!1),be=useRef(null),fe=useCallback(()=>{be.current&&(clearTimeout(be.current),be.current=null)},[]),pe=useCallback(()=>{fe(),de(!0)},[fe]),Se=useCallback(()=>{fe(),be.current=setTimeout(()=>de(!1),50)},[fe]);useEffect(()=>fe,[fe]);const me=!c&&(G||ue),ge=useMemo(()=>(R??[]).slice(0,j),[R,j]),he=useMemo(()=>(z??[]).slice(0,L).map(normalizeSuggestion),[z,L]),ve=me&&!ie&&ge.length>0,xe=me&&ie&&he.length>0,Ce=xe?he.length:0;useEffect(()=>{Ce>0&&announce(1===Ce?"1 suggestion":`${Ce} suggestions`)},[Ce]);const Re=useCallback(()=>{const e=resolveHaptic(T,"selection");e&&triggerHaptic(e)},[T]),ye=useCallback(e=>{Re(),W.current?.blur(),de(!1),F?.(e)},[Re,F]),je=useCallback(e=>{Re(),W.current?.blur(),de(!1),B?.(e)},[Re,B]),Fe=useCallback(e=>{Re(),k?.(e),announce(`Removed ${e}`),$()},[Re,k,$]),ke=useCallback(()=>{Re(),_?.(),announce("Recent searches cleared"),$()},[Re,_,$]),_e={size:N.iconSize,color:c?A.colors.text.disabled:A.colors.text.tertiary,disabled:c},ze=d?renderSlotIcon(d,_e):(A.icons?.search??defaultIcons.search)(_e),Le=Boolean(m)&&"float"===g,Be=useFloatingLabel({label:m,enabled:Le,floated:G||ie,variant:P,sizeTokens:{...M,...N},leadingOffset:N.iconSize+A.spacing.md,trailingOffset:ie?N.iconSize+A.spacing.md:0,paddingLeft:V?0:N.paddingHorizontal,color:A.colors.field.label,style:h}),Te=ie&&!c?_jsx(Pressable,{onPress:se,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(A.icons?.close??defaultIcons.close)({size:N.iconSize,color:A.colors.text.secondary})}):null;return _jsxs(View,{style:E,testID:w,children:[m&&!Le?_jsx(FieldLabel,{size:f,style:h,children:m}):null,_jsx(View,{style:q.root,children:_jsxs(View,{style:q.fieldWrap,children:[_jsx(FieldBase,{size:f,variant:P,focused:G,disabled:c,filled:ie,minHeight:N.minHeight,paddingHorizontal:V?0:N.paddingHorizontal,borderRadius:S??N.borderRadius,leading:ze,trailing:Te,topNotch:Be.topNotch,onPress:$,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:H??n,children:_jsx(TextInput,{ref:U,style:[q.input,{fontSize:N.fontSize,color:O.color,...O.weightStyle},I],value:ae,onChangeText:oe,onSubmitEditing:te,onFocus:Q,onBlur:X,placeholder:!Le||G||ie?n:void 0,placeholderTextColor:O.placeholderColor,autoFocus:r,editable:!c,returnKeyType:"search",selectionColor:resolveVariantColors(A,P).borderFocusedRepresentative,accessibilityLabel:H??n,accessibilityState:{disabled:c},"aria-disabled":c,...D})}),Be.node]})}),v&&v.length>0?_jsx(SearchScopeBar,{scopes:v,scope:ne||(v[0]?.value??""),disabled:c,haptic:T,onChange:ce}):null,ve?_jsx(SearchRecents,{recents:ge,title:y,onSelect:ye,onRemove:k?Fe:void 0,onClear:_?ke:void 0,onHold:pe,onRelease:Se}):null,xe?_jsx(SearchSuggestions,{suggestions:he,query:ae,onSelect:je,onHold:pe,onRelease:Se}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:0,margin:0,includeFontPadding:!1}});export{SearchBar};export default SearchBar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{memo,useMemo}from"react";import{Pressable,Text as RNText,ScrollView,StyleSheet,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Chip}from"../Chip/index.js";import{Text}from"../Text/index.js";import{splitHighlight}from"./highlight.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TOUCH=44,ICON=18;export const normalizeSuggestion=e=>"string"==typeof e?{text:e}:e;export const SearchScopeBar=({scopes:e,scope:s,disabled:t,haptic:o,onChange:i})=>{const r=useTheme(),n=useMemo(()=>buildStyles(r),[r]);return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",contentContainerStyle:n.scopes,accessibilityLabel:"Search scope",children:e.map(e=>_jsx(Chip,{label:e.label,selected:e.value===s,disabled:t,haptic:o,onPress:()=>i(e.value),containerStyle:n.scopeChip},e.value))})};export const SearchRecents=({recents:e,title:s,onSelect:t,onRemove:o,onClear:i,onHold:r,onRelease:n})=>{const l=useTheme(),c=useMemo(()=>buildStyles(l),[l]);return _jsxs(View,{style:c.list,children:[_jsxs(View,{style:c.header,children:[_jsx(Text,{variant:"label",accessibilityRole:"header",style:c.headerTitle,children:s}),i?_jsx(Pressable,{onPress:i,onPressIn:r,onPressOut:n,accessibilityRole:"button",accessibilityLabel:"Clear all recent searches",style:c.clearAll,children:_jsx(Text,{variant:"label",color:"link",children:"Clear all"})}):null]}),e.map(e=>_jsxs(View,{style:c.row,children:[_jsxs(Pressable,{onPress:()=>t(e),onPressIn:r,onPressOut:n,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:"Searches again",android_ripple:{color:l.colors.surface.pressed},style:({pressed:e})=>[c.rowMain,e?{backgroundColor:l.colors.surface.pressed}:null],children:[_jsx(AppIcon,{name:"history",size:18,color:l.colors.text.tertiary}),_jsx(Text,{variant:"body",numberOfLines:1,style:c.rowText,children:e})]}),o?_jsx(Pressable,{onPress:()=>o(e),onPressIn:r,onPressOut:n,accessibilityRole:"button",accessibilityLabel:`Remove ${e} from recent searches`,style:c.remove,children:_jsx(AppIcon,{name:"x",size:18,color:l.colors.text.secondary})}):null]},e))]})};const SuggestionRow=memo(({item:e,query:s,onSelect:t,onHold:o,onRelease:i,theme:r,styles:n})=>{const l=splitHighlight(e.text,s),c=e.icon?renderSlotIcon(e.icon,{size:18,color:r.colors.text.tertiary,disabled:!1}):_jsx(AppIcon,{name:"search",size:18,color:r.colors.text.tertiary});return _jsxs(Pressable,{onPress:()=>t(e),onPressIn:o,onPressOut:i,accessibilityRole:"button",accessibilityLabel:e.subtitle?`${e.text}, ${e.subtitle}`:e.text,android_ripple:{color:r.colors.surface.pressed},style:({pressed:e})=>[n.rowMain,n.suggestion,e?{backgroundColor:r.colors.surface.pressed}:null],children:[c,_jsxs(View,{style:n.rowText,children:[_jsx(Text,{variant:"body",color:"secondary",numberOfLines:1,children:l.map(e=>_jsx(RNText,{style:e.match?n.match:void 0,children:e.text},e.start))}),e.subtitle?_jsx(Text,{variant:"caption",numberOfLines:1,children:e.subtitle}):null]})]})});SuggestionRow.displayName="SuggestionRow";export const SearchSuggestions=({suggestions:e,query:s,onSelect:t,onHold:o,onRelease:i})=>{const r=useTheme(),n=useMemo(()=>buildStyles(r),[r]);return _jsx(View,{style:n.list,children:e.map(e=>_jsx(SuggestionRow,{item:e,query:s,onSelect:t,onHold:o,onRelease:i,theme:r,styles:n},e.id??e.text))})};const buildStyles=e=>({...StyleSheet.create({scopes:{flexDirection:"row",alignItems:"center",gap:e.spacing.sm,paddingTop:e.spacing.sm},scopeChip:{minHeight:44},list:{width:"100%",paddingTop:e.spacing.xs},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",minHeight:44,paddingHorizontal:e.spacing.xs},headerTitle:{flex:1},clearAll:{minHeight:44,minWidth:44,justifyContent:"center",alignItems:"flex-end"},row:{flexDirection:"row",alignItems:"center"},rowMain:{flex:1,flexDirection:"row",alignItems:"center",gap:e.spacing.md,minHeight:44,paddingHorizontal:e.spacing.xs},suggestion:{paddingVertical:e.spacing.xs},rowText:{flex:1},remove:{width:44,height:44,alignItems:"center",justifyContent:"center"}}),match:{...fontFor(e,"bold"),color:e.colors.text.primary}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const MAX_TOKENS=8,escapeRegExp=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");export const splitHighlight=(t,e)=>{const s=e.trim().split(/\s+/).filter(Boolean).slice(0,8).sort((t,e)=>e.length-t.length);if(!t||0===s.length)return[{text:t,match:!1,start:0}];const c=new RegExp(s.map(escapeRegExp).join("|"),"gi"),n=[];let l=0,h=c.exec(t);for(;null!==h;){const e=h.index,s=e+h[0].length;e>l&&n.push({text:t.slice(l,e),match:!1,start:l});const a=n[n.length-1];a?.match&&e===l?a.text+=h[0]:n.push({text:h[0],match:!0,start:e}),l=s,h=c.exec(t)}return l<t.length&&n.push({text:t.slice(l),match:!1,start:l}),n.length>0?n:[{text:t,match:!1,start:0}]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{default,SearchBar}from"./SearchBar.js";
|
|
1
|
+
"use strict";export{default,SearchBar}from"./SearchBar.js";export{useRecentSearches}from"./useRecentSearches.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Storage}from"@webority/mobile-core";import{useCallback,useEffect,useRef,useState}from"react";const DEFAULT_MAX=8,isStringList=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);export const useRecentSearches=(e,r)=>{const t=r?.max??8,[s,c]=useState([]),n=useRef([]),u=useRef(!1);useEffect(()=>{let r=!1;return u.current=!1,n.current=[],c([]),Storage.getJson(e).then(e=>{if(r||u.current||!isStringList(e))return;const s=e.slice(0,t);n.current=s,c(s)}),()=>{r=!0}},[e]);const a=useCallback(r=>{u.current=!0,n.current=r,c(r),Storage.setJson(e,r)},[e]);return{recents:s,add:useCallback(e=>{const r=e.trim();if(!r)return;const s=r.toLowerCase(),c=n.current.filter(e=>e.toLowerCase()!==s);a([r,...c].slice(0,t))},[a,t]),remove:useCallback(e=>{a(n.current.filter(r=>r!==e))},[a]),clear:useCallback(()=>{const e=n.current;return a([]),e},[a]),replace:useCallback(e=>{a(e.slice(0,t))},[a,t])}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,Text,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldSize,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sameSelectValue=(e,
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,Text,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldSize,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{NotationInkContext}from"../Notation/Notation.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t)),Select=forwardRef((e,t)=>{const{options:l,getOptionLabel:i,getOptionValue:o,getOptionDisabled:r,getOptionDescription:n,getOptionIcon:s,placeholder:a,searchable:d=!1,haptic:c,label:u,help:p,title:f,required:S=!1,error:h,helperText:x,prefix:b,numberOfLines:g=1,disabled:m=!1,size:v="md",variant:y,leftIcon:j,rightIcon:C,chevronColor:F,chevronSize:k,borderRadius:z,accessibilityLabel:O,labelStyle:T,style:V,triggerStyle:_,textStyle:I,optionStyle:H,selectedOptionStyle:R,optionTextStyle:w,selectedOptionTextStyle:L,testID:M}=e,N=!0===e.multi,D=useCallback(e=>i?i(e):e.label??"",[i]),P=useCallback(e=>o?o(e):e.value,[o]),B=useCallback(e=>r?r(e):!0===e.disabled,[r]),q=useCallback(e=>n?n(e):e.description,[n]),A=useCallback(e=>s?s(e):e.icon,[s]),E=useTheme(),$=useMemo(()=>buildStyles(E),[E]),G=resolveFieldSize(E,v),J=resolveFieldTextStyle(E,{disabled:m}),K=y??E.components.select?.defaultVariant??E.components.field?.defaultVariant??"outlined",Q=useMemo(()=>{const e=E.components.select?.fillColors?.[K];if(!e)return;const t={};return void 0!==e.idleEmpty&&(t.backgroundIdleEmpty=e.idleEmpty),void 0!==e.idleFilled&&(t.backgroundIdleFilled=e.idleFilled),void 0!==e.focus&&(t.backgroundFocused=e.focus),void 0!==e.error&&(t.backgroundError=e.error),void 0!==e.disabled&&(t.backgroundDisabled=e.disabled),Object.keys(t).length>0?t:void 0},[E.components.select?.fillColors,K]),U=z??E.components.select?.borderRadius,[W,X]=useState(!1),Y=useCallback(t=>{if(N){const l=e.value??[];return containsValue(l,t)}return null!=e.value&&sameSelectValue(e.value,t)},[N,e.value]),Z=useMemo(()=>{if(N){const t=e.value??[];return l.filter(e=>containsValue(t,P(e)))}const t=e.value;if(null==t)return[];const i=l.find(e=>sameSelectValue(P(e),t));return i?[i]:[]},[N,l,e.value,P]),ee=useCallback(()=>{if(m)return;const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),X(!0)},[m,c]),te=useCallback(()=>{X(!1)},[]),le=useCallback(t=>{if(B(t))return;const l=P(t),i=resolveHaptic(c,"selection");if(i&&triggerHaptic(i),N){const t=e.value??[],i=containsValue(t,l)?t.filter(e=>!sameSelectValue(e,l)):[...t,l];return void e.onChange(i)}e.onChange(l),te()},[N,e,te,B,P,c]),ie=0===Z.length?a??"Select…":Z.map(e=>D(e)).join(", "),oe=0===Z.length,re=!0===h||hasFieldText(h),ne=hasFieldText(u),se=fieldTextAsString(u),ae=Math.round(1.4*G.fontSize),de=useMemo(()=>({fontSize:G.fontSize,color:J.placeholderColor}),[G.fontSize,J.placeholderColor]),ce={color:m?E.colors.field.iconDisabled:W?E.colors.field.iconFocused:E.colors.field.icon,size:G.iconSize,disabled:m,focused:W,error:re},ue=0===Z.length?a??"No selection":`Selected: ${Z.map(e=>D(e)).join(", ")}`,pe=O??`${se??"Select"}. ${ue}`;return _jsxs(View,{style:[$.container,V],testID:M,children:[ne?_jsx(FieldLabel,{size:v,required:S,help:p,style:T,children:u}):null,_jsx(View,{ref:t,collapsable:!1,children:_jsxs(FieldBase,{size:v,variant:K,disabled:m,error:re,filled:Z.length>0,onPress:ee,borderRadius:U,fillOverrides:Q,paddingHorizontal:"underline"===K?0:void 0,accessibilityRole:"button",accessibilityLabel:pe,accessibilityState:{disabled:m,expanded:W},"aria-disabled":m,"aria-expanded":W,style:_,slotAlign:1===g?"center":"top",slotLineHeight:1===g?void 0:ae,leading:j?_jsx(View,{children:renderSlotIcon(j,ce)}):null,trailing:C?_jsx(View,{children:renderSlotIcon(C,ce)}):_jsx(Chevron,{color:F??(m?E.colors.text.disabled:E.colors.text.tertiary),size:k??G.iconSize,open:W,style:$.chevron}),children:[hasFieldText(b)?"string"==typeof b||"number"==typeof b?_jsx(Text,{style:[$.prefix,{color:J.placeholderColor,fontSize:G.fontSize,lineHeight:1===g?void 0:ae,marginRight:E.spacing.xs}],children:b}):_jsx(View,{style:[$.prefixNode,{minHeight:1===g?void 0:ae,justifyContent:"center",marginRight:E.spacing.xs}],children:_jsx(Text,{style:[$.prefix,{color:J.placeholderColor,fontSize:G.fontSize,lineHeight:1===g?void 0:ae}],children:_jsx(NotationInkContext.Provider,{value:de,children:b})})}):null,_jsxs(Text,{style:[$.triggerText,{color:oe?J.placeholderColor:J.color,fontSize:G.fontSize,lineHeight:1===g?void 0:ae,...J.weightStyle},I],numberOfLines:g,children:[ie,oe&&S&&!ne?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:v,error:re,text:re?h:x}),_jsx(OptionSheet,{open:W,onClose:te,title:f??se,accessibilityLabel:se??(ne?f:void 0)??a??"Options",options:l,labelOf:D,getValue:P,disabledOf:B,descriptionOf:q,iconOf:A,isSelected:Y,onSelect:le,multi:N,searchable:d,optionStyle:H,selectedOptionStyle:R,optionTextStyle:w,selectedOptionTextStyle:L,searchSelectionColor:resolveVariantColors(E,K,Q).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:8}});export{Select};export default Select;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatDateTime}from"@webority/mobile-core";import{forwardRef,memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,PixelRatio,Platform,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}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{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,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_LABELS={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."},STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,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 SignaturePad=forwardRef((e,t)=>{const{initialStrokes:n,onChange:r,initialTypedName:a="",onTypedNameChange:o,defaultMode:i="draw",onModeChange:s,onEmptyChange:l,allowTyped:d=!0,signedBy:c,signedAt:u,height:p=DEFAULT_HEIGHT,maxNameLength:m=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:h,scriptFontFamily:y,labels:f,haptic:S="selection",disabled:T=!1,style:w,testID:b}=e,E=useTheme(),A=g??lightTheme.colors.text.primary,x=h??lightTheme.colors.background.elevated,_=y??defaultScriptFont(),C=useMemo(()=>({...DEFAULT_LABELS,...f}),[f]),v=useScreenReader(),I=useRef(null),[L,R]=useState(0),[P,j]=useState(()=>(n??[]).map((e,t)=>({id:t+1,points:[...e]}))),D=useRef(P),k=useRef(P.length),N=useRef(null),F=useRef(null),[M,B]=useState(d?i:"draw"),[O,G]=useState(a),[H,Y]=useState(null),U=useRef(!1),W=useRef({onChange:r,onTypedNameChange:o,onModeChange:s,onEmptyChange:l});useEffect(()=>{W.current={onChange:r,onTypedNameChange:o,onModeChange:s,onEmptyChange:l}});const $="draw"===M&&!T,z="draw"===M?0===P.length:0===O.trim().length,V=useRef(null);useEffect(()=>{V.current!==z&&(V.current=z,W.current.onEmptyChange?.(z))},[z]);const K=useCallback(e=>{D.current=e,j(e)},[]),X=useCallback(()=>{Y(Date.now()),W.current.onChange?.(D.current.map(e=>e.points))},[]),J=useMemo(()=>{const pan=e=>Gesture.Pan().enabled($).runOnJS(!0).onBegin(e=>{N.current=pointOf(e.x,e.y)}).onStart(t=>{F.current=e,k.current+=1;const n=pointOf(t.x,t.y);K([...D.current,{id:k.current,points:[N.current??n,n]}])}).onUpdate(t=>{if(F.current!==e)return;const n=D.current[D.current.length-1],r=pointOf(t.x,t.y);distanceBetween(n.points[n.points.length-1],r)<.8||K([...D.current.slice(0,-1),{...n,points:[...n.points,r]}])}).onFinalize(()=>{F.current===e&&(F.current=null,X())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return Gesture.Race(e,t)},[$,K,X]),q=useCallback(e=>{B(e),W.current.onModeChange?.(e),announce("type"===e?C.typingAnnouncement:C.drawingAnnouncement)},[C.typingAnnouncement,C.drawingAnnouncement]);useEffect(()=>{v&&d&&!U.current&&"draw"===M&&0===D.current.length&&q("type")},[v,d,M,q]);const Q=useCallback(()=>{U.current=!0,q("draw"===M?"type":"draw")},[M,q]),Z=useCallback(e=>{G(e),Y(Date.now()),W.current.onTypedNameChange?.(e)},[]),ee=useCallback(()=>{"type"===M?Z(""):(K([]),X()),announce(C.clearedAnnouncement)},[M,Z,K,X,C.clearedAnnouncement]),te=useCallback(()=>{"draw"===M&&0!==D.current.length&&(K(D.current.slice(0,-1)),X(),announce(C.undoneAnnouncement))},[M,K,X,C.undoneAnnouncement]),ne=L||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(z)return void t(new Error(C.emptyError));if(!I.current)return void t(new Error("The signature pad is not on screen."));const n=Math.min(3,Math.max(1,PixelRatio.get()));I.current.toDataURL(n=>{try{e(writePng(n))}catch(e){t(e)}},{width:ne*n,height:p*n})}),toSvg:()=>buildSignatureSvg({width:ne,height:p,mode:M,strokes:P.map(e=>e.points),typedName:O,ink:A,paper:x,strokeWidth:2.5,fontFamily:cssFontStack(_)}),clear:ee,undo:te,isEmpty:()=>z}),[z,C.emptyError,ne,p,M,P,O,A,x,_,ee,te]);const re=useMemo(()=>[{name:"undo",label:C.undo},{name:"clear",label:C.clear},...d?[{name:"toggleMode",label:"draw"===M?C.typeInstead:C.drawInstead}]:[]],[C.undo,C.clear,C.typeInstead,C.drawInstead,d,M]),ae=useCallback(e=>{if(T)return;const{actionName:t}=e.nativeEvent;"undo"===t?te():"clear"===t?ee():"toggleMode"===t&&d&&Q()},[T,te,ee,Q,d]),oe=useCallback(e=>{R(e.nativeEvent.layout.width)},[]),ie=useMemo(()=>StyleSheet.create({root:{gap:E.spacing.sm},pad:{height:p,borderWidth:E.colors.border.width,borderColor:E.colors.border.primary,borderRadius:E.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:x,opacity:T?.5:1},baseline:{position:"absolute",left:E.spacing.md,right:E.spacing.md,top:p*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:E.spacing.xs},trailing:{flexDirection:"row",alignItems:"center",gap:E.spacing.xs}}),[E,p,x,A,T]),se=O.trim(),le=u??H,de=c&&!z?`Signed by ${c}${le?`, ${formatDateTime(le)}`:""}`:null,ce="type"===M&&se?`${C.pad}. ${se}`:C.pad;return _jsxs(View,{style:[ie.root,w],testID:b,children:[_jsx(GestureDetector,{gesture:J,children:_jsxs(View,{style:ie.pad,onLayout:oe,accessible:!0,accessibilityRole:"image",accessibilityLabel:ce,accessibilityHint:"draw"===M?C.padHint:void 0,accessibilityValue:{text:z?C.empty:C.signed},accessibilityState:{disabled:T},"aria-disabled":T,accessibilityActions:re,onAccessibilityAction:ae,children:[_jsxs(Svg,{ref:I,width:"100%",height:p,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:x}),"draw"===M?P.map(e=>_jsx(StrokePath,{points:e.points,color:A},e.id)):null,"type"===M&&se?_jsx(SvgText,{x:ne/2,y:p*BASELINE_RATIO,fontSize:typedFontSize(ne,se),fontFamily:_,textAnchor:"middle",fill:A,children:se}):null]}),_jsx(View,{pointerEvents:"none",style:ie.baseline})]})}),"type"===M?_jsx(Input,{label:C.typedLabel,placeholder:C.typedPlaceholder,value:O,onChangeText:Z,maxLength:m,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"===M?C.caption:C.typedCaption}),_jsxs(View,{style:ie.actions,children:[d?_jsx(Button,{title:"draw"===M?C.typeInstead:C.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:Q,testID:b?`${b}-mode`:void 0}):_jsx(View,{}),"draw"===M&&P.length>0?_jsxs(View,{style:ie.trailing,children:[_jsx(Button,{title:C.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:te,testID:b?`${b}-undo`:void 0}),_jsx(Button,{title:C.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:ee,testID:b?`${b}-clear`:void 0})]}):null,"type"===M&&se?_jsx(Button,{title:C.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:ee,testID:b?`${b}-clear`:void 0}):null]}),de?_jsx(Text,{variant:"caption",color:"secondary",children:de}):null]})});SignaturePad.displayName="SignaturePad";export{SignaturePad};export default SignaturePad;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{SignaturePad}from"./SignaturePad.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const FALLBACK_WIDTH=320;const MIN_FONT_SIZE=18,MAX_FONT_SIZE=56,SCRIPT_ADVANCE=.5,TYPED_WIDTH_SHARE=.88;export const BASELINE_RATIO=.7;const oneDecimal=t=>Math.round(10*t)/10;export const pointOf=(t,e)=>[oneDecimal(t),oneDecimal(e)];export const distanceBetween=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);const format=t=>t.toFixed(1);export const strokePath=t=>{if(0===t.length)return"";const[e,...o]=t,r=[`M${format(e[0])} ${format(e[1])}`];if(0===o.length)return r.push(`L${format(e[0])} ${format(e[1])}`),r.join(" ");if(1===o.length)return r.push(`L${format(o[0][0])} ${format(o[0][1])}`),r.join(" ");for(let t=0;t<o.length-1;t+=1){const e=o[t],n=o[t+1],a=(e[0]+n[0])/2,s=(e[1]+n[1])/2;r.push(`Q${format(e[0])} ${format(e[1])} ${format(a)} ${format(s)}`)}const n=o[o.length-1];return r.push(`L${format(n[0])} ${format(n[1])}`),r.join(" ")};export const typedFontSize=(t,e)=>{const o=Math.max(1,e.length),r=Math.floor(.88*t/(.5*o));return Math.min(56,Math.max(18,r))};export const escapeXml=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");export const buildSignatureSvg=t=>{const{width:e,height:o,mode:r,strokes:n,typedName:a,ink:s,paper:i,strokeWidth:p,fontFamily:c}=t,h=Math.round(e),l=Math.round(o),m=[`<rect x="0" y="0" width="${h}" height="${l}" fill="${escapeXml(i)}"/>`];if("type"===r){const t=a.trim();t&&m.push(`<text x="${h/2}" y="${format(.7*l)}" text-anchor="middle" font-family="${escapeXml(c)}" font-size="${typedFontSize(h,t)}" fill="${escapeXml(s)}">${escapeXml(t)}</text>`)}else for(const t of n)m.push(`<path d="${strokePath(t)}" fill="none" stroke="${escapeXml(s)}" stroke-width="${p}" stroke-linecap="round" stroke-linejoin="round"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${l}" viewBox="0 0 ${h} ${l}">${m.join("")}</svg>`};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const writePng=t=>`data:image/png;base64,${t}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{formatNumber}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import Svg,{Circle,Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{finiteValues,sparklineGeometry}from"./geometry.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DOT_RADIUS=3,lineColor=(e,t)=>"neutral"===t?e.colors.text.secondary:e.colors.toneText[t],defaultFormat=e=>formatNumber(e),Sparkline=forwardRef((e,t)=>{const{data:r,tone:i="primary",color:o,fill:l=!1,highlightLast:s=!0,height:a=32,width:n,strokeWidth:m=2,label:h,formatLabel:c=defaultFormat,accessibilityLabel:f,style:u,testID:d}=e,y=useTheme(),[p,x]=useState(0),g=n??p,k=useCallback(e=>{if(void 0===n){const t=Math.round(e.nativeEvent.layout.width);x(e=>e===t?e:t)}},[n]),S=Math.max(3,m/2)+1,b=useMemo(()=>sparklineGeometry(r,g,a,S),[r,g,a,S]),v=o??lineColor(y,i),j=useMemo(()=>{if(void 0!==f)return f;const e=finiteValues(r),t=h?`${h}, `:"";if(0===e.length)return`${t}no data`;if(1===e.length)return`${t}${c(e[0])}`;return`${t}from ${c(e[0])} to ${c(e[e.length-1])}, low ${c(Math.min(...e))}, high ${c(Math.max(...e))}`},[f,r,c,h]);return _jsx(View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:j,testID:d,onLayout:k,style:[styles.root,void 0===n?styles.stretch:{width:n},{height:a},u],children:""===b.line?null:_jsxs(Svg,{width:g,height:a,viewBox:`0 0 ${g} ${a}`,children:[l?_jsx(Path,{d:b.area,fill:v,fillOpacity:.14,stroke:"none"}):null,_jsx(Path,{d:b.line,fill:"none",stroke:v,strokeWidth:m,strokeLinecap:"round",strokeLinejoin:"round",testID:d?`${d}-line`:void 0}),s&&b.last?_jsx(Circle,{cx:b.last.x,cy:b.last.y,r:3,fill:v,testID:d?`${d}-dot`:void 0}):null]})})});Sparkline.displayName="Sparkline";const styles=StyleSheet.create({root:{overflow:"hidden"},stretch:{alignSelf:"stretch"}});export{Sparkline};export default Sparkline;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const finite=n=>n.filter(n=>Number.isFinite(n)),round=n=>(Math.round(100*n)/100).toString();export const sparklineGeometry=(n,t,e,r)=>{const i=finite(n);if(0===i.length||t<=0||e<=0)return{line:"",area:"",last:null};const a=Math.min(...i),o=Math.max(...i),u=Math.max(0,t-2*r),l=Math.max(0,e-2*r),s=o-a,h=i.map((n,a)=>({x:1===i.length?t/2:r+a*u/(i.length-1),y:0===s?e/2:r+(o-n)/s*l})),x=h.map((n,t)=>`${0===t?"M":"L"}${round(n.x)} ${round(n.y)}`).join(" "),d=h[0],m=h[h.length-1];return{line:x,area:`${x} L${round(m.x)} ${round(e)} L${round(d.x)} ${round(e)} Z`,last:m}};export const finiteValues=finite;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export{default,Sparkline}from"./Sparkline.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{ActivityIndicator,Animated,Easing,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{squircleHostRadius}from"../../utils/squircle.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sizeMap={sm:20,md:32,lg:48},DOT_COUNT=3,DOT_STAGGER_MS=150,DOT_CYCLE_MS=600,Dot=({size:e,color:t,delay:i,duration:
|
|
1
|
+
"use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{ActivityIndicator,Animated,Easing,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{blendOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{squircleHostRadius}from"../../utils/squircle.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sizeMap={sm:20,md:32,lg:48},CONTAINER_RATIO=1.5,DOT_COUNT=3,DOT_STAGGER_MS=150,DOT_CYCLE_MS=600,Dot=({size:e,color:t,delay:i,duration:n})=>{const r=useRef(createAnimatedValue(1)).current;return useEffect(()=>{const e=Animated.loop(Animated.sequence([Animated.delay(i),Animated.timing(r,{toValue:1.4,duration:n/2,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(r,{toValue:1,duration:n/2,easing:Easing.in(Easing.quad),useNativeDriver:!0})]));return e.start(),()=>{e.stop()}},[r,i,n]),_jsx(Animated.View,{style:{width:e,height:e,borderRadius:e/2,...smoothCorners,backgroundColor:t,transform:[{scale:r}]}})},Spinner=forwardRef((e,t)=>{const{size:i="md",color:n,message:r,overlay:o=!1,backdropColor:s,variant:a="circular",accessibilityLabel:l,style:c,testID:d}=e,u="contained"===a,m=o&&!u,g=useTheme(),y=useRef(createAnimatedValue(0)).current;useEffect(()=>{Animated.timing(y,{toValue:1,duration:g.motion.duration.normal,easing:Easing.bezier(...g.motion.easing.standard),useNativeDriver:!0}).start()},[y,g]);const f=useMemo(()=>buildStyles(g),[g]),h=sizeMap[i],p=n??g.colors.primary,b=s??g.colors.background.overlay,j=useMemo(()=>{if("contained"===a){const e=Math.round(1.5*h);return _jsx(View,{style:[f.container,{width:e,height:e,borderRadius:e/2,backgroundColor:blendOf(p,.14,g.colors.background.elevated,g.colors.background.secondary)}],children:_jsx(ActivityIndicator,{color:p,size:"sm"===i?"small":"large",style:{width:h,height:h}})})}if("dots"===a){const e=Math.max(6,Math.round(h/4));return _jsx(View,{style:[f.dotsRow,{gap:Math.round(e/2)}],children:Array.from({length:3}).map((t,i)=>_jsx(Dot,{size:e,color:p,delay:150*i,duration:600},i))})}return _jsx(ActivityIndicator,{color:p,size:"sm"===i?"small":"large",style:{width:h,height:h}})},[a,i,h,p,f.dotsRow,f.container,g.colors.background.elevated,g.colors.background.secondary]),x=l??r??"Loading",C=useRef(x);C.current=x,useEffect(()=>{u&&announce(C.current)},[u]);const S=useSquircle(m,g.radius.lg),v=S.active&&S.size?{borderRadius:squircleHostRadius(S.size.width,S.size.height,g.radius.lg)}:null;let w=f.inlineContent;m?w=f.overlayContent:u&&(w=f.containedContent);const z=_jsxs(Animated.View,{ref:t,accessible:!0,accessibilityRole:"progressbar",accessibilityLiveRegion:u?"none":"polite",accessibilityLabel:x,accessibilityState:{busy:!0},"aria-busy":!0,testID:d,onLayout:S.onLayout,style:[w,v,{opacity:y}],children:[S.active&&S.size?_jsx(SquircleFill,{width:S.size.width,height:S.size.height,radius:g.radius.lg,fill:g.colors.background.elevated}):null,j,r?_jsx(Text,{style:[f.message,{color:g.colors.text.primary,fontSize:g.typography.fontSize.base,fontWeight:g.typography.fontWeight.medium,marginTop:g.spacing.md}],numberOfLines:2,children:r}):null]});return _jsx(View,m?{pointerEvents:"auto",style:[f.overlay,{backgroundColor:b},c],children:z}:{style:[u?f.containedFill:f.inline,c],children:z})});Spinner.displayName="Spinner";const buildStyles=e=>StyleSheet.create({inline:{alignItems:"center",justifyContent:"center"},inlineContent:{alignItems:"center",justifyContent:"center"},containedFill:{flex:1,alignSelf:"stretch",alignItems:"center",justifyContent:"center",minHeight:Math.round(1.5*sizeMap.lg)+2*e.spacing.xl},containedContent:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.spacing.lg},container:{alignItems:"center",justifyContent:"center"},overlay:{...StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center",zIndex:1e3},overlayContent:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors.background.elevated,borderRadius:e.radius.lg,...smoothCorners,paddingHorizontal:e.spacing.xl,paddingVertical:e.spacing.xl,minWidth:140,...e.shadows.lg},dotsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},message:{textAlign:"center"}});export{Spinner};export default Spinner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{Card}from"../Card/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const isText=e=>"string"==typeof e||"number"==typeof e,StatTile=forwardRef((e,t)=>{const{label:
|
|
1
|
+
"use strict";import{formatPercent}from"@webority/mobile-core";import{forwardRef}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{AppIcon}from"../AppIcon/index.js";import{Card}from"../Card/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_WORD={up:"up",down:"down",flat:"no change"},TREND_SIGN={up:"+",down:"-",flat:""},percentText=e=>formatPercent(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=e=>{const t=[TREND_WORD[e.direction]];return"flat"!==e.direction&&t.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&t.push(e.period),t.join(" ")},StatTile=forwardRef((e,t)=>{const{label:r,value:n,icon:i,iconVariant:o,tone:s="primary",caption:l,trend:a,sparkline:c,onPress:d,loading:p=!1,accessibilityLabel:x,style:m,testID:u}=e,h=useTheme(),f=a?`, ${trendSpoken(a)}`:"",y=x??(isText(n)?`${r}, ${n}${f}`:void 0),T=!!a&&a.direction===(a.goodWhen??"up"),j=a&&"flat"!==a.direction?T?"success":"error":"secondary",w="secondary"===j?h.colors.text.secondary:h.colors.toneText[j];return _jsx(Card,p?{ref:t,variant:"outlined",style:m,testID:u,children:_jsxs(View,{style:[styles.row,{columnGap:h.spacing.md}],children:[void 0===i?null:_jsx(Skeleton,{shape:"circle",width:40,height:40}),_jsxs(View,{style:styles.text,children:[_jsx(Skeleton,{shape:"text",width:"50%",height:12}),_jsx(Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:h.spacing.xs}})]})]})}:{ref:t,variant:"outlined",onPress:d,accessibilityLabel:y,style:m,testID:u,children:_jsxs(View,{style:[styles.row,{columnGap:h.spacing.md}],children:[void 0===i?null:_jsx(IconBadge,{icon:i,iconVariant:o,tone:s}),_jsxs(View,{style:styles.text,children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r}),isText(n)?_jsx(Text,{variant:"h3",numberOfLines:1,children:n}):n,a?_jsxs(View,{style:[styles.trend,{columnGap:h.spacing.xxs}],testID:u?`${u}-trend`:void 0,children:[_jsx(AppIcon,{name:TREND_ICON[a.direction],size:"xs",color:w}),_jsxs(Text,{variant:"caption",color:j,numberOfLines:2,style:styles.text,children:[trendFigure(a),a.period?_jsx(Text,{variant:"caption",color:"tertiary",children:` ${a.period}`}):null]})]}):null,null==l||""===l?null:isText(l)?_jsx(Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:l}):l,null==c?null:_jsx(View,{style:{marginTop:h.spacing.sm},children:c})]})]})})});StatTile.displayName="StatTile";const styles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});export{StatTile};export default StatTile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,Easing,Modal,Platform,Pressable,StyleSheet,Text,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import Button from"../Button/Button.js";import{PickerTrigger}from"../PickerTrigger/PickerTrigger.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const ITEM_HEIGHT=40,VISIBLE_ITEMS=5,PICKER_HEIGHT=200,CENTER_OFFSET=Math.floor(2.5),HAPTIC_DEBOUNCE_MS=35,range=(e,t,i=1)=>{const a=[];for(let n=e;n<=t;n+=i)a.push(n);return a},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},Wheel=({kind:e,label:t,data:i,selectedIndex:a,onIndexChange:n,formatItem:s,theme:r,haptic:o,testID:l})=>{const c=useRef(null),u=useRef(createAnimatedValue(40*a)).current,d=useRef(a),m=useRef(0);useEffect(()=>{if(d.current!==a){d.current=a;const e=40*a;setNativeValue(u,e),requestAnimationFrame(()=>{c.current?.scrollToOffset({offset:e,animated:!1})})}},[a,u]);const p=r.components.timePicker?.hapticDebounceMs??35,h=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:u}}}],{useNativeDriver:!0,listener:e=>{const t=e.nativeEvent.contentOffset.y,a=Math.round(t/40);if(a!==d.current&&a>=0&&a<i.length){const e=Date.now();if(e-m.current>=p){const t=resolveHaptic(o,"selection");t&&triggerHaptic(t),m.current=e}d.current=a}}}),[u,i.length,o,p]),g=useCallback(e=>{const t=e.nativeEvent.contentOffset.y,s=Math.max(0,Math.min(i.length-1,Math.round(t/40)));s!==a&&n(s)},[i.length,n,a]),f=useCallback(e=>{const t=e.nativeEvent.actionName;if("increment"===t){const e=Math.min(i.length-1,a+1);e!==a&&n(e)}else if("decrement"===t){const e=Math.max(0,a-1);e!==a&&n(e)}},[i.length,n,a]),y=useCallback(({item:e,index:t})=>{const i=Animated.subtract(Animated.divide(u,40),t),n=i.interpolate({inputRange:[-2,-1,0,1,2],outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),o=i.interpolate({inputRange:[-2,-1,0,1,2],outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"}),l=t===a;return _jsx(Animated.View,{style:[styles.wheelItem,{opacity:n,transform:[{scale:o}]}],accessible:!1,importantForAccessibility:"no",children:_jsx(Text,{style:[{fontSize:r.typography.fontSize.xl,color:l?r.colors.text.primary:r.colors.text.secondary,fontWeight:l?r.typography.fontWeight.semibold:r.typography.fontWeight.medium,letterSpacing:r.typography.letterSpacing.normal}],children:s(e)})})},[u,a,r,s]),b=useCallback((t,i)=>`${e}-${String(t)}-${i}`,[e]),x=useCallback((e,t)=>({length:40,offset:40*t,index:t}),[]),S=s(i[a]??"");return _jsxs(View,{style:styles.wheelColumn,testID:l,children:[_jsx(View,{pointerEvents:"none",style:styles.wheelA11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:t,accessibilityValue:{text:S},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:f}),_jsx(Animated.FlatList,{ref:c,data:i,keyExtractor:b,renderItem:y,getItemLayout:x,showsVerticalScrollIndicator:!1,snapToInterval:40,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEventThrottle:16,onScroll:h,onMomentumScrollEnd:g,contentContainerStyle:{paddingVertical:40*CENTER_OFFSET},initialScrollIndex:a,style:styles.wheelList,importantForAccessibility:"no-hide-descendants"})]})},TimePicker=e=>{const{visible:t,value:i,onChange:a,onClose:n,format:s="12h",minuteStep:r=1,title:o="Select Time",confirmLabel:l="Confirm",cancelLabel:c="Cancel",testID:u,style:d,containerStyle:m,headerLabelStyle:p,footerButtonStyle:h,label:g,placeholder:f,helperText:y,error:b,required:x,disabled:S,size:v,variant:w,clearable:C,onClear:j,formatValue:k,triggerStyle:T,haptic:I}=e,M=void 0!==e.visible,[_,A]=useState(!1),E=M?t:_,V=M?u:u?`${u}-modal`:void 0,H=useTheme(),D=useSafeAreaInsets(),R=useMemo(()=>buildStyles(H),[H]),P=useRef(createAnimatedValue(0)).current,B=useRef(createAnimatedValue(40)).current,F=useRef(createAnimatedValue(0)).current,L=useRef(0),N=useCallback(()=>{M?n?.():A(!1)},[M,n]),O=useCallback(()=>{Animated.parallel([Animated.timing(P,{toValue:0,duration:H.motion.duration.fast,easing:Easing.bezier(...H.motion.easing.accelerate),useNativeDriver:!1}),Animated.timing(B,{toValue:40,duration:H.motion.duration.fast,easing:Easing.bezier(...H.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>N())},[N,P,B,H.motion.duration.fast,H.motion.easing.accelerate]),{handleGesture:W}=useDragToDismiss({drag:F,travel:()=>L.current||320,onDismiss:O}),$=useMemo(()=>"24h"===s?range(0,23):range(1,12),[s]),z=useMemo(()=>range(0,59,r),[r]),G=useMemo(()=>["AM","PM"],[]),q=useMemo(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),a=clampMinuteToStep(t,r),{displayHour:n,period:o}=from24h(e,s);return{displayHour:n,minute:a,period:o,hour24:e}},[i,s,r]),[U,K]=useState(()=>{const e=$.indexOf(q.displayHour);return e>=0?e:0}),[Y,J]=useState(()=>{const e=z.indexOf(q.minute);return e>=0?e:0}),[Q,X]=useState(()=>"PM"===q.period?1:0);useEffect(()=>{if(!E)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),a=clampMinuteToStep(t,r),{displayHour:n,period:o}=from24h(e,s),l=$.indexOf(n);K(l>=0?l:0);const c=z.indexOf(a);J(c>=0?c:0),X("PM"===o?1:0)},[E,i,s,r,$,z]),useEffect(()=>{let e;return E?(e=Animated.parallel([Animated.timing(P,{toValue:1,duration:H.motion.duration.normal,easing:Easing.out(Easing.cubic),useNativeDriver:!1}),Animated.spring(B,{toValue:0,damping:H.motion.spring.snappy.damping,stiffness:H.motion.spring.snappy.stiffness,mass:H.motion.spring.snappy.mass,useNativeDriver:!0})]),e.start()):(P.setValue(0),setNativeValue(B,40),setNativeValue(F,0)),()=>e?.stop()},[E,P,B,F,H.motion]);const Z=useCallback(e=>{"ios"!==Platform.OS&&"android"!==Platform.OS||AccessibilityInfo.announceForAccessibility(e)},[]),ee=useCallback(e=>{K(e),Z(`Hour ${$[e]}`)},[$,Z]),te=useCallback(e=>{J(e),Z(`${z[e]} minutes`)},[z,Z]),ie=useCallback(e=>{X(e),Z(G[e]??"")},[G,Z]),ae=useCallback(()=>{!1!==I&&triggerHaptic("selection"),O()},[O,I]),ne=useCallback(()=>{const e=$[U]??0,t=G[Q]??"AM",i=to24h(e,t,s),n=z[Y]??0;!1!==I&&triggerHaptic("notificationSuccess"),a?.({hour:i,minute:n}),O()},[$,U,G,Q,z,Y,s,a,O,I]),se=useMemo(()=>{const e=$[U]??0,t=z[Y]??0;if("24h"===s)return`${pad2(e)}:${pad2(t)}`;const i=G[Q]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[$,U,z,Y,G,Q,s]),re=useCallback(e=>pad2(Number(e)),[]),oe=useCallback(e=>pad2(Number(e)),[]),le=useCallback(e=>String(e),[]),ce=useCallback(e=>{if("24h"===s)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[s]),ue=!M&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(k??ce)(i):void 0,de=_jsx(Modal,{visible:E,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:O,testID:V,children:_jsxs(GestureHandlerRootView,{collapsable:!1,style:R.backdrop,children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:O,accessibilityLabel:"Close time picker",accessibilityRole:"button"}),_jsxs(Animated.View,{style:[R.sheet,{paddingBottom:Math.max(D.bottom,H.spacing.lg),transform:[{translateY:Animated.add(B,F)}]},d,m],onLayout:e=>{L.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessible:!0,accessibilityRole:"none",accessibilityLabel:o,children:[_jsx(GestureDetector,{gesture:W,children:_jsxs(View,{children:[_jsx(View,{style:R.handle}),_jsx(Text,{style:[R.title,p],accessibilityRole:"header",children:o})]})}),_jsx(View,{style:R.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:`Selected ${se}`,children:_jsx(Text,{style:R.summary,children:se})}),_jsxs(View,{style:R.wheelsRow,children:[_jsxs(View,{pointerEvents:"none",style:R.selectionBand,children:[_jsx(View,{style:R.bandLine}),_jsx(View,{style:[R.bandLine,R.bandLineBottom]})]}),_jsx(Wheel,{kind:"hour",label:"Hour",data:$,selectedIndex:U,onIndexChange:ee,formatItem:re,theme:H,haptic:I,testID:"time-picker-hour"}),_jsx(Text,{style:R.separator,children:":"}),_jsx(Wheel,{kind:"minute",label:"Minute",data:z,selectedIndex:Y,onIndexChange:te,formatItem:oe,theme:H,haptic:I,testID:"time-picker-minute"}),"12h"===s?_jsxs(_Fragment,{children:[_jsx(View,{style:R.spacer}),_jsx(Wheel,{kind:"period",label:"Period",data:G,selectedIndex:Q,onIndexChange:ie,formatItem:le,theme:H,haptic:I,testID:"time-picker-period"})]}):null]}),_jsxs(View,{style:R.footer,children:[_jsx(Button,{title:c,haptic:!1,variant:"ghost",tone:"neutral",onPress:ae,style:[R.footerBtn,h],accessibilityHint:"Dismiss without changes",testID:"time-picker-cancel"}),_jsx(Button,{title:l,variant:"solid",tone:"primary",haptic:!1,onPress:ne,style:[R.footerBtn,h],accessibilityHint:"Confirm selected time",testID:"time-picker-confirm"})]})]}),_jsx(ToastHost,{})]})});return M?de:_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:g,placeholder:f,helperText:y,error:b,required:x,disabled:S,size:v,variant:w,clearable:C,onClear:j,value:ue,onPress:()=>A(!0),triggerStyle:T,testID:u}),de]})},styles=StyleSheet.create({wheelColumn:{width:64,height:200,overflow:"hidden"},wheelList:{flexGrow:0,height:200},wheelItem:{height:40,alignItems:"center",justifyContent:"center"},wheelA11yLayer:{...StyleSheet.absoluteFill,zIndex:2}}),buildStyles=e=>{const t=e.shadows.xl;return StyleSheet.create({backdrop:{flex:1,backgroundColor:e.colors.background.overlay,justifyContent:"flex-end"},sheet:{backgroundColor:e.colors.background.elevated,borderTopLeftRadius:e.radius.xl,borderTopRightRadius:e.radius.xl,...smoothCorners,paddingTop:e.spacing.sm,paddingHorizontal:e.spacing.lg,paddingBottom:e.spacing.xl,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},handle:{alignSelf:"center",width:e.components.timePicker?.handleWidth??36,height:e.components.timePicker?.handleHeight??4,borderRadius:e.radius.full,...smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},title:{textAlign:"center",fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary,marginBottom:e.spacing.sm},summaryWrap:{alignItems:"center",marginBottom:e.spacing.md},summary:{fontSize:e.typography.fontSize["2xl"],fontWeight:e.typography.fontWeight.bold,color:e.colors.primary,letterSpacing:e.typography.letterSpacing.wide},wheelsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",height:200,position:"relative",marginBottom:e.spacing.lg},selectionBand:{position:"absolute",left:0,right:0,top:40*CENTER_OFFSET,height:40,justifyContent:"space-between"},bandLine:{height:2*StyleSheet.hairlineWidth,backgroundColor:e.colors.primary,opacity:.85},bandLineBottom:{},separator:{fontSize:e.typography.fontSize["2xl"],fontWeight:e.typography.fontWeight.bold,color:e.colors.text.primary,paddingHorizontal:e.spacing.xs},spacer:{width:e.spacing.md},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg}})};export{TimePicker};export default TimePicker;
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Modal,Pressable,StyleSheet,Text,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import Button from"../Button/Button.js";import{PickerTrigger}from"../PickerTrigger/PickerTrigger.js";import{ToastHost}from"../Toast/ToastProvider.js";import{WheelPicker}from"../WheelPicker/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const range=(e,t,i=1)=>{const r=[];for(let a=e;a<=t;a+=i)r.push(a);return r},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},TimePicker=e=>{const{visible:t,value:i,onChange:r,onClose:a,format:s="12h",minuteStep:o=1,title:n="Select Time",confirmLabel:l="Confirm",cancelLabel:u="Cancel",testID:m,style:c,containerStyle:d,headerLabelStyle:p,footerButtonStyle:g,label:h,placeholder:f,helperText:y,error:b,required:x,disabled:v,size:M,variant:k,clearable:S,onClear:j,formatValue:T,triggerStyle:w,haptic:C}=e,D=void 0!==e.visible,[H,P]=useState(!1),A=D?t:H,V=D?m:m?`${m}-modal`:void 0,_=useTheme(),R=useSafeAreaInsets(),B=useMemo(()=>buildStyles(_),[_]),N=useRef(createAnimatedValue(0)).current,$=useRef(createAnimatedValue(40)).current,I=useRef(createAnimatedValue(0)).current,L=useRef(0),z=useCallback(()=>{D?a?.():P(!1)},[D,a]),F=useCallback(()=>{Animated.parallel([Animated.timing(N,{toValue:0,duration:_.motion.duration.fast,easing:Easing.bezier(..._.motion.easing.accelerate),useNativeDriver:!1}),Animated.timing($,{toValue:40,duration:_.motion.duration.fast,easing:Easing.bezier(..._.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>z())},[z,N,$,_.motion.duration.fast,_.motion.easing.accelerate]),{handleGesture:O}=useDragToDismiss({drag:I,travel:()=>L.current||320,onDismiss:F}),W=useMemo(()=>"24h"===s?range(0,23):range(1,12),[s]),E=useMemo(()=>range(0,59,o),[o]),G=useMemo(()=>["AM","PM"],[]),q=useMemo(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,o),{displayHour:a,period:n}=from24h(e,s);return{displayHour:a,minute:r,period:n,hour24:e}},[i,s,o]),[U,Y]=useState(()=>{const e=W.indexOf(q.displayHour);return e>=0?e:0}),[J,K]=useState(()=>{const e=E.indexOf(q.minute);return e>=0?e:0}),[Q,X]=useState(()=>"PM"===q.period?1:0);useEffect(()=>{if(!A)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,o),{displayHour:a,period:n}=from24h(e,s),l=W.indexOf(a);Y(l>=0?l:0);const u=E.indexOf(r);K(u>=0?u:0),X("PM"===n?1:0)},[A,i,s,o,W,E]),useEffect(()=>{let e;return A?(e=Animated.parallel([Animated.timing(N,{toValue:1,duration:_.motion.duration.normal,easing:Easing.out(Easing.cubic),useNativeDriver:!1}),Animated.spring($,{toValue:0,damping:_.motion.spring.snappy.damping,stiffness:_.motion.spring.snappy.stiffness,mass:_.motion.spring.snappy.mass,useNativeDriver:!0})]),e.start()):(N.setValue(0),setNativeValue($,40),setNativeValue(I,0)),()=>e?.stop()},[A,N,$,I,_.motion]);const Z=useCallback((e,t)=>{"hour"===e?Y(Math.max(0,W.indexOf(Number(t)))):"minute"===e?K(Math.max(0,E.indexOf(Number(t)))):X("PM"===t?1:0)},[W,E]),ee=useCallback(()=>{!1!==C&&triggerHaptic("selection"),F()},[F,C]),te=useCallback(()=>{const e=W[U]??0,t=G[Q]??"AM",i=to24h(e,t,s),a=E[J]??0;!1!==C&&triggerHaptic("notificationSuccess"),r?.({hour:i,minute:a}),F()},[W,U,G,Q,E,J,s,r,F,C]),ie=useMemo(()=>{const e=W[U]??0,t=E[J]??0;if("24h"===s)return`${pad2(e)}:${pad2(t)}`;const i=G[Q]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[W,U,E,J,G,Q,s]),re=useMemo(()=>W.map(e=>({value:e,label:pad2(e),accessibilityLabel:`Hour ${e}`})),[W]),ae=useMemo(()=>E.map(e=>({value:e,label:pad2(e),accessibilityLabel:`${e} minutes`})),[E]),se=useMemo(()=>G.map(e=>({value:e,label:e})),[G]),oe=useMemo(()=>{const e=[{key:"hour",label:"Hour",items:re,value:W[U]??0,separator:":",testID:"time-picker-hour"},{key:"minute",label:"Minute",items:ae,value:E[J]??0,gapAfter:"12h"===s?_.spacing.md:void 0,testID:"time-picker-minute"}];return"12h"===s&&e.push({key:"period",label:"Period",items:se,value:G[Q]??"AM",testID:"time-picker-period"}),e},[re,ae,se,W,U,E,J,G,Q,s,_.spacing.md]),ne=useCallback(e=>{if("24h"===s)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[s]),le=!D&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(T??ne)(i):void 0,ue=_jsx(Modal,{visible:A,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:F,testID:V,children:_jsxs(GestureHandlerRootView,{collapsable:!1,style:B.backdrop,children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:F,accessibilityLabel:"Close time picker",accessibilityRole:"button"}),_jsxs(Animated.View,{style:[B.sheet,{paddingBottom:Math.max(R.bottom,_.spacing.lg),transform:[{translateY:Animated.add($,I)}]},c,d],onLayout:e=>{L.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessible:!0,accessibilityRole:"none",accessibilityLabel:n,children:[_jsx(GestureDetector,{gesture:O,children:_jsxs(View,{children:[_jsx(View,{style:B.handle}),_jsx(Text,{style:[B.title,p],accessibilityRole:"header",children:n})]})}),_jsx(View,{style:B.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:`Selected ${ie}`,children:_jsx(Text,{style:B.summary,children:ie})}),_jsx(WheelPicker,{columns:oe,onChange:Z,haptic:C,style:B.wheels}),_jsxs(View,{style:B.footer,children:[_jsx(Button,{title:u,haptic:!1,variant:"ghost",tone:"neutral",onPress:ee,style:[B.footerBtn,g],accessibilityHint:"Dismiss without changes",testID:"time-picker-cancel"}),_jsx(Button,{title:l,variant:"solid",tone:"primary",haptic:!1,onPress:te,style:[B.footerBtn,g],accessibilityHint:"Confirm selected time",testID:"time-picker-confirm"})]})]}),_jsx(ToastHost,{})]})});return D?ue:_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:h,placeholder:f,helperText:y,error:b,required:x,disabled:v,size:M,variant:k,clearable:S,onClear:j,value:le,onPress:()=>P(!0),triggerStyle:w,testID:m}),ue]})},buildStyles=e=>{const t=e.shadows.xl;return StyleSheet.create({backdrop:{flex:1,backgroundColor:e.colors.background.overlay,justifyContent:"flex-end"},sheet:{backgroundColor:e.colors.background.elevated,borderTopLeftRadius:e.radius.xl,borderTopRightRadius:e.radius.xl,...smoothCorners,paddingTop:e.spacing.sm,paddingHorizontal:e.spacing.lg,paddingBottom:e.spacing.xl,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},handle:{alignSelf:"center",width:e.components.timePicker?.handleWidth??36,height:e.components.timePicker?.handleHeight??4,borderRadius:e.radius.full,...smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},title:{textAlign:"center",fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary,marginBottom:e.spacing.sm},summaryWrap:{alignItems:"center",marginBottom:e.spacing.md},summary:{fontSize:e.typography.fontSize["2xl"],fontWeight:e.typography.fontWeight.bold,color:e.colors.primary,letterSpacing:e.typography.letterSpacing.wide},wheels:{marginBottom:e.spacing.lg},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg}})};export{TimePicker};export default TimePicker;
|