@webority/mobile-ui 0.144.2 → 0.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas-kit/kit.js +4429 -3708
- package/dist/canvas-kit/manifest.json +1 -1
- package/dist/canvas-kit/release.json +5 -5
- package/lib/commonjs/components/Accordion/Accordion.js +1 -1
- package/lib/commonjs/components/AmountSlider/AmountSlider.js +1 -1
- package/lib/commonjs/components/AnimatePresence/AnimatePresence.js +1 -1
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
- package/lib/commonjs/components/AsyncBlock/AsyncBlock.js +1 -1
- package/lib/commonjs/components/AuthedImage/AuthedImage.js +1 -1
- package/lib/commonjs/components/Autocomplete/Autocomplete.js +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js +1 -1
- package/lib/commonjs/components/Badge/Badge.js +1 -1
- package/lib/commonjs/components/Banner/Banner.js +1 -1
- package/lib/commonjs/components/BarChart/BarChart.js +1 -1
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Button/Button.js +1 -1
- package/lib/commonjs/components/Calendar/Calendar.js +1 -1
- package/lib/commonjs/components/Card/Card.js +1 -1
- package/lib/commonjs/components/Carousel/Carousel.js +1 -1
- package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
- package/lib/commonjs/components/Chip/Chip.js +1 -1
- package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/commonjs/components/Confetti/Confetti.js +1 -1
- package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
- package/lib/commonjs/components/Dialog/Dialog.js +1 -1
- package/lib/commonjs/components/Dialog/OverlayActions.js +1 -1
- package/lib/commonjs/components/Divider/Divider.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/EmptyState/EmptyState.js +1 -1
- package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
- package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
- package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
- package/lib/commonjs/components/FilterChipRow/FilterChipRow.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/FormField/FormField.js +1 -1
- package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
- package/lib/commonjs/components/IconButton/IconButton.js +1 -1
- package/lib/commonjs/components/InlineSelect/InlineSelect.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/ListSection/ListSection.js +1 -1
- package/lib/commonjs/components/Menu/Menu.js +1 -1
- package/lib/commonjs/components/Menu/useContextMenu.js +1 -1
- package/lib/commonjs/components/MessageBubble/MessageBubble.js +1 -1
- package/lib/commonjs/components/Modal/Modal.js +1 -1
- package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
- package/lib/commonjs/components/PermissionPrompt/PermissionPrompt.js +1 -1
- package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
- package/lib/commonjs/components/ProfileCompletion/ProfileCompletion.js +1 -1
- package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/commonjs/components/ProgressRing/ProgressRing.js +1 -1
- package/lib/commonjs/components/Radio/Radio.js +1 -1
- package/lib/commonjs/components/Rating/Rating.js +1 -1
- package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
- package/lib/commonjs/components/SectionHeader/SectionHeader.js +1 -1
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/commonjs/components/Select/Select.js +1 -1
- package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/commonjs/components/Skeleton/Skeleton.js +1 -1
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
- package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/commonjs/components/Slider/Slider.js +1 -1
- package/lib/commonjs/components/SliderField/SliderField.js +1 -1
- package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
- package/lib/commonjs/components/Spinner/Spinner.js +1 -1
- package/lib/commonjs/components/StatTile/StatTile.js +1 -1
- package/lib/commonjs/components/StatusBadge/StatusBadge.js +1 -1
- package/lib/commonjs/components/Stepper/Stepper.js +1 -1
- package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
- package/lib/commonjs/components/Switch/Switch.js +1 -1
- package/lib/commonjs/components/Tabs/Tabs.js +1 -1
- package/lib/commonjs/components/TagInput/TagInput.js +1 -1
- package/lib/commonjs/components/Text/Text.js +1 -1
- package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
- package/lib/commonjs/components/Timeline/Timeline.js +1 -1
- package/lib/commonjs/components/Toast/Toast.js +1 -1
- package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
- package/lib/commonjs/components/WheelPicker/WheelPicker.js +1 -1
- package/lib/commonjs/utils/assertValidValue.js +1 -0
- package/lib/module/components/Accordion/Accordion.js +1 -1
- package/lib/module/components/AmountSlider/AmountSlider.js +1 -1
- package/lib/module/components/AnimatePresence/AnimatePresence.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/AppIcon/AppIcon.js +1 -1
- package/lib/module/components/AsyncBlock/AsyncBlock.js +1 -1
- package/lib/module/components/AuthedImage/AuthedImage.js +1 -1
- package/lib/module/components/Autocomplete/Autocomplete.js +1 -1
- package/lib/module/components/Avatar/Avatar.js +1 -1
- package/lib/module/components/Badge/Badge.js +1 -1
- package/lib/module/components/Banner/Banner.js +1 -1
- package/lib/module/components/BarChart/BarChart.js +1 -1
- package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/Button/Button.js +1 -1
- package/lib/module/components/Calendar/Calendar.js +1 -1
- package/lib/module/components/Card/Card.js +1 -1
- package/lib/module/components/Carousel/Carousel.js +1 -1
- package/lib/module/components/Checkbox/Checkbox.js +1 -1
- package/lib/module/components/Chip/Chip.js +1 -1
- package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/module/components/Confetti/Confetti.js +1 -1
- package/lib/module/components/Descriptions/Descriptions.js +1 -1
- package/lib/module/components/Dialog/Dialog.js +1 -1
- package/lib/module/components/Dialog/OverlayActions.js +1 -1
- package/lib/module/components/Divider/Divider.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/EmptyState/EmptyState.js +1 -1
- package/lib/module/components/FieldBase/FieldBase.js +1 -1
- package/lib/module/components/FilePicker/FilePicker.js +1 -1
- package/lib/module/components/FileViewer/FileViewer.js +1 -1
- package/lib/module/components/FilterChipRow/FilterChipRow.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/FormField/FormField.js +1 -1
- package/lib/module/components/IconBadge/IconBadge.js +1 -1
- package/lib/module/components/IconButton/IconButton.js +1 -1
- package/lib/module/components/InlineSelect/InlineSelect.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/ListSection/ListSection.js +1 -1
- package/lib/module/components/Menu/Menu.js +1 -1
- package/lib/module/components/Menu/useContextMenu.js +1 -1
- package/lib/module/components/MessageBubble/MessageBubble.js +1 -1
- package/lib/module/components/Modal/Modal.js +1 -1
- package/lib/module/components/NumberInput/NumberInput.js +1 -1
- package/lib/module/components/OTPInput/OTPInput.js +1 -1
- package/lib/module/components/PermissionPrompt/PermissionPrompt.js +1 -1
- package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
- package/lib/module/components/ProfileCompletion/ProfileCompletion.js +1 -1
- package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
- package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/module/components/ProgressRing/ProgressRing.js +1 -1
- package/lib/module/components/Radio/Radio.js +1 -1
- package/lib/module/components/Rating/Rating.js +1 -1
- package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/module/components/SearchBar/SearchBar.js +1 -1
- package/lib/module/components/SectionHeader/SectionHeader.js +1 -1
- package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/module/components/Select/Select.js +1 -1
- package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/module/components/Skeleton/Skeleton.js +1 -1
- package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
- package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/module/components/Slider/Slider.js +1 -1
- package/lib/module/components/SliderField/SliderField.js +1 -1
- package/lib/module/components/Sparkline/Sparkline.js +1 -1
- package/lib/module/components/Spinner/Spinner.js +1 -1
- package/lib/module/components/StatTile/StatTile.js +1 -1
- package/lib/module/components/StatusBadge/StatusBadge.js +1 -1
- package/lib/module/components/Stepper/Stepper.js +1 -1
- package/lib/module/components/Swipeable/Swipeable.js +1 -1
- package/lib/module/components/Switch/Switch.js +1 -1
- package/lib/module/components/Tabs/Tabs.js +1 -1
- package/lib/module/components/TagInput/TagInput.js +1 -1
- package/lib/module/components/Text/Text.js +1 -1
- package/lib/module/components/TimePicker/TimePicker.js +1 -1
- package/lib/module/components/Timeline/Timeline.js +1 -1
- package/lib/module/components/Toast/Toast.js +1 -1
- package/lib/module/components/Tooltip/Tooltip.js +1 -1
- package/lib/module/components/WheelPicker/WheelPicker.js +1 -1
- package/lib/module/utils/assertValidValue.js +1 -0
- package/lib/typescript/commonjs/utils/assertValidValue.d.ts +10 -0
- package/lib/typescript/module/utils/assertValidValue.d.ts +10 -0
- package/package.json +7 -7
- package/lib/commonjs/utils/warnInvalidValue.js +0 -1
- package/lib/module/utils/warnInvalidValue.js +0 -1
- package/lib/typescript/commonjs/utils/warnInvalidValue.d.ts +0 -10
- package/lib/typescript/module/utils/warnInvalidValue.d.ts +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.BottomNavigation=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_shadows=require("../../utils/shadows.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index3=require("../AppIcon/index.js"),_index4=require("../Badge/index.js"),_index5=require("../Text/index.js"),_useScreenReaderEnabled=require("./useScreenReaderEnabled.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=n&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?n(r,a,i):r[a]=e[a]);return r}const DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"}),DEFAULT_ICON_SIZE=18,DEFAULT_LABEL_MAX_FONT_SCALE=1.2,ICON_WRAP_AIR=4,PILL_AIR=8,DEFAULT_PILL_MAX_WIDTH=64,TILE_MAX_WIDTH=96,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__center_action__",EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,badgeVariantOf=e=>null==e||!1===e?null:!0===e||"·"===e?"dot":"number"==typeof e?e>0?"standard":null:e.length>0?"standard":null,badgeAccessibilitySuffix=(e,t)=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${t.unread(e)}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=exports.BottomNavigation=(0,_react.forwardRef)((e,t)=>{const{tabs:i,centerAction:a,activeTab:n,onChange:r,haptic:o="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:h,marginHorizontal:_,marginVertical:m,paddingHorizontal:g,paddingVertical:b,border:x,minimizeOnScroll:f=!1,scrollDirection:y="idle",accessory:v,style:R,indicatorStyle:N,labelStyle:j,labelMaxFontScale:w,labels:A,testID:S}=e;(0,_warnInvalidValue.warnInvalidValue)("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),(0,_warnInvalidValue.warnInvalidValue)("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const I=(0,_react.useMemo)(()=>A?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...A}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[A]),E=(0,_index.useTheme)(),T=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),L=(0,_react.useMemo)(()=>buildStyles(E),[E]),V=h??18,M=V+4+8,B=E.space.lg,C=E.space.lg,D=E.radius.xl,O=(0,_useReducedMotion.useReducedMotion)(),k=(0,_useScreenReaderEnabled.useScreenReaderEnabled)(f),[P,z]=_react.default.useState(null);(0,_react.useEffect)(()=>{null!==P&&P!==y&&z(null)},[P,y]);const F=f&&!k&&"down"===y&&null===P,[H,W]=_react.default.useState(F);(0,_react.useEffect)(()=>{H!==F&&(O||"web"===_reactNative.Platform.OS||_reactNative.LayoutAnimation.configureNext(_reactNative.LayoutAnimation.Presets.easeInEaseOut),W(F))},[H,F,O]);const q="function"==typeof v?v({minimized:H}):v,U=null!=q&&!1!==q,$=H&&U,[X,G]=_react.default.useState(0),Z=U&&!$?X+E.space.xs:0,Y="tile"===l,K="floating"===l||Y,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||K||ee,ie=Math.max(0,i.findIndex(e=>e.key===n)),[ae,ne]=_react.default.useState(0),[re,oe]=_react.default.useState(0),se=a?Math.ceil(i.length/2):i.length,le=i.length+(a?1:0),[de,ce]=_react.default.useState({width:0,height:0}),ue=a?.size??48,pe=void 0!==a?.gap,he=Math.max(0,a?.gap??0),me=pe?(de.width||ue)+2*he:0,ge=pe?i.length>0?Math.max(0,ae-me)/i.length:0:le>0?ae/le:0,be=pe?me:ge,xe=(0,_react.useRef)((0,_index.createAnimatedValue)(ie)).current,fe=(0,_react.useRef)({}),ye=(0,_react.useRef)({});i.forEach(e=>{fe.current[e.key]||(fe.current[e.key]=new _reactNative.Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=(0,_index.createAnimatedValue)(e.key===n?1:0))});const ve=ge>0?Y?Math.min(ge-4,96):Math.min(ge-B,64):0,Re=ge>0?(ge-ve)/2:0,Ne=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!H&&!1!==e.showLabel&&e.label.trim().length>0,je=i[ie],we=je&&!hasLabel(je)&&re>0?re/2:E.space.xs+(V+4)/2,Ae=we-14-24,Se=Math.max(0,re-4),Ie=Y?2:we-M/2,Ee=(0,_react.useRef)(ie);(0,_react.useEffect)(()=>{if(Ee.current===ie)return;Ee.current=ie;const e=_reactNative.Animated.spring(xe,{toValue:ie,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[ie,xe]);const Te=Math.max(1,i.length-1),Le=(0,_react.useMemo)(()=>{const e=[],t=[];for(let i=0;i<=Te;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Te,se,ge,be]),Ve=i.map(e=>e.key).join(" "),Me=J||Q;(0,_react.useEffect)(()=>{const e=Ve.split(" ").flatMap(e=>{const t=e===n?1:0,i=ye.current[e];return i?Me?[_reactNative.Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=_reactNative.Animated.parallel(e);return t.start(),()=>t.stop()},[n,Ve,Me]);const popIcon=e=>{_reactNative.Animated.sequence([_reactNative.Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:!0}),_reactNative.Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:!0})]).start()},Be=(0,_react.useRef)(new _reactNative.Animated.Value(1)).current,{colors:Ce}=E,De=ee?Ce.primary:Ce.surface,Oe=ee?Ce["on-primary"]:Ce.primary,ke=ee?Ce["on-primary"]:Y?Ce["text-body"]:Ce["text-subtle"],Pe=ee?Ce["on-primary"]:Ce["primary-soft"],ze=ee?Ce.primary:J?Ce["on-primary"]:Oe,Fe=_??C,He=m??(K?C:0),We=He>0,qe=b??E.space.sm,Ue=g??(K?E.space.sm:E.space.xs),$e=We?qe:Math.max(qe,T.bottom),Xe=We?Math.max(He,T.bottom>0?T.bottom+E.space.sm:0):0,Ge="pill"===c,Ze=K?re+Z+2*qe+2*_reactNative.StyleSheet.hairlineWidth:re+Z+qe+$e,Ye=Ge?re>0?Ze/2:E.radius.pill:c??(Y?E.radius.pill:K?D:E.radius.none),Ke=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Ke?Math.min(Ye,e/2):t,Je="underline"===l?Math.max(Ue,Ge&&0===re?0:Ye):Ue,Qe=p??"none",et="none"===Qe?void 0:E.shadow[Qe],tt=void 0===et?null:(0,_shadows.supportsBoxShadow)()?{boxShadow:(0,_shadows.toBoxShadow)(et)}:et,it=x?_reactNative.StyleSheet.hairlineWidth:0,at=ee?Ce.primary:Ce.border,nt=a?.lift??0,rt=qe+it+Z,ot=a&&re>0?Math.max(0,(de.height||ue)/2+nt-re/2-rt):0,st=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.centerCell,pe?{flex:0,marginHorizontal:he}:null],pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{if(!a)return;const e=a.haptic??o;!1!==e&&(0,_index2.triggerHaptic)(e),popIcon(Be),a.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ce(e=>e.width===t&&e.height===i?e:{width:t,height:i})},accessibilityRole:"button",accessibilityLabel:a.label,hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[L.centerPressable,{top:-nt},e?{opacity:.85}:null],testID:a.testID??(S?`${S}-center`:void 0),children:[a.content?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Be}]},children:a.content}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.centerCircle,{width:ue,height:ue,borderRadius:E.radius.pill,..._corners.smoothCorners,backgroundColor:a.color??Ce.primary}],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Be}]},children:(0,_index3.renderSlotIcon)(a.icon??"add",{color:a.iconColor??Ce["on-primary"],size:a.iconSize??24,disabled:!1})})}),(lt=a,s&&!H&<.label.trim().length>0?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:w??E.settings.maxFontSizeMultiplier??1.2,style:[L.label,{color:ke,opacity:ee?.7:1},j],children:a.label}):null)]})},CENTER_KEY):null;var lt;const dt=U?(0,_jsxRuntime.jsx)(_reactNative.View,{style:$?L.accessoryInline:L.accessoryStacked,onLayout:e=>G(e.nativeEvent.layout.height),testID:S?`${S}-accessory`:void 0,children:q}):null,ct=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$?[L.tabRow,L.tabRowInline]:L.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ne(t),oe(i)},children:[te&&ve>0&&(!Y||Se>0)?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[L.pill,{width:ve,height:Y?Se:M,left:Re,top:Ie,backgroundColor:Pe,borderRadius:Y?activeBgRadius(Se,Se/2):activeBgRadius(M,E.radius.pill),..._corners.smoothCorners,transform:[{translateX:Le}]},N]}):null,J&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[L.bubble,E.shadow.elevated,{width:48,height:48,borderRadius:E.radius.pill,..._corners.smoothCorners,left:Ne,top:Ae,backgroundColor:Ce.primary,borderColor:Ce.surface,transform:[{translateX:Le}]},N]}):null,(ut=i.map(e=>{const t=e.key===n,i=t?Oe:ke,a=t?ze:ke,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=fe.current[e.key],c=ye.current[e.key],u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,I),h=ee&&!t?.7:1,_=J&&t||ee?Ce.primary:Ce.surface,m=hasLabel(e),g=m&&(!Q||t),b=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[L.iconWrap,{width:V+4,height:V+4,opacity:h,transform:[{scale:d}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_index3.renderSlotIcon)(l,{color:a,size:V,focused:t,disabled:!1})}),u?(0,_jsxRuntime.jsx)(_index4.Badge,{variant:u,value:"standard"===u?e.badge:void 0,tone:"danger",accessible:!1,style:"dot"===u?L.badgeDotPosition:L.badgePillPosition,badgeStyle:["dot"===u?L.badgeDot:L.badgePill,{borderColor:_}],textStyle:L.badgeText}):null]}),x=J?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:b}):b,f=g?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:w??E.settings.maxFontSizeMultiplier??1.2,style:[L.label,Q?L.labelInline:null,{color:i,opacity:Q?c:h,fontWeight:t?E.weight.semibold:E.weight.normal},j],children:e.label}):null,v=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>(e=>{H&&z(y),e.key!==n&&!1!==o&&(0,_index2.triggerHaptic)(o);const t=fe.current[e.key];t&&popIcon(t),r(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:I.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[L.tab,Y?L.tabTile:null,e?{opacity:.85}:null],testID:S?`${S}-tab-${e.key}`:void 0,children:Q?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[L.expandPill,{height:M,paddingHorizontal:t&&m?E.space.md:Math.max(0,(M-(V+4))/2)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[L.expandFill,{borderRadius:activeBgRadius(M,M/2),..._corners.smoothCorners,backgroundColor:t?Ce["primary-soft"]:"transparent"},t?N:null]}),x,f]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[x,f]})},e.key);return Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,m?1.5:1]})},children:v},e.key):v}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[L.underline,"top"===d?L.underlineTop:L.underlineBottom,"top"===d?{top:-qe-Z}:{bottom:-qe},{width:ge,height:3,backgroundColor:Ce.primary,transform:[{translateX:Le}]},N]}):null]});var ut;return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,testID:S,accessibilityRole:"tablist",style:[L.outer,{paddingHorizontal:Fe,paddingTop:Math.max(He,ot),paddingBottom:Xe},R],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[K?L.floatingBar:L.dockedBar,$?L.barInline:null,tt,{backgroundColor:De,borderColor:at,borderRadius:Ye,..._corners.smoothCorners},K?{borderWidth:it,paddingHorizontal:Ue,paddingVertical:qe}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:qe,paddingBottom:$e}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>_reactNative.StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:e.space.xs},floatingBar:{paddingVertical:e.space.sm,paddingHorizontal:e.space.sm},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.space.xs},accessoryInline:{flexShrink:0,marginRight:e.space.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:e.space.xs,gap:e.space.xs},tabTile:{paddingVertical:e.space.sm,gap:e.space.xxs},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerPressable:{alignItems:"center",maxWidth:"100%",gap:e.space.xs},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.text.xs.size,lineHeight:e.text.xs.size*e.leading.heading,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.text.sm.size,lineHeight:e.text.sm.size*e.leading.heading,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.space.xs},expandFill:{position:"absolute",top:0,right:0,bottom:0,left:0,overflow:"hidden"},pill:{position:"absolute",left:0},bubble:{position:"absolute",left:0,borderWidth:3},underline:{position:"absolute",left:0,height:3},underlineBottom:{borderTopLeftRadius:e.radius.none,borderTopRightRadius:e.radius.none,..._corners.smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,..._corners.smoothCorners},badgePillPosition:{position:"absolute",top:-4,right:-8},badgePill:{minWidth:18,height:18,paddingHorizontal:e.space.xs,paddingVertical:e.space.xxs,borderWidth:1.5},badgeDotPosition:{position:"absolute",top:-2,right:-2},badgeDot:{width:10,height:10,borderRadius:e.radius.pill,borderWidth:1.5},badgeText:{lineHeight:13}});var _default=exports.default=BottomNavigation;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.BottomNavigation=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_shadows=require("../../utils/shadows.js"),_index3=require("../AppIcon/index.js"),_index4=require("../Badge/index.js"),_index5=require("../Text/index.js"),_useScreenReaderEnabled=require("./useScreenReaderEnabled.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=n&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?n(r,a,i):r[a]=e[a]);return r}const DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"}),DEFAULT_ICON_SIZE=18,DEFAULT_LABEL_MAX_FONT_SCALE=1.2,ICON_WRAP_AIR=4,PILL_AIR=8,DEFAULT_PILL_MAX_WIDTH=64,TILE_MAX_WIDTH=96,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__center_action__",EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,badgeVariantOf=e=>null==e||!1===e?null:!0===e||"·"===e?"dot":"number"==typeof e?e>0?"standard":null:e.length>0?"standard":null,badgeAccessibilitySuffix=(e,t)=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${t.unread(e)}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=exports.BottomNavigation=(0,_react.forwardRef)((e,t)=>{const{tabs:i,centerAction:a,activeTab:n,onChange:r,haptic:o="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:h,marginHorizontal:_,marginVertical:m,paddingHorizontal:g,paddingVertical:b,border:x,minimizeOnScroll:f=!1,scrollDirection:y="idle",accessory:v,style:R,indicatorStyle:N,labelStyle:j,labelMaxFontScale:A,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),(0,_assertValidValue.assertValidValue)("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const E=(0,_react.useMemo)(()=>S?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...S}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[S]),I=(0,_index.useTheme)(),T=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),V=(0,_react.useMemo)(()=>buildStyles(I),[I]),L=h??18,M=L+4+8,B=I.space.lg,C=I.space.lg,D=I.radius.xl,O=(0,_useReducedMotion.useReducedMotion)(),k=(0,_useScreenReaderEnabled.useScreenReaderEnabled)(f),[P,z]=_react.default.useState(null);(0,_react.useEffect)(()=>{null!==P&&P!==y&&z(null)},[P,y]);const F=f&&!k&&"down"===y&&null===P,[H,W]=_react.default.useState(F);(0,_react.useEffect)(()=>{H!==F&&(O||"web"===_reactNative.Platform.OS||_reactNative.LayoutAnimation.configureNext(_reactNative.LayoutAnimation.Presets.easeInEaseOut),W(F))},[H,F,O]);const q="function"==typeof v?v({minimized:H}):v,U=null!=q&&!1!==q,$=H&&U,[X,G]=_react.default.useState(0),Z=U&&!$?X+I.space.xs:0,Y="tile"===l,K="floating"===l||Y,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||K||ee,ie=Math.max(0,i.findIndex(e=>e.key===n)),[ae,ne]=_react.default.useState(0),[re,oe]=_react.default.useState(0),se=a?Math.ceil(i.length/2):i.length,le=i.length+(a?1:0),[de,ce]=_react.default.useState({width:0,height:0}),ue=a?.size??48,pe=void 0!==a?.gap,he=Math.max(0,a?.gap??0),me=pe?(de.width||ue)+2*he:0,ge=pe?i.length>0?Math.max(0,ae-me)/i.length:0:le>0?ae/le:0,be=pe?me:ge,xe=(0,_react.useRef)((0,_index.createAnimatedValue)(ie)).current,fe=(0,_react.useRef)({}),ye=(0,_react.useRef)({});i.forEach(e=>{fe.current[e.key]||(fe.current[e.key]=new _reactNative.Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=(0,_index.createAnimatedValue)(e.key===n?1:0))});const ve=ge>0?Y?Math.min(ge-4,96):Math.min(ge-B,64):0,Re=ge>0?(ge-ve)/2:0,Ne=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!H&&!1!==e.showLabel&&e.label.trim().length>0,je=i[ie],Ae=je&&!hasLabel(je)&&re>0?re/2:I.space.xs+(L+4)/2,Se=Ae-14-24,we=Math.max(0,re-4),Ee=Y?2:Ae-M/2,Ie=(0,_react.useRef)(ie);(0,_react.useEffect)(()=>{if(Ie.current===ie)return;Ie.current=ie;const e=_reactNative.Animated.spring(xe,{toValue:ie,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[ie,xe]);const Te=Math.max(1,i.length-1),Ve=(0,_react.useMemo)(()=>{const e=[],t=[];for(let i=0;i<=Te;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Te,se,ge,be]),Le=i.map(e=>e.key).join(" "),Me=J||Q;(0,_react.useEffect)(()=>{const e=Le.split(" ").flatMap(e=>{const t=e===n?1:0,i=ye.current[e];return i?Me?[_reactNative.Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=_reactNative.Animated.parallel(e);return t.start(),()=>t.stop()},[n,Le,Me]);const popIcon=e=>{_reactNative.Animated.sequence([_reactNative.Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:!0}),_reactNative.Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:!0})]).start()},Be=(0,_react.useRef)(new _reactNative.Animated.Value(1)).current,{colors:Ce}=I,De=ee?Ce.primary:Ce.surface,Oe=ee?Ce["on-primary"]:Ce.primary,ke=ee?Ce["on-primary"]:Y?Ce["text-body"]:Ce["text-subtle"],Pe=ee?Ce["on-primary"]:Ce["primary-soft"],ze=ee?Ce.primary:J?Ce["on-primary"]:Oe,Fe=_??C,He=m??(K?C:0),We=He>0,qe=b??I.space.sm,Ue=g??(K?I.space.sm:I.space.xs),$e=We?qe:Math.max(qe,T.bottom),Xe=We?Math.max(He,T.bottom>0?T.bottom+I.space.sm:0):0,Ge="pill"===c,Ze=K?re+Z+2*qe+2*_reactNative.StyleSheet.hairlineWidth:re+Z+qe+$e,Ye=Ge?re>0?Ze/2:I.radius.pill:c??(Y?I.radius.pill:K?D:I.radius.none),Ke=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Ke?Math.min(Ye,e/2):t,Je="underline"===l?Math.max(Ue,Ge&&0===re?0:Ye):Ue,Qe=p??"none",et="none"===Qe?void 0:I.shadow[Qe],tt=void 0===et?null:(0,_shadows.supportsBoxShadow)()?{boxShadow:(0,_shadows.toBoxShadow)(et)}:et,it=x?_reactNative.StyleSheet.hairlineWidth:0,at=ee?Ce.primary:Ce.border,nt=a?.lift??0,rt=qe+it+Z,ot=a&&re>0?Math.max(0,(de.height||ue)/2+nt-re/2-rt):0,st=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCell,pe?{flex:0,marginHorizontal:he}:null],pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{if(!a)return;const e=a.haptic??o;!1!==e&&(0,_index2.triggerHaptic)(e),popIcon(Be),a.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ce(e=>e.width===t&&e.height===i?e:{width:t,height:i})},accessibilityRole:"button",accessibilityLabel:a.label,hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.centerPressable,{top:-nt},e?{opacity:.85}:null],testID:a.testID??(w?`${w}-center`:void 0),children:[a.content?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Be}]},children:a.content}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCircle,{width:ue,height:ue,borderRadius:I.radius.pill,..._corners.smoothCorners,backgroundColor:a.color??Ce.primary}],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Be}]},children:(0,_index3.renderSlotIcon)(a.icon??"add",{color:a.iconColor??Ce["on-primary"],size:a.iconSize??24,disabled:!1})})}),(lt=a,s&&!H&<.label.trim().length>0?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,{color:ke,opacity:ee?.7:1},j],children:a.label}):null)]})},CENTER_KEY):null;var lt;const dt=U?(0,_jsxRuntime.jsx)(_reactNative.View,{style:$?V.accessoryInline:V.accessoryStacked,onLayout:e=>G(e.nativeEvent.layout.height),testID:w?`${w}-accessory`:void 0,children:q}):null,ct=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$?[V.tabRow,V.tabRowInline]:V.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ne(t),oe(i)},children:[te&&ve>0&&(!Y||we>0)?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.pill,{width:ve,height:Y?we:M,left:Re,top:Ee,backgroundColor:Pe,borderRadius:Y?activeBgRadius(we,we/2):activeBgRadius(M,I.radius.pill),..._corners.smoothCorners,transform:[{translateX:Ve}]},N]}):null,J&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.bubble,I.shadow.elevated,{width:48,height:48,borderRadius:I.radius.pill,..._corners.smoothCorners,left:Ne,top:Se,backgroundColor:Ce.primary,borderColor:Ce.surface,transform:[{translateX:Ve}]},N]}):null,(ut=i.map(e=>{const t=e.key===n,i=t?Oe:ke,a=t?ze:ke,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=fe.current[e.key],c=ye.current[e.key],u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,E),h=ee&&!t?.7:1,_=J&&t||ee?Ce.primary:Ce.surface,m=hasLabel(e),g=m&&(!Q||t),b=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[V.iconWrap,{width:L+4,height:L+4,opacity:h,transform:[{scale:d}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_index3.renderSlotIcon)(l,{color:a,size:L,focused:t,disabled:!1})}),u?(0,_jsxRuntime.jsx)(_index4.Badge,{variant:u,value:"standard"===u?e.badge:void 0,tone:"danger",accessible:!1,style:"dot"===u?V.badgeDotPosition:V.badgePillPosition,badgeStyle:["dot"===u?V.badgeDot:V.badgePill,{borderColor:_}],textStyle:V.badgeText}):null]}),x=J?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:b}):b,f=g?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,Q?V.labelInline:null,{color:i,opacity:Q?c:h,fontWeight:t?I.weight.semibold:I.weight.normal},j],children:e.label}):null,v=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>(e=>{H&&z(y),e.key!==n&&!1!==o&&(0,_index2.triggerHaptic)(o);const t=fe.current[e.key];t&&popIcon(t),r(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:E.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.tab,Y?V.tabTile:null,e?{opacity:.85}:null],testID:w?`${w}-tab-${e.key}`:void 0,children:Q?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[V.expandPill,{height:M,paddingHorizontal:t&&m?I.space.md:Math.max(0,(M-(L+4))/2)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[V.expandFill,{borderRadius:activeBgRadius(M,M/2),..._corners.smoothCorners,backgroundColor:t?Ce["primary-soft"]:"transparent"},t?N:null]}),x,f]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[x,f]})},e.key);return Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,m?1.5:1]})},children:v},e.key):v}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.underline,"top"===d?V.underlineTop:V.underlineBottom,"top"===d?{top:-qe-Z}:{bottom:-qe},{width:ge,height:3,backgroundColor:Ce.primary,transform:[{translateX:Ve}]},N]}):null]});var ut;return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,testID:w,accessibilityRole:"tablist",style:[V.outer,{paddingHorizontal:Fe,paddingTop:Math.max(He,ot),paddingBottom:Xe},R],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[K?V.floatingBar:V.dockedBar,$?V.barInline:null,tt,{backgroundColor:De,borderColor:at,borderRadius:Ye,..._corners.smoothCorners},K?{borderWidth:it,paddingHorizontal:Ue,paddingVertical:qe}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:qe,paddingBottom:$e}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>_reactNative.StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:e.space.xs},floatingBar:{paddingVertical:e.space.sm,paddingHorizontal:e.space.sm},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.space.xs},accessoryInline:{flexShrink:0,marginRight:e.space.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:e.space.xs,gap:e.space.xs},tabTile:{paddingVertical:e.space.sm,gap:e.space.xxs},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerPressable:{alignItems:"center",maxWidth:"100%",gap:e.space.xs},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.text.xs.size,lineHeight:e.text.xs.size*e.leading.heading,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.text.sm.size,lineHeight:e.text.sm.size*e.leading.heading,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.space.xs},expandFill:{position:"absolute",top:0,right:0,bottom:0,left:0,overflow:"hidden"},pill:{position:"absolute",left:0},bubble:{position:"absolute",left:0,borderWidth:3},underline:{position:"absolute",left:0,height:3},underlineBottom:{borderTopLeftRadius:e.radius.none,borderTopRightRadius:e.radius.none,..._corners.smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,..._corners.smoothCorners},badgePillPosition:{position:"absolute",top:-4,right:-8},badgePill:{minWidth:18,height:18,paddingHorizontal:e.space.xs,paddingVertical:e.space.xxs,borderWidth:1.5},badgeDotPosition:{position:"absolute",top:-2,right:-2},badgeDot:{width:10,height:10,borderRadius:e.radius.pill,borderWidth:1.5},badgeText:{lineHeight:13}});var _default=exports.default=BottomNavigation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:i,onAfterClose:s,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:w,actions:j,actionsLayout:C="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:I,testID:A}=e;(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const B=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),L=null!=w||null!=d,P=null!=j&&j.length>0,V=null!=M||P,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[ie,se,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(L?ne:0)+ie+(V?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[we,je]=(0,_react.useState)(!1),[Ce,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(s);Ee.current=s;const[Te,ke]=(0,_react.useState)(!1),Ie=(0,_react.useRef)(!R&&a),Ae=(0,_react.useRef)(-1),Be=(0,_react.useRef)(!1);Be.current="modal"===D?Ce:Te;const Le=(0,_react.useRef)(u);Le.current=u;const Pe=(0,_react.useRef)(r);Pe.current=r;const Ve=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Ae.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(je(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!Ce:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,Ce,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,i?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[i,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),je(!0)):ke(!0),a<0&&Ie.current?(be.value=r,ye.value=1,Fe(t),void i?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void i?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,i,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Ae.current<0)return void(Be.current?He.current.push(e):e(!0));He.current.push(e),Ie.current=!1;const t=xe.value;Fe(-1),ge.current=!0,i?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,i,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Le.current;if(!r)return void e();if(Ve.current)return void t?.();const n=r();"boolean"!=typeof n?(Ve.current=!0,a?.(),n.then(a=>{Ve.current=!1,a&&De.current&&Ae.current>=0?e():t?.()},e=>{throw Ve.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Ae.current<0?e(!0):Ke(()=>{Pe.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Pe.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ie.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Ae.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(A?`${A}-content-gesture`:"bottom-sheet-content-gesture"),[A]),it=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(A?`${A}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value;if(a.velocityY>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,e[0]);let o=0,i=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const a=Math.abs(n-e[t]);a<i&&(i=a,o=t)}const s=e[0];r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(o,e[o])})},[fe,pe,c,nt,tt,at,A,be]),{height:st}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?st.value:0,[ct,st]),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,lt,F,ut,dt,be,Z,ye,tt]),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[lt,K,F,ut,dt,be,Z,tt,Se]),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(A?`${A}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,A]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!Ce)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:A,accessibilityViewIsModal:I??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:B.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:I??mt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:it,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:A?`${A}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,w]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:se,children:T}):T}),V&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[P?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:we,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:j,actions:C,actionsLayout:w="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=j||null!=d,L=null!=C&&C.length>0,P=null!=M||L,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(P?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[je,Ce]=(0,_react.useState)(!1),[we,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[Te,ke]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===D?we:Te;const Ie=(0,_react.useRef)(u);Ie.current=u;const Le=(0,_react.useRef)(r);Le.current=r;const Pe=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(Ce(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!we:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,we,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),Ce(!0)):ke(!0),a<0&&Ae.current?(be.value=r,ye.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,s,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=xe.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,s,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Pe.current)return void t?.();const n=r();"boolean"!=typeof n?(Pe.current=!0,a?.(),n.then(a=>{Pe.current=!1,a&&De.current&&Be.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{Le.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Le.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(B?`${B}-content-gesture`:"bottom-sheet-content-gesture"),[B]),st=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value;if(a.velocityY>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,e[0]);let o=0,s=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const a=Math.abs(n-e[t]);a<s&&(s=a,o=t)}const i=e[0];r&&n-i>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(o,e[o])})},[fe,pe,c,nt,tt,at,B,be]),{height:it}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?it.value:0,[ct,it]),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,lt,F,ut,dt,be,Z,ye,tt]),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[lt,K,F,ut,dt,be,Z,tt,Se]),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,B]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!we)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:A??mt,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:st,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,j]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:T}):T}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[L?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:C??[],layout:w})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:je,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_BUTTON_LABELS=exports.Button=void 0,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BUTTON_LABELS=exports.DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"}),Button=exports.Button=(0,_react.forwardRef)((e,t)=>{const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:a=!1,fullWidth:l=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:p,style:h,containerStyle:x,textStyle:m,pressAnimation:f,onPress:v,accessibilityLabel:y,accessibilityHint:S,accessibilityState:j,testID:I,onLayout:C,labels:L,...k}=e;(0,_warnInvalidValue.warnInvalidValue)("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),(0,_warnInvalidValue.warnInvalidValue)("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Button","size",e.size,["xs","sm","md","lg","xl"]);const w=(0,_index.useTheme)(),T=w.settings.components.button,F=o??T?.defaultVariant??"solid",R=i??T?.defaultSize??"md",N=(0,_react.useMemo)(()=>({...DEFAULT_BUTTON_LABELS,...L}),[L]),A=!a&&!n,V={...j,disabled:!A,busy:n},q="link"===F,O=f??T?.defaultPressAnimation??(!q&&"scale"),B=(0,_usePressAnimation.usePressAnimation)({preset:O||"scale",enabled:!1!==O&&A}),E=(0,_useFlickGuard.useFlickGuard)(),P=(0,_react.useMemo)(()=>buildStyles(w),[w]),z=(0,_react.useMemo)(()=>(0,_index.resolveButtonSize)(w,R),[w,R]),W=(0,_react.useMemo)(()=>toneFor(w,s),[w,s]),D=(0,_react.useMemo)(()=>variantFor(w,F,W,a),[w,F,W,a]),H=(0,_react.useMemo)(()=>!p||a||"solid"!==F?null:"string"==typeof p?w.settings.gradients[p]??null:p,[p,a,F,w.settings.gradients]),U=_reactNative.StyleSheet.flatten(h)?.borderRadius,M=q?0:"number"==typeof U?U:_?w.radius.pill:z.radius,G=(0,_SquircleFill.useSquircle)(!H&&"link"!==F,M,C),K=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[X,Y]=(0,_react.useState)(0),[J,Q]=(0,_react.useState)(null),Z=q?e=>Y(e.nativeEvent.layout.width):void 0,$=y??r,ee="outline"===F||"ghost"===F,te=!ee&&!q,re={color:D.textColor,size:z.icon,disabled:a},oe=b&&!q&&Boolean(c),se=w.space.xs,ie=z["min-height"]-2*se-2*D.borderWidth,ne={color:D.badgeInk,size:z["badge-icon"],disabled:a},ae=n?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:"sm",color:oe?D.badgeInk:D.textColor,accessibilityLabel:N.loading}):c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(c,oe?ne:re,u)}):null,le=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:P.contentRow,children:[oe?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[P.iconLeft,P.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:D.badgeFill}],children:ae}):ae?(0,_jsxRuntime.jsx)(_reactNative.View,{style:P.iconLeft,children:ae}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:Z,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[P.label,{color:D.textColor,fontSize:z.text,lineHeight:Math.round(z.text*w.leading.body)},m],children:r}),q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[P.linkUnderline,{backgroundColor:D.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:P.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(d,re,u)}):null]}),ce=q?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(z["min-height"]),de={top:ce,bottom:ce,left:q?LINK_HIT_SLOP:0,right:q?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[B.style,l?P.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!A||E.isFlick(e))return;B.press();const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),v?.(e)},onPressIn:e=>{E.onPressIn(e),B.pressIn(),q&&A&&(K.stopAnimation(),K.setValue(0),_reactNative.Animated.timing(K,{toValue:1,duration:w.motion.duration.slower,easing:_reactNative.Easing.bezier(...w.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{B.pressOut()},disabled:!A,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:S,accessibilityState:V,...(0,_ariaState.ariaFromState)(V),testID:I,onLayout:e=>{G.onLayout(e),q&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[P.base,{paddingHorizontal:q?0:z["padding-x"],paddingVertical:q?0:oe?se:z["padding-y"],paddingLeft:oe?se:void 0,minHeight:q?void 0:z["min-height"],borderRadius:M,..._corners.smoothCorners,backgroundColor:H||G.active?"transparent":D.backgroundColor,borderWidth:D.borderWidth,borderColor:G.active?"transparent":D.borderColor,opacity:n?.55:1,overflow:G.active||q?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:w.colors["surface-pressed"]}:null,l?P.fullWidth:null,h],...k,"aria-disabled":!A,"aria-busy":n,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:e&&ee?w.colors["surface-pressed"]:D.backgroundColor,stroke:D.borderColor,strokeWidth:D.borderWidth}):null,H?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:H,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:M,..._corners.smoothCorners}]}):null,e&&te?G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:D.pressedTint,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[P.pressedOverlay,{borderRadius:M,backgroundColor:D.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,le]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},a=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...a};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_BUTTON_LABELS=exports.Button=void 0,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BUTTON_LABELS=exports.DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"}),Button=exports.Button=(0,_react.forwardRef)((e,t)=>{const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:a=!1,fullWidth:l=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:p,style:h,containerStyle:x,textStyle:m,pressAnimation:f,onPress:y,accessibilityLabel:v,accessibilityHint:S,accessibilityState:j,testID:C,onLayout:I,labels:L,...k}=e;(0,_assertValidValue.assertValidValue)("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),(0,_assertValidValue.assertValidValue)("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Button","size",e.size,["xs","sm","md","lg","xl"]);const T=(0,_index.useTheme)(),F=T.settings.components.button,R=o??F?.defaultVariant??"solid",V=i??F?.defaultSize??"md",w=(0,_react.useMemo)(()=>({...DEFAULT_BUTTON_LABELS,...L}),[L]),N=!a&&!n,A={...j,disabled:!N,busy:n},q="link"===R,O=f??F?.defaultPressAnimation??(!q&&"scale"),B=(0,_usePressAnimation.usePressAnimation)({preset:O||"scale",enabled:!1!==O&&N}),E=(0,_useFlickGuard.useFlickGuard)(),P=(0,_react.useMemo)(()=>buildStyles(T),[T]),z=(0,_react.useMemo)(()=>(0,_index.resolveButtonSize)(T,V),[T,V]),W=(0,_react.useMemo)(()=>toneFor(T,s),[T,s]),D=(0,_react.useMemo)(()=>variantFor(T,R,W,a),[T,R,W,a]),H=(0,_react.useMemo)(()=>!p||a||"solid"!==R?null:"string"==typeof p?T.settings.gradients[p]??null:p,[p,a,R,T.settings.gradients]),U=_reactNative.StyleSheet.flatten(h)?.borderRadius,M=q?0:"number"==typeof U?U:_?T.radius.pill:z.radius,G=(0,_SquircleFill.useSquircle)(!H&&"link"!==R,M,I),K=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[X,Y]=(0,_react.useState)(0),[J,Q]=(0,_react.useState)(null),Z=q?e=>Y(e.nativeEvent.layout.width):void 0,$=v??r,ee="outline"===R||"ghost"===R,te=!ee&&!q,re={color:D.textColor,size:z.icon,disabled:a},oe=b&&!q&&Boolean(c),se=T.space.xs,ie=z["min-height"]-2*se-2*D.borderWidth,ne={color:D.badgeInk,size:z["badge-icon"],disabled:a},ae=n?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:"sm",color:oe?D.badgeInk:D.textColor,accessibilityLabel:w.loading}):c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(c,oe?ne:re,u)}):null,le=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:P.contentRow,children:[oe?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[P.iconLeft,P.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:D.badgeFill}],children:ae}):ae?(0,_jsxRuntime.jsx)(_reactNative.View,{style:P.iconLeft,children:ae}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:Z,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[P.label,{color:D.textColor,fontSize:z.text,lineHeight:Math.round(z.text*T.leading.body)},m],children:r}),q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[P.linkUnderline,{backgroundColor:D.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:P.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(d,re,u)}):null]}),ce=q?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(z["min-height"]),de={top:ce,bottom:ce,left:q?LINK_HIT_SLOP:0,right:q?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[B.style,l?P.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!N||E.isFlick(e))return;B.press();const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)},onPressIn:e=>{E.onPressIn(e),B.pressIn(),q&&N&&(K.stopAnimation(),K.setValue(0),_reactNative.Animated.timing(K,{toValue:1,duration:T.motion.duration.slower,easing:_reactNative.Easing.bezier(...T.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{B.pressOut()},disabled:!N,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:S,accessibilityState:A,...(0,_ariaState.ariaFromState)(A),testID:C,onLayout:e=>{G.onLayout(e),q&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[P.base,{paddingHorizontal:q?0:z["padding-x"],paddingVertical:q?0:oe?se:z["padding-y"],paddingLeft:oe?se:void 0,minHeight:q?void 0:z["min-height"],borderRadius:M,..._corners.smoothCorners,backgroundColor:H||G.active?"transparent":D.backgroundColor,borderWidth:D.borderWidth,borderColor:G.active?"transparent":D.borderColor,opacity:n?.55:1,overflow:G.active||q?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:T.colors["surface-pressed"]}:null,l?P.fullWidth:null,h],...k,"aria-disabled":!N,"aria-busy":n,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:e&&ee?T.colors["surface-pressed"]:D.backgroundColor,stroke:D.borderColor,strokeWidth:D.borderWidth}):null,H?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:H,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:M,..._corners.smoothCorners}]}):null,e&&te?G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:D.pressedTint,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[P.pressedOverlay,{borderRadius:M,backgroundColor:D.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,le]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},a=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...a};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CALENDAR_LABELS=exports.Calendar=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CALENDAR_LABELS=exports.Calendar=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_index4=require("../Text/index.js"),_CalendarDay=require("./CalendarDay.js"),_calendarDates=require("./calendarDates.js"),_calendarStyles=require("./calendarStyles.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALENDAR_LABELS=exports.DEFAULT_CALENDAR_LABELS=Object.freeze({previousMonth:"Previous month",nextMonth:"Next month",marked:"Marked"}),MAX_DOTS=3,DAY_TEXT_MAX_SCALE=1.5,toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"primary":return e.colors.primary;default:return e.colors["text-muted"]}},Calendar=exports.Calendar=(0,_react.forwardRef)((e,t)=>{const{selectionMode:a="single",value:r,onChange:i,month:s,onMonthChange:n,minDate:l,maxDate:o,disabledDates:c,weekStartsOn:d=0,locale:u="en-IN",marks:_,cellSize:m,haptic:x,accessibilityLabel:h,onTitlePress:y,labels:v,style:p,headerLabelStyle:g,navButtonStyle:b,testID:D}=e;(0,_assertValidValue.assertValidValue)("Calendar","selectionMode",e.selectionMode,["single","range"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_CALENDAR_LABELS,...v}),[v]),M=f.marked,j=(0,_index2.useTheme)(),S=(0,_index.usePresenceMotion)(),N=(0,_react.useMemo)(()=>(0,_calendarStyles.buildCalendarStyles)(j),[j]),[L,A]=(0,_index.useControllableState)({value:s?(0,_calendarDates.startOfMonth)(s):void 0,defaultValue:(0,_calendarDates.startOfMonth)(r?.start??new Date),onChange:n}),R=12*L.getFullYear()+L.getMonth(),T=r?.start?(0,_calendarDates.startOfDay)(r.start):null,C="range"===a&&r?.end?(0,_calendarDates.startOfDay)(r.end):null,w=T?.getTime()??null,E=C?.getTime()??null,k=(0,_calendarDates.toIso)(new Date),V=l?(0,_calendarDates.startOfDay)(l).getTime():null,I=o?(0,_calendarDates.startOfDay)(o).getTime():null,q=(0,_react.useMemo)(()=>new Set((c??[]).map(e=>(0,_calendarDates.toIso)(e))),[c]),F=(0,_react.useCallback)(e=>null!==V&&e.getTime()<V||null!==I&&e.getTime()>I||q.has((0,_calendarDates.toIso)(e)),[V,I,q]),O=(0,_react.useMemo)(()=>{const e=new Map;for(const t of _??[]){const a=t.date;let r=e.get(a);r||(r={dots:[],spoken:[]},e.set(a,r)),r.dots.length<3&&r.dots.push({key:`${t.tone}-${r.dots.length}`,color:toneColor(j,t.tone)}),r.spoken.push(t.label??M)}return e},[_,j,M]),P=(0,_react.useMemo)(()=>(0,_calendarDates.buildMonthMatrix)(new Date(Math.floor(R/12),R%12,1),d),[R,d]),B=(0,_react.useMemo)(()=>(0,_calendarDates.weekdayLabels)(u,d),[u,d]),z=(0,_react.useMemo)(()=>new Intl.DateTimeFormat(u,{month:"long",year:"numeric"}),[u]),$=(0,_react.useMemo)(()=>new Intl.DateTimeFormat(u,{weekday:"short",day:"numeric",month:"long"}),[u]),H=z.format(L),U=null===V||(0,_calendarDates.startOfMonth)(new Date(V)).getTime()<L.getTime(),X=null===I||(0,_calendarDates.startOfMonth)(new Date(I)).getTime()>L.getTime(),Z=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,Y=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,G=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>G.current?.stop(),[]);const W=(0,_react.useCallback)(e=>{!1!==x&&(0,_index3.triggerHaptic)("impactLight");const t=j.motion.duration.fast,a=j.motion.duration.fast,[r]=S.range(32*-e,0),[i]=S.range(32*e,0),s=S.reduced?S.duration("fast"):t,n=S.reduced?S.duration("fast"):a;G.current?.stop(),G.current=_reactNative.Animated.sequence([_reactNative.Animated.parallel([_reactNative.Animated.timing(Z,{toValue:r,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.quad),useNativeDriver:!0}),_reactNative.Animated.timing(Y,{toValue:0,duration:s,useNativeDriver:!0})]),_reactNative.Animated.timing(Z,{toValue:i,duration:0,useNativeDriver:!0}),_reactNative.Animated.parallel([_reactNative.Animated.timing(Z,{toValue:0,duration:a,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0}),_reactNative.Animated.timing(Y,{toValue:1,duration:n,useNativeDriver:!0})])]),G.current.start();const l=(0,_calendarDates.addMonths)(L,e);A(l),_reactNative.AccessibilityInfo.announceForAccessibility(z.format(l))},[x,L,Y,z,Z,S,A,j]),J=(0,_react.useCallback)(()=>W(-1),[W]),K=(0,_react.useCallback)(()=>W(1),[W]),pressDay=e=>{if(F(e.date))return;const t=(0,_index3.resolveHaptic)(x,"selection");t&&(0,_index3.triggerHaptic)(t);const r=e.date;"single"===a||!T||C||r.getTime()<T.getTime()?i({start:r}):i({start:T,end:r}),e.inMonth||A((0,_calendarDates.startOfMonth)(r))},Q=(0,_react.useRef)(pressDay);(0,_react.useLayoutEffect)(()=>{Q.current=pressDay});const ee=(0,_react.useCallback)(e=>Q.current(e),[]),te=void 0===m?void 0:Math.max(m,_calendarStyles.MIN_CELL_SIZE),ae=(0,_react.useMemo)(()=>void 0===te?{flex:1}:{width:te},[te]),re=(0,_react.useMemo)(()=>void 0===te?{flex:1,aspectRatio:1,minHeight:_calendarStyles.MIN_CELL_SIZE}:{width:te,height:te},[te]),ie=Math.max(j.space.sm,(_calendarStyles.MIN_CELL_SIZE-_calendarStyles.NAV_BUTTON_SIZE)/2),se=Math.min(j.settings.maxFontSizeMultiplier??1.5,1.5),ne=[];for(let e=0;e<_calendarDates.GRID_CELLS;e+=7)ne.push(P.slice(e,e+7));const le=(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",accessibilityLabel:h?`${h}, ${H}`:void 0,style:N.headerLabel,children:H});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[N.root,p],testID:D,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:N.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:J,disabled:!U,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,!U&&N.navBtnDisabled,b],accessibilityRole:"button",accessibilityLabel:f.previousMonth,accessibilityState:{disabled:!U},"aria-disabled":!U,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",style:N.navText,maxFontSizeMultiplier:se,children:"‹"})}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[N.headerLabelWrap,{opacity:Y,transform:[{translateX:Z}]},g],children:y?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:y,accessibilityRole:"button",accessibilityLabel:h?`${h}, ${H}`:H,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:le}):le}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:K,disabled:!X,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,!X&&N.navBtnDisabled,b],accessibilityRole:"button",accessibilityLabel:f.nextMonth,accessibilityState:{disabled:!X},"aria-disabled":!X,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",style:N.navText,maxFontSizeMultiplier:se,children:"›"})})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:N.weekdayRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:B.map(({weekday:e,label:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.weekdayCell,ae],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",style:N.weekdayText,maxFontSizeMultiplier:se,children:t})},e))}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{opacity:Y,transform:[{translateX:Z}]},children:ne.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:N.gridRow,children:e.map(e=>{const t=e.date.getTime(),r=null!==w&&t===w,i=null!==E&&t===E,s=null!==w&&null!==E&&t>=w&&t<=E,n=s&&!r&&!i,l=e.iso===k,o=O.get(e.iso),c=[$.format(e.date),...o?.spoken??[]];return l&&c.push("today"),"range"===a&&(r&&i?c.push("start and end of your range"):r?c.push("start of your range"):i?c.push("end of your range"):n&&c.push("in your range")),(0,_jsxRuntime.jsx)(_CalendarDay.CalendarDay,{cell:e,accessibilityLabel:c.join(", "),disabled:F(e.date),edge:r||i,mid:n,barLeft:s&&(i||n)&&!(r&&i),barRight:s&&(r||n)&&!(r&&i),today:l,dots:o?.dots,cellStyle:re,styles:N,maxFontSizeMultiplier:se,onPressDay:ee},e.iso)})},e[0].iso))})]})});Calendar.displayName="Calendar";var _default=exports.default=Calendar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,a=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=a&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?a(r,s,i):r[s]=e[s]);return r}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=exports.Card=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s,elevation:a="card",radius:r,padding:n,interactive:l=!1,pressAnimation:o="scale",bg:d,header:c,title:u,titleFont:h,lead:m,action:_,headerActions:x,collapsible:p=!1,collapsed:b,defaultCollapsed:g=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:v,separatorHeight:R=_reactNative.StyleSheet.hairlineWidth,footer:f,imageSource:S,imageHeight:w=160,imageAspectRatio:C,imageOverlay:A,loading:q=!1,gradient:F,onPress:N,haptic:I,contextMenu:V,accessibilityLabel:L,accessibilityHint:k,accessibilityRole:T,style:B,containerStyle:P,headerStyle:D,bodyStyle:H,footerStyle:M,testID:z,labels:E,onLayout:O,...W}=e;(0,_warnInvalidValue.warnInvalidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_warnInvalidValue.warnInvalidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_warnInvalidValue.warnInvalidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_warnInvalidValue.warnInvalidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=(0,_index.useTheme)(),G=U.settings.components.card,K=s??G?.defaultVariant??"elevated",$=r??G?.defaultRadius??"lg",J=n??G?.defaultPadding??"md",Q=h??G?.defaultTitleFont??"sans",X=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...E}),[E]),Y=l||"function"==typeof N,Z=(0,_useContextMenu.useContextMenu)(V,{haptic:I||!1,testID:z,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),ee=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:ae}=(0,_usePressAnimation.usePressAnimation)({preset:o||"scale",enabled:te&&!1!==o}),re=stylesFor(U),ne=Boolean(S),le=U.space[paddingMap[J]],oe=(0,_react.useMemo)(()=>F?"string"==typeof F?U.settings.gradients[F]??null:F:null,[F,U.settings.gradients]),de="flat"===K,ce=de?U.radius.none:U.radius[$],ue=resolveBackground(U,d),[he,me]=(0,_useControllableState.useControllableState)({value:b,defaultValue:g,onChange:j}),xe=p&&he,pe=hasBuiltInHeaderContent(e),be=Boolean(c)||pe,ge=(0,_SquircleFill.useSquircle)(!ne&&!oe&&!de,ce,O),je=_reactNative.StyleSheet.flatten([P,B])??{},ye=je.backgroundColor,ve=je.borderColor,Re=ye??ue??("filled"===K?U.colors["bg-subtle"]:U.colors.surface),fe="outline"===K?U.size.border:0,Se=ve??U.colors.border,we="none"===a?void 0:U.shadow[a],Ce="elevated"===K&&(0,_shadows.supportsBoxShadow)()&&we?(0,_shadows.toBoxShadow)(we):void 0,Ae=ge.active&&"elevated"===K&&!Ce,qe=ge.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=(0,_react.useMemo)(()=>{const e={borderRadius:Ae&&ge.size?(0,_squircle.squircleHostRadius)(ge.size.width,ge.size.height,ce):ce,..._corners.smoothCorners,padding:ne||ge.active?U.space.none:le,overflow:ge.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:R,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:ge.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:ge.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:ge.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...Ce?{boxShadow:Ce}:we}}},[U,K,we,ce,ne,le,ge.active,ge.size,Ce,Ae,ue,R]),Ne=(0,_react.useMemo)(()=>({..."number"==typeof C?{width:"100%",aspectRatio:C}:{width:"100%",height:w},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ce,C,w]),Ie=u??"",Ve=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,Q),children:u}):null,m?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:re.lead,children:m}):null,xe&&y?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:re.lead,children:y}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:I}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:re.actionNode,children:_}):null,x,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:xe?"chevron-down":"chevron-up",label:`${xe?X.show:X.hide} ${Ie}`.trim(),expanded:!xe,onPress:()=>me(!xe),haptic:I}):null,v?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:U.colors["danger-text"],haptic:I}):null]}),Le=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.header,!c&&re.headerRow,xe&&re.headerFolded,D],children:c??Ve}):null,xe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[be||f?re.body:null,H],children:i}),f&&!xe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.footer,M],children:f}):null]}),ke=ne?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Ne,accessibilityLabel:"",accessible:!1}),A?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:le},children:Le})]}):Le,Te=oe?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:oe,style:_reactNative.StyleSheet.absoluteFill}),ke]}):ge.active&&ge.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ge.size.width,height:ge.size.height,radius:ce,fill:Re,stroke:fe?Se:void 0,strokeWidth:fe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.squircleClip,{padding:le,borderRadius:ge.size?(0,_squircle.squircleHostRadius)(ge.size.width,ge.size.height,ce):ce}],children:ke})]}):ke;let Be;if(te){const handlePress=e=>{Y&&(I&&(0,_hapticUtils.triggerHaptic)(I),N?.(e))};Be=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ie,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:ae,accessibilityRole:T??(Y?"button":void 0),accessibilityLabel:L,accessibilityHint:k,testID:z,onLayout:ge.onLayout,style:[Fe,P,B,qe],...W,...Z.hostProps,children:Te})})}else Be=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:L,accessibilityHint:k,accessibilityRole:T,testID:z,onLayout:ge.onLayout,style:[Fe,P,B,qe],...W,children:Te});return q?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):Z.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Be,Z.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[Fe,P,B,qe,re.preview],children:Te}))]}):Be}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:a,header:r,footer:n,imageSource:l,imageHeight:o=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:h,footerStyle:m,style:_,labels:x,...p})=>{const b=(0,_index.useTheme)(),g=b.settings.components.card,j=e??g?.defaultVariant??"elevated",y=i??g?.defaultRadius??"lg",v=s??g?.defaultPadding??"md",R={...DEFAULT_CARD_LABELS,...x},f=paddingMap[v],S=b.space[f],w="flat"===j?b.radius.none:b.radius[y],C=void 0!==r||hasBuiltInHeaderContent(p),A=resolveBackground(b,a)??b.colors.surface,q="outline"===j?1:0,F="outline"===j?b.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:A,borderRadius:w,..._corners.smoothCorners,borderWidth:q,borderColor:F,overflow:"hidden"},c,_],accessibilityRole:"progressbar",accessibilityLabel:R.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:o,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,C?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingBottom:b.space.sm},u],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S},h],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:b.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingTop:b.space.sm,flexDirection:"row"},m],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:a,haptic:r})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:a??n.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,a=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=a&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?a(r,s,i):r[s]=e[s]);return r}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=exports.Card=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s,elevation:a="card",radius:r,padding:n,interactive:l=!1,pressAnimation:o="scale",bg:d,header:c,title:u,titleFont:h,lead:m,action:_,headerActions:x,collapsible:p=!1,collapsed:b,defaultCollapsed:g=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:v,separatorHeight:R=_reactNative.StyleSheet.hairlineWidth,footer:f,imageSource:S,imageHeight:C=160,imageAspectRatio:w,imageOverlay:A,loading:V=!1,gradient:q,onPress:F,haptic:N,contextMenu:L,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,style:P,containerStyle:I,headerStyle:D,bodyStyle:H,footerStyle:M,testID:z,labels:E,onLayout:O,...W}=e;(0,_assertValidValue.assertValidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_assertValidValue.assertValidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_assertValidValue.assertValidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_assertValidValue.assertValidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=(0,_index.useTheme)(),G=U.settings.components.card,K=s??G?.defaultVariant??"elevated",$=r??G?.defaultRadius??"lg",J=n??G?.defaultPadding??"md",Q=h??G?.defaultTitleFont??"sans",X=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...E}),[E]),Y=l||"function"==typeof F,Z=(0,_useContextMenu.useContextMenu)(L,{haptic:N||!1,testID:z,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),ee=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:ae}=(0,_usePressAnimation.usePressAnimation)({preset:o||"scale",enabled:te&&!1!==o}),re=stylesFor(U),ne=Boolean(S),le=U.space[paddingMap[J]],oe=(0,_react.useMemo)(()=>q?"string"==typeof q?U.settings.gradients[q]??null:q:null,[q,U.settings.gradients]),de="flat"===K,ce=de?U.radius.none:U.radius[$],ue=resolveBackground(U,d),[he,me]=(0,_useControllableState.useControllableState)({value:b,defaultValue:g,onChange:j}),xe=p&&he,pe=hasBuiltInHeaderContent(e),be=Boolean(c)||pe,ge=(0,_SquircleFill.useSquircle)(!ne&&!oe&&!de,ce,O),je=_reactNative.StyleSheet.flatten([I,P])??{},ye=je.backgroundColor,ve=je.borderColor,Re=ye??ue??("filled"===K?U.colors["bg-subtle"]:U.colors.surface),fe="outline"===K?U.size.border:0,Se=ve??U.colors.border,Ce="none"===a?void 0:U.shadow[a],we="elevated"===K&&(0,_shadows.supportsBoxShadow)()&&Ce?(0,_shadows.toBoxShadow)(Ce):void 0,Ae=ge.active&&"elevated"===K&&!we,Ve=ge.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,qe=(0,_react.useMemo)(()=>{const e={borderRadius:Ae&&ge.size?(0,_squircle.squircleHostRadius)(ge.size.width,ge.size.height,ce):ce,..._corners.smoothCorners,padding:ne||ge.active?U.space.none:le,overflow:ge.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:R,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:ge.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:ge.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:ge.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...we?{boxShadow:we}:Ce}}},[U,K,Ce,ce,ne,le,ge.active,ge.size,we,Ae,ue,R]),Fe=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:C},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ce,w,C]),Ne=u??"",Le=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,Q),children:u}):null,m?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:re.lead,children:m}):null,xe&&y?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:re.lead,children:y}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:N}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:re.actionNode,children:_}):null,x,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:xe?"chevron-down":"chevron-up",label:`${xe?X.show:X.hide} ${Ne}`.trim(),expanded:!xe,onPress:()=>me(!xe),haptic:N}):null,v?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:U.colors["danger-text"],haptic:N}):null]}),ke=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.header,!c&&re.headerRow,xe&&re.headerFolded,D],children:c??Le}):null,xe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[be||f?re.body:null,H],children:i}),f&&!xe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.footer,M],children:f}):null]}),Te=ne?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Fe,accessibilityLabel:"",accessible:!1}),A?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:le},children:ke})]}):ke,Be=oe?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:oe,style:_reactNative.StyleSheet.absoluteFill}),Te]}):ge.active&&ge.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ge.size.width,height:ge.size.height,radius:ce,fill:Re,stroke:fe?Se:void 0,strokeWidth:fe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.squircleClip,{padding:le,borderRadius:ge.size?(0,_squircle.squircleHostRadius)(ge.size.width,ge.size.height,ce):ce}],children:Te})]}):Te;let Pe;if(te){const handlePress=e=>{Y&&(N&&(0,_hapticUtils.triggerHaptic)(N),F?.(e))};Pe=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ie,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:ae,accessibilityRole:B??(Y?"button":void 0),accessibilityLabel:k,accessibilityHint:T,testID:z,onLayout:ge.onLayout,style:[qe,I,P,Ve],...W,...Z.hostProps,children:Be})})}else Pe=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,testID:z,onLayout:ge.onLayout,style:[qe,I,P,Ve],...W,children:Be});return V?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):Z.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Pe,Z.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[qe,I,P,Ve,re.preview],children:Be}))]}):Pe}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:a,header:r,footer:n,imageSource:l,imageHeight:o=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:h,footerStyle:m,style:_,labels:x,...p})=>{const b=(0,_index.useTheme)(),g=b.settings.components.card,j=e??g?.defaultVariant??"elevated",y=i??g?.defaultRadius??"lg",v=s??g?.defaultPadding??"md",R={...DEFAULT_CARD_LABELS,...x},f=paddingMap[v],S=b.space[f],C="flat"===j?b.radius.none:b.radius[y],w=void 0!==r||hasBuiltInHeaderContent(p),A=resolveBackground(b,a)??b.colors.surface,V="outline"===j?1:0,q="outline"===j?b.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:A,borderRadius:C,..._corners.smoothCorners,borderWidth:V,borderColor:q,overflow:"hidden"},c,_],accessibilityRole:"progressbar",accessibilityLabel:R.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:o,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,w?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingBottom:b.space.sm},u],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S},h],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:b.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingTop:b.space.sm,flexDirection:"row"},m],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:a,haptic:r})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:a??n.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CAROUSEL_LABELS=exports.Carousel=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CAROUSEL_LABELS=exports.Carousel=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CAROUSEL_LABELS=exports.DEFAULT_CAROUSEL_LABELS=Object.freeze({carousel:"Carousel",slideOf:(e,t)=>`Slide ${e} of ${t}`,goToSlide:e=>`Go to slide ${e}`}),CarouselInner=(0,_react.forwardRef)((e,t)=>{const{data:n,renderItem:r,keyExtractor:a,index:i,defaultIndex:s=0,onIndexChange:l,onScrollOffsetChange:c,autoPlay:o=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:x="screen",spacing:_=0,containerStyle:g,accessibilityLabel:b,testID:p,showThumbnails:y=!1,haptic:S,renderThumbnail:f,loading:v=!1,labels:j}=e;(0,_assertValidValue.assertValidValue)("Carousel","paginationStyle",e.paginationStyle,["dots","bars","numbers"]);const R=(0,_react.useMemo)(()=>({...DEFAULT_CAROUSEL_LABELS,...j}),[j]),C=(0,_index.useTheme)(),w="number"==typeof i,T=d||o,[E,I]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),A="screen"===x?E:x,N=A+_,k=(0,_react.useRef)(null),L=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,V=clamp(w?i:s,0,Math.max(0,n.length-1)),[O,D]=(0,_react.useState)(V),M=(0,_react.useRef)(null),P=(0,_react.useRef)(null),H=(0,_react.useRef)(!1),z=(0,_react.useRef)(O);z.current=O;const q=(0,_react.useCallback)(e=>{const t=clamp(e,0,Math.max(0,n.length-1));D(e=>e===t?e:(l?.(t),t))},[n.length,l]),U=(0,_react.useCallback)((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);k.current?.scrollToOffset({offset:r*N,animated:t}),q(r)},[n.length,N,q]),F=(0,_react.useCallback)(()=>{if(0===n.length)return;const e=z.current+1;e>=n.length?T&&U(0,!1):U(e,!0)},[n.length,T,U]),W=(0,_react.useCallback)(()=>{if(0===n.length)return;const e=z.current-1;e<0?T&&U(n.length-1,!1):U(e,!0)},[n.length,T,U]);(0,_react.useImperativeHandle)(t,()=>({scrollTo:U,next:F,prev:W}),[U,F,W]),(0,_react.useEffect)(()=>{w&&i!==O&&U(i,!0)},[i]);const B=(0,_react.useCallback)(()=>{M.current&&(clearInterval(M.current),M.current=null)},[]),$=(0,_react.useCallback)(()=>{!o||n.length<=1||(B(),M.current=setInterval(()=>{if(H.current)return;const e=z.current+1;e>=n.length?U(0,!1):U(e,!0)},u))},[o,u,n.length,U,B]);(0,_react.useEffect)(()=>($(),()=>{B(),P.current&&clearTimeout(P.current)}),[$,B]),(0,_react.useEffect)(()=>{const e=_reactNative.AppState.addEventListener("change",e=>{"active"!==e?(B(),P.current&&(clearTimeout(P.current),P.current=null)):$()});return()=>e.remove()},[$,B]);const G=m&&n.length>1&&"numbers"!==h||void 0!==c,K=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{x:L}}}],{useNativeDriver:!1,listener:c?e=>c(e.nativeEvent.contentOffset.x):void 0}),[L,c]),X=(0,_react.useCallback)(e=>{if(N<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/N);q(n)},[N,q]),J=(0,_react.useCallback)(()=>{H.current=!0,B(),P.current&&(clearTimeout(P.current),P.current=null)},[B]),Q=(0,_react.useCallback)(()=>{H.current=!1,o&&(P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{$()},1e3))},[o,$]),Y=(0,_react.useCallback)(e=>{switch(e.nativeEvent.actionName){case"increment":F();break;case"decrement":W()}},[F,W]),Z=(0,_react.useMemo)(()=>buildStyles(C),[C]),ee=(0,_react.useCallback)(({item:e,index:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:A,marginRight:t===n.length-1?0:_},accessibilityElementsHidden:t!==O,importantForAccessibility:t===O?"yes":"no-hide-descendants",children:r(e,t)}),[r,A,_,n.length,O]),te=(0,_react.useCallback)((e,t)=>String(t),[]),ne=(0,_react.useCallback)((e,t)=>({length:N,offset:N*t,index:t}),[N]);return v?(0,_jsxRuntime.jsx)(CarouselSkeleton,{...e,containerWidth:E}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Z.container,g],onLayout:e=>I(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:b??R.carousel,accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:O,text:R.slideOf(O+1,n.length)},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Y,testID:p,children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:k,data:n,keyExtractor:a??te,renderItem:ee,horizontal:!0,pagingEnabled:"screen"===x&&0===_,snapToInterval:N,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:G?K:void 0,scrollEventThrottle:G?16:void 0,onMomentumScrollEnd:X,onScrollBeginDrag:J,onScrollEndDrag:Q,getItemLayout:ne,initialScrollIndex:V,bounces:!1}),m&&n.length>1?(0,_jsxRuntime.jsx)(Pagination,{count:n.length,currentIndex:O,scrollX:L,slideStride:N,variant:h,theme:C,labels:R}):null,y&&n.length>0?(0,_jsxRuntime.jsx)(ThumbnailStrip,{data:n,currentIndex:O,renderThumbnail:f,labels:R,onSelect:e=>{const t=(0,_index2.resolveHaptic)(S,"selection");t&&(0,_index2.triggerHaptic)(t),U(e,!0)},theme:C}):null]})});CarouselInner.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:a})=>{const i=(0,_index.useTheme)(),s="screen"===e?a||320:e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[carouselSkeletonStyles.container,r],children:[(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:s,height:160,radius:"md"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:i.space.md}],children:SKELETON_PAGINATION_DOTS.map(e=>"numbers"===n?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:24,height:16,radius:"sm",style:{marginHorizontal:i.space.xs}},e):"bars"===n?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:20,height:4,radius:"pill",style:{marginHorizontal:i.space.xxs}},e):(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:8,height:8,style:{marginHorizontal:i.space.xs}},e))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const SKELETON_PAGINATION_DOTS=["first","second","third"],carouselSkeletonStyles=_reactNative.StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=exports.Carousel=CarouselInner;Carousel.Skeleton=CarouselSkeleton;const Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:a,theme:i,labels:s})=>{const l=(0,_react.useMemo)(()=>buildPaginationStyles(i),[i]);if("numbers"===a)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.numbersWrap,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"medium",color:"secondary",style:l.numbersText,accessibilityLabel:s.slideOf(t+1,e),children:`${t+1} / ${e}`})});const c=Array.from({length:e},(e,t)=>t),o="bars"===a,u=o?24:6,d=o?36:16,m=o?3:6;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:c.map(e=>{const a=[(e-1)*r,e*r,(e+1)*r],s=n.interpolate({inputRange:a,outputRange:[u,d,u],extrapolate:"clamp"}),l=n.interpolate({inputRange:a,outputRange:[.5,1,.5],extrapolate:"clamp"});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[{width:s,height:m,marginHorizontal:i.space.xs,borderRadius:i.radius.pill,..._corners.smoothCorners,backgroundColor:e===t?i.colors.primary:i.colors.border,opacity:l}]},e)})})},ThumbnailStrip=({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:a,labels:i})=>{const s=(0,_react.useMemo)(()=>buildThumbStyles(a),[a]);return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:s.row,accessibilityRole:"tablist",children:e.map((e,l)=>(0,_jsxRuntime.jsx)(ThumbnailItem,{item:e,index:l,isActive:l===t,renderThumbnail:n,onPress:()=>r(l),theme:a,styles:s,labels:i},l))})},ThumbnailItem=({item:e,index:t,isActive:n,renderThumbnail:r,onPress:a,theme:i,styles:s,labels:l})=>{const c=(0,_react.useRef)((0,_index.createAnimatedValue)(n?1.1:1)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(c,{toValue:n?1.1:1,useNativeDriver:!0,friction:6,tension:80});return e.start(),()=>e.stop()},[n,c]);const o=(0,_react.useMemo)(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:e.uri},style:s.image,resizeMode:"cover"}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[s.placeholder,{backgroundColor:i.colors["bg-subtle"]}],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",color:"secondary",children:t+1})}),[e,t,r,i,s]);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:a,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:l.goToSlide(t+1),children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[s.thumb,{borderColor:n?i.colors.primary:"transparent",transform:[{scale:c}]}],children:o})})},buildThumbStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.sm,paddingVertical:e.space.sm},thumb:{width:40,height:40,marginHorizontal:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"}}),buildPaginationStyles=e=>_reactNative.StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersText:{textAlign:"center"}});var _default=exports.default=Carousel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Checkbox=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Checkbox=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,i,s=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((t=s&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?s(a,i,t):a[i]=e[i]);return a}const CHECKBOX_SHAPES=["circle"],toneColor=(e,r)=>{switch(r){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},toneOnColor=(e,r)=>{switch(r){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];case"neutral":return e.colors["on-neutral"];default:return e.colors["on-primary"]}},Checkbox=exports.Checkbox=(0,_react.forwardRef)((e,r)=>{const{checked:t,defaultChecked:i,onChange:s,indeterminate:a=!1,disabled:o=!1,label:n,helperText:l,description:c,error:d,help:u,size:h="md",tone:p="primary",shape:x,accessibilityLabel:_,haptic:b,style:f,boxStyle:m,indeterminateBarStyle:g,containerStyle:y,labelStyle:C,testID:j,hitSlop:w,...S}=e,[k,v]=(0,_index.useControllableState)({value:t,defaultValue:i??!1,onChange:s}),V=(0,_index2.useTheme)(),R=(0,_react.useMemo)(()=>buildStyles(V),[V]),{"box-size":T}=(0,_react.useMemo)(()=>(0,_index2.resolveCheckboxSize)(V,h),[V,h]),q=V.size.border,N=(0,_index2.spaceOf)(V,V.components.checkbox["label-gap"]),B=toneColor(V,p),F=w??6;(0,_assertValidValue.assertValidValue)("Checkbox","shape",x,CHECKBOX_SHAPES),(0,_assertValidValue.assertValidValue)("Checkbox","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Checkbox","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const M="circle"===x,O="string"==typeof d?d:void 0,P={description:c,helperText:l,error:O},D=k||a,H=(0,_react.useRef)((0,_index2.createAnimatedValue)(D?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(H,{toValue:D?1:0,damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[D,H,V.motion.spring.snappy]);const W=H.interpolate({inputRange:[0,1],outputRange:[0,1]}),A=_??(0,_FieldBase.fieldTextAsString)(n),I=!0===d||(0,_FieldBase.hasFieldText)(d),L=D?B:o?V.colors.border:I?V.colors["field-border-error"]:V.colors.border,z=D?B:o?V.colors["surface-disabled"]:"transparent",E=o&&!D?V.colors["text-disabled"]:toneOnColor(V,p),U=Math.round(.72*T),K=Math.round(.55*T),X=Math.max(2,Math.round(.12*T)),G=(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:r,onPress:e=>{if(o)return;const r=(0,_hapticUtils.resolveHaptic)(b,"selection");r&&(0,_hapticUtils.triggerHaptic)(r),v(!k),S.onPressOut?.(e)},disabled:o,accessibilityRole:"checkbox",accessibilityLabel:A,accessibilityHint:S.accessibilityHint??(0,_FieldBase.fieldTextAsString)(l??c),accessibilityState:{checked:a?"mixed":k,disabled:o},"aria-checked":a?"mixed":k,"aria-disabled":o,testID:j,hitSlop:F,...(0,_hitSlop.hitSlopMarker)(F),...S,style:({pressed:e})=>[R.row,(0,_ChoiceText.hasChoiceDetail)(P)?R.rowTop:null,(0,_FieldBase.hasFieldText)(u)?R.rowShrink:null,{opacity:o?.55:e?.85:1},y,f],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[R.box,{width:T,height:T,borderWidth:q,borderRadius:M?T/2:V.radius.sm,...M?{}:_corners.smoothCorners,borderColor:L,backgroundColor:z},m],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[R.glyphWrap,{opacity:H,transform:[{scale:W}]}],children:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{width:K,height:X,borderRadius:V.radius.pill,..._corners.smoothCorners,backgroundColor:E},g]}):(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:U,height:U,viewBox:"0 0 24 24",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:E,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:n,helperText:l,description:c,error:O,disabled:o,style:{marginLeft:N},labelStyle:C})]});return(0,_FieldBase.hasFieldText)(u)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[R.helpRow,(0,_ChoiceText.hasChoiceDetail)(P)?R.rowTop:null],children:[G,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[R.help,{marginLeft:V.space.xs}],children:u})]}):G});Checkbox.displayName="Checkbox";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"},rowShrink:{flexShrink:1},helpRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},box:{alignItems:"center",justifyContent:"center"},glyphWrap:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Checkbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CHIP_LABELS=exports.Chip=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CHIP_LABELS=exports.Chip=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CHIP_LABELS=exports.DEFAULT_CHIP_LABELS=Object.freeze({remove:e=>`Remove ${e}`}),toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors["primary-soft"],on:e.colors.primary,ink:e.colors["primary-text"],border:e.colors.primary,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"success":return{base:e.colors["bg-muted"],on:e.colors.success,ink:e.colors["success-text"],border:e.colors.success,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"warning":return{base:e.colors["bg-muted"],on:e.colors.warning,ink:e.colors["warning-text"],border:e.colors.warning,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"danger":return{base:e.colors["bg-muted"],on:e.colors.danger,ink:e.colors["danger-text"],border:e.colors.danger,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"info":return{base:e.colors["bg-muted"],on:e.colors.info,ink:e.colors["info-text"],border:e.colors.info,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};default:return{base:e.colors["bg-muted"],on:e.colors["text-body"],ink:e.colors["text-body"],border:e.colors.border,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary}}},SOFT_FILL_OPACITY=.14,SOFT_SELECTED_FILL_OPACITY=.24,hasChipCount=e=>null!=e&&""!==e,Chip=exports.Chip=(0,_react.forwardRef)((e,t)=>{const{label:s,count:r,selected:i=!1,selectionMode:o="single",onPress:l,onRemove:a,leftIcon:n,iconVariant:c,variant:d="soft",tone:u="neutral",size:p="md",disabled:m=!1,loading:h=!1,accessibilityLabel:x,haptic:b,style:y,textStyle:_,containerStyle:g,countStyle:f,closeButtonStyle:S,closeIconStyle:C,labels:j,removeTestID:v,testID:k}=e;(0,_assertValidValue.assertValidValue)("Chip","variant",e.variant,["solid","soft","outline"]),(0,_assertValidValue.assertValidValue)("Chip","tone",e.tone,["primary","neutral","success","warning","danger","info"]),(0,_assertValidValue.assertValidValue)("Chip","size",e.size,["sm","md"]),(0,_assertValidValue.assertValidValue)("Chip","selectionMode",e.selectionMode,["single","multiple","radio"]);const I=(0,_index.useTheme)(),V=(0,_react.useMemo)(()=>({...DEFAULT_CHIP_LABELS,...j}),[j]),L=!!l&&!m,R="radio"===o,w=!!l&&(!m||R),B=hasChipCount(r),{style:z,pressIn:A,pressOut:O}=(0,_usePressAnimation.usePressAnimation)({enabled:L}),P=(0,_react.useMemo)(()=>toneFor(I,u),[I,u]),M=(0,_react.useMemo)(()=>(0,_index.resolveChipSize)(I,p),[I,p]),T=Math.max(0,Math.ceil((44-M["min-height"])/2)),q=R?{top:T,bottom:T}:void 0,D="solid"===d,E="soft"===d,F=(()=>{if(E){const e=i?P.selectedOn:P.on,t=i?.24:.14;return(0,_color.tintOf)(e,t,i?P.selectedBg:P.base)}return i?D?P.selectedBg:"transparent":D?P.base:"transparent"})(),H=E?"transparent":i?P.selectedBorder:D?"transparent":P.border,N=m?I.colors["text-disabled"]:i?E?I.colors["text-body"]:P.selectedInk:P.ink,U=D||E?0:I.size.border,handlePress=()=>{if(!L)return;const e=(0,_hapticUtils.resolveHaptic)(b,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),l?.()},$=x??(B?`${s}, ${r}`:s),Y=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.row,children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:M.gap},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(n,{color:N,size:M.icon,disabled:m},c)}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"medium",numberOfLines:1,style:[styles.label,{color:N,fontSize:M.text,lineHeight:Math.round(M.text*I.leading.body)},_],children:s??" "}),B?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",numberOfLines:1,style:[styles.count,{color:N,fontSize:Math.min(I.text.xs.size,M.text),marginLeft:I.space.xs},f],children:r}):null,a?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>{m||(!1!==b&&(0,_hapticUtils.triggerHaptic)("impactLight"),a?.())},disabled:m,accessibilityRole:"button",accessibilityLabel:V.remove(s),accessibilityState:{disabled:m},"aria-disabled":m,testID:v,hitSlop:6,...(0,_hitSlop.hitSlopMarker)(6),style:({pressed:e})=>[styles.close,{width:M["close-size"],height:M["close-size"],borderRadius:M["close-size"]/2,..._corners.smoothCorners,marginLeft:M.gap,backgroundColor:e?I.colors["surface-pressed"]:I.colors["surface-hover"]},S],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"bold",maxFontSizeMultiplier:1,style:[{color:N,fontSize:M["close-text"],lineHeight:M["close-text"]+2},C],children:"×"})}):null]}),W={paddingHorizontal:M["padding-x"],paddingVertical:M["padding-y"],minHeight:M["min-height"],borderRadius:I.radius.pill,..._corners.smoothCorners,overflow:"hidden",backgroundColor:F,borderWidth:U,borderColor:H,opacity:m?.55:1};let G;return G=w?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z,{alignSelf:"flex-start",borderRadius:I.radius.pill,..._corners.smoothCorners,overflow:"hidden"}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:handlePress,onPressIn:A,onPressOut:O,disabled:!L,accessibilityRole:R?"radio":"multiple"===o?"checkbox":"button",accessibilityLabel:$,accessibilityState:R||"multiple"===o?{checked:i,disabled:m}:{selected:i,disabled:m},"aria-checked":R||"multiple"===o?i:void 0,"aria-selected":R||"multiple"===o?void 0:i,"aria-disabled":m,hitSlop:q,...q?(0,_hitSlop.hitSlopMarker)(q):{},android_ripple:{color:I.colors["surface-pressed"],borderless:!1},testID:k,style:({pressed:e})=>[styles.base,W,e&&"outline"===d?{backgroundColor:I.colors["surface-pressed"]}:null,g,y],children:Y})}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:[styles.base,W,g,y],accessible:!0,accessibilityRole:"text",accessibilityLabel:$,accessibilityState:{selected:i,disabled:m},"aria-selected":i,"aria-disabled":m,testID:k,children:Y}),h?(0,_jsxRuntime.jsx)(ChipSkeleton,{...e}):G});Chip.displayName="Chip";const ChipSkeleton=({label:e,count:t,size:s="md",leftIcon:r,onRemove:i,style:o,containerStyle:l})=>{const a=(0,_index.useTheme)(),n=(0,_index.resolveChipSize)(a,s),c=Math.max(40,Math.min(120,7*(e??"").length)),d=n["min-height"],u=d/2,p=c+2*n["padding-x"]+(hasChipCount(t)?n.gap/2+7*String(t).length:0)+(void 0!==r?n.gap+14:0)+(void 0!==i?n.gap+n["close-size"]:0);return(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:p,height:d,radius:u,style:[{alignSelf:"flex-start"},l,o]})};ChipSkeleton.displayName="ChipSkeleton",Chip.Skeleton=ChipSkeleton;const styles=_reactNative.StyleSheet.create({base:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",justifyContent:"center"},row:{flexDirection:"row",alignItems:"center"},label:{flexShrink:1,textAlign:"center"},count:{flexShrink:0,fontVariant:["tabular-nums"]},close:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Chip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ChoiceGroup=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ChoiceGroup=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("../Radio/RadioDot.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=exports.ChoiceGroup=(0,_react.forwardRef)((e,i)=>{const{options:t,getOptionLabel:r,getOptionValue:o,isOptionDisabled:a,getOptionDescription:s,getOptionIcon:l,getOptionColor:n,renderOption:d,variant:c="card",indicatorPosition:u="trailing",direction:p="row",gap:x,wrap:h=!1,fullWidth:m,disabled:g=!1,size:b="md",labelLines:_,descriptionLines:j=2,haptic:f,accessibilityLabel:y,style:z,optionStyle:V,description:v,helperText:C,error:R,testID:S}=e,H=(0,_index2.useTheme)(),w=(0,_react.useMemo)(()=>buildStyles(H),[H]),T=(0,_react.useMemo)(()=>sizeTokensOf(H)[b],[H,b]);(0,_assertValidValue.assertValidValue)("ChoiceGroup","variant",e.variant,["card","chip"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","direction",e.direction,["row","column"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const k=(0,_react.useCallback)(e=>r?r(e):e.label??"",[r]),D=(0,_react.useCallback)(e=>o?o(e):e.value,[o]),O=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),G=(0,_react.useCallback)(e=>s?s(e):e.description,[s]),q=(0,_react.useCallback)(e=>l?l(e):e.icon,[l]),L=(0,_react.useCallback)(e=>n?n(e):e.color,[n]),I="multiple"===e.selectionMode,{min:M,max:P}=e,[N,F]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(I?[]:void 0),onChange:e.onChange}),W=Array.isArray(N)?N:[],A=(0,_react.useCallback)(e=>{const i=D(e);if(I){const e=W.includes(i);if(e&&null!=M&&W.length<=M)return;if(!e&&null!=P&&W.length>=P)return;const t=(0,_index3.resolveHaptic)(f,"selection");return t&&(0,_index3.triggerHaptic)(t),void F(e?W.filter(e=>e!==i):[...W,i])}const t=(0,_index3.resolveHaptic)(f,"selection");t&&(0,_index3.triggerHaptic)(t),F(i)},[f,I,M,P,W,F,D]),B=m??("card"===c&&"row"===p&&!h),E=h||B&&"row"===p,$=H.radius.md,surfaceFor=(e,i,t)=>i?{borderColor:H.colors.border,backgroundColor:H.colors["surface-disabled"]}:{borderColor:e?t:H.colors.border,backgroundColor:e?(0,_color.tintOf)(t,.12,H.colors["surface-selected"]):H.colors.bg},renderIcon=(e,i,t,r)=>{const o=q(e);if(null==o)return null;const a="string"==typeof o&&i?{name:o,variant:"bold"}:o;return(0,_slotIcon.renderSlotIcon)(a,{color:t,size:T.iconSize,disabled:r})},renderChip=e=>{const{option:i,selected:t,disabled:r,color:o}=e,a=r?H.colors["text-disabled"]:t?o:H.colors["text-body"],s=renderIcon(i,t,a,r);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.chip,{minHeight:T.minHeight,paddingHorizontal:T.chipPaddingHorizontal,paddingVertical:T.paddingVertical,borderRadius:H.radius.pill,..._corners.smoothCorners,borderWidth:H.size.border,...surfaceFor(t,r,o),columnGap:H.space.xs}],children:[s?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:s}):null,(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:_,ellipsizeMode:"tail",style:[w.cardLabel,{color:a,fontSize:T.fontSize,lineHeight:Math.round(T.fontSize*H.leading.body)}],children:k(i)})]})},renderDefaultCard=e=>{const{option:i,selected:t,disabled:r,color:o}=e,a=L(i),s=r?H.colors["text-disabled"]:a??H.colors["text-body"],l=G(i),n=renderIcon(i,t,s,r),d=(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:t,color:o,disabled:r,size:b});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.card,{minHeight:T.minHeight,paddingHorizontal:T.paddingHorizontal,paddingVertical:T.paddingVertical,borderRadius:$,..._corners.smoothCorners,borderWidth:H.size.border,...surfaceFor(t,r,o),columnGap:H.space.sm}],children:["leading"===u?d:null,n?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:n}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.cardTextWrap,children:[(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:_,ellipsizeMode:"tail",style:[w.cardLabel,{color:s,fontSize:T.fontSize,lineHeight:Math.round(T.fontSize*H.leading.body)}],children:k(i)}),l?(0,_jsxRuntime.jsx)(_index4.Text,{numberOfLines:j,ellipsizeMode:"tail",style:[w.cardDescription,{color:t?H.colors["text-muted"]:H.colors["text-subtle"],fontSize:H.text.xs.size,lineHeight:Math.round(H.text.xs.size*H.leading.body)}],children:l}):null]}),"trailing"===u?d:null]})},J="string"==typeof R&&""!==R?R:void 0,K=!0===R||void 0!==J?null:C,Q=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:i,accessibilityRole:I?void 0:"radiogroup",accessibilityLabel:y,accessibilityState:{disabled:g},"aria-disabled":g,testID:S,style:[{flexDirection:p,gap:x??H.space.sm,flexWrap:E?"wrap":"nowrap"},z],children:t.map((e,i)=>{const t=D(e),r=I?W.includes(t):N===t,o=I&&null!=P&&!r&&W.length>=P,a=g||o||O(e),s=L(e)??H.colors.primary,l=d||"card"!==c?void 0:G(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:e.testID,onPress:()=>{a||A(e)},disabled:a,accessibilityRole:I?"checkbox":"radio",accessibilityLabel:l?`${k(e)}, ${l}`:k(e),accessibilityState:{checked:r,disabled:a},"aria-checked":r,"aria-disabled":a,style:[B?w.stretchOption:null,{opacity:a&&d?.55:1},V],children:({pressed:t})=>{const o={option:e,index:i,selected:r,pressed:t&&!a,disabled:a,color:s};return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:d?d(o):"chip"===c?renderChip(o):renderDefaultCard(o)})}},String(t))})});return(0,_ChoiceText.hasChoiceDetail)({description:v,error:J,helperText:K??void 0})?(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[v?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:H.space.xs},children:v}):null,Q,void 0!==J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:H.space.xs},children:J}):K?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",style:{marginTop:H.space.xs},children:K}):null]}):Q});ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>_reactNative.StyleSheet.create({stretchOption:{flexGrow:1,flexShrink:0,flexBasis:"auto"},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flexGrow:1,flexShrink:1,flexBasis:"auto"},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});var _default=exports.default=ChoiceGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.buildPieces=exports.DEFAULT_PHYSICS=exports.Confetti=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.buildPieces=exports.DEFAULT_PHYSICS=exports.Confetti=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(s,r,t):s[r]=e[r]);return s}const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6},DEFAULT_PHYSICS=exports.DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0},PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const t=e.physics.spread>0?e.physics.spread/2:100,r=(-90+rand(-t,t))*DEG,i=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(r)*i*.7,vyFrac:Math.sin(r)*i,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const t=Math.max(1,Math.round(e/4)),r=a.physics.spread>0?a.physics.spread/2:180,i=[];for(let s=0;s<4&&i.length<e;s+=1){const n=rand(.18,.82),c=rand(.18,.52),o=s/4*.5+rand(0,.06);for(let s=0;s<t&&i.length<e;s+=1){const e=rand(-r,r)*DEG,t=rand(1.4,3.4)*a.physics.velocity;i.push({...commonPiece(a,i.length),x0Frac:n,y0Frac:c,vxFrac:Math.cos(e)*t*.7,vyFrac:Math.sin(e)*t,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:o,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return i},buildPieces=(e,a,t)=>{if("fireworks"===a)return buildFireworks(e,t);const r="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>r(t,a))};exports.buildPieces=buildPieces;const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:t,height:r,fadeOut:i})=>{const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const s=1-e.delay,n=s<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/s)),c=(1-Math.exp(-e.drag*n))/e.drag,o=e.x0Frac*t+e.vxFrac*t*c,l=e.y0Frac*r+e.terminalFrac*r*n+(e.vyFrac-e.terminalFrac)*r*c,d=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:i?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:o+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}},[e,a,t,r,i]),n=SHAPE_BOX[e.shape],c="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:c?"transparent":e.color},s],children:(0,_jsxRuntime.jsx)(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=exports.Confetti=(0,_react.forwardRef)(({count:e=80,colors:a,preset:t="pop",shapes:r,speed:i="normal",physics:s,origin:n,duration:c=2800,fadeOut:o=!0,autoStart:l=!1,recycle:d=!1,size:h=10,onComplete:p,style:u,testID:_},m)=>{(0,_assertValidValue.assertValidValue)("Confetti","preset",t,["pop","rain","fireworks"]),(0,_assertValidValue.assertValidValue)("Confetti","speed",i,["slow","normal","fast"]);for(const e of r??[])(0,_assertValidValue.assertValidValue)("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const y=(0,_index2.useTheme)(),f=(0,_index.useReducedMotion)(),v=(0,_reactNative.useWindowDimensions)(),[g,x]=(0,_react.useState)({width:v.width,height:v.height}),[S,w]=(0,_react.useState)(!1),[R,F]=(0,_react.useState)([]),P=(0,_react.useMemo)(()=>a??[y.colors.primary,y.colors.neutral,y.colors.success,y.colors.warning,y.colors.danger,y.colors.info],[a,y.colors]),M=(0,_reactNativeReanimated.useSharedValue)(0),A=c*SPEED_FACTOR[i],E=(0,_react.useCallback)(()=>{w(!1),p?.()},[p]),N=(0,_react.useCallback)(()=>{if(f)return void p?.();(0,_reactNativeReanimated.cancelAnimation)(M),M.value=0,F(buildPieces(e,t,{colors:P,baseSize:h,originXFrac:n?n.x/Math.max(1,g.width):.5,originYFrac:n?n.y/Math.max(1,g.height):.5,physics:{...DEFAULT_PHYSICS,...s},shapes:r??PRESET_SHAPES[t]})),w(!0);const a=(0,_reactNativeReanimated.withTiming)(1,{duration:A,easing:_reactNativeReanimated.Easing.linear},e=>{"worklet";e&&!d&&(0,_reactNativeReanimated.runOnJS)(E)()});M.value=d?(0,_reactNativeReanimated.withRepeat)(a,-1,!1):a},[f,M,A,d,E,p,e,P,t,r,s,h,n,g.width,g.height]),T=(0,_react.useCallback)(()=>{(0,_reactNativeReanimated.cancelAnimation)(M),w(!1)},[M]);(0,_react.useImperativeHandle)(m,()=>({start:N,stop:T}),[N,T]),(0,_react.useEffect)(()=>(l&&N(),()=>(0,_reactNativeReanimated.cancelAnimation)(M)),[]);const j=(0,_react.useCallback)(e=>{const{width:a,height:t}=e.nativeEvent.layout;a>0&&t>0&&x({width:a,height:t})},[]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_reactNative.StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:j,testID:_,children:S?R.map((e,a)=>(0,_jsxRuntime.jsx)(ConfettiPiece,{piece:e,progress:M,width:g.width,height:g.height,fadeOut:o},a)):null})});Confetti.displayName="Confetti";var _default=exports.default=Confetti;
|