@webority/mobile-ui 0.183.0 → 0.185.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/canvas-kit/kit.js +4 -4
  2. package/dist/canvas-kit/manifest.json +8 -1
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/Box/Box.js +1 -1
  5. package/lib/commonjs/components/Button/Button.js +1 -1
  6. package/lib/commonjs/components/Card/Card.js +1 -1
  7. package/lib/commonjs/components/Chip/Chip.js +1 -1
  8. package/lib/commonjs/components/EmptyState/EmptyState.js +1 -1
  9. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  10. package/lib/commonjs/components/FilterChipRow/FilterChipRow.js +1 -1
  11. package/lib/commonjs/components/Modal/Modal.js +1 -1
  12. package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
  13. package/lib/commonjs/components/Screen/Screen.js +1 -1
  14. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  15. package/lib/commonjs/components/Spinner/Spinner.js +1 -1
  16. package/lib/commonjs/components/SquircleFill/SquircleFill.js +1 -1
  17. package/lib/commonjs/components/SquircleView/SquircleView.js +1 -1
  18. package/lib/commonjs/components/Tabs/Tabs.js +1 -1
  19. package/lib/commonjs/theme/merge.js +1 -1
  20. package/lib/module/components/Box/Box.js +1 -1
  21. package/lib/module/components/Button/Button.js +1 -1
  22. package/lib/module/components/Card/Card.js +1 -1
  23. package/lib/module/components/Chip/Chip.js +1 -1
  24. package/lib/module/components/EmptyState/EmptyState.js +1 -1
  25. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  26. package/lib/module/components/FilterChipRow/FilterChipRow.js +1 -1
  27. package/lib/module/components/Modal/Modal.js +1 -1
  28. package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
  29. package/lib/module/components/Screen/Screen.js +1 -1
  30. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  31. package/lib/module/components/Spinner/Spinner.js +1 -1
  32. package/lib/module/components/SquircleFill/SquircleFill.js +1 -1
  33. package/lib/module/components/SquircleView/SquircleView.js +1 -1
  34. package/lib/module/components/Tabs/Tabs.js +1 -1
  35. package/lib/module/theme/merge.js +1 -1
  36. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +3 -3
  37. package/lib/typescript/commonjs/components/Screen/Screen.d.ts +2 -0
  38. package/lib/typescript/commonjs/components/SquircleFill/SquircleFill.d.ts +7 -1
  39. package/lib/typescript/commonjs/theme/types.d.ts +2 -0
  40. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +3 -3
  41. package/lib/typescript/module/components/Screen/Screen.d.ts +2 -0
  42. package/lib/typescript/module/components/SquircleFill/SquircleFill.d.ts +7 -1
  43. package/lib/typescript/module/theme/types.d.ts +2 -0
  44. package/package.json +7 -7
