@webority/mobile-ui 0.130.3 → 0.132.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 +6 -0
- package/dist/canvas-kit/kit.js +5054 -4863
- package/dist/canvas-kit/manifest.json +39 -2
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/BarChart/BarChart.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/commonjs/components/Confetti/Confetti.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
- package/lib/commonjs/components/FileViewer/useFileViewerZoom.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
- package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/commonjs/components/Screen/Screen.js +1 -1
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.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/WheelPicker/Wheel.js +1 -1
- package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/commonjs/navigation/NavigationScreen.js +1 -1
- package/lib/commonjs/network/NetworkStatusBanner.js +1 -1
- package/lib/commonjs/theme/merge.js +1 -1
- package/lib/commonjs/theme/tokens.generated.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/BarChart/BarChart.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/module/components/Confetti/Confetti.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/FileViewer/FileViewer.js +1 -1
- package/lib/module/components/FileViewer/useFileViewerZoom.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/MessageList/MessageList.js +1 -1
- package/lib/module/components/OTPInput/OTPInput.js +1 -1
- package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/module/components/Screen/Screen.js +1 -1
- package/lib/module/components/SegmentedControl/SegmentedControl.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/WheelPicker/Wheel.js +1 -1
- package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/module/navigation/NavigationScreen.js +1 -1
- package/lib/module/network/NetworkStatusBanner.js +1 -1
- package/lib/module/theme/merge.js +1 -1
- package/lib/module/theme/tokens.generated.js +1 -1
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +3 -1
- package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +3 -3
- package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +1 -1
- package/lib/typescript/commonjs/components/Screen/Screen.d.ts +4 -0
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +2 -1
- package/lib/typescript/commonjs/navigation/NavigationScreen.d.ts +2 -2
- package/lib/typescript/commonjs/network/NetworkStatusBanner.d.ts +7 -2
- package/lib/typescript/commonjs/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/commonjs/theme/types.d.ts +5 -1
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +3 -1
- package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +3 -3
- package/lib/typescript/module/components/MessageList/MessageList.d.ts +1 -1
- package/lib/typescript/module/components/Screen/Screen.d.ts +4 -0
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +2 -1
- package/lib/typescript/module/navigation/NavigationScreen.d.ts +2 -2
- package/lib/typescript/module/network/NetworkStatusBanner.d.ts +7 -2
- package/lib/typescript/module/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/module/theme/types.d.ts +5 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.TypingIndicator=exports.DEFAULT_TYPING_INDICATOR_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_index2=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,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=r&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?r(s,a,i):s[a]=e[a]);return s}const DEFAULT_TYPING_INDICATOR_LABELS=exports.DEFAULT_TYPING_INDICATOR_LABELS=Object.freeze({typing:"Typing"}),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 s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:r.value}));return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[a,{backgroundColor:i},t?{opacity:STILL_OPACITY[e]}:s]})},TypingIndicator=({label:e,accessibilityLabel:t,labels:i,bubble:a=!0,style:r,testID:s})=>{const c=(0,_index.useTheme)(),n=(0,_react.useMemo)(()=>buildStyles(c),[c]),o=(0,_useReducedMotion.useReducedMotion)(),l=c.colors["text-subtle"],d=(0,_react.useMemo)(()=>({...DEFAULT_TYPING_INDICATOR_LABELS,...i}),[i]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[n.root,a?n.bubble:null,r],accessible:!0,accessibilityRole:"progressbar",accessibilityLabel:e??t??d.typing,accessibilityState:{busy:!0},"aria-busy":!0,testID:s,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:n.dots,children:DOT_NAMES.map((e,t)=>(0,_jsxRuntime.jsx)(Dot,{index:t,still:o,colour:l,dotStyle:n.dot},e))}),e?(0,_jsxRuntime.jsx)(_index2.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=exports.DEFAULT_TYPING_INDICATOR_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_index2=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,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=r&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?r(s,a,i):s[a]=e[a]);return s}const DEFAULT_TYPING_INDICATOR_LABELS=exports.DEFAULT_TYPING_INDICATOR_LABELS=Object.freeze({typing:"Typing"}),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 s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:r.value}),[r]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[a,{backgroundColor:i},t?{opacity:STILL_OPACITY[e]}:s]})},TypingIndicator=({label:e,accessibilityLabel:t,labels:i,bubble:a=!0,style:r,testID:s})=>{const c=(0,_index.useTheme)(),n=(0,_react.useMemo)(()=>buildStyles(c),[c]),o=(0,_useReducedMotion.useReducedMotion)(),l=c.colors["text-subtle"],d=(0,_react.useMemo)(()=>({...DEFAULT_TYPING_INDICATOR_LABELS,...i}),[i]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[n.root,a?n.bubble:null,r],accessible:!0,accessibilityRole:"progressbar",accessibilityLabel:e??t??d.typing,accessibilityState:{busy:!0},"aria-busy":!0,testID:s,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:n.dots,children:DOT_NAMES.map((e,t)=>(0,_jsxRuntime.jsx)(Dot,{index:t,still:o,colour:l,dotStyle:n.dot},e))}),e?(0,_jsxRuntime.jsx)(_index2.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.Wheel=exports.WHEEL_VISIBLE_ITEMS=exports.WHEEL_CENTER_OFFSET=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const WHEEL_VISIBLE_ITEMS=exports.WHEEL_VISIBLE_ITEMS=5,WHEEL_CENTER_OFFSET=exports.WHEEL_CENTER_OFFSET=Math.floor(WHEEL_VISIBLE_ITEMS/2),HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=(0,_react.memo)(({label:e,index:t,scrollY:a,itemHeight:n,selected:r,theme:i,reducedMotion:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Wheel=exports.WHEEL_VISIBLE_ITEMS=exports.WHEEL_CENTER_OFFSET=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const WHEEL_VISIBLE_ITEMS=exports.WHEEL_VISIBLE_ITEMS=5,WHEEL_CENTER_OFFSET=exports.WHEEL_CENTER_OFFSET=Math.floor(WHEEL_VISIBLE_ITEMS/2),HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=(0,_react.memo)(({label:e,index:t,scrollY:a,itemHeight:n,selected:r,theme:i,reducedMotion:c,onPress:s,editor:l})=>{const{opacity:o,scale:u}=(0,_react.useMemo)(()=>{const e=_reactNative.Animated.subtract(_reactNative.Animated.divide(a,n),t);return{opacity:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),scale:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"})}},[a,n,t]),d=(0,_jsxRuntime.jsx)(_index2.Text,{variant:"h3",weight:r?"semibold":"medium",color:r?"primary":"secondary",numberOfLines:1,maxFontSizeMultiplier:1.5,style:{letterSpacing:i["letter-spacing"].normal},children:e});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.row,{height:n},c?{opacity:o}:{opacity:o,transform:[{scale:u}]}],accessible:!1,importantForAccessibility:"no",children:l??(s?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{focusable:!1,accessible:!1,onPress:()=>s(t),style:styles.rowPress,children:d}):d)})}),Wheel=({label:e,items:t,selectedIndex:a,onIndexChange:n,itemHeight:r,width:i,theme:c,haptic:s,disabled:l,reducedMotion:o,typeable:u,testID:d})=>{const m="web"===_reactNative.Platform.OS,[_,b]=(0,_react.useState)(null),x=(0,_react.useRef)(!1),h=(0,_react.useRef)(null),E=(0,_react.useRef)((0,_index.createAnimatedValue)(a*r)).current,y=(0,_react.useRef)(a*r),p=(0,_react.useRef)(a*r),f=(0,_react.useRef)(a),v=(0,_react.useRef)(0),S=(0,_react.useRef)(null),T=(0,_react.useRef)(()=>{}),g=t.length-1;(0,_react.useEffect)(()=>{f.current=a;const e=a*r;if(p.current===e)return;if(p.current=e,Math.abs(y.current-e)<1)return;y.current=e,m||(0,_index.setNativeValue)(E,e);const t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[a,r,E,m]),(0,_react.useEffect)(()=>{const e=y.current,t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[]),(0,_react.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);const M=(0,_react.useCallback)((e,r)=>{if(!(e===a||e<0||e>g)){if("accessibility"===r){const e=(0,_hapticUtils.resolveHaptic)(s,"denseTick");e&&(0,_hapticUtils.triggerHaptic)(e)}if("keyboard"!==r){const a=t[e];a&&(0,_announce.announce)(a.accessibilityLabel??a.label)}n(e)}},[a,g,t,s,n]),R=(0,_react.useCallback)(()=>{!l&&u&&(x.current=!0,b(String(t[a]?.value??"")))},[l,u,t,a]),I=(0,_react.useCallback)(e=>{if(!x.current)return;x.current=!1,b(null);const a=e.trim();if(!/^\d+$/.test(a))return;const n=Number(a),r=t.findIndex(e=>e.value===n);r>=0&&M(r,"keyboard")},[t,M]);T.current=()=>{S.current=null;const e=Math.max(0,Math.min(g,Math.round(y.current/r))),t=e*r;Math.abs(y.current-t)>=1&&h.current?.scrollTo({y:t,animated:!o}),M(e,"scroll")};const j=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{y:E}}}],{useNativeDriver:!m,listener:e=>{const t=e.nativeEvent.contentOffset.y;y.current=t;const a=Math.round(t/r);if(a!==f.current&&a>=0&&a<=g){const e=Date.now();if(e-v.current>=35){const t=(0,_hapticUtils.resolveHaptic)(s,"denseTick");t&&(0,_hapticUtils.triggerHaptic)(t),v.current=e}f.current=a}m&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>T.current(),120))}}),[E,r,g,s,m]),L=(0,_react.useCallback)(e=>{const t=e.nativeEvent.contentOffset.y;M(Math.max(0,Math.min(g,Math.round(t/r))),"scroll")},[M,g,r]),w=(0,_react.useCallback)(e=>{if(l)return;const t=e.nativeEvent.actionName;"increment"===t?M(Math.min(g,a+1),"accessibility"):"decrement"===t&&M(Math.max(0,a-1),"accessibility")},[l,M,g,a]),A=(0,_react.useCallback)(e=>{l||h.current?.scrollTo({y:e*r,animated:!o})},[l,r,o]),C=(0,_react.useCallback)(({item:t,index:n})=>{const i=n===a,s=i&&null!==_;return(0,_jsxRuntime.jsx)(WheelRow,{label:t.label,index:n,scrollY:E,itemHeight:r,selected:i,theme:c,reducedMotion:o,onPress:i&&u?R:m?A:void 0,editor:s?(0,_jsxRuntime.jsx)(_reactNative.TextInput,{autoFocus:!0,selectTextOnFocus:!0,keyboardType:"number-pad",returnKeyType:"done",accessibilityLabel:e,value:_,onChangeText:b,onSubmitEditing:()=>I(_),onBlur:()=>I(_),style:{width:"100%",padding:c.space.none,textAlign:"center",fontSize:c.text.xl.size,color:c.colors["text-body"],fontWeight:c.weight.semibold,letterSpacing:c["letter-spacing"].normal}}):void 0})},[E,r,a,c,o,m,A,u,R,_,I,e]),N=(0,_react.useCallback)((e,t)=>`${String(e.value)}-${t}`,[]),F=t[a]?t[a].accessibilityLabel??t[a].label:"",H=m?{focusable:!0,role:"spinbutton","aria-label":e,"aria-valuetext":F,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":g,"aria-disabled":l,onKeyDown:e=>{if(l)return;const t={ArrowDown:Math.min(g,a+1),PageDown:Math.min(g,a+1),ArrowUp:Math.max(0,a-1),PageUp:Math.max(0,a-1),Home:0,End:g}[e.key];void 0!==t&&(e.preventDefault?.(),M(t,"keyboard"))}}:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[void 0===i?styles.columnFlex:{width:i},{height:r*WHEEL_VISIBLE_ITEMS},styles.column,l?styles.disabled:null],testID:d,...H,children:[m?null:(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:styles.a11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:e,accessibilityValue:{text:F},accessibilityState:{disabled:Boolean(l)},"aria-disabled":Boolean(l),accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:w}),(0,_jsxRuntime.jsx)(_reactNative.Animated.ScrollView,{ref:h,showsVerticalScrollIndicator:!1,snapToInterval:r,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEnabled:!l,nestedScrollEnabled:!0,scrollEventThrottle:16,onScroll:j,onMomentumScrollEnd:L,contentOffset:{x:0,y:a*r},contentContainerStyle:{paddingVertical:r*WHEEL_CENTER_OFFSET},style:[styles.list,{height:r*WHEEL_VISIBLE_ITEMS}],importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:C({item:e,index:t})},N(e,t)))})]})};exports.Wheel=Wheel;const styles=_reactNative.StyleSheet.create({column:{overflow:"hidden"},columnFlex:{flex:1},disabled:{opacity:.5},list:{flexGrow:0},row:{alignItems:"center",justifyContent:"center"},rowPress:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",flex:1},a11yLayer:{..._reactNative.StyleSheet.absoluteFill,zIndex:2}});
|
|
@@ -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")),_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 S=(0,_react.useCallback)(()=>{const e=(0,_index.resolveHaptic)(l,"impactLight");e&&(0,_index.triggerHaptic)(e)},[l]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(!i).onStart(()=>{"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}).onEnd(()=>{"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]),h=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().enabled(!i).minPointers(1).maxPointers(1).onStart(()=>{"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)}).onEnd(()=>{"worklet";_.value=d.value,m.value=o.value}),[i,s,d,o,_,m]),p=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().enabled(!i).numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(S)(),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,S,r]),I=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(R,h,p),[R,h,p]),G=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:d.value},{translateY:o.value},{scale:s.value}]}));return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:I,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,G],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
|
+
"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")),_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 S=(0,_react.useCallback)(()=>{const e=(0,_index.resolveHaptic)(l,"impactLight");e&&(0,_index.triggerHaptic)(e)},[l]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(!i).onStart(()=>{"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}).onEnd(()=>{"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]),h=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().enabled(!i).minPointers(1).maxPointers(1).onStart(()=>{"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)}).onEnd(()=>{"worklet";_.value=d.value,m.value=o.value}),[i,s,d,o,_,m]),p=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().enabled(!i).numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(S)(),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,S,r]),I=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(R,h,p),[R,h,p]),G=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:d.value},{translateY:o.value},{scale:s.value}]}),[d,o,s]);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:I,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,G],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.NavigationScreen=NavigationScreen;var _bottomTabs=require("@react-navigation/bottom-tabs"),_native=require("@react-navigation/native"),_react=require("react"),_index=require("../components/Screen/index.js"),_index2=require("../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const TAB_EDGES=["top"];function NavigationScreen({kind:e="pushed",appBar:t=!0,onBack:i,...n}){const o=(0,_native.useNavigation)(),r=(0,_react.useContext)(_bottomTabs.BottomTabBarHeightContext),a=!0===(0,_index2.useTheme)().settings.components.screen?.tabBarFloats,s=t?n:{...n,title:void 0,subtitle:void 0,leading:void 0,rightActions:void 0};return"tab"===e?(0,_jsxRuntime.jsx)(_index.Screen,{...s,largeTitle:!
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NavigationScreen=NavigationScreen;var _bottomTabs=require("@react-navigation/bottom-tabs"),_native=require("@react-navigation/native"),_react=require("react"),_index=require("../components/Screen/index.js"),_index2=require("../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const TAB_EDGES=["top"];function NavigationScreen({kind:e="pushed",appBar:t=!0,onBack:i,...n}){const o=(0,_native.useNavigation)(),r=(0,_react.useContext)(_bottomTabs.BottomTabBarHeightContext),a=!0===(0,_index2.useTheme)().settings.components.screen?.tabBarFloats,s=t?n:{...n,title:void 0,subtitle:void 0,leading:void 0,trailing:void 0,rightActions:void 0};return"tab"===e?(0,_jsxRuntime.jsx)(_index.Screen,{...s,largeTitle:!1,edges:TAB_EDGES,bottomInset:a?r??0:0}):(0,_jsxRuntime.jsx)(_index.Screen,{...s,largeTitle:!1,onBack:"root"!==e&&t?i??o.goBack:void 0})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NetworkStatusBanner=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../hooks/usePresenceMotion.js"),_index=require("../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const NetworkStatusBanner=({message:e="You are offline. Some features may be unavailable.",
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NetworkStatusBanner=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../hooks/usePresenceMotion.js"),_index=require("../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const NetworkStatusBanner=({message:e="You are offline. Some features may be unavailable.",restoredMessage:t="You are back online.",restoredDuration:a=2e3,position:r="top",style:o,disabled:n=!1,safeArea:i=!0})=>{const s=(0,_index.useTheme)(),u=(0,_usePresenceMotion.usePresenceMotion)(),c=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),l=i?"top"===r?c.top:c.bottom:0,[d,f]=(0,_react.useState)(0),m=d>0?d:56+l,{isConnected:_,isInternetReachable:p}=(0,_mobileCore.useNetworkStatus)(),v=!(n||_&&!1!==p),[b,x]=(0,_react.useState)("hidden"),[N,g]=(0,_react.useState)("offline");(0,_react.useEffect)(()=>{"hidden"!==b&&g(b)},[b]),(0,_react.useEffect)(()=>{x(v?"offline":n?"hidden":e=>"offline"===e?"restored":e)},[v,n]),(0,_react.useEffect)(()=>{if("restored"!==b)return;const e=setTimeout(()=>x("hidden"),a);return()=>clearTimeout(e)},[b,a]);const S="hidden"!==b,h="restored"===b||"hidden"===b&&"restored"===N,y=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current,A=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current,w=u.duration("default");(0,_react.useEffect)(()=>{_reactNative.Animated.parallel([_reactNative.Animated.timing(y,{toValue:S?1:0,duration:s.motion.duration.default,useNativeDriver:!0}),_reactNative.Animated.timing(A,{toValue:S?1:0,duration:w,useNativeDriver:!0})]).start()},[S,y,A,s.motion.duration.default,w]);const R=(0,_react.useMemo)(()=>buildStyles(s),[s]),j=y.interpolate({inputRange:[0,1],outputRange:u.range("top"===r?-m:m,0)});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:S?"auto":"none",accessibilityRole:"alert",accessibilityLiveRegion:S?"polite":"none",onLayout:e=>f(e.nativeEvent.layout.height),style:[R.container,"top"===r?R.top:R.bottom,"top"===r?{paddingTop:s.space.sm+l}:{paddingBottom:s.space.sm+l},{backgroundColor:h?s.colors["online-fill"]:s.colors["offline-fill"],opacity:A,transform:[{translateY:j}]},o],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:h?s.colors["on-success"]:s.colors["on-danger"],fontSize:s.text.sm.size,...(0,_index.fontFor)(s,"semibold"),textAlign:"center"},numberOfLines:2,children:h?t:e})})};exports.NetworkStatusBanner=NetworkStatusBanner;const buildStyles=e=>_reactNative.StyleSheet.create({container:{position:"absolute",left:0,right:0,paddingVertical:e.space.sm,paddingHorizontal:e.space.lg,zIndex:1e3,elevation:8},top:{top:0},bottom:{bottom:0}});var _default=exports.default=NetworkStatusBanner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeBrand=void 0;var _componentSizes=require("./componentSizes.js"),_tokensGenerated=require("./tokens.generated.js"),_toneInk=require("./toneInk.js");const HINT="Run webority upgrade to rename old names.",BRAND_KEYS=["colors","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0}},isPlainObject=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),validateBrand=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`A brand is an object of colors, radius and font; got ${typeof e}. ${HINT}`);for(const t of Object.keys(e))if(!BRAND_KEYS.includes(t))throw new Error(`A brand sets colors, radius and font only; ${t} is not allowed (allowed: colors, radius, font). ${HINT}`);const t=e.colors;if(void 0!==t&&!isPlainObject(t))throw new Error(`A brand's colors is an object of light and dark; got ${typeof t}. ${HINT}`);for(const e of Object.keys(t??{})){if(!COLOR_MODES.includes(e))throw new Error(`A brand sets colours under light and dark only; ${e} is not allowed (allowed: light, dark). ${HINT}`);const o=t[e];for(const e of Object.keys(o)){if(!_tokensGenerated.COLOR_NAMES.includes(e))throw new Error(`unknown colour ${e}; allowed: ${_tokensGenerated.COLOR_NAMES.join(", ")}. ${HINT}`);if(void 0!==o[e]&&"string"!=typeof o[e])throw new Error(`colour ${e} must be a string; got ${typeof o[e]}.`)}}const o=e.radius;if(void 0!==o&&!isPlainObject(o))throw new Error(`A brand's radius is an object of radius names; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o??{})){const t=o[e];if(!_tokensGenerated.RADIUS_NAMES.includes(e))throw new Error(`unknown radius ${e}; allowed: ${RADIUS_ALLOWED}. ${HINT}`);if(FIXED_RADII.includes(e))throw new Error(`radius ${e} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof t||!Number.isFinite(t))throw new Error(`radius ${e} must be a number; got ${typeof t}.`)}const n=e.font;if(void 0!==n&&!isPlainObject(n))throw new Error(`A brand's font is an object of font names; got ${typeof n}. ${HINT}`);for(const e of Object.keys(n??{})){if(!_tokensGenerated.FONT_NAMES.includes(e))throw new Error(`unknown font ${e}; allowed: ${_tokensGenerated.FONT_NAMES.join(", ")}. ${HINT}`);const t=n[e];if(!isPlainObject(t))throw new Error(`font ${e} must be an object of weights; got ${typeof t}. ${HINT}`);for(const o of Object.keys(t)){if(!_tokensGenerated.WEIGHT_NAMES.includes(o))throw new Error(`unknown font weight ${o} in font ${e}; allowed: ${_tokensGenerated.WEIGHT_NAMES.join(", ")}. ${HINT}`);const n=t[o];if("string"!=typeof n||0===n.length)throw new Error(`font ${e} weight ${o} must be a non-empty string.`)}}},validateSettings=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`Theme settings is an object; got ${typeof e}. ${HINT}`);for(const t of Object.keys(e))if(!SETTINGS_KEYS.includes(t))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${t} is not allowed. ${HINT}`);const t=e.components;if(void 0===t)return;if(!isPlainObject(t))throw new Error(`Theme settings components is an object of component names; got ${typeof t}. ${HINT}`);const o=COMPONENT_SETTING_KEYS;for(const e of Object.keys(t)){if(!Object.keys(o).includes(e))throw new Error(`unknown component ${e} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}. ${HINT}`);const n=t[e];if(void 0===n)continue;if(!isPlainObject(n))throw new Error(`theme settings for ${e} is an object; got ${typeof n}. ${HINT}`);const r=o[e];for(const t of Object.keys(n))if(!(t in r))throw new Error(`unknown setting ${t} for ${e}; allowed: ${Object.keys(r).join(", ")}. ${HINT}`)}},TONES=["primary","success","warning","danger","info"],mergeBrand=(e,t,o)=>{validateBrand(t),validateSettings(o);const n=Object.fromEntries(Object.entries(t?.colors?.[e.mode]??{}).filter(([,e])=>void 0!==e)),r={...e.colors,...n},s={...e.radius,...t?.radius},i={...e.font};for(const o of Object.keys(t?.font??{}))i[o]={...e.font[o],...t?.font?.[o]};const a=[r.bg,r["bg-subtle"],r["bg-muted"]],d={};for(const t of TONES){const o="string"==typeof n[t];let s=r[t];if(o||"string"==typeof n[`on-${t}`]){const e=(0,_toneInk.deriveSolidFill)(s,r[`on-${t}`]);e!==s&&(d[t]=e,s=e)}if(o&&"string"!=typeof n[`${t}-text`]&&(d[`${t}-text`]=(0,_toneInk.deriveToneInk)(s,a,e.mode)),"primary"===t&&(o||void 0!==d.primary)){const t=(0,_toneInk.deriveStateFills)(s,r["on-primary"],{fill:e.colors.primary,hover:e.colors["primary-hover"],pressed:e.colors["primary-pressed"]});"string"!=typeof n["primary-hover"]&&(d["primary-hover"]=t.hover),"string"!=typeof n["primary-pressed"]&&(d["primary-pressed"]=t.pressed)}}const l={},f=new Set([...Object.keys(e.settings.components),...Object.keys(o?.components??{})]);for(const t of f)l[t]={...e.settings.components[t],...o?.components?.[t]};const c=o?.maxFontSizeMultiplier??e.settings.maxFontSizeMultiplier,u={icons:{...e.settings.icons,...o?.icons},gradients:{...e.settings.gradients,...o?.gradients},textVariants:{...e.settings.textVariants,...o?.textVariants},components:l,...void 0===c?{}:{maxFontSizeMultiplier:c}},p={...e,colors:{...r,...d},radius:s,font:i,settings:u};return(0,_componentSizes.validateComponentTokens)(p),p};exports.mergeBrand=mergeBrand;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeBrand=void 0;var _componentSizes=require("./componentSizes.js"),_tokensGenerated=require("./tokens.generated.js"),_toneInk=require("./toneInk.js");const HINT="Run webority upgrade to rename old names.",BRAND_KEYS=["colors","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0,headerShadowOnScroll:!0}},isPlainObject=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),validateBrand=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`A brand is an object of colors, radius and font; got ${typeof e}. ${HINT}`);for(const t of Object.keys(e))if(!BRAND_KEYS.includes(t))throw new Error(`A brand sets colors, radius and font only; ${t} is not allowed (allowed: colors, radius, font). ${HINT}`);const t=e.colors;if(void 0!==t&&!isPlainObject(t))throw new Error(`A brand's colors is an object of light and dark; got ${typeof t}. ${HINT}`);for(const e of Object.keys(t??{})){if(!COLOR_MODES.includes(e))throw new Error(`A brand sets colours under light and dark only; ${e} is not allowed (allowed: light, dark). ${HINT}`);const o=t[e];for(const e of Object.keys(o)){if(!_tokensGenerated.COLOR_NAMES.includes(e))throw new Error(`unknown colour ${e}; allowed: ${_tokensGenerated.COLOR_NAMES.join(", ")}. ${HINT}`);if(void 0!==o[e]&&"string"!=typeof o[e])throw new Error(`colour ${e} must be a string; got ${typeof o[e]}.`)}}const o=e.radius;if(void 0!==o&&!isPlainObject(o))throw new Error(`A brand's radius is an object of radius names; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o??{})){const t=o[e];if(!_tokensGenerated.RADIUS_NAMES.includes(e))throw new Error(`unknown radius ${e}; allowed: ${RADIUS_ALLOWED}. ${HINT}`);if(FIXED_RADII.includes(e))throw new Error(`radius ${e} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof t||!Number.isFinite(t))throw new Error(`radius ${e} must be a number; got ${typeof t}.`)}const n=e.font;if(void 0!==n&&!isPlainObject(n))throw new Error(`A brand's font is an object of font names; got ${typeof n}. ${HINT}`);for(const e of Object.keys(n??{})){if(!_tokensGenerated.FONT_NAMES.includes(e))throw new Error(`unknown font ${e}; allowed: ${_tokensGenerated.FONT_NAMES.join(", ")}. ${HINT}`);const t=n[e];if(!isPlainObject(t))throw new Error(`font ${e} must be an object of weights; got ${typeof t}. ${HINT}`);for(const o of Object.keys(t)){if(!_tokensGenerated.WEIGHT_NAMES.includes(o))throw new Error(`unknown font weight ${o} in font ${e}; allowed: ${_tokensGenerated.WEIGHT_NAMES.join(", ")}. ${HINT}`);const n=t[o];if("string"!=typeof n||0===n.length)throw new Error(`font ${e} weight ${o} must be a non-empty string.`)}}},validateSettings=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`Theme settings is an object; got ${typeof e}. ${HINT}`);for(const t of Object.keys(e))if(!SETTINGS_KEYS.includes(t))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${t} is not allowed. ${HINT}`);const t=e.components;if(void 0===t)return;if(!isPlainObject(t))throw new Error(`Theme settings components is an object of component names; got ${typeof t}. ${HINT}`);const o=COMPONENT_SETTING_KEYS;for(const e of Object.keys(t)){if(!Object.keys(o).includes(e))throw new Error(`unknown component ${e} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}. ${HINT}`);const n=t[e];if(void 0===n)continue;if(!isPlainObject(n))throw new Error(`theme settings for ${e} is an object; got ${typeof n}. ${HINT}`);const r=o[e];for(const t of Object.keys(n))if(!(t in r))throw new Error(`unknown setting ${t} for ${e}; allowed: ${Object.keys(r).join(", ")}. ${HINT}`)}},TONES=["primary","success","warning","danger","info"],mergeBrand=(e,t,o)=>{validateBrand(t),validateSettings(o);const n=Object.fromEntries(Object.entries(t?.colors?.[e.mode]??{}).filter(([,e])=>void 0!==e)),r={...e.colors,...n},s={...e.radius,...t?.radius},i={...e.font};for(const o of Object.keys(t?.font??{}))i[o]={...e.font[o],...t?.font?.[o]};const a=[r.bg,r["bg-subtle"],r["bg-muted"]],d={};for(const t of TONES){const o="string"==typeof n[t];let s=r[t];if(o||"string"==typeof n[`on-${t}`]){const e=(0,_toneInk.deriveSolidFill)(s,r[`on-${t}`]);e!==s&&(d[t]=e,s=e)}if(o&&"string"!=typeof n[`${t}-text`]&&(d[`${t}-text`]=(0,_toneInk.deriveToneInk)(s,a,e.mode)),"primary"===t&&(o||void 0!==d.primary)){const t=(0,_toneInk.deriveStateFills)(s,r["on-primary"],{fill:e.colors.primary,hover:e.colors["primary-hover"],pressed:e.colors["primary-pressed"]});"string"!=typeof n["primary-hover"]&&(d["primary-hover"]=t.hover),"string"!=typeof n["primary-pressed"]&&(d["primary-pressed"]=t.pressed)}}const l={},f=new Set([...Object.keys(e.settings.components),...Object.keys(o?.components??{})]);for(const t of f)l[t]={...e.settings.components[t],...o?.components?.[t]};const c=o?.maxFontSizeMultiplier??e.settings.maxFontSizeMultiplier,u={icons:{...e.settings.icons,...o?.icons},gradients:{...e.settings.gradients,...o?.gradients},textVariants:{...e.settings.textVariants,...o?.textVariants},components:l,...void 0===c?{}:{maxFontSizeMultiplier:c}},p={...e,colors:{...r,...d},radius:s,font:i,settings:u};return(0,_componentSizes.validateComponentTokens)(p),p};exports.mergeBrand=mergeBrand;
|
|
@@ -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","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","on-danger","info","info-soft","info-text","on-info","primary-pressed","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","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",text:"#252f4a","text-body":"#0f0f1a","text-muted":"#52525b","text-subtle":"#62626b","text-inverse":"#ffffff",link:"#5b5bd6",border:"#e5e5ec","border-subtle":"#efeff3","field-bg":"#f9fbfc","field-border":"#ebedf3","field-border-focus":"#bed2f9","focus-ring":"#5b5bd6",scrim:"#0f0f1a80","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#5b5bd6","primary-hover":"#4f4fbf","primary-soft":"#eeeefc","primary-text":"#4f4fd3","on-primary":"#ffffff","primary-wash":"#5b5bd614","primary-wash-strong":"#5b5bd633",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","on-danger":"#ffffff",info:"#1b6ef5","info-soft":"#e9f3ff","info-text":"#0958d9","on-info":"#ffffff","primary-pressed":"#4040a8","on-neutral-strong":"#ffffff","text-disabled":"#b4b4bb","surface-pressed":"#0f0f1a0f","surface-hover":"#0f0f1a0a","surface-selected":"#5b5bd61a","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":"#5b5bd6","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,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":34,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":44,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":58,text:"xl",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",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:"#ffffff",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","on-danger":"#0f0f1a",info:"#60a5fa","info-soft":"#056ee92e","info-text":"#60a5fa","on-info":"#0f0f1a","primary-pressed":"#a8a8f2","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,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":34,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":44,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":58,text:"xl",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","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","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","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",text:"#252f4a","text-body":"#0f0f1a","text-muted":"#52525b","text-subtle":"#62626b","text-inverse":"#ffffff",link:"#5b5bd6",border:"#e5e5ec","border-subtle":"#efeff3","field-bg":"#f9fbfc","field-border":"#ebedf3","field-border-focus":"#bed2f9","focus-ring":"#5b5bd6",scrim:"#0f0f1a80","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#5b5bd6","primary-hover":"#4f4fbf","primary-soft":"#eeeefc","primary-text":"#4f4fd3","on-primary":"#ffffff","primary-wash":"#5b5bd614","primary-wash-strong":"#5b5bd633",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":"#4040a8","on-neutral-strong":"#ffffff","text-disabled":"#b4b4bb","surface-pressed":"#0f0f1a0f","surface-hover":"#0f0f1a0a","surface-selected":"#5b5bd61a","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":"#5b5bd6","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,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":34,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":44,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":58,text:"xl",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",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:"#ffffff",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","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,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":34,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":44,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":58,text:"xl",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 +1 @@
|
|
|
1
|
-
"use strict";import{Fragment,forwardRef,useCallback,useMemo,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{Menu}from"../Menu/index.js";import{Text as ThemedText}from"../Text/Text.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4;export const DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"});const variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=forwardRef(({action:e,side:t,badgeStyle:i,haptic:n,flush:
|
|
1
|
+
"use strict";import{Fragment,forwardRef,useCallback,useMemo,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{Menu}from"../Menu/index.js";import{Text as ThemedText}from"../Text/Text.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4;export const DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"});const variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=forwardRef(({action:e,side:t,badgeStyle:i,haptic:n,flush:l,onPress:o},s)=>{const r=useTheme(),{style:a,pressIn:c,pressOut:d}=usePressAnimation({enabled:!0}),p=useMemo(()=>buildActionStyles(r),[r]),u=e.badge,h=void 0!==u&&0!==u,g=void 0!==e.label;return _jsx(Animated.View,{style:a,children:_jsxs(Pressable,{ref:s,onPress:t=>{const i=resolveHaptic(n,"selection");i&&triggerHaptic(i),"onPress"in e&&e.onPress(),o?.(t)},onPressIn:c,onPressOut:d,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,android_ripple:{color:r.colors["surface-pressed"],borderless:!g},style:({pressed:e})=>[g?p.textButton:p.actionButton,l?null:"left"===t?p.actionLeft:p.actionRight,e&&!g?p.actionPressed:null,e&&g?p.textPressed:null],children:[g?_jsx(ThemedText,{variant:"body",weight:"semibold",color:"link",numberOfLines:1,children:e.label}):_jsx(View,{style:p.iconWrap,children:e.icon}),h?_jsx(View,{style:[p.badge,i],pointerEvents:"none",children:_jsx(ThemedText,{variant:"caption",weight:"semibold",numberOfLines:1,style:p.badgeText,children:String(u)})}):null,e.dot?_jsx(View,{testID:e.testID?`${e.testID}-dot`:"appbar-action-dot",style:p.dot,pointerEvents:"none"}):null]})})}),COLLAPSE_RANGE=60,AppBar=forwardRef((e,t)=>{const{title:i,subtitle:n,titleAlignment:l="left",leftAction:o,rightActions:s,leading:r,trailing:a,onBack:c,gutter:d,titleVariant:p,titleOffset:u,height:h,divider:g,elevated:m=!1,variant:x="default",transparent:f=!1,scrollY:b,style:y,containerStyle:A,titleStyle:S,subtitleStyle:j,badgeStyle:w,haptic:_,labels:v,testID:I}=e;warnInvalidValue("AppBar","variant",e.variant,["default","large","compact"]),warnInvalidValue("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const T=useMemo(()=>({...DEFAULT_APP_BAR_LABELS,...v}),[v]),B=useTheme(),L=useSafeAreaInsets(),R=useMemo(()=>variantSize(B,x),[B,x]),C=useMemo(()=>buildStyles(B),[B]),z="large"===x,P=z&&void 0!==b,[V,O]=useState(40),D=useCallback(e=>O(e.nativeEvent.layout.height),[]),W=o??(c?{icon:_jsx(AppIcon,{name:"arrow-left",size:24,color:B.colors["text-body"]}),onPress:c,accessibilityLabel:T.back}:void 0),E=a?void 0:s?.[s.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?B.space.sm:Math.max((44-(e.glyphSize??24))/2,0),k=void 0===d?null:{paddingLeft:Math.max(d-opticalInset(W),0),paddingRight:Math.max(d-opticalInset(E),0)},H=void 0!==u,F=Boolean(W)||Boolean(r),M=!H&&"left"===l&&Boolean(W),N=H||M||!F&&"left"===l,$="default"!==x||F?R.titleSize:B.text.xl.size,U=g??!1,G=StyleSheet.hairlineWidth,Z=useMemo(()=>b?{rootHeight:b.interpolate({inputRange:[0,60],outputRange:[L.top+R.height+V,L.top+R.height],extrapolate:"clamp"}),titleRowOpacity:b.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:b.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:b.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}:null,[b,L.top,R.height,V]),Y=i?p?_jsx(ThemedText,{variant:p,align:"center"===l?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[C.titleVariant,S],children:i}):_jsx(Animated.Text,{accessibilityRole:"header",style:[C.title,{fontSize:$,fontWeight:B.weight[R.titleWeight],textAlign:"center"===l?"center":"left"},n?C.stackedText:null,S],numberOfLines:1,children:i}):null,q=P&&Z&&i?_jsx(Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[C.title,{fontSize:B.text.lg.size,fontWeight:B.weight.semibold,textAlign:"center"===l?"center":"left",opacity:Z.compactTitleOpacity}],numberOfLines:1,children:i}):null,J=n?_jsx(Animated.Text,{style:[C.subtitle,{textAlign:"center"===l?"center":"left"},j],numberOfLines:R.subtitleLines,children:n}):null,K=_jsxs(View,{style:[C.titleColumn,"center"===l?C.titleColumnCenter:null],children:[Y,J]}),Q=P?Animated.View:View,X=P&&Z?{height:Z.rootHeight,overflow:"hidden"}:z&&void 0===h?null:{height:(h??R.height)+L.top};return _jsxs(Q,{ref:t,testID:I,style:[C.root,{paddingTop:L.top,backgroundColor:f?"transparent":B.colors.surface},X,!P&&U?{borderBottomWidth:G,borderBottomColor:B.colors.border}:null,m&&!f?B.shadow.card:null,A,y],children:[P&&Z&&U?_jsx(Animated.View,{pointerEvents:"none",style:[C.animatedBorder,{backgroundColor:B.colors.border,opacity:Z.borderOpacity}]}):null,_jsxs(View,{testID:z&&I?`${I}-bar-row`:void 0,style:[C.row,z?{height:R.height}:{flex:1},k],children:[_jsxs(View,{testID:I?`${I}-leading-slot`:void 0,style:[C.sideSlot,N?C.sideSlotCompact:null],children:[W?_jsx(ActionButton,{action:W,side:"left",haptic:_,flush:H||M}):null,null!=r&&!1!==r?_jsx(View,{style:C.slotNode,children:r}):null]}),_jsx(View,{pointerEvents:"none",style:[C.center,"center"===l?C.centerAligned:C.centerLeft,H?{paddingLeft:F?u:B.space.none,paddingRight:B.space.none}:N?{paddingLeft:B.space.none}:null],children:z?q:K}),_jsxs(View,{style:[C.sideSlot,C.sideSlotRight,H?C.sideSlotCompact:null],children:[s?.map((e,t)=>_jsx(Fragment,{children:"menu"in e?_jsx(Menu,{items:e.menu,title:e.menuTitle,haptic:_,trigger:_jsx(ActionButton,{action:e,side:"right",badgeStyle:w,haptic:_,flush:H})}):_jsx(ActionButton,{action:e,side:"right",badgeStyle:w,haptic:_,flush:H})},`appbar-right-${t}`)),null!=a&&!1!==a?_jsx(View,{style:C.slotNode,children:a}):null]})]}),z?_jsx(Animated.View,{testID:I?`${I}-title-row`:void 0,onLayout:P?D:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??B.space.md,paddingBottom:B.space.sm},P&&Z?{opacity:Z.titleRowOpacity}:null],children:K}):null]})});AppBar.displayName="AppBar";const buildStyles=e=>StyleSheet.create({root:{width:"100%"},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.xs},sideSlot:{flexDirection:"row",alignItems:"center",minWidth:48},sideSlotRight:{justifyContent:"flex-end"},sideSlotCompact:{minWidth:0},slotNode:{flexDirection:"row",alignItems:"center"},center:{flex:1,minWidth:0,paddingHorizontal:e.space.xs},centerAligned:{alignItems:"center"},centerLeft:{alignItems:"flex-start"},titleColumn:{flexDirection:"column",maxWidth:"100%"},titleColumnCenter:{alignItems:"center"},title:{color:e.colors["text-body"]},titleVariant:{includeFontPadding:!1,textAlignVertical:"center"},stackedText:{includeFontPadding:!1},subtitle:{includeFontPadding:!1,color:e.colors["text-subtle"],fontSize:e.text.sm.size,fontWeight:e.weight.normal},animatedBorder:{position:"absolute",left:0,right:0,bottom:0,height:StyleSheet.hairlineWidth}}),buildActionStyles=e=>StyleSheet.create({actionButton:{width:44,height:44,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center"},actionLeft:{marginRight:e.space.xs},actionRight:{marginLeft:e.space.xs},actionPressed:{backgroundColor:e.colors["surface-pressed"]},textButton:{minWidth:44,minHeight:44,paddingHorizontal:e.space.sm,alignItems:"center",justifyContent:"center"},textPressed:{opacity:.6},dot:{position:"absolute",top:10,right:10,width:8,height:8,borderRadius:e.radius.pill,backgroundColor:e.colors.danger},iconWrap:{alignItems:"center",justifyContent:"center"},badge:{position:"absolute",top:4,right:4,minWidth:16,height:16,paddingHorizontal:e.space.xs,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors.danger,alignItems:"center",justifyContent:"center"},badgeText:{color:e.colors["on-danger"],fontSize:e.text.xs.size,fontWeight:e.weight.semibold,lineHeight:13}});export{AppBar};export default AppBar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{formatCompactNumber,formatNumber}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import{useControllableState}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{barScale}from"./scale.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`});const AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=
|
|
1
|
+
"use strict";import{formatCompactNumber,formatNumber}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import{useControllableState}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{barScale}from"./scale.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`});const AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,defaultFormatValue=e=>formatNumber(e),defaultFormatTick=e=>formatCompactNumber(e),BarChart=forwardRef((e,t)=>{const{data:r,tone:a="primary",color:s,series:o,height:i=160,label:l,summary:n,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:m,selection:h,defaultSelection:d=null,onSelect:p,haptic:x,labels:f,style:b,testID:y}=e;warnInvalidValue("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const _=useMemo(()=>({...DEFAULT_BAR_CHART_LABELS,...f}),[f]),g=useTheme(),w=r.length,[S,j]=useState(0),[T,C]=useControllableState({value:h,defaultValue:d,onChange:p}),M=null!==T&&T>=0&&T<w?T:null,v=useRef(M);v.current=M;const R=useRef(-1),A=resolveHaptic(x,"tick"),L=useCallback(()=>{A&&triggerHaptic(A)},[A]),V=m??(w>0&&w<=7),I=void 0!==o&&o.length>0,D=useMemo(()=>I?o.map((e,t)=>e.tone??STACK_TONES[t%STACK_TONES.length]):[],[I,o]),E=useMemo(()=>I?o.map(e=>e.key):[],[I,o]),$=useMemo(()=>I?r.map(e=>o.map(t=>safe(e.values?.[t.key]))):null,[r,o,I]),k=useMemo(()=>$?$.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,$]),B=useMemo(()=>$?$.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):k,[$,k]),H=useMemo(()=>barScale(B),[B]),O=V?20:6,F=V&&H.min<0?20:6,N=Math.max(1,i-O-F),G=useCallback(e=>O+(H.max-e)/(H.max-H.min)*N,[O,H.max,H.min,N]),W=G(0),U=useMemo(()=>H.ticks.map(e=>u(e)),[H.ticks,u]),z=Math.ceil(8*Math.max(...U.map(e=>e.length),1)*1.2)+g.space.xs,P=w>0?S/w:0,X=Math.max(1,Math.ceil(44/Math.max(1,P||44))),K=useCallback(e=>{const t=r[e];return t.accessibilityLabel?t.accessibilityLabel:$&&o?`${t.label}, ${o.map((t,r)=>`${t.label} ${c($[e][r])}`).join(", ")}`:`${t.label}, ${c(k[e])}`},[r,c,k,$,o]),J=useMemo(()=>{let e=-1;return k.forEach((t,r)=>{(-1===e||t>k[e])&&(e=r)}),e},[k]),Y=n??(J>=0?_.highest(r[J].label,c(k[J])):""),Z=useRef({fire:L,setSelected:C,count:w,plotWidth:S});Z.current={fire:L,setSelected:C,count:w,plotWidth:S};const q=useMemo(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Z.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===R.current||(R.current=t,Z.current.fire(),Z.current.setSelected(t))},e=Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{R.current=v.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(y?`${y}-pan`:"bar-chart-pan"),t=Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Z.current.fire(),R.current=r,Z.current.setSelected(r===v.current?null:r))}).withTestId(y?`${y}-tap`:"bar-chart-tap");return Gesture.Race(e,t)},[y]),Q=useCallback(e=>{if(0===w)return;const t=v.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(w-1,t+1):null===t?w-1:Math.max(0,t-1);r!==t&&(L(),C(r))},[w,L,C]),ee=useCallback(e=>{const t=Math.round(e.nativeEvent.layout.width);j(e=>e===t?e:t)},[]),te=s??toneColor(g,a),re=g.radius.sm,ae=l??_.chart,se=0===w?`${ae}, ${_.noData}`:Y?`${ae}, ${Y}`:ae,oe=null===M?Y:K(M),ie=Math.min(40,Math.max(4,.6*P)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),s=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===s)return null;const o=G(a),i=[];let l=0,n=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:n,s=a+e;e>0?l=s:n=s;const c=G(a),u=G(s);i.push(_jsx(View,{testID:y?`${y}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-o,height:Math.abs(c-u),backgroundColor:toneColor(g,D[r])}},E[r]))}),_jsx(View,{testID:y?`${y}-bar-${t}`:void 0,style:{position:"absolute",left:(P-ie)/2,top:o,width:ie,height:Math.max(2,G(s)-o),overflow:"hidden",opacity:r?.4:1,...smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...s<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:i})},le=k.map((e,t)=>{const r=G(e),a=e>=0?r:W,s=0===e?0:Math.max(2,Math.abs(r-W)),o=null!==M&&M!==t;return _jsxs(View,{style:[styles.slot,{height:i}],children:[S>0&&$?renderStack($[t],t,o):null,S>0&&!$&&s>0?_jsx(View,{testID:y?`${y}-bar-${t}`:void 0,style:{position:"absolute",left:(P-ie)/2,top:a,width:ie,height:s,backgroundColor:te,opacity:o?.4:1,...smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,V&&S>0?_jsx(Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?($?G(B[2*t]):r)-20+2:($?G(B[2*t+1]):r)+2},children:u(e)}):null]},t)});return 0===w?_jsx(View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:se,testID:y,style:[styles.root,b],children:_jsx(Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):_jsxs(View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:se,accessibilityValue:{min:0,max:w-1,now:M??0,text:oe},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:y,style:[styles.root,b],children:[_jsx(View,{style:[styles.header,{minHeight:48,marginBottom:g.space.sm}],children:null===M?Y?_jsx(Text,{variant:"bodySmall",color:"secondary",children:Y}):null:_jsxs(_Fragment,{children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r[M].label}),_jsx(Text,{variant:"h3",numberOfLines:1,testID:y?`${y}-callout`:void 0,children:c(k[M])})]})}),_jsxs(View,{style:styles.body,children:[_jsx(View,{style:{width:z,height:i},children:H.ticks.map((e,t)=>_jsx(Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:g.space.xs,left:0,top:G(e)-8},children:U[t]},e))}),_jsxs(View,{style:styles.plotColumn,children:[_jsx(GestureDetector,{gesture:q,children:_jsxs(View,{style:{height:i},onLayout:ee,testID:y?`${y}-plot`:void 0,children:[H.ticks.map(e=>_jsx(View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:StyleSheet.hairlineWidth),height:0===e?1.5:2*StyleSheet.hairlineWidth,backgroundColor:0===e?g.colors["text-subtle"]:g.colors["border-subtle"]}},e)),_jsx(View,{style:[styles.slots,{height:i}],children:le})]})}),_jsx(View,{style:styles.axis,children:r.map((e,t)=>_jsx(View,{style:styles.axisSlot,children:t%X===0?_jsx(Text,{variant:"caption",color:M===t?"primary":"tertiary",weight:M===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:P>0?{width:P*X}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),o&&I?_jsx(View,{style:[styles.legend,{marginTop:g.space.sm,columnGap:g.space.md,rowGap:g.space.xs}],children:o.map((e,t)=>_jsxs(View,{style:[styles.legendItem,{columnGap:g.space.xs}],children:[_jsx(View,{style:{width:10,height:10,borderRadius:g.radius.sm,...smoothCorners,backgroundColor:toneColor(g,D[t])}}),_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});export{BarChart};export default BarChart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:n,onSnapChange:r,onAnimate:a,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:S,onContentSizeChange:b,onScrollLayout:p,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:w="sheet",animateMount:C=!0,handleIndicatorStyle:x,containerStyle:_,header:M,actions:E,actionsLayout:O="auto",footer:T,headerStyle:k,footerStyle:I,children:R,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;warnInvalidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),warnInvalidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),warnInvalidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),B=null!=M||null!=d,L=null!=E&&E.length>0,P=null!=T||L,N=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,J]=useState(()=>Dimensions.get("window").height),[z,Y]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&J(e=>e===t?e:t),o>0&&Y(e=>e===o?e:o)},[]),$=useWindowDimensions(),W="dialog"===w||"auto"===w&&Math.min($.width,$.height)>=600,X=Math.min(560,z-2*H.space.xl),[q,Q]=useModalInsets(),Z="modal"===N?q.top:F.top,ee="modal"===N?q.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[ne,re]=useMeasuredHeight(),[ae,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=W?H.space.md:oe,he=te?Math.min(de+(B?ne:0)+ae+(P?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),Se=U,be=fe[fe.length-1]??0,pe=useSharedValue(Se),ve=useSharedValue(Se),ye=useSharedValue(1),ge=useSharedValue(-1),[we,Ce]=useState(-1),xe=useRef(!1),[Me,Ee]=useState(!1),[Oe,Te]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[Re,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),De=useRef(!1);De.current="modal"===N?Oe:Re;const Be=useRef(c);Be.current=c;const Le=useRef(s);Le.current=s;const Pe=useRef(!1),Ne=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return Se;const t=fe[e];return W?(U-t)/2:U-t},[fe,U,Se,W]),Ue=useCallback(e=>{Ve.current=e;we!==e&&(Ce(e),ge.value=e,e>=0&&r?.(e))},[we,ge,r]),Je=useCallback(()=>{xe.current=!1,ge.value<0&&(ke.current=!0,"modal"===N?(Ee(!1),"ios"!==Platform.OS&&Te(!1)):Ae(!1))},[N,ge]),ze=useCallback(()=>{ke.current&&Te(!1)},[]);useEffect(()=>{("modal"===N?!Oe:!Re)&&ke.current&&(ke.current=!1,Ie.current?.(),Ge(!0))},[N,Oe,Re,Ge]);const Ye=useCallback((e,t,o)=>{xe.current=!0,a?.(t,o),pe.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Je)()})},[a,pe,Je]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):we>=0?we:0,o=ge.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===N?(Te(!0),Ee(!0)):Ae(!0),o<0&&je.current?(pe.value=s,ye.value=1,Ue(t),void a?.(o,t)):o<0&&G.reduced?(pe.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(pe.value=Se,ye.value=1),Ue(t),void Ye(s,o,t))},[Ye,Se,we,ge,N,a,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,pe,Fe]),$e=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(De.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),xe.current=!0,a?.(t,-1);const o=G.reduced?ye:pe,s=G.reduced?0:Se;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Je)()})}),[Se,ge,Je,a,G,ye,Ue,pe,H.motion.ease.accelerate]),We=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Pe.current)return void t?.();const n=s();"boolean"!=typeof n?(Pe.current=!0,o?.(),n.then(o=>{Pe.current=!1,o&&Ne.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),Xe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):We(()=>{Le.current(),$e(),e(!0)},()=>e(!1))}),[$e,We]),qe=useCallback(()=>{Le.current()},[]),Qe=useCallback(()=>{u&&Xe()},[u,Xe]),Ze=useRef(null);useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?Ke(n??0):$e():o&&"number"==typeof n&&n!==ge.value&&Ke(n)},[o,n]);const et=useRef({hostHeight:U,contentSnap:he});useEffect(()=>{const e=et.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(et.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=Fe(ge.value);pe.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he]);const tt=U-be,ot=useMemo(()=>fe.map(e=>U-e),[fe,U]),st=useCallback(()=>{const e=Ve.current;e<0||Ye(Fe(e),e,e)},[Ye,Fe]),nt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ye(t,o,e)):We(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Le.current(),$e()},st,st)},[Ye,$e,ge,We,Ue,st]),rt=useMemo(()=>Gesture.Native().withTestId(V?`${V}-content-gesture`:"bottom-sheet-content-gesture"),[V]),at=useMemo(()=>{const e=ot,t=Se,o=tt,s=i;return Gesture.Pan().withTestId(V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ve.value=pe.value}).onUpdate(e=>{"worklet";const t=ve.value+e.translationY;pe.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=pe.value;if(o.velocityY>1e3)return s?void runOnJS(nt)(-1,t):void runOnJS(nt)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS(nt)(-1,t):runOnJS(nt)(r,e[r])})},[Se,ve,i,nt,tt,ot,V,pe]),{height:lt}=useReanimatedKeyboardAnimation(),it="shift"===y,ut=useDerivedValue(()=>it?lt.value:0),ct=fe[we>=0?we:0]??be,dt=H.space.md,ht=useAnimatedStyle(()=>{if(W){const e=ut.value,t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value;return{top:o<Z?Z:o,opacity:ye.value}}const e=pe.value+ut.value,t=ut.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}}),mt=useAnimatedStyle(()=>{const e=ut.value;if(W){const t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value,s=U+e-dt-(o<Z?Z:o);return{height:s<0?0:s>ct?ct:s}}const t=e<0?Z:tt,o=pe.value+e,s=U+e-(o<t?t:o);return{height:s<0?0:s>be?be:s}}),ft=we>=0,St=useMemo(()=>buildStyles(H),[H]),bt=useCallback(()=>{u&&We(()=>{triggerHaptic("selection"),Le.current(),$e()})},[u,$e,We]),pt=useMemo(()=>Gesture.Tap().withTestId(V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(bt)()}),[bt,V]),vt=useMemo(()=>({snapIndex:we,snapPoints:fe,close:qe,requestClose:Xe}),[we,fe,qe,Xe]);if("inline"===N&&!Re)return null;if("modal"===N&&!Oe)return null;const yt=_jsxs(View,{collapsable:!1,style:["modal"===N?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===N?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:K,testID:V,accessibilityViewIsModal:j??ft,children:[_jsx(GestureDetector,{gesture:pt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??ft,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},W?{height:ct,left:(z-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,_,ht],children:_jsxs(SheetBody,{style:[St.body,mt],keyboardOffset:ut,children:[W?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:at,children:_jsx(View,{style:St.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[St.handle,{backgroundColor:H.colors.border},x]})})}),B&&_jsxs(View,{style:[St.header,k],onLayout:te?re:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),m?_jsx(GestureDetector,{gesture:rt,children:_jsx(ScrollView,{ref:f,style:St.scrollContent,onScroll:S,onContentSizeChange:me,onLayout:p,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:R})}):_jsx(View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?_jsx(View,{onLayout:le,children:R}):R}),P&&_jsxs(View,{style:[St.footer,I],onLayout:te?ce:void 0,children:[L?_jsx(View,{style:St.actions,children:_jsx(OverlayActions,{actions:E??[],layout:O})}):null,T]})]})})]}),gt=_jsx(BottomSheetContext.Provider,{value:vt,children:yt});return"modal"===N?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?ze:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:St.modalRoot,children:gt}):gt}):gt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}});return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
|
|
1
|
+
"use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:n,onSnapChange:r,onAnimate:a,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:S,onContentSizeChange:b,onScrollLayout:p,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:w="sheet",animateMount:C=!0,handleIndicatorStyle:x,containerStyle:_,header:M,actions:E,actionsLayout:O="auto",footer:T,headerStyle:k,footerStyle:I,children:R,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;warnInvalidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),warnInvalidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),warnInvalidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),B=null!=M||null!=d,L=null!=E&&E.length>0,P=null!=T||L,N=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,J]=useState(()=>Dimensions.get("window").height),[z,Y]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&J(e=>e===t?e:t),o>0&&Y(e=>e===o?e:o)},[]),$=useWindowDimensions(),W="dialog"===w||"auto"===w&&Math.min($.width,$.height)>=600,X=Math.min(560,z-2*H.space.xl),[q,Q]=useModalInsets(),Z="modal"===N?q.top:F.top,ee="modal"===N?q.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[ne,re]=useMeasuredHeight(),[ae,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=W?H.space.md:oe,he=te?Math.min(de+(B?ne:0)+ae+(P?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),Se=U,be=fe[fe.length-1]??0,pe=useSharedValue(Se),ve=useSharedValue(Se),ye=useSharedValue(1),ge=useSharedValue(-1),[we,Ce]=useState(-1),xe=useRef(!1),[Me,Ee]=useState(!1),[Oe,Te]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[Re,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),De=useRef(!1);De.current="modal"===N?Oe:Re;const Be=useRef(c);Be.current=c;const Le=useRef(s);Le.current=s;const Pe=useRef(!1),Ne=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return Se;const t=fe[e];return W?(U-t)/2:U-t},[fe,U,Se,W]),Ue=useCallback(e=>{Ve.current=e;we!==e&&(Ce(e),ge.value=e,e>=0&&r?.(e))},[we,ge,r]),Je=useCallback(()=>{xe.current=!1,ge.value<0&&(ke.current=!0,"modal"===N?(Ee(!1),"ios"!==Platform.OS&&Te(!1)):Ae(!1))},[N,ge]),ze=useCallback(()=>{ke.current&&Te(!1)},[]);useEffect(()=>{("modal"===N?!Oe:!Re)&&ke.current&&(ke.current=!1,Ie.current?.(),Ge(!0))},[N,Oe,Re,Ge]);const Ye=useCallback((e,t,o)=>{xe.current=!0,a?.(t,o),pe.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Je)()})},[a,pe,Je]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):we>=0?we:0,o=ge.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===N?(Te(!0),Ee(!0)):Ae(!0),o<0&&je.current?(pe.value=s,ye.value=1,Ue(t),void a?.(o,t)):o<0&&G.reduced?(pe.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(pe.value=Se,ye.value=1),Ue(t),void Ye(s,o,t))},[Ye,Se,we,ge,N,a,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,pe,Fe]),$e=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(De.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),xe.current=!0,a?.(t,-1);const o=G.reduced?ye:pe,s=G.reduced?0:Se;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Je)()})}),[Se,ge,Je,a,G,ye,Ue,pe,H.motion.ease.accelerate]),We=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Pe.current)return void t?.();const n=s();"boolean"!=typeof n?(Pe.current=!0,o?.(),n.then(o=>{Pe.current=!1,o&&Ne.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),Xe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):We(()=>{Le.current(),$e(),e(!0)},()=>e(!1))}),[$e,We]),qe=useCallback(()=>{Le.current()},[]),Qe=useCallback(()=>{u&&Xe()},[u,Xe]),Ze=useRef(null);useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?Ke(n??0):$e():o&&"number"==typeof n&&n!==ge.value&&Ke(n)},[o,n]);const et=useRef({hostHeight:U,contentSnap:he});useEffect(()=>{const e=et.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(et.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=Fe(ge.value);pe.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he]);const tt=U-be,ot=useMemo(()=>fe.map(e=>U-e),[fe,U]),st=useCallback(()=>{const e=Ve.current;e<0||Ye(Fe(e),e,e)},[Ye,Fe]),nt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ye(t,o,e)):We(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Le.current(),$e()},st,st)},[Ye,$e,ge,We,Ue,st]),rt=useMemo(()=>Gesture.Native().withTestId(V?`${V}-content-gesture`:"bottom-sheet-content-gesture"),[V]),at=useMemo(()=>{const e=ot,t=Se,o=tt,s=i;return Gesture.Pan().withTestId(V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ve.value=pe.value}).onUpdate(e=>{"worklet";const t=ve.value+e.translationY;pe.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=pe.value;if(o.velocityY>1e3)return s?void runOnJS(nt)(-1,t):void runOnJS(nt)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS(nt)(-1,t):runOnJS(nt)(r,e[r])})},[Se,ve,i,nt,tt,ot,V,pe]),{height:lt}=useReanimatedKeyboardAnimation(),it="shift"===y,ut=useDerivedValue(()=>it?lt.value:0,[it,lt]),ct=fe[we>=0?we:0]??be,dt=H.space.md,ht=useAnimatedStyle(()=>{if(W){const e=ut.value,t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value;return{top:o<Z?Z:o,opacity:ye.value}}const e=pe.value+ut.value,t=ut.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[W,ut,U,ct,dt,pe,Z,ye,tt]),mt=useAnimatedStyle(()=>{const e=ut.value;if(W){const t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value,s=U+e-dt-(o<Z?Z:o);return{height:s<0?0:s>ct?ct:s}}const t=e<0?Z:tt,o=pe.value+e,s=U+e-(o<t?t:o);return{height:s<0?0:s>be?be:s}},[ut,W,U,ct,dt,pe,Z,tt,be]),ft=we>=0,St=useMemo(()=>buildStyles(H),[H]),bt=useCallback(()=>{u&&We(()=>{triggerHaptic("selection"),Le.current(),$e()})},[u,$e,We]),pt=useMemo(()=>Gesture.Tap().withTestId(V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(bt)()}),[bt,V]),vt=useMemo(()=>({snapIndex:we,snapPoints:fe,close:qe,requestClose:Xe}),[we,fe,qe,Xe]);if("inline"===N&&!Re)return null;if("modal"===N&&!Oe)return null;const yt=_jsxs(View,{collapsable:!1,style:["modal"===N?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===N?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:K,testID:V,accessibilityViewIsModal:j??ft,children:[_jsx(GestureDetector,{gesture:pt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??ft,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},W?{height:ct,left:(z-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,_,ht],children:_jsxs(SheetBody,{style:[St.body,mt],keyboardOffset:ut,children:[W?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:at,children:_jsx(View,{style:St.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[St.handle,{backgroundColor:H.colors.border},x]})})}),B&&_jsxs(View,{style:[St.header,k],onLayout:te?re:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),m?_jsx(GestureDetector,{gesture:rt,children:_jsx(ScrollView,{ref:f,style:St.scrollContent,onScroll:S,onContentSizeChange:me,onLayout:p,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:R})}):_jsx(View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?_jsx(View,{onLayout:le,children:R}):R}),P&&_jsxs(View,{style:[St.footer,I],onLayout:te?ce:void 0,children:[L?_jsx(View,{style:St.actions,children:_jsx(OverlayActions,{actions:E??[],layout:O})}):null,T]})]})})]}),gt=_jsx(BottomSheetContext.Provider,{value:vt,children:yt});return"modal"===N?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?ze:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:St.modalRoot,children:gt}):gt}):gt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}},[s,t]);return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useMemo}from"react";import{Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"../Radio/RadioDot.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=forwardRef((e,i)=>{const{options:o,getOptionLabel:t,getOptionValue:r,isOptionDisabled:l,getOptionDescription:a,getOptionIcon:s,getOptionColor:n,renderOption:d,variant:c="card",indicatorPosition:p="trailing",direction:u="row",gap:m,wrap:g=!1,fullWidth:h,disabled:
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useMemo}from"react";import{Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"../Radio/RadioDot.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=forwardRef((e,i)=>{const{options:o,getOptionLabel:t,getOptionValue:r,isOptionDisabled:l,getOptionDescription:a,getOptionIcon:s,getOptionColor:n,renderOption:d,variant:c="card",indicatorPosition:p="trailing",direction:u="row",gap:m,wrap:g=!1,fullWidth:h,disabled:x=!1,size:b="md",labelLines:f,descriptionLines:y=2,haptic:z,accessibilityLabel:C,style:j,optionStyle:S,description:v,helperText:w,error:H,testID:V}=e,T=useTheme(),_=useMemo(()=>buildStyles(T),[T]),k=useMemo(()=>sizeTokensOf(T)[b],[T,b]);warnInvalidValue("ChoiceGroup","variant",e.variant,["card","chip"]),warnInvalidValue("ChoiceGroup","size",e.size,["sm","md","lg"]),warnInvalidValue("ChoiceGroup","direction",e.direction,["row","column"]),warnInvalidValue("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),warnInvalidValue("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const I=useCallback(e=>t?t(e):e.label??"",[t]),D=useCallback(e=>r?r(e):e.value,[r]),O=useCallback(e=>l?l(e):!0===e.disabled,[l]),G=useCallback(e=>a?a(e):e.description,[a]),L=useCallback(e=>s?s(e):e.icon,[s]),M=useCallback(e=>n?n(e):e.color,[n]),P="multiple"===e.selectionMode,{min:R,max:F}=e,[W,B]=useControllableState({value:e.value,defaultValue:e.defaultValue??(P?[]:void 0),onChange:e.onChange}),A=Array.isArray(W)?W:[],$=useCallback(e=>{const i=D(e);if(P){const e=A.includes(i);if(e&&null!=R&&A.length<=R)return;if(!e&&null!=F&&A.length>=F)return;const o=resolveHaptic(z,"selection");return o&&triggerHaptic(o),void B(e?A.filter(e=>e!==i):[...A,i])}const o=resolveHaptic(z,"selection");o&&triggerHaptic(o),B(i)},[z,P,R,F,A,B,D]),N=h??("card"===c&&"row"===u&&!g),q=g||N&&"row"===u,E=T.radius.md,surfaceFor=(e,i,o)=>i?{borderColor:T.colors.border,backgroundColor:T.colors["surface-disabled"]}:{borderColor:e?o:T.colors.border,backgroundColor:e?tintOf(o,.12,T.colors["surface-selected"]):T.colors.bg},renderIcon=(e,i,o,t)=>{const r=L(e);if(null==r)return null;return renderSlotIcon("string"==typeof r&&i?{name:r,variant:"bold"}:r,{color:o,size:k.iconSize,disabled:t})},renderChip=e=>{const{option:i,selected:o,disabled:t,color:r}=e,l=t?T.colors["text-disabled"]:o?r:T.colors["text-body"],a=renderIcon(i,o,l,t);return _jsxs(View,{style:[_.chip,{minHeight:k.minHeight,paddingHorizontal:k.chipPaddingHorizontal,paddingVertical:k.paddingVertical,borderRadius:T.radius.pill,...smoothCorners,borderWidth:T.size.border,...surfaceFor(o,t,r),columnGap:T.space.xs}],children:[a?_jsx(View,{children:a}):null,_jsx(Text,{weight:"medium",numberOfLines:f,ellipsizeMode:"tail",style:[_.cardLabel,{color:l,fontSize:k.fontSize,lineHeight:Math.round(k.fontSize*T.leading.body)}],children:I(i)})]})},renderDefaultCard=e=>{const{option:i,selected:o,disabled:t,color:r}=e,l=M(i),a=t?T.colors["text-disabled"]:l??T.colors["text-body"],s=G(i),n=renderIcon(i,o,a,t),d=_jsx(RadioDot,{selected:o,color:r,disabled:t,size:b});return _jsxs(View,{style:[_.card,{minHeight:k.minHeight,paddingHorizontal:k.paddingHorizontal,paddingVertical:k.paddingVertical,borderRadius:E,...smoothCorners,borderWidth:T.size.border,...surfaceFor(o,t,r),columnGap:T.space.sm}],children:["leading"===p?d:null,n?_jsx(View,{children:n}):null,_jsxs(View,{style:_.cardTextWrap,children:[_jsx(Text,{weight:"medium",numberOfLines:f,ellipsizeMode:"tail",style:[_.cardLabel,{color:a,fontSize:k.fontSize,lineHeight:Math.round(k.fontSize*T.leading.body)}],children:I(i)}),s?_jsx(Text,{numberOfLines:y,ellipsizeMode:"tail",style:[_.cardDescription,{color:o?T.colors["text-muted"]:T.colors["text-subtle"],fontSize:T.text.xs.size,lineHeight:Math.round(T.text.xs.size*T.leading.body)}],children:s}):null]}),"trailing"===p?d:null]})},J="string"==typeof H&&""!==H?H:void 0,K=!0===H||void 0!==J?null:w,Q=_jsx(View,{ref:i,accessibilityRole:P?void 0:"radiogroup",accessibilityLabel:C,accessibilityState:{disabled:x},"aria-disabled":x,testID:V,style:[{flexDirection:u,gap:m??T.space.sm,flexWrap:q?"wrap":"nowrap"},j],children:o.map((e,i)=>{const o=D(e),t=P?A.includes(o):W===o,r=P&&null!=F&&!t&&A.length>=F,l=x||r||O(e),a=M(e)??T.colors.primary,s=d||"card"!==c?void 0:G(e);return _jsx(Pressable,{testID:e.testID,onPress:()=>{l||$(e)},disabled:l,accessibilityRole:P?"checkbox":"radio",accessibilityLabel:s?`${I(e)}, ${s}`:I(e),accessibilityState:{checked:t,disabled:l},"aria-checked":t,"aria-disabled":l,style:[N?_.stretchOption:null,{opacity:l&&d?.55:1},S],children:({pressed:o})=>{const r={option:e,index:i,selected:t,pressed:o&&!l,disabled:l,color:a};return _jsx(_Fragment,{children:d?d(r):"chip"===c?renderChip(r):renderDefaultCard(r)})}},String(o))})});return hasChoiceDetail({description:v,error:J,helperText:K??void 0})?_jsxs(View,{children:[v?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:T.space.xs},children:v}):null,Q,void 0!==J?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:T.space.xs},children:J}):K?_jsx(Text,{variant:"caption",color:"tertiary",style:{marginTop:T.space.xs},children:K}):null]}):Q});ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>StyleSheet.create({stretchOption:{flexGrow:1,flexShrink:0,flexBasis:"auto"},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flexGrow:1,flexShrink:1,flexBasis:"auto"},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});export{ChoiceGroup};export default ChoiceGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useState}from"react";import{StyleSheet,useWindowDimensions,View}from"react-native";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withRepeat,withTiming}from"react-native-reanimated";import Svg,{Path,Polygon}from"react-native-svg";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.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),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,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 n=rand(.18,.82),o=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:n,y0Frac:o,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,n=i<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/i)),o=(1-Math.exp(-e.drag*n))/e.drag,c=e.x0Frac*r+e.vxFrac*r*o,l=e.y0Frac*t+e.terminalFrac*t*n+(e.vyFrac-e.terminalFrac)*t*o,h=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,d=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:s?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:c+h},{translateY:l},{rotate:`${d}deg`},{scaleY:p}]}}),n=SHAPE_BOX[e.shape],o="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return _jsx(Animated.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:o?"transparent":e.color},i],children:_jsx(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=forwardRef(({count:e=80,colors:a,preset:r="pop",shapes:t,speed:s="normal",physics:i,origin:n,duration:o=2800,fadeOut:c=!0,autoStart:l=!1,recycle:h=!1,size:d=10,onComplete:p,style:u,testID:m},y)=>{warnInvalidValue("Confetti","preset",r,["pop","rain","fireworks"]),warnInvalidValue("Confetti","speed",s,["slow","normal","fast"]);for(const e of t??[])warnInvalidValue("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const g=useTheme(),w=useReducedMotion(),f=useWindowDimensions(),[S,F]=useState({width:f.width,height:f.height}),[v,x]=useState(!1),[P,A]=useState([]),E=useMemo(()=>a??[g.colors.primary,g.colors.neutral,g.colors.success,g.colors.warning,g.colors.danger,g.colors.info],[a,g.colors]),M=useSharedValue(0),T=o*SPEED_FACTOR[s],_=useCallback(()=>{x(!1),p?.()},[p]),R=useCallback(()=>{if(w)return void p?.();cancelAnimation(M),M.value=0,A(buildPieces(e,r,{colors:E,baseSize:d,originXFrac:n?n.x/Math.max(1,S.width):.5,originYFrac:n?n.y/Math.max(1,S.height):.5,physics:{...DEFAULT_PHYSICS,...i},shapes:t??PRESET_SHAPES[r]})),x(!0);const a=withTiming(1,{duration:T,easing:Easing.linear},e=>{"worklet";e&&!h&&runOnJS(_)()});M.value=h?withRepeat(a,-1,!1):a},[w,M,T,h,_,p,e,E,r,t,i,d,n,S.width,S.height]),C=useCallback(()=>{cancelAnimation(M),x(!1)},[M]);useImperativeHandle(y,()=>({start:R,stop:C}),[R,C]),useEffect(()=>(l&&R(),()=>cancelAnimation(M)),[]);const I=useCallback(e=>{const{width:a,height:r}=e.nativeEvent.layout;a>0&&r>0&&F({width:a,height:r})},[]);return _jsx(View,{style:[StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:I,testID:m,children:v?P.map((e,a)=>_jsx(ConfettiPiece,{piece:e,progress:M,width:S.width,height:S.height,fadeOut:c},a)):null})});Confetti.displayName="Confetti";export{Confetti};export default Confetti;
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useState}from"react";import{StyleSheet,useWindowDimensions,View}from"react-native";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withRepeat,withTiming}from"react-native-reanimated";import Svg,{Path,Polygon}from"react-native-svg";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.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),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,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 n=rand(.18,.82),o=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:n,y0Frac:o,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,n=i<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/i)),o=(1-Math.exp(-e.drag*n))/e.drag,c=e.x0Frac*r+e.vxFrac*r*o,l=e.y0Frac*t+e.terminalFrac*t*n+(e.vyFrac-e.terminalFrac)*t*o,h=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,d=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:s?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:c+h},{translateY:l},{rotate:`${d}deg`},{scaleY:p}]}},[e,a,r,t,s]),n=SHAPE_BOX[e.shape],o="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return _jsx(Animated.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:o?"transparent":e.color},i],children:_jsx(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=forwardRef(({count:e=80,colors:a,preset:r="pop",shapes:t,speed:s="normal",physics:i,origin:n,duration:o=2800,fadeOut:c=!0,autoStart:l=!1,recycle:h=!1,size:d=10,onComplete:p,style:u,testID:m},y)=>{warnInvalidValue("Confetti","preset",r,["pop","rain","fireworks"]),warnInvalidValue("Confetti","speed",s,["slow","normal","fast"]);for(const e of t??[])warnInvalidValue("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const g=useTheme(),w=useReducedMotion(),f=useWindowDimensions(),[S,F]=useState({width:f.width,height:f.height}),[v,x]=useState(!1),[P,A]=useState([]),E=useMemo(()=>a??[g.colors.primary,g.colors.neutral,g.colors.success,g.colors.warning,g.colors.danger,g.colors.info],[a,g.colors]),M=useSharedValue(0),T=o*SPEED_FACTOR[s],_=useCallback(()=>{x(!1),p?.()},[p]),R=useCallback(()=>{if(w)return void p?.();cancelAnimation(M),M.value=0,A(buildPieces(e,r,{colors:E,baseSize:d,originXFrac:n?n.x/Math.max(1,S.width):.5,originYFrac:n?n.y/Math.max(1,S.height):.5,physics:{...DEFAULT_PHYSICS,...i},shapes:t??PRESET_SHAPES[r]})),x(!0);const a=withTiming(1,{duration:T,easing:Easing.linear},e=>{"worklet";e&&!h&&runOnJS(_)()});M.value=h?withRepeat(a,-1,!1):a},[w,M,T,h,_,p,e,E,r,t,i,d,n,S.width,S.height]),C=useCallback(()=>{cancelAnimation(M),x(!1)},[M]);useImperativeHandle(y,()=>({start:R,stop:C}),[R,C]),useEffect(()=>(l&&R(),()=>cancelAnimation(M)),[]);const I=useCallback(e=>{const{width:a,height:r}=e.nativeEvent.layout;a>0&&r>0&&F({width:a,height:r})},[]);return _jsx(View,{style:[StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:I,testID:m,children:v?P.map((e,a)=>_jsx(ConfettiPiece,{piece:e,progress:M,width:S.width,height:S.height,fadeOut:c},a)):null})});Confetti.displayName="Confetti";export{Confetti};export default Confetti;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Dimensions,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{Extrapolation,interpolate,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"};const DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=forwardRef((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:o="left",width:s,enableSwipe:n=!0,enableBackdropPress:l=!0,backdropOpacity:u=.5,haptic:c,containerStyle:d,children:p,accessibilityLabel:h,labels:m,testID:f}=e,g=useTheme();warnInvalidValue("Drawer","side",e.side,["left","right","top","bottom"]);const b=useMemo(()=>({...DEFAULT_DRAWER_LABELS,...m}),[m]),v=usePresenceMotion(),w=v.reduced,S=v.duration("default"),E=v.duration("fast"),y=useSafeAreaInsets(),M="boolean"==typeof a,[_,D]=useState(()=>Dimensions.get("window"));useEffect(()=>{const e=Dimensions.addEventListener("change",({window:e})=>D(e));return()=>e.remove()},[]);const C="left"===o||"right"===o,O=useMemo(()=>resolveSize(s,C,_),[s,C,_]),R=useMemo(()=>{switch(o){case"left":case"top":return-O;case"right":case"bottom":return O}},[o,O]),T=useSharedValue(r?0:R),x=useSharedValue(r?0:R),k=useSharedValue(r?1:0),[A,L]=useState(r),I=useSharedValue(r);useEffect(()=>{A||w||(T.value=R,x.value=R)},[R,A,T,x,w]);const V=g.motion.spring.snappy,j=useCallback(()=>{if(w)return T.value=0,void(k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION}));k.value=1,T.value=withSpring(0,V)},[T,k,V,w,S]),N=useCallback(()=>{w?k.value=withTiming(0,{duration:E,reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(T.value=R)}):T.value=withSpring(R,V)},[T,k,R,V,w,E]),P=useCallback(e=>{L(t=>t===e?t:(i?.(e),e)),I.value=e},[i,I]),F=useCallback(()=>{P(!0),j()},[P,j]),U=useCallback(()=>{P(!1),N()},[P,N]),H=useCallback(()=>{A?U():F()},[A,F,U]);useImperativeHandle(t,()=>({open:F,close:U,toggle:H}),[F,U,H]),useEffect(()=>{M&&a!==A&&(a?F():U())},[a]);const B=useMemo(()=>{const e=R,t=o,a=n;let r=Gesture.Pan();return r=C?r.activeOffsetX([-10,10]).failOffsetY([-15,15]):r.activeOffsetY([-10,10]).failOffsetX([-15,15]),r.onStart(()=>{"worklet";a&&(x.value=T.value)}).onUpdate(t=>{"worklet";if(!a)return;const r=C?t.translationX:t.translationY,i=x.value+r,o=Math.min(0,e),s=Math.max(0,e);T.value=i<o?o+.25*(i-o):i>s?s+.25*(i-s):i}).onEnd(r=>{"worklet";if(!a)return;const i=C?r.velocityX:r.velocityY,o=T.value;let s=!1;s="left"===t||"top"===t?i<-1e3:i>1e3;const n=Math.abs(e),l=Math.abs(o)/n;s||l>.5?(runOnJS(P)(!1),w?k.value=withTiming(0,{duration:E,reduceMotion:PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(T.value=e)}):T.value=withSpring(e,V)):(runOnJS(P)(!0),w?(T.value=0,k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION})):T.value=withSpring(0,V))})},[R,x,n,C,T,k,P,o,V,w,S,E]),Y=useAnimatedStyle(()=>C?{opacity:k.value,transform:[{translateX:T.value}]}:{opacity:k.value,transform:[{translateY:T.value}]}),G=useAnimatedStyle(()=>({opacity:interpolate(T.value,[R,0],[0,u],Extrapolation.CLAMP)*k.value,pointerEvents:Math.abs(T.value-R)<.5?"none":"auto"}),[R,u]),X=useMemo(()=>buildStyles(g),[g]),J=useCallback(()=>{if(!l)return;const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),U()},[l,U,c]),z=useMemo(()=>{switch(o){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:O,paddingTop:y.top,paddingBottom:y.bottom,paddingLeft:y.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:O,paddingTop:y.top,paddingBottom:y.bottom,paddingRight:y.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:O,paddingTop:y.top,paddingLeft:y.left,paddingRight:y.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:O,paddingBottom:y.bottom,paddingLeft:y.left,paddingRight:y.right}}},[o,O,y]),W=useRef(r);return A&&(W.current=!0),W.current?_jsxs(View,{style:StyleSheet.absoluteFill,pointerEvents:"box-none",testID:f,accessibilityViewIsModal:A,children:[_jsx(Animated.View,{style:[X.backdrop,{backgroundColor:g.colors.scrim},G],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:J,accessibilityRole:"button",accessibilityLabel:b.close,disabled:!l||!A})}),_jsx(GestureDetector,{gesture:B,children:_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:h??b.drawer,style:[z,{backgroundColor:g.colors.surface,...g.shadow.modal},d,Y],children:_jsx(View,{style:X.content,children:p})})})]}):null});Drawer.displayName="Drawer";const resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},content:{flex:1}});export{Drawer};export default Drawer;
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Dimensions,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{Extrapolation,interpolate,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"};const DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=forwardRef((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:o="left",width:s,enableSwipe:n=!0,enableBackdropPress:l=!0,backdropOpacity:u=.5,haptic:c,containerStyle:d,children:p,accessibilityLabel:h,labels:m,testID:f}=e,g=useTheme();warnInvalidValue("Drawer","side",e.side,["left","right","top","bottom"]);const b=useMemo(()=>({...DEFAULT_DRAWER_LABELS,...m}),[m]),v=usePresenceMotion(),w=v.reduced,S=v.duration("default"),E=v.duration("fast"),y=useSafeAreaInsets(),M="boolean"==typeof a,[_,D]=useState(()=>Dimensions.get("window"));useEffect(()=>{const e=Dimensions.addEventListener("change",({window:e})=>D(e));return()=>e.remove()},[]);const C="left"===o||"right"===o,O=useMemo(()=>resolveSize(s,C,_),[s,C,_]),R=useMemo(()=>{switch(o){case"left":case"top":return-O;case"right":case"bottom":return O}},[o,O]),T=useSharedValue(r?0:R),x=useSharedValue(r?0:R),k=useSharedValue(r?1:0),[A,L]=useState(r),I=useSharedValue(r);useEffect(()=>{A||w||(T.value=R,x.value=R)},[R,A,T,x,w]);const V=g.motion.spring.snappy,j=useCallback(()=>{if(w)return T.value=0,void(k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION}));k.value=1,T.value=withSpring(0,V)},[T,k,V,w,S]),N=useCallback(()=>{w?k.value=withTiming(0,{duration:E,reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(T.value=R)}):T.value=withSpring(R,V)},[T,k,R,V,w,E]),P=useCallback(e=>{L(t=>t===e?t:(i?.(e),e)),I.value=e},[i,I]),F=useCallback(()=>{P(!0),j()},[P,j]),U=useCallback(()=>{P(!1),N()},[P,N]),H=useCallback(()=>{A?U():F()},[A,F,U]);useImperativeHandle(t,()=>({open:F,close:U,toggle:H}),[F,U,H]),useEffect(()=>{M&&a!==A&&(a?F():U())},[a]);const B=useMemo(()=>{const e=R,t=o,a=n;let r=Gesture.Pan();return r=C?r.activeOffsetX([-10,10]).failOffsetY([-15,15]):r.activeOffsetY([-10,10]).failOffsetX([-15,15]),r.onStart(()=>{"worklet";a&&(x.value=T.value)}).onUpdate(t=>{"worklet";if(!a)return;const r=C?t.translationX:t.translationY,i=x.value+r,o=Math.min(0,e),s=Math.max(0,e);T.value=i<o?o+.25*(i-o):i>s?s+.25*(i-s):i}).onEnd(r=>{"worklet";if(!a)return;const i=C?r.velocityX:r.velocityY,o=T.value;let s=!1;s="left"===t||"top"===t?i<-1e3:i>1e3;const n=Math.abs(e),l=Math.abs(o)/n;s||l>.5?(runOnJS(P)(!1),w?k.value=withTiming(0,{duration:E,reduceMotion:PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(T.value=e)}):T.value=withSpring(e,V)):(runOnJS(P)(!0),w?(T.value=0,k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION})):T.value=withSpring(0,V))})},[R,x,n,C,T,k,P,o,V,w,S,E]),Y=useAnimatedStyle(()=>C?{opacity:k.value,transform:[{translateX:T.value}]}:{opacity:k.value,transform:[{translateY:T.value}]},[C,T,k]),G=useAnimatedStyle(()=>({opacity:interpolate(T.value,[R,0],[0,u],Extrapolation.CLAMP)*k.value,pointerEvents:Math.abs(T.value-R)<.5?"none":"auto"}),[T,R,u,k]),X=useMemo(()=>buildStyles(g),[g]),J=useCallback(()=>{if(!l)return;const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),U()},[l,U,c]),z=useMemo(()=>{switch(o){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:O,paddingTop:y.top,paddingBottom:y.bottom,paddingLeft:y.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:O,paddingTop:y.top,paddingBottom:y.bottom,paddingRight:y.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:O,paddingTop:y.top,paddingLeft:y.left,paddingRight:y.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:O,paddingBottom:y.bottom,paddingLeft:y.left,paddingRight:y.right}}},[o,O,y]),W=useRef(r);return A&&(W.current=!0),W.current?_jsxs(View,{style:StyleSheet.absoluteFill,pointerEvents:"box-none",testID:f,accessibilityViewIsModal:A,children:[_jsx(Animated.View,{style:[X.backdrop,{backgroundColor:g.colors.scrim},G],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:J,accessibilityRole:"button",accessibilityLabel:b.close,disabled:!l||!A})}),_jsx(GestureDetector,{gesture:B,children:_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:h??b.drawer,style:[z,{backgroundColor:g.colors.surface,...g.shadow.modal},d,Y],children:_jsx(View,{style:X.content,children:p})})})]}):null});Drawer.displayName="Drawer";const resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},content:{flex:1}});export{Drawer};export default Drawer;
|