@webority/mobile-ui 0.179.0 → 0.181.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/canvas-kit/kit.js +10 -10
- package/dist/canvas-kit/manifest.json +16 -1
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Confetti/Confetti.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -1
- package/lib/commonjs/components/Skeleton/Skeleton.js +1 -1
- package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/commonjs/components/Slider/Slider.js +1 -1
- package/lib/commonjs/components/SortableList/SortableList.js +1 -1
- package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
- package/lib/commonjs/components/TypingIndicator/TypingIndicator.js +1 -1
- package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/commonjs/theme/Gradient.js +1 -1
- package/lib/commonjs/theme/tokens.generated.js +1 -1
- package/lib/commonjs/utils/animatedDeps.js +1 -0
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/Confetti/Confetti.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -1
- package/lib/module/components/Skeleton/Skeleton.js +1 -1
- package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/module/components/Slider/Slider.js +1 -1
- package/lib/module/components/SortableList/SortableList.js +1 -1
- package/lib/module/components/Swipeable/Swipeable.js +1 -1
- package/lib/module/components/TypingIndicator/TypingIndicator.js +1 -1
- package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/module/theme/Gradient.js +1 -1
- package/lib/module/theme/tokens.generated.js +1 -1
- package/lib/module/utils/animatedDeps.js +1 -0
- package/lib/typescript/commonjs/theme/Gradient.d.ts +2 -2
- package/lib/typescript/commonjs/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/commonjs/utils/animatedDeps.d.ts +2 -0
- package/lib/typescript/module/theme/Gradient.d.ts +2 -2
- package/lib/typescript/module/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/module/utils/animatedDeps.d.ts +2 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SortableList=SortableList,exports.default=void 0,exports.dropIndex=dropIndex,exports.moveItem=moveItem,exports.rowShifts=rowShifts,exports.slotTop=slotTop,exports.topOf=topOf;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../text/index.js"),_sortableListG=require("../../text/phone/sortableList.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_ScrollHost=require("../Screen/ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,l=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=l&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?l(i,r,a):i[r]=e[r]);return i}const LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};function moveItem(e,t,a){const r=e.slice();if(t<0||t>=r.length)return r;const[l]=r.splice(t,1);return void 0===l||r.splice(a,0,l),r}function topOf(e,t){"worklet";let a=0;for(let r=0;r<t;r++)a+=e[r]??0;return a}function slotTop(e,t,a){"worklet";let r=0,l=0;for(let i=0;i<e.length&&l<a;i++)i!==t&&(r+=e[i]??0,l++);return r}function dropIndex(e,t,a){"worklet";const r=topOf(e,t)+(e[t]??0)/2+a;let l=0,i=0;for(let a=0;a<e.length;a++){const s=e[a]??0;a!==t&&i+s/2<r&&l++,i+=s}return l}function rowShifts(e,t,a){const r=[];let l=0;for(const t of e)r.push(l),l+=t;const i=e.map(()=>0),s=moveItem(e.map((e,t)=>t),t,a);let n=0;for(const t of s)i[t]=n-(r[t]??0),n+=e[t]??0;return i}const buildStyles=e=>_reactNative.StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:r,isActive:l,dragging:i,handle:s,disabled:n,shared:o,callbacks:c,labels:u,children:d}){const v=(0,_index2.useTheme)(),_=(0,_react.useMemo)(()=>buildStyles(v),[v]),m=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{m.value=i&&!l?(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG):r},[i,l,r,m]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(m)},[m]);const h=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateY:l?o.dragY.value:m.value}],zIndex:l?1:0}),[l,o,m]),f=(0,_react.useMemo)(()=>{const{dragIndex:e,dropTo:a,dragY:r,translation:l,absoluteY:i,scrollY:u,scrollStart:d,hostOffset:v,hostStart:_,hostTarget:m,heights:h}=o,{onLift:f,onDrop:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SortableList=SortableList,exports.default=void 0,exports.dropIndex=dropIndex,exports.moveItem=moveItem,exports.rowShifts=rowShifts,exports.slotTop=slotTop,exports.topOf=topOf;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../text/index.js"),_sortableListG=require("../../text/phone/sortableList.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_ScrollHost=require("../Screen/ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,l=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=l&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?l(i,r,a):i[r]=e[r]);return i}const LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};function moveItem(e,t,a){const r=e.slice();if(t<0||t>=r.length)return r;const[l]=r.splice(t,1);return void 0===l||r.splice(a,0,l),r}function topOf(e,t){"worklet";let a=0;for(let r=0;r<t;r++)a+=e[r]??0;return a}function slotTop(e,t,a){"worklet";let r=0,l=0;for(let i=0;i<e.length&&l<a;i++)i!==t&&(r+=e[i]??0,l++);return r}function dropIndex(e,t,a){"worklet";const r=topOf(e,t)+(e[t]??0)/2+a;let l=0,i=0;for(let a=0;a<e.length;a++){const s=e[a]??0;a!==t&&i+s/2<r&&l++,i+=s}return l}function rowShifts(e,t,a){const r=[];let l=0;for(const t of e)r.push(l),l+=t;const i=e.map(()=>0),s=moveItem(e.map((e,t)=>t),t,a);let n=0;for(const t of s)i[t]=n-(r[t]??0),n+=e[t]??0;return i}const buildStyles=e=>_reactNative.StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:r,isActive:l,dragging:i,handle:s,disabled:n,shared:o,callbacks:c,labels:u,children:d}){const v=(0,_index2.useTheme)(),_=(0,_react.useMemo)(()=>buildStyles(v),[v]),m=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{m.value=i&&!l?(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG):r},[i,l,r,m]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(m)},[m]);const h=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateY:l?o.dragY.value:m.value}],zIndex:l?1:0}),...(0,_animatedDeps.webDeps)([l,o,m])),f=(0,_react.useMemo)(()=>{const{dragIndex:e,dropTo:a,dragY:r,translation:l,absoluteY:i,scrollY:u,scrollStart:d,hostOffset:v,hostStart:_,hostTarget:m,heights:h}=o,{onLift:f,onDrop:p,onSettled:S}=c;return{enabled:!n,...s?{}:{activateAfterLongPress:350},onActivate:s=>{"worklet";i.value=s.absoluteY,e.value=t,a.value=t,d.value=u.value,_.value=v.value,m.value=v.value,l.value=0,r.value=0,(0,_reactNativeWorklets.scheduleOnRN)(f,t)},onUpdate:a=>{"worklet";e.value===t&&(l.value=a.translationY,i.value=a.absoluteY)},onFinalize:()=>{"worklet";if(e.value!==t)return;const l=a.value,i=h.value;e.value=-1,r.value=topOf(i,t)+r.value-slotTop(i,t,l),r.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(S)}),(0,_reactNativeWorklets.scheduleOnRN)(p,t,l)}}},[n,s,t,c,o]),p=(0,_reactNativeGestureHandler.usePanGesture)(f),S=n?[]:[...t>0?[{name:"moveUp",label:u.moveUp}]:[],...t<a-1?[{name:"moveDown",label:u.moveDown}]:[]];return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:h,onLayout:t=>c.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:S,onAccessibilityAction:e=>{if(n)return;const r=t+(ACTION_STEP[e.nativeEvent.actionName]??0);r!==t&&r>=0&&r<a&&c.onMove(t,r)},testID:`sortable-row-${e}`,children:s?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handleRow,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:p,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handle,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.body,children:d})]}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:p,children:(0,_jsxRuntime.jsx)(_reactNative.View,{children:d})})})}function SortableList(e){const{data:t,keyExtractor:a,renderItem:r,onReorder:l,handle:i=!1,disabled:s=!1,accessibilityLabel:n,labels:o,testID:c}=e,u=(0,_index.useMobileUiText)("sortableList",_sortableListG.SORTABLE_LIST_TEXT),d=(0,_react.useMemo)(()=>({...u,...o}),[u,o]),v=(0,_react.useMemo)(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),_=(0,_react.useMemo)(()=>v.map(e=>e.key),[v]),m=(0,_reactNativeReanimated.useAnimatedRef)(),h=(0,_reactNativeReanimated.useSharedValue)(0),f=(0,_reactNativeReanimated.useSharedValue)(0),p=(0,_reactNativeReanimated.useSharedValue)(0),S=(0,_ScrollHost.useScrollHost)(),x=(0,_reactNativeReanimated.useSharedValue)(0),R=null!==S,g=S?.top??x,N=S?.bottom??x,b=S?.offset??x,w=S?.maxOffset??x,k=S?.scrollTo??noop,L=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_reactNativeReanimated.useSharedValue)(0),y=(0,_reactNativeReanimated.useSharedValue)(0),O=(0,_reactNativeReanimated.useSharedValue)(0),P=(0,_reactNativeReanimated.useSharedValue)(-1),C=(0,_reactNativeReanimated.useSharedValue)(-1),I=(0,_reactNativeReanimated.useSharedValue)(0),T=(0,_reactNativeReanimated.useSharedValue)([]),E=(0,_react.useRef)(new Map),M=(0,_react.useRef)(_),[V,A]=(0,_react.useState)(null),D=(0,_react.useCallback)(()=>{T.value=M.current.map(e=>E.current.get(e)??0)},[T]);(0,_react.useEffect)(()=>{M.current=_,D()},[_,D]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(I)},[I]);const G=(0,_react.useCallback)(e=>{A(t=>t?.dragging?{...t,to:e}:t)},[]),Y=(0,_reactNativeReanimated.useFrameCallback)(()=>{"worklet";const e=P.value;if(e<0)return;const t=(0,_reactNativeReanimated.measure)(m);if(t){const e=R?Math.max(t.pageY,g.value):t.pageY,a=R?Math.min(t.pageY+t.height,N.value):t.pageY+t.height,r=Math.max(0,p.value-t.height-SCROLL_SLACK_PX);O.value<e+EDGE_PX?h.value>SCROLL_SLACK_PX?(0,_reactNativeReanimated.scrollTo)(m,0,Math.max(0,h.value-SCROLL_STEP_PX),!1):R&&j.value>0&&(j.value=Math.max(0,j.value-SCROLL_STEP_PX),(0,_reactNativeWorklets.scheduleOnRN)(k,j.value)):O.value>a-EDGE_PX&&(h.value<r?(0,_reactNativeReanimated.scrollTo)(m,0,Math.min(r,h.value+SCROLL_STEP_PX),!1):R&&j.value<w.value&&(j.value=Math.min(w.value,j.value+SCROLL_STEP_PX),(0,_reactNativeWorklets.scheduleOnRN)(k,j.value)))}I.value=y.value+h.value-f.value+b.value-L.value;const a=dropIndex(T.value,e,I.value);a!==C.value&&(C.value=a,(0,_reactNativeWorklets.scheduleOnRN)(G,a))},!1),q=(0,_react.useCallback)(e=>{(0,_index3.triggerHaptic)("longPress"),Y.setActive(!0),A({key:_[e]??"",from:e,to:e,dragging:!0})},[Y,_]),H=(0,_react.useCallback)((e,t)=>{Y.setActive(!1),A(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&l(moveItem(_,e,t))},[Y,_,l]),X=(0,_react.useCallback)(()=>{A(e=>e&&!e.dragging?null:e)},[]),W=(0,_react.useCallback)((e,t)=>{l(moveItem(_,e,t))},[_,l]),F=(0,_react.useCallback)((e,t)=>{E.current.set(e,t),D()},[D]),K=(0,_reactNativeReanimated.useAnimatedScrollHandler)({onScroll:e=>{"worklet";h.value=e.contentOffset.y}}),U=(0,_react.useCallback)((e,t)=>{p.value=t},[p]),z=(0,_react.useMemo)(()=>({scrollRef:m,scrollY:h,scrollStart:f,hostOffset:b,hostStart:L,hostTarget:j,translation:y,absoluteY:O,dragIndex:P,dropTo:C,dragY:I,heights:T}),[m,h,f,b,L,j,y,O,P,C,I,T]),B=(0,_react.useMemo)(()=>({onLift:q,onDrop:H,onSettled:X,onMove:W,onHeight:F}),[q,H,X,W,F]),$=!0===V?.dragging,J=$&&V?rowShifts(_.map(e=>E.current.get(e)??0),V.from,V.to):null;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.ScrollView,{ref:m,onScroll:K,onContentSizeChange:U,scrollEventThrottle:16,scrollEnabled:!$,accessibilityLabel:n,testID:c,children:v.map((e,t)=>{const a=V?.key===e.key;return(0,_jsxRuntime.jsx)(SortableRow,{rowKey:e.key,index:t,count:v.length,shift:J?.[t]??0,isActive:a,dragging:$,handle:i,disabled:s,shared:z,callbacks:B,labels:d,children:r({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";var _default=exports.default=SortableList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Swipeable=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=n&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?n(r,i,a):r[i]=e[i]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:i,threshold:n,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:c,disabled:l=!1,haptic:o,style:u,contentStyle:d,actionStyle:_,accessibilityLabel:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Swipeable=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=n&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?n(r,i,a):r[i]=e[i]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:i,threshold:n,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:c,disabled:l=!1,haptic:o,style:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:h}=e,p=(0,_index.useTheme)(),v=n??80,N=r??200,b=(0,_react.useMemo)(()=>buildStyles(p),[p]),w=(0,_react.useMemo)(()=>buildActionStyles(p),[p]),f=!!a&&a.length>0,R=!!i&&i.length>0,x=_reactNative.Dimensions.get("window").width,y=f?v*(a?.length??0):0,g=R?v*(i?.length??0):0,S=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_reactNativeReanimated.useSharedValue)(0),I=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(S),(0,_reactNativeReanimated.cancelAnimation)(j)},[S,j]);const O=(0,_react.useCallback)(e=>{I.current!==e&&(I.current=e,s?.(e))},[s]),k=(0,_react.useCallback)(()=>{null!==I.current&&(I.current=null,c?.())},[c]),A=(0,_react.useCallback)(e=>{const t="left"===e?a:i,n=t?.[0];n&&(!1!==o&&(0,_index2.triggerHaptic)("notificationSuccess"),n.onPress(),S.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),I.current=null,c?.())},[a,i,S,c,o]),C=(0,_react.useCallback)(()=>{S.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),k()},[S,k]),G=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(o,"selection");t&&(0,_index2.triggerHaptic)(t),e.onPress(),C()},[C,o]),P=(0,_react.useMemo)(()=>{const e=y,t=g,a=N,i=-N,n=x,r=-x,s=v,c=f,o=R;return{enabled:!l,testID:h?`${h}-gesture`:"swipeable-gesture",activeOffsetX:[-10,10],failOffsetY:[-15,15],onActivate:()=>{"worklet";j.value=S.value},onUpdate:a=>{"worklet";const i=j.value+a.translationX;S.value=i>0&&!c||i<0&&!o?0:i>e&&c?e+.35*(i-e):i<-t&&o?.35*(i+t)-t:i},onDeactivate:()=>{"worklet";const l=S.value;return c&&l>=a?(S.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),void(0,_reactNativeWorklets.scheduleOnRN)(A,"left")):o&&l<=i?(S.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeWorklets.scheduleOnRN)(A,"right")):c&&l>=s?(S.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeWorklets.scheduleOnRN)(O,"left")):o&&l<=-s?(S.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeWorklets.scheduleOnRN)(O,"right")):(S.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeWorklets.scheduleOnRN)(k))}}},[l,j,A,N,f,R,y,k,O,g,x,v,S,h]),D=(0,_reactNativeGestureHandler.usePanGesture)(P),V=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:S.value}]}),...(0,_animatedDeps.webDeps)([S])),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:y>0?Math.min(1,Math.max(0,S.value/y)):0}),...(0,_animatedDeps.webDeps)([y,S])),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:g>0?Math.min(1,Math.max(0,-S.value/g)):0}),...(0,_animatedDeps.webDeps)([g,S])),q=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>{e.push({name:t.key,label:t.label})}),i?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[a,i]),M=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,n=[...a??[],...i??[]].find(e=>e.key===t);n&&(!1!==o&&(0,_index2.triggerHaptic)("selection"),n.onPress())},[a,i,o]);return f||R?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[b.root,u],testID:h,accessibilityLabel:m,accessibilityActions:q,onAccessibilityAction:M,children:[f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[b.actionsRow,b.actionsLeft,{width:y},_,F],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:p,actionStyles:w,width:v,onPress:G},e.key))}):null,R?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[b.actionsRow,b.actionsRight,{width:g},_,T],pointerEvents:"box-none",children:i?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:p,actionStyles:w,width:v,onPress:G},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:D,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[b.content,d,V],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:h,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:i,onPress:n})=>{(0,_assertValidValue.assertValidValue)("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),c=(0,_slotIcon.renderSlotIcon)(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1}),l=Boolean(c);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>n(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:i,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:c}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:[a.label,{color:toneToOnColor(t,r)}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>_reactNative.StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>_reactNative.StyleSheet.create({root:{position:"relative",overflow:"hidden"},content:{backgroundColor:"transparent"},actionsRow:{position:"absolute",top:0,bottom:0,flexDirection:"row"},actionsLeft:{left:0},actionsRight:{right:0,justifyContent:"flex-end"}});var _default=exports.default=Swipeable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.TypingIndicator=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../text/index.js"),_typingIndicatorG=require("../../text/phone/typingIndicator.g.js"),_index2=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,r=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(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=r&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?r(n,a,i):n[a]=e[a]);return n}const DOT=6,DIM=.3,PULSE_MS=400,STAGGER_MS=160,STILL_OPACITY=[1,.65,.3],DOT_NAMES=["first","second","third"],Dot=({index:e,still:t,colour:i,dotStyle:a})=>{const r=(0,_reactNativeReanimated.useSharedValue)(.3);(0,_react.useEffect)(()=>{if(!t)return r.value=(0,_reactNativeReanimated.withDelay)(160*e,(0,_reactNativeReanimated.withRepeat)((0,_reactNativeReanimated.withSequence)((0,_reactNativeReanimated.withTiming)(1,{duration:400}),(0,_reactNativeReanimated.withTiming)(.3,{duration:400})),-1)),()=>(0,_reactNativeReanimated.cancelAnimation)(r)},[t,e,r]);const n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:r.value}),[r]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[a,{backgroundColor:i},t?{opacity:STILL_OPACITY[e]}:n]})},TypingIndicator=({label:e,accessibilityLabel:t,labels:i,bubble:a=!0,style:r,testID:n})=>{const s=(0,_index2.useTheme)(),c=(0,_react.useMemo)(()=>buildStyles(s),[s]),o=(0,_useReducedMotion.useReducedMotion)(),d=s.colors["text-subtle"],l=(0,_index.useMobileUiText)("typingIndicator",_typingIndicatorG.TYPING_INDICATOR_TEXT),u=(0,_react.useMemo)(()=>({...l,...i}),[l,i]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[c.root,a?c.bubble:null,r],accessible:!0,accessibilityRole:"progressbar",accessibilityLabel:e??t??u.typing,accessibilityState:{busy:!0},"aria-busy":!0,testID:n,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.dots,children:DOT_NAMES.map((e,t)=>(0,_jsxRuntime.jsx)(Dot,{index:t,still:o,colour:d,dotStyle:c.dot},e))}),e?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",color:"secondary",children:e}):null]})};exports.TypingIndicator=TypingIndicator;const buildStyles=e=>_reactNative.StyleSheet.create({dot:{width:6,height:6,borderRadius:e.radius.pill,..._corners.smoothCorners},root:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,marginTop:e.space.sm},bubble:{backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.xl,..._corners.smoothCorners,paddingHorizontal:e.space.md,paddingVertical:e.space.sm+e.space.xs},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});var _default=exports.default=TypingIndicator;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.TypingIndicator=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../text/index.js"),_typingIndicatorG=require("../../text/phone/typingIndicator.g.js"),_index2=require("../../theme/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_corners=require("../../utils/corners.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,r=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(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=r&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?r(n,a,i):n[a]=e[a]);return n}const DOT=6,DIM=.3,PULSE_MS=400,STAGGER_MS=160,STILL_OPACITY=[1,.65,.3],DOT_NAMES=["first","second","third"],Dot=({index:e,still:t,colour:i,dotStyle:a})=>{const r=(0,_reactNativeReanimated.useSharedValue)(.3);(0,_react.useEffect)(()=>{if(!t)return r.value=(0,_reactNativeReanimated.withDelay)(160*e,(0,_reactNativeReanimated.withRepeat)((0,_reactNativeReanimated.withSequence)((0,_reactNativeReanimated.withTiming)(1,{duration:400}),(0,_reactNativeReanimated.withTiming)(.3,{duration:400})),-1)),()=>(0,_reactNativeReanimated.cancelAnimation)(r)},[t,e,r]);const n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:r.value}),...(0,_animatedDeps.webDeps)([r]));return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[a,{backgroundColor:i},t?{opacity:STILL_OPACITY[e]}:n]})},TypingIndicator=({label:e,accessibilityLabel:t,labels:i,bubble:a=!0,style:r,testID:n})=>{const s=(0,_index2.useTheme)(),c=(0,_react.useMemo)(()=>buildStyles(s),[s]),o=(0,_useReducedMotion.useReducedMotion)(),d=s.colors["text-subtle"],l=(0,_index.useMobileUiText)("typingIndicator",_typingIndicatorG.TYPING_INDICATOR_TEXT),u=(0,_react.useMemo)(()=>({...l,...i}),[l,i]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[c.root,a?c.bubble:null,r],accessible:!0,accessibilityRole:"progressbar",accessibilityLabel:e??t??u.typing,accessibilityState:{busy:!0},"aria-busy":!0,testID:n,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.dots,children:DOT_NAMES.map((e,t)=>(0,_jsxRuntime.jsx)(Dot,{index:t,still:o,colour:d,dotStyle:c.dot},e))}),e?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",color:"secondary",children:e}):null]})};exports.TypingIndicator=TypingIndicator;const buildStyles=e=>_reactNative.StyleSheet.create({dot:{width:6,height:6,borderRadius:e.radius.pill,..._corners.smoothCorners},root:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,marginTop:e.space.sm},bubble:{backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.xl,..._corners.smoothCorners,paddingHorizontal:e.space.md,paddingVertical:e.space.sm+e.space.xs},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});var _default=exports.default=TypingIndicator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ZoomableImage=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../utils/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,l={__proto__:null,default:e};if(Object(e)!==e)return l;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,l)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(l,r,t):l[r]=e[r]);return l}const DEFAULT_MAX_SCALE=4,DEFAULT_MIN_SCALE=1,DEFAULT_DOUBLE_TAP_SCALE=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ZoomableImage=({children:e,maxScale:a=4,minScale:t=1,doubleTapScale:r=2,disabled:i=!1,haptic:l,style:n,accessibilityLabel:u,testID:c})=>{const s=(0,_reactNativeReanimated.useSharedValue)(1),v=(0,_reactNativeReanimated.useSharedValue)(1),d=(0,_reactNativeReanimated.useSharedValue)(0),o=(0,_reactNativeReanimated.useSharedValue)(0),_=(0,_reactNativeReanimated.useSharedValue)(0),m=(0,_reactNativeReanimated.useSharedValue)(0),N=(0,_react.useCallback)(()=>{s.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),v.value=1,d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=0,m.value=0},[s,v,d,o,_,m]);(0,_react.useEffect)(()=>{i&&N()},[i,N]);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ZoomableImage=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,l={__proto__:null,default:e};if(Object(e)!==e)return l;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,l)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(l,r,t):l[r]=e[r]);return l}const DEFAULT_MAX_SCALE=4,DEFAULT_MIN_SCALE=1,DEFAULT_DOUBLE_TAP_SCALE=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ZoomableImage=({children:e,maxScale:a=4,minScale:t=1,doubleTapScale:r=2,disabled:i=!1,haptic:l,style:n,accessibilityLabel:u,testID:c})=>{const s=(0,_reactNativeReanimated.useSharedValue)(1),v=(0,_reactNativeReanimated.useSharedValue)(1),d=(0,_reactNativeReanimated.useSharedValue)(0),o=(0,_reactNativeReanimated.useSharedValue)(0),_=(0,_reactNativeReanimated.useSharedValue)(0),m=(0,_reactNativeReanimated.useSharedValue)(0),N=(0,_react.useCallback)(()=>{s.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),v.value=1,d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=0,m.value=0},[s,v,d,o,_,m]);(0,_react.useEffect)(()=>{i&&N()},[i,N]);const p=(0,_react.useCallback)(()=>{const e=(0,_index.resolveHaptic)(l,"impactLight");e&&(0,_index.triggerHaptic)(e)},[l]),h=(0,_react.useMemo)(()=>({enabled:!i,onActivate:()=>{"worklet";v.value=s.value},onUpdate:e=>{"worklet";const r=v.value*e.scale;s.value=r<t?t+.3*(r-t):r>a?a+.2*(r-a):r},onDeactivate:()=>{"worklet";return s.value<t?(s.value=(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG),d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),v.value=t,_.value=0,void(m.value=0)):s.value>a?(s.value=(0,_reactNativeReanimated.withSpring)(a,SPRING_CONFIG),void(v.value=a)):void(v.value=s.value)}}),[i,s,v,d,o,_,m,t,a]),R=(0,_reactNativeGestureHandler.usePinchGesture)(h),S=(0,_react.useMemo)(()=>({enabled:!i,minPointers:1,maxPointers:1,onActivate:()=>{"worklet";_.value=d.value,m.value=o.value},onUpdate:e=>{"worklet";s.value<=1||(d.value=_.value+e.translationX,o.value=m.value+e.translationY)},onDeactivate:()=>{"worklet";_.value=d.value,m.value=o.value}}),[i,s,d,o,_,m]),I=(0,_reactNativeGestureHandler.usePanGesture)(S),G=(0,_react.useMemo)(()=>({enabled:!i,numberOfTaps:2,onDeactivate:()=>{"worklet";(0,_reactNativeWorklets.scheduleOnRN)(p),s.value>1?(s.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),v.value=1,_.value=0,m.value=0):(s.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),v.value=r)}}),[i,s,v,d,o,_,m,p,r]),g=(0,_reactNativeGestureHandler.useTapGesture)(G),b=(0,_reactNativeGestureHandler.useCompetingGestures)(R,I,g),f=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:d.value},{translateY:o.value},{scale:s.value}]}),...(0,_animatedDeps.webDeps)([d,o,s]));return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:b,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.container,n],testID:c,accessibilityLabel:u,accessibilityState:{disabled:i},"aria-disabled":i,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.content,f],children:e})})})};exports.ZoomableImage=ZoomableImage,ZoomableImage.displayName="ZoomableImage";const styles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center",overflow:"hidden"},content:{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"}});var _default=exports.default=ZoomableImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.toBackgroundImage=exports.gradientAngle=exports.Gradient=void 0;var _reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_START={x:.5,y:0},DEFAULT_END={x:.5,y:1},round=e=>Math.round(1e3*e)/1e3,gradientAngle=(e=DEFAULT_START,t=DEFAULT_END)=>{const r=180*Math.atan2(t.x-e.x,e.y-t.y)/Math.PI;return round((r%360+360)%360)};exports.gradientAngle=gradientAngle;const toBackgroundImage=e=>{const t=e.colors.length-1;return{type:"linear-gradient",direction:`${gradientAngle(e.start,e.end)}deg`,colorStops:e.colors.map((r,n)=>{const o=e.locations?.[n]??(0===t?0:n/t);return{color:r,positions:[`${round(100*o)}%`]}})}};exports.toBackgroundImage=toBackgroundImage;const Gradient=({gradient:e,style:t,children:r})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.toBackgroundImage=exports.gradientAngle=exports.Gradient=void 0;var _reactNative=require("react-native"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_START={x:.5,y:0},DEFAULT_END={x:.5,y:1},round=e=>Math.round(1e3*e)/1e3,gradientAngle=(e=DEFAULT_START,t=DEFAULT_END)=>{const r=180*Math.atan2(t.x-e.x,e.y-t.y)/Math.PI;return round((r%360+360)%360)};exports.gradientAngle=gradientAngle;const toBackgroundImage=e=>{const t=e.colors.length-1;return{type:"linear-gradient",direction:`${gradientAngle(e.start,e.end)}deg`,colorStops:e.colors.map((r,n)=>{const o=e.locations?.[n]??(0===t?0:n/t);return{color:r,positions:[`${round(100*o)}%`]}})}};exports.toBackgroundImage=toBackgroundImage;const Gradient=({gradient:e,style:t,children:r})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{backgroundImage:[toBackgroundImage(e)]},t],children:r});exports.Gradient=Gradient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.lightTokens=exports.darkTokens=exports.WEIGHT_NAMES=exports.TEXT_NAMES=exports.SPACE_NAMES=exports.SIZE_NAMES=exports.SHADOW_NAMES=exports.RADIUS_NAMES=exports.LETTER_SPACING_NAMES=exports.LEADING_NAMES=exports.FONT_NAMES=exports.EASE_NAMES=exports.DURATION_NAMES=exports.COMPONENT_KINDS=exports.COLOR_NAMES=void 0;const COLOR_NAMES=exports.COLOR_NAMES=["bg","bg-subtle","bg-muted","surface","surface-inverse","surface-dark","surface-dark-border","on-surface-dark","on-surface-dark-muted","surface-ink","text","text-body","text-muted","text-subtle","text-inverse","link","border","border-subtle","field-bg","field-border","field-border-focus","focus-ring","scrim","on-scrim","thumb","primary","primary-hover","primary-soft","primary-text","on-primary","primary-wash","primary-wash-strong","neutral","neutral-hover","neutral-text","on-neutral","success","success-soft","success-text","on-success","warning","warning-soft","warning-text","on-warning","danger","danger-soft","danger-border","danger-text","offline-fill","online-fill","on-danger","info","info-soft","info-text","on-info","primary-pressed","switch-thumb","on-neutral-strong","text-disabled","surface-pressed","surface-hover","surface-selected","surface-disabled","skeleton","skeleton-highlight","glass-fill","glass-border","on-glass","glass-badge","field-bg-focus","field-bg-disabled","field-border-error","field-label","field-text","field-text-disabled","field-placeholder","field-placeholder-disabled","field-icon","field-icon-focus","field-icon-disabled","field-caret","field-message","avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],SPACE_NAMES=exports.SPACE_NAMES=["none","xxs","xs","sm","md","lg","xl","2xl","3xl","4xl"],RADIUS_NAMES=exports.RADIUS_NAMES=["none","sm","md","lg","xl","2xl","3xl","pill"],TEXT_NAMES=exports.TEXT_NAMES=["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl"],WEIGHT_NAMES=exports.WEIGHT_NAMES=["normal","medium","semibold","bold"],LEADING_NAMES=exports.LEADING_NAMES=["heading","body","display"],LETTER_SPACING_NAMES=exports.LETTER_SPACING_NAMES=["tight","normal","wide"],FONT_NAMES=exports.FONT_NAMES=["ui","display","mono"],SHADOW_NAMES=exports.SHADOW_NAMES=["card","elevated","popover","modal","drawer"],DURATION_NAMES=exports.DURATION_NAMES=["instant","fast","default","slow","slower"],EASE_NAMES=exports.EASE_NAMES=["in-out","accelerate","decelerate","sharp"],SIZE_NAMES=exports.SIZE_NAMES=["border"],COMPONENT_KINDS=exports.COMPONENT_KINDS={field:{radius:"radius","padding-x":"space","padding-y":"space","min-height":"px",text:"text",icon:"px","label-text":"text","label-gap":"space","message-text":"text","message-gap":"space"},press:{opacity:"number"},disabled:{opacity:"number"},button:{"padding-x":"space","padding-y":"space","min-height":"px",text:"text",radius:"radius",icon:"px","badge-icon":"px"},input:{"multiline-min-height":"px"},"search-bar":{radius:"radius"},"empty-state":{icon:"px","illustration-size":"px","title-text":"text","description-text":"text","padding-y":"space","title-gap":"space","description-gap":"space"},"list-item":{"padding-y":"space","title-text":"text","subtitle-text":"text","min-height":"px"},badge:{text:"text","min-width":"px",height:"px","padding-x":"space","dot-size":"px","border-width":"px","anchor-offset":"px"},chip:{"padding-x":"space","padding-y":"space",text:"text","min-height":"px","close-size":"px","close-text":"text",gap:"space",icon:"px"},checkbox:{"box-size":"px","label-gap":"space"},radio:{outer:"px",inner:"px","label-gap":"space"},switch:{"track-width":"px","track-height":"px","thumb-size":"px",padding:"space"},"otp-input":{cell:"px",text:"text",radius:"radius",gap:"space"},"segmented-control":{height:"px",text:"text","padding-x":"space",icon:"px","track-padding":"space","underline-height":"px","pill-inset":"space"},tabs:{text:"text","padding-y":"space","padding-x":"space","scrollable-padding-x":"space",icon:"px","icon-gap":"space","track-padding":"space","underline-height":"px","pill-inset":"space","disabled-opacity":"number","badge-gap":"space"},slider:{"track-height":"px","thumb-diameter":"px"},"floating-action-button":{diameter:"px",icon:"px",text:"text","label-padding-x":"space","edge-offset":"space","bottom-offset":"space","secondary-gap":"space","stagger-ms":"ms"},dialog:{"icon-wrapper-size":"px","action-button-min-height":"px"},toast:{"icon-circle-size":"px","icon-glyph-text":"text","tint-bar-width":"px","action-min-height":"px"},banner:{"tint-bar-width":"px"},screen:{gutter:"space"}},lightTokens=exports.lightTokens={mode:"light",colors:{bg:"#ffffff","bg-subtle":"#f8f8fb","bg-muted":"#f1f1f5",surface:"#ffffff","surface-inverse":"#0f0f1a","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7","surface-ink":"#0b0e16",text:"#252f4a","text-body":"#0f0f1a","text-muted":"#52525b","text-subtle":"#62626b","text-inverse":"#ffffff",link:"#4f46e5",border:"#e5e5ec","border-subtle":"#efeff3","field-bg":"#f9fbfc","field-border":"#ebedf3","field-border-focus":"#bed2f9","focus-ring":"#4f46e5",scrim:"#0f0f1a80","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#4f46e5","primary-hover":"#4338ca","primary-soft":"#e0e7ff","primary-text":"#4f46e5","on-primary":"#ffffff","primary-wash":"#4f46e514","primary-wash-strong":"#4f46e533",neutral:"#f4f4f8","neutral-hover":"#e9e9f0","neutral-text":"#52525b","on-neutral":"#0f0f1a",success:"#18864f","success-soft":"#e8faee","success-text":"#147042","on-success":"#ffffff",warning:"#f59e0b","warning-soft":"#fff8e6","warning-text":"#8f5c06","on-warning":"#0f0f1a",danger:"#e12c32","danger-soft":"#ffeaef","danger-border":"#e5484d","danger-text":"#bc1b20","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#ffffff",info:"#1b6ef5","info-soft":"#e9f3ff","info-text":"#0958d9","on-info":"#ffffff","primary-pressed":"#3730a3","switch-thumb":"#ffffff","on-neutral-strong":"#ffffff","text-disabled":"#b4b4bb","surface-pressed":"#0f0f1a0f","surface-hover":"#0f0f1a0a","surface-selected":"#4f46e51a","surface-disabled":"#f1f1f5",skeleton:"#ebedf3","skeleton-highlight":"#f5f6fa","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#ffffff","field-bg-disabled":"#f5f6fa","field-border-error":"#fdbfce","field-label":"#242f4a","field-text":"#252f4a","field-text-disabled":"#7a8197","field-placeholder":"#626d8b","field-placeholder-disabled":"#7a8197","field-icon":"#7a849f","field-icon-focus":"#4b5675","field-icon-disabled":"#c4cada","field-caret":"#5b8dee","field-message":"#d81736","avatar-1":"#4f46e5","avatar-2":"#0a7979","avatar-3":"#a45a05","avatar-4":"#cd226e","avatar-5":"#2462eb","avatar-6":"#7c3aed","avatar-7":"#047c57","avatar-8":"#d42222"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,"2xl":18,"3xl":20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.059,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.078,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.102,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":35,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":40,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"sm","min-height":45,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}},darkTokens=exports.darkTokens={mode:"dark",colors:{bg:"#0b0b12","bg-subtle":"#13131c","bg-muted":"#1c1c26",surface:"#1c1c26","surface-inverse":"#fafafa","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7","surface-ink":"#0b0e16",text:"#e2e2e2","text-body":"#fafafa","text-muted":"#b4b4bb","text-subtle":"#919199","text-inverse":"#0f0f1a",link:"#9292ee",border:"#27272f","border-subtle":"#1c1c26","field-bg":"#13131c","field-border":"#27272f","field-border-focus":"#3d5fb0","focus-ring":"#7c7ce8",scrim:"#000000a6","on-scrim":"#ffffff",thumb:"#3a3e49",primary:"#7c7ce8","primary-hover":"#9292ee","primary-soft":"#1f1f3d","primary-text":"#8989ea","on-primary":"#0f0f1a","primary-wash":"#7c7ce814","primary-wash-strong":"#7c7ce833",neutral:"#1f1f26","neutral-hover":"#2a2a33","neutral-text":"#b4b4bb","on-neutral":"#fafafa",success:"#30c780","success-soft":"#04b4402e","success-text":"#30c780","on-success":"#0f0f1a",warning:"#fbbf24","warning-soft":"#dfa0002e","warning-text":"#fbbf24","on-warning":"#0f0f1a",danger:"#f87171","danger-soft":"#e826462e","danger-border":"#f87171","danger-text":"#f87171","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#0f0f1a",info:"#60a5fa","info-soft":"#056ee92e","info-text":"#60a5fa","on-info":"#0f0f1a","primary-pressed":"#a8a8f2","switch-thumb":"#ffffff","on-neutral-strong":"#0f0f1a","text-disabled":"#52525b","surface-pressed":"#ffffff14","surface-hover":"#ffffff0d","surface-selected":"#7c7ce82e","surface-disabled":"#1c1c26",skeleton:"#1c1c26","skeleton-highlight":"#27272f","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#0b0b12","field-bg-disabled":"#1c1c26","field-border-error":"#8a2f42","field-label":"#e4e6ee","field-text":"#fafafa","field-text-disabled":"#71717a","field-placeholder":"#84848d","field-placeholder-disabled":"#71717a","field-icon":"#8b8b95","field-icon-focus":"#d4d4db","field-icon-disabled":"#52525b","field-caret":"#7c9ef0","field-message":"#f87171","avatar-1":"#8b8bee","avatar-2":"#2dd4bf","avatar-3":"#fcd34d","avatar-4":"#f472b6","avatar-5":"#60a5fa","avatar-6":"#a78bfa","avatar-7":"#34d399","avatar-8":"#f87171"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,"2xl":18,"3xl":20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.4,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.502,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.549,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":35,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":40,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"sm","min-height":45,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.lightTokens=exports.darkTokens=exports.WEIGHT_NAMES=exports.TEXT_NAMES=exports.SPACE_NAMES=exports.SIZE_NAMES=exports.SHADOW_NAMES=exports.RADIUS_NAMES=exports.LETTER_SPACING_NAMES=exports.LEADING_NAMES=exports.FONT_NAMES=exports.EASE_NAMES=exports.DURATION_NAMES=exports.COMPONENT_KINDS=exports.COLOR_NAMES=void 0;const COLOR_NAMES=exports.COLOR_NAMES=["bg","bg-subtle","bg-muted","surface","surface-inverse","surface-dark","surface-dark-border","on-surface-dark","on-surface-dark-muted","surface-ink","text","text-body","text-muted","text-subtle","text-inverse","link","border","border-subtle","field-bg","field-border","field-border-focus","focus-ring","scrim","on-scrim","thumb","primary","primary-hover","primary-pressed","primary-soft","primary-text","on-primary","primary-wash","primary-wash-strong","neutral","neutral-hover","neutral-text","on-neutral","success","success-soft","success-text","on-success","warning","warning-soft","warning-text","on-warning","danger","danger-soft","danger-border","danger-text","offline-fill","online-fill","on-danger","info","info-soft","info-text","on-info","switch-thumb","on-neutral-strong","text-disabled","surface-pressed","surface-hover","surface-selected","surface-disabled","skeleton","skeleton-highlight","glass-fill","glass-border","on-glass","glass-badge","field-bg-focus","field-bg-disabled","field-border-error","field-label","field-text","field-text-disabled","field-placeholder","field-placeholder-disabled","field-icon","field-icon-focus","field-icon-disabled","field-caret","field-message","avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],SPACE_NAMES=exports.SPACE_NAMES=["none","xxs","xs","sm","md","lg","xl","2xl","3xl","4xl"],RADIUS_NAMES=exports.RADIUS_NAMES=["none","sm","md","lg","xl","2xl","3xl","pill"],TEXT_NAMES=exports.TEXT_NAMES=["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl"],WEIGHT_NAMES=exports.WEIGHT_NAMES=["normal","medium","semibold","bold"],LEADING_NAMES=exports.LEADING_NAMES=["heading","body","display"],LETTER_SPACING_NAMES=exports.LETTER_SPACING_NAMES=["tight","normal","wide"],FONT_NAMES=exports.FONT_NAMES=["ui","display","mono"],SHADOW_NAMES=exports.SHADOW_NAMES=["card","elevated","popover","modal","drawer"],DURATION_NAMES=exports.DURATION_NAMES=["instant","fast","default","slow","slower"],EASE_NAMES=exports.EASE_NAMES=["in-out","accelerate","decelerate","sharp"],SIZE_NAMES=exports.SIZE_NAMES=["border"],COMPONENT_KINDS=exports.COMPONENT_KINDS={field:{radius:"radius","padding-x":"space","padding-y":"space","min-height":"px",text:"text",icon:"px","label-text":"text","label-gap":"space","message-text":"text","message-gap":"space"},press:{opacity:"number"},disabled:{opacity:"number"},button:{"padding-x":"space","padding-y":"space","min-height":"px",text:"text",radius:"radius",icon:"px","badge-icon":"px"},input:{"multiline-min-height":"px"},"search-bar":{radius:"radius"},"empty-state":{icon:"px","illustration-size":"px","title-text":"text","description-text":"text","padding-y":"space","title-gap":"space","description-gap":"space"},"list-item":{"padding-y":"space","title-text":"text","subtitle-text":"text","min-height":"px"},badge:{text:"text","min-width":"px",height:"px","padding-x":"space","dot-size":"px","border-width":"px","anchor-offset":"px"},chip:{"padding-x":"space","padding-y":"space",text:"text","min-height":"px","close-size":"px","close-text":"text",gap:"space",icon:"px"},checkbox:{"box-size":"px","label-gap":"space"},radio:{outer:"px",inner:"px","label-gap":"space"},switch:{"track-width":"px","track-height":"px","thumb-size":"px",padding:"space"},"otp-input":{cell:"px",text:"text",radius:"radius",gap:"space"},"segmented-control":{height:"px",text:"text","padding-x":"space",icon:"px","track-padding":"space","underline-height":"px","pill-inset":"space"},tabs:{text:"text","padding-y":"space","padding-x":"space","scrollable-padding-x":"space",icon:"px","icon-gap":"space","track-padding":"space","underline-height":"px","pill-inset":"space","disabled-opacity":"number","badge-gap":"space"},slider:{"track-height":"px","thumb-diameter":"px"},"floating-action-button":{diameter:"px",icon:"px",text:"text","label-padding-x":"space","edge-offset":"space","bottom-offset":"space","secondary-gap":"space","stagger-ms":"ms"},dialog:{"icon-wrapper-size":"px","action-button-min-height":"px"},toast:{"icon-circle-size":"px","icon-glyph-text":"text","tint-bar-width":"px","action-min-height":"px"},banner:{"tint-bar-width":"px"},screen:{gutter:"space"}},lightTokens=exports.lightTokens={mode:"light",colors:{bg:"#ffffff","bg-subtle":"#f8f8fb","bg-muted":"#f1f1f5",surface:"#ffffff","surface-inverse":"#0f0f1a","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7","surface-ink":"#0b0e16",text:"#252f4a","text-body":"#0f0f1a","text-muted":"#52525b","text-subtle":"#62626b","text-inverse":"#ffffff",link:"#4f46e5",border:"#e5e5ec","border-subtle":"#efeff3","field-bg":"#f9fbfc","field-border":"#ebedf3","field-border-focus":"#bed2f9","focus-ring":"#4f46e5",scrim:"#0f0f1a80","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#4f46e5","primary-hover":"#4338ca","primary-pressed":"#3730a3","primary-soft":"#e0e7ff","primary-text":"#4f46e5","on-primary":"#ffffff","primary-wash":"#4f46e514","primary-wash-strong":"#4f46e533",neutral:"#f4f4f8","neutral-hover":"#e9e9f0","neutral-text":"#52525b","on-neutral":"#0f0f1a",success:"#18864f","success-soft":"#e8faee","success-text":"#147042","on-success":"#ffffff",warning:"#f59e0b","warning-soft":"#fff8e6","warning-text":"#8f5c06","on-warning":"#0f0f1a",danger:"#e12c32","danger-soft":"#ffeaef","danger-border":"#e5484d","danger-text":"#bc1b20","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#ffffff",info:"#1b6ef5","info-soft":"#e9f3ff","info-text":"#0958d9","on-info":"#ffffff","switch-thumb":"#ffffff","on-neutral-strong":"#ffffff","text-disabled":"#b4b4bb","surface-pressed":"#0f0f1a0f","surface-hover":"#0f0f1a0a","surface-selected":"#4f46e51a","surface-disabled":"#f1f1f5",skeleton:"#ebedf3","skeleton-highlight":"#f5f6fa","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#ffffff","field-bg-disabled":"#f5f6fa","field-border-error":"#fdbfce","field-label":"#242f4a","field-text":"#252f4a","field-text-disabled":"#7a8197","field-placeholder":"#626d8b","field-placeholder-disabled":"#7a8197","field-icon":"#7a849f","field-icon-focus":"#4b5675","field-icon-disabled":"#c4cada","field-caret":"#5b8dee","field-message":"#d81736","avatar-1":"#4f46e5","avatar-2":"#0a7979","avatar-3":"#a45a05","avatar-4":"#cd226e","avatar-5":"#2462eb","avatar-6":"#7c3aed","avatar-7":"#047c57","avatar-8":"#d42222"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,"2xl":18,"3xl":20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.059,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.078,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.102,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":35,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":40,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"sm","min-height":45,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}},darkTokens=exports.darkTokens={mode:"dark",colors:{bg:"#0b0b12","bg-subtle":"#13131c","bg-muted":"#1c1c26",surface:"#1c1c26","surface-inverse":"#fafafa","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7","surface-ink":"#0b0e16",text:"#e2e2e2","text-body":"#fafafa","text-muted":"#b4b4bb","text-subtle":"#919199","text-inverse":"#0f0f1a",link:"#9292ee",border:"#27272f","border-subtle":"#1c1c26","field-bg":"#13131c","field-border":"#27272f","field-border-focus":"#3d5fb0","focus-ring":"#7c7ce8",scrim:"#000000a6","on-scrim":"#ffffff",thumb:"#3a3e49",primary:"#7c7ce8","primary-hover":"#9292ee","primary-pressed":"#a8a8f2","primary-soft":"#1f1f3d","primary-text":"#8989ea","on-primary":"#0f0f1a","primary-wash":"#7c7ce814","primary-wash-strong":"#7c7ce833",neutral:"#1f1f26","neutral-hover":"#2a2a33","neutral-text":"#b4b4bb","on-neutral":"#fafafa",success:"#30c780","success-soft":"#04b4402e","success-text":"#30c780","on-success":"#0f0f1a",warning:"#fbbf24","warning-soft":"#dfa0002e","warning-text":"#fbbf24","on-warning":"#0f0f1a",danger:"#f87171","danger-soft":"#e826462e","danger-border":"#f87171","danger-text":"#f87171","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#0f0f1a",info:"#60a5fa","info-soft":"#056ee92e","info-text":"#60a5fa","on-info":"#0f0f1a","switch-thumb":"#ffffff","on-neutral-strong":"#0f0f1a","text-disabled":"#52525b","surface-pressed":"#ffffff14","surface-hover":"#ffffff0d","surface-selected":"#7c7ce82e","surface-disabled":"#1c1c26",skeleton:"#1c1c26","skeleton-highlight":"#27272f","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#0b0b12","field-bg-disabled":"#1c1c26","field-border-error":"#8a2f42","field-label":"#e4e6ee","field-text":"#fafafa","field-text-disabled":"#71717a","field-placeholder":"#84848d","field-placeholder-disabled":"#71717a","field-icon":"#8b8b95","field-icon-focus":"#d4d4db","field-icon-disabled":"#52525b","field-caret":"#7c9ef0","field-message":"#f87171","avatar-1":"#8b8bee","avatar-2":"#2dd4bf","avatar-3":"#fcd34d","avatar-4":"#f472b6","avatar-5":"#60a5fa","avatar-6":"#a78bfa","avatar-7":"#34d399","avatar-8":"#f87171"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,"2xl":18,"3xl":20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.4,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.502,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.549,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":35,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":40,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"sm","min-height":45,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.webDeps=void 0;var _reactNative=require("react-native");const webDeps=e=>"web"===_reactNative.Platform.OS?[e]:[];exports.webDeps=webDeps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{createContext,useCallback,useContext,useEffect,useLayoutEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,useAnimatedReaction,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{BOTTOM_SHEET_TEXT}from"../../text/phone/bottomSheet.g.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:a,onSnapChange:r,onAnimate:n,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:b,onContentSizeChange:p,onScrollLayout:S,scrollEventThrottle:v,keyboardBehavior:g="shift",inline:y=!1,presentation:x="sheet",animateMount:w=!0,handleIndicatorStyle:C,sheetStyle:M,header:R,actions:_,actionsLayout:T="auto",footer:O,headerStyle:E,footerStyle:k,children:I,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMobileUiText("bottomSheet",BOTTOM_SHEET_TEXT),N=useMemo(()=>({...D,...h}),[D,h]),B=null!=R||null!=d,P=null!=_&&_.length>0,L=null!=O||P,H=y?"inline":"modal",G=useTheme(),F=usePresenceMotion(),U=useSafeAreaInsets(),Y="modal"===H&&"android"===Platform.OS,[K,$]=useState(()=>Dimensions.get(Y?"screen":"window").height),[z,X]=useState(()=>Dimensions.get(Y?"screen":"window").width),W=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;Y&&Math.abs(t-Dimensions.get("window").height)<1&&t<Dimensions.get("screen").height-1||(t>0&&$(e=>e===t?e:t),o>0&&X(e=>e===o?e:o))},[Y]),q=useWindowDimensions(),J="dialog"===x||"auto"===x&&Math.min(q.width,q.height)>=600,Q=Math.min(560,z-2*G.space.xl),[Z,ee]=useModalInsets(),te="modal"===H?Z.top:U.top,oe="modal"===H?Z.bottom:U.bottom,se=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,le]=useMeasuredHeight(),[ie,ue,ce]=useMeasuredHeight(),[de,he]=useMeasuredHeight(),me=J?G.space.md:ae,fe=se?Math.min(me+(B?ne:0)+ie+(L?de:0)+oe,K-te):0,be=useCallback((e,t)=>{se&&ce(t),p?.(e,t)},[se,p,ce]),pe=useMemo(()=>resolveSnapPoints(t,K,fe),[t,K,fe]),Se=K,ve=pe[pe.length-1]??0,ge=useSharedValue(Se),ye=useSharedValue(Se),xe=useSharedValue(1),we=useSharedValue(-1),[Ce,Me]=useState(-1),[Re,Te]=useState(!1),[Oe,Ee]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[Ae,je]=useState(!1),Ve=useRef(!w&&o),De=useRef(-1),Ne=useRef(!1);Ne.current="modal"===H?Oe:Ae;const Be=useRef(c);Be.current=c;const Pe=useRef(s);Pe.current=s;const Le=useRef(!1),He=useRef(!0),Ge=useRef([]),Fe=useCallback(e=>{const t=Ge.current;Ge.current=[];for(const o of t)o(e)},[]);useEffect(()=>(He.current=!0,()=>{He.current=!1,Fe(!1)}),[Fe]);const Ue=useCallback(e=>{if(e<0||e>=pe.length)return Se;const t=pe[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return J?(K-t)/2:K-t},[pe,K,Se,J]),Ye=useCallback(e=>{De.current=e;Ce!==e&&(Me(e),we.value=e,e>=0&&r?.(e))},[Ce,we,r]),Ke=useCallback(()=>{we.value<0&&(ke.current=!0,"modal"===H?(Te(!1),"ios"!==Platform.OS&&Ee(!1)):je(!1))},[H,we]),$e=useCallback(()=>{ke.current&&Ee(!1)},[]);useEffect(()=>{("modal"===H?!Oe:!Ae)&&ke.current&&(ke.current=!1,Ie.current?.(),Fe(!0))},[H,Oe,Ae,Fe]);const ze=useCallback((e,t,o)=>{n?.(t,o),ge.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(Ke)})},[n,ge,Ke]),Xe=useRef(null),We=useCallback(e=>{const t="number"==typeof e?clamp(e,0,pe.length-1):Math.max(Ce,0),o=we.value,s=Ue(t);return ke.current=!1,Fe(!1),"modal"===H?(Ee(!0),Te(!0)):je(!0),o<0&&Ve.current?(ge.value=s,xe.value=1,Ye(t),void n?.(o,t)):o<0&&F.reduced?(ge.value=s,xe.value=0,xe.value=withTiming(1,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ye(t),void n?.(o,t)):(o<0&&(ge.value=Se,xe.value=1),Ye(t),void(o<0&&t>=0&&!Ne.current?Xe.current={fromIndex:o,target:t}:ze(s,o,t)))},[ze,Se,Ce,we,H,n,F,xe,pe.length,Ye,Fe,G.motion.ease.decelerate,ge,Ue]),qe=useCallback(()=>new Promise(e=>{if(De.current<0)return void(Ne.current?Ge.current.push(e):e(!0));Ge.current.push(e),Ve.current=!1,Xe.current=null;const t=we.value;Ye(-1),n?.(t,-1);const o=F.reduced?xe:ge,s=F.reduced?0:Se;o.value=withTiming(s,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(Ke)})}),[Se,we,Ke,n,F,xe,Ye,ge,G.motion.ease.accelerate]),Je=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Le.current)return void t?.();const a=s();"boolean"!=typeof a?(Le.current=!0,o?.(),a.then(o=>{Le.current=!1,o&&He.current&&De.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(a?e:t)?.()},[]),Qe=useCallback(()=>new Promise(e=>{De.current<0?e(!0):Je(()=>{Pe.current(),qe(),e(!0)},()=>e(!1))}),[qe,Je]),Ze=useCallback(()=>{Pe.current()},[]),et=useCallback(()=>{u&&Qe()},[u,Qe]),tt=useRef(null),ot=useRef(We);ot.current=We;const st=useRef(qe);st.current=qe,useLayoutEffect(()=>{const e=tt.current!==o;tt.current=o,e?o?ot.current(a??0):st.current():o&&"number"==typeof a&&a!==we.value&&ot.current(a)},[o,a,we]);const at=useRef({hostHeight:K,contentSnap:fe}),rt=useRef(Ue);rt.current=Ue,useEffect(()=>{const e=at.current;if(e.hostHeight===K&&e.contentSnap===fe)return;if(at.current={hostHeight:K,contentSnap:fe},e.hostHeight===K&&we.value<0)return;const t=rt.current(we.value);ge.value=Ve.current?t:withSpring(t,SPRING_CONFIG)},[K,fe,we,ge]);const nt="modal"===H?Oe:Ae;useLayoutEffect(()=>{const e=Xe.current;null!==e&&nt&&(Xe.current=null,De.current===e.target&&ze(rt.current(e.target),e.fromIndex,e.target))},[nt,ze]);const lt=K-ve,it=useMemo(()=>pe.map(e=>K-e),[pe,K]),ut=useCallback(()=>{const e=De.current;e<0||ze(Ue(e),e,e)},[ze,Ue]),ct=useCallback((e,t)=>{const o=we.value;-1!==e?(Ye(e),ze(t,o,e)):Je(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Pe.current(),qe()},ut,ut)},[ze,qe,we,Je,Ye,ut]),dt=useMemo(()=>({testID:V?`${V}-content-gesture`:"bottom-sheet-content-gesture"}),[V]),ht=useNativeGesture(dt),mt=useMemo(()=>{const e=it,t=Se,o=lt,s=i;return{testID:V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ye.value=ge.value},onUpdate:e=>{"worklet";const t=ye.value+e.translationY;ge.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const a=ge.value,r=o.velocityY,[n]=e;if(void 0===n)return void scheduleOnRN(ct,-1,t);if(r>1e3)return s?void scheduleOnRN(ct,-1,t):void scheduleOnRN(ct,0,n);let l=0,i=n,u=1/0,c=0;for(const t of e){const e=Math.abs(a-t);e<u&&(u=e,i=t,l=c),c++}s&&a-n>80?scheduleOnRN(ct,-1,t):scheduleOnRN(ct,l,i)}}},[Se,ye,i,ct,lt,it,V,ge]),ft=usePanGesture(mt),{height:bt,progress:pt}=useReanimatedKeyboardAnimation(),St="shift"===g,vt=useDerivedValue(()=>St?bt.value:0,[St,bt]),gt=useSharedValue(0);useAnimatedReaction(()=>St&&pt.value>=1?bt.value:0,e=>{gt.value=e},[St,bt,pt,gt]);const yt=pe[Math.max(Ce,0)]??ve,xt=G.space.md,wt=useAnimatedStyle(()=>{const e=vt.value;if(J){const t=K+e-yt-xt,o=e<0&&ge.value>t?t:ge.value;return{top:ge.value,transform:[{translateY:Math.max(o,te)-ge.value}],opacity:xe.value}}const t=e<0?te:lt,o=Math.max(ge.value+e,t);return{top:ge.value,transform:[{translateY:o-ge.value}],opacity:xe.value}},[J,vt,K,yt,xt,ge,te,xe,lt]),Ct=useAnimatedStyle(()=>{const e=gt.value;if(J){const t=K+e-yt-xt,o=e<0&&ge.value>t?t:ge.value,s=Math.max(o,te),a=K+e-xt-s;return{height:a<0?0:Math.min(a,yt)}}const t=e<0?te:lt,o=Math.max(ge.value+e,t),s=K+e-o;return{height:s<0?0:Math.min(s,ve)}},[gt,J,K,yt,xt,ge,te,lt,ve]),Mt=Ce>=0,Rt=useMemo(()=>buildStyles(G),[G]),_t=useCallback(()=>{u&&Je(()=>{triggerHaptic("selection"),Pe.current(),qe()})},[u,qe,Je]),Tt=useMemo(()=>({testID:V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(_t)}}),[_t,V]),Ot=useTapGesture(Tt),Et=useMemo(()=>({snapIndex:Ce,snapPoints:pe,close:Ze,requestClose:Qe}),[Ce,pe,Ze,Qe]);if("inline"===H&&!Ae)return null;if("modal"===H&&!Oe)return null;const kt=_jsxs(View,{collapsable:!1,style:["modal"===H?Rt.backdropModal:Rt.backdropInline,{backgroundColor:"modal"===H?transparentOf(G.colors.scrim):G.colors.scrim}],onLayout:W,testID:V,accessibilityViewIsModal:j??Mt,children:[_jsx(GestureDetector,{gesture:Ot,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:N.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??Mt,accessibilityActions:[{name:"escape",label:N.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&et()},onAccessibilityEscape:et,style:[Rt.sheet,{height:ve,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,...smoothCorners,...G.shadow.modal},J?{height:yt,left:(z-Q)/2,right:void 0,width:Q,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,M,wt],children:_jsxs(SheetBody,{style:[Rt.body,Ct],settledKeyboardOffset:gt,children:[J?_jsx(View,{style:{height:G.space.md}}):_jsx(GestureDetector,{gesture:ft,children:_jsx(View,{style:Rt.handleRow,onLayout:se?re:void 0,accessible:!0,accessibilityLabel:N.dragHandle,accessibilityHint:N.dragHandleHintText,testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[Rt.handle,{backgroundColor:G.colors.border},C]})})}),B&&_jsxs(View,{style:[Rt.header,E],onLayout:se?le:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:ht,children:_jsx(ScrollView,{ref:f,testID:V?`${V}-scroll`:void 0,style:Rt.scrollContent,onScroll:b,onContentSizeChange:be,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:I})}):_jsx(View,{style:se?[Rt.content,{overflow:"visible"}]:Rt.content,children:se?_jsx(View,{style:Rt.contentMeasure,onLayout:ue,children:I}):I}),L&&_jsxs(View,{style:[Rt.footer,k],onLayout:se?he:void 0,children:[P?_jsx(View,{style:Rt.actions,children:_jsx(OverlayActions,{actions:_??[],layout:T})}):null,O]})]})})]}),It=_jsx(BottomSheetContext,{value:Et,children:kt});return"modal"===H?_jsx(Modal,{open:Re,onClose:et,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:ee,onDismissed:"ios"===Platform.OS?$e:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:Rt.modalRoot,children:It}):It}):It},SheetBody=({style:e,settledKeyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,a=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},[s,t]);return _jsx(Animated.View,{style:[e,a],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{backgroundColor:e.colors.surface},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},contentMeasure:{position:"absolute",top:0,left:0,right:0},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
|
|
1
|
+
"use strict";import{createContext,useCallback,useContext,useEffect,useLayoutEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,useAnimatedReaction,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{BOTTOM_SHEET_TEXT}from"../../text/phone/bottomSheet.g.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{webDeps}from"../../utils/animatedDeps.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:a,onSnapChange:r,onAnimate:n,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:p,onContentSizeChange:b,onScrollLayout:S,scrollEventThrottle:v,keyboardBehavior:g="shift",inline:y=!1,presentation:x="sheet",animateMount:w=!0,handleIndicatorStyle:C,sheetStyle:M,header:R,actions:_,actionsLayout:T="auto",footer:O,headerStyle:E,footerStyle:k,children:I,accessibilityLabel:D,accessibilityViewIsModal:j,testID:A}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const V=useMobileUiText("bottomSheet",BOTTOM_SHEET_TEXT),N=useMemo(()=>({...V,...h}),[V,h]),B=null!=R||null!=d,P=null!=_&&_.length>0,L=null!=O||P,H=y?"inline":"modal",G=useTheme(),F=usePresenceMotion(),U=useSafeAreaInsets(),Y="modal"===H&&"android"===Platform.OS,[K,$]=useState(()=>Dimensions.get(Y?"screen":"window").height),[z,X]=useState(()=>Dimensions.get(Y?"screen":"window").width),W=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;Y&&Math.abs(t-Dimensions.get("window").height)<1&&t<Dimensions.get("screen").height-1||(t>0&&$(e=>e===t?e:t),o>0&&X(e=>e===o?e:o))},[Y]),q=useWindowDimensions(),J="dialog"===x||"auto"===x&&Math.min(q.width,q.height)>=600,Q=Math.min(560,z-2*G.space.xl),[Z,ee]=useModalInsets(),te="modal"===H?Z.top:U.top,oe="modal"===H?Z.bottom:U.bottom,se=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,le]=useMeasuredHeight(),[ie,ue,ce]=useMeasuredHeight(),[de,he]=useMeasuredHeight(),me=J?G.space.md:ae,fe=se?Math.min(me+(B?ne:0)+ie+(L?de:0)+oe,K-te):0,pe=useCallback((e,t)=>{se&&ce(t),b?.(e,t)},[se,b,ce]),be=useMemo(()=>resolveSnapPoints(t,K,fe),[t,K,fe]),Se=K,ve=be[be.length-1]??0,ge=useSharedValue(Se),ye=useSharedValue(Se),xe=useSharedValue(1),we=useSharedValue(-1),[Ce,Me]=useState(-1),[Re,Te]=useState(!1),[Oe,Ee]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[De,je]=useState(!1),Ae=useRef(!w&&o),Ve=useRef(-1),Ne=useRef(!1);Ne.current="modal"===H?Oe:De;const Be=useRef(c);Be.current=c;const Pe=useRef(s);Pe.current=s;const Le=useRef(!1),He=useRef(!0),Ge=useRef([]),Fe=useCallback(e=>{const t=Ge.current;Ge.current=[];for(const o of t)o(e)},[]);useEffect(()=>(He.current=!0,()=>{He.current=!1,Fe(!1)}),[Fe]);const Ue=useCallback(e=>{if(e<0||e>=be.length)return Se;const t=be[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return J?(K-t)/2:K-t},[be,K,Se,J]),Ye=useCallback(e=>{Ve.current=e;Ce!==e&&(Me(e),we.value=e,e>=0&&r?.(e))},[Ce,we,r]),Ke=useCallback(()=>{we.value<0&&(ke.current=!0,"modal"===H?(Te(!1),"ios"!==Platform.OS&&Ee(!1)):je(!1))},[H,we]),$e=useCallback(()=>{ke.current&&Ee(!1)},[]);useEffect(()=>{("modal"===H?!Oe:!De)&&ke.current&&(ke.current=!1,Ie.current?.(),Fe(!0))},[H,Oe,De,Fe]);const ze=useCallback((e,t,o)=>{n?.(t,o),ge.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(Ke)})},[n,ge,Ke]),Xe=useRef(null),We=useCallback(e=>{const t="number"==typeof e?clamp(e,0,be.length-1):Math.max(Ce,0),o=we.value,s=Ue(t);return ke.current=!1,Fe(!1),"modal"===H?(Ee(!0),Te(!0)):je(!0),o<0&&Ae.current?(ge.value=s,xe.value=1,Ye(t),void n?.(o,t)):o<0&&F.reduced?(ge.value=s,xe.value=0,xe.value=withTiming(1,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ye(t),void n?.(o,t)):(o<0&&(ge.value=Se,xe.value=1),Ye(t),void(o<0&&t>=0&&!Ne.current?Xe.current={fromIndex:o,target:t}:ze(s,o,t)))},[ze,Se,Ce,we,H,n,F,xe,be.length,Ye,Fe,G.motion.ease.decelerate,ge,Ue]),qe=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(Ne.current?Ge.current.push(e):e(!0));Ge.current.push(e),Ae.current=!1,Xe.current=null;const t=we.value;Ye(-1),n?.(t,-1);const o=F.reduced?xe:ge,s=F.reduced?0:Se;o.value=withTiming(s,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(Ke)})}),[Se,we,Ke,n,F,xe,Ye,ge,G.motion.ease.accelerate]),Je=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Le.current)return void t?.();const a=s();"boolean"!=typeof a?(Le.current=!0,o?.(),a.then(o=>{Le.current=!1,o&&He.current&&Ve.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(a?e:t)?.()},[]),Qe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):Je(()=>{Pe.current(),qe(),e(!0)},()=>e(!1))}),[qe,Je]),Ze=useCallback(()=>{Pe.current()},[]),et=useCallback(()=>{u&&Qe()},[u,Qe]),tt=useRef(null),ot=useRef(We);ot.current=We;const st=useRef(qe);st.current=qe,useLayoutEffect(()=>{const e=tt.current!==o;tt.current=o,e?o?ot.current(a??0):st.current():o&&"number"==typeof a&&a!==we.value&&ot.current(a)},[o,a,we]);const at=useRef({hostHeight:K,contentSnap:fe}),rt=useRef(Ue);rt.current=Ue,useEffect(()=>{const e=at.current;if(e.hostHeight===K&&e.contentSnap===fe)return;if(at.current={hostHeight:K,contentSnap:fe},e.hostHeight===K&&we.value<0)return;const t=rt.current(we.value);ge.value=Ae.current?t:withSpring(t,SPRING_CONFIG)},[K,fe,we,ge]);const nt="modal"===H?Oe:De;useLayoutEffect(()=>{const e=Xe.current;null!==e&&nt&&(Xe.current=null,Ve.current===e.target&&ze(rt.current(e.target),e.fromIndex,e.target))},[nt,ze]);const lt=K-ve,it=useMemo(()=>be.map(e=>K-e),[be,K]),ut=useCallback(()=>{const e=Ve.current;e<0||ze(Ue(e),e,e)},[ze,Ue]),ct=useCallback((e,t)=>{const o=we.value;-1!==e?(Ye(e),ze(t,o,e)):Je(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Pe.current(),qe()},ut,ut)},[ze,qe,we,Je,Ye,ut]),dt=useMemo(()=>({testID:A?`${A}-content-gesture`:"bottom-sheet-content-gesture"}),[A]),ht=useNativeGesture(dt),mt=useMemo(()=>{const e=it,t=Se,o=lt,s=i;return{testID:A?`${A}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ye.value=ge.value},onUpdate:e=>{"worklet";const t=ye.value+e.translationY;ge.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const a=ge.value,r=o.velocityY,[n]=e;if(void 0===n)return void scheduleOnRN(ct,-1,t);if(r>1e3)return s?void scheduleOnRN(ct,-1,t):void scheduleOnRN(ct,0,n);let l=0,i=n,u=1/0,c=0;for(const t of e){const e=Math.abs(a-t);e<u&&(u=e,i=t,l=c),c++}s&&a-n>80?scheduleOnRN(ct,-1,t):scheduleOnRN(ct,l,i)}}},[Se,ye,i,ct,lt,it,A,ge]),ft=usePanGesture(mt),{height:pt,progress:bt}=useReanimatedKeyboardAnimation(),St="shift"===g,vt=useDerivedValue(()=>St?pt.value:0,...webDeps([St,pt])),gt=useSharedValue(0);useAnimatedReaction(()=>St&&bt.value>=1?pt.value:0,e=>{gt.value=e},[St,pt,bt,gt]);const yt=be[Math.max(Ce,0)]??ve,xt=G.space.md,wt=useAnimatedStyle(()=>{const e=vt.value;if(J){const t=K+e-yt-xt,o=e<0&&ge.value>t?t:ge.value;return{top:ge.value,transform:[{translateY:Math.max(o,te)-ge.value}],opacity:xe.value}}const t=e<0?te:lt,o=Math.max(ge.value+e,t);return{top:ge.value,transform:[{translateY:o-ge.value}],opacity:xe.value}},...webDeps([J,vt,K,yt,xt,ge,te,xe,lt])),Ct=useAnimatedStyle(()=>{const e=gt.value;if(J){const t=K+e-yt-xt,o=e<0&&ge.value>t?t:ge.value,s=Math.max(o,te),a=K+e-xt-s;return{height:a<0?0:Math.min(a,yt)}}const t=e<0?te:lt,o=Math.max(ge.value+e,t),s=K+e-o;return{height:s<0?0:Math.min(s,ve)}},...webDeps([gt,J,K,yt,xt,ge,te,lt,ve])),Mt=Ce>=0,Rt=useMemo(()=>buildStyles(G),[G]),_t=useCallback(()=>{u&&Je(()=>{triggerHaptic("selection"),Pe.current(),qe()})},[u,qe,Je]),Tt=useMemo(()=>({testID:A?`${A}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(_t)}}),[_t,A]),Ot=useTapGesture(Tt),Et=useMemo(()=>({snapIndex:Ce,snapPoints:be,close:Ze,requestClose:Qe}),[Ce,be,Ze,Qe]);if("inline"===H&&!De)return null;if("modal"===H&&!Oe)return null;const kt=_jsxs(View,{collapsable:!1,style:["modal"===H?Rt.backdropModal:Rt.backdropInline,{backgroundColor:"modal"===H?transparentOf(G.colors.scrim):G.colors.scrim}],onLayout:W,testID:A,accessibilityViewIsModal:j??Mt,children:[_jsx(GestureDetector,{gesture:Ot,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:N.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:D,accessibilityViewIsModal:j??Mt,accessibilityActions:[{name:"escape",label:N.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&et()},onAccessibilityEscape:et,style:[Rt.sheet,{height:ve,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,...smoothCorners,...G.shadow.modal},J?{height:yt,left:(z-Q)/2,right:void 0,width:Q,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,M,wt],children:_jsxs(SheetBody,{style:[Rt.body,Ct],settledKeyboardOffset:gt,children:[J?_jsx(View,{style:{height:G.space.md}}):_jsx(GestureDetector,{gesture:ft,children:_jsx(View,{style:Rt.handleRow,onLayout:se?re:void 0,accessible:!0,accessibilityLabel:N.dragHandle,accessibilityHint:N.dragHandleHintText,testID:A?`${A}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[Rt.handle,{backgroundColor:G.colors.border},C]})})}),B&&_jsxs(View,{style:[Rt.header,E],onLayout:se?le:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:ht,children:_jsx(ScrollView,{ref:f,testID:A?`${A}-scroll`:void 0,style:Rt.scrollContent,onScroll:p,onContentSizeChange:pe,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:I})}):_jsx(View,{style:se?[Rt.content,{overflow:"visible"}]:Rt.content,children:se?_jsx(View,{style:Rt.contentMeasure,onLayout:ue,children:I}):I}),L&&_jsxs(View,{style:[Rt.footer,k],onLayout:se?he:void 0,children:[P?_jsx(View,{style:Rt.actions,children:_jsx(OverlayActions,{actions:_??[],layout:T})}):null,O]})]})})]}),It=_jsx(BottomSheetContext,{value:Et,children:kt});return"modal"===H?_jsx(Modal,{open:Re,onClose:et,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:ee,onDismissed:"ios"===Platform.OS?$e:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:Rt.modalRoot,children:It}):It}):It},SheetBody=({style:e,settledKeyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,a=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},...webDeps([s,t]));return _jsx(Animated.View,{style:[e,a],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{backgroundColor:e.colors.surface},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},contentMeasure:{position:"absolute",top:0,left:0,right:0},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{StyleSheet,useWindowDimensions,View}from"react-native";import Animated,{cancelAnimation,Easing,useAnimatedStyle,useSharedValue,withRepeat,withTiming}from"react-native-reanimated";import Svg,{Path,Polygon}from"react-native-svg";import{scheduleOnRN}from"react-native-worklets";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{jsx as _jsx}from"react/jsx-runtime";const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6};export const DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0};const PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),itemAt=(e,a,r)=>{const t=e[a];if(void 0===t)throw new Error(`Confetti needs at least one ${r}`);return t},pick=e=>itemAt(e,Math.floor(Math.random()*e.length),"shape"),randomSign=()=>Math.random()<.5?1:-1,commonPiece=(e,a)=>({color:itemAt(e.colors,a%e.colors.length,"colour"),size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:randomSign(),flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const r=e.physics.spread>0?e.physics.spread/2:100,t=(-90+rand(-r,r))*DEG,s=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(t)*s*.7,vyFrac:Math.sin(t)*s,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const r=Math.max(1,Math.round(e/4)),t=a.physics.spread>0?a.physics.spread/2:180,s=[];for(let i=0;i<4&&s.length<e;i+=1){const o=rand(.18,.82),n=rand(.18,.52),c=i/4*.5+rand(0,.06);for(let i=0;i<r&&s.length<e;i+=1){const e=rand(-t,t)*DEG,r=rand(1.4,3.4)*a.physics.velocity;s.push({...commonPiece(a,s.length),x0Frac:o,y0Frac:n,vxFrac:Math.cos(e)*r*.7,vyFrac:Math.sin(e)*r,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:c,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return s};export const buildPieces=(e,a,r)=>{if("fireworks"===a)return buildFireworks(e,r);const t="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>t(r,a))};const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:_jsx(Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:_jsx(Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:r,height:t,fadeOut:s})=>{const i=useAnimatedStyle(()=>{const i=1-e.delay,o=i<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/i)),n=(1-Math.exp(-e.drag*o))/e.drag,c=e.x0Frac*r+e.vxFrac*r*n,l=e.y0Frac*t+e.terminalFrac*t*o+(e.vyFrac-e.terminalFrac)*t*n,d=Math.sin(o*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*o,p=.35+.65*Math.abs(Math.cos(o*e.flutterFreq*TAU));return{opacity:s?Math.max(0,1-Math.max(0,o-.75)/.25):1,transform:[{translateX:c+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}}
|
|
1
|
+
"use strict";import{useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{StyleSheet,useWindowDimensions,View}from"react-native";import Animated,{cancelAnimation,Easing,useAnimatedStyle,useSharedValue,withRepeat,withTiming}from"react-native-reanimated";import Svg,{Path,Polygon}from"react-native-svg";import{scheduleOnRN}from"react-native-worklets";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{webDeps}from"../../utils/animatedDeps.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{jsx as _jsx}from"react/jsx-runtime";const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6};export const DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0};const PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),itemAt=(e,a,r)=>{const t=e[a];if(void 0===t)throw new Error(`Confetti needs at least one ${r}`);return t},pick=e=>itemAt(e,Math.floor(Math.random()*e.length),"shape"),randomSign=()=>Math.random()<.5?1:-1,commonPiece=(e,a)=>({color:itemAt(e.colors,a%e.colors.length,"colour"),size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:randomSign(),flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const r=e.physics.spread>0?e.physics.spread/2:100,t=(-90+rand(-r,r))*DEG,s=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(t)*s*.7,vyFrac:Math.sin(t)*s,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const r=Math.max(1,Math.round(e/4)),t=a.physics.spread>0?a.physics.spread/2:180,s=[];for(let i=0;i<4&&s.length<e;i+=1){const o=rand(.18,.82),n=rand(.18,.52),c=i/4*.5+rand(0,.06);for(let i=0;i<r&&s.length<e;i+=1){const e=rand(-t,t)*DEG,r=rand(1.4,3.4)*a.physics.velocity;s.push({...commonPiece(a,s.length),x0Frac:o,y0Frac:n,vxFrac:Math.cos(e)*r*.7,vyFrac:Math.sin(e)*r,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:c,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return s};export const buildPieces=(e,a,r)=>{if("fireworks"===a)return buildFireworks(e,r);const t="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>t(r,a))};const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:_jsx(Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:_jsx(Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:r,height:t,fadeOut:s})=>{const i=useAnimatedStyle(()=>{const i=1-e.delay,o=i<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/i)),n=(1-Math.exp(-e.drag*o))/e.drag,c=e.x0Frac*r+e.vxFrac*r*n,l=e.y0Frac*t+e.terminalFrac*t*o+(e.vyFrac-e.terminalFrac)*t*n,d=Math.sin(o*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*o,p=.35+.65*Math.abs(Math.cos(o*e.flutterFreq*TAU));return{opacity:s?Math.max(0,1-Math.max(0,o-.75)/.25):1,transform:[{translateX:c+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}},...webDeps([e,a,r,t,s])),o=SHAPE_BOX[e.shape],n="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return _jsx(Animated.View,{style:[{position:"absolute",width:e.size*o.w,height:e.size*o.h,borderRadius:"circle"===e.shape?e.size*o.h/2:1,backgroundColor:n?"transparent":e.color},i],children:_jsx(ShapeBody,{shape:e.shape,color:e.color})})};function Confetti({ref:e,count:a=80,colors:r,preset:t="pop",shapes:s,speed:i="normal",physics:o,origin:n,duration:c=2800,fadeOut:l=!0,autoStart:d=!1,recycle:h=!1,size:p=10,onComplete:u,style:m,testID:y}){assertValidValue("Confetti","preset",t,["pop","rain","fireworks"]),assertValidValue("Confetti","speed",i,["slow","normal","fast"]);for(const e of s??[])assertValidValue("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const f=useTheme(),g=useReducedMotion(),S=useWindowDimensions(),[w,v]=useState({width:S.width,height:S.height}),[F,A]=useState(!1),[P,x]=useState([]),E=useMemo(()=>r??[f.colors.primary,f.colors.neutral,f.colors.success,f.colors.warning,f.colors.danger,f.colors.info],[r,f.colors]),M=useSharedValue(0),T=c*SPEED_FACTOR[i],_=useCallback(()=>{A(!1),u?.()},[u]),R=useCallback(()=>{if(g)return void u?.();cancelAnimation(M),M.value=0,x(buildPieces(a,t,{colors:E,baseSize:p,originXFrac:n?n.x/Math.max(1,w.width):.5,originYFrac:n?n.y/Math.max(1,w.height):.5,physics:{velocity:void 0===o?.velocity?DEFAULT_PHYSICS.velocity:o.velocity,drag:void 0===o?.drag?DEFAULT_PHYSICS.drag:o.drag,fallSpeed:void 0===o?.fallSpeed?DEFAULT_PHYSICS.fallSpeed:o.fallSpeed,spread:void 0===o?.spread?DEFAULT_PHYSICS.spread:o.spread},shapes:s??PRESET_SHAPES[t]})),A(!0);const e=withTiming(1,{duration:T,easing:Easing.linear},e=>{"worklet";e&&!h&&scheduleOnRN(_)});M.value=h?withRepeat(e,-1,!1):e},[g,M,T,h,_,u,a,E,t,s,o,p,n,w.width,w.height]),C=useCallback(()=>{cancelAnimation(M),A(!1)},[M]);useImperativeHandle(e,()=>({start:R,stop:C}),[R,C]);const k=useRef(d).current,D=useRef(R).current;useEffect(()=>(k&&D(),()=>cancelAnimation(M)),[M,k,D]);const b=useCallback(e=>{const{width:a,height:r}=e.nativeEvent.layout;a>0&&r>0&&v({width:a,height:r})},[]),I=useMemo(()=>P.map((e,a)=>({key:`confetti-${a}`,piece:e})),[P]);return _jsx(View,{style:[StyleSheet.absoluteFill,m],pointerEvents:"none",onLayout:b,testID:y,children:F?I.map(({key:e,piece:a})=>_jsx(ConfettiPiece,{piece:a,progress:M,width:w.width,height:w.height,fadeOut:l},e)):null})}export{Confetti};export default Confetti;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{Extrapolation,interpolate,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{DRAWER_TEXT}from"../../text/phone/drawer.g.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10;function Drawer({ref:e,...t}){const{open:a,defaultOpen:i=!1,onOpenChange:
|
|
1
|
+
"use strict";import{useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{Extrapolation,interpolate,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{DRAWER_TEXT}from"../../text/phone/drawer.g.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{webDeps}from"../../utils/animatedDeps.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10;function Drawer({ref:e,...t}){const{open:a,defaultOpen:i=!1,onOpenChange:s,side:o="left",width:r,enableSwipe:l=!0,enableBackdropPress:n=!0,backdropOpacity:u=.5,haptic:c,sheetStyle:d,children:p,accessibilityLabel:f,labels:m,testID:h}=t,b=useTheme();assertValidValue("Drawer","side",t.side,["left","right","top","bottom"]);const g=useMobileUiText("drawer",DRAWER_TEXT),v=useMemo(()=>({...g,...m}),[g,m]),w=usePresenceMotion(),E=w.reduced,S=w.duration("default"),y=w.duration("fast"),O=useSafeAreaInsets(),M="boolean"==typeof a,T=useWindowDimensions(),R="left"===o||"right"===o,x=useMemo(()=>resolveSize(r,R,T),[r,R,T]),D=useMemo(()=>closedOffsetOf(o,x),[o,x]),_=useSharedValue(i?0:D),C=useSharedValue(i?0:D),k=useSharedValue(i?1:0),[V,j]=useState(i),A=useSharedValue(i);useEffect(()=>{V||E||(_.value=D,C.value=D)},[D,V,_,C,E]);const N=b.motion.spring.snappy,I=useCallback(()=>{if(E)return _.value=0,void(k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION}));k.value=1,_.value=withSpring(0,N)},[_,k,N,E,S]),P=useCallback(()=>{E?k.value=withTiming(0,{duration:y,reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(_.value=D)}):_.value=withSpring(D,N)},[_,k,D,N,E,y]),L=useCallback(e=>{j(t=>t===e?t:(s?.(e),e)),A.value=e},[s,A]),U=useCallback(()=>{L(!0),I()},[L,I]),F=useCallback(()=>{L(!1),P()},[L,P]),H=useCallback(()=>{V?F():U()},[V,U,F]);useImperativeHandle(e,()=>({open:U,close:F,toggle:H}),[U,F,H]);const X=useRef({isOpen:V,open:U,close:F});X.current={isOpen:V,open:U,close:F},useEffect(()=>{if(!M)return;const e=X.current;a!==e.isOpen&&(a?e.open():e.close())},[a,M]);const Y=useMemo(()=>{const e=D,t=o,a=l;return{...R?{activeOffsetX:[-10,10],failOffsetY:[-15,15]}:{activeOffsetY:[-10,10],failOffsetX:[-15,15]},onActivate:()=>{"worklet";a&&(C.value=_.value)},onUpdate:t=>{"worklet";if(!a)return;const i=R?t.translationX:t.translationY,s=C.value+i,o=Math.min(0,e),r=Math.max(0,e);_.value=s<o?o+.25*(s-o):s>r?r+.25*(s-r):s},onDeactivate:i=>{"worklet";if(!a)return;const s=R?i.velocityX:i.velocityY,o=_.value;let r=!1;r="left"===t||"top"===t?s<-1e3:s>1e3;const l=Math.abs(e),n=Math.abs(o)/l;r||n>.5?(scheduleOnRN(L,!1),E?k.value=withTiming(0,{duration:y,reduceMotion:PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(_.value=e)}):_.value=withSpring(e,N)):(scheduleOnRN(L,!0),E?(_.value=0,k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION})):_.value=withSpring(0,N))}}},[D,C,l,R,_,k,L,o,N,E,S,y]),G=usePanGesture(Y),B=useAnimatedStyle(()=>R?{opacity:k.value,transform:[{translateX:_.value}]}:{opacity:k.value,transform:[{translateY:_.value}]},...webDeps([R,_,k])),W=useAnimatedStyle(()=>({opacity:interpolate(_.value,[D,0],[0,u],Extrapolation.CLAMP)*k.value,pointerEvents:Math.abs(_.value-D)<.5?"none":"auto"}),...webDeps([_,D,u,k])),z=useMemo(()=>buildStyles(b),[b]),q=useCallback(()=>{if(!n)return;const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),F()},[n,F,c]),J=useMemo(()=>sideLayoutOf(o,x,O),[o,x,O]),K=useRef(i);return V&&(K.current=!0),K.current?_jsxs(View,{style:StyleSheet.absoluteFill,pointerEvents:"box-none",testID:h,accessibilityViewIsModal:V,children:[_jsx(Animated.View,{style:[z.backdrop,{backgroundColor:b.colors.scrim},W],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:q,accessibilityRole:"button",accessibilityLabel:v.close,disabled:!n||!V})}),_jsx(GestureDetector,{gesture:G,children:_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:f??v.drawer,style:[J,{backgroundColor:b.colors.surface,...b.shadow.modal},d,B],children:_jsx(View,{style:z.content,children:p})})})]}):null}const closedOffsetOf=(e,t)=>{switch(e){case"left":case"top":return-t;case"right":case"bottom":return t}},sideLayoutOf=(e,t,a)=>{switch(e){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:t,paddingTop:a.top,paddingBottom:a.bottom,paddingLeft:a.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:t,paddingTop:a.top,paddingBottom:a.bottom,paddingRight:a.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:t,paddingTop:a.top,paddingLeft:a.left,paddingRight:a.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:t,paddingBottom:a.bottom,paddingLeft:a.left,paddingRight:a.right}}},resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const i=parseFloat(e);if(Number.isNaN(i))return t?280:Math.round(.4*a.height);return i/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},content:{flex:1}});export{Drawer};export default Drawer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Logger}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,BackHandler,Easing,Platform,Pressable,StyleSheet,Text,View}from"react-native";import Reanimated,{cancelAnimation,Easing as ReanimatedEasing,useAnimatedStyle,useSharedValue,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{FLOATING_ACTION_BUTTON_TEXT}from"../../text/phone/floatingActionButton.g.js";import{createAnimatedValue,resolveFloatingActionButtonSize,setNativeValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{ACCENT_PRESSED_TINT}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}};function FloatingActionButton({ref:e,...t}){const{icon:o,onPress:n,label:i,collapsed:s=!1,size:r="md",tone:a="primary",position:l,bottomOffset:c,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:p=!1,accessibilityLabel:f,accessibilityHint:b,haptic:g,style:h,labelStyle:y,testID:A}=t;assertValidValue("FloatingActionButton","size",t.size,FAB_SIZES),assertValidValue("FloatingActionButton","tone",t.tone,FAB_TONES),assertValidValue("FloatingActionButton","position",t.position,FAB_POSITIONS);const S=!u&&!d,x=useTheme(),v=useSafeAreaInsets(),w=useMemo(()=>resolveFloatingActionButtonSize(x,r),[x,r]),_=useMemo(()=>buildStyles(x),[x]),{style:E,pressIn:I,pressOut:R}=usePressAnimation({enabled:S}),T=usePresenceMotion(),j=x.space[x.components["floating-action-button"]["edge-offset"]],C=x.space[x.components["floating-action-button"]["bottom-offset"]],F=useRef(createAnimatedValue(1)).current,V=T.duration("default");useEffect(()=>{if(!m)return void setNativeValue(F,1);const e=Animated.timing(F,{toValue:p?0:1,duration:V,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[m,p,F,V,x.motion.ease["in-out"]]);const B=w.diameter+(c??C)+v.bottom+j,P=F.interpolate({inputRange:[0,1],outputRange:T.range(B,0)}),k=useMemo(()=>Animated.multiply(F,E.opacity),[F,E.opacity]),D="string"==typeof i&&i.length>0,O=D&&s,N=T.reduced,L=x.space.sm,z=w["label-padding-x"],M=x.motion.duration.fast,H=x.motion.ease["in-out"],G=useSharedValue(O?1:0),[$,U]=useState(null);useEffect(()=>{const e=O?1:0;return G.value=N?e:withTiming(e,{duration:M,easing:ReanimatedEasing.bezier(...H)}),()=>cancelAnimation(G)},[O,N,G,M,H]);const W=useCallback(e=>{const t=Math.ceil(e);U(e=>e===t?e:t)},[]),X=useAnimatedStyle(()=>({paddingHorizontal:z*(1-G.value)}),[z,G]),Y=useAnimatedStyle(()=>{const e=Math.max(0,1-2*G.value);return null===$?G.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:($+L)*(1-G.value)}},[G,$,L]),Z=u?x.colors["surface-disabled"]:toneBackground(x,a),q=u?x.colors["text-disabled"]:toneForeground(x,a),J=d?_jsx(Spinner,{variant:"circular",size:"lg"===r?"md":"sm",color:q}):renderSlotIcon(o,{color:q,size:w.icon,disabled:u}),K=useMemo(()=>{if(!l)return null;const e=(c??C)+v.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:j};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:j}}},[l,c,v.bottom,C,j]);return _jsx(Animated.View,{style:[K,{transform:[{translateY:P},...E.transform],opacity:k},h],pointerEvents:m&&p?"none":"auto",children:_jsx(Pressable,{ref:e,onPress:e=>{if(!S)return;const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t),n()},onPressIn:I,onPressOut:R,disabled:!S,accessibilityRole:"button",accessibilityLabel:f,accessibilityHint:b,accessibilityState:{disabled:!S,busy:d},"aria-disabled":!S,"aria-busy":d,testID:A,style:[_.base,D?{height:w.diameter,minWidth:w.diameter,borderRadius:w.diameter/2,...smoothCorners}:{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,...smoothCorners},x.shadow.popover,{backgroundColor:Z,opacity:u||d?.55:1}],children:({pressed:e})=>_jsxs(_Fragment,{children:[e&&S?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[_.pressedTint,{backgroundColor:pressedTintFor(x,a),borderRadius:w.diameter/2,...smoothCorners}]}):null,D?_jsxs(Reanimated.View,{style:[_.extendedRow,X],children:[J,_jsx(Reanimated.View,{style:[_.labelClip,Y],children:_jsx(Text,{onLayout:e=>W(e.nativeEvent.layout.width),style:[_.label,{color:q,fontSize:w.text,fontWeight:x.weight.semibold,marginLeft:L},y],numberOfLines:1,children:i})})]}):J]})})})}const buildStyles=e=>StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:o,actions:n,expanded:i,defaultExpanded:s=!1,onExpandedChange:r,labels:a,position:l="bottomRight",bottomOffset:c,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:p=!1,isScrolling:f=!1,style:b,secondaryActionStyle:g,labelPillStyle:h,labelStyle:y,testID:A}=e;assertValidValue("FloatingActionButtonGroup","size",e.size,FAB_SIZES),assertValidValue("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const S=useMobileUiText("floatingActionButton",FLOATING_ACTION_BUTTON_TEXT),x=useMemo(()=>({...S,...a}),[S,a]),v=d??x.quickActions,w=useTheme(),_=useSafeAreaInsets(),E=useMemo(()=>resolveFloatingActionButtonSize(w,u),[w,u]),I=useMemo(()=>buildGroupStyles(w),[w]),R=usePresenceMotion(),T=R.duration("default"),j=w.space[w.components["floating-action-button"]["edge-offset"]],C=w.space[w.components["floating-action-button"]["bottom-offset"]],F=w.space[w.components["floating-action-button"]["secondary-gap"]],V=w.components["floating-action-button"]["stagger-ms"],B=useMemo(()=>n.slice(0,6),[n]),P=B.length,k=useMemo(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);n.forEach(e=>{assertValidValue("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const D=__DEV__?describeActionProblem(n):"";useEffect(()=>{__DEV__&&D&&Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${D}`)},[D]);const O="boolean"==typeof i,[N,L]=useState(s),z="boolean"==typeof i?i:N,M=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!p)return void setNativeValue(M,1);const e=Animated.timing(M,{toValue:f?0:1,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[p,f,M,T,w.motion.ease["in-out"]]);const H=p&&f;useEffect(()=>{H&&z&&(O||L(!1),r?.(!1))},[H,z,O,r]);const G=E.diameter+(c??C)+_.bottom+j,$=M.interpolate({inputRange:[0,1],outputRange:R.range(G,0)}),U=M,W=useRef(createAnimatedValue(z?1:0)).current,X=useRef([]),[Y,Z]=useState(0);useEffect(()=>{const e=X.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let o=e.length;o<P;o+=1)t.push(new Animated.Value(z?1:0));X.current=t}else X.current=e.slice(0,P);Z(e=>e+1)}},[P,z]),useEffect(()=>{const e=Animated.timing(W,{toValue:z?1:0,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver});e.start();const t=X.current.map(e=>Animated.timing(e,{toValue:z?1:0,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver})),o=z?t:[...t].reverse(),n=Animated.stagger(V,o);return n.start(),()=>{e.stop(),n.stop()}},[z,W,T,w.motion.ease["in-out"],P,Y,V]);const q=useCallback(e=>{const t=resolveHaptic(m,"impactLight");t&&triggerHaptic(t),O||L(e),r?.(e)},[O,r,m]),J=useRef(null),K=useRef(z),Q=useRef(!1);useEffect(()=>{if(K.current===z)return;K.current=z;const e=Q.current;if(Q.current=!1,H||e)return;const t=J.current;t&&("web"===Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():AccessibilityInfo.sendAccessibilityEvent(t,"focus")),announce(z?pluralText(x,"expanded",P,{label:v}):fillText(x.collapsed,{label:v}))},[z,H,v,P,x]);const ee=useCallback(()=>{q(!z)},[z,q]),te=useCallback(e=>{!1!==m&&triggerHaptic("selection"),Q.current=!0,e.onPress(),O||L(!1),r?.(!1)},[O,r,m]),oe=useCallback(()=>{z&&q(!1)},[z,q]);useEffect(()=>{if(!z)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(q(!1),!0));return()=>e.remove()},[z,q]),useEffect(()=>{if(!z||"web"!==Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&q(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[z,q]);const ne=useMemo(()=>{const e=(c??C)+_.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:j,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:j,alignItems:"flex-end"}}},[l,c,_.bottom,C,j]),slotOffset=e=>-(E.diameter+F)*(e+1),ie=useMemo(()=>{switch(l){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[l]),se=.78*E.diameter,re=useMemo(()=>{const e=se+w.space.sm;switch(l){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:E.diameter/2+se/2+w.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[l,se,E.diameter,w.space.sm]),ae=W.interpolate({inputRange:[0,1],outputRange:[0,.4]}),le=W.interpolate(R.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return _jsxs(_Fragment,{children:[z?_jsx(Animated.View,{pointerEvents:z?"auto":"none",style:[StyleSheet.absoluteFill,{backgroundColor:w.colors.scrim,opacity:ae}],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:oe,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:A?`${A}-backdrop`:void 0})}):null,_jsxs(Animated.View,{pointerEvents:H?"none":"box-none",style:[ne,{transform:[{translateY:$}],opacity:U},b],accessibilityRole:"menu",testID:A,children:[k.map(({action:e,index:t})=>{const o=X.current[t];if(!o)return null;const n=o.interpolate({inputRange:[0,1],outputRange:R.range(0,slotOffset(t))}),i=o.interpolate({inputRange:[0,1],outputRange:R.range(.6,1)}),s=toneBackground(w,e.tone??"primary"),r=toneForeground(w,e.tone??"primary"),a=e.label?_jsx(View,{pointerEvents:"none",style:[I.labelSlot,re],testID:A?`${A}-label-${e.key}`:void 0,children:_jsx(View,{style:[I.labelPill,w.shadow.card,{backgroundColor:w.colors.surface,paddingHorizontal:w.space.sm,paddingVertical:w.space.xs,borderRadius:w.radius.sm,...smoothCorners},h],children:_jsx(Text,{style:[{color:w.colors["text-body"],fontSize:w.text.sm.size,fontWeight:w.weight.medium},y],numberOfLines:1,children:e.label})})}):null;return _jsxs(Animated.View,{pointerEvents:z?"auto":"none",accessibilityElementsHidden:!z,importantForAccessibility:z?"auto":"no-hide-descendants","aria-hidden":!z,style:[I.secondaryRow,ie,{position:"absolute",bottom:0,opacity:o,transform:[{translateY:n},{scale:i}]}],children:[_jsx(Pressable,{onPress:()=>te(e),focusable:z,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[I.fabBase,w.shadow.elevated,{width:se,height:se,borderRadius:se/2,...smoothCorners,backgroundColor:s},g],testID:A?`${A}-action-${e.key}`:void 0,children:({pressed:t})=>_jsxs(_Fragment,{children:[t?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:pressedTintFor(w,e.tone??"primary"),borderRadius:se/2,...smoothCorners}]}):null,renderSlotIcon(e.icon,{color:r,size:E.icon,disabled:!1})]})}),a]},e.key)}),_jsx(Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:v,accessibilityState:{expanded:z},"aria-expanded":z,style:[I.fabBase,w.shadow.popover,{width:E.diameter,height:E.diameter,borderRadius:E.diameter/2,...smoothCorners,backgroundColor:w.colors.primary}],testID:A?`${A}-primary`:void 0,children:({pressed:e})=>_jsxs(_Fragment,{children:[e?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:ACCENT_PRESSED_TINT,borderRadius:E.diameter/2,...smoothCorners}]}):null,_jsx(Animated.View,{style:o?void 0:{transform:[{rotate:le}]},children:renderSlotIcon(z&&o?o:t,{color:w.colors["on-primary"],size:E.icon,disabled:!1})})]})})]})]})},buildGroupStyles=e=>StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});export{FloatingActionButton,FloatingActionButtonGroup};export default FloatingActionButton;
|
|
1
|
+
"use strict";import{Logger}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,BackHandler,Easing,Platform,Pressable,StyleSheet,Text,View}from"react-native";import Reanimated,{cancelAnimation,Easing as ReanimatedEasing,useAnimatedStyle,useSharedValue,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{FLOATING_ACTION_BUTTON_TEXT}from"../../text/phone/floatingActionButton.g.js";import{createAnimatedValue,resolveFloatingActionButtonSize,setNativeValue,useTheme}from"../../theme/index.js";import{webDeps}from"../../utils/animatedDeps.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{ACCENT_PRESSED_TINT}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}};function FloatingActionButton({ref:e,...t}){const{icon:o,onPress:n,label:i,collapsed:s=!1,size:r="md",tone:a="primary",position:l,bottomOffset:c,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:p=!1,accessibilityLabel:f,accessibilityHint:b,haptic:g,style:h,labelStyle:y,testID:A}=t;assertValidValue("FloatingActionButton","size",t.size,FAB_SIZES),assertValidValue("FloatingActionButton","tone",t.tone,FAB_TONES),assertValidValue("FloatingActionButton","position",t.position,FAB_POSITIONS);const S=!u&&!d,x=useTheme(),v=useSafeAreaInsets(),w=useMemo(()=>resolveFloatingActionButtonSize(x,r),[x,r]),_=useMemo(()=>buildStyles(x),[x]),{style:E,pressIn:I,pressOut:R}=usePressAnimation({enabled:S}),T=usePresenceMotion(),j=x.space[x.components["floating-action-button"]["edge-offset"]],C=x.space[x.components["floating-action-button"]["bottom-offset"]],F=useRef(createAnimatedValue(1)).current,V=T.duration("default");useEffect(()=>{if(!m)return void setNativeValue(F,1);const e=Animated.timing(F,{toValue:p?0:1,duration:V,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[m,p,F,V,x.motion.ease["in-out"]]);const B=w.diameter+(c??C)+v.bottom+j,P=F.interpolate({inputRange:[0,1],outputRange:T.range(B,0)}),D=useMemo(()=>Animated.multiply(F,E.opacity),[F,E.opacity]),k="string"==typeof i&&i.length>0,O=k&&s,N=T.reduced,L=x.space.sm,z=w["label-padding-x"],M=x.motion.duration.fast,H=x.motion.ease["in-out"],G=useSharedValue(O?1:0),[$,U]=useState(null);useEffect(()=>{const e=O?1:0;return G.value=N?e:withTiming(e,{duration:M,easing:ReanimatedEasing.bezier(...H)}),()=>cancelAnimation(G)},[O,N,G,M,H]);const W=useCallback(e=>{const t=Math.ceil(e);U(e=>e===t?e:t)},[]),X=useAnimatedStyle(()=>({paddingHorizontal:z*(1-G.value)}),...webDeps([z,G])),Y=useAnimatedStyle(()=>{const e=Math.max(0,1-2*G.value);return null===$?G.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:($+L)*(1-G.value)}},...webDeps([G,$,L])),Z=u?x.colors["surface-disabled"]:toneBackground(x,a),q=u?x.colors["text-disabled"]:toneForeground(x,a),J=d?_jsx(Spinner,{variant:"circular",size:"lg"===r?"md":"sm",color:q}):renderSlotIcon(o,{color:q,size:w.icon,disabled:u}),K=useMemo(()=>{if(!l)return null;const e=(c??C)+v.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:j};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:j}}},[l,c,v.bottom,C,j]);return _jsx(Animated.View,{style:[K,{transform:[{translateY:P},...E.transform],opacity:D},h],pointerEvents:m&&p?"none":"auto",children:_jsx(Pressable,{ref:e,onPress:e=>{if(!S)return;const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t),n()},onPressIn:I,onPressOut:R,disabled:!S,accessibilityRole:"button",accessibilityLabel:f,accessibilityHint:b,accessibilityState:{disabled:!S,busy:d},"aria-disabled":!S,"aria-busy":d,testID:A,style:[_.base,k?{height:w.diameter,minWidth:w.diameter,borderRadius:w.diameter/2,...smoothCorners}:{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,...smoothCorners},x.shadow.popover,{backgroundColor:Z,opacity:u||d?.55:1}],children:({pressed:e})=>_jsxs(_Fragment,{children:[e&&S?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[_.pressedTint,{backgroundColor:pressedTintFor(x,a),borderRadius:w.diameter/2,...smoothCorners}]}):null,k?_jsxs(Reanimated.View,{style:[_.extendedRow,X],children:[J,_jsx(Reanimated.View,{style:[_.labelClip,Y],children:_jsx(Text,{onLayout:e=>W(e.nativeEvent.layout.width),style:[_.label,{color:q,fontSize:w.text,fontWeight:x.weight.semibold,marginLeft:L},y],numberOfLines:1,children:i})})]}):J]})})})}const buildStyles=e=>StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:o,actions:n,expanded:i,defaultExpanded:s=!1,onExpandedChange:r,labels:a,position:l="bottomRight",bottomOffset:c,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:p=!1,isScrolling:f=!1,style:b,secondaryActionStyle:g,labelPillStyle:h,labelStyle:y,testID:A}=e;assertValidValue("FloatingActionButtonGroup","size",e.size,FAB_SIZES),assertValidValue("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const S=useMobileUiText("floatingActionButton",FLOATING_ACTION_BUTTON_TEXT),x=useMemo(()=>({...S,...a}),[S,a]),v=d??x.quickActions,w=useTheme(),_=useSafeAreaInsets(),E=useMemo(()=>resolveFloatingActionButtonSize(w,u),[w,u]),I=useMemo(()=>buildGroupStyles(w),[w]),R=usePresenceMotion(),T=R.duration("default"),j=w.space[w.components["floating-action-button"]["edge-offset"]],C=w.space[w.components["floating-action-button"]["bottom-offset"]],F=w.space[w.components["floating-action-button"]["secondary-gap"]],V=w.components["floating-action-button"]["stagger-ms"],B=useMemo(()=>n.slice(0,6),[n]),P=B.length,D=useMemo(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);n.forEach(e=>{assertValidValue("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const k=__DEV__?describeActionProblem(n):"";useEffect(()=>{__DEV__&&k&&Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${k}`)},[k]);const O="boolean"==typeof i,[N,L]=useState(s),z="boolean"==typeof i?i:N,M=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!p)return void setNativeValue(M,1);const e=Animated.timing(M,{toValue:f?0:1,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[p,f,M,T,w.motion.ease["in-out"]]);const H=p&&f;useEffect(()=>{H&&z&&(O||L(!1),r?.(!1))},[H,z,O,r]);const G=E.diameter+(c??C)+_.bottom+j,$=M.interpolate({inputRange:[0,1],outputRange:R.range(G,0)}),U=M,W=useRef(createAnimatedValue(z?1:0)).current,X=useRef([]),[Y,Z]=useState(0);useEffect(()=>{const e=X.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let o=e.length;o<P;o+=1)t.push(new Animated.Value(z?1:0));X.current=t}else X.current=e.slice(0,P);Z(e=>e+1)}},[P,z]),useEffect(()=>{const e=Animated.timing(W,{toValue:z?1:0,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver});e.start();const t=X.current.map(e=>Animated.timing(e,{toValue:z?1:0,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver})),o=z?t:[...t].reverse(),n=Animated.stagger(V,o);return n.start(),()=>{e.stop(),n.stop()}},[z,W,T,w.motion.ease["in-out"],P,Y,V]);const q=useCallback(e=>{const t=resolveHaptic(m,"impactLight");t&&triggerHaptic(t),O||L(e),r?.(e)},[O,r,m]),J=useRef(null),K=useRef(z),Q=useRef(!1);useEffect(()=>{if(K.current===z)return;K.current=z;const e=Q.current;if(Q.current=!1,H||e)return;const t=J.current;t&&("web"===Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():AccessibilityInfo.sendAccessibilityEvent(t,"focus")),announce(z?pluralText(x,"expanded",P,{label:v}):fillText(x.collapsed,{label:v}))},[z,H,v,P,x]);const ee=useCallback(()=>{q(!z)},[z,q]),te=useCallback(e=>{!1!==m&&triggerHaptic("selection"),Q.current=!0,e.onPress(),O||L(!1),r?.(!1)},[O,r,m]),oe=useCallback(()=>{z&&q(!1)},[z,q]);useEffect(()=>{if(!z)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(q(!1),!0));return()=>e.remove()},[z,q]),useEffect(()=>{if(!z||"web"!==Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&q(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[z,q]);const ne=useMemo(()=>{const e=(c??C)+_.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:j,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:j,alignItems:"flex-end"}}},[l,c,_.bottom,C,j]),slotOffset=e=>-(E.diameter+F)*(e+1),ie=useMemo(()=>{switch(l){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[l]),se=.78*E.diameter,re=useMemo(()=>{const e=se+w.space.sm;switch(l){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:E.diameter/2+se/2+w.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[l,se,E.diameter,w.space.sm]),ae=W.interpolate({inputRange:[0,1],outputRange:[0,.4]}),le=W.interpolate(R.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return _jsxs(_Fragment,{children:[z?_jsx(Animated.View,{pointerEvents:z?"auto":"none",style:[StyleSheet.absoluteFill,{backgroundColor:w.colors.scrim,opacity:ae}],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:oe,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:A?`${A}-backdrop`:void 0})}):null,_jsxs(Animated.View,{pointerEvents:H?"none":"box-none",style:[ne,{transform:[{translateY:$}],opacity:U},b],accessibilityRole:"menu",testID:A,children:[D.map(({action:e,index:t})=>{const o=X.current[t];if(!o)return null;const n=o.interpolate({inputRange:[0,1],outputRange:R.range(0,slotOffset(t))}),i=o.interpolate({inputRange:[0,1],outputRange:R.range(.6,1)}),s=toneBackground(w,e.tone??"primary"),r=toneForeground(w,e.tone??"primary"),a=e.label?_jsx(View,{pointerEvents:"none",style:[I.labelSlot,re],testID:A?`${A}-label-${e.key}`:void 0,children:_jsx(View,{style:[I.labelPill,w.shadow.card,{backgroundColor:w.colors.surface,paddingHorizontal:w.space.sm,paddingVertical:w.space.xs,borderRadius:w.radius.sm,...smoothCorners},h],children:_jsx(Text,{style:[{color:w.colors["text-body"],fontSize:w.text.sm.size,fontWeight:w.weight.medium},y],numberOfLines:1,children:e.label})})}):null;return _jsxs(Animated.View,{pointerEvents:z?"auto":"none",accessibilityElementsHidden:!z,importantForAccessibility:z?"auto":"no-hide-descendants","aria-hidden":!z,style:[I.secondaryRow,ie,{position:"absolute",bottom:0,opacity:o,transform:[{translateY:n},{scale:i}]}],children:[_jsx(Pressable,{onPress:()=>te(e),focusable:z,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[I.fabBase,w.shadow.elevated,{width:se,height:se,borderRadius:se/2,...smoothCorners,backgroundColor:s},g],testID:A?`${A}-action-${e.key}`:void 0,children:({pressed:t})=>_jsxs(_Fragment,{children:[t?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:pressedTintFor(w,e.tone??"primary"),borderRadius:se/2,...smoothCorners}]}):null,renderSlotIcon(e.icon,{color:r,size:E.icon,disabled:!1})]})}),a]},e.key)}),_jsx(Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:v,accessibilityState:{expanded:z},"aria-expanded":z,style:[I.fabBase,w.shadow.popover,{width:E.diameter,height:E.diameter,borderRadius:E.diameter/2,...smoothCorners,backgroundColor:w.colors.primary}],testID:A?`${A}-primary`:void 0,children:({pressed:e})=>_jsxs(_Fragment,{children:[e?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:ACCENT_PRESSED_TINT,borderRadius:E.diameter/2,...smoothCorners}]}):null,_jsx(Animated.View,{style:o?void 0:{transform:[{rotate:le}]},children:renderSlotIcon(z&&o?o:t,{color:w.colors["on-primary"],size:E.icon,disabled:!1})})]})})]})]})},buildGroupStyles=e=>StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});export{FloatingActionButton,FloatingActionButtonGroup};export default FloatingActionButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{useCallback,useMemo,useRef,useState}from"react";import{Dimensions,Image,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,useCompetingGestures,usePanGesture,usePinchGesture,useTapGesture}from"react-native-gesture-handler";import Animated,{useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{scheduleOnRN}from"react-native-worklets";import{fillText,useMobileUiText}from"../../text/index.js";import{IMAGE_GALLERY_TEXT}from"../../text/phone/imageGallery.g.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Carousel}from"../Carousel/index.js";import{Modal}from"../Modal/Modal.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:t=0,showThumbnails:a=!0,showCounter:l=!0,enableLightbox:i=!0,enablePinchZoom:s=!0,onIndexChange:o,haptic:n,loading:r=!1,accessibilityLabel:u,style:c,testID:m,labels:d})=>{const h=useTheme(),g=useMemo(()=>buildStyles(h),[h]),p=useMobileUiText("imageGallery",IMAGE_GALLERY_TEXT),b=useMemo(()=>({...p,...d}),[p,d]),[x,v]=useState(clamp(t,0,Math.max(0,e.length-1))),[S,y]=useState(!1),I=useCallback(e=>{v(e),o?.(e)},[o]),w=useCallback(()=>{if(!i)return;const e=resolveHaptic(n,"selection");e&&triggerHaptic(e),y(!0)},[i,n]),C=useCallback(()=>{const e=resolveHaptic(n,"selection");e&&triggerHaptic(e),y(!1)},[n]),f=useCallback((t,a)=>{const l=t.alt??fillText(b.imageOf,{index:a+1,total:e.length});return _jsx(Pressable,{onPress:w,accessibilityRole:"image",accessibilityLabel:l,accessibilityHint:i?b.openFullscreen:void 0,style:g.imageWrap,children:_jsx(Image,{source:t.source,style:g.image,resizeMode:"cover"})})},[i,e.length,w,g,b]),_=useCallback(e=>_jsx(Image,{source:e.source,style:g.thumbnailImage,resizeMode:"cover"}),[g]),G=_jsxs(View,{style:[g.container,c],testID:m,accessibilityLabel:u??b.gallery,children:[_jsxs(View,{style:g.carouselWrap,accessibilityElementsHidden:S,importantForAccessibility:S?"no-hide-descendants":"auto",children:[_jsx(Carousel,{data:e,defaultIndex:t,onIndexChange:I,renderItem:f,showPagination:!1,showThumbnails:a,renderThumbnail:_,haptic:n}),l&&e.length>0?_jsx(View,{style:g.counterPill,pointerEvents:"none",children:_jsx(Text,{variant:"label",weight:"semibold",style:{color:h.colors["on-scrim"]},accessibilityLabel:fillText(b.imageOf,{index:x+1,total:e.length}),children:`${x+1} / ${e.length}`})}):null]}),i?_jsx(Lightbox,{open:S,images:e,initialIndex:x,enablePinchZoom:s,showCounter:l,onClose:C,onIndexChange:I,haptic:n,labels:b,testID:m}):null]});return r?_jsx(ImageGallerySkeleton,{images:e,showThumbnails:a,showCounter:l,style:c,testID:m}):G};ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:t=!0,showCounter:a=!0,style:l,testID:i})=>{const s=useTheme(),o=Math.min(e?.length||4,6),n=useMemo(()=>Array.from({length:o},(e,t)=>({key:`sk-thumb-${t}`})),[o]);return _jsxs(View,{style:[{width:"100%"},l],testID:i,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[_jsxs(View,{style:{position:"relative"},children:[_jsx(Skeleton,{width:"100%",height:280,radius:"lg"}),a?_jsx(View,{style:{position:"absolute",top:12,right:12},children:_jsx(Skeleton,{width:44,height:22,radius:"pill"})}):null]}),t?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.md},children:n.map(e=>_jsx(Skeleton,{width:64,height:64,radius:"md",style:{marginRight:s.space.sm}},e.key))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:t,initialIndex:a,enablePinchZoom:l,showCounter:i,onClose:s,onIndexChange:o,haptic:n,labels:r,testID:u})=>{const c=useTheme(),m=useMemo(()=>buildLightboxStyles(c),[c]),d=useRef(null),[h,g]=useState(a),p=useCallback(e=>{if(e!==h){const t=resolveHaptic(n,"selection");t&&triggerHaptic(t),g(e),o(e)}},[h,o,n]),b=useCallback((e,a)=>_jsx(ZoomableImage,{image:e,index:a,total:t.length,active:a===h,enabled:l,maxScale:4,minScale:1,doubleTapScale:2,haptic:n,imageLabel:r.imageOf}),[h,l,t.length,n,r]),x=t[h]?.caption;return _jsx(Modal,{open:e,onClose:s,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:_jsxs(View,{style:m.backdrop,children:[_jsx(Carousel,{ref:d,testID:u?`${u}-lightbox`:void 0,data:t,defaultIndex:a,onIndexChange:p,renderItem:b,showPagination:!1,haptic:n}),i&&t.length>0?_jsx(View,{style:m.counterPill,pointerEvents:"none",children:_jsx(Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:fillText(r.imageOf,{index:h+1,total:t.length}),children:`${h+1} / ${t.length}`})}):null,_jsx(Pressable,{onPress:s,accessibilityRole:"button",accessibilityLabel:r.closeGallery,style:m.closeButton,hitSlop:12,...hitSlopMarker(12),children:(c.settings.icons.close??defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),x?_jsx(Animated.View,{style:m.captionWrap,accessibilityElementsHidden:!1,children:_jsx(Text,{variant:"body",align:"center",numberOfLines:3,style:m.captionText,children:x})}):null]})})},ZoomableImage=({image:e,index:t,total:a,active:l,enabled:i,maxScale:s,minScale:o,doubleTapScale:n,haptic:r,imageLabel:u})=>{const c=Dimensions.get("window"),m=useSharedValue(1),d=useSharedValue(1),h=useSharedValue(0),g=useSharedValue(0),p=useSharedValue(0),b=useSharedValue(0),x=useCallback(()=>{m.value=withSpring(1,SPRING_CONFIG),d.value=1,h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),p.value=0,b.value=0},[m,d,h,g,p,b]);React.useEffect(()=>{l||(m.value=withTiming(1,{duration:150}),h.value=withTiming(0,{duration:150}),g.value=withTiming(0,{duration:150}),d.value=1,p.value=0,b.value=0)},[l,m,h,g,d,p,b]);const v=useCallback(()=>{!1!==r&&triggerHaptic("impactLight")},[r]),S=useMemo(()=>({enabled:i,onActivate:()=>{"worklet";d.value=m.value},onUpdate:e=>{"worklet";const t=d.value*e.scale;m.value=t<o?o+.3*(t-o):t>s?s+.2*(t-s):t},onDeactivate:()=>{"worklet";return m.value<o?(m.value=withSpring(o,SPRING_CONFIG),h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),d.value=o,p.value=0,void(b.value=0)):m.value>s?(m.value=withSpring(s,SPRING_CONFIG),void(d.value=s)):void(d.value=m.value)}}),[i,m,d,h,g,p,b,o,s]),y=usePinchGesture(S),I=useMemo(()=>({minPointers:1,maxPointers:1,onActivate:()=>{"worklet";p.value=h.value,b.value=g.value},onUpdate:e=>{"worklet";m.value<=1||(h.value=p.value+e.translationX,g.value=b.value+e.translationY)},onDeactivate:()=>{"worklet";p.value=h.value,b.value=g.value}}),[m,h,g,p,b]),w=usePanGesture(I),C=useMemo(()=>({numberOfTaps:2,onDeactivate:()=>{"worklet";scheduleOnRN(v),m.value>1?(m.value=withSpring(1,SPRING_CONFIG),h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),d.value=1,p.value=0,b.value=0):(m.value=withSpring(n,SPRING_CONFIG),d.value=n)}}),[m,d,h,g,p,b,v,n]),f=useTapGesture(C),_=useCompetingGestures(y,w,f),G=useAnimatedStyle(()=>({transform:[{translateX:h.value},{translateY:g.value},{scale:m.value}]})
|
|
1
|
+
"use strict";import React,{useCallback,useMemo,useRef,useState}from"react";import{Dimensions,Image,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,useCompetingGestures,usePanGesture,usePinchGesture,useTapGesture}from"react-native-gesture-handler";import Animated,{useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{scheduleOnRN}from"react-native-worklets";import{fillText,useMobileUiText}from"../../text/index.js";import{IMAGE_GALLERY_TEXT}from"../../text/phone/imageGallery.g.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{webDeps}from"../../utils/animatedDeps.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Carousel}from"../Carousel/index.js";import{Modal}from"../Modal/Modal.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:t=0,showThumbnails:a=!0,showCounter:l=!0,enableLightbox:i=!0,enablePinchZoom:s=!0,onIndexChange:o,haptic:n,loading:r=!1,accessibilityLabel:u,style:c,testID:m,labels:d})=>{const h=useTheme(),g=useMemo(()=>buildStyles(h),[h]),p=useMobileUiText("imageGallery",IMAGE_GALLERY_TEXT),b=useMemo(()=>({...p,...d}),[p,d]),[x,v]=useState(clamp(t,0,Math.max(0,e.length-1))),[S,y]=useState(!1),I=useCallback(e=>{v(e),o?.(e)},[o]),w=useCallback(()=>{if(!i)return;const e=resolveHaptic(n,"selection");e&&triggerHaptic(e),y(!0)},[i,n]),C=useCallback(()=>{const e=resolveHaptic(n,"selection");e&&triggerHaptic(e),y(!1)},[n]),f=useCallback((t,a)=>{const l=t.alt??fillText(b.imageOf,{index:a+1,total:e.length});return _jsx(Pressable,{onPress:w,accessibilityRole:"image",accessibilityLabel:l,accessibilityHint:i?b.openFullscreen:void 0,style:g.imageWrap,children:_jsx(Image,{source:t.source,style:g.image,resizeMode:"cover"})})},[i,e.length,w,g,b]),_=useCallback(e=>_jsx(Image,{source:e.source,style:g.thumbnailImage,resizeMode:"cover"}),[g]),G=_jsxs(View,{style:[g.container,c],testID:m,accessibilityLabel:u??b.gallery,children:[_jsxs(View,{style:g.carouselWrap,accessibilityElementsHidden:S,importantForAccessibility:S?"no-hide-descendants":"auto",children:[_jsx(Carousel,{data:e,defaultIndex:t,onIndexChange:I,renderItem:f,showPagination:!1,showThumbnails:a,renderThumbnail:_,haptic:n}),l&&e.length>0?_jsx(View,{style:g.counterPill,pointerEvents:"none",children:_jsx(Text,{variant:"label",weight:"semibold",style:{color:h.colors["on-scrim"]},accessibilityLabel:fillText(b.imageOf,{index:x+1,total:e.length}),children:`${x+1} / ${e.length}`})}):null]}),i?_jsx(Lightbox,{open:S,images:e,initialIndex:x,enablePinchZoom:s,showCounter:l,onClose:C,onIndexChange:I,haptic:n,labels:b,testID:m}):null]});return r?_jsx(ImageGallerySkeleton,{images:e,showThumbnails:a,showCounter:l,style:c,testID:m}):G};ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:t=!0,showCounter:a=!0,style:l,testID:i})=>{const s=useTheme(),o=Math.min(e?.length||4,6),n=useMemo(()=>Array.from({length:o},(e,t)=>({key:`sk-thumb-${t}`})),[o]);return _jsxs(View,{style:[{width:"100%"},l],testID:i,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[_jsxs(View,{style:{position:"relative"},children:[_jsx(Skeleton,{width:"100%",height:280,radius:"lg"}),a?_jsx(View,{style:{position:"absolute",top:12,right:12},children:_jsx(Skeleton,{width:44,height:22,radius:"pill"})}):null]}),t?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.md},children:n.map(e=>_jsx(Skeleton,{width:64,height:64,radius:"md",style:{marginRight:s.space.sm}},e.key))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:t,initialIndex:a,enablePinchZoom:l,showCounter:i,onClose:s,onIndexChange:o,haptic:n,labels:r,testID:u})=>{const c=useTheme(),m=useMemo(()=>buildLightboxStyles(c),[c]),d=useRef(null),[h,g]=useState(a),p=useCallback(e=>{if(e!==h){const t=resolveHaptic(n,"selection");t&&triggerHaptic(t),g(e),o(e)}},[h,o,n]),b=useCallback((e,a)=>_jsx(ZoomableImage,{image:e,index:a,total:t.length,active:a===h,enabled:l,maxScale:4,minScale:1,doubleTapScale:2,haptic:n,imageLabel:r.imageOf}),[h,l,t.length,n,r]),x=t[h]?.caption;return _jsx(Modal,{open:e,onClose:s,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:_jsxs(View,{style:m.backdrop,children:[_jsx(Carousel,{ref:d,testID:u?`${u}-lightbox`:void 0,data:t,defaultIndex:a,onIndexChange:p,renderItem:b,showPagination:!1,haptic:n}),i&&t.length>0?_jsx(View,{style:m.counterPill,pointerEvents:"none",children:_jsx(Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:fillText(r.imageOf,{index:h+1,total:t.length}),children:`${h+1} / ${t.length}`})}):null,_jsx(Pressable,{onPress:s,accessibilityRole:"button",accessibilityLabel:r.closeGallery,style:m.closeButton,hitSlop:12,...hitSlopMarker(12),children:(c.settings.icons.close??defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),x?_jsx(Animated.View,{style:m.captionWrap,accessibilityElementsHidden:!1,children:_jsx(Text,{variant:"body",align:"center",numberOfLines:3,style:m.captionText,children:x})}):null]})})},ZoomableImage=({image:e,index:t,total:a,active:l,enabled:i,maxScale:s,minScale:o,doubleTapScale:n,haptic:r,imageLabel:u})=>{const c=Dimensions.get("window"),m=useSharedValue(1),d=useSharedValue(1),h=useSharedValue(0),g=useSharedValue(0),p=useSharedValue(0),b=useSharedValue(0),x=useCallback(()=>{m.value=withSpring(1,SPRING_CONFIG),d.value=1,h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),p.value=0,b.value=0},[m,d,h,g,p,b]);React.useEffect(()=>{l||(m.value=withTiming(1,{duration:150}),h.value=withTiming(0,{duration:150}),g.value=withTiming(0,{duration:150}),d.value=1,p.value=0,b.value=0)},[l,m,h,g,d,p,b]);const v=useCallback(()=>{!1!==r&&triggerHaptic("impactLight")},[r]),S=useMemo(()=>({enabled:i,onActivate:()=>{"worklet";d.value=m.value},onUpdate:e=>{"worklet";const t=d.value*e.scale;m.value=t<o?o+.3*(t-o):t>s?s+.2*(t-s):t},onDeactivate:()=>{"worklet";return m.value<o?(m.value=withSpring(o,SPRING_CONFIG),h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),d.value=o,p.value=0,void(b.value=0)):m.value>s?(m.value=withSpring(s,SPRING_CONFIG),void(d.value=s)):void(d.value=m.value)}}),[i,m,d,h,g,p,b,o,s]),y=usePinchGesture(S),I=useMemo(()=>({minPointers:1,maxPointers:1,onActivate:()=>{"worklet";p.value=h.value,b.value=g.value},onUpdate:e=>{"worklet";m.value<=1||(h.value=p.value+e.translationX,g.value=b.value+e.translationY)},onDeactivate:()=>{"worklet";p.value=h.value,b.value=g.value}}),[m,h,g,p,b]),w=usePanGesture(I),C=useMemo(()=>({numberOfTaps:2,onDeactivate:()=>{"worklet";scheduleOnRN(v),m.value>1?(m.value=withSpring(1,SPRING_CONFIG),h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),d.value=1,p.value=0,b.value=0):(m.value=withSpring(n,SPRING_CONFIG),d.value=n)}}),[m,d,h,g,p,b,v,n]),f=useTapGesture(C),_=useCompetingGestures(y,w,f),G=useAnimatedStyle(()=>({transform:[{translateX:h.value},{translateY:g.value},{scale:m.value}]}),...webDeps([h,g,m]));React.useEffect(()=>{l||x()},[l,x]);const j=e.alt??fillText(u,{index:t+1,total:a});return _jsx(GestureDetector,{gesture:_,children:_jsx(Animated.View,{style:[lightboxImageStyles.container,{width:c.width}],children:_jsx(Animated.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,G],accessibilityLabel:j,accessible:!0})})})},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,...smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:e.colors["on-scrim"]}}),lightboxImageStyles=StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});export{ImageGallery};export default ImageGallery;
|