@webority/mobile-ui 0.157.0 → 0.158.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 (111) hide show
  1. package/canvas-kit.json +1 -1
  2. package/dist/canvas-kit/kit.js +5 -5
  3. package/dist/canvas-kit/manifest.json +17 -12
  4. package/dist/canvas-kit/release.json +7 -7
  5. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  6. package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
  7. package/lib/commonjs/components/AppIcon/index.js +1 -1
  8. package/lib/commonjs/components/Banner/Banner.js +1 -1
  9. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  10. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  11. package/lib/commonjs/components/Button/Button.js +1 -1
  12. package/lib/commonjs/components/Button/index.js +1 -1
  13. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  14. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  15. package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
  16. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  17. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  18. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  19. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  20. package/lib/commonjs/components/MessageList/MessageList.js +1 -1
  21. package/lib/commonjs/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -1
  22. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  23. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  24. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  25. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  26. package/lib/commonjs/components/Radio/Radio.js +1 -1
  27. package/lib/commonjs/components/Radio/RadioGroup.js +1 -1
  28. package/lib/commonjs/components/Rating/Rating.js +1 -1
  29. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  30. package/lib/commonjs/components/SearchBar/useRecentSearches.js +1 -1
  31. package/lib/commonjs/components/Skeleton/Skeleton.js +1 -1
  32. package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
  33. package/lib/commonjs/components/Skeleton/SkeletonList.js +1 -1
  34. package/lib/commonjs/components/Slider/valueText.js +1 -1
  35. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  36. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  37. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  38. package/lib/commonjs/components/Toast/Toast.js +1 -1
  39. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  40. package/lib/commonjs/hooks/useControllableState.js +1 -1
  41. package/lib/commonjs/icons.js +1 -1
  42. package/lib/commonjs/index.js +1 -1
  43. package/lib/module/components/AppBar/AppBar.js +1 -1
  44. package/lib/module/components/AppIcon/AppIcon.js +1 -1
  45. package/lib/module/components/AppIcon/index.js +1 -1
  46. package/lib/module/components/Banner/Banner.js +1 -1
  47. package/lib/module/components/BarChart/BarChart.js +1 -1
  48. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  49. package/lib/module/components/Button/Button.js +1 -1
  50. package/lib/module/components/Button/index.js +1 -1
  51. package/lib/module/components/Carousel/Carousel.js +1 -1
  52. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  53. package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
  54. package/lib/module/components/Confetti/Confetti.js +1 -1
  55. package/lib/module/components/Drawer/Drawer.js +1 -1
  56. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  57. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  58. package/lib/module/components/MessageList/MessageList.js +1 -1
  59. package/lib/module/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -1
  60. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  61. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  62. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  63. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  64. package/lib/module/components/Radio/Radio.js +1 -1
  65. package/lib/module/components/Radio/RadioGroup.js +1 -1
  66. package/lib/module/components/Rating/Rating.js +1 -1
  67. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  68. package/lib/module/components/SearchBar/useRecentSearches.js +1 -1
  69. package/lib/module/components/Skeleton/Skeleton.js +1 -1
  70. package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
  71. package/lib/module/components/Skeleton/SkeletonList.js +1 -1
  72. package/lib/module/components/Slider/valueText.js +1 -1
  73. package/lib/module/components/Stepper/Stepper.js +1 -1
  74. package/lib/module/components/TagInput/TagInput.js +1 -1
  75. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  76. package/lib/module/components/Toast/Toast.js +1 -1
  77. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  78. package/lib/module/hooks/useControllableState.js +1 -1
  79. package/lib/module/icons.js +1 -1
  80. package/lib/module/index.js +1 -1
  81. package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +2 -0
  82. package/lib/typescript/commonjs/components/AppIcon/index.d.ts +1 -1
  83. package/lib/typescript/commonjs/components/Button/Button.d.ts +4 -0
  84. package/lib/typescript/commonjs/components/Button/index.d.ts +1 -1
  85. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +7 -4
  86. package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +14 -6
  87. package/lib/typescript/commonjs/components/FieldBase/ChoiceText.d.ts +6 -5
  88. package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +2 -2
  89. package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +15 -9
  90. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +7 -4
  91. package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +5 -0
  92. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +4 -4
  93. package/lib/typescript/commonjs/hooks/useControllableState.d.ts +23 -8
  94. package/lib/typescript/commonjs/icons.d.ts +1 -1
  95. package/lib/typescript/commonjs/index.d.ts +2 -1
  96. package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +2 -0
  97. package/lib/typescript/module/components/AppIcon/index.d.ts +1 -1
  98. package/lib/typescript/module/components/Button/Button.d.ts +4 -0
  99. package/lib/typescript/module/components/Button/index.d.ts +1 -1
  100. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +7 -4
  101. package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +14 -6
  102. package/lib/typescript/module/components/FieldBase/ChoiceText.d.ts +6 -5
  103. package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +2 -2
  104. package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +15 -9
  105. package/lib/typescript/module/components/Radio/Radio.d.ts +7 -4
  106. package/lib/typescript/module/components/Radio/RadioGroup.d.ts +5 -0
  107. package/lib/typescript/module/components/Switch/Switch.d.ts +4 -4
  108. package/lib/typescript/module/hooks/useControllableState.d.ts +23 -8
  109. package/lib/typescript/module/icons.d.ts +1 -1
  110. package/lib/typescript/module/index.d.ts +2 -1
  111. package/package.json +7 -7
@@ -2,9 +2,9 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.157.0"
5
+ "version": "0.158.0"
6
6
  },
7
- "rendererProtocolVersion": 13,
7
+ "rendererProtocolVersion": 14,
8
8
  "platform": "Phone",
9
9
  "kitModuleVersion": 2,
10
10
  "productKit": null,
@@ -4103,7 +4103,7 @@
4103
4103
  },
4104
4104
  {
4105
4105
  "name": "description",
4106
- "type": "string",
4106
+ "type": "node",
4107
4107
  "required": false,
4108
4108
  "description": "A secondary line under the label and the helper text."
4109
4109
  },
@@ -4128,7 +4128,7 @@
4128
4128
  },
4129
4129
  {
4130
4130
  "name": "helperText",
4131
- "type": "string",
4131
+ "type": "node",
4132
4132
  "required": false,
4133
4133
  "description": "A hint under the label."
4134
4134
  },
@@ -4431,7 +4431,7 @@
4431
4431
  },
4432
4432
  {
4433
4433
  "name": "description",
4434
- "type": "string",
4434
+ "type": "node",
4435
4435
  "required": false,
4436
4436
  "description": "A line of text drawn above the options."
4437
4437
  },
@@ -4480,7 +4480,7 @@
4480
4480
  },
4481
4481
  {
4482
4482
  "name": "helperText",
4483
- "type": "string",
4483
+ "type": "node",
4484
4484
  "required": false,
4485
4485
  "description": "A hint drawn under the options; hidden while error is set."
4486
4486
  },
@@ -12342,13 +12342,13 @@
12342
12342
  },
12343
12343
  {
12344
12344
  "name": "subtitle",
12345
- "type": "string",
12345
+ "type": "node",
12346
12346
  "required": false,
12347
12347
  "description": "Muted text beside or beneath the photo in the inline and profile layouts."
12348
12348
  },
12349
12349
  {
12350
12350
  "name": "title",
12351
- "type": "string",
12351
+ "type": "node",
12352
12352
  "required": false,
12353
12353
  "description": "Bold text beside or beneath the photo in the inline and profile layouts."
12354
12354
  },
@@ -12761,7 +12761,7 @@
12761
12761
  },
12762
12762
  {
12763
12763
  "name": "description",
12764
- "type": "string",
12764
+ "type": "node",
12765
12765
  "required": false,
12766
12766
  "description": "A secondary line under the label and the helper text."
12767
12767
  },
@@ -12780,7 +12780,7 @@
12780
12780
  },
12781
12781
  {
12782
12782
  "name": "helperText",
12783
- "type": "string",
12783
+ "type": "node",
12784
12784
  "required": false,
12785
12785
  "description": "A hint under the label."
12786
12786
  },
@@ -17960,7 +17960,7 @@
17960
17960
  },
17961
17961
  {
17962
17962
  "name": "description",
17963
- "type": "string",
17963
+ "type": "node",
17964
17964
  "required": false,
17965
17965
  "description": "A secondary line under the label."
17966
17966
  },
@@ -17979,7 +17979,7 @@
17979
17979
  },
17980
17980
  {
17981
17981
  "name": "helperText",
17982
- "type": "string",
17982
+ "type": "node",
17983
17983
  "required": false,
17984
17984
  "description": "A hint under the label."
17985
17985
  },
@@ -22996,6 +22996,11 @@
22996
22996
  "version": "0.152.0",
22997
22997
  "components": [],
22998
22998
  "values": {}
22999
+ },
23000
+ {
23001
+ "version": "0.158.0",
23002
+ "components": [],
23003
+ "values": {}
22999
23004
  }
23000
23005
  ]
