@webority/mobile-ui 0.131.0 → 0.132.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 (46) hide show
  1. package/dist/canvas-kit/kit.js +4960 -4856
  2. package/dist/canvas-kit/manifest.json +34 -2
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  5. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  6. package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
  7. package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
  8. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  9. package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
  10. package/lib/commonjs/components/Screen/Screen.js +1 -1
  11. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  12. package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
  13. package/lib/commonjs/navigation/NavigationScreen.js +1 -1
  14. package/lib/commonjs/network/NetworkStatusBanner.js +1 -1
  15. package/lib/commonjs/theme/merge.js +1 -1
  16. package/lib/commonjs/theme/tokens.generated.js +1 -1
  17. package/lib/module/components/AppBar/AppBar.js +1 -1
  18. package/lib/module/components/BarChart/BarChart.js +1 -1
  19. package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
  20. package/lib/module/components/FileViewer/FileViewer.js +1 -1
  21. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  22. package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
  23. package/lib/module/components/Screen/Screen.js +1 -1
  24. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  25. package/lib/module/components/WheelPicker/Wheel.js +1 -1
  26. package/lib/module/navigation/NavigationScreen.js +1 -1
  27. package/lib/module/network/NetworkStatusBanner.js +1 -1
  28. package/lib/module/theme/merge.js +1 -1
  29. package/lib/module/theme/tokens.generated.js +1 -1
  30. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +3 -1
  31. package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +3 -3
  32. package/lib/typescript/commonjs/components/Screen/Screen.d.ts +4 -0
  33. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +2 -1
  34. package/lib/typescript/commonjs/navigation/NavigationScreen.d.ts +2 -2
  35. package/lib/typescript/commonjs/network/NetworkStatusBanner.d.ts +7 -2
  36. package/lib/typescript/commonjs/theme/tokens.generated.d.ts +1 -1
  37. package/lib/typescript/commonjs/theme/types.d.ts +5 -1
  38. package/lib/typescript/module/components/AppBar/AppBar.d.ts +3 -1
  39. package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +3 -3
  40. package/lib/typescript/module/components/Screen/Screen.d.ts +4 -0
  41. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +2 -1
  42. package/lib/typescript/module/navigation/NavigationScreen.d.ts +2 -2
  43. package/lib/typescript/module/network/NetworkStatusBanner.d.ts +7 -2
  44. package/lib/typescript/module/theme/tokens.generated.d.ts +1 -1
  45. package/lib/typescript/module/theme/types.d.ts +5 -1
  46. package/package.json +7 -7
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.131.0"
5
+ "version": "0.132.0"
6
6
  },
7
7
  "rendererProtocolVersion": 13,
8
8
  "platform": "Phone",
@@ -546,7 +546,14 @@
546
546
  "name": "divider",
547
547
  "type": "boolean",
548
548
  "required": false,
549
- "description": "Draws a hairline under the bar; it shows unless the bar is transparent."
549
+ "description": "Draws a hairline under the bar; off by default."
550
+ },
551
+ {
552
+ "name": "elevated",
553
+ "type": "boolean",
554
+ "required": false,
555
+ "description": "Draws a shadow under the bar, for content scrolled beneath it; ignored when the bar is transparent.",
556
+ "default": false
550
557
  },
551
558
  {
552
559
  "name": "gutter",
@@ -13508,6 +13515,13 @@
13508
13515
  "description": "Keeps the content inside the page's side margin. List pages default to false, because their rows carry their own padding.",
13509
13516
  "default": true
13510
13517
  },
13518
+ {
13519
+ "name": "headerShadowOnScroll",
13520
+ "type": "boolean",
13521
+ "required": false,
13522
+ "description": "Shows a shadow under the fixed bar once the content scrolls, and hides it back at the top.",
13523
+ "default": true
13524
+ },
13511
13525
  {
13512
13526
  "name": "keyboardToolbar",
13513
13527
  "type": "boolean",
@@ -13591,6 +13605,12 @@
13591
13605
  "type": "string",
13592
13606
  "required": false,
13593
13607
  "description": "The app bar title."
13608
+ },
13609
+ {
13610
+ "name": "trailing",
13611
+ "type": "node",
13612
+ "required": false,
13613
+ "description": "Content at the right edge of the app bar, such as a profile avatar, in place of the last right action."
13594
13614
  }
13595
13615
  ],
13596
13616
  "itemsTakeAction": [],
@@ -20468,6 +20488,7 @@
20468
20488
  "neutral",
20469
20489
  "neutral-hover",
20470
20490
  "neutral-text",
20491
+ "offline-fill",
20471
20492
  "on-danger",
20472
20493
  "on-glass",
20473
20494
  "on-info",
@@ -20479,6 +20500,7 @@
20479
20500
  "on-surface-dark",
20480
20501
  "on-surface-dark-muted",
20481
20502
  "on-warning",
20503
+ "online-fill",
20482
20504
  "primary",
20483
20505
  "primary-hover",
20484
20506
  "primary-pressed",
@@ -20607,6 +20629,7 @@
20607
20629
  "neutral": "Quiet unbranded fill for supporting actions such as Back, Skip and Close.",
20608
20630
  "neutral-hover": "Neutral fill while a control is hovered.",
20609
20631
  "neutral-text": "Text on the soft neutral background.",
20632
+ "offline-fill": "Fill of the offline network banner: the source red, not the contrast-darkened danger fill.",
20610
20633
  "on-danger": "Ink on a solid danger fill.",
20611
20634
  "on-glass": "Ink on a translucent control on a brand surface.",
20612
20635
  "on-info": "Ink on a solid info fill.",
@@ -20618,6 +20641,7 @@
20618
20641
  "on-surface-dark": "Text and icons on a surface-dark band.",
20619
20642
  "on-surface-dark-muted": "Secondary text on a surface-dark band.",
20620
20643
  "on-warning": "Ink on a solid warning fill.",
20644
+ "online-fill": "Fill of the back-online network banner: the source green, not the contrast-darkened success fill.",
20621
20645
  "primary": "Primary fill for buttons, selected states and borders.",
20622
20646
  "primary-hover": "Primary fill while a control is hovered or pressed.",
20623
20647
  "primary-pressed": "Primary fill while a control is pressed.",
@@ -20829,6 +20853,10 @@
20829
20853
  "light": "#52525b",
20830
20854
  "dark": "#b4b4bb"
20831
20855
  },
20856
+ "offline-fill": {
20857
+ "light": "#e82646",
20858
+ "dark": "#e82646"
20859
+ },
20832
20860
  "on-danger": {
20833
20861
  "light": "#ffffff",
20834
20862
  "dark": "#0f0f1a"
@@ -20873,6 +20901,10 @@
20873
20901
  "light": "#0f0f1a",
20874
20902
  "dark": "#0f0f1a"
20875
20903
  },
