@webority/mobile-ui 0.163.0 → 0.165.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 (162) hide show
  1. package/LICENSE.txt +1 -1
  2. package/android/src/newarch/java/com/webority/mobileui/pdfrasterizer/PdfRasterizerModule.kt +4 -4
  3. package/dist/canvas-kit/kit.js +5 -5
  4. package/dist/canvas-kit/manifest.json +11 -1
  5. package/dist/canvas-kit/release.json +6 -6
  6. package/ios/PdfRasterizer.mm +3 -3
  7. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  8. package/lib/commonjs/components/Banner/Banner.js +1 -1
  9. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  10. package/lib/commonjs/components/Card/Card.js +1 -1
  11. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  12. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
  13. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  14. package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
  15. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  16. package/lib/commonjs/components/Input/Input.js +1 -1
  17. package/lib/commonjs/components/MessageBubble/MessageBubble.js +1 -1
  18. package/lib/commonjs/components/Modal/Modal.js +1 -1
  19. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  20. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  21. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  22. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  23. package/lib/commonjs/components/Screen/Screen.js +1 -1
  24. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  25. package/lib/commonjs/components/Slider/Slider.js +1 -1
  26. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  27. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  28. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  29. package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
  30. package/lib/commonjs/theme/merge.js +1 -1
  31. package/lib/commonjs/utils/warnUnknownProps.js +1 -1
  32. package/lib/module/components/Avatar/Avatar.js +1 -1
  33. package/lib/module/components/Banner/Banner.js +1 -1
  34. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  35. package/lib/module/components/Card/Card.js +1 -1
  36. package/lib/module/components/Carousel/Carousel.js +1 -1
  37. package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
  38. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  39. package/lib/module/components/IconBadge/IconBadge.js +1 -1
  40. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  41. package/lib/module/components/Input/Input.js +1 -1
  42. package/lib/module/components/MessageBubble/MessageBubble.js +1 -1
  43. package/lib/module/components/Modal/Modal.js +1 -1
  44. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  45. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  46. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  47. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  48. package/lib/module/components/Screen/Screen.js +1 -1
  49. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  50. package/lib/module/components/Slider/Slider.js +1 -1
  51. package/lib/module/components/SliderField/SliderField.js +1 -1
  52. package/lib/module/components/TagInput/TagInput.js +1 -1
  53. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  54. package/lib/module/hooks/useDragToDismiss.js +1 -1
  55. package/lib/module/theme/merge.js +1 -1
  56. package/lib/module/utils/warnUnknownProps.js +1 -1
  57. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +1 -0
  58. package/lib/typescript/commonjs/components/Autocomplete/Autocomplete.d.ts +1 -1
  59. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +2 -1
  60. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +5 -4
  61. package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +2 -1
  62. package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +4 -4
  63. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +2 -1
  64. package/lib/typescript/commonjs/components/Descriptions/Descriptions.d.ts +2 -2
  65. package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +1 -1
  66. package/lib/typescript/commonjs/components/FieldBase/Chevron.d.ts +1 -1
  67. package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +14 -13
  68. package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +10 -10
  69. package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +2 -2
  70. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +1 -1
  71. package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +2 -2
  72. package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +2 -1
  73. package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +7 -7
  74. package/lib/typescript/commonjs/components/Input/Input.d.ts +3 -2
  75. package/lib/typescript/commonjs/components/Menu/Menu.d.ts +1 -1
  76. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +2 -1
  77. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +1 -0
  78. package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +5 -5
  79. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -0
  80. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -4
  81. package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +2 -1
  82. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +1 -1
  83. package/lib/typescript/commonjs/components/Radio/RadioDot.d.ts +2 -2
  84. package/lib/typescript/commonjs/components/Repeater/Repeater.d.ts +2 -2
  85. package/lib/typescript/commonjs/components/RichTextEditor/markdownActions.d.ts +3 -3
  86. package/lib/typescript/commonjs/components/Screen/Screen.d.ts +1 -0
  87. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +2 -1
  88. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +1 -1
  89. package/lib/typescript/commonjs/components/Select/Select.d.ts +6 -6
  90. package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +3 -3
  91. package/lib/typescript/commonjs/components/Skeleton/SkeletonClock.d.ts +3 -3
  92. package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +6 -6
  93. package/lib/typescript/commonjs/components/Skeleton/SkeletonList.d.ts +2 -2
  94. package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +5 -5
  95. package/lib/typescript/commonjs/components/Skeleton/SkeletonSkip.d.ts +2 -2
  96. package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +1 -1
  97. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +5 -0
  98. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +1 -0
  99. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +2 -2
  100. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +2 -1
  101. package/lib/typescript/commonjs/components/Timeline/Timeline.d.ts +8 -8
  102. package/lib/typescript/commonjs/components/ZoomableImage/ZoomableImage.d.ts +4 -4
  103. package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +2 -0
  104. package/lib/typescript/commonjs/specs/NativePdfRasterizer.d.ts +4 -4
  105. package/lib/typescript/commonjs/theme/animatedValue.d.ts +4 -4
  106. package/lib/typescript/commonjs/theme/types.d.ts +9 -3
  107. package/lib/typescript/commonjs/utils/feedback.d.ts +3 -3
  108. package/lib/typescript/commonjs/utils/warnUnknownProps.d.ts +2 -2
  109. package/lib/typescript/module/components/AppBar/AppBar.d.ts +1 -0
  110. package/lib/typescript/module/components/Autocomplete/Autocomplete.d.ts +1 -1
  111. package/lib/typescript/module/components/Avatar/Avatar.d.ts +2 -1
  112. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +5 -4
  113. package/lib/typescript/module/components/Carousel/Carousel.d.ts +2 -1
  114. package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +4 -4
  115. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +2 -1
  116. package/lib/typescript/module/components/Descriptions/Descriptions.d.ts +2 -2
  117. package/lib/typescript/module/components/Drawer/Drawer.d.ts +1 -1
  118. package/lib/typescript/module/components/FieldBase/Chevron.d.ts +1 -1
  119. package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +14 -13
  120. package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +10 -10
  121. package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +2 -2
  122. package/lib/typescript/module/components/FormField/FormField.d.ts +1 -1
  123. package/lib/typescript/module/components/IconButton/IconButton.d.ts +2 -2
  124. package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +2 -1
  125. package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +7 -7
  126. package/lib/typescript/module/components/Input/Input.d.ts +3 -2
  127. package/lib/typescript/module/components/Menu/Menu.d.ts +1 -1
  128. package/lib/typescript/module/components/Modal/Modal.d.ts +2 -1
  129. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +1 -0
  130. package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +5 -5
  131. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -0
  132. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -4
  133. package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +2 -1
  134. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +1 -1
  135. package/lib/typescript/module/components/Radio/RadioDot.d.ts +2 -2
  136. package/lib/typescript/module/components/Repeater/Repeater.d.ts +2 -2
  137. package/lib/typescript/module/components/RichTextEditor/markdownActions.d.ts +3 -3
  138. package/lib/typescript/module/components/Screen/Screen.d.ts +1 -0
  139. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +2 -1
  140. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +1 -1
  141. package/lib/typescript/module/components/Select/Select.d.ts +6 -6
  142. package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +3 -3
  143. package/lib/typescript/module/components/Skeleton/SkeletonClock.d.ts +3 -3
  144. package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +6 -6
  145. package/lib/typescript/module/components/Skeleton/SkeletonList.d.ts +2 -2
  146. package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +5 -5
  147. package/lib/typescript/module/components/Skeleton/SkeletonSkip.d.ts +2 -2
  148. package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +1 -1
  149. package/lib/typescript/module/components/Slider/Slider.d.ts +5 -0
  150. package/lib/typescript/module/components/SliderField/SliderField.d.ts +1 -0
  151. package/lib/typescript/module/components/Tabs/Tabs.d.ts +2 -2
  152. package/lib/typescript/module/components/TagInput/TagInput.d.ts +2 -1
  153. package/lib/typescript/module/components/Timeline/Timeline.d.ts +8 -8
  154. package/lib/typescript/module/components/ZoomableImage/ZoomableImage.d.ts +4 -4
  155. package/lib/typescript/module/hooks/useDragToDismiss.d.ts +2 -0
  156. package/lib/typescript/module/specs/NativePdfRasterizer.d.ts +4 -4
  157. package/lib/typescript/module/theme/animatedValue.d.ts +4 -4
  158. package/lib/typescript/module/theme/types.d.ts +9 -3
  159. package/lib/typescript/module/utils/feedback.d.ts +3 -3
  160. package/lib/typescript/module/utils/warnUnknownProps.d.ts +2 -2
  161. package/package.json +9 -10
  162. package/src/specs/NativePdfRasterizer.ts +4 -4
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.163.0"
5
+ "version": "0.165.0"
6
6
  },
7
7
  "rendererProtocolVersion": 14,
8
8
  "platform": "Phone",
@@ -23006,6 +23006,16 @@
23006
23006
  "version": "0.160.0",
23007
23007
  "components": [],
23008
23008
  "values": {}
23009
+ },
23010
+ {
23011
+ "version": "0.164.0",
23012
+ "components": [],
23013
+ "values": {}
23014
+ },
23015
+ {
23016
+ "version": "0.165.0",
23017
+ "components": [],
23018
+ "values": {}
23009
23019
  }
23010
23020
  ]
23011
23021
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.163.0",
3
+ "version": "0.165.0",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 14,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.163.0"
9
+ "version": "0.165.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "735bb65f892c505093a9b20866997a4e03465b4d8dc9a327015f67cb854b96db",
14
- "bytes": 668500
13
+ "sha256": "3e7c064f1c90c96126e0cecde3864c3466498ccafc6f1375ba3859cc21b74c3c",
14
+ "bytes": 668668
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "07244be32a17d6425af748cdcd18b5b08a32d2d2d824715d5497d1f86f2b09d5",
18
- "bytes": 5663355
17
+ "sha256": "c27be7df630a47fc5fd7e048213196c64aca54ceadb02b21c45e3f1e5044cdb0",
18
+ "bytes": 5664832
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -8,7 +8,7 @@ static NSString *const kCacheDirName = @"pdf-rasterizer-cache";
8
8
  // Both render sides stay within this, scaled together so the aspect ratio holds.
9
9
  static const CGFloat kMaxRenderDimensionPx = 4096;
10
10
 
11
- // Wraps a CGPDFDocumentRef so ARC can own its lifetime inside an NSMutableDictionary —
11
+ // Wraps a CGPDFDocumentRef so ARC can own its lifetime inside an NSMutableDictionary.
12
12
  // CGPDFDocumentRef is a plain CF type with no toll-free-bridged Foundation counterpart.
13
13
  @interface PdfRasterizerDocumentBox : NSObject
14
14
  @property (nonatomic, assign, readonly) CGPDFDocumentRef document;
@@ -126,7 +126,7 @@ static CGAffineTransform PdfRasterizerFillTransform(CGPDFPageRef page, CGSize ta
126
126
  }
127
127
 
