@webority/mobile-ui 0.147.0 → 0.148.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 (184) hide show
  1. package/dist/canvas-kit/kit.js +1614 -1543
  2. package/dist/canvas-kit/manifest.json +8 -1
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  5. package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
  6. package/lib/commonjs/components/AuthedImage/imageStore.js +1 -1
  7. package/lib/commonjs/components/AuthedImage/imageStore.web.js +1 -1
  8. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  9. package/lib/commonjs/components/Box/Box.js +1 -1
  10. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  11. package/lib/commonjs/components/Input/Input.js +1 -1
  12. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  13. package/lib/commonjs/components/Markdown/Markdown.js +1 -1
  14. package/lib/commonjs/components/MessageList/MessageList.js +1 -1
  15. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  16. package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
  17. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  18. package/lib/commonjs/components/SignaturePad/writePng.js +1 -1
  19. package/lib/commonjs/components/SignaturePad/writePng.web.js +1 -1
  20. package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
  21. package/lib/commonjs/index.js +1 -1
  22. package/lib/commonjs/theme/Gradient.js +1 -1
  23. package/lib/module/components/AppBar/AppBar.js +1 -1
  24. package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
  25. package/lib/module/components/AuthedImage/imageStore.js +1 -1
  26. package/lib/module/components/AuthedImage/imageStore.web.js +1 -1
  27. package/lib/module/components/Avatar/Avatar.js +1 -1
  28. package/lib/module/components/Box/Box.js +1 -1
  29. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  30. package/lib/module/components/Input/Input.js +1 -1
  31. package/lib/module/components/ListItem/ListItem.js +1 -1
  32. package/lib/module/components/Markdown/Markdown.js +1 -1
  33. package/lib/module/components/MessageList/MessageList.js +1 -1
  34. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  35. package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
  36. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  37. package/lib/module/components/SignaturePad/writePng.js +1 -1
  38. package/lib/module/components/SignaturePad/writePng.web.js +1 -1
  39. package/lib/module/components/WheelPicker/Wheel.js +1 -1
  40. package/lib/module/index.js +1 -1
  41. package/lib/module/theme/Gradient.js +1 -1
  42. package/lib/typescript/commonjs/canvasKit/index.d.ts +15 -6
  43. package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +3 -2
  44. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +2 -2
  45. package/lib/typescript/commonjs/components/AuthedImage/imageStore.d.ts +1 -1
  46. package/lib/typescript/commonjs/components/AuthedImage/imageStore.web.d.ts +1 -1
  47. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +2 -2
  48. package/lib/typescript/commonjs/components/Badge/Badge.d.ts +2 -2
  49. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +2 -2
  50. package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +2 -2
  51. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +2 -2
  52. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +2 -3
  53. package/lib/typescript/commonjs/components/Box/Box.d.ts +4 -4
  54. package/lib/typescript/commonjs/components/Button/Button.d.ts +3 -2
  55. package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +3 -2
  56. package/lib/typescript/commonjs/components/Calendar/calendarStyles.d.ts +25 -116
  57. package/lib/typescript/commonjs/components/Card/Card.d.ts +2 -2
  58. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +2 -2
  59. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +2 -2
  60. package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +2 -2
  61. package/lib/typescript/commonjs/components/Composer/Composer.d.ts +2 -3
  62. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +3 -2
  63. package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +3 -2
  64. package/lib/typescript/commonjs/components/Divider/Divider.d.ts +3 -2
  65. package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +2 -2
  66. package/lib/typescript/commonjs/components/FileViewer/useFileViewerZoom.d.ts +14 -22
  67. package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +3 -2
  68. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +2 -2
  69. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +2 -2
  70. package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +3 -2
  71. package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +3 -2
  72. package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +2 -2
  73. package/lib/typescript/commonjs/components/Input/Input.d.ts +2 -3
  74. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
  75. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +4 -3
  76. package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +3 -1
  77. package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +2 -2
  78. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +3 -3
  79. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -2
  80. package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +2 -2
  81. package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +2 -2
  82. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +4 -4
  83. package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +2 -2
  84. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -3
  85. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +2 -2
  86. package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +2 -2
  87. package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +2 -2
  88. package/lib/typescript/commonjs/components/Screen/Screen.d.ts +2 -2
  89. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +3 -3
  90. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -3
  91. package/lib/typescript/commonjs/components/Select/Select.d.ts +2 -2
  92. package/lib/typescript/commonjs/components/SignaturePad/writePng.d.ts +1 -1
  93. package/lib/typescript/commonjs/components/SignaturePad/writePng.web.d.ts +1 -1
  94. package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +2 -2
  95. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +2 -2
  96. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +2 -2
  97. package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +3 -2
  98. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +2 -2
  99. package/lib/typescript/commonjs/components/SquircleView/SquircleView.d.ts +3 -2
  100. package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +3 -3
  101. package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +2 -2
  102. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +2 -2
  103. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -3
  104. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -3
  105. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +3 -2
  106. package/lib/typescript/commonjs/components/Text/Text.d.ts +2 -2
  107. package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +3 -3
  108. package/lib/typescript/commonjs/components/Tour/Tour.d.ts +2 -2
  109. package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +5 -5
  110. package/lib/typescript/commonjs/index.d.ts +1 -1
  111. package/lib/typescript/commonjs/theme/Gradient.d.ts +5 -1
  112. package/lib/typescript/commonjs/theme/makeStyles.d.ts +4 -2
  113. package/lib/typescript/module/canvasKit/index.d.ts +15 -6
  114. package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +3 -2
  115. package/lib/typescript/module/components/AppBar/AppBar.d.ts +2 -2
  116. package/lib/typescript/module/components/AuthedImage/imageStore.d.ts +1 -1
  117. package/lib/typescript/module/components/AuthedImage/imageStore.web.d.ts +1 -1
  118. package/lib/typescript/module/components/Avatar/Avatar.d.ts +2 -2
  119. package/lib/typescript/module/components/Badge/Badge.d.ts +2 -2
  120. package/lib/typescript/module/components/Banner/Banner.d.ts +2 -2
  121. package/lib/typescript/module/components/BarChart/BarChart.d.ts +2 -2
  122. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +2 -2
  123. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +2 -3
  124. package/lib/typescript/module/components/Box/Box.d.ts +4 -4
  125. package/lib/typescript/module/components/Button/Button.d.ts +3 -2
  126. package/lib/typescript/module/components/Calendar/Calendar.d.ts +3 -2
  127. package/lib/typescript/module/components/Calendar/calendarStyles.d.ts +25 -116
  128. package/lib/typescript/module/components/Card/Card.d.ts +2 -2
  129. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +2 -2
  130. package/lib/typescript/module/components/Chip/Chip.d.ts +2 -2
  131. package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +2 -2
  132. package/lib/typescript/module/components/Composer/Composer.d.ts +2 -3
  133. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +3 -2
  134. package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +3 -2
  135. package/lib/typescript/module/components/Divider/Divider.d.ts +3 -2
  136. package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +2 -2
  137. package/lib/typescript/module/components/FileViewer/useFileViewerZoom.d.ts +14 -22
  138. package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +3 -2
  139. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +2 -2
  140. package/lib/typescript/module/components/FormField/FormField.d.ts +2 -2
  141. package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +3 -2
  142. package/lib/typescript/module/components/IconButton/IconButton.d.ts +3 -2
  143. package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +2 -2
  144. package/lib/typescript/module/components/Input/Input.d.ts +2 -3
  145. package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
  146. package/lib/typescript/module/components/ListItem/ListItem.d.ts +4 -3
  147. package/lib/typescript/module/components/Markdown/Markdown.d.ts +3 -1
  148. package/lib/typescript/module/components/Menu/useContextMenu.d.ts +2 -2
  149. package/lib/typescript/module/components/Modal/Modal.d.ts +3 -3
  150. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -2
  151. package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +2 -2
  152. package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +2 -2
  153. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +4 -4
  154. package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +2 -2
  155. package/lib/typescript/module/components/Radio/Radio.d.ts +3 -3
  156. package/lib/typescript/module/components/Rating/Rating.d.ts +2 -2
  157. package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +2 -2
  158. package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +2 -2
  159. package/lib/typescript/module/components/Screen/Screen.d.ts +2 -2
  160. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +3 -3
  161. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -3
  162. package/lib/typescript/module/components/Select/Select.d.ts +2 -2
  163. package/lib/typescript/module/components/SignaturePad/writePng.d.ts +1 -1
  164. package/lib/typescript/module/components/SignaturePad/writePng.web.d.ts +1 -1
  165. package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +2 -2
  166. package/lib/typescript/module/components/Slider/Slider.d.ts +2 -2
  167. package/lib/typescript/module/components/SliderField/SliderField.d.ts +2 -2
  168. package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +3 -2
  169. package/lib/typescript/module/components/Spinner/Spinner.d.ts +2 -2
  170. package/lib/typescript/module/components/SquircleView/SquircleView.d.ts +3 -2
  171. package/lib/typescript/module/components/StatTile/StatTile.d.ts +3 -3
  172. package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +2 -2
  173. package/lib/typescript/module/components/Stepper/Stepper.d.ts +2 -2
  174. package/lib/typescript/module/components/Switch/Switch.d.ts +3 -3
  175. package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -3
  176. package/lib/typescript/module/components/TagInput/TagInput.d.ts +3 -2
  177. package/lib/typescript/module/components/Text/Text.d.ts +2 -2
  178. package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +3 -3
  179. package/lib/typescript/module/components/Tour/Tour.d.ts +2 -2
  180. package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +5 -5
  181. package/lib/typescript/module/index.d.ts +1 -1
  182. package/lib/typescript/module/theme/Gradient.d.ts +5 -1
  183. package/lib/typescript/module/theme/makeStyles.d.ts +4 -2
  184. package/package.json +29 -29
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,Text,useWindowDimensions,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,resolveCheckboxSize,resolveListItemSize,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{themeStyles}from"../../utils/themeStyles.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Button}from"../Button/index.js";import{IconBadge}from"../IconBadge/index.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{webOnly}from"../Menu/webOnly.js";import{Skeleton}from"../Skeleton/index.js";import{Swipeable}from"../Swipeable/index.js";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Chevron=({color:e})=>{const t=useTheme();return _jsx(_Fragment,{children:(t.settings.icons.chevronRight??defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,MENU_ROW_MIN_HEIGHT=48,WEB_CHECKABLE_ROLE=webOnly({role:"menuitemcheckbox"}),SelectionBox=({checked:e,disabled:t})=>{const i=useTheme(),s=resolveCheckboxSize(i,"md")["box-size"],l=Math.round(.72*s);return _jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.size.border,borderRadius:i.radius.sm,...smoothCorners,borderColor:e?i.colors.primary:i.colors.border,backgroundColor:e?i.colors.primary:t?i.colors["surface-disabled"]:"transparent"},children:e?_jsx(Svg,{width:l,height:l,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors["on-primary"],strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})}):null})},isActionList=e=>Array.isArray(e)&&e.length>0&&e.every(e=>null!=e&&"object"==typeof e&&!React.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>_jsx(Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,label:e.label,onPress:e.onPress},e.label)):e,ListItem=React.memo(forwardRef((e,t)=>{const{title:i,loading:s=!1,subtitle:l,description:o,children:n,titleLines:r,subtitleLines:a=1,leading:c,icon:d,iconTone:m="primary",trailing:u,rightPlacement:h="auto",selectable:p=!1,checked:x=!1,onCheckedChange:g,actions:b,onPress:y,onFocus:f,haptic:j,selected:S=!1,expanded:_,disabled:w=!1,size:v="md",variant:I="list",divider:L=!1,chevron:k=!1,leftActions:V,rightActions:C,contextMenu:A,accessibilityLabel:R,accessibilityHint:B,style:z,containerStyle:T,titleStyle:E,subtitleStyle:F,descriptionStyle:P,leftSlotStyle:D,rightSlotStyle:H,testID:M}=e;assertValidValue("ListItem","size",e.size,["sm","md","lg"]),assertValidValue("ListItem","iconTone",e.iconTone,["primary","success","warning","danger","info","neutral"]),assertValidValue("ListItem","rightPlacement",e.rightPlacement,["auto","side","below"]),assertValidValue("ListItem","variant",e.variant,["list","menu"]);const O="menu"===I,W=r??(O?2:1),G=O?e.checked:void 0,N=useTheme(),K=useMemo(()=>resolveListItemSize(N,v),[N,v]),U=stylesFor(N),{fontScale:Z}=useWindowDimensions(),q=!!u&&("below"===h||"auto"===h&&Z>1.2),J=useContextMenu(w?void 0:A,{haptic:j||!1,testID:M}),Q=useMemo(()=>mergeRefs(t,J.hostRef),[t,J.hostRef]),X=p||!!y,Y=X||J.enabled,$=Y&&!w,{style:ee,pressIn:te,pressOut:ie}=usePressAnimation({enabled:$&&!O}),se=useFlickGuard(),le=R??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,oe=c??(void 0===d?null:_jsx(IconBadge,{icon:d,tone:m,size:BADGE_SIZE[v]})),ne=p?_jsxs(View,{style:U.selectionLead,children:[_jsx(SelectionBox,{checked:x,disabled:w}),oe?_jsx(View,{style:U.selectionLeadContent,children:oe}):null]}):oe,re=null!=b&&!1!==b&&!(Array.isArray(b)&&0===b.length),ae=L&&!re,ce=_jsxs(View,{style:[U.row,{paddingVertical:O?N.space.sm:K["padding-y"],minHeight:O?48:K["min-height"],backgroundColor:S?N.colors["surface-selected"]:"transparent"},ae?U.divider:null,w&&!O?U.disabled:null,T],children:[ne?_jsx(View,{style:[U.leftSlot,D],children:ne}):null,_jsxs(View,{style:U.middle,children:[null==i||isText(i)?_jsx(Text,{style:[U.title,{fontSize:O?N.text.base.size:K["title-text"],...fontFor(N,O?"normal":"medium"),color:w?N.colors["text-disabled"]:N.colors["text-body"]},E],numberOfLines:W,children:i??" "}):i,null==l||""===l?null:isText(l)?_jsx(Text,{style:[U.subtitle,{fontSize:O?N.text.xs.size:K["subtitle-text"],color:w?N.colors["text-disabled"]:N.colors["text-muted"]},O?U.menuSubtitle:null,F],numberOfLines:a,children:l}):l,o?_jsx(Text,{style:[U.description,{fontSize:K["subtitle-text"],color:w?N.colors["text-disabled"]:N.colors["text-subtle"]},P],numberOfLines:2,children:o}):null,null!=n&&!1!==n?_jsx(View,{style:U.body,children:n}):null,q?_jsx(View,{style:[U.rightBelow,H],children:u}):null]}),u&&!q||k?_jsxs(View,{style:[U.rightSlot,q?null:H],children:[q?null:u,k?_jsx(View,{style:u&&!q?U.chevronWithRight:null,children:_jsx(Chevron,{color:w?N.colors["text-disabled"]:N.colors["text-subtle"]})}):null]}):null]}),de=Y?_jsx(Pressable,{ref:Q,onPress:e=>{$&&X&&!se.isFlick(e)&&(j&&triggerHaptic(j),p?g?.(!x):y?.(e))},onPressIn:e=>{se.onPressIn(e),te()},onPressOut:ie,disabled:!$,onFocus:f,accessibilityRole:p?"checkbox":O?"menuitem":y?"button":void 0,accessibilityLabel:le,accessibilityHint:B,accessibilityState:p?{checked:x,disabled:!$,expanded:_}:{selected:S,disabled:!$,expanded:_,...void 0!==G?{checked:G}:null},"aria-disabled":!$,"aria-expanded":_,...p?{"aria-checked":x}:void 0!==G?{"aria-checked":G}:{"aria-selected":S},...void 0!==G?WEB_CHECKABLE_ROLE:null,testID:M,android_ripple:{color:N.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[z,e?U.pressed:null],...J.hostProps,children:_jsx(Animated.View,{style:ee,children:ce})}):_jsx(View,{ref:t,accessibilityRole:"none",accessibilityLabel:le,accessibilityHint:B,accessibilityState:{selected:S,disabled:w},"aria-selected":S,"aria-disabled":w,testID:M,style:z,children:ce}),me=V&&V.length>0||C&&C.length>0,ue=re?_jsxs(View,{style:[S?{backgroundColor:N.colors["surface-selected"]}:null,L?U.divider:null],children:[de,_jsx(View,{style:U.actions,children:renderActions(b)})]}):de,he=me?_jsx(Swipeable,{leftActions:V,rightActions:C,accessibilityLabel:le,children:ue}):ue;return s?_jsx(ListItemSkeleton,{...e}):J.enabled?_jsxs(_Fragment,{children:[he,J.renderSurface(_jsx(View,{style:U.preview,children:ce}))]}):he}));ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,leading:i,icon:s,trailing:l,chevron:o,size:n="md",variant:r="list",containerStyle:a,style:c})=>{const d=useTheme(),m=resolveListItemSize(d,n),u=Math.round(1.15*m["title-text"]),h=Math.round(1.15*m["subtitle-text"]),p="menu"===r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:d.space.md,paddingVertical:p?d.space.sm:m["padding-y"],minHeight:p?48:m["min-height"]},a,c],children:[void 0!==i||void 0!==s?_jsx(View,{style:{marginRight:d.space.sm},children:_jsx(Skeleton,{shape:"circle",width:40,height:40})}):null,_jsxs(View,{style:{flex:1},children:[_jsx(Skeleton,{shape:"text",width:"70%",height:u,style:{marginBottom:d.space.xs}}),void 0!==e?_jsx(Skeleton,{shape:"text",width:"50%",height:h,style:void 0!==t?{marginBottom:d.space.xs}:void 0}):null,void 0!==t?_jsx(Skeleton,{shape:"text",width:"85%",height:h}):null]}),void 0!==l||o?_jsx(View,{style:{marginLeft:d.space.sm},children:_jsx(Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.md},divider:{borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors.border},pressed:{backgroundColor:e.colors["surface-pressed"]},disabled:{opacity:.55},leftSlot:{marginRight:e.space.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.space.sm},body:{marginTop:e.space.xs},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.space.xs},rightSlot:{marginLeft:e.space.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm,paddingHorizontal:e.space.md,paddingBottom:e.space.md},chevronWithRight:{marginLeft:e.space.xs},preview:{flex:1,backgroundColor:e.colors.surface,borderRadius:e.radius.md,...smoothCorners,overflow:"hidden"},title:{letterSpacing:e["letter-spacing"].normal},subtitle:{marginTop:e.space.xxs,...fontFor(e,"normal")},menuSubtitle:{marginTop:0},description:{marginTop:e.space.xxs,...fontFor(e,"normal")}}),stylesFor=themeStyles(buildStyles);export{ListItem};export default ListItem;
1
+ "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,Text,useWindowDimensions,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,resolveCheckboxSize,resolveListItemSize,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{themeStyles}from"../../utils/themeStyles.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Button}from"../Button/index.js";import{IconBadge}from"../IconBadge/index.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{webOnly}from"../Menu/webOnly.js";import{Skeleton}from"../Skeleton/index.js";import{Swipeable}from"../Swipeable/index.js";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Chevron=({color:e})=>{const t=useTheme();return _jsx(_Fragment,{children:(t.settings.icons.chevronRight??defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,MENU_ROW_MIN_HEIGHT=48,WEB_CHECKABLE_ROLE=webOnly({role:"menuitemcheckbox"}),SelectionBox=({checked:e,disabled:t})=>{const i=useTheme(),s=resolveCheckboxSize(i,"md")["box-size"],l=Math.round(.72*s);return _jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.size.border,borderRadius:i.radius.sm,...smoothCorners,borderColor:e?i.colors.primary:i.colors.border,backgroundColor:e?i.colors.primary:t?i.colors["surface-disabled"]:"transparent"},children:e?_jsx(Svg,{width:l,height:l,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors["on-primary"],strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})}):null})},isActionList=e=>Array.isArray(e)&&e.length>0&&e.every(e=>null!=e&&"object"==typeof e&&!React.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>_jsx(Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,label:e.label,onPress:e.onPress},e.label)):e,ListItem=React.memo(forwardRef((e,t)=>{const{title:i,loading:s=!1,subtitle:l,description:o,children:n,titleLines:r,subtitleLines:a=1,leading:c,icon:d,iconTone:m="primary",trailing:u,rightPlacement:h="auto",selectable:p=!1,checked:x=!1,onCheckedChange:g,actions:b,onPress:y,onFocus:f,haptic:j,selected:S=!1,expanded:_,disabled:w=!1,size:v="md",variant:I="list",divider:L=!1,chevron:k=!1,leftActions:V,rightActions:C,contextMenu:A,accessibilityLabel:R,accessibilityHint:B,style:z,containerStyle:T,titleStyle:E,subtitleStyle:F,descriptionStyle:P,leftSlotStyle:D,rightSlotStyle:H,testID:M}=e;assertValidValue("ListItem","size",e.size,["sm","md","lg"]),assertValidValue("ListItem","iconTone",e.iconTone,["primary","success","warning","danger","info","neutral"]),assertValidValue("ListItem","rightPlacement",e.rightPlacement,["auto","side","below"]),assertValidValue("ListItem","variant",e.variant,["list","menu"]);const O="menu"===I,W=r??(O?2:1),G=O?e.checked:void 0,N=useTheme(),K=useMemo(()=>resolveListItemSize(N,v),[N,v]),U=stylesFor(N),{fontScale:Z}=useWindowDimensions(),q=!!u&&("below"===h||"auto"===h&&Z>1.2),J=useContextMenu(w?void 0:A,{haptic:j||!1,testID:M}),Q=useMemo(()=>mergeRefs(t,J.hostRef),[t,J.hostRef]),X=p||!!y,Y=X||J.enabled,$=Y&&!w,{style:ee,pressIn:te,pressOut:ie}=usePressAnimation({enabled:$&&!O}),se=useFlickGuard(),le=R??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,oe=c??(void 0===d?null:_jsx(IconBadge,{icon:d,tone:m,size:BADGE_SIZE[v]})),ne=p?_jsxs(View,{style:U.selectionLead,children:[_jsx(SelectionBox,{checked:x,disabled:w}),oe?_jsx(View,{style:U.selectionLeadContent,children:oe}):null]}):oe,re=null!=b&&!1!==b&&!(Array.isArray(b)&&0===b.length),ae=L&&!re,ce=_jsxs(View,{style:[U.row,{paddingVertical:O?N.space.sm:K["padding-y"],minHeight:O?48:K["min-height"],backgroundColor:S?N.colors["surface-selected"]:"transparent"},ae?U.divider:null,w&&!O?U.disabled:null,T],children:[ne?_jsx(View,{style:[U.leftSlot,D],children:ne}):null,_jsxs(View,{style:U.middle,children:[null==i||isText(i)?_jsx(Text,{style:[U.title,{fontSize:O?N.text.base.size:K["title-text"],...fontFor(N,O?"normal":"medium"),color:w?N.colors["text-disabled"]:N.colors["text-body"]},E],numberOfLines:W,children:i??" "}):i,null==l||""===l?null:isText(l)?_jsx(Text,{style:[U.subtitle,{fontSize:O?N.text.xs.size:K["subtitle-text"],color:w?N.colors["text-disabled"]:N.colors["text-muted"]},O?U.menuSubtitle:null,F],numberOfLines:a,children:l}):l,null==o||""===o?null:isText(o)?_jsx(Text,{style:[U.description,{fontSize:K["subtitle-text"],color:w?N.colors["text-disabled"]:N.colors["text-subtle"]},P],numberOfLines:2,children:o}):o,null!=n&&!1!==n?_jsx(View,{style:U.body,children:n}):null,q?_jsx(View,{style:[U.rightBelow,H],children:u}):null]}),u&&!q||k?_jsxs(View,{style:[U.rightSlot,q?null:H],children:[q?null:u,k?_jsx(View,{style:u&&!q?U.chevronWithRight:null,children:_jsx(Chevron,{color:w?N.colors["text-disabled"]:N.colors["text-subtle"]})}):null]}):null]}),de=Y?_jsx(Pressable,{ref:Q,onPress:e=>{$&&X&&!se.isFlick(e)&&(j&&triggerHaptic(j),p?g?.(!x):y?.(e))},onPressIn:e=>{se.onPressIn(e),te()},onPressOut:ie,disabled:!$,onFocus:f,accessibilityRole:p?"checkbox":O?"menuitem":y?"button":void 0,accessibilityLabel:le,accessibilityHint:B,accessibilityState:p?{checked:x,disabled:!$,expanded:_}:{selected:S,disabled:!$,expanded:_,...void 0!==G?{checked:G}:null},"aria-disabled":!$,"aria-expanded":_,...p?{"aria-checked":x}:void 0!==G?{"aria-checked":G}:{"aria-selected":S},...void 0!==G?WEB_CHECKABLE_ROLE:null,testID:M,android_ripple:{color:N.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[z,e?U.pressed:null],...J.hostProps,children:_jsx(Animated.View,{style:ee,children:ce})}):_jsx(View,{ref:t,accessibilityRole:"none",accessibilityLabel:le,accessibilityHint:B,accessibilityState:{selected:S,disabled:w},"aria-selected":S,"aria-disabled":w,testID:M,style:z,children:ce}),me=V&&V.length>0||C&&C.length>0,ue=re?_jsxs(View,{style:[S?{backgroundColor:N.colors["surface-selected"]}:null,L?U.divider:null],children:[de,_jsx(View,{style:U.actions,children:renderActions(b)})]}):de,he=me?_jsx(Swipeable,{leftActions:V,rightActions:C,accessibilityLabel:le,children:ue}):ue;return s?_jsx(ListItemSkeleton,{...e}):J.enabled?_jsxs(_Fragment,{children:[he,J.renderSurface(_jsx(View,{style:U.preview,children:ce}))]}):he}));ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,leading:i,icon:s,trailing:l,chevron:o,size:n="md",variant:r="list",containerStyle:a,style:c})=>{const d=useTheme(),m=resolveListItemSize(d,n),u=Math.round(1.15*m["title-text"]),h=Math.round(1.15*m["subtitle-text"]),p="menu"===r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:d.space.md,paddingVertical:p?d.space.sm:m["padding-y"],minHeight:p?48:m["min-height"]},a,c],children:[void 0!==i||void 0!==s?_jsx(View,{style:{marginRight:d.space.sm},children:_jsx(Skeleton,{shape:"circle",width:40,height:40})}):null,_jsxs(View,{style:{flex:1},children:[_jsx(Skeleton,{shape:"text",width:"70%",height:u,style:{marginBottom:d.space.xs}}),void 0!==e?_jsx(Skeleton,{shape:"text",width:"50%",height:h,style:void 0!==t?{marginBottom:d.space.xs}:void 0}):null,void 0!==t?_jsx(Skeleton,{shape:"text",width:"85%",height:h}):null]}),void 0!==l||o?_jsx(View,{style:{marginLeft:d.space.sm},children:_jsx(Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.md},divider:{borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors.border},pressed:{backgroundColor:e.colors["surface-pressed"]},disabled:{opacity:.55},leftSlot:{marginRight:e.space.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.space.sm},body:{marginTop:e.space.xs},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.space.xs},rightSlot:{marginLeft:e.space.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm,paddingHorizontal:e.space.md,paddingBottom:e.space.md},chevronWithRight:{marginLeft:e.space.xs},preview:{flex:1,backgroundColor:e.colors.surface,borderRadius:e.radius.md,...smoothCorners,overflow:"hidden"},title:{letterSpacing:e["letter-spacing"].normal},subtitle:{marginTop:e.space.xxs,...fontFor(e,"normal")},menuSubtitle:{marginTop:0},description:{marginTop:e.space.xxs,...fontFor(e,"normal")}}),stylesFor=themeStyles(buildStyles);export{ListItem};export default ListItem;
@@ -1 +1 @@
1
- "use strict";import{linkTarget,parseInline,parseMarkdown}from"@webority/markdown-core";import{useMemo}from"react";import{Linking,Platform,Text as RNText,ScrollView,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MONO=Platform.select({ios:"Menlo",android:"monospace",default:"monospace"}),HEADING_SCALE={1:"3xl",2:"2xl",3:"xl",4:"lg",5:"base",6:"sm"},createStyles=e=>StyleSheet.create({block:{marginBottom:e.space.sm},listRow:{flexDirection:"row",marginBottom:e.space.xs},marker:{width:e.space.lg},listText:{flex:1},quote:{borderLeftWidth:3,borderLeftColor:e.colors["border-subtle"],paddingLeft:e.space.sm,marginBottom:e.space.sm},quoteText:{color:e.colors["text-muted"],fontStyle:"italic"},code:{backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.sm,...smoothCorners,padding:e.space.sm,marginBottom:e.space.sm},codeText:{fontFamily:MONO},inlineCode:{fontFamily:MONO,backgroundColor:e.colors["bg-subtle"],color:e.colors["text-body"]},link:{color:e.colors.link,textDecorationLine:"underline"},citation:{color:e.colors.primary,fontWeight:e.weight.semibold},strong:{fontWeight:e.weight.bold},em:{fontStyle:"italic"},strike:{textDecorationLine:"line-through"},table:{borderWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border},row:{flexDirection:"row"},headerRow:{backgroundColor:e.colors["bg-subtle"]},cell:{minWidth:96,maxWidth:220,padding:e.space.xs,borderRightWidth:StyleSheet.hairlineWidth,borderBottomWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border},rule:{height:StyleSheet.hairlineWidth,backgroundColor:e.colors.border,marginVertical:e.space.md}}),withPositionKeys=e=>e.map((e,t)=>({key:t,value:e})),openHref=(e,t)=>{t?t(e):Linking.openURL(e).catch(()=>{})};function Inline({tokens:e,ctx:t}){const{styles:i}=t;return _jsx(_Fragment,{children:e.map(e=>{switch(e.type){case"text":return t.figureText?_jsx(RNText,{children:t.figureText(e.text).map((e,i)=>renderFigureRun(e,i,t.theme))},e.key):_jsx(RNText,{children:e.text},e.key);case"code":return _jsx(RNText,{style:i.inlineCode,children:e.text},e.key);case"strong":return _jsx(RNText,{style:i.strong,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"em":return _jsx(RNText,{style:i.em,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"strike":return _jsx(RNText,{style:i.strike,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"image":return _jsxs(RNText,{children:["[",_jsx(Inline,{tokens:e.children,ctx:t}),"]"]},e.key);case"link":return renderLink(e.key,e.href,e.children,t);case"citation":return _jsx(RNText,{style:i.citation,accessibilityRole:t.onOpenCitation?"button":void 0,accessibilityLabel:e.text,onPress:t.onOpenCitation?()=>t.onOpenCitation?.(e.text):void 0,children:e.text},e.key);default:return null}})})}function renderLink(e,t,i,n){const{styles:s,links:r,resolveLink:o,onAppLinkPress:l,onLinkPress:a,onPageLinkPress:c}=n,d=_jsx(Inline,{tokens:i,ctx:n}),x=linkTarget(t,r,o);return null===x?_jsx(RNText,{children:d},e):"page"===x.kind?_jsx(RNText,c?{accessibilityRole:"link",style:s.link,onPress:()=>c(x.href),children:d}:{children:d},e):"app"===x.kind?_jsx(RNText,l?{accessibilityRole:"link",style:s.link,onPress:()=>l(x.target),children:d}:{children:d},e):_jsx(RNText,{accessibilityRole:"link",style:s.link,onPress:()=>openHref(x.href,a),children:d},e)}function renderFigureRun(e,t,i){if("text"===e.kind)return e.text;const n=i.text.base.size,s="sub"===e.kind?Math.round(.4*n):-Math.round(.45*n),r=Math.round(.75*n);return _jsx(View,{style:{transform:[{translateY:s}]},children:_jsx(RNText,{style:{fontSize:r,lineHeight:r,includeFontPadding:!1,color:i.colors["text-body"]},children:e.text})},t)}function RenderBlock({block:e,ctx:t}){const{theme:i,styles:n,textStyle:s,headings:r}=t;switch(e.type){case"heading":return _jsx(Text,{variant:"body",weight:"outline"===r?"semibold":"bold",size:"outline"===r?HEADING_SCALE[e.level]:void 0,accessibilityRole:"header",style:[n.block,s],children:_jsx(Inline,{tokens:parseInline(e.text,{isCitation:t.isCitation}),ctx:t})});case"paragraph":return _jsx(Text,{variant:"body",style:[n.block,s],children:_jsx(Inline,{tokens:parseInline(e.lines.join("\n"),{isCitation:t.isCitation}),ctx:t})});case"list":return _jsx(View,{children:withPositionKeys(e.items).map(({key:e,value:r})=>_jsxs(View,{style:[n.listRow,{marginLeft:r.depth*i.space.md}],children:[_jsx(Text,{variant:"body",style:[n.marker,s],children:r.ordered?`${r.number}.`:"•"}),_jsx(Text,{variant:"body",style:[n.listText,s],children:_jsx(Inline,{tokens:parseInline(r.text,{isCitation:t.isCitation}),ctx:t})})]},e))});case"table":return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:n.block,children:_jsx(View,{style:n.table,children:withPositionKeys([e.header,...e.rows]).map(({key:i,value:r})=>_jsx(View,{style:[n.row,0===i&&n.headerRow],children:withPositionKeys(e.header).map(({key:e})=>_jsx(View,{style:n.cell,children:_jsx(Text,{variant:"bodySmall",weight:0===i?"semibold":void 0,style:s,children:_jsx(Inline,{tokens:parseInline(r[e]??"",{isCitation:t.isCitation}),ctx:t})})},e))},i))})});case"code":return _jsx(ScrollView,{horizontal:!0,style:n.code,children:_jsx(Text,{variant:"body",size:"sm",selectable:!0,style:n.codeText,children:e.text})});case"quote":return _jsx(View,{style:n.quote,children:_jsx(Text,{variant:"body",style:[n.quoteText,s],children:_jsx(Inline,{tokens:parseInline(e.lines.join("\n"),{isCitation:t.isCitation}),ctx:t})})});case"rule":return _jsx(View,{style:n.rule});default:return null}}const MarkdownSkeleton=({style:e,testID:t})=>{const i=useTheme();return _jsxs(View,{style:e,testID:t,children:[_jsx(Skeleton,{shape:"text",width:"70%",height:20,style:{marginBottom:i.space.sm}}),_jsx(Skeleton,{shape:"text",width:"100%",height:14,style:{marginBottom:i.space.xs}}),_jsx(Skeleton,{shape:"text",width:"92%",height:14,style:{marginBottom:i.space.xs}}),_jsx(Skeleton,{shape:"text",width:"60%",height:14})]})};export function Markdown({children:e,links:t="web",headings:i="outline",figureText:n,resolveLink:s,isCitation:r,onOpenCitation:o,onAppLinkPress:l,onLinkPress:a,onPageLinkPress:c,loading:d=!1,style:x,textStyle:h,testID:k}){const m=useTheme(),y=useMemo(()=>createStyles(m),[m]),u=useMemo(()=>parseMarkdown(e??""),[e]);if(d)return _jsx(MarkdownSkeleton,{style:x,testID:k});if(0===u.length)return null;const p={theme:m,styles:y,links:t,headings:i,textStyle:h,figureText:n,resolveLink:s,isCitation:r,onOpenCitation:o,onAppLinkPress:l,onLinkPress:a,onPageLinkPress:c};return _jsx(View,{style:x,testID:k,children:u.map(e=>_jsx(RenderBlock,{block:e,ctx:p},e.key))})}Markdown.displayName="Markdown";
1
+ "use strict";import{linkTarget,parseInline,parseMarkdown}from"@webority/markdown-core";import{useMemo}from"react";import{Linking,Platform,Text as RNText,ScrollView,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MONO=Platform.select({ios:"Menlo",android:"monospace",default:"monospace"}),HEADING_SCALE={1:"3xl",2:"2xl",3:"xl",4:"lg",5:"base",6:"sm"},createStyles=e=>StyleSheet.create({block:{marginBottom:e.space.sm},listRow:{flexDirection:"row",marginBottom:e.space.xs},marker:{width:e.space.lg},listText:{flex:1},quote:{borderLeftWidth:3,borderLeftColor:e.colors["border-subtle"],paddingLeft:e.space.sm,marginBottom:e.space.sm},quoteText:{color:e.colors["text-muted"],fontStyle:"italic"},code:{backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.sm,...smoothCorners,padding:e.space.sm,marginBottom:e.space.sm},codeText:{fontFamily:MONO},inlineCode:{fontFamily:MONO,backgroundColor:e.colors["bg-subtle"],color:e.colors["text-body"]},link:{color:e.colors.link,textDecorationLine:"underline"},citation:{color:e.colors.primary,fontWeight:e.weight.semibold},strong:{fontWeight:e.weight.bold},em:{fontStyle:"italic"},strike:{textDecorationLine:"line-through"},table:{borderWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border},row:{flexDirection:"row"},headerRow:{backgroundColor:e.colors["bg-subtle"]},cell:{minWidth:96,maxWidth:220,padding:e.space.xs,borderRightWidth:StyleSheet.hairlineWidth,borderBottomWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border},rule:{height:StyleSheet.hairlineWidth,backgroundColor:e.colors.border,marginVertical:e.space.md}}),withPositionKeys=e=>e.map((e,t)=>({key:t,value:e})),openHref=(e,t)=>{t?t(e):Linking.openURL(e).catch(()=>{})};function Inline({tokens:e,ctx:t}){const{styles:i}=t;return _jsx(_Fragment,{children:e.map(e=>{switch(e.type){case"text":return t.figureText?_jsx(RNText,{children:t.figureText(e.text).map((e,i)=>renderFigureRun(e,i,t.theme))},e.key):_jsx(RNText,{children:e.text},e.key);case"code":return _jsx(RNText,{style:i.inlineCode,children:e.text},e.key);case"strong":return _jsx(RNText,{style:i.strong,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"em":return _jsx(RNText,{style:i.em,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"strike":return _jsx(RNText,{style:i.strike,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"image":return _jsxs(RNText,{children:["[",_jsx(Inline,{tokens:e.children,ctx:t}),"]"]},e.key);case"link":return renderLink(e.key,e.href,e.children,t);case"citation":return _jsx(RNText,{style:i.citation,accessibilityRole:t.onOpenCitation?"button":void 0,accessibilityLabel:e.text,onPress:t.onOpenCitation?()=>t.onOpenCitation?.(e.text):void 0,children:e.text},e.key);default:return null}})})}function renderLink(e,t,i,n){const{styles:s,links:r,resolveLink:o,onAppLinkPress:l,onLinkPress:a,onPageLinkPress:c}=n,d=_jsx(Inline,{tokens:i,ctx:n}),x=linkTarget(t,r,o);return null===x?_jsx(RNText,{children:d},e):"page"===x.kind?_jsx(RNText,c?{accessibilityRole:"link",style:s.link,onPress:()=>c(x.href),children:d}:{children:d},e):"app"===x.kind?_jsx(RNText,l?{accessibilityRole:"link",style:s.link,onPress:()=>l(x.target),children:d}:{children:d},e):_jsx(RNText,{accessibilityRole:"link",style:s.link,onPress:()=>openHref(x.href,a),children:d},e)}function renderFigureRun(e,t,i){if("text"===e.kind)return e.text;const n=i.text.base.size,s="sub"===e.kind?Math.round(.4*n):-Math.round(.45*n),r=Math.round(.75*n);return _jsx(View,{style:{transform:[{translateY:s}]},children:_jsx(RNText,{style:{fontSize:r,lineHeight:r,includeFontPadding:!1,color:i.colors["text-body"]},children:e.text})},t)}function RenderBlock({block:e,ctx:t}){const{theme:i,styles:n,textStyle:s,headings:r,selectable:o}=t;switch(e.type){case"heading":return _jsx(Text,{variant:"body",weight:"outline"===r?"semibold":"bold",size:"outline"===r?HEADING_SCALE[e.level]:void 0,accessibilityRole:"header",selectable:o,style:[n.block,s],children:_jsx(Inline,{tokens:parseInline(e.text,{isCitation:t.isCitation}),ctx:t})});case"paragraph":return _jsx(Text,{variant:"body",selectable:o,style:[n.block,s],children:_jsx(Inline,{tokens:parseInline(e.lines.join("\n"),{isCitation:t.isCitation}),ctx:t})});case"list":return _jsx(View,{children:withPositionKeys(e.items).map(({key:e,value:r})=>_jsxs(View,{style:[n.listRow,{marginLeft:r.depth*i.space.md}],children:[_jsx(Text,{variant:"body",style:[n.marker,s],children:r.ordered?`${r.number}.`:"•"}),_jsx(Text,{variant:"body",selectable:o,style:[n.listText,s],children:_jsx(Inline,{tokens:parseInline(r.text,{isCitation:t.isCitation}),ctx:t})})]},e))});case"table":return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:n.block,children:_jsx(View,{style:n.table,children:withPositionKeys([e.header,...e.rows]).map(({key:i,value:r})=>_jsx(View,{style:[n.row,0===i&&n.headerRow],children:withPositionKeys(e.header).map(({key:e})=>_jsx(View,{style:n.cell,children:_jsx(Text,{variant:"bodySmall",weight:0===i?"semibold":void 0,selectable:o,style:s,children:_jsx(Inline,{tokens:parseInline(r[e]??"",{isCitation:t.isCitation}),ctx:t})})},e))},i))})});case"code":return _jsx(ScrollView,{horizontal:!0,style:n.code,children:_jsx(Text,{variant:"body",size:"sm",selectable:!0,style:n.codeText,children:e.text})});case"quote":return _jsx(View,{style:n.quote,children:_jsx(Text,{variant:"body",selectable:o,style:[n.quoteText,s],children:_jsx(Inline,{tokens:parseInline(e.lines.join("\n"),{isCitation:t.isCitation}),ctx:t})})});case"rule":return _jsx(View,{style:n.rule});default:return null}}const MarkdownSkeleton=({style:e,testID:t})=>{const i=useTheme();return _jsxs(View,{style:e,testID:t,children:[_jsx(Skeleton,{shape:"text",width:"70%",height:20,style:{marginBottom:i.space.sm}}),_jsx(Skeleton,{shape:"text",width:"100%",height:14,style:{marginBottom:i.space.xs}}),_jsx(Skeleton,{shape:"text",width:"92%",height:14,style:{marginBottom:i.space.xs}}),_jsx(Skeleton,{shape:"text",width:"60%",height:14})]})};export function Markdown({children:e,links:t="web",headings:i="outline",figureText:n,resolveLink:s,isCitation:r,onOpenCitation:o,onAppLinkPress:l,onLinkPress:a,onPageLinkPress:c,loading:d=!1,style:x,textStyle:h,selectable:k=!1,testID:m}){const y=useTheme(),u=useMemo(()=>createStyles(y),[y]),p=useMemo(()=>parseMarkdown(e??""),[e]);if(d)return _jsx(MarkdownSkeleton,{style:x,testID:m});if(0===p.length)return null;const b={theme:y,styles:u,links:t,headings:i,textStyle:h,selectable:k,figureText:n,resolveLink:s,isCitation:r,onOpenCitation:o,onAppLinkPress:l,onLinkPress:a,onPageLinkPress:c};return _jsx(View,{style:x,testID:m,children:p.map(e=>_jsx(RenderBlock,{block:e,ctx:b},e.key))})}Markdown.displayName="Markdown";
@@ -1 +1 @@
1
- "use strict";import{formatDate}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{FlatList,StyleSheet,View}from"react-native";import{KeyboardChatScrollView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{Badge}from"../Badge/index.js";import{DateSeparator,dayLabel}from"../DateSeparator/index.js";import{IconButton}from"../IconButton/index.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"});const JUMP_AT=160,FOLLOW_AT=48,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:160},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";export function MessageList({messages:e,keyExtractor:t,renderMessage:o,getAuthorKey:n,getDate:s,firstUnreadKey:r,onLoadOlder:a,loadingOlder:l=!1,hasOlder:i=!0,typing:u,empty:c,getAnnouncement:d,followNew:m,keyboardAware:p=!0,keyboardOffset:f,labels:y,now:x,onScroll:g,onContentSizeChange:b,contentContainerStyle:S,style:h,testID:j,...w}){const L=useTheme(),_=useSafeAreaInsets(),C=useReducedMotion(),E=useMemo(()=>buildStyles(L),[L]),v=useMemo(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...y}),[y]),T=f??_.bottom,O=useRef(null),I=useRef(!1),k=useRef(!0),M=useRef(0),[A,D]=useState(!1),[V,P]=useState(0),R=useMemo(()=>{const o=s?e.map(e=>formatDate(s(e))):null,a=n?e.map(n):null,l=void 0===r?-1:e.findIndex(e=>t(e)===r);return e.map((t,n)=>{const r=n===e.length-1,i=null!==o&&(r||o[n]!==o[n+1]),u=null!==a&&!r&&a[n+1]===a[n]&&!i&&n!==l,c=null!==a&&n>0&&a[n-1]===a[n]&&(null===o||o[n-1]===o[n])&&n-1!==l;return{groupPosition:positionOf(u,c),day:i&&s?dayLabel(s(t),{now:x,labels:v}):null,unread:n===l}})},[e,s,n,r,t,x,v]),B=useCallback(()=>{k.current=!0,O.current?.scrollToOffset({offset:0,animated:!C}),P(0)},[C]),F=e[0],z=void 0===F?null:t(F),K=useRef(z);useEffect(()=>{const o=K.current;if(K.current=z,null===o||null===z||o===z)return;const n=e.findIndex(e=>t(e)===o);if(-1===n)return void P(0);const s=e.slice(0,n).reverse();for(const e of s){const t=d?.(e);t&&announce(t)}m&&s.some(m)?B():I.current&&P(e=>e+s.length)},[z]);const N=useCallback(e=>{k.current=e.nativeEvent.contentOffset.y<=48;const t=e.nativeEvent.contentOffset.y>160;t!==I.current&&(I.current=t,D(t),t||P(0)),g?.(e)},[g]),U=useCallback((e,t)=>{const o=t>M.current;M.current=t,o&&k.current&&O.current?.scrollToOffset({offset:0,animated:!1}),b?.(e,t)},[b]),$=useCallback(()=>{i&&!l&&a?.()},[i,l,a]),G=useCallback(({item:e,index:t})=>{const n=R[t];return _jsxs(View,{children:[n?.day?_jsx(DateSeparator,{label:n.day}):null,n?.unread?_jsx(DateSeparator,{label:v.unread,emphasis:!0}):null,o({item:e,index:t,groupPosition:n?.groupPosition??"single"})]})},[R,v.unread,o]),H=useCallback(e=>t(e),[t]),J=useCallback(e=>_jsx(KeyboardChatScrollView,{...e,inverted:!0,offset:T}),[T]),W=V>0?`${v.newMessages(V)}. ${v.jumpToLatest}`:v.jumpToLatest;return _jsxs(View,{style:[E.root,h],children:[_jsx(FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...w,ref:O,data:e,renderItem:G,keyExtractor:H,inverted:!0,onScroll:N,onContentSizeChange:U,onEndReached:a?$:void 0,ListHeaderComponent:u?_jsx(View,{children:u}):null,ListFooterComponent:l?_jsx(Spinner,{size:"sm",accessibilityLabel:v.loadingOlder,style:E.older}):null,ListEmptyComponent:c?_jsx(View,{style:E.fill,children:c}):null,renderScrollComponent:p?J:void 0,contentContainerStyle:[E.content,0===e.length?E.grow:null,S],testID:j}),A?_jsxs(View,{style:E.jump,pointerEvents:"box-none",children:[_jsx(View,{style:E.jumpDisc,children:_jsx(IconButton,{icon:"arrow-down",accessibilityLabel:W,variant:"ghost",tone:"neutral",onPress:B,testID:j?`${j}-jump`:void 0})}),V>0?_jsx(View,{style:E.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:_jsx(Badge,{value:V,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>StyleSheet.create({root:{flex:1},content:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm},grow:{flexGrow:1},fill:{flex:1},older:{paddingVertical:e.space.md},jump:{position:"absolute",right:e.space.md,bottom:e.space.md},jumpDisc:{borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});export default MessageList;
1
+ "use strict";import{formatDate}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{FlatList,StyleSheet,View}from"react-native";import{KeyboardChatScrollView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{Badge}from"../Badge/index.js";import{DateSeparator,dayLabel}from"../DateSeparator/index.js";import{IconButton}from"../IconButton/index.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"});const JUMP_AT=160,FOLLOW_AT=48,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:160},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";export function MessageList({messages:e,keyExtractor:t,renderMessage:o,getAuthorKey:s,getDate:n,firstUnreadKey:r,onLoadOlder:a,loadingOlder:i=!1,hasOlder:l=!0,typing:d,empty:u,getAnnouncement:c,followNew:m,keyboardAware:p=!0,keyboardOffset:f,labels:y,now:x,onScroll:g,onContentSizeChange:b,contentContainerStyle:S,style:h,testID:j,...w}){const L=useTheme(),_=useSafeAreaInsets(),v=useReducedMotion(),C=useMemo(()=>buildStyles(L),[L]),E=useMemo(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...y}),[y]),T=f??_.bottom,O=useRef(null),I=useRef(!1),k=useRef(!0),M=useRef(0),[A,D]=useState(!1),[V,P]=useState(0),R=useMemo(()=>{const o=n?e.map(e=>formatDate(n(e))):null,a=s?e.map(s):null,i=void 0===r?-1:e.findIndex(e=>t(e)===r);return e.map((t,s)=>{const r=s===e.length-1,l=null!==o&&(r||o[s]!==o[s+1]),d=null!==a&&!r&&a[s+1]===a[s]&&!l&&s!==i,u=null!==a&&s>0&&a[s-1]===a[s]&&(null===o||o[s-1]===o[s])&&s-1!==i;return{groupPosition:positionOf(d,u),day:l&&n?dayLabel(n(t),{now:x,labels:E}):null,unread:s===i}})},[e,n,s,r,t,x,E]),B=useCallback(()=>{k.current=!0,O.current?.scrollToOffset({offset:0,animated:!v}),P(0)},[v]),F=e[0],z=void 0===F?null:t(F),K=useRef(z);useEffect(()=>{const o=K.current;if(K.current=z,null===o||null===z||o===z)return;const s=e.findIndex(e=>t(e)===o);if(-1===s)return void P(0);const n=e.slice(0,s).reverse();for(const e of n){const t=c?.(e);t&&announce(t)}m&&n.some(m)?B():I.current&&P(e=>e+n.length)},[z]);const N=useCallback(e=>{k.current=e.nativeEvent.contentOffset.y<=48;const t=e.nativeEvent.contentOffset.y>160;t!==I.current&&(I.current=t,D(t),t||P(0)),g?.(e)},[g]),U=useCallback((e,t)=>{const o=t>M.current;M.current=t,o&&k.current&&O.current?.scrollToOffset({offset:0,animated:!1}),b?.(e,t)},[b]),$=useCallback(()=>{l&&!i&&a?.()},[l,i,a]),G=useCallback(({item:e,index:t})=>{const s=R[t];return _jsxs(View,{children:[s?.day?_jsx(DateSeparator,{label:s.day}):null,s?.unread?_jsx(DateSeparator,{label:E.unread,emphasis:!0}):null,o({item:e,index:t,groupPosition:s?.groupPosition??"single"})]})},[R,E.unread,o]),H=useCallback(e=>t(e),[t]),J=useCallback(e=>_jsx(KeyboardChatScrollView,{...e,inverted:!0,offset:T}),[T]),W=V>0?`${E.newMessages(V)}. ${E.jumpToLatest}`:E.jumpToLatest;return _jsxs(View,{style:[C.root,h],children:[_jsx(FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...w,ref:O,data:e,renderItem:G,keyExtractor:H,inverted:!0,onScroll:N,onContentSizeChange:U,onEndReached:a?$:void 0,ListHeaderComponent:d?_jsx(View,{children:d}):void 0,ListFooterComponent:i?_jsx(Spinner,{size:"sm",accessibilityLabel:E.loadingOlder,style:C.older}):void 0,ListEmptyComponent:u?_jsx(View,{style:C.fill,children:u}):void 0,renderScrollComponent:p?J:void 0,contentContainerStyle:[C.content,0===e.length?C.grow:null,S],testID:j}),A?_jsxs(View,{style:C.jump,pointerEvents:"box-none",children:[_jsx(View,{style:C.jumpDisc,children:_jsx(IconButton,{icon:"arrow-down",accessibilityLabel:W,variant:"ghost",tone:"neutral",onPress:B,testID:j?`${j}-jump`:void 0})}),V>0?_jsx(View,{style:C.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:_jsx(Badge,{value:V,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>StyleSheet.create({root:{flex:1},content:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm},grow:{flexGrow:1},fill:{flex:1},older:{paddingVertical:e.space.md},jump:{position:"absolute",right:e.space.md,bottom:e.space.md},jumpDisc:{borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});export default MessageList;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,Gradient,setNativeValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"});const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=tintOf(e,0,"transparent"),r=tintOf(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=forwardRef((e,t)=>{const r=useTheme(),s=useReducedMotion(),{progress:a,label:i,showPercent:o=!1,valueLabel:n,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:m,barColor:p,gradient:g,segments:f,animated:y=!0,style:h,containerStyle:b,barStyle:x,accessibilityLabel:w,labels:R,testID:A}=e;assertValidValue("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const _=useMemo(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...R}),[R]),j=l??"number"!=typeof a,v=clampProgress(a),V=useRef(createAnimatedValue(v)).current,E=useRef(createAnimatedValue(0)).current,S=useRef(createAnimatedValue(0)).current,T=useRef(0),N=useMemo(()=>buildStyles(r),[r]),O=c??r.radius.pill,D=m??r.colors["surface-disabled"],L=p??toneColor(r,d),B=useMemo(()=>g?"string"==typeof g?r.settings.gradients[g]??null:g:null,[g,r.settings.gradients]),I=useMemo(()=>glowOf(L),[L]),C=Array.isArray(f)&&f.length>0;useEffect(()=>{j||(y?Animated.timing(V,{toValue:v,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():V.setValue(v))},[y,v,V,j,r]),useEffect(()=>{if(!j)return;setNativeValue(E,0);const e=Animated.loop(Animated.timing(E,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver}));return e.start(),()=>{e.stop()}},[j,E]);const M=V.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),P=E.interpolate({inputRange:[0,1],outputRange:[-1,1]}),k=E.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=o&&!j&&!C,F=null!=i||G||null!=n,U=_jsx(View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:w??("string"==typeof i?i:void 0),accessibilityValue:j?{text:_.loading}:{min:0,max:100,now:Math.round(100*v)},testID:A,onLayout:e=>{const t=e.nativeEvent.layout.width;T.current=t,setNativeValue(S,t)},style:[N.track,{height:u,borderRadius:O,...smoothCorners,backgroundColor:D},b,h],children:C?_jsx(View,{style:[N.segments,{height:u}],children:(f??[]).map((e,t)=>_jsx(View,{style:{width:100*clampProgress(e.value)+"%",height:u,backgroundColor:e.color??toneColor(r,e.tone??"primary")}},t))}):_jsx(Animated.View,j?{style:[N.indeterminateBar,{height:u,width:s?"100%":"30%",opacity:s?k:1,transform:s?[]:[{translateX:Animated.multiply(P,S)}]},x],children:_jsx(Gradient,{gradient:I,style:StyleSheet.absoluteFill})}:{style:[N.determinateBar,{height:u,borderRadius:O,...smoothCorners,backgroundColor:B?"transparent":L,width:M,overflow:B?"hidden":void 0},x],children:B?_jsx(Gradient,{gradient:B,style:StyleSheet.absoluteFill}):null})});return F?_jsxs(View,{style:N.wrapper,children:[_jsxs(View,{style:[N.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof i||"number"==typeof i?_jsx(Text,{variant:"label",color:"primary",style:N.label,children:i}):_jsx(View,{style:N.label,children:i}),null!=n?"string"==typeof n||"number"==typeof n?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:n}):n:G?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*v)}%`}):null]}),U]}):U});ProgressBar.displayName="ProgressBar";const buildStyles=e=>StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});export{ProgressBar};export default ProgressBar;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,Gradient,setNativeValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"});const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=tintOf(e,0,"transparent"),r=tintOf(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=forwardRef((e,t)=>{const r=useTheme(),s=useReducedMotion(),{progress:i,label:n,showPercent:a=!1,valueLabel:o,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:m,barColor:g,gradient:p,segments:f,animated:h=!0,style:y,containerStyle:b,barStyle:w,accessibilityLabel:x,labels:R,testID:A}=e;assertValidValue("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const j=useMemo(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...R}),[R]),v=l??"number"!=typeof i,_=clampProgress(i),V=useRef(createAnimatedValue(_)).current,E=useRef(createAnimatedValue(0)).current,O=useRef(createAnimatedValue(0)).current,S=useRef(0),T=useMemo(()=>buildStyles(r),[r]),N=c??r.radius.pill,D=m??r.colors["surface-disabled"],B=g??toneColor(r,d),L=useMemo(()=>{if(null==p)return null;if("string"!=typeof p)return p;const e=r.settings.gradients[p];if(void 0===e){const e=Object.keys(r.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <ProgressBar> received gradient="${p}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}return e},[p,r.settings.gradients]),I=useMemo(()=>glowOf(B),[B]),P=Array.isArray(f)&&f.length>0;useEffect(()=>{v||(h?Animated.timing(V,{toValue:_,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():V.setValue(_))},[h,_,V,v,r]),useEffect(()=>{if(!v)return;setNativeValue(E,0);const e=Animated.loop(Animated.timing(E,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver}));return e.start(),()=>{e.stop()}},[v,E]);const C=V.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),M=E.interpolate({inputRange:[0,1],outputRange:[-1,1]}),k=E.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=a&&!v&&!P,F=null!=n||G||null!=o,$=_jsx(View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:x??("string"==typeof n?n:void 0),accessibilityValue:v?{text:j.loading}:{min:0,max:100,now:Math.round(100*_)},testID:A,onLayout:e=>{const t=e.nativeEvent.layout.width;S.current=t,setNativeValue(O,t)},style:[T.track,{height:u,borderRadius:N,...smoothCorners,backgroundColor:D},b,y],children:P?_jsx(View,{style:[T.segments,{height:u}],children:(f??[]).map((e,t)=>_jsx(View,{style:{width:100*clampProgress(e.value)+"%",height:u,backgroundColor:e.color??toneColor(r,e.tone??"primary")}},t))}):_jsx(Animated.View,v?{style:[T.indeterminateBar,{height:u,width:s?"100%":"30%",opacity:s?k:1,transform:s?[]:[{translateX:Animated.multiply(M,O)}]},w],children:_jsx(Gradient,{gradient:I,style:StyleSheet.absoluteFill})}:{style:[T.determinateBar,{height:u,borderRadius:N,...smoothCorners,backgroundColor:L?"transparent":B,width:C,overflow:L?"hidden":void 0},w],children:L?_jsx(Gradient,{gradient:L,style:StyleSheet.absoluteFill}):null})});return F?_jsxs(View,{style:T.wrapper,children:[_jsxs(View,{style:[T.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof n||"number"==typeof n?_jsx(Text,{variant:"label",color:"primary",style:T.label,children:n}):_jsx(View,{style:T.label,children:n}),null!=o?"string"==typeof o||"number"==typeof o?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:o}):o:G?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*_)}%`}):null]}),$]}):$});ProgressBar.displayName="ProgressBar";const buildStyles=e=>StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});export{ProgressBar};export default ProgressBar;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{applyMarkdownAction,normalizeSelection}from"./markdownActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_RICH_TEXT_EDITOR_LABELS=Object.freeze({bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",code:"Inline code",link:"Link",heading1:"Heading 1",heading2:"Heading 2",bulletList:"Bulleted list",numberedList:"Numbered list",quote:"Quote"});const ACTION_GLYPH={bold:"B",italic:"I",strikethrough:"S",code:"</>",link:"link",heading1:"H1",heading2:"H2",bulletList:"•",numberedList:"1.",quote:">"},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5;export const RichTextEditor=forwardRef((e,t)=>{const{value:o,onChangeText:i,placeholder:s,actions:l=DEFAULT_ACTIONS,disabled:r=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:d=!1,accessibilityLabel:c,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),S=useMemo(()=>u?{...DEFAULT_RICH_TEXT_EDITOR_LABELS,...u}:DEFAULT_RICH_TEXT_EDITOR_LABELS,[u]),y=o??"",[_,k]=useState({start:0,end:0}),[f,L]=useState(!1),[I,E]=useState(null),j=useCallback(e=>{k(e.nativeEvent.selection),E(null)},[]),C=useCallback(e=>{E(null),i?.(e)},[i]),H=useCallback(e=>{if(r)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:y,selection:normalizeSelection(_,y.length)},e);k(o.selection),E(o.selection),i?.(o.text)},[r,h,i,_,y]);return n?_jsx(RichTextEditorSkeleton,{actionCount:l.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:f?g.colors["focus-ring"]:g.colors.border,opacity:r?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:l.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:r,onPress:H,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:y,onChangeText:C,onSelectionChange:j,onFocus:()=>L(!0),onBlur:()=>L(!1),selection:I??void 0,editable:!r,autoFocus:d,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:c,style:[T.input,{minHeight:a},p],testID:x?`${x}-input`:void 0})]})});RichTextEditor.displayName="RichTextEditor";const ToolbarButton=({action:e,label:t,disabled:o,onPress:i,styles:s,theme:l,testID:r})=>{const n={color:o?l.colors["text-disabled"]:l.colors["text-body"]};return"bold"===e&&(n.fontWeight=l.weight.bold),"italic"===e&&(n.fontStyle="italic"),"strikethrough"===e&&(n.textDecorationLine="line-through"),_jsx(Pressable,{onPress:()=>i(e),disabled:o,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:o},"aria-disabled":o,hitSlop:4,...hitSlopMarker(4),testID:r,style:({pressed:e})=>[s.button,{backgroundColor:e?l.colors["surface-pressed"]:l.colors["bg-subtle"]}],children:_jsx(Text,{variant:"body",maxFontSizeMultiplier:Math.min(l.settings.maxFontSizeMultiplier??1.5,1.5),style:[s.buttonLabel,n],children:ACTION_GLYPH[e]})})};ToolbarButton.displayName="RichTextEditorToolbarButton";const RichTextEditorSkeleton=({actionCount:e,minHeight:t,style:o,testID:i})=>{const s=useTheme(),l=useMemo(()=>buildStyles(s),[s]),r=Array.from({length:Math.max(1,e)},(e,t)=>t);return _jsxs(View,{testID:i,style:[l.container,o],children:[_jsx(View,{style:l.toolbar,children:r.map(e=>_jsx(Skeleton,{width:34,height:30,radius:"sm"},e))}),_jsxs(View,{style:[l.skeletonBody,{minHeight:t}],children:[_jsx(Skeleton,{shape:"text",width:"94%",height:14}),_jsx(Skeleton,{shape:"text",width:"100%",height:14}),_jsx(Skeleton,{shape:"text",width:"72%",height:14})]})]})};RichTextEditorSkeleton.displayName="RichTextEditorSkeleton";const buildStyles=e=>StyleSheet.create({container:{borderWidth:e.size.border,borderColor:e.colors.border,borderRadius:e.radius.md,...smoothCorners,backgroundColor:e.colors.bg,overflow:"hidden"},toolbar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,padding:e.space.xs,borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors["border-subtle"],backgroundColor:e.colors["bg-subtle"]},button:{minWidth:34,height:30,paddingHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,alignItems:"center",justifyContent:"center"},buttonLabel:{...fontFor(e,"medium"),fontSize:e.text.sm.size},input:{...fontFor(e,"normal"),color:e.colors["text-body"],fontSize:e.text.base.size,lineHeight:1.5*e.text.base.size,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},skeletonBody:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.sm}});export default RichTextEditor;
1
+ "use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{applyMarkdownAction,normalizeSelection}from"./markdownActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_RICH_TEXT_EDITOR_LABELS=Object.freeze({bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",code:"Inline code",link:"Link",heading1:"Heading 1",heading2:"Heading 2",bulletList:"Bulleted list",numberedList:"Numbered list",quote:"Quote"});const ACTION_GLYPH={bold:"B",italic:"I",strikethrough:"S",code:"</>",link:"link",heading1:"H1",heading2:"H2",bulletList:"•",numberedList:"1.",quote:">"},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5;export const RichTextEditor=forwardRef((e,t)=>{const{value:o,onChangeText:i,placeholder:s,actions:l=DEFAULT_ACTIONS,disabled:r=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:d=!1,accessibilityLabel:c,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),S=useMemo(()=>u?{...DEFAULT_RICH_TEXT_EDITOR_LABELS,...u}:DEFAULT_RICH_TEXT_EDITOR_LABELS,[u]),y=o??"",[_,k]=useState({start:0,end:0}),[f,L]=useState(!1),[I,E]=useState(null),j=useCallback(e=>{k(e.nativeEvent.selection),E(null)},[]),C=useCallback(e=>{E(null),i?.(e)},[i]),H=useCallback(e=>{if(r)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:y,selection:normalizeSelection(_,y.length)},e);k(o.selection),E(o.selection),i?.(o.text)},[r,h,i,_,y]);return n?_jsx(RichTextEditorSkeleton,{actionCount:l.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:f?g.colors["focus-ring"]:g.colors.border,opacity:r?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:l.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:r,onPress:H,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:y,onChangeText:C,onSelectionChange:j,onFocus:()=>L(!0),onBlur:()=>L(!1),selection:I??void 0,editable:!r,autoFocus:d,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:c,style:[T.input,{minHeight:a},p],testID:x?`${x}-input`:void 0})]})});RichTextEditor.displayName="RichTextEditor";const ToolbarButton=({action:e,label:t,disabled:o,onPress:i,styles:s,theme:l,testID:r})=>{const n={color:o?l.colors["text-disabled"]:l.colors["text-body"],..."bold"===e?{fontWeight:l.weight.bold}:{},..."italic"===e?{fontStyle:"italic"}:{},..."strikethrough"===e?{textDecorationLine:"line-through"}:{}};return _jsx(Pressable,{onPress:()=>i(e),disabled:o,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:o},"aria-disabled":o,hitSlop:4,...hitSlopMarker(4),testID:r,style:({pressed:e})=>[s.button,{backgroundColor:e?l.colors["surface-pressed"]:l.colors["bg-subtle"]}],children:_jsx(Text,{variant:"body",maxFontSizeMultiplier:Math.min(l.settings.maxFontSizeMultiplier??1.5,1.5),style:[s.buttonLabel,n],children:ACTION_GLYPH[e]})})};ToolbarButton.displayName="RichTextEditorToolbarButton";const RichTextEditorSkeleton=({actionCount:e,minHeight:t,style:o,testID:i})=>{const s=useTheme(),l=useMemo(()=>buildStyles(s),[s]),r=Array.from({length:Math.max(1,e)},(e,t)=>t);return _jsxs(View,{testID:i,style:[l.container,o],children:[_jsx(View,{style:l.toolbar,children:r.map(e=>_jsx(Skeleton,{width:34,height:30,radius:"sm"},e))}),_jsxs(View,{style:[l.skeletonBody,{minHeight:t}],children:[_jsx(Skeleton,{shape:"text",width:"94%",height:14}),_jsx(Skeleton,{shape:"text",width:"100%",height:14}),_jsx(Skeleton,{shape:"text",width:"72%",height:14})]})]})};RichTextEditorSkeleton.displayName="RichTextEditorSkeleton";const buildStyles=e=>StyleSheet.create({container:{borderWidth:e.size.border,borderColor:e.colors.border,borderRadius:e.radius.md,...smoothCorners,backgroundColor:e.colors.bg,overflow:"hidden"},toolbar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,padding:e.space.xs,borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors["border-subtle"],backgroundColor:e.colors["bg-subtle"]},button:{minWidth:34,height:30,paddingHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,alignItems:"center",justifyContent:"center"},buttonLabel:{...fontFor(e,"medium"),fontSize:e.text.sm.size},input:{...fontFor(e,"normal"),color:e.colors["text-body"],fontSize:e.text.base.size,lineHeight:1.5*e.text.base.size,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},skeletonBody:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.sm}});export default RichTextEditor;
@@ -1 +1 @@
1
- "use strict";import{formatDateTime}from"@webority/mobile-core";import{forwardRef,memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SIGNATURE_PAD_LABELS=Object.freeze({pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first.",expand:"Expand",done:"Done",close:"Close"});const STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,EXPANDED_CHROME=200,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:a,fontFamily:r,width:o,height:i})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:i*BASELINE_RATIO,fontSize:typedFontSize(o,n),fontFamily:r,textAnchor:"middle",fill:a,children:n}):null,SignaturePadSurface=forwardRef((e,t)=>{const{expandable:n,initialStrokes:a,onChange:r,initialTypedName:o="",onTypedNameChange:i,defaultMode:s="draw",onModeChange:l,onEmptyChange:d,allowTyped:c=!0,signedBy:u,signedAt:p,height:m=DEFAULT_HEIGHT,maxNameLength:h=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x="selection",disabled:T=!1,style:w,testID:b}=e;assertValidValue("SignaturePad","defaultMode",e.defaultMode,["draw","type"]);const _=useTheme(),E=void 0===g&&void 0===y,A=E?_.colors["text-body"]:g??lightTheme.colors["text-body"],C=E?_.colors.surface:y??lightTheme.colors.surface,v=E?lightTheme.colors["text-body"]:A,R=E?lightTheme.colors.surface:C,I=v!==A||R!==C,j=f??defaultScriptFont(),P=useMemo(()=>({...DEFAULT_SIGNATURE_PAD_LABELS,...S}),[S]),D=useScreenReader(),k=useRef(null),L=useRef(null),[F,M]=useState(0),[G,N]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),B=useRef(G),O=useRef(G.length),H=useRef(null),V=useRef(null),[Y,$]=useState(c?s:"draw"),[z,U]=useState(o),[W,K]=useState(null),X=useRef(!1),{height:q}=useWindowDimensions(),[J,Q]=useState(!1),[Z,ee]=useState([]),te=useRef({onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d});useEffect(()=>{te.current={onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d}});const ne="draw"===Y&&!T,ae="draw"===Y?0===G.length:0===z.trim().length,re=useRef(null);useEffect(()=>{re.current!==ae&&(re.current=ae,te.current.onEmptyChange?.(ae))},[ae]);const oe=useCallback(e=>{B.current=e,N(e)},[]),ie=useCallback(()=>{K(Date.now()),te.current.onChange?.(B.current.map(e=>e.points))},[]),se=useMemo(()=>{const pan=e=>Gesture.Pan().enabled(ne).runOnJS(!0).onBegin(e=>{H.current=pointOf(e.x,e.y)}).onStart(t=>{V.current=e,O.current+=1;const n=pointOf(t.x,t.y);oe([...B.current,{id:O.current,points:[H.current??n,n]}])}).onUpdate(t=>{if(V.current!==e)return;const n=B.current[B.current.length-1];if(void 0===n)throw new Error("The stroke being drawn is missing.");const a=pointOf(t.x,t.y),r=n.points[n.points.length-1];if(void 0===r)throw new Error("A drawn stroke has no points.");distanceBetween(r,a)<.8||oe([...B.current.slice(0,-1),{...n,points:[...n.points,a]}])}).onFinalize(()=>{V.current===e&&(V.current=null,ie())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return Gesture.Race(e,t)},[ne,oe,ie]),le=useCallback(e=>{$(e),te.current.onModeChange?.(e),announce("type"===e?P.typingAnnouncement:P.drawingAnnouncement)},[P.typingAnnouncement,P.drawingAnnouncement]);useEffect(()=>{D&&c&&!X.current&&"draw"===Y&&0===B.current.length&&le("type")},[D,c,Y,le]);const de=useCallback(()=>{X.current=!0,le("draw"===Y?"type":"draw")},[Y,le]),ce=useCallback(e=>{U(e),K(Date.now()),te.current.onTypedNameChange?.(e)},[]),ue=useCallback(()=>{"type"===Y?ce(""):(oe([]),ie()),announce(P.clearedAnnouncement)},[Y,ce,oe,ie,P.clearedAnnouncement]),pe=useCallback(()=>{"draw"===Y&&0!==B.current.length&&(oe(B.current.slice(0,-1)),ie(),announce(P.undoneAnnouncement))},[Y,oe,ie,P.undoneAnnouncement]),me=useCallback(()=>{ee(B.current.map(e=>e.points)),Q(!0)},[]),he=useCallback(()=>{Q(!1)},[]),ge=useCallback(()=>{oe(Z.map(e=>(O.current+=1,{id:O.current,points:[...e]}))),ie(),Q(!1)},[Z,oe,ie]),ye=F||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(ae)return void t(new Error(P.emptyError));const n=I?L.current:k.current;if(!n)return void t(new Error("The signature pad is not on screen."));const a=Math.min(3,Math.max(1,PixelRatio.get()));n.toDataURL(n=>{try{e(writePng(n))}catch(e){t(e)}},{width:ye*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:ye,height:m,mode:Y,strokes:G.map(e=>e.points),typedName:z,ink:v,paper:R,strokeWidth:2.5,fontFamily:cssFontStack(j)}),clear:ue,undo:pe,isEmpty:()=>ae}),[ae,P.emptyError,ye,m,Y,G,z,I,v,R,j,ue,pe]);const fe=useMemo(()=>[{name:"undo",label:P.undo},{name:"clear",label:P.clear},...c?[{name:"toggleMode",label:"draw"===Y?P.typeInstead:P.drawInstead}]:[]],[P.undo,P.clear,P.typeInstead,P.drawInstead,c,Y]),Se=useCallback(e=>{if(T)return;const{actionName:t}=e.nativeEvent;"undo"===t?pe():"clear"===t?ue():"toggleMode"===t&&c&&de()},[T,pe,ue,de,c]),xe=useCallback(e=>{M(e.nativeEvent.layout.width)},[]),Te=useMemo(()=>StyleSheet.create({root:{gap:_.space.sm},pad:{height:m,borderWidth:_.size.border,borderColor:_.colors.border,borderRadius:_.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:C,opacity:T?.5:1},baseline:{position:"absolute",left:_.space.md,right:_.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:_.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:_.space.xs},expandedRoot:{flex:1,padding:_.space.md,gap:_.space.sm,backgroundColor:_.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[_,m,C,A,T]),we=z.trim(),be=p??W,Ee=u&&!ae?`Signed by ${u}${be?`, ${formatDateTime(be)}`:""}`:null,Ae="type"===Y&&we?`${P.pad}. ${we}`:P.pad;return _jsxs(View,{style:[Te.root,w],testID:b,children:[_jsx(GestureDetector,{gesture:se,children:_jsxs(View,{style:Te.pad,onLayout:xe,accessible:!0,accessibilityRole:"image",accessibilityLabel:Ae,accessibilityHint:"draw"===Y?P.padHint:void 0,accessibilityValue:{text:ae?P.empty:P.signed},accessibilityState:{disabled:T},"aria-disabled":T,accessibilityActions:fe,onAccessibilityAction:Se,children:[I?_jsxs(Svg,{ref:L,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:R}),_jsx(Marks,{mode:Y,strokes:G,name:we,color:v,fontFamily:j,width:ye,height:m})]}):null,_jsxs(Svg,{ref:k,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:C}),_jsx(Marks,{mode:Y,strokes:G,name:we,color:A,fontFamily:j,width:ye,height:m})]}),_jsx(View,{pointerEvents:"none",style:Te.baseline})]})}),"type"===Y?_jsx(Input,{label:P.typedLabel,placeholder:P.typedPlaceholder,value:z,onChangeText:ce,maxLength:h,disabled:T,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:b?`${b}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===Y?P.caption:P.typedCaption}),_jsxs(View,{style:Te.actions,children:[c?_jsx(Button,{label:"draw"===Y?P.typeInstead:P.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:de,testID:b?`${b}-mode`:void 0}):_jsx(View,{}),"draw"===Y?_jsxs(View,{style:Te.trailing,children:[G.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:P.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:pe,testID:b?`${b}-undo`:void 0}),_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:b?`${b}-clear`:void 0})]}):null,n?_jsx(Button,{label:P.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:me,testID:b?`${b}-expand`:void 0}):null]}):null,"type"===Y&&we?_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:b?`${b}-clear`:void 0}):null]}),Ee?_jsx(Text,{variant:"caption",color:"secondary",children:Ee}):null,n?_jsx(Modal,{visible:J,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:he,children:_jsxs(ExpandedRoot,{style:Te.expandedRoot,children:[_jsxs(View,{style:Te.expandedBar,children:[_jsx(Button,{label:P.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:he,testID:b?`${b}-close`:void 0}),_jsx(Button,{label:P.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:ge,testID:b?`${b}-done`:void 0})]}),J?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:Z,onChange:ee,height:Math.max(DEFAULT_HEIGHT,q-200),inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x,testID:b?`${b}-expanded`:void 0}):null]})}):null]})});SignaturePadSurface.displayName="SignaturePadSurface";const ExpandedRoot="android"===Platform.OS?GestureHandlerRootView:View,SignaturePad=forwardRef((e,t)=>_jsx(SignaturePadSurface,{...e,expandable:!0,ref:t}));SignaturePad.displayName="SignaturePad";export{SignaturePad};export default SignaturePad;
1
+ "use strict";import{formatDateTime}from"@webority/mobile-core";import{forwardRef,memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SIGNATURE_PAD_LABELS=Object.freeze({pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first.",expand:"Expand",done:"Done",close:"Close"});const STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,EXPANDED_CHROME=200,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:a,fontFamily:r,width:o,height:i})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:i*BASELINE_RATIO,fontSize:typedFontSize(o,n),fontFamily:r,textAnchor:"middle",fill:a,children:n}):null,SignaturePadSurface=forwardRef((e,t)=>{const{expandable:n,initialStrokes:a,onChange:r,initialTypedName:o="",onTypedNameChange:i,defaultMode:s="draw",onModeChange:l,onEmptyChange:d,allowTyped:c=!0,signedBy:u,signedAt:p,height:m=DEFAULT_HEIGHT,maxNameLength:h=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x="selection",disabled:T=!1,style:w,testID:b}=e;assertValidValue("SignaturePad","defaultMode",e.defaultMode,["draw","type"]);const _=useTheme(),E=void 0===g&&void 0===y,A=E?_.colors["text-body"]:g??lightTheme.colors["text-body"],C=E?_.colors.surface:y??lightTheme.colors.surface,v=E?lightTheme.colors["text-body"]:A,R=E?lightTheme.colors.surface:C,I=v!==A||R!==C,j=f??defaultScriptFont(),P=useMemo(()=>({...DEFAULT_SIGNATURE_PAD_LABELS,...S}),[S]),D=useScreenReader(),k=useRef(null),L=useRef(null),[F,M]=useState(0),[G,N]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),B=useRef(G),O=useRef(G.length),H=useRef(null),V=useRef(null),[Y,$]=useState(c?s:"draw"),[z,U]=useState(o),[W,K]=useState(null),X=useRef(!1),{height:q}=useWindowDimensions(),[J,Q]=useState(!1),[Z,ee]=useState([]),te=useRef({onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d});useEffect(()=>{te.current={onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d}});const ne="draw"===Y&&!T,ae="draw"===Y?0===G.length:0===z.trim().length,re=useRef(null);useEffect(()=>{re.current!==ae&&(re.current=ae,te.current.onEmptyChange?.(ae))},[ae]);const oe=useCallback(e=>{B.current=e,N(e)},[]),ie=useCallback(()=>{K(Date.now()),te.current.onChange?.(B.current.map(e=>e.points))},[]),se=useMemo(()=>{const pan=e=>Gesture.Pan().enabled(ne).runOnJS(!0).onBegin(e=>{H.current=pointOf(e.x,e.y)}).onStart(t=>{V.current=e,O.current+=1;const n=pointOf(t.x,t.y);oe([...B.current,{id:O.current,points:[H.current??n,n]}])}).onUpdate(t=>{if(V.current!==e)return;const n=B.current[B.current.length-1];if(void 0===n)throw new Error("The stroke being drawn is missing.");const a=pointOf(t.x,t.y),r=n.points[n.points.length-1];if(void 0===r)throw new Error("A drawn stroke has no points.");distanceBetween(r,a)<.8||oe([...B.current.slice(0,-1),{...n,points:[...n.points,a]}])}).onFinalize(()=>{V.current===e&&(V.current=null,ie())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return Gesture.Race(e,t)},[ne,oe,ie]),le=useCallback(e=>{$(e),te.current.onModeChange?.(e),announce("type"===e?P.typingAnnouncement:P.drawingAnnouncement)},[P.typingAnnouncement,P.drawingAnnouncement]);useEffect(()=>{D&&c&&!X.current&&"draw"===Y&&0===B.current.length&&le("type")},[D,c,Y,le]);const de=useCallback(()=>{X.current=!0,le("draw"===Y?"type":"draw")},[Y,le]),ce=useCallback(e=>{U(e),K(Date.now()),te.current.onTypedNameChange?.(e)},[]),ue=useCallback(()=>{"type"===Y?ce(""):(oe([]),ie()),announce(P.clearedAnnouncement)},[Y,ce,oe,ie,P.clearedAnnouncement]),pe=useCallback(()=>{"draw"===Y&&0!==B.current.length&&(oe(B.current.slice(0,-1)),ie(),announce(P.undoneAnnouncement))},[Y,oe,ie,P.undoneAnnouncement]),me=useCallback(()=>{ee(B.current.map(e=>e.points)),Q(!0)},[]),he=useCallback(()=>{Q(!1)},[]),ge=useCallback(()=>{oe(Z.map(e=>(O.current+=1,{id:O.current,points:[...e]}))),ie(),Q(!1)},[Z,oe,ie]),ye=F||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(ae)return void t(new Error(P.emptyError));const n=I?L.current:k.current;if(!n)return void t(new Error("The signature pad is not on screen."));const a=Math.min(3,Math.max(1,PixelRatio.get()));n.toDataURL(n=>{writePng(n).then(e,t)},{width:ye*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:ye,height:m,mode:Y,strokes:G.map(e=>e.points),typedName:z,ink:v,paper:R,strokeWidth:2.5,fontFamily:cssFontStack(j)}),clear:ue,undo:pe,isEmpty:()=>ae}),[ae,P.emptyError,ye,m,Y,G,z,I,v,R,j,ue,pe]);const fe=useMemo(()=>[{name:"undo",label:P.undo},{name:"clear",label:P.clear},...c?[{name:"toggleMode",label:"draw"===Y?P.typeInstead:P.drawInstead}]:[]],[P.undo,P.clear,P.typeInstead,P.drawInstead,c,Y]),Se=useCallback(e=>{if(T)return;const{actionName:t}=e.nativeEvent;"undo"===t?pe():"clear"===t?ue():"toggleMode"===t&&c&&de()},[T,pe,ue,de,c]),xe=useCallback(e=>{M(e.nativeEvent.layout.width)},[]),Te=useMemo(()=>StyleSheet.create({root:{gap:_.space.sm},pad:{height:m,borderWidth:_.size.border,borderColor:_.colors.border,borderRadius:_.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:C,opacity:T?.5:1},baseline:{position:"absolute",left:_.space.md,right:_.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:_.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:_.space.xs},expandedRoot:{flex:1,padding:_.space.md,gap:_.space.sm,backgroundColor:_.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[_,m,C,A,T]),we=z.trim(),be=p??W,Ee=u&&!ae?`Signed by ${u}${be?`, ${formatDateTime(be)}`:""}`:null,Ae="type"===Y&&we?`${P.pad}. ${we}`:P.pad;return _jsxs(View,{style:[Te.root,w],testID:b,children:[_jsx(GestureDetector,{gesture:se,children:_jsxs(View,{style:Te.pad,onLayout:xe,accessible:!0,accessibilityRole:"image",accessibilityLabel:Ae,accessibilityHint:"draw"===Y?P.padHint:void 0,accessibilityValue:{text:ae?P.empty:P.signed},accessibilityState:{disabled:T},"aria-disabled":T,accessibilityActions:fe,onAccessibilityAction:Se,children:[I?_jsxs(Svg,{ref:L,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:R}),_jsx(Marks,{mode:Y,strokes:G,name:we,color:v,fontFamily:j,width:ye,height:m})]}):null,_jsxs(Svg,{ref:k,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:C}),_jsx(Marks,{mode:Y,strokes:G,name:we,color:A,fontFamily:j,width:ye,height:m})]}),_jsx(View,{pointerEvents:"none",style:Te.baseline})]})}),"type"===Y?_jsx(Input,{label:P.typedLabel,placeholder:P.typedPlaceholder,value:z,onChangeText:ce,maxLength:h,disabled:T,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:b?`${b}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===Y?P.caption:P.typedCaption}),_jsxs(View,{style:Te.actions,children:[c?_jsx(Button,{label:"draw"===Y?P.typeInstead:P.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:de,testID:b?`${b}-mode`:void 0}):_jsx(View,{}),"draw"===Y?_jsxs(View,{style:Te.trailing,children:[G.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:P.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:pe,testID:b?`${b}-undo`:void 0}),_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:b?`${b}-clear`:void 0})]}):null,n?_jsx(Button,{label:P.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:me,testID:b?`${b}-expand`:void 0}):null]}):null,"type"===Y&&we?_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:b?`${b}-clear`:void 0}):null]}),Ee?_jsx(Text,{variant:"caption",color:"secondary",children:Ee}):null,n?_jsx(Modal,{visible:J,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:he,children:_jsxs(ExpandedRoot,{style:Te.expandedRoot,children:[_jsxs(View,{style:Te.expandedBar,children:[_jsx(Button,{label:P.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:he,testID:b?`${b}-close`:void 0}),_jsx(Button,{label:P.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:ge,testID:b?`${b}-done`:void 0})]}),J?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:Z,onChange:ee,height:Math.max(DEFAULT_HEIGHT,q-200),inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x,testID:b?`${b}-expanded`:void 0}):null]})}):null]})});SignaturePadSurface.displayName="SignaturePadSurface";const ExpandedRoot="android"===Platform.OS?GestureHandlerRootView:View,SignaturePad=forwardRef((e,t)=>_jsx(SignaturePadSurface,{...e,expandable:!0,ref:t}));SignaturePad.displayName="SignaturePad";export{SignaturePad};export default SignaturePad;
@@ -1 +1 @@
1
- "use strict";export const writePng=e=>{const{File:t,Paths:r}=require("expo-file-system"),i=new t(r.cache,`signature-${Date.now().toString(36)}.png`);return i.create({intermediates:!0,overwrite:!0}),i.write(e,{encoding:"base64"}),i.uri};
1
+ "use strict";export const writePng=async e=>{const{File:t,Paths:r}=require("expo-file-system"),i=new t(r.cache,`signature-${Date.now().toString(36)}.png`);return i.create({intermediates:!0,overwrite:!0}),await i.write(e,{encoding:"base64"}),i.uri};
@@ -1 +1 @@
1
- "use strict";export const writePng=t=>`data:image/png;base64,${t}`;
1
+ "use strict";export const writePng=async t=>`data:image/png;base64,${t}`;
@@ -1 +1 @@
1
- "use strict";import{Fragment,memo,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Platform,Pressable,StyleSheet,TextInput,View}from"react-native";import{createAnimatedValue,setNativeValue}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const WHEEL_VISIBLE_ITEMS=5;export const WHEEL_CENTER_OFFSET=Math.floor(2.5);const HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=memo(({label:e,index:t,scrollY:n,itemHeight:a,selected:r,theme:i,reducedMotion:s,onPress:l,editor:c})=>{const{opacity:o,scale:u}=useMemo(()=>{const e=Animated.subtract(Animated.divide(n,a),t);return{opacity:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),scale:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"})}},[n,a,t]),m=_jsx(Text,{variant:"h3",weight:r?"semibold":"medium",color:r?"primary":"secondary",numberOfLines:1,maxFontSizeMultiplier:1.5,style:{letterSpacing:i["letter-spacing"].normal},children:e});return _jsx(Animated.View,{style:[styles.row,{height:a},s?{opacity:o}:{opacity:o,transform:[{scale:u}]}],accessible:!1,importantForAccessibility:"no",children:c??(l?_jsx(Pressable,{focusable:!1,accessible:!1,onPress:()=>l(t),style:styles.rowPress,children:m}):m)})});export const Wheel=({label:e,items:t,selectedIndex:n,onIndexChange:a,itemHeight:r,width:i,theme:s,haptic:l,disabled:c,reducedMotion:o,typeable:u,testID:m})=>{const d="web"===Platform.OS,[b,y]=useState(null),f=useRef(!1),h=useRef(null),p=useRef(createAnimatedValue(n*r)).current,x=useRef(n*r),g=useRef(n*r),S=useRef(n),v=useRef(0),E=useRef(null),T=useRef(()=>{}),w=t.length-1;useEffect(()=>{S.current=n;const e=n*r;if(g.current===e)return;if(g.current=e,Math.abs(x.current-e)<1)return;x.current=e,d||setNativeValue(p,e);const t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[n,r,p,d]),useEffect(()=>{const e=x.current,t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[]),useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const M=useCallback((e,r)=>{if(!(e===n||e<0||e>w)){if("accessibility"===r){const e=resolveHaptic(l,"denseTick");e&&triggerHaptic(e)}if("keyboard"!==r){const n=t[e];n&&announce(n.accessibilityLabel??n.label)}a(e)}},[n,w,t,l,a]),A=useCallback(()=>{!c&&u&&(f.current=!0,y(String(t[n]?.value??"")))},[c,u,t,n]),_=useCallback(e=>{if(!f.current)return;f.current=!1,y(null);const n=e.trim();if(!/^\d+$/.test(n))return;const a=Number(n),r=t.findIndex(e=>e.value===a);r>=0&&M(r,"keyboard")},[t,M]);T.current=()=>{E.current=null;const e=Math.max(0,Math.min(w,Math.round(x.current/r))),t=e*r;Math.abs(x.current-t)>=1&&h.current?.scrollTo({y:t,animated:!o}),M(e,"scroll")};const j=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:p}}}],{useNativeDriver:!d,listener:e=>{const t=e.nativeEvent.contentOffset.y;x.current=t;const n=Math.round(t/r);if(n!==S.current&&n>=0&&n<=w){const e=Date.now();if(e-v.current>=35){const t=resolveHaptic(l,"denseTick");t&&triggerHaptic(t),v.current=e}S.current=n}d&&(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>T.current(),120))}}),[p,r,w,l,d]),C=useCallback(e=>{const t=e.nativeEvent.contentOffset.y;M(Math.max(0,Math.min(w,Math.round(t/r))),"scroll")},[M,w,r]),R=useCallback(e=>{if(c)return;const t=e.nativeEvent.actionName;"increment"===t?M(Math.min(w,n+1),"accessibility"):"decrement"===t&&M(Math.max(0,n-1),"accessibility")},[c,M,w,n]),F=useCallback(e=>{c||h.current?.scrollTo({y:e*r,animated:!o})},[c,r,o]),k=useCallback(({item:t,index:a})=>{const i=a===n,l=i&&null!==b;return _jsx(WheelRow,{label:t.label,index:a,scrollY:p,itemHeight:r,selected:i,theme:s,reducedMotion:o,onPress:i&&u?A:d?F:void 0,editor:l?_jsx(TextInput,{autoFocus:!0,selectTextOnFocus:!0,keyboardType:"number-pad",returnKeyType:"done",accessibilityLabel:e,value:b,onChangeText:y,onSubmitEditing:()=>_(b),onBlur:()=>_(b),style:{width:"100%",padding:s.space.none,textAlign:"center",fontSize:s.text.xl.size,color:s.colors["text-body"],fontWeight:s.weight.semibold,letterSpacing:s["letter-spacing"].normal}}):void 0})},[p,r,n,s,o,d,F,u,A,b,_,e]),I=useCallback((e,t)=>`${String(e.value)}-${t}`,[]),L=t[n]?t[n].accessibilityLabel??t[n].label:"",P=d?{focusable:!0,role:"spinbutton","aria-label":e,"aria-valuetext":L,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":w,"aria-disabled":c,onKeyDown:e=>{if(c)return;const t={ArrowDown:Math.min(w,n+1),PageDown:Math.min(w,n+1),ArrowUp:Math.max(0,n-1),PageUp:Math.max(0,n-1),Home:0,End:w}[e.key];void 0!==t&&(e.preventDefault?.(),M(t,"keyboard"))}}:void 0;return _jsxs(View,{style:[void 0===i?styles.columnFlex:{width:i},{height:5*r},styles.column,c?styles.disabled:null],testID:m,...P,children:[d?null:_jsx(View,{pointerEvents:"none",style:styles.a11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:e,accessibilityValue:{text:L},accessibilityState:{disabled:Boolean(c)},"aria-disabled":Boolean(c),accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:R}),_jsx(Animated.ScrollView,{ref:h,showsVerticalScrollIndicator:!1,snapToInterval:r,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEnabled:!c,nestedScrollEnabled:!0,scrollEventThrottle:16,onScroll:j,onMomentumScrollEnd:C,contentOffset:{x:0,y:n*r},contentContainerStyle:{paddingVertical:r*WHEEL_CENTER_OFFSET},style:[styles.list,{height:5*r}],importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:t.map((e,t)=>_jsx(Fragment,{children:k({item:e,index:t})},I(e,t)))})]})};const styles=StyleSheet.create({column:{overflow:"hidden"},columnFlex:{flex:1},disabled:{opacity:.5},list:{flexGrow:0},row:{alignItems:"center",justifyContent:"center"},rowPress:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",flex:1},a11yLayer:{...StyleSheet.absoluteFill,zIndex:2}});
1
+ "use strict";import{Fragment,memo,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Platform,Pressable,StyleSheet,TextInput,View}from"react-native";import{createAnimatedValue,setNativeValue}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const WHEEL_VISIBLE_ITEMS=5;export const WHEEL_CENTER_OFFSET=Math.floor(2.5);const HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=memo(({label:e,index:t,scrollY:n,itemHeight:a,selected:r,theme:i,reducedMotion:s,onPress:l,editor:c})=>{const{opacity:o,scale:u}=useMemo(()=>{const e=Animated.subtract(Animated.divide(n,a),t);return{opacity:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),scale:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"})}},[n,a,t]),m=_jsx(Text,{variant:"h3",weight:r?"semibold":"medium",color:r?"primary":"secondary",numberOfLines:1,maxFontSizeMultiplier:1.5,style:{letterSpacing:i["letter-spacing"].normal},children:e});return _jsx(Animated.View,{style:[styles.row,{height:a},s?{opacity:o}:{opacity:o,transform:[{scale:u}]}],accessible:!1,importantForAccessibility:"no",children:c??(l?_jsx(Pressable,{focusable:!1,accessible:!1,onPress:()=>l(t),style:styles.rowPress,children:m}):m)})});export const Wheel=({label:e,items:t,selectedIndex:n,onIndexChange:a,itemHeight:r,width:i,theme:s,haptic:l,disabled:c,reducedMotion:o,typeable:u,testID:m})=>{const d="web"===Platform.OS,[b,y]=useState(null),f=useRef(!1),h=useRef(null),p=useRef(createAnimatedValue(n*r)).current,x=useRef(n*r),g=useRef(n*r),S=useRef(n),v=useRef(0),E=useRef(null),T=useRef(()=>{}),w=t.length-1;useEffect(()=>{S.current=n;const e=n*r;if(g.current===e)return;if(g.current=e,Math.abs(x.current-e)<1)return;x.current=e,d||setNativeValue(p,e);const t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[n,r,p,d]),useEffect(()=>{const e=x.current,t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[]),useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const M=useCallback((e,r)=>{if(!(e===n||e<0||e>w)){if("accessibility"===r){const e=resolveHaptic(l,"denseTick");e&&triggerHaptic(e)}if("keyboard"!==r){const n=t[e];n&&announce(n.accessibilityLabel??n.label)}a(e)}},[n,w,t,l,a]),A=useCallback(()=>{!c&&u&&(f.current=!0,y(String(t[n]?.value??"")))},[c,u,t,n]),_=useCallback(e=>{if(!f.current)return;f.current=!1,y(null);const n=e.trim();if(!/^\d+$/.test(n))return;const a=Number(n),r=t.findIndex(e=>e.value===a);r>=0&&M(r,"keyboard")},[t,M]);T.current=()=>{E.current=null;const e=Math.max(0,Math.min(w,Math.round(x.current/r))),t=e*r;Math.abs(x.current-t)>=1&&h.current?.scrollTo({y:t,animated:!o}),M(e,"scroll")};const j=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:p}}}],{useNativeDriver:!d,listener:e=>{const t=e.nativeEvent.contentOffset.y;x.current=t;const n=Math.round(t/r);if(n!==S.current&&n>=0&&n<=w){const e=Date.now();if(e-v.current>=35){const t=resolveHaptic(l,"denseTick");t&&triggerHaptic(t),v.current=e}S.current=n}d&&(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>T.current(),120))}}),[p,r,w,l,d]),C=useCallback(e=>{const t=e.nativeEvent.contentOffset.y;M(Math.max(0,Math.min(w,Math.round(t/r))),"scroll")},[M,w,r]),R=useCallback(e=>{if(c)return;const t=e.nativeEvent.actionName;"increment"===t?M(Math.min(w,n+1),"accessibility"):"decrement"===t&&M(Math.max(0,n-1),"accessibility")},[c,M,w,n]),F=useCallback(e=>{c||h.current?.scrollTo({y:e*r,animated:!o})},[c,r,o]),k=useCallback(({item:t,index:a})=>{const i=a===n,l=i&&null!==b;return _jsx(WheelRow,{label:t.label,index:a,scrollY:p,itemHeight:r,selected:i,theme:s,reducedMotion:o,onPress:i&&u?A:d?F:void 0,editor:l?_jsx(TextInput,{autoFocus:!0,selectTextOnFocus:!0,keyboardType:"number-pad",returnKeyType:"done",accessibilityLabel:e,value:b,onChangeText:y,onSubmitEditing:()=>_(b),onBlur:()=>_(b),style:{width:"100%",padding:s.space.none,textAlign:"center",fontSize:s.text.xl.size,color:s.colors["text-body"],fontWeight:s.weight.semibold,letterSpacing:s["letter-spacing"].normal}}):void 0})},[p,r,n,s,o,d,F,u,A,b,_,e]),I=useCallback((e,t)=>`${String(e.value)}-${t}`,[]),L=t[n]?t[n].accessibilityLabel??t[n].label:"",P=d?{focusable:!0,role:"spinbutton","aria-label":e,"aria-valuetext":L,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":w,"aria-disabled":c,onKeyDown:e=>{if(c)return;const t={ArrowDown:Math.min(w,n+1),PageDown:Math.min(w,n+1),ArrowUp:Math.max(0,n-1),PageUp:Math.max(0,n-1),Home:0,End:w}[e.nativeEvent.key];void 0!==t&&(e.preventDefault(),M(t,"keyboard"))}}:void 0;return _jsxs(View,{style:[void 0===i?styles.columnFlex:{width:i},{height:5*r},styles.column,c?styles.disabled:null],testID:m,...P,children:[d?null:_jsx(View,{pointerEvents:"none",style:styles.a11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:e,accessibilityValue:{text:L},accessibilityState:{disabled:Boolean(c)},"aria-disabled":Boolean(c),accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:R}),_jsx(Animated.ScrollView,{ref:h,showsVerticalScrollIndicator:!1,snapToInterval:r,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEnabled:!c,nestedScrollEnabled:!0,scrollEventThrottle:16,onScroll:j,onMomentumScrollEnd:C,contentOffset:{x:0,y:n*r},contentContainerStyle:{paddingVertical:r*WHEEL_CENTER_OFFSET},style:[styles.list,{height:5*r}],importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:t.map((e,t)=>_jsx(Fragment,{children:k({item:e,index:t})},I(e,t)))})]})};const styles=StyleSheet.create({column:{overflow:"hidden"},columnFlex:{flex:1},disabled:{opacity:.5},list:{flexGrow:0},row:{alignItems:"center",justifyContent:"center"},rowPress:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",flex:1},a11yLayer:{...StyleSheet.absoluteFill,zIndex:2}});
@@ -1 +1 @@
1
- "use strict";export{PHONE_CHROME_INSETS}from"./canvasKit/index.js";export{Accordion,AccordionGroup,ALL_CALLING_CODES,AmountSlider,AnimatePresence,AppBar,AppLockOverlay,AsyncBlock,AuthedImage,Autocomplete,Avatar,AvatarGroup,authedImageCacheStats,Badge,Banner,BarChart,BottomNavigation,BottomSheet,Box,Button,buttonLabelInk,Calendar,Card,Carousel,Checkbox,Chip,ChoiceGroup,Composer,Confetti,ConfirmHost,clearAuthedImageCache,confirm,DatePicker,DateRangePicker,DateSeparator,DEFAULT_CALLING_CODES,DecimalInput,Descriptions,Dialog,Divider,Drawer,defineStatusMap,EmptyState,ErrorBoundary,FilePicker,FileViewer,FilterChipRow,FloatingActionButton,FloatingActionButtonGroup,ForceUpdateDialog,FormField,formatE164,formatFileSize,getAuthedImageCacheLimit,IconBadge,IconButton,ImageGallery,InlineSelect,Input,KeyboardAwareScrollView,KeyboardToolbar,ListItem,ListSection,LoaderOverlay,loader,Markdown,Menu,MessageBubble,MessageList,MODAL_DISMISS_GRACE_MS,Modal,NumberInput,OnboardingPager,OptionSheet,OTPInput,OTPResendRow,PagedListFooter,PermissionPrompt,PhoneNumberInput,PickerTrigger,ProfileCompletion,ProfilePicker,ProgressBar,ProgressRing,Radio,RadioDot,RadioGroup,Rating,Repeater,RichTextEditor,Row,ScannerOverlay,Screen,SearchBar,SectionHeader,SegmentedControl,Select,SignaturePad,Skeleton,SkeletonCircle,SkeletonClockProvider,SkeletonContent,SkeletonList,SkeletonProvider,SkeletonSkip,SkeletonText,Slider,SliderField,SlideToConfirm,SortableList,Spacer,Sparkline,Spinner,SquircleImage,SquircleView,Stack,StatTile,StatusBadge,Stepper,Swipeable,Switch,setAuthedImageCacheLimit,Tabs,TagInput,Text,TextInkContext,Timeline,TimePicker,Toast,ToastHost,ToastProvider,Tooltip,Tour,TypingIndicator,toast,useBottomSheet,useErrorHandler,useRecentSearches,useTextInk,useToast,WheelPicker,withErrorBoundary,ZoomableImage}from"./components/index.js";export{AppIcon}from"./components/AppIcon/index.js";export{HookFormField,useHookFormField}from"./form/index.js";export{useDebounce,useFieldChain,useReducedMotion,useRefreshControl,useScrollDirection}from"./hooks/index.js";export{NetworkStatusBanner}from"./network/index.js";export{KitThemeBridge,lightTheme,makeStyles,radiusOf,ThemeProvider,useTheme,useThemeMode}from"./theme/index.js";export{announce,isHapticsEnabled,setHapticImplementation,setHapticsEnabled,triggerHaptic}from"./utils/index.js";
1
+ "use strict";export{PHONE_CHROME_INSETS}from"./canvasKit/index.js";export{Accordion,AccordionGroup,ALL_CALLING_CODES,AmountSlider,AnimatePresence,AppBar,AppLockOverlay,AsyncBlock,AuthedImage,Autocomplete,Avatar,AvatarGroup,authedImageCacheStats,Badge,Banner,BarChart,BottomNavigation,BottomSheet,Box,Button,buttonLabelInk,Calendar,Card,Carousel,Checkbox,Chip,ChoiceGroup,Composer,Confetti,ConfirmHost,clearAuthedImageCache,confirm,DatePicker,DateRangePicker,DateSeparator,DEFAULT_CALLING_CODES,DecimalInput,Descriptions,Dialog,Divider,Drawer,defineStatusMap,EmptyState,ErrorBoundary,FilePicker,FileViewer,FilterChipRow,FloatingActionButton,FloatingActionButtonGroup,ForceUpdateDialog,FormField,formatE164,formatFileSize,getAuthedImageCacheLimit,IconBadge,IconButton,ImageGallery,InlineSelect,Input,KeyboardAwareScrollView,KeyboardToolbar,ListItem,ListSection,LoaderOverlay,loader,Markdown,Menu,MessageBubble,MessageList,MODAL_DISMISS_GRACE_MS,Modal,NumberInput,OnboardingPager,OptionSheet,OTPInput,OTPResendRow,PagedListFooter,PermissionPrompt,PhoneNumberInput,PickerTrigger,ProfileCompletion,ProfilePicker,ProgressBar,ProgressRing,Radio,RadioDot,RadioGroup,Rating,Repeater,RichTextEditor,Row,ScannerOverlay,Screen,SearchBar,SectionHeader,SegmentedControl,Select,SignaturePad,Skeleton,SkeletonCircle,SkeletonClockProvider,SkeletonContent,SkeletonList,SkeletonProvider,SkeletonSkip,SkeletonText,Slider,SliderField,SlideToConfirm,SortableList,Spacer,Sparkline,Spinner,SquircleImage,SquircleView,Stack,StatTile,StatusBadge,Stepper,Swipeable,Switch,setAuthedImageCacheLimit,Tabs,TagInput,Text,TextInkContext,Timeline,TimePicker,Toast,ToastHost,ToastProvider,Tooltip,Tour,TypingIndicator,toast,useBottomSheet,useErrorHandler,useRecentSearches,useTextInk,useToast,WheelPicker,withErrorBoundary,ZoomableImage}from"./components/index.js";export{AppIcon}from"./components/AppIcon/index.js";export{HookFormField,useHookFormField}from"./form/index.js";export{useDebounce,useFieldChain,useReducedMotion,useRefreshControl,useScrollDirection}from"./hooks/index.js";export{NetworkStatusBanner}from"./network/index.js";export{fontFor,KitThemeBridge,lightTheme,makeStyles,radiusOf,ThemeProvider,useTheme,useThemeMode}from"./theme/index.js";export{announce,isHapticsEnabled,setHapticImplementation,setHapticsEnabled,triggerHaptic}from"./utils/index.js";
@@ -1 +1 @@
1
- "use strict";import{View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_START={x:.5,y:0},DEFAULT_END={x:.5,y:1},round=t=>Math.round(1e3*t)/1e3;export const gradientAngle=(t=DEFAULT_START,o=DEFAULT_END)=>{const r=180*Math.atan2(o.x-t.x,t.y-o.y)/Math.PI;return round((r%360+360)%360)};export const toBackgroundImage=t=>({type:"linear-gradient",direction:`${gradientAngle(t.start,t.end)}deg`,colorStops:t.colors.map((o,r)=>{const e=t.locations?.[r];return void 0===e?{color:o}:{color:o,positions:[`${round(100*e)}%`]}})});export const Gradient=({gradient:t,style:o,children:r})=>_jsx(View,{style:[{experimental_backgroundImage:[toBackgroundImage(t)]},o],children:r});
1
+ "use strict";import{View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_START={x:.5,y:0},DEFAULT_END={x:.5,y:1},round=t=>Math.round(1e3*t)/1e3;export const gradientAngle=(t=DEFAULT_START,r=DEFAULT_END)=>{const e=180*Math.atan2(r.x-t.x,t.y-r.y)/Math.PI;return round((e%360+360)%360)};export const toBackgroundImage=t=>{const r=t.colors.length-1;return{type:"linear-gradient",direction:`${gradientAngle(t.start,t.end)}deg`,colorStops:t.colors.map((e,o)=>{const n=t.locations?.[o]??(0===r?0:o/r);return{color:e,positions:[`${round(100*n)}%`]}})}};export const Gradient=({gradient:t,style:r,children:e})=>_jsx(View,{style:[{experimental_backgroundImage:[toBackgroundImage(t)]},r],children:e});
@@ -1,5 +1,4 @@
1
1
  import { type ReactNode } from "react";
2
- import { View } from "react-native";
3
2
  import type { ColorMode } from "../theme/types";
4
3
  export type PhoneChromeOs = "Ios" | "Android";
5
4
  export declare const PHONE_CHROME_INSETS: {
@@ -22,29 +21,39 @@ export interface StatusBarProps {
22
21
  /** Battery level in percent, 0 to 100. */
23
22
  battery?: number;
24
23
  }
25
- export declare const StatusBar: ({ os, colorMode, time, signal, battery }: StatusBarProps) => import("react").CElement<import("react-native").ViewProps, View>;
24
+ export declare const StatusBar: ({ os, colorMode, time, signal, battery }: StatusBarProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
25
+ ref?: React.Ref<import("react-native").ViewInstance> | undefined;
26
+ }>;
26
27
  export interface HomeIndicatorProps {
27
28
  os: PhoneChromeOs;
28
29
  colorMode?: ColorMode;
29
30
  }
30
- export declare const HomeIndicator: ({ os, colorMode }: HomeIndicatorProps) => import("react").CElement<import("react-native").ViewProps, View>;
31
+ export declare const HomeIndicator: ({ os, colorMode }: HomeIndicatorProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
32
+ ref?: React.Ref<import("react-native").ViewInstance> | undefined;
33
+ }>;
31
34
  export interface NavigationBarProps {
32
35
  os: PhoneChromeOs;
33
36
  colorMode?: ColorMode;
34
37
  }
35
- export declare const NavigationBar: ({ os, colorMode }: NavigationBarProps) => import("react").CElement<import("react-native").ViewProps, View> | null;
38
+ export declare const NavigationBar: ({ os, colorMode }: NavigationBarProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
39
+ ref?: React.Ref<import("react-native").ViewInstance> | undefined;
40
+ }> | null;
36
41
  export interface SafeAreaProps {
37
42
  os: PhoneChromeOs;
38
43
  children?: ReactNode;
39
44
  }
40
- export declare const SafeArea: ({ os, children }: SafeAreaProps) => import("react").CElement<import("react-native").ViewProps, View>;
45
+ export declare const SafeArea: ({ os, children }: SafeAreaProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
46
+ ref?: React.Ref<import("react-native").ViewInstance> | undefined;
47
+ }>;
41
48
  export type KeyboardPreviewOs = "ios" | "android";
42
49
  export interface KeyboardFrameProps {
43
50
  colorMode?: ColorMode;
44
51
  previewOs?: KeyboardPreviewOs;
45
52
  children?: ReactNode;
46
53
  }
47
- export declare const KeyboardFrame: ({ colorMode, previewOs, children }: KeyboardFrameProps) => import("react").CElement<import("react-native").ViewProps, View>;
54
+ export declare const KeyboardFrame: ({ colorMode, previewOs, children }: KeyboardFrameProps) => import("react").FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
55
+ ref?: React.Ref<import("react-native").ViewInstance> | undefined;
56
+ }>;
48
57
  export interface PhoneChromeManifestProp {
49
58
  name: string;
50
59
  type: "enum" | "string" | "number";
@@ -1,5 +1,6 @@
1
1
  import { type NumberGrouping } from "@webority/mobile-core";
2
- import type { View as RNView, StyleProp, TextStyle, ViewStyle } from "react-native";
2
+ import { type ForwardRefExoticComponent, type RefAttributes } from "react";
3
+ import type { HostInstance, StyleProp, TextStyle, ViewStyle } from "react-native";
3
4
  import type { HapticType } from "../../utils";
4
5
  import type { SliderSize, SliderTone, SliderVariant } from "../Slider";
5
6
  export interface AmountSliderLabels {
@@ -61,7 +62,7 @@ interface Scaled {
61
62
  type ScaleUnits = Exclude<NumberGrouping, "none">;
62
63
  /** Splits a value into the number and unit the header shows. */
63
64
  export declare const scaleAmount: (value: number, units: ScaleUnits, labels?: AmountSliderLabels) => Scaled;
64
- declare const AmountSlider: import("react").ForwardRefExoticComponent<AmountSliderProps & import("react").RefAttributes<RNView>>;
65
+ declare const AmountSlider: ForwardRefExoticComponent<AmountSliderProps & RefAttributes<HostInstance>>;
65
66
  export { AmountSlider };
66
67
  export default AmountSlider;
67
68
  //# sourceMappingURL=AmountSlider.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import type React from "react";
2
- import type { View as RNView, StyleProp, ViewStyle } from "react-native";
2
+ import type { HostInstance, StyleProp, ViewStyle } from "react-native";
3
3
  import { Animated } from "react-native";
4
4
  import type { HapticType } from "../../utils/hapticUtils";
5
5
  import type { MenuItem } from "../Menu";
@@ -128,7 +128,7 @@ export interface AppBarProps {
128
128
  haptic?: HapticType | false;
129
129
  testID?: string;
130
130
  }
131
- declare const AppBar: React.ForwardRefExoticComponent<AppBarProps & React.RefAttributes<RNView>>;
131
+ declare const AppBar: React.ForwardRefExoticComponent<AppBarProps & React.RefAttributes<HostInstance>>;
132
132
  export { AppBar };
133
133
  export default AppBar;
134
134
  //# sourceMappingURL=AppBar.d.ts.map
@@ -1,4 +1,4 @@
1
- export declare const writeImage: (fileName: string, bytes: Uint8Array<ArrayBuffer>, _contentType: string) => string;
1
+ export declare const writeImage: (fileName: string, bytes: Uint8Array<ArrayBuffer>, _contentType: string) => Promise<string>;
2
2
  export declare const imageUri: (fileName: string) => string;
3
3
  export declare const imageExists: (fileName: string) => boolean;
4
4
  export declare const deleteImage: (fileName: string) => void;
@@ -1,4 +1,4 @@
1
- export declare const writeImage: (fileName: string, bytes: Uint8Array<ArrayBuffer>, contentType: string) => string;
1
+ export declare const writeImage: (fileName: string, bytes: Uint8Array<ArrayBuffer>, contentType: string) => Promise<string>;
2
2
  export declare const imageUri: (fileName: string) => string;
3
3
  export declare const imageExists: (fileName: string) => boolean;
4
4
  export declare const deleteImage: (fileName: string) => void;
@@ -1,6 +1,6 @@
1
1
  import type { DownloadHttpClient } from "@webority/mobile-core/download";
2
2
  import type React from "react";
3
- import type { GestureResponderEvent, ImageSourcePropType, ImageStyle, PressableProps, View as RNView, StyleProp, TextStyle, ViewStyle } from "react-native";
3
+ import type { GestureResponderEvent, HostInstance, ImageSourcePropType, ImageStyle, PressableProps, StyleProp, TextStyle, ViewStyle } from "react-native";
4
4
  import type { RadiusName } from "../../theme/tokens.generated";
5
5
  import type { Theme } from "../../theme/types";
6
6
  import type { Size, Tone } from "../../types/vocabulary";
@@ -139,7 +139,7 @@ export interface AvatarProps {
139
139
  labels?: Partial<AvatarLabels>;
140
140
  testID?: string;
141
141
  }
142
- declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<RNView>> & {
142
+ declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HostInstance>> & {
143
143
  Skeleton: React.FC<AvatarProps>;
144
144
  };
145
145
  export type AvatarGroupSpacing = "tight" | "normal" | "loose";
@@ -1,5 +1,5 @@
1
1
  import type React from "react";
2
- import type { View as RNView, StyleProp, TextStyle, ViewStyle } from "react-native";
2
+ import type { HostInstance, StyleProp, TextStyle, ViewStyle } from "react-native";
3
3
  import type { Size, Tone } from "../../types/vocabulary";
4
4
  export type BadgeVariant = "standard" | "dot";
5
5
  export type BadgeTone = Tone;
@@ -38,7 +38,7 @@ export interface BadgeProps {
38
38
  textStyle?: StyleProp<TextStyle>;
39
39
  testID?: string;
40
40
  }
41
- declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<RNView>> & {
41
+ declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HostInstance>> & {
42
42
  Skeleton: React.FC<BadgeProps>;
43
43
  };
44
44
  export { Badge };
@@ -1,5 +1,5 @@
1
1
  import type React from "react";
2
- import type { View as RNView, StyleProp, ViewStyle } from "react-native";
2
+ import type { HostInstance, StyleProp, ViewStyle } from "react-native";
3
3
  import type { FillVariant, Size, Tone } from "../../types/vocabulary";
4
4
  import type { HapticType } from "../../utils/hapticUtils";
5
5
  import type { SlotIcon } from "../AppIcon/slotIcon";
@@ -87,7 +87,7 @@ export interface BannerProps {
87
87
  actionButtonStyle?: StyleProp<ViewStyle>;
88
88
  testID?: string;
89
89
  }
90
- declare const Banner: React.ForwardRefExoticComponent<BannerProps & React.RefAttributes<RNView>> & {
90
+ declare const Banner: React.ForwardRefExoticComponent<BannerProps & React.RefAttributes<HostInstance>> & {
91
91
  Skeleton: React.FC<BannerProps>;
92
92
  };
93
93
  export { Banner };
@@ -19,7 +19,7 @@
19
19
  * A legend names the series, and a bar is read as its label and every series value.
20
20
  */
21
21
  import type React from "react";
22
- import type { View as RNView, StyleProp, ViewStyle } from "react-native";
22
+ import type { HostInstance, StyleProp, ViewStyle } from "react-native";
23
23
  import type { Tone } from "../../types/vocabulary";
24
24
  import type { HapticType } from "../../utils";
25
25
  export type BarChartTone = Tone;
@@ -85,7 +85,7 @@ export interface BarChartProps {
85
85
  style?: StyleProp<ViewStyle>;
86
86
  testID?: string;
87
87
  }
88
- declare const BarChart: React.ForwardRefExoticComponent<BarChartProps & React.RefAttributes<RNView>>;
88
+ declare const BarChart: React.ForwardRefExoticComponent<BarChartProps & React.RefAttributes<HostInstance>>;
89
89
  export { BarChart };
90
90
  export default BarChart;
91
91
  //# sourceMappingURL=BarChart.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { View as RNView, StyleProp, TextStyle, ViewStyle } from "react-native";
2
+ import type { HostInstance, StyleProp, TextStyle, ViewStyle } from "react-native";
3
3
  import type { ScrollDirection } from "../../hooks/useScrollDirection";
4
4
  import type { ShadowName } from "../../theme/types";
5
5
  import type { HapticType } from "../../utils";
@@ -257,7 +257,7 @@ export interface BottomNavigationProps {
257
257
  labels?: Partial<BottomNavigationLabels>;
258
258
  testID?: string;
259
259
  }
260
- declare const BottomNavigation: React.ForwardRefExoticComponent<BottomNavigationProps & React.RefAttributes<RNView>>;
260
+ declare const BottomNavigation: React.ForwardRefExoticComponent<BottomNavigationProps & React.RefAttributes<HostInstance>>;
261
261
  export { BottomNavigation };
262
262
  export default BottomNavigation;
263
263
  //# sourceMappingURL=BottomNavigation.d.ts.map
@@ -12,8 +12,7 @@
12
12
  * </BottomSheet>
13
13
  */
14
14
  import type React from "react";
15
- import type { LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent, StyleProp, ViewStyle } from "react-native";
16
- import { ScrollView } from "react-native";
15
+ import type { LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent, ScrollViewInstance, StyleProp, ViewStyle } from "react-native";
17
16
  import type { DialogAction } from "../Dialog/Dialog";
18
17
  import { type ActionsLayout } from "../Dialog/OverlayActions";
19
18
  /**
@@ -94,7 +93,7 @@ export interface BottomSheetProps {
94
93
  */
95
94
  scrollable?: boolean;
96
95
  /** Ref to the inner ScrollView. Used only with `scrollable`. */
97
- scrollRef?: React.Ref<ScrollView>;
96
+ scrollRef?: React.Ref<ScrollViewInstance>;
98
97
  /** Forwarded to the inner ScrollView. Used only with `scrollable`. */
99
98
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
100
99
  /** Forwarded to the inner ScrollView. Used only with `scrollable`. */
@@ -1,5 +1,5 @@
1
1
  import type React from "react";
2
- import type { View as RNView, StyleProp, ViewProps, ViewStyle } from "react-native";
2
+ import type { HostInstance, StyleProp, ViewProps, ViewStyle } from "react-native";
3
3
  import type { RadiusName, SpaceName, Theme } from "../../theme/types";
4
4
  export type BackgroundToken = "bg" | "bg-subtle" | "bg-muted" | "surface" | "scrim" | "surface-inverse" | "primary-wash";
5
5
  export interface BoxProps extends ViewProps {
@@ -37,13 +37,13 @@ export interface BoxProps extends ViewProps {
37
37
  }
38
38
  type LayoutProps = Omit<BoxProps, "style" | "children">;
39
39
  export declare const resolveBoxStyle: (theme: Theme, p: LayoutProps) => ViewStyle;
40
- declare const Box: React.ForwardRefExoticComponent<BoxProps & React.RefAttributes<RNView>>;
40
+ declare const Box: React.ForwardRefExoticComponent<BoxProps & React.RefAttributes<HostInstance>>;
41
41
  export type StackProps = Omit<BoxProps, "direction">;
42
42
  /** Vertical flex container with token spacing between children (default gap `md`). */
43
- declare const Stack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<RNView>>;
43
+ declare const Stack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<HostInstance>>;
44
44
  export type RowProps = Omit<BoxProps, "direction">;
45
45
  /** Horizontal flex container (default `align="center"`, gap `sm`). */
46
- declare const Row: React.ForwardRefExoticComponent<RowProps & React.RefAttributes<RNView>>;
46
+ declare const Row: React.ForwardRefExoticComponent<RowProps & React.RefAttributes<HostInstance>>;
47
47
  export interface SpacerProps {
48
48
  /** Fixed spacer of this spacing token. Omit for a flexible spacer (`flex: 1`). */
49
49
  size?: SpaceName;
@@ -1,4 +1,5 @@
1
- import type { PressableProps, View as RNView, StyleProp, TextStyle, ViewStyle } from "react-native";
1
+ import { type ForwardRefExoticComponent, type RefAttributes } from "react";
2
+ import type { HostInstance, PressableProps, StyleProp, TextStyle, ViewStyle } from "react-native";
2
3
  import type { PressAnimationPreset } from "../../hooks/usePressAnimation";
3
4
  import type { GradientDefinition, Theme } from "../../theme/types";
4
5
  import type { FillVariant, Size, Tone } from "../../types/vocabulary";
@@ -86,7 +87,7 @@ export interface ButtonProps extends Omit<PressableProps, "style" | "children">
86
87
  /** Overrides the text the Button draws for its own states; a key left out keeps its default. */
87
88
  labels?: Partial<ButtonLabels>;
88
89
  }
89
- declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<RNView>>;
90
+ declare const Button: ForwardRefExoticComponent<ButtonProps & RefAttributes<HostInstance>>;
90
91
  /**
91
92
  * The colour a Button draws its label in, for the given variant, tone and disabled state: the same value
92
93
  * the Button itself uses, so a renderer that draws a Button's label (Canvas) never keeps its own copy of the rules.
@@ -3,7 +3,8 @@
3
3
  * days drawn as dots in a tone and read aloud with each day. DateRangePicker
4
4
  * renders this same grid inside its sheet.
5
5
  */
6
- import type { View as RNView, StyleProp, ViewStyle } from "react-native";
6
+ import type { ForwardRefExoticComponent, RefAttributes } from "react";
7
+ import type { HostInstance, StyleProp, ViewStyle } from "react-native";
7
8
  import type { SelectionMode, Tone } from "../../types/vocabulary";
8
9
  import type { HapticType } from "../../utils";
9
10
  import type { CalendarWeekStart } from "./calendarDates";
@@ -73,7 +74,7 @@ export interface CalendarProps {
73
74
  navButtonStyle?: StyleProp<ViewStyle>;
74
75
  testID?: string;
75
76
  }
76
- declare const Calendar: import("react").ForwardRefExoticComponent<CalendarProps & import("react").RefAttributes<RNView>>;
77
+ declare const Calendar: ForwardRefExoticComponent<CalendarProps & RefAttributes<HostInstance>>;
77
78
  export { Calendar };
78
79
  export default Calendar;
79
80
  //# sourceMappingURL=Calendar.d.ts.map