@webority/mobile-ui 0.129.0 → 0.130.1
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 +2 -1
- package/dist/canvas-kit/kit.js +3358 -2919
- package/dist/canvas-kit/manifest.json +824 -295
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/AppLockOverlay/AppLockOverlay.js +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js +1 -1
- package/lib/commonjs/components/Banner/Banner.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Card/Card.js +1 -1
- package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
- package/lib/commonjs/components/Confirm/confirm.js +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/commonjs/components/Dialog/Dialog.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
- package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.js +1 -1
- package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/InlineSelect/InlineSelect.js +1 -1
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/ListItem/ListItem.js +1 -1
- package/lib/commonjs/components/Menu/Menu.js +1 -1
- package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
- package/lib/commonjs/components/Menu/useContextMenu.js +1 -1
- package/lib/commonjs/components/Modal/Modal.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
- package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/commonjs/components/PickerTrigger/PickerTrigger.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/Rating/Rating.js +1 -1
- package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
- package/lib/commonjs/components/Select/Select.js +1 -1
- package/lib/commonjs/components/SliderField/SliderField.js +1 -1
- package/lib/commonjs/components/SquircleImage/SquircleImage.js +1 -1
- package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
- package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
- package/lib/commonjs/components/Tour/Tour.js +1 -1
- package/lib/commonjs/components/index.js +1 -1
- package/lib/commonjs/components/not-drawn.json +0 -1
- package/lib/commonjs/icons.js +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/navigation/DiscardGuard.js +1 -1
- package/lib/commonjs/sizes.js +1 -0
- package/lib/commonjs/squircle.js +1 -0
- package/lib/commonjs/utils/index.js +1 -1
- package/lib/module/components/AppLockOverlay/AppLockOverlay.js +1 -1
- package/lib/module/components/Avatar/Avatar.js +1 -1
- package/lib/module/components/Banner/Banner.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/Card/Card.js +1 -1
- package/lib/module/components/Checkbox/Checkbox.js +1 -1
- package/lib/module/components/Confirm/confirm.js +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +1 -1
- package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/module/components/Dialog/Dialog.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/FieldBase/FieldBase.js +1 -1
- package/lib/module/components/FilePicker/FilePicker.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/ForceUpdateDialog/ForceUpdateDialog.js +1 -1
- package/lib/module/components/IconBadge/IconBadge.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/InlineSelect/InlineSelect.js +1 -1
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/ListItem/ListItem.js +1 -1
- package/lib/module/components/Menu/Menu.js +1 -1
- package/lib/module/components/Menu/MenuSurface.js +1 -1
- package/lib/module/components/Menu/useContextMenu.js +1 -1
- package/lib/module/components/Modal/Modal.js +1 -1
- package/lib/module/components/OTPInput/OTPInput.js +1 -1
- package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/module/components/PickerTrigger/PickerTrigger.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/Rating/Rating.js +1 -1
- package/lib/module/components/SearchBar/SearchBar.js +1 -1
- package/lib/module/components/Select/Select.js +1 -1
- package/lib/module/components/SliderField/SliderField.js +1 -1
- package/lib/module/components/SquircleImage/SquircleImage.js +1 -1
- package/lib/module/components/TimePicker/TimePicker.js +1 -1
- package/lib/module/components/Tooltip/Tooltip.js +1 -1
- package/lib/module/components/Tour/Tour.js +1 -1
- package/lib/module/components/index.js +1 -1
- package/lib/module/components/not-drawn.json +0 -1
- package/lib/module/icons.js +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/navigation/DiscardGuard.js +1 -1
- package/lib/module/sizes.js +1 -0
- package/lib/module/squircle.js +1 -0
- package/lib/module/utils/index.js +1 -1
- package/lib/typescript/commonjs/components/AppLockOverlay/AppLockOverlay.d.ts +3 -3
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +7 -0
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +1 -1
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +4 -4
- package/lib/typescript/commonjs/components/Calendar/calendarStyles.d.ts +4 -4
- package/lib/typescript/commonjs/components/Card/Card.d.ts +1 -3
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +3 -3
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +3 -3
- package/lib/typescript/commonjs/components/Descriptions/Descriptions.d.ts +2 -2
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +1 -1
- package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +4 -4
- package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +8 -6
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +5 -0
- package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +3 -3
- package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +4 -0
- package/lib/typescript/commonjs/components/IconBadge/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/Input/Input.d.ts +3 -2
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +7 -7
- package/lib/typescript/commonjs/components/Menu/Menu.d.ts +3 -3
- package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +1 -1
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +4 -4
- package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +5 -5
- package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +3 -3
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +5 -3
- package/lib/typescript/commonjs/components/Select/Select.d.ts +4 -3
- package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +2 -2
- package/lib/typescript/commonjs/components/SquircleImage/SquircleImage.d.ts +4 -3
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +3 -3
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +2 -2
- package/lib/typescript/commonjs/components/Tour/Tour.d.ts +1 -1
- package/lib/typescript/commonjs/components/index.d.ts +0 -2
- package/lib/typescript/commonjs/icons.d.ts +3 -0
- package/lib/typescript/commonjs/index.d.ts +7 -6
- package/lib/typescript/commonjs/sizes.d.ts +2 -0
- package/lib/typescript/commonjs/squircle.d.ts +2 -0
- package/lib/typescript/commonjs/utils/index.d.ts +1 -1
- package/lib/typescript/module/components/AppLockOverlay/AppLockOverlay.d.ts +3 -3
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +7 -0
- package/lib/typescript/module/components/Banner/Banner.d.ts +1 -1
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +4 -4
- package/lib/typescript/module/components/Calendar/calendarStyles.d.ts +4 -4
- package/lib/typescript/module/components/Card/Card.d.ts +1 -3
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +3 -3
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +3 -3
- package/lib/typescript/module/components/Descriptions/Descriptions.d.ts +2 -2
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +1 -1
- package/lib/typescript/module/components/Drawer/Drawer.d.ts +4 -4
- package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +8 -6
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +5 -0
- package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +3 -3
- package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +4 -0
- package/lib/typescript/module/components/IconBadge/index.d.ts +1 -1
- package/lib/typescript/module/components/Input/Input.d.ts +3 -2
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +7 -7
- package/lib/typescript/module/components/Menu/Menu.d.ts +3 -3
- package/lib/typescript/module/components/Menu/useContextMenu.d.ts +1 -1
- package/lib/typescript/module/components/Modal/Modal.d.ts +4 -4
- package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +5 -5
- package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +3 -2
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +3 -3
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +5 -3
- package/lib/typescript/module/components/Select/Select.d.ts +4 -3
- package/lib/typescript/module/components/SliderField/SliderField.d.ts +2 -2
- package/lib/typescript/module/components/SquircleImage/SquircleImage.d.ts +4 -3
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +3 -3
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +2 -2
- package/lib/typescript/module/components/Tour/Tour.d.ts +1 -1
- package/lib/typescript/module/components/index.d.ts +0 -2
- package/lib/typescript/module/icons.d.ts +3 -0
- package/lib/typescript/module/index.d.ts +7 -6
- package/lib/typescript/module/sizes.d.ts +2 -0
- package/lib/typescript/module/squircle.d.ts +2 -0
- package/lib/typescript/module/utils/index.d.ts +1 -1
- package/package.json +37 -7
- package/lib/commonjs/components/Notation/Notation.js +0 -1
- package/lib/commonjs/components/Notation/index.js +0 -1
- package/lib/module/components/Notation/Notation.js +0 -1
- package/lib/module/components/Notation/index.js +0 -1
- package/lib/typescript/commonjs/components/Notation/Notation.d.ts +0 -43
- package/lib/typescript/commonjs/components/Notation/index.d.ts +0 -3
- package/lib/typescript/module/components/Notation/Notation.d.ts +0 -43
- package/lib/typescript/module/components/Notation/index.d.ts +0 -3
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webority-phone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.130.1",
|
|
4
4
|
"platform": "Phone",
|
|
5
5
|
"kitModuleVersion": 2,
|
|
6
6
|
"rendererProtocolVersion": 13,
|
|
7
7
|
"library": {
|
|
8
8
|
"name": "@webority/mobile-ui",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.130.1"
|
|
10
10
|
},
|
|
11
11
|
"files": {
|
|
12
12
|
"manifest.json": {
|
|
13
|
-
"sha256": "
|
|
14
|
-
"bytes":
|
|
13
|
+
"sha256": "4e6cc524b09b911ad4f178bfd62a0c87abd7745c656604b9c4aaa7e3c8233bb3",
|
|
14
|
+
"bytes": 660956
|
|
15
15
|
},
|
|
16
16
|
"kit.js": {
|
|
17
|
-
"sha256": "
|
|
18
|
-
"bytes":
|
|
17
|
+
"sha256": "b3d0ba11cc3b8ae2d75cb862abc938ff3d62b26eeafc0a929d8620c751cb34e2",
|
|
18
|
+
"bytes": 6100043
|
|
19
19
|
},
|
|
20
20
|
"kit.css": {
|
|
21
21
|
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppLockOverlay=AppLockOverlay,exports.DEFAULT_APP_LOCK_OVERLAY_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../Modal/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_APP_LOCK_OVERLAY_LABELS=exports.DEFAULT_APP_LOCK_OVERLAY_LABELS=Object.freeze({title:"Locked",message:"Unlock to continue",unlock:"Unlock",lockout:"Too many tries. Wait a moment, then try again.",notEnrolled:"Set up a screen lock on this phone to use app lock.",failed:"That didn't unlock. Try again."}),noop=()=>{},useStyles=(0,_index.makeStyles)(e=>({body:{alignItems:"center",flex:1,gap:e.space.sm,justifyContent:"center",paddingHorizontal:e.space["2xl"]},footer:{paddingHorizontal:e.space.xl},iconCircle:{alignItems:"center",backgroundColor:e.colors["primary-wash"],borderRadius:e.radius.pill,..._corners.smoothCorners,height:e.space["4xl"],justifyContent:"center",marginBottom:e.space.md,width:e.space["4xl"]}})),failureMessage=(e,t)=>{switch(e){case"lockout":return t.lockout;case"not-enrolled":return t.notEnrolled;case"failed":case"not-available":return t.failed;default:return null}};function AppLockOverlay({
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppLockOverlay=AppLockOverlay,exports.DEFAULT_APP_LOCK_OVERLAY_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../Modal/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_APP_LOCK_OVERLAY_LABELS=exports.DEFAULT_APP_LOCK_OVERLAY_LABELS=Object.freeze({title:"Locked",message:"Unlock to continue",unlock:"Unlock",lockout:"Too many tries. Wait a moment, then try again.",notEnrolled:"Set up a screen lock on this phone to use app lock.",failed:"That didn't unlock. Try again."}),noop=()=>{},useStyles=(0,_index.makeStyles)(e=>({body:{alignItems:"center",flex:1,gap:e.space.sm,justifyContent:"center",paddingHorizontal:e.space["2xl"]},footer:{paddingHorizontal:e.space.xl},iconCircle:{alignItems:"center",backgroundColor:e.colors["primary-wash"],borderRadius:e.radius.pill,..._corners.smoothCorners,height:e.space["4xl"],justifyContent:"center",marginBottom:e.space.md,width:e.space["4xl"]}})),failureMessage=(e,t)=>{switch(e){case"lockout":return t.lockout;case"not-enrolled":return t.notEnrolled;case"failed":case"not-available":return t.failed;default:return null}};function AppLockOverlay({open:e,onUnlock:t,failure:n,secondaryAction:r,brandMark:i,labels:s,testID:a}){const o=(0,_index.useTheme)(),l=useStyles(),c=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),u=(0,_react.useMemo)(()=>({...DEFAULT_APP_LOCK_OVERLAY_LABELS,...s}),[s]),d=(0,_react.useRef)(t);d.current=t,(0,_react.useEffect)(()=>{e&&d.current()},[e]);const x=failureMessage(n,u);return(0,_jsxRuntime.jsxs)(_index4.Modal,{open:e,onClose:noop,presentation:"fullScreen",hardwareBackPress:!1,haptic:!1,accessibilityLabel:u.title,testID:a,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:l.body,children:[i??(0,_jsxRuntime.jsx)(_reactNative.View,{style:l.iconCircle,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"lock",size:"xl",color:o.colors["primary-text"]})}),(0,_jsxRuntime.jsx)(_index5.Text,{variant:"h3",weight:"semibold",align:"center",children:u.title}),(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",weight:"medium",align:"center",children:u.message}),x?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",weight:"semibold",align:"center",color:"danger",children:x}):null]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[l.footer,{paddingBottom:o.space.xl+c.bottom}],children:[(0,_jsxRuntime.jsx)(_index3.Button,{fullWidth:!0,size:"lg",label:u.unlock,onPress:t,testID:a?`${a}-unlock`:void 0}),r?(0,_jsxRuntime.jsx)(_index3.Button,{variant:"link",label:r.label,onPress:r.onPress,testID:a?`${a}-secondary`:void 0}):null]})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};default:return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,a)=>{switch(t){case"circle":return r/2;case"rounded":return a?e.radius[a]:Math.max(e.radius.sm,Math.round(.22*r));default:return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean);return 0===t.length?"":1===t.length?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[1].charAt(0)).toUpperCase()},hashColor=(e,t)=>{if(!e)return t[0];let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t[Math.abs(r)%t.length]},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;default:return e.colors["text-subtle"]}},Avatar=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:a,name:o,size:s="md",shape:i="circle",dimension:n,radius:l,border:c=!1,contentFit:u="cover",placeholderIcon:d,status:h=null,statusPosition:v="bottomRight",tone:m,backgroundColor:p,color:g,fontSize:_,loading:b=!1,accessibilityLabel:x,onPress:A,onLongPress:y,haptic:f,hitSlop:R,style:I,textStyle:j,testID:w,labels:S}=e;(0,_warnInvalidValue.warnInvalidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_warnInvalidValue.warnInvalidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const C=(0,_react.useMemo)(()=>S?{...DEFAULT_AVATAR_LABELS,...S}:DEFAULT_AVATAR_LABELS,[S]),V=(0,_index.useTheme)(),[T,L]=(0,_react.useState)(null),M=(0,_react.useMemo)(()=>n??resolveSize(s),[n,s]),E=(0,_react.useMemo)(()=>resolveRadius(V,i,M,l),[V,i,M,l]),N=c?V.size.border:0,O=V.colors.border,k=V.colors.surface,z=(0,_react.useMemo)(()=>initialsFromName(o),[o]),F=(0,_react.useMemo)(()=>m?avatarToneColors(V,m):null,[V,m]),D=(0,_react.useMemo)(()=>p||(F?.background??V.colors[hashColor(o??"",AVATAR_COLORS)]),[p,F,o,V]),G=g??F?.color??V.colors["on-primary"],U=r?keyOfSource(r):null,q=null!==U&&U!==T,P=!q&&""===z&&null!=d,$=g??F?.color??V.colors["text-subtle"],B=_??Math.max(V.text.xs.size,Math.round(.4*M)),W=Math.max(8,Math.round(.25*M)),H=isRingStatus(h),Y=M-2*(H?3:N),X=H?resolveRadius(V,i,Y,l):Math.max(0,E-N),J=P?(0,_slotIcon.renderSlotIcon)(d,{color:$,size:Math.round(.45*Y),disabled:!1}):null,K=H?statusColor(V,h):"transparent",Q=Math.max(12,Math.round(.32*M)),Z=Math.max(10,Q-4),ee=p??F?.background??V.colors["bg-muted"],te=q?"contain"===u?"transparent":V.colors["bg-muted"]:P?ee:D,re=w??"avatar",ae=o?C.avatarOf(o):C.avatar,oe="verified"===h?`, ${C.verified}`:"pending"===h?`, ${C.pendingVerification}`:"",se=x??`${ae}${oe}`,ie="function"==typeof A||"function"==typeof y,ne=x??`${o||ae}${oe}`,le=Math.max(0,Math.ceil((44-M)/2)),ce=R??le,ue=[styles.root,{width:M,height:M,borderRadius:E,..._corners.smoothCorners,borderWidth:H?0:N,borderColor:O,backgroundColor:H?"transparent":te},I],de=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[H?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:E,..._corners.smoothCorners,borderWidth:1.5,borderColor:K}],accessible:!1,pointerEvents:"none",testID:`${re}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:Y,height:Y,borderRadius:X,..._corners.smoothCorners,borderWidth:H?N:0,borderColor:O,backgroundColor:H?te:"transparent"}],children:q?(()=>{const e={width:Y,height:Y,borderRadius:X,..._corners.smoothCorners},onError=()=>L(U);return a?(0,_jsxRuntime.jsx)(a,{source:r,onError:onError,style:e,contentFit:u,resizeMode:u,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:r,onError:onError,style:e,contentFit:u,accessibilityIgnoresInvertColors:!0})})():J||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:G,fontSize:B,lineHeight:Math.round(B*V.leading.body)},j],children:z??" "})}),"verified"===h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===v?styles.badgeTopRight:styles.badgeBottomRight,{width:Q,height:Q,borderRadius:Q/2,..._corners.smoothCorners,backgroundColor:k}],accessible:!1,pointerEvents:"none",testID:`${re}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:Z,color:K})}):null,h&&!H?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===v?styles.statusTopRight:styles.statusBottomRight,{width:W,height:W,borderRadius:W/2,..._corners.smoothCorners,backgroundColor:statusColor(V,h),borderWidth:2,borderColor:k}],accessible:!1,pointerEvents:"none"}):null]}),he=ie?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:A?e=>{const t=(0,_hapticUtils.resolveHaptic)(f,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),A?.(e)}:void 0,onLongPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(f,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,hitSlop:ce,...(0,_hitSlop.hitSlopMarker)(ce),accessibilityRole:"button",accessibilityLabel:ne,testID:w,style:({pressed:e})=>[ue,e?styles.pressed:null],children:de}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:ue,accessible:!0,accessibilityRole:"image",accessibilityLabel:se,testID:w,children:de});return b?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):he});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:a})=>{const o=r??resolveSize(e),s="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:s,width:o,height:o,style:a})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:a,children:o})=>{const s=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:s.radius.pill,borderColor:r,borderWidth:a,opacity:i}],children:o})},AvatarGroup=e=>{const{children:t,max:r=4,size:a="md",spacing:o="normal",overflowVariant:s="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),v=h.length,m=h.slice(0,r),p=Math.max(0,v-r),g=p>0,_=-d.space[SPACING_OFFSET[o]],b=d.colors.surface,x=i??u.groupOf(v),A=(0,_react.useMemo)(()=>resolveSize(a),[a]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[m.map((e,t)=>{const r=e.key??`avatar-${t}`,o=(0,_react.cloneElement)(e,{size:a,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:_,borderColor:b,borderWidth:1.5,children:o},r)}),g?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*m.length,marginLeft:0===m.length?0:_,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===s?u.moreCount(p):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===s?`+${p}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};default:return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,a)=>{switch(t){case"circle":return r/2;case"rounded":return a?e.radius[a]:Math.max(e.radius.sm,Math.round(.22*r));default:return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean);return 0===t.length?"":1===t.length?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[1].charAt(0)).toUpperCase()},hashColor=(e,t)=>{if(!e)return t[0];let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t[Math.abs(r)%t.length]},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;default:return e.colors["text-subtle"]}},Avatar=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:a,imageClient:o,name:s,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:h,status:m=null,statusPosition:v="bottomRight",tone:g,backgroundColor:p,color:_,fontSize:b,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:I,style:j,textStyle:S,testID:w,labels:C}=e;(0,_warnInvalidValue.warnInvalidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_warnInvalidValue.warnInvalidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const V=(0,_react.useMemo)(()=>C?{...DEFAULT_AVATAR_LABELS,...C}:DEFAULT_AVATAR_LABELS,[C]),T=(0,_index.useTheme)(),[L,M]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(T,n,E,c),[T,n,E,c]),k=u?T.size.border:0,N=T.colors.border,z=T.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(s),[s]),D=(0,_react.useMemo)(()=>g?avatarToneColors(T,g):null,[T,g]),G=(0,_react.useMemo)(()=>p||(D?.background??T.colors[hashColor(s??"",AVATAR_COLORS)]),[p,D,s,T]),U=_??D?.color??T.colors["on-primary"],q=r?keyOfSource(r):null,P=null!==q&&q!==L,$=!P&&""===F&&null!=h,B=_??D?.color??T.colors["text-subtle"],W=b??Math.max(T.text.xs.size,Math.round(.4*E)),H=Math.max(8,Math.round(.25*E)),Y=isRingStatus(m),X=E-2*(Y?3:k),J=Y?resolveRadius(T,n,X,c):Math.max(0,O-k),K=$?(0,_slotIcon.renderSlotIcon)(h,{color:B,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(T,m):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=p??D?.background??T.colors["bg-muted"],re=P?"contain"===d?"transparent":T.colors["bg-muted"]:$?te:G,ae=w??"avatar",oe=s?V.avatarOf(s):V.avatar,se="verified"===m?`, ${V.verified}`:"pending"===m?`, ${V.pendingVerification}`:"",ie=A??`${oe}${se}`,ne="function"==typeof y||"function"==typeof f,le=A??`${s||oe}${se}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=I??ce,de=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:Y?0:k,borderColor:N,backgroundColor:Y?"transparent":re},j],he=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${ae}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:X,height:X,borderRadius:J,..._corners.smoothCorners,borderWidth:Y?k:0,borderColor:N,backgroundColor:Y?re:"transparent"}],children:P?(()=>{const e={width:X,height:X,borderRadius:J,..._corners.smoothCorners},onError=()=>M(q),t=uriOfSource(r);return a?(0,_jsxRuntime.jsx)(a,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):o&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:o,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:U,fontSize:W,lineHeight:Math.round(W*T.leading.body)},S],children:F??" "})}),"verified"===m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===v?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${ae}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,m&&!Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===v?styles.statusTopRight:styles.statusBottomRight,{width:H,height:H,borderRadius:H/2,..._corners.smoothCorners,backgroundColor:statusColor(T,m),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),me=ne?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:ue,...(0,_hitSlop.hitSlopMarker)(ue),accessibilityRole:"button",accessibilityLabel:le,testID:w,style:({pressed:e})=>[de,e?styles.pressed:null],children:he}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:w,children:he});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):me});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:a})=>{const o=r??resolveSize(e),s="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:s,width:o,height:o,style:a})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:a,children:o})=>{const s=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:s.radius.pill,borderColor:r,borderWidth:a,opacity:i}],children:o})},AvatarGroup=e=>{const{children:t,max:r=4,size:a="md",spacing:o="normal",overflowVariant:s="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),m=h.length,v=h.slice(0,r),g=Math.max(0,m-r),p=g>0,_=-d.space[SPACING_OFFSET[o]],b=d.colors.surface,x=i??u.groupOf(m),A=(0,_react.useMemo)(()=>resolveSize(a),[a]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[v.map((e,t)=>{const r=e.key??`avatar-${t}`,o=(0,_react.cloneElement)(e,{size:a,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:_,borderColor:b,borderWidth:1.5,children:o},r)}),p?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*v.length,marginLeft:0===v.length?0:_,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===s?u.moreCount(g):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===s?`+${g}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),Banner=exports.Banner=(0,_react.forwardRef)((e,t)=>{const{title:r,message:n,tone:i="neutral",variant:s="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),Banner=exports.Banner=(0,_react.forwardRef)((e,t)=>{const{title:r,message:n,tone:i="neutral",variant:s="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:x=!0,loading:m=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:g,style:h,containerStyle:y,iconCircleStyle:b,tintBarStyle:v,closeButtonStyle:f,actionButtonStyle:j,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_warnInvalidValue.warnInvalidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const R=(0,_index.useTheme)(),B=(0,_usePresenceMotion.usePresenceMotion)(),S=(0,_react.useMemo)(()=>buildStyles(R),[R]),N=(0,_react.useMemo)(()=>tintFor(R,i),[R,i]),I=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...g}),[g]),[C,V]=B.range(-20,0),k=(0,_react.useRef)((0,_index.createAnimatedValue)(x&&u?C:0)).current,L=(0,_react.useRef)((0,_index.createAnimatedValue)(x&&u?0:u?1:0)).current,[A,D]=(0,_react.useState)(u),E=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>{if(E.current&&(E.current=!1,!x))return;let e;return u?(D(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(k,{toValue:V,duration:R.motion.duration.default,useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:1,duration:B.duration("default"),useNativeDriver:!0})]),e.start()):A&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(k,{toValue:C,duration:R.motion.duration.fast,useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:0,duration:B.duration("fast"),useNativeDriver:!0})]),e.start(()=>{D(!1)})),()=>e?.stop()},[u]),!A)return null;const T=r??" ",q="string"==typeof n?n??" ":"",M="wash"===s,H="bar"!==s,z="alert"===p?"danger"===i?"assertive":"polite":"none",P=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:z,accessibilityLabel:_,testID:w,style:[S.container,{backgroundColor:H?N.soft:R.colors["bg-subtle"],borderRadius:M?R.radius.sm:R.radius.md,..._corners.smoothCorners,padding:R.space.md,opacity:L,transform:[{translateY:k}]},y,h],children:[!M&&R.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.tintBar,{backgroundColor:N.bar},v]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[S.row,void 0===r&&S.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:S.iconWrap,children:(0,_slotIcon.renderSlotIcon)(a,{color:N.ink,size:R.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:N.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[S.iconGlyph,{color:N.ink}],children:N.glyph}),style:[S.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:S.textBlock,children:[r||m?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...M?{color:N.ink}:null},children:T}):null,"string"==typeof n||m?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?R.space.xxs:0},children:q||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?R.space.xxs:0},children:n})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:I.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[S.closeBtn,{backgroundColor:e?R.colors["surface-pressed"]:"transparent"},f],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:S.actionsRow,children:o.map((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Banner","action.variant",e.variant,["solid","outline","ghost"]),(0,_warnInvalidValue.warnInvalidValue)("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",n=e.variant??"ghost",i="primary"===r?N.glyphColor:"neutral"===r?R.colors["text-muted"]:R.colors[r],s="primary"===r?N.ink:"neutral"===r?R.colors["text-muted"]:R.colors[`${r}-text`],a="primary"===r?N.on:"neutral"===r?R.colors["on-neutral-strong"]:R.colors[`on-${r}`],o="solid"===n;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=(0,_hapticUtils.resolveHaptic)(d,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:({pressed:t})=>[S.actionBtn,"md"===e.size&&S.actionBtnMd,"outline"===n&&{borderWidth:1,borderColor:s},{backgroundColor:o?i:t?R.colors["surface-pressed"]:"transparent",opacity:o&&t?.85:1},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:s},children:e.label})},`${e.label}-${t}`)})}):null]});return m?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):P});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:n,style:i})=>{const s=(0,_index.useTheme)(),a=!1!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,..._corners.smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},n,i],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:s.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:s.space.sm},children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return _reactNative.StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,visible:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:i,onAfterClose:s,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:b,scrollEventThrottle:S,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:w,actions:j,actionsLayout:C="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:I,testID:A}=e;(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const B=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),L=null!=w||null!=d,P=null!=j&&j.length>0,V=null!=M||P,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[ie,se,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(L?ne:0)+ie+(V?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,be=ve[ve.length-1]??0,Se=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[we,je]=(0,_react.useState)(!1),[Ce,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(s);Ee.current=s;const[Te,ke]=(0,_react.useState)(!1),Ie=(0,_react.useRef)(!R&&a),Ae=(0,_react.useRef)(-1),Be=(0,_react.useRef)(!1);Be.current="modal"===D?Ce:Te;const Le=(0,_react.useRef)(u);Le.current=u;const Pe=(0,_react.useRef)(r);Pe.current=r;const Ve=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Ae.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(je(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!Ce:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,Ce,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,i?.(t,a),Se.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[i,Se,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),je(!0)):ke(!0),a<0&&Ie.current?(Se.value=r,ye.value=1,Fe(t),void i?.(a,t)):a<0&&G.reduced?(Se.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void i?.(a,t)):(a<0&&(Se.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,i,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,Se,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Ae.current<0)return void(Be.current?He.current.push(e):e(!0));He.current.push(e),Ie.current=!1;const t=xe.value;Fe(-1),ge.current=!0,i?.(t,-1);const a=G.reduced?ye:Se,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,i,G,ye,Fe,Se,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Le.current;if(!r)return void e();if(Ve.current)return void t?.();const n=r();"boolean"!=typeof n?(Ve.current=!0,a?.(),n.then(a=>{Ve.current=!1,a&&De.current&&Ae.current>=0?e():t?.()},e=>{throw Ve.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Ae.current<0?e(!0):Ke(()=>{Pe.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Pe.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);Se.value=Ie.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-be,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Ae.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(A?`${A}-content-gesture`:"bottom-sheet-content-gesture"),[A]),it=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(A?`${A}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=Se.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;Se.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=Se.value;if(a.velocityY>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,e[0]);let o=0,i=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const a=Math.abs(n-e[t]);a<i&&(i=a,o=t)}const s=e[0];r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(o,e[o])})},[fe,pe,c,nt,tt,at,A,Se]),{height:st}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?st.value:0),ut=ve[Re>=0?Re:0]??be,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&Se.value>t?t:Se.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=Se.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}}),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&Se.value>t?t:Se.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=Se.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>be?be:r}}),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()})},[l,Ye,Ke]),bt=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(A?`${A}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,A]),St=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!Ce)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:A,accessibilityViewIsModal:I??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:bt,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:B.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:I??mt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:it,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:A?`${A}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,w]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:b,scrollEventThrottle:S,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:se,children:T}):T}),V&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[P?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:St,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{visible:we,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}});return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:i,onAfterClose:s,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:w,actions:j,actionsLayout:C="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:I,testID:A}=e;(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const B=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),L=null!=w||null!=d,P=null!=j&&j.length>0,V=null!=M||P,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[ie,se,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(L?ne:0)+ie+(V?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[we,je]=(0,_react.useState)(!1),[Ce,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(s);Ee.current=s;const[Te,ke]=(0,_react.useState)(!1),Ie=(0,_react.useRef)(!R&&a),Ae=(0,_react.useRef)(-1),Be=(0,_react.useRef)(!1);Be.current="modal"===D?Ce:Te;const Le=(0,_react.useRef)(u);Le.current=u;const Pe=(0,_react.useRef)(r);Pe.current=r;const Ve=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Ae.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(je(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!Ce:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,Ce,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,i?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[i,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),je(!0)):ke(!0),a<0&&Ie.current?(be.value=r,ye.value=1,Fe(t),void i?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void i?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,i,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Ae.current<0)return void(Be.current?He.current.push(e):e(!0));He.current.push(e),Ie.current=!1;const t=xe.value;Fe(-1),ge.current=!0,i?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,i,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Le.current;if(!r)return void e();if(Ve.current)return void t?.();const n=r();"boolean"!=typeof n?(Ve.current=!0,a?.(),n.then(a=>{Ve.current=!1,a&&De.current&&Ae.current>=0?e():t?.()},e=>{throw Ve.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Ae.current<0?e(!0):Ke(()=>{Pe.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Pe.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ie.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Ae.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(A?`${A}-content-gesture`:"bottom-sheet-content-gesture"),[A]),it=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(A?`${A}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value;if(a.velocityY>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,e[0]);let o=0,i=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const a=Math.abs(n-e[t]);a<i&&(i=a,o=t)}const s=e[0];r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(o,e[o])})},[fe,pe,c,nt,tt,at,A,be]),{height:st}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?st.value:0),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}}),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}}),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(A?`${A}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,A]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!Ce)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:A,accessibilityViewIsModal:I??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:B.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:I??mt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:it,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:A?`${A}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,w]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:se,children:T}):T}),V&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[P?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:we,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}});return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,s=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(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=s&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?s(r,a,i):r[a]=e[a]);return r}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=exports.Card=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:a,elevation:s="card",radius:r,padding:n,interactive:o=!1,pressAnimation:l="scale",bg:d,header:c,title:u,titleFont:h,lead:m,action:_,headerActions:x,collapsible:p=!1,collapsed:b,defaultCollapsed:g=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:v,separatorHeight:R=_reactNative.StyleSheet.hairlineWidth,footer:f,imageSource:S,imageHeight:w=160,imageAspectRatio:C,imageOverlay:A,loading:q=!1,gradient:F,onPress:I,haptic:N,contextMenu:L,accessibilityLabel:V,accessibilityHint:k,accessibilityRole:T,style:B,containerStyle:P,headerStyle:D,bodyStyle:M,footerStyle:z,borderRadius:H,testID:E,labels:O,onLayout:W,...U}=e;(0,_warnInvalidValue.warnInvalidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_warnInvalidValue.warnInvalidValue)("Card","radius",e.radius,["sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_warnInvalidValue.warnInvalidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const G=(0,_index.useTheme)(),K=G.settings.components.card,$=a??K?.defaultVariant??"elevated",J=r??K?.defaultRadius??"lg",Q=n??K?.defaultPadding??"md",X=h??K?.defaultTitleFont??"sans",Y=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...O}),[O]),Z=o||"function"==typeof I,ee=(0,_useContextMenu.useContextMenu)(L,{haptic:N||!1,testID:E,accessibilityActions:U.accessibilityActions,onAccessibilityAction:U.onAccessibilityAction}),te=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,ee.hostRef),[t,ee.hostRef]),ie=Z||ee.enabled,{style:ae,pressIn:se,pressOut:re}=(0,_usePressAnimation.usePressAnimation)({preset:l||"scale",enabled:ie&&!1!==l}),ne=stylesFor(G),oe=Boolean(S),le=G.space[paddingMap[Q]],de=(0,_react.useMemo)(()=>F?"string"==typeof F?G.settings.gradients[F]??null:F:null,[F,G.settings.gradients]),ce="flat"===$,ue=ce?G.radius.none:H??G.radius[J],he=resolveBackground(G,d),[me,xe]=(0,_useControllableState.useControllableState)({value:b,defaultValue:g,onChange:j}),pe=p&&me,be=hasBuiltInHeaderContent(e),ge=Boolean(c)||be,je=(0,_SquircleFill.useSquircle)(!oe&&!de&&!ce,ue,W),ye=_reactNative.StyleSheet.flatten([P,B])??{},ve=ye.backgroundColor,Re=ye.borderColor,fe=ve??he??("filled"===$?G.colors["bg-subtle"]:G.colors.surface),Se="outline"===$?G.size.border:0,we=Re??G.colors.border,Ce="none"===s?void 0:G.shadow[s],Ae="elevated"===$&&(0,_shadows.supportsBoxShadow)()&&Ce?(0,_shadows.toBoxShadow)(Ce):void 0,qe=je.active&&"elevated"===$&&!Ae,Fe=je.active&&!qe?{backgroundColor:"transparent",borderColor:"transparent"}:null,Ie=(0,_react.useMemo)(()=>{const e={borderRadius:qe&&je.size?(0,_squircle.squircleHostRadius)(je.size.width,je.size.height,ue):ue,..._corners.smoothCorners,padding:oe||je.active?G.space.none:le,overflow:je.active?"visible":"hidden"};switch($){case"flat":return{...e,backgroundColor:he??G.colors.surface,borderBottomWidth:R,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:je.active?"transparent":he??G.colors.surface,borderWidth:G.size.border,borderColor:je.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:je.active?"transparent":he??G.colors["bg-subtle"]};default:return{...e,backgroundColor:he??G.colors.surface,...Ae?{boxShadow:Ae}:Ce}}},[G,$,Ce,ue,oe,le,je.active,je.size,Ae,qe,he,R]),Ne=(0,_react.useMemo)(()=>({..."number"==typeof C?{width:"100%",aspectRatio:C}:{width:"100%",height:w},borderTopLeftRadius:ue,borderTopRightRadius:ue,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,..._corners.smoothCorners}),[G,ue,C,w]),Le=u??"",Ve=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:ne.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,X),children:u}):null,m?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:ne.lead,children:m}):null,pe&&y?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:ne.lead,children:y}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:N}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:ne.actionNode,children:_}):null,x,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?Y.show:Y.hide} ${Le}`.trim(),expanded:!pe,onPress:()=>xe(!pe),haptic:N}):null,v?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:Y.remove,onPress:v,color:G.colors["danger-text"],haptic:N}):null]}),ke=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ge?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ne.header,!c&&ne.headerRow,pe&&ne.headerFolded,D],children:c??Ve}):null,pe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ge||f?ne.body:null,M],children:i}),f&&!pe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ne.footer,z],children:f}):null]}),Te=oe?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:ne.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Ne,accessibilityLabel:"",accessible:!1}),A?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:ne.imageOverlay,children:A}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:le},children:ke})]}):ke,Be=de?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:de,style:_reactNative.StyleSheet.absoluteFill}),Te]}):je.active&&je.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:je.size.width,height:je.size.height,radius:ue,fill:fe,stroke:Se?we:void 0,strokeWidth:Se}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ne.squircleClip,{padding:le,borderRadius:je.size?(0,_squircle.squircleHostRadius)(je.size.width,je.size.height,ue):ue}],children:Te})]}):Te;let Pe;if(ie){const handlePress=e=>{Z&&(N&&(0,_hapticUtils.triggerHaptic)(N),I?.(e))};Pe=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ae,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:te,onPress:handlePress,onPressIn:se,onPressOut:re,accessibilityRole:T??(Z?"button":void 0),accessibilityLabel:V,accessibilityHint:k,testID:E,onLayout:je.onLayout,style:[Ie,P,B,Fe],...U,...ee.hostProps,children:Be})})}else Pe=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:V,accessibilityHint:k,accessibilityRole:T,testID:E,onLayout:je.onLayout,style:[Ie,P,B,Fe],...U,children:Be});return q?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):ee.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Pe,ee.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[Ie,P,B,Fe,ne.preview],children:Be}))]}):Pe}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:a,bg:s,header:r,footer:n,imageSource:o,imageHeight:l=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:m,footerStyle:_,style:x,labels:p,...b})=>{const g=(0,_index.useTheme)(),j=g.settings.components.card,y=e??j?.defaultVariant??"elevated",v=i??j?.defaultRadius??"lg",R=a??j?.defaultPadding??"md",f={...DEFAULT_CARD_LABELS,...p},S=paddingMap[R],w=g.space[S],C="flat"===y?g.radius.none:c??g.radius[v],A=void 0!==r||hasBuiltInHeaderContent(b),q=resolveBackground(g,s)??g.colors.surface,F="outline"===y?1:0,I="outline"===y?g.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:q,borderRadius:C,..._corners.smoothCorners,borderWidth:F,borderColor:I,overflow:"hidden"},u,x],accessibilityRole:"progressbar",accessibilityLabel:f.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==o?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,A?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:w,paddingBottom:g.space.sm},h],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:w},m],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:g.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:w,paddingTop:g.space.sm,flexDirection:"row"},_],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:a,color:s,haptic:r})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===a?void 0:{expanded:a},"aria-expanded":a,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:s??n.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,s=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(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=s&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?s(r,a,i):r[a]=e[a]);return r}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=exports.Card=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:a,elevation:s="card",radius:r,padding:n,interactive:l=!1,pressAnimation:o="scale",bg:d,header:c,title:u,titleFont:h,lead:m,action:_,headerActions:x,collapsible:p=!1,collapsed:b,defaultCollapsed:g=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:v,separatorHeight:R=_reactNative.StyleSheet.hairlineWidth,footer:f,imageSource:S,imageHeight:w=160,imageAspectRatio:C,imageOverlay:A,loading:q=!1,gradient:F,onPress:I,haptic:N,contextMenu:L,accessibilityLabel:V,accessibilityHint:k,accessibilityRole:T,style:B,containerStyle:P,headerStyle:D,bodyStyle:M,footerStyle:z,testID:H,labels:E,onLayout:O,...W}=e;(0,_warnInvalidValue.warnInvalidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_warnInvalidValue.warnInvalidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_warnInvalidValue.warnInvalidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_warnInvalidValue.warnInvalidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=(0,_index.useTheme)(),G=U.settings.components.card,K=a??G?.defaultVariant??"elevated",$=r??G?.defaultRadius??"lg",J=n??G?.defaultPadding??"md",Q=h??G?.defaultTitleFont??"sans",X=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...E}),[E]),Y=l||"function"==typeof I,Z=(0,_useContextMenu.useContextMenu)(L,{haptic:N||!1,testID:H,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),ee=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:ae,pressOut:se}=(0,_usePressAnimation.usePressAnimation)({preset:o||"scale",enabled:te&&!1!==o}),re=stylesFor(U),ne=Boolean(S),le=U.space[paddingMap[J]],oe=(0,_react.useMemo)(()=>F?"string"==typeof F?U.settings.gradients[F]??null:F:null,[F,U.settings.gradients]),de="flat"===K,ce=de?U.radius.none:U.radius[$],ue=resolveBackground(U,d),[he,me]=(0,_useControllableState.useControllableState)({value:b,defaultValue:g,onChange:j}),xe=p&&he,pe=hasBuiltInHeaderContent(e),be=Boolean(c)||pe,ge=(0,_SquircleFill.useSquircle)(!ne&&!oe&&!de,ce,O),je=_reactNative.StyleSheet.flatten([P,B])??{},ye=je.backgroundColor,ve=je.borderColor,Re=ye??ue??("filled"===K?U.colors["bg-subtle"]:U.colors.surface),fe="outline"===K?U.size.border:0,Se=ve??U.colors.border,we="none"===s?void 0:U.shadow[s],Ce="elevated"===K&&(0,_shadows.supportsBoxShadow)()&&we?(0,_shadows.toBoxShadow)(we):void 0,Ae=ge.active&&"elevated"===K&&!Ce,qe=ge.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=(0,_react.useMemo)(()=>{const e={borderRadius:Ae&&ge.size?(0,_squircle.squircleHostRadius)(ge.size.width,ge.size.height,ce):ce,..._corners.smoothCorners,padding:ne||ge.active?U.space.none:le,overflow:ge.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:R,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:ge.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:ge.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:ge.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...Ce?{boxShadow:Ce}:we}}},[U,K,we,ce,ne,le,ge.active,ge.size,Ce,Ae,ue,R]),Ie=(0,_react.useMemo)(()=>({..."number"==typeof C?{width:"100%",aspectRatio:C}:{width:"100%",height:w},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ce,C,w]),Ne=u??"",Le=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,Q),children:u}):null,m?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:re.lead,children:m}):null,xe&&y?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:re.lead,children:y}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:N}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:re.actionNode,children:_}):null,x,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:xe?"chevron-down":"chevron-up",label:`${xe?X.show:X.hide} ${Ne}`.trim(),expanded:!xe,onPress:()=>me(!xe),haptic:N}):null,v?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:U.colors["danger-text"],haptic:N}):null]}),Ve=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.header,!c&&re.headerRow,xe&&re.headerFolded,D],children:c??Le}):null,xe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[be||f?re.body:null,M],children:i}),f&&!xe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.footer,z],children:f}):null]}),ke=ne?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Ie,accessibilityLabel:"",accessible:!1}),A?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:le},children:Ve})]}):Ve,Te=oe?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:oe,style:_reactNative.StyleSheet.absoluteFill}),ke]}):ge.active&&ge.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ge.size.width,height:ge.size.height,radius:ce,fill:Re,stroke:fe?Se:void 0,strokeWidth:fe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.squircleClip,{padding:le,borderRadius:ge.size?(0,_squircle.squircleHostRadius)(ge.size.width,ge.size.height,ce):ce}],children:ke})]}):ke;let Be;if(te){const handlePress=e=>{Y&&(N&&(0,_hapticUtils.triggerHaptic)(N),I?.(e))};Be=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ie,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:ee,onPress:handlePress,onPressIn:ae,onPressOut:se,accessibilityRole:T??(Y?"button":void 0),accessibilityLabel:V,accessibilityHint:k,testID:H,onLayout:ge.onLayout,style:[Fe,P,B,qe],...W,...Z.hostProps,children:Te})})}else Be=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:V,accessibilityHint:k,accessibilityRole:T,testID:H,onLayout:ge.onLayout,style:[Fe,P,B,qe],...W,children:Te});return q?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):Z.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Be,Z.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[Fe,P,B,qe,re.preview],children:Te}))]}):Be}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:a,bg:s,header:r,footer:n,imageSource:l,imageHeight:o=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:h,footerStyle:m,style:_,labels:x,...p})=>{const b=(0,_index.useTheme)(),g=b.settings.components.card,j=e??g?.defaultVariant??"elevated",y=i??g?.defaultRadius??"lg",v=a??g?.defaultPadding??"md",R={...DEFAULT_CARD_LABELS,...x},f=paddingMap[v],S=b.space[f],w="flat"===j?b.radius.none:b.radius[y],C=void 0!==r||hasBuiltInHeaderContent(p),A=resolveBackground(b,s)??b.colors.surface,q="outline"===j?1:0,F="outline"===j?b.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:A,borderRadius:w,..._corners.smoothCorners,borderWidth:q,borderColor:F,overflow:"hidden"},c,_],accessibilityRole:"progressbar",accessibilityLabel:R.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:o,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,C?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingBottom:b.space.sm},u],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S},h],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:b.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingTop:b.space.sm,flexDirection:"row"},m],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:a,color:s,haptic:r})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===a?void 0:{expanded:a},"aria-expanded":a,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:s??n.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Checkbox=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,i,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Checkbox=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;var t,i,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(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((t=a&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?a(s,i,t):s[i]=e[i]);return s}const CHECKBOX_SHAPES=["circle"],toneColor=(e,r)=>{switch(r){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},toneOnColor=(e,r)=>{switch(r){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];case"neutral":return e.colors["on-neutral"];default:return e.colors["on-primary"]}},Checkbox=exports.Checkbox=(0,_react.forwardRef)((e,r)=>{const{checked:t,defaultChecked:i,onChange:a,indeterminate:s=!1,disabled:n=!1,label:o,helperText:l,description:c,error:d,help:u,size:h="md",tone:p="primary",shape:x,accessibilityLabel:_,haptic:b,style:f,boxStyle:m,indeterminateBarStyle:g,containerStyle:y,labelStyle:w,testID:v,hitSlop:C,...j}=e,[S,k]=(0,_index.useControllableState)({value:t,defaultValue:i??!1,onChange:a}),R=(0,_index2.useTheme)(),T=(0,_react.useMemo)(()=>buildStyles(R),[R]),{"box-size":V}=(0,_react.useMemo)(()=>(0,_index2.resolveCheckboxSize)(R,h),[R,h]),I=R.size.border,q=(0,_index2.spaceOf)(R,R.components.checkbox["label-gap"]),N=toneColor(R,p),B=C??6;(0,_warnInvalidValue.warnInvalidValue)("Checkbox","shape",x,CHECKBOX_SHAPES),(0,_warnInvalidValue.warnInvalidValue)("Checkbox","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Checkbox","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const F="circle"===x,M="string"==typeof d?d:void 0,O={description:c,helperText:l,error:M},P=S||s,D=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(D,{toValue:P?1:0,damping:R.motion.spring.snappy.damping,stiffness:R.motion.spring.snappy.stiffness,mass:R.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[P,D,R.motion.spring.snappy]);const H=D.interpolate({inputRange:[0,1],outputRange:[0,1]}),W=_??(0,_FieldBase.fieldTextAsString)(o),A=!0===d||(0,_FieldBase.hasFieldText)(d),L=P?N:n?R.colors.border:A?R.colors["field-border-error"]:R.colors.border,z=P?N:n?R.colors["surface-disabled"]:"transparent",E=n&&!P?R.colors["text-disabled"]:toneOnColor(R,p),U=Math.round(.72*V),K=Math.round(.55*V),X=Math.max(2,Math.round(.12*V)),G=(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:r,onPress:e=>{if(n)return;const r=(0,_hapticUtils.resolveHaptic)(b,"selection");r&&(0,_hapticUtils.triggerHaptic)(r),k(!S),j.onPressOut?.(e)},disabled:n,accessibilityRole:"checkbox",accessibilityLabel:W,accessibilityHint:j.accessibilityHint??(0,_FieldBase.fieldTextAsString)(l??c),accessibilityState:{checked:s?"mixed":S,disabled:n},"aria-checked":s?"mixed":S,"aria-disabled":n,testID:v,hitSlop:B,...(0,_hitSlop.hitSlopMarker)(B),...j,style:({pressed:e})=>[T.row,(0,_ChoiceText.hasChoiceDetail)(O)?T.rowTop:null,(0,_FieldBase.hasFieldText)(u)?T.rowShrink:null,{opacity:n?.55:e?.85:1},y,f],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[T.box,{width:V,height:V,borderWidth:I,borderRadius:F?V/2:R.radius.sm,...F?{}:_corners.smoothCorners,borderColor:L,backgroundColor:z},m],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[T.glyphWrap,{opacity:D,transform:[{scale:H}]}],children:s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{width:K,height:X,borderRadius:R.radius.pill,..._corners.smoothCorners,backgroundColor:E},g]}):(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:U,height:U,viewBox:"0 0 24 24",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:E,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:o,helperText:l,description:c,error:M,disabled:n,style:{marginLeft:q},labelStyle:w})]});return(0,_FieldBase.hasFieldText)(u)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T.helpRow,(0,_ChoiceText.hasChoiceDetail)(O)?T.rowTop:null],children:[G,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[T.help,{marginLeft:R.space.xs}],children:u})]}):G});Checkbox.displayName="Checkbox";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"},rowShrink:{flexShrink:1},helpRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},box:{alignItems:"center",justifyContent:"center"},glyphWrap:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Checkbox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfirmHost=ConfirmHost,exports.confirm=confirm;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_index=require("../Dialog/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CONFIRM_HOST_LABELS={cancel:"Cancel"};let queue=[],hostCount=0,nextId=0;const listeners=new Set,emit=()=>{for(const e of listeners)e()},subscribe=e=>(listeners.add(e),()=>{listeners.delete(e)}),getQueue=()=>queue,settle=(e,t)=>{const o=queue.find(t=>t.id===e);o&&(queue=queue.filter(t=>t.id!==e),emit(),o.resolve(t))};function confirm(e){if(0===hostCount)throw new Error("[@webority/mobile-ui] confirm: mount <ConfirmHost /> once at the app root before calling confirm.");return new Promise(t=>{nextId+=1,queue=[...queue,{id:nextId,options:e,resolve:t}],emit()})}function ConfirmHost({labels:e,testID:t}){const o=(0,_react.useMemo)(()=>({...DEFAULT_CONFIRM_HOST_LABELS,...e}),[e]),n=(0,_react.useSyncExternalStore)(subscribe,getQueue)[0],r=(0,_react.useRef)(void 0);n&&(r.current=n),(0,_react.useEffect)(()=>(hostCount+=1,hostCount>1&&_mobileCore.Logger.warn("[@webority/mobile-ui] ConfirmHost: mounted more than once; mount one at the app root."),()=>{if(hostCount-=1,0===hostCount){const e=queue;queue=[],emit();for(const t of e)t.resolve(!1)}}),[]);const s=n??r.current;return s?(0,_jsxRuntime.jsx)(_index.Dialog,{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConfirmHost=ConfirmHost,exports.confirm=confirm;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_index=require("../Dialog/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CONFIRM_HOST_LABELS={cancel:"Cancel"};let queue=[],hostCount=0,nextId=0;const listeners=new Set,emit=()=>{for(const e of listeners)e()},subscribe=e=>(listeners.add(e),()=>{listeners.delete(e)}),getQueue=()=>queue,settle=(e,t)=>{const o=queue.find(t=>t.id===e);o&&(queue=queue.filter(t=>t.id!==e),emit(),o.resolve(t))};function confirm(e){if(0===hostCount)throw new Error("[@webority/mobile-ui] confirm: mount <ConfirmHost /> once at the app root before calling confirm.");return new Promise(t=>{nextId+=1,queue=[...queue,{id:nextId,options:e,resolve:t}],emit()})}function ConfirmHost({labels:e,testID:t}){const o=(0,_react.useMemo)(()=>({...DEFAULT_CONFIRM_HOST_LABELS,...e}),[e]),n=(0,_react.useSyncExternalStore)(subscribe,getQueue)[0],r=(0,_react.useRef)(void 0);n&&(r.current=n),(0,_react.useEffect)(()=>(hostCount+=1,hostCount>1&&_mobileCore.Logger.warn("[@webority/mobile-ui] ConfirmHost: mounted more than once; mount one at the app root."),()=>{if(hostCount-=1,0===hostCount){const e=queue;queue=[],emit();for(const t of e)t.resolve(!1)}}),[]);const s=n??r.current;return s?(0,_jsxRuntime.jsx)(_index.Dialog,{open:void 0!==n,onClose:()=>settle(s.id,!1),title:s.options.title,message:s.options.message,dismissOnAction:!1,actions:[{label:o.cancel,tone:"neutral",onPress:()=>settle(s.id,!1)},{label:s.options.confirmLabel,tone:s.options.tone??"primary",onPress:()=>settle(s.id,!0)}],testID:t}):null}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DatePicker=exports.DEFAULT_DATE_PICKER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_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("../Calendar/index.js"),_index4=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index5=require("../PickerTrigger/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const NAV_BUTTON_SIZE=36,DEFAULT_DATE_PICKER_LABELS=exports.DEFAULT_DATE_PICKER_LABELS=Object.freeze({title:"Select Date",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss",previousMonth:"Previous month",nextMonth:"Next month",previousYears:"Previous years",nextYears:"Next years",previousDecades:"Previous decades",nextDecades:"Next decades",switchToYears:"switch to year selection",switchToDecades:"switch to decade selection",year:e=>`Year ${e}`,decade:(e,t)=>`Decade ${e} to ${t}`}),GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:i,maxDate:s,disabledDates:n,inline:l=!1,locale:o="en-IN",weekStartsOn:c=0,title:d,labels:u,style:x,containerStyle:_,headerLabelStyle:m,navButtonStyle:g,footerButtonStyle:h,haptic:y,testID:b,label:p,help:v,placeholder:f,helperText:j,error:R,required:D,disabled:C,size:w,variant:S,clearable:N,onClear:T,leadingIcon:A,trailing:M,triggerStyle:P,valueStyle:L,labelStyle:I,messageStyle:k,accessibilityLabel:E,triggerLabels:V,formatValue:B}=e,F=l?"inline":"modal",Y=(0,_react.useMemo)(()=>u?{...DEFAULT_DATE_PICKER_LABELS,...u}:DEFAULT_DATE_PICKER_LABELS,[u]),z=void 0!==e.visible,[H,q]=(0,_react.useState)(!1),$=z?e.visible:H,O=z?b:b?`${b}-calendar`:void 0,W=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),[U,K]=(0,_ModalSafeArea.useModalInsets)(),Z=(0,_react.useMemo)(()=>buildStyles(W),[W]),[X,J]=(0,_react.useState)(()=>startOfDay(new Date));(0,_react.useEffect)(()=>{$&&J(startOfDay(new Date))},[$]);const Q=t?startOfDay(t):X,[ee,te]=(0,_react.useState)(Q),[ae,re]=(0,_react.useState)(t?startOfDay(t):null),[ie,se]=(0,_react.useState)("days"),ne=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,le=(0,_react.useRef)(0),oe=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,ce=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,de=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(t){const e=startOfDay(t);re(e),te(e)}else re(null)},[t]);const ue=(0,_react.useMemo)(()=>i?startOfDay(i):null,[i]),xe=(0,_react.useMemo)(()=>s?startOfDay(s):null,[s]),me=(0,_react.useMemo)(()=>buildYearCells(ee.getFullYear()),[ee]),ge=(0,_react.useMemo)(()=>buildDecadeCells(ee.getFullYear()),[ee]),he=(0,_react.useMemo)(()=>{if("years"===ie){return`${me[0]} - ${me[me.length-1]}`}return`${ge[0]} - ${ge[ge.length-1]+9}`},[ge,ie,me]),ye=(0,_react.useCallback)(e=>!!(ue&&e<ue.getFullYear())||!!(xe&&e>xe.getFullYear()),[ue,xe]),be=(0,_react.useCallback)(e=>!!(ue&&e+10-1<ue.getFullYear())||!!(xe&&e>xe.getFullYear()),[ue,xe]),pe=(0,_react.useCallback)(()=>{!1!==y&&(0,_index2.triggerHaptic)("impactLight"),te("years"===ie?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))},[ie,y]),ve=(0,_react.useCallback)(()=>{!1!==y&&(0,_index2.triggerHaptic)("impactLight"),te("years"===ie?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))},[ie,y]),fe=(0,_react.useCallback)(()=>{const[e]=G.range(.9,1),t=G.reduced?G.duration("default"):W.motion.duration.default;(0,_index.setNativeValue)(oe,0),(0,_index.setNativeValue)(ce,e),_reactNative.Animated.parallel([_reactNative.Animated.timing(oe,{toValue:1,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0}),_reactNative.Animated.timing(ce,{toValue:1,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0})]).start()},[oe,ce,G,W.motion.duration.default]),je=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(y,"selection");if(e&&(0,_index2.triggerHaptic)(e),!G.reduced){const e=80,t=100;_reactNative.Animated.sequence([_reactNative.Animated.timing(de,{toValue:.96,duration:e,useNativeDriver:!0}),_reactNative.Animated.timing(de,{toValue:1,duration:t,useNativeDriver:!0})]).start()}se(e=>"days"===e?"years":"years"===e?"decades":"years"),fe()},[fe,de,y,G.reduced]),Re=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(y,"selection");t&&(0,_index2.triggerHaptic)(t),te(t=>new Date(e,t.getMonth(),1)),se("days"),fe()},[fe,y]),De=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(y,"selection");t&&(0,_index2.triggerHaptic)(t),te(t=>new Date(e+4,t.getMonth(),1)),se("years"),fe()},[fe,y]),Ce=(0,_react.useCallback)(e=>{re(e.start)},[]),we=(0,_react.useCallback)(()=>{z||q(!1),r?.()},[z,r]),{handleGesture:Se,opacity:Ne}=(0,_useDragToDismiss.useDragToDismiss)({drag:ne,travel:()=>le.current||320,onDismiss:we});(0,_react.useEffect)(()=>{$&&"modal"===F&&((0,_index.setNativeValue)(ne,0),(0,_index.setNativeValue)(Ne,1))},[$,F,ne,Ne]);const Te=(0,_react.useCallback)(()=>{!1!==y&&(0,_index2.triggerHaptic)("selection"),we()},[we,y]),Ae=(0,_react.useCallback)(()=>{ae&&(!1!==y&&(0,_index2.triggerHaptic)("notificationSuccess"),a?.(ae),we())},[we,a,ae,y]),Me=(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.titleRow,children:(0,_jsxRuntime.jsx)(_index6.Text,{style:Z.title,variant:"title",accessibilityRole:"header",children:d??Y.title})}),Pe=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Z.card,_,x],accessibilityRole:"modal"===F?void 0:"none",accessible:!1,testID:O,children:["modal"===F?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Se,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Z.grabArea,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.handle}),Me]})}):Me,"days"!==ie?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Z.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:pe,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,g],accessibilityRole:"button",accessibilityLabel:"years"===ie?Y.previousYears:Y.previousDecades,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),children:(0,_jsxRuntime.jsx)(_index6.Text,{style:Z.navText,variant:"title",children:"‹"})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:je,style:[Z.headerLabelWrap,m],accessibilityRole:"button",accessibilityLabel:`${he}, ${"years"===ie?Y.switchToDecades:Y.switchToYears}`,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),children:(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[Z.headerLabelInner,{transform:[{scale:de}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[Z.headerLabel,{transform:[{translateX:0}]}],accessibilityLiveRegion:"polite",children:he}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.headerCaret,children:(W.settings.icons.chevronDown??_defaultIcons.defaultIcons.chevronDown)({size:W.text.sm.size,color:W.colors["text-muted"]})})]})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ve,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,g],accessibilityRole:"button",accessibilityLabel:"years"===ie?Y.nextYears:Y.nextDecades,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),children:(0,_jsxRuntime.jsx)(_index6.Text,{style:Z.navText,variant:"title",children:"›"})})]}):null,"days"===ie?(0,_jsxRuntime.jsx)(_index3.Calendar,{selectionMode:"single",value:ae?{start:ae}:null,onChange:Ce,month:ee,onMonthChange:te,minDate:i,maxDate:s,disabledDates:n,weekStartsOn:c,locale:o,haptic:y,headerLabelStyle:m,navButtonStyle:g,onTitlePress:je,labels:{previousMonth:Y.previousMonth,nextMonth:Y.nextMonth},testID:O?`${O}-grid`:void 0}):"years"===ie?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Z.yearGrid,{opacity:oe,transform:[{scale:ce}]}],children:Array.from({length:3},(e,t)=>me.slice(4*t,4*t+4)).map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.gridRow,children:e.map(e=>{const t=ye(e),a=!!ae&&ae.getFullYear()===e,r=X.getFullYear()===e,i=a?W.colors.primary:"transparent",s=r&&!a?W.colors.primary:"transparent",n=a?W.colors["on-primary"]:t?W.colors["text-disabled"]:W.colors["text-body"],l=t?.3:1;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:t,onPress:()=>Re(e),accessibilityRole:"button",accessibilityLabel:Y.year(e),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:Z.yearCell,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Z.yearInner,{backgroundColor:i,borderColor:s,borderWidth:r&&!a?1.5:0,opacity:l}],children:(0,_jsxRuntime.jsx)(_index6.Text,{style:[Z.yearText,{color:n}],variant:"body",children:e})})},`year-${e}`)})},`yr-${e[0]}`))}):(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Z.yearGrid,{opacity:oe,transform:[{scale:ce}]}],children:Array.from({length:3},(e,t)=>ge.slice(4*t,4*t+4)).map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.gridRow,children:e.map(e=>{const t=e+10-1,a=be(e),r=!!ae&&decadeStartFor(ae.getFullYear())===e,i=decadeStartFor(X.getFullYear())===e,s=r?W.colors.primary:"transparent",n=i&&!r?W.colors.primary:"transparent",l=r?W.colors["on-primary"]:a?W.colors["text-disabled"]:W.colors["text-body"],o=a?.3:1;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:a,onPress:()=>De(e),accessibilityRole:"button",accessibilityLabel:Y.decade(e,t),accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:Z.yearCell,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Z.yearInner,{backgroundColor:s,borderColor:n,borderWidth:i&&!r?1.5:0,opacity:o}],children:[(0,_jsxRuntime.jsx)(_index6.Text,{style:[Z.yearText,{color:l}],variant:"body",children:`${e}s`}),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",style:[Z.decadeRangeText,{color:r?W.colors["on-primary"]:W.colors["text-subtle"]}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${e[0]}`))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Z.footer,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Te,style:({pressed:e})=>[Z.footerBtn,Z.footerCancel,e&&Z.footerBtnPressed,h],accessibilityRole:"button",accessibilityLabel:Y.cancel,children:(0,_jsxRuntime.jsx)(_index6.Text,{style:[Z.footerBtnText,{color:W.colors["text-muted"]}],variant:"label",weight:"semibold",children:Y.cancel})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ae,disabled:!ae,style:({pressed:e})=>[Z.footerBtn,Z.footerConfirm,{backgroundColor:W.colors.primary,opacity:ae?1:.5},e&&{backgroundColor:W.colors["primary-hover"]},h],accessibilityRole:"button",accessibilityLabel:Y.confirm,accessibilityState:{disabled:!ae},"aria-disabled":!ae,children:(0,_jsxRuntime.jsx)(_index6.Text,{style:[Z.footerBtnText,{color:W.colors["on-primary"]}],variant:"label",weight:"semibold",children:Y.confirm})})]})]}),Le=t?(B??(e=>e.toLocaleDateString()))(t):void 0,Ie=!z,ke={label:p,help:v,placeholder:f,helperText:j,error:R,required:D,disabled:C,size:w,variant:S,clearable:N,onClear:T,leadingIcon:A,trailing:M,triggerStyle:P,valueStyle:L,labelStyle:I,messageStyle:k,accessibilityLabel:E,labels:V};if("inline"===F)return $||Ie?Ie?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index5.PickerTrigger,{...ke,value:Le,onPress:()=>q(!0),testID:b}),$?Pe:null]}):Pe:null;const Ee=(0,_jsxRuntime.jsx)(_index4.Modal,{visible:$,onClose:we,presentation:"bottom",bare:!0,haptic:!1,labels:{close:Y.dismiss},onInsetsChange:K,children:(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Z.sheetWrap,{paddingBottom:Math.max(U.bottom,W.space.lg),opacity:Ne,transform:[{translateY:ne}]}],onLayout:e=>{le.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Pe})})});return Ie?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index5.PickerTrigger,{...ke,value:Le,onPress:()=>q(!0),testID:b}),Ee]}):Ee};exports.DatePicker=DatePicker;const buildStyles=e=>{const t=e.shadow.popover;return _reactNative.StyleSheet.create({sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,..._corners.smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navText:{fontSize:e.text["2xl"].size,lineHeight:26,color:e.colors["text-body"],fontWeight:e.weight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.text.base.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerCaret:{marginLeft:e.space.xs,alignItems:"center",justifyContent:"center"},gridRow:{flexDirection:"row"},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.space.xs},yearInner:{width:"100%",height:"100%",borderRadius:e.radius.lg,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.text.base.size,lineHeight:Math.round(e.text.base.size*e.leading.body),fontWeight:e.weight.semibold},decadeRangeText:{fontSize:e.text.xs.size,lineHeight:Math.round(e.text.xs.size*e.leading.body),fontWeight:e.weight.medium,marginTop:e.space.xxs},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,..._corners.smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};var _default=exports.default=DatePicker;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DatePicker=exports.DEFAULT_DATE_PICKER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_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("../Calendar/index.js"),_index4=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index5=require("../PickerTrigger/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const NAV_BUTTON_SIZE=36,DEFAULT_DATE_PICKER_LABELS=exports.DEFAULT_DATE_PICKER_LABELS=Object.freeze({title:"Select Date",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss",previousMonth:"Previous month",nextMonth:"Next month",previousYears:"Previous years",nextYears:"Next years",previousDecades:"Previous decades",nextDecades:"Next decades",switchToYears:"switch to year selection",switchToDecades:"switch to decade selection",year:e=>`Year ${e}`,decade:(e,t)=>`Decade ${e} to ${t}`}),GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:i,maxDate:s,disabledDates:n,inline:l=!1,locale:o="en-IN",weekStartsOn:c=0,title:d,labels:u,style:x,containerStyle:_,headerLabelStyle:m,navButtonStyle:g,footerButtonStyle:h,haptic:y,testID:b,label:p,help:v,placeholder:f,helperText:j,error:R,required:D,disabled:C,size:w,variant:S,clearable:N,onClear:T,leftIcon:A,trailing:M,triggerStyle:P,valueStyle:L,labelStyle:I,messageStyle:k,accessibilityLabel:E,triggerLabels:V,formatValue:B}=e,F=l?"inline":"modal",Y=(0,_react.useMemo)(()=>u?{...DEFAULT_DATE_PICKER_LABELS,...u}:DEFAULT_DATE_PICKER_LABELS,[u]),z=void 0!==e.open,[H,q]=(0,_react.useState)(!1),$=z?e.open:H,O=z?b:b?`${b}-calendar`:void 0,W=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),[U,K]=(0,_ModalSafeArea.useModalInsets)(),Z=(0,_react.useMemo)(()=>buildStyles(W),[W]),[X,J]=(0,_react.useState)(()=>startOfDay(new Date));(0,_react.useEffect)(()=>{$&&J(startOfDay(new Date))},[$]);const Q=t?startOfDay(t):X,[ee,te]=(0,_react.useState)(Q),[ae,re]=(0,_react.useState)(t?startOfDay(t):null),[ie,se]=(0,_react.useState)("days"),ne=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,le=(0,_react.useRef)(0),oe=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,ce=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,de=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(t){const e=startOfDay(t);re(e),te(e)}else re(null)},[t]);const ue=(0,_react.useMemo)(()=>i?startOfDay(i):null,[i]),xe=(0,_react.useMemo)(()=>s?startOfDay(s):null,[s]),me=(0,_react.useMemo)(()=>buildYearCells(ee.getFullYear()),[ee]),ge=(0,_react.useMemo)(()=>buildDecadeCells(ee.getFullYear()),[ee]),he=(0,_react.useMemo)(()=>{if("years"===ie){return`${me[0]} - ${me[me.length-1]}`}return`${ge[0]} - ${ge[ge.length-1]+9}`},[ge,ie,me]),ye=(0,_react.useCallback)(e=>!!(ue&&e<ue.getFullYear())||!!(xe&&e>xe.getFullYear()),[ue,xe]),be=(0,_react.useCallback)(e=>!!(ue&&e+10-1<ue.getFullYear())||!!(xe&&e>xe.getFullYear()),[ue,xe]),pe=(0,_react.useCallback)(()=>{!1!==y&&(0,_index2.triggerHaptic)("impactLight"),te("years"===ie?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))},[ie,y]),ve=(0,_react.useCallback)(()=>{!1!==y&&(0,_index2.triggerHaptic)("impactLight"),te("years"===ie?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))},[ie,y]),fe=(0,_react.useCallback)(()=>{const[e]=G.range(.9,1),t=G.reduced?G.duration("default"):W.motion.duration.default;(0,_index.setNativeValue)(oe,0),(0,_index.setNativeValue)(ce,e),_reactNative.Animated.parallel([_reactNative.Animated.timing(oe,{toValue:1,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0}),_reactNative.Animated.timing(ce,{toValue:1,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0})]).start()},[oe,ce,G,W.motion.duration.default]),je=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(y,"selection");if(e&&(0,_index2.triggerHaptic)(e),!G.reduced){const e=80,t=100;_reactNative.Animated.sequence([_reactNative.Animated.timing(de,{toValue:.96,duration:e,useNativeDriver:!0}),_reactNative.Animated.timing(de,{toValue:1,duration:t,useNativeDriver:!0})]).start()}se(e=>"days"===e?"years":"years"===e?"decades":"years"),fe()},[fe,de,y,G.reduced]),Re=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(y,"selection");t&&(0,_index2.triggerHaptic)(t),te(t=>new Date(e,t.getMonth(),1)),se("days"),fe()},[fe,y]),De=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(y,"selection");t&&(0,_index2.triggerHaptic)(t),te(t=>new Date(e+4,t.getMonth(),1)),se("years"),fe()},[fe,y]),Ce=(0,_react.useCallback)(e=>{re(e.start)},[]),we=(0,_react.useCallback)(()=>{z||q(!1),r?.()},[z,r]),{handleGesture:Se,opacity:Ne}=(0,_useDragToDismiss.useDragToDismiss)({drag:ne,travel:()=>le.current||320,onDismiss:we});(0,_react.useEffect)(()=>{$&&"modal"===F&&((0,_index.setNativeValue)(ne,0),(0,_index.setNativeValue)(Ne,1))},[$,F,ne,Ne]);const Te=(0,_react.useCallback)(()=>{!1!==y&&(0,_index2.triggerHaptic)("selection"),we()},[we,y]),Ae=(0,_react.useCallback)(()=>{ae&&(!1!==y&&(0,_index2.triggerHaptic)("notificationSuccess"),a?.(ae),we())},[we,a,ae,y]),Me=(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.titleRow,children:(0,_jsxRuntime.jsx)(_index6.Text,{style:Z.title,variant:"title",accessibilityRole:"header",children:d??Y.title})}),Pe=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Z.card,_,x],accessibilityRole:"modal"===F?void 0:"none",accessible:!1,testID:O,children:["modal"===F?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Se,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Z.grabArea,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.handle}),Me]})}):Me,"days"!==ie?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Z.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:pe,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,g],accessibilityRole:"button",accessibilityLabel:"years"===ie?Y.previousYears:Y.previousDecades,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),children:(0,_jsxRuntime.jsx)(_index6.Text,{style:Z.navText,variant:"title",children:"‹"})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:je,style:[Z.headerLabelWrap,m],accessibilityRole:"button",accessibilityLabel:`${he}, ${"years"===ie?Y.switchToDecades:Y.switchToYears}`,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),children:(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[Z.headerLabelInner,{transform:[{scale:de}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[Z.headerLabel,{transform:[{translateX:0}]}],accessibilityLiveRegion:"polite",children:he}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.headerCaret,children:(W.settings.icons.chevronDown??_defaultIcons.defaultIcons.chevronDown)({size:W.text.sm.size,color:W.colors["text-muted"]})})]})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ve,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,g],accessibilityRole:"button",accessibilityLabel:"years"===ie?Y.nextYears:Y.nextDecades,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),children:(0,_jsxRuntime.jsx)(_index6.Text,{style:Z.navText,variant:"title",children:"›"})})]}):null,"days"===ie?(0,_jsxRuntime.jsx)(_index3.Calendar,{selectionMode:"single",value:ae?{start:ae}:null,onChange:Ce,month:ee,onMonthChange:te,minDate:i,maxDate:s,disabledDates:n,weekStartsOn:c,locale:o,haptic:y,headerLabelStyle:m,navButtonStyle:g,onTitlePress:je,labels:{previousMonth:Y.previousMonth,nextMonth:Y.nextMonth},testID:O?`${O}-grid`:void 0}):"years"===ie?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Z.yearGrid,{opacity:oe,transform:[{scale:ce}]}],children:Array.from({length:3},(e,t)=>me.slice(4*t,4*t+4)).map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.gridRow,children:e.map(e=>{const t=ye(e),a=!!ae&&ae.getFullYear()===e,r=X.getFullYear()===e,i=a?W.colors.primary:"transparent",s=r&&!a?W.colors.primary:"transparent",n=a?W.colors["on-primary"]:t?W.colors["text-disabled"]:W.colors["text-body"],l=t?.3:1;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:t,onPress:()=>Re(e),accessibilityRole:"button",accessibilityLabel:Y.year(e),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:Z.yearCell,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Z.yearInner,{backgroundColor:i,borderColor:s,borderWidth:r&&!a?1.5:0,opacity:l}],children:(0,_jsxRuntime.jsx)(_index6.Text,{style:[Z.yearText,{color:n}],variant:"body",children:e})})},`year-${e}`)})},`yr-${e[0]}`))}):(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Z.yearGrid,{opacity:oe,transform:[{scale:ce}]}],children:Array.from({length:3},(e,t)=>ge.slice(4*t,4*t+4)).map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:Z.gridRow,children:e.map(e=>{const t=e+10-1,a=be(e),r=!!ae&&decadeStartFor(ae.getFullYear())===e,i=decadeStartFor(X.getFullYear())===e,s=r?W.colors.primary:"transparent",n=i&&!r?W.colors.primary:"transparent",l=r?W.colors["on-primary"]:a?W.colors["text-disabled"]:W.colors["text-body"],o=a?.3:1;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:a,onPress:()=>De(e),accessibilityRole:"button",accessibilityLabel:Y.decade(e,t),accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:Z.yearCell,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Z.yearInner,{backgroundColor:s,borderColor:n,borderWidth:i&&!r?1.5:0,opacity:o}],children:[(0,_jsxRuntime.jsx)(_index6.Text,{style:[Z.yearText,{color:l}],variant:"body",children:`${e}s`}),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",style:[Z.decadeRangeText,{color:r?W.colors["on-primary"]:W.colors["text-subtle"]}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${e[0]}`))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Z.footer,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Te,style:({pressed:e})=>[Z.footerBtn,Z.footerCancel,e&&Z.footerBtnPressed,h],accessibilityRole:"button",accessibilityLabel:Y.cancel,children:(0,_jsxRuntime.jsx)(_index6.Text,{style:[Z.footerBtnText,{color:W.colors["text-muted"]}],variant:"label",weight:"semibold",children:Y.cancel})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ae,disabled:!ae,style:({pressed:e})=>[Z.footerBtn,Z.footerConfirm,{backgroundColor:W.colors.primary,opacity:ae?1:.5},e&&{backgroundColor:W.colors["primary-hover"]},h],accessibilityRole:"button",accessibilityLabel:Y.confirm,accessibilityState:{disabled:!ae},"aria-disabled":!ae,children:(0,_jsxRuntime.jsx)(_index6.Text,{style:[Z.footerBtnText,{color:W.colors["on-primary"]}],variant:"label",weight:"semibold",children:Y.confirm})})]})]}),Le=t?(B??(e=>e.toLocaleDateString()))(t):void 0,Ie=!z,ke={label:p,help:v,placeholder:f,helperText:j,error:R,required:D,disabled:C,size:w,variant:S,clearable:N,onClear:T,leftIcon:A,trailing:M,triggerStyle:P,valueStyle:L,labelStyle:I,messageStyle:k,accessibilityLabel:E,labels:V};if("inline"===F)return $||Ie?Ie?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index5.PickerTrigger,{...ke,value:Le,onPress:()=>q(!0),testID:b}),$?Pe:null]}):Pe:null;const Ee=(0,_jsxRuntime.jsx)(_index4.Modal,{open:$,onClose:we,presentation:"bottom",bare:!0,haptic:!1,labels:{close:Y.dismiss},onInsetsChange:K,children:(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Z.sheetWrap,{paddingBottom:Math.max(U.bottom,W.space.lg),opacity:Ne,transform:[{translateY:ne}]}],onLayout:e=>{le.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Pe})})});return Ie?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index5.PickerTrigger,{...ke,value:Le,onPress:()=>q(!0),testID:b}),Ee]}):Ee};exports.DatePicker=DatePicker;const buildStyles=e=>{const t=e.shadow.popover;return _reactNative.StyleSheet.create({sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,..._corners.smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navText:{fontSize:e.text["2xl"].size,lineHeight:26,color:e.colors["text-body"],fontWeight:e.weight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.text.base.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerCaret:{marginLeft:e.space.xs,alignItems:"center",justifyContent:"center"},gridRow:{flexDirection:"row"},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.space.xs},yearInner:{width:"100%",height:"100%",borderRadius:e.radius.lg,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.text.base.size,lineHeight:Math.round(e.text.base.size*e.leading.body),fontWeight:e.weight.semibold},decadeRangeText:{fontSize:e.text.xs.size,lineHeight:Math.round(e.text.xs.size*e.leading.body),fontWeight:e.weight.medium,marginTop:e.space.xxs},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,..._corners.smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};var _default=exports.default=DatePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DateRangePicker=exports.DEFAULT_DATE_RANGE_PICKER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Calendar/index.js"),_calendarDates=require("../Calendar/calendarDates.js"),_index4=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index5=require("../PickerTrigger/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_DATE_RANGE_PICKER_LABELS=exports.DEFAULT_DATE_RANGE_PICKER_LABELS=Object.freeze({title:"Select Date Range",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss"}),formatRangePart=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short"}).format(e),DateRangePicker=exports.DateRangePicker=(0,_react.forwardRef)((e,t)=>{const{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DateRangePicker=exports.DEFAULT_DATE_RANGE_PICKER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Calendar/index.js"),_calendarDates=require("../Calendar/calendarDates.js"),_index4=require("../Modal/index.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index5=require("../PickerTrigger/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_DATE_RANGE_PICKER_LABELS=exports.DEFAULT_DATE_RANGE_PICKER_LABELS=Object.freeze({title:"Select Date Range",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss"}),formatRangePart=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short"}).format(e),DateRangePicker=exports.DateRangePicker=(0,_react.forwardRef)((e,t)=>{const{open:a,value:r,onChange:s,onClose:i,label:n,help:l,placeholder:o,helperText:c,error:d,required:u,disabled:_,size:m,variant:x,clearable:g,onClear:h,leftIcon:b,trailing:f,triggerStyle:y,valueStyle:p,labelStyle:R,messageStyle:D,accessibilityLabel:j,triggerLabels:v,formatValue:S,minDate:C,maxDate:w,disabledDates:T,marks:A,locale:P="en-IN",weekStartsOn:k=0,title:E,labels:L,maxRange:M,haptic:N,style:B,containerStyle:I,headerLabelStyle:q,navButtonStyle:z,footerButtonStyle:O,testID:H}=e,V={label:n,help:l,placeholder:o,helperText:c,error:d,required:u,disabled:_,size:m,variant:x,clearable:g,onClear:h,leftIcon:b,trailing:f,triggerStyle:y,valueStyle:p,labelStyle:R,messageStyle:D,accessibilityLabel:j},G=void 0!==a,[$,F]=(0,_react.useState)(!1),W=G?a:$,K=G?H:H?`${H}-calendar`:void 0,U=(0,_index.useTheme)(),[Y,J]=(0,_ModalSafeArea.useModalInsets)(),Q=(0,_react.useMemo)(()=>buildStyles(U),[U]),X=(0,_react.useMemo)(()=>({...DEFAULT_DATE_RANGE_PICKER_LABELS,...L}),[L]),[Z,ee]=(0,_react.useState)(()=>(0,_calendarDates.startOfMonth)(r.start??new Date)),[te,ae]=(0,_react.useState)(r.start?(0,_calendarDates.startOfDay)(r.start):null),[re,se]=(0,_react.useState)(r.end?(0,_calendarDates.startOfDay)(r.end):null),ie=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,ne=(0,_react.useRef)(0);(0,_react.useEffect)(()=>{if(r.start){const e=(0,_calendarDates.startOfDay)(r.start);ae(e),ee((0,_calendarDates.startOfMonth)(e))}else ae(null);r.end?se((0,_calendarDates.startOfDay)(r.end)):se(null)},[r.start,r.end]);const le=(0,_react.useCallback)(e=>{if(e.end&&M&&(0,_calendarDates.daysBetween)(e.start,e.end)+1>M)return!1!==N&&(0,_index2.triggerHaptic)("notificationWarning"),ae(e.end),void se(null);ae(e.start),se(e.end??null)},[M,N]),oe=(0,_react.useCallback)(()=>{G?i?.():F(!1)},[G,i]),{handleGesture:ce,opacity:de}=(0,_useDragToDismiss.useDragToDismiss)({drag:ie,travel:()=>ne.current||320,onDismiss:oe});(0,_react.useEffect)(()=>{W&&((0,_index.setNativeValue)(ie,0),(0,_index.setNativeValue)(de,1))},[W,ie,de]);const ue=(0,_react.useCallback)(()=>{!1!==N&&(0,_index2.triggerHaptic)("selection"),oe()},[oe,N]),me=(0,_react.useCallback)(()=>{te&&re&&(!1!==N&&(0,_index2.triggerHaptic)("notificationSuccess"),s?.({start:te,end:re}),oe())},[oe,s,te,re,N]),xe=(0,_react.useMemo)(()=>te&&re?`${formatRangePart(te,P)} — ${formatRangePart(re,P)}`:te?`${formatRangePart(te,P)} — …`:"—",[te,re,P]),ge=!te||!re,he=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Q.card,I,B],ref:t,accessible:!1,testID:K,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ce,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.grabArea,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:Q.handle}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.titleRow,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"title",style:Q.title,accessibilityRole:"header",children:E??X.title}),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",style:Q.subtitle,accessibilityLiveRegion:"polite",children:xe})]})]})}),(0,_jsxRuntime.jsx)(_index3.Calendar,{selectionMode:"range",value:te?{start:te,end:re??void 0}:null,onChange:le,month:Z,onMonthChange:ee,minDate:C,maxDate:w,disabledDates:T,marks:A,weekStartsOn:k,locale:P,haptic:N,headerLabelStyle:q,navButtonStyle:z,testID:K?`${K}-grid`:void 0}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Q.footer,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ue,style:({pressed:e})=>[Q.footerBtn,Q.footerCancel,e&&Q.footerBtnPressed,O],accessibilityRole:"button",accessibilityLabel:X.cancel,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["text-muted"]}],children:X.cancel})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:me,disabled:ge,style:({pressed:e})=>[Q.footerBtn,Q.footerConfirm,{backgroundColor:U.colors.primary,opacity:ge?.5:1},e&&{backgroundColor:U.colors["primary-hover"]},O],accessibilityRole:"button",accessibilityLabel:X.confirm,accessibilityState:{disabled:ge},"aria-disabled":ge,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["on-primary"]}],children:X.confirm})})]})]}),be=(0,_react.useMemo)(()=>{if(!r.start||!r.end)return"";const e={start:r.start,end:r.end};return S?S(e):`${e.start.toLocaleDateString()} – ${e.end.toLocaleDateString()}`},[r.start,r.end,S]);return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G?null:(0,_jsxRuntime.jsx)(_index5.PickerTrigger,{...V,labels:v,value:be,onPress:()=>F(!0),testID:H}),(0,_jsxRuntime.jsx)(_index4.Modal,{open:W,onClose:oe,presentation:"bottom",bare:!0,haptic:!1,labels:{close:X.dismiss},onInsetsChange:J,children:(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Q.sheetWrap,{paddingBottom:Math.max(Y.bottom,U.space.lg),opacity:de,transform:[{translateY:ie}]}],onLayout:e=>{ne.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:he})})})]})});DateRangePicker.displayName="DateRangePicker";const buildStyles=e=>{const t=e.shadow.popover;return _reactNative.StyleSheet.create({sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,..._corners.smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},subtitle:{marginTop:e.space.xxs,fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),color:e.colors["text-muted"]},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,..._corners.smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};var _default=exports.default=DateRangePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Dialog=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_Modal=require("../Modal/Modal.js"),_OverlayActions=require("./OverlayActions.js"),_jsxRuntime=require("react/jsx-runtime");const DIALOG_ILLUSTRATION_SIZE=120,STATUS_MARK={success:"check-circle",warning:"alert-triangle",danger:"alert-circle",info:"info-circle"},Dialog=e=>{const{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Dialog=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_Modal=require("../Modal/Modal.js"),_OverlayActions=require("./OverlayActions.js"),_jsxRuntime=require("react/jsx-runtime");const DIALOG_ILLUSTRATION_SIZE=120,STATUS_MARK={success:"check-circle",warning:"alert-triangle",danger:"alert-circle",info:"info-circle"},Dialog=e=>{const{open:t,onClose:i,title:l,message:s,children:n,icon:r,illustration:a,tone:o="neutral",actions:c,actionsLayout:u="auto",dismissOnAction:d=!0,accessibilityLabel:_,contentStyle:m,containerStyle:g,titleStyle:x,messageStyle:y,iconWrapperStyle:p,actionsRowStyle:S,actionButtonStyle:j,actionTextStyle:h,haptic:v,testID:b}=e;(0,_warnInvalidValue.warnInvalidValue)("Dialog","tone",e.tone,_OverlayActions.OVERLAY_TONES),(0,_warnInvalidValue.warnInvalidValue)("Dialog","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const A=(0,_index.useTheme)(),I=(0,_react.useMemo)(()=>buildStyles(),[]),O=(0,_react.useMemo)(()=>discFor(A,o),[A,o]),R=A.components.dialog["icon-wrapper-size"],f=Boolean(c&&c.length>0),w=(0,_react.useState)(null),M=(0,_react.useCallback)(e=>{if(e.loading||e.disabled)return;const t=(0,_hapticUtils.resolveHaptic)(v,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),d?(i(),setTimeout(e.onPress,_Modal.MODAL_DISMISS_GRACE_MS)):e.onPress()},[d,i,v]),T=(0,_react.useMemo)(()=>(c??[]).map(e=>({...e,onPress:()=>M(e)})),[c,M]),D=null==r&&null==a&&STATUS_MARK[o]?(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:STATUS_MARK[o],size:Math.round(R/2),color:A.colors[o]}):null,L=r??D;return(0,_jsxRuntime.jsx)(_Modal.Modal,{open:t,onClose:i,haptic:v,presentation:"centered",accessibilityLabel:_??l,contentStyle:m,testID:b,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"alert",accessibilityLabel:_??l,style:[I.container,g],children:[null!=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{alignItems:"center",marginBottom:A.space.md},children:(0,_react.isValidElement)(a)?a:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:a,style:{width:120,height:120},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):null,L?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[I.iconWrapper,{width:R,height:R,borderRadius:A.radius.pill,..._corners.smoothCorners,backgroundColor:O,marginBottom:A.space.md},p],children:L}):null,l?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[I.title,{color:A.colors["text-body"],fontSize:A.text.xl.size,...(0,_index.fontFor)(A,"semibold"),marginBottom:s||null!=n?A.space.sm:A.space.md},x],accessibilityRole:"header",children:l}):null,s?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[I.message,{color:A.colors["text-muted"],fontSize:A.text.base.size,lineHeight:A.text.base.size*A.leading.body,marginBottom:null!=n?A.space.md:f?A.space.lg:0},y],children:s}):null,null!=n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginBottom:f?A.space.lg:0},children:n}):null,f?(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:T,layout:u,stackedLabels:w,rowStyle:S,buttonStyle:j,textStyle:h}):null]})})};exports.Dialog=Dialog,Dialog.displayName="Dialog";const SOFT_DISC_OPACITY=.14,discFor=(e,t)=>{const i=e.colors["bg-subtle"];switch(t){case"success":return(0,_color.tintOf)(e.colors.success,.14,i);case"warning":return(0,_color.tintOf)(e.colors.warning,.14,i);case"danger":return(0,_color.tintOf)(e.colors.danger,.14,i);case"info":return(0,_color.tintOf)(e.colors.info,.14,i);default:return e.colors["primary-soft"]}},buildStyles=()=>_reactNative.StyleSheet.create({container:{alignItems:"stretch"},iconWrapper:{alignItems:"center",justifyContent:"center",alignSelf:"center"},title:{textAlign:"center"},message:{textAlign:"center"}});var _default=exports.default=Dialog;
|
|
@@ -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"),_warnInvalidValue=require("../../utils/warnInvalidValue.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{
|
|
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"),_warnInvalidValue=require("../../utils/warnInvalidValue.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:o,enableSwipe:s=!0,enableBackdropPress:c=!0,backdropOpacity:l=.5,haptic:u,containerStyle:d,children:_,accessibilityLabel:v,labels:p,testID:h}=e,f=(0,_index.useTheme)();(0,_warnInvalidValue.warnInvalidValue)("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"),w=b.duration("fast"),N=(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 x="left"===n||"right"===n,M=(0,_react.useMemo)(()=>resolveSize(o,x,S),[o,x,S]),D=(0,_react.useMemo)(()=>{switch(n){case"left":case"top":return-M;case"right":case"bottom":return M}},[n,M]),O=(0,_reactNativeReanimated.useSharedValue)(r?0:D),C=(0,_reactNativeReanimated.useSharedValue)(r?0:D),L=(0,_reactNativeReanimated.useSharedValue)(r?1:0),[A,T]=(0,_react.useState)(r),j=(0,_reactNativeReanimated.useSharedValue)(r);(0,_react.useEffect)(()=>{A||R||(O.value=D,C.value=D)},[D,A,O,C,R]);const k=f.motion.spring.snappy,P=(0,_react.useCallback)(()=>{if(R)return O.value=0,void(L.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}));L.value=1,O.value=(0,_reactNativeReanimated.withSpring)(0,k)},[O,L,k,R,g]),I=(0,_react.useCallback)(()=>{R?L.value=(0,_reactNativeReanimated.withTiming)(0,{duration:w,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(O.value=D)}):O.value=(0,_reactNativeReanimated.withSpring)(D,k)},[O,L,D,k,R,w]),V=(0,_react.useCallback)(e=>{T(t=>t===e?t:(i?.(e),e)),j.value=e},[i,j]),q=(0,_react.useCallback)(()=>{V(!0),P()},[V,P]),F=(0,_react.useCallback)(()=>{V(!1),I()},[V,I]),U=(0,_react.useCallback)(()=>{A?F():q()},[A,q,F]);(0,_react.useImperativeHandle)(t,()=>({open:q,close:F,toggle:U}),[q,F,U]),(0,_react.useEffect)(()=>{E&&a!==A&&(a?q():F())},[a]);const B=(0,_react.useMemo)(()=>{const e=D,t=n,a=s;let r=_reactNativeGestureHandler.Gesture.Pan();return r=x?r.activeOffsetX([-10,10]).failOffsetY([-15,15]):r.activeOffsetY([-10,10]).failOffsetX([-15,15]),r.onStart(()=>{"worklet";a&&(C.value=O.value)}).onUpdate(t=>{"worklet";if(!a)return;const r=x?t.translationX:t.translationY,i=C.value+r,n=Math.min(0,e),o=Math.max(0,e);O.value=i<n?n+.25*(i-n):i>o?o+.25*(i-o):i}).onEnd(r=>{"worklet";if(!a)return;const i=x?r.velocityX:r.velocityY,n=O.value;let o=!1;o="left"===t||"top"===t?i<-1e3:i>1e3;const s=Math.abs(e),c=Math.abs(n)/s;o||c>.5?((0,_reactNativeReanimated.runOnJS)(V)(!1),R?L.value=(0,_reactNativeReanimated.withTiming)(0,{duration:w,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(O.value=e)}):O.value=(0,_reactNativeReanimated.withSpring)(e,k)):((0,_reactNativeReanimated.runOnJS)(V)(!0),R?(O.value=0,L.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION})):O.value=(0,_reactNativeReanimated.withSpring)(0,k))})},[D,C,s,x,O,L,V,n,k,R,g,w]),H=(0,_reactNativeReanimated.useAnimatedStyle)(()=>x?{opacity:L.value,transform:[{translateX:O.value}]}:{opacity:L.value,transform:[{translateY:O.value}]}),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:(0,_reactNativeReanimated.interpolate)(O.value,[D,0],[0,l],_reactNativeReanimated.Extrapolation.CLAMP)*L.value,pointerEvents:Math.abs(O.value-D)<.5?"none":"auto"}),[D,l]),G=(0,_react.useMemo)(()=>buildStyles(f),[f]),Y=(0,_react.useCallback)(()=>{if(!c)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),F()},[c,F,u]),X=(0,_react.useMemo)(()=>{switch(n){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:M,paddingTop:N.top,paddingBottom:N.bottom,paddingLeft:N.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:M,paddingTop:N.top,paddingBottom:N.bottom,paddingRight:N.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:M,paddingTop:N.top,paddingLeft:N.left,paddingRight:N.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:M,paddingBottom:N.bottom,paddingLeft:N.left,paddingRight:N.right}}},[n,M,N]),z=(0,_react.useRef)(r);return A&&(z.current=!0),z.current?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",testID:h,accessibilityViewIsModal:A,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[G.backdrop,{backgroundColor:f.colors.scrim},W],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:Y,accessibilityRole:"button",accessibilityLabel:m.close,disabled:!c||!A})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:B,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:v??m.drawer,style:[X,{backgroundColor:f.colors.surface,...f.shadow.modal},d,H],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:G.content,children:_})})})]}):null});Drawer.displayName="Drawer";const 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;
|