128
128
  if (CGPDFDocumentIsEncrypted(document)) {
129
- // Only ever try the empty password — a real password prompt is a UI
129
+ // Only ever try the empty password. A real password prompt is a UI
130
130
  // concern the caller owns, not this module's job to solve.
131
131
  CGPDFDocumentUnlockWithPassword(document, "");
132
132
  if (!CGPDFDocumentIsUnlocked(document)) {
@@ -302,7 +302,7 @@ static CGAffineTransform PdfRasterizerFillTransform(CGPDFPageRef page, CGSize ta
302
302
  [self.documents removeObjectForKey:handle];
303
303
 
304
304
  NSString *cacheDir = [self cacheDirectoryForHandle:handle];
305
- // Best-effort cleanup — a stale cache dir on delete failure is not worth
305
+ // Best-effort cleanup: a stale cache dir on delete failure is not worth
306
306
  // failing an otherwise-successful close over.
307
307
  [[NSFileManager defaultManager] removeItemAtPath:cacheDir error:nil];
308
308
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",rejected:"rejected",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,o)=>{switch(t){case"circle":return r/2;case"rounded":return o?e.radius[o]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,o]=t;return void 0===r?"":void 0===o?r.charAt(0).toUpperCase():(r.charAt(0)+o.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const o=t[Math.abs(r)%t.length];if(void 0===o)throw new Error("The avatar colour palette is empty.");return o},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isImageSourceList=e=>Array.isArray(e),toExpoSource=e=>({...void 0!==e.uri?{uri:e.uri}:{},...void 0!==e.headers?{headers:e.headers}:{},...void 0!==e.width?{width:e.width}:{},...void 0!==e.height?{height:e.height}:{}}),toExpoSources=e=>"number"==typeof e?e:isImageSourceList(e)?e.map(toExpoSource):toExpoSource(e),isRingStatus=e=>"verified"===e||"pending"===e||"rejected"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":case"rejected":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},AvatarRoot=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:o,imageClient:s,name:a,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:h,status:m=null,statusPosition:p="bottomRight",tone:g,backgroundColor:v,color:_,fontSize:b,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:j,style:V,textStyle:S,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending","rejected"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[w,M]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(a),[a]),D=(0,_react.useMemo)(()=>g?avatarToneColors(L,g):null,[L,g]),q=(0,_react.useMemo)(()=>v||(D?.background??L.colors[hashColor(a??"",AVATAR_COLORS)]),[v,D,a,L]),G=_??D?.color??L.colors["on-primary"],U=r?keyOfSource(r):null,P=(0,_react.useMemo)(()=>void 0!==r?toExpoSources(r):void 0,[r]),$=null!==U&&U!==w,B=!$&&""===F&&null!=h,W=_??D?.color??L.colors["text-subtle"],H=b??Math.max(L.text.xs.size,Math.round(.4*E)),Y=Math.max(8,Math.round(.25*E)),X=isRingStatus(m),J=E-2*(X?3:k),K=X?resolveRadius(L,n,J,c):Math.max(0,O-k),Q=B?(0,_slotIcon.renderSlotIcon)(h,{color:W,size:Math.round(.45*J),disabled:!1}):null,Z=X?statusColor(L,m):"transparent",ee=Math.max(12,Math.round(.32*E)),te=Math.max(10,ee-4),re=v??D?.background??L.colors["bg-muted"],oe=$?"contain"===d?"transparent":L.colors["bg-muted"]:B?re:q,se=C??"avatar",ae=a?T.avatarOf(a):T.avatar,ie="verified"===m?`, ${T.verified}`:"pending"===m?`, ${T.pendingVerification}`:"rejected"===m?`, ${T.rejected}`:"",ne=A??`${ae}${ie}`,le="function"==typeof y||"function"==typeof f,ce=A??`${a||ae}${ie}`,ue=Math.max(0,Math.ceil((44-E)/2)),de=j??ue,he=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:X?0:k,borderColor:N,backgroundColor:X?"transparent":oe},V],me=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[X?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Z}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:J,height:J,borderRadius:K,..._corners.smoothCorners,borderWidth:X?k:0,borderColor:N,backgroundColor:X?oe:"transparent"}],children:$?(()=>{const e={width:J,height:J,borderRadius:K,..._corners.smoothCorners};if(!r)return null;const onError=()=>M(U),t=uriOfSource(r);return o?(0,_jsxRuntime.jsx)(o,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):s&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:s,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{...void 0!==P?{source:P}:{},onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():Q||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:G,fontSize:H,lineHeight:Math.round(H*L.leading.body)},S],children:F??" "})}),"verified"===m||"rejected"===m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===p?styles.badgeTopRight:styles.badgeBottomRight,{width:ee,height:ee,borderRadius:ee/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verified"===m?"verify":"close-circle",variant:"bold",size:te,color:Z})}):null,m&&!X?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===p?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,..._corners.smoothCorners,backgroundColor:statusColor(L,m),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),pe=le?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:ce,testID:C,style:({pressed:e})=>[he,e?styles.pressed:null],children:me}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:he,accessible:!0,accessibilityRole:"image",accessibilityLabel:ne,testID:C,children:me});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):pe}),AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e),a="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:a,width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton";const Avatar=exports.Avatar=Object.assign(AvatarRoot,{Skeleton:AvatarSkeleton});Avatar.displayName="Avatar";const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:o,children:s})=>{const a=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:_nativeDriver.nativeDriver});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:a.radius.pill,borderColor:r,borderWidth:o,opacity:i}],children:s})},AvatarGroup=e=>{const{children:t,max:r=4,size:o="md",spacing:s="normal",overflowVariant:a="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),m=h.length,p=h.slice(0,r),g=Math.max(0,m-r),v=g>0,_=-d.space[SPACING_OFFSET[s]],b=d.colors.surface,x=i??u.groupOf(m),A=(0,_react.useMemo)(()=>resolveSize(o),[o]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[p.map((e,t)=>{const r=e.key??`avatar-${t}`,s=(0,_react.cloneElement)(e,{size:o,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:_,borderColor:b,borderWidth:1.5,children:s},r)}),v?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*p.length,marginLeft:0===p.length?0:_,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(g):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===a?`+${g}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",rejected:"rejected",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,o)=>{switch(t){case"circle":return r/2;case"rounded":return o?e.radius[o]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,o]=t;return void 0===r?"":void 0===o?r.charAt(0).toUpperCase():(r.charAt(0)+o.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const o=t[Math.abs(r)%t.length];if(void 0===o)throw new Error("The avatar colour palette is empty.");return o},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isImageSourceList=e=>Array.isArray(e),toExpoSource=e=>({...void 0!==e.uri?{uri:e.uri}:{},...void 0!==e.headers?{headers:e.headers}:{},...void 0!==e.width?{width:e.width}:{},...void 0!==e.height?{height:e.height}:{}}),toExpoSources=e=>"number"==typeof e?e:isImageSourceList(e)?e.map(toExpoSource):toExpoSource(e),isRingStatus=e=>"verified"===e||"pending"===e||"rejected"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":case"rejected":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},AvatarRoot=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:o,imageClient:s,name:a,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:h,status:m=null,statusPosition:g="bottomRight",tone:p,backgroundColor:v,color:_,fontSize:b,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:j,style:V,textStyle:S,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending","rejected"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[w,M]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(a),[a]),D=(0,_react.useMemo)(()=>p?avatarToneColors(L,p):null,[L,p]),q=(0,_react.useMemo)(()=>v||(D?.background??L.colors[hashColor(a??"",AVATAR_COLORS)]),[v,D,a,L]),G=_??D?.color??L.colors["on-primary"],U=r?keyOfSource(r):null,$=(0,_react.useMemo)(()=>void 0!==r?toExpoSources(r):void 0,[r]),P=null!==U&&U!==w,B=!P&&""===F&&null!=h,W=_??D?.color??L.colors["text-subtle"],H=b??Math.max(L.text.xs.size,Math.round(.4*E)),Y=Math.max(8,Math.round(.25*E)),X=isRingStatus(m),J=E-2*(X?3:k),K=X?resolveRadius(L,n,J,c):Math.max(0,O-k),Q=B?(0,_slotIcon.renderSlotIcon)(h,{color:W,size:Math.round(.45*J),disabled:!1}):null,Z=X?statusColor(L,m):"transparent",ee=Math.max(12,Math.round(.32*E)),te=Math.max(10,ee-4),re=v??D?.background??L.colors["bg-muted"],oe=P?"contain"===d?"transparent":L.colors["bg-muted"]:B?re:q,se=C??"avatar",ae=a?T.avatarOf(a):T.avatar,ie="verified"===m?`, ${T.verified}`:"pending"===m?`, ${T.pendingVerification}`:"rejected"===m?`, ${T.rejected}`:"",ne=A??`${ae}${ie}`,le="function"==typeof y||"function"==typeof f,ce=A??`${a||ae}${ie}`,ue=Math.max(0,Math.ceil((44-E)/2)),de=j??ue,he=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:X?0:k,borderColor:N,backgroundColor:X?"transparent":oe},V],me=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[X?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Z}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:J,height:J,borderRadius:K,..._corners.smoothCorners,borderWidth:X?k:0,borderColor:N,backgroundColor:X?oe:"transparent"}],children:P?(()=>{const e={width:J,height:J,borderRadius:K,..._corners.smoothCorners};if(!r)return null;const onError=()=>M(U),t=uriOfSource(r);return o?(0,_jsxRuntime.jsx)(o,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):s&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:s,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{...void 0!==$?{source:$}:{},onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0,testID:C?`${C}-image`:void 0})})():Q||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:G,fontSize:H,lineHeight:Math.round(H*L.leading.body)},S],children:F??" "})}),"verified"===m||"rejected"===m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:ee,height:ee,borderRadius:ee/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verified"===m?"verify":"close-circle",variant:"bold",size:te,color:Z})}):null,m&&!X?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,..._corners.smoothCorners,backgroundColor:statusColor(L,m),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),ge=le?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:ce,testID:C,style:({pressed:e})=>[he,e?styles.pressed:null],children:me}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:he,accessible:!0,accessibilityRole:"image",accessibilityLabel:ne,testID:C,children:me});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):ge}),AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e),a="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:a,width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton";const Avatar=exports.Avatar=Object.assign(AvatarRoot,{Skeleton:AvatarSkeleton});Avatar.displayName="Avatar";const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:o,children:s})=>{const a=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:_nativeDriver.nativeDriver});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:a.radius.pill,borderColor:r,borderWidth:o,opacity:i}],children:s})},AvatarGroup=e=>{const{children:t,max:r=4,size:o="md",spacing:s="normal",overflowVariant:a="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),m=h.length,g=h.slice(0,r),p=Math.max(0,m-r),v=p>0,_=-d.space[SPACING_OFFSET[s]],b=d.colors.surface,x=i??u.groupOf(m),A=(0,_react.useMemo)(()=>resolveSize(o),[o]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,s=(0,_react.cloneElement)(e,{size:o,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:_,borderColor:b,borderWidth:1.5,children:s},r)}),v?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:_,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(p):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===a?`+${p}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
@@ -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: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
+ "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??" ":"",P="wash"===s,Y="bar"!==s,H="alert"===p,U=H?"danger"===n?"assertive":"polite":"none",F=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,..."web"===_reactNative.Platform.OS&&H&&"danger"!==n?{role:"status"}:null,accessibilityLiveRegion:U,accessibilityLabel:_,testID:R,style:[B.container,{backgroundColor:Y?S.soft:w.colors["bg-subtle"],borderRadius:P?w.radius.sm:w.radius.md,..._corners.smoothCorners,padding:w.space.md,opacity:L,transform:[{translateY:A}]},y,g],children:[!P&&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:P?{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}):F}),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.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"),_reactNativeWorklets=require("react-native-worklets"),_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,o=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=o&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?o(s,r,a):s[r]=e[r]);return s}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:o,onSnapChange:s,onAnimate:n,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:b,scrollEventThrottle:S,keyboardBehavior:p="shift",inline:x=!1,presentation:R="sheet",animateMount:y=!0,handleIndicatorStyle:N,containerStyle:g,header:M,actions:j,actionsLayout:w="auto",footer:C,headerStyle:k,footerStyle:O,children:E,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!=C||D,P=x?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[W,F]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[U,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),Y=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&F(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),K=(0,_reactNative.useWindowDimensions)(),$="dialog"===R||"auto"===R&&Math.min(K.width,K.height)>=600,X=Math.min(560,U-2*H.space.xl),[J,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===P?J.top:q.top,ee="modal"===P?J.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[oe,se]=useMeasuredHeight(),[ne,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=$?H.space.md:ae,he=te?Math.min(de+(I?oe:0)+ne+(L?le:0)+ee,W-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,W,he),[t,W,he]),fe=W,be=ve[ve.length-1]??0,Se=(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),[we,Ce]=(0,_react.useState)(!1),ke=(0,_react.useRef)(!1),Oe=(0,_react.useRef)(i);Oe.current=i;const[Ee,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?we:Ee;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 $?(W-t)/2:W-t},[ve,W,fe,$]),We=(0,_react.useCallback)(e=>{Be.current=e;ye!==e&&(Ne(e),Re.value=e,e>=0&&s?.(e))},[ye,Re,s]),Fe=(0,_react.useCallback)(()=>{ge.current=!1,Re.value<0&&(ke.current=!0,"modal"===P?(je(!1),"ios"!==_reactNative.Platform.OS&&Ce(!1)):Te(!1))},[P,Re]),Ue=(0,_react.useCallback)(()=>{ke.current&&Ce(!1)},[]);(0,_react.useEffect)(()=>{("modal"===P?!we:!Ee)&&ke.current&&(ke.current=!1,Oe.current?.(),Ge(!0))},[P,we,Ee,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,n?.(t,a),Se.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Fe)})},[n,Se,Fe]),Ye=(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 ke.current=!1,Ge(!1),"modal"===P?(Ce(!0),je(!0)):Te(!0),a<0&&Ae.current?(Se.value=r,xe.value=1,We(t),void n?.(a,t)):a<0&&G.reduced?(Se.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}),We(t),void n?.(a,t)):(a<0&&(Se.value=fe,xe.value=1),We(t),void ze(r,a,t))},[ze,fe,ye,Re,P,n,G,xe,ve.length,We,Ge,H.motion.ease.decelerate,Se,qe]),Ke=(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;We(-1),ge.current=!0,n?.(t,-1);const a=G.reduced?xe:Se,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,_reactNativeWorklets.scheduleOnRN)(Fe)})}),[fe,Re,Fe,n,G,xe,We,Se,H.motion.ease.accelerate]),$e=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Le.current)return void t?.();const o=r();"boolean"!=typeof o?(Le.current=!0,a?.(),o.then(a=>{Le.current=!1,a&&Pe.current&&Be.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(o?e:t)?.()},[]),Xe=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):$e(()=>{De.current(),Ke(),e(!0)},()=>e(!1))}),[Ke,$e]),Je=(0,_react.useCallback)(()=>{De.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&Xe()},[l,Xe]),Ze=(0,_react.useRef)(null),et=(0,_react.useRef)(Ye);et.current=Ye;const tt=(0,_react.useRef)(Ke);tt.current=Ke,(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?et.current(o??0):tt.current():a&&"number"==typeof o&&o!==Re.value&&et.current(o)},[a,o,Re]);const at=(0,_react.useRef)({hostHeight:W,contentSnap:he}),rt=(0,_react.useRef)(qe);rt.current=qe,(0,_react.useEffect)(()=>{const e=at.current;if(e.hostHeight===W&&e.contentSnap===he)return;if(at.current={hostHeight:W,contentSnap:he},e.hostHeight===W&&Re.value<0)return;const t=rt.current(Re.value);Se.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[W,he,Re,Se]);const ot=W-be,st=(0,_react.useMemo)(()=>ve.map(e=>W-e),[ve,W]),nt=(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?(We(e),ze(t,a,e)):$e(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),De.current(),Ke()},nt,nt)},[ze,Ke,Re,$e,We,nt]),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=st,t=fe,a=ot,r=c;return{testID:B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";pe.value=Se.value},onUpdate:e=>{"worklet";const t=pe.value+e.translationY;Se.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const o=Se.value,s=a.velocityY,[n]=e;if(void 0===n)return void(0,_reactNativeWorklets.scheduleOnRN)(it,-1,t);if(s>1e3)return r?void(0,_reactNativeWorklets.scheduleOnRN)(it,-1,t):void(0,_reactNativeWorklets.scheduleOnRN)(it,0,n);let i=0,c=n,l=1/0,u=0;for(const t of e){const e=Math.abs(o-t);e<l&&(l=e,c=t,i=u),u++}r&&o-n>80?(0,_reactNativeWorklets.scheduleOnRN)(it,-1,t):(0,_reactNativeWorklets.scheduleOnRN)(it,i,c)}}},[fe,pe,c,it,ot,st,B,Se]),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)]??be,ft=H.space.md,bt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if($){const e=mt.value,t=W+e-vt-ft,a=e<0&&Se.value>t?t:Se.value;return{top:Math.max(a,Z),opacity:xe.value}}const e=Se.value+mt.value,t=mt.value<0?Z:ot;return{top:Math.max(e,t),opacity:xe.value}},[$,mt,W,vt,ft,Se,Z,xe,ot]),St=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=mt.value;if($){const t=W+e-vt-ft,a=e<0&&Se.value>t?t:Se.value,r=Math.max(a,Z),o=W+e-ft-r;return{height:o<0?0:Math.min(o,vt)}}const t=e<0?Z:ot,a=Se.value+e,r=Math.max(a,t),o=W+e-r;return{height:o<0?0:Math.min(o,be)}},[mt,$,W,vt,ft,Se,Z,ot,be]),pt=ye>=0,xt=(0,_react.useMemo)(()=>buildStyles(H),[H]),Rt=(0,_react.useCallback)(()=>{l&&$e(()=>{(0,_index2.triggerHaptic)("selection"),De.current(),Ke()})},[l,Ke,$e]),yt=(0,_react.useMemo)(()=>({testID:B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeWorklets.scheduleOnRN)(Rt)}}),[Rt,B]),Nt=(0,_reactNativeGestureHandler.useTapGesture)(yt),gt=(0,_react.useMemo)(()=>({snapIndex:ye,snapPoints:ve,close:Je,requestClose:Xe}),[ye,ve,Je,Xe]);if("inline"===P&&!Ee)return null;if("modal"===P&&!we)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:Y,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:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},$?{height:vt,left:(U-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,bt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[xt.body,St],keyboardOffset:mt,children:[$?(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,k],onLayout:te?se: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:b,scrollEventThrottle:S,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:E})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[xt.content,{overflow:"visible"}]:xt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:E}):E}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[xt.footer,O],onLayout:te?ue:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:xt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:w})}):null,C]})]})})]}),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?Ue: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,o=(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,o],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"),_reactNativeWorklets=require("react-native-worklets"),_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,o=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=o&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?o(s,r,a):s[r]=e[r]);return s}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:o,onSnapChange:s,onAnimate:n,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:b,scrollEventThrottle:S,keyboardBehavior:p="shift",inline:x=!1,presentation:R="sheet",animateMount:y=!0,handleIndicatorStyle:N,containerStyle:g,header:M,actions:j,actionsLayout:w="auto",footer:C,headerStyle:k,footerStyle:O,children:E,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!=C||D,P=x?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[W,F]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[U,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),Y=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&F(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),$=(0,_reactNative.useWindowDimensions)(),K="dialog"===R||"auto"===R&&Math.min($.width,$.height)>=600,X=Math.min(560,U-2*H.space.xl),[J,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===P?J.top:q.top,ee="modal"===P?J.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[oe,se]=useMeasuredHeight(),[ne,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?oe:0)+ne+(L?le:0)+ee,W-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,W,he),[t,W,he]),fe=W,be=ve[ve.length-1]??0,Se=(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),[we,Ce]=(0,_react.useState)(!1),ke=(0,_react.useRef)(!1),Oe=(0,_react.useRef)(i);Oe.current=i;const[Ee,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?we:Ee;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?(W-t)/2:W-t},[ve,W,fe,K]),We=(0,_react.useCallback)(e=>{Be.current=e;ye!==e&&(Ne(e),Re.value=e,e>=0&&s?.(e))},[ye,Re,s]),Fe=(0,_react.useCallback)(()=>{ge.current=!1,Re.value<0&&(ke.current=!0,"modal"===P?(je(!1),"ios"!==_reactNative.Platform.OS&&Ce(!1)):Te(!1))},[P,Re]),Ue=(0,_react.useCallback)(()=>{ke.current&&Ce(!1)},[]);(0,_react.useEffect)(()=>{("modal"===P?!we:!Ee)&&ke.current&&(ke.current=!1,Oe.current?.(),Ge(!0))},[P,we,Ee,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,n?.(t,a),Se.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Fe)})},[n,Se,Fe]),Ye=(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 ke.current=!1,Ge(!1),"modal"===P?(Ce(!0),je(!0)):Te(!0),a<0&&Ae.current?(Se.value=r,xe.value=1,We(t),void n?.(a,t)):a<0&&G.reduced?(Se.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}),We(t),void n?.(a,t)):(a<0&&(Se.value=fe,xe.value=1),We(t),void ze(r,a,t))},[ze,fe,ye,Re,P,n,G,xe,ve.length,We,Ge,H.motion.ease.decelerate,Se,qe]),$e=(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;We(-1),ge.current=!0,n?.(t,-1);const a=G.reduced?xe:Se,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,_reactNativeWorklets.scheduleOnRN)(Fe)})}),[fe,Re,Fe,n,G,xe,We,Se,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 o=r();"boolean"!=typeof o?(Le.current=!0,a?.(),o.then(a=>{Le.current=!1,a&&Pe.current&&Be.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(o?e:t)?.()},[]),Xe=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{De.current(),$e(),e(!0)},()=>e(!1))}),[$e,Ke]),Je=(0,_react.useCallback)(()=>{De.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&Xe()},[l,Xe]),Ze=(0,_react.useRef)(null),et=(0,_react.useRef)(Ye);et.current=Ye;const tt=(0,_react.useRef)($e);tt.current=$e,(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?et.current(o??0):tt.current():a&&"number"==typeof o&&o!==Re.value&&et.current(o)},[a,o,Re]);const at=(0,_react.useRef)({hostHeight:W,contentSnap:he}),rt=(0,_react.useRef)(qe);rt.current=qe,(0,_react.useEffect)(()=>{const e=at.current;if(e.hostHeight===W&&e.contentSnap===he)return;if(at.current={hostHeight:W,contentSnap:he},e.hostHeight===W&&Re.value<0)return;const t=rt.current(Re.value);Se.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[W,he,Re,Se]);const ot=W-be,st=(0,_react.useMemo)(()=>ve.map(e=>W-e),[ve,W]),nt=(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?(We(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),De.current(),$e()},nt,nt)},[ze,$e,Re,Ke,We,nt]),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=st,t=fe,a=ot,r=c;return{testID:B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";pe.value=Se.value},onUpdate:e=>{"worklet";const t=pe.value+e.translationY;Se.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const o=Se.value,s=a.velocityY,[n]=e;if(void 0===n)return void(0,_reactNativeWorklets.scheduleOnRN)(it,-1,t);if(s>1e3)return r?void(0,_reactNativeWorklets.scheduleOnRN)(it,-1,t):void(0,_reactNativeWorklets.scheduleOnRN)(it,0,n);let i=0,c=n,l=1/0,u=0;for(const t of e){const e=Math.abs(o-t);e<l&&(l=e,c=t,i=u),u++}r&&o-n>80?(0,_reactNativeWorklets.scheduleOnRN)(it,-1,t):(0,_reactNativeWorklets.scheduleOnRN)(it,i,c)}}},[fe,pe,c,it,ot,st,B,Se]),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)]??be,ft=H.space.md,bt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=mt.value,t=W+e-vt-ft,a=e<0&&Se.value>t?t:Se.value;return{top:Math.max(a,Z),opacity:xe.value}}const e=Se.value+mt.value,t=mt.value<0?Z:ot;return{top:Math.max(e,t),opacity:xe.value}},[K,mt,W,vt,ft,Se,Z,xe,ot]),St=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=mt.value;if(K){const t=W+e-vt-ft,a=e<0&&Se.value>t?t:Se.value,r=Math.max(a,Z),o=W+e-ft-r;return{height:o<0?0:Math.min(o,vt)}}const t=e<0?Z:ot,a=Se.value+e,r=Math.max(a,t),o=W+e-r;return{height:o<0?0:Math.min(o,be)}},[mt,K,W,vt,ft,Se,Z,ot,be]),pt=ye>=0,xt=(0,_react.useMemo)(()=>buildStyles(H),[H]),Rt=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),De.current(),$e()})},[l,$e,Ke]),yt=(0,_react.useMemo)(()=>({testID:B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeWorklets.scheduleOnRN)(Rt)}}),[Rt,B]),Nt=(0,_reactNativeGestureHandler.useTapGesture)(yt),gt=(0,_react.useMemo)(()=>({snapIndex:ye,snapPoints:ve,close:Je,requestClose:Xe}),[ye,ve,Je,Xe]);if("inline"===P&&!Ee)return null;if("modal"===P&&!we)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:Y,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:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:vt,left:(U-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,bt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[xt.body,St],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,k],onLayout:te?se: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,testID:B?`${B}-scroll`:void 0,style:xt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:b,scrollEventThrottle:S,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:E})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[xt.content,{overflow:"visible"}]:xt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:E}):E}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[xt.footer,O],onLayout:te?ue:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:xt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:w})}):null,C]})]})})]}),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?Ue: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,o=(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,o],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=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_guards=require("../../utils/guards.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,a=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=a&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?a(r,s,i):r[s]=e[s]);return r}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s,elevation:a="card",radius:r,padding:n,interactive:o=!1,pressAnimation:l="scale",bg:d,header:c,title:u,titleFont:h,lead:m,action:_,headerActions:x,collapsible:p=!1,collapsed:g,defaultCollapsed:b=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:v,separatorHeight:R=_reactNative.StyleSheet.hairlineWidth,footer:f,imageSource:S,imageHeight:C=160,imageAspectRatio:w,imageOverlay:A,loading:V=!1,gradient:q,onPress:F,haptic:N,contextMenu:L,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,style:P,containerStyle:I,headerStyle:D,bodyStyle:H,footerStyle:M,testID:O,labels:z,onLayout:E,...W}=e;(0,_assertValidValue.assertValidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_assertValidValue.assertValidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_assertValidValue.assertValidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_assertValidValue.assertValidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=(0,_index.useTheme)(),G=U.settings.components.card,K=s??G?.defaultVariant??"elevated",$=r??G?.defaultRadius??"lg",J=n??G?.defaultPadding??"md",Q=h??G?.defaultTitleFont??"sans",X=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...z}),[z]),Y=o||"function"==typeof F,Z=(0,_useContextMenu.useContextMenu)(L,{haptic:N||!1,testID:O,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),ee=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:ae}=(0,_usePressAnimation.usePressAnimation)({preset:l||"scale",enabled:te&&!1!==l}),re=stylesFor(U),ne=Boolean(S),oe=U.space[paddingMap[J]],le=(0,_react.useMemo)(()=>q?"string"==typeof q?U.settings.gradients[q]??null:q:null,[q,U.settings.gradients]),de="flat"===K,ce=de?U.radius.none:U.radius[$],ue=resolveBackground(U,d),[he,me]=(0,_useControllableState.useControllableState)({value:g,defaultValue:b,onChange:j}),xe=p&&he,pe=hasBuiltInHeaderContent(e),ge=Boolean(c)||pe,be=(0,_SquircleFill.useSquircle)(!ne&&!le&&!de,ce,E),je=_reactNative.StyleSheet.flatten([I,P])??{},ye="string"==typeof je.backgroundColor?je.backgroundColor:void 0,ve="string"==typeof je.borderColor?je.borderColor:void 0,Re=ye??ue??("filled"===K?U.colors["bg-subtle"]:U.colors.surface),fe="outline"===K?U.size.border:0,Se=ve??U.colors.border,Ce="none"===a?void 0:U.shadow[a],we="elevated"===K&&(0,_shadows.supportsBoxShadow)()&&Ce?(0,_shadows.toBoxShadow)(Ce):void 0,Ae=be.active&&"elevated"===K&&!we,Ve=be.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,qe=(0,_react.useMemo)(()=>{const e={borderRadius:Ae&&be.size?(0,_squircle.squircleHostRadius)(be.size.width,be.size.height,ce):ce,..._corners.smoothCorners,padding:ne||be.active?U.space.none:oe,overflow:be.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:R,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:be.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:be.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:be.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...we?{boxShadow:we}:Ce}}},[U,K,Ce,ce,ne,oe,be.active,be.size,we,Ae,ue,R]),Fe=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:C},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ce,w,C]),Ne=u??"",Le=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,Q),children:u}):null,m?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:re.lead,children:m}):null,xe&&y?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:re.lead,children:y}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:N}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:re.actionNode,children:_}):null,x,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:xe?"chevron-down":"chevron-up",label:`${xe?X.show:X.hide} ${Ne}`.trim(),expanded:!xe,onPress:()=>me(!xe),haptic:N}):null,v?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:U.colors["danger-text"],haptic:N}):null]}),ke=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ge?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.header,!c&&re.headerRow,xe&&re.headerFolded,D],children:c??Le}):null,xe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ge||f?re.body:null,H],children:i}),f&&!xe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.footer,M],children:f}):null]}),Te=S?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Fe,accessibilityLabel:"",accessible:!1}),A?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:oe},children:ke})]}):ke,Be=le?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:le,style:_reactNative.StyleSheet.absoluteFill}),Te]}):be.active&&be.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:be.size.width,height:be.size.height,radius:ce,fill:Re,stroke:fe?Se:void 0,strokeWidth:fe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.squircleClip,{padding:oe,borderRadius:be.size?(0,_squircle.squircleHostRadius)(be.size.width,be.size.height,ce):ce}],children:Te})]}):Te;let Pe;if(te){const handlePress=e=>{Y&&(N&&(0,_hapticUtils.triggerHaptic)(N),F?.(e))};Pe=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ie,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:ae,accessibilityRole:B??(Y?"button":void 0),accessibilityLabel:k,accessibilityHint:T,testID:O,onLayout:be.onLayout,style:[qe,I,P,Ve],...W,...Z.hostProps,children:Be})})}else Pe=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,testID:O,onLayout:be.onLayout,style:[qe,I,P,Ve],...W,children:Be});return V?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):Z.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Pe,Z.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[qe,I,P,Ve,re.preview],children:Be}))]}):Pe})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:a,header:r,footer:n,imageSource:o,imageHeight:l=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:h,footerStyle:m,style:_,labels:x,...p})=>{const g=(0,_index.useTheme)(),b=g.settings.components.card,j=e??b?.defaultVariant??"elevated",y=i??b?.defaultRadius??"lg",v=s??b?.defaultPadding??"md",R={...DEFAULT_CARD_LABELS,...x},f=paddingMap[v],S=g.space[f],C="flat"===j?g.radius.none:g.radius[y],w=void 0!==r||hasBuiltInHeaderContent(p),A=resolveBackground(g,a)??g.colors.surface,V="outline"===j?1:0,q="outline"===j?g.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:A,borderRadius:C,..._corners.smoothCorners,borderWidth:V,borderColor:q,overflow:"hidden"},c,_],accessibilityRole:"progressbar",accessibilityLabel:R.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==o?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,w?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingBottom:g.space.sm},u],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S},h],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:g.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingTop:g.space.sm,flexDirection:"row"},m],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=exports.Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:a,haptic:r})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:a??n.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return(0,_guards.isOneOf)(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_guards=require("../../utils/guards.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,a=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=a&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?a(r,s,i):r[s]=e[s]);return r}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s,elevation:a="card",radius:r,padding:n,interactive:o=!1,pressAnimation:l="scale",bg:d,header:c,title:u,titleFont:h,lead:m,action:_,headerActions:x,collapsible:p=!1,collapsed:g,defaultCollapsed:b=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:v,separatorHeight:R=_reactNative.StyleSheet.hairlineWidth,footer:f,imageSource:S,imageHeight:C=160,imageAspectRatio:w,imageOverlay:A,loading:V=!1,gradient:q,onPress:F,haptic:N,contextMenu:L,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,style:P,containerStyle:I,headerStyle:D,bodyStyle:H,footerStyle:M,testID:O,labels:z,onLayout:E,...W}=e;(0,_assertValidValue.assertValidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_assertValidValue.assertValidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_assertValidValue.assertValidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_assertValidValue.assertValidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=(0,_index.useTheme)(),G=U.settings.components.card,K=s??G?.defaultVariant??"elevated",$=r??G?.defaultRadius??"lg",J=n??G?.defaultPadding??"md",Q=h??G?.defaultTitleFont??"sans",X=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...z}),[z]),Y=o||"function"==typeof F,Z=(0,_useContextMenu.useContextMenu)(L,{haptic:N||!1,testID:O,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),ee=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:ae}=(0,_usePressAnimation.usePressAnimation)({preset:l||"scale",enabled:te&&!1!==l}),re=stylesFor(U),ne=Boolean(S),oe=U.space[paddingMap[J]],le=(0,_react.useMemo)(()=>q?"string"==typeof q?U.settings.gradients[q]??null:q:null,[q,U.settings.gradients]),de="flat"===K,ce=de?U.radius.none:U.radius[$],ue=resolveBackground(U,d),[he,me]=(0,_useControllableState.useControllableState)({value:g,defaultValue:b,onChange:j}),xe=p&&he,pe=hasBuiltInHeaderContent(e),ge=Boolean(c)||pe,be=(0,_SquircleFill.useSquircle)(!ne&&!le&&!de,ce,E),je=_reactNative.StyleSheet.flatten([I,P])??{},ye="string"==typeof je.backgroundColor?je.backgroundColor:void 0,ve="string"==typeof je.borderColor?je.borderColor:void 0,Re=ye??ue??("filled"===K?U.colors["bg-subtle"]:U.colors.surface),fe="outline"===K?U.size.border:0,Se=ve??U.colors.border,Ce="none"===a?void 0:U.shadow[a],we="elevated"===K&&(0,_shadows.supportsBoxShadow)()&&Ce?(0,_shadows.toBoxShadow)(Ce):void 0,Ae=be.active&&"elevated"===K&&!we,Ve=be.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,qe=(0,_react.useMemo)(()=>{const e={borderRadius:Ae&&be.size?(0,_squircle.squircleHostRadius)(be.size.width,be.size.height,ce):ce,..._corners.smoothCorners,padding:ne||be.active?U.space.none:oe,overflow:be.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:R,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:be.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:be.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:be.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...we?{boxShadow:we}:Ce}}},[U,K,Ce,ce,ne,oe,be.active,be.size,we,Ae,ue,R]),Fe=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:C},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ce,w,C]),Ne=u??"",Le=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,Q),children:u}):null,m?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:re.lead,children:m}):null,xe&&y?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:re.lead,children:y}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:N}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:re.actionNode,children:_}):null,x,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:xe?"chevron-down":"chevron-up",label:`${xe?X.show:X.hide} ${Ne}`.trim(),expanded:!xe,onPress:()=>me(!xe),haptic:N}):null,v?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:U.colors["danger-text"],haptic:N}):null]}),ke=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ge?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.header,!c&&re.headerRow,xe&&re.headerFolded,D],children:c??Le}):null,xe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ge||f?re.body:null,H],children:i}),f&&!xe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.footer,M],children:f}):null]}),Te=S?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Fe,accessibilityLabel:"",accessible:!1}),A?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:oe},children:ke})]}):ke,Be=le?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:le,style:_reactNative.StyleSheet.absoluteFill}),Te]}):be.active&&be.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:be.size.width,height:be.size.height,radius:ce,fill:Re,stroke:fe?Se:void 0,strokeWidth:fe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.squircleClip,{padding:oe,borderRadius:be.size?(0,_squircle.squircleHostRadius)(be.size.width,be.size.height,ce):ce}],children:Te})]}):Te;let Pe;if(te){const handlePress=e=>{Y&&(N&&(0,_hapticUtils.triggerHaptic)(N),F?.(e))};Pe=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ie,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:ae,accessibilityRole:B??(Y?"button":void 0),accessibilityLabel:k,accessibilityHint:T,testID:O,onLayout:be.onLayout,style:[qe,I,P,Ve],...W,...Z.hostProps,children:Be})})}else Pe=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,testID:O,onLayout:be.onLayout,style:[qe,I,P,Ve],...W,children:Be});return V?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):Z.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Pe,Z.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[qe,I,P,Ve,re.preview],children:Be}))]}):Pe})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:a,header:r,footer:n,imageSource:o,imageHeight:l=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:h,footerStyle:m,style:_,labels:x,...p})=>{const g=(0,_index.useTheme)(),b=g.settings.components.card,j=e??b?.defaultVariant??"elevated",y=i??b?.defaultRadius??"lg",v=s??b?.defaultPadding??"md",R={...DEFAULT_CARD_LABELS,...x},f=paddingMap[v],S=g.space[f],C="flat"===j?g.radius.none:g.radius[y],w=void 0!==r||hasBuiltInHeaderContent(p),A=resolveBackground(g,a)??g.colors.surface,V="outline"===j?1:0,q="outline"===j?g.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:A,borderRadius:C,..._corners.smoothCorners,borderWidth:V,borderColor:q,overflow:"hidden"},c,_],accessibilityRole:"progressbar",accessibilityLabel:R.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==o?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,w?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingBottom:g.space.sm},u],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S},h],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:g.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingTop:g.space.sm,flexDirection:"row"},m],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=exports.Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:a,haptic:r})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:a??n.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return(0,_guards.isOneOf)(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{overflow:"hidden",..._corners.smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CAROUSEL_LABELS=exports.Carousel=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_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
+ "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:v,renderThumbnail:S,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,D]=(0,_react.useState)(L),O=(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));D(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)(()=>{O.current&&(clearInterval(O.current),O.current=null)},[]),B=(0,_react.useCallback)(()=>{!o||n.length<=1||($(),O.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,testID:p?`${p}-list`:void 0,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:S,labels:R,onSelect:e=>{const t=(0,_index2.resolveHaptic)(v,"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.DateRangePicker=exports.DEFAULT_DATE_RANGE_PICKER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Calendar/index.js"),_calendarDates=require("../Calendar/calendarDates.js"),_index4=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index5=require("../PickerTrigger/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_DATE_RANGE_PICKER_LABELS=exports.DEFAULT_DATE_RANGE_PICKER_LABELS=Object.freeze({title:"Select Date Range",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss"}),formatRangePart=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short"}).format(e),DateRangePicker=exports.DateRangePicker=(0,_react.forwardRef)((e,t)=>{const{open:a,value:r,onChange:s,onClose:i,label:n,help:o,placeholder:l,helperText:c,error:d,required:u,disabled:_,size:m,variant:x,clearable:g,onClear:h,leftIcon:b,trailing:f,triggerStyle:y,valueStyle:p,labelStyle:R,messageStyle:D,accessibilityLabel:j,triggerLabels:v,formatValue:S,minDate:C,maxDate:w,disabledDates:T,marks:A,locale:P="en-IN",weekStartsOn:k=0,title:E,labels:L,maxRange:M,haptic:N,style:B,containerStyle:I,headerLabelStyle:q,navButtonStyle:z,footerButtonStyle:O,testID:H}=e,V={label:n,help:o,placeholder:l,helperText:c,error:d,required:u,disabled:_,size:m,variant:x,clearable:g,onClear:h,leftIcon:b,trailing:f,triggerStyle:y,valueStyle:p,labelStyle:R,messageStyle:D,accessibilityLabel:j},G=void 0!==a,[$,F]=(0,_react.useState)(!1),W=void 0!==a?a:$,K=G?H:H?`${H}-calendar`:void 0,U=(0,_index.useTheme)(),[Y,J]=(0,_ModalSafeArea.useModalInsets)(),Q=(0,_react.useMemo)(()=>buildStyles(U),[U]),X=(0,_react.useMemo)(()=>({...DEFAULT_DATE_RANGE_PICKER_LABELS,...L}),[L]),[Z,ee]=(0,_react.useState)(()=>(0,_calendarDates.startOfMonth)(r.start??new Date)),[te,ae]=(0,_react.useState)(r.start?(0,_calendarDates.startOfDay)(r.start):null),[re,se]=(0,_react.useState)(r.end?(0,_calendarDates.startOfDay)(r.end):null),ie=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,ne=(0,_react.useRef)(0);(0,_react.useEffect)(()=>{if(r.start){const e=(0,_calendarDates.startOfDay)(r.start);ae(e),ee((0,_calendarDates.startOfMonth)(e))}else ae(null);r.end?se((0,_calendarDates.startOfDay)(r.end)):se(null)},[r.start,r.end]);const oe=(0,_react.useCallback)(e=>{if(e.end&&M&&(0,_calendarDates.daysBetween)(e.start,e.end)+1>M)return!1!==N&&(0,_index2.triggerHaptic)("notificationWarning"),ae(e.end),void se(null);ae(e.start),se(e.end??null)},[M,N]),le=(0,_react.useCallback)(()=>{G?i?.():F(!1)},[G,i]),{handleGesture:ce,opacity:de}=(0,_useDragToDismiss.useDragToDismiss)({drag:ie,travel:()=>ne.current||320,onDismiss:le});(0,_react.useEffect)(()=>{W&&((0,_index.setNativeValue)(ie,0),(0,_index.setNativeValue)(de,1))},[W,ie,de]);const ue=(0,_react.useCallback)(()=>{!1!==N&&(0,_index2.triggerHaptic)("selection"),le()},[le,N]),me=(0,_react.useCallback)(()=>{te&&re&&(!1!==N&&(0,_index2.triggerHaptic)("notificationSuccess"),s?.({start:te,end:re}),le())},[le,s,te,re,N]),xe=(0,_react.useMemo)(()=>te&&re?`${formatRangePart(te,P)} — ${formatRangePart(re,P)}`:te?`${formatRangePart(te,P)} — …`:"—",[te,re,P]),ge=!te||!re,he=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Q.card,I,B],ref:t,accessible:!1,testID:K,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ce,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.grabArea,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:Q.handle}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.titleRow,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"title",style:Q.title,accessibilityRole:"header",children:E??X.title}),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",style:Q.subtitle,accessibilityLiveRegion:"polite",children:xe})]})]})}),(0,_jsxRuntime.jsx)(_index3.Calendar,{selectionMode:"range",value:te?{start:te,end:re??void 0}:null,onChange:oe,month:Z,onMonthChange:ee,minDate:C,maxDate:w,disabledDates:T,marks:A,weekStartsOn:k,locale:P,haptic:N,headerLabelStyle:q,navButtonStyle:z,testID:K?`${K}-grid`:void 0}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.footer,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ue,style:({pressed:e})=>[Q.footerBtn,Q.footerCancel,e&&Q.footerBtnPressed,O],accessibilityRole:"button",accessibilityLabel:X.cancel,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["text-muted"]}],children:X.cancel})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:me,disabled:ge,style:({pressed:e})=>[Q.footerBtn,Q.footerConfirm,{backgroundColor:U.colors.primary,opacity:ge?.5:1},e&&{backgroundColor:U.colors["primary-hover"]},O],accessibilityRole:"button",accessibilityLabel:X.confirm,accessibilityState:{disabled:ge},"aria-disabled":ge,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["on-primary"]}],children:X.confirm})})]})]}),be=(0,_react.useMemo)(()=>{if(!r.start||!r.end)return"";const e={start:r.start,end:r.end};return S?S(e):`${e.start.toLocaleDateString()} – ${e.end.toLocaleDateString()}`},[r.start,r.end,S]);return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G?null:(0,_jsxRuntime.jsx)(_index5.PickerTrigger,{...V,labels:v,value:be,onPress:()=>F(!0),testID:H}),(0,_jsxRuntime.jsx)(_index4.Modal,{open:W,onClose:le,presentation:"bottom",bare:!0,haptic:!1,labels:{close:X.dismiss},onInsetsChange:J,children:(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:Q.gestureRoot,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Q.sheetWrap,{paddingBottom:Math.max(Y.bottom,U.space.lg),opacity:de,transform:[{translateY:ie}]}],onLayout:e=>{ne.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:he})})})]})});DateRangePicker.displayName="DateRangePicker";const buildStyles=e=>{const t=e.shadow.popover;return _reactNative.StyleSheet.create({gestureRoot:{width:"100%"},sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,..._corners.smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},subtitle:{marginTop:e.space.xxs,fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),color:e.colors["text-muted"]},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,..._corners.smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};var _default=exports.default=DateRangePicker;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DateRangePicker=exports.DEFAULT_DATE_RANGE_PICKER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Calendar/index.js"),_calendarDates=require("../Calendar/calendarDates.js"),_index4=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index5=require("../PickerTrigger/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_DATE_RANGE_PICKER_LABELS=exports.DEFAULT_DATE_RANGE_PICKER_LABELS=Object.freeze({title:"Select Date Range",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss"}),formatRangePart=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short"}).format(e),DateRangePicker=exports.DateRangePicker=(0,_react.forwardRef)((e,t)=>{const{open:a,value:r,onChange:s,onClose:i,label:n,help:o,placeholder:l,helperText:c,error:d,required:u,disabled:_,size:m,variant:x,clearable:g,onClear:h,leftIcon:b,trailing:f,triggerStyle:y,valueStyle:p,labelStyle:R,messageStyle:D,accessibilityLabel:j,triggerLabels:v,formatValue:S,minDate:C,maxDate:w,disabledDates:T,marks:A,locale:P="en-IN",weekStartsOn:k=0,title:E,labels:L,maxRange:M,haptic:N,style:B,containerStyle:I,headerLabelStyle:q,navButtonStyle:z,footerButtonStyle:O,testID:H}=e,V={label:n,help:o,placeholder:l,helperText:c,error:d,required:u,disabled:_,size:m,variant:x,clearable:g,onClear:h,leftIcon:b,trailing:f,triggerStyle:y,valueStyle:p,labelStyle:R,messageStyle:D,accessibilityLabel:j},G=void 0!==a,[$,F]=(0,_react.useState)(!1),W=void 0!==a?a:$,K=G?H:H?`${H}-calendar`:void 0,U=(0,_index.useTheme)(),[Y,J]=(0,_ModalSafeArea.useModalInsets)(),Q=(0,_react.useMemo)(()=>buildStyles(U),[U]),X=(0,_react.useMemo)(()=>({...DEFAULT_DATE_RANGE_PICKER_LABELS,...L}),[L]),[Z,ee]=(0,_react.useState)(()=>(0,_calendarDates.startOfMonth)(r.start??new Date)),[te,ae]=(0,_react.useState)(r.start?(0,_calendarDates.startOfDay)(r.start):null),[re,se]=(0,_react.useState)(r.end?(0,_calendarDates.startOfDay)(r.end):null),ie=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,ne=(0,_react.useRef)(0);(0,_react.useEffect)(()=>{if(r.start){const e=(0,_calendarDates.startOfDay)(r.start);ae(e),ee((0,_calendarDates.startOfMonth)(e))}else ae(null);r.end?se((0,_calendarDates.startOfDay)(r.end)):se(null)},[r.start,r.end]);const oe=(0,_react.useCallback)(e=>{if(e.end&&M&&(0,_calendarDates.daysBetween)(e.start,e.end)+1>M)return!1!==N&&(0,_index2.triggerHaptic)("notificationWarning"),ae(e.end),void se(null);ae(e.start),se(e.end??null)},[M,N]),le=(0,_react.useCallback)(()=>{G?i?.():F(!1)},[G,i]),{handleGesture:ce,opacity:de}=(0,_useDragToDismiss.useDragToDismiss)({drag:ie,travel:()=>ne.current||320,onDismiss:le,testID:H});(0,_react.useEffect)(()=>{W&&((0,_index.setNativeValue)(ie,0),(0,_index.setNativeValue)(de,1))},[W,ie,de]);const ue=(0,_react.useCallback)(()=>{!1!==N&&(0,_index2.triggerHaptic)("selection"),le()},[le,N]),me=(0,_react.useCallback)(()=>{te&&re&&(!1!==N&&(0,_index2.triggerHaptic)("notificationSuccess"),s?.({start:te,end:re}),le())},[le,s,te,re,N]),xe=(0,_react.useMemo)(()=>te&&re?`${formatRangePart(te,P)} — ${formatRangePart(re,P)}`:te?`${formatRangePart(te,P)} — …`:"—",[te,re,P]),ge=!te||!re,he=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Q.card,I,B],ref:t,accessible:!1,testID:K,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ce,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.grabArea,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:Q.handle}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.titleRow,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"title",style:Q.title,accessibilityRole:"header",children:E??X.title}),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",style:Q.subtitle,accessibilityLiveRegion:"polite",children:xe})]})]})}),(0,_jsxRuntime.jsx)(_index3.Calendar,{selectionMode:"range",value:te?{start:te,end:re??void 0}:null,onChange:oe,month:Z,onMonthChange:ee,minDate:C,maxDate:w,disabledDates:T,marks:A,weekStartsOn:k,locale:P,haptic:N,headerLabelStyle:q,navButtonStyle:z,testID:K?`${K}-grid`:void 0}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.footer,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ue,style:({pressed:e})=>[Q.footerBtn,Q.footerCancel,e&&Q.footerBtnPressed,O],accessibilityRole:"button",accessibilityLabel:X.cancel,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["text-muted"]}],children:X.cancel})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:me,disabled:ge,style:({pressed:e})=>[Q.footerBtn,Q.footerConfirm,{backgroundColor:U.colors.primary,opacity:ge?.5:1},e&&{backgroundColor:U.colors["primary-hover"]},O],accessibilityRole:"button",accessibilityLabel:X.confirm,accessibilityState:{disabled:ge},"aria-disabled":ge,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["on-primary"]}],children:X.confirm})})]})]}),be=(0,_react.useMemo)(()=>{if(!r.start||!r.end)return"";const e={start:r.start,end:r.end};return S?S(e):`${e.start.toLocaleDateString()} – ${e.end.toLocaleDateString()}`},[r.start,r.end,S]);return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G?null:(0,_jsxRuntime.jsx)(_index5.PickerTrigger,{...V,labels:v,value:be,onPress:()=>F(!0),testID:H}),(0,_jsxRuntime.jsx)(_index4.Modal,{open:W,onClose:le,presentation:"bottom",bare:!0,haptic:!1,labels:{close:X.dismiss},onInsetsChange:J,children:(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:Q.gestureRoot,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Q.sheetWrap,{paddingBottom:Math.max(Y.bottom,U.space.lg),opacity:de,transform:[{translateY:ie}]}],onLayout:e=>{ne.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:he})})})]})});DateRangePicker.displayName="DateRangePicker";const buildStyles=e=>{const t=e.shadow.popover;return _reactNative.StyleSheet.create({gestureRoot:{width:"100%"},sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,..._corners.smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},subtitle:{marginTop:e.space.xxs,fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),color:e.colors["text-muted"]},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,..._corners.smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};var _default=exports.default=DateRangePicker;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveVariantColors=exports.resolveFieldTextStyle=exports.pickRepresentativeBorderColor=exports.hasFieldText=exports.fieldTextAsString=exports.default=exports.RequiredPlaceholder=exports.RequiredMark=exports.FieldMessage=exports.FieldLabel=exports.FieldErrorGlyph=exports.FieldBase=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFieldErrorScroll=require("../../hooks/useFieldErrorScroll.js"),_index=require("../../theme/index.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0},pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const r=e[t];if(r&&"transparent"!==r)return r}return e.bottom};exports.pickRepresentativeBorderColor=pickRepresentativeBorderColor;const resolveFieldTextStyle=(e,t={})=>{const{disabled:r=!1}=t;return{color:r?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:r?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:(0,_index.fontFor)(e,"normal")}};exports.resolveFieldTextStyle=resolveFieldTextStyle;const RequiredMark=()=>{const e=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:e.colors["danger-text"]},children:` ${e.settings.components.field?.requiredMarker??"*"}`})};exports.RequiredMark=RequiredMark;const RequiredPlaceholder=({text:e,color:t,fontSize:r,weightStyle:i,align:o="center",paddingTop:l,textAlign:s})=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{justifyContent:"top"===o?"flex-start":"center",paddingTop:l}],children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:r,...i,includeFontPadding:!1,textAlign:s},children:[e,(0,_jsxRuntime.jsx)(RequiredMark,{})]})});exports.RequiredPlaceholder=RequiredPlaceholder;const FieldErrorGlyph=({size:e,color:t})=>{const r=(0,_index.useTheme)().settings.icons.error??_defaultIcons.defaultIcons.error;return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r({size:e,color:t})})};exports.FieldErrorGlyph=FieldErrorGlyph;const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;exports.hasFieldText=hasFieldText;const fieldTextAsString=e=>"string"==typeof e?e:void 0;exports.fieldTextAsString=fieldTextAsString;const FieldLabel=({children:e,size:t="md",required:r=!1,help:i,color:o,style:l})=>{const s=(0,_index.useTheme)(),a=(0,_index.resolveFieldSize)(s,t),n=hasFieldText(i),d=(0,_textInk.useTextInk)(l,a["label-text"],o??s.colors["field-label"]),c=(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[familyStyles.label,{color:o??s.colors["field-label"],fontSize:a["label-text"],...(0,_index.fontFor)(s,"semibold"),marginBottom:n?s.space.none:a["label-gap"]},n?familyStyles.labelShrink:null,l],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:d,children:e}),r?(0,_jsxRuntime.jsx)(RequiredMark,{}):null]});return n?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.labelRow,{marginBottom:a["label-gap"]}],children:[c,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:i})]}):c};exports.FieldLabel=FieldLabel;const FieldMessage=({text:e,error:t=!1,size:r="md",style:i})=>{const o=(0,_index.useTheme)(),l=(0,_index.resolveFieldSize)(o,r),s=t?o.colors["field-message"]:o.colors["text-muted"],a=(0,_textInk.useTextInk)(i,l["message-text"],s);return hasFieldText(e)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:o.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?(0,_jsxRuntime.jsx)(FieldErrorGlyph,{size:l["message-text"],color:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...(0,_index.fontFor)(o,"normal")},i],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:a,children:e})})]}):null};exports.FieldMessage=FieldMessage;const familyStyles=_reactNative.StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}}),resolveVariantColors=(e,t)=>{let r,i,o,l,s;"outline"===t?(r=e.colors["field-bg"],i=e.colors["field-bg-focus"],o=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(r="transparent",i=void 0,o="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(r=e.colors["field-bg"],i=void 0,o=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},a=expandColorSides(l),n=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:r,backgroundIdleFilled:r,backgroundFocused:i,backgroundError:void 0,backgroundDisabled:o,borderIdle:a,borderFocused:n,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(n)}};exports.resolveVariantColors=resolveVariantColors;const FieldBase=e=>{(0,_assertValidValue.assertValidValue)("FieldBase","variant",e.variant,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:r,focused:i=!1,disabled:o=!1,error:l=!1,filled:s=!1,leading:a,leadingDivider:n=!1,trailing:d,slotAlign:c="center",slotLineHeight:u,topNotch:b,children:x,onPress:p,pressFeedback:m=!0,minHeight:g,maxHeight:h,width:f,height:_,paddingHorizontal:y,paddingLeft:v,paddingRight:R,paddingVertical:j,radius:S,borderTopLeftRadius:F,borderTopRightRadius:k,borderBottomLeftRadius:T,borderBottomRightRadius:C,borderWidth:V,borderTopWidth:I,borderRightWidth:q,borderBottomWidth:w,borderLeftWidth:B,gap:L,flushBottom:N=!1,style:z,testID:E,accessibilityRole:D,accessibilityLabel:M,accessibilityState:W,accessibilityHint:P}=e,A=(0,_index.useTheme)(),H=(0,_useFieldErrorScroll.useFieldErrorAnchor)(l),G=(0,_react.useMemo)(()=>buildStyles(),[]),O=r??A.settings.components.field?.defaultVariant??"outline",$=(0,_index.resolveFieldSize)(A,t),J=(0,_react.useMemo)(()=>resolveVariantColors(A,O),[A,O]),K=l?2:i?1:0,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(K)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Q,{toValue:K,duration:A.motion.duration.fast,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[K,Q,A.motion.duration.fast,A.motion.ease["in-out"]]);const U=[0,1,2],X=s?J.backgroundIdleFilled:J.backgroundIdleEmpty,Y=J.backgroundFocused??X,Z=J.backgroundError??X,ee=o?J.backgroundDisabled:Q.interpolate({inputRange:U,outputRange:[X,Y,Z]}),te=J.borderIdle,re=J.borderFocused,ie=J.borderError,oe={top:I,right:q,bottom:w,left:B},le={top:oe.top??V??J.borderWidth.top,right:oe.right??V??J.borderWidth.right,bottom:oe.bottom??V??J.borderWidth.bottom,left:oe.left??V??J.borderWidth.left},se="underline"===O,ae=se?A.radius.none:S?A.radius[S]:$.radius,ne=se?{tl:A.radius.none,tr:A.radius.none,bl:A.radius.none,br:A.radius.none}:{tl:F??ae,tr:k??ae,bl:T??ae,br:C??ae},sideColor=e=>Q.interpolate({inputRange:U,outputRange:[te[e],re[e],ie[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,de=!se&&ne.tl===ne.tr&&ne.tl===ne.bl&&ne.tl===ne.br&&sameOnEverySide(le)&&sameOnEverySide(te)&&sameOnEverySide(re)&&sameOnEverySide(ie)&&sameOnEverySide(J.borderDisabled),ce=(0,_SquircleFill.useSquircle)(de,ne.tl),ue=ce.active?{borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent",borderLeftColor:"transparent"}:o?{borderTopColor:J.borderDisabled.top,borderRightColor:J.borderDisabled.right,borderBottomColor:J.borderDisabled.bottom,borderLeftColor:J.borderDisabled.left}:{borderTopColor:sideColor("top"),borderRightColor:sideColor("right"),borderBottomColor:sideColor("bottom"),borderLeftColor:sideColor("left")},be=o?J.borderDisabled.top:sideColor("top"),xe={minHeight:_??g??$["min-height"],maxHeight:h,paddingHorizontal:y??$["padding-x"],paddingVertical:j??$["padding-y"],paddingLeft:v??y??$["padding-x"],paddingRight:R??y??$["padding-x"],backgroundColor:ce.active?"transparent":ee,columnGap:L??A.space.md,alignItems:"top"===c?"flex-start":"center",borderTopLeftRadius:ne.tl,borderTopRightRadius:ne.tr,borderBottomLeftRadius:ne.bl,borderBottomRightRadius:ne.br,borderCurve:_corners.smoothCorners.borderCurve,borderTopWidth:le.top,borderRightWidth:le.right,borderBottomWidth:le.bottom,borderLeftWidth:le.left,...ue,...void 0!==f?{width:f}:null,...void 0!==_?{height:_}:null},pe=(0,_react.useRef)(K);pe.current=K,(0,_react.useEffect)(()=>{Q.setValue(pe.current)},[J,Q]);const me=N?{marginBottom:A.space.none}:void 0,ge={disabled:o,...W},he="top"===c,fe=he?{alignSelf:"flex-start",marginTop:Math.max(0,((u??$.icon)-$.icon)/2)}:null,ye=_??g??$["min-height"],ve=(()=>{if(!b)return 0;const e=Math.min(ne.tl,ye/2),t=b.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),Re=b&&le.top>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-le.top,left:b.left-le.left,width:b.width,height:le.top+ve,backgroundColor:ee}}):null,renderInner=e=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ce.active&&ce.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ce.size.width,height:ce.size.height,radius:ne.tl,fill:e&&!o?A.colors["surface-pressed"]:ee,stroke:be,strokeWidth:le.top}):null,Re,null!=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:a}):null,null!=a&&n?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[G.divider,fe,{height:$.icon,backgroundColor:A.colors["field-border"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.content,he?G.contentTop:null],children:x}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:d}):null]}),je=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,xe,p?null:me,z],accessibilityRole:D,accessibilityLabel:M,accessibilityHint:P,accessibilityState:ge,...(0,_ariaState.ariaFromState)(ge),testID:E,children:renderInner(!1)});return p&&!m?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,accessible:!1,style:me,children:je}):p?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,style:me,accessibilityRole:D??"button",accessibilityLabel:M,accessibilityHint:P,accessibilityState:ge,...(0,_ariaState.ariaFromState)(ge),testID:E,children:({pressed:e})=>(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,xe,!e||o||ce.active?null:{backgroundColor:A.colors["surface-pressed"]},z],children:renderInner(e)})}):je};exports.FieldBase=FieldBase,FieldBase.displayName="FieldBase";const buildStyles=()=>_reactNative.StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});var _default=exports.default=FieldBase;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveVariantColors=exports.resolveFieldTextStyle=exports.pickRepresentativeBorderColor=exports.hasFieldText=exports.fieldTextAsString=exports.default=exports.RequiredPlaceholder=exports.RequiredMark=exports.FieldMessage=exports.FieldLabel=exports.FieldErrorGlyph=exports.FieldBase=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFieldErrorScroll=require("../../hooks/useFieldErrorScroll.js"),_index=require("../../theme/index.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0},pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const r=e[t];if(r&&"transparent"!==r)return r}return e.bottom};exports.pickRepresentativeBorderColor=pickRepresentativeBorderColor;const resolveFieldTextStyle=(e,t={})=>{const{disabled:r=!1}=t;return{color:r?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:r?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:(0,_index.fontFor)(e,"normal")}};exports.resolveFieldTextStyle=resolveFieldTextStyle;const RequiredMark=()=>{const e=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:e.colors["danger-text"]},..."web"===_reactNative.Platform.OS?{"aria-hidden":!0}:null,children:` ${e.settings.components.field?.requiredMarker??"*"}`})};exports.RequiredMark=RequiredMark;const RequiredPlaceholder=({text:e,color:t,fontSize:r,weightStyle:i,align:o="center",paddingTop:l,textAlign:s})=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{justifyContent:"top"===o?"flex-start":"center",paddingTop:l}],children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:r,...i,includeFontPadding:!1,textAlign:s},children:[e,(0,_jsxRuntime.jsx)(RequiredMark,{})]})});exports.RequiredPlaceholder=RequiredPlaceholder;const FieldErrorGlyph=({size:e,color:t})=>{const r=(0,_index.useTheme)().settings.icons.error??_defaultIcons.defaultIcons.error;return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r({size:e,color:t})})};exports.FieldErrorGlyph=FieldErrorGlyph;const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;exports.hasFieldText=hasFieldText;const fieldTextAsString=e=>"string"==typeof e?e:void 0;exports.fieldTextAsString=fieldTextAsString;const FieldLabel=({children:e,size:t="md",required:r=!1,help:i,color:o,style:l})=>{const s=(0,_index.useTheme)(),a=(0,_index.resolveFieldSize)(s,t),n=hasFieldText(i),d=(0,_textInk.useTextInk)(l,a["label-text"],o??s.colors["field-label"]),c=(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[familyStyles.label,{color:o??s.colors["field-label"],fontSize:a["label-text"],...(0,_index.fontFor)(s,"semibold"),marginBottom:n?s.space.none:a["label-gap"]},n?familyStyles.labelShrink:null,l],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:d,children:e}),r?(0,_jsxRuntime.jsx)(RequiredMark,{}):null]});return n?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.labelRow,{marginBottom:a["label-gap"]}],children:[c,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:i})]}):c};exports.FieldLabel=FieldLabel;const FieldMessage=({text:e,error:t=!1,size:r="md",style:i})=>{const o=(0,_index.useTheme)(),l=(0,_index.resolveFieldSize)(o,r),s=t?o.colors["field-message"]:o.colors["text-muted"],a=(0,_textInk.useTextInk)(i,l["message-text"],s);return hasFieldText(e)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:o.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?(0,_jsxRuntime.jsx)(FieldErrorGlyph,{size:l["message-text"],color:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...(0,_index.fontFor)(o,"normal")},i],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:a,children:e})})]}):null};exports.FieldMessage=FieldMessage;const familyStyles=_reactNative.StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}}),resolveVariantColors=(e,t)=>{let r,i,o,l,s;"outline"===t?(r=e.colors["field-bg"],i=e.colors["field-bg-focus"],o=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(r="transparent",i=void 0,o="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(r=e.colors["field-bg"],i=void 0,o=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},a=expandColorSides(l),n=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:r,backgroundIdleFilled:r,backgroundFocused:i,backgroundError:void 0,backgroundDisabled:o,borderIdle:a,borderFocused:n,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(n)}};exports.resolveVariantColors=resolveVariantColors;const FieldBase=e=>{(0,_assertValidValue.assertValidValue)("FieldBase","variant",e.variant,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:r,focused:i=!1,disabled:o=!1,error:l=!1,filled:s=!1,leading:a,leadingDivider:n=!1,trailing:d,slotAlign:c="center",slotLineHeight:u,topNotch:b,children:x,onPress:p,pressFeedback:m=!0,minHeight:g,maxHeight:h,width:f,height:_,paddingHorizontal:v,paddingLeft:y,paddingRight:R,paddingVertical:j,radius:S,borderTopLeftRadius:F,borderTopRightRadius:k,borderBottomLeftRadius:T,borderBottomRightRadius:C,borderWidth:V,borderTopWidth:I,borderRightWidth:q,borderBottomWidth:w,borderLeftWidth:B,gap:N,flushBottom:L=!1,style:z,testID:E,accessibilityRole:D,accessibilityLabel:M,accessibilityState:W,accessibilityHint:P}=e,A=(0,_index.useTheme)(),H=(0,_useFieldErrorScroll.useFieldErrorAnchor)(l),G=(0,_react.useMemo)(()=>buildStyles(),[]),O=r??A.settings.components.field?.defaultVariant??"outline",$=(0,_index.resolveFieldSize)(A,t),J=(0,_react.useMemo)(()=>resolveVariantColors(A,O),[A,O]),K=l?2:i?1:0,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(K)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Q,{toValue:K,duration:A.motion.duration.fast,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[K,Q,A.motion.duration.fast,A.motion.ease["in-out"]]);const U=[0,1,2],X=s?J.backgroundIdleFilled:J.backgroundIdleEmpty,Y=J.backgroundFocused??X,Z=J.backgroundError??X,ee=o?J.backgroundDisabled:Q.interpolate({inputRange:U,outputRange:[X,Y,Z]}),te=J.borderIdle,re=J.borderFocused,ie=J.borderError,oe={top:I,right:q,bottom:w,left:B},le={top:oe.top??V??J.borderWidth.top,right:oe.right??V??J.borderWidth.right,bottom:oe.bottom??V??J.borderWidth.bottom,left:oe.left??V??J.borderWidth.left},se="underline"===O,ae=se?A.radius.none:S?A.radius[S]:$.radius,ne=se?{tl:A.radius.none,tr:A.radius.none,bl:A.radius.none,br:A.radius.none}:{tl:F??ae,tr:k??ae,bl:T??ae,br:C??ae},sideColor=e=>Q.interpolate({inputRange:U,outputRange:[te[e],re[e],ie[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,de=!se&&ne.tl===ne.tr&&ne.tl===ne.bl&&ne.tl===ne.br&&sameOnEverySide(le)&&sameOnEverySide(te)&&sameOnEverySide(re)&&sameOnEverySide(ie)&&sameOnEverySide(J.borderDisabled),ce=(0,_SquircleFill.useSquircle)(de,ne.tl),ue=ce.active?{borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent",borderLeftColor:"transparent"}:o?{borderTopColor:J.borderDisabled.top,borderRightColor:J.borderDisabled.right,borderBottomColor:J.borderDisabled.bottom,borderLeftColor:J.borderDisabled.left}:{borderTopColor:sideColor("top"),borderRightColor:sideColor("right"),borderBottomColor:sideColor("bottom"),borderLeftColor:sideColor("left")},be=o?J.borderDisabled.top:sideColor("top"),xe={minHeight:_??g??$["min-height"],maxHeight:h,paddingHorizontal:v??$["padding-x"],paddingVertical:j??$["padding-y"],paddingLeft:y??v??$["padding-x"],paddingRight:R??v??$["padding-x"],backgroundColor:ce.active?"transparent":ee,columnGap:N??A.space.md,alignItems:"top"===c?"flex-start":"center",borderTopLeftRadius:ne.tl,borderTopRightRadius:ne.tr,borderBottomLeftRadius:ne.bl,borderBottomRightRadius:ne.br,borderCurve:_corners.smoothCorners.borderCurve,borderTopWidth:le.top,borderRightWidth:le.right,borderBottomWidth:le.bottom,borderLeftWidth:le.left,...ue,...void 0!==f?{width:f}:null,...void 0!==_?{height:_}:null},pe=(0,_react.useRef)(K);pe.current=K,(0,_react.useEffect)(()=>{Q.setValue(pe.current)},[J,Q]);const me=L?{marginBottom:A.space.none}:void 0,ge={disabled:o,...W},he="top"===c,fe=he?{alignSelf:"flex-start",marginTop:Math.max(0,((u??$.icon)-$.icon)/2)}:null,ve=_??g??$["min-height"],ye=(()=>{if(!b)return 0;const e=Math.min(ne.tl,ve/2),t=b.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),Re=b&&le.top>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-le.top,left:b.left-le.left,width:b.width,height:le.top+ye,backgroundColor:ee}}):null,renderInner=e=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ce.active&&ce.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ce.size.width,height:ce.size.height,radius:ne.tl,fill:e&&!o?A.colors["surface-pressed"]:ee,stroke:be,strokeWidth:le.top}):null,Re,null!=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:a}):null,null!=a&&n?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[G.divider,fe,{height:$.icon,backgroundColor:A.colors["field-border"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.content,he?G.contentTop:null],children:x}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:d}):null]}),je=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,xe,p?null:me,z],accessibilityRole:D,accessibilityLabel:M,accessibilityHint:P,accessibilityState:ge,...(0,_ariaState.ariaFromState)(ge),testID:E,children:renderInner(!1)});return p&&!m?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,accessible:!1,style:me,testID:E?`${E}-press`:void 0,children:je}):p?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,style:me,accessibilityRole:D??"button",accessibilityLabel:M,accessibilityHint:P,accessibilityState:ge,...(0,_ariaState.ariaFromState)(ge),testID:E,children:({pressed:e})=>(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,xe,!e||o||ce.active?null:{backgroundColor:A.colors["surface-pressed"]},z],children:renderInner(e)})}):je};exports.FieldBase=FieldBase,FieldBase.displayName="FieldBase";const buildStyles=()=>_reactNative.StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});var _default=exports.default=FieldBase;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.IconBadge=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_squircle=require("../../squircle.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,a,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((t=i&&Object.getOwnPropertyDescriptor(e,a))&&(t.get||t.set)?i(s,a,t):s[a]=e[a]);return s}const SIZE_MAP={sm:{diameter:32,icon:16},md:{diameter:40,icon:20},lg:{diameter:56,icon:28}},FILL_OPACITY=.14,HALO_FILL_OPACITY=.16,inkFor=(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["text-muted"];default:return e.colors.primary}},IconBadge=exports.IconBadge=(0,_react.forwardRef)((e,r)=>{const{icon:t,iconVariant:a,size:i="md",tone:s="primary",color:o,fill:c="tint",shape:n="circle",dimension:l,accessibilityLabel:u,pointerEvents:d,style:_,testID:g}=e;(0,_assertValidValue.assertValidValue)("IconBadge","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("IconBadge","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("IconBadge","iconVariant",e.iconVariant,["linear","bold","broken","bulk","outline","twotone"]),(0,_assertValidValue.assertValidValue)("IconBadge","fill",e.fill,["tint","halo","surface"]),(0,_assertValidValue.assertValidValue)("IconBadge","shape",e.shape,["circle","squircle"]);const h=(0,_index.useTheme)(),f=SIZE_MAP[i],m=o??inkFor(h,s),p=l??f.diameter,V=null!=l?Math.round(l/2):f.icon,v="surface"===c?h.colors.surface:void 0===o&&"neutral"===s?h.colors["bg-muted"]:(0,_color.tintOf)(m,"halo"===c?.16:.14,h.colors["bg-muted"]),I={color:m,size:V,disabled:!1},y=void 0!==u,b="squircle"===n;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,testID:g,pointerEvents:d,accessible:y,accessibilityRole:y?"image":void 0,accessibilityLabel:u,importantForAccessibility:y?"yes":"no",style:[styles.base,b?{width:p,height:p}:{width:p,height:p,borderRadius:p/2,..._corners.smoothCorners,backgroundColor:v},_],children:[b?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{style:styles.overlay,width:p,height:p,viewBox:`0 0 ${p} ${p}`,children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:(0,_squircle.squirclePath)({width:p,height:p,radius:h.radius.lg,smoothing:h.cornerSmoothing}),fill:v})}):null,(0,_slotIcon.renderSlotIcon)(t,I,a)]})});IconBadge.displayName="IconBadge";const styles=_reactNative.StyleSheet.create({base:{alignItems:"center",justifyContent:"center"},overlay:{position:"absolute",top:0,left:0}});var _default=exports.default=IconBadge;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.IconBadge=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_squircle=require("../../squircle.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,a,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((t=i&&Object.getOwnPropertyDescriptor(e,a))&&(t.get||t.set)?i(s,a,t):s[a]=e[a]);return s}const SIZE_MAP={sm:{diameter:32,icon:16},md:{diameter:40,icon:20},lg:{diameter:56,icon:28}},FILL_OPACITY=.14,HALO_FILL_OPACITY=.16,inkFor=(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["text-muted"];default:return e.colors.primary}},IconBadge=exports.IconBadge=(0,_react.forwardRef)((e,r)=>{const{icon:t,iconVariant:a,size:i="md",tone:s="primary",color:o,fill:c="tint",shape:n="circle",dimension:l,accessibilityLabel:u,pointerEvents:d,style:_,testID:h}=e;(0,_assertValidValue.assertValidValue)("IconBadge","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("IconBadge","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("IconBadge","iconVariant",e.iconVariant,["linear","bold","broken","bulk","outline","twotone"]),(0,_assertValidValue.assertValidValue)("IconBadge","fill",e.fill,["tint","halo","surface"]),(0,_assertValidValue.assertValidValue)("IconBadge","shape",e.shape,["circle","squircle"]);const g=(0,_index.useTheme)(),f=SIZE_MAP[i],m=o??inkFor(g,s),p=l??f.diameter,V=null!=l?Math.round(l/2):f.icon,v="surface"===c?g.colors.surface:void 0===o&&"neutral"===s?g.colors["bg-muted"]:(0,_color.tintOf)(m,"halo"===c?.16:.14,g.colors["bg-muted"]),I={color:m,size:V,disabled:!1},y=void 0!==u,b="squircle"===n;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,testID:h,pointerEvents:d,accessible:y,accessibilityRole:y?"image":void 0,accessibilityLabel:u,importantForAccessibility:y?"yes":"no",..."web"!==_reactNative.Platform.OS||y?null:{"aria-hidden":!0},style:[styles.base,b?{width:p,height:p}:{width:p,height:p,borderRadius:p/2,..._corners.smoothCorners,backgroundColor:v},_],children:[b?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{style:styles.overlay,width:p,height:p,viewBox:`0 0 ${p} ${p}`,children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:(0,_squircle.squirclePath)({width:p,height:p,radius:g.radius.lg,smoothing:g.cornerSmoothing}),fill:v})}):null,(0,_slotIcon.renderSlotIcon)(t,I,a)]})});IconBadge.displayName="IconBadge";const styles=_reactNative.StyleSheet.create({base:{alignItems:"center",justifyContent:"center"},overlay:{position:"absolute",top:0,left:0}});var _default=exports.default=IconBadge;