@webority/mobile-ui 0.164.0 → 0.165.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE.txt +1 -1
  2. package/dist/canvas-kit/kit.js +5 -5
  3. package/dist/canvas-kit/manifest.json +6 -1
  4. package/dist/canvas-kit/release.json +6 -6
  5. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  6. package/lib/commonjs/components/Banner/Banner.js +1 -1
  7. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  8. package/lib/commonjs/components/Card/Card.js +1 -1
  9. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  10. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
  11. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  12. package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
  13. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  14. package/lib/commonjs/components/Input/Input.js +1 -1
  15. package/lib/commonjs/components/MessageBubble/MessageBubble.js +1 -1
  16. package/lib/commonjs/components/Modal/Modal.js +1 -1
  17. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  18. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  19. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  20. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  21. package/lib/commonjs/components/Screen/Screen.js +1 -1
  22. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  23. package/lib/commonjs/components/Slider/Slider.js +1 -1
  24. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  25. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  26. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  27. package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
  28. package/lib/commonjs/theme/merge.js +1 -1
  29. package/lib/module/components/Avatar/Avatar.js +1 -1
  30. package/lib/module/components/Banner/Banner.js +1 -1
  31. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  32. package/lib/module/components/Card/Card.js +1 -1
  33. package/lib/module/components/Carousel/Carousel.js +1 -1
  34. package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
  35. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  36. package/lib/module/components/IconBadge/IconBadge.js +1 -1
  37. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  38. package/lib/module/components/Input/Input.js +1 -1
  39. package/lib/module/components/MessageBubble/MessageBubble.js +1 -1
  40. package/lib/module/components/Modal/Modal.js +1 -1
  41. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  42. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  43. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  44. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  45. package/lib/module/components/Screen/Screen.js +1 -1
  46. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  47. package/lib/module/components/Slider/Slider.js +1 -1
  48. package/lib/module/components/SliderField/SliderField.js +1 -1
  49. package/lib/module/components/TagInput/TagInput.js +1 -1
  50. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  51. package/lib/module/hooks/useDragToDismiss.js +1 -1
  52. package/lib/module/theme/merge.js +1 -1
  53. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +1 -0
  54. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +1 -0
  55. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +1 -0
  56. package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +1 -0
  57. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +1 -0
  58. package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +1 -0
  59. package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +1 -0
  60. package/lib/typescript/commonjs/components/Input/Input.d.ts +1 -0
  61. package/lib/typescript/commonjs/components/Menu/Menu.d.ts +1 -1
  62. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +1 -0
  63. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +1 -0
  64. package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +1 -1
  65. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -0
  66. package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +1 -0
  67. package/lib/typescript/commonjs/components/Screen/Screen.d.ts +1 -0
  68. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +1 -0
  69. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +5 -0
  70. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +1 -0
  71. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +1 -0
  72. package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +2 -0
  73. package/lib/typescript/commonjs/theme/types.d.ts +9 -3
  74. package/lib/typescript/module/components/AppBar/AppBar.d.ts +1 -0
  75. package/lib/typescript/module/components/Avatar/Avatar.d.ts +1 -0
  76. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +1 -0
  77. package/lib/typescript/module/components/Carousel/Carousel.d.ts +1 -0
  78. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +1 -0
  79. package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +1 -0
  80. package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +1 -0
  81. package/lib/typescript/module/components/Input/Input.d.ts +1 -0
  82. package/lib/typescript/module/components/Menu/Menu.d.ts +1 -1
  83. package/lib/typescript/module/components/Modal/Modal.d.ts +1 -0
  84. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +1 -0
  85. package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +1 -1
  86. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -0
  87. package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +1 -0
  88. package/lib/typescript/module/components/Screen/Screen.d.ts +1 -0
  89. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +1 -0
  90. package/lib/typescript/module/components/Slider/Slider.d.ts +5 -0
  91. package/lib/typescript/module/components/SliderField/SliderField.d.ts +1 -0
  92. package/lib/typescript/module/components/TagInput/TagInput.d.ts +1 -0
  93. package/lib/typescript/module/hooks/useDragToDismiss.d.ts +2 -0
  94. package/lib/typescript/module/theme/types.d.ts +9 -3
  95. package/package.json +9 -10
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SliderField=exports.DEFAULT_SLIDER_FIELD_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_index3=require("../AppIcon/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../IconButton/index.js"),_index5=require("../Slider/index.js"),_valueText=require("../Slider/valueText.js"),_index6=require("../Text/index.js"),_index7=require("../Tooltip/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SLIDER_FIELD_LABELS=exports.DEFAULT_SLIDER_FIELD_LABELS=Object.freeze({about:e=>`About ${e}`,decrease:"Decrease",increase:"Increase",fallbackName:"Value",low:e=>`${e} low`,high:e=>`${e} high`,current:e=>`${e} value`}),DEFAULT_INPUT_WIDTH=72,defaultFormatValue=e=>String(e),stepDecimals=e=>String(e).split(".")[1]?.length??0,ValueBox=({draft:e,error:i,disabled:t,width:a,accessibilityLabel:l,styles:s,style:r,testID:n})=>{const o=(0,_index2.useTheme)(),d=(0,_index2.resolveFieldSize)(o,"sm"),u=(0,_FieldBase.resolveFieldTextStyle)(o,{disabled:t}),c=(0,_react.useRef)(null),x=(0,_react.useCallback)(()=>{t||c.current?.focus()},[t]);return(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:"sm",focused:e.editing,disabled:t,error:i,filled:!0,width:a,onPress:x,pressFeedback:!1,paddingHorizontal:o.space.sm,gap:o.space.xs,trailing:i?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"info-circle",size:d.icon,color:o.colors["danger-text"]}):void 0,style:r,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:c,style:[s.boxInput,{color:u.color,fontSize:d.text,...u.weightStyle}],value:e.text,onChangeText:e.onChangeText,onFocus:e.onFocus,onBlur:e.onBlur,onSubmitEditing:e.onBlur,editable:!t,keyboardType:"decimal-pad",returnKeyType:"done",textAlign:"center",selectionColor:o.colors.primary,accessibilityLabel:l,accessibilityState:{disabled:t},"aria-disabled":t,testID:n})})},SliderField=exports.SliderField=(0,_react.forwardRef)((e,i)=>{const{label:t,unit:a,info:l,required:s=!1,helperText:r,error:n,min:o=0,max:d=100,step:u=1,disabled:c=!1,tone:x="primary",size:_,variant:m,haptic:b,showBubble:p=!0,showBounds:h=!0,showInput:j=!1,showStepper:y=!1,leftIcon:v,rightIcon:g,startLabel:f,endLabel:S,formatValue:I=defaultFormatValue,parseInput:F,animationDuration:T,inputWidth:V=DEFAULT_INPUT_WIDTH,labels:L,accessibilityLabel:w,style:R,labelStyle:D,boundStyle:B,sliderStyle:A,inputStyle:E,testID:z}=e;(0,_assertValidValue.assertValidValue)("SliderField","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("SliderField","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("SliderField","variant",e.variant,["default","inset","minimal","bar"]);const N=(0,_react.useMemo)(()=>({...DEFAULT_SLIDER_FIELD_LABELS,...L}),[L]),q=(0,_index2.useTheme)(),C=(0,_react.useMemo)(()=>buildStyles(q),[q]),k=T??q.motion.duration.fast,$=!0===e.range,M=!0===n||(0,_FieldBase.hasFieldText)(n),P=stepDecimals(u),U=(0,_react.useCallback)(i=>{if(!0!==e.range){if(Array.isArray(i))throw new Error("SliderField received a range value in single mode.");e.onChange?.(i)}else{if(!Array.isArray(i))throw new Error("SliderField received a single value in range mode.");e.onChange?.(i)}},[e.onChange,e.range]),[W,H]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??($?[o,d]:o),onChange:U}),[O,K]=Array.isArray(W)?W:[W,d],G=(0,_valueText.clampValue)(Math.min(O,K),o,d),J=(0,_valueText.clampValue)(Math.max(O,K),o,d),Q=(0,_valueText.useValueDraft)({value:G,min:o,max:d,step:u,format:I,parse:F,onChange:e=>H($?[Math.min(e,J),J]:e)}),X=(0,_valueText.useValueDraft)({value:J,min:o,max:d,step:u,format:I,parse:F,onChange:e=>H([G,Math.max(e,G)])}),stepBy=e=>{const i=(0,_valueText.snapValue)(G+e*u,o,d,u);i!==G&&H(i)},Y={color:c?q.colors["text-disabled"]:q.colors["text-muted"],size:(0,_index2.resolveFieldSize)(q,"md").icon,disabled:c},Z=[C.bubbleText,{color:(0,_valueText.sliderToneInk)(q,x)}],boundText=e=>(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",style:[C.bound,{color:c?q.colors["text-disabled"]:q.colors["text-muted"]},B],children:e}),ee={min:o,max:d,step:u,disabled:c,tone:x,size:_,variant:m,haptic:b,showLabel:!!p&&"always",renderLabel:p?e=>(0,_jsxRuntime.jsx)(_valueText.CountingText,{value:e,format:I,decimals:P,duration:k,style:Z,testID:z&&!$?`${z}-bubble`:void 0}):void 0,accessibilityLabel:w??t,style:A,testID:z?`${z}-slider`:void 0};return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:i,style:[C.container,R],testID:z,children:[t?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:C.labelRow,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{required:s,style:D,children:t}),a?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",style:{color:q.colors["text-subtle"]},children:a}):null,l?(0,_jsxRuntime.jsx)(_index7.Tooltip,{content:l,trigger:"press",placement:"top",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.about(t),hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:C.infoButton,children:(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"info-circle",variant:"bold",size:16,color:q.colors["text-subtle"]})})}):null]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[C.row,p?C.rowWithBubble:null],children:[v?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_index3.renderSlotIcon)(v,Y)}):null,y&&!$?(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:e=>(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"minus",size:e.size,color:e.color}),onPress:()=>stepBy(-1),accessibilityLabel:N.decrease,variant:"ghost",tone:"neutral",size:"sm",disabled:c||G<=o,haptic:b,testID:z?`${z}-minus`:void 0}):null,$&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:Q,error:M,disabled:c,width:V,accessibilityLabel:N.low(t??N.fallbackName),styles:C,style:E,testID:z?`${z}-input-low`:void 0}):h?boundText(f??I(o)):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.sliderWrap,children:$?(0,_jsxRuntime.jsx)(_index5.Slider,{...ee,range:!0,value:[G,J],onChange:H}):(0,_jsxRuntime.jsx)(_index5.Slider,{...ee,value:G,onChange:H})}),$&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:X,error:M,disabled:c,width:V,accessibilityLabel:N.high(t??N.fallbackName),styles:C,style:E,testID:z?`${z}-input-high`:void 0}):h?boundText(S??I(d)):null,y&&!$?(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:e=>(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"add",size:e.size,color:e.color}),onPress:()=>stepBy(1),accessibilityLabel:N.increase,variant:"ghost",tone:"neutral",size:"sm",disabled:c||G>=d,haptic:b,testID:z?`${z}-plus`:void 0}):null,g?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_index3.renderSlotIcon)(g,Y)}):null,!$&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:Q,error:M,disabled:c,width:V,accessibilityLabel:N.current(t??N.fallbackName),styles:C,style:E,testID:z?`${z}-input`:void 0}):null]}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{text:M?n:r,error:M})]})});SliderField.displayName="SliderField";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",gap:e.space.xs},infoButton:{marginLeft:e.space.xxs},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},rowWithBubble:{marginTop:e.space.lg},sliderWrap:{flex:1,paddingHorizontal:e.space.sm},bound:{fontVariant:["tabular-nums"]},bubbleText:{fontVariant:["tabular-nums"]},boxInput:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});var _default=exports.default=SliderField;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SliderField=exports.DEFAULT_SLIDER_FIELD_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_index3=require("../AppIcon/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../IconButton/index.js"),_index5=require("../Slider/index.js"),_valueText=require("../Slider/valueText.js"),_index6=require("../Text/index.js"),_index7=require("../Tooltip/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SLIDER_FIELD_LABELS=exports.DEFAULT_SLIDER_FIELD_LABELS=Object.freeze({about:e=>`About ${e}`,decrease:"Decrease",increase:"Increase",fallbackName:"Value",low:e=>`${e} low`,high:e=>`${e} high`,current:e=>`${e} value`}),DEFAULT_INPUT_WIDTH=72,defaultFormatValue=e=>String(e),stepDecimals=e=>String(e).split(".")[1]?.length??0,ValueBox=({draft:e,error:i,disabled:t,width:l,accessibilityLabel:a,styles:s,style:r,testID:n,fieldTestID:o})=>{const d=(0,_index2.useTheme)(),u=(0,_index2.resolveFieldSize)(d,"sm"),c=(0,_FieldBase.resolveFieldTextStyle)(d,{disabled:t}),x=(0,_react.useRef)(null),_=(0,_react.useCallback)(()=>{t||x.current?.focus()},[t]);return(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{testID:o,size:"sm",focused:e.editing,disabled:t,error:i,filled:!0,width:l,onPress:_,pressFeedback:!1,paddingHorizontal:d.space.sm,gap:d.space.xs,trailing:i?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"info-circle",size:u.icon,color:d.colors["danger-text"]}):void 0,style:r,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:x,style:[s.boxInput,{color:c.color,fontSize:u.text,...c.weightStyle}],value:e.text,onChangeText:e.onChangeText,onFocus:e.onFocus,onBlur:e.onBlur,onSubmitEditing:e.onBlur,editable:!t,keyboardType:"decimal-pad",returnKeyType:"done",textAlign:"center",selectionColor:d.colors.primary,accessibilityLabel:a,accessibilityState:{disabled:t},"aria-disabled":t,testID:n})})},SliderField=exports.SliderField=(0,_react.forwardRef)((e,i)=>{const{label:t,unit:l,info:a,required:s=!1,helperText:r,error:n,min:o=0,max:d=100,step:u=1,disabled:c=!1,tone:x="primary",size:_,variant:m,haptic:b,showBubble:p=!0,showBounds:h=!0,showInput:j=!1,showStepper:v=!1,leftIcon:y,rightIcon:f,startLabel:g,endLabel:S,formatValue:I=defaultFormatValue,parseInput:T,animationDuration:F,inputWidth:D=DEFAULT_INPUT_WIDTH,labels:V,accessibilityLabel:w,style:L,labelStyle:R,boundStyle:B,sliderStyle:A,inputStyle:E,testID:z}=e;(0,_assertValidValue.assertValidValue)("SliderField","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("SliderField","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("SliderField","variant",e.variant,["default","inset","minimal","bar"]);const N=(0,_react.useMemo)(()=>({...DEFAULT_SLIDER_FIELD_LABELS,...V}),[V]),q=(0,_index2.useTheme)(),C=(0,_react.useMemo)(()=>buildStyles(q),[q]),$=F??q.motion.duration.fast,k=!0===e.range,M=!0===n||(0,_FieldBase.hasFieldText)(n),P=stepDecimals(u),U=(0,_react.useCallback)(i=>{if(!0!==e.range){if(Array.isArray(i))throw new Error("SliderField received a range value in single mode.");e.onChange?.(i)}else{if(!Array.isArray(i))throw new Error("SliderField received a single value in range mode.");e.onChange?.(i)}},[e.onChange,e.range]),[W,H]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(k?[o,d]:o),onChange:U}),[O,K]=Array.isArray(W)?W:[W,d],G=(0,_valueText.clampValue)(Math.min(O,K),o,d),J=(0,_valueText.clampValue)(Math.max(O,K),o,d),Q=(0,_valueText.useValueDraft)({value:G,min:o,max:d,step:u,format:I,parse:T,onChange:e=>H(k?[Math.min(e,J),J]:e)}),X=(0,_valueText.useValueDraft)({value:J,min:o,max:d,step:u,format:I,parse:T,onChange:e=>H([G,Math.max(e,G)])}),stepBy=e=>{const i=(0,_valueText.snapValue)(G+e*u,o,d,u);i!==G&&H(i)},Y={color:c?q.colors["text-disabled"]:q.colors["text-muted"],size:(0,_index2.resolveFieldSize)(q,"md").icon,disabled:c},Z=[C.bubbleText,{color:(0,_valueText.sliderToneInk)(q,x)}],boundText=e=>(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",style:[C.bound,{color:c?q.colors["text-disabled"]:q.colors["text-muted"]},B],children:e}),ee={min:o,max:d,step:u,disabled:c,tone:x,size:_,variant:m,haptic:b,showLabel:!!p&&"always",renderLabel:p?e=>(0,_jsxRuntime.jsx)(_valueText.CountingText,{value:e,format:I,decimals:P,duration:$,style:Z,testID:z&&!k?`${z}-bubble`:void 0}):void 0,accessibilityLabel:w??t,style:A,testID:z?`${z}-slider`:void 0};return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:i,style:[C.container,L],testID:z,children:[t?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:C.labelRow,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{required:s,style:R,children:t}),l?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",style:{color:q.colors["text-subtle"]},children:l}):null,a?(0,_jsxRuntime.jsx)(_index7.Tooltip,{content:a,trigger:"press",placement:"top",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.about(t),hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:C.infoButton,children:(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"info-circle",variant:"bold",size:16,color:q.colors["text-subtle"]})})}):null]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[C.row,p?C.rowWithBubble:null],children:[y?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_index3.renderSlotIcon)(y,Y)}):null,v&&!k?(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:e=>(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"minus",size:e.size,color:e.color}),onPress:()=>stepBy(-1),accessibilityLabel:N.decrease,variant:"ghost",tone:"neutral",size:"sm",disabled:c||G<=o,haptic:b,testID:z?`${z}-minus`:void 0}):null,k&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:Q,error:M,disabled:c,width:D,accessibilityLabel:N.low(t??N.fallbackName),styles:C,style:E,testID:z?`${z}-input-low`:void 0,fieldTestID:z?`${z}-field-low`:void 0}):h?boundText(g??I(o)):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.sliderWrap,children:k?(0,_jsxRuntime.jsx)(_index5.Slider,{...ee,range:!0,value:[G,J],onChange:H}):(0,_jsxRuntime.jsx)(_index5.Slider,{...ee,value:G,onChange:H})}),k&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:X,error:M,disabled:c,width:D,accessibilityLabel:N.high(t??N.fallbackName),styles:C,style:E,testID:z?`${z}-input-high`:void 0,fieldTestID:z?`${z}-field-high`:void 0}):h?boundText(S??I(d)):null,v&&!k?(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:e=>(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"add",size:e.size,color:e.color}),onPress:()=>stepBy(1),accessibilityLabel:N.increase,variant:"ghost",tone:"neutral",size:"sm",disabled:c||G>=d,haptic:b,testID:z?`${z}-plus`:void 0}):null,f?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_index3.renderSlotIcon)(f,Y)}):null,!k&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:Q,error:M,disabled:c,width:D,accessibilityLabel:N.current(t??N.fallbackName),styles:C,style:E,testID:z?`${z}-input`:void 0,fieldTestID:z?`${z}-field`:void 0}):null]}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{text:M?n:r,error:M})]})});SliderField.displayName="SliderField";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",gap:e.space.xs},infoButton:{marginLeft:e.space.xxs},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},rowWithBubble:{marginTop:e.space.lg},sliderWrap:{flex:1,paddingHorizontal:e.space.sm},bound:{fontVariant:["tabular-nums"]},bubbleText:{fontVariant:["tabular-nums"]},boxInput:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});var _default=exports.default=SliderField;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.TagInput=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index4=require("../Chip/index.js"),_index5=require("../FieldBase/index.js"),_jsxRuntime=require("react/jsx-runtime");const TagInput=exports.TagInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:a,onChange:s,placeholder:r,label:n,helperText:l,error:u,required:o,disabled:d=!1,size:c="md",variant:x,maxTags:_,unique:p=!0,transform:m,separators:g=[","],haptic:h,onFocus:f,style:v,testID:b}=e;(0,_assertValidValue.assertValidValue)("TagInput","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("TagInput","variant",e.variant,["outline","filled","underline"]);const j=(0,_index2.useTheme)(),y=(0,_react.useMemo)(()=>buildStyles(j),[j]),[V,T]=(0,_index.useControllableState)({value:i,defaultValue:a??[],onChange:s}),[R,C]=(0,_react.useState)(""),[q,I]=(0,_react.useState)(!1),w=(0,_react.useRef)(null),k=(0,_react.useMemo)(()=>(0,_index3.mergeRefs)(w,t),[t]),z=(0,_react.useCallback)(()=>{d||w.current?.focus()},[d]),S="number"==typeof _&&V.length>=_,F=!0===u||(0,_index5.hasFieldText)(u),B=o&&!n&&0===V.length&&0===R.length&&Boolean(r),N=(0,_react.useCallback)(e=>{const t=m?m(e.trim()):e.trim();if(!t)return;if(S)return;if(p&&V.some(e=>e.toLowerCase()===t.toLowerCase()))return void C("");T([...V,t]),C("");const i=(0,_index3.resolveHaptic)(h,"selection");i&&(0,_index3.triggerHaptic)(i)},[S,h,T,V,m,p]),M=(0,_react.useCallback)(e=>{const t=V.filter((t,i)=>i!==e);T(t);const i=(0,_index3.resolveHaptic)(h,"selection");i&&(0,_index3.triggerHaptic)(i)},[h,T,V]),D=(0,_react.useCallback)(e=>{const t=g.find(t=>t.length>0&&e.includes(t));t?N(e.slice(0,e.indexOf(t))):C(e)},[N,g]),H=(0,_react.useCallback)(e=>{d||"Backspace"===e.nativeEvent.key&&""===R&&V.length>0&&M(V.length-1)},[d,R,M,V.length]),L=(0,_react.useMemo)(()=>V.map((e,t)=>({key:`${e}-${t}`,tag:e,index:t})),[V]),P=(0,_jsxRuntime.jsx)(_index5.FieldBase,{size:c,variant:x,focused:q,disabled:d,error:F,filled:V.length>0||R.length>0,onPress:z,pressFeedback:!1,style:v,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:y.wrap,children:[L.map(({key:e,tag:t,index:i})=>(0,_jsxRuntime.jsx)(_index4.Chip,{label:t,size:"sm",onRemove:d?void 0:()=>M(i),haptic:h},e)),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:y.inputBox,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:k,value:R,onChangeText:D,onKeyPress:H,onSubmitEditing:()=>N(R),onFocus:e=>{I(!0),f?.(e)},onBlur:()=>{I(!1),N(R)},editable:!d&&!S,placeholder:S||B?void 0:r,placeholderTextColor:j.colors["text-subtle"],submitBehavior:"submit",returnKeyType:"done",accessibilityLabel:n??r,style:[y.input,{color:j.colors["text-body"],fontSize:j.text.base.size}],testID:b?`${b}-input`:void 0}),B?(0,_jsxRuntime.jsx)(_index5.RequiredPlaceholder,{text:r??"",color:j.colors["text-subtle"],fontSize:j.text.base.size,weightStyle:(0,_index2.fontFor)(j,"normal")}):null]})]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:b,children:[n?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{size:c,required:o,children:n}):null,P,(0,_jsxRuntime.jsx)(_index5.FieldMessage,{size:c,error:F,text:F?u:l})]})});TagInput.displayName="TagInput";const buildStyles=e=>_reactNative.StyleSheet.create({wrap:{flex:1,flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,paddingVertical:e.space.xs},inputBox:{flexGrow:1,minWidth:80},input:{...(0,_index2.fontFor)(e,"normal"),padding:e.space.none}});var _default=exports.default=TagInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.TagInput=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index4=require("../Chip/index.js"),_index5=require("../FieldBase/index.js"),_jsxRuntime=require("react/jsx-runtime");const TagInput=exports.TagInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:a,onChange:s,placeholder:r,label:n,helperText:l,error:u,required:o,disabled:d=!1,size:c="md",variant:x,maxTags:_,unique:p=!0,transform:m,separators:g=[","],haptic:h,onFocus:f,style:v,testID:b}=e;(0,_assertValidValue.assertValidValue)("TagInput","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("TagInput","variant",e.variant,["outline","filled","underline"]);const j=(0,_index2.useTheme)(),y=(0,_react.useMemo)(()=>buildStyles(j),[j]),[V,T]=(0,_index.useControllableState)({value:i,defaultValue:a??[],onChange:s}),[R,C]=(0,_react.useState)(""),[I,q]=(0,_react.useState)(!1),w=(0,_react.useRef)(null),k=(0,_react.useMemo)(()=>(0,_index3.mergeRefs)(w,t),[t]),z=(0,_react.useCallback)(()=>{d||w.current?.focus()},[d]),S="number"==typeof _&&V.length>=_,F=!0===u||(0,_index5.hasFieldText)(u),B=o&&!n&&0===V.length&&0===R.length&&Boolean(r),N=(0,_react.useCallback)(e=>{const t=m?m(e.trim()):e.trim();if(!t)return;if(S)return;if(p&&V.some(e=>e.toLowerCase()===t.toLowerCase()))return void C("");T([...V,t]),C("");const i=(0,_index3.resolveHaptic)(h,"selection");i&&(0,_index3.triggerHaptic)(i)},[S,h,T,V,m,p]),D=(0,_react.useCallback)(e=>{const t=V.filter((t,i)=>i!==e);T(t);const i=(0,_index3.resolveHaptic)(h,"selection");i&&(0,_index3.triggerHaptic)(i)},[h,T,V]),M=(0,_react.useCallback)(e=>{const t=g.find(t=>t.length>0&&e.includes(t));t?N(e.slice(0,e.indexOf(t))):C(e)},[N,g]),H=(0,_react.useCallback)(e=>{d||"Backspace"===e.nativeEvent.key&&""===R&&V.length>0&&D(V.length-1)},[d,R,D,V.length]),L=(0,_react.useMemo)(()=>V.map((e,t)=>({key:`${e}-${t}`,tag:e,index:t})),[V]),P=(0,_jsxRuntime.jsx)(_index5.FieldBase,{testID:b?`${b}-field`:void 0,size:c,variant:x,focused:I,disabled:d,error:F,filled:V.length>0||R.length>0,onPress:z,pressFeedback:!1,style:v,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:y.wrap,children:[L.map(({key:e,tag:t,index:i})=>(0,_jsxRuntime.jsx)(_index4.Chip,{label:t,size:"sm",onRemove:d?void 0:()=>D(i),haptic:h},e)),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:y.inputBox,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:k,value:R,onChangeText:M,onKeyPress:H,onSubmitEditing:()=>N(R),onFocus:e=>{q(!0),f?.(e)},onBlur:()=>{q(!1),N(R)},editable:!d&&!S,placeholder:S||B?void 0:r,placeholderTextColor:j.colors["text-subtle"],submitBehavior:"submit",returnKeyType:"done",accessibilityLabel:n??r,style:[y.input,{color:j.colors["text-body"],fontSize:j.text.base.size}],testID:b?`${b}-input`:void 0}),B?(0,_jsxRuntime.jsx)(_index5.RequiredPlaceholder,{text:r??"",color:j.colors["text-subtle"],fontSize:j.text.base.size,weightStyle:(0,_index2.fontFor)(j,"normal")}):null]})]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:b,children:[n?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{size:c,required:o,children:n}):null,P,(0,_jsxRuntime.jsx)(_index5.FieldMessage,{size:c,error:F,text:F?u:l})]})});TagInput.displayName="TagInput";const buildStyles=e=>_reactNative.StyleSheet.create({wrap:{flex:1,flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,paddingVertical:e.space.xs},inputBox:{flexGrow:1,minWidth:80},input:{...(0,_index2.fontFor)(e,"normal"),padding:e.space.none}});var _default=exports.default=TagInput;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Tooltip=exports.DEFAULT_TOOLTIP_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_placement=require("../../utils/placement.js"),_focusHost=require("../Menu/focusHost.js"),_index2=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_RichTooltipBody=require("./RichTooltipBody.js"),_tooltipPosition=require("./tooltipPosition.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,a,i=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((r=i&&Object.getOwnPropertyDescriptor(e,a))&&(r.get||r.set)?i(o,a,r):o[a]=e[a]);return o}const DEFAULT_TOOLTIP_LABELS=exports.DEFAULT_TOOLTIP_LABELS=Object.freeze({close:"Close tooltip",longPressHint:"Long press for more info",fallbackName:"Tooltip"}),PRESS_AUTO_HIDE_MS=4e3,ARROW_HALF_WIDTH=4,ARROW_HEIGHT=6,ARROW_CORNER_PADDING=12,DEFAULT_MAX_WIDTH=240,RICH_MAX_WIDTH=280,MESSAGE_LINE_HEIGHT=18,EXIT_DURATION_MS=150,Tooltip=e=>{const{content:t,children:r,variant:a="plain",title:i,action:o,placement:s="auto",open:n,onOpenChange:c,hideOnContentPress:l=!0,maxWidth:u,showArrow:d=!0,accessibilityLabel:_,style:p,containerStyle:f,arrowStyle:m,messageStyle:h,labels:v,testID:g}=e;(0,_assertValidValue.assertValidValue)("Tooltip","variant",e.variant,["plain","rich"]),(0,_assertValidValue.assertValidValue)("Tooltip","placement",e.placement,["top","bottom","left","right","auto"]),(0,_assertValidValue.assertValidValue)("Tooltip","trigger",e.trigger,["longPress","press","manual"]);const b="rich"===a,R=e.trigger??(b?"press":"longPress"),x=(0,_react.useMemo)(()=>({...DEFAULT_TOOLTIP_LABELS,...v}),[v]),T=(0,_index.useTheme)(),y=(0,_usePresenceMotion.usePresenceMotion)(),A=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[S,j]=(0,_ModalSafeArea.useModalInsets)(),w=(0,_react.useMemo)(()=>({...A,top:S.top,bottom:S.bottom}),[A,S]),N=(0,_reactNative.useWindowDimensions)(),P=(0,_react.useMemo)(()=>buildStyles(T),[T]),D=T.space.sm,O=T.space.sm,L=u??(b?280:240),E="press"===R&&!b,M=(T.settings.components.tooltip?.enableScaleAnimation??!1)&&!y.reduced,V="manual"===R||"boolean"==typeof n,[H,C]=(0,_react.useState)(!1),I=V?Boolean(n):H,[q,W]=(0,_react.useState)(null),[k,B]=(0,_react.useState)({width:0,height:0}),F=(0,_react.useRef)(null),U=(0,_react.useRef)(null),z=(0,_react.useRef)(null),G=(0,_react.useRef)(null),X=(0,_react.useRef)(null),Y=(0,_react.useRef)(!1),J=(0,_react.useRef)(!1),K=(0,_react.useRef)((0,_index.createAnimatedValue)(I||!M?1:.85)).current,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:0)).current,Z=(0,_react.useRef)(null),$=(0,_react.useRef)(!1),[ee,te]=(0,_react.useState)(I),re=(0,_react.useCallback)(e=>{V||C(e),c?.(e)},[V,c]),ae=(0,_react.useCallback)(()=>{F.current&&F.current.measureInWindow((e,t,r,a)=>{W({x:e,y:t,width:r,height:a})})},[]),ie=(0,_react.useCallback)(e=>{ae(),re(!0)},[ae,re]),oe=(0,_react.useCallback)(()=>{re(!1)},[re]),se=(0,_react.useRef)(oe);se.current=oe;const ne=(0,_react.useCallback)(()=>{if(!Y.current)return;Y.current=!1;const e=X.current;X.current=null,e?e():b&&(0,_focusHost.focusHost)(U.current??F.current)},[b]);(0,_react.useEffect)(()=>{if(I)return J.current=!0,Y.current=!1,(0,_placement.claimAnchoredSurface)(()=>se.current());J.current&&(J.current=!1,Y.current=!0)},[I]),(0,_react.useEffect)(()=>{I&&te(!0)},[I]);const ce=(0,_react.useCallback)(()=>{X.current=o?.onPress??null,oe()},[o,oe]),le=(0,_react.useRef)({autoHide:E,scaleAnimates:M,presence:y,theme:T,handleHide:oe});le.current={autoHide:E,scaleAnimates:M,presence:y,theme:T,handleHide:oe},(0,_react.useEffect)(()=>{const{autoHide:e,scaleAnimates:t,presence:r,theme:a,handleHide:i}=le.current;if(!$.current)return $.current=!0,I&&(ae(),e&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{i()},4e3))),()=>{Z.current&&(clearTimeout(Z.current),Z.current=null)};let o;if(I){ae();const s=[_reactNative.Animated.timing(Q,{toValue:1,duration:r.duration("fast"),useNativeDriver:_nativeDriver.nativeDriver})];t?s.push(_reactNative.Animated.spring(K,{toValue:1,damping:a.motion.spring.snappy.damping,stiffness:a.motion.spring.snappy.stiffness,mass:a.motion.spring.snappy.mass,useNativeDriver:_nativeDriver.nativeDriver})):(0,_index.setNativeValue)(K,1),o=_reactNative.Animated.parallel(s),o.start(),e&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{i()},4e3))}else{const e=[_reactNative.Animated.timing(Q,{toValue:0,duration:r.reduced?r.duration("fast"):150,easing:_reactNative.Easing.bezier(...a.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver})];t&&e.push(_reactNative.Animated.timing(K,{toValue:.85,duration:150,easing:_reactNative.Easing.bezier(...a.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver})),o=_reactNative.Animated.parallel(e),o.start(({finished:e})=>{e&&te(!1)}),Z.current&&(clearTimeout(Z.current),Z.current=null)}return()=>{o?.stop(),Z.current&&(clearTimeout(Z.current),Z.current=null)}},[I,ae,Q,K]);const handleContentLayout=e=>{const{width:t,height:r}=e.nativeEvent.layout;t===k.width&&r===k.height||B({width:t,height:r})},ue=(0,_react.useMemo)(()=>(0,_tooltipPosition.resolveTooltipPosition)({anchor:q,size:k,placement:s,rich:b,viewport:{width:N.width,height:N.height,insets:w},maxWidth:L,gap:D,padding:O,arrowCornerPadding:12}),[q,k,s,b,N.width,N.height,w,L,D,O]),de=null!==q&&k.width>0,pe=I&&de;(0,_react.useEffect)(()=>{if(!b||!pe)return;const e="web"===_reactNative.Platform.OS?G:z,t=setTimeout(()=>(0,_focusHost.focusHost)(e.current),_focusHost.FOCUS_DELAY_MS);return()=>clearTimeout(t)},[b,pe]),(0,_react.useEffect)(()=>{!b&&pe&&"ios"===_reactNative.Platform.OS&&"string"==typeof t&&(0,_announce.announce)(t)},[b,pe,t]);const fe=r.props,me=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(fe.ref,U),[fe.ref]),he={};"longPress"!==R||fe.contextMenu?"press"===R&&(he.onPress=e=>{fe.onPress?.(e),ie(e)}):(he.onLongPress=ie,he.accessibilityHint=x.longPressHint),b&&(he.ref=me);const ve=_react.default.cloneElement(r,he),ge=_??("string"==typeof t?t:x.fallbackName),be=(0,_react.useMemo)(()=>{if(!d)return null;const e={position:"absolute",width:0,height:0,backgroundColor:"transparent",borderStyle:"solid",borderLeftWidth:4,borderRightWidth:4,borderBottomWidth:6,borderTopWidth:0,borderLeftColor:"transparent",borderRightColor:"transparent",borderTopColor:"transparent",borderBottomColor:b?T.colors.surface:T.colors["surface-inverse"]};return"top"===ue.placement?{...e,bottom:-6,left:ue.arrowOffset-4,transform:[{rotate:"180deg"}]}:"bottom"===ue.placement?{...e,top:-6,left:ue.arrowOffset-4}:"left"===ue.placement?{...e,right:-6,top:ue.arrowOffset-4,transform:[{rotate:"90deg"}]}:{...e,left:-6,top:ue.arrowOffset-4,transform:[{rotate:"-90deg"}]}},[d,ue,T,b]),Re={position:"absolute",top:ue.top,left:ue.left,maxWidth:L,opacity:I&&!de?0:Q,transform:[{scale:K}]},xe=be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[be,m],pointerEvents:"none"}):null;return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{ref:F,collapsable:!1,onLayout:ae,testID:g,children:ve}),(0,_jsxRuntime.jsxs)(_index2.Modal,{open:ee,onClose:oe,presentation:"fullScreen",bare:!0,backdropOpacity:0,backdropPressClose:l,haptic:!1,labels:{close:x.close},onInsetsChange:j,onDismissed:ne,children:[ee&&b?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{onLayout:handleContentLayout,style:[Re,f,p],children:[(0,_jsxRuntime.jsx)(_RichTooltipBody.RichTooltipBody,{title:i,content:t,action:o,onAction:ce,focusRef:z,actionRef:G,messageStyle:h}),xe]}):null,ee&&!b?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{accessibilityRole:"web"===_reactNative.Platform.OS?"tooltip":void 0,accessibilityLiveRegion:"polite",accessibilityLabel:ge,onLayout:handleContentLayout,style:[Re,f,p],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[P.tooltip,{backgroundColor:T.colors["surface-inverse"],borderRadius:T.radius.md,..._corners.smoothCorners,paddingHorizontal:T.space.md,paddingVertical:T.space.sm,...T.shadow.popover,shadowColor:T.shadow.popover.shadowColor}],children:"string"==typeof t?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",color:"inverse",style:{lineHeight:18,..._reactNative.StyleSheet.flatten(h)},children:t}):t}),xe]}):null]})]})};exports.Tooltip=Tooltip;const buildStyles=e=>_reactNative.StyleSheet.create({tooltip:{overflow:"hidden"}});var _default=exports.default=Tooltip;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Tooltip=exports.DEFAULT_TOOLTIP_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_placement=require("../../utils/placement.js"),_focusHost=require("../Menu/focusHost.js"),_index2=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_RichTooltipBody=require("./RichTooltipBody.js"),_tooltipPosition=require("./tooltipPosition.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,a,i=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((r=i&&Object.getOwnPropertyDescriptor(e,a))&&(r.get||r.set)?i(o,a,r):o[a]=e[a]);return o}const DEFAULT_TOOLTIP_LABELS=exports.DEFAULT_TOOLTIP_LABELS=Object.freeze({close:"Close tooltip",longPressHint:"Long press for more info",fallbackName:"Tooltip"}),PRESS_AUTO_HIDE_MS=4e3,ARROW_HALF_WIDTH=4,ARROW_HEIGHT=6,ARROW_CORNER_PADDING=12,DEFAULT_MAX_WIDTH=240,RICH_MAX_WIDTH=280,MESSAGE_LINE_HEIGHT=18,EXIT_DURATION_MS=150,Tooltip=e=>{const{content:t,children:r,variant:a="plain",title:i,action:o,placement:s="auto",open:n,onOpenChange:c,hideOnContentPress:l=!0,maxWidth:u,showArrow:d=!0,accessibilityLabel:_,style:p,containerStyle:f,arrowStyle:m,messageStyle:h,labels:v,testID:g}=e;(0,_assertValidValue.assertValidValue)("Tooltip","variant",e.variant,["plain","rich"]),(0,_assertValidValue.assertValidValue)("Tooltip","placement",e.placement,["top","bottom","left","right","auto"]),(0,_assertValidValue.assertValidValue)("Tooltip","trigger",e.trigger,["longPress","press","manual"]);const b="rich"===a,R=e.trigger??(b?"press":"longPress"),x=(0,_react.useMemo)(()=>({...DEFAULT_TOOLTIP_LABELS,...v}),[v]),T=(0,_index.useTheme)(),y=(0,_usePresenceMotion.usePresenceMotion)(),A=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[S,j]=(0,_ModalSafeArea.useModalInsets)(),w=(0,_react.useMemo)(()=>({...A,top:S.top,bottom:S.bottom}),[A,S]),D=(0,_reactNative.useWindowDimensions)(),N=(0,_react.useMemo)(()=>buildStyles(T),[T]),P=T.space.sm,O=T.space.sm,L=u??(b?280:240),E="press"===R&&!b,M=(T.settings.components.tooltip?.enableScaleAnimation??!1)&&!y.reduced,V="manual"===R||"boolean"==typeof n,[H,C]=(0,_react.useState)(!1),I=V?Boolean(n):H,[q,W]=(0,_react.useState)(null),[k,B]=(0,_react.useState)({width:0,height:0}),F=(0,_react.useRef)(null),U=(0,_react.useRef)(null),z=(0,_react.useRef)(null),G=(0,_react.useRef)(null),X=(0,_react.useRef)(null),Y=(0,_react.useRef)(!1),J=(0,_react.useRef)(!1),K=(0,_react.useRef)((0,_index.createAnimatedValue)(I||!M?1:.85)).current,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:0)).current,Z=(0,_react.useRef)(null),$=(0,_react.useRef)(!1),[ee,te]=(0,_react.useState)(I),re=(0,_react.useCallback)(e=>{V||C(e),c?.(e)},[V,c]),ae=(0,_react.useCallback)(()=>{F.current&&F.current.measureInWindow((e,t,r,a)=>{W({x:e,y:t,width:r,height:a})})},[]),ie=(0,_react.useCallback)(e=>{ae(),re(!0)},[ae,re]),oe=(0,_react.useCallback)(()=>{re(!1)},[re]),se=(0,_react.useRef)(oe);se.current=oe;const ne=(0,_react.useCallback)(()=>{if(!Y.current)return;Y.current=!1;const e=X.current;X.current=null,e?e():b&&(0,_focusHost.focusHost)(U.current??F.current)},[b]);(0,_react.useEffect)(()=>{if(I)return J.current=!0,Y.current=!1,(0,_placement.claimAnchoredSurface)(()=>se.current());J.current&&(J.current=!1,Y.current=!0)},[I]),(0,_react.useEffect)(()=>{I&&te(!0)},[I]);const ce=(0,_react.useCallback)(()=>{X.current=o?.onPress??null,oe()},[o,oe]),le=(0,_react.useRef)({autoHide:E,scaleAnimates:M,presence:y,theme:T,handleHide:oe});le.current={autoHide:E,scaleAnimates:M,presence:y,theme:T,handleHide:oe},(0,_react.useEffect)(()=>{const{autoHide:e,scaleAnimates:t,presence:r,theme:a,handleHide:i}=le.current;if(!$.current)return $.current=!0,I&&(ae(),e&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{i()},4e3))),()=>{Z.current&&(clearTimeout(Z.current),Z.current=null)};let o;if(I){ae();const s=[_reactNative.Animated.timing(Q,{toValue:1,duration:r.duration("fast"),useNativeDriver:_nativeDriver.nativeDriver})];t?s.push(_reactNative.Animated.spring(K,{toValue:1,damping:a.motion.spring.snappy.damping,stiffness:a.motion.spring.snappy.stiffness,mass:a.motion.spring.snappy.mass,useNativeDriver:_nativeDriver.nativeDriver})):(0,_index.setNativeValue)(K,1),o=_reactNative.Animated.parallel(s),o.start(),e&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{i()},4e3))}else{const e=[_reactNative.Animated.timing(Q,{toValue:0,duration:r.reduced?r.duration("fast"):150,easing:_reactNative.Easing.bezier(...a.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver})];t&&e.push(_reactNative.Animated.timing(K,{toValue:.85,duration:150,easing:_reactNative.Easing.bezier(...a.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver})),o=_reactNative.Animated.parallel(e),o.start(({finished:e})=>{e&&te(!1)}),Z.current&&(clearTimeout(Z.current),Z.current=null)}return()=>{o?.stop(),Z.current&&(clearTimeout(Z.current),Z.current=null)}},[I,ae,Q,K]);const handleContentLayout=e=>{const{width:t,height:r}=e.nativeEvent.layout;t===k.width&&r===k.height||B({width:t,height:r})},ue=(0,_react.useMemo)(()=>(0,_tooltipPosition.resolveTooltipPosition)({anchor:q,size:k,placement:s,rich:b,viewport:{width:D.width,height:D.height,insets:w},maxWidth:L,gap:P,padding:O,arrowCornerPadding:12}),[q,k,s,b,D.width,D.height,w,L,P,O]),de=null!==q&&k.width>0,pe=I&&de;(0,_react.useEffect)(()=>{if(!b||!pe)return;const e="web"===_reactNative.Platform.OS?G:z,t=setTimeout(()=>(0,_focusHost.focusHost)(e.current),_focusHost.FOCUS_DELAY_MS);return()=>clearTimeout(t)},[b,pe]),(0,_react.useEffect)(()=>{!b&&pe&&"ios"===_reactNative.Platform.OS&&"string"==typeof t&&(0,_announce.announce)(t)},[b,pe,t]);const fe=r.props,me=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(fe.ref,U),[fe.ref]),he={};"longPress"!==R||fe.contextMenu?"press"===R&&(he.onPress=e=>{fe.onPress?.(e),ie(e)}):(he.onLongPress=ie,he.accessibilityHint=x.longPressHint),b&&(he.ref=me);const ve=_react.default.cloneElement(r,he),ge=_??("string"==typeof t?t:x.fallbackName),be=(0,_react.useMemo)(()=>{if(!d)return null;const e={position:"absolute",width:0,height:0,backgroundColor:"transparent",borderStyle:"solid",borderLeftWidth:4,borderRightWidth:4,borderBottomWidth:6,borderTopWidth:0,borderLeftColor:"transparent",borderRightColor:"transparent",borderTopColor:"transparent",borderBottomColor:b?T.colors.surface:T.colors["surface-inverse"]};return"top"===ue.placement?{...e,bottom:-6,left:ue.arrowOffset-4,transform:[{rotate:"180deg"}]}:"bottom"===ue.placement?{...e,top:-6,left:ue.arrowOffset-4}:"left"===ue.placement?{...e,right:-6,top:ue.arrowOffset-4,transform:[{rotate:"90deg"}]}:{...e,left:-6,top:ue.arrowOffset-4,transform:[{rotate:"-90deg"}]}},[d,ue,T,b]),Re={position:"absolute",top:ue.top,left:ue.left,maxWidth:L,opacity:I&&!de?0:Q,transform:[{scale:K}]},xe=be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[be,m],pointerEvents:"none"}):null;return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{ref:F,collapsable:!1,onLayout:ae,testID:g,children:ve}),(0,_jsxRuntime.jsxs)(_index2.Modal,{open:ee,onClose:oe,presentation:"fullScreen",bare:!0,backdropOpacity:0,backdropPressClose:l,haptic:!1,labels:{close:x.close},onInsetsChange:j,onDismissed:ne,testID:g,children:[ee&&b?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{onLayout:handleContentLayout,style:[Re,f,p],children:[(0,_jsxRuntime.jsx)(_RichTooltipBody.RichTooltipBody,{title:i,content:t,action:o,onAction:ce,focusRef:z,actionRef:G,messageStyle:h}),xe]}):null,ee&&!b?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{accessibilityRole:"web"===_reactNative.Platform.OS?"tooltip":void 0,accessibilityLiveRegion:"polite",accessibilityLabel:ge,onLayout:handleContentLayout,style:[Re,f,p],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.tooltip,{backgroundColor:T.colors["surface-inverse"],borderRadius:T.radius.md,..._corners.smoothCorners,paddingHorizontal:T.space.md,paddingVertical:T.space.sm,...T.shadow.popover,shadowColor:T.shadow.popover.shadowColor}],children:"string"==typeof t?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",color:"inverse",style:{lineHeight:18,..._reactNative.StyleSheet.flatten(h)},children:t}):t}),xe]}):null]})]})};exports.Tooltip=Tooltip;const buildStyles=e=>_reactNative.StyleSheet.create({tooltip:{overflow:"hidden"}});var _default=exports.default=Tooltip;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useDragToDismiss=exports.createDragToDismissController=exports.DRAG_DISMISS_VELOCITY=exports.DRAG_DISMISS_DISTANCE=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../theme/index.js"),_nativeDriver=require("../utils/nativeDriver.js"),_usePresenceMotion=require("./usePresenceMotion.js");const DRAG_DISMISS_DISTANCE=exports.DRAG_DISMISS_DISTANCE=100,DRAG_DISMISS_VELOCITY=exports.DRAG_DISMISS_VELOCITY=.5,createDragToDismissController=({drag:e,travel:t,onDismiss:r,opacity:a},i,s)=>{const{snappy:n}=i.spring,springBack=()=>_reactNative.Animated.spring(e,{toValue:0,damping:n.damping,stiffness:n.stiffness,mass:n.mass,useNativeDriver:_nativeDriver.nativeDriver}).start(),o=!0===s?.reduced?a:void 0,c=s?.duration("default")??i.duration.default;return{move:t=>{(0,_index.setNativeValue)(e,Math.max(0,t))},release:(a,s)=>{if(a>DRAG_DISMISS_DISTANCE||s>DRAG_DISMISS_VELOCITY){if(o)return void _reactNative.Animated.timing(o,{toValue:0,duration:c,easing:_reactNative.Easing.bezier(...i.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver}).start(()=>r());_reactNative.Animated.timing(e,{toValue:"function"==typeof t?t():t,duration:i.duration.fast,easing:_reactNative.Easing.bezier(...i.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver}).start(()=>r())}else springBack()},cancel:springBack}};exports.createDragToDismissController=createDragToDismissController;const useDragToDismiss=e=>{const{drag:t,travel:r,onDismiss:a,contentAtTop:i,scrollGesture:s}=e,{motion:n}=(0,_index.useTheme)(),o=(0,_usePresenceMotion.usePresenceMotion)(),c=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,u=(0,_react.useMemo)(()=>createDragToDismissController({drag:t,travel:r,onDismiss:a,opacity:c},n,o),[t,r,a,c,n,o]),l=(0,_react.useMemo)(()=>({runOnJS:!0,activeOffsetY:6,failOffsetX:[-12,12],onUpdate:e=>u.move(e.translationY),onDeactivate:e=>u.release(e.translationY,e.velocityY/1e3),onFinalize:e=>{e.canceled&&u.cancel()}}),[u]),D=(0,_reactNativeGestureHandler.usePanGesture)(l),v=(0,_react.useMemo)(()=>{let e=0,t=!1;return{runOnJS:!0,activeOffsetY:8,failOffsetX:[-12,12],simultaneousWith:s,onBegin:()=>{e=0,t=!1},onUpdate:r=>{if(!t){if(i&&!i())return;t=!0,e=r.translationY}u.move(r.translationY-e)},onDeactivate:r=>{t&&u.release(r.translationY-e,r.velocityY/1e3)},onFinalize:e=>{e.canceled&&t&&u.cancel()}}},[u,i,s]),_=(0,_reactNativeGestureHandler.usePanGesture)(v);return(0,_react.useMemo)(()=>({handleGesture:D,sheetGesture:_,opacity:c}),[D,_,c])};exports.useDragToDismiss=useDragToDismiss;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useDragToDismiss=exports.createDragToDismissController=exports.DRAG_DISMISS_VELOCITY=exports.DRAG_DISMISS_DISTANCE=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../theme/index.js"),_nativeDriver=require("../utils/nativeDriver.js"),_usePresenceMotion=require("./usePresenceMotion.js");const DRAG_DISMISS_DISTANCE=exports.DRAG_DISMISS_DISTANCE=100,DRAG_DISMISS_VELOCITY=exports.DRAG_DISMISS_VELOCITY=.5,createDragToDismissController=({drag:e,travel:t,onDismiss:r,opacity:a},i,s)=>{const{snappy:n}=i.spring,springBack=()=>_reactNative.Animated.spring(e,{toValue:0,damping:n.damping,stiffness:n.stiffness,mass:n.mass,useNativeDriver:_nativeDriver.nativeDriver}).start(),o=!0===s?.reduced?a:void 0,c=s?.duration("default")??i.duration.default;return{move:t=>{(0,_index.setNativeValue)(e,Math.max(0,t))},release:(a,s)=>{if(a>DRAG_DISMISS_DISTANCE||s>DRAG_DISMISS_VELOCITY){if(o)return void _reactNative.Animated.timing(o,{toValue:0,duration:c,easing:_reactNative.Easing.bezier(...i.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver}).start(()=>r());_reactNative.Animated.timing(e,{toValue:"function"==typeof t?t():t,duration:i.duration.fast,easing:_reactNative.Easing.bezier(...i.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver}).start(()=>r())}else springBack()},cancel:springBack}};exports.createDragToDismissController=createDragToDismissController;const useDragToDismiss=e=>{const{drag:t,travel:r,onDismiss:a,contentAtTop:i,scrollGesture:s,testID:n}=e,{motion:o}=(0,_index.useTheme)(),c=(0,_usePresenceMotion.usePresenceMotion)(),u=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,D=(0,_react.useMemo)(()=>createDragToDismissController({drag:t,travel:r,onDismiss:a,opacity:u},o,c),[t,r,a,u,o,c]),l=(0,_react.useMemo)(()=>({runOnJS:!0,activeOffsetY:6,failOffsetX:[-12,12],testID:n?`${n}-pan`:void 0,onUpdate:e=>D.move(e.translationY),onDeactivate:e=>D.release(e.translationY,e.velocityY/1e3),onFinalize:e=>{e.canceled&&D.cancel()}}),[D,n]),v=(0,_reactNativeGestureHandler.usePanGesture)(l),_=(0,_react.useMemo)(()=>{let e=0,t=!1;return{runOnJS:!0,activeOffsetY:8,failOffsetX:[-12,12],simultaneousWith:s,onBegin:()=>{e=0,t=!1},onUpdate:r=>{if(!t){if(i&&!i())return;t=!0,e=r.translationY}D.move(r.translationY-e)},onDeactivate:r=>{t&&D.release(r.translationY-e,r.velocityY/1e3)},onFinalize:e=>{e.canceled&&t&&D.cancel()}}},[D,i,s]),d=(0,_reactNativeGestureHandler.usePanGesture)(_);return(0,_react.useMemo)(()=>({handleGesture:v,sheetGesture:d,opacity:u}),[v,d,u])};exports.useDragToDismiss=useDragToDismiss;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeBrand=void 0;var _guards=require("../utils/guards.js"),_componentSizes=require("./componentSizes.js"),_tokensGenerated=require("./tokens.generated.js"),_toneInk=require("./toneInk.js");const HINT="Run webority upgrade to rename old names.",BRAND_KEYS=["colors","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0,headerShadowOnScroll:!0}},isPlainObject=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),validateBrand=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`A brand is an object of colors, radius and font; got ${typeof e}. ${HINT}`);for(const o of Object.keys(e))if(!BRAND_KEYS.includes(o))throw new Error(`A brand sets colors, radius and font only; ${o} is not allowed (allowed: colors, radius, font). ${HINT}`);const o=e.colors;if(void 0!==o&&!isPlainObject(o))throw new Error(`A brand's colors is an object of light and dark; got ${typeof o}. ${HINT}`);if((0,_guards.isRecord)(o))for(const e of Object.keys(o)){if(!COLOR_MODES.includes(e))throw new Error(`A brand sets colours under light and dark only; ${e} is not allowed (allowed: light, dark). ${HINT}`);const t=o[e];if(void 0===t)throw new Error(`A brand's ${e} colours are missing. ${HINT}`);if(!(0,_guards.isRecord)(t))throw new Error(`A brand's ${e} colours is an object of colour names; got ${typeof t}. ${HINT}`);for(const e of Object.keys(t)){if(!(0,_guards.isOneOf)(_tokensGenerated.COLOR_NAMES,e))throw new Error(`unknown colour ${e}; allowed: ${_tokensGenerated.COLOR_NAMES.join(", ")}. ${HINT}`);if(void 0!==t[e]&&"string"!=typeof t[e])throw new Error(`colour ${e} must be a string; got ${typeof t[e]}.`)}}const t=e.radius;if(void 0!==t){if(!isPlainObject(t))throw new Error(`A brand's radius is an object of radius names; got ${typeof t}. ${HINT}`);for(const e of Object.keys(t)){const o=t[e];if(!(0,_guards.isOneOf)(_tokensGenerated.RADIUS_NAMES,e))throw new Error(`unknown radius ${e}; allowed: ${RADIUS_ALLOWED}. ${HINT}`);if(FIXED_RADII.includes(e))throw new Error(`radius ${e} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof o||!Number.isFinite(o))throw new Error(`radius ${e} must be a number; got ${typeof o}.`)}}const n=e.font;if(void 0!==n){if(!isPlainObject(n))throw new Error(`A brand's font is an object of font names; got ${typeof n}. ${HINT}`);for(const e of Object.keys(n)){if(!(0,_guards.isOneOf)(_tokensGenerated.FONT_NAMES,e))throw new Error(`unknown font ${e}; allowed: ${_tokensGenerated.FONT_NAMES.join(", ")}. ${HINT}`);const o=n[e];if(!isPlainObject(o))throw new Error(`font ${e} must be an object of weights; got ${typeof o}. ${HINT}`);for(const t of Object.keys(o)){if(!(0,_guards.isOneOf)(_tokensGenerated.WEIGHT_NAMES,t))throw new Error(`unknown font weight ${t} in font ${e}; allowed: ${_tokensGenerated.WEIGHT_NAMES.join(", ")}. ${HINT}`);const n=o[t];if("string"!=typeof n||0===n.length)throw new Error(`font ${e} weight ${t} must be a non-empty string.`)}}}},validateSettings=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`Theme settings is an object; got ${typeof e}. ${HINT}`);for(const o of Object.keys(e))if(!(0,_guards.isOneOf)(SETTINGS_KEYS,o))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${o} is not allowed. ${HINT}`);const o=e.components;if(void 0!==o){if(!isPlainObject(o))throw new Error(`Theme settings components is an object of component names; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o)){if(!(0,_guards.hasKey)(COMPONENT_SETTING_KEYS,e))throw new Error(`unknown component ${e} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}. ${HINT}`);const t=o[e];if(void 0===t)continue;if(!isPlainObject(t))throw new Error(`theme settings for ${e} is an object; got ${typeof t}. ${HINT}`);const n=COMPONENT_SETTING_KEYS[e];for(const o of Object.keys(t))if(!(o in n))throw new Error(`unknown setting ${o} for ${e}; allowed: ${Object.keys(n).join(", ")}. ${HINT}`)}}},TONES=["primary","success","warning","danger","info"],setComponentSettings=(e,o,t)=>{e[o]=t},mergeComponentSettings=(e,o,t)=>({...(0,_guards.hasKey)(e,t)?e[t]:void 0,...void 0!==o&&(0,_guards.hasKey)(o,t)?o[t]:void 0}),mergeBrand=(e,o,t)=>{validateBrand(o),validateSettings(t);const n={};for(const[t,r]of Object.entries(o?.colors?.[e.mode]??{}))void 0!==r&&(n[t]=r);const r={...e.colors,...n},colorOf=e=>{const o=r[e];if(void 0===o)throw new Error(`The theme has no colour ${e}.`);return o},s={...e.radius,...o?.radius},i={...e.font};if(void 0!==o?.font)for(const t of(0,_guards.keysOf)(o.font))i[t]={...e.font[t],...o.font[t]};const a=[colorOf("bg"),colorOf("bg-subtle"),colorOf("bg-muted")],d={};for(const o of TONES){const t="string"==typeof n[o];let r=colorOf(o);if(t||"string"==typeof n[`on-${o}`]){const e=(0,_toneInk.deriveSolidFill)(r,colorOf(`on-${o}`));e!==r&&(d[o]=e,r=e)}if(t&&"string"!=typeof n[`${o}-text`]&&(d[`${o}-text`]=(0,_toneInk.deriveToneInk)(r,a,e.mode)),"primary"===o&&(t||void 0!==d.primary)){const o=(0,_toneInk.deriveStateFills)(r,colorOf("on-primary"),{fill:e.colors.primary,hover:e.colors["primary-hover"],pressed:e.colors["primary-pressed"]});"string"!=typeof n["primary-hover"]&&(d["primary-hover"]=o.hover),"string"!=typeof n["primary-pressed"]&&(d["primary-pressed"]=o.pressed)}}const f=e.settings.components,l=t?.components,c={},u=new Set([...(0,_guards.keysOf)(f),...void 0===l?[]:(0,_guards.keysOf)(l)]);for(const e of u)setComponentSettings(c,e,mergeComponentSettings(f,l,e));const g=t?.maxFontSizeMultiplier??e.settings.maxFontSizeMultiplier,p={icons:{...e.settings.icons,...t?.icons},gradients:{...e.settings.gradients,...t?.gradients},textVariants:{...e.settings.textVariants,...t?.textVariants},components:c,...void 0===g?{}:{maxFontSizeMultiplier:g}},w={...e.colors};for(const e of _tokensGenerated.COLOR_NAMES)w[e]=d[e]??r[e];const m={...e,colors:w,radius:s,font:i,settings:p};return(0,_componentSizes.validateComponentTokens)(m),m};exports.mergeBrand=mergeBrand;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeBrand=void 0;var _guards=require("../utils/guards.js"),_componentSizes=require("./componentSizes.js"),_tokensGenerated=require("./tokens.generated.js"),_toneInk=require("./toneInk.js");const HINT="Run webority upgrade to rename old names.",BRAND_KEYS=["colors","descriptions","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0,headerShadowOnScroll:!0}},isPlainObject=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),validateBrand=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`A brand is an object of colors, radius and font; got ${typeof e}. ${HINT}`);for(const o of Object.keys(e))if(!BRAND_KEYS.includes(o))throw new Error(`A brand sets colors, descriptions, radius and font only; ${o} is not allowed (allowed: colors, descriptions, radius, font). ${HINT}`);const o=e.descriptions;if(void 0!==o){if(!isPlainObject(o))throw new Error(`A brand's descriptions is an object of colour names to a description; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o)){const t=o[e];if("string"!=typeof t||""===t)throw new Error(`description of colour ${e} must be a non-empty string.`)}}const t=e.colors;if(void 0!==t&&!isPlainObject(t))throw new Error(`A brand's colors is an object of light and dark; got ${typeof t}. ${HINT}`);if((0,_guards.isRecord)(t))for(const e of Object.keys(t)){if(!COLOR_MODES.includes(e))throw new Error(`A brand sets colours under light and dark only; ${e} is not allowed (allowed: light, dark). ${HINT}`);const r=t[e];if(void 0===r)throw new Error(`A brand's ${e} colours are missing. ${HINT}`);if(!(0,_guards.isRecord)(r))throw new Error(`A brand's ${e} colours is an object of colour names; got ${typeof r}. ${HINT}`);for(const e of Object.keys(r)){const t=(0,_guards.isRecord)(o)&&"string"==typeof o[e];if(!(0,_guards.isOneOf)(_tokensGenerated.COLOR_NAMES,e)&&!t)throw new Error(`unknown colour ${e}; allowed: ${_tokensGenerated.COLOR_NAMES.join(", ")}. ${HINT}`);if(void 0!==r[e]&&"string"!=typeof r[e])throw new Error(`colour ${e} must be a string; got ${typeof r[e]}.`)}}const r=e.radius;if(void 0!==r){if(!isPlainObject(r))throw new Error(`A brand's radius is an object of radius names; got ${typeof r}. ${HINT}`);for(const e of Object.keys(r)){const o=r[e];if(!(0,_guards.isOneOf)(_tokensGenerated.RADIUS_NAMES,e))throw new Error(`unknown radius ${e}; allowed: ${RADIUS_ALLOWED}. ${HINT}`);if(FIXED_RADII.includes(e))throw new Error(`radius ${e} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof o||!Number.isFinite(o))throw new Error(`radius ${e} must be a number; got ${typeof o}.`)}}const n=e.font;if(void 0!==n){if(!isPlainObject(n))throw new Error(`A brand's font is an object of font names; got ${typeof n}. ${HINT}`);for(const e of Object.keys(n)){if(!(0,_guards.isOneOf)(_tokensGenerated.FONT_NAMES,e))throw new Error(`unknown font ${e}; allowed: ${_tokensGenerated.FONT_NAMES.join(", ")}. ${HINT}`);const o=n[e];if(!isPlainObject(o))throw new Error(`font ${e} must be an object of weights; got ${typeof o}. ${HINT}`);for(const t of Object.keys(o)){if(!(0,_guards.isOneOf)(_tokensGenerated.WEIGHT_NAMES,t))throw new Error(`unknown font weight ${t} in font ${e}; allowed: ${_tokensGenerated.WEIGHT_NAMES.join(", ")}. ${HINT}`);const r=o[t];if("string"!=typeof r||0===r.length)throw new Error(`font ${e} weight ${t} must be a non-empty string.`)}}}},validateSettings=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`Theme settings is an object; got ${typeof e}. ${HINT}`);for(const o of Object.keys(e))if(!(0,_guards.isOneOf)(SETTINGS_KEYS,o))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${o} is not allowed. ${HINT}`);const o=e.components;if(void 0!==o){if(!isPlainObject(o))throw new Error(`Theme settings components is an object of component names; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o)){if(!(0,_guards.hasKey)(COMPONENT_SETTING_KEYS,e))throw new Error(`unknown component ${e} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}. ${HINT}`);const t=o[e];if(void 0===t)continue;if(!isPlainObject(t))throw new Error(`theme settings for ${e} is an object; got ${typeof t}. ${HINT}`);const r=COMPONENT_SETTING_KEYS[e];for(const o of Object.keys(t))if(!(o in r))throw new Error(`unknown setting ${o} for ${e}; allowed: ${Object.keys(r).join(", ")}. ${HINT}`)}}},TONES=["primary","success","warning","danger","info"],setComponentSettings=(e,o,t)=>{e[o]=t},mergeComponentSettings=(e,o,t)=>({...(0,_guards.hasKey)(e,t)?e[t]:void 0,...void 0!==o&&(0,_guards.hasKey)(o,t)?o[t]:void 0}),mergeBrand=(e,o,t)=>{validateBrand(o),validateSettings(t);const r={};for(const[t,n]of Object.entries(o?.colors?.[e.mode]??{}))void 0!==n&&(r[t]=n);const n={...e.colors,...r},colorOf=e=>{const o=n[e];if(void 0===o)throw new Error(`The theme has no colour ${e}.`);return o},s={...e.radius,...o?.radius},i={...e.font};if(void 0!==o?.font)for(const t of(0,_guards.keysOf)(o.font))i[t]={...e.font[t],...o.font[t]};const a=[colorOf("bg"),colorOf("bg-subtle"),colorOf("bg-muted")],d={};for(const o of TONES){const t="string"==typeof r[o];let n=colorOf(o);if(t||"string"==typeof r[`on-${o}`]){const e=(0,_toneInk.deriveSolidFill)(n,colorOf(`on-${o}`));e!==n&&(d[o]=e,n=e)}if(t&&"string"!=typeof r[`${o}-text`]&&(d[`${o}-text`]=(0,_toneInk.deriveToneInk)(n,a,e.mode)),"primary"===o&&(t||void 0!==d.primary)){const o=(0,_toneInk.deriveStateFills)(n,colorOf("on-primary"),{fill:e.colors.primary,hover:e.colors["primary-hover"],pressed:e.colors["primary-pressed"]});"string"!=typeof r["primary-hover"]&&(d["primary-hover"]=o.hover),"string"!=typeof r["primary-pressed"]&&(d["primary-pressed"]=o.pressed)}}const f=e.settings.components,c=t?.components,l={},u=new Set([...(0,_guards.keysOf)(f),...void 0===c?[]:(0,_guards.keysOf)(c)]);for(const e of u)setComponentSettings(l,e,mergeComponentSettings(f,c,e));const g=t?.maxFontSizeMultiplier??e.settings.maxFontSizeMultiplier,p={icons:{...e.settings.icons,...t?.icons},gradients:{...e.settings.gradients,...t?.gradients},textVariants:{...e.settings.textVariants,...t?.textVariants},components:l,...void 0===g?{}:{maxFontSizeMultiplier:g}},w={...e.colors,...Object.fromEntries(Object.entries(r).filter(([e])=>!(0,_guards.isOneOf)(_tokensGenerated.COLOR_NAMES,e))),...Object.fromEntries(_tokensGenerated.COLOR_NAMES.map(e=>[e,d[e]??colorOf(e)]))},m={...e,colors:w,radius:s,font:i,settings:p};return(0,_componentSizes.validateComponentTokens)(m),m};exports.mergeBrand=mergeBrand;
@@ -1 +1 @@
1
- "use strict";import{Image}from"expo-image";import{Children,cloneElement,forwardRef,isValidElement,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{AuthedImage}from"../AuthedImage/AuthedImage.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2;export const AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"];export const avatarToneColors=(e,t)=>{const soft=(e,t)=>tintOf(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};export const DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",rejected:"rejected",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"});const sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,o)=>{switch(t){case"circle":return r/2;case"rounded":return o?e.radius[o]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,o]=t;return void 0===r?"":void 0===o?r.charAt(0).toUpperCase():(r.charAt(0)+o.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const o=t[Math.abs(r)%t.length];if(void 0===o)throw new Error("The avatar colour palette is empty.");return o},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isImageSourceList=e=>Array.isArray(e),toExpoSource=e=>({...void 0!==e.uri?{uri:e.uri}:{},...void 0!==e.headers?{headers:e.headers}:{},...void 0!==e.width?{width:e.width}:{},...void 0!==e.height?{height:e.height}:{}}),toExpoSources=e=>"number"==typeof e?e:isImageSourceList(e)?e.map(toExpoSource):toExpoSource(e),isRingStatus=e=>"verified"===e||"pending"===e||"rejected"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":case"rejected":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},AvatarRoot=forwardRef((e,t)=>{const{source:r,ImageComponent:o,imageClient:s,name:a,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:h=null,statusPosition:g="bottomRight",tone:p,backgroundColor:b,color:v,fontSize:f,loading:y=!1,accessibilityLabel:A,onPress:x,onLongPress:S,haptic:j,hitSlop:C,style:I,textStyle:R,testID:V,labels:_}=e;assertValidValue("Avatar","size",e.size,Object.keys(sizeMap)),assertValidValue("Avatar","shape",e.shape,["circle","square","rounded"]),assertValidValue("Avatar","radius",e.radius,["sm","md","lg"]),assertValidValue("Avatar","contentFit",e.contentFit,["cover","contain"]),assertValidValue("Avatar","status",e.status,["online","offline","busy","away","verified","pending","rejected"]),assertValidValue("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),assertValidValue("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const w=useMemo(()=>_?{...DEFAULT_AVATAR_LABELS,..._}:DEFAULT_AVATAR_LABELS,[_]),M=useTheme(),[T,E]=useState(null),L=useMemo(()=>l??resolveSize(i),[l,i]),k=useMemo(()=>resolveRadius(M,n,L,c),[M,n,L,c]),z=u?M.size.border:0,O=M.colors.border,F=M.colors.surface,D=useMemo(()=>initialsFromName(a),[a]),G=useMemo(()=>p?avatarToneColors(M,p):null,[M,p]),P=useMemo(()=>b||(G?.background??M.colors[hashColor(a??"",AVATAR_COLORS)]),[b,G,a,M]),$=v??G?.color??M.colors["on-primary"],N=r?keyOfSource(r):null,B=useMemo(()=>void 0!==r?toExpoSources(r):void 0,[r]),H=null!==N&&N!==T,U=!H&&""===D&&null!=m,W=v??G?.color??M.colors["text-subtle"],q=f??Math.max(M.text.xs.size,Math.round(.4*L)),Y=Math.max(8,Math.round(.25*L)),X=isRingStatus(h),J=L-2*(X?3:z),K=X?resolveRadius(M,n,J,c):Math.max(0,k-z),Q=U?renderSlotIcon(m,{color:W,size:Math.round(.45*J),disabled:!1}):null,Z=X?statusColor(M,h):"transparent",ee=Math.max(12,Math.round(.32*L)),te=Math.max(10,ee-4),re=b??G?.background??M.colors["bg-muted"],oe=H?"contain"===d?"transparent":M.colors["bg-muted"]:U?re:P,se=V??"avatar",ae=a?w.avatarOf(a):w.avatar,ie="verified"===h?`, ${w.verified}`:"pending"===h?`, ${w.pendingVerification}`:"rejected"===h?`, ${w.rejected}`:"",ne=A??`${ae}${ie}`,le="function"==typeof x||"function"==typeof S,ce=A??`${a||ae}${ie}`,ue=Math.max(0,Math.ceil((44-L)/2)),de=C??ue,me=[styles.root,{width:L,height:L,borderRadius:k,...smoothCorners,borderWidth:X?0:z,borderColor:O,backgroundColor:X?"transparent":oe},I],he=_jsxs(_Fragment,{children:[X?_jsx(View,{style:[styles.ring,{borderRadius:k,...smoothCorners,borderWidth:1.5,borderColor:Z}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,_jsx(View,{style:[styles.picture,{width:J,height:J,borderRadius:K,...smoothCorners,borderWidth:X?z:0,borderColor:O,backgroundColor:X?oe:"transparent"}],children:H?(()=>{const e={width:J,height:J,borderRadius:K,...smoothCorners};if(!r)return null;const onError=()=>E(N),t=uriOfSource(r);return o?_jsx(o,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):s&&void 0!==t?_jsx(AuthedImage,{uri:t,client:s,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):_jsx(Image,{...void 0!==B?{source:B}:{},onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():Q||_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:$,fontSize:q,lineHeight:Math.round(q*M.leading.body)},R],children:D??" "})}),"verified"===h||"rejected"===h?_jsx(View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:ee,height:ee,borderRadius:ee/2,...smoothCorners,backgroundColor:F}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:_jsx(AppIcon,{name:"verified"===h?"verify":"close-circle",variant:"bold",size:te,color:Z})}):null,h&&!X?_jsx(View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,...smoothCorners,backgroundColor:statusColor(M,h),borderWidth:2,borderColor:F}],accessible:!1,pointerEvents:"none"}):null]}),ge=le?_jsx(Pressable,{ref:t,onPress:x?e=>{const t=resolveHaptic(j,"selection");t&&triggerHaptic(t),x?.(e)}:void 0,onLongPress:S?e=>{const t=resolveHaptic(j,"longPress");t&&triggerHaptic(t),S?.(e)}:void 0,hitSlop:de,...hitSlopMarker(de),accessibilityRole:"button",accessibilityLabel:ce,testID:V,style:({pressed:e})=>[me,e?styles.pressed:null],children:he}):_jsx(View,{ref:t,style:me,accessible:!0,accessibilityRole:"image",accessibilityLabel:ne,testID:V,children:he});return y?_jsx(AvatarSkeleton,{...e}):ge}),AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e);return _jsx(Skeleton,{shape:"circle"===t?"circle":"rounded"===t?"rounded":"rect",width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton";const Avatar=Object.assign(AvatarRoot,{Skeleton:AvatarSkeleton});Avatar.displayName="Avatar";const styles=StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:o,children:s})=>{const a=useTheme(),i=useRef(createAnimatedValue(0)).current;return useEffect(()=>{const t=Animated.timing(i,{toValue:1,duration:220,delay:e,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver});return t.start(),()=>t.stop()},[e,i]),_jsx(Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:a.radius.pill,borderColor:r,borderWidth:o,opacity:i}],children:s})},AvatarGroup=e=>{const{children:t,max:r=4,size:o="md",spacing:s="normal",overflowVariant:a="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;assertValidValue("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),assertValidValue("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),assertValidValue("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=useMemo(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=useTheme(),m=useMemo(()=>Children.toArray(t).filter(e=>isValidElement(e)),[t]),h=m.length,g=m.slice(0,r),p=Math.max(0,h-r),b=p>0,v=-d.space[SPACING_OFFSET[s]],f=d.colors.surface,y=i??u.groupOf(h),A=useMemo(()=>resolveSize(o),[o]),x=Math.max(d.text.xs.size,Math.round(.34*A));return _jsxs(View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:y,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,s=cloneElement(e,{size:o,labels:e.props.labels??c});return _jsx(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:v,borderColor:f,borderWidth:1.5,children:s},r)}),b?_jsx(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:v,borderColor:f,borderWidth:1.5,children:_jsx(View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,...smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(p):u.moreAvatars,children:_jsx(Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:x,lineHeight:Math.round(x*d.leading.body)},children:"count"===a?`+${p}`:"+"})})},"avatar-overflow"):null]})},groupStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{...smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});export{Avatar,AvatarGroup};export default Avatar;
1
+ "use strict";import{Image}from"expo-image";import{Children,cloneElement,forwardRef,isValidElement,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{AuthedImage}from"../AuthedImage/AuthedImage.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2;export const AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"];export const avatarToneColors=(e,t)=>{const soft=(e,t)=>tintOf(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};export const DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",rejected:"rejected",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"});const sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,o)=>{switch(t){case"circle":return r/2;case"rounded":return o?e.radius[o]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,o]=t;return void 0===r?"":void 0===o?r.charAt(0).toUpperCase():(r.charAt(0)+o.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const o=t[Math.abs(r)%t.length];if(void 0===o)throw new Error("The avatar colour palette is empty.");return o},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isImageSourceList=e=>Array.isArray(e),toExpoSource=e=>({...void 0!==e.uri?{uri:e.uri}:{},...void 0!==e.headers?{headers:e.headers}:{},...void 0!==e.width?{width:e.width}:{},...void 0!==e.height?{height:e.height}:{}}),toExpoSources=e=>"number"==typeof e?e:isImageSourceList(e)?e.map(toExpoSource):toExpoSource(e),isRingStatus=e=>"verified"===e||"pending"===e||"rejected"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":case"rejected":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},AvatarRoot=forwardRef((e,t)=>{const{source:r,ImageComponent:o,imageClient:s,name:a,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:h=null,statusPosition:g="bottomRight",tone:p,backgroundColor:b,color:v,fontSize:f,loading:y=!1,accessibilityLabel:A,onPress:x,onLongPress:S,haptic:j,hitSlop:C,style:I,textStyle:R,testID:V,labels:_}=e;assertValidValue("Avatar","size",e.size,Object.keys(sizeMap)),assertValidValue("Avatar","shape",e.shape,["circle","square","rounded"]),assertValidValue("Avatar","radius",e.radius,["sm","md","lg"]),assertValidValue("Avatar","contentFit",e.contentFit,["cover","contain"]),assertValidValue("Avatar","status",e.status,["online","offline","busy","away","verified","pending","rejected"]),assertValidValue("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),assertValidValue("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const w=useMemo(()=>_?{...DEFAULT_AVATAR_LABELS,..._}:DEFAULT_AVATAR_LABELS,[_]),M=useTheme(),[T,E]=useState(null),L=useMemo(()=>l??resolveSize(i),[l,i]),k=useMemo(()=>resolveRadius(M,n,L,c),[M,n,L,c]),z=u?M.size.border:0,O=M.colors.border,F=M.colors.surface,D=useMemo(()=>initialsFromName(a),[a]),$=useMemo(()=>p?avatarToneColors(M,p):null,[M,p]),G=useMemo(()=>b||($?.background??M.colors[hashColor(a??"",AVATAR_COLORS)]),[b,$,a,M]),P=v??$?.color??M.colors["on-primary"],N=r?keyOfSource(r):null,B=useMemo(()=>void 0!==r?toExpoSources(r):void 0,[r]),H=null!==N&&N!==T,U=!H&&""===D&&null!=m,W=v??$?.color??M.colors["text-subtle"],q=f??Math.max(M.text.xs.size,Math.round(.4*L)),Y=Math.max(8,Math.round(.25*L)),X=isRingStatus(h),J=L-2*(X?3:z),K=X?resolveRadius(M,n,J,c):Math.max(0,k-z),Q=U?renderSlotIcon(m,{color:W,size:Math.round(.45*J),disabled:!1}):null,Z=X?statusColor(M,h):"transparent",ee=Math.max(12,Math.round(.32*L)),te=Math.max(10,ee-4),re=b??$?.background??M.colors["bg-muted"],oe=H?"contain"===d?"transparent":M.colors["bg-muted"]:U?re:G,se=V??"avatar",ae=a?w.avatarOf(a):w.avatar,ie="verified"===h?`, ${w.verified}`:"pending"===h?`, ${w.pendingVerification}`:"rejected"===h?`, ${w.rejected}`:"",ne=A??`${ae}${ie}`,le="function"==typeof x||"function"==typeof S,ce=A??`${a||ae}${ie}`,ue=Math.max(0,Math.ceil((44-L)/2)),de=C??ue,me=[styles.root,{width:L,height:L,borderRadius:k,...smoothCorners,borderWidth:X?0:z,borderColor:O,backgroundColor:X?"transparent":oe},I],he=_jsxs(_Fragment,{children:[X?_jsx(View,{style:[styles.ring,{borderRadius:k,...smoothCorners,borderWidth:1.5,borderColor:Z}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,_jsx(View,{style:[styles.picture,{width:J,height:J,borderRadius:K,...smoothCorners,borderWidth:X?z:0,borderColor:O,backgroundColor:X?oe:"transparent"}],children:H?(()=>{const e={width:J,height:J,borderRadius:K,...smoothCorners};if(!r)return null;const onError=()=>E(N),t=uriOfSource(r);return o?_jsx(o,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):s&&void 0!==t?_jsx(AuthedImage,{uri:t,client:s,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):_jsx(Image,{...void 0!==B?{source:B}:{},onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0,testID:V?`${V}-image`:void 0})})():Q||_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:P,fontSize:q,lineHeight:Math.round(q*M.leading.body)},R],children:D??" "})}),"verified"===h||"rejected"===h?_jsx(View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:ee,height:ee,borderRadius:ee/2,...smoothCorners,backgroundColor:F}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:_jsx(AppIcon,{name:"verified"===h?"verify":"close-circle",variant:"bold",size:te,color:Z})}):null,h&&!X?_jsx(View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,...smoothCorners,backgroundColor:statusColor(M,h),borderWidth:2,borderColor:F}],accessible:!1,pointerEvents:"none"}):null]}),ge=le?_jsx(Pressable,{ref:t,onPress:x?e=>{const t=resolveHaptic(j,"selection");t&&triggerHaptic(t),x?.(e)}:void 0,onLongPress:S?e=>{const t=resolveHaptic(j,"longPress");t&&triggerHaptic(t),S?.(e)}:void 0,hitSlop:de,...hitSlopMarker(de),accessibilityRole:"button",accessibilityLabel:ce,testID:V,style:({pressed:e})=>[me,e?styles.pressed:null],children:he}):_jsx(View,{ref:t,style:me,accessible:!0,accessibilityRole:"image",accessibilityLabel:ne,testID:V,children:he});return y?_jsx(AvatarSkeleton,{...e}):ge}),AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e);return _jsx(Skeleton,{shape:"circle"===t?"circle":"rounded"===t?"rounded":"rect",width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton";const Avatar=Object.assign(AvatarRoot,{Skeleton:AvatarSkeleton});Avatar.displayName="Avatar";const styles=StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:o,children:s})=>{const a=useTheme(),i=useRef(createAnimatedValue(0)).current;return useEffect(()=>{const t=Animated.timing(i,{toValue:1,duration:220,delay:e,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver});return t.start(),()=>t.stop()},[e,i]),_jsx(Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:a.radius.pill,borderColor:r,borderWidth:o,opacity:i}],children:s})},AvatarGroup=e=>{const{children:t,max:r=4,size:o="md",spacing:s="normal",overflowVariant:a="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;assertValidValue("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),assertValidValue("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),assertValidValue("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=useMemo(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=useTheme(),m=useMemo(()=>Children.toArray(t).filter(e=>isValidElement(e)),[t]),h=m.length,g=m.slice(0,r),p=Math.max(0,h-r),b=p>0,v=-d.space[SPACING_OFFSET[s]],f=d.colors.surface,y=i??u.groupOf(h),A=useMemo(()=>resolveSize(o),[o]),x=Math.max(d.text.xs.size,Math.round(.34*A));return _jsxs(View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:y,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,s=cloneElement(e,{size:o,labels:e.props.labels??c});return _jsx(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:v,borderColor:f,borderWidth:1.5,children:s},r)}),b?_jsx(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:v,borderColor:f,borderWidth:1.5,children:_jsx(View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,...smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(p):u.moreAvatars,children:_jsx(Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:x,lineHeight:Math.round(x*d.leading.body)},children:"count"===a?`+${p}`:"+"})})},"avatar-overflow"):null]})},groupStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{...smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});export{Avatar,AvatarGroup};export default Avatar;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"});const BannerRoot=forwardRef((e,t)=>{const{title:r,message:n,tone:o="neutral",variant:s="bar",icon:i,actions:a,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:p=!1,accessibilityRole:g="alert",accessibilityLabel:h,labels:y,style:b,containerStyle:x,iconCircleStyle:f,tintBarStyle:w,closeButtonStyle:j,actionButtonStyle:v,testID:S}=e;assertValidValue("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Banner","variant",e.variant,["bar","wash","tint"]),assertValidValue("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const B=useTheme(),k=usePresenceMotion(),V=useMemo(()=>buildStyles(B),[B]),C=useMemo(()=>tintFor(B,o),[B,o]),_=useMemo(()=>({...DEFAULT_BANNER_LABELS,...y}),[y]),R=useMemo(()=>(a??[]).map((e,t)=>({key:`${e.label}-${t}`,action:e})),[a]),[I,D]=k.range(-20,0),A=useRef(createAnimatedValue(m&&u?I:0)).current,M=useRef(createAnimatedValue(m&&u?0:u?1:0)).current,[T,L]=useState(u),E=useRef(!0),z=useRef({animateMount:m,mounted:T,theme:B,presence:k,hiddenY:I,shownY:D,translateY:A,opacity:M});if(z.current={animateMount:m,mounted:T,theme:B,presence:k,hiddenY:I,shownY:D,translateY:A,opacity:M},useEffect(()=>{if(E.current&&(E.current=!1,!z.current.animateMount))return;let e;return u?(L(!0),e=Animated.parallel([Animated.timing(z.current.translateY,{toValue:z.current.shownY,duration:z.current.theme.motion.duration.default,useNativeDriver:nativeDriver}),Animated.timing(z.current.opacity,{toValue:1,duration:z.current.presence.duration("default"),useNativeDriver:nativeDriver})]),e.start()):z.current.mounted&&(e=Animated.parallel([Animated.timing(z.current.translateY,{toValue:z.current.hiddenY,duration:z.current.theme.motion.duration.fast,useNativeDriver:nativeDriver}),Animated.timing(z.current.opacity,{toValue:0,duration:z.current.presence.duration("fast"),useNativeDriver:nativeDriver})]),e.start(()=>{L(!1)})),()=>e?.stop()},[u]),!T)return null;const H=r??" ",N="string"==typeof n?n??" ":"",Y="wash"===s,P="bar"!==s,W="alert"===g?"danger"===o?"assertive":"polite":"none",F=_jsxs(Animated.View,{ref:t,accessibilityRole:g,accessibilityLiveRegion:W,accessibilityLabel:h,testID:S,style:[V.container,{backgroundColor:P?C.soft:B.colors["bg-subtle"],borderRadius:Y?B.radius.sm:B.radius.md,...smoothCorners,padding:B.space.md,opacity:M,transform:[{translateY:A}]},x,b],children:[!Y&&B.components.banner["tint-bar-width"]>0?_jsx(View,{style:[V.tintBar,{backgroundColor:C.bar},w]}):null,_jsxs(View,{style:[V.row,void 0===r&&V.rowCentred],children:[!1===i?null:i?_jsx(View,{style:V.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(i,{color:C.ink,size:B.text.xl.size,disabled:!1})}):_jsx(IconBadge,{dimension:ICON_CIRCLE_SIZE,color:C.bar,icon:_jsx(Text,{variant:"body",weight:"bold",accessible:!1,style:[V.iconGlyph,{color:C.ink}],children:C.glyph}),style:[V.iconCircle,f]}),_jsxs(View,{style:V.textBlock,children:[r||p?_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:2,style:Y?{color:C.ink}:void 0,children:H}):null,"string"==typeof n||p?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{marginTop:r?B.space.xxs:0},children:N||" "}):_jsx(View,{style:{marginTop:r?B.space.xxs:0},children:n})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:_.dismiss,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),c?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[V.closeBtn,{backgroundColor:e?B.colors["surface-pressed"]:"transparent"},j],children:_jsx(Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:Math.round(B.text.lg.size*B.leading.heading)},children:"×"})}):null]}),a&&a.length>0?_jsx(View,{style:V.actionsRow,children:R.map(({key:e,action:t})=>{assertValidValue("Banner","action.tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Banner","action.variant",t.variant,["solid","outline","ghost"]),assertValidValue("Banner","action.size",t.size,["sm","md"]);const r=t.tone??"primary",n=t.variant??"ghost",o="primary"===r?C.glyphColor:"neutral"===r?B.colors["text-muted"]:B.colors[r],s="primary"===r?C.ink:"neutral"===r?B.colors["text-muted"]:B.colors[`${r}-text`],i="primary"===r?C.on:"neutral"===r?B.colors["on-neutral-strong"]:B.colors[`on-${r}`],a="solid"===n;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t.label,testID:t.testID,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),t.onPress()},style:({pressed:e})=>[V.actionBtn,"md"===t.size&&V.actionBtnMd,"outline"===n&&{borderWidth:1,borderColor:s},{backgroundColor:a?o:e?B.colors["surface-pressed"]:"transparent",opacity:a&&e?.85:1},v],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:a?i:s},children:t.label})},e)})}):null]});return p?_jsx(BannerSkeleton,{...e}):F}),BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:n,style:o})=>{const s=useTheme(),i=!1!==r,a=t?.length??0,l=useMemo(()=>Array.from({length:a},(e,t)=>({key:`sk-banner-action-${t}`})),[a]);return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,...smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},n,o],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:s.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.sm},children:l.map(e=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},e.key))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton";const Banner=Object.assign(BannerRoot,{Skeleton:BannerSkeleton});Banner.displayName="Banner";const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:Math.round(e.text.base.size*e.leading.heading)},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Platform,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"});const BannerRoot=forwardRef((e,t)=>{const{title:r,message:n,tone:o="neutral",variant:s="bar",icon:i,actions:a,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:p=!1,accessibilityRole:g="alert",accessibilityLabel:h,labels:y,style:b,containerStyle:x,iconCircleStyle:f,tintBarStyle:w,closeButtonStyle:j,actionButtonStyle:S,testID:v}=e;assertValidValue("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Banner","variant",e.variant,["bar","wash","tint"]),assertValidValue("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const B=useTheme(),k=usePresenceMotion(),V=useMemo(()=>buildStyles(B),[B]),C=useMemo(()=>tintFor(B,o),[B,o]),_=useMemo(()=>({...DEFAULT_BANNER_LABELS,...y}),[y]),R=useMemo(()=>(a??[]).map((e,t)=>({key:`${e.label}-${t}`,action:e})),[a]),[I,D]=k.range(-20,0),A=useRef(createAnimatedValue(m&&u?I:0)).current,M=useRef(createAnimatedValue(m&&u?0:u?1:0)).current,[T,L]=useState(u),E=useRef(!0),z=useRef({animateMount:m,mounted:T,theme:B,presence:k,hiddenY:I,shownY:D,translateY:A,opacity:M});if(z.current={animateMount:m,mounted:T,theme:B,presence:k,hiddenY:I,shownY:D,translateY:A,opacity:M},useEffect(()=>{if(E.current&&(E.current=!1,!z.current.animateMount))return;let e;return u?(L(!0),e=Animated.parallel([Animated.timing(z.current.translateY,{toValue:z.current.shownY,duration:z.current.theme.motion.duration.default,useNativeDriver:nativeDriver}),Animated.timing(z.current.opacity,{toValue:1,duration:z.current.presence.duration("default"),useNativeDriver:nativeDriver})]),e.start()):z.current.mounted&&(e=Animated.parallel([Animated.timing(z.current.translateY,{toValue:z.current.hiddenY,duration:z.current.theme.motion.duration.fast,useNativeDriver:nativeDriver}),Animated.timing(z.current.opacity,{toValue:0,duration:z.current.presence.duration("fast"),useNativeDriver:nativeDriver})]),e.start(()=>{L(!1)})),()=>e?.stop()},[u]),!T)return null;const H=r??" ",N="string"==typeof n?n??" ":"",P="wash"===s,Y="bar"!==s,W="alert"===g,F=W?"danger"===o?"assertive":"polite":"none",O=_jsxs(Animated.View,{ref:t,accessibilityRole:g,..."web"===Platform.OS&&W&&"danger"!==o?{role:"status"}:null,accessibilityLiveRegion:F,accessibilityLabel:h,testID:v,style:[V.container,{backgroundColor:Y?C.soft:B.colors["bg-subtle"],borderRadius:P?B.radius.sm:B.radius.md,...smoothCorners,padding:B.space.md,opacity:M,transform:[{translateY:A}]},x,b],children:[!P&&B.components.banner["tint-bar-width"]>0?_jsx(View,{style:[V.tintBar,{backgroundColor:C.bar},w]}):null,_jsxs(View,{style:[V.row,void 0===r&&V.rowCentred],children:[!1===i?null:i?_jsx(View,{style:V.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(i,{color:C.ink,size:B.text.xl.size,disabled:!1})}):_jsx(IconBadge,{dimension:ICON_CIRCLE_SIZE,color:C.bar,icon:_jsx(Text,{variant:"body",weight:"bold",accessible:!1,style:[V.iconGlyph,{color:C.ink}],children:C.glyph}),style:[V.iconCircle,f]}),_jsxs(View,{style:V.textBlock,children:[r||p?_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:2,style:P?{color:C.ink}:void 0,children:H}):null,"string"==typeof n||p?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{marginTop:r?B.space.xxs:0},children:N||" "}):_jsx(View,{style:{marginTop:r?B.space.xxs:0},children:n})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:_.dismiss,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),c?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[V.closeBtn,{backgroundColor:e?B.colors["surface-pressed"]:"transparent"},j],children:_jsx(Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:Math.round(B.text.lg.size*B.leading.heading)},children:"×"})}):null]}),a&&a.length>0?_jsx(View,{style:V.actionsRow,children:R.map(({key:e,action:t})=>{assertValidValue("Banner","action.tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Banner","action.variant",t.variant,["solid","outline","ghost"]),assertValidValue("Banner","action.size",t.size,["sm","md"]);const r=t.tone??"primary",n=t.variant??"ghost",o="primary"===r?C.glyphColor:"neutral"===r?B.colors["text-muted"]:B.colors[r],s="primary"===r?C.ink:"neutral"===r?B.colors["text-muted"]:B.colors[`${r}-text`],i="primary"===r?C.on:"neutral"===r?B.colors["on-neutral-strong"]:B.colors[`on-${r}`],a="solid"===n;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t.label,testID:t.testID,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),t.onPress()},style:({pressed:e})=>[V.actionBtn,"md"===t.size&&V.actionBtnMd,"outline"===n&&{borderWidth:1,borderColor:s},{backgroundColor:a?o:e?B.colors["surface-pressed"]:"transparent",opacity:a&&e?.85:1},S],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:a?i:s},children:t.label})},e)})}):null]});return p?_jsx(BannerSkeleton,{...e}):O}),BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:n,style:o})=>{const s=useTheme(),i=!1!==r,a=t?.length??0,l=useMemo(()=>Array.from({length:a},(e,t)=>({key:`sk-banner-action-${t}`})),[a]);return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,...smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},n,o],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:s.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.sm},children:l.map(e=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},e.key))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton";const Banner=Object.assign(BannerRoot,{Skeleton:BannerSkeleton});Banner.displayName="Banner";const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:Math.round(e.text.base.size*e.leading.heading)},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
@@ -1 +1 @@
1
- "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:r,onSnapChange:a,onAnimate:n,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:p,onContentSizeChange:b,onScrollLayout:S,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:x="sheet",animateMount:w=!0,handleIndicatorStyle:C,containerStyle:M,header:R,actions:_,actionsLayout:O="auto",footer:k,headerStyle:E,footerStyle:T,children:A,accessibilityLabel:I,accessibilityViewIsModal:j,testID:V}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),N=null!=R||null!=d,B=null!=_&&_.length>0,L=null!=k||B,P=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,z]=useState(()=>Dimensions.get("window").height),[Y,K]=useState(()=>Dimensions.get("window").width),$=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&z(e=>e===t?e:t),o>0&&K(e=>e===o?e:o)},[]),W=useWindowDimensions(),X="dialog"===x||"auto"===x&&Math.min(W.width,W.height)>=600,q=Math.min(560,Y-2*H.space.xl),[J,Q]=useModalInsets(),Z="modal"===P?J.top:F.top,ee="modal"===P?J.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[re,ae]=useMeasuredHeight(),[ne,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=X?H.space.md:oe,he=te?Math.min(de+(N?re:0)+ne+(L?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),pe=U,be=fe[fe.length-1]??0,Se=useSharedValue(pe),ve=useSharedValue(pe),ye=useSharedValue(1),ge=useSharedValue(-1),[xe,we]=useState(-1),Ce=useRef(!1),[Me,Re]=useState(!1),[Oe,ke]=useState(!1),Ee=useRef(!1),Te=useRef(l);Te.current=l;const[Ae,Ie]=useState(!1),je=useRef(!w&&o),Ve=useRef(-1),De=useRef(!1);De.current="modal"===P?Oe:Ae;const Ne=useRef(c);Ne.current=c;const Be=useRef(s);Be.current=s;const Le=useRef(!1),Pe=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Pe.current=!0,()=>{Pe.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return pe;const t=fe[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return X?(U-t)/2:U-t},[fe,U,pe,X]),Ue=useCallback(e=>{Ve.current=e;xe!==e&&(we(e),ge.value=e,e>=0&&a?.(e))},[xe,ge,a]),ze=useCallback(()=>{Ce.current=!1,ge.value<0&&(Ee.current=!0,"modal"===P?(Re(!1),"ios"!==Platform.OS&&ke(!1)):Ie(!1))},[P,ge]),Ye=useCallback(()=>{Ee.current&&ke(!1)},[]);useEffect(()=>{("modal"===P?!Oe:!Ae)&&Ee.current&&(Ee.current=!1,Te.current?.(),Ge(!0))},[P,Oe,Ae,Ge]);const Ke=useCallback((e,t,o)=>{Ce.current=!0,n?.(t,o),Se.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(ze)})},[n,Se,ze]),$e=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):Math.max(xe,0),o=ge.value,s=Fe(t);return Ee.current=!1,Ge(!1),"modal"===P?(ke(!0),Re(!0)):Ie(!0),o<0&&je.current?(Se.value=s,ye.value=1,Ue(t),void n?.(o,t)):o<0&&G.reduced?(Se.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void n?.(o,t)):(o<0&&(Se.value=pe,ye.value=1),Ue(t),void Ke(s,o,t))},[Ke,pe,xe,ge,P,n,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,Se,Fe]),We=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(De.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),Ce.current=!0,n?.(t,-1);const o=G.reduced?ye:Se,s=G.reduced?0:pe;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(ze)})}),[pe,ge,ze,n,G,ye,Ue,Se,H.motion.ease.accelerate]),Xe=useCallback((e,t,o)=>{const s=Ne.current;if(!s)return void e();if(Le.current)return void t?.();const r=s();"boolean"!=typeof r?(Le.current=!0,o?.(),r.then(o=>{Le.current=!1,o&&Pe.current&&Ve.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(r?e:t)?.()},[]),qe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):Xe(()=>{Be.current(),We(),e(!0)},()=>e(!1))}),[We,Xe]),Je=useCallback(()=>{Be.current()},[]),Qe=useCallback(()=>{u&&qe()},[u,qe]),Ze=useRef(null),et=useRef($e);et.current=$e;const tt=useRef(We);tt.current=We,useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?et.current(r??0):tt.current():o&&"number"==typeof r&&r!==ge.value&&et.current(r)},[o,r,ge]);const ot=useRef({hostHeight:U,contentSnap:he}),st=useRef(Fe);st.current=Fe,useEffect(()=>{const e=ot.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(ot.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=st.current(ge.value);Se.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he,ge,Se]);const rt=U-be,at=useMemo(()=>fe.map(e=>U-e),[fe,U]),nt=useCallback(()=>{const e=Ve.current;e<0||Ke(Fe(e),e,e)},[Ke,Fe]),lt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ke(t,o,e)):Xe(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Be.current(),We()},nt,nt)},[Ke,We,ge,Xe,Ue,nt]),it=useMemo(()=>({testID:V?`${V}-content-gesture`:"bottom-sheet-content-gesture"}),[V]),ut=useNativeGesture(it),ct=useMemo(()=>{const e=at,t=pe,o=rt,s=i;return{testID:V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ve.value=Se.value},onUpdate:e=>{"worklet";const t=ve.value+e.translationY;Se.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const r=Se.value,a=o.velocityY,[n]=e;if(void 0===n)return void scheduleOnRN(lt,-1,t);if(a>1e3)return s?void scheduleOnRN(lt,-1,t):void scheduleOnRN(lt,0,n);let l=0,i=n,u=1/0,c=0;for(const t of e){const e=Math.abs(r-t);e<u&&(u=e,i=t,l=c),c++}s&&r-n>80?scheduleOnRN(lt,-1,t):scheduleOnRN(lt,l,i)}}},[pe,ve,i,lt,rt,at,V,Se]),dt=usePanGesture(ct),{height:ht}=useReanimatedKeyboardAnimation(),mt="shift"===y,ft=useDerivedValue(()=>mt?ht.value:0,[mt,ht]),pt=fe[Math.max(xe,0)]??be,bt=H.space.md,St=useAnimatedStyle(()=>{if(X){const e=ft.value,t=U+e-pt-bt,o=e<0&&Se.value>t?t:Se.value;return{top:Math.max(o,Z),opacity:ye.value}}const e=Se.value+ft.value,t=ft.value<0?Z:rt;return{top:Math.max(e,t),opacity:ye.value}},[X,ft,U,pt,bt,Se,Z,ye,rt]),vt=useAnimatedStyle(()=>{const e=ft.value;if(X){const t=U+e-pt-bt,o=e<0&&Se.value>t?t:Se.value,s=Math.max(o,Z),r=U+e-bt-s;return{height:r<0?0:Math.min(r,pt)}}const t=e<0?Z:rt,o=Se.value+e,s=Math.max(o,t),r=U+e-s;return{height:r<0?0:Math.min(r,be)}},[ft,X,U,pt,bt,Se,Z,rt,be]),yt=xe>=0,gt=useMemo(()=>buildStyles(H),[H]),xt=useCallback(()=>{u&&Xe(()=>{triggerHaptic("selection"),Be.current(),We()})},[u,We,Xe]),wt=useMemo(()=>({testID:V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(xt)}}),[xt,V]),Ct=useTapGesture(wt),Mt=useMemo(()=>({snapIndex:xe,snapPoints:fe,close:Je,requestClose:qe}),[xe,fe,Je,qe]);if("inline"===P&&!Ae)return null;if("modal"===P&&!Oe)return null;const Rt=_jsxs(View,{collapsable:!1,style:["modal"===P?gt.backdropModal:gt.backdropInline,{backgroundColor:"modal"===P?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:$,testID:V,accessibilityViewIsModal:j??yt,children:[_jsx(GestureDetector,{gesture:Ct,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:I,accessibilityViewIsModal:j??yt,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[gt.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},X?{height:pt,left:(Y-q)/2,right:void 0,width:q,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,M,St],children:_jsxs(SheetBody,{style:[gt.body,vt],keyboardOffset:ft,children:[X?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:dt,children:_jsx(View,{style:gt.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[gt.handle,{backgroundColor:H.colors.border},C]})})}),N&&_jsxs(View,{style:[gt.header,E],onLayout:te?ae:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:ut,children:_jsx(ScrollView,{ref:f,style:gt.scrollContent,onScroll:p,onContentSizeChange:me,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:A})}):_jsx(View,{style:te?[gt.content,{overflow:"visible"}]:gt.content,children:te?_jsx(View,{onLayout:le,children:A}):A}),L&&_jsxs(View,{style:[gt.footer,T],onLayout:te?ce:void 0,children:[B?_jsx(View,{style:gt.actions,children:_jsx(OverlayActions,{actions:_??[],layout:O})}):null,k]})]})})]}),_t=_jsx(BottomSheetContext.Provider,{value:Mt,children:Rt});return"modal"===P?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?Ye:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:gt.modalRoot,children:_t}):_t}):_t},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,r=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},[s,t]);return _jsx(Animated.View,{style:[e,r],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
1
+ "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:r,onSnapChange:a,onAnimate:n,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:p,onContentSizeChange:b,onScrollLayout:S,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:x="sheet",animateMount:w=!0,handleIndicatorStyle:C,containerStyle:M,header:R,actions:_,actionsLayout:O="auto",footer:k,headerStyle:E,footerStyle:T,children:A,accessibilityLabel:I,accessibilityViewIsModal:j,testID:D}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const V=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),N=null!=R||null!=d,B=null!=_&&_.length>0,L=null!=k||B,P=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,z]=useState(()=>Dimensions.get("window").height),[Y,$]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&z(e=>e===t?e:t),o>0&&$(e=>e===o?e:o)},[]),W=useWindowDimensions(),X="dialog"===x||"auto"===x&&Math.min(W.width,W.height)>=600,q=Math.min(560,Y-2*H.space.xl),[J,Q]=useModalInsets(),Z="modal"===P?J.top:F.top,ee="modal"===P?J.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[re,ae]=useMeasuredHeight(),[ne,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=X?H.space.md:oe,he=te?Math.min(de+(N?re:0)+ne+(L?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),pe=U,be=fe[fe.length-1]??0,Se=useSharedValue(pe),ve=useSharedValue(pe),ye=useSharedValue(1),ge=useSharedValue(-1),[xe,we]=useState(-1),Ce=useRef(!1),[Me,Re]=useState(!1),[Oe,ke]=useState(!1),Ee=useRef(!1),Te=useRef(l);Te.current=l;const[Ae,Ie]=useState(!1),je=useRef(!w&&o),De=useRef(-1),Ve=useRef(!1);Ve.current="modal"===P?Oe:Ae;const Ne=useRef(c);Ne.current=c;const Be=useRef(s);Be.current=s;const Le=useRef(!1),Pe=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Pe.current=!0,()=>{Pe.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return pe;const t=fe[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return X?(U-t)/2:U-t},[fe,U,pe,X]),Ue=useCallback(e=>{De.current=e;xe!==e&&(we(e),ge.value=e,e>=0&&a?.(e))},[xe,ge,a]),ze=useCallback(()=>{Ce.current=!1,ge.value<0&&(Ee.current=!0,"modal"===P?(Re(!1),"ios"!==Platform.OS&&ke(!1)):Ie(!1))},[P,ge]),Ye=useCallback(()=>{Ee.current&&ke(!1)},[]);useEffect(()=>{("modal"===P?!Oe:!Ae)&&Ee.current&&(Ee.current=!1,Te.current?.(),Ge(!0))},[P,Oe,Ae,Ge]);const $e=useCallback((e,t,o)=>{Ce.current=!0,n?.(t,o),Se.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(ze)})},[n,Se,ze]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):Math.max(xe,0),o=ge.value,s=Fe(t);return Ee.current=!1,Ge(!1),"modal"===P?(ke(!0),Re(!0)):Ie(!0),o<0&&je.current?(Se.value=s,ye.value=1,Ue(t),void n?.(o,t)):o<0&&G.reduced?(Se.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void n?.(o,t)):(o<0&&(Se.value=pe,ye.value=1),Ue(t),void $e(s,o,t))},[$e,pe,xe,ge,P,n,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,Se,Fe]),We=useCallback(()=>new Promise(e=>{if(De.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),Ce.current=!0,n?.(t,-1);const o=G.reduced?ye:Se,s=G.reduced?0:pe;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(ze)})}),[pe,ge,ze,n,G,ye,Ue,Se,H.motion.ease.accelerate]),Xe=useCallback((e,t,o)=>{const s=Ne.current;if(!s)return void e();if(Le.current)return void t?.();const r=s();"boolean"!=typeof r?(Le.current=!0,o?.(),r.then(o=>{Le.current=!1,o&&Pe.current&&De.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(r?e:t)?.()},[]),qe=useCallback(()=>new Promise(e=>{De.current<0?e(!0):Xe(()=>{Be.current(),We(),e(!0)},()=>e(!1))}),[We,Xe]),Je=useCallback(()=>{Be.current()},[]),Qe=useCallback(()=>{u&&qe()},[u,qe]),Ze=useRef(null),et=useRef(Ke);et.current=Ke;const tt=useRef(We);tt.current=We,useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?et.current(r??0):tt.current():o&&"number"==typeof r&&r!==ge.value&&et.current(r)},[o,r,ge]);const ot=useRef({hostHeight:U,contentSnap:he}),st=useRef(Fe);st.current=Fe,useEffect(()=>{const e=ot.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(ot.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=st.current(ge.value);Se.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he,ge,Se]);const rt=U-be,at=useMemo(()=>fe.map(e=>U-e),[fe,U]),nt=useCallback(()=>{const e=De.current;e<0||$e(Fe(e),e,e)},[$e,Fe]),lt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),$e(t,o,e)):Xe(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Be.current(),We()},nt,nt)},[$e,We,ge,Xe,Ue,nt]),it=useMemo(()=>({testID:D?`${D}-content-gesture`:"bottom-sheet-content-gesture"}),[D]),ut=useNativeGesture(it),ct=useMemo(()=>{const e=at,t=pe,o=rt,s=i;return{testID:D?`${D}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ve.value=Se.value},onUpdate:e=>{"worklet";const t=ve.value+e.translationY;Se.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const r=Se.value,a=o.velocityY,[n]=e;if(void 0===n)return void scheduleOnRN(lt,-1,t);if(a>1e3)return s?void scheduleOnRN(lt,-1,t):void scheduleOnRN(lt,0,n);let l=0,i=n,u=1/0,c=0;for(const t of e){const e=Math.abs(r-t);e<u&&(u=e,i=t,l=c),c++}s&&r-n>80?scheduleOnRN(lt,-1,t):scheduleOnRN(lt,l,i)}}},[pe,ve,i,lt,rt,at,D,Se]),dt=usePanGesture(ct),{height:ht}=useReanimatedKeyboardAnimation(),mt="shift"===y,ft=useDerivedValue(()=>mt?ht.value:0,[mt,ht]),pt=fe[Math.max(xe,0)]??be,bt=H.space.md,St=useAnimatedStyle(()=>{if(X){const e=ft.value,t=U+e-pt-bt,o=e<0&&Se.value>t?t:Se.value;return{top:Math.max(o,Z),opacity:ye.value}}const e=Se.value+ft.value,t=ft.value<0?Z:rt;return{top:Math.max(e,t),opacity:ye.value}},[X,ft,U,pt,bt,Se,Z,ye,rt]),vt=useAnimatedStyle(()=>{const e=ft.value;if(X){const t=U+e-pt-bt,o=e<0&&Se.value>t?t:Se.value,s=Math.max(o,Z),r=U+e-bt-s;return{height:r<0?0:Math.min(r,pt)}}const t=e<0?Z:rt,o=Se.value+e,s=Math.max(o,t),r=U+e-s;return{height:r<0?0:Math.min(r,be)}},[ft,X,U,pt,bt,Se,Z,rt,be]),yt=xe>=0,gt=useMemo(()=>buildStyles(H),[H]),xt=useCallback(()=>{u&&Xe(()=>{triggerHaptic("selection"),Be.current(),We()})},[u,We,Xe]),wt=useMemo(()=>({testID:D?`${D}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(xt)}}),[xt,D]),Ct=useTapGesture(wt),Mt=useMemo(()=>({snapIndex:xe,snapPoints:fe,close:Je,requestClose:qe}),[xe,fe,Je,qe]);if("inline"===P&&!Ae)return null;if("modal"===P&&!Oe)return null;const Rt=_jsxs(View,{collapsable:!1,style:["modal"===P?gt.backdropModal:gt.backdropInline,{backgroundColor:"modal"===P?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:K,testID:D,accessibilityViewIsModal:j??yt,children:[_jsx(GestureDetector,{gesture:Ct,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:I,accessibilityViewIsModal:j??yt,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[gt.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},X?{height:pt,left:(Y-q)/2,right:void 0,width:q,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,M,St],children:_jsxs(SheetBody,{style:[gt.body,vt],keyboardOffset:ft,children:[X?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:dt,children:_jsx(View,{style:gt.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:D?`${D}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[gt.handle,{backgroundColor:H.colors.border},C]})})}),N&&_jsxs(View,{style:[gt.header,E],onLayout:te?ae:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:ut,children:_jsx(ScrollView,{ref:f,testID:D?`${D}-scroll`:void 0,style:gt.scrollContent,onScroll:p,onContentSizeChange:me,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:A})}):_jsx(View,{style:te?[gt.content,{overflow:"visible"}]:gt.content,children:te?_jsx(View,{onLayout:le,children:A}):A}),L&&_jsxs(View,{style:[gt.footer,T],onLayout:te?ce:void 0,children:[B?_jsx(View,{style:gt.actions,children:_jsx(OverlayActions,{actions:_??[],layout:O})}):null,k]})]})})]}),_t=_jsx(BottomSheetContext.Provider,{value:Mt,children:Rt});return"modal"===P?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?Ye:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:gt.modalRoot,children:_t}):_t}):_t},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,r=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},[s,t]);return _jsx(Animated.View,{style:[e,r],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{isOneOf}from"../../utils/guards.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=React.memo(forwardRef((e,t)=>{const{children:i,variant:o,elevation:s="card",radius:r,padding:a,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:y,defaultCollapsed:f=!1,onCollapsedChange:x,collapsedSummary:S,onRemove:j,separatorHeight:C=StyleSheet.hairlineWidth,footer:v,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:V=!1,gradient:F,onPress:k,haptic:T,contextMenu:B,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,style:P,containerStyle:z,headerStyle:M,bodyStyle:O,footerStyle:D,testID:E,labels:q,onLayout:W,...N}=e;assertValidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),assertValidValue("Card","radius",e.radius,["sm","md","lg","xl","pill"]),assertValidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),assertValidValue("Card","titleFont",e.titleFont,["sans","serif"]),assertValidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const G=useTheme(),U=G.settings.components.card,K=o??U?.defaultVariant??"elevated",$=r??U?.defaultRadius??"lg",J=a??U?.defaultPadding??"md",Q=m??U?.defaultTitleFont??"sans",X=useMemo(()=>({...DEFAULT_CARD_LABELS,...q}),[q]),Y=l||"function"==typeof k,Z=useContextMenu(B,{haptic:T||!1,testID:E,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),ee=useMemo(()=>mergeRefs(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:oe,pressOut:se}=usePressAnimation({preset:n||"scale",enabled:te&&!1!==n}),re=stylesFor(G),ae=Boolean(_),le=G.space[paddingMap[J]],ne=useMemo(()=>F?"string"==typeof F?G.settings.gradients[F]??null:F:null,[F,G.settings.gradients]),de="flat"===K,ce=de?G.radius.none:G.radius[$],ue=resolveBackground(G,d),[me,he]=useControllableState({value:y,defaultValue:f,onChange:x}),pe=b&&me,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,ye=useSquircle(!ae&&!ne&&!de,ce,W),fe=StyleSheet.flatten([z,P])??{},xe="string"==typeof fe.backgroundColor?fe.backgroundColor:void 0,Se="string"==typeof fe.borderColor?fe.borderColor:void 0,je=xe??ue??("filled"===K?G.colors["bg-subtle"]:G.colors.surface),Ce="outline"===K?G.size.border:0,ve=Se??G.colors.border,we="none"===s?void 0:G.shadow[s],Re="elevated"===K&&supportsBoxShadow()&&we?toBoxShadow(we):void 0,Ae=ye.active&&"elevated"===K&&!Re,Ve=ye.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=useMemo(()=>{const e={borderRadius:Ae&&ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce,...smoothCorners,padding:ae||ye.active?G.space.none:le,overflow:ye.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??G.colors.surface,borderBottomWidth:C,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors.surface,borderWidth:G.size.border,borderColor:ye.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??G.colors.surface,...Re?{boxShadow:Re}:we}}},[G,K,we,ce,ae,le,ye.active,ye.size,Re,Ae,ue,C]),ke=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,ce,R,w]),Te=u??"",Be=_jsxs(_Fragment,{children:[_jsxs(View,{style:re.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,Q),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:re.lead,children:h}):null,pe&&S?_jsx(Text,{variant:"caption",style:re.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:T}):p?_jsx(View,{style:re.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?X.show:X.hide} ${Te}`.trim(),expanded:!pe,onPress:()=>he(!pe),haptic:T}):null,j?_jsx(CardIconAction,{icon:"trash",label:X.remove,onPress:j,color:G.colors["danger-text"],haptic:T}):null]}),Le=_jsxs(_Fragment,{children:[be?_jsx(View,{style:[re.header,!c&&re.headerRow,pe&&re.headerFolded,M],children:c??Be}):null,pe?null:_jsx(View,{style:[be||v?re.body:null,O],children:i}),v&&!pe?_jsx(View,{style:[re.footer,D],children:v}):null]}),Ie=_?_jsxs(_Fragment,{children:[_jsxs(View,{style:re.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:ke,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:le},children:Le})]}):Le,He=ne?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:ne,style:StyleSheet.absoluteFill}),Ie]}):ye.active&&ye.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ye.size.width,height:ye.size.height,radius:ce,fill:je,stroke:Ce?ve:void 0,strokeWidth:Ce}),_jsx(View,{style:[re.squircleClip,{padding:le,borderRadius:ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce}],children:Ie})]}):Ie;let Pe;if(te){const handlePress=e=>{Y&&(T&&triggerHaptic(T),k?.(e))};Pe=_jsx(Animated.View,{style:ie,children:_jsx(Pressable,{ref:ee,onPress:handlePress,onPressIn:oe,onPressOut:se,accessibilityRole:H??(Y?"button":void 0),accessibilityLabel:L,accessibilityHint:I,testID:E,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,...Z.hostProps,children:He})})}else Pe=_jsx(View,{ref:t,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,testID:E,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,children:He});return V?_jsx(CardSkeleton,{...e}):Z.enabled?_jsxs(_Fragment,{children:[Pe,Z.renderSurface(_jsx(View,{style:[Fe,z,P,Ve,re.preview],children:He}))]}):Pe})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:o,bg:s,header:r,footer:a,imageSource:l,imageHeight:n=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:m,footerStyle:h,style:p,labels:g,...b})=>{const y=useTheme(),f=y.settings.components.card,x=e??f?.defaultVariant??"elevated",S=i??f?.defaultRadius??"lg",j=o??f?.defaultPadding??"md",C={...DEFAULT_CARD_LABELS,...g},v=paddingMap[j],_=y.space[v],w="flat"===x?y.radius.none:y.radius[S],R=void 0!==r||hasBuiltInHeaderContent(b),A=resolveBackground(y,s)??y.colors.surface,V="outline"===x?1:0,F="outline"===x?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:w,...smoothCorners,borderWidth:V,borderColor:F,overflow:"hidden"},c,p],accessibilityRole:"progressbar",accessibilityLabel:C.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:_,paddingBottom:y.space.sm},u],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==a?_jsx(View,{style:[{padding:_,paddingTop:y.space.sm,flexDirection:"row"},h],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:o,color:s,haptic:r})=>{const a=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===o?void 0:{expanded:o},"aria-expanded":o,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:s??a.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return isOneOf(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
1
+ "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{isOneOf}from"../../utils/guards.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=React.memo(forwardRef((e,t)=>{const{children:i,variant:s,elevation:o="card",radius:r,padding:a,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:y,defaultCollapsed:f=!1,onCollapsedChange:x,collapsedSummary:S,onRemove:j,separatorHeight:C=StyleSheet.hairlineWidth,footer:v,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:V=!1,gradient:F,onPress:k,haptic:T,contextMenu:B,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,style:P,containerStyle:z,headerStyle:M,bodyStyle:O,footerStyle:D,testID:E,labels:q,onLayout:W,...N}=e;assertValidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),assertValidValue("Card","radius",e.radius,["sm","md","lg","xl","pill"]),assertValidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),assertValidValue("Card","titleFont",e.titleFont,["sans","serif"]),assertValidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=useTheme(),G=U.settings.components.card,K=s??G?.defaultVariant??"elevated",$=r??G?.defaultRadius??"lg",J=a??G?.defaultPadding??"md",Q=m??G?.defaultTitleFont??"sans",X=useMemo(()=>({...DEFAULT_CARD_LABELS,...q}),[q]),Y=l||"function"==typeof k,Z=useContextMenu(B,{haptic:T||!1,testID:E,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),ee=useMemo(()=>mergeRefs(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:oe}=usePressAnimation({preset:n||"scale",enabled:te&&!1!==n}),re=stylesFor(U),ae=Boolean(_),le=U.space[paddingMap[J]],ne=useMemo(()=>F?"string"==typeof F?U.settings.gradients[F]??null:F:null,[F,U.settings.gradients]),de="flat"===K,ce=de?U.radius.none:U.radius[$],ue=resolveBackground(U,d),[me,he]=useControllableState({value:y,defaultValue:f,onChange:x}),pe=b&&me,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,ye=useSquircle(!ae&&!ne&&!de,ce,W),fe=StyleSheet.flatten([z,P])??{},xe="string"==typeof fe.backgroundColor?fe.backgroundColor:void 0,Se="string"==typeof fe.borderColor?fe.borderColor:void 0,je=xe??ue??("filled"===K?U.colors["bg-subtle"]:U.colors.surface),Ce="outline"===K?U.size.border:0,ve=Se??U.colors.border,we="none"===o?void 0:U.shadow[o],Re="elevated"===K&&supportsBoxShadow()&&we?toBoxShadow(we):void 0,Ae=ye.active&&"elevated"===K&&!Re,Ve=ye.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=useMemo(()=>{const e={borderRadius:Ae&&ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce,...smoothCorners,padding:ae||ye.active?U.space.none:le,overflow:ye.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:C,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:ye.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:ye.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:ye.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...Re?{boxShadow:Re}:we}}},[U,K,we,ce,ae,le,ye.active,ye.size,Re,Ae,ue,C]),ke=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,...smoothCorners}),[U,ce,R,w]),Te=u??"",Be=_jsxs(_Fragment,{children:[_jsxs(View,{style:re.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,Q),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:re.lead,children:h}):null,pe&&S?_jsx(Text,{variant:"caption",style:re.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:T}):p?_jsx(View,{style:re.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?X.show:X.hide} ${Te}`.trim(),expanded:!pe,onPress:()=>he(!pe),haptic:T}):null,j?_jsx(CardIconAction,{icon:"trash",label:X.remove,onPress:j,color:U.colors["danger-text"],haptic:T}):null]}),Le=_jsxs(_Fragment,{children:[be?_jsx(View,{style:[re.header,!c&&re.headerRow,pe&&re.headerFolded,M],children:c??Be}):null,pe?null:_jsx(View,{style:[be||v?re.body:null,O],children:i}),v&&!pe?_jsx(View,{style:[re.footer,D],children:v}):null]}),Ie=_?_jsxs(_Fragment,{children:[_jsxs(View,{style:re.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:ke,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:le},children:Le})]}):Le,He=ne?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:ne,style:StyleSheet.absoluteFill}),Ie]}):ye.active&&ye.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ye.size.width,height:ye.size.height,radius:ce,fill:je,stroke:Ce?ve:void 0,strokeWidth:Ce}),_jsx(View,{style:[re.squircleClip,{padding:le,borderRadius:ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce}],children:Ie})]}):Ie;let Pe;if(te){const handlePress=e=>{Y&&(T&&triggerHaptic(T),k?.(e))};Pe=_jsx(Animated.View,{style:ie,children:_jsx(Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:oe,accessibilityRole:H??(Y?"button":void 0),accessibilityLabel:L,accessibilityHint:I,testID:E,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,...Z.hostProps,children:He})})}else Pe=_jsx(View,{ref:t,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,testID:E,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,children:He});return V?_jsx(CardSkeleton,{...e}):Z.enabled?_jsxs(_Fragment,{children:[Pe,Z.renderSurface(_jsx(View,{style:[Fe,z,P,Ve,re.preview],children:He}))]}):Pe})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:o,header:r,footer:a,imageSource:l,imageHeight:n=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:m,footerStyle:h,style:p,labels:g,...b})=>{const y=useTheme(),f=y.settings.components.card,x=e??f?.defaultVariant??"elevated",S=i??f?.defaultRadius??"lg",j=s??f?.defaultPadding??"md",C={...DEFAULT_CARD_LABELS,...g},v=paddingMap[j],_=y.space[v],w="flat"===x?y.radius.none:y.radius[S],R=void 0!==r||hasBuiltInHeaderContent(b),A=resolveBackground(y,o)??y.colors.surface,V="outline"===x?1:0,F="outline"===x?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:w,...smoothCorners,borderWidth:V,borderColor:F,overflow:"hidden"},c,p],accessibilityRole:"progressbar",accessibilityLabel:C.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:_,paddingBottom:y.space.sm},u],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==a?_jsx(View,{style:[{padding:_,paddingTop:y.space.sm,flexDirection:"row"},h],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:o,haptic:r})=>{const a=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:o??a.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return isOneOf(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,AppState,Dimensions,FlatList,Image,Pressable,ScrollView,StyleSheet,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CAROUSEL_LABELS=Object.freeze({carousel:"Carousel",slideOf:(e,t)=>`Slide ${e} of ${t}`,goToSlide:e=>`Go to slide ${e}`});function CarouselRoot({ref:e,...t}){const{data:n,renderItem:r,keyExtractor:i,index:s,defaultIndex:a=0,onIndexChange:l,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:g="screen",spacing:b=0,containerStyle:p,accessibilityLabel:f,testID:y,showThumbnails:x=!1,haptic:S,renderThumbnail:v,loading:w=!1,labels:C}=t;assertValidValue("Carousel","paginationStyle",t.paginationStyle,["dots","bars","numbers"]);const T=useMemo(()=>({...DEFAULT_CAROUSEL_LABELS,...C}),[C]),j=useTheme(),k=d||c,[I,_]=useState(()=>Dimensions.get("window").width),A="screen"===g?I:g,E=A+b,R=useRef(null),V=useRef(createAnimatedValue(0)).current,L=clamp("number"==typeof s?s:a,0,Math.max(0,n.length-1)),[D,O]=useState(L),H=useRef(null),M=useRef(null),P=useRef(!1),z=useRef(D);z.current=D;const N=useCallback(e=>{const t=clamp(e,0,Math.max(0,n.length-1));O(e=>e===t?e:(l?.(t),t))},[n.length,l]),W=useCallback((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);R.current?.scrollToOffset({offset:r*E,animated:t}),N(r)},[n.length,E,N]),F=useRef(W);F.current=W;const $=useCallback(()=>{if(0===n.length)return;const e=z.current+1;e>=n.length?k&&W(0,!1):W(e,!0)},[n.length,k,W]),U=useCallback(()=>{if(0===n.length)return;const e=z.current-1;e<0?k&&W(n.length-1,!1):W(e,!0)},[n.length,k,W]);useImperativeHandle(e,()=>({scrollTo:W,next:$,prev:U}),[W,$,U]),useEffect(()=>{"number"==typeof s&&s!==z.current&&F.current(s,!0)},[s]);const B=useCallback(()=>{H.current&&(clearInterval(H.current),H.current=null)},[]),G=useCallback(()=>{!c||n.length<=1||(B(),H.current=setInterval(()=>{if(P.current)return;const e=z.current+1;e>=n.length?W(0,!1):W(e,!0)},u))},[c,u,n.length,W,B]);useEffect(()=>(G(),()=>{B(),M.current&&clearTimeout(M.current)}),[G,B]),useEffect(()=>{const e=AppState.addEventListener("change",e=>{"active"!==e?(B(),M.current&&(clearTimeout(M.current),M.current=null)):G()});return()=>e.remove()},[G,B]);const K=m&&n.length>1&&"numbers"!==h||void 0!==o,X=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{x:V}}}],{useNativeDriver:!1,listener:o?e=>o(e.nativeEvent.contentOffset.x):void 0}),[V,o]),q=useCallback(e=>{if(E<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/E);N(n)},[E,N]),J=useCallback(()=>{P.current=!0,B(),M.current&&(clearTimeout(M.current),M.current=null)},[B]),Q=useCallback(()=>{P.current=!1,c&&(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{G()},1e3))},[c,G]),Y=useCallback(e=>{switch(e.nativeEvent.actionName){case"increment":$();break;case"decrement":U()}},[$,U]),Z=useMemo(()=>buildStyles(j),[j]),ee=useCallback(({item:e,index:t})=>_jsx(View,{style:{width:A,marginRight:t===n.length-1?0:b},accessibilityElementsHidden:t!==D,importantForAccessibility:t===D?"yes":"no-hide-descendants",children:r(e,t)}),[r,A,b,n.length,D]),te=useCallback((e,t)=>String(t),[]),ne=useCallback((e,t)=>({length:E,offset:E*t,index:t}),[E]);return w?_jsx(CarouselSkeleton,{...t,containerWidth:I}):_jsxs(View,{style:[Z.container,p],onLayout:e=>_(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:f??T.carousel,accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:D,text:T.slideOf(D+1,n.length)},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Y,testID:y,children:[_jsx(FlatList,{ref:R,data:n,keyExtractor:i??te,renderItem:ee,horizontal:!0,pagingEnabled:"screen"===g&&0===b,snapToInterval:E,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:K?X:void 0,scrollEventThrottle:K?16:void 0,onMomentumScrollEnd:q,onScrollBeginDrag:J,onScrollEndDrag:Q,getItemLayout:ne,initialScrollIndex:L,bounces:!1}),m&&n.length>1?_jsx(Pagination,{count:n.length,currentIndex:D,scrollX:V,slideStride:E,variant:h,theme:j,labels:T}):null,x&&n.length>0?_jsx(ThumbnailStrip,{data:n,currentIndex:D,renderThumbnail:v,labels:T,onSelect:e=>{const t=resolveHaptic(S,"selection");t&&triggerHaptic(t),W(e,!0)},theme:j}):null]})}CarouselRoot.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:i})=>{const s=useTheme(),a="screen"===e?i||320:e;return _jsxs(View,{style:[carouselSkeletonStyles.container,r],children:[_jsx(Skeleton,{width:a,height:160,radius:"md"}),t?_jsx(View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:s.space.md}],children:SKELETON_PAGINATION_DOTS.map(e=>_jsx(Skeleton,"numbers"===n?{width:24,height:16,radius:"sm",style:{marginHorizontal:s.space.xs}}:"bars"===n?{width:20,height:4,radius:"pill",style:{marginHorizontal:s.space.xxs}}:{shape:"circle",width:8,height:8,style:{marginHorizontal:s.space.xs}},e))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const SKELETON_PAGINATION_DOTS=["first","second","third"],carouselSkeletonStyles=StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=Object.assign(CarouselRoot,{Skeleton:CarouselSkeleton}),Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:i,theme:s,labels:a})=>{const l=useMemo(()=>buildPaginationStyles(s),[s]);if("numbers"===i)return _jsx(View,{style:l.numbersWrap,children:_jsx(Text,{variant:"bodySmall",weight:"medium",color:"secondary",style:l.numbersText,accessibilityLabel:a.slideOf(t+1,e),children:`${t+1} / ${e}`})});const o=Array.from({length:e},(e,t)=>t),c="bars"===i,u=c?24:6,d=c?36:16,m=c?3:6;return _jsx(View,{style:l.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o.map(e=>{const i=[(e-1)*r,e*r,(e+1)*r],a=n.interpolate({inputRange:i,outputRange:[u,d,u],extrapolate:"clamp"}),l=n.interpolate({inputRange:i,outputRange:[.5,1,.5],extrapolate:"clamp"});return _jsx(Animated.View,{style:[{width:a,height:m,marginHorizontal:s.space.xs,borderRadius:s.radius.pill,...smoothCorners,backgroundColor:e===t?s.colors.primary:s.colors.border,opacity:l}]},e)})})};function ThumbnailStrip({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:i,labels:s}){const a=useMemo(()=>buildThumbStyles(i),[i]),l=useMemo(()=>e.map((e,t)=>({key:`thumb-${t}`,item:e,index:t})),[e]);return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:a.row,accessibilityRole:"tablist",children:l.map(({key:e,item:l,index:o})=>_jsx(ThumbnailItem,{item:l,index:o,isActive:o===t,renderThumbnail:n,onPress:()=>r(o),theme:i,styles:a,labels:s},e))})}function ThumbnailItem({item:e,index:t,isActive:n,renderThumbnail:r,onPress:i,theme:s,styles:a,labels:l}){const o=useRef(createAnimatedValue(n?1.1:1)).current;useEffect(()=>{const e=Animated.spring(o,{toValue:n?1.1:1,useNativeDriver:nativeDriver,friction:6,tension:80});return e.start(),()=>e.stop()},[n,o]);const c=useMemo(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?_jsx(Image,{source:{uri:e.uri},style:a.image,resizeMode:"cover"}):_jsx(View,{style:[a.placeholder,{backgroundColor:s.colors["bg-subtle"]}],children:_jsx(Text,{variant:"caption",weight:"semibold",color:"secondary",children:t+1})}),[e,t,r,s,a]);return _jsx(Pressable,{onPress:i,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:l.goToSlide(t+1),children:_jsx(Animated.View,{style:[a.thumb,{borderColor:n?s.colors.primary:"transparent",transform:[{scale:o}]}],children:c})})}const buildThumbStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.sm,paddingVertical:e.space.sm},thumb:{width:40,height:40,marginHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>StyleSheet.create({container:{width:"100%"}}),buildPaginationStyles=e=>StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersText:{textAlign:"center"}});export{Carousel};export default Carousel;
1
+ "use strict";import{useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,AppState,Dimensions,FlatList,Image,Pressable,ScrollView,StyleSheet,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CAROUSEL_LABELS=Object.freeze({carousel:"Carousel",slideOf:(e,t)=>`Slide ${e} of ${t}`,goToSlide:e=>`Go to slide ${e}`});function CarouselRoot({ref:e,...t}){const{data:n,renderItem:r,keyExtractor:i,index:s,defaultIndex:a=0,onIndexChange:l,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:g="screen",spacing:b=0,containerStyle:p,accessibilityLabel:f,testID:y,showThumbnails:x=!1,haptic:S,renderThumbnail:v,loading:w=!1,labels:C}=t;assertValidValue("Carousel","paginationStyle",t.paginationStyle,["dots","bars","numbers"]);const T=useMemo(()=>({...DEFAULT_CAROUSEL_LABELS,...C}),[C]),j=useTheme(),k=d||c,[I,_]=useState(()=>Dimensions.get("window").width),A="screen"===g?I:g,E=A+b,R=useRef(null),V=useRef(createAnimatedValue(0)).current,D=clamp("number"==typeof s?s:a,0,Math.max(0,n.length-1)),[L,O]=useState(D),H=useRef(null),M=useRef(null),P=useRef(!1),z=useRef(L);z.current=L;const N=useCallback(e=>{const t=clamp(e,0,Math.max(0,n.length-1));O(e=>e===t?e:(l?.(t),t))},[n.length,l]),W=useCallback((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);R.current?.scrollToOffset({offset:r*E,animated:t}),N(r)},[n.length,E,N]),$=useRef(W);$.current=W;const F=useCallback(()=>{if(0===n.length)return;const e=z.current+1;e>=n.length?k&&W(0,!1):W(e,!0)},[n.length,k,W]),U=useCallback(()=>{if(0===n.length)return;const e=z.current-1;e<0?k&&W(n.length-1,!1):W(e,!0)},[n.length,k,W]);useImperativeHandle(e,()=>({scrollTo:W,next:F,prev:U}),[W,F,U]),useEffect(()=>{"number"==typeof s&&s!==z.current&&$.current(s,!0)},[s]);const B=useCallback(()=>{H.current&&(clearInterval(H.current),H.current=null)},[]),G=useCallback(()=>{!c||n.length<=1||(B(),H.current=setInterval(()=>{if(P.current)return;const e=z.current+1;e>=n.length?W(0,!1):W(e,!0)},u))},[c,u,n.length,W,B]);useEffect(()=>(G(),()=>{B(),M.current&&clearTimeout(M.current)}),[G,B]),useEffect(()=>{const e=AppState.addEventListener("change",e=>{"active"!==e?(B(),M.current&&(clearTimeout(M.current),M.current=null)):G()});return()=>e.remove()},[G,B]);const K=m&&n.length>1&&"numbers"!==h||void 0!==o,X=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{x:V}}}],{useNativeDriver:!1,listener:o?e=>o(e.nativeEvent.contentOffset.x):void 0}),[V,o]),q=useCallback(e=>{if(E<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/E);N(n)},[E,N]),J=useCallback(()=>{P.current=!0,B(),M.current&&(clearTimeout(M.current),M.current=null)},[B]),Q=useCallback(()=>{P.current=!1,c&&(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{G()},1e3))},[c,G]),Y=useCallback(e=>{switch(e.nativeEvent.actionName){case"increment":F();break;case"decrement":U()}},[F,U]),Z=useMemo(()=>buildStyles(j),[j]),ee=useCallback(({item:e,index:t})=>_jsx(View,{style:{width:A,marginRight:t===n.length-1?0:b},accessibilityElementsHidden:t!==L,importantForAccessibility:t===L?"yes":"no-hide-descendants",children:r(e,t)}),[r,A,b,n.length,L]),te=useCallback((e,t)=>String(t),[]),ne=useCallback((e,t)=>({length:E,offset:E*t,index:t}),[E]);return w?_jsx(CarouselSkeleton,{...t,containerWidth:I}):_jsxs(View,{style:[Z.container,p],onLayout:e=>_(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:f??T.carousel,accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:L,text:T.slideOf(L+1,n.length)},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Y,testID:y,children:[_jsx(FlatList,{ref:R,testID:y?`${y}-list`:void 0,data:n,keyExtractor:i??te,renderItem:ee,horizontal:!0,pagingEnabled:"screen"===g&&0===b,snapToInterval:E,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:K?X:void 0,scrollEventThrottle:K?16:void 0,onMomentumScrollEnd:q,onScrollBeginDrag:J,onScrollEndDrag:Q,getItemLayout:ne,initialScrollIndex:D,bounces:!1}),m&&n.length>1?_jsx(Pagination,{count:n.length,currentIndex:L,scrollX:V,slideStride:E,variant:h,theme:j,labels:T}):null,x&&n.length>0?_jsx(ThumbnailStrip,{data:n,currentIndex:L,renderThumbnail:v,labels:T,onSelect:e=>{const t=resolveHaptic(S,"selection");t&&triggerHaptic(t),W(e,!0)},theme:j}):null]})}CarouselRoot.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:i})=>{const s=useTheme(),a="screen"===e?i||320:e;return _jsxs(View,{style:[carouselSkeletonStyles.container,r],children:[_jsx(Skeleton,{width:a,height:160,radius:"md"}),t?_jsx(View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:s.space.md}],children:SKELETON_PAGINATION_DOTS.map(e=>_jsx(Skeleton,"numbers"===n?{width:24,height:16,radius:"sm",style:{marginHorizontal:s.space.xs}}:"bars"===n?{width:20,height:4,radius:"pill",style:{marginHorizontal:s.space.xxs}}:{shape:"circle",width:8,height:8,style:{marginHorizontal:s.space.xs}},e))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const SKELETON_PAGINATION_DOTS=["first","second","third"],carouselSkeletonStyles=StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=Object.assign(CarouselRoot,{Skeleton:CarouselSkeleton}),Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:i,theme:s,labels:a})=>{const l=useMemo(()=>buildPaginationStyles(s),[s]);if("numbers"===i)return _jsx(View,{style:l.numbersWrap,children:_jsx(Text,{variant:"bodySmall",weight:"medium",color:"secondary",style:l.numbersText,accessibilityLabel:a.slideOf(t+1,e),children:`${t+1} / ${e}`})});const o=Array.from({length:e},(e,t)=>t),c="bars"===i,u=c?24:6,d=c?36:16,m=c?3:6;return _jsx(View,{style:l.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o.map(e=>{const i=[(e-1)*r,e*r,(e+1)*r],a=n.interpolate({inputRange:i,outputRange:[u,d,u],extrapolate:"clamp"}),l=n.interpolate({inputRange:i,outputRange:[.5,1,.5],extrapolate:"clamp"});return _jsx(Animated.View,{style:[{width:a,height:m,marginHorizontal:s.space.xs,borderRadius:s.radius.pill,...smoothCorners,backgroundColor:e===t?s.colors.primary:s.colors.border,opacity:l}]},e)})})};function ThumbnailStrip({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:i,labels:s}){const a=useMemo(()=>buildThumbStyles(i),[i]),l=useMemo(()=>e.map((e,t)=>({key:`thumb-${t}`,item:e,index:t})),[e]);return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:a.row,accessibilityRole:"tablist",children:l.map(({key:e,item:l,index:o})=>_jsx(ThumbnailItem,{item:l,index:o,isActive:o===t,renderThumbnail:n,onPress:()=>r(o),theme:i,styles:a,labels:s},e))})}function ThumbnailItem({item:e,index:t,isActive:n,renderThumbnail:r,onPress:i,theme:s,styles:a,labels:l}){const o=useRef(createAnimatedValue(n?1.1:1)).current;useEffect(()=>{const e=Animated.spring(o,{toValue:n?1.1:1,useNativeDriver:nativeDriver,friction:6,tension:80});return e.start(),()=>e.stop()},[n,o]);const c=useMemo(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?_jsx(Image,{source:{uri:e.uri},style:a.image,resizeMode:"cover"}):_jsx(View,{style:[a.placeholder,{backgroundColor:s.colors["bg-subtle"]}],children:_jsx(Text,{variant:"caption",weight:"semibold",color:"secondary",children:t+1})}),[e,t,r,s,a]);return _jsx(Pressable,{onPress:i,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:l.goToSlide(t+1),children:_jsx(Animated.View,{style:[a.thumb,{borderColor:n?s.colors.primary:"transparent",transform:[{scale:o}]}],children:c})})}const buildThumbStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.sm,paddingVertical:e.space.sm},thumb:{width:40,height:40,marginHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>StyleSheet.create({container:{width:"100%"}}),buildPaginationStyles=e=>StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersText:{textAlign:"center"}});export{Carousel};export default Carousel;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{Calendar}from"../Calendar/index.js";import{daysBetween,startOfDay,startOfMonth}from"../Calendar/calendarDates.js";import{Modal}from"../Modal/index.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_DATE_RANGE_PICKER_LABELS=Object.freeze({title:"Select Date Range",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss"});const formatRangePart=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short"}).format(e),DateRangePicker=forwardRef((e,t)=>{const{open:a,value:s,onChange:r,onClose:o,label:i,help:l,placeholder:n,helperText:d,error:c,required:m,disabled:u,size:g,variant:f,clearable:h,onClear:p,leftIcon:b,trailing:y,triggerStyle:x,valueStyle:D,labelStyle:S,messageStyle:C,accessibilityLabel:w,triggerLabels:j,formatValue:R,minDate:v,maxDate:_,disabledDates:T,marks:k,locale:M="en-IN",weekStartsOn:P=0,title:B,labels:L,maxRange:V,haptic:A,style:I,containerStyle:O,headerLabelStyle:z,navButtonStyle:E,footerButtonStyle:H,testID:G}=e,N={label:i,help:l,placeholder:n,helperText:d,error:c,required:m,disabled:u,size:g,variant:f,clearable:h,onClear:p,leftIcon:b,trailing:y,triggerStyle:x,valueStyle:D,labelStyle:S,messageStyle:C,accessibilityLabel:w},$=void 0!==a,[F,W]=useState(!1),q=void 0!==a?a:F,K=$?G:G?`${G}-calendar`:void 0,U=useTheme(),[Y,J]=useModalInsets(),Q=useMemo(()=>buildStyles(U),[U]),X=useMemo(()=>({...DEFAULT_DATE_RANGE_PICKER_LABELS,...L}),[L]),[Z,ee]=useState(()=>startOfMonth(s.start??new Date)),[te,ae]=useState(s.start?startOfDay(s.start):null),[se,re]=useState(s.end?startOfDay(s.end):null),oe=useRef(createAnimatedValue(0)).current,ie=useRef(0);useEffect(()=>{if(s.start){const e=startOfDay(s.start);ae(e),ee(startOfMonth(e))}else ae(null);s.end?re(startOfDay(s.end)):re(null)},[s.start,s.end]);const le=useCallback(e=>{if(e.end&&V&&daysBetween(e.start,e.end)+1>V)return!1!==A&&triggerHaptic("notificationWarning"),ae(e.end),void re(null);ae(e.start),re(e.end??null)},[V,A]),ne=useCallback(()=>{$?o?.():W(!1)},[$,o]),{handleGesture:de,opacity:ce}=useDragToDismiss({drag:oe,travel:()=>ie.current||320,onDismiss:ne});useEffect(()=>{q&&(setNativeValue(oe,0),setNativeValue(ce,1))},[q,oe,ce]);const me=useCallback(()=>{!1!==A&&triggerHaptic("selection"),ne()},[ne,A]),ue=useCallback(()=>{te&&se&&(!1!==A&&triggerHaptic("notificationSuccess"),r?.({start:te,end:se}),ne())},[ne,r,te,se,A]),ge=useMemo(()=>te&&se?`${formatRangePart(te,M)} — ${formatRangePart(se,M)}`:te?`${formatRangePart(te,M)} — …`:"—",[te,se,M]),fe=!te||!se,he=_jsxs(View,{style:[Q.card,O,I],ref:t,accessible:!1,testID:K,children:[_jsx(GestureDetector,{gesture:de,children:_jsxs(View,{style:Q.grabArea,children:[_jsx(View,{style:Q.handle}),_jsxs(View,{style:Q.titleRow,children:[_jsx(Text,{variant:"title",style:Q.title,accessibilityRole:"header",children:B??X.title}),_jsx(Text,{variant:"bodySmall",style:Q.subtitle,accessibilityLiveRegion:"polite",children:ge})]})]})}),_jsx(Calendar,{selectionMode:"range",value:te?{start:te,end:se??void 0}:null,onChange:le,month:Z,onMonthChange:ee,minDate:v,maxDate:_,disabledDates:T,marks:k,weekStartsOn:P,locale:M,haptic:A,headerLabelStyle:z,navButtonStyle:E,testID:K?`${K}-grid`:void 0}),_jsxs(View,{style:Q.footer,children:[_jsx(Pressable,{onPress:me,style:({pressed:e})=>[Q.footerBtn,Q.footerCancel,e&&Q.footerBtnPressed,H],accessibilityRole:"button",accessibilityLabel:X.cancel,children:_jsx(Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["text-muted"]}],children:X.cancel})}),_jsx(Pressable,{onPress:ue,disabled:fe,style:({pressed:e})=>[Q.footerBtn,Q.footerConfirm,{backgroundColor:U.colors.primary,opacity:fe?.5:1},e&&{backgroundColor:U.colors["primary-hover"]},H],accessibilityRole:"button",accessibilityLabel:X.confirm,accessibilityState:{disabled:fe},"aria-disabled":fe,children:_jsx(Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["on-primary"]}],children:X.confirm})})]})]}),pe=useMemo(()=>{if(!s.start||!s.end)return"";const e={start:s.start,end:s.end};return R?R(e):`${e.start.toLocaleDateString()} – ${e.end.toLocaleDateString()}`},[s.start,s.end,R]);return _jsxs(_Fragment,{children:[$?null:_jsx(PickerTrigger,{...N,labels:j,value:pe,onPress:()=>W(!0),testID:G}),_jsx(Modal,{open:q,onClose:ne,presentation:"bottom",bare:!0,haptic:!1,labels:{close:X.dismiss},onInsetsChange:J,children:_jsx(GestureHandlerRootView,{style:Q.gestureRoot,children:_jsx(Animated.View,{style:[Q.sheetWrap,{paddingBottom:Math.max(Y.bottom,U.space.lg),opacity:ce,transform:[{translateY:oe}]}],onLayout:e=>{ie.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:he})})})]})});DateRangePicker.displayName="DateRangePicker";const buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({gestureRoot:{width:"100%"},sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},subtitle:{marginTop:e.space.xxs,fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),color:e.colors["text-muted"]},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};export{DateRangePicker};export default DateRangePicker;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{Calendar}from"../Calendar/index.js";import{daysBetween,startOfDay,startOfMonth}from"../Calendar/calendarDates.js";import{Modal}from"../Modal/index.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_DATE_RANGE_PICKER_LABELS=Object.freeze({title:"Select Date Range",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss"});const formatRangePart=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short"}).format(e),DateRangePicker=forwardRef((e,t)=>{const{open:a,value:s,onChange:r,onClose:o,label:i,help:l,placeholder:n,helperText:d,error:c,required:m,disabled:u,size:g,variant:f,clearable:h,onClear:p,leftIcon:b,trailing:y,triggerStyle:x,valueStyle:D,labelStyle:S,messageStyle:C,accessibilityLabel:w,triggerLabels:j,formatValue:R,minDate:v,maxDate:_,disabledDates:T,marks:k,locale:M="en-IN",weekStartsOn:P=0,title:B,labels:I,maxRange:L,haptic:V,style:A,containerStyle:O,headerLabelStyle:z,navButtonStyle:E,footerButtonStyle:H,testID:G}=e,N={label:i,help:l,placeholder:n,helperText:d,error:c,required:m,disabled:u,size:g,variant:f,clearable:h,onClear:p,leftIcon:b,trailing:y,triggerStyle:x,valueStyle:D,labelStyle:S,messageStyle:C,accessibilityLabel:w},$=void 0!==a,[F,W]=useState(!1),q=void 0!==a?a:F,K=$?G:G?`${G}-calendar`:void 0,U=useTheme(),[Y,J]=useModalInsets(),Q=useMemo(()=>buildStyles(U),[U]),X=useMemo(()=>({...DEFAULT_DATE_RANGE_PICKER_LABELS,...I}),[I]),[Z,ee]=useState(()=>startOfMonth(s.start??new Date)),[te,ae]=useState(s.start?startOfDay(s.start):null),[se,re]=useState(s.end?startOfDay(s.end):null),oe=useRef(createAnimatedValue(0)).current,ie=useRef(0);useEffect(()=>{if(s.start){const e=startOfDay(s.start);ae(e),ee(startOfMonth(e))}else ae(null);s.end?re(startOfDay(s.end)):re(null)},[s.start,s.end]);const le=useCallback(e=>{if(e.end&&L&&daysBetween(e.start,e.end)+1>L)return!1!==V&&triggerHaptic("notificationWarning"),ae(e.end),void re(null);ae(e.start),re(e.end??null)},[L,V]),ne=useCallback(()=>{$?o?.():W(!1)},[$,o]),{handleGesture:de,opacity:ce}=useDragToDismiss({drag:oe,travel:()=>ie.current||320,onDismiss:ne,testID:G});useEffect(()=>{q&&(setNativeValue(oe,0),setNativeValue(ce,1))},[q,oe,ce]);const me=useCallback(()=>{!1!==V&&triggerHaptic("selection"),ne()},[ne,V]),ue=useCallback(()=>{te&&se&&(!1!==V&&triggerHaptic("notificationSuccess"),r?.({start:te,end:se}),ne())},[ne,r,te,se,V]),ge=useMemo(()=>te&&se?`${formatRangePart(te,M)} — ${formatRangePart(se,M)}`:te?`${formatRangePart(te,M)} — …`:"—",[te,se,M]),fe=!te||!se,he=_jsxs(View,{style:[Q.card,O,A],ref:t,accessible:!1,testID:K,children:[_jsx(GestureDetector,{gesture:de,children:_jsxs(View,{style:Q.grabArea,children:[_jsx(View,{style:Q.handle}),_jsxs(View,{style:Q.titleRow,children:[_jsx(Text,{variant:"title",style:Q.title,accessibilityRole:"header",children:B??X.title}),_jsx(Text,{variant:"bodySmall",style:Q.subtitle,accessibilityLiveRegion:"polite",children:ge})]})]})}),_jsx(Calendar,{selectionMode:"range",value:te?{start:te,end:se??void 0}:null,onChange:le,month:Z,onMonthChange:ee,minDate:v,maxDate:_,disabledDates:T,marks:k,weekStartsOn:P,locale:M,haptic:V,headerLabelStyle:z,navButtonStyle:E,testID:K?`${K}-grid`:void 0}),_jsxs(View,{style:Q.footer,children:[_jsx(Pressable,{onPress:me,style:({pressed:e})=>[Q.footerBtn,Q.footerCancel,e&&Q.footerBtnPressed,H],accessibilityRole:"button",accessibilityLabel:X.cancel,children:_jsx(Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["text-muted"]}],children:X.cancel})}),_jsx(Pressable,{onPress:ue,disabled:fe,style:({pressed:e})=>[Q.footerBtn,Q.footerConfirm,{backgroundColor:U.colors.primary,opacity:fe?.5:1},e&&{backgroundColor:U.colors["primary-hover"]},H],accessibilityRole:"button",accessibilityLabel:X.confirm,accessibilityState:{disabled:fe},"aria-disabled":fe,children:_jsx(Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["on-primary"]}],children:X.confirm})})]})]}),pe=useMemo(()=>{if(!s.start||!s.end)return"";const e={start:s.start,end:s.end};return R?R(e):`${e.start.toLocaleDateString()} – ${e.end.toLocaleDateString()}`},[s.start,s.end,R]);return _jsxs(_Fragment,{children:[$?null:_jsx(PickerTrigger,{...N,labels:j,value:pe,onPress:()=>W(!0),testID:G}),_jsx(Modal,{open:q,onClose:ne,presentation:"bottom",bare:!0,haptic:!1,labels:{close:X.dismiss},onInsetsChange:J,children:_jsx(GestureHandlerRootView,{style:Q.gestureRoot,children:_jsx(Animated.View,{style:[Q.sheetWrap,{paddingBottom:Math.max(Y.bottom,U.space.lg),opacity:ce,transform:[{translateY:oe}]}],onLayout:e=>{ie.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:he})})})]})});DateRangePicker.displayName="DateRangePicker";const buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({gestureRoot:{width:"100%"},sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},subtitle:{marginTop:e.space.xxs,fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),color:e.colors["text-muted"]},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};export{DateRangePicker};export default DateRangePicker;
@@ -1 +1 @@
1
- "use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,View}from"react-native";import{useFieldErrorAnchor}from"../../hooks/useFieldErrorScroll.js";import{createAnimatedValue,fontFor,resolveFieldSize,useTheme}from"../../theme/index.js";import{ariaFromState}from"../../utils/ariaState.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{TextInkContext,useTextInk}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0};export const pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const o=e[t];if(o&&"transparent"!==o)return o}return e.bottom};export const resolveFieldTextStyle=(e,t={})=>{const{disabled:o=!1}=t;return{color:o?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:o?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:fontFor(e,"normal")}};export const RequiredMark=()=>{const e=useTheme();return _jsx(Text,{style:{color:e.colors["danger-text"]},children:` ${e.settings.components.field?.requiredMarker??"*"}`})};export const RequiredPlaceholder=({text:e,color:t,fontSize:o,weightStyle:r,align:i="center",paddingTop:l,textAlign:s})=>_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{justifyContent:"top"===i?"flex-start":"center",paddingTop:l}],children:_jsxs(Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:o,...r,includeFontPadding:!1,textAlign:s},children:[e,_jsx(RequiredMark,{})]})});export const FieldErrorGlyph=({size:e,color:t})=>{const o=useTheme().settings.icons.error??defaultIcons.error;return _jsx(_Fragment,{children:o({size:e,color:t})})};export const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;export const fieldTextAsString=e=>"string"==typeof e?e:void 0;export const FieldLabel=({children:e,size:t="md",required:o=!1,help:r,color:i,style:l})=>{const s=useTheme(),n=resolveFieldSize(s,t),d=hasFieldText(r),a=useTextInk(l,n["label-text"],i??s.colors["field-label"]),c=_jsxs(Text,{style:[familyStyles.label,{color:i??s.colors["field-label"],fontSize:n["label-text"],...fontFor(s,"semibold"),marginBottom:d?s.space.none:n["label-gap"]},d?familyStyles.labelShrink:null,l],children:[_jsx(TextInkContext.Provider,{value:a,children:e}),o?_jsx(RequiredMark,{}):null]});return d?_jsxs(View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,_jsx(View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:r})]}):c};export const FieldMessage=({text:e,error:t=!1,size:o="md",style:r})=>{const i=useTheme(),l=resolveFieldSize(i,o),s=t?i.colors["field-message"]:i.colors["text-muted"],n=useTextInk(r,l["message-text"],s);return hasFieldText(e)?_jsxs(View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:i.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?_jsx(FieldErrorGlyph,{size:l["message-text"],color:s}):null,_jsx(Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...fontFor(i,"normal")},r],children:_jsx(TextInkContext.Provider,{value:n,children:e})})]}):null};const familyStyles=StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}});export const resolveVariantColors=(e,t)=>{let o,r,i,l,s;"outline"===t?(o=e.colors["field-bg"],r=e.colors["field-bg-focus"],i=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(o="transparent",r=void 0,i="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(o=e.colors["field-bg"],r=void 0,i=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),d=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:o,backgroundIdleFilled:o,backgroundFocused:r,backgroundError:void 0,backgroundDisabled:i,borderIdle:n,borderFocused:d,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(d)}};export const FieldBase=e=>{assertValidValue("FieldBase","variant",e.variant,["outline","filled","underline"]),assertValidValue("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:o,focused:r=!1,disabled:i=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:d=!1,trailing:a,slotAlign:c="center",slotLineHeight:u,topNotch:b,children:p,onPress:m,pressFeedback:g=!0,minHeight:h,maxHeight:f,width:x,height:y,paddingHorizontal:S,paddingLeft:F,paddingRight:v,paddingVertical:j,radius:R,borderTopLeftRadius:T,borderTopRightRadius:k,borderBottomLeftRadius:C,borderBottomRightRadius:w,borderWidth:_,borderTopWidth:V,borderRightWidth:I,borderBottomWidth:z,borderLeftWidth:L,gap:B,flushBottom:E=!1,style:D,testID:W,accessibilityRole:A,accessibilityLabel:q,accessibilityState:M,accessibilityHint:P}=e,H=useTheme(),G=useFieldErrorAnchor(l),N=useMemo(()=>buildStyles(),[]),O=o??H.settings.components.field?.defaultVariant??"outline",$=resolveFieldSize(H,t),J=useMemo(()=>resolveVariantColors(H,O),[H,O]),K=l?2:r?1:0,Q=useRef(createAnimatedValue(K)).current;useEffect(()=>{const e=Animated.timing(Q,{toValue:K,duration:H.motion.duration.fast,easing:Easing.bezier(...H.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[K,Q,H.motion.duration.fast,H.motion.ease["in-out"]]);const U=[0,1,2],X=s?J.backgroundIdleFilled:J.backgroundIdleEmpty,Y=J.backgroundFocused??X,Z=J.backgroundError??X,ee=i?J.backgroundDisabled:Q.interpolate({inputRange:U,outputRange:[X,Y,Z]}),te=J.borderIdle,oe=J.borderFocused,re=J.borderError,ie={top:V,right:I,bottom:z,left:L},le={top:ie.top??_??J.borderWidth.top,right:ie.right??_??J.borderWidth.right,bottom:ie.bottom??_??J.borderWidth.bottom,left:ie.left??_??J.borderWidth.left},se="underline"===O,ne=se?H.radius.none:R?H.radius[R]:$.radius,de=se?{tl:H.radius.none,tr:H.radius.none,bl:H.radius.none,br:H.radius.none}:{tl:T??ne,tr:k??ne,bl:C??ne,br:w??ne},sideColor=e=>Q.interpolate({inputRange:U,outputRange:[te[e],oe[e],re[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,ae=!se&&de.tl===de.tr&&de.tl===de.bl&&de.tl===de.br&&sameOnEverySide(le)&&sameOnEverySide(te)&&sameOnEverySide(oe)&&sameOnEverySide(re)&&sameOnEverySide(J.borderDisabled),ce=useSquircle(ae,de.tl),ue=ce.active?{borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent",borderLeftColor:"transparent"}:i?{borderTopColor:J.borderDisabled.top,borderRightColor:J.borderDisabled.right,borderBottomColor:J.borderDisabled.bottom,borderLeftColor:J.borderDisabled.left}:{borderTopColor:sideColor("top"),borderRightColor:sideColor("right"),borderBottomColor:sideColor("bottom"),borderLeftColor:sideColor("left")},be=i?J.borderDisabled.top:sideColor("top"),pe={minHeight:y??h??$["min-height"],maxHeight:f,paddingHorizontal:S??$["padding-x"],paddingVertical:j??$["padding-y"],paddingLeft:F??S??$["padding-x"],paddingRight:v??S??$["padding-x"],backgroundColor:ce.active?"transparent":ee,columnGap:B??H.space.md,alignItems:"top"===c?"flex-start":"center",borderTopLeftRadius:de.tl,borderTopRightRadius:de.tr,borderBottomLeftRadius:de.bl,borderBottomRightRadius:de.br,borderCurve:smoothCorners.borderCurve,borderTopWidth:le.top,borderRightWidth:le.right,borderBottomWidth:le.bottom,borderLeftWidth:le.left,...ue,...void 0!==x?{width:x}:null,...void 0!==y?{height:y}:null},me=useRef(K);me.current=K,useEffect(()=>{Q.setValue(me.current)},[J,Q]);const ge=E?{marginBottom:H.space.none}:void 0,he={disabled:i,...M},fe="top"===c,xe=fe?{alignSelf:"flex-start",marginTop:Math.max(0,((u??$.icon)-$.icon)/2)}:null,ye=y??h??$["min-height"],Se=(()=>{if(!b)return 0;const e=Math.min(de.tl,ye/2),t=b.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),Fe=b&&le.top>0?_jsx(Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-le.top,left:b.left-le.left,width:b.width,height:le.top+Se,backgroundColor:ee}}):null,renderInner=e=>_jsxs(_Fragment,{children:[ce.active&&ce.size?_jsx(SquircleFill,{width:ce.size.width,height:ce.size.height,radius:de.tl,fill:e&&!i?H.colors["surface-pressed"]:ee,stroke:be,strokeWidth:le.top}):null,Fe,null!=n?_jsx(View,{style:[N.slot,xe],children:n}):null,null!=n&&d?_jsx(View,{pointerEvents:"none",style:[N.divider,xe,{height:$.icon,backgroundColor:H.colors["field-border"]}]}):null,_jsx(View,{style:[N.content,fe?N.contentTop:null],children:p}),null!=a?_jsx(View,{style:[N.slot,xe],children:a}):null]}),ve=_jsx(Animated.View,{ref:G,onLayout:ce.onLayout,style:[N.box,pe,m?null:ge,D],accessibilityRole:A,accessibilityLabel:q,accessibilityHint:P,accessibilityState:he,...ariaFromState(he),testID:W,children:renderInner(!1)});return m&&!g?_jsx(Pressable,{onPress:m,disabled:i,accessible:!1,style:ge,children:ve}):m?_jsx(Pressable,{onPress:m,disabled:i,style:ge,accessibilityRole:A??"button",accessibilityLabel:q,accessibilityHint:P,accessibilityState:he,...ariaFromState(he),testID:W,children:({pressed:e})=>_jsx(Animated.View,{ref:G,onLayout:ce.onLayout,style:[N.box,pe,!e||i||ce.active?null:{backgroundColor:H.colors["surface-pressed"]},D],children:renderInner(e)})}):ve};FieldBase.displayName="FieldBase";const buildStyles=()=>StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});export default FieldBase;
1
+ "use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,Easing,Platform,Pressable,StyleSheet,Text,View}from"react-native";import{useFieldErrorAnchor}from"../../hooks/useFieldErrorScroll.js";import{createAnimatedValue,fontFor,resolveFieldSize,useTheme}from"../../theme/index.js";import{ariaFromState}from"../../utils/ariaState.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{TextInkContext,useTextInk}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0};export const pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const o=e[t];if(o&&"transparent"!==o)return o}return e.bottom};export const resolveFieldTextStyle=(e,t={})=>{const{disabled:o=!1}=t;return{color:o?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:o?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:fontFor(e,"normal")}};export const RequiredMark=()=>{const e=useTheme();return _jsx(Text,{style:{color:e.colors["danger-text"]},..."web"===Platform.OS?{"aria-hidden":!0}:null,children:` ${e.settings.components.field?.requiredMarker??"*"}`})};export const RequiredPlaceholder=({text:e,color:t,fontSize:o,weightStyle:r,align:i="center",paddingTop:l,textAlign:s})=>_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{justifyContent:"top"===i?"flex-start":"center",paddingTop:l}],children:_jsxs(Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:o,...r,includeFontPadding:!1,textAlign:s},children:[e,_jsx(RequiredMark,{})]})});export const FieldErrorGlyph=({size:e,color:t})=>{const o=useTheme().settings.icons.error??defaultIcons.error;return _jsx(_Fragment,{children:o({size:e,color:t})})};export const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;export const fieldTextAsString=e=>"string"==typeof e?e:void 0;export const FieldLabel=({children:e,size:t="md",required:o=!1,help:r,color:i,style:l})=>{const s=useTheme(),n=resolveFieldSize(s,t),d=hasFieldText(r),a=useTextInk(l,n["label-text"],i??s.colors["field-label"]),c=_jsxs(Text,{style:[familyStyles.label,{color:i??s.colors["field-label"],fontSize:n["label-text"],...fontFor(s,"semibold"),marginBottom:d?s.space.none:n["label-gap"]},d?familyStyles.labelShrink:null,l],children:[_jsx(TextInkContext.Provider,{value:a,children:e}),o?_jsx(RequiredMark,{}):null]});return d?_jsxs(View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,_jsx(View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:r})]}):c};export const FieldMessage=({text:e,error:t=!1,size:o="md",style:r})=>{const i=useTheme(),l=resolveFieldSize(i,o),s=t?i.colors["field-message"]:i.colors["text-muted"],n=useTextInk(r,l["message-text"],s);return hasFieldText(e)?_jsxs(View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:i.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?_jsx(FieldErrorGlyph,{size:l["message-text"],color:s}):null,_jsx(Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...fontFor(i,"normal")},r],children:_jsx(TextInkContext.Provider,{value:n,children:e})})]}):null};const familyStyles=StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}});export const resolveVariantColors=(e,t)=>{let o,r,i,l,s;"outline"===t?(o=e.colors["field-bg"],r=e.colors["field-bg-focus"],i=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(o="transparent",r=void 0,i="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(o=e.colors["field-bg"],r=void 0,i=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),d=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:o,backgroundIdleFilled:o,backgroundFocused:r,backgroundError:void 0,backgroundDisabled:i,borderIdle:n,borderFocused:d,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(d)}};export const FieldBase=e=>{assertValidValue("FieldBase","variant",e.variant,["outline","filled","underline"]),assertValidValue("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:o,focused:r=!1,disabled:i=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:d=!1,trailing:a,slotAlign:c="center",slotLineHeight:u,topNotch:b,children:p,onPress:m,pressFeedback:g=!0,minHeight:h,maxHeight:f,width:x,height:y,paddingHorizontal:S,paddingLeft:F,paddingRight:v,paddingVertical:j,radius:R,borderTopLeftRadius:T,borderTopRightRadius:k,borderBottomLeftRadius:C,borderBottomRightRadius:w,borderWidth:_,borderTopWidth:I,borderRightWidth:V,borderBottomWidth:z,borderLeftWidth:L,gap:B,flushBottom:D=!1,style:E,testID:W,accessibilityRole:A,accessibilityLabel:P,accessibilityState:q,accessibilityHint:M}=e,H=useTheme(),G=useFieldErrorAnchor(l),N=useMemo(()=>buildStyles(),[]),O=o??H.settings.components.field?.defaultVariant??"outline",$=resolveFieldSize(H,t),J=useMemo(()=>resolveVariantColors(H,O),[H,O]),K=l?2:r?1:0,Q=useRef(createAnimatedValue(K)).current;useEffect(()=>{const e=Animated.timing(Q,{toValue:K,duration:H.motion.duration.fast,easing:Easing.bezier(...H.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[K,Q,H.motion.duration.fast,H.motion.ease["in-out"]]);const U=[0,1,2],X=s?J.backgroundIdleFilled:J.backgroundIdleEmpty,Y=J.backgroundFocused??X,Z=J.backgroundError??X,ee=i?J.backgroundDisabled:Q.interpolate({inputRange:U,outputRange:[X,Y,Z]}),te=J.borderIdle,oe=J.borderFocused,re=J.borderError,ie={top:I,right:V,bottom:z,left:L},le={top:ie.top??_??J.borderWidth.top,right:ie.right??_??J.borderWidth.right,bottom:ie.bottom??_??J.borderWidth.bottom,left:ie.left??_??J.borderWidth.left},se="underline"===O,ne=se?H.radius.none:R?H.radius[R]:$.radius,de=se?{tl:H.radius.none,tr:H.radius.none,bl:H.radius.none,br:H.radius.none}:{tl:T??ne,tr:k??ne,bl:C??ne,br:w??ne},sideColor=e=>Q.interpolate({inputRange:U,outputRange:[te[e],oe[e],re[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,ae=!se&&de.tl===de.tr&&de.tl===de.bl&&de.tl===de.br&&sameOnEverySide(le)&&sameOnEverySide(te)&&sameOnEverySide(oe)&&sameOnEverySide(re)&&sameOnEverySide(J.borderDisabled),ce=useSquircle(ae,de.tl),ue=ce.active?{borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent",borderLeftColor:"transparent"}:i?{borderTopColor:J.borderDisabled.top,borderRightColor:J.borderDisabled.right,borderBottomColor:J.borderDisabled.bottom,borderLeftColor:J.borderDisabled.left}:{borderTopColor:sideColor("top"),borderRightColor:sideColor("right"),borderBottomColor:sideColor("bottom"),borderLeftColor:sideColor("left")},be=i?J.borderDisabled.top:sideColor("top"),pe={minHeight:y??h??$["min-height"],maxHeight:f,paddingHorizontal:S??$["padding-x"],paddingVertical:j??$["padding-y"],paddingLeft:F??S??$["padding-x"],paddingRight:v??S??$["padding-x"],backgroundColor:ce.active?"transparent":ee,columnGap:B??H.space.md,alignItems:"top"===c?"flex-start":"center",borderTopLeftRadius:de.tl,borderTopRightRadius:de.tr,borderBottomLeftRadius:de.bl,borderBottomRightRadius:de.br,borderCurve:smoothCorners.borderCurve,borderTopWidth:le.top,borderRightWidth:le.right,borderBottomWidth:le.bottom,borderLeftWidth:le.left,...ue,...void 0!==x?{width:x}:null,...void 0!==y?{height:y}:null},me=useRef(K);me.current=K,useEffect(()=>{Q.setValue(me.current)},[J,Q]);const ge=D?{marginBottom:H.space.none}:void 0,he={disabled:i,...q},fe="top"===c,xe=fe?{alignSelf:"flex-start",marginTop:Math.max(0,((u??$.icon)-$.icon)/2)}:null,ye=y??h??$["min-height"],Se=(()=>{if(!b)return 0;const e=Math.min(de.tl,ye/2),t=b.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),Fe=b&&le.top>0?_jsx(Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-le.top,left:b.left-le.left,width:b.width,height:le.top+Se,backgroundColor:ee}}):null,renderInner=e=>_jsxs(_Fragment,{children:[ce.active&&ce.size?_jsx(SquircleFill,{width:ce.size.width,height:ce.size.height,radius:de.tl,fill:e&&!i?H.colors["surface-pressed"]:ee,stroke:be,strokeWidth:le.top}):null,Fe,null!=n?_jsx(View,{style:[N.slot,xe],children:n}):null,null!=n&&d?_jsx(View,{pointerEvents:"none",style:[N.divider,xe,{height:$.icon,backgroundColor:H.colors["field-border"]}]}):null,_jsx(View,{style:[N.content,fe?N.contentTop:null],children:p}),null!=a?_jsx(View,{style:[N.slot,xe],children:a}):null]}),ve=_jsx(Animated.View,{ref:G,onLayout:ce.onLayout,style:[N.box,pe,m?null:ge,E],accessibilityRole:A,accessibilityLabel:P,accessibilityHint:M,accessibilityState:he,...ariaFromState(he),testID:W,children:renderInner(!1)});return m&&!g?_jsx(Pressable,{onPress:m,disabled:i,accessible:!1,style:ge,testID:W?`${W}-press`:void 0,children:ve}):m?_jsx(Pressable,{onPress:m,disabled:i,style:ge,accessibilityRole:A??"button",accessibilityLabel:P,accessibilityHint:M,accessibilityState:he,...ariaFromState(he),testID:W,children:({pressed:e})=>_jsx(Animated.View,{ref:G,onLayout:ce.onLayout,style:[N.box,pe,!e||i||ce.active?null:{backgroundColor:H.colors["surface-pressed"]},E],children:renderInner(e)})}):ve};FieldBase.displayName="FieldBase";const buildStyles=()=>StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});export default FieldBase;