@@ -1 +1 @@
1
- "use strict";import{useEffect,useMemo,useRef}from"react";import{ActivityIndicator,Animated,Easing,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{SPINNER_TEXT}from"../../text/phone/spinner.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{blendOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{squircleHostRadius}from"../../utils/squircle.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sizeMap={sm:20,md:32,lg:48},CONTAINER_RATIO=1.5,DOT_NAMES=["first","second","third"],DOT_STAGGER_MS=150,DOT_CYCLE_MS=600,DOT_GROW_SCALE=1.4,DOT_PULSE_MIN_OPACITY=.4,Dot=({size:e,color:t,delay:i,duration:n,reduced:s})=>{const r=useTheme(),o=useRef(createAnimatedValue(0)).current;useEffect(()=>{const e=Animated.loop(Animated.sequence([Animated.delay(i),Animated.timing(o,{toValue:1,duration:n/2,easing:Easing.out(Easing.quad),useNativeDriver:nativeDriver}),Animated.timing(o,{toValue:0,duration:n/2,easing:Easing.in(Easing.quad),useNativeDriver:nativeDriver})]));return e.start(),()=>{e.stop()}},[o,i,n]);const a=useMemo(()=>({grow:o.interpolate({inputRange:[0,1],outputRange:[1,1.4]}),fade:o.interpolate({inputRange:[0,1],outputRange:[.4,1]})}),[o]);return _jsx(Animated.View,{style:{width:e,height:e,borderRadius:r.radius.pill,...smoothCorners,backgroundColor:t,...s?{opacity:a.fade}:{transform:[{scale:a.grow}]}}})};function Spinner({ref:e,...t}){const{size:i="md",color:n,message:s,overlay:r=!1,backdropColor:o,variant:a="circular",accessibilityLabel:l,labels:c,style:u,testID:d}=t;assertValidValue("Spinner","size",t.size,["sm","md","lg"]),assertValidValue("Spinner","variant",t.variant,["circular","dots","contained"]);const m=useMobileUiText("spinner",SPINNER_TEXT),g=useMemo(()=>({...m,...c}),[m,c]),p="contained"===a,f=r&&!p,h=useTheme(),y=usePresenceMotion(),b=y.duration("default"),j=useRef(createAnimatedValue(0)).current;useEffect(()=>{Animated.timing(j,{toValue:1,duration:b,easing:Easing.bezier(...h.motion.ease["in-out"]),useNativeDriver:nativeDriver}).start()},[j,h,b]);const x=useMemo(()=>buildStyles(h),[h]),v=sizeMap[i],S=n??h.colors.primary,C=o??h.colors.scrim,_=useMemo(()=>{if("contained"===a){const e=Math.round(1.5*v);return _jsx(View,{style:[x.container,{width:e,height:e,borderRadius:h.radius.pill,backgroundColor:blendOf(S,.14,h.colors.surface,h.colors["bg-subtle"])}],children:_jsx(ActivityIndicator,{color:S,size:"sm"===i?"small":"large",style:{width:v,height:v}})})}if("dots"===a){const e=Math.max(6,Math.round(v/4));return _jsx(View,{style:[x.dotsRow,{gap:Math.round(e/2)}],children:DOT_NAMES.map((t,i)=>_jsx(Dot,{size:e,color:S,delay:150*i,duration:600,reduced:y.reduced},t))})}return _jsx(ActivityIndicator,{color:S,size:"sm"===i?"small":"large",style:{width:v,height:v}})},[a,i,v,S,x.dotsRow,x.container,y.reduced,h.radius.pill,h.colors.surface,h.colors["bg-subtle"]]),R=l??s??g.loading,A=useRef(R);A.current=R,useEffect(()=>{p&&announce(A.current)},[p]);const M=useSquircle(f,h.radius.lg),T=M.active&&M.size?{borderRadius:squircleHostRadius(M.size.width,M.size.height,h.radius.lg)}:null;let E=x.inlineContent;f?E=x.overlayContent:p&&(E=x.containedContent);const w=_jsxs(Animated.View,{ref:e,accessible:!0,accessibilityRole:"progressbar",accessibilityLiveRegion:p?"none":"polite",accessibilityLabel:R,accessibilityState:{busy:!0},"aria-busy":!0,testID:d,onLayout:M.onLayout,style:[E,T,{opacity:j}],children:[M.active&&M.size?_jsx(SquircleFill,{width:M.size.width,height:M.size.height,radius:h.radius.lg,fill:h.colors.surface}):null,_,s?_jsx(Text,{variant:"body",weight:"medium",style:[x.message,{marginTop:h.space.md}],numberOfLines:2,children:s}):null]});return _jsx(View,f?{pointerEvents:"auto",style:[x.overlay,{backgroundColor:C},u],children:w}:{style:[p?x.containedFill:x.inline,u],children:w})}const buildStyles=e=>StyleSheet.create({inline:{alignItems:"center",justifyContent:"center"},inlineContent:{alignItems:"center",justifyContent:"center"},containedFill:{flex:1,alignSelf:"stretch",alignItems:"center",justifyContent:"center",minHeight:Math.round(1.5*sizeMap.lg)+2*e.space.xl},containedContent:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},container:{alignItems:"center",justifyContent:"center"},overlay:{...StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center",zIndex:1e3},overlayContent:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors.surface,borderRadius:e.radius.lg,...smoothCorners,paddingHorizontal:e.space.xl,paddingVertical:e.space.xl,minWidth:140,...e.shadow.popover},dotsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},message:{textAlign:"center"}});export{Spinner};export default Spinner;
1
+ "use strict";import{useEffect,useMemo,useRef}from"react";import{ActivityIndicator,Animated,Easing,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{SPINNER_TEXT}from"../../text/phone/spinner.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{blendOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{squircleHostRadius}from"../../utils/squircle.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sizeMap={sm:20,md:32,lg:48},CONTAINER_RATIO=1.5,DOT_NAMES=["first","second","third"],DOT_STAGGER_MS=150,DOT_CYCLE_MS=600,DOT_GROW_SCALE=1.4,DOT_PULSE_MIN_OPACITY=.4,Dot=({size:e,color:t,delay:i,duration:r,reduced:s})=>{const n=useTheme(),o=useRef(createAnimatedValue(0)).current;useEffect(()=>{const e=Animated.loop(Animated.sequence([Animated.delay(i),Animated.timing(o,{toValue:1,duration:r/2,easing:Easing.out(Easing.quad),useNativeDriver:nativeDriver}),Animated.timing(o,{toValue:0,duration:r/2,easing:Easing.in(Easing.quad),useNativeDriver:nativeDriver})]));return e.start(),()=>{e.stop()}},[o,i,r]);const a=useMemo(()=>({grow:o.interpolate({inputRange:[0,1],outputRange:[1,1.4]}),fade:o.interpolate({inputRange:[0,1],outputRange:[.4,1]})}),[o]);return _jsx(Animated.View,{style:{width:e,height:e,borderRadius:n.radius.pill,...smoothCorners,backgroundColor:t,...s?{opacity:a.fade}:{transform:[{scale:a.grow}]}}})};function Spinner({ref:e,...t}){const{size:i="md",color:r,message:s,overlay:n=!1,backdropColor:o,variant:a="circular",accessibilityLabel:l,labels:c,style:u,testID:d}=t;assertValidValue("Spinner","size",t.size,["sm","md","lg"]),assertValidValue("Spinner","variant",t.variant,["circular","dots","contained"]);const m=useMobileUiText("spinner",SPINNER_TEXT),g=useMemo(()=>({...m,...c}),[m,c]),p="contained"===a,f=n&&!p,h=useTheme(),y=usePresenceMotion(),b=y.duration("default"),j=useRef(createAnimatedValue(0)).current;useEffect(()=>{Animated.timing(j,{toValue:1,duration:b,easing:Easing.bezier(...h.motion.ease["in-out"]),useNativeDriver:nativeDriver}).start()},[j,h,b]);const x=useMemo(()=>buildStyles(h),[h]),v=sizeMap[i],S=r??h.colors.primary,C=o??h.colors.scrim,_=useMemo(()=>{if("contained"===a){const e=Math.round(1.5*v);return _jsx(View,{style:[x.container,{width:e,height:e,borderRadius:h.radius.pill,backgroundColor:blendOf(S,.14,h.colors.surface,h.colors["bg-subtle"])}],children:_jsx(ActivityIndicator,{color:S,size:"sm"===i?"small":"large",style:{width:v,height:v}})})}if("dots"===a){const e=Math.max(6,Math.round(v/4));return _jsx(View,{style:[x.dotsRow,{gap:Math.round(e/2)}],children:DOT_NAMES.map((t,i)=>_jsx(Dot,{size:e,color:S,delay:150*i,duration:600,reduced:y.reduced},t))})}return _jsx(ActivityIndicator,{color:S,size:"sm"===i?"small":"large",style:{width:v,height:v}})},[a,i,v,S,x.dotsRow,x.container,y.reduced,h.radius.pill,h.colors.surface,h.colors["bg-subtle"]]),R=l??s??g.loading,A=useRef(R);A.current=R,useEffect(()=>{p&&announce(A.current)},[p]);const M=useSquircle(f,h.radius.lg),T=M.active&&M.size?{borderRadius:squircleHostRadius(M.size.width,M.size.height,h.radius.lg)}:null;let E=x.inlineContent;f?E=x.overlayContent:p&&(E=x.containedContent);const w=_jsxs(Animated.View,{ref:e,accessible:!0,accessibilityRole:"progressbar",accessibilityLiveRegion:p?"none":"polite",accessibilityLabel:R,accessibilityState:{busy:!0},"aria-busy":!0,testID:d,onLayout:M.onLayout,style:[E,T,{opacity:j}],children:[M.active&&M.size?_jsx(SquircleFill,{width:M.size.width,height:M.size.height,radius:h.radius.lg,fill:h.colors.surface,hostBorderWidth:0}):null,_,s?_jsx(Text,{variant:"body",weight:"medium",style:[x.message,{marginTop:h.space.md}],numberOfLines:2,children:s}):null]});return _jsx(View,f?{pointerEvents:"auto",style:[x.overlay,{backgroundColor:C},u],children:w}:{style:[p?x.containedFill:x.inline,u],children:w})}const buildStyles=e=>StyleSheet.create({inline:{alignItems:"center",justifyContent:"center"},inlineContent:{alignItems:"center",justifyContent:"center"},containedFill:{flex:1,alignSelf:"stretch",alignItems:"center",justifyContent:"center",minHeight:Math.round(1.5*sizeMap.lg)+2*e.space.xl},containedContent:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},container:{alignItems:"center",justifyContent:"center"},overlay:{...StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center",zIndex:1e3},overlayContent:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors.surface,borderRadius:e.radius.lg,...smoothCorners,paddingHorizontal:e.space.xl,paddingVertical:e.space.xl,minWidth:140,...e.shadow.popover},dotsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},message:{textAlign:"center"}});export{Spinner};export default Spinner;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useState}from"react";import{Animated,Platform,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{squircleApplies,squirclePath}from"../../utils/squircle.js";import{jsx as _jsx}from"react/jsx-runtime";const AnimatedPath=Animated.createAnimatedComponent(Path);export function SquircleFill({width:t,height:e,radius:i,fill:r,stroke:s,strokeWidth:o=0,testID:l}){const a=o>0&&void 0!==s&&"transparent"!==s,n=a?o/2:0,h=useTheme().cornerSmoothing,u=squirclePath({width:t,height:e,radius:i,inset:n,smoothing:h});return _jsx(View,{pointerEvents:"none",style:styles.overlay,testID:l,children:_jsx(Svg,{width:t,height:e,viewBox:`0 0 ${t} ${e}`,children:_jsx(AnimatedPath,{d:u,fill:r,...a?{stroke:s,strokeWidth:o}:{}})})})}SquircleFill.displayName="SquircleFill";export function useSquircle(t,e,i){const[r,s]=useState(null),o=t&&"android"===Platform.OS;return{onLayout:useCallback(t=>{if(o){const{width:e,height:i}=t.nativeEvent.layout;s(t=>t&&t.width===e&&t.height===i?t:{width:e,height:i})}i?.(t)},[o,i]),size:r,active:o&&null!==r&&squircleApplies(r.width,r.height,e)}}const styles=StyleSheet.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0}});
1
+ "use strict";import{useCallback,useState}from"react";import{Animated,Platform,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{squircleApplies,squirclePath}from"../../utils/squircle.js";import{jsx as _jsx}from"react/jsx-runtime";const AnimatedPath=Animated.createAnimatedComponent(Path);export function SquircleFill({width:t,height:e,radius:i,fill:r,stroke:o,strokeWidth:s=0,hostBorderWidth:l,testID:n}){const a=s>0&&void 0!==o&&"transparent"!==o,h=a?s/2:0,u=useTheme().cornerSmoothing,c=squirclePath({width:t,height:e,radius:i,inset:h,smoothing:u});return _jsx(View,{pointerEvents:"none",style:[styles.overlay,l>0?{top:-l,left:-l,right:-l,bottom:-l}:null],testID:n,children:_jsx(Svg,{width:"100%",height:"100%",viewBox:`0 0 ${t} ${e}`,preserveAspectRatio:"none",children:_jsx(AnimatedPath,{d:c,fill:r,...a?{stroke:o,strokeWidth:s}:{}})})})}SquircleFill.displayName="SquircleFill";export function useSquircle(t,e,i){const[r,o]=useState(null),s=t&&"android"===Platform.OS;return{onLayout:useCallback(t=>{if(s){const{width:e,height:i}=t.nativeEvent.layout;o(t=>t&&t.width===e&&t.height===i?t:{width:e,height:i})}i?.(t)},[s,i]),size:r,active:s&&null!==r&&squircleApplies(r.width,r.height,e)}}const styles=StyleSheet.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0}});
@@ -1 +1 @@
1
- "use strict";import{StyleSheet,View}from"react-native";import{smoothCorners}from"../../utils/corners.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const PER_EDGE_KEYS=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderTopStartRadius","borderTopEndRadius","borderBottomStartRadius","borderBottomEndRadius","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStartWidth","borderEndWidth","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderStartColor","borderEndColor"],readShape=r=>{const{borderRadius:e,backgroundColor:o,borderColor:t,borderWidth:i=0,borderStyle:d}=r;if("number"!=typeof e||e<=0||"hidden"===r.overflow||(r.elevation??0)>0||void 0!==d&&"solid"!==d||PER_EDGE_KEYS.some(e=>void 0!==r[e]))return null;const s="string"==typeof o&&"transparent"!==o,l=i>0&&"string"==typeof t&&"transparent"!==t;return void 0!==o&&"string"!=typeof o||i>0&&void 0!==t&&"string"!=typeof t||!s&&!l?null:{radius:e,fill:s?o:"transparent",stroke:l?t:void 0,strokeWidth:l?i:0}};function SquircleView({style:r,children:e,onLayout:o,ref:t,...i}){const d=StyleSheet.flatten(r)??{},s=readShape(d),l="number"==typeof d.borderRadius?d.borderRadius:0,n=useSquircle(l>0,l,o),a=n.active?n.size:null,u=null!==s&&null!==a;return _jsxs(View,{ref:t,...i,onLayout:n.onLayout,style:[l>0?smoothCorners:null,r,u?styles.hostTransparent:null],children:[s&&a?_jsx(SquircleFill,{width:a.width,height:a.height,radius:s.radius,fill:s.fill,stroke:s.stroke,strokeWidth:s.strokeWidth}):null,e]})}SquircleView.displayName="SquircleView";const styles=StyleSheet.create({hostTransparent:{backgroundColor:"transparent",borderColor:"transparent"}});export{SquircleView};export default SquircleView;
1
+ "use strict";import{StyleSheet,View}from"react-native";import{smoothCorners}from"../../utils/corners.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const PER_EDGE_KEYS=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderTopStartRadius","borderTopEndRadius","borderBottomStartRadius","borderBottomEndRadius","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStartWidth","borderEndWidth","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderStartColor","borderEndColor"],readShape=r=>{const{borderRadius:e,backgroundColor:o,borderColor:t,borderWidth:i=0,borderStyle:d}=r;if("number"!=typeof e||e<=0||"hidden"===r.overflow||(r.elevation??0)>0||void 0!==d&&"solid"!==d||PER_EDGE_KEYS.some(e=>void 0!==r[e]))return null;const s="string"==typeof o&&"transparent"!==o,l=i>0&&"string"==typeof t&&"transparent"!==t;return void 0!==o&&"string"!=typeof o||i>0&&void 0!==t&&"string"!=typeof t||!s&&!l?null:{radius:e,fill:s?o:"transparent",stroke:l?t:void 0,strokeWidth:l?i:0}};function SquircleView({style:r,children:e,onLayout:o,ref:t,...i}){const d=StyleSheet.flatten(r)??{},s=readShape(d),l="number"==typeof d.borderRadius?d.borderRadius:0,n=useSquircle(l>0,l,o),a=n.active?n.size:null,u=null!==s&&null!==a;return _jsxs(View,{ref:t,...i,onLayout:n.onLayout,style:[l>0?smoothCorners:null,r,u?styles.hostTransparent:null],children:[s&&a?_jsx(SquircleFill,{width:a.width,height:a.height,radius:s.radius,fill:s.fill,stroke:s.stroke,strokeWidth:s.strokeWidth,hostBorderWidth:"number"==typeof d.borderWidth?d.borderWidth:0}):null,e]})}SquircleView.displayName="SquircleView";const styles=StyleSheet.create({hostTransparent:{backgroundColor:"transparent",borderColor:"transparent"}});export{SquircleView};export default SquircleView;
@@ -1 +1 @@
1
- "use strict";import{Logger}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,ScrollView,StyleSheet,View}from"react-native";import{createAnimatedValue,resolveSegmentedControlSize,resolveTabsSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Badge}from"../Badge/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const measuredLayout=(e,t)=>{const i=e[t];if(void 0===i)throw new Error(`Tabs: tab "${t}" has no measured layout while its progress signal drives the indicator`);return i};function Tabs({ref:e,...t}){const{tabs:i,activeKey:a,onChange:r,variant:s="underline",radius:n,size:o="md",scrollable:l=!1,align:d="left",style:c,tabStyle:u,tabLabelStyle:m,tabIconStyle:p,tabBadgeStyle:b,dividerStyle:g,indicatorStyle:h,progress:f,pages:y,haptic:x,accessibilityLabel:v,testID:S}=t;assertValidValue("Tabs","variant",t.variant,["underline","pills","segmented"]),assertValidValue("Tabs","size",t.size,["sm","md","lg"]),assertValidValue("Tabs","align",t.align,["left","center"]);const w=useTheme(),V=useMemo(()=>buildStyles(w),[w]),j=w.components.tabs,_=useMemo(()=>resolveTabsSize(w,o),[w,o]),k=l?_["scrollable-padding-x"]:_["padding-x"],T=_["padding-y"],z=_.text,C=w.space[j["icon-gap"]],R=_.icon,L=j["underline-height"],E=w.space[j["pill-inset"]],I=j["disabled-opacity"],A=w.space[j["badge-gap"]],F="segmented"===s,M=useMemo(()=>resolveSegmentedControlSize(w,o),[w,o]),H=w.space[j["track-padding"]],B="number"==typeof n?n:n?w.radius[n]:void 0,D=B??w.radius.md,P=void 0===B?w.radius.sm:Math.max(B-H,0),q=B??w.radius.pill,$=B??w.radius.none,N=w.colors["bg-muted"],O=useSquircle(F,D),[W,U]=useState({}),K=useRef(createAnimatedValue(0)).current,X=useRef(createAnimatedValue(0)).current,[G,J]=useState(0),Q=useRef(createAnimatedValue(0)).current,Y=useRef(null),Z=useRef(0),ee=W[a],te=Math.max(0,i.findIndex(e=>e.key===a)),ie=useMemo(()=>y&&G>0?Q.interpolate({inputRange:[0,G],outputRange:[0,1]}):void 0,[y,G,Q])??f,ae=i.every(e=>void 0!==W[e.key]),re=void 0!==ie&&ae&&i.length>1,se=useMemo(()=>re&&ie?ie.interpolate({inputRange:i.map((e,t)=>t),outputRange:i.map(e=>measuredLayout(W,e.key).x),extrapolate:"clamp"}):null,[re,ie,i,W]),ne=useMemo(()=>re&&ie?ie.interpolate({inputRange:i.map((e,t)=>t),outputRange:i.map(e=>measuredLayout(W,e.key).width),extrapolate:"clamp"}):null,[re,ie,i,W]),oe=useRef(null);useEffect(()=>{if(!ee)return;if(re)return;const e=null!==oe.current&&oe.current!==a;if(oe.current=a,!e)return K.setValue(ee.x),void X.setValue(ee.width);const t=w.motion.spring.snappy,i=Animated.parallel([Animated.spring(K,{toValue:ee.x,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!1}),Animated.spring(X,{toValue:ee.width,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!1})]);return i.start(),()=>i.stop()},[ee,a,K,X,w.motion.spring.snappy,re]),useEffect(()=>{y&&0!==G&&Z.current!==te&&(Z.current=te,Y.current?.scrollTo({x:te*G,animated:!0}))},[y,G,te]);const le=y?.length;useEffect(()=>{__DEV__&&void 0!==le&&le!==i.length&&Logger.warn(`[@webority/mobile-ui] Tabs pages has ${le} entries for ${i.length} tabs; each tab needs one page.`)},[le,i.length]);const de=useCallback(e=>t=>{const{x:i,width:a}=t.nativeEvent.layout;U(t=>{const r=t[e];return r&&r.x===i&&r.width===a?t:{...t,[e]:{x:i,width:a}}})},[]),ce=useCallback(e=>{if(e.disabled)return;if(e.key===a)return;const t=resolveHaptic(x,"selection");t&&triggerHaptic(t),r(e.key)},[a,r,x]),ue="pills"===s,me=_jsx(Animated.View,{pointerEvents:"none",style:[F?V.indicatorThumb:ue?V.indicatorPill:V.indicatorUnderline,F?null:ue?{top:E,bottom:E}:{height:L},{width:ne??X,transform:[{translateX:se??K}],backgroundColor:F?w.colors.surface:ue?w.colors["primary-soft"]:w.colors.primary,borderRadius:F?P:ue?q:$,...smoothCorners},h]}),renderTabs=()=>i.map(e=>{const t=e.key===a,i=!0===e.disabled,r=t?w.colors.primary:w.colors["text-subtle"],s=renderSlotIcon(e.icon,{color:r,size:R,focused:t,disabled:i}),n=Boolean(s);return _jsxs(Pressable,{onPress:()=>ce(e),onLayout:de(e.key),disabled:i,accessibilityRole:"tab",accessibilityLabel:e.label,accessibilityState:{selected:t,disabled:i},"aria-selected":t,"aria-disabled":i,android_ripple:F?void 0:{color:w.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[V.tab,l?null:V.tabFlex,F?{paddingHorizontal:M["padding-x"],height:M.height-2*H}:{paddingHorizontal:k,paddingVertical:T},{opacity:i?I:e&&F&&!t?.7:1,backgroundColor:e&&!F?w.colors["surface-pressed"]:"transparent"},u],children:[n?_jsx(View,{style:[V.tabIcon,{marginRight:C},p],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:s}):null,_jsx(Text,{variant:"label",weight:t?"semibold":"medium",color:t?"brand":"tertiary",style:[V.tabLabel,{fontSize:F?M.text:z},m],numberOfLines:1,children:e.label}),void 0!==e.badge&&null!==e.badge?_jsx(Badge,{value:String(e.badge),tone:"primary",fill:"soft",accessible:!1,style:{marginLeft:A},badgeStyle:[V.tabBadge,b]}):null]},e.key)}),pe={flexDirection:"row",alignItems:"stretch",justifyContent:l?"flex-start":"center"===d?"center":"flex-start",position:"relative",overflow:"hidden"},be=_jsxs(_Fragment,F?{children:[me,renderTabs()]}:{children:[renderTabs(),me]}),ge=_jsxs(View,{ref:e,style:[V.container,{borderBottomColor:w.colors["border-subtle"],borderBottomWidth:"underline"===s?StyleSheet.hairlineWidth:0},"underline"===s?g:null,F?{padding:H,borderRadius:D,...smoothCorners,backgroundColor:O.active?"transparent":N}:null,c],onLayout:O.onLayout,accessibilityRole:"tablist",accessibilityLabel:v,testID:S,children:[O.active&&O.size?_jsx(SquircleFill,{width:O.size.width,height:O.size.height,radius:D,fill:N}):null,l?_jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:[pe],keyboardShouldPersistTaps:"handled",children:be}):_jsx(View,{style:pe,children:be})]});return y?_jsxs(View,{style:V.root,children:[ge,_jsx(Animated.ScrollView,{ref:Y,horizontal:!0,pagingEnabled:!0,showsHorizontalScrollIndicator:!1,scrollEventThrottle:16,onLayout:e=>J(Math.round(e.nativeEvent.layout.width)),onScroll:Animated.event([{nativeEvent:{contentOffset:{x:Q}}}],{useNativeDriver:!1}),onMomentumScrollEnd:e=>{if(0===G)return;const t=Math.round(e.nativeEvent.contentOffset.x/G),s=i[t];s?.disabled?Y.current?.scrollTo({x:te*G,animated:!0}):(Z.current=t,s&&s.key!==a&&r(s.key))},style:V.pager,testID:S?`${S}-pages`:void 0,children:i.map((e,t)=>_jsx(View,{style:{width:G},accessibilityElementsHidden:t!==te,importantForAccessibility:t===te?"auto":"no-hide-descendants",children:y[t]},e.key))})]}):ge}const buildStyles=e=>StyleSheet.create({root:{flex:1},pager:{flex:1},container:{width:"100%",position:"relative"},tab:{flexDirection:"row",alignItems:"center",justifyContent:"center"},tabFlex:{flex:1},tabIcon:{},tabLabel:{includeFontPadding:!1,flexShrink:1},tabBadge:{minWidth:18,minHeight:0},indicatorUnderline:{position:"absolute",left:0,bottom:0},indicatorPill:{position:"absolute",left:0,zIndex:-1},indicatorThumb:{position:"absolute",left:0,top:0,bottom:0}});export{Tabs};export default Tabs;
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,ScrollView,StyleSheet,View}from"react-native";import{createAnimatedValue,resolveSegmentedControlSize,resolveTabsSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Badge}from"../Badge/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const measuredLayout=(e,t)=>{const i=e[t];if(void 0===i)throw new Error(`Tabs: tab "${t}" has no measured layout while its progress signal drives the indicator`);return i};function Tabs({ref:e,...t}){const{tabs:i,activeKey:a,onChange:r,variant:s="underline",radius:n,size:o="md",scrollable:l=!1,align:d="left",style:c,tabStyle:u,tabLabelStyle:m,tabIconStyle:p,tabBadgeStyle:b,dividerStyle:g,indicatorStyle:h,progress:f,pages:y,haptic:x,accessibilityLabel:v,testID:S}=t;assertValidValue("Tabs","variant",t.variant,["underline","pills","segmented"]),assertValidValue("Tabs","size",t.size,["sm","md","lg"]),assertValidValue("Tabs","align",t.align,["left","center"]);const w=useTheme(),V=useMemo(()=>buildStyles(w),[w]),j=w.components.tabs,_=useMemo(()=>resolveTabsSize(w,o),[w,o]),k=l?_["scrollable-padding-x"]:_["padding-x"],T=_["padding-y"],z=_.text,C=w.space[j["icon-gap"]],R=_.icon,L=j["underline-height"],E=w.space[j["pill-inset"]],I=j["disabled-opacity"],A=w.space[j["badge-gap"]],F="segmented"===s,M=useMemo(()=>resolveSegmentedControlSize(w,o),[w,o]),H=w.space[j["track-padding"]],B="number"==typeof n?n:n?w.radius[n]:void 0,D=B??w.radius.md,P=void 0===B?w.radius.sm:Math.max(B-H,0),q=B??w.radius.pill,W=B??w.radius.none,$=w.colors["bg-muted"],N=useSquircle(F,D),[O,U]=useState({}),K=useRef(createAnimatedValue(0)).current,X=useRef(createAnimatedValue(0)).current,[G,J]=useState(0),Q=useRef(createAnimatedValue(0)).current,Y=useRef(null),Z=useRef(0),ee=O[a],te=Math.max(0,i.findIndex(e=>e.key===a)),ie=useMemo(()=>y&&G>0?Q.interpolate({inputRange:[0,G],outputRange:[0,1]}):void 0,[y,G,Q])??f,ae=i.every(e=>void 0!==O[e.key]),re=void 0!==ie&&ae&&i.length>1,se=useMemo(()=>re&&ie?ie.interpolate({inputRange:i.map((e,t)=>t),outputRange:i.map(e=>measuredLayout(O,e.key).x),extrapolate:"clamp"}):null,[re,ie,i,O]),ne=useMemo(()=>re&&ie?ie.interpolate({inputRange:i.map((e,t)=>t),outputRange:i.map(e=>measuredLayout(O,e.key).width),extrapolate:"clamp"}):null,[re,ie,i,O]),oe=useRef(null);useEffect(()=>{if(!ee)return;if(re)return;const e=null!==oe.current&&oe.current!==a;if(oe.current=a,!e)return K.setValue(ee.x),void X.setValue(ee.width);const t=w.motion.spring.snappy,i=Animated.parallel([Animated.spring(K,{toValue:ee.x,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!1}),Animated.spring(X,{toValue:ee.width,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!1})]);return i.start(),()=>i.stop()},[ee,a,K,X,w.motion.spring.snappy,re]),useEffect(()=>{y&&0!==G&&Z.current!==te&&(Z.current=te,Y.current?.scrollTo({x:te*G,animated:!0}))},[y,G,te]);const le=y?.length;useEffect(()=>{__DEV__&&void 0!==le&&le!==i.length&&Logger.warn(`[@webority/mobile-ui] Tabs pages has ${le} entries for ${i.length} tabs; each tab needs one page.`)},[le,i.length]);const de=useCallback(e=>t=>{const{x:i,width:a}=t.nativeEvent.layout;U(t=>{const r=t[e];return r&&r.x===i&&r.width===a?t:{...t,[e]:{x:i,width:a}}})},[]),ce=useCallback(e=>{if(e.disabled)return;if(e.key===a)return;const t=resolveHaptic(x,"selection");t&&triggerHaptic(t),r(e.key)},[a,r,x]),ue="pills"===s,me=_jsx(Animated.View,{pointerEvents:"none",style:[F?V.indicatorThumb:ue?V.indicatorPill:V.indicatorUnderline,F?null:ue?{top:E,bottom:E}:{height:L},{width:ne??X,transform:[{translateX:se??K}],backgroundColor:F?w.colors.surface:ue?w.colors["primary-soft"]:w.colors.primary,borderRadius:F?P:ue?q:W,...smoothCorners},h]}),renderTabs=()=>i.map(e=>{const t=e.key===a,i=!0===e.disabled,r=t?w.colors.primary:w.colors["text-subtle"],s=renderSlotIcon(e.icon,{color:r,size:R,focused:t,disabled:i}),n=Boolean(s);return _jsxs(Pressable,{onPress:()=>ce(e),onLayout:de(e.key),disabled:i,accessibilityRole:"tab",accessibilityLabel:e.label,accessibilityState:{selected:t,disabled:i},"aria-selected":t,"aria-disabled":i,android_ripple:F?void 0:{color:w.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[V.tab,l?null:V.tabFlex,F?{paddingHorizontal:M["padding-x"],height:M.height-2*H}:{paddingHorizontal:k,paddingVertical:T},{opacity:i?I:e&&F&&!t?.7:1,backgroundColor:e&&!F?w.colors["surface-pressed"]:"transparent"},u],children:[n?_jsx(View,{style:[V.tabIcon,{marginRight:C},p],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:s}):null,_jsx(Text,{variant:"label",weight:t?"semibold":"medium",color:t?"brand":"tertiary",style:[V.tabLabel,{fontSize:F?M.text:z},m],numberOfLines:1,children:e.label}),void 0!==e.badge&&null!==e.badge?_jsx(Badge,{value:String(e.badge),tone:"primary",fill:"soft",accessible:!1,style:{marginLeft:A},badgeStyle:[V.tabBadge,b]}):null]},e.key)}),pe={flexDirection:"row",alignItems:"stretch",justifyContent:l?"flex-start":"center"===d?"center":"flex-start",position:"relative",overflow:"hidden"},be=_jsxs(_Fragment,F?{children:[me,renderTabs()]}:{children:[renderTabs(),me]}),ge=_jsxs(View,{ref:e,style:[V.container,{borderBottomColor:w.colors["border-subtle"],borderBottomWidth:"underline"===s?StyleSheet.hairlineWidth:0},"underline"===s?g:null,F?{padding:H,borderRadius:D,...smoothCorners,backgroundColor:N.active?"transparent":$}:null,c],onLayout:N.onLayout,accessibilityRole:"tablist",accessibilityLabel:v,testID:S,children:[N.active&&N.size?_jsx(SquircleFill,{width:N.size.width,height:N.size.height,radius:D,fill:$,hostBorderWidth:0}):null,l?_jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:[pe],keyboardShouldPersistTaps:"handled",children:be}):_jsx(View,{style:pe,children:be})]});return y?_jsxs(View,{style:V.root,children:[ge,_jsx(Animated.ScrollView,{ref:Y,horizontal:!0,pagingEnabled:!0,showsHorizontalScrollIndicator:!1,scrollEventThrottle:16,onLayout:e=>J(Math.round(e.nativeEvent.layout.width)),onScroll:Animated.event([{nativeEvent:{contentOffset:{x:Q}}}],{useNativeDriver:!1}),onMomentumScrollEnd:e=>{if(0===G)return;const t=Math.round(e.nativeEvent.contentOffset.x/G),s=i[t];s?.disabled?Y.current?.scrollTo({x:te*G,animated:!0}):(Z.current=t,s&&s.key!==a&&r(s.key))},style:V.pager,testID:S?`${S}-pages`:void 0,children:i.map((e,t)=>_jsx(View,{style:{width:G},accessibilityElementsHidden:t!==te,importantForAccessibility:t===te?"auto":"no-hide-descendants",children:y[t]},e.key))})]}):ge}const buildStyles=e=>StyleSheet.create({root:{flex:1},pager:{flex:1},container:{width:"100%",position:"relative"},tab:{flexDirection:"row",alignItems:"center",justifyContent:"center"},tabFlex:{flex:1},tabIcon:{},tabLabel:{includeFontPadding:!1,flexShrink:1},tabBadge:{minWidth:18,minHeight:0},indicatorUnderline:{position:"absolute",left:0,bottom:0},indicatorPill:{position:"absolute",left:0,zIndex:-1},indicatorThumb:{position:"absolute",left:0,top:0,bottom:0}});export{Tabs};export default Tabs;
@@ -1 +1 @@
1
- "use strict";import{hasKey,isOneOf,isRecord,keysOf}from"../utils/guards.js";import{validateComponentTokens}from"./componentSizes.js";import{COLOR_NAMES,FONT_NAMES,RADIUS_NAMES,WEIGHT_NAMES}from"./tokens.generated.js";import{deriveSolidFill,deriveStateFills,deriveToneInk}from"./toneInk.js";const BRAND_KEYS=["colors","descriptions","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0,headerShadowOnScroll:!0}},isPlainObject=o=>"object"==typeof o&&null!==o&&!Array.isArray(o),validateBrand=o=>{if(void 0===o)return;if(!isPlainObject(o))throw new Error(`A brand is an object of colors, radius and font; got ${typeof o}.`);for(const t of Object.keys(o))if(!BRAND_KEYS.includes(t))throw new Error(`A brand sets colors, descriptions, radius and font only; ${t} is not allowed (allowed: colors, descriptions, radius, font).`);const t=o.descriptions;if(void 0!==t){if(!isPlainObject(t))throw new Error(`A brand's descriptions is an object of colour names to a description; got ${typeof t}.`);for(const o of Object.keys(t)){const e=t[o];if("string"!=typeof e||""===e)throw new Error(`description of colour ${o} must be a non-empty string.`)}}const e=o.colors;if(void 0!==e&&!isPlainObject(e))throw new Error(`A brand's colors is an object of light and dark; got ${typeof e}.`);if(isRecord(e))for(const o of Object.keys(e)){if(!COLOR_MODES.includes(o))throw new Error(`A brand sets colours under light and dark only; ${o} is not allowed (allowed: light, dark).`);const n=e[o];if(void 0===n)throw new Error(`A brand's ${o} colours are missing.`);if(!isRecord(n))throw new Error(`A brand's ${o} colours is an object of colour names; got ${typeof n}.`);for(const o of Object.keys(n)){const e=isRecord(t)&&"string"==typeof t[o];if(!isOneOf(COLOR_NAMES,o)&&!e)throw new Error(`unknown colour ${o}; allowed: ${COLOR_NAMES.join(", ")}.`);if(void 0!==n[o]&&"string"!=typeof n[o])throw new Error(`colour ${o} must be a string; got ${typeof n[o]}.`)}}const n=o.radius;if(void 0!==n){if(!isPlainObject(n))throw new Error(`A brand's radius is an object of radius names; got ${typeof n}.`);for(const o of Object.keys(n)){const t=n[o];if(!isOneOf(RADIUS_NAMES,o))throw new Error(`unknown radius ${o}; allowed: ${RADIUS_ALLOWED}.`);if(FIXED_RADII.includes(o))throw new Error(`radius ${o} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof t||!Number.isFinite(t))throw new Error(`radius ${o} must be a number; got ${typeof t}.`)}}const r=o.font;if(void 0!==r){if(!isPlainObject(r))throw new Error(`A brand's font is an object of font names; got ${typeof r}.`);for(const o of Object.keys(r)){if(!isOneOf(FONT_NAMES,o))throw new Error(`unknown font ${o}; allowed: ${FONT_NAMES.join(", ")}.`);const t=r[o];if(!isPlainObject(t))throw new Error(`font ${o} must be an object of weights; got ${typeof t}.`);for(const e of Object.keys(t)){if(!isOneOf(WEIGHT_NAMES,e))throw new Error(`unknown font weight ${e} in font ${o}; allowed: ${WEIGHT_NAMES.join(", ")}.`);const n=t[e];if("string"!=typeof n||0===n.length)throw new Error(`font ${o} weight ${e} must be a non-empty string.`)}}}},validateSettings=o=>{if(void 0===o)return;if(!isPlainObject(o))throw new Error(`Theme settings is an object; got ${typeof o}.`);for(const t of Object.keys(o))if(!isOneOf(SETTINGS_KEYS,t))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${t} is not allowed.`);const t=o.components;if(void 0!==t){if(!isPlainObject(t))throw new Error(`Theme settings components is an object of component names; got ${typeof t}.`);for(const o of Object.keys(t)){if(!hasKey(COMPONENT_SETTING_KEYS,o))throw new Error(`unknown component ${o} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}.`);const e=t[o];if(void 0===e)continue;if(!isPlainObject(e))throw new Error(`theme settings for ${o} is an object; got ${typeof e}.`);const n=COMPONENT_SETTING_KEYS[o];for(const t of Object.keys(e))if(!(t in n))throw new Error(`unknown setting ${t} for ${o}; allowed: ${Object.keys(n).join(", ")}.`)}}},TONES=["primary","success","warning","danger","info"],setComponentSettings=(o,t,e)=>{o[t]=e},mergeComponentSettings=(o,t,e)=>({...hasKey(o,e)?o[e]:void 0,...void 0!==t&&hasKey(t,e)?t[e]:void 0});export const mergeBrand=(o,t,e)=>{validateBrand(t),validateSettings(e);const n={};for(const[e,r]of Object.entries(t?.colors?.[o.mode]??{}))void 0!==r&&(n[e]=r);const r={...o.colors,...n},colorOf=o=>{const t=r[o];if(void 0===t)throw new Error(`The theme has no colour ${o}.`);return t},i={...o.radius,...t?.radius},s={...o.font};if(void 0!==t?.font)for(const e of keysOf(t.font))s[e]={...o.font[e],...t.font[e]};const a=[colorOf("bg"),colorOf("bg-subtle"),colorOf("bg-muted")],f={};for(const t of TONES){const e="string"==typeof n[t];let r=colorOf(t);if(e||"string"==typeof n[`on-${t}`]){const o=deriveSolidFill(r,colorOf(`on-${t}`));o!==r&&(f[t]=o,r=o)}if(e&&"string"!=typeof n[`${t}-text`]&&(f[`${t}-text`]=deriveToneInk(r,a,o.mode)),"primary"===t&&(e||void 0!==f.primary)){const t=deriveStateFills(r,colorOf("on-primary"),{fill:o.colors.primary,hover:o.colors["primary-hover"],pressed:o.colors["primary-pressed"]});"string"!=typeof n["primary-hover"]&&(f["primary-hover"]=t.hover),"string"!=typeof n["primary-pressed"]&&(f["primary-pressed"]=t.pressed)}}const d=o.settings.components,l=e?.components,c={},p=new Set([...keysOf(d),...void 0===l?[]:keysOf(l)]);for(const o of p)setComponentSettings(c,o,mergeComponentSettings(d,l,o));const u=e?.maxFontSizeMultiplier??o.settings.maxFontSizeMultiplier,O={icons:{...o.settings.icons,...e?.icons},gradients:{...o.settings.gradients,...e?.gradients},textVariants:{...o.settings.textVariants,...e?.textVariants},components:c,...void 0===u?{}:{maxFontSizeMultiplier:u}},m={...o.colors,...Object.fromEntries(Object.entries(n).filter(([o])=>!isOneOf(COLOR_NAMES,o))),...Object.fromEntries(COLOR_NAMES.map(o=>[o,f[o]??colorOf(o)]))},w={...o,colors:m,radius:i,font:s,settings:O};return validateComponentTokens(w),w};
1
+ "use strict";import{hasKey,isOneOf,isRecord,keysOf}from"../utils/guards.js";import{validateComponentTokens}from"./componentSizes.js";import{COLOR_NAMES,FONT_NAMES,RADIUS_NAMES,WEIGHT_NAMES}from"./tokens.generated.js";import{deriveSolidFill,deriveStateFills,deriveToneInk}from"./toneInk.js";const BRAND_KEYS=["colors","descriptions","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0,requiredMarkerSpace:!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=o=>"object"==typeof o&&null!==o&&!Array.isArray(o),validateBrand=o=>{if(void 0===o)return;if(!isPlainObject(o))throw new Error(`A brand is an object of colors, radius and font; got ${typeof o}.`);for(const e of Object.keys(o))if(!BRAND_KEYS.includes(e))throw new Error(`A brand sets colors, descriptions, radius and font only; ${e} is not allowed (allowed: colors, descriptions, radius, font).`);const e=o.descriptions;if(void 0!==e){if(!isPlainObject(e))throw new Error(`A brand's descriptions is an object of colour names to a description; got ${typeof e}.`);for(const o of Object.keys(e)){const t=e[o];if("string"!=typeof t||""===t)throw new Error(`description of colour ${o} must be a non-empty string.`)}}const t=o.colors;if(void 0!==t&&!isPlainObject(t))throw new Error(`A brand's colors is an object of light and dark; got ${typeof t}.`);if(isRecord(t))for(const o of Object.keys(t)){if(!COLOR_MODES.includes(o))throw new Error(`A brand sets colours under light and dark only; ${o} is not allowed (allowed: light, dark).`);const r=t[o];if(void 0===r)throw new Error(`A brand's ${o} colours are missing.`);if(!isRecord(r))throw new Error(`A brand's ${o} colours is an object of colour names; got ${typeof r}.`);for(const o of Object.keys(r)){const t=isRecord(e)&&"string"==typeof e[o];if(!isOneOf(COLOR_NAMES,o)&&!t)throw new Error(`unknown colour ${o}; allowed: ${COLOR_NAMES.join(", ")}.`);if(void 0!==r[o]&&"string"!=typeof r[o])throw new Error(`colour ${o} must be a string; got ${typeof r[o]}.`)}}const r=o.radius;if(void 0!==r){if(!isPlainObject(r))throw new Error(`A brand's radius is an object of radius names; got ${typeof r}.`);for(const o of Object.keys(r)){const e=r[o];if(!isOneOf(RADIUS_NAMES,o))throw new Error(`unknown radius ${o}; allowed: ${RADIUS_ALLOWED}.`);if(FIXED_RADII.includes(o))throw new Error(`radius ${o} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof e||!Number.isFinite(e))throw new Error(`radius ${o} must be a number; got ${typeof e}.`)}}const n=o.font;if(void 0!==n){if(!isPlainObject(n))throw new Error(`A brand's font is an object of font names; got ${typeof n}.`);for(const o of Object.keys(n)){if(!isOneOf(FONT_NAMES,o))throw new Error(`unknown font ${o}; allowed: ${FONT_NAMES.join(", ")}.`);const e=n[o];if(!isPlainObject(e))throw new Error(`font ${o} must be an object of weights; got ${typeof e}.`);for(const t of Object.keys(e)){if(!isOneOf(WEIGHT_NAMES,t))throw new Error(`unknown font weight ${t} in font ${o}; allowed: ${WEIGHT_NAMES.join(", ")}.`);const r=e[t];if("string"!=typeof r||0===r.length)throw new Error(`font ${o} weight ${t} must be a non-empty string.`)}}}},validateSettings=o=>{if(void 0===o)return;if(!isPlainObject(o))throw new Error(`Theme settings is an object; got ${typeof o}.`);for(const e of Object.keys(o))if(!isOneOf(SETTINGS_KEYS,e))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${e} is not allowed.`);const e=o.components;if(void 0!==e){if(!isPlainObject(e))throw new Error(`Theme settings components is an object of component names; got ${typeof e}.`);for(const o of Object.keys(e)){if(!hasKey(COMPONENT_SETTING_KEYS,o))throw new Error(`unknown component ${o} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}.`);const t=e[o];if(void 0===t)continue;if(!isPlainObject(t))throw new Error(`theme settings for ${o} is an object; got ${typeof t}.`);const r=COMPONENT_SETTING_KEYS[o];for(const e of Object.keys(t))if(!(e in r))throw new Error(`unknown setting ${e} for ${o}; allowed: ${Object.keys(r).join(", ")}.`)}}},TONES=["primary","success","warning","danger","info"],setComponentSettings=(o,e,t)=>{o[e]=t},mergeComponentSettings=(o,e,t)=>({...hasKey(o,t)?o[t]:void 0,...void 0!==e&&hasKey(e,t)?e[t]:void 0});export const mergeBrand=(o,e,t)=>{validateBrand(e),validateSettings(t);const r={};for(const[t,n]of Object.entries(e?.colors?.[o.mode]??{}))void 0!==n&&(r[t]=n);const n={...o.colors,...r},colorOf=o=>{const e=n[o];if(void 0===e)throw new Error(`The theme has no colour ${o}.`);return e},i={...o.radius,...e?.radius},s={...o.font};if(void 0!==e?.font)for(const t of keysOf(e.font))s[t]={...o.font[t],...e.font[t]};const a=[colorOf("bg"),colorOf("bg-subtle"),colorOf("bg-muted")],f={};for(const e of TONES){const t="string"==typeof r[e];let n=colorOf(e);if(t||"string"==typeof r[`on-${e}`]){const o=deriveSolidFill(n,colorOf(`on-${e}`));o!==n&&(f[e]=o,n=o)}if(t&&"string"!=typeof r[`${e}-text`]&&(f[`${e}-text`]=deriveToneInk(n,a,o.mode)),"primary"===e&&(t||void 0!==f.primary)){const e=deriveStateFills(n,colorOf("on-primary"),{fill:o.colors.primary,hover:o.colors["primary-hover"],pressed:o.colors["primary-pressed"]});"string"!=typeof r["primary-hover"]&&(f["primary-hover"]=e.hover),"string"!=typeof r["primary-pressed"]&&(f["primary-pressed"]=e.pressed)}}const d=o.settings.components,l=t?.components,c={},p=new Set([...keysOf(d),...void 0===l?[]:keysOf(l)]);for(const o of p)setComponentSettings(c,o,mergeComponentSettings(d,l,o));const u=t?.maxFontSizeMultiplier??o.settings.maxFontSizeMultiplier,O={icons:{...o.settings.icons,...t?.icons},gradients:{...o.settings.gradients,...t?.gradients},textVariants:{...o.settings.textVariants,...t?.textVariants},components:c,...void 0===u?{}:{maxFontSizeMultiplier:u}},m={...o.colors,...Object.fromEntries(Object.entries(r).filter(([o])=>!isOneOf(COLOR_NAMES,o))),...Object.fromEntries(COLOR_NAMES.map(o=>[o,f[o]??colorOf(o)]))},w={...o,colors:m,radius:i,font:s,settings:O};return validateComponentTokens(w),w};
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import type React from "react";
15
15
  import { type Ref } from "react";
16
- import type { View as RNView, StyleProp, TextStyle, ViewStyle } from "react-native";
16
+ import type { HostInstance, StyleProp, TextStyle, ViewStyle } from "react-native";
17
17
  import { type PickerTriggerText } from "../../text/phone/pickerTrigger.g";
18
18
  import type { FieldVariant, Size } from "../../types/vocabulary";
19
19
  export type PickerTriggerSize = Extract<Size, "sm" | "md" | "lg">;
@@ -60,14 +60,14 @@ export interface PickerTriggerProps {
60
60
  accessibilityLabel?: string | undefined;
61
61
  labels?: Partial<PickerTriggerText> | undefined;
62
62
  testID?: string | undefined;
63
- ref?: Ref<RNView> | undefined;
63
+ ref?: Ref<HostInstance> | undefined;
64
64
  }
65
65
  /** The PickerTrigger props a picker forwards to its built-in trigger field. */
66
66
  export type PickerTriggerPassThroughProps = Pick<PickerTriggerProps, "label" | "help" | "placeholder" | "helperText" | "error" | "required" | "disabled" | "size" | "variant" | "clearable" | "onClear" | "leftIcon" | "trailing" | "triggerStyle" | "valueStyle" | "labelStyle" | "messageStyle" | "accessibilityLabel"> & {
67
67
  /** Copy for the trigger field (placeholder, selection, noSelection, clear). Named apart from labels, which is the copy of the picker sheet. */
68
68
  triggerLabels?: Partial<PickerTriggerText> | undefined;
69
69
  };
70
- declare function PickerTrigger(props: PickerTriggerProps): React.ReactElement;
70
+ declare function PickerTrigger({ ref, ...props }: PickerTriggerProps): React.ReactElement;
71
71
  export { PickerTrigger };
72
72
  export default PickerTrigger;
73
73
  //# sourceMappingURL=PickerTrigger.d.ts.map
@@ -58,6 +58,8 @@ export interface ScreenProps<ItemT = unknown> {
58
58
  floatingAction?: React.ReactElement<FloatingActionSlotProps> | undefined;
59
59
  /** Default true. */
60
60
  keyboardToolbar?: boolean | undefined;
61
+ /** Drops the footer's bottom safe-area and tab-bar padding while the keyboard is open, so the footer sits right on the keyboard. Default false. */
62
+ footerHugsKeyboard?: boolean | undefined;
61
63
  scrollRef?: React.Ref<ScrollViewInstance | FlatList<ItemT>> | undefined;
62
64
  onScroll?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;
63
65
  contentContainerStyle?: StyleProp<ViewStyle> | undefined;
@@ -33,9 +33,15 @@ export interface SquircleFillProps {
33
33
  stroke?: SquircleColor | undefined;
34
34
  /** Border width; the path is inset by half of it so the outer edge meets the host's bounds. */
35
35
  strokeWidth?: number | undefined;
36
+ /**
37
+ * The host's own native border width (0 for none). Absolute children are laid out inside a
38
+ * native border, so the overlay is pulled outward by it to cover the whole border box; without
39
+ * that the shape drew one border width right and down, past the host's labels and buttons.
40
+ */
41
+ hostBorderWidth: number;
36
42
  testID?: string | undefined;
37
43
  }
38
- export declare function SquircleFill({ width, height, radius, fill, stroke, strokeWidth, testID }: SquircleFillProps): import("react").JSX.Element;
44
+ export declare function SquircleFill({ width, height, radius, fill, stroke, strokeWidth, hostBorderWidth, testID }: SquircleFillProps): import("react").JSX.Element;
39
45
  export declare namespace SquircleFill {
40
46
  var displayName: string;
41
47
  }
@@ -106,6 +106,8 @@ export interface ComponentSettings {
106
106
  field?: {
107
107
  defaultVariant?: FieldVariant | undefined;
108
108
  requiredMarker?: string | undefined;
109
+ /** Default true: a space between the label and the required marker. False draws the marker right after the label. */
110
+ requiredMarkerSpace?: boolean | undefined;
109
111
  } | undefined;
110
112
  input?: {
111
113
  defaultVariant?: FieldVariant | undefined;
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import type React from "react";
15
15
  import { type Ref } from "react";
16
- import type { View as RNView, StyleProp, TextStyle, ViewStyle } from "react-native";
16
+ import type { HostInstance, StyleProp, TextStyle, ViewStyle } from "react-native";
17
17
  import { type PickerTriggerText } from "../../text/phone/pickerTrigger.g.js";
18
18
  import type { FieldVariant, Size } from "../../types/vocabulary.js";
19
19
  export type PickerTriggerSize = Extract<Size, "sm" | "md" | "lg">;
@@ -60,14 +60,14 @@ export interface PickerTriggerProps {
60
60
  accessibilityLabel?: string | undefined;
61
61
  labels?: Partial<PickerTriggerText> | undefined;
62
62
  testID?: string | undefined;
63
- ref?: Ref<RNView> | undefined;
63
+ ref?: Ref<HostInstance> | undefined;
64
64
  }
65
65
  /** The PickerTrigger props a picker forwards to its built-in trigger field. */
66
66
  export type PickerTriggerPassThroughProps = Pick<PickerTriggerProps, "label" | "help" | "placeholder" | "helperText" | "error" | "required" | "disabled" | "size" | "variant" | "clearable" | "onClear" | "leftIcon" | "trailing" | "triggerStyle" | "valueStyle" | "labelStyle" | "messageStyle" | "accessibilityLabel"> & {
67
67
  /** Copy for the trigger field (placeholder, selection, noSelection, clear). Named apart from labels, which is the copy of the picker sheet. */
68
68
  triggerLabels?: Partial<PickerTriggerText> | undefined;
69
69
  };
70
- declare function PickerTrigger(props: PickerTriggerProps): React.ReactElement;
70
+ declare function PickerTrigger({ ref, ...props }: PickerTriggerProps): React.ReactElement;
71
71
  export { PickerTrigger };
72
72
  export default PickerTrigger;
73
73
  //# sourceMappingURL=PickerTrigger.d.ts.map
@@ -58,6 +58,8 @@ export interface ScreenProps<ItemT = unknown> {
58
58
  floatingAction?: React.ReactElement<FloatingActionSlotProps> | undefined;
59
59
  /** Default true. */
60
60
  keyboardToolbar?: boolean | undefined;
61
+ /** Drops the footer's bottom safe-area and tab-bar padding while the keyboard is open, so the footer sits right on the keyboard. Default false. */
62
+ footerHugsKeyboard?: boolean | undefined;
61
63
  scrollRef?: React.Ref<ScrollViewInstance | FlatList<ItemT>> | undefined;
62
64
  onScroll?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;
63
65
  contentContainerStyle?: StyleProp<ViewStyle> | undefined;
@@ -33,9 +33,15 @@ export interface SquircleFillProps {
33
33
  stroke?: SquircleColor | undefined;
34
34
  /** Border width; the path is inset by half of it so the outer edge meets the host's bounds. */
35
35
  strokeWidth?: number | undefined;
36
+ /**
37
+ * The host's own native border width (0 for none). Absolute children are laid out inside a
38
+ * native border, so the overlay is pulled outward by it to cover the whole border box; without
39
+ * that the shape drew one border width right and down, past the host's labels and buttons.
40
+ */
41
+ hostBorderWidth: number;
36
42
  testID?: string | undefined;
37
43
  }
38
- export declare function SquircleFill({ width, height, radius, fill, stroke, strokeWidth, testID }: SquircleFillProps): import("react").JSX.Element;
44
+ export declare function SquircleFill({ width, height, radius, fill, stroke, strokeWidth, hostBorderWidth, testID }: SquircleFillProps): import("react").JSX.Element;
39
45
  export declare namespace SquircleFill {
40
46
  var displayName: string;
41
47
  }
@@ -106,6 +106,8 @@ export interface ComponentSettings {
106
106
  field?: {
107
107
  defaultVariant?: FieldVariant | undefined;
108
108
  requiredMarker?: string | undefined;
109
+ /** Default true: a space between the label and the required marker. False draws the marker right after the label. */
110
+ requiredMarkerSpace?: boolean | undefined;
109
111
  } | undefined;
110
112
  input?: {
111
113
  defaultVariant?: FieldVariant | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-ui",
3
- "version": "0.183.0",
3
+ "version": "0.185.0",
4
4
  "description": "Beautiful, animated, accessible React Native components, theme and form engine for Webority projects.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -126,13 +126,13 @@
126
126
  }
127
127
  },
128
128
  "dependencies": {
129
- "@webority/markdown-core": "0.183.0"
129
+ "@webority/markdown-core": "0.185.0"
130
130
  },
131
131
  "peerDependencies": {
132
132
  "@react-navigation/bottom-tabs": ">=7.0.0",
133
133
  "@react-navigation/native": ">=7.0.0",
134
- "@webority/canvas-kit": "0.183.0",
135
- "@webority/mobile-core": "0.183.0",
134
+ "@webority/canvas-kit": "0.185.0",
135
+ "@webority/mobile-core": "0.185.0",
136
136
  "expo": ">=58.0.0",
137
137
  "expo-file-system": ">=58.0.0",
138
138
  "expo-haptics": ">=58.0.0",
@@ -196,10 +196,10 @@
196
196
  "@types/jest": "29.5.14",
197
197
  "@types/node": "25.6.0",
198
198
  "@types/react": "19.3.0",
199
- "@webority/canvas-kit": "0.183.0",
200
- "@webority/mobile-core": "0.183.0",
199
+ "@webority/canvas-kit": "0.185.0",
200
+ "@webority/mobile-core": "0.185.0",
201
201
  "@webority/mobile-dev": "0.0.0",
202
- "@webority/tokens": "0.183.0",
202
+ "@webority/tokens": "0.185.0",
203
203
  "expo": "58.0.23",
204
204
  "expo-file-system": "58.0.13",
205
205
  "expo-haptics": "58.0.7",