20904
+ "online-fill": {
20905
+ "light": "#04b440",
20906
+ "dark": "#04b440"
20907
+ },
20876
20908
  "primary": {
20877
20909
  "light": "#5b5bd6",
20878
20910
  "dark": "#7c7ce8"
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.131.0",
3
+ "version": "0.132.0",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 13,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.131.0"
9
+ "version": "0.132.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "576741fa610212e433381257501d8eaafe727f43c05ddde24b17c62327c12d01",
14
- "bytes": 662255
13
+ "sha256": "93ccea95aa1fbffca8372ee25e3db8d82ff10670b54197758a7ab058153bc0b3",
14
+ "bytes": 663451
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "d71c8f815cbfd3ca7c602775257494283285db94cfad97c5f0230edddee3a997",
18
- "bytes": 6107361
17
+ "sha256": "f2105393c7f83bf51c3b5b4605eeb7182ac63bcd5ca9f7cc59f2706df6ea9f4f",
18
+ "bytes": 6110395
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_APP_BAR_LABELS=exports.AppBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_index2=require("../Menu/index.js"),_Text=require("../Text/Text.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4,DEFAULT_APP_BAR_LABELS=exports.DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"}),variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=(0,_react.forwardRef)(({action:e,side:t,badgeStyle:i,haptic:n,flush:a,onPress:r},s)=>{const l=(0,_index.useTheme)(),{style:o,pressIn:c,pressOut:d}=(0,_usePressAnimation.usePressAnimation)({enabled:!0}),u=(0,_react.useMemo)(()=>buildActionStyles(l),[l]),p=e.badge,h=void 0!==p&&0!==p,x=void 0!==e.label;return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:o,children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:s,onPress:t=>{const i=(0,_hapticUtils.resolveHaptic)(n,"selection");i&&(0,_hapticUtils.triggerHaptic)(i),"onPress"in e&&e.onPress(),r?.(t)},onPressIn:c,onPressOut:d,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,android_ripple:{color:l.colors["surface-pressed"],borderless:!x},style:({pressed:e})=>[x?u.textButton:u.actionButton,a?null:"left"===t?u.actionLeft:u.actionRight,e&&!x?u.actionPressed:null,e&&x?u.textPressed:null],children:[x?(0,_jsxRuntime.jsx)(_Text.Text,{variant:"body",weight:"semibold",color:"link",numberOfLines:1,children:e.label}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.iconWrap,children:e.icon}),h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.badge,i],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_Text.Text,{variant:"caption",weight:"semibold",numberOfLines:1,style:u.badgeText,children:String(p)})}):null,e.dot?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:e.testID?`${e.testID}-dot`:"appbar-action-dot",style:u.dot,pointerEvents:"none"}):null]})})}),COLLAPSE_RANGE=60,AppBar=exports.AppBar=(0,_react.forwardRef)((e,t)=>{const{title:i,subtitle:n,titleAlignment:a="left",leftAction:r,rightActions:s,leading:l,trailing:o,onBack:c,gutter:d,titleVariant:u,titleOffset:p,height:h,divider:x,variant:g="default",transparent:m=!1,scrollY:_,style:b,containerStyle:f,titleStyle:j,subtitleStyle:v,badgeStyle:y,haptic:A,labels:R,testID:S}=e;(0,_warnInvalidValue.warnInvalidValue)("AppBar","variant",e.variant,["default","large","compact"]),(0,_warnInvalidValue.warnInvalidValue)("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const w=(0,_react.useMemo)(()=>({...DEFAULT_APP_BAR_LABELS,...R}),[R]),I=(0,_index.useTheme)(),L=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),B=(0,_react.useMemo)(()=>variantSize(I,g),[I,g]),N=(0,_react.useMemo)(()=>buildStyles(I),[I]),T="large"===g,C=T&&void 0!==_,[P,V]=(0,_react.useState)(40),z=(0,_react.useCallback)(e=>V(e.nativeEvent.layout.height),[]),O=r??(c?{icon:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"arrow-left",size:24,color:I.colors["text-body"]}),onPress:c,accessibilityLabel:w.back}:void 0),E=o?void 0:s?.[s.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?I.space.sm:Math.max((44-(e.glyphSize??24))/2,0),D=void 0===d?null:{paddingLeft:Math.max(d-opticalInset(O),0),paddingRight:Math.max(d-opticalInset(E),0)},W=void 0!==p,k=Boolean(O)||Boolean(l),q=W||!k&&"left"===a,H=x??!m,F=_reactNative.StyleSheet.hairlineWidth,M=(0,_react.useMemo)(()=>_?{rootHeight:_.interpolate({inputRange:[0,60],outputRange:[L.top+B.height+P,L.top+B.height],extrapolate:"clamp"}),titleRowOpacity:_.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:_.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:_.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}:null,[_,L.top,B.height,P]),U=i?u?(0,_jsxRuntime.jsx)(_Text.Text,{variant:u,align:"center"===a?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[N.titleVariant,j],children:i}):(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityRole:"header",style:[N.title,{fontSize:B.titleSize,fontWeight:I.weight[B.titleWeight],textAlign:"center"===a?"center":"left"},j],numberOfLines:1,children:i}):null,$=C&&M&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[N.title,{fontSize:I.text.lg.size,fontWeight:I.weight.semibold,textAlign:"center"===a?"center":"left",opacity:M.compactTitleOpacity}],numberOfLines:1,children:i}):null,G=n?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[N.subtitle,{textAlign:"center"===a?"center":"left"},v],numberOfLines:B.subtitleLines,children:n}):null,Z=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[N.titleColumn,"center"===a?N.titleColumnCenter:null],children:[U,G]}),Y=C?_reactNative.Animated.View:_reactNative.View,J=C&&M?{height:M.rootHeight,overflow:"hidden"}:T&&void 0===h?null:{height:(h??B.height)+L.top};return(0,_jsxRuntime.jsxs)(Y,{ref:t,testID:S,style:[N.root,{paddingTop:L.top,backgroundColor:m?"transparent":I.colors.surface},J,!C&&H?{borderBottomWidth:F,borderBottomColor:I.colors.border}:null,f,b],children:[C&&M&&H?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[N.animatedBorder,{backgroundColor:I.colors.border,opacity:M.borderOpacity}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:T&&S?`${S}-bar-row`:void 0,style:[N.row,T?{height:B.height}:{flex:1},D],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:S?`${S}-leading-slot`:void 0,style:[N.sideSlot,q?N.sideSlotCompact:null],children:[O?(0,_jsxRuntime.jsx)(ActionButton,{action:O,side:"left",haptic:A,flush:W}):null,null!=l&&!1!==l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:N.slotNode,children:l}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[N.center,"center"===a?N.centerAligned:N.centerLeft,W?{paddingLeft:k?p:I.space.none,paddingRight:I.space.none}:q?{paddingLeft:I.space.none}:null],children:T?$:Z}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[N.sideSlot,N.sideSlotRight,W?N.sideSlotCompact:null],children:[s?.map((e,t)=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:"menu"in e?(0,_jsxRuntime.jsx)(_index2.Menu,{items:e.menu,title:e.menuTitle,haptic:A,trigger:(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:y,haptic:A,flush:W})}):(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:y,haptic:A,flush:W})},`appbar-right-${t}`)),null!=o&&!1!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:N.slotNode,children:o}):null]})]}),T?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{testID:S?`${S}-title-row`:void 0,onLayout:C?z:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??I.space.md,paddingBottom:I.space.sm},C&&M?{opacity:M.titleRowOpacity}:null],children:Z}):null]})});AppBar.displayName="AppBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{width:"100%"},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.xs},sideSlot:{flexDirection:"row",alignItems:"center",minWidth:48},sideSlotRight:{justifyContent:"flex-end"},sideSlotCompact:{minWidth:0},slotNode:{flexDirection:"row",alignItems:"center"},center:{flex:1,minWidth:0,paddingHorizontal:e.space.xs},centerAligned:{alignItems:"center"},centerLeft:{alignItems:"flex-start"},titleColumn:{flexDirection:"column",maxWidth:"100%"},titleColumnCenter:{alignItems:"center"},title:{color:e.colors["text-body"]},titleVariant:{includeFontPadding:!1,textAlignVertical:"center"},subtitle:{marginTop:e.space.xxs,color:e.colors["text-subtle"],fontSize:e.text.sm.size,fontWeight:e.weight.normal},animatedBorder:{position:"absolute",left:0,right:0,bottom:0,height:_reactNative.StyleSheet.hairlineWidth}}),buildActionStyles=e=>_reactNative.StyleSheet.create({actionButton:{width:44,height:44,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},actionLeft:{marginRight:e.space.xs},actionRight:{marginLeft:e.space.xs},actionPressed:{backgroundColor:e.colors["surface-pressed"]},textButton:{minWidth:44,minHeight:44,paddingHorizontal:e.space.sm,alignItems:"center",justifyContent:"center"},textPressed:{opacity:.6},dot:{position:"absolute",top:10,right:10,width:8,height:8,borderRadius:e.radius.pill,backgroundColor:e.colors.danger},iconWrap:{alignItems:"center",justifyContent:"center"},badge:{position:"absolute",top:4,right:4,minWidth:16,height:16,paddingHorizontal:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.danger,alignItems:"center",justifyContent:"center"},badgeText:{color:e.colors["on-danger"],fontSize:e.text.xs.size,fontWeight:e.weight.semibold,lineHeight:13}});var _default=exports.default=AppBar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_APP_BAR_LABELS=exports.AppBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_index2=require("../Menu/index.js"),_Text=require("../Text/Text.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4,DEFAULT_APP_BAR_LABELS=exports.DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"}),variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=(0,_react.forwardRef)(({action:e,side:t,badgeStyle:i,haptic:n,flush:a,onPress:l},r)=>{const s=(0,_index.useTheme)(),{style:o,pressIn:c,pressOut:d}=(0,_usePressAnimation.usePressAnimation)({enabled:!0}),u=(0,_react.useMemo)(()=>buildActionStyles(s),[s]),p=e.badge,h=void 0!==p&&0!==p,x=void 0!==e.label;return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:o,children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:r,onPress:t=>{const i=(0,_hapticUtils.resolveHaptic)(n,"selection");i&&(0,_hapticUtils.triggerHaptic)(i),"onPress"in e&&e.onPress(),l?.(t)},onPressIn:c,onPressOut:d,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,android_ripple:{color:s.colors["surface-pressed"],borderless:!x},style:({pressed:e})=>[x?u.textButton:u.actionButton,a?null:"left"===t?u.actionLeft:u.actionRight,e&&!x?u.actionPressed:null,e&&x?u.textPressed:null],children:[x?(0,_jsxRuntime.jsx)(_Text.Text,{variant:"body",weight:"semibold",color:"link",numberOfLines:1,children:e.label}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.iconWrap,children:e.icon}),h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.badge,i],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_Text.Text,{variant:"caption",weight:"semibold",numberOfLines:1,style:u.badgeText,children:String(p)})}):null,e.dot?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:e.testID?`${e.testID}-dot`:"appbar-action-dot",style:u.dot,pointerEvents:"none"}):null]})})}),COLLAPSE_RANGE=60,AppBar=exports.AppBar=(0,_react.forwardRef)((e,t)=>{const{title:i,subtitle:n,titleAlignment:a="left",leftAction:l,rightActions:r,leading:s,trailing:o,onBack:c,gutter:d,titleVariant:u,titleOffset:p,height:h,divider:x,elevated:g=!1,variant:m="default",transparent:_=!1,scrollY:b,style:f,containerStyle:j,titleStyle:v,subtitleStyle:y,badgeStyle:A,haptic:R,labels:S,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("AppBar","variant",e.variant,["default","large","compact"]),(0,_warnInvalidValue.warnInvalidValue)("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const I=(0,_react.useMemo)(()=>({...DEFAULT_APP_BAR_LABELS,...S}),[S]),B=(0,_index.useTheme)(),L=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>variantSize(B,m),[B,m]),T=(0,_react.useMemo)(()=>buildStyles(B),[B]),P="large"===m,C=P&&void 0!==b,[z,V]=(0,_react.useState)(40),O=(0,_react.useCallback)(e=>V(e.nativeEvent.layout.height),[]),E=l??(c?{icon:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"arrow-left",size:24,color:B.colors["text-body"]}),onPress:c,accessibilityLabel:I.back}:void 0),D=o?void 0:r?.[r.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?B.space.sm:Math.max((44-(e.glyphSize??24))/2,0),W=void 0===d?null:{paddingLeft:Math.max(d-opticalInset(E),0),paddingRight:Math.max(d-opticalInset(D),0)},k=void 0!==p,F=Boolean(E)||Boolean(s),q=!k&&"left"===a&&Boolean(E),H=k||q||!F&&"left"===a,M="default"!==m||F?N.titleSize:B.text.xl.size,U=x??!1,$=_reactNative.StyleSheet.hairlineWidth,G=(0,_react.useMemo)(()=>b?{rootHeight:b.interpolate({inputRange:[0,60],outputRange:[L.top+N.height+z,L.top+N.height],extrapolate:"clamp"}),titleRowOpacity:b.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:b.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:b.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}:null,[b,L.top,N.height,z]),Z=i?u?(0,_jsxRuntime.jsx)(_Text.Text,{variant:u,align:"center"===a?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[T.titleVariant,v],children:i}):(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityRole:"header",style:[T.title,{fontSize:M,fontWeight:B.weight[N.titleWeight],textAlign:"center"===a?"center":"left"},n?T.stackedText:null,v],numberOfLines:1,children:i}):null,Y=C&&G&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[T.title,{fontSize:B.text.lg.size,fontWeight:B.weight.semibold,textAlign:"center"===a?"center":"left",opacity:G.compactTitleOpacity}],numberOfLines:1,children:i}):null,J=n?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[T.subtitle,{textAlign:"center"===a?"center":"left"},y],numberOfLines:N.subtitleLines,children:n}):null,K=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T.titleColumn,"center"===a?T.titleColumnCenter:null],children:[Z,J]}),Q=C?_reactNative.Animated.View:_reactNative.View,X=C&&G?{height:G.rootHeight,overflow:"hidden"}:P&&void 0===h?null:{height:(h??N.height)+L.top};return(0,_jsxRuntime.jsxs)(Q,{ref:t,testID:w,style:[T.root,{paddingTop:L.top,backgroundColor:_?"transparent":B.colors.surface},X,!C&&U?{borderBottomWidth:$,borderBottomColor:B.colors.border}:null,g&&!_?B.shadow.card:null,j,f],children:[C&&G&&U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[T.animatedBorder,{backgroundColor:B.colors.border,opacity:G.borderOpacity}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:P&&w?`${w}-bar-row`:void 0,style:[T.row,P?{height:N.height}:{flex:1},W],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:w?`${w}-leading-slot`:void 0,style:[T.sideSlot,H?T.sideSlotCompact:null],children:[E?(0,_jsxRuntime.jsx)(ActionButton,{action:E,side:"left",haptic:R,flush:k||q}):null,null!=s&&!1!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:T.slotNode,children:s}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[T.center,"center"===a?T.centerAligned:T.centerLeft,k?{paddingLeft:F?p:B.space.none,paddingRight:B.space.none}:H?{paddingLeft:B.space.none}:null],children:P?Y:K}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T.sideSlot,T.sideSlotRight,k?T.sideSlotCompact:null],children:[r?.map((e,t)=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:"menu"in e?(0,_jsxRuntime.jsx)(_index2.Menu,{items:e.menu,title:e.menuTitle,haptic:R,trigger:(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})}):(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})},`appbar-right-${t}`)),null!=o&&!1!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:T.slotNode,children:o}):null]})]}),P?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{testID:w?`${w}-title-row`:void 0,onLayout:C?O:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??B.space.md,paddingBottom:B.space.sm},C&&G?{opacity:G.titleRowOpacity}:null],children:K}):null]})});AppBar.displayName="AppBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{width:"100%"},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.xs},sideSlot:{flexDirection:"row",alignItems:"center",minWidth:48},sideSlotRight:{justifyContent:"flex-end"},sideSlotCompact:{minWidth:0},slotNode:{flexDirection:"row",alignItems:"center"},center:{flex:1,minWidth:0,paddingHorizontal:e.space.xs},centerAligned:{alignItems:"center"},centerLeft:{alignItems:"flex-start"},titleColumn:{flexDirection:"column",maxWidth:"100%"},titleColumnCenter:{alignItems:"center"},title:{color:e.colors["text-body"]},titleVariant:{includeFontPadding:!1,textAlignVertical:"center"},stackedText:{includeFontPadding:!1},subtitle:{includeFontPadding:!1,color:e.colors["text-subtle"],fontSize:e.text.sm.size,fontWeight:e.weight.normal},animatedBorder:{position:"absolute",left:0,right:0,bottom:0,height:_reactNative.StyleSheet.hairlineWidth}}),buildActionStyles=e=>_reactNative.StyleSheet.create({actionButton:{width:44,height:44,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},actionLeft:{marginRight:e.space.xs},actionRight:{marginLeft:e.space.xs},actionPressed:{backgroundColor:e.colors["surface-pressed"]},textButton:{minWidth:44,minHeight:44,paddingHorizontal:e.space.sm,alignItems:"center",justifyContent:"center"},textPressed:{opacity:.6},dot:{position:"absolute",top:10,right:10,width:8,height:8,borderRadius:e.radius.pill,backgroundColor:e.colors.danger},iconWrap:{alignItems:"center",justifyContent:"center"},badge:{position:"absolute",top:4,right:4,minWidth:16,height:16,paddingHorizontal:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.danger,alignItems:"center",justifyContent:"center"},badgeText:{color:e.colors["on-danger"],fontSize:e.text.xs.size,fontWeight:e.weight.semibold,lineHeight:13}});var _default=exports.default=AppBar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_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"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=7,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:b,style:p,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...b}),[b]),j=(0,_index2.useTheme)(),v=r.length,[R,g]=(0,_react.useState)(0),[w,S]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),T=null!==w&&w>=0&&w<v?w:null,C=(0,_react.useRef)(T);C.current=T;const A=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(v>0&&v<=7),V=void 0!==s&&s.length>0,E=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??STACK_TONES[t%STACK_TONES.length]):[],[V,s]),I=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),B=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),D=(0,_react.useMemo)(()=>B?B.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,B]),H=(0,_react.useMemo)(()=>B?B.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):D,[B,D]),$=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&$.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+($.max-e)/($.max-$.min)*F,[k,$.max,$.min,F]),q=G(0),W=(0,_react.useMemo)(()=>$.ticks.map(e=>u(e)),[$.ticks,u]),U=Math.ceil(7*Math.max(...W.map(e=>e.length),1)*1.2),z=v>0?R/v:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=r[e];return t.accessibilityLabel?t.accessibilityLabel:B&&s?`${t.label}, ${s.map((t,r)=>`${t.label} ${c(B[e][r])}`).join(", ")}`:`${t.label}, ${c(D[e])}`},[r,c,D,B,s]),K=(0,_react.useMemo)(()=>{let e=-1;return D.forEach((t,r)=>{(-1===e||t>D[e])&&(e=r)}),e},[D]),J=o??(K>=0?y.highest(r[K].label,c(D[K])):""),Y=(0,_react.useRef)({fire:N,setSelected:S,count:v,plotWidth:R});Y.current={fire:N,setSelected:S,count:v,plotWidth:R};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===A.current||(A.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{A.current=C.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(f?`${f}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),A.current=r,Y.current.setSelected(r===C.current?null:r))}).withTestId(f?`${f}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[f]),Q=(0,_react.useCallback)(e=>{if(0===v)return;const t=C.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(v-1,t+1):null===t?v-1:Math.max(0,t-1);r!==t&&(N(),S(r))},[v,N,S]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??y.chart,ie=0===v?`${ae}, ${y.noData}`:J?`${ae}, ${J}`:ae,se=null===T?J:X(T),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,E[r])}},I[r]))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=D.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==T&&T!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[R>0&&B?renderStack(B[t],t,s):null,R>0&&!B&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&R>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(B?G(H[2*t]):r)-20+2:(B?G(H[2*t+1]):r)+2},children:u(e)}):null]},t)});return 0===v?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:f,style:[styles.root,p],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:v-1,now:T??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:f,style:[styles.root,p],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===T?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r[T].label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:f?`${f}-callout`:void 0,children:c(D[T])})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:$.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:W[t]},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:f?`${f}-plot`:void 0,children:[$.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:T===t?"primary":"tertiary",weight:T===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,E[t])}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_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"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:p,style:b,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...p}),[p]),j=(0,_index2.useTheme)(),v=r.length,[R,g]=(0,_react.useState)(0),[w,S]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),T=null!==w&&w>=0&&w<v?w:null,C=(0,_react.useRef)(T);C.current=T;const A=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(v>0&&v<=7),V=void 0!==s&&s.length>0,E=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??STACK_TONES[t%STACK_TONES.length]):[],[V,s]),I=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),B=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),D=(0,_react.useMemo)(()=>B?B.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,B]),H=(0,_react.useMemo)(()=>B?B.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):D,[B,D]),$=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&$.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+($.max-e)/($.max-$.min)*F,[k,$.max,$.min,F]),q=G(0),W=(0,_react.useMemo)(()=>$.ticks.map(e=>u(e)),[$.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=v>0?R/v:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=r[e];return t.accessibilityLabel?t.accessibilityLabel:B&&s?`${t.label}, ${s.map((t,r)=>`${t.label} ${c(B[e][r])}`).join(", ")}`:`${t.label}, ${c(D[e])}`},[r,c,D,B,s]),K=(0,_react.useMemo)(()=>{let e=-1;return D.forEach((t,r)=>{(-1===e||t>D[e])&&(e=r)}),e},[D]),J=o??(K>=0?y.highest(r[K].label,c(D[K])):""),Y=(0,_react.useRef)({fire:N,setSelected:S,count:v,plotWidth:R});Y.current={fire:N,setSelected:S,count:v,plotWidth:R};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===A.current||(A.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{A.current=C.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(f?`${f}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),A.current=r,Y.current.setSelected(r===C.current?null:r))}).withTestId(f?`${f}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[f]),Q=(0,_react.useCallback)(e=>{if(0===v)return;const t=C.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(v-1,t+1):null===t?v-1:Math.max(0,t-1);r!==t&&(N(),S(r))},[v,N,S]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??y.chart,ie=0===v?`${ae}, ${y.noData}`:J?`${ae}, ${J}`:ae,se=null===T?J:X(T),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,E[r])}},I[r]))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=D.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==T&&T!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[R>0&&B?renderStack(B[t],t,s):null,R>0&&!B&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&R>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(B?G(H[2*t]):r)-20+2:(B?G(H[2*t+1]):r)+2},children:u(e)}):null]},t)});return 0===v?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:f,style:[styles.root,b],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:v-1,now:T??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:f,style:[styles.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===T?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r[T].label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:f?`${f}-callout`:void 0,children:c(D[T])})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:$.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:W[t]},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:f?`${f}-plot`:void 0,children:[$.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:T===t?"primary":"tertiary",weight:T===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,E[t])}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ChoiceGroup=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("../Radio/RadioDot.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=exports.ChoiceGroup=(0,_react.forwardRef)((e,i)=>{const{options:t,getOptionLabel:r,getOptionValue:o,isOptionDisabled:a,getOptionDescription:n,getOptionIcon:l,getOptionColor:s,renderOption:c,variant:d="card",indicatorPosition:u="trailing",direction:p="row",gap:x,wrap:g=!1,fullWidth:h,disabled:_=!1,size:m="md",labelLines:b,descriptionLines:v=2,haptic:j,accessibilityLabel:f,style:y,optionStyle:z,description:C,helperText:w,error:R,testID:V}=e,S=(0,_index2.useTheme)(),H=(0,_react.useMemo)(()=>buildStyles(S),[S]),I=(0,_react.useMemo)(()=>sizeTokensOf(S)[m],[S,m]);(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","variant",e.variant,["card","chip"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","direction",e.direction,["row","column"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const T=(0,_react.useCallback)(e=>r?r(e):e.label??"",[r]),D=(0,_react.useCallback)(e=>o?o(e):e.value,[o]),O=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),k=(0,_react.useCallback)(e=>n?n(e):e.description,[n]),q=(0,_react.useCallback)(e=>l?l(e):e.icon,[l]),G=(0,_react.useCallback)(e=>s?s(e):e.color,[s]),L="multiple"===e.selectionMode,{min:M,max:P}=e,[N,W]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(L?[]:void 0),onChange:e.onChange}),F=Array.isArray(N)?N:[],A=(0,_react.useCallback)(e=>{const i=D(e);if(L){const e=F.includes(i);if(e&&null!=M&&F.length<=M)return;if(!e&&null!=P&&F.length>=P)return;const t=(0,_index3.resolveHaptic)(j,"selection");return t&&(0,_index3.triggerHaptic)(t),void W(e?F.filter(e=>e!==i):[...F,i])}const t=(0,_index3.resolveHaptic)(j,"selection");t&&(0,_index3.triggerHaptic)(t),W(i)},[j,L,M,P,F,W,D]),B=h??("card"===d&&"row"===p&&!g),$=S.radius.md,surfaceFor=(e,i,t)=>i?{borderColor:S.colors.border,backgroundColor:S.colors["surface-disabled"]}:{borderColor:e?t:S.colors.border,backgroundColor:e?(0,_color.tintOf)(t,.12,S.colors["surface-selected"]):S.colors.bg},renderIcon=(e,i,t,r)=>{const o=q(e);if(null==o)return null;const a="string"==typeof o&&i?{name:o,variant:"bold"}:o;return(0,_slotIcon.renderSlotIcon)(a,{color:t,size:I.iconSize,disabled:r})},renderChip=e=>{const{option:i,selected:t,disabled:r,color:o}=e,a=r?S.colors["text-disabled"]:t?o:S.colors["text-body"],n=renderIcon(i,t,a,r);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.chip,{minHeight:I.minHeight,paddingHorizontal:I.chipPaddingHorizontal,paddingVertical:I.paddingVertical,borderRadius:S.radius.pill,..._corners.smoothCorners,borderWidth:S.size.border,...surfaceFor(t,r,o),columnGap:S.space.xs}],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{children:n}):null,(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:b,ellipsizeMode:"tail",style:[H.cardLabel,{color:a,fontSize:I.fontSize,lineHeight:Math.round(I.fontSize*S.leading.body)}],children:T(i)})]})},renderDefaultCard=e=>{const{option:i,selected:t,disabled:r,color:o}=e,a=G(i),n=r?S.colors["text-disabled"]:a??S.colors["text-body"],l=k(i),s=renderIcon(i,t,n,r),c=(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:t,color:o,disabled:r,size:m});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.card,{minHeight:I.minHeight,paddingHorizontal:I.paddingHorizontal,paddingVertical:I.paddingVertical,borderRadius:$,..._corners.smoothCorners,borderWidth:S.size.border,...surfaceFor(t,r,o),columnGap:S.space.sm}],children:["leading"===u?c:null,s?(0,_jsxRuntime.jsx)(_reactNative.View,{children:s}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.cardTextWrap,children:[(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:b,ellipsizeMode:"tail",style:[H.cardLabel,{color:n,fontSize:I.fontSize,lineHeight:Math.round(I.fontSize*S.leading.body)}],children:T(i)}),l?(0,_jsxRuntime.jsx)(_index4.Text,{numberOfLines:v,ellipsizeMode:"tail",style:[H.cardDescription,{color:t?S.colors["text-muted"]:S.colors["text-subtle"],fontSize:S.text.xs.size,lineHeight:Math.round(S.text.xs.size*S.leading.body)}],children:l}):null]}),"trailing"===u?c:null]})},E="string"==typeof R&&""!==R?R:void 0,J=!0===R||void 0!==E?null:w,K=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:i,accessibilityRole:L?void 0:"radiogroup",accessibilityLabel:f,accessibilityState:{disabled:_},"aria-disabled":_,testID:V,style:[{flexDirection:p,gap:x??S.space.sm,flexWrap:g?"wrap":"nowrap"},y],children:t.map((e,i)=>{const t=D(e),r=L?F.includes(t):N===t,o=L&&null!=P&&!r&&F.length>=P,a=_||o||O(e),n=G(e)??S.colors.primary,l=c||"card"!==d?void 0:k(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:e.testID,onPress:()=>{a||A(e)},disabled:a,accessibilityRole:L?"checkbox":"radio",accessibilityLabel:l?`${T(e)}, ${l}`:T(e),accessibilityState:{checked:r,disabled:a},"aria-checked":r,"aria-disabled":a,style:[B?H.stretchOption:null,{opacity:a&&c?.55:1},z],children:({pressed:t})=>{const o={option:e,index:i,selected:r,pressed:t&&!a,disabled:a,color:n};return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:c?c(o):"chip"===d?renderChip(o):renderDefaultCard(o)})}},String(t))})});return(0,_ChoiceText.hasChoiceDetail)({description:C,error:E,helperText:J??void 0})?(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[C?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:S.space.xs},children:C}):null,K,void 0!==E?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:S.space.xs},children:E}):J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",style:{marginTop:S.space.xs},children:J}):null]}):K});ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>_reactNative.StyleSheet.create({stretchOption:{flex:1},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flex:1},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});var _default=exports.default=ChoiceGroup;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ChoiceGroup=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("../Radio/RadioDot.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=exports.ChoiceGroup=(0,_react.forwardRef)((e,i)=>{const{options:t,getOptionLabel:r,getOptionValue:o,isOptionDisabled:a,getOptionDescription:n,getOptionIcon:l,getOptionColor:s,renderOption:c,variant:d="card",indicatorPosition:u="trailing",direction:p="row",gap:x,wrap:h=!1,fullWidth:g,disabled:_=!1,size:m="md",labelLines:b,descriptionLines:v=2,haptic:j,accessibilityLabel:f,style:y,optionStyle:z,description:w,helperText:C,error:R,testID:V}=e,S=(0,_index2.useTheme)(),H=(0,_react.useMemo)(()=>buildStyles(S),[S]),I=(0,_react.useMemo)(()=>sizeTokensOf(S)[m],[S,m]);(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","variant",e.variant,["card","chip"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","direction",e.direction,["row","column"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const T=(0,_react.useCallback)(e=>r?r(e):e.label??"",[r]),k=(0,_react.useCallback)(e=>o?o(e):e.value,[o]),D=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),O=(0,_react.useCallback)(e=>n?n(e):e.description,[n]),G=(0,_react.useCallback)(e=>l?l(e):e.icon,[l]),q=(0,_react.useCallback)(e=>s?s(e):e.color,[s]),L="multiple"===e.selectionMode,{min:M,max:P}=e,[N,W]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(L?[]:void 0),onChange:e.onChange}),B=Array.isArray(N)?N:[],F=(0,_react.useCallback)(e=>{const i=k(e);if(L){const e=B.includes(i);if(e&&null!=M&&B.length<=M)return;if(!e&&null!=P&&B.length>=P)return;const t=(0,_index3.resolveHaptic)(j,"selection");return t&&(0,_index3.triggerHaptic)(t),void W(e?B.filter(e=>e!==i):[...B,i])}const t=(0,_index3.resolveHaptic)(j,"selection");t&&(0,_index3.triggerHaptic)(t),W(i)},[j,L,M,P,B,W,k]),A=g??("card"===d&&"row"===p&&!h),$=h||A&&"row"===p,E=S.radius.md,surfaceFor=(e,i,t)=>i?{borderColor:S.colors.border,backgroundColor:S.colors["surface-disabled"]}:{borderColor:e?t:S.colors.border,backgroundColor:e?(0,_color.tintOf)(t,.12,S.colors["surface-selected"]):S.colors.bg},renderIcon=(e,i,t,r)=>{const o=G(e);if(null==o)return null;const a="string"==typeof o&&i?{name:o,variant:"bold"}:o;return(0,_slotIcon.renderSlotIcon)(a,{color:t,size:I.iconSize,disabled:r})},renderChip=e=>{const{option:i,selected:t,disabled:r,color:o}=e,a=r?S.colors["text-disabled"]:t?o:S.colors["text-body"],n=renderIcon(i,t,a,r);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.chip,{minHeight:I.minHeight,paddingHorizontal:I.chipPaddingHorizontal,paddingVertical:I.paddingVertical,borderRadius:S.radius.pill,..._corners.smoothCorners,borderWidth:S.size.border,...surfaceFor(t,r,o),columnGap:S.space.xs}],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{children:n}):null,(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:b,ellipsizeMode:"tail",style:[H.cardLabel,{color:a,fontSize:I.fontSize,lineHeight:Math.round(I.fontSize*S.leading.body)}],children:T(i)})]})},renderDefaultCard=e=>{const{option:i,selected:t,disabled:r,color:o}=e,a=q(i),n=r?S.colors["text-disabled"]:a??S.colors["text-body"],l=O(i),s=renderIcon(i,t,n,r),c=(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:t,color:o,disabled:r,size:m});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.card,{minHeight:I.minHeight,paddingHorizontal:I.paddingHorizontal,paddingVertical:I.paddingVertical,borderRadius:E,..._corners.smoothCorners,borderWidth:S.size.border,...surfaceFor(t,r,o),columnGap:S.space.sm}],children:["leading"===u?c:null,s?(0,_jsxRuntime.jsx)(_reactNative.View,{children:s}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.cardTextWrap,children:[(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:b,ellipsizeMode:"tail",style:[H.cardLabel,{color:n,fontSize:I.fontSize,lineHeight:Math.round(I.fontSize*S.leading.body)}],children:T(i)}),l?(0,_jsxRuntime.jsx)(_index4.Text,{numberOfLines:v,ellipsizeMode:"tail",style:[H.cardDescription,{color:t?S.colors["text-muted"]:S.colors["text-subtle"],fontSize:S.text.xs.size,lineHeight:Math.round(S.text.xs.size*S.leading.body)}],children:l}):null]}),"trailing"===u?c:null]})},J="string"==typeof R&&""!==R?R:void 0,K=!0===R||void 0!==J?null:C,Q=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:i,accessibilityRole:L?void 0:"radiogroup",accessibilityLabel:f,accessibilityState:{disabled:_},"aria-disabled":_,testID:V,style:[{flexDirection:p,gap:x??S.space.sm,flexWrap:$?"wrap":"nowrap"},y],children:t.map((e,i)=>{const t=k(e),r=L?B.includes(t):N===t,o=L&&null!=P&&!r&&B.length>=P,a=_||o||D(e),n=q(e)??S.colors.primary,l=c||"card"!==d?void 0:O(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:e.testID,onPress:()=>{a||F(e)},disabled:a,accessibilityRole:L?"checkbox":"radio",accessibilityLabel:l?`${T(e)}, ${l}`:T(e),accessibilityState:{checked:r,disabled:a},"aria-checked":r,"aria-disabled":a,style:[A?H.stretchOption:null,{opacity:a&&c?.55:1},z],children:({pressed:t})=>{const o={option:e,index:i,selected:r,pressed:t&&!a,disabled:a,color:n};return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:c?c(o):"chip"===d?renderChip(o):renderDefaultCard(o)})}},String(t))})});return(0,_ChoiceText.hasChoiceDetail)({description:w,error:J,helperText:K??void 0})?(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[w?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:S.space.xs},children:w}):null,Q,void 0!==J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:S.space.xs},children:J}):K?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",style:{marginTop:S.space.xs},children:K}):null]}):Q});ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>_reactNative.StyleSheet.create({stretchOption:{flexGrow:1,flexShrink:0,flexBasis:"auto"},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flexGrow:1,flexShrink:1,flexBasis:"auto"},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});var _default=exports.default=ChoiceGroup;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FileViewer=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireDefault(require("react-native-reanimated")),_NativePdfRasterizer=_interopRequireDefault(require("../../specs/NativePdfRasterizer.js")),_index=require("../../theme/index.js"),_index2=require("../Spinner/index.js"),_FileViewerImage=require("./FileViewerImage.js"),_FileViewerPage=require("./FileViewerPage.js"),_fileSource=require("./fileSource.js"),_useFileViewerZoom=require("./useFileViewerZoom.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const MAX_RENDER_SCALE=5,RENDER_OVERSCALE=1.25,RENDER_AHEAD=3,MOUNT_AROUND=2,DEFAULT_MAX_ZOOM=4,toError=e=>e instanceof Error?e:new Error(String(e)),scaleForWidth=(e,t,r)=>{if(t<=0)return 1;const i=e/t*_reactNative.PixelRatio.get()*1.25*r;return Math.round(100*Math.min(Math.max(i,1),5))/100},AnimatedScrollView=_reactNativeReanimated.default.createAnimatedComponent(_reactNative.ScrollView),FileViewerPdf=({source:e,onLoadComplete:t,onPageChanged:r,onError:i,loadingIndicator:a,zoomEnabled:l=!0,maxZoom:s=4,style:n,testID:o,accessibilityLabel:c})=>{const u=(0,_index.useTheme)().space.sm,{width:d,height:_}=(0,_reactNative.useWindowDimensions)(),[h,f]=(0,_react.useState)({width:0,height:0}),[m,w]=(0,_react.useState)(0),[g,R]=(0,_react.useState)({width:612,height:792}),p=g.height/g.width,[x,v]=(0,_react.useState)({}),[j,V]=(0,_react.useState)(null),[y,b]=(0,_react.useState)(0),F=(0,_react.useRef)(0),E=(0,_react.useRef)(null),S=(0,_react.useRef)(null),N=(0,_react.useRef)(i);N.current=i;const P=(0,_react.useRef)(t);P.current=t;const M=(0,_react.useRef)(r);M.current=r;const q=(0,_react.useRef)(a);q.current=a;const z=d*p,C=z+u,D=h.height>0?h.height:_,{scrollRef:Z,scrollGesture:O,zoomGesture:A,zoomStyle:L,zoomLevel:G,resetZoom:H}=(0,_useFileViewerZoom.useFileViewerZoom)({zoomEnabled:l,maxZoom:s,viewportWidth:h.width>0?h.width:d,viewportHeight:D,maxScroll:Math.max(0,m*C-u-D)}),I=(0,_react.useMemo)(()=>({uri:e.uri,headers:e.headers,client:e.client,cache:e.cache}),[e.uri,e.headers,e.client,e.cache]);(0,_react.useEffect)(()=>{let e=!1;return(async()=>{if(_NativePdfRasterizer.default)try{const t=await(0,_fileSource.localPathFromSource)(I);if(e)return;const r=await _NativePdfRasterizer.default.open(t);if(e)return void await _NativePdfRasterizer.default.close(r.handle).catch(()=>{});E.current=r.handle,F.current=0,w(r.pageCount),b(0),v({}),V(null),H(),r.pageWidth>0&&r.pageHeight>0&&R({width:r.pageWidth,height:r.pageHeight}),P.current?.(r.pageCount)}catch(t){if(!e){const e=toError(t);_mobileCore.Logger.error("[@webority/mobile-ui] FileViewer failed to load.",e),N.current?.(e)}}else N.current?.(new Error("[@webority/mobile-ui] PdfRasterizer native module is not linked. Run pod install / rebuild the app after adding @webority/mobile-ui."))})(),()=>{e=!0;const t=E.current;E.current=null,t&&_NativePdfRasterizer.default?.close(t).catch(()=>{})}},[I,H]);const k=scaleForWidth(d,g.width,1),T=G>_useFileViewerZoom.ZOOM_REST?scaleForWidth(d,g.width,Math.ceil(G)):0,W=(0,_react.useCallback)(async()=>{const e=E.current;if(!e||!_NativePdfRasterizer.default||0===m)return;if(S.current===e)return;let t;if(void 0===x[y])t={page:y,scale:k,sharp:!1};else if(T>k&&null!==x[y]&&(j?.page!==y||j.scale!==T))t={page:y,scale:T,sharp:!0};else for(let e=1;e<=3&&!t;e+=1)for(const r of[y+e,y-e])if(r>=0&&r<m&&void 0===x[r]){t={page:r,scale:k,sharp:!1};break}if(!t)return;const{page:r,scale:i,sharp:a}=t;S.current=e;let l=null;try{l=await _NativePdfRasterizer.default.renderPage(e,r,i)}catch(t){E.current===e&&_mobileCore.Logger.error(`[@webority/mobile-ui] FileViewer failed to render page ${r}.`,toError(t))}finally{S.current===e&&(S.current=null)}E.current===e&&(a?V({page:r,scale:i,uri:l}):v(e=>({...e,[r]:l})))},[k,y,m,x,j,T]);(0,_react.useEffect)(()=>{W()},[W]),(0,_react.useEffect)(()=>{G<=_useFileViewerZoom.ZOOM_REST&&V(null)},[G]);const U=(0,_react.useCallback)(e=>{const{width:t,height:r}=e.nativeEvent.layout;f(e=>e.width===t&&e.height===r?e:{width:t,height:r})},[]),X=(0,_react.useCallback)(e=>{if(C<=0||0===m)return;const t=Math.min(m-1,Math.max(0,Math.round(e.nativeEvent.contentOffset.y/C)));t!==F.current&&(F.current=t,b(t),M.current?.(t+1,m))},[m,C]),K=(0,_react.useCallback)(()=>q.current?.()??(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"lg"}),[]),$=(0,_react.useMemo)(()=>({gap:u}),[u]),B=(0,_react.useMemo)(()=>Array.from({length:m},(e,t)=>t),[m]),J=G>_useFileViewerZoom.ZOOM_REST;return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:[styles.root,n],onLayout:U,testID:o,accessible:void 0!==c,accessibilityLabel:c,accessibilityRole:"none",children:0===m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.pagePlaceholder,children:a?a():(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"lg"})}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:A,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.viewport,collapsable:!1,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.viewport,L],children:(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:O,children:(0,_jsxRuntime.jsx)(AnimatedScrollView,{ref:Z,onScroll:X,scrollEventThrottle:16,scrollEnabled:!J,showsVerticalScrollIndicator:!J,contentContainerStyle:$,children:B.map(e=>(0,_jsxRuntime.jsx)(_FileViewerPage.FileViewerPage,{width:d,height:z,uri:J&&j?.page===e&&j.uri?j.uri:x[e],mounted:Math.abs(e-y)<=2,renderLoading:K},e))})})})})})})},FileViewer=({kind:e="auto",...t})=>"image"===(0,_fileSource.resolveKind)(e,t.source.uri)?(0,_jsxRuntime.jsx)(_FileViewerImage.FileViewerImage,{...t}):(0,_jsxRuntime.jsx)(FileViewerPdf,{...t});exports.FileViewer=FileViewer,FileViewer.displayName="FileViewer";const styles=_reactNative.StyleSheet.create({root:{flex:1,overflow:"hidden"},viewport:{flex:1},pagePlaceholder:{flex:1,alignItems:"center",justifyContent:"center"}});var _default=exports.default=FileViewer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FileViewer=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireDefault(require("react-native-reanimated")),_NativePdfRasterizer=_interopRequireDefault(require("../../specs/NativePdfRasterizer.js")),_index=require("../../theme/index.js"),_index2=require("../Spinner/index.js"),_FileViewerImage=require("./FileViewerImage.js"),_FileViewerPage=require("./FileViewerPage.js"),_fileSource=require("./fileSource.js"),_useFileViewerZoom=require("./useFileViewerZoom.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const MAX_RENDER_SCALE=5,RENDER_OVERSCALE=1.25,RENDER_AHEAD=3,MOUNT_AROUND=2,DEFAULT_MAX_ZOOM=4,toError=e=>e instanceof Error?e:new Error(String(e)),scaleForWidth=(e,t,r)=>{if(t<=0)return 1;const i=e/t*_reactNative.PixelRatio.get()*1.25*r;return Math.round(100*Math.min(Math.max(i,1),5))/100},AnimatedScrollView=_reactNativeReanimated.default.createAnimatedComponent(_reactNative.ScrollView),FileViewerPdf=({source:e,onLoadComplete:t,onPageChanged:r,onError:i,loadingIndicator:a,zoomEnabled:l=!0,maxZoom:n=4,style:s,testID:o,accessibilityLabel:c})=>{const u=(0,_index.useTheme)().space.sm,{width:d,height:_}=(0,_reactNative.useWindowDimensions)(),[h,f]=(0,_react.useState)({width:0,height:0}),m=h.width>0?h.width:d,[w,g]=(0,_react.useState)(0),[R,p]=(0,_react.useState)({width:612,height:792}),v=R.height/R.width,[x,j]=(0,_react.useState)({}),[V,y]=(0,_react.useState)(null),[b,E]=(0,_react.useState)(0),F=(0,_react.useRef)(0),S=(0,_react.useRef)(null),N=(0,_react.useRef)(null),P=(0,_react.useRef)(i);P.current=i;const M=(0,_react.useRef)(t);M.current=t;const q=(0,_react.useRef)(r);q.current=r;const z=(0,_react.useRef)(a);z.current=a;const C=m*v,D=C+u,Z=h.height>0?h.height:_,{scrollRef:O,scrollGesture:A,zoomGesture:L,zoomStyle:G,zoomLevel:H,resetZoom:I}=(0,_useFileViewerZoom.useFileViewerZoom)({zoomEnabled:l,maxZoom:n,viewportWidth:h.width>0?h.width:d,viewportHeight:Z,maxScroll:Math.max(0,w*D-u-Z)}),k=(0,_react.useMemo)(()=>({uri:e.uri,headers:e.headers,client:e.client,cache:e.cache}),[e.uri,e.headers,e.client,e.cache]);(0,_react.useEffect)(()=>{let e=!1;return(async()=>{if(_NativePdfRasterizer.default)try{const t=await(0,_fileSource.localPathFromSource)(k);if(e)return;const r=await _NativePdfRasterizer.default.open(t);if(e)return void await _NativePdfRasterizer.default.close(r.handle).catch(()=>{});S.current=r.handle,F.current=0,g(r.pageCount),E(0),j({}),y(null),I(),r.pageWidth>0&&r.pageHeight>0&&p({width:r.pageWidth,height:r.pageHeight}),M.current?.(r.pageCount)}catch(t){if(!e){const e=toError(t);_mobileCore.Logger.error("[@webority/mobile-ui] FileViewer failed to load.",e),P.current?.(e)}}else P.current?.(new Error("[@webority/mobile-ui] PdfRasterizer native module is not linked. Run pod install / rebuild the app after adding @webority/mobile-ui."))})(),()=>{e=!0;const t=S.current;S.current=null,t&&_NativePdfRasterizer.default?.close(t).catch(()=>{})}},[k,I]);const T=scaleForWidth(m,R.width,1),W=H>_useFileViewerZoom.ZOOM_REST?scaleForWidth(m,R.width,Math.ceil(H)):0,U=(0,_react.useRef)(T);U.current=T;const X=(0,_react.useRef)(W);X.current=W;const K=(0,_react.useRef)(T);(0,_react.useEffect)(()=>{K.current!==T&&(K.current=T,j({}))},[T]);const $=(0,_react.useCallback)(async()=>{const e=S.current;if(!e||!_NativePdfRasterizer.default||0===w)return;if(N.current===e)return;let t;if(void 0===x[b])t={page:b,scale:T,sharp:!1};else if(W>T&&null!==x[b]&&(V?.page!==b||V.scale!==W))t={page:b,scale:W,sharp:!0};else for(let e=1;e<=3&&!t;e+=1)for(const r of[b+e,b-e])if(r>=0&&r<w&&void 0===x[r]){t={page:r,scale:T,sharp:!1};break}if(!t)return;const{page:r,scale:i,sharp:a}=t;N.current=e;let l=null;try{l=await _NativePdfRasterizer.default.renderPage(e,r,i)}catch(t){S.current===e&&_mobileCore.Logger.error(`[@webority/mobile-ui] FileViewer failed to render page ${r}.`,toError(t))}finally{N.current===e&&(N.current=null)}S.current===e&&(i===(a?X.current:U.current)?a?y({page:r,scale:i,uri:l}):j(e=>({...e,[r]:l})):j(e=>({...e})))},[T,b,w,x,V,W]);(0,_react.useEffect)(()=>{$()},[$]),(0,_react.useEffect)(()=>{H<=_useFileViewerZoom.ZOOM_REST&&y(null)},[H]);const B=(0,_react.useCallback)(e=>{const{width:t,height:r}=e.nativeEvent.layout;f(e=>e.width===t&&e.height===r?e:{width:t,height:r})},[]),J=(0,_react.useCallback)(e=>{if(D<=0||0===w)return;const t=Math.min(w-1,Math.max(0,Math.round(e.nativeEvent.contentOffset.y/D)));t!==F.current&&(F.current=t,E(t),q.current?.(t+1,w))},[w,D]),Q=(0,_react.useCallback)(()=>z.current?.()??(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"lg"}),[]),Y=(0,_react.useMemo)(()=>({gap:u}),[u]),ee=(0,_react.useMemo)(()=>Array.from({length:w},(e,t)=>t),[w]),te=H>_useFileViewerZoom.ZOOM_REST;return(0,_jsxRuntime.jsxs)(_reactNativeGestureHandler.GestureHandlerRootView,{style:[styles.root,s],onLayout:B,testID:o,accessible:void 0!==c,accessibilityLabel:c,accessibilityRole:"none",children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:L,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.viewport,collapsable:!1,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.viewport,G],children:(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:A,children:(0,_jsxRuntime.jsx)(AnimatedScrollView,{ref:O,onScroll:J,scrollEventThrottle:16,scrollEnabled:!te,showsVerticalScrollIndicator:!te,contentContainerStyle:Y,children:ee.map(e=>(0,_jsxRuntime.jsx)(_FileViewerPage.FileViewerPage,{width:m,height:C,uri:te&&V?.page===e&&V.uri?V.uri:x[e],mounted:Math.abs(e-b)<=2,renderLoading:Q},e))})})})})}),0===w&&(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,styles.pagePlaceholder],children:a?a():(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"lg"})})]})},FileViewer=({kind:e="auto",...t})=>"image"===(0,_fileSource.resolveKind)(e,t.source.uri)?(0,_jsxRuntime.jsx)(_FileViewerImage.FileViewerImage,{...t}):(0,_jsxRuntime.jsx)(FileViewerPdf,{...t});exports.FileViewer=FileViewer,FileViewer.displayName="FileViewer";const styles=_reactNative.StyleSheet.create({root:{flex:1,overflow:"hidden"},viewport:{flex:1},pagePlaceholder:{flex:1,alignItems:"center",justifyContent:"center"}});var _default=exports.default=FileViewer;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=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"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:n,onChange:a,onComplete:r,length:s=6,keyboardType:l="number-pad",autoFocus:o=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:p=!1,haptic:m,labels:x,onFocus:g,accessibilityLabel:f,style:v,cellStyle:h,textStyle:b,testID:y}=e;(0,_warnInvalidValue.warnInvalidValue)("OTPInput","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("OTPInput","keyboardType",e.keyboardType,["number-pad","default"]);const T=x?{...DEFAULT_OTP_INPUT_LABELS,...x}:DEFAULT_OTP_INPUT_LABELS,[j,N]=(0,_index.useControllableState)({value:i,defaultValue:n??"",onChange:a}),I=(0,_index2.useTheme)(),E=(0,_react.useMemo)(()=>buildStyles(I),[I]),A=(0,_index2.resolveOtpInputSize)(I,_),V=I.components["otp-input"][_].radius,w=(0,_react.useRef)([]),[F,P]=(0,_react.useState)(-1),R=(0,_react.useRef)(null),O=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,C=(0,_react.useRef)(new Map),k=(0,_react.useMemo)(()=>{const e=C.current,t=[];for(let i=0;i<s;i+=1){let n=e.get(i);n||(n=new _reactNative.Animated.Value(0),e.set(i,n)),t.push(n)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),S=(0,_react.useRef)(-1),L=I.settings.components["otp-input"]?.shakeOnError??!1,B=(0,_index.useReducedMotion)(),D=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===R.current||!D||R.current||(m&&(0,_index3.triggerHaptic)("notificationError"),L&&!B&&((0,_index2.setNativeValue)(O,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(O,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(O,{toValue:-1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(O,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(O,{toValue:0,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0})]),e.start())),R.current=D,()=>e?.stop()},[D,O,L,m,B,I.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=S.current;if(S.current=F,e===F)return;if(-1===e&&-1===F)return;const t=[];return k.forEach((i,n)=>{const a=n===F?1:0;if(n!==F&&n!==e)return;const r=_reactNative.Animated.timing(i,{toValue:a,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!0});r.start(),t.push(r)}),()=>t.forEach(e=>{e.stop()})},[F,k,I]);const z=(0,_react.useCallback)(e=>{const t=w.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>z(0),blur:()=>{const e=w.current[F>=0?F:0];e?.blur()},clear:()=>{N(""),z(0)}}),[z,F,N]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>z(0),c);return()=>clearTimeout(e)}},[o,c,u,z]);const q=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(j.length,s);t+=1)e[t]=j[t]??"";return e},[j,s]),U=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==j&&(N(t),t.length===s&&r&&r(t))},[s,N,r,j]),M=(0,_react.useCallback)((e,t)=>{const i=t.replace(/\u200B/g,""),n=sanitizeChar(i,l);if(!n){const t=q.slice(),i=(t[e]??"").length>0;if(t[e]="",U(t.join("").slice(0,s)),!i&&e>0){const t=q.slice();t[e-1]="",U(t.join("")),z(e-1)}return}const a=q[e]??"",r=a&&n.length>s&&n.startsWith(a)?n.slice(a.length):n;if(r.length>=s){const t=r.slice(0,s),i=j.length;return U(t),t.length!==i&&m&&(0,_index3.triggerHaptic)(m),void w.current[e]?.blur()}const o=q.slice();let c=e;for(let e=0;e<n.length&&c<s;e+=1)o[c]=n[e]??"",c+=1;const u=o.join("").slice(0,s),d=j.length;U(u),u.length!==d&&m&&(0,_index3.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?w.current[e]?.blur():z(_)},[q,z,l,s,m,U,j]),H=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===(q[e]??"").length){if(e>0){const t=q.slice();t[e-1]="",U(t.join("")),z(e-1)}}else{const t=q.slice();t[e]="",U(t.join(""))}},[q,z,U]),W=(0,_react.useCallback)((e,t)=>{P(e),g?.(t)},[g]),$=(0,_react.useCallback)(()=>{P(-1)},[]),G=(0,_react.useCallback)(()=>{if(u)return;const e=q.indexOf("");z(-1===e?s-1:e)},[q,u,z,s]),K=f??T.field(s),X=O.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:v,accessible:!0,accessibilityRole:"none",accessibilityLabel:K,accessibilityValue:{text:i},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:G,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.row,{columnGap:A.gap,transform:[{translateX:X}]}],children:q.map((e,t)=>{const i=F===t,n=e.length>0,a=D?I.colors["danger-border"]:I.colors["focus-ring"],r=k[t];if(!r)return null;const o=p&&n?"●":e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:A.cell,height:A.cell,radius:V,borderWidth:1.5,focused:i,error:D,filled:n,disabled:u,paddingHorizontal:I.space.none,paddingVertical:I.space.none,gap:I.space.none,style:h,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{w.current[t]=e},value:(p&&n?"":e)||"​",onChangeText:e=>M(t,e),onKeyPress:e=>H(t,e),onFocus:e=>W(t,e),onBlur:$,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:n,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[E.input,{fontSize:A.text,color:I.colors["text-body"],...(0,_index2.fontFor)(I,"semibold")},b]}),p&&n?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:E.maskOverlay,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:[{fontSize:A.text},b],children:o})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.underline,{backgroundColor:a,opacity:r}]})]},`otp-cell-${t}`)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=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"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:a,defaultValue:i,onChange:n,onComplete:r,length:s=6,keyboardType:l="number-pad",autoFocus:o=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:p=!1,haptic:m,labels:x,onFocus:g,accessibilityLabel:f,style:h,cellStyle:v,textStyle:b,testID:y}=e;(0,_warnInvalidValue.warnInvalidValue)("OTPInput","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("OTPInput","keyboardType",e.keyboardType,["number-pad","default"]);const T=x?{...DEFAULT_OTP_INPUT_LABELS,...x}:DEFAULT_OTP_INPUT_LABELS,[j,N]=(0,_index.useControllableState)({value:a,defaultValue:i??"",onChange:n}),I=(0,_index2.useTheme)(),E=(0,_react.useMemo)(()=>buildStyles(I),[I]),A=(0,_index2.resolveOtpInputSize)(I,_),w=I.components["otp-input"][_].radius,V=(0,_react.useRef)([]),[F,P]=(0,_react.useState)(-1),[R,C]=(0,_react.useState)(0),O=(0,_react.useRef)(null),k=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,S=(0,_react.useRef)(new Map),L=(0,_react.useMemo)(()=>{const e=S.current,t=[];for(let a=0;a<s;a+=1){let i=e.get(a);i||(i=new _reactNative.Animated.Value(0),e.set(a,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),B=(0,_react.useRef)(-1),D=I.settings.components["otp-input"]?.shakeOnError??!1,z=(0,_index.useReducedMotion)(),M=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===O.current||!M||O.current||(m&&(0,_index3.triggerHaptic)("notificationError"),D&&!z&&((0,_index2.setNativeValue)(k,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(k,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:-1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:0,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0})]),e.start())),O.current=M,()=>e?.stop()},[M,k,D,m,z,I.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=B.current;if(B.current=F,e===F)return;if(-1===e&&-1===F)return;const t=[];return L.forEach((a,i)=>{const n=i===F?1:0;if(i!==F&&i!==e)return;const r=_reactNative.Animated.timing(a,{toValue:n,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!0});r.start(),t.push(r)}),()=>t.forEach(e=>{e.stop()})},[F,L,I]);const q=(0,_react.useCallback)(e=>{const t=V.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>q(0),blur:()=>{const e=V.current[F>=0?F:0];e?.blur()},clear:()=>{N(""),q(0)}}),[q,F,N]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>q(0),c);return()=>clearTimeout(e)}},[o,c,u,q]);const U=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(j.length,s);t+=1)e[t]=j[t]??"";return e},[j,s]),H=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==j&&(N(t),t.length===s&&r&&r(t))},[s,N,r,j]),W=(0,_react.useCallback)((e,t)=>{const a=t.replace(/\u200B/g,""),i=sanitizeChar(a,l);if(!i){const t=U.slice(),a=(t[e]??"").length>0;if(t[e]="",H(t.join("").slice(0,s)),!a&&e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}return}const n=U[e]??"",r=n&&i.length>s&&i.startsWith(n)?i.slice(n.length):i;if(r.length>=s){const t=r.slice(0,s),a=j.length;return H(t),t.length!==a&&m&&(0,_index3.triggerHaptic)(m),void V.current[e]?.blur()}const o=U.slice();let c=e;for(let e=0;e<i.length&&c<s;e+=1)o[c]=i[e]??"",c+=1;const u=o.join("").slice(0,s),d=j.length;H(u),u.length!==d&&m&&(0,_index3.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?V.current[e]?.blur():q(_)},[U,q,l,s,m,H,j]),$=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===(U[e]??"").length){if(e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}}else{const t=U.slice();t[e]="",H(t.join(""))}},[U,q,H]),G=(0,_react.useCallback)((e,t)=>{P(e),g?.(t)},[g]),K=(0,_react.useCallback)(()=>{P(-1)},[]),X=(0,_react.useCallback)(()=>{if(u)return;const e=U.indexOf("");q(-1===e?s-1:e)},[U,u,q,s]),J=(0,_react.useCallback)(e=>{C(e.nativeEvent.layout.width)},[]),Q=f??T.field(s),Y=R>0?Math.max(24,Math.min(A.cell,Math.floor((R-A.gap*(s-1))/s))):A.cell,Z=k.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h,onLayout:J,accessible:!0,accessibilityRole:"none",accessibilityLabel:Q,accessibilityValue:{text:a},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:X,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.row,{columnGap:A.gap,transform:[{translateX:Z}]}],children:U.map((e,t)=>{const a=F===t,i=e.length>0,n=M?I.colors["danger-border"]:I.colors["focus-ring"],r=L[t];if(!r)return null;const o=p&&i?"●":e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:Y,height:Y,radius:w,borderWidth:1.5,focused:a,error:M,filled:i,disabled:u,paddingHorizontal:I.space.none,paddingVertical:I.space.none,gap:I.space.none,style:v,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{V.current[t]=e},value:(p&&i?"":e)||"​",onChangeText:e=>W(t,e),onKeyPress:e=>$(t,e),onFocus:e=>G(t,e),onBlur:K,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:i,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[E.input,{fontSize:A.text,color:I.colors["text-body"],...(0,_index2.fontFor)(I,"semibold")},b]}),p&&i?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:E.maskOverlay,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:[{fontSize:A.text},b],children:o})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.underline,{backgroundColor:n,opacity:r}]})]},`otp-cell-${t}`)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ScannerOverlay=exports.DEFAULT_SCANNER_OVERLAY_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../IconButton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,LIFT=.06,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}],DEFAULT_SCANNER_OVERLAY_LABELS=exports.DEFAULT_SCANNER_OVERLAY_LABELS=Object.freeze({hint:"Point the camera at the code",found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."}),ScannerOverlay=exports.ScannerOverlay=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:i,state:n="scanning",helperText:a,labels:r,torch:s=!1,onTorchChange:o,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:u=DEFAULT_FRAME,haptic:m,style:h,testID:_}=e,x=(0,_index.useTheme)(),p=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),f=(0,_useReducedMotion.useReducedMotion)(),v=(0,_react.useMemo)(()=>buildStyles(x),[x]),g=(0,_react.useMemo)(()=>({...DEFAULT_SCANNER_OVERLAY_LABELS,...r}),[r]),y=a??g.hint,[j,b]=(0,_react.useState)({width:0,height:0}),R="scanning"===n||"found"===n||"invalid"===n,A=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,E=x.motion.duration.slower,N=x.motion.duration.default;(0,_react.useEffect)(()=>{if(A.setValue(1),f)return;let e;return"scanning"===n&&E>0?e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(A,{toValue:1.03,duration:2*E,useNativeDriver:!0}),_reactNative.Animated.timing(A,{toValue:1,duration:2*E,useNativeDriver:!0})])):"found"===n&&N>0&&(A.setValue(1.08),e=_reactNative.Animated.timing(A,{toValue:1,duration:N,useNativeDriver:!0})),e?.start(),()=>e?.stop()},[n,f,E,N,A]);const S=(0,_react.useRef)(n);(0,_react.useEffect)(()=>{S.current!==n&&(S.current=n,!1!==m&&("found"===n?(0,_hapticUtils.triggerHaptic)("notificationSuccess"):"invalid"===n&&(0,_hapticUtils.triggerHaptic)("notificationError")))},[n,m]);const{found:w,invalid:V}=g,{noPermissionTitle:C,noPermissionMessage:L}=g,{noCameraTitle:M,noCameraMessage:O}=g;(0,_react.useEffect)(()=>{switch(n){case"scanning":(0,_announce.announce)(y);break;case"found":(0,_announce.announce)(w);break;case"invalid":(0,_announce.announce)(V,{polite:!1});break;case"noPermission":(0,_announce.announce)(`${C}. ${L}`);break;case"noCamera":(0,_announce.announce)(`${M}. ${O}`)}},[n,y,w,V,C,L,M,O]);const I=Math.max(240,Math.min(u,j.width-2*x.space.xl)),P=(j.width-I)/2,k=Math.max(x.space.md,(j.height-I)/2-.06*j.height),q=j.width>0&&j.height>0,F={borderColor:"found"===n?x.colors.success:"invalid"===n?x.colors.danger:x.colors["on-scrim"],width:32,height:32},B="found"===n||"invalid"===n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.pill,{backgroundColor:"found"===n?x.colors.success:x.colors.danger}],children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===n?x.colors["on-success"]:x.colors["on-danger"]},children:"found"===n?w:V})}):(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",align:"center",style:{color:x.colors["on-scrim"]},children:y}),D=R&&null!=o,U=R?"glass":"outline";return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,testID:_,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;b(e=>e.width===t&&e.height===i?e:{width:t,height:i})},style:[v.root,!R&&{backgroundColor:x.colors.bg},h],children:[R?(0,_jsxRuntime.jsx)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,children:i}):null,R&&q?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",style:_reactNative.StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,right:0,top:0,height:k}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,right:0,top:k+I,bottom:0}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,width:P,top:k,height:I}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:P+I,right:0,top:k,height:I}]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{position:"absolute",left:P,top:k,width:I,height:I,transform:[{scale:A}]},children:CORNERS.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.mark,F,e.style]},e.key))})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[v.message,{top:k+I+x.space.md}],children:B})]}):null,R?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:v.panel,children:(0,_jsxRuntime.jsx)(_index4.EmptyState,{fill:!0,icon:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"noPermission"===n?"camera":"camera-slash",size:48,color:x.colors["text-subtle"]}),title:"noPermission"===n?C:M,description:"noPermission"===n?L:O,action:"noPermission"===n&&d?{label:g.permissionAction,onPress:d}:void 0})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"box-none",style:[v.bar,{paddingBottom:Math.max(p.bottom,x.space.md)}],children:[D?(0,_jsxRuntime.jsx)(_index5.IconButton,{icon:s?"flash":"flash-slash",variant:"glass",size:"lg",active:s,haptic:m,accessibilityLabel:s?g.torchOff:g.torchOn,onPress:()=>o?.(!s)}):null,c?(0,_jsxRuntime.jsx)(_index3.Button,{label:g.gallery,leftIcon:"gallery",variant:U,tone:"neutral",size:"lg",haptic:m,onPress:c}):null,l?(0,_jsxRuntime.jsx)(_index3.Button,{label:g.manualEntry,leftIcon:"keyboard",variant:U,tone:"neutral",size:"lg",haptic:m,onPress:l}):null]})]})});ScannerOverlay.displayName="ScannerOverlay";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.scrim},mark:{position:"absolute"},message:{position:"absolute",left:0,right:0,alignItems:"center",paddingHorizontal:e.space.xl},pill:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners},panel:{..._reactNative.StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.space.sm,paddingHorizontal:e.space.md}});var _default=exports.default=ScannerOverlay;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ScannerOverlay=exports.DEFAULT_SCANNER_OVERLAY_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../IconButton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,LIFT=.06,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}],DEFAULT_SCANNER_OVERLAY_LABELS=exports.DEFAULT_SCANNER_OVERLAY_LABELS=Object.freeze({hint:"Point the camera at the code",found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."}),ScannerOverlay=exports.ScannerOverlay=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:i,state:n="scanning",helperText:a,labels:r,torch:s=!1,onTorchChange:o,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:u=DEFAULT_FRAME,haptic:m,style:h,testID:_}=e,x=(0,_index.useTheme)(),p=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),f=(0,_useReducedMotion.useReducedMotion)(),v=(0,_react.useMemo)(()=>buildStyles(x),[x]),g=(0,_react.useMemo)(()=>({...DEFAULT_SCANNER_OVERLAY_LABELS,...r}),[r]),y=a??g.hint,[j,b]=(0,_react.useState)({width:0,height:0}),R="scanning"===n||"found"===n||"invalid"===n,A=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,N=x.motion.duration.slower,E=x.motion.duration.default;(0,_react.useEffect)(()=>{if(A.setValue(1),f)return;let e;return"scanning"===n&&N>0?e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(A,{toValue:1.03,duration:2*N,useNativeDriver:!0}),_reactNative.Animated.timing(A,{toValue:1,duration:2*N,useNativeDriver:!0})])):"found"===n&&E>0&&(A.setValue(1.08),e=_reactNative.Animated.timing(A,{toValue:1,duration:E,useNativeDriver:!0})),e?.start(),()=>e?.stop()},[n,f,N,E,A]);const S=(0,_react.useRef)(n);(0,_react.useEffect)(()=>{S.current!==n&&(S.current=n,!1!==m&&("found"===n?(0,_hapticUtils.triggerHaptic)("notificationSuccess"):"invalid"===n&&(0,_hapticUtils.triggerHaptic)("notificationError")))},[n,m]);const{found:w,invalid:V}=g,{noPermissionTitle:C,noPermissionMessage:L}=g,{noCameraTitle:M,noCameraMessage:I}=g;(0,_react.useEffect)(()=>{switch(n){case"scanning":(0,_announce.announce)(y);break;case"found":(0,_announce.announce)(w);break;case"invalid":(0,_announce.announce)(V,{polite:!1});break;case"noPermission":(0,_announce.announce)(`${C}. ${L}`);break;case"noCamera":(0,_announce.announce)(`${M}. ${I}`)}},[n,y,w,V,C,L,M,I]);const O=Math.max(240,Math.min(u,j.width-2*x.space.xl)),P=(j.width-O)/2,k=Math.max(x.space.md,(j.height-O)/2-.06*j.height),q=j.width>0&&j.height>0,F={borderColor:"found"===n?x.colors.success:"invalid"===n?x.colors.danger:x.colors["on-scrim"],width:32,height:32},B="found"===n||"invalid"===n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.pill,{backgroundColor:"found"===n?x.colors.success:x.colors.danger}],children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===n?x.colors["on-success"]:x.colors["on-danger"]},children:"found"===n?w:V})}):(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",align:"center",style:{color:x.colors["on-scrim"]},children:y}),D=R&&null!=o,U=R?"glass":"outline";return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,testID:_,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;b(e=>e.width===t&&e.height===i?e:{width:t,height:i})},style:[v.root,!R&&{backgroundColor:x.colors.bg},h],children:[R?(0,_jsxRuntime.jsx)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,children:i}):null,R&&q?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",style:_reactNative.StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,right:0,top:0,height:k}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,right:0,top:k+O,bottom:0}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,width:P,top:k,height:O}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:P+O,right:0,top:k,height:O}]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{position:"absolute",left:P,top:k,width:O,height:O,transform:[{scale:A}]},children:CORNERS.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.mark,F,e.style]},e.key))})]})}):null,R?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:v.panel,children:(0,_jsxRuntime.jsx)(_index4.EmptyState,{fill:!0,icon:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"noPermission"===n?"camera":"camera-slash",size:48,color:x.colors["text-subtle"]}),title:"noPermission"===n?C:M,description:"noPermission"===n?L:I,action:"noPermission"===n&&d?{label:g.permissionAction,onPress:d}:void 0})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"box-none",style:[v.bar,{paddingBottom:Math.max(p.bottom,x.space.md)}],children:[R&&q?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:v.message,children:B}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:v.actions,children:[D?(0,_jsxRuntime.jsx)(_index5.IconButton,{icon:s?"flash":"flash-slash",variant:"glass",size:"lg",active:s,haptic:m,accessibilityLabel:s?g.torchOff:g.torchOn,onPress:()=>o?.(!s)}):null,c?(0,_jsxRuntime.jsx)(_index3.Button,{label:g.gallery,leftIcon:"gallery",variant:U,tone:"neutral",size:"lg",haptic:m,onPress:c}):null,l?(0,_jsxRuntime.jsx)(_index3.Button,{label:g.manualEntry,leftIcon:"keyboard",variant:U,tone:"neutral",size:"lg",haptic:m,onPress:l}):null]})]})]})});ScannerOverlay.displayName="ScannerOverlay";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.scrim},mark:{position:"absolute"},message:{alignItems:"center",paddingHorizontal:e.space.xl},pill:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners},panel:{..._reactNative.StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.space.sm,paddingHorizontal:e.space.md},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.space.sm}});var _default=exports.default=ScannerOverlay;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Screen=Screen;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=require("react-native-reanimated"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useRefreshControl=require("../../hooks/useRefreshControl.js"),_index=require("../../theme/index.js"),_index2=require("../AppBar/index.js"),_index3=require("../AsyncBlock/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../KeyboardAwareScrollView/index.js"),_index6=require("../KeyboardToolbar/index.js"),_index7=require("../PagedListFooter/index.js"),_ScrollHost=require("./ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{};function renderFooter(e){return(0,_react.isValidElement)(e)?e:e?(0,_react.createElement)(e):null}const topPaddingOf=e=>{const t=_reactNative.StyleSheet.flatten(e),o=t?.paddingTop??t?.paddingVertical??t?.padding;return"number"==typeof o?o:0},buildStyles=e=>_reactNative.StyleSheet.create({flex:{flex:1},root:{flex:1,backgroundColor:e.colors.bg},overlay:{position:"absolute",top:0,left:0,right:0},footer:{backgroundColor:e.colors.bg,borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:e.colors.border}});function Screen(e){const{title:t,subtitle:o,largeTitle:r=!0,onBack:n,rightActions:a,leading:i,children:l,onRefresh:s,refreshing:c=!1,footer:d,scroll:u=!0,list:_,edges:f=DEFAULT_EDGES,keyboardToolbar:m=!0,bottomInset:p=0,gutter:x,floatingAction:v,scrollRef:g,onScroll:h,contentContainerStyle:y,testID:R}=e,S=(0,_index.useTheme)(),b=x??void 0===_,j=S.space[S.components.screen.gutter],C=b?j:0,E=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),T=(0,_react.useMemo)(()=>buildStyles(S),[S]),[L]=(0,_react.useState)(()=>new _reactNative.Animated.Value(0)),[N,k]=(0,_react.useState)(0),[A,V]=(0,_react.useState)(0),O=void 0!==n,q=(0,_react.useRef)(n);q.current=n;const w=Boolean(t||o||n||i||a?.length),B=r&&void 0!==t,F=B&&(void 0!==_||u),M=F?N:0,headerGap=e=>e>0?e:F?S.space.lg:0,H=void 0!==d,{refreshControl:P}=(0,_useRefreshControl.useRefreshControl)({onRefresh:s??noop,refreshing:c}),D=s?(0,_react.cloneElement)(P,{progressViewOffset:M}):void 0,K=(0,_reactNativeReanimated.useSharedValue)(0),z=(0,_reactNativeReanimated.useSharedValue)(0),I=(0,_reactNativeReanimated.useSharedValue)(0),W=(0,_reactNativeReanimated.useSharedValue)(0),G=(0,_react.useRef)(null),U=(0,_react.useRef)(0),Y=(0,_react.useRef)(0),J=(0,_react.useMemo)(()=>({top:K,bottom:z,offset:I,maxOffset:W,scrollTo:e=>{const t=G.current;t instanceof _reactNative.FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[K,z,I,W]),Q=(0,_react.useCallback)(e=>{G.current=e,"function"==typeof g?g(e):g&&(g.current=e)},[g]),X=(0,_react.useCallback)(()=>{W.value=Math.max(0,U.current-Y.current)},[W]),Z=(0,_react.useRef)(h);Z.current=h;const $=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{y:L}}}],{useNativeDriver:!1,listener:e=>{I.value=e.nativeEvent.contentOffset.y,Z.current?.(e)}}),[L,I]),ee=(0,_react.useCallback)(e=>{const{height:t}=e.nativeEvent.layout;k(e=>Math.max(e,t))},[]),te=(0,_react.useCallback)(e=>{V(e.nativeEvent.layout.height)},[]);(0,_react.useEffect)(()=>{if(!O)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(q.current?.(),!0));return()=>e.remove()},[O]);const oe=f.includes("left")?E.left:0,re=f.includes("right")?E.right:0,ne=f.includes("bottom")?E.bottom:0,ae=f.includes("top")&&!w?E.top:0,ie=S.space[S.components["floating-action-button"]["bottom-offset"]],le=v?.props.bottomOffset??ie,se=v?(0,_index.resolveFloatingActionButtonSize)(S,v.props.size??"md").diameter+le+S.space.lg:0,ce=H?Math.max(0,A-E.bottom):p,de=v?(0,_react.cloneElement)(v,{bottomOffset:le+ce,position:v.props.position??"bottomRight"}):null,ue=H?se:Math.max(ne,v?se+E.bottom:0),fe=p+ue-(H?0:ne),me=f.filter(e=>"top"!==e&&!("bottom"===e&&H)),pe=w?(0,_jsxRuntime.jsx)(_reactNative.View,{style:F?T.overlay:void 0,onLayout:F?ee:void 0,children:(0,_jsxRuntime.jsx)(_index2.AppBar,{title:t,subtitle:o,variant:B?"large":"default",scrollY:F?L:void 0,onBack:n,rightActions:a,leading:i,gutter:j})}):null,xe=(0,_react.useCallback)(()=>{const e=G.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,o,r)=>{Y.current=r,K.value=t+M,z.value=t+r,X()})},[M,K,z,X]);(0,_react.useEffect)(()=>{xe()},[xe]);const ve=(0,_react.useCallback)((e,t)=>{U.current=t,X()},[X]);let ge;if(void 0!==_){const{state:e,paging:t,...o}=_,r=topPaddingOf([o.contentContainerStyle,y]),handleEndReached=e=>{t?.hasMore&&!t.loadingMore&&null==t.errorMore&&t.loadMore(),o.onEndReached?.(e)},n=(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",onEndReachedThreshold:t?.5:void 0,...o,ref:Q,refreshControl:D,onScroll:$,onLayout:e=>{xe(),o.onLayout?.(e)},onContentSizeChange:(e,t)=>{ve(e,t),o.onContentSizeChange?.(e,t)},onEndReached:t?handleEndReached:o.onEndReached,ListEmptyComponent:e?.empty?(0,_jsxRuntime.jsx)(_index4.EmptyState,{...e.empty}):void 0,ListFooterComponent:t||o.ListFooterComponent?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[renderFooter(o.ListFooterComponent),t?(0,_jsxRuntime.jsx)(_index7.PagedListFooter,{paging:t}):null]}):void 0,scrollEventThrottle:SCROLL_EVENT_THROTTLE,style:T.flex,contentContainerStyle:[{paddingTop:M,paddingLeft:oe+C,paddingRight:re+C},{paddingBottom:p+ue},o.contentContainerStyle,y,{paddingTop:M+headerGap(r)}]});ge=(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext.Provider,{value:J,children:e?(0,_jsxRuntime.jsx)(_index3.AsyncBlock,{loading:e.loading,error:e.error,errorTitle:e.errorTitle,onRetry:e.onRetry,skeleton:e.skeleton,style:[T.flex,{paddingTop:M+headerGap(r)}],children:n}):n})}else ge=u?(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext.Provider,{value:J,children:(0,_jsxRuntime.jsxs)(_index5.KeyboardAwareScrollView,{ref:Q,refreshControl:D,onScroll:$,scrollEventThrottle:SCROLL_EVENT_THROTTLE,onLayout:xe,onContentSizeChange:ve,safeAreaEdges:me,style:T.flex,contentContainerStyle:[{paddingHorizontal:C},y,{paddingTop:M+headerGap(topPaddingOf(y))}],children:[l,fe>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:fe}}):null]})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[T.flex,{paddingLeft:oe+C,paddingRight:re+C,paddingBottom:p+ue},y],children:l});const he=H?(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardStickyView,{onLayout:te,style:[T.footer,{paddingLeft:oe+j,paddingRight:re+j,paddingBottom:ne+p}],children:d}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:R,style:[T.root,{paddingTop:ae}],children:[F?null:pe,ge,he,de,void 0!==_?l:null,F?pe:null,m?(0,_jsxRuntime.jsx)(_index6.KeyboardToolbar,{}):null]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Screen=Screen;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=require("react-native-reanimated"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useRefreshControl=require("../../hooks/useRefreshControl.js"),_index=require("../../theme/index.js"),_index2=require("../AppBar/index.js"),_index3=require("../AsyncBlock/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../KeyboardAwareScrollView/index.js"),_index6=require("../KeyboardToolbar/index.js"),_index7=require("../PagedListFooter/index.js"),_ScrollHost=require("./ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{};function renderFooter(e){return(0,_react.isValidElement)(e)?e:e?(0,_react.createElement)(e):null}const topPaddingOf=e=>{const t=_reactNative.StyleSheet.flatten(e),r=t?.paddingTop??t?.paddingVertical??t?.padding;return"number"==typeof r?r:0},buildStyles=e=>_reactNative.StyleSheet.create({flex:{flex:1},root:{flex:1,backgroundColor:e.colors.bg},overlay:{position:"absolute",top:0,left:0,right:0},headerRaised:{zIndex:1},footer:{backgroundColor:e.colors.bg,borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:e.colors.border}});function Screen(e){const{title:t,subtitle:r,largeTitle:o=!0,headerShadowOnScroll:n,onBack:a,rightActions:i,leading:l,trailing:s,children:c,onRefresh:d,refreshing:u=!1,footer:_,scroll:f=!0,list:h,edges:m=DEFAULT_EDGES,keyboardToolbar:p=!0,bottomInset:x=0,gutter:v,floatingAction:g,scrollRef:S,onScroll:y,contentContainerStyle:R,testID:b}=e,j=(0,_index.useTheme)(),C=v??void 0===h,E=j.space[j.components.screen.gutter],T=C?E:0,L=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>buildStyles(j),[j]),[k]=(0,_react.useState)(()=>new _reactNative.Animated.Value(0)),[O,A]=(0,_react.useState)(0),[V,q]=(0,_react.useState)(0),w=void 0!==a,B=(0,_react.useRef)(a);B.current=a;const F=Boolean(t||r||a||l||s||i?.length),M=o&&void 0!==t,H=M&&(void 0!==h||f),P=H?O:0,z=F&&!H&&(n??j.settings.components.screen?.headerShadowOnScroll??!0),[D,K]=(0,_react.useState)(!1),I=(0,_react.useRef)(z);I.current=z;const headerGap=e=>e>0?e:F?j.space.lg:0,W=void 0!==_,{refreshControl:G}=(0,_useRefreshControl.useRefreshControl)({onRefresh:d??noop,refreshing:u}),U=d?(0,_react.cloneElement)(G,{progressViewOffset:P}):void 0,Y=(0,_reactNativeReanimated.useSharedValue)(0),J=(0,_reactNativeReanimated.useSharedValue)(0),Q=(0,_reactNativeReanimated.useSharedValue)(0),X=(0,_reactNativeReanimated.useSharedValue)(0),Z=(0,_react.useRef)(null),$=(0,_react.useRef)(0),ee=(0,_react.useRef)(0),te=(0,_react.useMemo)(()=>({top:Y,bottom:J,offset:Q,maxOffset:X,scrollTo:e=>{const t=Z.current;t instanceof _reactNative.FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[Y,J,Q,X]),re=(0,_react.useCallback)(e=>{Z.current=e,"function"==typeof S?S(e):S&&(S.current=e)},[S]),oe=(0,_react.useCallback)(()=>{X.value=Math.max(0,$.current-ee.current)},[X]),ne=(0,_react.useRef)(y);ne.current=y;const ae=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{y:k}}}],{useNativeDriver:!1,listener:e=>{if(Q.value=e.nativeEvent.contentOffset.y,I.current){const t=e.nativeEvent.contentOffset.y>0;K(e=>e===t?e:t)}ne.current?.(e)}}),[k,Q]),ie=(0,_react.useCallback)(e=>{const{height:t}=e.nativeEvent.layout;A(e=>Math.max(e,t))},[]),le=(0,_react.useCallback)(e=>{q(e.nativeEvent.layout.height)},[]);(0,_react.useEffect)(()=>{if(!w)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(B.current?.(),!0));return()=>e.remove()},[w]);const se=m.includes("left")?L.left:0,ce=m.includes("right")?L.right:0,de=m.includes("bottom")?L.bottom:0,ue=m.includes("top")&&!F?L.top:0,fe=j.space[j.components["floating-action-button"]["bottom-offset"]],he=g?.props.bottomOffset??fe,me=g?(0,_index.resolveFloatingActionButtonSize)(j,g.props.size??"md").diameter+he+j.space.lg:0,pe=W?Math.max(0,V-L.bottom):x,xe=g?(0,_react.cloneElement)(g,{bottomOffset:he+pe,position:g.props.position??"bottomRight"}):null,ve=W?me:Math.max(de,g?me+L.bottom:0),ge=x+ve-(W?0:de),Se=m.filter(e=>"top"!==e&&!("bottom"===e&&W)),ye=F?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H?N.overlay:z?N.headerRaised:void 0,onLayout:H?ie:void 0,children:(0,_jsxRuntime.jsx)(_index2.AppBar,{title:t,subtitle:r,variant:M?"large":"default",scrollY:H?k:void 0,elevated:z&&D,onBack:a,rightActions:i,leading:l,trailing:s,gutter:E})}):null,Re=(0,_react.useCallback)(()=>{const e=Z.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,r,o)=>{ee.current=o,Y.value=t+P,J.value=t+o,oe()})},[P,Y,J,oe]);(0,_react.useEffect)(()=>{Re()},[Re]);const be=(0,_react.useCallback)((e,t)=>{$.current=t,oe()},[oe]);let je;if(void 0!==h){const{state:e,paging:t,...r}=h,o=topPaddingOf([r.contentContainerStyle,R]),handleEndReached=e=>{t?.hasMore&&!t.loadingMore&&null==t.errorMore&&t.loadMore(),r.onEndReached?.(e)},n=(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",onEndReachedThreshold:t?.5:void 0,...r,ref:re,refreshControl:U,onScroll:ae,onLayout:e=>{Re(),r.onLayout?.(e)},onContentSizeChange:(e,t)=>{be(e,t),r.onContentSizeChange?.(e,t)},onEndReached:t?handleEndReached:r.onEndReached,ListEmptyComponent:e?.empty?(0,_jsxRuntime.jsx)(_index4.EmptyState,{...e.empty}):void 0,ListFooterComponent:t||r.ListFooterComponent?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[renderFooter(r.ListFooterComponent),t?(0,_jsxRuntime.jsx)(_index7.PagedListFooter,{paging:t}):null]}):void 0,scrollEventThrottle:SCROLL_EVENT_THROTTLE,style:N.flex,contentContainerStyle:[{paddingTop:P,paddingLeft:se+T,paddingRight:ce+T},{paddingBottom:x+ve},r.contentContainerStyle,R,{paddingTop:P+headerGap(o)}]});je=(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext.Provider,{value:te,children:e?(0,_jsxRuntime.jsx)(_index3.AsyncBlock,{loading:e.loading,error:e.error,errorTitle:e.errorTitle,onRetry:e.onRetry,skeleton:e.skeleton,style:[N.flex,{paddingTop:P+headerGap(o)}],children:n}):n})}else je=f?(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext.Provider,{value:te,children:(0,_jsxRuntime.jsxs)(_index5.KeyboardAwareScrollView,{ref:re,refreshControl:U,onScroll:ae,scrollEventThrottle:SCROLL_EVENT_THROTTLE,onLayout:Re,onContentSizeChange:be,safeAreaEdges:Se,style:N.flex,contentContainerStyle:[{paddingHorizontal:T},R,{paddingTop:P+headerGap(topPaddingOf(R))}],children:[c,ge>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:ge}}):null]})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.flex,{paddingLeft:se+T,paddingRight:ce+T,paddingBottom:x+ve},R],children:c});const Ce=W?(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardStickyView,{onLayout:le,style:[N.footer,{paddingLeft:se+E,paddingRight:ce+E,paddingBottom:de+x}],children:_}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:b,style:[N.root,{paddingTop:ue}],children:[H?null:ye,je,Ce,xe,void 0!==h?c:null,H?ye:null,p?(0,_jsxRuntime.jsx)(_index6.KeyboardToolbar,{}):null]})}
@@ -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:r,label:i,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:g,labelLines:h=1,haptic:_,accessibilityLabel:p,style:b,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??r[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=h>=2?2:1,L=F>1,N="segmented"===x,z="underline"===x,M="pills"===x,T=N?R.space[V["track-padding"]]:0,A=Math.ceil(1.25*k.text)*(F-1),E=V["underline-height"],D=R.space[V["pill-inset"]],H="number"==typeof g?g:g?R.radius[g]:void 0,W=H??R.radius.md,B=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)(0),J=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,K=Math.max(0,r.findIndex(e=>e.value===I)),Q=G>0?(G-2*T)/Math.max(r.length,1):0,U=(0,_react.useCallback)((e,t)=>{if(t<=0)return;const r=t*e,i=R.motion.spring.snappy,n=_reactNative.Animated.spring(J,{toValue:r,damping:i.damping,stiffness:i.stiffness,mass:i.mass,overshootClamping:!0,useNativeDriver:!0});return n.start(),n},[R.motion.spring.snappy,J]),Y=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(Q<=0)return;const e=null!==Y.current&&Y.current!==K;if(Y.current=K,!e)return void J.setValue(Q*K);const t=U(K,Q);return()=>t?.stop()},[K,Q,U,J]);const Z=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;t!==G&&X(t)},[G]),$=(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,_]),ee=N?R.colors.surface:M?R.colors["primary-soft"]:R.colors.primary,te=N?B:M?P:O,re=activeInkFor(R,m),ie=R.colors["bg-muted"],ne=(0,_SquircleFill.useSquircle)(N,W,Z),le=!0===l||(0,_index4.hasFieldText)(l),se=le&&!u,ae=R.colors["field-border-error"],oe=R.size.border,de=(0,_index4.hasFieldText)(i),ce=le?l:n,ue=(0,_index4.hasFieldText)(ce),me=p??("string"==typeof i?i:void 0),xe=(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:me,testID:w,style:[q.track,{...L?{minHeight:k.height+A}:{height:k.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},N?{borderRadius:W,..._corners.smoothCorners,backgroundColor:ne.active?"transparent":ie,padding:T}:z?{borderBottomColor:se?ae:R.colors["border-subtle"],borderBottomWidth:_reactNative.StyleSheet.hairlineWidth}:null,v,b],onLayout:ne.onLayout,children:[ne.active&&ne.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ne.size.width,height:ne.size.height,radius:W,fill:ie,stroke:se?ae:void 0,strokeWidth:oe}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:q.row,children:[Q>0?(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:E},{width:M?Math.max(Q-2*D,0):Q,borderRadius:te,..._corners.smoothCorners,backgroundColor:ee,transform:[{translateX:J}]},y]}):null,r.map(e=>{const t=e.value===I,r=t?re:R.colors["text-subtle"],i=(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:k.icon,selected:t,disabled:u});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>$(e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:t,selected:t,disabled:u},"aria-checked":t,"aria-disabled":u,style:({pressed:e})=>[q.segment,L?q.segmentMultiline:null,{paddingHorizontal:k["padding-x"],opacity:e&&!t?.7:1},f],children:[i?(0,_jsxRuntime.jsx)(_reactNative.View,{style:q.segmentIcon,children:i}):null,(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:t?"semibold":"medium",style:[q.segmentLabel,L?q.segmentLabelMultiline:null,{color:r,fontSize:k.text},S,j],numberOfLines:F,children:e.label})]},String(e.value))})]}),!se||z||ne.active?null:(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{borderWidth:oe,borderColor:ae,borderRadius:N?W:P,..._corners.smoothCorners}]})]});return de||ue?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{alignSelf:c?"stretch":"flex-start"},children:[de?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:d,children:i}):null,xe,ue?(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:d,text:ce,error:le}):null]}):xe});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:{flex:1,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:r,label:i,helperText:n,error:l,value:s,defaultValue:a,onChange:o,size:c="md",fullWidth:d=!0,disabled:u=!1,tone:m="primary",variant:x="segmented",radius:g,labelLines:h=1,haptic:_,accessibilityLabel:p,style:v,containerStyle:b,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??r[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,c),[R,c]),F=h>=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 g?g:g?R.radius[g]: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,r.findIndex(e=>e.value===I)),Q=G[K],U=Q?.x,Y=(0,_react.useCallback)(e=>{const t=R.motion.spring.snappy,r=_reactNative.Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!0});return r.start(),r},[R.motion.spring.snappy,J]);(0,_react.useEffect)(()=>{X(e=>e.length===r.length||0===e.length?e:[])},[r.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:r,width:i}=t.nativeEvent.layout;X(t=>{const n=t[e];if(n&&n.x===r&&n.width===i)return t;const l=t.slice();return l[e]={x:r,width:i},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.surface:M?R.colors["primary-soft"]:R.colors.primary,re=N?W:M?P:O,ie=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"],ce=R.size.border,de=(0,_index4.hasFieldText)(i),ue=se?l:n,me=(0,_index4.hasFieldText)(ue),xe=p??("string"==typeof i?i:void 0),ge=(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:d?"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,b,v],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:ce}):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:re,..._corners.smoothCorners,backgroundColor:te,transform:[{translateX:J}]},y]}):null,r.map((e,t)=>{const r=e.value===I,i=r?ie:R.colors["text-subtle"],n=(0,_slotIcon.renderSlotIcon)(e.icon,{color:i,size:k.icon,selected:r,disabled:u});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>ee(e),onLayout:e=>$(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:r,selected:r,disabled:u},"aria-checked":r,"aria-disabled":u,style:({pressed:e})=>[q.segment,L?q.segmentMultiline:null,{paddingHorizontal:k["padding-x"],opacity:e&&!r?.7:1},f],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:q.segmentIcon,children:n}):null,(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:r?"semibold":"medium",style:[q.segmentLabel,L?q.segmentLabelMultiline:null,{color:i,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:ce,borderColor:oe,borderRadius:N?B:P,..._corners.smoothCorners}]})]});return de||me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{alignSelf:d?"stretch":"flex-start"},children:[de?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:c,children:i}):null,ge,me?(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:c,text:ue,error:se}):null]}):ge});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.Wheel=exports.WHEEL_VISIBLE_ITEMS=exports.WHEEL_CENTER_OFFSET=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const WHEEL_VISIBLE_ITEMS=exports.WHEEL_VISIBLE_ITEMS=5,WHEEL_CENTER_OFFSET=exports.WHEEL_CENTER_OFFSET=Math.floor(WHEEL_VISIBLE_ITEMS/2),HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=(0,_react.memo)(({label:e,index:t,scrollY:a,itemHeight:n,selected:r,theme:i,reducedMotion:s,onPress:c,editor:l})=>{const{opacity:o,scale:u}=(0,_react.useMemo)(()=>{const e=_reactNative.Animated.subtract(_reactNative.Animated.divide(a,n),t);return{opacity:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),scale:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"})}},[a,n,t]),d=(0,_jsxRuntime.jsx)(_index2.Text,{variant:"h3",weight:r?"semibold":"medium",color:r?"primary":"secondary",numberOfLines:1,maxFontSizeMultiplier:1.5,style:{letterSpacing:i["letter-spacing"].normal},children:e});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.row,{height:n},s?{opacity:o}:{opacity:o,transform:[{scale:u}]}],accessible:!1,importantForAccessibility:"no",children:l??(c?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{focusable:!1,accessible:!1,onPress:()=>c(t),style:styles.rowPress,children:d}):d)})}),Wheel=({label:e,items:t,selectedIndex:a,onIndexChange:n,itemHeight:r,width:i,theme:s,haptic:c,disabled:l,reducedMotion:o,typeable:u,testID:d})=>{const m="web"===_reactNative.Platform.OS,[_,b]=(0,_react.useState)(null),x=(0,_react.useRef)(!1),E=(0,_react.useRef)(null),h=(0,_react.useRef)((0,_index.createAnimatedValue)(a*r)).current,f=(0,_react.useRef)(a*r),y=(0,_react.useRef)(a*r),p=(0,_react.useRef)(a),v=(0,_react.useRef)(0),S=(0,_react.useRef)(null),g=(0,_react.useRef)(()=>{}),T=t.length-1;(0,_react.useEffect)(()=>{p.current=a;const e=a*r;if(y.current===e)return;if(y.current=e,Math.abs(f.current-e)<1)return;f.current=e,m||(0,_index.setNativeValue)(h,e);const t=requestAnimationFrame(()=>{E.current?.scrollToOffset({offset:e,animated:!1})});return()=>cancelAnimationFrame(t)},[a,r,h,m]),(0,_react.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);const I=(0,_react.useCallback)((e,r)=>{if(!(e===a||e<0||e>T)){if("accessibility"===r){const e=(0,_hapticUtils.resolveHaptic)(c,"denseTick");e&&(0,_hapticUtils.triggerHaptic)(e)}if("keyboard"!==r){const a=t[e];a&&(0,_announce.announce)(a.accessibilityLabel??a.label)}n(e)}},[a,T,t,c,n]),M=(0,_react.useCallback)(()=>{!l&&u&&(x.current=!0,b(String(t[a]?.value??"")))},[l,u,t,a]),R=(0,_react.useCallback)(e=>{if(!x.current)return;x.current=!1,b(null);const a=e.trim();if(!/^\d+$/.test(a))return;const n=Number(a),r=t.findIndex(e=>e.value===n);r>=0&&I(r,"keyboard")},[t,I]);g.current=()=>{S.current=null;const e=Math.max(0,Math.min(T,Math.round(f.current/r))),t=e*r;Math.abs(f.current-t)>=1&&E.current?.scrollToOffset({offset:t,animated:!o}),I(e,"scroll")};const L=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{y:h}}}],{useNativeDriver:!m,listener:e=>{const t=e.nativeEvent.contentOffset.y;f.current=t;const a=Math.round(t/r);if(a!==p.current&&a>=0&&a<=T){const e=Date.now();if(e-v.current>=35){const t=(0,_hapticUtils.resolveHaptic)(c,"denseTick");t&&(0,_hapticUtils.triggerHaptic)(t),v.current=e}p.current=a}m&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>g.current(),120))}}),[h,r,T,c,m]),j=(0,_react.useCallback)(e=>{const t=e.nativeEvent.contentOffset.y;I(Math.max(0,Math.min(T,Math.round(t/r))),"scroll")},[I,T,r]),w=(0,_react.useCallback)(e=>{if(l)return;const t=e.nativeEvent.actionName;"increment"===t?I(Math.min(T,a+1),"accessibility"):"decrement"===t&&I(Math.max(0,a-1),"accessibility")},[l,I,T,a]),C=(0,_react.useCallback)(e=>{l||E.current?.scrollToOffset({offset:e*r,animated:!o})},[l,r,o]),N=(0,_react.useCallback)(({item:t,index:n})=>{const i=n===a,c=i&&null!==_;return(0,_jsxRuntime.jsx)(WheelRow,{label:t.label,index:n,scrollY:h,itemHeight:r,selected:i,theme:s,reducedMotion:o,onPress:i&&u?M:m?C:void 0,editor:c?(0,_jsxRuntime.jsx)(_reactNative.TextInput,{autoFocus:!0,selectTextOnFocus:!0,keyboardType:"number-pad",returnKeyType:"done",accessibilityLabel:e,value:_,onChangeText:b,onSubmitEditing:()=>R(_),onBlur:()=>R(_),style:{width:"100%",padding:s.space.none,textAlign:"center",fontSize:s.text.xl.size,color:s.colors["text-body"],fontWeight:s.weight.semibold,letterSpacing:s["letter-spacing"].normal}}):void 0})},[h,r,a,s,o,m,C,u,M,_,R,e]),A=(0,_react.useCallback)((e,t)=>`${String(e.value)}-${t}`,[]),F=(0,_react.useCallback)((e,t)=>({length:r,offset:r*t,index:t}),[r]),H=t[a]?t[a].accessibilityLabel??t[a].label:"",O=m?{focusable:!0,role:"spinbutton","aria-label":e,"aria-valuetext":H,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":T,"aria-disabled":l,onKeyDown:e=>{if(l)return;const t={ArrowDown:Math.min(T,a+1),PageDown:Math.min(T,a+1),ArrowUp:Math.max(0,a-1),PageUp:Math.max(0,a-1),Home:0,End:T}[e.key];void 0!==t&&(e.preventDefault?.(),I(t,"keyboard"))}}:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[void 0===i?styles.columnFlex:{width:i},{height:r*WHEEL_VISIBLE_ITEMS},styles.column,l?styles.disabled:null],testID:d,...O,children:[m?null:(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:styles.a11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:e,accessibilityValue:{text:H},accessibilityState:{disabled:Boolean(l)},"aria-disabled":Boolean(l),accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:w}),(0,_jsxRuntime.jsx)(_reactNative.Animated.FlatList,{ref:E,data:t,keyExtractor:A,renderItem:N,getItemLayout:F,showsVerticalScrollIndicator:!1,snapToInterval:r,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEnabled:!l,nestedScrollEnabled:!0,scrollEventThrottle:16,onScroll:L,onMomentumScrollEnd:j,contentContainerStyle:{paddingVertical:r*WHEEL_CENTER_OFFSET},initialScrollIndex:a,style:[styles.list,{height:r*WHEEL_VISIBLE_ITEMS}],importantForAccessibility:"no-hide-descendants","aria-hidden":!0})]})};exports.Wheel=Wheel;const styles=_reactNative.StyleSheet.create({column:{overflow:"hidden"},columnFlex:{flex:1},disabled:{opacity:.5},list:{flexGrow:0},row:{alignItems:"center",justifyContent:"center"},rowPress:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",flex:1},a11yLayer:{..._reactNative.StyleSheet.absoluteFill,zIndex:2}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Wheel=exports.WHEEL_VISIBLE_ITEMS=exports.WHEEL_CENTER_OFFSET=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const WHEEL_VISIBLE_ITEMS=exports.WHEEL_VISIBLE_ITEMS=5,WHEEL_CENTER_OFFSET=exports.WHEEL_CENTER_OFFSET=Math.floor(WHEEL_VISIBLE_ITEMS/2),HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=(0,_react.memo)(({label:e,index:t,scrollY:a,itemHeight:n,selected:r,theme:i,reducedMotion:c,onPress:s,editor:l})=>{const{opacity:o,scale:u}=(0,_react.useMemo)(()=>{const e=_reactNative.Animated.subtract(_reactNative.Animated.divide(a,n),t);return{opacity:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),scale:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"})}},[a,n,t]),d=(0,_jsxRuntime.jsx)(_index2.Text,{variant:"h3",weight:r?"semibold":"medium",color:r?"primary":"secondary",numberOfLines:1,maxFontSizeMultiplier:1.5,style:{letterSpacing:i["letter-spacing"].normal},children:e});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.row,{height:n},c?{opacity:o}:{opacity:o,transform:[{scale:u}]}],accessible:!1,importantForAccessibility:"no",children:l??(s?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{focusable:!1,accessible:!1,onPress:()=>s(t),style:styles.rowPress,children:d}):d)})}),Wheel=({label:e,items:t,selectedIndex:a,onIndexChange:n,itemHeight:r,width:i,theme:c,haptic:s,disabled:l,reducedMotion:o,typeable:u,testID:d})=>{const m="web"===_reactNative.Platform.OS,[_,b]=(0,_react.useState)(null),x=(0,_react.useRef)(!1),h=(0,_react.useRef)(null),E=(0,_react.useRef)((0,_index.createAnimatedValue)(a*r)).current,y=(0,_react.useRef)(a*r),p=(0,_react.useRef)(a*r),f=(0,_react.useRef)(a),v=(0,_react.useRef)(0),S=(0,_react.useRef)(null),T=(0,_react.useRef)(()=>{}),g=t.length-1;(0,_react.useEffect)(()=>{f.current=a;const e=a*r;if(p.current===e)return;if(p.current=e,Math.abs(y.current-e)<1)return;y.current=e,m||(0,_index.setNativeValue)(E,e);const t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[a,r,E,m]),(0,_react.useEffect)(()=>{const e=y.current,t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[]),(0,_react.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);const M=(0,_react.useCallback)((e,r)=>{if(!(e===a||e<0||e>g)){if("accessibility"===r){const e=(0,_hapticUtils.resolveHaptic)(s,"denseTick");e&&(0,_hapticUtils.triggerHaptic)(e)}if("keyboard"!==r){const a=t[e];a&&(0,_announce.announce)(a.accessibilityLabel??a.label)}n(e)}},[a,g,t,s,n]),R=(0,_react.useCallback)(()=>{!l&&u&&(x.current=!0,b(String(t[a]?.value??"")))},[l,u,t,a]),I=(0,_react.useCallback)(e=>{if(!x.current)return;x.current=!1,b(null);const a=e.trim();if(!/^\d+$/.test(a))return;const n=Number(a),r=t.findIndex(e=>e.value===n);r>=0&&M(r,"keyboard")},[t,M]);T.current=()=>{S.current=null;const e=Math.max(0,Math.min(g,Math.round(y.current/r))),t=e*r;Math.abs(y.current-t)>=1&&h.current?.scrollTo({y:t,animated:!o}),M(e,"scroll")};const j=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{y:E}}}],{useNativeDriver:!m,listener:e=>{const t=e.nativeEvent.contentOffset.y;y.current=t;const a=Math.round(t/r);if(a!==f.current&&a>=0&&a<=g){const e=Date.now();if(e-v.current>=35){const t=(0,_hapticUtils.resolveHaptic)(s,"denseTick");t&&(0,_hapticUtils.triggerHaptic)(t),v.current=e}f.current=a}m&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>T.current(),120))}}),[E,r,g,s,m]),L=(0,_react.useCallback)(e=>{const t=e.nativeEvent.contentOffset.y;M(Math.max(0,Math.min(g,Math.round(t/r))),"scroll")},[M,g,r]),w=(0,_react.useCallback)(e=>{if(l)return;const t=e.nativeEvent.actionName;"increment"===t?M(Math.min(g,a+1),"accessibility"):"decrement"===t&&M(Math.max(0,a-1),"accessibility")},[l,M,g,a]),A=(0,_react.useCallback)(e=>{l||h.current?.scrollTo({y:e*r,animated:!o})},[l,r,o]),C=(0,_react.useCallback)(({item:t,index:n})=>{const i=n===a,s=i&&null!==_;return(0,_jsxRuntime.jsx)(WheelRow,{label:t.label,index:n,scrollY:E,itemHeight:r,selected:i,theme:c,reducedMotion:o,onPress:i&&u?R:m?A:void 0,editor:s?(0,_jsxRuntime.jsx)(_reactNative.TextInput,{autoFocus:!0,selectTextOnFocus:!0,keyboardType:"number-pad",returnKeyType:"done",accessibilityLabel:e,value:_,onChangeText:b,onSubmitEditing:()=>I(_),onBlur:()=>I(_),style:{width:"100%",padding:c.space.none,textAlign:"center",fontSize:c.text.xl.size,color:c.colors["text-body"],fontWeight:c.weight.semibold,letterSpacing:c["letter-spacing"].normal}}):void 0})},[E,r,a,c,o,m,A,u,R,_,I,e]),N=(0,_react.useCallback)((e,t)=>`${String(e.value)}-${t}`,[]),F=t[a]?t[a].accessibilityLabel??t[a].label:"",H=m?{focusable:!0,role:"spinbutton","aria-label":e,"aria-valuetext":F,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":g,"aria-disabled":l,onKeyDown:e=>{if(l)return;const t={ArrowDown:Math.min(g,a+1),PageDown:Math.min(g,a+1),ArrowUp:Math.max(0,a-1),PageUp:Math.max(0,a-1),Home:0,End:g}[e.key];void 0!==t&&(e.preventDefault?.(),M(t,"keyboard"))}}:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[void 0===i?styles.columnFlex:{width:i},{height:r*WHEEL_VISIBLE_ITEMS},styles.column,l?styles.disabled:null],testID:d,...H,children:[m?null:(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:styles.a11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:e,accessibilityValue:{text:F},accessibilityState:{disabled:Boolean(l)},"aria-disabled":Boolean(l),accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:w}),(0,_jsxRuntime.jsx)(_reactNative.Animated.ScrollView,{ref:h,showsVerticalScrollIndicator:!1,snapToInterval:r,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEnabled:!l,nestedScrollEnabled:!0,scrollEventThrottle:16,onScroll:j,onMomentumScrollEnd:L,contentOffset:{x:0,y:a*r},contentContainerStyle:{paddingVertical:r*WHEEL_CENTER_OFFSET},style:[styles.list,{height:r*WHEEL_VISIBLE_ITEMS}],importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:C({item:e,index:t})},N(e,t)))})]})};exports.Wheel=Wheel;const styles=_reactNative.StyleSheet.create({column:{overflow:"hidden"},columnFlex:{flex:1},disabled:{opacity:.5},list:{flexGrow:0},row:{alignItems:"center",justifyContent:"center"},rowPress:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",flex:1},a11yLayer:{..._reactNative.StyleSheet.absoluteFill,zIndex:2}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NavigationScreen=NavigationScreen;var _bottomTabs=require("@react-navigation/bottom-tabs"),_native=require("@react-navigation/native"),_react=require("react"),_index=require("../components/Screen/index.js"),_index2=require("../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const TAB_EDGES=["top"];function NavigationScreen({kind:e="pushed",appBar:t=!0,onBack:i,...n}){const o=(0,_native.useNavigation)(),r=(0,_react.useContext)(_bottomTabs.BottomTabBarHeightContext),a=!0===(0,_index2.useTheme)().settings.components.screen?.tabBarFloats,s=t?n:{...n,title:void 0,subtitle:void 0,leading:void 0,rightActions:void 0};return"tab"===e?(0,_jsxRuntime.jsx)(_index.Screen,{...s,largeTitle:!0,edges:TAB_EDGES,bottomInset:a?r??0:0}):(0,_jsxRuntime.jsx)(_index.Screen,{...s,largeTitle:!1,onBack:"root"!==e&&t?i??o.goBack:void 0})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NavigationScreen=NavigationScreen;var _bottomTabs=require("@react-navigation/bottom-tabs"),_native=require("@react-navigation/native"),_react=require("react"),_index=require("../components/Screen/index.js"),_index2=require("../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const TAB_EDGES=["top"];function NavigationScreen({kind:e="pushed",appBar:t=!0,onBack:i,...n}){const o=(0,_native.useNavigation)(),r=(0,_react.useContext)(_bottomTabs.BottomTabBarHeightContext),a=!0===(0,_index2.useTheme)().settings.components.screen?.tabBarFloats,s=t?n:{...n,title:void 0,subtitle:void 0,leading:void 0,trailing:void 0,rightActions:void 0};return"tab"===e?(0,_jsxRuntime.jsx)(_index.Screen,{...s,largeTitle:!1,edges:TAB_EDGES,bottomInset:a?r??0:0}):(0,_jsxRuntime.jsx)(_index.Screen,{...s,largeTitle:!1,onBack:"root"!==e&&t?i??o.goBack:void 0})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NetworkStatusBanner=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../hooks/usePresenceMotion.js"),_index=require("../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const NetworkStatusBanner=({message:e="You are offline. Some features may be unavailable.",position:t="top",style:a,disabled:r=!1,safeArea:o=!0})=>{const n=(0,_index.useTheme)(),i=(0,_usePresenceMotion.usePresenceMotion)(),s=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),u=o?"top"===t?s.top:s.bottom:0,[c,l]=(0,_react.useState)(0),d=c>0?c:56+u,{isConnected:m,isInternetReachable:p}=(0,_mobileCore.useNetworkStatus)(),_=!(r||m&&!1!==p),v=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current,f=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current,x=i.duration("default");(0,_react.useEffect)(()=>{_reactNative.Animated.parallel([_reactNative.Animated.timing(v,{toValue:_?1:0,duration:n.motion.duration.default,useNativeDriver:!0}),_reactNative.Animated.timing(f,{toValue:_?1:0,duration:x,useNativeDriver:!0})]).start()},[_,v,f,n.motion.duration.default,x]);const b=(0,_react.useMemo)(()=>buildStyles(n),[n]),N=v.interpolate({inputRange:[0,1],outputRange:i.range("top"===t?-d:d,0)});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:_?"auto":"none",accessibilityRole:"alert",accessibilityLiveRegion:_?"polite":"none",onLayout:e=>l(e.nativeEvent.layout.height),style:[b.container,"top"===t?b.top:b.bottom,"top"===t?{paddingTop:n.space.sm+u}:{paddingBottom:n.space.sm+u},{backgroundColor:n.colors.danger,opacity:f,transform:[{translateY:N}]},a],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:n.colors["on-danger"],fontSize:n.text.sm.size,...(0,_index.fontFor)(n,"semibold"),textAlign:"center"},numberOfLines:2,children:e})})};exports.NetworkStatusBanner=NetworkStatusBanner;const buildStyles=e=>_reactNative.StyleSheet.create({container:{position:"absolute",left:0,right:0,paddingVertical:e.space.sm,paddingHorizontal:e.space.lg,zIndex:1e3,elevation:8},top:{top:0},bottom:{bottom:0}});var _default=exports.default=NetworkStatusBanner;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NetworkStatusBanner=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../hooks/usePresenceMotion.js"),_index=require("../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const NetworkStatusBanner=({message:e="You are offline. Some features may be unavailable.",restoredMessage:t="You are back online.",restoredDuration:a=2e3,position:r="top",style:o,disabled:n=!1,safeArea:i=!0})=>{const s=(0,_index.useTheme)(),u=(0,_usePresenceMotion.usePresenceMotion)(),c=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),l=i?"top"===r?c.top:c.bottom:0,[d,f]=(0,_react.useState)(0),m=d>0?d:56+l,{isConnected:_,isInternetReachable:p}=(0,_mobileCore.useNetworkStatus)(),v=!(n||_&&!1!==p),[b,x]=(0,_react.useState)("hidden"),[N,g]=(0,_react.useState)("offline");(0,_react.useEffect)(()=>{"hidden"!==b&&g(b)},[b]),(0,_react.useEffect)(()=>{x(v?"offline":n?"hidden":e=>"offline"===e?"restored":e)},[v,n]),(0,_react.useEffect)(()=>{if("restored"!==b)return;const e=setTimeout(()=>x("hidden"),a);return()=>clearTimeout(e)},[b,a]);const S="hidden"!==b,h="restored"===b||"hidden"===b&&"restored"===N,y=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current,A=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current,w=u.duration("default");(0,_react.useEffect)(()=>{_reactNative.Animated.parallel([_reactNative.Animated.timing(y,{toValue:S?1:0,duration:s.motion.duration.default,useNativeDriver:!0}),_reactNative.Animated.timing(A,{toValue:S?1:0,duration:w,useNativeDriver:!0})]).start()},[S,y,A,s.motion.duration.default,w]);const R=(0,_react.useMemo)(()=>buildStyles(s),[s]),j=y.interpolate({inputRange:[0,1],outputRange:u.range("top"===r?-m:m,0)});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:S?"auto":"none",accessibilityRole:"alert",accessibilityLiveRegion:S?"polite":"none",onLayout:e=>f(e.nativeEvent.layout.height),style:[R.container,"top"===r?R.top:R.bottom,"top"===r?{paddingTop:s.space.sm+l}:{paddingBottom:s.space.sm+l},{backgroundColor:h?s.colors["online-fill"]:s.colors["offline-fill"],opacity:A,transform:[{translateY:j}]},o],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:h?s.colors["on-success"]:s.colors["on-danger"],fontSize:s.text.sm.size,...(0,_index.fontFor)(s,"semibold"),textAlign:"center"},numberOfLines:2,children:h?t:e})})};exports.NetworkStatusBanner=NetworkStatusBanner;const buildStyles=e=>_reactNative.StyleSheet.create({container:{position:"absolute",left:0,right:0,paddingVertical:e.space.sm,paddingHorizontal:e.space.lg,zIndex:1e3,elevation:8},top:{top:0},bottom:{bottom:0}});var _default=exports.default=NetworkStatusBanner;