@webority/mobile-ui 0.133.0 → 0.134.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/canvas-kit/kit.js +2162 -2048
  2. package/dist/canvas-kit/manifest.json +2 -2
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/AppIcon/slotIcon.js +1 -1
  5. package/lib/commonjs/components/Banner/Banner.js +1 -1
  6. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  7. package/lib/commonjs/components/Button/Button.js +1 -1
  8. package/lib/commonjs/components/Card/Card.js +1 -1
  9. package/lib/commonjs/components/Chip/Chip.js +1 -1
  10. package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
  11. package/lib/commonjs/components/DateSeparator/DateSeparator.js +1 -1
  12. package/lib/commonjs/components/Dialog/OverlayActions.js +1 -1
  13. package/lib/commonjs/components/IconButton/IconButton.js +1 -1
  14. package/lib/commonjs/components/Input/Input.js +1 -1
  15. package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
  16. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  17. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  18. package/lib/commonjs/components/SearchBar/SearchPanel.js +1 -1
  19. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  20. package/lib/commonjs/components/Select/Select.js +1 -1
  21. package/lib/commonjs/components/StatTile/StatTile.js +1 -1
  22. package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
  23. package/lib/commonjs/components/Tabs/Tabs.js +1 -1
  24. package/lib/module/components/AppIcon/slotIcon.js +1 -1
  25. package/lib/module/components/Banner/Banner.js +1 -1
  26. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  27. package/lib/module/components/Button/Button.js +1 -1
  28. package/lib/module/components/Card/Card.js +1 -1
  29. package/lib/module/components/Chip/Chip.js +1 -1
  30. package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
  31. package/lib/module/components/DateSeparator/DateSeparator.js +1 -1
  32. package/lib/module/components/Dialog/OverlayActions.js +1 -1
  33. package/lib/module/components/IconButton/IconButton.js +1 -1
  34. package/lib/module/components/Input/Input.js +1 -1
  35. package/lib/module/components/Menu/MenuSurface.js +1 -1
  36. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  37. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  38. package/lib/module/components/SearchBar/SearchPanel.js +1 -1
  39. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  40. package/lib/module/components/Select/Select.js +1 -1
  41. package/lib/module/components/StatTile/StatTile.js +1 -1
  42. package/lib/module/components/Swipeable/Swipeable.js +1 -1
  43. package/lib/module/components/Tabs/Tabs.js +1 -1
  44. package/lib/typescript/commonjs/components/AppIcon/slotIcon.d.ts +8 -0
  45. package/lib/typescript/commonjs/components/DateSeparator/DateSeparator.d.ts +2 -3
  46. package/lib/typescript/module/components/AppIcon/slotIcon.d.ts +8 -0
  47. package/lib/typescript/module/components/DateSeparator/DateSeparator.d.ts +2 -3
  48. package/package.json +7 -7
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MenuSurface=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_placement=require("../../utils/placement.js"),_responsive=require("../../utils/responsive.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Box/index.js"),_index3=require("../Divider/index.js"),_index4=require("../ListItem/index.js"),_index5=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index6=require("../OptionSheet/index.js"),_index7=require("../Text/index.js"),_focusHost=require("./focusHost.js"),_menuModel=require("./menuModel.js"),_webOnly=require("./webOnly.js"),_jsxRuntime=require("react/jsx-runtime");const MENU_MIN_WIDTH=180,MENU_MAX_WIDTH=280,TOP_ACTION_MIN_HEIGHT=64,ICON_SIZE=20,PREVIEW_LIFT=1.02,BACK_KEY="__menu-back",TOP_PREFIX="__menu-top:",MenuSurface=e=>{const{open:t,anchor:i,items:s,title:n,topActions:r,placement:o,presentation:a,unavailable:c,context:l=!1,preview:u,onClose:d,restoreFocusTo:_,haptic:m,accessibilityLabel:p,labels:x,testID:b}=e,h=(0,_index.useTheme)(),f=(0,_react.useMemo)(()=>buildStyles(h),[h]),j=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[v,y]=(0,_ModalSafeArea.useModalInsets)(),g=(0,_react.useMemo)(()=>({...j,top:v.top,bottom:v.bottom}),[j,v]),R=(0,_reactNative.useWindowDimensions)(),w=(0,_usePresenceMotion.usePresenceMotion)(),I=w.duration("fast"),A=(0,_react.useMemo)(()=>(0,_menuModel.visibleGroups)(s,c),[s,c]),k=(0,_react.useMemo)(()=>(0,_menuModel.visibleTopActions)(r,c),[r,c]),M="sheet"===a||"auto"===a&&R.width<_responsive.Breakpoints.lg&&(0,_menuModel.wantsSheet)(A,k),[N,S]=(0,_react.useState)(null),[C,E]=(0,_react.useState)(null),D=(0,_react.useRef)(d);D.current=d;const O=(0,_react.useRef)(_);O.current=_;const L=(0,_react.useRef)(null),T=(0,_react.useRef)(!1),P=(0,_react.useRef)(!1),q=(0,_react.useRef)(new Map),H=(0,_react.useRef)(null),V=(0,_react.useCallback)(()=>{if(!T.current)return;T.current=!1;const e=L.current;L.current=null,e?e():(0,_focusHost.focusHost)(O.current?.())},[]);(0,_react.useEffect)(()=>{if(t)return P.current=!0,T.current=!1,L.current=null,(0,_placement.claimAnchoredSurface)(()=>D.current());P.current&&(P.current=!1,T.current=!0,S(null),E(null))},[t]);const B=(0,_react.useCallback)(e=>{if(e.disabled)return;const t=(0,_hapticUtils.resolveHaptic)(m,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.key!==BACK_KEY?e.submenu?S(e):(L.current=e.onPress??null,D.current()):S(null)},[m]),F=(0,_react.useMemo)(()=>({width:R.width,height:R.height,insets:g}),[R.width,R.height,g]),K=(0,_react.useMemo)(()=>{if(!i||!C)return null;const e=i.x+i.width/2>F.width/2?"end":"start";return(0,_placement.computePlacement)(i,C,F,o,{align:e})},[i,C,F,o]);let $=F.height-g.top-g.bottom-2*_placement.PLACEMENT_MARGIN;if(i&&K){const e=(0,_placement.placementRoom)(i,F);$="top"===K.placement?e.above:e.below}const z=Math.min(280,F.width-g.left-g.right-2*_placement.PLACEMENT_MARGIN),U=t&&null!==K,W=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,Y=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!U)return(0,_index.setNativeValue)(W,0),void(0,_index.setNativeValue)(Y,1);const e=[_reactNative.Animated.timing(W,{toValue:1,duration:I,easing:_reactNative.Easing.bezier(...h.motion.ease.decelerate),useNativeDriver:!0})];l&&!w.reduced&&e.push(_reactNative.Animated.spring(Y,{toValue:1.02,damping:h.motion.spring.snappy.damping,stiffness:h.motion.spring.snappy.stiffness,mass:h.motion.spring.snappy.mass,useNativeDriver:!0}));const t=_reactNative.Animated.parallel(e);return t.start(),()=>t.stop()},[U,l,w.reduced,W,Y,h.motion,I]);const G=(0,_react.useCallback)(e=>{const{width:t,height:i}=e.nativeEvent.layout;E(e=>e&&e.width===t&&e.height===i?e:{width:t,height:i})},[]),X=l&&"top"===K?.placement,Z=N?.submenu?[N.submenu]:A,J=X?[...Z].reverse().map(e=>[...e].reverse()):Z,Q=[];if(N)Q.push({key:BACK_KEY,label:N.label});else for(const e of k)Q.push({key:`${TOP_PREFIX}${e.key}`,label:e.label,item:e});for(const e of J)for(const t of e)Q.push({key:t.key,label:t.label,item:t});const ee=Q[0]?.key;(0,_react.useEffect)(()=>{if(!U||M||!ee)return;const e=setTimeout(()=>(0,_focusHost.focusHost)(q.current.get(ee)),_focusHost.FOCUS_DELAY_MS);return()=>clearTimeout(e)},[U,M,ee]);const setItemRef=e=>t=>{t?q.current.set(e,t):q.current.delete(e)},te=(0,_webOnly.webOnly)({onKeyDown:e=>{const t=e.key??e.nativeEvent?.key??"",i=Q.length,s=Q.findIndex(e=>e.key===H.current);let n=-1;if("ArrowDown"===t)n=(s+1)%i;else if("ArrowUp"===t)n=s<=0?i-1:s-1;else if("Home"===t)n=0;else if("End"===t)n=i-1;else{if("ArrowLeft"===t&&N)return e.preventDefault?.(),void S(null);if("ArrowRight"===t&&Q[s]?.item?.submenu)return e.preventDefault?.(),void B(Q[s].item);if(1===t.length&&""!==t.trim()){const e=t.toLowerCase();for(let t=1;t<=i;t+=1){const r=(s+t)%i;if(Q[r].label.toLowerCase().startsWith(e)){n=r;break}}}}n>=0&&(e.preventDefault?.(),(e=>{const t=Q[e];t&&(0,_focusHost.focusHost)(q.current.get(t.key))})(n))}});if(M){const e=N?.submenu?[{key:BACK_KEY,label:x.back,icon:"chevron-left"},...N.submenu]:[...k,...A.flat()],i=[...new Set(e.filter(e=>e.checked).map(e=>e.key))];return(0,_jsxRuntime.jsx)(_index6.OptionSheet,{open:t,onClose:d,onAfterClose:V,title:N?.label??n,options:e,getOptionLabel:e=>e.label,getOptionValue:e=>e.key,isOptionDisabled:e=>Boolean(e.disabled),destructiveOf:e=>Boolean(e.destructive),getOptionDescription:e=>e.description,getOptionIcon:e=>{const t=e;return(0,_slotIcon.renderSlotIcon)(t.icon,{color:t.destructive?h.colors["danger-text"]:h.colors["text-muted"],size:20,disabled:Boolean(t.disabled)})},value:i,onChange:(e,t)=>B(t),accessibilityLabel:p??n,testID:b?`${b}-sheet`:void 0})}const inkFor=e=>e.disabled?h.colors["text-disabled"]:e.destructive?h.colors["danger-text"]:h.colors["text-body"],inkRoleFor=e=>e.disabled?"disabled":e.destructive?"danger":"primary",ie=N?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.ListItem,{ref:setItemRef(BACK_KEY),variant:"menu",onPress:()=>S(null),onFocus:()=>{H.current=BACK_KEY},accessibilityLabel:`${x.back}, ${N.label}`,leading:(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.icon,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"chevron-left",size:20,color:h.colors["text-muted"]})}),title:(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",weight:"semibold",numberOfLines:1,children:N.label})}),(0,_jsxRuntime.jsx)(_index3.Divider,{spacing:"none"})]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[n?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"caption",color:"secondary",accessibilityRole:"header",numberOfLines:2,style:f.title,children:n}):null,k.length>0?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.topRow,children:k.map(e=>{const t=`${TOP_PREFIX}${e.key}`,i=Boolean(e.disabled),s=inkFor(e);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:setItemRef(t),onPress:()=>B(e),onFocus:()=>{H.current=t},disabled:i,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityState:{disabled:i},"aria-disabled":i,testID:e.testID,style:({pressed:e})=>[f.topAction,e?f.pressed:null],children:[(0,_slotIcon.renderSlotIcon)(e.icon,{color:s,size:20,disabled:i}),(0,_jsxRuntime.jsx)(_index7.Text,{variant:"caption",color:inkRoleFor(e),numberOfLines:1,children:e.label})]},t)})}),(0,_jsxRuntime.jsx)(_index3.Divider,{spacing:"none"})]}):null]});return(0,_jsxRuntime.jsxs)(_index5.Modal,{open:t,onClose:d,presentation:"fullScreen",bare:!0,backdropOpacity:l?void 0:0,haptic:!1,labels:{close:x.close},onInsetsChange:y,onDismissed:V,testID:b?`${b}-modal`:void 0,children:[l&&u&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[f.preview,{left:i.x,top:i.y,width:i.width,height:i.height,transform:[{scale:Y}]}],children:u}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{accessibilityRole:"menu",accessibilityLabel:N?.label??p??n,onLayout:G,testID:b?`${b}-menu`:void 0,...te,style:[f.anchored,{left:K?.x??0,top:K?.y??0,maxWidth:z,opacity:U?W:0}],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.surface,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[f.clip,{maxHeight:$}],children:[ie,(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:f.scroll,bounces:!1,keyboardShouldPersistTaps:"handled",children:J.map((e,t)=>{const i=e.some(e=>null!=e.icon);return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[t>0?(0,_jsxRuntime.jsx)(_index3.Divider,{spacing:"none"}):null,e.map(e=>((e,t)=>{const i=Boolean(e.disabled),s=inkFor(e),n=e.detail||e.checked||e.submenu?(0,_jsxRuntime.jsxs)(_index2.Row,{gap:"md",children:[e.detail?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"caption",color:"tertiary",children:e.detail}):null,e.checked?(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"check",size:20,color:h.colors.primary}):null,e.submenu?(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"chevron-right",size:20,color:h.colors["text-subtle"]}):null]}):void 0;return(0,_jsxRuntime.jsx)(_index4.ListItem,{ref:setItemRef(e.key),variant:"menu",onPress:()=>B(e),onFocus:()=>{H.current=e.key},disabled:i,checked:e.checked,accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,rightPlacement:"side",leading:t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.icon,children:(0,_slotIcon.renderSlotIcon)(e.icon,{color:s,size:20,disabled:i})}):void 0,title:(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",color:inkRoleFor(e),numberOfLines:2,children:e.label}),subtitle:e.description?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"caption",color:"secondary",numberOfLines:2,children:e.description}):void 0,trailing:n},e.key)})(e,i))]},e[0].key)})})]})})})]})};exports.MenuSurface=MenuSurface;const buildStyles=e=>_reactNative.StyleSheet.create({preview:{position:"absolute"},anchored:{position:"absolute",minWidth:180},surface:{backgroundColor:e.colors.surface,borderRadius:e.radius.md,..._corners.smoothCorners,...e.shadow.popover},clip:{borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden"},scroll:{flexGrow:0,flexShrink:1},title:{paddingHorizontal:e.space.md,paddingTop:e.space.sm,paddingBottom:e.space.xs},pressed:{backgroundColor:e.colors["surface-pressed"]},icon:{width:20,alignItems:"center"},topRow:{flexDirection:"row",padding:e.space.xs,gap:e.space.xs},topAction:{flexGrow:1,flexBasis:0,alignItems:"center",justifyContent:"center",gap:e.space.xs,minHeight:64,borderRadius:e.radius.sm,..._corners.smoothCorners}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MenuSurface=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_placement=require("../../utils/placement.js"),_responsive=require("../../utils/responsive.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Box/index.js"),_index3=require("../Divider/index.js"),_index4=require("../ListItem/index.js"),_index5=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index6=require("../OptionSheet/index.js"),_index7=require("../Text/index.js"),_focusHost=require("./focusHost.js"),_menuModel=require("./menuModel.js"),_webOnly=require("./webOnly.js"),_jsxRuntime=require("react/jsx-runtime");const MENU_MIN_WIDTH=180,MENU_MAX_WIDTH=280,TOP_ACTION_MIN_HEIGHT=64,ICON_SIZE=20,PREVIEW_LIFT=1.02,BACK_KEY="__menu-back",TOP_PREFIX="__menu-top:",MenuSurface=e=>{const{open:t,anchor:i,items:s,title:n,topActions:r,placement:o,presentation:a,unavailable:c,context:l=!1,preview:u,onClose:d,restoreFocusTo:_,haptic:m,accessibilityLabel:p,labels:x,testID:b}=e,h=(0,_index.useTheme)(),f=(0,_react.useMemo)(()=>buildStyles(h),[h]),j=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[v,y]=(0,_ModalSafeArea.useModalInsets)(),g=(0,_react.useMemo)(()=>({...j,top:v.top,bottom:v.bottom}),[j,v]),R=(0,_reactNative.useWindowDimensions)(),w=(0,_usePresenceMotion.usePresenceMotion)(),I=w.duration("fast"),A=(0,_react.useMemo)(()=>(0,_menuModel.visibleGroups)(s,c),[s,c]),k=(0,_react.useMemo)(()=>(0,_menuModel.visibleTopActions)(r,c),[r,c]),M="sheet"===a||"auto"===a&&R.width<_responsive.Breakpoints.lg&&(0,_menuModel.wantsSheet)(A,k),[N,S]=(0,_react.useState)(null),[E,C]=(0,_react.useState)(null),D=(0,_react.useRef)(d);D.current=d;const O=(0,_react.useRef)(_);O.current=_;const L=(0,_react.useRef)(null),T=(0,_react.useRef)(!1),P=(0,_react.useRef)(!1),q=(0,_react.useRef)(new Map),H=(0,_react.useRef)(null),V=(0,_react.useCallback)(()=>{if(!T.current)return;T.current=!1;const e=L.current;L.current=null,e?e():(0,_focusHost.focusHost)(O.current?.())},[]);(0,_react.useEffect)(()=>{if(t)return P.current=!0,T.current=!1,L.current=null,(0,_placement.claimAnchoredSurface)(()=>D.current());P.current&&(P.current=!1,T.current=!0,S(null),C(null))},[t]);const B=(0,_react.useCallback)(e=>{if(e.disabled)return;const t=(0,_hapticUtils.resolveHaptic)(m,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.key!==BACK_KEY?e.submenu?S(e):(L.current=e.onPress??null,D.current()):S(null)},[m]),F=(0,_react.useMemo)(()=>({width:R.width,height:R.height,insets:g}),[R.width,R.height,g]),K=(0,_react.useMemo)(()=>{if(!i||!E)return null;const e=i.x+i.width/2>F.width/2?"end":"start";return(0,_placement.computePlacement)(i,E,F,o,{align:e})},[i,E,F,o]);let $=F.height-g.top-g.bottom-2*_placement.PLACEMENT_MARGIN;if(i&&K){const e=(0,_placement.placementRoom)(i,F);$="top"===K.placement?e.above:e.below}const z=Math.min(280,F.width-g.left-g.right-2*_placement.PLACEMENT_MARGIN),U=t&&null!==K,W=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,Y=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!U)return(0,_index.setNativeValue)(W,0),void(0,_index.setNativeValue)(Y,1);const e=[_reactNative.Animated.timing(W,{toValue:1,duration:I,easing:_reactNative.Easing.bezier(...h.motion.ease.decelerate),useNativeDriver:!0})];l&&!w.reduced&&e.push(_reactNative.Animated.spring(Y,{toValue:1.02,damping:h.motion.spring.snappy.damping,stiffness:h.motion.spring.snappy.stiffness,mass:h.motion.spring.snappy.mass,useNativeDriver:!0}));const t=_reactNative.Animated.parallel(e);return t.start(),()=>t.stop()},[U,l,w.reduced,W,Y,h.motion,I]);const G=(0,_react.useCallback)(e=>{const{width:t,height:i}=e.nativeEvent.layout;C(e=>e&&e.width===t&&e.height===i?e:{width:t,height:i})},[]),X=l&&"top"===K?.placement,Z=N?.submenu?[N.submenu]:A,J=X?[...Z].reverse().map(e=>[...e].reverse()):Z,Q=[];if(N)Q.push({key:BACK_KEY,label:N.label});else for(const e of k)Q.push({key:`${TOP_PREFIX}${e.key}`,label:e.label,item:e});for(const e of J)for(const t of e)Q.push({key:t.key,label:t.label,item:t});const ee=Q[0]?.key;(0,_react.useEffect)(()=>{if(!U||M||!ee)return;const e=setTimeout(()=>(0,_focusHost.focusHost)(q.current.get(ee)),_focusHost.FOCUS_DELAY_MS);return()=>clearTimeout(e)},[U,M,ee]);const setItemRef=e=>t=>{t?q.current.set(e,t):q.current.delete(e)},te=(0,_webOnly.webOnly)({onKeyDown:e=>{const t=e.key??e.nativeEvent?.key??"",i=Q.length,s=Q.findIndex(e=>e.key===H.current);let n=-1;if("ArrowDown"===t)n=(s+1)%i;else if("ArrowUp"===t)n=s<=0?i-1:s-1;else if("Home"===t)n=0;else if("End"===t)n=i-1;else{if("ArrowLeft"===t&&N)return e.preventDefault?.(),void S(null);if("ArrowRight"===t&&Q[s]?.item?.submenu)return e.preventDefault?.(),void B(Q[s].item);if(1===t.length&&""!==t.trim()){const e=t.toLowerCase();for(let t=1;t<=i;t+=1){const r=(s+t)%i;if(Q[r].label.toLowerCase().startsWith(e)){n=r;break}}}}n>=0&&(e.preventDefault?.(),(e=>{const t=Q[e];t&&(0,_focusHost.focusHost)(q.current.get(t.key))})(n))}});if(M){const e=N?.submenu?[{key:BACK_KEY,label:x.back,icon:"chevron-left"},...N.submenu]:[...k,...A.flat()],i=[...new Set(e.filter(e=>e.checked).map(e=>e.key))];return(0,_jsxRuntime.jsx)(_index6.OptionSheet,{open:t,onClose:d,onAfterClose:V,title:N?.label??n,options:e,getOptionLabel:e=>e.label,getOptionValue:e=>e.key,isOptionDisabled:e=>Boolean(e.disabled),destructiveOf:e=>Boolean(e.destructive),getOptionDescription:e=>e.description,getOptionIcon:e=>{const t=e;return(0,_slotIcon.renderSlotIcon)(t.icon,{color:t.destructive?h.colors["danger-text"]:h.colors["text-muted"],size:20,disabled:Boolean(t.disabled)})},value:i,onChange:(e,t)=>B(t),accessibilityLabel:p??n,testID:b?`${b}-sheet`:void 0})}const inkFor=e=>e.disabled?h.colors["text-disabled"]:e.destructive?h.colors["danger-text"]:h.colors["text-body"],inkRoleFor=e=>e.disabled?"disabled":e.destructive?"danger":"primary",ie=N?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.ListItem,{ref:setItemRef(BACK_KEY),variant:"menu",onPress:()=>S(null),onFocus:()=>{H.current=BACK_KEY},accessibilityLabel:`${x.back}, ${N.label}`,leading:(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.icon,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"chevron-left",size:20,color:h.colors["text-muted"]})}),title:(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",weight:"semibold",numberOfLines:1,children:N.label})}),(0,_jsxRuntime.jsx)(_index3.Divider,{spacing:"none"})]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[n?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"caption",color:"secondary",accessibilityRole:"header",numberOfLines:2,style:f.title,children:n}):null,k.length>0?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.topRow,children:k.map(e=>{const t=`${TOP_PREFIX}${e.key}`,i=Boolean(e.disabled),s=inkFor(e);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:setItemRef(t),onPress:()=>B(e),onFocus:()=>{H.current=t},disabled:i,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityState:{disabled:i},"aria-disabled":i,testID:e.testID,style:({pressed:e})=>[f.topAction,e?f.pressed:null],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(e.icon,{color:s,size:20,disabled:i})}),(0,_jsxRuntime.jsx)(_index7.Text,{variant:"caption",color:inkRoleFor(e),numberOfLines:1,children:e.label})]},t)})}),(0,_jsxRuntime.jsx)(_index3.Divider,{spacing:"none"})]}):null]});return(0,_jsxRuntime.jsxs)(_index5.Modal,{open:t,onClose:d,presentation:"fullScreen",bare:!0,backdropOpacity:l?void 0:0,haptic:!1,labels:{close:x.close},onInsetsChange:y,onDismissed:V,testID:b?`${b}-modal`:void 0,children:[l&&u&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[f.preview,{left:i.x,top:i.y,width:i.width,height:i.height,transform:[{scale:Y}]}],children:u}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{accessibilityRole:"menu",accessibilityLabel:N?.label??p??n,onLayout:G,testID:b?`${b}-menu`:void 0,...te,style:[f.anchored,{left:K?.x??0,top:K?.y??0,maxWidth:z,opacity:U?W:0}],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.surface,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[f.clip,{maxHeight:$}],children:[ie,(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:f.scroll,bounces:!1,keyboardShouldPersistTaps:"handled",children:J.map((e,t)=>{const i=e.some(e=>null!=e.icon);return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[t>0?(0,_jsxRuntime.jsx)(_index3.Divider,{spacing:"none"}):null,e.map(e=>((e,t)=>{const i=Boolean(e.disabled),s=inkFor(e),n=e.detail||e.checked||e.submenu?(0,_jsxRuntime.jsxs)(_index2.Row,{gap:"md",children:[e.detail?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"caption",color:"tertiary",children:e.detail}):null,e.checked?(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"check",size:20,color:h.colors.primary}):null,e.submenu?(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"chevron-right",size:20,color:h.colors["text-subtle"]}):null]}):void 0;return(0,_jsxRuntime.jsx)(_index4.ListItem,{ref:setItemRef(e.key),variant:"menu",onPress:()=>B(e),onFocus:()=>{H.current=e.key},disabled:i,checked:e.checked,accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,rightPlacement:"side",leading:t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.icon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(e.icon,{color:s,size:20,disabled:i})}):void 0,title:(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",color:inkRoleFor(e),numberOfLines:2,children:e.label}),subtitle:e.description?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"caption",color:"secondary",numberOfLines:2,children:e.description}):void 0,trailing:n},e.key)})(e,i))]},e[0].key)})})]})})})]})};exports.MenuSurface=MenuSurface;const buildStyles=e=>_reactNative.StyleSheet.create({preview:{position:"absolute"},anchored:{position:"absolute",minWidth:180},surface:{backgroundColor:e.colors.surface,borderRadius:e.radius.md,..._corners.smoothCorners,...e.shadow.popover},clip:{borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden"},scroll:{flexGrow:0,flexShrink:1},title:{paddingHorizontal:e.space.md,paddingTop:e.space.sm,paddingBottom:e.space.xs},pressed:{backgroundColor:e.colors["surface-pressed"]},icon:{width:20,alignItems:"center"},topRow:{flexDirection:"row",padding:e.space.xs,gap:e.space.xs},topAction:{flexGrow:1,flexBasis:0,alignItems:"center",justifyContent:"center",gap:e.space.xs,minHeight:64,borderRadius:e.radius.sm,..._corners.smoothCorners}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProfilePicker=exports.DEFAULT_PROFILE_PICKER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_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"),_index3=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Avatar/index.js"),_index5=require("../FieldBase/index.js"),_FilePicker=require("../FilePicker/FilePicker.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index6=require("../Spinner/index.js"),_index7=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PROFILE_PICKER_LABELS=exports.DEFAULT_PROFILE_PICKER_LABELS=Object.freeze({pick:"Change profile photo",remove:"Remove photo",sheetTitle:"Change photo",errorTooLarge:e=>`The photo is larger than ${e} MB.`,errorWrongType:"That file is not a supported image."}),DEFAULT_ACCEPT=["image/*"],SHEET_ICON_SIZE=20,SOFT_FILL_OPACITY=.14,SIZE_PX={sm:72,md:120,lg:160},clamp=(e,r,t)=>Math.min(t,Math.max(r,e)),toneFor=(e,r)=>{switch(r){case"success":return{base:e.colors.success,on:e.colors["on-success"]};case"warning":return{base:e.colors.warning,on:e.colors["on-warning"]};case"danger":return{base:e.colors.danger,on:e.colors["on-danger"]};case"info":return{base:e.colors.info,on:e.colors["on-info"]};case"neutral":return{base:e.colors["text-muted"],on:e.colors["on-neutral-strong"]};default:return{base:e.colors.primary,on:e.colors["on-primary"]}}},badgeLookFor=(e,r,t)=>{const i=toneFor(e,r),n=i.base,o=e.colors.bg,s="neutral"===r;let a;switch(t){case"soft":a={fill:s?e.colors["bg-muted"]:(0,_color.blendOf)(n,.14,o,e.colors["bg-subtle"]),ring:o,icon:n};break;case"outline":a={fill:o,ring:s?e.colors.border:n,icon:n};break;default:a={fill:n,ring:o,icon:i.on}}return a},resolveRadius=(e,r)=>"circle"===e?r/2:"rounded"===e?Math.max(6,Math.round(.22*r)):0,REMOVE_VALUE="__profile-picker-remove__",ProfilePicker=exports.ProfilePicker=(0,_react.forwardRef)((e,r)=>{const{value:t,name:i,sources:n,onPick:o,onRemove:s,loading:a=!1,disabled:l=!1,accept:c=DEFAULT_ACCEPT,maxSizeMB:u,size:d="md",shape:_="circle",badgeIcon:m="camera",tone:x,variant:p,avatarTone:g,avatarBackgroundColor:h,avatarColor:b,label:v,required:f=!1,helperText:y,error:j,layout:k="stacked",title:I,subtitle:P,ImageComponent:C,labels:R,haptic:E,onError:w,accessibilityLabel:S,style:T,testID:F}=e;(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","shape",e.shape,["circle","rounded","square"]),(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","variant",e.variant,["solid","soft","outline"]),(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","layout",e.layout,["stacked","inline","profile"]);const L=(0,_index.useTheme)(),A=L.settings.components["profile-picker"],V=x??A?.defaultTone??"primary",O=p??A?.defaultVariant??"solid",q=(0,_react.useMemo)(()=>badgeLookFor(L,V,O),[L,V,O]),M=g??A?.defaultAvatarTone,D=(0,_react.useMemo)(()=>({...DEFAULT_PROFILE_PICKER_LABELS,...R}),[R]),[N,B]=(0,_react.useState)(null),[z,H]=(0,_react.useState)(null),[U,K]=(0,_react.useState)(!1),[$,W]=(0,_react.useState)(t);t!==$&&(W(t),B(null));const Z=a||l,G=N??t??null,X=(0,_react.useMemo)(()=>G?{uri:G}:void 0,[G]),Q=j??z??void 0,Y=!Z&&(null!==N||Boolean(t)&&Boolean(s)),J=n.length>0||Y,ee=SIZE_PX[d],re=resolveRadius(_,ee),te=re*(1-Math.SQRT1_2),ie=clamp(Math.round(.28*ee),24,44),ne=te-ie/2,oe=Math.max(0,-ne),se=(0,_react.useCallback)(e=>{H(e),w?.(e),!1!==E&&(0,_index2.triggerHaptic)("notificationError")},[w,E]),ae=(0,_react.useCallback)(async e=>{let r;try{r=await e.pick()}catch(e){return void se(e instanceof Error?e.message:String(e))}const t=r?.[0];if(!t)return;if("number"==typeof u&&"number"==typeof t.size&&t.size>1024*u*1024)return void se(D.errorTooLarge(u));if(t.type&&!(0,_FilePicker.matchesAccept)(t.type,c))return void se(D.errorWrongType);H(null),B(t.uri);const i=(0,_index2.resolveHaptic)(E,"selection");i&&(0,_index2.triggerHaptic)(i),o?.(t)},[u,c,D,E,o,se]),le=(0,_react.useCallback)(()=>{Z||(de.current=null,1!==n.length||Y?(n.length>0||Y)&&K(!0):ae(n[0]))},[Z,n,Y,ae]),ce=(0,_react.useCallback)(()=>{B(null),H(null);const e=(0,_index2.resolveHaptic)(E,"selection");e&&(0,_index2.triggerHaptic)(e),s?.()},[E,s]),ue=(0,_react.useMemo)(()=>{const e=n.map(e=>({kind:"source",source:e}));return Y&&e.push({kind:"remove"}),e},[n,Y]),de=(0,_react.useRef)(null),me=(0,_react.useCallback)(e=>{de.current||(K(!1),"remove"===e.kind?ce():de.current=e.source)},[ce]),xe=(0,_react.useRef)(ae);xe.current=ae;const pe=(0,_react.useCallback)(()=>{const e=de.current;de.current=null,e&&xe.current(e)},[]),ge=F??"profile-picker",he=S??(J?D.pick:i),be=(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:ee,height:ee,marginBottom:oe,marginRight:oe},children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:le,disabled:Z||!J,accessibilityRole:J?"button":"image",accessibilityLabel:he,accessibilityHint:(0,_index5.fieldTextAsString)(Q),accessibilityState:J?{disabled:Z,busy:a}:{busy:a},"aria-disabled":J?Z:void 0,"aria-busy":a,testID:`${ge}-button`,style:({pressed:e})=>[{width:ee,height:ee,borderRadius:re,..._corners.smoothCorners},{opacity:l?.55:e?.85:1}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index4.Avatar,{dimension:ee,shape:_,name:i||void 0,source:X,ImageComponent:C,tone:M,backgroundColor:h,color:b,placeholderIcon:"user"})}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.fill,styles.overlay,{borderRadius:re,..._corners.smoothCorners,backgroundColor:L.colors.scrim}],testID:`${ge}-loading`,children:(0,_jsxRuntime.jsx)(_index6.Spinner,{size:ee>=100?"md":"sm",color:L.colors["on-primary"]})}):null,!l&&J?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:`${ge}-badge`,style:[styles.badge,{width:ie,height:ie,borderRadius:L.radius.pill,..._corners.smoothCorners,right:ne,bottom:ne,backgroundColor:q.fill,borderColor:q.ring}],children:(0,_slotIcon.renderSlotIcon)(m,{color:q.icon,size:Math.round(.55*ie),disabled:!1})}):null]})}),ve="stacked"!==k?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.meta,"profile"===k?styles.metaCentred:null],children:[I?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",weight:"semibold",style:[styles.title,"profile"===k?styles.textCentred:null],children:I}):null,P?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"bodySmall",color:"secondary",style:[styles.subtitle,"profile"===k?styles.textCentred:null,{marginTop:L.space.xxs}],children:P}):null,(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Q??y,error:(0,_index5.hasFieldText)(Q)})]}):(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Q??y,error:(0,_index5.hasFieldText)(Q)});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,style:T,testID:F,children:[v?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{required:f,children:v}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:"inline"===k?[styles.row,{columnGap:L.space.md}]:["profile"===k?styles.columnCentred:styles.column,{rowGap:L.space.xs}],children:[be,ve]}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:U,haptic:E,onClose:()=>K(!1),onAfterClose:pe,title:D.sheetTitle,options:ue,getOptionLabel:e=>"remove"===e.kind?D.remove:e.source.label,getOptionValue:e=>"remove"===e.kind?REMOVE_VALUE:e.source.key,destructiveOf:e=>"remove"===e.kind,getOptionDescription:e=>"remove"===e.kind?void 0:e.source.description,getOptionIcon:e=>"remove"===e.kind?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"trash",size:20,color:L.colors["danger-text"]}):e.source.icon,onChange:(e,r)=>me(r)})]})});ProfilePicker.displayName="ProfilePicker";const styles=_reactNative.StyleSheet.create({fill:{alignItems:"center",justifyContent:"center",overflow:"hidden"},overlay:{..._reactNative.StyleSheet.absoluteFill},badge:{position:"absolute",alignItems:"center",justifyContent:"center",borderWidth:2},row:{flexDirection:"row",alignItems:"center"},column:{alignItems:"flex-start"},columnCentred:{alignItems:"center"},meta:{flexShrink:1},metaCentred:{alignItems:"center"},title:{includeFontPadding:!1},subtitle:{includeFontPadding:!1},textCentred:{textAlign:"center"}});var _default=exports.default=ProfilePicker;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProfilePicker=exports.DEFAULT_PROFILE_PICKER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_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"),_index3=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Avatar/index.js"),_index5=require("../FieldBase/index.js"),_FilePicker=require("../FilePicker/FilePicker.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index6=require("../Spinner/index.js"),_index7=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PROFILE_PICKER_LABELS=exports.DEFAULT_PROFILE_PICKER_LABELS=Object.freeze({pick:"Change profile photo",remove:"Remove photo",sheetTitle:"Change photo",errorTooLarge:e=>`The photo is larger than ${e} MB.`,errorWrongType:"That file is not a supported image."}),DEFAULT_ACCEPT=["image/*"],SHEET_ICON_SIZE=20,SOFT_FILL_OPACITY=.14,SIZE_PX={sm:72,md:120,lg:160},clamp=(e,r,t)=>Math.min(t,Math.max(r,e)),toneFor=(e,r)=>{switch(r){case"success":return{base:e.colors.success,on:e.colors["on-success"]};case"warning":return{base:e.colors.warning,on:e.colors["on-warning"]};case"danger":return{base:e.colors.danger,on:e.colors["on-danger"]};case"info":return{base:e.colors.info,on:e.colors["on-info"]};case"neutral":return{base:e.colors["text-muted"],on:e.colors["on-neutral-strong"]};default:return{base:e.colors.primary,on:e.colors["on-primary"]}}},badgeLookFor=(e,r,t)=>{const i=toneFor(e,r),n=i.base,o=e.colors.bg,s="neutral"===r;let a;switch(t){case"soft":a={fill:s?e.colors["bg-muted"]:(0,_color.blendOf)(n,.14,o,e.colors["bg-subtle"]),ring:o,icon:n};break;case"outline":a={fill:o,ring:s?e.colors.border:n,icon:n};break;default:a={fill:n,ring:o,icon:i.on}}return a},resolveRadius=(e,r)=>"circle"===e?r/2:"rounded"===e?Math.max(6,Math.round(.22*r)):0,REMOVE_VALUE="__profile-picker-remove__",ProfilePicker=exports.ProfilePicker=(0,_react.forwardRef)((e,r)=>{const{value:t,name:i,sources:n,onPick:o,onRemove:s,loading:a=!1,disabled:l=!1,accept:c=DEFAULT_ACCEPT,maxSizeMB:d,size:u="md",shape:_="circle",badgeIcon:m="camera",tone:x,variant:p,avatarTone:g,avatarBackgroundColor:h,avatarColor:b,label:v,required:f=!1,helperText:y,error:j,layout:k="stacked",title:I,subtitle:P,ImageComponent:C,labels:R,haptic:E,onError:w,accessibilityLabel:S,style:T,testID:F}=e;(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","shape",e.shape,["circle","rounded","square"]),(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","variant",e.variant,["solid","soft","outline"]),(0,_warnInvalidValue.warnInvalidValue)("ProfilePicker","layout",e.layout,["stacked","inline","profile"]);const L=(0,_index.useTheme)(),A=L.settings.components["profile-picker"],V=x??A?.defaultTone??"primary",O=p??A?.defaultVariant??"solid",q=(0,_react.useMemo)(()=>badgeLookFor(L,V,O),[L,V,O]),M=g??A?.defaultAvatarTone,D=(0,_react.useMemo)(()=>({...DEFAULT_PROFILE_PICKER_LABELS,...R}),[R]),[N,B]=(0,_react.useState)(null),[z,H]=(0,_react.useState)(null),[U,K]=(0,_react.useState)(!1),[$,W]=(0,_react.useState)(t);t!==$&&(W(t),B(null));const Z=a||l,G=N??t??null,X=(0,_react.useMemo)(()=>G?{uri:G}:void 0,[G]),Q=j??z??void 0,Y=!Z&&(null!==N||Boolean(t)&&Boolean(s)),J=n.length>0||Y,ee=SIZE_PX[u],re=resolveRadius(_,ee),te=re*(1-Math.SQRT1_2),ie=clamp(Math.round(.28*ee),24,44),ne=te-ie/2,oe=Math.max(0,-ne),se=(0,_react.useCallback)(e=>{H(e),w?.(e),!1!==E&&(0,_index2.triggerHaptic)("notificationError")},[w,E]),ae=(0,_react.useCallback)(async e=>{let r;try{r=await e.pick()}catch(e){return void se(e instanceof Error?e.message:String(e))}const t=r?.[0];if(!t)return;if("number"==typeof d&&"number"==typeof t.size&&t.size>1024*d*1024)return void se(D.errorTooLarge(d));if(t.type&&!(0,_FilePicker.matchesAccept)(t.type,c))return void se(D.errorWrongType);H(null),B(t.uri);const i=(0,_index2.resolveHaptic)(E,"selection");i&&(0,_index2.triggerHaptic)(i),o?.(t)},[d,c,D,E,o,se]),le=(0,_react.useCallback)(()=>{Z||(ue.current=null,1!==n.length||Y?(n.length>0||Y)&&K(!0):ae(n[0]))},[Z,n,Y,ae]),ce=(0,_react.useCallback)(()=>{B(null),H(null);const e=(0,_index2.resolveHaptic)(E,"selection");e&&(0,_index2.triggerHaptic)(e),s?.()},[E,s]),de=(0,_react.useMemo)(()=>{const e=n.map(e=>({kind:"source",source:e}));return Y&&e.push({kind:"remove"}),e},[n,Y]),ue=(0,_react.useRef)(null),me=(0,_react.useCallback)(e=>{ue.current||(K(!1),"remove"===e.kind?ce():ue.current=e.source)},[ce]),xe=(0,_react.useRef)(ae);xe.current=ae;const pe=(0,_react.useCallback)(()=>{const e=ue.current;ue.current=null,e&&xe.current(e)},[]),ge=F??"profile-picker",he=S??(J?D.pick:i),be=(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:ee,height:ee,marginBottom:oe,marginRight:oe},children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:le,disabled:Z||!J,accessibilityRole:J?"button":"image",accessibilityLabel:he,accessibilityHint:(0,_index5.fieldTextAsString)(Q),accessibilityState:J?{disabled:Z,busy:a}:{busy:a},"aria-disabled":J?Z:void 0,"aria-busy":a,testID:`${ge}-button`,style:({pressed:e})=>[{width:ee,height:ee,borderRadius:re,..._corners.smoothCorners},{opacity:l?.55:e?.85:1}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index4.Avatar,{dimension:ee,shape:_,name:i||void 0,source:X,ImageComponent:C,tone:M,backgroundColor:h,color:b,placeholderIcon:"user"})}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.fill,styles.overlay,{borderRadius:re,..._corners.smoothCorners,backgroundColor:L.colors.scrim}],testID:`${ge}-loading`,children:(0,_jsxRuntime.jsx)(_index6.Spinner,{size:ee>=100?"md":"sm",color:L.colors["on-primary"]})}):null,!l&&J?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:`${ge}-badge`,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,style:[styles.badge,{width:ie,height:ie,borderRadius:L.radius.pill,..._corners.smoothCorners,right:ne,bottom:ne,backgroundColor:q.fill,borderColor:q.ring}],children:(0,_slotIcon.renderSlotIcon)(m,{color:q.icon,size:Math.round(.55*ie),disabled:!1})}):null]})}),ve="stacked"!==k?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.meta,"profile"===k?styles.metaCentred:null],children:[I?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",weight:"semibold",style:[styles.title,"profile"===k?styles.textCentred:null],children:I}):null,P?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"bodySmall",color:"secondary",style:[styles.subtitle,"profile"===k?styles.textCentred:null,{marginTop:L.space.xxs}],children:P}):null,(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Q??y,error:(0,_index5.hasFieldText)(Q)})]}):(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Q??y,error:(0,_index5.hasFieldText)(Q)});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,style:T,testID:F,children:[v?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{required:f,children:v}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:"inline"===k?[styles.row,{columnGap:L.space.md}]:["profile"===k?styles.columnCentred:styles.column,{rowGap:L.space.xs}],children:[be,ve]}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:U,haptic:E,onClose:()=>K(!1),onAfterClose:pe,title:D.sheetTitle,options:de,getOptionLabel:e=>"remove"===e.kind?D.remove:e.source.label,getOptionValue:e=>"remove"===e.kind?REMOVE_VALUE:e.source.key,destructiveOf:e=>"remove"===e.kind,getOptionDescription:e=>"remove"===e.kind?void 0:e.source.description,getOptionIcon:e=>"remove"===e.kind?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"trash",size:20,color:L.colors["danger-text"]}):e.source.icon,onChange:(e,r)=>me(r)})]})});ProfilePicker.displayName="ProfilePicker";const styles=_reactNative.StyleSheet.create({fill:{alignItems:"center",justifyContent:"center",overflow:"hidden"},overlay:{..._reactNative.StyleSheet.absoluteFill},badge:{position:"absolute",alignItems:"center",justifyContent:"center",borderWidth:2},row:{flexDirection:"row",alignItems:"center"},column:{alignItems:"flex-start"},columnCentred:{alignItems:"center"},meta:{flexShrink:1},metaCentred:{alignItems:"center"},title:{includeFontPadding:!1},subtitle:{includeFontPadding:!1},textCentred:{textAlign:"center"}});var _default=exports.default=ProfilePicker;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SearchBar=exports.DEFAULT_SEARCH_BAR_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_useDebounce=require("../../hooks/useDebounce.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_SearchPanel=require("./SearchPanel.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SEARCH_BAR_LABELS=exports.DEFAULT_SEARCH_BAR_LABELS=Object.freeze({placeholder:"Search…",recents:"Recent searches",clearAll:"Clear all",clearAllRecents:"Clear all recent searches",searchAgain:"Searches again",removeRecent:e=>`Remove ${e} from recent searches`,scope:"Search scope",clearSearch:"Clear search",searching:e=>`Searching ${e}`,suggestionCount:e=>1===e?"1 suggestion":`${e} suggestions`,removed:e=>`Removed ${e}`,recentsCleared:"Recent searches cleared"}),DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=exports.SearchBar=(0,_react.forwardRef)((e,a)=>{const{value:l,onChangeText:t,onSubmit:s,onFocus:r,onBlur:n,placeholder:c,autoFocus:i=!1,disabled:o=!1,onClear:u,leftIcon:d,debounceMs:_,size:h="md",variant:b,radius:p,label:S,labelMode:g="top",labelStyle:f,scopes:v,scope:m,onScopeChange:x,recents:R,maxRecents:C=DEFAULT_PANEL_ROWS,onSelectRecent:j,onRemove:B,onClearRecents:F,suggestions:L,maxSuggestions:A=DEFAULT_PANEL_ROWS,onSelect:y,haptic:E,labels:I,style:k,inputStyle:q,accessibilityLabel:w,testID:T,...D}=e;(0,_warnInvalidValue.warnInvalidValue)("SearchBar","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("SearchBar","variant",e.variant,["outline","filled","underline"]),(0,_warnInvalidValue.warnInvalidValue)("SearchBar","labelMode",e.labelMode,["top","float"]);const V=(0,_index.useTheme)(),P=(0,_react.useMemo)(()=>({...DEFAULT_SEARCH_BAR_LABELS,...I}),[I]),z=c??P.placeholder,H=b??V.settings.components["search-bar"]?.defaultVariant??V.settings.components.field?.defaultVariant??"filled",N="underline"===H,U=(0,_index.resolveFieldSize)(V,h),M=p??V.components["search-bar"][h].radius,O=(0,_FieldBase.resolveFieldTextStyle)(V,{disabled:o}),W=(0,_react.useRef)(null),$=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(W,a),[a]),K=(0,_react.useCallback)(()=>{o||W.current?.focus()},[o]),G=(0,_react.useMemo)(()=>buildStyles(V),[V]),J="string"==typeof l?l:"",[Q,X]=(0,_react.useState)(!1),Y=(0,_react.useCallback)(e=>{X(!0),r?.(e)},[r]),Z=(0,_react.useCallback)(e=>{X(!1),n?.(e)},[n]),[ee,ae]=(0,_react.useState)(J),le=(0,_useDebounce.useDebounce)(ee,_??0);(0,_react.useEffect)(()=>{void 0!==_&&J!==ee&&ae(J)},[J,_]);const te=(0,_react.useRef)(J);(0,_react.useEffect)(()=>{void 0!==_&&le!==te.current&&(te.current=le,t(le))},[le,_,t]);const se=(0,_react.useCallback)(e=>{void 0===_?t(e):ae(e)},[_,t]),re=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(E,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),void 0!==_&&(ae(""),te.current=""),t(""),u?.()},[E,_,t,u]),ne=(0,_react.useCallback)(()=>{s?.(void 0!==_?ee:J)},[s,_,ee,J]),ce=void 0!==_?ee:J,ie=ce.length>0,[oe,ue]=(0,_useControllableState.useControllableState)({value:m,defaultValue:v?.[0]?.value??"",onChange:x}),de=(0,_react.useCallback)(e=>{ue(e);const a=v?.find(a=>a.value===e)?.label;a&&(0,_announce.announce)(P.searching(a))},[v,ue,P]),[he,be]=(0,_react.useState)(!1),pe=(0,_react.useRef)(null),Se=(0,_react.useCallback)(()=>{pe.current&&(clearTimeout(pe.current),pe.current=null)},[]),ge=(0,_react.useCallback)(()=>{Se(),be(!0)},[Se]),fe=(0,_react.useCallback)(()=>{Se(),pe.current=setTimeout(()=>be(!1),50)},[Se]);(0,_react.useEffect)(()=>Se,[Se]);const ve=!o&&(Q||he),me=(0,_react.useMemo)(()=>(R??[]).slice(0,C),[R,C]),xe=(0,_react.useMemo)(()=>(L??[]).slice(0,A).map(_SearchPanel.normalizeSuggestion),[L,A]),Re=ve&&!ie&&me.length>0,Ce=ve&&ie&&xe.length>0,je=Ce?xe.length:0,Be=je>0?P.suggestionCount(je):"";(0,_react.useEffect)(()=>{Be&&(0,_announce.announce)(Be)},[Be]);const Fe=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(E,"selection");e&&(0,_hapticUtils.triggerHaptic)(e)},[E]),Le=(0,_react.useCallback)(e=>{Fe(),W.current?.blur(),be(!1),j?.(e)},[Fe,j]),Ae=(0,_react.useCallback)(e=>{Fe(),W.current?.blur(),be(!1),y?.(e)},[Fe,y]),ye=(0,_react.useCallback)(e=>{Fe(),B?.(e),(0,_announce.announce)(P.removed(e)),K()},[Fe,B,K,P]),Ee=(0,_react.useCallback)(()=>{Fe(),F?.(),(0,_announce.announce)(P.recentsCleared),K()},[Fe,F,K,P]),Ie={size:U.icon,color:o?V.colors["text-disabled"]:V.colors["text-subtle"],disabled:o},ke=d?(0,_slotIcon.renderSlotIcon)(d,Ie):(V.settings.icons.search??_defaultIcons.defaultIcons.search)(Ie),qe=Boolean(S)&&"float"===g,we=(0,_useFloatingLabel.useFloatingLabel)({label:S,enabled:qe,floated:Q||ie,variant:H,sizeTokens:U,leadingOffset:U.icon+V.space.md,trailingOffset:ie?U.icon+V.space.md:0,paddingLeft:N?V.space.none:U["padding-x"],color:V.colors["field-label"],style:f}),Te=ie&&!o?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:re,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:P.clearSearch,children:(V.settings.icons.close??_defaultIcons.defaultIcons.close)({size:U.icon,color:V.colors["text-muted"]})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:k,testID:T,children:[S&&!qe?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:h,style:f,children:S}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:G.root,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:G.fieldWrap,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:h,variant:H,focused:Q,disabled:o,filled:ie,minHeight:U["min-height"],paddingHorizontal:N?V.space.none:U["padding-x"],radius:M,leading:ke,trailing:Te,topNotch:we.topNotch,onPress:K,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:w??z,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:$,style:[G.input,{fontSize:U.text,color:O.color,...O.weightStyle},q],value:ce,onChangeText:se,onSubmitEditing:ne,onFocus:Y,onBlur:Z,placeholder:!qe||Q||ie?z:void 0,placeholderTextColor:O.placeholderColor,autoFocus:i,editable:!o,returnKeyType:"search",selectionColor:(0,_FieldBase.resolveVariantColors)(V,H).borderFocusedRepresentative,accessibilityLabel:w??z,accessibilityState:{disabled:o},"aria-disabled":o,...D})}),we.node]})}),v&&v.length>0?(0,_jsxRuntime.jsx)(_SearchPanel.SearchScopeBar,{scopes:v,scope:oe||(v[0]?.value??""),disabled:o,haptic:E,labels:P,onChange:de}):null,Re?(0,_jsxRuntime.jsx)(_SearchPanel.SearchRecents,{recents:me,labels:P,onSelect:Le,onRemove:B?ye:void 0,onClear:F?Ee:void 0,onHold:ge,onRelease:fe}):null,Ce?(0,_jsxRuntime.jsx)(_SearchPanel.SearchSuggestions,{suggestions:xe,query:ce,onSelect:Ae,onHold:ge,onRelease:fe}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});var _default=exports.default=SearchBar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SearchBar=exports.DEFAULT_SEARCH_BAR_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_useDebounce=require("../../hooks/useDebounce.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_SearchPanel=require("./SearchPanel.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SEARCH_BAR_LABELS=exports.DEFAULT_SEARCH_BAR_LABELS=Object.freeze({placeholder:"Search…",recents:"Recent searches",clearAll:"Clear all",clearAllRecents:"Clear all recent searches",searchAgain:"Searches again",removeRecent:e=>`Remove ${e} from recent searches`,scope:"Search scope",clearSearch:"Clear search",searching:e=>`Searching ${e}`,suggestionCount:e=>1===e?"1 suggestion":`${e} suggestions`,removed:e=>`Removed ${e}`,recentsCleared:"Recent searches cleared"}),DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=exports.SearchBar=(0,_react.forwardRef)((e,a)=>{const{value:t,onChangeText:l,onSubmit:s,onFocus:r,onBlur:n,placeholder:c,autoFocus:i=!1,disabled:o=!1,onClear:u,leftIcon:d,debounceMs:_,size:h="md",variant:b,radius:p,label:S,labelMode:g="top",labelStyle:v,scopes:f,scope:m,onScopeChange:x,recents:R,maxRecents:C=DEFAULT_PANEL_ROWS,onSelectRecent:j,onRemove:F,onClearRecents:B,suggestions:L,maxSuggestions:y=DEFAULT_PANEL_ROWS,onSelect:A,haptic:E,labels:I,style:k,inputStyle:w,accessibilityLabel:q,testID:T,...V}=e;(0,_warnInvalidValue.warnInvalidValue)("SearchBar","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("SearchBar","variant",e.variant,["outline","filled","underline"]),(0,_warnInvalidValue.warnInvalidValue)("SearchBar","labelMode",e.labelMode,["top","float"]);const D=(0,_index.useTheme)(),H=(0,_react.useMemo)(()=>({...DEFAULT_SEARCH_BAR_LABELS,...I}),[I]),N=c??H.placeholder,P=b??D.settings.components["search-bar"]?.defaultVariant??D.settings.components.field?.defaultVariant??"filled",z="underline"===P,U=(0,_index.resolveFieldSize)(D,h),M=p??D.components["search-bar"][h].radius,O=(0,_FieldBase.resolveFieldTextStyle)(D,{disabled:o}),W=(0,_react.useRef)(null),$=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(W,a),[a]),K=(0,_react.useCallback)(()=>{o||W.current?.focus()},[o]),G=(0,_react.useMemo)(()=>buildStyles(D),[D]),J="string"==typeof t?t:"",[Q,X]=(0,_react.useState)(!1),Y=(0,_react.useCallback)(e=>{X(!0),r?.(e)},[r]),Z=(0,_react.useCallback)(e=>{X(!1),n?.(e)},[n]),[ee,ae]=(0,_react.useState)(J),te=(0,_useDebounce.useDebounce)(ee,_??0);(0,_react.useEffect)(()=>{void 0!==_&&J!==ee&&ae(J)},[J,_]);const le=(0,_react.useRef)(J);(0,_react.useEffect)(()=>{void 0!==_&&te!==le.current&&(le.current=te,l(te))},[te,_,l]);const se=(0,_react.useCallback)(e=>{void 0===_?l(e):ae(e)},[_,l]),re=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(E,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),void 0!==_&&(ae(""),le.current=""),l(""),u?.()},[E,_,l,u]),ne=(0,_react.useCallback)(()=>{s?.(void 0!==_?ee:J)},[s,_,ee,J]),ce=void 0!==_?ee:J,ie=ce.length>0,[oe,ue]=(0,_useControllableState.useControllableState)({value:m,defaultValue:f?.[0]?.value??"",onChange:x}),de=(0,_react.useCallback)(e=>{ue(e);const a=f?.find(a=>a.value===e)?.label;a&&(0,_announce.announce)(H.searching(a))},[f,ue,H]),[he,be]=(0,_react.useState)(!1),pe=(0,_react.useRef)(null),Se=(0,_react.useCallback)(()=>{pe.current&&(clearTimeout(pe.current),pe.current=null)},[]),ge=(0,_react.useCallback)(()=>{Se(),be(!0)},[Se]),ve=(0,_react.useCallback)(()=>{Se(),pe.current=setTimeout(()=>be(!1),50)},[Se]);(0,_react.useEffect)(()=>Se,[Se]);const fe=!o&&(Q||he),me=(0,_react.useMemo)(()=>(R??[]).slice(0,C),[R,C]),xe=(0,_react.useMemo)(()=>(L??[]).slice(0,y).map(_SearchPanel.normalizeSuggestion),[L,y]),Re=fe&&!ie&&me.length>0,Ce=fe&&ie&&xe.length>0,je=Ce?xe.length:0,Fe=je>0?H.suggestionCount(je):"";(0,_react.useEffect)(()=>{Fe&&(0,_announce.announce)(Fe)},[Fe]);const Be=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(E,"selection");e&&(0,_hapticUtils.triggerHaptic)(e)},[E]),Le=(0,_react.useCallback)(e=>{Be(),W.current?.blur(),be(!1),j?.(e)},[Be,j]),ye=(0,_react.useCallback)(e=>{Be(),W.current?.blur(),be(!1),A?.(e)},[Be,A]),Ae=(0,_react.useCallback)(e=>{Be(),F?.(e),(0,_announce.announce)(H.removed(e)),K()},[Be,F,K,H]),Ee=(0,_react.useCallback)(()=>{Be(),B?.(),(0,_announce.announce)(H.recentsCleared),K()},[Be,B,K,H]),Ie={size:U.icon,color:o?D.colors["text-disabled"]:D.colors["text-subtle"],disabled:o},ke=d?(0,_slotIcon.renderSlotIcon)(d,Ie):(D.settings.icons.search??_defaultIcons.defaultIcons.search)(Ie),we=(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:ke}),qe=Boolean(S)&&"float"===g,Te=(0,_useFloatingLabel.useFloatingLabel)({label:S,enabled:qe,floated:Q||ie,variant:P,sizeTokens:U,leadingOffset:U.icon+D.space.md,trailingOffset:ie?U.icon+D.space.md:0,paddingLeft:z?D.space.none:U["padding-x"],color:D.colors["field-label"],style:v}),Ve=ie&&!o?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:re,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:H.clearSearch,children:(D.settings.icons.close??_defaultIcons.defaultIcons.close)({size:U.icon,color:D.colors["text-muted"]})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:k,testID:T,children:[S&&!qe?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:h,style:v,children:S}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:G.root,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:G.fieldWrap,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:h,variant:P,focused:Q,disabled:o,filled:ie,minHeight:U["min-height"],paddingHorizontal:z?D.space.none:U["padding-x"],radius:M,leading:we,trailing:Ve,topNotch:Te.topNotch,onPress:K,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:q??N,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:$,style:[G.input,{fontSize:U.text,color:O.color,...O.weightStyle},w],value:ce,onChangeText:se,onSubmitEditing:ne,onFocus:Y,onBlur:Z,placeholder:!qe||Q||ie?N:void 0,placeholderTextColor:O.placeholderColor,autoFocus:i,editable:!o,returnKeyType:"search",selectionColor:(0,_FieldBase.resolveVariantColors)(D,P).borderFocusedRepresentative,accessibilityLabel:q??N,accessibilityState:{disabled:o},"aria-disabled":o,...V})}),Te.node]})}),f&&f.length>0?(0,_jsxRuntime.jsx)(_SearchPanel.SearchScopeBar,{scopes:f,scope:oe||(f[0]?.value??""),disabled:o,haptic:E,labels:H,onChange:de}):null,Re?(0,_jsxRuntime.jsx)(_SearchPanel.SearchRecents,{recents:me,labels:H,onSelect:Le,onRemove:F?Ae:void 0,onClear:B?Ee:void 0,onHold:ge,onRelease:ve}):null,Ce?(0,_jsxRuntime.jsx)(_SearchPanel.SearchSuggestions,{suggestions:xe,query:ce,onSelect:ye,onHold:ge,onRelease:ve}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});var _default=exports.default=SearchBar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeSuggestion=exports.SearchSuggestions=exports.SearchScopeBar=exports.SearchRecents=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Chip/index.js"),_index4=require("../Text/index.js"),_highlight=require("./highlight.js"),_jsxRuntime=require("react/jsx-runtime");const TOUCH=44,ICON=18,normalizeSuggestion=e=>"string"==typeof e?{text:e}:e;exports.normalizeSuggestion=normalizeSuggestion;const SearchScopeBar=({scopes:e,scope:s,disabled:t,haptic:i,labels:n,onChange:r})=>{const o=(0,_index.useTheme)(),l=(0,_react.useMemo)(()=>buildStyles(o),[o]);return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",contentContainerStyle:l.scopes,accessibilityLabel:n.scope,children:e.map(e=>(0,_jsxRuntime.jsx)(_index3.Chip,{label:e.label,selected:e.value===s,disabled:t,haptic:i,onPress:()=>r(e.value),containerStyle:l.scopeChip},e.value))})};exports.SearchScopeBar=SearchScopeBar;const SearchRecents=({recents:e,labels:s,onSelect:t,onRemove:i,onClear:n,onHold:r,onRelease:o})=>{const l=(0,_index.useTheme)(),c=(0,_react.useMemo)(()=>buildStyles(l),[l]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.list,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.header,children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",accessibilityRole:"header",style:c.headerTitle,children:s.recents}),n?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:n,onPressIn:r,onPressOut:o,accessibilityRole:"button",accessibilityLabel:s.clearAllRecents,style:c.clearAll,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",color:"link",children:s.clearAll})}):null]}),e.map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.row,children:[(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>t(e),onPressIn:r,onPressOut:o,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:s.searchAgain,android_ripple:{color:l.colors["surface-pressed"]},style:({pressed:e})=>[c.rowMain,e?{backgroundColor:l.colors["surface-pressed"]}:null],children:[(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"history",size:18,color:l.colors["text-subtle"]}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",numberOfLines:1,style:c.rowText,children:e})]}),i?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>i(e),onPressIn:r,onPressOut:o,accessibilityRole:"button",accessibilityLabel:s.removeRecent(e),style:c.remove,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"x",size:18,color:l.colors["text-muted"]})}):null]},e))]})};exports.SearchRecents=SearchRecents;const SuggestionRow=(0,_react.memo)(({item:e,query:s,onSelect:t,onHold:i,onRelease:n,theme:r,styles:o})=>{const l=(0,_highlight.splitHighlight)(e.text,s),c=e.icon?(0,_slotIcon.renderSlotIcon)(e.icon,{size:18,color:r.colors["text-subtle"],disabled:!1}):(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"search",size:18,color:r.colors["text-subtle"]});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>t(e),onPressIn:i,onPressOut:n,accessibilityRole:"button",accessibilityLabel:e.subtitle?`${e.text}, ${e.subtitle}`:e.text,android_ripple:{color:r.colors["surface-pressed"]},style:({pressed:e})=>[o.rowMain,o.suggestion,e?{backgroundColor:r.colors["surface-pressed"]}:null],children:[c,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.rowText,children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",color:"secondary",numberOfLines:1,children:l.map(e=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",color:"secondary",style:e.match?o.match:void 0,children:e.text},e.start))}),e.subtitle?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",numberOfLines:1,children:e.subtitle}):null]})]})});SuggestionRow.displayName="SuggestionRow";const SearchSuggestions=({suggestions:e,query:s,onSelect:t,onHold:i,onRelease:n})=>{const r=(0,_index.useTheme)(),o=(0,_react.useMemo)(()=>buildStyles(r),[r]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:o.list,children:e.map(e=>(0,_jsxRuntime.jsx)(SuggestionRow,{item:e,query:s,onSelect:t,onHold:i,onRelease:n,theme:r,styles:o},e.id??e.text))})};exports.SearchSuggestions=SearchSuggestions;const buildStyles=e=>({..._reactNative.StyleSheet.create({scopes:{flexDirection:"row",alignItems:"center",gap:e.space.sm,paddingTop:e.space.sm},scopeChip:{minHeight:44},list:{width:"100%",paddingTop:e.space.xs},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",minHeight:44,paddingHorizontal:e.space.xs},headerTitle:{flex:1},clearAll:{minHeight:44,minWidth:44,justifyContent:"center",alignItems:"flex-end"},row:{flexDirection:"row",alignItems:"center"},rowMain:{flex:1,flexDirection:"row",alignItems:"center",gap:e.space.md,minHeight:44,paddingHorizontal:e.space.xs},suggestion:{paddingVertical:e.space.xs},rowText:{flex:1},remove:{width:44,height:44,alignItems:"center",justifyContent:"center"}}),match:{...(0,_index.fontFor)(e,"bold"),color:e.colors["text-body"]}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeSuggestion=exports.SearchSuggestions=exports.SearchScopeBar=exports.SearchRecents=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Chip/index.js"),_index4=require("../Text/index.js"),_highlight=require("./highlight.js"),_jsxRuntime=require("react/jsx-runtime");const TOUCH=44,ICON=18,normalizeSuggestion=e=>"string"==typeof e?{text:e}:e;exports.normalizeSuggestion=normalizeSuggestion;const SearchScopeBar=({scopes:e,scope:s,disabled:t,haptic:i,labels:n,onChange:r})=>{const o=(0,_index.useTheme)(),l=(0,_react.useMemo)(()=>buildStyles(o),[o]);return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",contentContainerStyle:l.scopes,accessibilityLabel:n.scope,children:e.map(e=>(0,_jsxRuntime.jsx)(_index3.Chip,{label:e.label,selected:e.value===s,disabled:t,haptic:i,onPress:()=>r(e.value),containerStyle:l.scopeChip},e.value))})};exports.SearchScopeBar=SearchScopeBar;const SearchRecents=({recents:e,labels:s,onSelect:t,onRemove:i,onClear:n,onHold:r,onRelease:o})=>{const l=(0,_index.useTheme)(),c=(0,_react.useMemo)(()=>buildStyles(l),[l]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.list,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.header,children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",accessibilityRole:"header",style:c.headerTitle,children:s.recents}),n?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:n,onPressIn:r,onPressOut:o,accessibilityRole:"button",accessibilityLabel:s.clearAllRecents,style:c.clearAll,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",color:"link",children:s.clearAll})}):null]}),e.map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.row,children:[(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>t(e),onPressIn:r,onPressOut:o,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:s.searchAgain,android_ripple:{color:l.colors["surface-pressed"]},style:({pressed:e})=>[c.rowMain,e?{backgroundColor:l.colors["surface-pressed"]}:null],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"history",size:18,color:l.colors["text-subtle"]})}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",numberOfLines:1,style:c.rowText,children:e})]}),i?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>i(e),onPressIn:r,onPressOut:o,accessibilityRole:"button",accessibilityLabel:s.removeRecent(e),style:c.remove,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"x",size:18,color:l.colors["text-muted"]})})}):null]},e))]})};exports.SearchRecents=SearchRecents;const SuggestionRow=(0,_react.memo)(({item:e,query:s,onSelect:t,onHold:i,onRelease:n,theme:r,styles:o})=>{const l=(0,_highlight.splitHighlight)(e.text,s),c=e.icon?(0,_slotIcon.renderSlotIcon)(e.icon,{size:18,color:r.colors["text-subtle"],disabled:!1}):(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"search",size:18,color:r.colors["text-subtle"]});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>t(e),onPressIn:i,onPressOut:n,accessibilityRole:"button",accessibilityLabel:e.subtitle?`${e.text}, ${e.subtitle}`:e.text,android_ripple:{color:r.colors["surface-pressed"]},style:({pressed:e})=>[o.rowMain,o.suggestion,e?{backgroundColor:r.colors["surface-pressed"]}:null],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:c}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:o.rowText,children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",color:"secondary",numberOfLines:1,children:l.map(e=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",color:"secondary",style:e.match?o.match:void 0,children:e.text},e.start))}),e.subtitle?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",numberOfLines:1,children:e.subtitle}):null]})]})});SuggestionRow.displayName="SuggestionRow";const SearchSuggestions=({suggestions:e,query:s,onSelect:t,onHold:i,onRelease:n})=>{const r=(0,_index.useTheme)(),o=(0,_react.useMemo)(()=>buildStyles(r),[r]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:o.list,children:e.map(e=>(0,_jsxRuntime.jsx)(SuggestionRow,{item:e,query:s,onSelect:t,onHold:i,onRelease:n,theme:r,styles:o},e.id??e.text))})};exports.SearchSuggestions=SearchSuggestions;const buildStyles=e=>({..._reactNative.StyleSheet.create({scopes:{flexDirection:"row",alignItems:"center",gap:e.space.sm,paddingTop:e.space.sm},scopeChip:{minHeight:44},list:{width:"100%",paddingTop:e.space.xs},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",minHeight:44,paddingHorizontal:e.space.xs},headerTitle:{flex:1},clearAll:{minHeight:44,minWidth:44,justifyContent:"center",alignItems:"flex-end"},row:{flexDirection:"row",alignItems:"center"},rowMain:{flex:1,flexDirection:"row",alignItems:"center",gap:e.space.md,minHeight:44,paddingHorizontal:e.space.xs},suggestion:{paddingVertical:e.space.xs},rowText:{flex:1},remove:{width:44,height:44,alignItems:"center",justifyContent:"center"}}),match:{...(0,_index.fontFor)(e,"bold"),color:e.colors["text-body"]}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SegmentedControl=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"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../FieldBase/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];default:return e.colors["info-text"]}},SegmentedControl=exports.SegmentedControl=(0,_react.forwardRef)((e,t)=>{const{segments:i,label:r,helperText:n,error:l,value:s,defaultValue:a,onChange:o,size:d="md",fullWidth:c=!0,disabled:u=!1,tone:m="primary",variant:x="segmented",radius:h,labelLines:g=1,haptic:_,accessibilityLabel:b,style:p,containerStyle:v,segmentStyle:f,selectedIndicatorStyle:y,textStyle:S,labelStyle:j,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","variant",e.variant,["underline","pills","segmented"]);const[I,C]=(0,_index.useControllableState)({value:s,defaultValue:a??i[0]?.value,onChange:o}),R=(0,_index2.useTheme)(),V=R.components["segmented-control"],q=(0,_react.useMemo)(()=>buildStyles(R),[R]),k=(0,_react.useMemo)(()=>(0,_index2.resolveSegmentedControlSize)(R,d),[R,d]),F=g>=2?2:1,L=F>1,N="segmented"===x,z="underline"===x,M="pills"===x,T=N?R.space[V["track-padding"]]:0,E=Math.ceil(1.25*k.text)*(F-1),A=V["underline-height"],D=R.space[V["pill-inset"]],H="number"==typeof h?h:h?R.radius[h]:void 0,B=H??R.radius.md,W=void 0===H?R.radius.sm:Math.max(H-T,0),P=H??R.radius.pill,O=H??R.radius.none,[G,X]=(0,_react.useState)([]),J=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,K=Math.max(0,i.findIndex(e=>e.value===I)),Q=G[K],U=Q?.x,Y=(0,_react.useCallback)(e=>{const t=R.motion.spring.snappy,i=_reactNative.Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!0});return i.start(),i},[R.motion.spring.snappy,J]);(0,_react.useEffect)(()=>{X(e=>e.length===i.length||0===e.length?e:[])},[i.length]);const Z=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(void 0===U)return;const e=null!==Z.current&&Z.current!==K;if(Z.current=K,!e)return void J.setValue(U);const t=Y(U);return()=>t.stop()},[K,U,Y,J]);const $=(0,_react.useCallback)((e,t)=>{const{x:i,width:r}=t.nativeEvent.layout;X(t=>{const n=t[e];if(n&&n.x===i&&n.width===r)return t;const l=t.slice();return l[e]={x:i,width:r},l})},[]),ee=(0,_react.useCallback)(e=>{if(u)return;if(e.value===I)return;const t=(0,_index3.resolveHaptic)(_,"selection");t&&(0,_index3.triggerHaptic)(t),C(e.value)},[u,C,I,_]),te=N?R.colors.thumb:M?R.colors["primary-soft"]:R.colors.primary,ie=N?W:M?P:O,re=activeInkFor(R,m),ne=R.colors["bg-muted"],le=(0,_SquircleFill.useSquircle)(N,B),se=!0===l||(0,_index4.hasFieldText)(l),ae=se&&!u,oe=R.colors["field-border-error"],de=R.size.border,ce=(0,_index4.hasFieldText)(r),ue=se?l:n,me=(0,_index4.hasFieldText)(ue),xe=b??("string"==typeof r?r:void 0),he=(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:xe,testID:w,style:[q.track,{...L?{minHeight:k.height+E}:{height:k.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},N?{borderRadius:B,..._corners.smoothCorners,backgroundColor:le.active?"transparent":ne,padding:T}:z?{borderBottomColor:ae?oe:R.colors["border-subtle"],borderBottomWidth:_reactNative.StyleSheet.hairlineWidth}:null,v,p],onLayout:le.onLayout,children:[le.active&&le.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:le.size.width,height:le.size.height,radius:B,fill:ne,stroke:ae?oe:void 0,strokeWidth:de}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:q.row,children:[Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[q.thumb,N?L?{top:0,bottom:0}:{top:0,height:k.height-2*T}:M?{top:D,bottom:D,left:D}:{bottom:0,height:A},{width:M?Math.max(Q.width-2*D,0):Q.width,borderRadius:ie,..._corners.smoothCorners,backgroundColor:te,transform:[{translateX:J}]},y]}):null,i.map((e,t)=>{const i=e.value===I,r=i?re:R.colors["text-subtle"],n=(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:k.icon,selected:i,disabled:u});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>ee(e),onLayout:e=>$(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:i,selected:i,disabled:u},"aria-checked":i,"aria-disabled":u,style:({pressed:e})=>[q.segment,L?q.segmentMultiline:null,{paddingHorizontal:k["padding-x"],opacity:e&&!i?.7:1},f],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:q.segmentIcon,children:n}):null,(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:i?"semibold":"medium",style:[q.segmentLabel,L?q.segmentLabelMultiline:null,{color:r,fontSize:k.text},S,j],numberOfLines:F,children:e.label})]},String(e.value))})]}),!ae||z||le.active?null:(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{borderWidth:de,borderColor:oe,borderRadius:N?B:P,..._corners.smoothCorners}]})]});return ce||me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ce?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:d,children:r}):null,he,me?(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:d,text:ue,error:se}):null]}):he});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>_reactNative.StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flexGrow:1,flexShrink:1,flexBasis:"auto",flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:e.space.xs},segmentMultiline:{paddingVertical:e.space.xs},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});var _default=exports.default=SegmentedControl;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SegmentedControl=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"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../FieldBase/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];default:return e.colors["info-text"]}},SegmentedControl=exports.SegmentedControl=(0,_react.forwardRef)((e,t)=>{const{segments:i,label:r,helperText:n,error:s,value:l,defaultValue:a,onChange:o,size:d="md",fullWidth:c=!0,disabled:u=!1,tone:m="primary",variant:x="segmented",radius:h,labelLines:g=1,haptic:_,accessibilityLabel:b,style:p,containerStyle:v,segmentStyle:f,selectedIndicatorStyle:y,textStyle:S,labelStyle:j,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","variant",e.variant,["underline","pills","segmented"]);const[I,C]=(0,_index.useControllableState)({value:l,defaultValue:a??i[0]?.value,onChange:o}),R=(0,_index2.useTheme)(),V=R.components["segmented-control"],q=(0,_react.useMemo)(()=>buildStyles(R),[R]),k=(0,_react.useMemo)(()=>(0,_index2.resolveSegmentedControlSize)(R,d),[R,d]),F=g>=2?2:1,L=F>1,N="segmented"===x,z="underline"===x,M="pills"===x,E=N?R.space[V["track-padding"]]:0,T=Math.ceil(1.25*k.text)*(F-1),A=V["underline-height"],H=R.space[V["pill-inset"]],D="number"==typeof h?h:h?R.radius[h]:void 0,B=D??R.radius.md,W=void 0===D?R.radius.sm:Math.max(D-E,0),P=D??R.radius.pill,O=D??R.radius.none,[G,X]=(0,_react.useState)([]),J=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,K=Math.max(0,i.findIndex(e=>e.value===I)),Q=G[K],U=Q?.x,Y=(0,_react.useCallback)(e=>{const t=R.motion.spring.snappy,i=_reactNative.Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!0});return i.start(),i},[R.motion.spring.snappy,J]);(0,_react.useEffect)(()=>{X(e=>e.length===i.length||0===e.length?e:[])},[i.length]);const Z=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(void 0===U)return;const e=null!==Z.current&&Z.current!==K;if(Z.current=K,!e)return void J.setValue(U);const t=Y(U);return()=>t.stop()},[K,U,Y,J]);const $=(0,_react.useCallback)((e,t)=>{const{x:i,width:r}=t.nativeEvent.layout;X(t=>{const n=t[e];if(n&&n.x===i&&n.width===r)return t;const s=t.slice();return s[e]={x:i,width:r},s})},[]),ee=(0,_react.useCallback)(e=>{if(u)return;if(e.value===I)return;const t=(0,_index3.resolveHaptic)(_,"selection");t&&(0,_index3.triggerHaptic)(t),C(e.value)},[u,C,I,_]),te=N?R.colors.thumb:M?R.colors["primary-soft"]:R.colors.primary,ie=N?W:M?P:O,re=activeInkFor(R,m),ne=R.colors["bg-muted"],se=(0,_SquircleFill.useSquircle)(N,B),le=!0===s||(0,_index4.hasFieldText)(s),ae=le&&!u,oe=R.colors["field-border-error"],de=R.size.border,ce=(0,_index4.hasFieldText)(r),ue=le?s:n,me=(0,_index4.hasFieldText)(ue),xe=b??("string"==typeof r?r:void 0),he=(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:xe,testID:w,style:[q.track,{...L?{minHeight:k.height+T}:{height:k.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},N?{borderRadius:B,..._corners.smoothCorners,backgroundColor:se.active?"transparent":ne,padding:E}:z?{borderBottomColor:ae?oe:R.colors["border-subtle"],borderBottomWidth:_reactNative.StyleSheet.hairlineWidth}:null,v,p],onLayout:se.onLayout,children:[se.active&&se.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:se.size.width,height:se.size.height,radius:B,fill:ne,stroke:ae?oe:void 0,strokeWidth:de}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:q.row,children:[Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[q.thumb,N?L?{top:0,bottom:0}:{top:0,height:k.height-2*E}:M?{top:H,bottom:H,left:H}:{bottom:0,height:A},{width:M?Math.max(Q.width-2*H,0):Q.width,borderRadius:ie,..._corners.smoothCorners,backgroundColor:te,transform:[{translateX:J}]},y]}):null,i.map((e,t)=>{const i=e.value===I,r=i?re:R.colors["text-subtle"],n=(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:k.icon,selected:i,disabled:u});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>ee(e),onLayout:e=>$(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:i,selected:i,disabled:u},"aria-checked":i,"aria-disabled":u,style:({pressed:e})=>[q.segment,L?q.segmentMultiline:null,{paddingHorizontal:k["padding-x"],opacity:e&&!i?.7:1},f],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:q.segmentIcon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:n}):null,(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:i?"semibold":"medium",style:[q.segmentLabel,L?q.segmentLabelMultiline:null,{color:r,fontSize:k.text},S,j],numberOfLines:F,children:e.label})]},String(e.value))})]}),!ae||z||se.active?null:(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{borderWidth:de,borderColor:oe,borderRadius:N?B:P,..._corners.smoothCorners}]})]});return ce||me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ce?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:d,children:r}):null,he,me?(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:d,text:ue,error:le}):null]}):he});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>_reactNative.StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flexGrow:1,flexShrink:1,flexBasis:"auto",flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:e.space.xs},segmentMultiline:{paddingVertical:e.space.xs},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});var _default=exports.default=SegmentedControl;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Select=exports.DEFAULT_SELECT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_Chevron=require("../FieldBase/Chevron.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index3=require("../Text/index.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SELECT_LABELS=exports.DEFAULT_SELECT_LABELS={placeholder:"Select…",noSelection:"No selection",selected:e=>`Selected: ${e}`,fallbackName:"Select",sheetName:"Options",searchPlaceholder:_OptionSheet.DEFAULT_OPTION_SHEET_LABELS.searchPlaceholder,empty:_OptionSheet.DEFAULT_OPTION_SHEET_LABELS.empty},sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t)),Select=exports.Select=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("Select","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Select","variant",e.variant,["outline","filled","underline"]);const{options:i,getOptionLabel:l,getOptionValue:n,isOptionDisabled:a,getOptionDescription:r,getOptionIcon:o,placeholder:s,onOpenChange:c,searchable:d=!1,haptic:u,labels:x,label:_,help:p,title:h,required:S=!1,error:v,helperText:g,prefix:b,numberOfLines:m=1,disabled:f=!1,size:j="md",variant:y,leftIcon:L,rightIcon:T,chevronColor:F,chevronSize:C,radius:O,accessibilityLabel:E,labelStyle:I,style:V,triggerStyle:B,textStyle:R,optionStyle:k,selectedOptionStyle:A,optionTextStyle:N,selectedOptionTextStyle:q,testID:z}=e,w=!0===e.multi,D=x?{...DEFAULT_SELECT_LABELS,...x}:DEFAULT_SELECT_LABELS,P=(0,_react.useCallback)(e=>l?l(e):e.label??"",[l]),H=(0,_react.useCallback)(e=>n?n(e):e.value,[n]),M=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),U=(0,_react.useCallback)(e=>r?r(e):e.description,[r]),$=(0,_react.useCallback)(e=>o?o(e):e.icon,[o]),G=(0,_index.useTheme)(),J=(0,_react.useMemo)(()=>buildStyles(G),[G]),K=(0,_index.resolveFieldSize)(G,j),Q=(0,_FieldBase.resolveFieldTextStyle)(G,{disabled:f}),W=y??G.settings.components.select?.defaultVariant??G.settings.components.field?.defaultVariant??"outline",[X,Y]=(0,_react.useState)(!1),Z=(0,_react.useMemo)(()=>{if(w){const t=e.value??[];return i.filter(e=>containsValue(t,H(e)))}const t=e.value;if(null==t)return[];const l=i.find(e=>sameSelectValue(H(e),t));return l?[l]:[]},[w,i,e.value,H]),ee=(0,_react.useCallback)(()=>{if(f)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),Y(!0)},[f,u]),te=(0,_react.useCallback)(()=>{Y(!1)},[]),ie=(0,_react.useCallback)(t=>{if(M(t))return;const i=H(t),l=(0,_index2.resolveHaptic)(u,"selection");if(l&&(0,_index2.triggerHaptic)(l),w){const t=e.value??[],l=containsValue(t,i)?t.filter(e=>!sameSelectValue(e,i)):[...t,i];return void e.onChange(l)}e.onChange(i),te()},[w,e,te,M,H,u]),le=0===Z.length?s??D.placeholder:Z.map(e=>P(e)).join(", "),ne=0===Z.length,ae=!0===v||(0,_FieldBase.hasFieldText)(v),re=(0,_FieldBase.hasFieldText)(_),oe=(0,_FieldBase.fieldTextAsString)(_),se=Math.round(1.4*K.text),ce=(0,_react.useMemo)(()=>({fontSize:K.text,color:Q.placeholderColor}),[K.text,Q.placeholderColor]),de={color:f?G.colors["field-icon-disabled"]:X?G.colors["field-icon-focus"]:G.colors["field-icon"],size:K.icon,disabled:f,focused:X,error:ae},ue=0===Z.length?s??D.noSelection:D.selected(Z.map(e=>P(e)).join(", ")),xe=E??`${oe??D.fallbackName}. ${ue}`;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[J.container,V],testID:z,children:[re?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:j,required:S,help:p,style:I,children:_}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,collapsable:!1,children:(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:j,variant:W,disabled:f,error:ae,filled:Z.length>0,onPress:ee,radius:O,paddingHorizontal:"underline"===W?G.space.none:void 0,accessibilityRole:"button",accessibilityLabel:xe,accessibilityState:{disabled:f,expanded:X},"aria-disabled":f,"aria-expanded":X,style:B,slotAlign:1===m?"center":"top",slotLineHeight:1===m?void 0:se,leading:L?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_slotIcon.renderSlotIcon)(L,de)}):null,trailing:T?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_slotIcon.renderSlotIcon)(T,de)}):(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:F??(f?G.colors["text-disabled"]:G.colors["text-subtle"]),size:C??K.icon,open:X,style:J.chevron}),children:[(0,_FieldBase.hasFieldText)(b)?"string"==typeof b||"number"==typeof b?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===m?void 0:se,marginRight:G.space.xs}],children:b}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[J.prefixNode,{minHeight:1===m?void 0:se,justifyContent:"center",marginRight:G.space.xs}],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===m?void 0:se}],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:ce,children:b})})}):null,(0,_jsxRuntime.jsxs)(_index3.Text,{variant:"body",style:[J.triggerText,{color:ne?Q.placeholderColor:Q.color,fontSize:K.text,lineHeight:1===m?void 0:se,...Q.weightStyle},R],numberOfLines:m,children:[le,ne&&S&&!re?(0,_jsxRuntime.jsx)(_FieldBase.RequiredMark,{}):null]})]})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:j,error:ae,text:ae?v:g}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:X,onClose:te,onOpenChange:c,haptic:u,title:h??oe,accessibilityLabel:oe??(re?h:void 0)??s??D.sheetName,options:i,getOptionLabel:P,getOptionValue:H,isOptionDisabled:M,getOptionDescription:U,getOptionIcon:$,value:e.value,onChange:(e,t)=>ie(t),multi:w,searchable:d,labels:{searchPlaceholder:D.searchPlaceholder,empty:D.empty},optionStyle:k,selectedOptionStyle:A,optionTextStyle:N,selectedOptionTextStyle:q,searchSelectionColor:(0,_FieldBase.resolveVariantColors)(G,W).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});var _default=exports.default=Select;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Select=exports.DEFAULT_SELECT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_Chevron=require("../FieldBase/Chevron.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index3=require("../Text/index.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SELECT_LABELS=exports.DEFAULT_SELECT_LABELS={placeholder:"Select…",noSelection:"No selection",selected:e=>`Selected: ${e}`,fallbackName:"Select",sheetName:"Options",searchPlaceholder:_OptionSheet.DEFAULT_OPTION_SHEET_LABELS.searchPlaceholder,empty:_OptionSheet.DEFAULT_OPTION_SHEET_LABELS.empty},sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t)),Select=exports.Select=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("Select","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Select","variant",e.variant,["outline","filled","underline"]);const{options:i,getOptionLabel:l,getOptionValue:n,isOptionDisabled:a,getOptionDescription:o,getOptionIcon:r,placeholder:s,onOpenChange:c,searchable:d=!1,haptic:u,labels:x,label:_,help:p,title:h,required:S=!1,error:g,helperText:v,prefix:b,numberOfLines:m=1,disabled:f=!1,size:y="md",variant:j,leftIcon:L,rightIcon:T,chevronColor:F,chevronSize:C,radius:O,accessibilityLabel:I,labelStyle:E,style:V,triggerStyle:B,textStyle:R,optionStyle:k,selectedOptionStyle:A,optionTextStyle:q,selectedOptionTextStyle:z,testID:N}=e,w=!0===e.multi,D=x?{...DEFAULT_SELECT_LABELS,...x}:DEFAULT_SELECT_LABELS,P=(0,_react.useCallback)(e=>l?l(e):e.label??"",[l]),H=(0,_react.useCallback)(e=>n?n(e):e.value,[n]),M=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),U=(0,_react.useCallback)(e=>o?o(e):e.description,[o]),$=(0,_react.useCallback)(e=>r?r(e):e.icon,[r]),G=(0,_index.useTheme)(),J=(0,_react.useMemo)(()=>buildStyles(G),[G]),K=(0,_index.resolveFieldSize)(G,y),Q=(0,_FieldBase.resolveFieldTextStyle)(G,{disabled:f}),W=j??G.settings.components.select?.defaultVariant??G.settings.components.field?.defaultVariant??"outline",[X,Y]=(0,_react.useState)(!1),Z=(0,_react.useMemo)(()=>{if(w){const t=e.value??[];return i.filter(e=>containsValue(t,H(e)))}const t=e.value;if(null==t)return[];const l=i.find(e=>sameSelectValue(H(e),t));return l?[l]:[]},[w,i,e.value,H]),ee=(0,_react.useCallback)(()=>{if(f)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),Y(!0)},[f,u]),te=(0,_react.useCallback)(()=>{Y(!1)},[]),ie=(0,_react.useCallback)(t=>{if(M(t))return;const i=H(t),l=(0,_index2.resolveHaptic)(u,"selection");if(l&&(0,_index2.triggerHaptic)(l),w){const t=e.value??[],l=containsValue(t,i)?t.filter(e=>!sameSelectValue(e,i)):[...t,i];return void e.onChange(l)}e.onChange(i),te()},[w,e,te,M,H,u]),le=0===Z.length?s??D.placeholder:Z.map(e=>P(e)).join(", "),ne=0===Z.length,ae=!0===g||(0,_FieldBase.hasFieldText)(g),oe=(0,_FieldBase.hasFieldText)(_),re=(0,_FieldBase.fieldTextAsString)(_),se=Math.round(1.4*K.text),ce=(0,_react.useMemo)(()=>({fontSize:K.text,color:Q.placeholderColor}),[K.text,Q.placeholderColor]),de={color:f?G.colors["field-icon-disabled"]:X?G.colors["field-icon-focus"]:G.colors["field-icon"],size:K.icon,disabled:f,focused:X,error:ae},ue=0===Z.length?s??D.noSelection:D.selected(Z.map(e=>P(e)).join(", ")),xe=I??`${re??D.fallbackName}. ${ue}`;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[J.container,V],testID:N,children:[oe?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:y,required:S,help:p,style:E,children:_}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,collapsable:!1,children:(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:y,variant:W,disabled:f,error:ae,filled:Z.length>0,onPress:ee,radius:O,paddingHorizontal:"underline"===W?G.space.none:void 0,accessibilityRole:"button",accessibilityLabel:xe,accessibilityState:{disabled:f,expanded:X},"aria-disabled":f,"aria-expanded":X,style:B,slotAlign:1===m?"center":"top",slotLineHeight:1===m?void 0:se,leading:L?(0,_slotIcon.slotIconView)(L,(0,_slotIcon.renderSlotIcon)(L,de)):null,trailing:T?(0,_slotIcon.slotIconView)(T,(0,_slotIcon.renderSlotIcon)(T,de)):(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:F??(f?G.colors["text-disabled"]:G.colors["text-subtle"]),size:C??K.icon,open:X,style:J.chevron}),children:[(0,_FieldBase.hasFieldText)(b)?"string"==typeof b||"number"==typeof b?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===m?void 0:se,marginRight:G.space.xs}],children:b}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[J.prefixNode,{minHeight:1===m?void 0:se,justifyContent:"center",marginRight:G.space.xs}],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===m?void 0:se}],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:ce,children:b})})}):null,(0,_jsxRuntime.jsxs)(_index3.Text,{variant:"body",style:[J.triggerText,{color:ne?Q.placeholderColor:Q.color,fontSize:K.text,lineHeight:1===m?void 0:se,...Q.weightStyle},R],numberOfLines:m,children:[le,ne&&S&&!oe?(0,_jsxRuntime.jsx)(_FieldBase.RequiredMark,{}):null]})]})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:y,error:ae,text:ae?g:v}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:X,onClose:te,onOpenChange:c,haptic:u,title:h??re,accessibilityLabel:re??(oe?h:void 0)??s??D.sheetName,options:i,getOptionLabel:P,getOptionValue:H,isOptionDisabled:M,getOptionDescription:U,getOptionIcon:$,value:e.value,onChange:(e,t)=>ie(t),multi:w,searchable:d,labels:{searchPlaceholder:D.searchPlaceholder,empty:D.empty},optionStyle:k,selectedOptionStyle:A,optionTextStyle:q,selectedOptionTextStyle:z,searchSelectionColor:(0,_FieldBase.resolveVariantColors)(G,W).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});var _default=exports.default=Select;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.StatTile=exports.DEFAULT_STAT_TILE_LABELS=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Card/index.js"),_index4=require("../IconBadge/index.js"),_index5=require("../Skeleton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_STAT_TILE_LABELS=exports.DEFAULT_STAT_TILE_LABELS=Object.freeze({trendUp:"up",trendDown:"down",trendFlat:"no change"}),isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_SIGN={up:"+",down:"-",flat:""},percentText=e=>(0,_mobileCore.formatPercent)(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=(e,t)=>{const n=[{up:t.trendUp,down:t.trendDown,flat:t.trendFlat}[e.direction]];return"flat"!==e.direction&&n.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&n.push(e.period),n.join(" ")},StatTile=exports.StatTile=(0,_react.forwardRef)((e,t)=>{const{label:n,value:i,icon:r,iconVariant:a,tone:s="primary",caption:l,trend:o,sparkline:d,onPress:x,loading:c=!1,accessibilityLabel:u,labels:_,style:p,testID:m}=e,j=(0,_index.useTheme)();(0,_warnInvalidValue.warnInvalidValue)("StatTile","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("StatTile","trend.direction",o?.direction,["up","down","flat"]),(0,_warnInvalidValue.warnInvalidValue)("StatTile","trend.goodWhen",o?.goodWhen,["up","down"]);const T=(0,_react.useMemo)(()=>({...DEFAULT_STAT_TILE_LABELS,..._}),[_]),v=o?`, ${trendSpoken(o,T)}`:"",h=isText(n)?`${n}, `:"",w=u??(isText(i)?`${h}${i}${v}`:void 0),y=!!o&&o.direction===(o.goodWhen??"up"),f=o&&"flat"!==o.direction?y?"success":"danger":"secondary",S="secondary"===f?j.colors["text-muted"]:j.colors[`${f}-text`];return c?(0,_jsxRuntime.jsx)(_index3.Card,{ref:t,variant:"outline",style:p,testID:m,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,{columnGap:j.space.md}],children:[void 0===r?null:(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"circle",width:40,height:40}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"text",width:"50%",height:12}),(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:j.space.xs}})]})]})}):(0,_jsxRuntime.jsx)(_index3.Card,{ref:t,variant:"outline",onPress:x,accessibilityLabel:w,style:p,testID:m,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,{columnGap:j.space.md}],children:[void 0===r?null:(0,_jsxRuntime.jsx)(_index4.IconBadge,{icon:r,iconVariant:a,tone:s}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:n}),isText(i)?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"h3",numberOfLines:1,children:i}):i,o?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.trend,{columnGap:j.space.xxs}],testID:m?`${m}-trend`:void 0,children:[(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:TREND_ICON[o.direction],size:"xs",color:S}),(0,_jsxRuntime.jsxs)(_index6.Text,{variant:"caption",color:f,numberOfLines:2,style:styles.text,children:[trendFigure(o),o.period?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"tertiary",children:` ${o.period}`}):null]})]}):null,null==l||""===l?null:isText(l)?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:l}):l,null==d?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:j.space.sm},children:d})]})]})})});StatTile.displayName="StatTile";const styles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});var _default=exports.default=StatTile;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.StatTile=exports.DEFAULT_STAT_TILE_LABELS=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Card/index.js"),_index4=require("../IconBadge/index.js"),_index5=require("../Skeleton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_STAT_TILE_LABELS=exports.DEFAULT_STAT_TILE_LABELS=Object.freeze({trendUp:"up",trendDown:"down",trendFlat:"no change"}),isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_SIGN={up:"+",down:"-",flat:""},percentText=e=>(0,_mobileCore.formatPercent)(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=(e,t)=>{const i=[{up:t.trendUp,down:t.trendDown,flat:t.trendFlat}[e.direction]];return"flat"!==e.direction&&i.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&i.push(e.period),i.join(" ")},StatTile=exports.StatTile=(0,_react.forwardRef)((e,t)=>{const{label:i,value:n,icon:r,iconVariant:a,tone:s="primary",caption:l,trend:o,sparkline:d,onPress:c,loading:x=!1,accessibilityLabel:u,labels:_,style:p,testID:m}=e,j=(0,_index.useTheme)();(0,_warnInvalidValue.warnInvalidValue)("StatTile","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("StatTile","trend.direction",o?.direction,["up","down","flat"]),(0,_warnInvalidValue.warnInvalidValue)("StatTile","trend.goodWhen",o?.goodWhen,["up","down"]);const T=(0,_react.useMemo)(()=>({...DEFAULT_STAT_TILE_LABELS,..._}),[_]),h=o?`, ${trendSpoken(o,T)}`:"",v=isText(i)?`${i}, `:"",w=u??(isText(n)?`${v}${n}${h}`:void 0),y=!!o&&o.direction===(o.goodWhen??"up"),f=o&&"flat"!==o.direction?y?"success":"danger":"secondary",S="secondary"===f?j.colors["text-muted"]:j.colors[`${f}-text`];return x?(0,_jsxRuntime.jsx)(_index3.Card,{ref:t,variant:"outline",style:p,testID:m,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,{columnGap:j.space.md}],children:[void 0===r?null:(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"circle",width:40,height:40}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"text",width:"50%",height:12}),(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:j.space.xs}})]})]})}):(0,_jsxRuntime.jsx)(_index3.Card,{ref:t,variant:"outline",onPress:c,accessibilityLabel:w,style:p,testID:m,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,{columnGap:j.space.md}],children:[void 0===r?null:(0,_jsxRuntime.jsx)(_index4.IconBadge,{icon:r,iconVariant:a,tone:s}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:i}),isText(n)?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"h3",numberOfLines:1,children:n}):n,o?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.trend,{columnGap:j.space.xxs}],testID:m?`${m}-trend`:void 0,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:TREND_ICON[o.direction],size:"xs",color:S})}),(0,_jsxRuntime.jsxs)(_index6.Text,{variant:"caption",color:f,numberOfLines:2,style:styles.text,children:[trendFigure(o),o.period?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"tertiary",children:` ${o.period}`}):null]})]}):null,null==l||""===l?null:isText(l)?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:l}):l,null==d?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:j.space.sm},children:d})]})]})})});StatTile.displayName="StatTile";const styles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});var _default=exports.default=StatTile;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Swipeable=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,n,i=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(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((a=i&&Object.getOwnPropertyDescriptor(e,n))&&(a.get||a.set)?i(r,n,a):r[n]=e[n]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:n,threshold:i,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:c,disabled:o=!1,haptic:l,containerStyle:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:v}=e,h=(0,_index.useTheme)(),p=i??80,w=r??200,S=(0,_react.useMemo)(()=>buildStyles(h),[h]),b=(0,_react.useMemo)(()=>buildActionStyles(h),[h]),f=!!a&&a.length>0,N=!!n&&n.length>0,R=_reactNative.Dimensions.get("window").width,x=f?p*(a?.length??0):0,g=N?p*(n?.length??0):0,y=(0,_reactNativeReanimated.useSharedValue)(0),I=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(y),(0,_reactNativeReanimated.cancelAnimation)(I)},[y,I]);const O=(0,_react.useCallback)(e=>{j.current!==e&&(j.current=e,s?.(e))},[s]),C=(0,_react.useCallback)(()=>{null!==j.current&&(j.current=null,c?.())},[c]),A=(0,_react.useCallback)(e=>{const t="left"===e?a:n,i=t?.[0];i&&(!1!==l&&(0,_index2.triggerHaptic)("notificationSuccess"),i.onPress(),y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),j.current=null,c?.())},[a,n,y,c,l]),G=(0,_react.useCallback)(()=>{y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),C()},[y,C]),P=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(l,"selection");t&&(0,_index2.triggerHaptic)(t),e.onPress(),G()},[G,l]),k=(0,_react.useMemo)(()=>{const e=x,t=g,a=w,n=-w,i=R,r=-R,s=p,c=f,l=N;return _reactNativeGestureHandler.Gesture.Pan().enabled(!o).withTestId(v?`${v}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";I.value=y.value}).onUpdate(a=>{"worklet";const n=I.value+a.translationX;y.value=n>0&&!c||n<0&&!l?0:n>e&&c?e+.35*(n-e):n<-t&&l?.35*(n+t)-t:n}).onEnd(()=>{"worklet";const o=y.value;return c&&o>=a?(y.value=(0,_reactNativeReanimated.withSpring)(i,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("left")):l&&o<=n?(y.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("right")):c&&o>=s?(y.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("left")):l&&o<=-s?(y.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("right")):(y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(C)())})},[o,I,A,w,f,N,x,C,O,g,R,p,y,v]),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:y.value}]}),[y]),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:x>0?Math.min(1,Math.max(0,y.value/x)):0}),[x,y]),V=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:g>0?Math.min(1,Math.max(0,-y.value/g)):0}),[g,y]),q=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>{e.push({name:t.key,label:t.label})}),n?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[a,n]),M=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,i=[...a??[],...n??[]].find(e=>e.key===t);i&&(!1!==l&&(0,_index2.triggerHaptic)("selection"),i.onPress())},[a,n,l]);return f||N?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[S.root,u],testID:v,accessibilityLabel:m,accessibilityActions:q,onAccessibilityAction:M,children:[f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsLeft,{width:x},_,F],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,N?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsRight,{width:g},_,V],pointerEvents:"box-none",children:n?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:k,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.content,d,T],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:v,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:n,onPress:i})=>{(0,_warnInvalidValue.warnInvalidValue)("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),c=(0,_slotIcon.renderSlotIcon)(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>i(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:n,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,children:c}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:[a.label,{color:toneToOnColor(t,r)}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>_reactNative.StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>_reactNative.StyleSheet.create({root:{position:"relative",overflow:"hidden"},content:{backgroundColor:"transparent"},actionsRow:{position:"absolute",top:0,bottom:0,flexDirection:"row"},actionsLeft:{left:0},actionsRight:{right:0,justifyContent:"flex-end"}});var _default=exports.default=Swipeable;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Swipeable=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,n,i=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(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((a=i&&Object.getOwnPropertyDescriptor(e,n))&&(a.get||a.set)?i(r,n,a):r[n]=e[n]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:n,threshold:i,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:c,disabled:o=!1,haptic:l,containerStyle:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:v}=e,h=(0,_index.useTheme)(),p=i??80,w=r??200,b=(0,_react.useMemo)(()=>buildStyles(h),[h]),S=(0,_react.useMemo)(()=>buildActionStyles(h),[h]),f=!!a&&a.length>0,N=!!n&&n.length>0,R=_reactNative.Dimensions.get("window").width,x=f?p*(a?.length??0):0,y=N?p*(n?.length??0):0,g=(0,_reactNativeReanimated.useSharedValue)(0),I=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(g),(0,_reactNativeReanimated.cancelAnimation)(I)},[g,I]);const O=(0,_react.useCallback)(e=>{j.current!==e&&(j.current=e,s?.(e))},[s]),C=(0,_react.useCallback)(()=>{null!==j.current&&(j.current=null,c?.())},[c]),A=(0,_react.useCallback)(e=>{const t="left"===e?a:n,i=t?.[0];i&&(!1!==l&&(0,_index2.triggerHaptic)("notificationSuccess"),i.onPress(),g.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),j.current=null,c?.())},[a,n,g,c,l]),G=(0,_react.useCallback)(()=>{g.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),C()},[g,C]),P=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(l,"selection");t&&(0,_index2.triggerHaptic)(t),e.onPress(),G()},[G,l]),k=(0,_react.useMemo)(()=>{const e=x,t=y,a=w,n=-w,i=R,r=-R,s=p,c=f,l=N;return _reactNativeGestureHandler.Gesture.Pan().enabled(!o).withTestId(v?`${v}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";I.value=g.value}).onUpdate(a=>{"worklet";const n=I.value+a.translationX;g.value=n>0&&!c||n<0&&!l?0:n>e&&c?e+.35*(n-e):n<-t&&l?.35*(n+t)-t:n}).onEnd(()=>{"worklet";const o=g.value;return c&&o>=a?(g.value=(0,_reactNativeReanimated.withSpring)(i,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("left")):l&&o<=n?(g.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("right")):c&&o>=s?(g.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("left")):l&&o<=-s?(g.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("right")):(g.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(C)())})},[o,I,A,w,f,N,x,C,O,y,R,p,g,v]),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:g.value}]}),[g]),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:x>0?Math.min(1,Math.max(0,g.value/x)):0}),[x,g]),V=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:y>0?Math.min(1,Math.max(0,-g.value/y)):0}),[y,g]),q=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>{e.push({name:t.key,label:t.label})}),n?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[a,n]),E=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,i=[...a??[],...n??[]].find(e=>e.key===t);i&&(!1!==l&&(0,_index2.triggerHaptic)("selection"),i.onPress())},[a,n,l]);return f||N?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[b.root,u],testID:v,accessibilityLabel:m,accessibilityActions:q,onAccessibilityAction:E,children:[f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[b.actionsRow,b.actionsLeft,{width:x},_,F],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:S,width:p,onPress:P},e.key))}):null,N?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[b.actionsRow,b.actionsRight,{width:y},_,V],pointerEvents:"box-none",children:n?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:S,width:p,onPress:P},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:k,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[b.content,d,T],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:v,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:n,onPress:i})=>{(0,_warnInvalidValue.warnInvalidValue)("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),c=(0,_slotIcon.renderSlotIcon)(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>i(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:n,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:c}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:[a.label,{color:toneToOnColor(t,r)}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>_reactNative.StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>_reactNative.StyleSheet.create({root:{position:"relative",overflow:"hidden"},content:{backgroundColor:"transparent"},actionsRow:{position:"absolute",top:0,bottom:0,flexDirection:"row"},actionsLeft:{left:0},actionsRight:{right:0,justifyContent:"flex-end"}});var _default=exports.default=Swipeable;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Tabs=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Badge/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const Tabs=exports.Tabs=(0,_react.forwardRef)((e,t)=>{const{tabs:i,activeKey:a,onChange:r,variant:n="underline",radius:s,size:l="md",scrollable:o=!1,align:d="left",style:c,tabStyle:u,tabLabelStyle:m,tabIconStyle:b,tabBadgeStyle:p,dividerStyle:_,indicatorStyle:x,progress:g,pages:h,haptic:v,accessibilityLabel:f,testID:y}=e;(0,_warnInvalidValue.warnInvalidValue)("Tabs","variant",e.variant,["underline","pills","segmented"]),(0,_warnInvalidValue.warnInvalidValue)("Tabs","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Tabs","align",e.align,["left","center"]);const j=(0,_index.useTheme)(),w=(0,_react.useMemo)(()=>buildStyles(j),[j]),S=j.components.tabs,R=(0,_react.useMemo)(()=>(0,_index.resolveTabsSize)(j,l),[j,l]),I=o?R["scrollable-padding-x"]:R["padding-x"],V=R["padding-y"],k=R.text,N=j.space[S["icon-gap"]],T=R.icon,q=S["underline-height"],z=j.space[S["pill-inset"]],C=S["disabled-opacity"],E=j.space[S["badge-gap"]],L="segmented"===n,F=(0,_react.useMemo)(()=>(0,_index.resolveSegmentedControlSize)(j,l),[j,l]),M=j.space[S["track-padding"]],A="number"==typeof s?s:s?j.radius[s]:void 0,D=A??j.radius.md,H=void 0===A?j.radius.sm:Math.max(A-M,0),B=A??j.radius.pill,P=A??j.radius.none,O=j.colors["bg-muted"],W=(0,_SquircleFill.useSquircle)(L,D),[$,U]=(0,_react.useState)({}),K=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,X=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,[G,J]=(0,_react.useState)(0),Q=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,Y=(0,_react.useRef)(null),Z=(0,_react.useRef)(0),ee=$[a],te=Math.max(0,i.findIndex(e=>e.key===a)),ie=(0,_react.useMemo)(()=>h&&G>0?Q.interpolate({inputRange:[0,G],outputRange:[0,1]}):void 0,[h,G,Q])??g,ae=i.every(e=>void 0!==$[e.key]),re=void 0!==ie&&ae&&i.length>1,ne=(0,_react.useMemo)(()=>re&&ie?ie.interpolate({inputRange:i.map((e,t)=>t),outputRange:i.map(e=>$[e.key].x),extrapolate:"clamp"}):null,[re,ie,i,$]),se=(0,_react.useMemo)(()=>re&&ie?ie.interpolate({inputRange:i.map((e,t)=>t),outputRange:i.map(e=>$[e.key].width),extrapolate:"clamp"}):null,[re,ie,i,$]),le=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!ee)return;if(re)return;const e=null!==le.current&&le.current!==a;if(le.current=a,!e)return K.setValue(ee.x),void X.setValue(ee.width);const t=j.motion.spring.snappy,i=_reactNative.Animated.parallel([_reactNative.Animated.spring(K,{toValue:ee.x,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!1}),_reactNative.Animated.spring(X,{toValue:ee.width,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!1})]);return i.start(),()=>i.stop()},[ee,a,K,X,j.motion.spring.snappy,re]),(0,_react.useEffect)(()=>{h&&0!==G&&Z.current!==te&&(Z.current=te,Y.current?.scrollTo({x:te*G,animated:!0}))},[h,G,te]);const oe=h?.length;(0,_react.useEffect)(()=>{__DEV__&&void 0!==oe&&oe!==i.length&&_mobileCore.Logger.warn(`[@webority/mobile-ui] Tabs pages has ${oe} entries for ${i.length} tabs; each tab needs one page.`)},[oe,i.length]);const de=(0,_react.useCallback)(e=>t=>{const{x:i,width:a}=t.nativeEvent.layout;U(t=>{const r=t[e];return r&&r.x===i&&r.width===a?t:{...t,[e]:{x:i,width:a}}})},[]),ce=(0,_react.useCallback)(e=>{if(e.disabled)return;if(e.key===a)return;const t=(0,_index2.resolveHaptic)(v,"selection");t&&(0,_index2.triggerHaptic)(t),r(e.key)},[a,r,v]),ue="pills"===n,me=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[L?w.indicatorThumb:ue?w.indicatorPill:w.indicatorUnderline,L?null:ue?{top:z,bottom:z}:{height:q},{width:se??X,transform:[{translateX:ne??K}],backgroundColor:L?j.colors.surface:ue?j.colors["primary-soft"]:j.colors.primary,borderRadius:L?H:ue?B:P,..._corners.smoothCorners},x]}),renderTabs=()=>i.map(e=>{const t=e.key===a,i=!0===e.disabled,r=t?j.colors.primary:j.colors["text-subtle"],n=(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:T,focused:t,disabled:i});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>ce(e),onLayout:de(e.key),disabled:i,accessibilityRole:"tab",accessibilityLabel:e.label,accessibilityState:{selected:t,disabled:i},"aria-selected":t,"aria-disabled":i,android_ripple:L?void 0:{color:j.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[w.tab,o?null:w.tabFlex,L?{paddingHorizontal:F["padding-x"],height:F.height-2*M}:{paddingHorizontal:I,paddingVertical:V},{opacity:i?C:e&&L&&!t?.7:1,backgroundColor:e&&!L?j.colors["surface-pressed"]:"transparent"},u],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tabIcon,{marginRight:N},b],children:n}):null,(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:t?"semibold":"medium",color:t?"brand":"tertiary",style:[w.tabLabel,{fontSize:L?F.text:k},m],numberOfLines:1,children:e.label}),void 0!==e.badge&&null!==e.badge?(0,_jsxRuntime.jsx)(_index3.Badge,{value:String(e.badge),tone:"primary",fill:"soft",accessible:!1,style:{marginLeft:E},badgeStyle:[w.tabBadge,p]}):null]},e.key)}),be={flexDirection:"row",alignItems:"stretch",justifyContent:o?"flex-start":"center"===d?"center":"flex-start",position:"relative",overflow:"hidden"},pe=L?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[me,renderTabs()]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[renderTabs(),me]}),xe=(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[w.container,{borderBottomColor:j.colors["border-subtle"],borderBottomWidth:"underline"===n?_reactNative.StyleSheet.hairlineWidth:0},"underline"===n?_:null,L?{padding:M,borderRadius:D,..._corners.smoothCorners,backgroundColor:W.active?"transparent":O}:null,c],onLayout:W.onLayout,accessibilityRole:"tablist",accessibilityLabel:f,testID:y,children:[W.active&&W.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:W.size.width,height:W.size.height,radius:D,fill:O}):null,o?(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:[be],keyboardShouldPersistTaps:"handled",children:pe}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:be,children:pe})]});return h?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.root,children:[xe,(0,_jsxRuntime.jsx)(_reactNative.Animated.ScrollView,{ref:Y,horizontal:!0,pagingEnabled:!0,showsHorizontalScrollIndicator:!1,scrollEventThrottle:16,onLayout:e=>J(Math.round(e.nativeEvent.layout.width)),onScroll:_reactNative.Animated.event([{nativeEvent:{contentOffset:{x:Q}}}],{useNativeDriver:!1}),onMomentumScrollEnd:e=>{if(0===G)return;const t=Math.round(e.nativeEvent.contentOffset.x/G),n=i[t];n?.disabled?Y.current?.scrollTo({x:te*G,animated:!0}):(Z.current=t,n&&n.key!==a&&r(n.key))},style:w.pager,testID:y?`${y}-pages`:void 0,children:i.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:G},accessibilityElementsHidden:t!==te,importantForAccessibility:t===te?"auto":"no-hide-descendants",children:h[t]},e.key))})]}):xe});Tabs.displayName="Tabs";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},pager:{flex:1},container:{width:"100%",position:"relative"},tab:{flexDirection:"row",alignItems:"center",justifyContent:"center"},tabFlex:{flex:1},tabIcon:{},tabLabel:{includeFontPadding:!1,flexShrink:1},tabBadge:{minWidth:18,minHeight:0},indicatorUnderline:{position:"absolute",left:0,bottom:0},indicatorPill:{position:"absolute",left:0,zIndex:-1},indicatorThumb:{position:"absolute",left:0,top:0,bottom:0}});var _default=exports.default=Tabs;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Tabs=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Badge/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const Tabs=exports.Tabs=(0,_react.forwardRef)((e,t)=>{const{tabs:i,activeKey:a,onChange:r,variant:n="underline",radius:s,size:l="md",scrollable:o=!1,align:d="left",style:c,tabStyle:u,tabLabelStyle:m,tabIconStyle:b,tabBadgeStyle:p,dividerStyle:_,indicatorStyle:x,progress:g,pages:h,haptic:v,accessibilityLabel:y,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("Tabs","variant",e.variant,["underline","pills","segmented"]),(0,_warnInvalidValue.warnInvalidValue)("Tabs","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Tabs","align",e.align,["left","center"]);const j=(0,_index.useTheme)(),w=(0,_react.useMemo)(()=>buildStyles(j),[j]),S=j.components.tabs,R=(0,_react.useMemo)(()=>(0,_index.resolveTabsSize)(j,l),[j,l]),I=o?R["scrollable-padding-x"]:R["padding-x"],V=R["padding-y"],k=R.text,N=j.space[S["icon-gap"]],T=R.icon,q=S["underline-height"],z=j.space[S["pill-inset"]],C=S["disabled-opacity"],E=j.space[S["badge-gap"]],F="segmented"===n,L=(0,_react.useMemo)(()=>(0,_index.resolveSegmentedControlSize)(j,l),[j,l]),A=j.space[S["track-padding"]],M="number"==typeof s?s:s?j.radius[s]:void 0,D=M??j.radius.md,H=void 0===M?j.radius.sm:Math.max(M-A,0),B=M??j.radius.pill,P=M??j.radius.none,O=j.colors["bg-muted"],W=(0,_SquircleFill.useSquircle)(F,D),[$,U]=(0,_react.useState)({}),K=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,X=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,[G,J]=(0,_react.useState)(0),Q=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,Y=(0,_react.useRef)(null),Z=(0,_react.useRef)(0),ee=$[a],te=Math.max(0,i.findIndex(e=>e.key===a)),ie=(0,_react.useMemo)(()=>h&&G>0?Q.interpolate({inputRange:[0,G],outputRange:[0,1]}):void 0,[h,G,Q])??g,ae=i.every(e=>void 0!==$[e.key]),re=void 0!==ie&&ae&&i.length>1,ne=(0,_react.useMemo)(()=>re&&ie?ie.interpolate({inputRange:i.map((e,t)=>t),outputRange:i.map(e=>$[e.key].x),extrapolate:"clamp"}):null,[re,ie,i,$]),se=(0,_react.useMemo)(()=>re&&ie?ie.interpolate({inputRange:i.map((e,t)=>t),outputRange:i.map(e=>$[e.key].width),extrapolate:"clamp"}):null,[re,ie,i,$]),le=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!ee)return;if(re)return;const e=null!==le.current&&le.current!==a;if(le.current=a,!e)return K.setValue(ee.x),void X.setValue(ee.width);const t=j.motion.spring.snappy,i=_reactNative.Animated.parallel([_reactNative.Animated.spring(K,{toValue:ee.x,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!1}),_reactNative.Animated.spring(X,{toValue:ee.width,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!1})]);return i.start(),()=>i.stop()},[ee,a,K,X,j.motion.spring.snappy,re]),(0,_react.useEffect)(()=>{h&&0!==G&&Z.current!==te&&(Z.current=te,Y.current?.scrollTo({x:te*G,animated:!0}))},[h,G,te]);const oe=h?.length;(0,_react.useEffect)(()=>{__DEV__&&void 0!==oe&&oe!==i.length&&_mobileCore.Logger.warn(`[@webority/mobile-ui] Tabs pages has ${oe} entries for ${i.length} tabs; each tab needs one page.`)},[oe,i.length]);const de=(0,_react.useCallback)(e=>t=>{const{x:i,width:a}=t.nativeEvent.layout;U(t=>{const r=t[e];return r&&r.x===i&&r.width===a?t:{...t,[e]:{x:i,width:a}}})},[]),ce=(0,_react.useCallback)(e=>{if(e.disabled)return;if(e.key===a)return;const t=(0,_index2.resolveHaptic)(v,"selection");t&&(0,_index2.triggerHaptic)(t),r(e.key)},[a,r,v]),ue="pills"===n,me=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[F?w.indicatorThumb:ue?w.indicatorPill:w.indicatorUnderline,F?null:ue?{top:z,bottom:z}:{height:q},{width:se??X,transform:[{translateX:ne??K}],backgroundColor:F?j.colors.surface:ue?j.colors["primary-soft"]:j.colors.primary,borderRadius:F?H:ue?B:P,..._corners.smoothCorners},x]}),renderTabs=()=>i.map(e=>{const t=e.key===a,i=!0===e.disabled,r=t?j.colors.primary:j.colors["text-subtle"],n=(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:T,focused:t,disabled:i});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>ce(e),onLayout:de(e.key),disabled:i,accessibilityRole:"tab",accessibilityLabel:e.label,accessibilityState:{selected:t,disabled:i},"aria-selected":t,"aria-disabled":i,android_ripple:F?void 0:{color:j.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[w.tab,o?null:w.tabFlex,F?{paddingHorizontal:L["padding-x"],height:L.height-2*A}:{paddingHorizontal:I,paddingVertical:V},{opacity:i?C:e&&F&&!t?.7:1,backgroundColor:e&&!F?j.colors["surface-pressed"]:"transparent"},u],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tabIcon,{marginRight:N},b],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:n}):null,(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:t?"semibold":"medium",color:t?"brand":"tertiary",style:[w.tabLabel,{fontSize:F?L.text:k},m],numberOfLines:1,children:e.label}),void 0!==e.badge&&null!==e.badge?(0,_jsxRuntime.jsx)(_index3.Badge,{value:String(e.badge),tone:"primary",fill:"soft",accessible:!1,style:{marginLeft:E},badgeStyle:[w.tabBadge,p]}):null]},e.key)}),be={flexDirection:"row",alignItems:"stretch",justifyContent:o?"flex-start":"center"===d?"center":"flex-start",position:"relative",overflow:"hidden"},pe=F?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[me,renderTabs()]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[renderTabs(),me]}),xe=(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[w.container,{borderBottomColor:j.colors["border-subtle"],borderBottomWidth:"underline"===n?_reactNative.StyleSheet.hairlineWidth:0},"underline"===n?_:null,F?{padding:A,borderRadius:D,..._corners.smoothCorners,backgroundColor:W.active?"transparent":O}:null,c],onLayout:W.onLayout,accessibilityRole:"tablist",accessibilityLabel:y,testID:f,children:[W.active&&W.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:W.size.width,height:W.size.height,radius:D,fill:O}):null,o?(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:[be],keyboardShouldPersistTaps:"handled",children:pe}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:be,children:pe})]});return h?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.root,children:[xe,(0,_jsxRuntime.jsx)(_reactNative.Animated.ScrollView,{ref:Y,horizontal:!0,pagingEnabled:!0,showsHorizontalScrollIndicator:!1,scrollEventThrottle:16,onLayout:e=>J(Math.round(e.nativeEvent.layout.width)),onScroll:_reactNative.Animated.event([{nativeEvent:{contentOffset:{x:Q}}}],{useNativeDriver:!1}),onMomentumScrollEnd:e=>{if(0===G)return;const t=Math.round(e.nativeEvent.contentOffset.x/G),n=i[t];n?.disabled?Y.current?.scrollTo({x:te*G,animated:!0}):(Z.current=t,n&&n.key!==a&&r(n.key))},style:w.pager,testID:f?`${f}-pages`:void 0,children:i.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:G},accessibilityElementsHidden:t!==te,importantForAccessibility:t===te?"auto":"no-hide-descendants",children:h[t]},e.key))})]}):xe});Tabs.displayName="Tabs";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},pager:{flex:1},container:{width:"100%",position:"relative"},tab:{flexDirection:"row",alignItems:"center",justifyContent:"center"},tabFlex:{flex:1},tabIcon:{},tabLabel:{includeFontPadding:!1,flexShrink:1},tabBadge:{minWidth:18,minHeight:0},indicatorUnderline:{position:"absolute",left:0,bottom:0},indicatorPill:{position:"absolute",left:0,zIndex:-1},indicatorThumb:{position:"absolute",left:0,top:0,bottom:0}});var _default=exports.default=Tabs;
@@ -1 +1 @@
1
- "use strict";import React from"react";import{AppIcon}from"./AppIcon.js";import{jsx as _jsx}from"react/jsx-runtime";const isIconRef=o=>"object"==typeof o&&null!==o&&!React.isValidElement(o)&&"name"in o&&"string"==typeof o.name;export function renderSlotIcon(o,n,e){return null==o||!1===o?null:"string"==typeof o?_jsx(AppIcon,{name:o,variant:e,size:n.size,color:n.color}):"function"==typeof o?o(n):isIconRef(o)?_jsx(AppIcon,{name:o.name,variant:o.variant??e,size:n.size,color:n.color}):o}
1
+ "use strict";import React from"react";import{View}from"react-native";import{AppIcon}from"./AppIcon.js";import{jsx as _jsx}from"react/jsx-runtime";const isIconRef=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"name"in e&&"string"==typeof e.name;export function renderSlotIcon(e,o,n){return null==e||!1===e?null:"string"==typeof e?_jsx(AppIcon,{name:e,variant:n,size:o.size,color:o.color}):"function"==typeof e?e(o):isIconRef(e)?_jsx(AppIcon,{name:e.name,variant:e.variant??n,size:o.size,color:o.color}):e}export const isDecorativeSlotIcon=e=>"string"==typeof e||isIconRef(e);export function slotIconView(e,o){return isDecorativeSlotIcon(e)?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:o}):_jsx(View,{children:o})}
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"});const Banner=forwardRef((e,t)=>{const{title:r,message:o,tone:n="neutral",variant:s="bar",icon:i,actions:a,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:p=!1,accessibilityRole:g="alert",accessibilityLabel:h,labels:y,style:x,containerStyle:b,iconCircleStyle:f,tintBarStyle:w,closeButtonStyle:j,actionButtonStyle:S,testID:B}=e;warnInvalidValue("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Banner","variant",e.variant,["bar","wash","tint"]),warnInvalidValue("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const v=useTheme(),k=usePresenceMotion(),C=useMemo(()=>buildStyles(v),[v]),_=useMemo(()=>tintFor(v,n),[v,n]),I=useMemo(()=>({...DEFAULT_BANNER_LABELS,...y}),[y]),[R,V]=k.range(-20,0),A=useRef(createAnimatedValue(m&&u?R:0)).current,T=useRef(createAnimatedValue(m&&u?0:u?1:0)).current,[L,D]=useState(u),H=useRef(!0);if(useEffect(()=>{if(H.current&&(H.current=!1,!m))return;let e;return u?(D(!0),e=Animated.parallel([Animated.timing(A,{toValue:V,duration:v.motion.duration.default,useNativeDriver:!0}),Animated.timing(T,{toValue:1,duration:k.duration("default"),useNativeDriver:!0})]),e.start()):L&&(e=Animated.parallel([Animated.timing(A,{toValue:R,duration:v.motion.duration.fast,useNativeDriver:!0}),Animated.timing(T,{toValue:0,duration:k.duration("fast"),useNativeDriver:!0})]),e.start(()=>{D(!1)})),()=>e?.stop()},[u]),!L)return null;const E=r??" ",M="string"==typeof o?o??" ":"",N="wash"===s,z="bar"!==s,P="alert"===g?"danger"===n?"assertive":"polite":"none",W=_jsxs(Animated.View,{ref:t,accessibilityRole:g,accessibilityLiveRegion:P,accessibilityLabel:h,testID:B,style:[C.container,{backgroundColor:z?_.soft:v.colors["bg-subtle"],borderRadius:N?v.radius.sm:v.radius.md,...smoothCorners,padding:v.space.md,opacity:T,transform:[{translateY:A}]},b,x],children:[!N&&v.components.banner["tint-bar-width"]>0?_jsx(View,{style:[C.tintBar,{backgroundColor:_.bar},w]}):null,_jsxs(View,{style:[C.row,void 0===r&&C.rowCentred],children:[!1===i?null:i?_jsx(View,{style:C.iconWrap,children:renderSlotIcon(i,{color:_.ink,size:v.text.xl.size,disabled:!1})}):_jsx(IconBadge,{dimension:ICON_CIRCLE_SIZE,color:_.bar,icon:_jsx(Text,{variant:"body",weight:"bold",accessible:!1,style:[C.iconGlyph,{color:_.ink}],children:_.glyph}),style:[C.iconCircle,f]}),_jsxs(View,{style:C.textBlock,children:[r||p?_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...N?{color:_.ink}:null},children:E}):null,"string"==typeof o||p?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?v.space.xxs:0},children:M||" "}):_jsx(View,{style:{marginTop:r?v.space.xxs:0},children:o})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:I.dismiss,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),c?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[C.closeBtn,{backgroundColor:e?v.colors["surface-pressed"]:"transparent"},j],children:_jsx(Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),a&&a.length>0?_jsx(View,{style:C.actionsRow,children:a.map((e,t)=>{warnInvalidValue("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Banner","action.variant",e.variant,["solid","outline","ghost"]),warnInvalidValue("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",o=e.variant??"ghost",n="primary"===r?_.glyphColor:"neutral"===r?v.colors["text-muted"]:v.colors[r],s="primary"===r?_.ink:"neutral"===r?v.colors["text-muted"]:v.colors[`${r}-text`],i="primary"===r?_.on:"neutral"===r?v.colors["on-neutral-strong"]:v.colors[`on-${r}`],a="solid"===o;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=resolveHaptic(d,"selection");t&&triggerHaptic(t),e.onPress()},style:({pressed:t})=>[C.actionBtn,"md"===e.size&&C.actionBtnMd,"outline"===o&&{borderWidth:1,borderColor:s},{backgroundColor:a?n:t?v.colors["surface-pressed"]:"transparent",opacity:a&&t?.85:1},S],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:a?i:s},children:e.label})},`${e.label}-${t}`)})}):null]});return p?_jsx(BannerSkeleton,{...e}):W});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:o,style:n})=>{const s=useTheme(),i=!1!==r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,...smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},o,n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:s.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.sm},children:t.map((e,t)=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"});const Banner=forwardRef((e,t)=>{const{title:r,message:o,tone:n="neutral",variant:s="bar",icon:i,actions:a,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:p=!1,accessibilityRole:g="alert",accessibilityLabel:h,labels:y,style:b,containerStyle:x,iconCircleStyle:f,tintBarStyle:w,closeButtonStyle:j,actionButtonStyle:S,testID:B}=e;warnInvalidValue("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Banner","variant",e.variant,["bar","wash","tint"]),warnInvalidValue("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const v=useTheme(),k=usePresenceMotion(),C=useMemo(()=>buildStyles(v),[v]),_=useMemo(()=>tintFor(v,n),[v,n]),I=useMemo(()=>({...DEFAULT_BANNER_LABELS,...y}),[y]),[R,V]=k.range(-20,0),A=useRef(createAnimatedValue(m&&u?R:0)).current,T=useRef(createAnimatedValue(m&&u?0:u?1:0)).current,[L,D]=useState(u),H=useRef(!0);if(useEffect(()=>{if(H.current&&(H.current=!1,!m))return;let e;return u?(D(!0),e=Animated.parallel([Animated.timing(A,{toValue:V,duration:v.motion.duration.default,useNativeDriver:!0}),Animated.timing(T,{toValue:1,duration:k.duration("default"),useNativeDriver:!0})]),e.start()):L&&(e=Animated.parallel([Animated.timing(A,{toValue:R,duration:v.motion.duration.fast,useNativeDriver:!0}),Animated.timing(T,{toValue:0,duration:k.duration("fast"),useNativeDriver:!0})]),e.start(()=>{D(!1)})),()=>e?.stop()},[u]),!L)return null;const E=r??" ",M="string"==typeof o?o??" ":"",N="wash"===s,z="bar"!==s,P="alert"===g?"danger"===n?"assertive":"polite":"none",W=_jsxs(Animated.View,{ref:t,accessibilityRole:g,accessibilityLiveRegion:P,accessibilityLabel:h,testID:B,style:[C.container,{backgroundColor:z?_.soft:v.colors["bg-subtle"],borderRadius:N?v.radius.sm:v.radius.md,...smoothCorners,padding:v.space.md,opacity:T,transform:[{translateY:A}]},x,b],children:[!N&&v.components.banner["tint-bar-width"]>0?_jsx(View,{style:[C.tintBar,{backgroundColor:_.bar},w]}):null,_jsxs(View,{style:[C.row,void 0===r&&C.rowCentred],children:[!1===i?null:i?_jsx(View,{style:C.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(i,{color:_.ink,size:v.text.xl.size,disabled:!1})}):_jsx(IconBadge,{dimension:ICON_CIRCLE_SIZE,color:_.bar,icon:_jsx(Text,{variant:"body",weight:"bold",accessible:!1,style:[C.iconGlyph,{color:_.ink}],children:_.glyph}),style:[C.iconCircle,f]}),_jsxs(View,{style:C.textBlock,children:[r||p?_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...N?{color:_.ink}:null},children:E}):null,"string"==typeof o||p?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?v.space.xxs:0},children:M||" "}):_jsx(View,{style:{marginTop:r?v.space.xxs:0},children:o})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:I.dismiss,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),c?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[C.closeBtn,{backgroundColor:e?v.colors["surface-pressed"]:"transparent"},j],children:_jsx(Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),a&&a.length>0?_jsx(View,{style:C.actionsRow,children:a.map((e,t)=>{warnInvalidValue("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Banner","action.variant",e.variant,["solid","outline","ghost"]),warnInvalidValue("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",o=e.variant??"ghost",n="primary"===r?_.glyphColor:"neutral"===r?v.colors["text-muted"]:v.colors[r],s="primary"===r?_.ink:"neutral"===r?v.colors["text-muted"]:v.colors[`${r}-text`],i="primary"===r?_.on:"neutral"===r?v.colors["on-neutral-strong"]:v.colors[`on-${r}`],a="solid"===o;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=resolveHaptic(d,"selection");t&&triggerHaptic(t),e.onPress()},style:({pressed:t})=>[C.actionBtn,"md"===e.size&&C.actionBtnMd,"outline"===o&&{borderWidth:1,borderColor:s},{backgroundColor:a?n:t?v.colors["surface-pressed"]:"transparent",opacity:a&&t?.85:1},S],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:a?i:s},children:e.label})},`${e.label}-${t}`)})}):null]});return p?_jsx(BannerSkeleton,{...e}):W});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:o,style:n})=>{const s=useTheme(),i=!1!==r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,...smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},o,n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:s.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.sm},children:t.map((e,t)=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,LayoutAnimation,Platform,Pressable,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/index.js";import{Badge}from"../Badge/index.js";import{Text}from"../Text/index.js";import{useScreenReaderEnabled}from"./useScreenReaderEnabled.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"});const 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=forwardRef((e,t)=>{const{tabs:i,centerAction:n,activeTab:o,onChange:a,haptic:r="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:m,marginHorizontal:h,marginVertical:g,paddingHorizontal:b,paddingVertical:f,border:x,minimizeOnScroll:y=!1,scrollDirection:_="idle",accessory:S,style:w,indicatorStyle:I,labelStyle:A,labelMaxFontScale:E,labels:R,testID:v}=e;warnInvalidValue("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),warnInvalidValue("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const T=useMemo(()=>R?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...R}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[R]),L=useTheme(),j=useSafeAreaInsets(),V=useMemo(()=>buildStyles(L),[L]),B=m??18,C=B+4+8,M=L.space.lg,D=L.space.lg,k=L.radius.xl,N=useReducedMotion(),P=useScreenReaderEnabled(y),[z,F]=React.useState(null);useEffect(()=>{null!==z&&z!==_&&F(null)},[z,_]);const H=y&&!P&&"down"===_&&null===z,[O,W]=React.useState(H);useEffect(()=>{O!==H&&(N||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),W(H))},[O,H,N]);const U="function"==typeof S?S({minimized:O}):S,$=null!=U&&!1!==U,X=O&&$,[G,Z]=React.useState(0),Y=$&&!X?G+L.space.xs:0,K="tile"===l,q="floating"===l||K,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||q||ee,ie=Math.max(0,i.findIndex(e=>e.key===o)),[ne,oe]=React.useState(0),[ae,re]=React.useState(0),se=n?Math.ceil(i.length/2):i.length,le=i.length+(n?1:0),[de,ce]=React.useState({width:0,height:0}),ue=n?.size??48,pe=void 0!==n?.gap,me=Math.max(0,n?.gap??0),he=pe?(de.width||ue)+2*me:0,ge=pe?i.length>0?Math.max(0,ne-he)/i.length:0:le>0?ne/le:0,be=pe?he:ge,fe=useRef(createAnimatedValue(ie)).current,xe=useRef({}),ye=useRef({});i.forEach(e=>{xe.current[e.key]||(xe.current[e.key]=new Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Se=ge>0?K?Math.min(ge-4,96):Math.min(ge-M,64):0,we=ge>0?(ge-Se)/2:0,Ie=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!O&&!1!==e.showLabel&&e.label.trim().length>0,Ae=i[ie],Ee=Ae&&!hasLabel(Ae)&&ae>0?ae/2:L.space.xs+(B+4)/2,Re=Ee-14-24,ve=Math.max(0,ae-4),Te=K?2:Ee-C/2,Le=useRef(ie);useEffect(()=>{if(Le.current===ie)return;Le.current=ie;const e=Animated.spring(fe,{toValue:ie,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[ie,fe]);const je=Math.max(1,i.length-1),Ve=useMemo(()=>{const e=[],t=[];for(let i=0;i<=je;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return fe.interpolate({inputRange:e,outputRange:t})},[fe,je,se,ge,be]),Be=i.map(e=>e.key).join(" "),Ce=J||Q;useEffect(()=>{const e=Be.split(" ").flatMap(e=>{const t=e===o?1:0,i=ye.current[e];return i?Ce?[Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=Animated.parallel(e);return t.start(),()=>t.stop()},[o,Be,Ce]);const popIcon=e=>{Animated.sequence([Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:!0}),Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:!0})]).start()},Me=useRef(new Animated.Value(1)).current,{colors:De}=L,ke=ee?De.primary:De.surface,Ne=ee?De["on-primary"]:De.primary,Pe=ee?De["on-primary"]:K?De["text-body"]:De["text-subtle"],ze=ee?De["on-primary"]:De["primary-soft"],Fe=ee?De.primary:J?De["on-primary"]:Ne,He=h??D,Oe=g??(q?D:0),We=Oe>0,Ue=f??L.space.sm,$e=b??(q?L.space.sm:L.space.xs),Xe=We?Ue:Math.max(Ue,j.bottom),Ge=We?Math.max(Oe,j.bottom>0?j.bottom+L.space.sm:0):0,Ze="pill"===c,Ye=q?ae+Y+2*Ue+2*StyleSheet.hairlineWidth:ae+Y+Ue+Xe,Ke=Ze?ae>0?Ye/2:L.radius.pill:c??(K?L.radius.pill:q?k:L.radius.none),qe=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&qe?Math.min(Ke,e/2):t,Je="underline"===l?Math.max($e,Ze&&0===ae?0:Ke):$e,Qe=p??"none",et="none"===Qe?void 0:L.shadow[Qe],tt=void 0===et?null:supportsBoxShadow()?{boxShadow:toBoxShadow(et)}:et,it=x?StyleSheet.hairlineWidth:0,nt=ee?De.primary:De.border,ot=n?.lift??0,at=Ue+it+Y,rt=n&&ae>0?Math.max(0,(de.height||ue)/2+ot-ae/2-at):0,st=n?_jsx(View,{style:[V.centerCell,pe?{flex:0,marginHorizontal:me}:null],pointerEvents:"box-none",children:_jsxs(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??r;!1!==e&&triggerHaptic(e),popIcon(Me),n.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:n.label,hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.centerPressable,{top:-ot},e?{opacity:.85}:null],testID:n.testID??(v?`${v}-center`:void 0),children:[n.content?_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:n.content}):_jsx(View,{style:[V.centerCircle,{width:ue,height:ue,borderRadius:L.radius.pill,...smoothCorners,backgroundColor:n.color??De.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??De["on-primary"],size:n.iconSize??24,disabled:!1})})}),(lt=n,s&&!O&&lt.label.trim().length>0?_jsx(Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:E??L.settings.maxFontSizeMultiplier??1.2,style:[V.label,{color:Pe,opacity:ee?.7:1},A],children:n.label}):null)]})},CENTER_KEY):null;var lt;const dt=$?_jsx(View,{style:X?V.accessoryInline:V.accessoryStacked,onLayout:e=>Z(e.nativeEvent.layout.height),testID:v?`${v}-accessory`:void 0,children:U}):null,ct=_jsxs(View,{style:X?[V.tabRow,V.tabRowInline]:V.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;oe(t),re(i)},children:[te&&Se>0&&(!K||ve>0)?_jsx(Animated.View,{pointerEvents:"none",style:[V.pill,{width:Se,height:K?ve:C,left:we,top:Te,backgroundColor:ze,borderRadius:K?activeBgRadius(ve,ve/2):activeBgRadius(C,L.radius.pill),...smoothCorners,transform:[{translateX:Ve}]},I]}):null,J&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[V.bubble,L.shadow.elevated,{width:48,height:48,borderRadius:L.radius.pill,...smoothCorners,left:Ie,top:Re,backgroundColor:De.primary,borderColor:De.surface,transform:[{translateX:Ve}]},I]}):null,(ut=i.map(e=>{const t=e.key===o,i=t?Ne:Pe,n=t?Fe:Pe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=xe.current[e.key],c=ye.current[e.key],u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,T),m=ee&&!t?.7:1,h=J&&t||ee?De.primary:De.surface,g=hasLabel(e),b=g&&(!Q||t),f=_jsxs(Animated.View,{style:[V.iconWrap,{width:B+4,height:B+4,opacity:m,transform:[{scale:d}]}],children:[renderSlotIcon(l,{color:n,size:B,focused:t,disabled:!1}),u?_jsx(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:h}],textStyle:V.badgeText}):null]}),x=J?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:f}):f,y=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:E??L.settings.maxFontSizeMultiplier??1.2,style:[V.label,Q?V.labelInline:null,{color:i,opacity:Q?c:m,fontWeight:t?L.weight.semibold:L.weight.normal},A],children:e.label}):null,S=_jsx(Pressable,{onPress:()=>(e=>{O&&F(_),e.key!==o&&!1!==r&&triggerHaptic(r);const t=xe.current[e.key];t&&popIcon(t),a(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:T.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.tab,K?V.tabTile:null,e?{opacity:.85}:null],testID:v?`${v}-tab-${e.key}`:void 0,children:Q?_jsxs(View,{style:[V.expandPill,{height:C,paddingHorizontal:t&&g?L.space.md:Math.max(0,(C-(B+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[V.expandFill,{borderRadius:activeBgRadius(C,C/2),...smoothCorners,backgroundColor:t?De["primary-soft"]:"transparent"},t?I:null]}),x,y]}):_jsxs(_Fragment,{children:[x,y]})},e.key);return Q?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:S},e.key):S}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[V.underline,"top"===d?V.underlineTop:V.underlineBottom,"top"===d?{top:-Ue-Y}:{bottom:-Ue},{width:ge,height:3,backgroundColor:De.primary,transform:[{translateX:Ve}]},I]}):null]});var ut;return _jsx(View,{ref:t,testID:v,accessibilityRole:"tablist",style:[V.outer,{paddingHorizontal:He,paddingTop:Math.max(Oe,rt),paddingBottom:Ge},w],children:_jsxs(View,{style:[q?V.floatingBar:V.dockedBar,X?V.barInline:null,tt,{backgroundColor:ke,borderColor:nt,borderRadius:Ke,...smoothCorners},q?{borderWidth:it,paddingHorizontal:$e,paddingVertical:Ue}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:Ue,paddingBottom:Xe}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>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,...smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,...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}});export{BottomNavigation};export default BottomNavigation;
1
+ "use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,LayoutAnimation,Platform,Pressable,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/index.js";import{Badge}from"../Badge/index.js";import{Text}from"../Text/index.js";import{useScreenReaderEnabled}from"./useScreenReaderEnabled.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"});const 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=forwardRef((e,t)=>{const{tabs:i,centerAction:n,activeTab:o,onChange:a,haptic:r="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:m,marginHorizontal:h,marginVertical:g,paddingHorizontal:b,paddingVertical:f,border:x,minimizeOnScroll:y=!1,scrollDirection:_="idle",accessory:S,style:w,indicatorStyle:I,labelStyle:A,labelMaxFontScale:E,labels:R,testID:v}=e;warnInvalidValue("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),warnInvalidValue("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const T=useMemo(()=>R?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...R}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[R]),L=useTheme(),j=useSafeAreaInsets(),V=useMemo(()=>buildStyles(L),[L]),B=m??18,C=B+4+8,M=L.space.lg,D=L.space.lg,k=L.radius.xl,N=useReducedMotion(),P=useScreenReaderEnabled(y),[z,F]=React.useState(null);useEffect(()=>{null!==z&&z!==_&&F(null)},[z,_]);const H=y&&!P&&"down"===_&&null===z,[O,W]=React.useState(H);useEffect(()=>{O!==H&&(N||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),W(H))},[O,H,N]);const U="function"==typeof S?S({minimized:O}):S,$=null!=U&&!1!==U,X=O&&$,[G,Z]=React.useState(0),Y=$&&!X?G+L.space.xs:0,K="tile"===l,q="floating"===l||K,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||q||ee,ie=Math.max(0,i.findIndex(e=>e.key===o)),[ne,oe]=React.useState(0),[ae,re]=React.useState(0),se=n?Math.ceil(i.length/2):i.length,le=i.length+(n?1:0),[de,ce]=React.useState({width:0,height:0}),ue=n?.size??48,pe=void 0!==n?.gap,me=Math.max(0,n?.gap??0),he=pe?(de.width||ue)+2*me:0,ge=pe?i.length>0?Math.max(0,ne-he)/i.length:0:le>0?ne/le:0,be=pe?he:ge,fe=useRef(createAnimatedValue(ie)).current,xe=useRef({}),ye=useRef({});i.forEach(e=>{xe.current[e.key]||(xe.current[e.key]=new Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Se=ge>0?K?Math.min(ge-4,96):Math.min(ge-M,64):0,we=ge>0?(ge-Se)/2:0,Ie=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!O&&!1!==e.showLabel&&e.label.trim().length>0,Ae=i[ie],Ee=Ae&&!hasLabel(Ae)&&ae>0?ae/2:L.space.xs+(B+4)/2,Re=Ee-14-24,ve=Math.max(0,ae-4),Te=K?2:Ee-C/2,Le=useRef(ie);useEffect(()=>{if(Le.current===ie)return;Le.current=ie;const e=Animated.spring(fe,{toValue:ie,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[ie,fe]);const je=Math.max(1,i.length-1),Ve=useMemo(()=>{const e=[],t=[];for(let i=0;i<=je;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return fe.interpolate({inputRange:e,outputRange:t})},[fe,je,se,ge,be]),Be=i.map(e=>e.key).join(" "),Ce=J||Q;useEffect(()=>{const e=Be.split(" ").flatMap(e=>{const t=e===o?1:0,i=ye.current[e];return i?Ce?[Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=Animated.parallel(e);return t.start(),()=>t.stop()},[o,Be,Ce]);const popIcon=e=>{Animated.sequence([Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:!0}),Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:!0})]).start()},Me=useRef(new Animated.Value(1)).current,{colors:De}=L,ke=ee?De.primary:De.surface,Ne=ee?De["on-primary"]:De.primary,Pe=ee?De["on-primary"]:K?De["text-body"]:De["text-subtle"],ze=ee?De["on-primary"]:De["primary-soft"],Fe=ee?De.primary:J?De["on-primary"]:Ne,He=h??D,Oe=g??(q?D:0),We=Oe>0,Ue=f??L.space.sm,$e=b??(q?L.space.sm:L.space.xs),Xe=We?Ue:Math.max(Ue,j.bottom),Ge=We?Math.max(Oe,j.bottom>0?j.bottom+L.space.sm:0):0,Ze="pill"===c,Ye=q?ae+Y+2*Ue+2*StyleSheet.hairlineWidth:ae+Y+Ue+Xe,Ke=Ze?ae>0?Ye/2:L.radius.pill:c??(K?L.radius.pill:q?k:L.radius.none),qe=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&qe?Math.min(Ke,e/2):t,Je="underline"===l?Math.max($e,Ze&&0===ae?0:Ke):$e,Qe=p??"none",et="none"===Qe?void 0:L.shadow[Qe],tt=void 0===et?null:supportsBoxShadow()?{boxShadow:toBoxShadow(et)}:et,it=x?StyleSheet.hairlineWidth:0,nt=ee?De.primary:De.border,ot=n?.lift??0,at=Ue+it+Y,rt=n&&ae>0?Math.max(0,(de.height||ue)/2+ot-ae/2-at):0,st=n?_jsx(View,{style:[V.centerCell,pe?{flex:0,marginHorizontal:me}:null],pointerEvents:"box-none",children:_jsxs(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??r;!1!==e&&triggerHaptic(e),popIcon(Me),n.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:n.label,hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.centerPressable,{top:-ot},e?{opacity:.85}:null],testID:n.testID??(v?`${v}-center`:void 0),children:[n.content?_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:n.content}):_jsx(View,{style:[V.centerCircle,{width:ue,height:ue,borderRadius:L.radius.pill,...smoothCorners,backgroundColor:n.color??De.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??De["on-primary"],size:n.iconSize??24,disabled:!1})})}),(lt=n,s&&!O&&lt.label.trim().length>0?_jsx(Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:E??L.settings.maxFontSizeMultiplier??1.2,style:[V.label,{color:Pe,opacity:ee?.7:1},A],children:n.label}):null)]})},CENTER_KEY):null;var lt;const dt=$?_jsx(View,{style:X?V.accessoryInline:V.accessoryStacked,onLayout:e=>Z(e.nativeEvent.layout.height),testID:v?`${v}-accessory`:void 0,children:U}):null,ct=_jsxs(View,{style:X?[V.tabRow,V.tabRowInline]:V.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;oe(t),re(i)},children:[te&&Se>0&&(!K||ve>0)?_jsx(Animated.View,{pointerEvents:"none",style:[V.pill,{width:Se,height:K?ve:C,left:we,top:Te,backgroundColor:ze,borderRadius:K?activeBgRadius(ve,ve/2):activeBgRadius(C,L.radius.pill),...smoothCorners,transform:[{translateX:Ve}]},I]}):null,J&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[V.bubble,L.shadow.elevated,{width:48,height:48,borderRadius:L.radius.pill,...smoothCorners,left:Ie,top:Re,backgroundColor:De.primary,borderColor:De.surface,transform:[{translateX:Ve}]},I]}):null,(ut=i.map(e=>{const t=e.key===o,i=t?Ne:Pe,n=t?Fe:Pe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=xe.current[e.key],c=ye.current[e.key],u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,T),m=ee&&!t?.7:1,h=J&&t||ee?De.primary:De.surface,g=hasLabel(e),b=g&&(!Q||t),f=_jsxs(Animated.View,{style:[V.iconWrap,{width:B+4,height:B+4,opacity:m,transform:[{scale:d}]}],children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(l,{color:n,size:B,focused:t,disabled:!1})}),u?_jsx(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:h}],textStyle:V.badgeText}):null]}),x=J?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:f}):f,y=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:E??L.settings.maxFontSizeMultiplier??1.2,style:[V.label,Q?V.labelInline:null,{color:i,opacity:Q?c:m,fontWeight:t?L.weight.semibold:L.weight.normal},A],children:e.label}):null,S=_jsx(Pressable,{onPress:()=>(e=>{O&&F(_),e.key!==o&&!1!==r&&triggerHaptic(r);const t=xe.current[e.key];t&&popIcon(t),a(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:T.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.tab,K?V.tabTile:null,e?{opacity:.85}:null],testID:v?`${v}-tab-${e.key}`:void 0,children:Q?_jsxs(View,{style:[V.expandPill,{height:C,paddingHorizontal:t&&g?L.space.md:Math.max(0,(C-(B+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[V.expandFill,{borderRadius:activeBgRadius(C,C/2),...smoothCorners,backgroundColor:t?De["primary-soft"]:"transparent"},t?I:null]}),x,y]}):_jsxs(_Fragment,{children:[x,y]})},e.key);return Q?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:S},e.key):S}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[V.underline,"top"===d?V.underlineTop:V.underlineBottom,"top"===d?{top:-Ue-Y}:{bottom:-Ue},{width:ge,height:3,backgroundColor:De.primary,transform:[{translateX:Ve}]},I]}):null]});var ut;return _jsx(View,{ref:t,testID:v,accessibilityRole:"tablist",style:[V.outer,{paddingHorizontal:He,paddingTop:Math.max(Oe,rt),paddingBottom:Ge},w],children:_jsxs(View,{style:[q?V.floatingBar:V.dockedBar,X?V.barInline:null,tt,{backgroundColor:ke,borderColor:nt,borderRadius:Ke,...smoothCorners},q?{borderWidth:it,paddingHorizontal:$e,paddingVertical:Ue}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:Ue,paddingBottom:Xe}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>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,...smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,...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}});export{BottomNavigation};export default BottomNavigation;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});const Button=forwardRef((e,o)=>{const{label:t,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:I,accessibilityState:_,testID:v,onLayout:T,labels:k,...w}=e;warnInvalidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),warnInvalidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const j=useTheme(),F=j.settings.components.button,L=r??F?.defaultVariant??"solid",O=i??F?.defaultSize??"md",R=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...k}),[k]),A=!l&&!n,V={..._,disabled:!A,busy:n},B="link"===L,P=y??F?.defaultPressAnimation??(!B&&"scale"),z=usePressAnimation({preset:P||"scale",enabled:!1!==P&&A}),E=useFlickGuard(),W=useMemo(()=>buildStyles(j),[j]),H=useMemo(()=>resolveButtonSize(j,O),[j,O]),D=useMemo(()=>toneFor(j,s),[j,s]),N=useMemo(()=>variantFor(j,L,D,l),[j,L,D,l]),M=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?j.settings.gradients[m]??null:m,[m,l,L,j.settings.gradients]),U=StyleSheet.flatten(f)?.borderRadius,q=B?0:"number"==typeof U?U:p?j.radius.pill:H.radius,G=useSquircle(!M&&"link"!==L,q,T),K=useRef(createAnimatedValue(0)).current,[X,Y]=useState(0),[J,Q]=useState(null),Z=B?e=>Y(e.nativeEvent.layout.width):void 0,$=C??t,ee="outline"===L||"ghost"===L,oe=!ee&&!B,te={color:N.textColor,size:H.icon,disabled:l},re=b&&!B&&Boolean(d),se=j.space.xs,ie=H["min-height"]-2*se-2*N.borderWidth,ne={color:N.badgeInk,size:H["badge-icon"],disabled:l},le=n?_jsx(Spinner,{variant:"circular",size:"sm",color:re?N.badgeInk:N.textColor,accessibilityLabel:R.loading}):d?renderSlotIcon(d,re?ne:te,u):null,ae=_jsxs(View,{style:W.contentRow,children:[re?_jsx(View,{testID:"button-icon-badge",style:[W.iconLeft,W.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:N.badgeFill}],children:le}):le?_jsx(View,{style:W.iconLeft,children:le}):null,_jsxs(View,{onLayout:Z,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[W.label,{color:N.textColor,fontSize:H.text,lineHeight:Math.round(H.text*j.leading.body)},x],children:t}),B?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[W.linkUnderline,{backgroundColor:N.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:W.iconRight,children:renderSlotIcon(c,te,u)}):null]}),de=B?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(H["min-height"]),ce={top:de,bottom:de,left:B?LINK_HIT_SLOP:0,right:B?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[z.style,a?W.fullWidth:null,h],children:_jsx(Pressable,{ref:o,onPress:e=>{if(!A||E.isFlick(e))return;z.press();const o=resolveHaptic(g,"impactLight");o&&triggerHaptic(o),S?.(e)},onPressIn:e=>{E.onPressIn(e),z.pressIn(),B&&A&&(K.stopAnimation(),K.setValue(0),Animated.timing(K,{toValue:1,duration:j.motion.duration.slower,easing:Easing.bezier(...j.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{z.pressOut()},disabled:!A,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:I,accessibilityState:V,...ariaFromState(V),testID:v,onLayout:e=>{G.onLayout(e),B&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[W.base,{paddingHorizontal:B?0:H["padding-x"],paddingVertical:B?0:re?se:H["padding-y"],paddingLeft:re?se:void 0,minHeight:B?void 0:H["min-height"],borderRadius:q,...smoothCorners,backgroundColor:M||G.active?"transparent":N.backgroundColor,borderWidth:N.borderWidth,borderColor:G.active?"transparent":N.borderColor,opacity:n?.55:1,overflow:G.active||B?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:j.colors["surface-pressed"]}:null,a?W.fullWidth:null,f],...w,"aria-disabled":!A,"aria-busy":n,children:({pressed:e})=>_jsxs(_Fragment,{children:[G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:e&&ee?j.colors["surface-pressed"]:N.backgroundColor,stroke:N.borderColor,strokeWidth:N.borderWidth}):null,M?_jsx(Gradient,{gradient:M,style:[StyleSheet.absoluteFill,{borderRadius:q,...smoothCorners}]}):null,e&&oe?G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:N.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[W.pressedOverlay,{borderRadius:q,backgroundColor:N.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,o)=>{switch(o){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft: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: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: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: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: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,o,t,r)=>{const s=r?e.colors["text-disabled"]:t.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:t.on,badgeInk:t.base},l=r?i:{badgeFill:t.base,badgeInk:t.on};switch(o){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:t.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:t.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:t.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:t.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:t.base};default:return{backgroundColor:t.base,borderColor:"transparent",borderWidth:1,textColor:t.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,o){return variantFor(o,e.variant??"solid",toneFor(o,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>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"}});export{Button};export default Button;
1
+ "use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});const Button=forwardRef((e,t)=>{const{label:o,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:I,accessibilityState:_,testID:v,onLayout:w,labels:T,...j}=e;warnInvalidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),warnInvalidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const k=useTheme(),F=k.settings.components.button,L=r??F?.defaultVariant??"solid",A=i??F?.defaultSize??"md",O=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...T}),[T]),R=!l&&!n,V={..._,disabled:!R,busy:n},B="link"===L,E=y??F?.defaultPressAnimation??(!B&&"scale"),P=usePressAnimation({preset:E||"scale",enabled:!1!==E&&R}),z=useFlickGuard(),H=useMemo(()=>buildStyles(k),[k]),W=useMemo(()=>resolveButtonSize(k,A),[k,A]),D=useMemo(()=>toneFor(k,s),[k,s]),N=useMemo(()=>variantFor(k,L,D,l),[k,L,D,l]),M=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?k.settings.gradients[m]??null:m,[m,l,L,k.settings.gradients]),U=StyleSheet.flatten(f)?.borderRadius,q=B?0:"number"==typeof U?U:p?k.radius.pill:W.radius,G=useSquircle(!M&&"link"!==L,q,w),K=useRef(createAnimatedValue(0)).current,[X,Y]=useState(0),[J,Q]=useState(null),Z=B?e=>Y(e.nativeEvent.layout.width):void 0,$=C??o,ee="outline"===L||"ghost"===L,te=!ee&&!B,oe={color:N.textColor,size:W.icon,disabled:l},re=b&&!B&&Boolean(d),se=k.space.xs,ie=W["min-height"]-2*se-2*N.borderWidth,ne={color:N.badgeInk,size:W["badge-icon"],disabled:l},le=n?_jsx(Spinner,{variant:"circular",size:"sm",color:re?N.badgeInk:N.textColor,accessibilityLabel:O.loading}):d?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(d,re?ne:oe,u)}):null,ae=_jsxs(View,{style:H.contentRow,children:[re?_jsx(View,{testID:"button-icon-badge",style:[H.iconLeft,H.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:N.badgeFill}],children:le}):le?_jsx(View,{style:H.iconLeft,children:le}):null,_jsxs(View,{onLayout:Z,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[H.label,{color:N.textColor,fontSize:W.text,lineHeight:Math.round(W.text*k.leading.body)},x],children:o}),B?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[H.linkUnderline,{backgroundColor:N.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:H.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(c,oe,u)}):null]}),de=B?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(W["min-height"]),ce={top:de,bottom:de,left:B?LINK_HIT_SLOP:0,right:B?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[P.style,a?H.fullWidth:null,h],children:_jsx(Pressable,{ref:t,onPress:e=>{if(!R||z.isFlick(e))return;P.press();const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t),S?.(e)},onPressIn:e=>{z.onPressIn(e),P.pressIn(),B&&R&&(K.stopAnimation(),K.setValue(0),Animated.timing(K,{toValue:1,duration:k.motion.duration.slower,easing:Easing.bezier(...k.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{P.pressOut()},disabled:!R,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:I,accessibilityState:V,...ariaFromState(V),testID:v,onLayout:e=>{G.onLayout(e),B&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[H.base,{paddingHorizontal:B?0:W["padding-x"],paddingVertical:B?0:re?se:W["padding-y"],paddingLeft:re?se:void 0,minHeight:B?void 0:W["min-height"],borderRadius:q,...smoothCorners,backgroundColor:M||G.active?"transparent":N.backgroundColor,borderWidth:N.borderWidth,borderColor:G.active?"transparent":N.borderColor,opacity:n?.55:1,overflow:G.active||B?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:k.colors["surface-pressed"]}:null,a?H.fullWidth:null,f],...j,"aria-disabled":!R,"aria-busy":n,children:({pressed:e})=>_jsxs(_Fragment,{children:[G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:e&&ee?k.colors["surface-pressed"]:N.backgroundColor,stroke:N.borderColor,strokeWidth:N.borderWidth}):null,M?_jsx(Gradient,{gradient:M,style:[StyleSheet.absoluteFill,{borderRadius:q,...smoothCorners}]}):null,e&&te?G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:N.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[H.pressedOverlay,{borderRadius:q,backgroundColor:N.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ae]})})})});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: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: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: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: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: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,o,r)=>{const s=r?e.colors["text-disabled"]:o.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:o.on,badgeInk:o.base},l=r?i:{badgeFill:o.base,badgeInk:o.on};switch(t){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:o.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:o.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:o.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:o.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:o.base};default:return{backgroundColor:o.base,borderColor:"transparent",borderWidth:1,textColor:o.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>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"}});export{Button};export default Button;