23001
23006
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.157.0",
3
+ "version": "0.158.0",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
- "rendererProtocolVersion": 13,
6
+ "rendererProtocolVersion": 14,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.157.0"
9
+ "version": "0.158.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "69c8f08c03f269fc6a4990b6085d714531e4553451a2e4ac60eb695529514a30",
14
- "bytes": 668352
13
+ "sha256": "93c6a370adf08a16e045c1ce0525dbf862420079f4c6b47e75508429154c5550",
14
+ "bytes": 668416
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "82373e79ef73a0788352464355809370e430bdeaa646d40270f8a777bbc85d4a",
18
- "bytes": 5660981
17
+ "sha256": "fbf19411e57154acc226fcf61661ad9b7cd5bab20061c0147e16576c9e19d068",
18
+ "bytes": 5663320
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"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.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:s},r)=>{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:r,onPress:t=>{const i=(0,_hapticUtils.resolveHaptic)(n,"selection");i&&(0,_hapticUtils.triggerHaptic)(i),"onPress"in e&&e.onPress(),s?.(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:s,rightActions:r,leading:l,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:y,subtitleStyle:v,badgeStyle:A,haptic:R,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("AppBar","variant",e.variant,["default","large","compact"]),(0,_assertValidValue.assertValidValue)("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const B=(0,_react.useMemo)(()=>({...DEFAULT_APP_BAR_LABELS,...S}),[S]),L=(0,_index.useTheme)(),N=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),T=(0,_react.useMemo)(()=>variantSize(L,m),[L,m]),I=(0,_react.useMemo)(()=>buildStyles(L),[L]),V="large"===m,P=V&&void 0!==b,[C,z]=(0,_react.useState)(40),O=(0,_react.useCallback)(e=>z(e.nativeEvent.layout.height),[]),E=s??(c?{icon:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"arrow-left",size:24,color:L.colors["text-body"]}),onPress:c,accessibilityLabel:B.back}:void 0),D=o?void 0:r?.[r.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?L.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(l),q=!k&&"left"===a&&Boolean(E),H=k||q||!F&&"left"===a,M="default"!==m||F?T.titleSize:L.text.xl.size,U=x??!1,$=_reactNative.StyleSheet.hairlineWidth,G=(0,_react.useMemo)(()=>{if(!b)return null;const e=b;return{rootHeight:e.interpolate({inputRange:[0,60],outputRange:[N.top+T.height+C,N.top+T.height],extrapolate:"clamp"}),titleRowOpacity:e.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:e.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:e.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}},[b,N.top,T.height,C]),Z=i?u?(0,_jsxRuntime.jsx)(_Text.Text,{variant:u,align:"center"===a?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[I.titleVariant,y],children:i}):(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityRole:"header",style:[I.title,{fontSize:M,fontWeight:L.weight[T.titleWeight],textAlign:"center"===a?"center":"left"},n?I.stackedText:null,y],numberOfLines:1,children:i}):null,Y=P&&G&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[I.title,{fontSize:L.text.lg.size,fontWeight:L.weight.semibold,textAlign:"center"===a?"center":"left",opacity:G.compactTitleOpacity}],numberOfLines:1,children:i}):null,J=n?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[I.subtitle,{textAlign:"center"===a?"center":"left"},v],numberOfLines:T.subtitleLines,children:n}):null,K=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I.titleColumn,"center"===a?I.titleColumnCenter:null],children:[Z,J]}),Q=P?_reactNative.Animated.View:_reactNative.View,X=P&&G?{height:G.rootHeight,overflow:"hidden"}:V&&void 0===h?null:{height:(h??T.height)+N.top};return(0,_jsxRuntime.jsxs)(Q,{ref:t,testID:w,style:[I.root,{paddingTop:N.top,backgroundColor:_?"transparent":L.colors.surface},X,!P&&U?{borderBottomWidth:$,borderBottomColor:L.colors.border}:null,g&&!_?L.shadow.card:null,j,f],children:[P&&G&&U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[I.animatedBorder,{backgroundColor:L.colors.border,opacity:G.borderOpacity}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:V&&w?`${w}-bar-row`:void 0,style:[I.row,V?{height:T.height}:{flex:1},W],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:w?`${w}-leading-slot`:void 0,style:[I.sideSlot,H?I.sideSlotCompact:null],children:[E?(0,_jsxRuntime.jsx)(ActionButton,{action:E,side:"left",haptic:R,flush:k||q}):null,null!=l&&!1!==l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:I.slotNode,children:l}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[I.center,"center"===a?I.centerAligned:I.centerLeft,k?{paddingLeft:F?p:L.space.none,paddingRight:L.space.none}:H?{paddingLeft:L.space.none}:null],children:V?Y:K}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I.sideSlot,I.sideSlotRight,k?I.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:I.slotNode,children:o}):null]})]}),V?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{testID:w?`${w}-title-row`:void 0,onLayout:P?O:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??L.space.md,paddingBottom:L.space.sm},P&&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:Math.round(e.text.xs.size*e.leading.heading)}});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"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.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:s},r)=>{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:r,onPress:t=>{const i=(0,_hapticUtils.resolveHaptic)(n,"selection");i&&(0,_hapticUtils.triggerHaptic)(i),"onPress"in e&&e.onPress(),s?.(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:s,rightActions:r,leading:l,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:y,subtitleStyle:v,badgeStyle:A,haptic:R,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("AppBar","variant",e.variant,["default","large","compact"]),(0,_assertValidValue.assertValidValue)("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const B=(0,_react.useMemo)(()=>({...DEFAULT_APP_BAR_LABELS,...S}),[S]),L=(0,_index.useTheme)(),N=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),T=(0,_react.useMemo)(()=>variantSize(L,m),[L,m]),I=(0,_react.useMemo)(()=>buildStyles(L),[L]),V="large"===m,P=V&&void 0!==b,[C,z]=(0,_react.useState)(40),O=(0,_react.useCallback)(e=>z(e.nativeEvent.layout.height),[]),E=s??(c?{icon:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"arrow-left",size:24,color:L.colors["text-body"]}),onPress:c,accessibilityLabel:B.back}:void 0),D=o?void 0:r?.[r.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?L.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(l),M=!k&&"left"===a&&Boolean(E),q=k||M||!F&&"left"===a,H="default"!==m||F?T.titleSize:L.text.xl.size,U=x??!1,$=_reactNative.StyleSheet.hairlineWidth,G=(0,_react.useMemo)(()=>{if(!b)return null;const e=b;return{rootHeight:e.interpolate({inputRange:[0,60],outputRange:[N.top+T.height+C,N.top+T.height],extrapolate:"clamp"}),titleRowOpacity:e.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:e.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:e.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}},[b,N.top,T.height,C]),Z=i?u?(0,_jsxRuntime.jsx)(_Text.Text,{variant:u,align:"center"===a?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[I.titleVariant,y],children:i}):(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityRole:"header",style:[I.title,{fontSize:H,fontWeight:L.weight[T.titleWeight],textAlign:"center"===a?"center":"left"},n?I.stackedText:null,y],numberOfLines:1,children:i}):null,Y=P&&G&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[I.title,{fontSize:L.text.lg.size,fontWeight:L.weight.semibold,textAlign:"center"===a?"center":"left",opacity:G.compactTitleOpacity}],numberOfLines:1,children:i}):null,J=n?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[I.subtitle,{textAlign:"center"===a?"center":"left"},v],numberOfLines:T.subtitleLines,children:n}):null,K=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I.titleColumn,"center"===a?I.titleColumnCenter:null],children:[Z,J]}),Q=P?_reactNative.Animated.View:_reactNative.View,X=P&&G?{height:G.rootHeight,overflow:"hidden"}:V&&void 0===h?null:{height:(h??T.height)+N.top},ee=(0,_react.useMemo)(()=>(r??[]).map((e,t)=>({key:`appbar-right-${t}`,action:e})),[r]);return(0,_jsxRuntime.jsxs)(Q,{ref:t,testID:w,style:[I.root,{paddingTop:N.top,backgroundColor:_?"transparent":L.colors.surface},X,!P&&U?{borderBottomWidth:$,borderBottomColor:L.colors.border}:null,g&&!_?L.shadow.card:null,j,f],children:[P&&G&&U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[I.animatedBorder,{backgroundColor:L.colors.border,opacity:G.borderOpacity}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:V&&w?`${w}-bar-row`:void 0,style:[I.row,V?{height:T.height}:{flex:1},W],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:w?`${w}-leading-slot`:void 0,style:[I.sideSlot,q?I.sideSlotCompact:null],children:[E?(0,_jsxRuntime.jsx)(ActionButton,{action:E,side:"left",haptic:R,flush:k||M}):null,null!=l&&!1!==l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:I.slotNode,children:l}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[I.center,"center"===a?I.centerAligned:I.centerLeft,k?{paddingLeft:F?p:L.space.none,paddingRight:L.space.none}:q?{paddingLeft:L.space.none}:null],children:V?Y:K}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I.sideSlot,I.sideSlotRight,k?I.sideSlotCompact:null],children:[ee.map(({key:e,action:t})=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:"menu"in t?(0,_jsxRuntime.jsx)(_index2.Menu,{items:t.menu,title:t.menuTitle,haptic:R,trigger:(0,_jsxRuntime.jsx)(ActionButton,{action:t,side:"right",badgeStyle:A,haptic:R,flush:k})}):(0,_jsxRuntime.jsx)(ActionButton,{action:t,side:"right",badgeStyle:A,haptic:R,flush:k})},e)),null!=o&&!1!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:I.slotNode,children:o}):null]})]}),V?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{testID:w?`${w}-title-row`:void 0,onLayout:P?O:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??L.space.md,paddingBottom:L.space.sm},P&&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:Math.round(e.text.xs.size*e.leading.heading)}});var _default=exports.default=AppBar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppIcon=exports.APP_ICON_SIZES=void 0,Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _glyphsG.CURATED_ICON_NAMES}}),exports.ICONSAX_SUFFIX=void 0,Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _catalogG.ICON_NAMES}}),exports.resolveGlyph=exports.default=exports.buildIconXml=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNativeSvg=require("react-native-svg"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_guards=require("../../utils/guards.js"),_Text=require("../Text/Text.js"),_catalogG=require("./catalog.g.js"),_glyphsG=require("./glyphs.g.js"),_jsxRuntime=require("react/jsx-runtime");const ICONSAX_SUFFIX=exports.ICONSAX_SUFFIX="-iconsax",APP_ICON_SIZES=exports.APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36},tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",a=`${e}:${t}`,o=shardCache.get(a);if(void 0!==o)return o;const l=_catalogG.CATALOG_LOADERS[e]?.[t],s=l?tryRequire(l):null;return shardCache.set(a,s),s},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)},resolveGlyph=(e,r="linear")=>{if(e.endsWith(ICONSAX_SUFFIX)){const t=e.slice(0,-ICONSAX_SUFFIX.length);return t in _glyphsG.GLYPHS?resolveCatalogue(t,r):null}const t=(0,_guards.hasKey)(_glyphsG.GLYPHS,e)?_glyphsG.GLYPHS[e]:void 0;return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};exports.resolveGlyph=resolveGlyph;const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;exports.buildIconXml=buildIconXml;const iconXmlCache=new Map,AppIcon=({name:e,size:r="md",color:t,variant:a="linear",style:o,accessibilityLabel:l,testID:s})=>{const n=(0,_index.useTheme)();"string"==typeof r&&(0,_assertValidValue.assertValidValue)("AppIcon","size",r,Object.keys(APP_ICON_SIZES)),(0,_assertValidValue.assertValidValue)("AppIcon","variant",a,["linear","bold","bulk","broken","outline","twotone"]);const i="number"==typeof r?r:APP_ICON_SIZES[r]??APP_ICON_SIZES.md,c=void 0===t?n.colors["text-body"]:(0,_Text.resolveColor)(n,t),u=resolveGlyph(e,a),d=(0,_react.useMemo)(()=>{if(!u)return null;const r=`${e}|${a}|${i}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const o=buildIconXml(u,i,c);return iconXmlCache.set(r,o),o},[e,a,u,i,c]);if(!d)return __DEV__&&!warned.has(e)&&(warned.add(e),_mobileCore.Logger.warn(`[@webority/mobile-ui] AppIcon: Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run node scripts/gen-icons.mjs after adding one there.`)),null;const p=null!=l?{accessibilityLabel:l,accessibilityRole:"image"}:{};return(0,_jsxRuntime.jsx)(_reactNativeSvg.SvgXml,{xml:d,width:i,height:i,...void 0!==o?{style:o}:{},accessible:null!=l,...p,...void 0!==s?{testID:s}:{}})};exports.AppIcon=AppIcon,AppIcon.displayName="AppIcon";var _default=exports.default=AppIcon;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppIcon=exports.APP_ICON_SIZES=void 0,Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _glyphsG.CURATED_ICON_NAMES}}),exports.ICONSAX_SUFFIX=void 0,Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _catalogG.ICON_NAMES}}),exports.default=exports.buildIconXml=void 0,exports.isAppIconName=isAppIconName,exports.resolveGlyph=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNativeSvg=require("react-native-svg"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_guards=require("../../utils/guards.js"),_Text=require("../Text/Text.js"),_catalogG=require("./catalog.g.js"),_glyphsG=require("./glyphs.g.js"),_jsxRuntime=require("react/jsx-runtime");const ICONSAX_SUFFIX=exports.ICONSAX_SUFFIX="-iconsax";function isAppIconName(e){return"string"==typeof e&&(!!_catalogG.ICON_NAMES.some(r=>r===e)||e.endsWith(ICONSAX_SUFFIX)&&_glyphsG.CURATED_ICON_NAMES.some(r=>r===e.slice(0,-ICONSAX_SUFFIX.length)))}const APP_ICON_SIZES=exports.APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36},tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",o=`${e}:${t}`,a=shardCache.get(o);if(void 0!==a)return a;const s=_catalogG.CATALOG_LOADERS[e]?.[t],n=s?tryRequire(s):null;return shardCache.set(o,n),n},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)},resolveGlyph=(e,r="linear")=>{if(e.endsWith(ICONSAX_SUFFIX)){const t=e.slice(0,-ICONSAX_SUFFIX.length);return t in _glyphsG.GLYPHS?resolveCatalogue(t,r):null}const t=(0,_guards.hasKey)(_glyphsG.GLYPHS,e)?_glyphsG.GLYPHS[e]:void 0;return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};exports.resolveGlyph=resolveGlyph;const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;exports.buildIconXml=buildIconXml;const iconXmlCache=new Map,AppIcon=({name:e,size:r="md",color:t,variant:o="linear",style:a,accessibilityLabel:s,testID:n})=>{const l=(0,_index.useTheme)();"string"==typeof r&&(0,_assertValidValue.assertValidValue)("AppIcon","size",r,Object.keys(APP_ICON_SIZES)),(0,_assertValidValue.assertValidValue)("AppIcon","variant",o,["linear","bold","bulk","broken","outline","twotone"]);const i="number"==typeof r?r:APP_ICON_SIZES[r]??APP_ICON_SIZES.md,c=void 0===t?l.colors["text-body"]:(0,_Text.resolveColor)(l,t),u=resolveGlyph(e,o),d=(0,_react.useMemo)(()=>{if(!u)return null;const r=`${e}|${o}|${i}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const a=buildIconXml(u,i,c);return iconXmlCache.set(r,a),a},[e,o,u,i,c]);if(!d)return __DEV__&&!warned.has(e)&&(warned.add(e),_mobileCore.Logger.warn(`[@webority/mobile-ui] AppIcon: Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run node scripts/gen-icons.mjs after adding one there.`)),null;const p=null!=s?{accessibilityLabel:s,accessibilityRole:"image"}:{};return(0,_jsxRuntime.jsx)(_reactNativeSvg.SvgXml,{xml:d,width:i,height:i,...void 0!==a?{style:a}:{},accessible:null!=s,...p,...void 0!==n?{testID:n}:{}})};exports.AppIcon=AppIcon,AppIcon.displayName="AppIcon";var _default=exports.default=AppIcon;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"APP_ICON_SIZES",{enumerable:!0,get:function(){return _AppIcon.APP_ICON_SIZES}}),Object.defineProperty(exports,"AppIcon",{enumerable:!0,get:function(){return _AppIcon.AppIcon}}),Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _AppIcon.CURATED_ICON_NAMES}}),Object.defineProperty(exports,"ICONSAX_SUFFIX",{enumerable:!0,get:function(){return _AppIcon.ICONSAX_SUFFIX}}),Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _AppIcon.ICON_NAMES}}),Object.defineProperty(exports,"buildIconXml",{enumerable:!0,get:function(){return _AppIcon.buildIconXml}}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return _AppIcon.default}}),Object.defineProperty(exports,"defaultIcons",{enumerable:!0,get:function(){return _defaultIcons.defaultIcons}}),Object.defineProperty(exports,"renderSlotIcon",{enumerable:!0,get:function(){return _slotIcon.renderSlotIcon}}),Object.defineProperty(exports,"resolveGlyph",{enumerable:!0,get:function(){return _AppIcon.resolveGlyph}});var cache,_AppIcon=_interopRequireWildcard(require("./AppIcon.js")),_defaultIcons=require("./defaultIcons.js"),_slotIcon=require("./slotIcon.js");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,n,o=Object.defineProperty,c={__proto__:null,default:e};if(Object(e)!==e)return c;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,c)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((t=o&&Object.getOwnPropertyDescriptor(e,n))&&(t.get||t.set)?o(c,n,t):c[n]=e[n]);return c}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"APP_ICON_SIZES",{enumerable:!0,get:function(){return _AppIcon.APP_ICON_SIZES}}),Object.defineProperty(exports,"AppIcon",{enumerable:!0,get:function(){return _AppIcon.AppIcon}}),Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _AppIcon.CURATED_ICON_NAMES}}),Object.defineProperty(exports,"ICONSAX_SUFFIX",{enumerable:!0,get:function(){return _AppIcon.ICONSAX_SUFFIX}}),Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _AppIcon.ICON_NAMES}}),Object.defineProperty(exports,"buildIconXml",{enumerable:!0,get:function(){return _AppIcon.buildIconXml}}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return _AppIcon.default}}),Object.defineProperty(exports,"defaultIcons",{enumerable:!0,get:function(){return _defaultIcons.defaultIcons}}),Object.defineProperty(exports,"isAppIconName",{enumerable:!0,get:function(){return _AppIcon.isAppIconName}}),Object.defineProperty(exports,"renderSlotIcon",{enumerable:!0,get:function(){return _slotIcon.renderSlotIcon}}),Object.defineProperty(exports,"resolveGlyph",{enumerable:!0,get:function(){return _AppIcon.resolveGlyph}});var cache,_AppIcon=_interopRequireWildcard(require("./AppIcon.js")),_defaultIcons=require("./defaultIcons.js"),_slotIcon=require("./slotIcon.js");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,n,o=Object.defineProperty,c={__proto__:null,default:e};if(Object(e)!==e)return c;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,c)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((t=o&&Object.getOwnPropertyDescriptor(e,n))&&(t.get||t.set)?o(c,n,t):c[n]=e[n]);return c}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),BannerRoot=(0,_react.forwardRef)((e,t)=>{const{title:r,message:i,tone:s="neutral",variant:n="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:x=!0,loading:m=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:g,style:h,containerStyle:y,iconCircleStyle:b,tintBarStyle:v,closeButtonStyle:j,actionButtonStyle:f,testID:R}=e;(0,_assertValidValue.assertValidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_assertValidValue.assertValidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const w=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),B=(0,_react.useMemo)(()=>buildStyles(w),[w]),S=(0,_react.useMemo)(()=>tintFor(w,s),[w,s]),N=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...g}),[g]),[C,k]=V.range(-20,0),D=(0,_react.useRef)((0,_index.createAnimatedValue)(x&&u?C:0)).current,A=(0,_react.useRef)((0,_index.createAnimatedValue)(x&&u?0:u?1:0)).current,[L,I]=(0,_react.useState)(u),E=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>{if(E.current&&(E.current=!1,!x))return;let e;return u?(I(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(D,{toValue:k,duration:w.motion.duration.default,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(A,{toValue:1,duration:V.duration("default"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start()):L&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(D,{toValue:C,duration:w.motion.duration.fast,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(A,{toValue:0,duration:V.duration("fast"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start(()=>{I(!1)})),()=>e?.stop()},[u]),!L)return null;const T=r??" ",q="string"==typeof i?i??" ":"",M="wash"===n,z="bar"!==n,H="alert"===p?"danger"===s?"assertive":"polite":"none",P=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:H,accessibilityLabel:_,testID:R,style:[B.container,{backgroundColor:z?S.soft:w.colors["bg-subtle"],borderRadius:M?w.radius.sm:w.radius.md,..._corners.smoothCorners,padding:w.space.md,opacity:A,transform:[{translateY:D}]},y,h],children:[!M&&w.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[B.tintBar,{backgroundColor:S.bar},v]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.row,void 0===r&&B.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(a,{color:S.ink,size:w.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:S.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[B.iconGlyph,{color:S.ink}],children:S.glyph}),style:[B.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.textBlock,children:[r||m?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:M?{color:S.ink}:void 0,children:T}):null,"string"==typeof i||m?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{marginTop:r?w.space.xxs:0},children:q||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?w.space.xxs:0},children:i})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[B.closeBtn,{backgroundColor:e?w.colors["surface-pressed"]:"transparent"},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:Math.round(w.text.lg.size*w.leading.heading)},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.actionsRow,children:o.map((e,t)=>{(0,_assertValidValue.assertValidValue)("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","action.variant",e.variant,["solid","outline","ghost"]),(0,_assertValidValue.assertValidValue)("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",i=e.variant??"ghost",s="primary"===r?S.glyphColor:"neutral"===r?w.colors["text-muted"]:w.colors[r],n="primary"===r?S.ink:"neutral"===r?w.colors["text-muted"]:w.colors[`${r}-text`],a="primary"===r?S.on:"neutral"===r?w.colors["on-neutral-strong"]:w.colors[`on-${r}`],o="solid"===i;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=(0,_hapticUtils.resolveHaptic)(d,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:({pressed:t})=>[B.actionBtn,"md"===e.size&&B.actionBtnMd,"outline"===i&&{borderWidth:1,borderColor:n},{backgroundColor:o?s:t?w.colors["surface-pressed"]:"transparent",opacity:o&&t?.85:1},f],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:n},children:e.label})},`${e.label}-${t}`)})}):null]});return m?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):P}),BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:i,style:s})=>{const n=(0,_index.useTheme)(),a=!1!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,..._corners.smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},i,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:n.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:n.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton";const Banner=exports.Banner=Object.assign(BannerRoot,{Skeleton:BannerSkeleton});Banner.displayName="Banner";const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return _reactNative.StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:Math.round(e.text.base.size*e.leading.heading)},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),BannerRoot=(0,_react.forwardRef)((e,t)=>{const{title:r,message:i,tone:n="neutral",variant:s="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:x=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:h,style:g,containerStyle:y,iconCircleStyle:b,tintBarStyle:v,closeButtonStyle:f,actionButtonStyle:j,testID:R}=e;(0,_assertValidValue.assertValidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_assertValidValue.assertValidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const w=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),B=(0,_react.useMemo)(()=>buildStyles(w),[w]),S=(0,_react.useMemo)(()=>tintFor(w,n),[w,n]),N=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...h}),[h]),k=(0,_react.useMemo)(()=>(o??[]).map((e,t)=>({key:`${e.label}-${t}`,action:e})),[o]),[C,D]=V.range(-20,0),A=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?C:0)).current,L=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?0:u?1:0)).current,[I,M]=(0,_react.useState)(u),E=(0,_react.useRef)(!0),T=(0,_react.useRef)({animateMount:m,mounted:I,theme:w,presence:V,hiddenY:C,shownY:D,translateY:A,opacity:L});if(T.current={animateMount:m,mounted:I,theme:w,presence:V,hiddenY:C,shownY:D,translateY:A,opacity:L},(0,_react.useEffect)(()=>{if(E.current&&(E.current=!1,!T.current.animateMount))return;let e;return u?(M(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(T.current.translateY,{toValue:T.current.shownY,duration:T.current.theme.motion.duration.default,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(T.current.opacity,{toValue:1,duration:T.current.presence.duration("default"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start()):T.current.mounted&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(T.current.translateY,{toValue:T.current.hiddenY,duration:T.current.theme.motion.duration.fast,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(T.current.opacity,{toValue:0,duration:T.current.presence.duration("fast"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start(()=>{M(!1)})),()=>e?.stop()},[u]),!I)return null;const q=r??" ",z="string"==typeof i?i??" ":"",Y="wash"===s,H="bar"!==s,P="alert"===p?"danger"===n?"assertive":"polite":"none",U=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:P,accessibilityLabel:_,testID:R,style:[B.container,{backgroundColor:H?S.soft:w.colors["bg-subtle"],borderRadius:Y?w.radius.sm:w.radius.md,..._corners.smoothCorners,padding:w.space.md,opacity:L,transform:[{translateY:A}]},y,g],children:[!Y&&w.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[B.tintBar,{backgroundColor:S.bar},v]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.row,void 0===r&&B.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(a,{color:S.ink,size:w.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:S.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[B.iconGlyph,{color:S.ink}],children:S.glyph}),style:[B.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.textBlock,children:[r||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:Y?{color:S.ink}:void 0,children:q}):null,"string"==typeof i||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{marginTop:r?w.space.xxs:0},children:z||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?w.space.xxs:0},children:i})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[B.closeBtn,{backgroundColor:e?w.colors["surface-pressed"]:"transparent"},f],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:Math.round(w.text.lg.size*w.leading.heading)},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.actionsRow,children:k.map(({key:e,action:t})=>{(0,_assertValidValue.assertValidValue)("Banner","action.tone",t.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","action.variant",t.variant,["solid","outline","ghost"]),(0,_assertValidValue.assertValidValue)("Banner","action.size",t.size,["sm","md"]);const r=t.tone??"primary",i=t.variant??"ghost",n="primary"===r?S.glyphColor:"neutral"===r?w.colors["text-muted"]:w.colors[r],s="primary"===r?S.ink:"neutral"===r?w.colors["text-muted"]:w.colors[`${r}-text`],a="primary"===r?S.on:"neutral"===r?w.colors["on-neutral-strong"]:w.colors[`on-${r}`],o="solid"===i;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t.label,testID:t.testID,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),t.onPress()},style:({pressed:e})=>[B.actionBtn,"md"===t.size&&B.actionBtnMd,"outline"===i&&{borderWidth:1,borderColor:s},{backgroundColor:o?n:e?w.colors["surface-pressed"]:"transparent",opacity:o&&e?.85:1},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:s},children:t.label})},e)})}):null]});return x?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):U}),BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:i,style:n})=>{const s=(0,_index.useTheme)(),a=!1!==r,o=t?.length??0,l=(0,_react.useMemo)(()=>Array.from({length:o},(e,t)=>({key:`sk-banner-action-${t}`})),[o]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,..._corners.smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},i,n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:s.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:s.space.sm},children:l.map(e=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},e.key))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton";const Banner=exports.Banner=Object.assign(BannerRoot,{Skeleton:BannerSkeleton});Banner.displayName="Banner";const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return _reactNative.StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:Math.round(e.text.base.size*e.leading.heading)},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
@@ -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"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.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,entryAt=(e,t)=>{const r=e[t];if(void 0===r)throw new Error(`BarChart has no entry at index ${t}.`);return r},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:y,style:b,testID:p}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...y}),[y]),j=(0,_index2.useTheme)(),v=r.length,[R,A]=(0,_react.useState)(0),[g,C]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),S=null!==g&&g>=0&&g<v?g:null,w=(0,_react.useRef)(S);w.current=S;const M=(0,_react.useRef)(-1),T=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{T&&(0,_index3.triggerHaptic)(T)},[T]),L=d??(v>0&&v<=7),V=void 0!==s&&s.length>0,B=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??entryAt(STACK_TONES,t%STACK_TONES.length)):[],[V,s]),D=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),E=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),$=(0,_react.useMemo)(()=>E?E.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,E]),H=(0,_react.useMemo)(()=>E?E.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):$,[E,$]),I=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&I.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+(I.max-e)/(I.max-I.min)*F,[k,I.max,I.min,F]),q=G(0),W=(0,_react.useMemo)(()=>I.ticks.map(e=>u(e)),[I.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=entryAt(r,e);if(t.accessibilityLabel)return t.accessibilityLabel;if(E&&s){const r=entryAt(E,e);return`${t.label}, ${s.map((e,t)=>`${e.label} ${c(entryAt(r,t))}`).join(", ")}`}return`${t.label}, ${c(entryAt($,e))}`},[r,c,$,E,s]),K=(0,_react.useMemo)(()=>{let e=-1,t=0;for(const[r,a]of $.entries())(-1===e||a>t)&&(e=r,t=a);return e},[$]),J=o??(K>=0?f.highest(entryAt(r,K).label,c(entryAt($,K))):""),Y=(0,_react.useRef)({fire:N,setSelected:C,count:v,plotWidth:R});Y.current={fire:N,setSelected:C,count:v,plotWidth:R};const Z=(0,_react.useCallback)(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)))},[]),Q=(0,_react.useCallback)(e=>{const t=Z(e);t<0||t===M.current||(M.current=t,Y.current.fire(),Y.current.setSelected(t))},[Z]),ee=(0,_react.useMemo)(()=>({runOnJS:!0,activeOffsetX:[-8,8],failOffsetY:[-12,12],onActivate:e=>{M.current=w.current??-1,Q(e.x)},onUpdate:e=>Q(e.x),testID:p?`${p}-pan`:"bar-chart-pan"}),[Q,p]),te=(0,_reactNativeGestureHandler.usePanGesture)(ee),re=(0,_react.useMemo)(()=>({runOnJS:!0,onDeactivate:e=>{if(e.canceled)return;const t=Z(e.x);t<0||(Y.current.fire(),M.current=t,Y.current.setSelected(t===w.current?null:t))},testID:p?`${p}-tap`:"bar-chart-tap"}),[Z,p]),ae=(0,_reactNativeGestureHandler.useTapGesture)(re),ie=(0,_reactNativeGestureHandler.useCompetingGestures)(te,ae),se=(0,_react.useCallback)(e=>{if(0===v)return;const t=w.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(),C(r))},[v,N,C]),ne=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);A(e=>e===t?e:t)},[]),le=i??toneColor(j,a),oe=j.radius.sm,ce=l??f.chart,ue=0===v?`${ce}, ${f.noData}`:J?`${ce}, ${J}`:ce,de=null===S?J:X(S),me=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:p?`${p}-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,entryAt(B,r))}},entryAt(D,r)))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:p?`${p}-bar-${t}`:void 0,style:{position:"absolute",left:(z-me)/2,top:s,width:me,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:oe,borderTopRightRadius:oe}:null,...i<0?{borderBottomLeftRadius:oe,borderBottomRightRadius:oe}:null},children:n})},xe=$.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!==S&&S!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[R>0&&E?renderStack(entryAt(E,t),t,s):null,R>0&&!E&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:p?`${p}-bar-${t}`:void 0,style:{position:"absolute",left:(z-me)/2,top:a,width:me,height:i,backgroundColor:le,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:oe,borderTopRightRadius:oe}:{borderBottomLeftRadius:oe,borderBottomRightRadius:oe}}}):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?(E?G(entryAt(H,2*t)):r)-20+2:(E?G(entryAt(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:ue,testID:p,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:ue,accessibilityValue:{min:0,max:v-1,now:S??0,text:de},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:se,testID:p,style:[styles.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===S?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:entryAt(r,S).label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:p?`${p}-callout`:void 0,children:c(entryAt($,S))})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:I.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:entryAt(W,t)},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ie,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ne,testID:p?`${p}-plot`:void 0,children:[I.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:xe})]})}),(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:S===t?"primary":"tertiary",weight:S===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,entryAt(B,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"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.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,entryAt=(e,t)=>{const r=e[t];if(void 0===r)throw new Error(`BarChart has no entry at index ${t}.`);return r},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:y,style:p,testID:b}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...y}),[y]),j=(0,_index2.useTheme)(),v=r.length,[R,A]=(0,_react.useState)(0),[g,C]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),M=null!==g&&g>=0&&g<v?g:null,S=(0,_react.useRef)(M);S.current=M;const w=(0,_react.useRef)(-1),T=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{T&&(0,_index3.triggerHaptic)(T)},[T]),L=d??(v>0&&v<=7),V=void 0!==s&&s.length>0,B=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??entryAt(STACK_TONES,t%STACK_TONES.length)):[],[V,s]),D=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),k=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),E=(0,_react.useMemo)(()=>k?k.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,k]),$=(0,_react.useMemo)(()=>k?k.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):E,[k,E]),H=(0,_react.useMemo)(()=>(0,_scale.barScale)($),[$]),I=L?20:6,O=L&&H.min<0?20:6,F=Math.max(1,n-I-O),G=(0,_react.useCallback)(e=>I+(H.max-e)/(H.max-H.min)*F,[I,H.max,H.min,F]),q=G(0),W=(0,_react.useMemo)(()=>H.ticks.map(e=>u(e)),[H.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.useMemo)(()=>r.map((e,t)=>({key:`axis-${t}`,d:e,index:t})),[r]),K=(0,_react.useCallback)(e=>{const t=entryAt(r,e);if(t.accessibilityLabel)return t.accessibilityLabel;if(k&&s){const r=entryAt(k,e);return`${t.label}, ${s.map((e,t)=>`${e.label} ${c(entryAt(r,t))}`).join(", ")}`}return`${t.label}, ${c(entryAt(E,e))}`},[r,c,E,k,s]),J=(0,_react.useMemo)(()=>{let e=-1,t=0;for(const[r,a]of E.entries())(-1===e||a>t)&&(e=r,t=a);return e},[E]),Y=o??(J>=0?f.highest(entryAt(r,J).label,c(entryAt(E,J))):""),Z=(0,_react.useRef)({fire:N,setSelected:C,count:v,plotWidth:R});Z.current={fire:N,setSelected:C,count:v,plotWidth:R};const Q=(0,_react.useCallback)(e=>{const{count:t,plotWidth:r}=Z.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},[]),ee=(0,_react.useCallback)(e=>{const t=Q(e);t<0||t===w.current||(w.current=t,Z.current.fire(),Z.current.setSelected(t))},[Q]),te=(0,_react.useMemo)(()=>({runOnJS:!0,activeOffsetX:[-8,8],failOffsetY:[-12,12],onActivate:e=>{w.current=S.current??-1,ee(e.x)},onUpdate:e=>ee(e.x),testID:b?`${b}-pan`:"bar-chart-pan"}),[ee,b]),re=(0,_reactNativeGestureHandler.usePanGesture)(te),ae=(0,_react.useMemo)(()=>({runOnJS:!0,onDeactivate:e=>{if(e.canceled)return;const t=Q(e.x);t<0||(Z.current.fire(),w.current=t,Z.current.setSelected(t===S.current?null:t))},testID:b?`${b}-tap`:"bar-chart-tap"}),[Q,b]),ie=(0,_reactNativeGestureHandler.useTapGesture)(ae),se=(0,_reactNativeGestureHandler.useCompetingGestures)(re,ie),ne=(0,_react.useCallback)(e=>{if(0===v)return;const t=S.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(),C(r))},[v,N,C]),le=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);A(e=>e===t?e:t)},[]),oe=i??toneColor(j,a),ce=j.radius.sm,ue=l??f.chart,de=0===v?`${ue}, ${f.noData}`:Y?`${ue}, ${Y}`:ue,me=null===M?Y:K(M),xe=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:b?`${b}-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,entryAt(B,r))}},entryAt(D,r)))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}`:void 0,style:{position:"absolute",left:(z-xe)/2,top:s,width:xe,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:ce,borderTopRightRadius:ce}:null,...i<0?{borderBottomLeftRadius:ce,borderBottomRightRadius:ce}:null},children:n})},he=(0,_react.useMemo)(()=>E.map((e,t)=>({key:`bar-${t}`,value:e,index:t})),[E]).map(({key:e,value:t,index:r})=>{const a=G(t),i=t>=0?a:q,s=0===t?0:Math.max(2,Math.abs(a-q)),l=null!==M&&M!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[R>0&&k?renderStack(entryAt(k,r),r,l):null,R>0&&!k&&s>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${r}`:void 0,style:{position:"absolute",left:(z-xe)/2,top:i,width:xe,height:s,backgroundColor:oe,opacity:l?.4:1,..._corners.smoothCorners,...t>=0?{borderTopLeftRadius:ce,borderTopRightRadius:ce}:{borderBottomLeftRadius:ce,borderBottomRightRadius:ce}}}):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:t>=0?(k?G(entryAt($,2*r)):a)-20+2:(k?G(entryAt($,2*r+1)):a)+2},children:u(t)}):null]},e)});return 0===v?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:de,testID:b,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:de,accessibilityValue:{min:0,max:v-1,now:M??0,text:me},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:ne,testID:b,style:[styles.root,p],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===M?Y?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:Y}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:entryAt(r,M).label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:b?`${b}-callout`:void 0,children:c(entryAt(E,M))})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:H.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:entryAt(W,t)},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:se,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:le,testID:b?`${b}-plot`:void 0,children:[H.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:he})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:X.map(({key:e,d:t,index:r})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:r%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:M===r?"primary":"tertiary",weight:M===r?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:t.axisLabel??t.label}):null},e))})]})]}),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,entryAt(B,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.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:j,actions:C,actionsLayout:w="auto",footer:M,headerStyle:O,footerStyle:E,children:k,accessibilityLabel:T,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=j||null!=d,D=null!=C&&C.length>0,L=null!=M||D,P=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===P?X.top:q.top,ee="modal"===P?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(L?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[je,Ce]=(0,_react.useState)(!1),[we,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[ke,Te]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===P?we:ke;const Ie=(0,_react.useRef)(u);Ie.current=u;const De=(0,_react.useRef)(r);De.current=r;const Le=(0,_react.useRef)(!1),Pe=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(Pe.current=!0,()=>{Pe.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===P?(Ce(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):Te(!1))},[P,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===P?!we:!ke)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[P,we,ke,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===P?(Me(!0),Ce(!0)):Te(!0),a<0&&Ae.current?(be.value=r,ye.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,P,s,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=xe.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,s,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Le.current)return void t?.();const n=r();"boolean"!=typeof n?(Le.current=!0,a?.(),n.then(a=>{Le.current=!1,a&&Pe.current&&Be.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{De.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{De.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),De.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>({testID:B?`${B}-content-gesture`:"bottom-sheet-content-gesture"}),[B]),st=(0,_reactNativeGestureHandler.useNativeGesture)(ot),it=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return{testID:B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";pe.value=be.value},onUpdate:e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const n=be.value,o=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t);if(o>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(n-t);e<l&&(l=e,c=t,i=u),u++}r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(i,c)}}},[fe,pe,c,nt,tt,at,B,be]),ct=(0,_reactNativeGestureHandler.usePanGesture)(it),{height:lt}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ut="shift"===p,dt=(0,_reactNativeReanimated.useDerivedValue)(()=>ut?lt.value:0,[ut,lt]),_t=ve[Re>=0?Re:0]??Se,ht=H.space.md,mt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=dt.value,t=F+e-_t-ht,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+dt.value,t=dt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,dt,F,_t,ht,be,Z,ye,tt]),vt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=dt.value;if(K){const t=F+e-_t-ht,a=e<0&&be.value>t?t:be.value,r=F+e-ht-(a<Z?Z:a);return{height:r<0?0:r>_t?_t:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[dt,K,F,_t,ht,be,Z,tt,Se]),ft=Re>=0,St=(0,_react.useMemo)(()=>buildStyles(H),[H]),bt=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),De.current(),Ye()})},[l,Ye,Ke]),pt=(0,_react.useMemo)(()=>({testID:B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeReanimated.runOnJS)(bt)()}}),[bt,B]),yt=(0,_reactNativeGestureHandler.useTapGesture)(pt),xt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===P&&!ke)return null;if("modal"===P&&!we)return null;const Rt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===P?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===P?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??ft,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:yt,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:T,accessibilityViewIsModal:A??ft,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:_t,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,mt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[St.body,vt],keyboardOffset:dt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ct,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:St.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[St.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[St.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,j]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:st,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:St.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:k})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:k}):k}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[St.footer,E],onLayout:te?ue:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:St.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:C??[],layout:w})}):null,M]})]})})]}),Nt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:xt,children:Rt});return"modal"===P?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:je,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:St.modalRoot,children:Nt}):Nt}):Nt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:x=!1,presentation:R="sheet",animateMount:y=!0,handleIndicatorStyle:N,containerStyle:g,header:M,actions:j,actionsLayout:C="auto",footer:w,headerStyle:O,footerStyle:E,children:k,accessibilityLabel:T,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=M||null!=d,D=null!=j&&j.length>0,L=null!=w||D,P=x?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===R||"auto"===R&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===P?X.top:q.top,ee="modal"===P?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(L?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),xe=(0,_reactNativeReanimated.useSharedValue)(1),Re=(0,_reactNativeReanimated.useSharedValue)(-1),[ye,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[Me,je]=(0,_react.useState)(!1),[Ce,we]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[ke,Te]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!y&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===P?Ce:ke;const Ie=(0,_react.useRef)(u);Ie.current=u;const De=(0,_react.useRef)(r);De.current=r;const Le=(0,_react.useRef)(!1),Pe=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(Pe.current=!0,()=>{Pe.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;ye!==e&&(Ne(e),Re.value=e,e>=0&&o?.(e))},[ye,Re,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,Re.value<0&&(Oe.current=!0,"modal"===P?(je(!1),"ios"!==_reactNative.Platform.OS&&we(!1)):Te(!1))},[P,Re]),Je=(0,_react.useCallback)(()=>{Oe.current&&we(!1)},[]);(0,_react.useEffect)(()=>{("modal"===P?!Ce:!ke)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[P,Ce,ke,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Math.max(ye,0),a=Re.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===P?(we(!0),je(!0)):Te(!0),a<0&&Ae.current?(be.value=r,xe.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,xe.value=0,xe.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,xe.value=1),Fe(t),void ze(r,a,t))},[ze,fe,ye,Re,P,s,G,xe,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=Re.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?xe:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,Re,Ue,s,G,xe,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Le.current)return void t?.();const n=r();"boolean"!=typeof n?(Le.current=!0,a?.(),n.then(a=>{Le.current=!1,a&&Pe.current&&Be.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{De.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{De.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null),et=(0,_react.useRef)(We);et.current=We;const tt=(0,_react.useRef)(Ye);tt.current=Ye,(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?et.current(n??0):tt.current():a&&"number"==typeof n&&n!==Re.value&&et.current(n)},[a,n,Re]);const at=(0,_react.useRef)({hostHeight:F,contentSnap:he}),rt=(0,_react.useRef)(qe);rt.current=qe,(0,_react.useEffect)(()=>{const e=at.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(at.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&Re.value<0)return;const t=rt.current(Re.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he,Re,be]);const nt=F-Se,ot=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),st=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),it=(0,_react.useCallback)((e,t)=>{const a=Re.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),De.current(),Ye()},st,st)},[ze,Ye,Re,Ke,Fe,st]),ct=(0,_react.useMemo)(()=>({testID:B?`${B}-content-gesture`:"bottom-sheet-content-gesture"}),[B]),lt=(0,_reactNativeGestureHandler.useNativeGesture)(ct),ut=(0,_react.useMemo)(()=>{const e=ot,t=fe,a=nt,r=c;return{testID:B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";pe.value=be.value},onUpdate:e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const n=be.value,o=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeReanimated.runOnJS)(it)(-1,t);if(o>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(it)(-1,t):void(0,_reactNativeReanimated.runOnJS)(it)(0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(n-t);e<l&&(l=e,c=t,i=u),u++}r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(it)(-1,t):(0,_reactNativeReanimated.runOnJS)(it)(i,c)}}},[fe,pe,c,it,nt,ot,B,be]),dt=(0,_reactNativeGestureHandler.usePanGesture)(ut),{height:_t}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ht="shift"===p,mt=(0,_reactNativeReanimated.useDerivedValue)(()=>ht?_t.value:0,[ht,_t]),vt=ve[Math.max(ye,0)]??Se,ft=H.space.md,St=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=mt.value,t=F+e-vt-ft,a=e<0&&be.value>t?t:be.value;return{top:Math.max(a,Z),opacity:xe.value}}const e=be.value+mt.value,t=mt.value<0?Z:nt;return{top:Math.max(e,t),opacity:xe.value}},[K,mt,F,vt,ft,be,Z,xe,nt]),bt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=mt.value;if(K){const t=F+e-vt-ft,a=e<0&&be.value>t?t:be.value,r=Math.max(a,Z),n=F+e-ft-r;return{height:n<0?0:Math.min(n,vt)}}const t=e<0?Z:nt,a=be.value+e,r=Math.max(a,t),n=F+e-r;return{height:n<0?0:Math.min(n,Se)}},[mt,K,F,vt,ft,be,Z,nt,Se]),pt=ye>=0,xt=(0,_react.useMemo)(()=>buildStyles(H),[H]),Rt=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),De.current(),Ye()})},[l,Ye,Ke]),yt=(0,_react.useMemo)(()=>({testID:B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeReanimated.runOnJS)(Rt)()}}),[Rt,B]),Nt=(0,_reactNativeGestureHandler.useTapGesture)(yt),gt=(0,_react.useMemo)(()=>({snapIndex:ye,snapPoints:ve,close:Xe,requestClose:$e}),[ye,ve,Xe,$e]);if("inline"===P&&!ke)return null;if("modal"===P&&!Ce)return null;const Mt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===P?xt.backdropModal:xt.backdropInline,{backgroundColor:"modal"===P?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??pt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Nt,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:T,accessibilityViewIsModal:A??pt,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[xt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:vt,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,St],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[xt.body,bt],keyboardOffset:mt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:dt,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:xt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[xt.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[xt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:lt,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:xt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:k})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[xt.content,{overflow:"visible"}]:xt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:k}):k}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[xt.footer,E],onLayout:te?ue:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:xt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,w]})]})})]}),jt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:gt,children:Mt});return"modal"===P?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:xt.modalRoot,children:jt}):jt}):jt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:Math.max(e,0)}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_BUTTON_LABELS=exports.Button=void 0,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BUTTON_LABELS=exports.DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"}),Button=exports.Button=(0,_react.forwardRef)((e,t)=>{const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:a=!1,fullWidth:l=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:p,style:h,containerStyle:x,textStyle:m,pressAnimation:f,onPress:v,accessibilityLabel:y,accessibilityHint:S,accessibilityState:j,testID:C,onLayout:I,labels:L,...k}=e;(0,_assertValidValue.assertValidValue)("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),(0,_assertValidValue.assertValidValue)("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Button","size",e.size,["xs","sm","md","lg","xl"]);const T=(0,_index.useTheme)(),R=T.settings.components.button,F=o??R?.defaultVariant??"solid",V=i??R?.defaultSize??"md",w=(0,_react.useMemo)(()=>({...DEFAULT_BUTTON_LABELS,...L}),[L]),[N,q]=(0,_react.useState)(!1),A=(0,_react.useRef)(!1),O=n||N,B=!a&&!O,P={...j,disabled:!B,busy:O},D="link"===F,E=f??R?.defaultPressAnimation??(!D&&"scale"),z=(0,_usePressAnimation.usePressAnimation)({preset:E||"scale",enabled:!1!==E&&B}),W=(0,_useFlickGuard.useFlickGuard)(),H=(0,_react.useMemo)(()=>buildStyles(T),[T]),U=(0,_react.useMemo)(()=>(0,_index.resolveButtonSize)(T,V),[T,V]),M=(0,_react.useMemo)(()=>toneFor(T,s),[T,s]),G=(0,_react.useMemo)(()=>variantFor(T,F,M,a),[T,F,M,a]),K=(0,_react.useMemo)(()=>!p||a||"solid"!==F?null:"string"==typeof p?T.settings.gradients[p]??null:p,[p,a,F,T.settings.gradients]),X=_reactNative.StyleSheet.flatten(h)?.borderRadius,Y=D?0:"number"==typeof X?X:_?T.radius.pill:U.radius,J=(0,_SquircleFill.useSquircle)(!K&&"link"!==F,Y,I),Q=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[Z,$]=(0,_react.useState)(0),[ee,te]=(0,_react.useState)(null),re=D?e=>$(e.nativeEvent.layout.width):void 0,settlePending=()=>{A.current=!1,q(!1)},oe=y??r,se="outline"===F||"ghost"===F,ie=!se&&!D,ne={color:G.textColor,size:U.icon,disabled:a},ae=b&&!D&&Boolean(c),le=T.space.xs,ce=U["min-height"]-2*le-2*G.borderWidth,de={color:G.badgeInk,size:U["badge-icon"],disabled:a},ue=O?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:"sm",color:ae?G.badgeInk:G.textColor,accessibilityLabel:w.loading}):c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(c,ae?de:ne,u)}):null,be=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.contentRow,children:[ae?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[H.iconLeft,H.iconBadge,{width:ce,height:ce,borderRadius:ce/2,backgroundColor:G.badgeFill}],children:ue}):ue?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.iconLeft,children:ue}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:re,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[H.label,{color:G.textColor,fontSize:U.text,lineHeight:Math.round(U.text*T.leading.body)},m],children:r}),D?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[H.linkUnderline,{backgroundColor:G.textColor,transform:[{translateX:Q.interpolate({inputRange:[0,1],outputRange:[-Z/2,0]})},{scaleX:Q.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(d,ne,u)}):null]}),ge=D?null===ee?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(ee)):touchSlopFor(U["min-height"]),pe={top:ge,bottom:ge,left:D?LINK_HIT_SLOP:0,right:D?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.style,l?H.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!B||A.current||W.isFlick(e))return;z.press();const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t);const r=v?.(e);return r instanceof Promise?(A.current=!0,q(!0),r.then(settlePending,e=>{throw settlePending(),e})):void 0},onPressIn:e=>{W.onPressIn(e),z.pressIn(),D&&B&&(Q.stopAnimation(),Q.setValue(0),_reactNative.Animated.timing(Q,{toValue:1,duration:T.motion.duration.slower,easing:_reactNative.Easing.bezier(...T.motion.ease.decelerate),useNativeDriver:_nativeDriver.nativeDriver}).start())},onPressOut:()=>{z.pressOut()},disabled:!B,hitSlop:pe,...(0,_hitSlop.hitSlopMarker)(pe),accessibilityRole:"button",accessibilityLabel:oe,accessibilityHint:S,accessibilityState:P,...(0,_ariaState.ariaFromState)(P),testID:C,onLayout:e=>{J.onLayout(e),D&&te(e.nativeEvent.layout.height)},style:({pressed:e})=>[H.base,{paddingHorizontal:D?0:U["padding-x"],paddingVertical:D?0:ae?le:U["padding-y"],paddingLeft:ae?le:void 0,minHeight:D?void 0:U["min-height"],borderRadius:Y,..._corners.smoothCorners,backgroundColor:K||J.active?"transparent":G.backgroundColor,borderWidth:G.borderWidth,borderColor:J.active?"transparent":G.borderColor,opacity:O?.55:1,overflow:J.active||D?"visible":"hidden"},e&&se&&!J.active?{backgroundColor:T.colors["surface-pressed"]}:null,l?H.fullWidth:null,h],...k,"aria-disabled":!B,"aria-busy":O,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[J.active&&J.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:J.size.width,height:J.size.height,radius:Y,fill:e&&se?T.colors["surface-pressed"]:G.backgroundColor,stroke:G.borderColor,strokeWidth:G.borderWidth}):null,K?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:K,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:Y,..._corners.smoothCorners}]}):null,e&&ie?J.active&&J.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:J.size.width,height:J.size.height,radius:Y,fill:G.pressedTint,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[H.pressedOverlay,{borderRadius:Y,backgroundColor:G.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,be]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};case"neutral":return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},a=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...a};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:e.size.border},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_BUTTON_LABELS=exports.Button=exports.BUTTON_VARIANTS=exports.BUTTON_TONES=void 0,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0,exports.isButtonTone=isButtonTone,exports.isButtonVariant=isButtonVariant;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const BUTTON_VARIANTS=exports.BUTTON_VARIANTS=["solid","soft","outline","ghost","link","glass"],BUTTON_TONES=exports.BUTTON_TONES=["primary","success","warning","danger","info","neutral"];function isButtonVariant(e){return BUTTON_VARIANTS.some(t=>t===e)}function isButtonTone(e){return BUTTON_TONES.some(t=>t===e)}const DEFAULT_BUTTON_LABELS=exports.DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"}),Button=exports.Button=(0,_react.forwardRef)((e,t)=>{const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:a=!1,fullWidth:l=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:p,style:h,containerStyle:x,textStyle:m,pressAnimation:f,onPress:T,accessibilityLabel:v,accessibilityHint:y,accessibilityState:S,testID:j,onLayout:I,labels:N,...C}=e;(0,_assertValidValue.assertValidValue)("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),(0,_assertValidValue.assertValidValue)("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Button","size",e.size,["xs","sm","md","lg","xl"]);const R=(0,_index.useTheme)(),k=R.settings.components.button,L=o??k?.defaultVariant??"solid",V=i??k?.defaultSize??"md",F=(0,_react.useMemo)(()=>({...DEFAULT_BUTTON_LABELS,...N}),[N]),[B,O]=(0,_react.useState)(!1),w=(0,_react.useRef)(!1),A=n||B,q=!a&&!A,E={...S,disabled:!q,busy:A},U="link"===L,P=f??k?.defaultPressAnimation??(!U&&"scale"),D=(0,_usePressAnimation.usePressAnimation)({preset:P||"scale",enabled:!1!==P&&q}),z=(0,_useFlickGuard.useFlickGuard)(),W=(0,_react.useMemo)(()=>buildStyles(R),[R]),H=(0,_react.useMemo)(()=>(0,_index.resolveButtonSize)(R,V),[R,V]),M=(0,_react.useMemo)(()=>toneFor(R,s),[R,s]),G=(0,_react.useMemo)(()=>variantFor(R,L,M,a),[R,L,M,a]),K=(0,_react.useMemo)(()=>!p||a||"solid"!==L?null:"string"==typeof p?R.settings.gradients[p]??null:p,[p,a,L,R.settings.gradients]),X=_reactNative.StyleSheet.flatten(h)?.borderRadius,Y=U?0:"number"==typeof X?X:_?R.radius.pill:H.radius,J=(0,_SquircleFill.useSquircle)(!K&&"link"!==L,Y,I),Q=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[Z,$]=(0,_react.useState)(0),[ee,te]=(0,_react.useState)(null),re=U?e=>$(e.nativeEvent.layout.width):void 0,settlePending=()=>{w.current=!1,O(!1)},oe=v??r,se="outline"===L||"ghost"===L,ie=!se&&!U,ne={color:G.textColor,size:H.icon,disabled:a},ae=b&&!U&&Boolean(c),le=R.space.xs,ce=H["min-height"]-2*le-2*G.borderWidth,de={color:G.badgeInk,size:H["badge-icon"],disabled:a},ue=A?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:"sm",color:ae?G.badgeInk:G.textColor,accessibilityLabel:F.loading}):c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(c,ae?de:ne,u)}):null,be=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.contentRow,children:[ae?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[W.iconLeft,W.iconBadge,{width:ce,height:ce,borderRadius:ce/2,backgroundColor:G.badgeFill}],children:ue}):ue?(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.iconLeft,children:ue}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:re,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[W.label,{color:G.textColor,fontSize:H.text,lineHeight:Math.round(H.text*R.leading.body)},m],children:r}),U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[W.linkUnderline,{backgroundColor:G.textColor,transform:[{translateX:Q.interpolate({inputRange:[0,1],outputRange:[-Z/2,0]})},{scaleX:Q.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(d,ne,u)}):null]}),ge=U?null===ee?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(ee)):touchSlopFor(H["min-height"]),pe={top:ge,bottom:ge,left:U?LINK_HIT_SLOP:0,right:U?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[D.style,l?W.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!q||w.current||z.isFlick(e))return;D.press();const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t);const r=T?.(e);return r instanceof Promise?(w.current=!0,O(!0),r.then(settlePending,e=>{throw settlePending(),e})):void 0},onPressIn:e=>{z.onPressIn(e),D.pressIn(),U&&q&&(Q.stopAnimation(),Q.setValue(0),_reactNative.Animated.timing(Q,{toValue:1,duration:R.motion.duration.slower,easing:_reactNative.Easing.bezier(...R.motion.ease.decelerate),useNativeDriver:_nativeDriver.nativeDriver}).start())},onPressOut:()=>{D.pressOut()},disabled:!q,hitSlop:pe,...(0,_hitSlop.hitSlopMarker)(pe),accessibilityRole:"button",accessibilityLabel:oe,accessibilityHint:y,accessibilityState:E,...(0,_ariaState.ariaFromState)(E),testID:j,onLayout:e=>{J.onLayout(e),U&&te(e.nativeEvent.layout.height)},style:({pressed:e})=>[W.base,{paddingHorizontal:U?0:H["padding-x"],paddingVertical:U?0:ae?le:H["padding-y"],paddingLeft:ae?le:void 0,minHeight:U?void 0:H["min-height"],borderRadius:Y,..._corners.smoothCorners,backgroundColor:K||J.active?"transparent":G.backgroundColor,borderWidth:G.borderWidth,borderColor:J.active?"transparent":G.borderColor,opacity:A?.55:1,overflow:J.active||U?"visible":"hidden"},e&&se&&!J.active?{backgroundColor:R.colors["surface-pressed"]}:null,l?W.fullWidth:null,h],...C,"aria-disabled":!q,"aria-busy":A,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[J.active&&J.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:J.size.width,height:J.size.height,radius:Y,fill:e&&se?R.colors["surface-pressed"]:G.backgroundColor,stroke:G.borderColor,strokeWidth:G.borderWidth}):null,K?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:K,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:Y,..._corners.smoothCorners}]}):null,e&&ie?J.active&&J.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:J.size.width,height:J.size.height,radius:Y,fill:G.pressedTint,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[W.pressedOverlay,{borderRadius:Y,backgroundColor:G.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,be]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};case"neutral":return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},a=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...a};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:e.size.border},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Button",{enumerable:!0,get:function(){return _Button.Button}}),Object.defineProperty(exports,"buttonLabelInk",{enumerable:!0,get:function(){return _Button.buttonLabelInk}}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return _Button.default}});var cache,_Button=_interopRequireWildcard(require("./Button.js"));function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,n,u=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((r=u&&Object.getOwnPropertyDescriptor(e,n))&&(r.get||r.set)?u(o,n,r):o[n]=e[n]);return o}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"BUTTON_TONES",{enumerable:!0,get:function(){return _Button.BUTTON_TONES}}),Object.defineProperty(exports,"BUTTON_VARIANTS",{enumerable:!0,get:function(){return _Button.BUTTON_VARIANTS}}),Object.defineProperty(exports,"Button",{enumerable:!0,get:function(){return _Button.Button}}),Object.defineProperty(exports,"buttonLabelInk",{enumerable:!0,get:function(){return _Button.buttonLabelInk}}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return _Button.default}}),Object.defineProperty(exports,"isButtonTone",{enumerable:!0,get:function(){return _Button.isButtonTone}}),Object.defineProperty(exports,"isButtonVariant",{enumerable:!0,get:function(){return _Button.isButtonVariant}});var cache,_Button=_interopRequireWildcard(require("./Button.js"));function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,n,o=Object.defineProperty,u={__proto__:null,default:e};if(Object(e)!==e)return u;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,u)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((r=o&&Object.getOwnPropertyDescriptor(e,n))&&(r.get||r.set)?o(u,n,r):u[n]=e[n]);return u}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CAROUSEL_LABELS=exports.Carousel=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CAROUSEL_LABELS=exports.DEFAULT_CAROUSEL_LABELS=Object.freeze({carousel:"Carousel",slideOf:(e,t)=>`Slide ${e} of ${t}`,goToSlide:e=>`Go to slide ${e}`});function CarouselRoot({ref:e,...t}){const{data:n,renderItem:r,keyExtractor:a,index:i,defaultIndex:s=0,onIndexChange:l,onScrollOffsetChange:c,autoPlay:o=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:_="screen",spacing:x=0,containerStyle:g,accessibilityLabel:b,testID:p,showThumbnails:y=!1,haptic:S,renderThumbnail:v,loading:f=!1,labels:j}=t;(0,_assertValidValue.assertValidValue)("Carousel","paginationStyle",t.paginationStyle,["dots","bars","numbers"]);const R=(0,_react.useMemo)(()=>({...DEFAULT_CAROUSEL_LABELS,...j}),[j]),C=(0,_index.useTheme)(),w=d||o,[T,E]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),A="screen"===_?T:_,N=A+x,k=(0,_react.useRef)(null),I=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,L=clamp("number"==typeof i?i:s,0,Math.max(0,n.length-1)),[V,O]=(0,_react.useState)(L),D=(0,_react.useRef)(null),M=(0,_react.useRef)(null),P=(0,_react.useRef)(!1),H=(0,_react.useRef)(V);H.current=V;const z=(0,_react.useCallback)(e=>{const t=clamp(e,0,Math.max(0,n.length-1));O(e=>e===t?e:(l?.(t),t))},[n.length,l]),q=(0,_react.useCallback)((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);k.current?.scrollToOffset({offset:r*N,animated:t}),z(r)},[n.length,N,z]),U=(0,_react.useCallback)(()=>{if(0===n.length)return;const e=H.current+1;e>=n.length?w&&q(0,!1):q(e,!0)},[n.length,w,q]),F=(0,_react.useCallback)(()=>{if(0===n.length)return;const e=H.current-1;e<0?w&&q(n.length-1,!1):q(e,!0)},[n.length,w,q]);(0,_react.useImperativeHandle)(e,()=>({scrollTo:q,next:U,prev:F}),[q,U,F]),(0,_react.useEffect)(()=>{"number"==typeof i&&i!==V&&q(i,!0)},[i]);const W=(0,_react.useCallback)(()=>{D.current&&(clearInterval(D.current),D.current=null)},[]),B=(0,_react.useCallback)(()=>{!o||n.length<=1||(W(),D.current=setInterval(()=>{if(P.current)return;const e=H.current+1;e>=n.length?q(0,!1):q(e,!0)},u))},[o,u,n.length,q,W]);(0,_react.useEffect)(()=>(B(),()=>{W(),M.current&&clearTimeout(M.current)}),[B,W]),(0,_react.useEffect)(()=>{const e=_reactNative.AppState.addEventListener("change",e=>{"active"!==e?(W(),M.current&&(clearTimeout(M.current),M.current=null)):B()});return()=>e.remove()},[B,W]);const $=m&&n.length>1&&"numbers"!==h||void 0!==c,G=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{x:I}}}],{useNativeDriver:!1,listener:c?e=>c(e.nativeEvent.contentOffset.x):void 0}),[I,c]),K=(0,_react.useCallback)(e=>{if(N<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/N);z(n)},[N,z]),X=(0,_react.useCallback)(()=>{P.current=!0,W(),M.current&&(clearTimeout(M.current),M.current=null)},[W]),J=(0,_react.useCallback)(()=>{P.current=!1,o&&(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{B()},1e3))},[o,B]),Q=(0,_react.useCallback)(e=>{switch(e.nativeEvent.actionName){case"increment":U();break;case"decrement":F()}},[U,F]),Y=(0,_react.useMemo)(()=>buildStyles(C),[C]),Z=(0,_react.useCallback)(({item:e,index:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:A,marginRight:t===n.length-1?0:x},accessibilityElementsHidden:t!==V,importantForAccessibility:t===V?"yes":"no-hide-descendants",children:r(e,t)}),[r,A,x,n.length,V]),ee=(0,_react.useCallback)((e,t)=>String(t),[]),te=(0,_react.useCallback)((e,t)=>({length:N,offset:N*t,index:t}),[N]);return f?(0,_jsxRuntime.jsx)(CarouselSkeleton,{...t,containerWidth:T}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Y.container,g],onLayout:e=>E(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:b??R.carousel,accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:V,text:R.slideOf(V+1,n.length)},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:p,children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:k,data:n,keyExtractor:a??ee,renderItem:Z,horizontal:!0,pagingEnabled:"screen"===_&&0===x,snapToInterval:N,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:$?G:void 0,scrollEventThrottle:$?16:void 0,onMomentumScrollEnd:K,onScrollBeginDrag:X,onScrollEndDrag:J,getItemLayout:te,initialScrollIndex:L,bounces:!1}),m&&n.length>1?(0,_jsxRuntime.jsx)(Pagination,{count:n.length,currentIndex:V,scrollX:I,slideStride:N,variant:h,theme:C,labels:R}):null,y&&n.length>0?(0,_jsxRuntime.jsx)(ThumbnailStrip,{data:n,currentIndex:V,renderThumbnail:v,labels:R,onSelect:e=>{const t=(0,_index2.resolveHaptic)(S,"selection");t&&(0,_index2.triggerHaptic)(t),q(e,!0)},theme:C}):null]})}CarouselRoot.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:a})=>{const i=(0,_index.useTheme)(),s="screen"===e?a||320:e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[carouselSkeletonStyles.container,r],children:[(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:s,height:160,radius:"md"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:i.space.md}],children:SKELETON_PAGINATION_DOTS.map(e=>"numbers"===n?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:24,height:16,radius:"sm",style:{marginHorizontal:i.space.xs}},e):"bars"===n?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:20,height:4,radius:"pill",style:{marginHorizontal:i.space.xxs}},e):(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:8,height:8,style:{marginHorizontal:i.space.xs}},e))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const SKELETON_PAGINATION_DOTS=["first","second","third"],carouselSkeletonStyles=_reactNative.StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=exports.Carousel=Object.assign(CarouselRoot,{Skeleton:CarouselSkeleton}),Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:a,theme:i,labels:s})=>{const l=(0,_react.useMemo)(()=>buildPaginationStyles(i),[i]);if("numbers"===a)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.numbersWrap,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"medium",color:"secondary",style:l.numbersText,accessibilityLabel:s.slideOf(t+1,e),children:`${t+1} / ${e}`})});const c=Array.from({length:e},(e,t)=>t),o="bars"===a,u=o?24:6,d=o?36:16,m=o?3:6;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:c.map(e=>{const a=[(e-1)*r,e*r,(e+1)*r],s=n.interpolate({inputRange:a,outputRange:[u,d,u],extrapolate:"clamp"}),l=n.interpolate({inputRange:a,outputRange:[.5,1,.5],extrapolate:"clamp"});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[{width:s,height:m,marginHorizontal:i.space.xs,borderRadius:i.radius.pill,..._corners.smoothCorners,backgroundColor:e===t?i.colors.primary:i.colors.border,opacity:l}]},e)})})};function ThumbnailStrip({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:a,labels:i}){const s=(0,_react.useMemo)(()=>buildThumbStyles(a),[a]);return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:s.row,accessibilityRole:"tablist",children:e.map((e,l)=>(0,_jsxRuntime.jsx)(ThumbnailItem,{item:e,index:l,isActive:l===t,renderThumbnail:n,onPress:()=>r(l),theme:a,styles:s,labels:i},l))})}function ThumbnailItem({item:e,index:t,isActive:n,renderThumbnail:r,onPress:a,theme:i,styles:s,labels:l}){const c=(0,_react.useRef)((0,_index.createAnimatedValue)(n?1.1:1)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(c,{toValue:n?1.1:1,useNativeDriver:_nativeDriver.nativeDriver,friction:6,tension:80});return e.start(),()=>e.stop()},[n,c]);const o=(0,_react.useMemo)(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:e.uri},style:s.image,resizeMode:"cover"}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[s.placeholder,{backgroundColor:i.colors["bg-subtle"]}],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",color:"secondary",children:t+1})}),[e,t,r,i,s]);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:a,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:l.goToSlide(t+1),children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[s.thumb,{borderColor:n?i.colors.primary:"transparent",transform:[{scale:c}]}],children:o})})}const buildThumbStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.sm,paddingVertical:e.space.sm},thumb:{width:40,height:40,marginHorizontal:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"}}),buildPaginationStyles=e=>_reactNative.StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersText:{textAlign:"center"}});var _default=exports.default=Carousel;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CAROUSEL_LABELS=exports.Carousel=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CAROUSEL_LABELS=exports.DEFAULT_CAROUSEL_LABELS=Object.freeze({carousel:"Carousel",slideOf:(e,t)=>`Slide ${e} of ${t}`,goToSlide:e=>`Go to slide ${e}`});function CarouselRoot({ref:e,...t}){const{data:n,renderItem:r,keyExtractor:a,index:i,defaultIndex:s=0,onIndexChange:l,onScrollOffsetChange:c,autoPlay:o=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:_="screen",spacing:x=0,containerStyle:b,accessibilityLabel:g,testID:p,showThumbnails:y=!1,haptic:S,renderThumbnail:v,loading:f=!1,labels:j}=t;(0,_assertValidValue.assertValidValue)("Carousel","paginationStyle",t.paginationStyle,["dots","bars","numbers"]);const R=(0,_react.useMemo)(()=>({...DEFAULT_CAROUSEL_LABELS,...j}),[j]),C=(0,_index.useTheme)(),w=d||o,[T,k]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),E="screen"===_?T:_,A=E+x,N=(0,_react.useRef)(null),I=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,L=clamp("number"==typeof i?i:s,0,Math.max(0,n.length-1)),[V,O]=(0,_react.useState)(L),D=(0,_react.useRef)(null),M=(0,_react.useRef)(null),P=(0,_react.useRef)(!1),H=(0,_react.useRef)(V);H.current=V;const z=(0,_react.useCallback)(e=>{const t=clamp(e,0,Math.max(0,n.length-1));O(e=>e===t?e:(l?.(t),t))},[n.length,l]),q=(0,_react.useCallback)((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);N.current?.scrollToOffset({offset:r*A,animated:t}),z(r)},[n.length,A,z]),U=(0,_react.useRef)(q);U.current=q;const F=(0,_react.useCallback)(()=>{if(0===n.length)return;const e=H.current+1;e>=n.length?w&&q(0,!1):q(e,!0)},[n.length,w,q]),W=(0,_react.useCallback)(()=>{if(0===n.length)return;const e=H.current-1;e<0?w&&q(n.length-1,!1):q(e,!0)},[n.length,w,q]);(0,_react.useImperativeHandle)(e,()=>({scrollTo:q,next:F,prev:W}),[q,F,W]),(0,_react.useEffect)(()=>{"number"==typeof i&&i!==H.current&&U.current(i,!0)},[i]);const $=(0,_react.useCallback)(()=>{D.current&&(clearInterval(D.current),D.current=null)},[]),B=(0,_react.useCallback)(()=>{!o||n.length<=1||($(),D.current=setInterval(()=>{if(P.current)return;const e=H.current+1;e>=n.length?q(0,!1):q(e,!0)},u))},[o,u,n.length,q,$]);(0,_react.useEffect)(()=>(B(),()=>{$(),M.current&&clearTimeout(M.current)}),[B,$]),(0,_react.useEffect)(()=>{const e=_reactNative.AppState.addEventListener("change",e=>{"active"!==e?($(),M.current&&(clearTimeout(M.current),M.current=null)):B()});return()=>e.remove()},[B,$]);const G=m&&n.length>1&&"numbers"!==h||void 0!==c,K=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{x:I}}}],{useNativeDriver:!1,listener:c?e=>c(e.nativeEvent.contentOffset.x):void 0}),[I,c]),X=(0,_react.useCallback)(e=>{if(A<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/A);z(n)},[A,z]),J=(0,_react.useCallback)(()=>{P.current=!0,$(),M.current&&(clearTimeout(M.current),M.current=null)},[$]),Q=(0,_react.useCallback)(()=>{P.current=!1,o&&(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{B()},1e3))},[o,B]),Y=(0,_react.useCallback)(e=>{switch(e.nativeEvent.actionName){case"increment":F();break;case"decrement":W()}},[F,W]),Z=(0,_react.useMemo)(()=>buildStyles(C),[C]),ee=(0,_react.useCallback)(({item:e,index:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:E,marginRight:t===n.length-1?0:x},accessibilityElementsHidden:t!==V,importantForAccessibility:t===V?"yes":"no-hide-descendants",children:r(e,t)}),[r,E,x,n.length,V]),te=(0,_react.useCallback)((e,t)=>String(t),[]),ne=(0,_react.useCallback)((e,t)=>({length:A,offset:A*t,index:t}),[A]);return f?(0,_jsxRuntime.jsx)(CarouselSkeleton,{...t,containerWidth:T}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Z.container,b],onLayout:e=>k(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:g??R.carousel,accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:V,text:R.slideOf(V+1,n.length)},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Y,testID:p,children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:N,data:n,keyExtractor:a??te,renderItem:ee,horizontal:!0,pagingEnabled:"screen"===_&&0===x,snapToInterval:A,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:G?K:void 0,scrollEventThrottle:G?16:void 0,onMomentumScrollEnd:X,onScrollBeginDrag:J,onScrollEndDrag:Q,getItemLayout:ne,initialScrollIndex:L,bounces:!1}),m&&n.length>1?(0,_jsxRuntime.jsx)(Pagination,{count:n.length,currentIndex:V,scrollX:I,slideStride:A,variant:h,theme:C,labels:R}):null,y&&n.length>0?(0,_jsxRuntime.jsx)(ThumbnailStrip,{data:n,currentIndex:V,renderThumbnail:v,labels:R,onSelect:e=>{const t=(0,_index2.resolveHaptic)(S,"selection");t&&(0,_index2.triggerHaptic)(t),q(e,!0)},theme:C}):null]})}CarouselRoot.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:a})=>{const i=(0,_index.useTheme)(),s="screen"===e?a||320:e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[carouselSkeletonStyles.container,r],children:[(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:s,height:160,radius:"md"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:i.space.md}],children:SKELETON_PAGINATION_DOTS.map(e=>"numbers"===n?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:24,height:16,radius:"sm",style:{marginHorizontal:i.space.xs}},e):"bars"===n?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:20,height:4,radius:"pill",style:{marginHorizontal:i.space.xxs}},e):(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:8,height:8,style:{marginHorizontal:i.space.xs}},e))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const SKELETON_PAGINATION_DOTS=["first","second","third"],carouselSkeletonStyles=_reactNative.StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=exports.Carousel=Object.assign(CarouselRoot,{Skeleton:CarouselSkeleton}),Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:a,theme:i,labels:s})=>{const l=(0,_react.useMemo)(()=>buildPaginationStyles(i),[i]);if("numbers"===a)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.numbersWrap,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"medium",color:"secondary",style:l.numbersText,accessibilityLabel:s.slideOf(t+1,e),children:`${t+1} / ${e}`})});const c=Array.from({length:e},(e,t)=>t),o="bars"===a,u=o?24:6,d=o?36:16,m=o?3:6;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:c.map(e=>{const a=[(e-1)*r,e*r,(e+1)*r],s=n.interpolate({inputRange:a,outputRange:[u,d,u],extrapolate:"clamp"}),l=n.interpolate({inputRange:a,outputRange:[.5,1,.5],extrapolate:"clamp"});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[{width:s,height:m,marginHorizontal:i.space.xs,borderRadius:i.radius.pill,..._corners.smoothCorners,backgroundColor:e===t?i.colors.primary:i.colors.border,opacity:l}]},e)})})};function ThumbnailStrip({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:a,labels:i}){const s=(0,_react.useMemo)(()=>buildThumbStyles(a),[a]),l=(0,_react.useMemo)(()=>e.map((e,t)=>({key:`thumb-${t}`,item:e,index:t})),[e]);return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:s.row,accessibilityRole:"tablist",children:l.map(({key:e,item:l,index:c})=>(0,_jsxRuntime.jsx)(ThumbnailItem,{item:l,index:c,isActive:c===t,renderThumbnail:n,onPress:()=>r(c),theme:a,styles:s,labels:i},e))})}function ThumbnailItem({item:e,index:t,isActive:n,renderThumbnail:r,onPress:a,theme:i,styles:s,labels:l}){const c=(0,_react.useRef)((0,_index.createAnimatedValue)(n?1.1:1)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(c,{toValue:n?1.1:1,useNativeDriver:_nativeDriver.nativeDriver,friction:6,tension:80});return e.start(),()=>e.stop()},[n,c]);const o=(0,_react.useMemo)(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:e.uri},style:s.image,resizeMode:"cover"}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[s.placeholder,{backgroundColor:i.colors["bg-subtle"]}],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",color:"secondary",children:t+1})}),[e,t,r,i,s]);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:a,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:l.goToSlide(t+1),children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[s.thumb,{borderColor:n?i.colors.primary:"transparent",transform:[{scale:c}]}],children:o})})}const buildThumbStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.sm,paddingVertical:e.space.sm},thumb:{width:40,height:40,marginHorizontal:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"}}),buildPaginationStyles=e=>_reactNative.StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersText:{textAlign:"center"}});var _default=exports.default=Carousel;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Checkbox=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,i,s=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((t=s&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?s(a,i,t):a[i]=e[i]);return a}const CHECKBOX_SHAPES=["circle"],toneColor=(e,r)=>{switch(r){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},toneOnColor=(e,r)=>{switch(r){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];case"neutral":return e.colors["on-neutral"];default:return e.colors["on-primary"]}},Checkbox=exports.Checkbox=(0,_react.forwardRef)((e,r)=>{const{checked:t,defaultChecked:i,onChange:s,indeterminate:a=!1,disabled:o=!1,label:n,helperText:l,description:c,error:d,help:u,size:h="md",tone:p="primary",shape:x,accessibilityLabel:_,haptic:b,style:f,boxStyle:m,indeterminateBarStyle:g,containerStyle:y,labelStyle:v,testID:C,hitSlop:j,...w}=e,[S,k]=(0,_index.useControllableState)({value:t,defaultValue:i??!1,onChange:s}),V=(0,_index2.useTheme)(),R=(0,_react.useMemo)(()=>buildStyles(V),[V]),{"box-size":T}=(0,_react.useMemo)(()=>(0,_index2.resolveCheckboxSize)(V,h),[V,h]),q=V.size.border,N=(0,_index2.spaceOf)(V,V.components.checkbox["label-gap"]),B=toneColor(V,p),D=j??6;(0,_assertValidValue.assertValidValue)("Checkbox","shape",x,CHECKBOX_SHAPES),(0,_assertValidValue.assertValidValue)("Checkbox","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Checkbox","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const F="circle"===x,M="string"==typeof d?d:void 0,O={description:c,helperText:l,error:M},P=S||a,H=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(H,{toValue:P?1:0,damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass,useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[P,H,V.motion.spring.snappy]);const W=H.interpolate({inputRange:[0,1],outputRange:[0,1]}),A=_??(0,_FieldBase.fieldTextAsString)(n),I=!0===d||(0,_FieldBase.hasFieldText)(d),L=P?B:o?V.colors.border:I?V.colors["field-border-error"]:V.colors.border,z=P?B:o?V.colors["surface-disabled"]:"transparent",E=o&&!P?V.colors["text-disabled"]:toneOnColor(V,p),U=Math.round(.72*T),K=Math.round(.55*T),X=Math.max(2,Math.round(.12*T)),G=(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:r,onPress:e=>{if(o)return;const r=(0,_hapticUtils.resolveHaptic)(b,"selection");r&&(0,_hapticUtils.triggerHaptic)(r),k(!S),w.onPressOut?.(e)},disabled:o,accessibilityRole:"checkbox",accessibilityLabel:A,accessibilityHint:w.accessibilityHint??(0,_FieldBase.fieldTextAsString)(l??c),accessibilityState:{checked:a?"mixed":S,disabled:o},"aria-checked":a?"mixed":S,"aria-disabled":o,testID:C,hitSlop:D,...(0,_hitSlop.hitSlopMarker)(D),...w,style:({pressed:e})=>[R.row,(0,_ChoiceText.hasChoiceDetail)(O)?R.rowTop:null,(0,_FieldBase.hasFieldText)(u)?R.rowShrink:null,{opacity:o?.55:e?.85:1},y,f],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[R.box,{width:T,height:T,borderWidth:q,borderRadius:F?T/2:V.radius.sm,...F?{}:_corners.smoothCorners,borderColor:L,backgroundColor:z},m],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[R.glyphWrap,{opacity:H,transform:[{scale:W}]}],children:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{width:K,height:X,borderRadius:V.radius.pill,..._corners.smoothCorners,backgroundColor:E},g]}):(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:U,height:U,viewBox:"0 0 24 24",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:E,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:n,helperText:l,description:c,error:M,disabled:o,style:{marginLeft:N},labelStyle:v})]});return(0,_FieldBase.hasFieldText)(u)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[R.helpRow,(0,_ChoiceText.hasChoiceDetail)(O)?R.rowTop:null],children:[G,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[R.help,{marginLeft:V.space.xs}],children:u})]}):G});Checkbox.displayName="Checkbox";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"},rowShrink:{flexShrink:1},helpRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},box:{alignItems:"center",justifyContent:"center"},glyphWrap:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Checkbox;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Checkbox=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,i,s=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((t=s&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?s(a,i,t):a[i]=e[i]);return a}const CHECKBOX_SHAPES=["circle"],toneColor=(e,r)=>{switch(r){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},toneOnColor=(e,r)=>{switch(r){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];case"neutral":return e.colors["on-neutral"];default:return e.colors["on-primary"]}},Checkbox=exports.Checkbox=(0,_react.forwardRef)((e,r)=>{const{checked:t,defaultChecked:i,onChange:s,indeterminate:a=!1,disabled:o=!1,label:n,helperText:l,description:c,error:d,help:u,size:h="md",tone:p="primary",shape:x,accessibilityLabel:_,haptic:b,style:f,boxStyle:m,indeterminateBarStyle:g,containerStyle:y,labelStyle:v,testID:C,hitSlop:j,...S}=e,[w,k]=(0,_index.useControllableState)({value:t,defaultValue:i??!1,onChange:s}),V=(0,_index2.useTheme)(),R=(0,_react.useMemo)(()=>buildStyles(V),[V]),{"box-size":T}=(0,_react.useMemo)(()=>(0,_index2.resolveCheckboxSize)(V,h),[V,h]),q=V.size.border,B=(0,_index2.spaceOf)(V,V.components.checkbox["label-gap"]),N=toneColor(V,p),F=j??6;(0,_assertValidValue.assertValidValue)("Checkbox","shape",x,CHECKBOX_SHAPES),(0,_assertValidValue.assertValidValue)("Checkbox","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Checkbox","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const D="circle"===x,M="string"==typeof d?d:void 0,O={description:c,helperText:l,error:M},P=w||a,A=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(A,{toValue:P?1:0,damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass,useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[P,A,V.motion.spring.snappy]);const H=A.interpolate({inputRange:[0,1],outputRange:[0,1]}),W=_??(0,_FieldBase.fieldTextAsString)(n),I=!0===d||(0,_FieldBase.hasFieldText)(d),L=P?N:o?V.colors.border:I?V.colors["field-border-error"]:V.colors.border,z=P?N:o?V.colors["surface-disabled"]:"transparent",E=o&&!P?V.colors["text-disabled"]:toneOnColor(V,p),U=Math.round(.72*T),K=Math.round(.55*T),X=Math.max(2,Math.round(.12*T)),G=(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:r,onPress:e=>{if(o)return;const r=(0,_hapticUtils.resolveHaptic)(b,"selection");r&&(0,_hapticUtils.triggerHaptic)(r),k(!w),S.onPressOut?.(e)},disabled:o,accessibilityRole:"checkbox",accessibilityLabel:W,accessibilityHint:S.accessibilityHint??(0,_FieldBase.fieldTextAsString)(l)??(0,_FieldBase.fieldTextAsString)(c),accessibilityState:{checked:a?"mixed":w,disabled:o},"aria-checked":a?"mixed":w,"aria-disabled":o,testID:C,hitSlop:F,...(0,_hitSlop.hitSlopMarker)(F),...S,style:({pressed:e})=>[R.row,(0,_ChoiceText.hasChoiceDetail)(O)?R.rowTop:null,(0,_FieldBase.hasFieldText)(u)?R.rowShrink:null,{opacity:o?.55:e?.85:1},y,f],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[R.box,{width:T,height:T,borderWidth:q,borderRadius:D?T/2:V.radius.sm,...D?{}:_corners.smoothCorners,borderColor:L,backgroundColor:z},m],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[R.glyphWrap,{opacity:A,transform:[{scale:H}]}],children:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{width:K,height:X,borderRadius:V.radius.pill,..._corners.smoothCorners,backgroundColor:E},g]}):(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:U,height:U,viewBox:"0 0 24 24",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:E,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:n,helperText:l,description:c,error:M,disabled:o,style:{marginLeft:B},labelStyle:v})]});return(0,_FieldBase.hasFieldText)(u)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[R.helpRow,(0,_ChoiceText.hasChoiceDetail)(O)?R.rowTop:null],children:[G,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[R.help,{marginLeft:V.space.xs}],children:u})]}):G});Checkbox.displayName="Checkbox";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"},rowShrink:{flexShrink:1},helpRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},box:{alignItems:"center",justifyContent:"center"},glyphWrap:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Checkbox;