@webority/mobile-ui 0.157.0 → 0.158.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas-kit.json +1 -1
- package/dist/canvas-kit/kit.js +5 -5
- package/dist/canvas-kit/manifest.json +17 -12
- package/dist/canvas-kit/release.json +7 -7
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
- package/lib/commonjs/components/AppIcon/index.js +1 -1
- package/lib/commonjs/components/Banner/Banner.js +1 -1
- package/lib/commonjs/components/BarChart/BarChart.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Button/Button.js +1 -1
- package/lib/commonjs/components/Button/index.js +1 -1
- package/lib/commonjs/components/Carousel/Carousel.js +1 -1
- package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
- package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/commonjs/components/Confetti/Confetti.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +1 -1
- package/lib/commonjs/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -1
- package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
- package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/commonjs/components/Radio/Radio.js +1 -1
- package/lib/commonjs/components/Radio/RadioGroup.js +1 -1
- package/lib/commonjs/components/Rating/Rating.js +1 -1
- package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
- package/lib/commonjs/components/SearchBar/useRecentSearches.js +1 -1
- package/lib/commonjs/components/Skeleton/Skeleton.js +1 -1
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
- package/lib/commonjs/components/Skeleton/SkeletonList.js +1 -1
- package/lib/commonjs/components/Slider/valueText.js +1 -1
- package/lib/commonjs/components/Stepper/Stepper.js +1 -1
- package/lib/commonjs/components/TagInput/TagInput.js +1 -1
- package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
- package/lib/commonjs/components/Toast/Toast.js +1 -1
- package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
- package/lib/commonjs/hooks/useControllableState.js +1 -1
- package/lib/commonjs/icons.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/AppIcon/AppIcon.js +1 -1
- package/lib/module/components/AppIcon/index.js +1 -1
- package/lib/module/components/Banner/Banner.js +1 -1
- package/lib/module/components/BarChart/BarChart.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/Button/Button.js +1 -1
- package/lib/module/components/Button/index.js +1 -1
- package/lib/module/components/Carousel/Carousel.js +1 -1
- package/lib/module/components/Checkbox/Checkbox.js +1 -1
- package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/module/components/Confetti/Confetti.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/MessageList/MessageList.js +1 -1
- package/lib/module/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -1
- package/lib/module/components/NumberInput/NumberInput.js +1 -1
- package/lib/module/components/OTPInput/OTPInput.js +1 -1
- package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
- package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/module/components/Radio/Radio.js +1 -1
- package/lib/module/components/Radio/RadioGroup.js +1 -1
- package/lib/module/components/Rating/Rating.js +1 -1
- package/lib/module/components/SearchBar/SearchBar.js +1 -1
- package/lib/module/components/SearchBar/useRecentSearches.js +1 -1
- package/lib/module/components/Skeleton/Skeleton.js +1 -1
- package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
- package/lib/module/components/Skeleton/SkeletonList.js +1 -1
- package/lib/module/components/Slider/valueText.js +1 -1
- package/lib/module/components/Stepper/Stepper.js +1 -1
- package/lib/module/components/TagInput/TagInput.js +1 -1
- package/lib/module/components/TimePicker/TimePicker.js +1 -1
- package/lib/module/components/Toast/Toast.js +1 -1
- package/lib/module/components/Tooltip/Tooltip.js +1 -1
- package/lib/module/hooks/useControllableState.js +1 -1
- package/lib/module/icons.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +2 -0
- package/lib/typescript/commonjs/components/AppIcon/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/Button/Button.d.ts +4 -0
- package/lib/typescript/commonjs/components/Button/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +7 -4
- package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +14 -6
- package/lib/typescript/commonjs/components/FieldBase/ChoiceText.d.ts +6 -5
- package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +2 -2
- package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +15 -9
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +7 -4
- package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +5 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +4 -4
- package/lib/typescript/commonjs/hooks/useControllableState.d.ts +23 -8
- package/lib/typescript/commonjs/icons.d.ts +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -1
- package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +2 -0
- package/lib/typescript/module/components/AppIcon/index.d.ts +1 -1
- package/lib/typescript/module/components/Button/Button.d.ts +4 -0
- package/lib/typescript/module/components/Button/index.d.ts +1 -1
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +7 -4
- package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +14 -6
- package/lib/typescript/module/components/FieldBase/ChoiceText.d.ts +6 -5
- package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +2 -2
- package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +15 -9
- package/lib/typescript/module/components/Radio/Radio.d.ts +7 -4
- package/lib/typescript/module/components/Radio/RadioGroup.d.ts +5 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +4 -4
- package/lib/typescript/module/hooks/useControllableState.d.ts +23 -8
- package/lib/typescript/module/icons.d.ts +1 -1
- package/lib/typescript/module/index.d.ts +2 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChoiceGroup=ChoiceGroup,exports.default=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"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_guards=require("../../utils/guards.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("../Radio/RadioDot.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),isChoiceOption=e=>(0,_guards.isRecord)(e)&&("string"==typeof e.value||"number"==typeof e.value);function ChoiceGroup(e){const{ref:i,options:t,getOptionLabel:r,getOptionValue:o,isOptionDisabled:s,getOptionDescription:a,getOptionIcon:n,getOptionColor:l,renderOption:c,variant:d="card",indicatorPosition:u="trailing",direction:p="row",gap:x,wrap:h=!1,fullWidth:g,disabled:m=!1,size:b="md",labelLines:_,descriptionLines:f=2,haptic:y,accessibilityLabel:j,style:v,optionStyle:C,description:V,helperText:z,error:R,testID:S}=e,w=(0,_index2.useTheme)(),H=(0,_react.useMemo)(()=>buildStyles(w),[w]),O=(0,_react.useMemo)(()=>sizeTokensOf(w)[b],[w,b]);(0,_assertValidValue.assertValidValue)("ChoiceGroup","variant",e.variant,["card","chip"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","direction",e.direction,["row","column"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const T=(0,_react.useCallback)(e=>r?r(e):isChoiceOption(e)?e.label??"":"",[r]),k=(0,_react.useCallback)(e=>{if(o)return o(e);if(isChoiceOption(e))return e.value;throw new Error("ChoiceGroup option has no value; pass getOptionValue.")},[o]),G=(0,_react.useCallback)(e=>s?s(e):isChoiceOption(e)&&!0===e.disabled,[s]),D=(0,_react.useCallback)(e=>a?a(e):isChoiceOption(e)?e.description:void 0,[a]),q=(0,_react.useCallback)(e=>n?n(e):isChoiceOption(e)?e.icon:void 0,[n]),M=(0,_react.useCallback)(e=>l?l(e):isChoiceOption(e)?e.color:void 0,[l]),L="multiple"===e.selectionMode,{min:I,max:P}=e,N=(0,_react.useCallback)(i=>{if("multiple"!==e.selectionMode){if("string"!=typeof i&&"number"!=typeof i)throw new Error(`ChoiceGroup received a ${Array.isArray(i)?"list":"missing"} value in single mode.`);e.onChange?.(i)}else{if(!Array.isArray(i))throw new Error("ChoiceGroup received a single value in multiple mode.");e.onChange?.(i)}},[e.onChange,e.selectionMode]),[A,F]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(L?[]:void 0),onChange:N}),W=Array.isArray(A)?A:[],E=(0,_react.useCallback)(e=>{const i=k(e);if(L){const e=W.includes(i);if(e&&null!=I&&W.length<=I)return;if(!e&&null!=P&&W.length>=P)return;const t=(0,_index3.resolveHaptic)(y,"selection");return t&&(0,_index3.triggerHaptic)(t),void F(e?W.filter(e=>e!==i):[...W,i])}const t=(0,_index3.resolveHaptic)(y,"selection");t&&(0,_index3.triggerHaptic)(t),F(i)},[y,L,I,P,W,F,k]),B=g??("card"===d&&"row"===p&&!h),$=h||B&&"row"===p,J=w.radius.md,surfaceFor=(e,i,t)=>i?{borderColor:w.colors.border,backgroundColor:w.colors["surface-disabled"]}:{borderColor:e?t:w.colors.border,backgroundColor:e?(0,_color.tintOf)(t,.12,w.colors["surface-selected"]):w.colors.bg},renderIcon=(e,i,t,r)=>{const o=q(e);if(null==o)return null;const s="string"==typeof o&&i?{name:o,variant:"bold"}:o;return(0,_slotIcon.renderSlotIcon)(s,{color:t,size:O.iconSize,disabled:r})},renderChip=e=>{const{option:i,selected:t,disabled:r,color:o}=e,s=r?w.colors["text-disabled"]:t?o:w.colors["text-body"],a=renderIcon(i,t,s,r);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.chip,{minHeight:O.minHeight,paddingHorizontal:O.chipPaddingHorizontal,paddingVertical:O.paddingVertical,borderRadius:w.radius.pill,..._corners.smoothCorners,borderWidth:w.size.border,...surfaceFor(t,r,o),columnGap:w.space.xs}],children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:a}):null,(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:_,ellipsizeMode:"tail",style:[H.cardLabel,{color:s,fontSize:O.fontSize,lineHeight:Math.round(O.fontSize*w.leading.body)}],children:T(i)})]})},renderDefaultCard=e=>{const{option:i,selected:t,disabled:r,color:o}=e,s=M(i),a=r?w.colors["text-disabled"]:s??w.colors["text-body"],n=D(i),l=renderIcon(i,t,a,r),c=(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:t,color:o,disabled:r,size:b});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.card,{minHeight:O.minHeight,paddingHorizontal:O.paddingHorizontal,paddingVertical:O.paddingVertical,borderRadius:J,..._corners.smoothCorners,borderWidth:w.size.border,...surfaceFor(t,r,o),columnGap:w.space.sm}],children:["leading"===u?c:null,l?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:l}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.cardTextWrap,children:[(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:_,ellipsizeMode:"tail",style:[H.cardLabel,{color:a,fontSize:O.fontSize,lineHeight:Math.round(O.fontSize*w.leading.body)}],children:T(i)}),n?(0,_jsxRuntime.jsx)(_index4.Text,{numberOfLines:f,ellipsizeMode:"tail",style:[H.cardDescription,{color:t?w.colors["text-muted"]:w.colors["text-subtle"],fontSize:w.text.xs.size,lineHeight:Math.round(w.text.xs.size*w.leading.body)}],children:n}):null]}),"trailing"===u?c:null]})},K="string"==typeof R&&""!==R?R:void 0,Q=!0===R||void 0!==K?null:z,U=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:i,accessibilityRole:L?void 0:"radiogroup",accessibilityLabel:j,accessibilityState:{disabled:m},"aria-disabled":m,testID:S,style:[{flexDirection:p,gap:x??w.space.sm,flexWrap:$?"wrap":"nowrap"},v],children:t.map((e,i)=>{const t=k(e),r=L?W.includes(t):A===t,o=L&&null!=P&&!r&&W.length>=P,s=m||o||G(e),a=M(e)??w.colors.primary,n=c||"card"!==d?void 0:D(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:isChoiceOption(e)?e.testID:void 0,onPress:()=>{s||E(e)},disabled:s,accessibilityRole:L?"checkbox":"radio",accessibilityLabel:n?`${T(e)}, ${n}`:T(e),accessibilityState:{checked:r,disabled:s},"aria-checked":r,"aria-disabled":s,style:[B?H.stretchOption:null,{opacity:s&&c?.55:1},C],children:({pressed:t})=>{const o={option:e,index:i,selected:r,pressed:t&&!s,disabled:s,color:a};return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:c?c(o):"chip"===d?renderChip(o):renderDefaultCard(o)})}},String(t))})});return(0,_ChoiceText.hasChoiceDetail)({description:V,error:K,helperText:Q??void 0})?(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[V?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:w.space.xs},children:V}):null,U,void 0!==K?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:w.space.xs},children:K}):Q?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",style:{marginTop:w.space.xs},children:Q}):null]}):U}ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>_reactNative.StyleSheet.create({stretchOption:{flexGrow:1,flexShrink:0,flexBasis:"auto"},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flexGrow:1,flexShrink:1,flexBasis:"auto"},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});var _default=exports.default=ChoiceGroup;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ChoiceGroup=ChoiceGroup,exports.default=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"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_guards=require("../../utils/guards.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("../Radio/RadioDot.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),isChoiceOption=e=>(0,_guards.isRecord)(e)&&("string"==typeof e.value||"number"==typeof e.value);function ChoiceGroup(e){const{ref:i,options:t,getOptionLabel:r,getOptionValue:o,isOptionDisabled:s,getOptionDescription:a,getOptionIcon:n,getOptionColor:l,renderOption:c,variant:d="card",indicatorPosition:u="trailing",direction:p="row",gap:x,wrap:h=!1,fullWidth:g,disabled:m=!1,size:b="md",labelLines:_,descriptionLines:f=2,haptic:y,accessibilityLabel:j,style:v,optionStyle:C,description:V,helperText:z,error:R,testID:S}=e,w=(0,_index2.useTheme)(),H=(0,_react.useMemo)(()=>buildStyles(w),[w]),O=(0,_react.useMemo)(()=>sizeTokensOf(w)[b],[w,b]);(0,_assertValidValue.assertValidValue)("ChoiceGroup","variant",e.variant,["card","chip"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","direction",e.direction,["row","column"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),(0,_assertValidValue.assertValidValue)("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const T=(0,_react.useCallback)(e=>r?r(e):isChoiceOption(e)?e.label??"":"",[r]),k=(0,_react.useCallback)(e=>{if(o)return o(e);if(isChoiceOption(e))return e.value;throw new Error("ChoiceGroup option has no value; pass getOptionValue.")},[o]),G=(0,_react.useCallback)(e=>s?s(e):isChoiceOption(e)&&!0===e.disabled,[s]),D=(0,_react.useCallback)(e=>a?a(e):isChoiceOption(e)?e.description:void 0,[a]),q=(0,_react.useCallback)(e=>n?n(e):isChoiceOption(e)?e.icon:void 0,[n]),M=(0,_react.useCallback)(e=>l?l(e):isChoiceOption(e)?e.color:void 0,[l]),L="multiple"===e.selectionMode,{min:I,max:P}=e,N=(0,_react.useCallback)(i=>{if("multiple"!==e.selectionMode){if("string"!=typeof i&&"number"!=typeof i)throw new Error(`ChoiceGroup received a ${Array.isArray(i)?"list":"missing"} value in single mode.`);e.onChange?.(i)}else{if(!Array.isArray(i))throw new Error("ChoiceGroup received a single value in multiple mode.");e.onChange?.(i)}},[e.onChange,e.selectionMode]),[A,F]=(0,_index.useControllableState)({controlled:"value"in e,value:e.value,defaultValue:e.defaultValue??(L?[]:void 0),onChange:N}),W=Array.isArray(A)?A:[],E=(0,_react.useCallback)(e=>{const i=k(e);if(L){const e=W.includes(i);if(e&&null!=I&&W.length<=I)return;if(!e&&null!=P&&W.length>=P)return;const t=(0,_index3.resolveHaptic)(y,"selection");return t&&(0,_index3.triggerHaptic)(t),void F(e?W.filter(e=>e!==i):[...W,i])}const t=(0,_index3.resolveHaptic)(y,"selection");t&&(0,_index3.triggerHaptic)(t),F(i)},[y,L,I,P,W,F,k]),B=g??("card"===d&&"row"===p&&!h),$=h||B&&"row"===p,J=w.radius.md,surfaceFor=(e,i,t)=>i?{borderColor:w.colors.border,backgroundColor:w.colors["surface-disabled"]}:{borderColor:e?t:w.colors.border,backgroundColor:e?(0,_color.tintOf)(t,.12,w.colors["surface-selected"]):w.colors.bg},renderIcon=(e,i,t,r)=>{const o=q(e);if(null==o)return null;const s="string"==typeof o&&i?{name:o,variant:"bold"}:o;return(0,_slotIcon.renderSlotIcon)(s,{color:t,size:O.iconSize,disabled:r})},renderChip=e=>{const{option:i,selected:t,disabled:r,color:o}=e,s=r?w.colors["text-disabled"]:t?o:w.colors["text-body"],a=renderIcon(i,t,s,r);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.chip,{minHeight:O.minHeight,paddingHorizontal:O.chipPaddingHorizontal,paddingVertical:O.paddingVertical,borderRadius:w.radius.pill,..._corners.smoothCorners,borderWidth:w.size.border,...surfaceFor(t,r,o),columnGap:w.space.xs}],children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:a}):null,(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:_,ellipsizeMode:"tail",style:[H.cardLabel,{color:s,fontSize:O.fontSize,lineHeight:Math.round(O.fontSize*w.leading.body)}],children:T(i)})]})},renderDefaultCard=e=>{const{option:i,selected:t,disabled:r,color:o}=e,s=M(i),a=r?w.colors["text-disabled"]:s??w.colors["text-body"],n=D(i),l=renderIcon(i,t,a,r),c=(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:t,color:o,disabled:r,size:b});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.card,{minHeight:O.minHeight,paddingHorizontal:O.paddingHorizontal,paddingVertical:O.paddingVertical,borderRadius:J,..._corners.smoothCorners,borderWidth:w.size.border,...surfaceFor(t,r,o),columnGap:w.space.sm}],children:["leading"===u?c:null,l?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:l}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.cardTextWrap,children:[(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:_,ellipsizeMode:"tail",style:[H.cardLabel,{color:a,fontSize:O.fontSize,lineHeight:Math.round(O.fontSize*w.leading.body)}],children:T(i)}),n?(0,_jsxRuntime.jsx)(_index4.Text,{numberOfLines:f,ellipsizeMode:"tail",style:[H.cardDescription,{color:t?w.colors["text-muted"]:w.colors["text-subtle"],fontSize:w.text.xs.size,lineHeight:Math.round(w.text.xs.size*w.leading.body)}],children:n}):null]}),"trailing"===u?c:null]})},K="string"==typeof R&&""!==R?R:void 0,Q=!0===R||void 0!==K?null:z,U=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:i,accessibilityRole:L?void 0:"radiogroup",accessibilityLabel:j,accessibilityState:{disabled:m},"aria-disabled":m,testID:S,style:[{flexDirection:p,gap:x??w.space.sm,flexWrap:$?"wrap":"nowrap"},v],children:t.map((e,i)=>{const t=k(e),r=L?W.includes(t):A===t,o=L&&null!=P&&!r&&W.length>=P,s=m||o||G(e),a=M(e)??w.colors.primary,n=c||"card"!==d?void 0:D(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:isChoiceOption(e)?e.testID:void 0,onPress:()=>{s||E(e)},disabled:s,accessibilityRole:L?"checkbox":"radio",accessibilityLabel:n?`${T(e)}, ${n}`:T(e),accessibilityState:{checked:r,disabled:s},"aria-checked":r,"aria-disabled":s,style:[B?H.stretchOption:null,{opacity:s&&c?.55:1},C],children:({pressed:t})=>{const o={option:e,index:i,selected:r,pressed:t&&!s,disabled:s,color:a};return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:c?c(o):"chip"===d?renderChip(o):renderDefaultCard(o)})}},String(t))})});return(0,_ChoiceText.hasChoiceDetail)({description:V,error:K,helperText:Q??void 0})?(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[V?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:w.space.xs},children:V}):null,U,void 0!==K?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:w.space.xs},children:K}):Q?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",style:{marginTop:w.space.xs},children:Q}):null]}):U}ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>_reactNative.StyleSheet.create({stretchOption:{flexGrow:1,flexShrink:0,flexBasis:"auto"},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flexGrow:1,flexShrink:1,flexBasis:"auto"},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});var _default=exports.default=ChoiceGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.buildPieces=exports.DEFAULT_PHYSICS=exports.Confetti=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(s,r,t):s[r]=e[r]);return s}const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6},DEFAULT_PHYSICS=exports.DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0},PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),itemAt=(e,a,t)=>{const r=e[a];if(void 0===r)throw new Error(`Confetti needs at least one ${t}`);return r},pick=e=>itemAt(e,Math.floor(Math.random()*e.length),"shape"),randomSign=()=>Math.random()<.5?1:-1,commonPiece=(e,a)=>({color:itemAt(e.colors,a%e.colors.length,"colour"),size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:randomSign(),flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const t=e.physics.spread>0?e.physics.spread/2:100,r=(-90+rand(-t,t))*DEG,i=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(r)*i*.7,vyFrac:Math.sin(r)*i,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const t=Math.max(1,Math.round(e/4)),r=a.physics.spread>0?a.physics.spread/2:180,i=[];for(let s=0;s<4&&i.length<e;s+=1){const n=rand(.18,.82),c=rand(.18,.52),o=s/4*.5+rand(0,.06);for(let s=0;s<t&&i.length<e;s+=1){const e=rand(-r,r)*DEG,t=rand(1.4,3.4)*a.physics.velocity;i.push({...commonPiece(a,i.length),x0Frac:n,y0Frac:c,vxFrac:Math.cos(e)*t*.7,vyFrac:Math.sin(e)*t,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:o,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return i},buildPieces=(e,a,t)=>{if("fireworks"===a)return buildFireworks(e,t);const r="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>r(t,a))};exports.buildPieces=buildPieces;const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:t,height:r,fadeOut:i})=>{const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const s=1-e.delay,n=s<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/s)),c=(1-Math.exp(-e.drag*n))/e.drag,o=e.x0Frac*t+e.vxFrac*t*c,l=e.y0Frac*r+e.terminalFrac*r*n+(e.vyFrac-e.terminalFrac)*r*c,d=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:i?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:o+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}},[e,a,t,r,i]),n=SHAPE_BOX[e.shape],c="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:c?"transparent":e.color},s],children:(0,_jsxRuntime.jsx)(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=exports.Confetti=(0,_react.forwardRef)(({count:e=80,colors:a,preset:t="pop",shapes:r,speed:i="normal",physics:s,origin:n,duration:c=2800,fadeOut:o=!0,autoStart:l=!1,recycle:d=!1,size:h=10,onComplete:p,style:u,testID:_},m)=>{(0,_assertValidValue.assertValidValue)("Confetti","preset",t,["pop","rain","fireworks"]),(0,_assertValidValue.assertValidValue)("Confetti","speed",i,["slow","normal","fast"]);for(const e of r??[])(0,_assertValidValue.assertValidValue)("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.buildPieces=exports.DEFAULT_PHYSICS=exports.Confetti=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(s,r,t):s[r]=e[r]);return s}const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6},DEFAULT_PHYSICS=exports.DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0},PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),itemAt=(e,a,t)=>{const r=e[a];if(void 0===r)throw new Error(`Confetti needs at least one ${t}`);return r},pick=e=>itemAt(e,Math.floor(Math.random()*e.length),"shape"),randomSign=()=>Math.random()<.5?1:-1,commonPiece=(e,a)=>({color:itemAt(e.colors,a%e.colors.length,"colour"),size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:randomSign(),flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const t=e.physics.spread>0?e.physics.spread/2:100,r=(-90+rand(-t,t))*DEG,i=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(r)*i*.7,vyFrac:Math.sin(r)*i,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const t=Math.max(1,Math.round(e/4)),r=a.physics.spread>0?a.physics.spread/2:180,i=[];for(let s=0;s<4&&i.length<e;s+=1){const n=rand(.18,.82),c=rand(.18,.52),o=s/4*.5+rand(0,.06);for(let s=0;s<t&&i.length<e;s+=1){const e=rand(-r,r)*DEG,t=rand(1.4,3.4)*a.physics.velocity;i.push({...commonPiece(a,i.length),x0Frac:n,y0Frac:c,vxFrac:Math.cos(e)*t*.7,vyFrac:Math.sin(e)*t,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:o,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return i},buildPieces=(e,a,t)=>{if("fireworks"===a)return buildFireworks(e,t);const r="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>r(t,a))};exports.buildPieces=buildPieces;const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:t,height:r,fadeOut:i})=>{const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const s=1-e.delay,n=s<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/s)),c=(1-Math.exp(-e.drag*n))/e.drag,o=e.x0Frac*t+e.vxFrac*t*c,l=e.y0Frac*r+e.terminalFrac*r*n+(e.vyFrac-e.terminalFrac)*r*c,d=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:i?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:o+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}},[e,a,t,r,i]),n=SHAPE_BOX[e.shape],c="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:c?"transparent":e.color},s],children:(0,_jsxRuntime.jsx)(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=exports.Confetti=(0,_react.forwardRef)(({count:e=80,colors:a,preset:t="pop",shapes:r,speed:i="normal",physics:s,origin:n,duration:c=2800,fadeOut:o=!0,autoStart:l=!1,recycle:d=!1,size:h=10,onComplete:p,style:u,testID:_},m)=>{(0,_assertValidValue.assertValidValue)("Confetti","preset",t,["pop","rain","fireworks"]),(0,_assertValidValue.assertValidValue)("Confetti","speed",i,["slow","normal","fast"]);for(const e of r??[])(0,_assertValidValue.assertValidValue)("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const y=(0,_index2.useTheme)(),f=(0,_index.useReducedMotion)(),v=(0,_reactNative.useWindowDimensions)(),[g,S]=(0,_react.useState)({width:v.width,height:v.height}),[x,w]=(0,_react.useState)(!1),[R,F]=(0,_react.useState)([]),P=(0,_react.useMemo)(()=>a??[y.colors.primary,y.colors.neutral,y.colors.success,y.colors.warning,y.colors.danger,y.colors.info],[a,y.colors]),A=(0,_reactNativeReanimated.useSharedValue)(0),E=c*SPEED_FACTOR[i],M=(0,_react.useCallback)(()=>{w(!1),p?.()},[p]),T=(0,_react.useCallback)(()=>{if(f)return void p?.();(0,_reactNativeReanimated.cancelAnimation)(A),A.value=0,F(buildPieces(e,t,{colors:P,baseSize:h,originXFrac:n?n.x/Math.max(1,g.width):.5,originYFrac:n?n.y/Math.max(1,g.height):.5,physics:{velocity:void 0===s?.velocity?DEFAULT_PHYSICS.velocity:s.velocity,drag:void 0===s?.drag?DEFAULT_PHYSICS.drag:s.drag,fallSpeed:void 0===s?.fallSpeed?DEFAULT_PHYSICS.fallSpeed:s.fallSpeed,spread:void 0===s?.spread?DEFAULT_PHYSICS.spread:s.spread},shapes:r??PRESET_SHAPES[t]})),w(!0);const a=(0,_reactNativeReanimated.withTiming)(1,{duration:E,easing:_reactNativeReanimated.Easing.linear},e=>{"worklet";e&&!d&&(0,_reactNativeReanimated.runOnJS)(M)()});A.value=d?(0,_reactNativeReanimated.withRepeat)(a,-1,!1):a},[f,A,E,d,M,p,e,P,t,r,s,h,n,g.width,g.height]),C=(0,_react.useCallback)(()=>{(0,_reactNativeReanimated.cancelAnimation)(A),w(!1)},[A]);(0,_react.useImperativeHandle)(m,()=>({start:T,stop:C}),[T,C]);const N=(0,_react.useRef)(l).current,j=(0,_react.useRef)(T).current;(0,_react.useEffect)(()=>(N&&j(),()=>(0,_reactNativeReanimated.cancelAnimation)(A)),[A,N,j]);const b=(0,_react.useCallback)(e=>{const{width:a,height:t}=e.nativeEvent.layout;a>0&&t>0&&S({width:a,height:t})},[]),k=(0,_react.useMemo)(()=>R.map((e,a)=>({key:`confetti-${a}`,piece:e})),[R]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_reactNative.StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:b,testID:_,children:x?k.map(({key:e,piece:a})=>(0,_jsxRuntime.jsx)(ConfettiPiece,{piece:a,progress:A,width:g.width,height:g.height,fadeOut:o},e)):null})});Confetti.displayName="Confetti";var _default=exports.default=Confetti;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Drawer=exports.DEFAULT_DRAWER_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_DRAWER_LABELS=exports.DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"},DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=exports.Drawer=(0,_react.forwardRef)((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:n="left",width:s,enableSwipe:o=!0,enableBackdropPress:c=!0,backdropOpacity:l=.5,haptic:u,containerStyle:d,children:_,accessibilityLabel:v,labels:p,testID:f}=e,h=(0,_index.useTheme)();(0,_assertValidValue.assertValidValue)("Drawer","side",e.side,["left","right","top","bottom"]);const m=(0,_react.useMemo)(()=>({...DEFAULT_DRAWER_LABELS,...p}),[p]),b=(0,_usePresenceMotion.usePresenceMotion)(),R=b.reduced,g=b.duration("default"),N=b.duration("fast"),w=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E="boolean"==typeof a,[S,y]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window"));(0,_react.useEffect)(()=>{const e=_reactNative.Dimensions.addEventListener("change",({window:e})=>y(e));return()=>e.remove()},[]);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Drawer=exports.DEFAULT_DRAWER_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_DRAWER_LABELS=exports.DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"},DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=exports.Drawer=(0,_react.forwardRef)((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:n="left",width:s,enableSwipe:o=!0,enableBackdropPress:c=!0,backdropOpacity:l=.5,haptic:u,containerStyle:d,children:_,accessibilityLabel:v,labels:p,testID:f}=e,h=(0,_index.useTheme)();(0,_assertValidValue.assertValidValue)("Drawer","side",e.side,["left","right","top","bottom"]);const m=(0,_react.useMemo)(()=>({...DEFAULT_DRAWER_LABELS,...p}),[p]),b=(0,_usePresenceMotion.usePresenceMotion)(),R=b.reduced,g=b.duration("default"),N=b.duration("fast"),w=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E="boolean"==typeof a,[S,y]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window"));(0,_react.useEffect)(()=>{const e=_reactNative.Dimensions.addEventListener("change",({window:e})=>y(e));return()=>e.remove()},[]);const O="left"===n||"right"===n,x=(0,_react.useMemo)(()=>resolveSize(s,O,S),[s,O,S]),M=(0,_react.useMemo)(()=>closedOffsetOf(n,x),[n,x]),D=(0,_reactNativeReanimated.useSharedValue)(r?0:M),L=(0,_reactNativeReanimated.useSharedValue)(r?0:M),C=(0,_reactNativeReanimated.useSharedValue)(r?1:0),[A,T]=(0,_react.useState)(r),j=(0,_reactNativeReanimated.useSharedValue)(r);(0,_react.useEffect)(()=>{A||R||(D.value=M,L.value=M)},[M,A,D,L,R]);const k=h.motion.spring.snappy,P=(0,_react.useCallback)(()=>{if(R)return D.value=0,void(C.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}));C.value=1,D.value=(0,_reactNativeReanimated.withSpring)(0,k)},[D,C,k,R,g]),V=(0,_react.useCallback)(()=>{R?C.value=(0,_reactNativeReanimated.withTiming)(0,{duration:N,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(D.value=M)}):D.value=(0,_reactNativeReanimated.withSpring)(M,k)},[D,C,M,k,R,N]),q=(0,_react.useCallback)(e=>{T(t=>t===e?t:(i?.(e),e)),j.value=e},[i,j]),F=(0,_react.useCallback)(()=>{q(!0),P()},[q,P]),I=(0,_react.useCallback)(()=>{q(!1),V()},[q,V]),U=(0,_react.useCallback)(()=>{A?I():F()},[A,F,I]);(0,_react.useImperativeHandle)(t,()=>({open:F,close:I,toggle:U}),[F,I,U]);const B=(0,_react.useRef)({isOpen:A,open:F,close:I});B.current={isOpen:A,open:F,close:I},(0,_react.useEffect)(()=>{if(!E)return;const e=B.current;a!==e.isOpen&&(a?e.open():e.close())},[a,E]);const H=(0,_react.useMemo)(()=>{const e=M,t=n,a=o;return{...O?{activeOffsetX:[-10,10],failOffsetY:[-15,15]}:{activeOffsetY:[-10,10],failOffsetX:[-15,15]},onActivate:()=>{"worklet";a&&(L.value=D.value)},onUpdate:t=>{"worklet";if(!a)return;const r=O?t.translationX:t.translationY,i=L.value+r,n=Math.min(0,e),s=Math.max(0,e);D.value=i<n?n+.25*(i-n):i>s?s+.25*(i-s):i},onDeactivate:r=>{"worklet";if(!a)return;const i=O?r.velocityX:r.velocityY,n=D.value;let s=!1;s="left"===t||"top"===t?i<-1e3:i>1e3;const o=Math.abs(e),c=Math.abs(n)/o;s||c>.5?((0,_reactNativeReanimated.runOnJS)(q)(!1),R?C.value=(0,_reactNativeReanimated.withTiming)(0,{duration:N,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(D.value=e)}):D.value=(0,_reactNativeReanimated.withSpring)(e,k)):((0,_reactNativeReanimated.runOnJS)(q)(!0),R?(D.value=0,C.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION})):D.value=(0,_reactNativeReanimated.withSpring)(0,k))}}},[M,L,o,O,D,C,q,n,k,R,g,N]),W=(0,_reactNativeGestureHandler.usePanGesture)(H),G=(0,_reactNativeReanimated.useAnimatedStyle)(()=>O?{opacity:C.value,transform:[{translateX:D.value}]}:{opacity:C.value,transform:[{translateY:D.value}]},[O,D,C]),Y=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:(0,_reactNativeReanimated.interpolate)(D.value,[M,0],[0,l],_reactNativeReanimated.Extrapolation.CLAMP)*C.value,pointerEvents:Math.abs(D.value-M)<.5?"none":"auto"}),[D,M,l,C]),X=(0,_react.useMemo)(()=>buildStyles(h),[h]),z=(0,_react.useCallback)(()=>{if(!c)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),I()},[c,I,u]),J=(0,_react.useMemo)(()=>sideLayoutOf(n,x,w),[n,x,w]),K=(0,_react.useRef)(r);return A&&(K.current=!0),K.current?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",testID:f,accessibilityViewIsModal:A,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[X.backdrop,{backgroundColor:h.colors.scrim},Y],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:z,accessibilityRole:"button",accessibilityLabel:m.close,disabled:!c||!A})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:W,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:v??m.drawer,style:[J,{backgroundColor:h.colors.surface,...h.shadow.modal},d,G],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:X.content,children:_})})})]}):null});Drawer.displayName="Drawer";const closedOffsetOf=(e,t)=>{switch(e){case"left":case"top":return-t;case"right":case"bottom":return t}},sideLayoutOf=(e,t,a)=>{switch(e){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:t,paddingTop:a.top,paddingBottom:a.bottom,paddingLeft:a.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:t,paddingTop:a.top,paddingBottom:a.bottom,paddingRight:a.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:t,paddingTop:a.top,paddingLeft:a.left,paddingRight:a.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:t,paddingBottom:a.bottom,paddingLeft:a.left,paddingRight:a.right}}},resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>_reactNative.StyleSheet.create({backdrop:{..._reactNative.StyleSheet.absoluteFill},content:{flex:1}});var _default=exports.default=Drawer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FloatingActionButtonGroup=exports.FloatingActionButton=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,n,o=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((i=o&&Object.getOwnPropertyDescriptor(e,n))&&(i.get||i.set)?o(a,n,i):a[n]=e[n]);return a}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}},FloatingActionButton=exports.FloatingActionButton=(0,_react.forwardRef)((e,t)=>{const{icon:i,onPress:n,label:o,collapsed:a=!1,size:r="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:f,style:g,containerStyle:v,labelStyle:h,testID:x}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButton","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","tone",e.tone,FAB_TONES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","position",e.position,FAB_POSITIONS);const y=!u&&!d,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,r),[A,r]),S=(0,_react.useMemo)(()=>buildStyles(A),[A]),{scale:j,opacity:w,pressIn:I,pressOut:E}=(0,_usePressAnimation.usePressAnimation)({enabled:y}),F=(0,_usePresenceMotion.usePresenceMotion)(),V=A.space[A.components["floating-action-button"]["edge-offset"]],C=A.space[A.components["floating-action-button"]["bottom-offset"]],B=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,P=F.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index.setNativeValue)(B,1);const e=_reactNative.Animated.timing(B,{toValue:_?0:1,duration:P,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[m,_,B,P,A.motion.ease["in-out"]]);const T=N.diameter+(l??C)+R.bottom+V,O=B.interpolate({inputRange:[0,1],outputRange:F.range(T,0)}),D=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(B,w),[B,w]),L="string"==typeof o&&o.length>0,k=L&&a,M=F.reduced,z=A.space.sm,G=N["label-padding-x"],U=A.motion.duration.fast,q=A.motion.ease["in-out"],$=(0,_reactNativeReanimated.useSharedValue)(k?1:0),[H,W]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=k?1:0;return $.value=M?e:(0,_reactNativeReanimated.withTiming)(e,{duration:U,easing:_reactNativeReanimated.Easing.bezier(...q)}),()=>(0,_reactNativeReanimated.cancelAnimation)($)},[k,M,$,U,q]);const Y=(0,_react.useCallback)(e=>{const t=Math.ceil(e);W(e=>e===t?e:t)},[]),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:G*(1-$.value)}),[G,$]),Q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*$.value);return null===H?$.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+z)*(1-$.value)}},[$,H,z]),X=u?A.colors["surface-disabled"]:toneBackground(A,s),J=u?A.colors["text-disabled"]:toneForeground(A,s),K="lg"===r?"md":"sm",ee=d?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:K,color:J}):(0,_slotIcon.renderSlotIcon)(i,{color:J,size:N.icon,disabled:u}),te=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??C)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:V};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:V}}},[c,l,R.bottom,C,V]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[te,{transform:[{translateY:O},{scale:j}],opacity:D},v,g],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!y)return;const t=(0,_hapticUtils.resolveHaptic)(f,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),n()},onPressIn:I,onPressOut:E,disabled:!y,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!y,busy:d},"aria-disabled":!y,"aria-busy":d,testID:x,style:[S.base,L?{height:N.diameter,minWidth:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners}:{width:N.diameter,height:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners},A.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&y?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:pressedTintFor(A,s),borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,L?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[S.extendedRow,Z],children:[ee,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.labelClip,Q],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>Y(e.nativeEvent.layout.width),style:[S.label,{color:J,fontSize:N.text,fontWeight:A.weight.semibold,marginLeft:z},h],numberOfLines:1,children:o})})]}):ee]})})})});FloatingActionButton.displayName="FloatingActionButton";const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS={quickActions:"Quick actions",expanded:(e,t)=>`${e}, expanded, ${t} ${1===t?"action":"actions"}`,collapsed:e=>`${e}, collapsed`},FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:i,actions:n,expanded:o,defaultExpanded:a=!1,onExpandedChange:r,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,containerStyle:b,secondaryActionStyle:f,labelPillStyle:g,labelStyle:v,testID:h}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_react.useMemo)(()=>({...DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS,...s}),[s]),y=d??x.quickActions,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,u),[A,u]),S=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),j=(0,_usePresenceMotion.usePresenceMotion)(),w=j.duration("default"),I=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],F=A.space[A.components["floating-action-button"]["secondary-gap"]],V=A.components["floating-action-button"]["stagger-ms"],C=(0,_react.useMemo)(()=>n.slice(0,6),[n]),B=C.length,P=(0,_react.useMemo)(()=>C.map((e,t)=>({action:e,index:t})).reverse(),[C]);n.forEach(e=>{(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const T=__DEV__?describeActionProblem(n):"";(0,_react.useEffect)(()=>{__DEV__&&T&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${T}`)},[T]);const O="boolean"==typeof o,[D,L]=(0,_react.useState)(a),k="boolean"==typeof o?o:D,M=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index.setNativeValue)(M,1);const e=_reactNative.Animated.timing(M,{toValue:p?0:1,duration:w,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[_,p,M,w,A.motion.ease["in-out"]]);const z=_&&p;(0,_react.useEffect)(()=>{z&&k&&(O||L(!1),r?.(!1))},[z,k,O,r]);const G=N.diameter+(l??E)+R.bottom+I,U=M.interpolate({inputRange:[0,1],outputRange:j.range(G,0)}),q=M,$=(0,_react.useRef)((0,_index.createAnimatedValue)(k?1:0)).current,H=(0,_react.useRef)([]),[W,Y]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=H.current;if(e.length!==B){if(e.length<B){const t=e.slice();for(let i=e.length;i<B;i+=1)t.push(new _reactNative.Animated.Value(k?1:0));H.current=t}else H.current=e.slice(0,B);Y(e=>e+1)}},[B]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:k?1:0,duration:w,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});e.start();const t=H.current.map(e=>_reactNative.Animated.timing(e,{toValue:k?1:0,duration:w,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})),i=k?t:[...t].reverse(),n=_reactNative.Animated.stagger(V,i);return n.start(),()=>{e.stop(),n.stop()}},[k,$,w,A.motion.ease["in-out"],B,W,V]);const Z=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),O||L(e),r?.(e)},[O,r,m]),Q=(0,_react.useRef)(null),X=(0,_react.useRef)(k),J=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(X.current===k)return;X.current=k;const e=J.current;if(J.current=!1,z||e)return;const t=Q.current;t&&("web"===_reactNative.Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(k?x.expanded(y,B):x.collapsed(y))},[k,z,y,B,x]);const K=(0,_react.useCallback)(()=>{Z(!k)},[k,Z]),ee=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),J.current=!0,e.onPress(),O||L(!1),r?.(!1)},[O,r,m]),te=(0,_react.useCallback)(()=>{k&&Z(!1)},[k,Z]);(0,_react.useEffect)(()=>{if(!k)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(Z(!1),!0));return()=>e.remove()},[k,Z]),(0,_react.useEffect)(()=>{if(!k||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&Z(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[k,Z]);const ie=(0,_react.useMemo)(()=>{const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:I,alignItems:"flex-end"}}},[c,l,R.bottom,E,I]),slotOffset=e=>-(N.diameter+F)*(e+1),ne=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),oe=.78*N.diameter,ae=(0,_react.useMemo)(()=>{const e=oe+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:N.diameter/2+oe/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,oe,N.diameter,A.space.sm]),re=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),se=$.interpolate(j.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[k?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:k?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:re}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:te,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:z?"none":"box-none",style:[ie,{transform:[{translateY:U}],opacity:q},b],accessibilityRole:"menu",testID:h,children:[P.map(({action:e,index:t})=>{const i=H.current[t];if(!i)return null;const n=i.interpolate({inputRange:[0,1],outputRange:j.range(0,slotOffset(t))}),o=i.interpolate({inputRange:[0,1],outputRange:j.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),r=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[S.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},g],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:k?"auto":"none",accessibilityElementsHidden:!k,importantForAccessibility:k?"auto":"no-hide-descendants","aria-hidden":!k,style:[S.secondaryRow,ne,{position:"absolute",bottom:0,opacity:i,transform:[{translateY:n},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ee(e),focusable:k,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[S.fabBase,A.shadow.elevated,{width:oe,height:oe,borderRadius:oe/2,..._corners.smoothCorners,backgroundColor:a},f],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:oe/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:N.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:Q,onPress:K,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{expanded:k},"aria-expanded":k,style:[S.fabBase,A.shadow.popover,{width:N.diameter,height:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:i?void 0:{transform:[{rotate:se}]},children:(0,_slotIcon.renderSlotIcon)(k&&i?i:t,{color:A.colors["on-primary"],size:N.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FloatingActionButtonGroup=exports.FloatingActionButton=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,n,o=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((i=o&&Object.getOwnPropertyDescriptor(e,n))&&(i.get||i.set)?o(a,n,i):a[n]=e[n]);return a}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}},FloatingActionButton=exports.FloatingActionButton=(0,_react.forwardRef)((e,t)=>{const{icon:i,onPress:n,label:o,collapsed:a=!1,size:r="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:f,style:g,containerStyle:v,labelStyle:h,testID:x}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButton","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","tone",e.tone,FAB_TONES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","position",e.position,FAB_POSITIONS);const y=!u&&!d,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,r),[A,r]),S=(0,_react.useMemo)(()=>buildStyles(A),[A]),{scale:j,opacity:w,pressIn:I,pressOut:E}=(0,_usePressAnimation.usePressAnimation)({enabled:y}),F=(0,_usePresenceMotion.usePresenceMotion)(),V=A.space[A.components["floating-action-button"]["edge-offset"]],C=A.space[A.components["floating-action-button"]["bottom-offset"]],B=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,P=F.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index.setNativeValue)(B,1);const e=_reactNative.Animated.timing(B,{toValue:_?0:1,duration:P,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[m,_,B,P,A.motion.ease["in-out"]]);const T=N.diameter+(l??C)+R.bottom+V,O=B.interpolate({inputRange:[0,1],outputRange:F.range(T,0)}),D=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(B,w),[B,w]),L="string"==typeof o&&o.length>0,k=L&&a,M=F.reduced,z=A.space.sm,G=N["label-padding-x"],U=A.motion.duration.fast,q=A.motion.ease["in-out"],$=(0,_reactNativeReanimated.useSharedValue)(k?1:0),[H,W]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=k?1:0;return $.value=M?e:(0,_reactNativeReanimated.withTiming)(e,{duration:U,easing:_reactNativeReanimated.Easing.bezier(...q)}),()=>(0,_reactNativeReanimated.cancelAnimation)($)},[k,M,$,U,q]);const Y=(0,_react.useCallback)(e=>{const t=Math.ceil(e);W(e=>e===t?e:t)},[]),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:G*(1-$.value)}),[G,$]),Q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*$.value);return null===H?$.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+z)*(1-$.value)}},[$,H,z]),X=u?A.colors["surface-disabled"]:toneBackground(A,s),J=u?A.colors["text-disabled"]:toneForeground(A,s),K="lg"===r?"md":"sm",ee=d?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:K,color:J}):(0,_slotIcon.renderSlotIcon)(i,{color:J,size:N.icon,disabled:u}),te=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??C)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:V};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:V}}},[c,l,R.bottom,C,V]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[te,{transform:[{translateY:O},{scale:j}],opacity:D},v,g],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!y)return;const t=(0,_hapticUtils.resolveHaptic)(f,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),n()},onPressIn:I,onPressOut:E,disabled:!y,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!y,busy:d},"aria-disabled":!y,"aria-busy":d,testID:x,style:[S.base,L?{height:N.diameter,minWidth:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners}:{width:N.diameter,height:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners},A.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&y?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:pressedTintFor(A,s),borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,L?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[S.extendedRow,Z],children:[ee,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.labelClip,Q],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>Y(e.nativeEvent.layout.width),style:[S.label,{color:J,fontSize:N.text,fontWeight:A.weight.semibold,marginLeft:z},h],numberOfLines:1,children:o})})]}):ee]})})})});FloatingActionButton.displayName="FloatingActionButton";const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS={quickActions:"Quick actions",expanded:(e,t)=>`${e}, expanded, ${t} ${1===t?"action":"actions"}`,collapsed:e=>`${e}, collapsed`},FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:i,actions:n,expanded:o,defaultExpanded:a=!1,onExpandedChange:r,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,containerStyle:b,secondaryActionStyle:f,labelPillStyle:g,labelStyle:v,testID:h}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_react.useMemo)(()=>({...DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS,...s}),[s]),y=d??x.quickActions,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,u),[A,u]),S=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),j=(0,_usePresenceMotion.usePresenceMotion)(),w=j.duration("default"),I=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],F=A.space[A.components["floating-action-button"]["secondary-gap"]],V=A.components["floating-action-button"]["stagger-ms"],C=(0,_react.useMemo)(()=>n.slice(0,6),[n]),B=C.length,P=(0,_react.useMemo)(()=>C.map((e,t)=>({action:e,index:t})).reverse(),[C]);n.forEach(e=>{(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const T=__DEV__?describeActionProblem(n):"";(0,_react.useEffect)(()=>{__DEV__&&T&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${T}`)},[T]);const O="boolean"==typeof o,[D,L]=(0,_react.useState)(a),k="boolean"==typeof o?o:D,M=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index.setNativeValue)(M,1);const e=_reactNative.Animated.timing(M,{toValue:p?0:1,duration:w,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[_,p,M,w,A.motion.ease["in-out"]]);const z=_&&p;(0,_react.useEffect)(()=>{z&&k&&(O||L(!1),r?.(!1))},[z,k,O,r]);const G=N.diameter+(l??E)+R.bottom+I,U=M.interpolate({inputRange:[0,1],outputRange:j.range(G,0)}),q=M,$=(0,_react.useRef)((0,_index.createAnimatedValue)(k?1:0)).current,H=(0,_react.useRef)([]),[W,Y]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=H.current;if(e.length!==B){if(e.length<B){const t=e.slice();for(let i=e.length;i<B;i+=1)t.push(new _reactNative.Animated.Value(k?1:0));H.current=t}else H.current=e.slice(0,B);Y(e=>e+1)}},[B,k]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:k?1:0,duration:w,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});e.start();const t=H.current.map(e=>_reactNative.Animated.timing(e,{toValue:k?1:0,duration:w,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})),i=k?t:[...t].reverse(),n=_reactNative.Animated.stagger(V,i);return n.start(),()=>{e.stop(),n.stop()}},[k,$,w,A.motion.ease["in-out"],B,W,V]);const Z=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),O||L(e),r?.(e)},[O,r,m]),Q=(0,_react.useRef)(null),X=(0,_react.useRef)(k),J=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(X.current===k)return;X.current=k;const e=J.current;if(J.current=!1,z||e)return;const t=Q.current;t&&("web"===_reactNative.Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(k?x.expanded(y,B):x.collapsed(y))},[k,z,y,B,x]);const K=(0,_react.useCallback)(()=>{Z(!k)},[k,Z]),ee=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),J.current=!0,e.onPress(),O||L(!1),r?.(!1)},[O,r,m]),te=(0,_react.useCallback)(()=>{k&&Z(!1)},[k,Z]);(0,_react.useEffect)(()=>{if(!k)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(Z(!1),!0));return()=>e.remove()},[k,Z]),(0,_react.useEffect)(()=>{if(!k||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&Z(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[k,Z]);const ie=(0,_react.useMemo)(()=>{const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:I,alignItems:"flex-end"}}},[c,l,R.bottom,E,I]),slotOffset=e=>-(N.diameter+F)*(e+1),ne=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),oe=.78*N.diameter,ae=(0,_react.useMemo)(()=>{const e=oe+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:N.diameter/2+oe/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,oe,N.diameter,A.space.sm]),re=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),se=$.interpolate(j.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[k?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:k?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:re}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:te,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:z?"none":"box-none",style:[ie,{transform:[{translateY:U}],opacity:q},b],accessibilityRole:"menu",testID:h,children:[P.map(({action:e,index:t})=>{const i=H.current[t];if(!i)return null;const n=i.interpolate({inputRange:[0,1],outputRange:j.range(0,slotOffset(t))}),o=i.interpolate({inputRange:[0,1],outputRange:j.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),r=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[S.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},g],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:k?"auto":"none",accessibilityElementsHidden:!k,importantForAccessibility:k?"auto":"no-hide-descendants","aria-hidden":!k,style:[S.secondaryRow,ne,{position:"absolute",bottom:0,opacity:i,transform:[{translateY:n},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ee(e),focusable:k,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[S.fabBase,A.shadow.elevated,{width:oe,height:oe,borderRadius:oe/2,..._corners.smoothCorners,backgroundColor:a},f],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:oe/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:N.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:Q,onPress:K,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{expanded:k},"aria-expanded":k,style:[S.fabBase,A.shadow.popover,{width:N.diameter,height:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:i?void 0:{transform:[{rotate:se}]},children:(0,_slotIcon.renderSlotIcon)(k&&i?i:t,{color:A.colors["on-primary"],size:N.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ImageGallery=exports.DEFAULT_IMAGE_GALLERY_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Carousel/index.js"),_Modal=require("../Modal/Modal.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,i,l=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((t=l&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?l(r,i,t):r[i]=e[i]);return r}const DEFAULT_IMAGE_GALLERY_LABELS=exports.DEFAULT_IMAGE_GALLERY_LABELS={gallery:"Image gallery",imageOf:(e,a)=>`Image ${e} of ${a}`,openFullscreen:"Tap to open fullscreen",closeGallery:"Close gallery"},MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:a=0,showThumbnails:t=!0,showCounter:i=!0,enableLightbox:l=!0,enablePinchZoom:r=!0,onIndexChange:n,haptic:s,loading:o=!1,accessibilityLabel:c,containerStyle:u,testID:d,labels:m})=>{const _=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>buildStyles(_),[_]),g=(0,_react.useMemo)(()=>({...DEFAULT_IMAGE_GALLERY_LABELS,...m}),[m]),[v,x]=(0,_react.useState)(clamp(a,0,Math.max(0,e.length-1))),[p,b]=(0,_react.useState)(!1),R=(0,_react.useCallback)(e=>{x(e),n?.(e)},[n]),y=(0,_react.useCallback)(()=>{if(!l)return;const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!0)},[l,s]),S=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!1)},[s]),I=(0,_react.useCallback)((a,t)=>{const i=a.alt??g.imageOf(t+1,e.length);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:y,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:l?g.openFullscreen:void 0,style:h.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:a.source,style:h.image,resizeMode:"cover"})})},[l,e.length,y,h,g]),N=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:h.thumbnailImage,resizeMode:"cover"}),[h]),j=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[h.container,u],testID:d,accessibilityLabel:c??g.gallery,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h.carouselWrap,accessibilityElementsHidden:p,importantForAccessibility:p?"no-hide-descendants":"auto",children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{data:e,defaultIndex:a,onIndexChange:R,renderItem:I,showPagination:!1,showThumbnails:t,renderThumbnail:N,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:h.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:_.colors["on-scrim"]},accessibilityLabel:g.imageOf(v+1,e.length),children:`${v+1} / ${e.length}`})}):null]}),l?(0,_jsxRuntime.jsx)(Lightbox,{open:p,images:e,initialIndex:v,enablePinchZoom:r,showCounter:i,onClose:S,onIndexChange:R,haptic:s,labels:g}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:t,showCounter:i,containerStyle:u,testID:d}):j};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:a=!0,showCounter:t=!0,containerStyle:i,testID:l})=>{const r=(0,_index.useTheme)(),n=Math.min(e?.length||4,6);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{width:"100%"},i],testID:l,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:"100%",height:280,radius:"lg"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:r.space.md},children:Array.from({length:n}).map((e,a)=>(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:r.space.sm}},`sk-thumb-${a}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:a,initialIndex:t,enablePinchZoom:i,showCounter:l,onClose:r,onIndexChange:n,haptic:s,labels:o})=>{const c=(0,_index.useTheme)(),u=(0,_react.useMemo)(()=>buildLightboxStyles(c),[c]),d=(0,_react.useRef)(null),[m,_]=(0,_react.useState)(t),h=(0,_react.useCallback)(e=>{if(e!==m){const a=(0,_index2.resolveHaptic)(s,"selection");a&&(0,_index2.triggerHaptic)(a),_(e),n(e)}},[m,n,s]),g=(0,_react.useCallback)((e,t)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:t,total:a.length,active:t===m,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s,imageLabel:o.imageOf}),[m,i,a.length,s,o]),v=a[m]?.caption;return(0,_jsxRuntime.jsx)(_Modal.Modal,{open:e,onClose:r,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.backdrop,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{ref:d,data:a,defaultIndex:t,onIndexChange:h,renderItem:g,showPagination:!1,haptic:s}),l&&a.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:o.imageOf(m+1,a.length),children:`${m+1} / ${a.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:o.closeGallery,style:u.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(c.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),v?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:u.captionWrap,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",align:"center",numberOfLines:3,style:u.captionText,children:v})}):null]})})},ZoomableImage=({image:e,index:a,total:t,active:i,enabled:l,maxScale:r,minScale:n,doubleTapScale:s,haptic:o,imageLabel:c})=>{const u=_reactNative.Dimensions.get("window"),d=(0,_reactNativeReanimated.useSharedValue)(1),m=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),g=(0,_reactNativeReanimated.useSharedValue)(0),v=(0,_reactNativeReanimated.useSharedValue)(0),x=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),m.value=1,_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),g.value=0,v.value=0},[d,m,_,h,g,v]);_react.default.useEffect(()=>{i||(d.value=(0,_reactNativeReanimated.withTiming)(1,{duration:150}),_.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),h.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),m.value=1,g.value=0,v.value=0)},[i,d,_,h,m,g,v]);const p=(0,_react.useCallback)(()=>{!1!==o&&(0,_index2.triggerHaptic)("impactLight")},[o]),b=(0,_react.useMemo)(()=>({enabled:l,onActivate:()=>{"worklet";m.value=d.value},onUpdate:e=>{"worklet";const a=m.value*e.scale;d.value=a<n?n+.3*(a-n):a>r?r+.2*(a-r):a},onDeactivate:()=>{"worklet";return d.value<n?(d.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=n,g.value=0,void(v.value=0)):d.value>r?(d.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(m.value=r)):void(m.value=d.value)}}),[l,d,m,_,h,g,v,n,r]),R=(0,_reactNativeGestureHandler.usePinchGesture)(b),y=(0,_react.useMemo)(()=>({minPointers:1,maxPointers:1,onActivate:()=>{"worklet";g.value=_.value,v.value=h.value},onUpdate:e=>{"worklet";d.value<=1||(_.value=g.value+e.translationX,h.value=v.value+e.translationY)},onDeactivate:()=>{"worklet";g.value=_.value,v.value=h.value}}),[d,_,h,g,v]),S=(0,_reactNativeGestureHandler.usePanGesture)(y),I=(0,_react.useMemo)(()=>({numberOfTaps:2,onDeactivate:()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(p)(),d.value>1?(d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=1,g.value=0,v.value=0):(d.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),m.value=s)}}),[d,m,_,h,g,v,p,s]),N=(0,_reactNativeGestureHandler.useTapGesture)(I),j=(0,_reactNativeGestureHandler.useCompetingGestures)(R,S,N),w=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:_.value},{translateY:h.value},{scale:d.value}]}),[_,h,d]);_react.default.useEffect(()=>{i||x()},[i,x]);const C=e.alt??c(a+1,t);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:j,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[lightboxImageStyles.container,{width:u.width}],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,w],accessibilityLabel:C,accessible:!0})})})},clamp=(e,a,t)=>Math.min(Math.max(e,a),t),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,..._corners.smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>_reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:e.colors["on-scrim"]}}),lightboxImageStyles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});var _default=exports.default=ImageGallery;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ImageGallery=exports.DEFAULT_IMAGE_GALLERY_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Carousel/index.js"),_Modal=require("../Modal/Modal.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,i,l=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((t=l&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?l(r,i,t):r[i]=e[i]);return r}const DEFAULT_IMAGE_GALLERY_LABELS=exports.DEFAULT_IMAGE_GALLERY_LABELS={gallery:"Image gallery",imageOf:(e,a)=>`Image ${e} of ${a}`,openFullscreen:"Tap to open fullscreen",closeGallery:"Close gallery"},MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:a=0,showThumbnails:t=!0,showCounter:i=!0,enableLightbox:l=!0,enablePinchZoom:r=!0,onIndexChange:n,haptic:s,loading:o=!1,accessibilityLabel:c,containerStyle:u,testID:d,labels:m})=>{const _=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>buildStyles(_),[_]),g=(0,_react.useMemo)(()=>({...DEFAULT_IMAGE_GALLERY_LABELS,...m}),[m]),[v,x]=(0,_react.useState)(clamp(a,0,Math.max(0,e.length-1))),[p,b]=(0,_react.useState)(!1),y=(0,_react.useCallback)(e=>{x(e),n?.(e)},[n]),R=(0,_react.useCallback)(()=>{if(!l)return;const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!0)},[l,s]),S=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!1)},[s]),I=(0,_react.useCallback)((a,t)=>{const i=a.alt??g.imageOf(t+1,e.length);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:R,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:l?g.openFullscreen:void 0,style:h.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:a.source,style:h.image,resizeMode:"cover"})})},[l,e.length,R,h,g]),N=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:h.thumbnailImage,resizeMode:"cover"}),[h]),j=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[h.container,u],testID:d,accessibilityLabel:c??g.gallery,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h.carouselWrap,accessibilityElementsHidden:p,importantForAccessibility:p?"no-hide-descendants":"auto",children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{data:e,defaultIndex:a,onIndexChange:y,renderItem:I,showPagination:!1,showThumbnails:t,renderThumbnail:N,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:h.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:_.colors["on-scrim"]},accessibilityLabel:g.imageOf(v+1,e.length),children:`${v+1} / ${e.length}`})}):null]}),l?(0,_jsxRuntime.jsx)(Lightbox,{open:p,images:e,initialIndex:v,enablePinchZoom:r,showCounter:i,onClose:S,onIndexChange:y,haptic:s,labels:g}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:t,showCounter:i,containerStyle:u,testID:d}):j};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:a=!0,showCounter:t=!0,containerStyle:i,testID:l})=>{const r=(0,_index.useTheme)(),n=Math.min(e?.length||4,6),s=(0,_react.useMemo)(()=>Array.from({length:n},(e,a)=>({key:`sk-thumb-${a}`})),[n]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{width:"100%"},i],testID:l,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:"100%",height:280,radius:"lg"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:r.space.md},children:s.map(e=>(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:r.space.sm}},e.key))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:a,initialIndex:t,enablePinchZoom:i,showCounter:l,onClose:r,onIndexChange:n,haptic:s,labels:o})=>{const c=(0,_index.useTheme)(),u=(0,_react.useMemo)(()=>buildLightboxStyles(c),[c]),d=(0,_react.useRef)(null),[m,_]=(0,_react.useState)(t),h=(0,_react.useCallback)(e=>{if(e!==m){const a=(0,_index2.resolveHaptic)(s,"selection");a&&(0,_index2.triggerHaptic)(a),_(e),n(e)}},[m,n,s]),g=(0,_react.useCallback)((e,t)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:t,total:a.length,active:t===m,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s,imageLabel:o.imageOf}),[m,i,a.length,s,o]),v=a[m]?.caption;return(0,_jsxRuntime.jsx)(_Modal.Modal,{open:e,onClose:r,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.backdrop,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{ref:d,data:a,defaultIndex:t,onIndexChange:h,renderItem:g,showPagination:!1,haptic:s}),l&&a.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:o.imageOf(m+1,a.length),children:`${m+1} / ${a.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:o.closeGallery,style:u.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(c.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),v?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:u.captionWrap,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",align:"center",numberOfLines:3,style:u.captionText,children:v})}):null]})})},ZoomableImage=({image:e,index:a,total:t,active:i,enabled:l,maxScale:r,minScale:n,doubleTapScale:s,haptic:o,imageLabel:c})=>{const u=_reactNative.Dimensions.get("window"),d=(0,_reactNativeReanimated.useSharedValue)(1),m=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),g=(0,_reactNativeReanimated.useSharedValue)(0),v=(0,_reactNativeReanimated.useSharedValue)(0),x=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),m.value=1,_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),g.value=0,v.value=0},[d,m,_,h,g,v]);_react.default.useEffect(()=>{i||(d.value=(0,_reactNativeReanimated.withTiming)(1,{duration:150}),_.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),h.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),m.value=1,g.value=0,v.value=0)},[i,d,_,h,m,g,v]);const p=(0,_react.useCallback)(()=>{!1!==o&&(0,_index2.triggerHaptic)("impactLight")},[o]),b=(0,_react.useMemo)(()=>({enabled:l,onActivate:()=>{"worklet";m.value=d.value},onUpdate:e=>{"worklet";const a=m.value*e.scale;d.value=a<n?n+.3*(a-n):a>r?r+.2*(a-r):a},onDeactivate:()=>{"worklet";return d.value<n?(d.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=n,g.value=0,void(v.value=0)):d.value>r?(d.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(m.value=r)):void(m.value=d.value)}}),[l,d,m,_,h,g,v,n,r]),y=(0,_reactNativeGestureHandler.usePinchGesture)(b),R=(0,_react.useMemo)(()=>({minPointers:1,maxPointers:1,onActivate:()=>{"worklet";g.value=_.value,v.value=h.value},onUpdate:e=>{"worklet";d.value<=1||(_.value=g.value+e.translationX,h.value=v.value+e.translationY)},onDeactivate:()=>{"worklet";g.value=_.value,v.value=h.value}}),[d,_,h,g,v]),S=(0,_reactNativeGestureHandler.usePanGesture)(R),I=(0,_react.useMemo)(()=>({numberOfTaps:2,onDeactivate:()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(p)(),d.value>1?(d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=1,g.value=0,v.value=0):(d.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),m.value=s)}}),[d,m,_,h,g,v,p,s]),N=(0,_reactNativeGestureHandler.useTapGesture)(I),j=(0,_reactNativeGestureHandler.useCompetingGestures)(y,S,N),w=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:_.value},{translateY:h.value},{scale:d.value}]}),[_,h,d]);_react.default.useEffect(()=>{i||x()},[i,x]);const C=e.alt??c(a+1,t);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:j,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[lightboxImageStyles.container,{width:u.width}],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,w],accessibilityLabel:C,accessible:!0})})})},clamp=(e,a,t)=>Math.min(Math.max(e,a),t),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,..._corners.smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>_reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:e.colors["on-scrim"]}}),lightboxImageStyles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});var _default=exports.default=ImageGallery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_MESSAGE_LIST_LABELS=void 0,exports.MessageList=MessageList,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_index2=require("../Badge/index.js"),_index3=require("../DateSeparator/index.js"),_index4=require("../IconButton/index.js"),_index5=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MESSAGE_LIST_LABELS=exports.DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"}),JUMP_AT=160,FOLLOW_AT=48,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:JUMP_AT},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";function MessageList({messages:e,keyExtractor:t,renderMessage:n,getAuthorKey:r,getDate:s,firstUnreadKey:a,onLoadOlder:o,loadingOlder:i=!1,hasOlder:l=!0,typing:c,empty:u,getAnnouncement:d,followNew:_,keyboardAware:m=!0,keyboardOffset:x,labels:p,now:f,onScroll:j,onContentSizeChange:y,contentContainerStyle:v,style:b,testID:g,...S}){const L=(0,_index.useTheme)(),h=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E=(0,_useReducedMotion.useReducedMotion)(),C=(0,_react.useMemo)(()=>buildStyles(L),[L]),R=(0,_react.useMemo)(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...p}),[p]),T=x??h.bottom,w=(0,_react.useRef)(null),A=(0,_react.useRef)(!1),M=(0,_react.useRef)(!0),O=(0,_react.useRef)(0),[I,N]=(0,_react.useState)(!1),[k,q]=(0,_react.useState)(0),D=(0,_react.useMemo)(()=>{const n=s?e.map(e=>(0,_mobileCore.formatDate)(s(e))):null,o=r?e.map(r):null,i=void 0===a?-1:e.findIndex(e=>t(e)===a);return e.map((t,r)=>{const a=r===e.length-1,l=null!==n&&(a||n[r]!==n[r+1]),c=null!==o&&!a&&o[r+1]===o[r]&&!l&&r!==i,u=null!==o&&r>0&&o[r-1]===o[r]&&(null===n||n[r-1]===n[r])&&r-1!==i;return{groupPosition:positionOf(c,u),day:l&&s?(0,_index3.dayLabel)(s(t),{now:f,labels:R}):null,unread:r===i}})},[e,s,r,a,t,f,R]),P=(0,_react.useCallback)(()=>{M.current=!0,w.current?.scrollToOffset({offset:0,animated:!E}),q(0)},[E]),V=e[0],F=void 0===V?null:t(V),B=(0,_react.useRef)(F);(0,_react.useEffect)(()=>{const n=B.current;if(B.current=F,null===n||null===F||n===F)return;const r=e.findIndex(e=>t(e)===n);if(-1===r)return void q(0);const s=e.slice(0,r).reverse();for(const e of s){const t=d?.(e);t&&(0,_announce.announce)(t)}_&&s.some(_)?P():A.current&&q(e=>e+s.length)},[F]);const U=(0,_react.useCallback)(e=>{M.current=e.nativeEvent.contentOffset.y<=FOLLOW_AT;const t=e.nativeEvent.contentOffset.y>JUMP_AT;t!==A.current&&(A.current=t,N(t),t||q(0)),j?.(e)},[j]),K=(0,_react.useCallback)((e,t)=>{const n=t>O.current;O.current=t,n&&M.current&&w.current?.scrollToOffset({offset:0,animated:!1}),y?.(e,t)},[y]),z=(0,_react.useCallback)(()=>{l&&!i&&o?.()},[l,i,o]),G=(0,_react.useCallback)(({item:e,index:t})=>{const r=D[t];return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[r?.day?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:r.day}):null,r?.unread?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:R.unread,emphasis:!0}):null,n({item:e,index:t,groupPosition:r?.groupPosition??"single"})]})},[D,R.unread,n]),J=(0,_react.useCallback)(e=>t(e),[t]),$=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardChatScrollView,{...e,inverted:!0,offset:T}),[T]),H=k>0?`${R.newMessages(k)}. ${R.jumpToLatest}`:R.jumpToLatest;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[C.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...S,ref:w,data:e,renderItem:G,keyExtractor:J,inverted:!0,onScroll:U,onContentSizeChange:K,onEndReached:o?z:void 0,ListHeaderComponent:c?(0,_jsxRuntime.jsx)(_reactNative.View,{children:c}):void 0,ListFooterComponent:i?(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm",accessibilityLabel:R.loadingOlder,style:C.older}):void 0,ListEmptyComponent:u?(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.fill,children:u}):void 0,renderScrollComponent:m?$:void 0,contentContainerStyle:[C.content,0===e.length?C.grow:null,v],testID:g}),I?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:C.jump,pointerEvents:"box-none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.jumpDisc,children:(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:"arrow-down",accessibilityLabel:H,variant:"ghost",tone:"neutral",onPress:P,testID:g?`${g}-jump`:void 0})}),k>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:(0,_jsxRuntime.jsx)(_index2.Badge,{value:k,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},content:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm},grow:{flexGrow:1},fill:{flex:1},older:{paddingVertical:e.space.md},jump:{position:"absolute",right:e.space.md,bottom:e.space.md},jumpDisc:{borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});var _default=exports.default=MessageList;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_MESSAGE_LIST_LABELS=void 0,exports.MessageList=MessageList,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_index2=require("../Badge/index.js"),_index3=require("../DateSeparator/index.js"),_index4=require("../IconButton/index.js"),_index5=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MESSAGE_LIST_LABELS=exports.DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"}),JUMP_AT=160,FOLLOW_AT=48,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:JUMP_AT},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";function MessageList({messages:e,keyExtractor:t,renderMessage:n,getAuthorKey:r,getDate:s,firstUnreadKey:a,onLoadOlder:o,loadingOlder:i=!1,hasOlder:l=!0,typing:c,empty:u,getAnnouncement:d,followNew:_,keyboardAware:m=!0,keyboardOffset:x,labels:p,now:f,onScroll:j,onContentSizeChange:y,contentContainerStyle:v,style:b,testID:g,...S}){const L=(0,_index.useTheme)(),h=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E=(0,_useReducedMotion.useReducedMotion)(),C=(0,_react.useMemo)(()=>buildStyles(L),[L]),R=(0,_react.useMemo)(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...p}),[p]),T=x??h.bottom,w=(0,_react.useRef)(null),A=(0,_react.useRef)(!1),M=(0,_react.useRef)(!0),O=(0,_react.useRef)(0),[I,N]=(0,_react.useState)(!1),[k,q]=(0,_react.useState)(0),D=(0,_react.useMemo)(()=>{const n=s?e.map(e=>(0,_mobileCore.formatDate)(s(e))):null,o=r?e.map(r):null,i=void 0===a?-1:e.findIndex(e=>t(e)===a);return e.map((t,r)=>{const a=r===e.length-1,l=null!==n&&(a||n[r]!==n[r+1]),c=null!==o&&!a&&o[r+1]===o[r]&&!l&&r!==i,u=null!==o&&r>0&&o[r-1]===o[r]&&(null===n||n[r-1]===n[r])&&r-1!==i;return{groupPosition:positionOf(c,u),day:l&&s?(0,_index3.dayLabel)(s(t),{now:f,labels:R}):null,unread:r===i}})},[e,s,r,a,t,f,R]),P=(0,_react.useCallback)(()=>{M.current=!0,w.current?.scrollToOffset({offset:0,animated:!E}),q(0)},[E]),V=e[0],F=void 0===V?null:t(V),B=(0,_react.useRef)(F);(0,_react.useEffect)(()=>{const n=B.current;if(B.current=F,null===n||null===F||n===F)return;const r=e.findIndex(e=>t(e)===n);if(-1===r)return void q(0);const s=e.slice(0,r).reverse();for(const e of s){const t=d?.(e);t&&(0,_announce.announce)(t)}_&&s.some(_)?P():A.current&&q(e=>e+s.length)},[F,e,t,d,_,P]);const U=(0,_react.useCallback)(e=>{M.current=e.nativeEvent.contentOffset.y<=FOLLOW_AT;const t=e.nativeEvent.contentOffset.y>JUMP_AT;t!==A.current&&(A.current=t,N(t),t||q(0)),j?.(e)},[j]),K=(0,_react.useCallback)((e,t)=>{const n=t>O.current;O.current=t,n&&M.current&&w.current?.scrollToOffset({offset:0,animated:!1}),y?.(e,t)},[y]),z=(0,_react.useCallback)(()=>{l&&!i&&o?.()},[l,i,o]),G=(0,_react.useCallback)(({item:e,index:t})=>{const r=D[t];return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[r?.day?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:r.day}):null,r?.unread?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:R.unread,emphasis:!0}):null,n({item:e,index:t,groupPosition:r?.groupPosition??"single"})]})},[D,R.unread,n]),J=(0,_react.useCallback)(e=>t(e),[t]),$=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardChatScrollView,{...e,inverted:!0,offset:T}),[T]),H=k>0?`${R.newMessages(k)}. ${R.jumpToLatest}`:R.jumpToLatest;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[C.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...S,ref:w,data:e,renderItem:G,keyExtractor:J,inverted:!0,onScroll:U,onContentSizeChange:K,onEndReached:o?z:void 0,ListHeaderComponent:c?(0,_jsxRuntime.jsx)(_reactNative.View,{children:c}):void 0,ListFooterComponent:i?(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm",accessibilityLabel:R.loadingOlder,style:C.older}):void 0,ListEmptyComponent:u?(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.fill,children:u}):void 0,renderScrollComponent:m?$:void 0,contentContainerStyle:[C.content,0===e.length?C.grow:null,v],testID:g}),I?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:C.jump,pointerEvents:"box-none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.jumpDisc,children:(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:"arrow-down",accessibilityLabel:H,variant:"ghost",tone:"neutral",onPress:P,testID:g?`${g}-jump`:void 0})}),k>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:(0,_jsxRuntime.jsx)(_index2.Badge,{value:k,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},content:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm},grow:{flexGrow:1},fill:{flex:1},older:{paddingVertical:e.space.md},jump:{position:"absolute",right:e.space.md,bottom:e.space.md},jumpDisc:{borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});var _default=exports.default=MessageList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NonModalBottomSheet=exports.DEFAULT_NON_MODAL_BOTTOM_SHEET_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(i,r,a):i[r]=e[r]);return i}const DEFAULT_NON_MODAL_BOTTOM_SHEET_LABELS=exports.DEFAULT_NON_MODAL_BOTTOM_SHEET_LABELS=Object.freeze({dragHandle:"Drag handle"}),ERROR_PREFIX="[@webority/mobile-ui] NonModalBottomSheet: ",SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,OVERSHOOT_TO_CLOSE=80,PERCENT_PATTERN=/^(\d+(?:\.\d+)?|\.\d+)%$/,parsePercent=e=>{if("string"!=typeof e)return;const t=PERCENT_PATTERN.exec(e);if(!t)return;const a=Number(t[1]);return a>0&&a<=100?a:void 0},isValidSnapPoint=e=>"number"==typeof e?Number.isFinite(e)&&e>0:void 0!==parsePercent(e),validateProps=(e,t)=>{if(0===e.length)throw new Error(`${ERROR_PREFIX}snapPoints needs at least one snap point.`);for(const t of e)if(!isValidSnapPoint(t))throw new Error(`${ERROR_PREFIX}snap point ${String(t)} is not a positive number or a percentage up to 100%.`);if(null!=t&&(!Number.isInteger(t)||t<0||t>=e.length))throw new Error(`${ERROR_PREFIX}snapIndex ${t} is outside the snap points.`)},resolveNonModalSnapPoints=(e,t)=>e.map(e=>"number"==typeof e?e:parseFloat(e)/100*t).sort((e,t)=>e-t),topAt=(e,t,a)=>{const r=e[a];if(void 0===r)throw new Error(`${ERROR_PREFIX}snap index ${a} has no snap point.`);return Math.max(0,t-r)},NonModalBottomSheet=e=>{const{open:t,onClose:a,snapPoints:r,snapIndex:n,onSnapChange:i,enablePanDownToClose:o=!0,scrollable:s=!1,title:c,header:l,footer:u,labels:d,handleIndicatorStyle:_,containerStyle:h,children:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NonModalBottomSheet=exports.DEFAULT_NON_MODAL_BOTTOM_SHEET_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(i,r,a):i[r]=e[r]);return i}const DEFAULT_NON_MODAL_BOTTOM_SHEET_LABELS=exports.DEFAULT_NON_MODAL_BOTTOM_SHEET_LABELS=Object.freeze({dragHandle:"Drag handle"}),ERROR_PREFIX="[@webority/mobile-ui] NonModalBottomSheet: ",SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,OVERSHOOT_TO_CLOSE=80,PERCENT_PATTERN=/^(\d+(?:\.\d+)?|\.\d+)%$/,parsePercent=e=>{if("string"!=typeof e)return;const t=PERCENT_PATTERN.exec(e);if(!t)return;const a=Number(t[1]);return a>0&&a<=100?a:void 0},isValidSnapPoint=e=>"number"==typeof e?Number.isFinite(e)&&e>0:void 0!==parsePercent(e),validateProps=(e,t)=>{if(0===e.length)throw new Error(`${ERROR_PREFIX}snapPoints needs at least one snap point.`);for(const t of e)if(!isValidSnapPoint(t))throw new Error(`${ERROR_PREFIX}snap point ${String(t)} is not a positive number or a percentage up to 100%.`);if(null!=t&&(!Number.isInteger(t)||t<0||t>=e.length))throw new Error(`${ERROR_PREFIX}snapIndex ${t} is outside the snap points.`)},resolveNonModalSnapPoints=(e,t)=>e.map(e=>"number"==typeof e?e:parseFloat(e)/100*t).sort((e,t)=>e-t),topAt=(e,t,a)=>{const r=e[a];if(void 0===r)throw new Error(`${ERROR_PREFIX}snap index ${a} has no snap point.`);return Math.max(0,t-r)},NonModalBottomSheet=e=>{const{open:t,onClose:a,snapPoints:r,snapIndex:n,onSnapChange:i,enablePanDownToClose:o=!0,scrollable:s=!1,title:c,header:l,footer:u,labels:d,handleIndicatorStyle:_,containerStyle:h,children:m,accessibilityLabel:v,testID:p}=e;validateProps(r,n);const f=(0,_react.useMemo)(()=>({...DEFAULT_NON_MODAL_BOTTOM_SHEET_LABELS,...d}),[d]),R=(0,_index.useTheme)(),N=(0,_usePresenceMotion.usePresenceMotion)(),E=N.reduced,S=(0,_react.useMemo)(()=>buildStyles(R),[R]),[b,x]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),O=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.height;t>0&&x(t)},[]),g=(0,_react.useMemo)(()=>resolveNonModalSnapPoints(r,b),[r,b]),M=g[g.length-1]??0,y=b,w=Math.max(0,b-M),T=(0,_react.useCallback)(e=>topAt(g,b,e),[g,b]),[P,j]=(0,_react.useState)(!1),[C,A]=(0,_react.useState)(-1),I=(0,_react.useRef)(-1),L=(0,_react.useRef)(a);L.current=a;const D=(0,_react.useRef)(i);D.current=i;const k=(0,_reactNativeReanimated.useSharedValue)(y),B=(0,_reactNativeReanimated.useSharedValue)(y),F=(0,_react.useCallback)(()=>{I.current<0&&j(!1)},[]),V=(0,_react.useCallback)(()=>{if(I.current=-1,A(-1),E)return k.value=y,void F();k.value=(0,_reactNativeReanimated.withTiming)(y,{duration:N.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...R.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(F)()})},[y,N,E,R.motion.ease.accelerate,k,F]),H=(0,_react.useCallback)(e=>{const t=T(e);k.value=E?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[E,T,k]),$=(0,_react.useCallback)((e,t)=>{e!==I.current&&(I.current=e,A(e),H(e),t&&D.current?.(e))},[H]),q=(0,_react.useEffectEvent)(e=>{if(!e)return void(I.current>=0&&V());const t=n??0;j(!0);const a=T(t);E?k.value=a:(k.value=y,k.value=(0,_reactNativeReanimated.withSpring)(a,SPRING_CONFIG)),I.current=t,A(t)});(0,_react.useEffect)(()=>{q(t)},[t]);const G=(0,_react.useEffectEvent)(e=>{t&&P&&e!==I.current&&$(e,!1)});(0,_react.useEffect)(()=>{null!=n&&G(n)},[n]);const U=(0,_react.useEffectEvent)(e=>{const t=I.current;t>=0&&(k.value=topAt(g,e,t))});(0,_react.useEffect)(()=>{U(b)},[b]);const X=(0,_react.useCallback)(e=>{if(e<0)return(0,_index2.triggerHaptic)("selection"),V(),void L.current();e!==I.current?$(e,!0):H(e)},[$,H,V]),J=(0,_react.useCallback)(e=>{const t=I.current;t<0||$(Math.min(Math.max(t+e,0),g.length-1),!0)},[$,g.length]),W=(0,_react.useMemo)(()=>g.map(e=>b-e),[g,b]),Y=(0,_react.useMemo)(()=>{const e=W,t=w,a=o;return{testID:p?`${p}-pan-gesture`:"non-modal-bottom-sheet-pan-gesture",activeOffsetY:[-10,10],onActivate:()=>{"worklet";B.value=k.value},onUpdate:e=>{"worklet";const a=B.value+e.translationY;k.value=a<t?t+.25*(a-t):a},onDeactivate:t=>{"worklet";const r=k.value,n=e[0];if(void 0===n)return;if(t.velocityY>1e3)return void(0,_reactNativeReanimated.runOnJS)(X)(a?-1:0);if(a&&r-n>80)return void(0,_reactNativeReanimated.runOnJS)(X)(-1);let i=0,o=1/0,s=0;for(const t of e){const e=Math.abs(r-t);e<o&&(o=e,i=s),s++}(0,_reactNativeReanimated.runOnJS)(X)(i)}}},[B,o,X,w,W,p,k]),z=(0,_reactNativeGestureHandler.usePanGesture)(Y),K=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({top:Math.max(k.value,w)}),[w]),Q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(k.value,w),t=b-e;return{height:Math.max(0,Math.min(t,M))}},[b,M,w]);return P?(0,_jsxRuntime.jsx)(_reactNative.View,{collapsable:!1,style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",onLayout:O,testID:p,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityLabel:v,testID:p?`${p}-sheet`:void 0,style:[S.sheet,{height:M,backgroundColor:R.colors.surface,borderTopLeftRadius:R.radius.xl,borderTopRightRadius:R.radius.xl,..._corners.smoothCorners,...R.shadow.modal},h,K],children:(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[S.body,Q],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:z,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:S.handleRow,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:f.dragHandle,accessibilityHint:"Swipe up or down to change the height of the sheet",accessibilityValue:{text:`Snap point ${C+1} of ${g.length}`},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName?J(1):"decrement"===e.nativeEvent.actionName&&J(-1)},testID:p?`${p}-handle`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.handle,{backgroundColor:R.colors.border},_]})})}),null!=c?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:c}):null,l,s?(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:S.scrollContent,children:m}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:S.content,children:m}),u]})})}):null};exports.NonModalBottomSheet=NonModalBottomSheet,NonModalBottomSheet.displayName="NonModalBottomSheet";const buildStyles=e=>_reactNative.StyleSheet.create({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},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1}});var _default=exports.default=NonModalBottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NumberInput=exports.DEFAULT_NUMBER_INPUT_LABELS=void 0;var cache,_react=_interopRequireWildcard(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"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,r,a=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(s,r,i):s[r]=e[r]);return s}const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_NUMBER_INPUT_LABELS=exports.DEFAULT_NUMBER_INPUT_LABELS=Object.freeze({decrease:"Decrease",increase:"Increase",input:"Number input"}),DEFAULT_LONG_PRESS_DELAY=500,DEFAULT_LONG_PRESS_INTERVAL=80,roundToPrecision=(e,t)=>{if(!Number.isFinite(e))return 0;if(t<=0)return Math.round(e);const i=10**t;return Math.round(e*i)/i},clamp=(e,t,i)=>e<t?t:e>i?i:e,formatValue=(e,t,i)=>Number.isFinite(e)?t&&i>0?e.toFixed(i):String(Math.trunc(e)):"",sanitizeTyped=(e,t)=>{if(!e)return"";let i=e.replace(/[^0-9.-]/g,"");if(i=i.replace(/(?!^)-/g,""),t){const e=i.indexOf(".");-1!==e&&(i=i.slice(0,e+1)+i.slice(e+1).replace(/\./g,""))}else i=i.replace(/\./g,"");return i},NumberInput=exports.NumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:a,min:s=Number.NEGATIVE_INFINITY,max:n=Number.POSITIVE_INFINITY,step:l=1,allowDecimal:c=!1,precision:u=0,label:o,help:d,helperText:_,error:b,disabled:m=!1,size:p="md",variant:x="inline",unit:f,haptic:N,labels:h,accessibilityLabel:y,style:I,containerStyle:T,inputStyle:j,buttonStyle:S,unitStyle:g,labelStyle:R,textInputProps:F,testID:v}=e;(0,_assertValidValue.assertValidValue)("NumberInput","size",e.size,NUMBER_INPUT_SIZES),(0,_assertValidValue.assertValidValue)("NumberInput","variant",e.variant,NUMBER_INPUT_VARIANTS);const E=(0,_react.useMemo)(()=>({...DEFAULT_NUMBER_INPUT_LABELS,...h}),[h]),[V,L]=(0,_index.useControllableState)({value:i,defaultValue:r??e.min??0,onChange:a}),P=(0,_index2.useTheme)(),B=(0,_index2.resolveFieldSize)(P,p),A=(0,_FieldBase.resolveFieldTextStyle)(P,{disabled:m}),U=(0,_react.useMemo)(()=>buildStyles(P),[P]),C=(0,_react.useRef)(null),[w,z]=(0,_react.useState)(formatValue(V,c,u)),[M,k]=(0,_react.useState)(!1),[D,O]=(0,_react.useState)(!1),q=(0,_react.useCallback)(()=>{m||C.current?.focus()},[m]),W=(0,_react.useRef)(null),H=(0,_react.useRef)(null),G=(0,_react.useCallback)(()=>{null!==W.current&&(clearTimeout(W.current),W.current=null),null!==H.current&&(clearInterval(H.current),H.current=null)},[]);(0,_react.useEffect)(()=>G,[G]),(0,_react.useEffect)(()=>{M||z(formatValue(V,c,u))},[V,c,u,M]);const Y=V<=s,Z=V>=n,$=!m,J=(0,_react.useCallback)(e=>{const t=roundToPrecision(e,c?u:0),i=clamp(t,s,n);i!==V&&L(i)},[c,n,s,L,u,V]),K=(0,_react.useCallback)(()=>{if(!$||Y)return;const e=(0,_index3.resolveHaptic)(N,"selection");e&&(0,_index3.triggerHaptic)(e),J(V-l)},[Y,$,N,J,l,V]),Q=(0,_react.useCallback)(()=>{if(!$||Z)return;const e=(0,_index3.resolveHaptic)(N,"selection");e&&(0,_index3.triggerHaptic)(e),J(V+l)},[Z,$,N,J,l,V]);_react.default.useImperativeHandle(t,()=>({focus:()=>C.current?.focus(),blur:()=>C.current?.blur(),clear:()=>{z(""),Number.isFinite(s)&&s>0?L(s):L(0<s?s:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NumberInput=exports.DEFAULT_NUMBER_INPUT_LABELS=void 0;var cache,_react=_interopRequireWildcard(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"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,r,a=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(s,r,i):s[r]=e[r]);return s}const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_NUMBER_INPUT_LABELS=exports.DEFAULT_NUMBER_INPUT_LABELS=Object.freeze({decrease:"Decrease",increase:"Increase",input:"Number input"}),DEFAULT_LONG_PRESS_DELAY=500,DEFAULT_LONG_PRESS_INTERVAL=80,roundToPrecision=(e,t)=>{if(!Number.isFinite(e))return 0;if(t<=0)return Math.round(e);const i=10**t;return Math.round(e*i)/i},clamp=(e,t,i)=>e<t?t:e>i?i:e,formatValue=(e,t,i)=>Number.isFinite(e)?t&&i>0?e.toFixed(i):String(Math.trunc(e)):"",sanitizeTyped=(e,t)=>{if(!e)return"";let i=e.replace(/[^0-9.-]/g,"");if(i=i.replace(/(?!^)-/g,""),t){const e=i.indexOf(".");-1!==e&&(i=i.slice(0,e+1)+i.slice(e+1).replace(/\./g,""))}else i=i.replace(/\./g,"");return i},NumberInput=exports.NumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:a,min:s=Number.NEGATIVE_INFINITY,max:n=Number.POSITIVE_INFINITY,step:l=1,allowDecimal:c=!1,precision:u=0,label:o,help:d,helperText:_,error:b,disabled:m=!1,size:p="md",variant:x="inline",unit:f,haptic:N,labels:h,accessibilityLabel:y,style:I,containerStyle:T,inputStyle:j,buttonStyle:S,unitStyle:g,labelStyle:R,textInputProps:F,testID:v}=e;(0,_assertValidValue.assertValidValue)("NumberInput","size",e.size,NUMBER_INPUT_SIZES),(0,_assertValidValue.assertValidValue)("NumberInput","variant",e.variant,NUMBER_INPUT_VARIANTS);const E=(0,_react.useMemo)(()=>({...DEFAULT_NUMBER_INPUT_LABELS,...h}),[h]),[V,L]=(0,_index.useControllableState)({value:i,defaultValue:r??e.min??0,onChange:a}),P=(0,_index2.useTheme)(),B=(0,_index2.resolveFieldSize)(P,p),A=(0,_FieldBase.resolveFieldTextStyle)(P,{disabled:m}),U=(0,_react.useMemo)(()=>buildStyles(P),[P]),C=(0,_react.useRef)(null),[w,z]=(0,_react.useState)(formatValue(V,c,u)),[M,k]=(0,_react.useState)(!1),[D,O]=(0,_react.useState)(!1),q=(0,_react.useCallback)(()=>{m||C.current?.focus()},[m]),W=(0,_react.useRef)(null),H=(0,_react.useRef)(null),G=(0,_react.useCallback)(()=>{null!==W.current&&(clearTimeout(W.current),W.current=null),null!==H.current&&(clearInterval(H.current),H.current=null)},[]);(0,_react.useEffect)(()=>G,[G]),(0,_react.useEffect)(()=>{M||z(formatValue(V,c,u))},[V,c,u,M]);const Y=V<=s,Z=V>=n,$=!m,J=(0,_react.useCallback)(e=>{const t=roundToPrecision(e,c?u:0),i=clamp(t,s,n);i!==V&&L(i)},[c,n,s,L,u,V]),K=(0,_react.useCallback)(()=>{if(!$||Y)return;const e=(0,_index3.resolveHaptic)(N,"selection");e&&(0,_index3.triggerHaptic)(e),J(V-l)},[Y,$,N,J,l,V]),Q=(0,_react.useCallback)(()=>{if(!$||Z)return;const e=(0,_index3.resolveHaptic)(N,"selection");e&&(0,_index3.triggerHaptic)(e),J(V+l)},[Z,$,N,J,l,V]);_react.default.useImperativeHandle(t,()=>({focus:()=>C.current?.focus(),blur:()=>C.current?.blur(),clear:()=>{z(""),Number.isFinite(s)&&s>0?L(s):L(0<s?s:Math.min(n,0))}}),[n,s,L]);const X=(0,_react.useCallback)(e=>{$&&(G(),W.current=setTimeout(()=>{H.current=setInterval(()=>{"inc"===e?Q():K()},80)},500))},[G,K,Q,$]),ee=(0,_react.useCallback)(e=>{const t=sanitizeTyped(e,c);z(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=s&&i<=n&&i!==V&&L(roundToPrecision(i,c?u:0))},[c,n,s,L,u,V]),te=(0,_react.useCallback)(()=>{k(!1),O(!1);const e=Number(w);if(""===w||!Number.isFinite(e))return void z(formatValue(V,c,u));const t=roundToPrecision(e,c?u:0),i=clamp(t,s,n);i!==V&&L(i),z(formatValue(i,c,u))},[c,w,n,s,L,u,V]),ie=(0,_react.useCallback)(()=>{k(!0),O(!0)},[]),re=Y||m?P.colors["text-disabled"]:P.colors["text-body"],ae=Z||m?P.colors["text-disabled"]:P.colors["text-body"],se=B.icon+8,renderStepper=(e,t,i,r,a,s)=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:t,onLongPress:()=>X(e),onPressOut:G,delayLongPress:500,disabled:i,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:se,height:se,alignItems:"center",justifyContent:"center",borderRadius:P.radius.pill,..._corners.smoothCorners},e&&!i?{backgroundColor:P.colors["surface-pressed"]}:null,S],testID:`${v??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:{fontSize:B.icon,color:a,fontWeight:P.weight.semibold,lineHeight:B.icon+2},children:s})}),ne=y??(0,_FieldBase.fieldTextAsString)(o)??E.input,le=!0===b||(0,_FieldBase.hasFieldText)(b),ce=(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:p,disabled:m,error:le,filled:!0,focused:D,onPress:q,pressFeedback:!1,leading:renderStepper("dec",K,Y||m,E.decrease,re,"−"),trailing:renderStepper("inc",Q,Z||m,E.increase,ae,"+"),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:C,value:w,onChangeText:ee,onFocus:ie,onBlur:te,editable:!m,keyboardType:c?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:ne,accessibilityValue:{now:Number.isFinite(V)?V:0},accessibilityState:{disabled:m},"aria-disabled":m,accessibilityActions:[{name:"increment",label:E.increase},{name:"decrement",label:E.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&Q(),"decrement"===e.nativeEvent.actionName&&K()},style:[U.input,{fontSize:B.text,color:A.color,...A.weightStyle},j],...F}),f?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",style:[U.unit,{fontSize:B.text,color:A.placeholderColor},g],children:f}):null]})}),ue=(0,_FieldBase.hasFieldText)(o)?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:p,help:d,style:R,children:o}):null,oe=(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:p,error:le,text:le?b:_});return"horizontal"===x?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[U.horizontalContainer,T,I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:U.horizontalLabelWrap,children:ue}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[ce,oe]})]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T,I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[ue,ce,oe]})});NumberInput.displayName="NumberInput";const buildStyles=e=>_reactNative.StyleSheet.create({inputRow:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},input:{flex:1,textAlign:"center",padding:e.space.none,margin:e.space.none,includeFontPadding:!1},unit:{marginLeft:e.space.xs},label:{marginBottom:e.space.xs},helper:{marginTop:e.space.xs},horizontalContainer:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},horizontalLabelWrap:{flexShrink:1,paddingRight:e.space.md}});var _default=exports.default=NumberInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),cellAt=(e,t)=>{const i=e[t];if(void 0===i)throw new Error(`OTP cell ${t} is outside the ${e.length} cells.`);return i},sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:a,onComplete:n,length:s=6,keyboardType:l="number-pad",autoFocus:o=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:p=!1,haptic:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),cellAt=(e,t)=>{const i=e[t];if(void 0===i)throw new Error(`OTP cell ${t} is outside the ${e.length} cells.`);return i},sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:a,onComplete:n,length:s=6,keyboardType:l="number-pad",autoFocus:o=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:p=!1,haptic:m,labels:v,onFocus:x,accessibilityLabel:g,style:h,cellStyle:f,textStyle:b,testID:y}=e;(0,_assertValidValue.assertValidValue)("OTPInput","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("OTPInput","keyboardType",e.keyboardType,["number-pad","default"]);const T=v?{...DEFAULT_OTP_INPUT_LABELS,...v}:DEFAULT_OTP_INPUT_LABELS,[j,N]=(0,_index.useControllableState)({value:i,defaultValue:r??"",onChange:a}),A=(0,_index2.useTheme)(),V=(0,_react.useMemo)(()=>buildStyles(A),[A]),D=(0,_index2.resolveOtpInputSize)(A,_),E=A.components["otp-input"][_].radius,P=(0,_react.useRef)([]),[k,F]=(0,_react.useState)(-1),[O,R]=(0,_react.useState)(0),C=(0,_react.useRef)(null),I=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,S=(0,_react.useRef)(new Map),w=(0,_react.useMemo)(()=>{const e=S.current,t=[];for(let i=0;i<s;i+=1){let r=e.get(i);r||(r=new _reactNative.Animated.Value(0),e.set(i,r)),t.push(r)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),L=(0,_react.useRef)(-1),B=A.settings.components["otp-input"]?.shakeOnError??!1,M=(0,_index.useReducedMotion)(),z=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===C.current||!z||C.current||(m&&(0,_index3.triggerHaptic)("notificationError"),B&&!M&&((0,_index2.setNativeValue)(I,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(I,{toValue:1,duration:A.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(I,{toValue:-1,duration:A.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(I,{toValue:1,duration:A.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(I,{toValue:0,duration:A.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver})]),e.start())),C.current=z,()=>e?.stop()},[z,I,B,m,M,A.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=L.current;if(L.current=k,e===k)return;if(-1===e&&-1===k)return;const t=[];return w.forEach((i,r)=>{const a=r===k?1:0;if(r!==k&&r!==e)return;const n=_reactNative.Animated.timing(i,{toValue:a,duration:A.motion.duration.fast,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});n.start(),t.push(n)}),()=>t.forEach(e=>{e.stop()})},[k,w,A]);const q=(0,_react.useCallback)(e=>{const t=P.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>q(0),blur:()=>{const e=P.current[Math.max(k,0)];e?.blur()},clear:()=>{N(""),q(0)}}),[q,k,N]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>q(0),c);return()=>clearTimeout(e)}},[o,c,u,q]);const U=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(j.length,s);t+=1)e[t]=j.charAt(t);return e},[j,s]),H=(0,_react.useMemo)(()=>U.map((e,t)=>({key:`otp-cell-${t}`,index:t,char:e})),[U]),W=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==j&&(N(t),t.length===s&&n&&n(t))},[s,N,n,j]),$=(0,_react.useCallback)((e,t)=>{const i=t.replace(/\u200B/g,""),r=sanitizeChar(i,l);if(!r){const t=U.slice(),i=cellAt(U,e).length>0;if(t[e]="",W(t.join("").slice(0,s)),!i&&e>0){const t=U.slice();t[e-1]="",W(t.join("")),q(e-1)}return}const a=cellAt(U,e),n=a&&r.length>s&&r.startsWith(a)?r.slice(a.length):r;if(n.length>=s){const t=n.slice(0,s),i=j.length;return W(t),t.length!==i&&m&&(0,_index3.triggerHaptic)(m),void P.current[e]?.blur()}const o=U.slice();let c=e;for(let e=0;e<r.length&&c<s;e+=1)o[c]=r.charAt(e),c+=1;const u=o.join("").slice(0,s),d=j.length;W(u),u.length!==d&&m&&(0,_index3.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?P.current[e]?.blur():q(_)},[U,q,l,s,m,W,j]),G=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===cellAt(U,e).length){if(e>0){const t=U.slice();t[e-1]="",W(t.join("")),q(e-1)}}else{const t=U.slice();t[e]="",W(t.join(""))}},[U,q,W]),K=(0,_react.useCallback)((e,t)=>{F(e),x?.(t)},[x]),X=(0,_react.useCallback)(()=>{F(-1)},[]),J=(0,_react.useCallback)(()=>{if(u)return;const e=U.indexOf("");q(-1===e?s-1:e)},[U,u,q,s]),Q=(0,_react.useCallback)(e=>{R(e.nativeEvent.layout.width)},[]),Y=g??T.field(s),Z=O>0?Math.max(24,Math.min(D.cell,Math.floor((O-D.gap*(s-1))/s))):D.cell,ee=I.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h,onLayout:Q,accessible:!0,accessibilityRole:"none",accessibilityLabel:Y,accessibilityValue:{text:i},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:J,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[V.row,{columnGap:D.gap,transform:[{translateX:ee}]}],children:H.map(({key:e,index:t,char:i})=>{const r=k===t,a=i.length>0,n=z?A.colors["danger-border"]:A.colors["focus-ring"],o=w[t];if(!o)return null;const c=p&&a?"●":i;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:V.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:Z,height:Z,radius:E,borderWidth:1.5,focused:r,error:z,filled:a,disabled:u,paddingHorizontal:A.space.none,paddingVertical:A.space.none,gap:A.space.none,style:f,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{P.current[t]=e},value:(p&&a?"":i)||"",onChangeText:e=>$(t,e),onKeyPress:e=>G(t,e),onFocus:e=>K(t,e),onBlur:X,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:a,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[V.input,{fontSize:D.text,color:A.colors["text-body"],...(0,_index2.fontFor)(A,"semibold")},b]}),p&&a?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:V.maskOverlay,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:[{fontSize:D.text},b],children:c})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[V.underline,{backgroundColor:n,opacity:o}]})]},e)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_PROFILE_PICKER_LABELS=void 0,exports.ProfilePicker=ProfilePicker,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_index3=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Avatar/index.js"),_index5=require("../FieldBase/index.js"),_FilePicker=require("../FilePicker/FilePicker.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index6=require("../Spinner/index.js"),_index7=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PROFILE_PICKER_LABELS=exports.DEFAULT_PROFILE_PICKER_LABELS=Object.freeze({pick:"Change profile photo",remove:"Remove photo",sheetTitle:"Change photo",errorTooLarge:e=>`The photo is larger than ${e} MB.`,errorWrongType:"That file is not a supported image."}),DEFAULT_ACCEPT=["image/*"],SHEET_ICON_SIZE=20,SOFT_FILL_OPACITY=.14,SIZE_PX={sm:72,md:120,lg:160},clamp=(e,r,t)=>Math.min(t,Math.max(r,e)),toneFor=(e,r)=>{switch(r){case"success":return{base:e.colors.success,on:e.colors["on-success"]};case"warning":return{base:e.colors.warning,on:e.colors["on-warning"]};case"danger":return{base:e.colors.danger,on:e.colors["on-danger"]};case"info":return{base:e.colors.info,on:e.colors["on-info"]};case"neutral":return{base:e.colors["text-muted"],on:e.colors["on-neutral-strong"]};default:return{base:e.colors.primary,on:e.colors["on-primary"]}}},badgeLookFor=(e,r,t)=>{const i=toneFor(e,r),s=i.base,o=e.colors.bg,n="neutral"===r;let a;switch(t){case"soft":a={fill:n?e.colors["bg-muted"]:(0,_color.blendOf)(s,.14,o,e.colors["bg-subtle"]),ring:o,icon:s};break;case"outline":a={fill:o,ring:n?e.colors.border:s,icon:s};break;default:a={fill:s,ring:o,icon:i.on}}return a},resolveRadius=(e,r)=>"circle"===e?r/2:"rounded"===e?Math.max(6,Math.round(.22*r)):0,REMOVE_VALUE="__profile-picker-remove__";function ProfilePicker(e){const{ref:r,value:t,name:i,sources:s,onPick:o,onRemove:n,loading:a=!1,disabled:l=!1,accept:c=DEFAULT_ACCEPT,maxSizeMB:d,size:u="md",shape:_="circle",badgeIcon:m="camera",tone:x,variant:p,avatarTone:g,avatarBackgroundColor:h,avatarColor:b,label:f,required:y=!1,helperText:v,error:j,layout:k="stacked",title:P,subtitle:C,ImageComponent:E,labels:R,haptic:I,onError:V,accessibilityLabel:S,style:T,testID:F}=e;(0,_assertValidValue.assertValidValue)("ProfilePicker","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("ProfilePicker","shape",e.shape,["circle","rounded","square"]),(0,_assertValidValue.assertValidValue)("ProfilePicker","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("ProfilePicker","variant",e.variant,["solid","soft","outline"]),(0,_assertValidValue.assertValidValue)("ProfilePicker","layout",e.layout,["stacked","inline","profile"]);const L=(0,_index.useTheme)(),A=L.settings.components["profile-picker"],w=x??A?.defaultTone??"primary",O=p??A?.defaultVariant??"solid",q=(0,_react.useMemo)(()=>badgeLookFor(L,w,O),[L,w,O]),M=g??A?.defaultAvatarTone,N=(0,_react.useMemo)(()=>({...DEFAULT_PROFILE_PICKER_LABELS,...R}),[R]),[D,B]=(0,_react.useState)(null),[z,H]=(0,_react.useState)(null),[U,K]=(0,_react.useState)(!1),[Z,$]=(0,_react.useState)(t);t!==Z&&($(t),B(null));const W=a||l,G=D??t??null,X=(0,_react.useMemo)(()=>G?{uri:G}:void 0,[G]),Q=j??z??void 0,Y=!W&&(null!==D||Boolean(t)&&Boolean(n)),J=s.length>0||Y,ee=SIZE_PX[u],re=resolveRadius(_,ee),te=re*(1-Math.SQRT1_2),ie=clamp(Math.round(.28*ee),24,44),se=te-ie/2,oe=Math.max(0,-se),ne=(0,_react.useCallback)(e=>{H(e),V?.(e),!1!==I&&(0,_index2.triggerHaptic)("notificationError")},[V,I]),ae=(0,_react.useCallback)(async e=>{let r;try{r=await e.pick()}catch(e){return void ne(e instanceof Error?e.message:String(e))}const t=r?.[0];if(!t)return;if("number"==typeof d&&"number"==typeof t.size&&t.size>1024*d*1024)return void ne(N.errorTooLarge(d));if(t.type&&!(0,_FilePicker.matchesAccept)(t.type,c))return void ne(N.errorWrongType);H(null),B(t.uri);const i=(0,_index2.resolveHaptic)(I,"selection");i&&(0,_index2.triggerHaptic)(i),o?.(t)},[d,c,N,I,o,ne]),le=(0,_react.useCallback)(()=>{if(W)return;ue.current=null;const[e]=s;void 0===e||1!==s.length||Y?(s.length>0||Y)&&K(!0):ae(e)},[W,s,Y,ae]),ce=(0,_react.useCallback)(()=>{B(null),H(null);const e=(0,_index2.resolveHaptic)(I,"selection");e&&(0,_index2.triggerHaptic)(e),n?.()},[I,n]),de=(0,_react.useMemo)(()=>{const e=s.map(e=>({kind:"source",source:e}));return Y&&e.push({kind:"remove"}),e},[s,Y]),ue=(0,_react.useRef)(null),me=(0,_react.useCallback)(e=>{ue.current||(K(!1),"remove"===e.kind?ce():ue.current=e.source)},[ce]),xe=(0,_react.useRef)(ae);xe.current=ae;const pe=(0,_react.useCallback)(()=>{const e=ue.current;ue.current=null,e&&xe.current(e)},[]),ge=F??"profile-picker",he=S??(J?N.pick:i),be=(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:ee,height:ee,marginBottom:oe,marginRight:oe},children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:le,disabled:W||!J,accessibilityRole:J?"button":"image",accessibilityLabel:he,accessibilityHint:(0,_index5.fieldTextAsString)(Q),accessibilityState:J?{disabled:W,busy:a}:{busy:a},"aria-disabled":J?W:void 0,"aria-busy":a,testID:`${ge}-button`,style:({pressed:e})=>[{width:ee,height:ee,borderRadius:re,..._corners.smoothCorners},{opacity:l?.55:e?.85:1}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index4.Avatar,{dimension:ee,shape:_,name:i||void 0,source:X,ImageComponent:E,tone:M,backgroundColor:h,color:b,placeholderIcon:"user"})}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.fill,styles.overlay,{borderRadius:re,..._corners.smoothCorners,backgroundColor:L.colors.scrim}],testID:`${ge}-loading`,children:(0,_jsxRuntime.jsx)(_index6.Spinner,{size:ee>=100?"md":"sm",color:L.colors["on-primary"]})}):null,!l&&J?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:`${ge}-badge`,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,style:[styles.badge,{width:ie,height:ie,borderRadius:L.radius.pill,..._corners.smoothCorners,right:se,bottom:se,backgroundColor:q.fill,borderColor:q.ring}],children:(0,_slotIcon.renderSlotIcon)(m,{color:q.icon,size:Math.round(.55*ie),disabled:!1})}):null]})}),fe="stacked"!==k?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.meta,"profile"===k?styles.metaCentred:null],children:[P?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",weight:"semibold",style:[styles.title,"profile"===k?styles.textCentred:null],children:P}):null,C?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"bodySmall",color:"secondary",style:[styles.subtitle,"profile"===k?styles.textCentred:null,{marginTop:L.space.xxs}],children:C}):null,(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Q??v,error:(0,_index5.hasFieldText)(Q)})]}):(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Q??v,error:(0,_index5.hasFieldText)(Q)});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,style:T,testID:F,children:[f?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{required:y,children:f}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:"inline"===k?[styles.row,{columnGap:L.space.md}]:["profile"===k?styles.columnCentred:styles.column,{rowGap:L.space.xs}],children:[be,fe]}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:U,haptic:I,onClose:()=>K(!1),onAfterClose:pe,title:N.sheetTitle,options:de,getOptionLabel:e=>"remove"===e.kind?N.remove:e.source.label,getOptionValue:e=>"remove"===e.kind?REMOVE_VALUE:e.source.key,destructiveOf:e=>"remove"===e.kind,getOptionDescription:e=>"remove"===e.kind?void 0:e.source.description,getOptionIcon:e=>"remove"===e.kind?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"trash",size:SHEET_ICON_SIZE,color:L.colors["danger-text"]}):e.source.icon,onChange:(e,r)=>me(r)})]})}ProfilePicker.displayName="ProfilePicker";const styles=_reactNative.StyleSheet.create({fill:{alignItems:"center",justifyContent:"center",overflow:"hidden"},overlay:{..._reactNative.StyleSheet.absoluteFill},badge:{position:"absolute",alignItems:"center",justifyContent:"center",borderWidth:2},row:{flexDirection:"row",alignItems:"center"},column:{alignItems:"flex-start"},columnCentred:{alignItems:"center"},meta:{flexShrink:1},metaCentred:{alignItems:"center"},title:{includeFontPadding:!1},subtitle:{includeFontPadding:!1},textCentred:{textAlign:"center"}});var _default=exports.default=ProfilePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProgressBar=exports.DEFAULT_PROGRESS_BAR_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PROGRESS_BAR_LABELS=exports.DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"}),toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=(0,_color.tintOf)(e,0,"transparent"),r=(0,_color.tintOf)(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=exports.ProgressBar=(0,_react.forwardRef)((e,t)=>{const r=(0,_index.useTheme)(),i=(0,_useReducedMotion.useReducedMotion)(),{progress:a,label:s,showPercent:n=!1,valueLabel:o,indeterminate:l,height:c=6,radius:u,tone:d="primary",trackColor:_,barColor:m,gradient:g,segments:p,animated:x=!0,style:y,containerStyle:h,barStyle:R,accessibilityLabel:v,labels:b,testID:f}=e;(0,_assertValidValue.assertValidValue)("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const j=(0,_react.useMemo)(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...b}),[b]),w=l??"number"!=typeof a,N=clampProgress(a),A=(0,_react.useRef)((0,_index.createAnimatedValue)(N)).current,E=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,S=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,V=(0,_react.useRef)(0),O=(0,_react.useMemo)(()=>buildStyles(r),[r]),L=u??r.radius.pill,B=_??r.colors["surface-disabled"],D=m??toneColor(r,d),T=(0,_react.useMemo)(()=>{if(null==g)return null;if("string"!=typeof g)return g;const e=r.settings.gradients[g];if(void 0===e){const e=Object.keys(r.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <ProgressBar> received gradient="${g}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}return e},[g,r.settings.gradients]),P=(0,_react.useMemo)(()=>glowOf(D),[D]),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProgressBar=exports.DEFAULT_PROGRESS_BAR_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PROGRESS_BAR_LABELS=exports.DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"}),toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=(0,_color.tintOf)(e,0,"transparent"),r=(0,_color.tintOf)(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=exports.ProgressBar=(0,_react.forwardRef)((e,t)=>{const r=(0,_index.useTheme)(),i=(0,_useReducedMotion.useReducedMotion)(),{progress:a,label:s,showPercent:n=!1,valueLabel:o,indeterminate:l,height:c=6,radius:u,tone:d="primary",trackColor:_,barColor:m,gradient:g,segments:p,animated:x=!0,style:y,containerStyle:h,barStyle:R,accessibilityLabel:v,labels:b,testID:f}=e;(0,_assertValidValue.assertValidValue)("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const j=(0,_react.useMemo)(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...b}),[b]),w=l??"number"!=typeof a,N=clampProgress(a),A=(0,_react.useRef)((0,_index.createAnimatedValue)(N)).current,E=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,S=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,V=(0,_react.useRef)(0),O=(0,_react.useMemo)(()=>buildStyles(r),[r]),L=u??r.radius.pill,B=_??r.colors["surface-disabled"],D=m??toneColor(r,d),T=(0,_react.useMemo)(()=>{if(null==g)return null;if("string"!=typeof g)return g;const e=r.settings.gradients[g];if(void 0===e){const e=Object.keys(r.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <ProgressBar> received gradient="${g}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}return e},[g,r.settings.gradients]),P=(0,_react.useMemo)(()=>glowOf(D),[D]),M=Array.isArray(p)&&p.length>0,I=(0,_react.useMemo)(()=>(p??[]).map((e,t)=>({key:`segment-${t}`,segment:e})),[p]);(0,_react.useEffect)(()=>{w||(x?_reactNative.Animated.timing(A,{toValue:N,duration:400,easing:_reactNative.Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():A.setValue(N))},[x,N,A,w,r]),(0,_react.useEffect)(()=>{if(!w)return;(0,_index.setNativeValue)(E,0);const e=_reactNative.Animated.loop(_reactNative.Animated.timing(E,{toValue:1,duration:1500,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:_nativeDriver.nativeDriver}));return e.start(),()=>{e.stop()}},[w,E]);const k=A.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),C=E.interpolate({inputRange:[0,1],outputRange:[-1,1]}),q=E.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=n&&!w&&!M,F=null!=s||G||null!=o,U=v??("string"==typeof s?s:void 0),$=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:U,accessibilityValue:w?{text:j.loading}:{min:0,max:100,now:Math.round(100*N)},testID:f,onLayout:e=>{const t=e.nativeEvent.layout.width;V.current=t,(0,_index.setNativeValue)(S,t)},style:[O.track,{height:c,borderRadius:L,..._corners.smoothCorners,backgroundColor:B},h,y],children:M?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[O.segments,{height:c}],children:I.map(({key:e,segment:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:100*clampProgress(t.value)+"%",height:c,backgroundColor:t.color??toneColor(r,t.tone??"primary")}},e))}):w?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[O.indeterminateBar,{height:c,width:i?"100%":"30%",opacity:i?q:1,transform:i?[]:[{translateX:_reactNative.Animated.multiply(C,S)}]},R],children:(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:P,style:_reactNative.StyleSheet.absoluteFill})}):(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[O.determinateBar,{height:c,borderRadius:L,..._corners.smoothCorners,backgroundColor:T?"transparent":D,width:k,overflow:T?"hidden":void 0},R],children:T?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:T,style:_reactNative.StyleSheet.absoluteFill}):null})});return F?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:O.wrapper,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[O.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof s||"number"==typeof s?(0,_jsxRuntime.jsx)(_index2.Text,{variant:"label",color:"primary",style:O.label,children:s}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:O.label,children:s}),null!=o?"string"==typeof o||"number"==typeof o?(0,_jsxRuntime.jsx)(_index2.Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:o}):o:G?(0,_jsxRuntime.jsx)(_index2.Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*N)}%`}):null]}),$]}):$});ProgressBar.displayName="ProgressBar";const buildStyles=e=>_reactNative.StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});var _default=exports.default=ProgressBar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRadioGroup=exports.default=exports.RadioGroupContext=exports.Radio=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("./RadioDot.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroupContext=exports.RadioGroupContext=(0,_react.createContext)(null),useRadioGroup=()=>(0,_react.useContext)(RadioGroupContext);exports.useRadioGroup=useRadioGroup;const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},Radio=exports.Radio=(0,_react.forwardRef)((e,t)=>{const{value:i,selected:r,onChange:o,disabled:s=!1,label:a,helperText:l,description:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRadioGroup=exports.default=exports.RadioGroupContext=exports.Radio=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("./RadioDot.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroupContext=exports.RadioGroupContext=(0,_react.createContext)(null),useRadioGroup=()=>(0,_react.useContext)(RadioGroupContext);exports.useRadioGroup=useRadioGroup;const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},Radio=exports.Radio=(0,_react.forwardRef)((e,t)=>{const{value:i,selected:r,onChange:o,disabled:s=!1,label:a,helperText:l,description:d,error:c,size:n="md",tone:u="primary",accessibilityLabel:p,haptic:x,style:_,containerStyle:h,circleStyle:b,dotStyle:y,labelStyle:R,testID:m,hitSlop:g,...f}=e;(0,_assertValidValue.assertValidValue)("Radio","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Radio","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const S=(0,_index.useTheme)(),C=(0,_react.useMemo)(()=>buildStyles(S),[S]),j=useRadioGroup();__DEV__&&void 0===i&&_mobileCore.Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const w=j?j.selectedValue===i:!!r,T=j&&j.disabled||s,V=toneColor(S,u),v=(0,_index.spaceOf)(S,S.components.radio["label-gap"]),q=g??6,D=p??(0,_index2.fieldTextAsString)(a),G="string"==typeof c?c:void 0,k={description:d,helperText:l,error:G},z=!0===j?.error||!0===c||(0,_index2.hasFieldText)(c);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:e=>{if(T)return;const t=(0,_hapticUtils.resolveHaptic)(x,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),j?j.onChange(i):o?.(i)},disabled:T,accessibilityRole:"radio",accessibilityLabel:D,accessibilityHint:f.accessibilityHint??(0,_index2.fieldTextAsString)(l)??(0,_index2.fieldTextAsString)(d),accessibilityState:{checked:w,disabled:T},"aria-checked":w,"aria-disabled":T,testID:m,hitSlop:q,...(0,_hitSlop.hitSlopMarker)(q),...f,style:({pressed:e})=>[C.row,(0,_ChoiceText.hasChoiceDetail)(k)?C.rowTop:null,{opacity:T?.55:e?.85:1},h,_],children:[(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:w,color:V,disabled:T&&!w,size:n,style:[!z||w||T?null:{borderColor:S.colors["field-border-error"]},b],dotStyle:y}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:a,helperText:l,description:d,error:G,disabled:T,style:{marginLeft:v},labelStyle:R})]})});Radio.displayName="Radio";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});var _default=exports.default=Radio;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.RadioGroup=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_Radio=require("./Radio.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroup=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.RadioGroup=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_Radio=require("./Radio.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroup=e=>{const{value:i,defaultValue:r,onChange:a,children:t,disabled:o=!1,error:s,accessibilityLabel:d,style:l,testID:u}=e,n=(0,_react.useCallback)(e=>{if("string"!=typeof e&&"number"!=typeof e)throw new Error("RadioGroup received a missing value in single mode.");a?.(e)},[a]),[c,x]=(0,_index.useControllableState)({controlled:"value"in e,value:i,defaultValue:r??void 0,onChange:n}),p=!0===s||(0,_index2.hasFieldText)(s),_=(0,_react.useMemo)(()=>({selectedValue:c,onChange:x,disabled:o,error:p}),[c,x,o,p]);return(0,_jsxRuntime.jsxs)(_Radio.RadioGroupContext.Provider,{value:_,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"radiogroup",accessibilityLabel:d,accessibilityState:{disabled:o},"aria-disabled":o,testID:u,style:l,children:t}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{error:"string"==typeof s?s:void 0})]})};exports.RadioGroup=RadioGroup,RadioGroup.displayName="RadioGroup";var _default=exports.default=RadioGroup;
|