@webority/mobile-ui 0.107.0 → 0.108.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/canvas-kit/kit.js +4678 -4676
  2. package/dist/canvas-kit/manifest.json +7 -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/EmptyState/EmptyState.js +1 -1
  8. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  9. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  10. package/lib/commonjs/components/Select/Select.js +1 -1
  11. package/lib/commonjs/components/SquircleFill/SquircleFill.js +1 -1
  12. package/lib/commonjs/components/SquircleView/SquircleView.js +1 -1
  13. package/lib/module/components/Box/Box.js +1 -1
  14. package/lib/module/components/Button/Button.js +1 -1
  15. package/lib/module/components/Card/Card.js +1 -1
  16. package/lib/module/components/EmptyState/EmptyState.js +1 -1
  17. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  18. package/lib/module/components/ListItem/ListItem.js +1 -1
  19. package/lib/module/components/Select/Select.js +1 -1
  20. package/lib/module/components/SquircleFill/SquircleFill.js +1 -1
  21. package/lib/module/components/SquircleView/SquircleView.js +1 -1
  22. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +6 -0
  23. package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +1 -1
  24. package/lib/typescript/commonjs/components/Select/Select.d.ts +4 -0
  25. package/lib/typescript/commonjs/components/SquircleFill/SquircleFill.d.ts +1 -8
  26. package/lib/typescript/commonjs/navigation/NavigationScreen.d.ts +3 -0
  27. package/lib/typescript/module/components/ListItem/ListItem.d.ts +6 -0
  28. package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +1 -1
  29. package/lib/typescript/module/components/Select/Select.d.ts +4 -0
  30. package/lib/typescript/module/components/SquircleFill/SquircleFill.d.ts +1 -8
  31. package/lib/typescript/module/navigation/NavigationScreen.d.ts +3 -0
  32. package/package.json +7 -7
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.107.0"
5
+ "version": "0.108.1"
6
6
  },
7
7
  "rendererProtocolVersion": 12,
8
8
  "platform": "Phone",
@@ -8646,6 +8646,12 @@
8646
8646
  "description": "A bottom hairline drawn under the row.",
8647
8647
  "default": false
8648
8648
  },
8649
+ {
8650
+ "name": "expanded",
8651
+ "type": "boolean",
8652
+ "required": false,
8653
+ "description": "Open or closed state of a row that shows or hides content below it, announced to screen readers. Leave it unset on a row that discloses nothing."
8654
+ },
8649
8655
  {
8650
8656
  "name": "icon",
8651
8657
  "type": "icon",
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.107.0",
3
+ "version": "0.108.1",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 12,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.107.0"
9
+ "version": "0.108.1"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "6a67b1f63def2f747c7148adab6d6a3dfa09430bd39722b96ad4c750176f6653",
14
- "bytes": 622474
13
+ "sha256": "ae720951e31698d7a327b12be3aeb48af1d862e5f9b6d529f7c66e490ccfbf19",
14
+ "bytes": 622755
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "6c8ce45cffcaa55598e3733c8b3a6221bd5545cfb10cb776ffcf19d3503eef25",
18
- "bytes": 5932182
17
+ "sha256": "ff6c0fa9aff0c3dc04852bdda202a503bfcbf991aa79e0567d0e6f7a521889f8",
18
+ "bytes": 5932345
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveBoxStyle=exports.default=exports.Stack=exports.Spacer=exports.Row=exports.Box=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_scale=require("../../theme/scale.js"),_corners=require("../../utils/corners.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],space=(e,r)=>null==r?void 0:(0,_scale.spaceOf)(e,r),resolveBoxStyle=(e,r)=>{const t={};return null!=r.p&&(t.padding=space(e,r.p)),null!=r.px&&(t.paddingHorizontal=space(e,r.px)),null!=r.py&&(t.paddingVertical=space(e,r.py)),null!=r.pt&&(t.paddingTop=space(e,r.pt)),null!=r.pr&&(t.paddingRight=space(e,r.pr)),null!=r.pb&&(t.paddingBottom=space(e,r.pb)),null!=r.pl&&(t.paddingLeft=space(e,r.pl)),null!=r.m&&(t.margin=space(e,r.m)),null!=r.mx&&(t.marginHorizontal=space(e,r.mx)),null!=r.my&&(t.marginVertical=space(e,r.my)),null!=r.mt&&(t.marginTop=space(e,r.mt)),null!=r.mr&&(t.marginRight=space(e,r.mr)),null!=r.mb&&(t.marginBottom=space(e,r.mb)),null!=r.ml&&(t.marginLeft=space(e,r.ml)),null!=r.gap&&(t.gap=space(e,r.gap)),null!=r.bg&&(t.backgroundColor=BACKGROUND_TOKENS.includes(r.bg)?e.colors[r.bg]:r.bg),null!=r.radius&&(t.borderRadius=(0,_scale.radiusOf)(e,r.radius),t.borderCurve=_corners.smoothCorners.borderCurve),r.border&&(t.borderWidth=e.size.border,t.borderColor=e.colors.border),null!=r.flex&&(t.flex=r.flex),null!=r.align&&(t.alignItems=r.align),null!=r.justify&&(t.justifyContent=r.justify),null!=r.direction&&(t.flexDirection=r.direction),r.wrap&&(t.flexWrap="wrap"),t};exports.resolveBoxStyle=resolveBoxStyle;const Box=exports.Box=(0,_react.forwardRef)((e,r)=>{const t=(0,_index.useTheme)(),{p:l,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:_,radius:y,border:S,flex:j,align:h,justify:R,direction:v,wrap:w,style:B,children:q,...C}=e,N=resolveBoxStyle(t,{p:l,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:_,radius:y,border:S,flex:j,align:h,justify:R,direction:v,wrap:w}),k=(0,_SquircleFill.useSquircle)(null!=y&&(null!=_||Boolean(S)),N.borderRadius,C.onLayout),O=k.active?{...N,backgroundColor:"transparent",borderColor:"transparent"}:N;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,...C,onLayout:k.onLayout,style:[O,B],children:[k.active&&k.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:k.size.width,height:k.size.height,radius:N.borderRadius,fill:N.backgroundColor??"transparent",stroke:N.borderColor,strokeWidth:N.borderWidth??0,outset:N.borderWidth??0}):null,q]})});Box.displayName="Box";const Stack=exports.Stack=(0,_react.forwardRef)(({gap:e="md",...r},t)=>(0,_jsxRuntime.jsx)(Box,{ref:t,direction:"column",gap:e,...r}));Stack.displayName="Stack";const Row=exports.Row=(0,_react.forwardRef)(({gap:e="sm",align:r="center",...t},l)=>(0,_jsxRuntime.jsx)(Box,{ref:l,direction:"row",gap:e,align:r,...t}));Row.displayName="Row";const Spacer=({size:e,style:r,testID:t})=>{const l=(0,_index.useTheme)();if(null!=e){const a=(0,_scale.spaceOf)(l,e);return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:t,style:[{width:a,height:a},r]})}return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:t,style:[{flex:1},r]})};exports.Spacer=Spacer,Spacer.displayName="Spacer";var _default=exports.default=Box;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveBoxStyle=exports.default=exports.Stack=exports.Spacer=exports.Row=exports.Box=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_scale=require("../../theme/scale.js"),_corners=require("../../utils/corners.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],space=(e,r)=>null==r?void 0:(0,_scale.spaceOf)(e,r),resolveBoxStyle=(e,r)=>{const l={};return null!=r.p&&(l.padding=space(e,r.p)),null!=r.px&&(l.paddingHorizontal=space(e,r.px)),null!=r.py&&(l.paddingVertical=space(e,r.py)),null!=r.pt&&(l.paddingTop=space(e,r.pt)),null!=r.pr&&(l.paddingRight=space(e,r.pr)),null!=r.pb&&(l.paddingBottom=space(e,r.pb)),null!=r.pl&&(l.paddingLeft=space(e,r.pl)),null!=r.m&&(l.margin=space(e,r.m)),null!=r.mx&&(l.marginHorizontal=space(e,r.mx)),null!=r.my&&(l.marginVertical=space(e,r.my)),null!=r.mt&&(l.marginTop=space(e,r.mt)),null!=r.mr&&(l.marginRight=space(e,r.mr)),null!=r.mb&&(l.marginBottom=space(e,r.mb)),null!=r.ml&&(l.marginLeft=space(e,r.ml)),null!=r.gap&&(l.gap=space(e,r.gap)),null!=r.bg&&(l.backgroundColor=BACKGROUND_TOKENS.includes(r.bg)?e.colors[r.bg]:r.bg),null!=r.radius&&(l.borderRadius=(0,_scale.radiusOf)(e,r.radius),l.borderCurve=_corners.smoothCorners.borderCurve),r.border&&(l.borderWidth=e.size.border,l.borderColor=e.colors.border),null!=r.flex&&(l.flex=r.flex),null!=r.align&&(l.alignItems=r.align),null!=r.justify&&(l.justifyContent=r.justify),null!=r.direction&&(l.flexDirection=r.direction),r.wrap&&(l.flexWrap="wrap"),l};exports.resolveBoxStyle=resolveBoxStyle;const Box=exports.Box=(0,_react.forwardRef)((e,r)=>{const l=(0,_index.useTheme)(),{p:t,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:c,mx:u,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:_,radius:y,border:S,flex:j,align:R,justify:h,direction:v,wrap:w,style:B,children:q,...C}=e,N=resolveBoxStyle(l,{p:t,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:c,mx:u,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:_,radius:y,border:S,flex:j,align:R,justify:h,direction:v,wrap:w}),k=(0,_SquircleFill.useSquircle)(null!=y&&(null!=_||Boolean(S)),N.borderRadius,C.onLayout),O=k.active?{...N,backgroundColor:"transparent",borderColor:"transparent"}:N;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,...C,onLayout:k.onLayout,style:[O,B],children:[k.active&&k.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:k.size.width,height:k.size.height,radius:N.borderRadius,fill:N.backgroundColor??"transparent",stroke:N.borderColor,strokeWidth:N.borderWidth??0}):null,q]})});Box.displayName="Box";const Stack=exports.Stack=(0,_react.forwardRef)(({gap:e="md",...r},l)=>(0,_jsxRuntime.jsx)(Box,{ref:l,direction:"column",gap:e,...r}));Stack.displayName="Stack";const Row=exports.Row=(0,_react.forwardRef)(({gap:e="sm",align:r="center",...l},t)=>(0,_jsxRuntime.jsx)(Box,{ref:t,direction:"row",gap:e,align:r,...l}));Row.displayName="Row";const Spacer=({size:e,style:r,testID:l})=>{const t=(0,_index.useTheme)();if(null!=e){const a=(0,_scale.spaceOf)(t,e);return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:l,style:[{width:a,height:a},r]})}return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:l,style:[{flex:1},r]})};exports.Spacer=Spacer,Spacer.displayName="Spacer";var _default=exports.default=Box;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_BUTTON_LABELS=exports.Button=void 0,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BUTTON_LABELS=exports.DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"}),Button=exports.Button=(0,_react.forwardRef)((e,t)=>{const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:p,style:h,containerStyle:x,textStyle:m,pressAnimation:f,onPress:v,accessibilityLabel:y,accessibilityHint:S,accessibilityState:I,testID:j,onLayout:C,labels:k,...L}=e;(0,_warnInvalidValue.warnInvalidValue)("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),(0,_warnInvalidValue.warnInvalidValue)("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Button","size",e.size,["xs","sm","md","lg","xl"]);const T=(0,_index.useTheme)(),w=T.settings.components.button,R=o??w?.defaultVariant??"solid",F=i??w?.defaultSize??"md",N=(0,_react.useMemo)(()=>({...DEFAULT_BUTTON_LABELS,...k}),[k]),q=!l&&!n,O={...I,disabled:!q,busy:n},V="link"===R,A=f??w?.defaultPressAnimation??(!V&&"scale"),B=(0,_usePressAnimation.usePressAnimation)({preset:A||"scale",enabled:!1!==A&&q}),P=(0,_useFlickGuard.useFlickGuard)(),W=(0,_react.useMemo)(()=>buildStyles(T),[T]),z=(0,_react.useMemo)(()=>(0,_index.resolveButtonSize)(T,F),[T,F]),E=(0,_react.useMemo)(()=>toneFor(T,s),[T,s]),D=(0,_react.useMemo)(()=>variantFor(T,R,E,l),[T,R,E,l]),U=(0,_react.useMemo)(()=>!p||l||"solid"!==R?null:"string"==typeof p?T.settings.gradients[p]??null:p,[p,l,R,T.settings.gradients]),H=_reactNative.StyleSheet.flatten(h)?.borderRadius,M=V?0:"number"==typeof H?H:_?T.radius.pill:z.radius,G=(0,_SquircleFill.useSquircle)(!U&&"link"!==R,M,C),K=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[X,Y]=(0,_react.useState)(0),[J,Q]=(0,_react.useState)(null),Z=V?e=>Y(e.nativeEvent.layout.width):void 0,$=y??r,ee="outline"===R||"ghost"===R,te=!ee&&!V,re={color:D.textColor,size:z.icon,disabled:l},oe=b&&!V&&Boolean(c),se=T.space.xs,ie=z["min-height"]-2*se-2*D.borderWidth,ne={color:D.badgeInk,size:z["badge-icon"],disabled:l},le=n?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:"sm",color:oe?D.badgeInk:D.textColor,accessibilityLabel:N.loading}):c?(0,_slotIcon.renderSlotIcon)(c,oe?ne:re,u):null,ae=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.contentRow,children:[oe?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[W.iconLeft,W.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:D.badgeFill}],children:le}):le?(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.iconLeft,children:le}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:Z,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[W.label,{color:D.textColor,fontSize:z.text,lineHeight:Math.round(z.text*T.leading.body)},m],children:r}),V?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[W.linkUnderline,{backgroundColor:D.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.iconRight,children:(0,_slotIcon.renderSlotIcon)(d,re,u)}):null]}),ce=V?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(z["min-height"]),de={top:ce,bottom:ce,left:V?LINK_HIT_SLOP:0,right:V?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[B.style,a?W.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{q&&!P.isFlick(e)&&(B.press(),g&&(0,_hapticUtils.triggerHaptic)(g),v?.(e))},onPressIn:e=>{P.onPressIn(e),B.pressIn(),V&&q&&(K.stopAnimation(),K.setValue(0),_reactNative.Animated.timing(K,{toValue:1,duration:T.motion.duration.slower,easing:_reactNative.Easing.bezier(...T.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{B.pressOut()},disabled:!q,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:S,accessibilityState:O,...(0,_ariaState.ariaFromState)(O),testID:j,onLayout:e=>{G.onLayout(e),V&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[W.base,{paddingHorizontal:V?0:z["padding-x"],paddingVertical:V?0:oe?se:z["padding-y"],paddingLeft:oe?se:void 0,minHeight:V?void 0:z["min-height"],borderRadius:M,..._corners.smoothCorners,backgroundColor:U||G.active?"transparent":D.backgroundColor,borderWidth:D.borderWidth,borderColor:G.active?"transparent":D.borderColor,opacity:n?.55:1,overflow:G.active||V?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:T.colors["surface-pressed"]}:null,a?W.fullWidth:null,h],...L,"aria-disabled":!q,"aria-busy":n,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:e&&ee?T.colors["surface-pressed"]:D.backgroundColor,stroke:D.borderColor,strokeWidth:D.borderWidth,outset:D.borderWidth}):null,U?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:U,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:M,..._corners.smoothCorners}]}):null,e&&te?G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:D.pressedTint,outset:D.borderWidth,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[W.pressedOverlay,{borderRadius:M,backgroundColor:D.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},l=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_BUTTON_LABELS=exports.Button=void 0,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BUTTON_LABELS=exports.DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"}),Button=exports.Button=(0,_react.forwardRef)((e,t)=>{const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:p,style:h,containerStyle:x,textStyle:m,pressAnimation:f,onPress:v,accessibilityLabel:y,accessibilityHint:S,accessibilityState:I,testID:j,onLayout:C,labels:k,...L}=e;(0,_warnInvalidValue.warnInvalidValue)("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),(0,_warnInvalidValue.warnInvalidValue)("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Button","size",e.size,["xs","sm","md","lg","xl"]);const T=(0,_index.useTheme)(),w=T.settings.components.button,R=o??w?.defaultVariant??"solid",F=i??w?.defaultSize??"md",N=(0,_react.useMemo)(()=>({...DEFAULT_BUTTON_LABELS,...k}),[k]),q=!l&&!n,O={...I,disabled:!q,busy:n},V="link"===R,A=f??w?.defaultPressAnimation??(!V&&"scale"),B=(0,_usePressAnimation.usePressAnimation)({preset:A||"scale",enabled:!1!==A&&q}),P=(0,_useFlickGuard.useFlickGuard)(),z=(0,_react.useMemo)(()=>buildStyles(T),[T]),E=(0,_react.useMemo)(()=>(0,_index.resolveButtonSize)(T,F),[T,F]),W=(0,_react.useMemo)(()=>toneFor(T,s),[T,s]),D=(0,_react.useMemo)(()=>variantFor(T,R,W,l),[T,R,W,l]),U=(0,_react.useMemo)(()=>!p||l||"solid"!==R?null:"string"==typeof p?T.settings.gradients[p]??null:p,[p,l,R,T.settings.gradients]),H=_reactNative.StyleSheet.flatten(h)?.borderRadius,M=V?0:"number"==typeof H?H:_?T.radius.pill:E.radius,G=(0,_SquircleFill.useSquircle)(!U&&"link"!==R,M,C),K=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[X,Y]=(0,_react.useState)(0),[J,Q]=(0,_react.useState)(null),Z=V?e=>Y(e.nativeEvent.layout.width):void 0,$=y??r,ee="outline"===R||"ghost"===R,te=!ee&&!V,re={color:D.textColor,size:E.icon,disabled:l},oe=b&&!V&&Boolean(c),se=T.space.xs,ie=E["min-height"]-2*se-2*D.borderWidth,ne={color:D.badgeInk,size:E["badge-icon"],disabled:l},le=n?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:"sm",color:oe?D.badgeInk:D.textColor,accessibilityLabel:N.loading}):c?(0,_slotIcon.renderSlotIcon)(c,oe?ne:re,u):null,ae=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:z.contentRow,children:[oe?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[z.iconLeft,z.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:D.badgeFill}],children:le}):le?(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.iconLeft,children:le}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:Z,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[z.label,{color:D.textColor,fontSize:E.text,lineHeight:Math.round(E.text*T.leading.body)},m],children:r}),V?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[z.linkUnderline,{backgroundColor:D.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.iconRight,children:(0,_slotIcon.renderSlotIcon)(d,re,u)}):null]}),ce=V?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(E["min-height"]),de={top:ce,bottom:ce,left:V?LINK_HIT_SLOP:0,right:V?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[B.style,a?z.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{q&&!P.isFlick(e)&&(B.press(),g&&(0,_hapticUtils.triggerHaptic)(g),v?.(e))},onPressIn:e=>{P.onPressIn(e),B.pressIn(),V&&q&&(K.stopAnimation(),K.setValue(0),_reactNative.Animated.timing(K,{toValue:1,duration:T.motion.duration.slower,easing:_reactNative.Easing.bezier(...T.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{B.pressOut()},disabled:!q,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:S,accessibilityState:O,...(0,_ariaState.ariaFromState)(O),testID:j,onLayout:e=>{G.onLayout(e),V&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[z.base,{paddingHorizontal:V?0:E["padding-x"],paddingVertical:V?0:oe?se:E["padding-y"],paddingLeft:oe?se:void 0,minHeight:V?void 0:E["min-height"],borderRadius:M,..._corners.smoothCorners,backgroundColor:U||G.active?"transparent":D.backgroundColor,borderWidth:D.borderWidth,borderColor:G.active?"transparent":D.borderColor,opacity:n?.55:1,overflow:G.active||V?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:T.colors["surface-pressed"]}:null,a?z.fullWidth:null,h],...L,"aria-disabled":!q,"aria-busy":n,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:e&&ee?T.colors["surface-pressed"]:D.backgroundColor,stroke:D.borderColor,strokeWidth:D.borderWidth}):null,U?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:U,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:M,..._corners.smoothCorners}]}):null,e&&te?G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:D.pressedTint,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[z.pressedOverlay,{borderRadius:M,backgroundColor:D.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},l=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,r=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=r&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?r(a,s,i):a[s]=e[s]);return a}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=exports.Card=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s="elevated",elevation:r="card",radius:a="lg",padding:n="md",interactive:o=!1,bg:l,header:d,title:c,titleFont:u="sans",lead:h,action:_,headerActions:x,collapsible:m=!1,collapsed:p,defaultCollapsed:b=!1,onCollapsedChange:g,collapsedSummary:j,onRemove:y,separatorHeight:v=_reactNative.StyleSheet.hairlineWidth,footer:R,imageSource:f,imageHeight:S=160,imageAspectRatio:C,imageOverlay:w,loading:A=!1,gradient:q,onPress:N,haptic:F,contextMenu:L,accessibilityLabel:I,accessibilityHint:k,accessibilityRole:T,style:V,containerStyle:B,headerStyle:P,bodyStyle:D,footerStyle:M,borderRadius:z,testID:H,labels:E,onLayout:O,...W}=e;(0,_warnInvalidValue.warnInvalidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_warnInvalidValue.warnInvalidValue)("Card","radius",e.radius,["sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("Card","titleFont",e.titleFont,["sans","serif"]);const U=(0,_index.useTheme)(),G=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...E}),[E]),K=o||"function"==typeof N,$=(0,_useContextMenu.useContextMenu)(L,{haptic:F||!1,testID:H,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),J=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,$.hostRef),[t,$.hostRef]),Q=K||$.enabled,{style:X,pressIn:Y,pressOut:Z}=(0,_usePressAnimation.usePressAnimation)({enabled:Q}),ee=stylesFor(U),te=Boolean(f),ie=U.space[paddingMap[n]],se=(0,_react.useMemo)(()=>q?"string"==typeof q?U.settings.gradients[q]??null:q:null,[q,U.settings.gradients]),re="flat"===s,ae=re?U.radius.none:z??U.radius[a],ne=resolveBackground(U,l),[oe,le]=(0,_useControllableState.useControllableState)({value:p,defaultValue:b,onChange:g}),de=m&&oe,ce=hasBuiltInHeaderContent(e),ue=Boolean(d)||ce,he=(0,_SquircleFill.useSquircle)(!te&&!se&&!re,ae,O),xe=_reactNative.StyleSheet.flatten([V,B])??{},me=xe.backgroundColor,pe=xe.borderColor,be=me??ne??("filled"===s?U.colors["bg-subtle"]:U.colors.surface),ge="outline"===s?U.size.border:0,je=pe??U.colors.border,ye="none"===r?void 0:U.shadow[r],ve="elevated"===s&&(0,_shadows.supportsBoxShadow)()&&ye?(0,_shadows.toBoxShadow)(ye):void 0,Re=he.active&&"elevated"===s&&!ve,fe=he.active&&!Re?{backgroundColor:"transparent",borderColor:"transparent"}:null,Se=(0,_react.useMemo)(()=>{const e={borderRadius:Re&&he.size?(0,_squircle.squircleHostRadius)(he.size.width,he.size.height,ae):ae,..._corners.smoothCorners,padding:te||he.active?U.space.none:ie,overflow:he.active?"visible":"hidden"};switch(s){case"flat":return{...e,backgroundColor:ne??U.colors.surface,borderBottomWidth:v,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:he.active?"transparent":ne??U.colors.surface,borderWidth:U.size.border,borderColor:he.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:he.active?"transparent":ne??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ne??U.colors.surface,...ve?{boxShadow:ve}:ye}}},[U,s,ye,ae,te,ie,he.active,he.size,ve,Re,ne,v]),Ce=(0,_react.useMemo)(()=>({..."number"==typeof C?{width:"100%",aspectRatio:C}:{width:"100%",height:S},borderTopLeftRadius:ae,borderTopRightRadius:ae,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ae,C,S]),we=c??"",Ae=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:ee.titleColumn,children:[c?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,u),children:c}):null,h?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:ee.lead,children:h}):null,de&&j?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:ee.lead,children:j}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:F}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:ee.actionNode,children:_}):null,x,m?(0,_jsxRuntime.jsx)(CardIconAction,{icon:de?"chevron-down":"chevron-up",label:`${de?G.show:G.hide} ${we}`.trim(),expanded:!de,onPress:()=>le(!de),haptic:F}):null,y?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:G.remove,onPress:y,color:U.colors["danger-text"],haptic:F}):null]}),qe=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ue?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ee.header,!d&&ee.headerRow,de&&ee.headerFolded,P],children:d??Ae}):null,de?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ue||R?ee.body:null,D],children:i}),R&&!de?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ee.footer,M],children:R}):null]}),Ne=te?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:ee.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:f,resizeMode:"cover",style:Ce,accessibilityLabel:"",accessible:!1}),w?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:ee.imageOverlay,children:w}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:ie},children:qe})]}):qe,Fe=se?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:se,style:_reactNative.StyleSheet.absoluteFill}),Ne]}):he.active&&he.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:he.size.width,height:he.size.height,radius:ae,fill:be,stroke:ge?je:void 0,strokeWidth:ge,outset:ge}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ee.squircleClip,{padding:ie,borderRadius:he.size?(0,_squircle.squircleHostRadius)(he.size.width,he.size.height,ae):ae}],children:Ne})]}):Ne;let Le;if(Q){const handlePress=e=>{K&&(F&&(0,_hapticUtils.triggerHaptic)(F),N?.(e))};Le=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:X,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:J,onPress:handlePress,onPressIn:Y,onPressOut:Z,accessibilityRole:T??(K?"button":void 0),accessibilityLabel:I,accessibilityHint:k,testID:H,onLayout:he.onLayout,style:[Se,V,B,fe],...W,...$.hostProps,children:Fe})})}else Le=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:I,accessibilityHint:k,accessibilityRole:T,testID:H,onLayout:he.onLayout,style:[Se,V,B,fe],...W,children:Fe});return A?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):$.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Le,$.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[Se,V,B,fe,ee.preview],children:Fe}))]}):Le}));Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:i="lg",padding:s="md",bg:r,header:a,footer:n,imageSource:o,imageHeight:l=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:_,footerStyle:x,style:m,labels:p,...b})=>{const g=(0,_index.useTheme)(),j={...DEFAULT_CARD_LABELS,...p},y=paddingMap[s],v=g.space[y],R="flat"===e?g.radius.none:c??g.radius[i],f=void 0!==a||hasBuiltInHeaderContent(b),S=resolveBackground(g,r)??g.colors.surface,C="outline"===e?1:0,w="outline"===e?g.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:S,borderRadius:R,..._corners.smoothCorners,borderWidth:C,borderColor:w,overflow:"hidden"},u,m],accessibilityRole:"progressbar",accessibilityLabel:j.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==o?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,f?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:v,paddingBottom:g.space.sm},h],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:v},_],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:g.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:v,paddingTop:g.space.sm,flexDirection:"row"},x],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:r,haptic:a})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{a&&(0,_hapticUtils.triggerHaptic)(a),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:r??n.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,r=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=r&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?r(a,s,i):a[s]=e[s]);return a}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=exports.Card=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s="elevated",elevation:r="card",radius:a="lg",padding:n="md",interactive:o=!1,bg:l,header:d,title:c,titleFont:u="sans",lead:h,action:_,headerActions:x,collapsible:m=!1,collapsed:p,defaultCollapsed:b=!1,onCollapsedChange:g,collapsedSummary:j,onRemove:y,separatorHeight:v=_reactNative.StyleSheet.hairlineWidth,footer:R,imageSource:f,imageHeight:S=160,imageAspectRatio:C,imageOverlay:w,loading:A=!1,gradient:q,onPress:N,haptic:F,contextMenu:L,accessibilityLabel:I,accessibilityHint:k,accessibilityRole:T,style:V,containerStyle:B,headerStyle:P,bodyStyle:D,footerStyle:M,borderRadius:z,testID:H,labels:E,onLayout:O,...W}=e;(0,_warnInvalidValue.warnInvalidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_warnInvalidValue.warnInvalidValue)("Card","radius",e.radius,["sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("Card","titleFont",e.titleFont,["sans","serif"]);const U=(0,_index.useTheme)(),G=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...E}),[E]),K=o||"function"==typeof N,$=(0,_useContextMenu.useContextMenu)(L,{haptic:F||!1,testID:H,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),J=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,$.hostRef),[t,$.hostRef]),Q=K||$.enabled,{style:X,pressIn:Y,pressOut:Z}=(0,_usePressAnimation.usePressAnimation)({enabled:Q}),ee=stylesFor(U),te=Boolean(f),ie=U.space[paddingMap[n]],se=(0,_react.useMemo)(()=>q?"string"==typeof q?U.settings.gradients[q]??null:q:null,[q,U.settings.gradients]),re="flat"===s,ae=re?U.radius.none:z??U.radius[a],ne=resolveBackground(U,l),[oe,le]=(0,_useControllableState.useControllableState)({value:p,defaultValue:b,onChange:g}),de=m&&oe,ce=hasBuiltInHeaderContent(e),ue=Boolean(d)||ce,he=(0,_SquircleFill.useSquircle)(!te&&!se&&!re,ae,O),xe=_reactNative.StyleSheet.flatten([V,B])??{},me=xe.backgroundColor,pe=xe.borderColor,be=me??ne??("filled"===s?U.colors["bg-subtle"]:U.colors.surface),ge="outline"===s?U.size.border:0,je=pe??U.colors.border,ye="none"===r?void 0:U.shadow[r],ve="elevated"===s&&(0,_shadows.supportsBoxShadow)()&&ye?(0,_shadows.toBoxShadow)(ye):void 0,Re=he.active&&"elevated"===s&&!ve,fe=he.active&&!Re?{backgroundColor:"transparent",borderColor:"transparent"}:null,Se=(0,_react.useMemo)(()=>{const e={borderRadius:Re&&he.size?(0,_squircle.squircleHostRadius)(he.size.width,he.size.height,ae):ae,..._corners.smoothCorners,padding:te||he.active?U.space.none:ie,overflow:he.active?"visible":"hidden"};switch(s){case"flat":return{...e,backgroundColor:ne??U.colors.surface,borderBottomWidth:v,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:he.active?"transparent":ne??U.colors.surface,borderWidth:U.size.border,borderColor:he.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:he.active?"transparent":ne??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ne??U.colors.surface,...ve?{boxShadow:ve}:ye}}},[U,s,ye,ae,te,ie,he.active,he.size,ve,Re,ne,v]),Ce=(0,_react.useMemo)(()=>({..."number"==typeof C?{width:"100%",aspectRatio:C}:{width:"100%",height:S},borderTopLeftRadius:ae,borderTopRightRadius:ae,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ae,C,S]),we=c??"",Ae=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:ee.titleColumn,children:[c?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,u),children:c}):null,h?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:ee.lead,children:h}):null,de&&j?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:ee.lead,children:j}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:F}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:ee.actionNode,children:_}):null,x,m?(0,_jsxRuntime.jsx)(CardIconAction,{icon:de?"chevron-down":"chevron-up",label:`${de?G.show:G.hide} ${we}`.trim(),expanded:!de,onPress:()=>le(!de),haptic:F}):null,y?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:G.remove,onPress:y,color:U.colors["danger-text"],haptic:F}):null]}),qe=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ue?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ee.header,!d&&ee.headerRow,de&&ee.headerFolded,P],children:d??Ae}):null,de?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ue||R?ee.body:null,D],children:i}),R&&!de?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ee.footer,M],children:R}):null]}),Ne=te?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:ee.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:f,resizeMode:"cover",style:Ce,accessibilityLabel:"",accessible:!1}),w?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:ee.imageOverlay,children:w}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:ie},children:qe})]}):qe,Fe=se?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:se,style:_reactNative.StyleSheet.absoluteFill}),Ne]}):he.active&&he.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:he.size.width,height:he.size.height,radius:ae,fill:be,stroke:ge?je:void 0,strokeWidth:ge}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ee.squircleClip,{padding:ie,borderRadius:he.size?(0,_squircle.squircleHostRadius)(he.size.width,he.size.height,ae):ae}],children:Ne})]}):Ne;let Le;if(Q){const handlePress=e=>{K&&(F&&(0,_hapticUtils.triggerHaptic)(F),N?.(e))};Le=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:X,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:J,onPress:handlePress,onPressIn:Y,onPressOut:Z,accessibilityRole:T??(K?"button":void 0),accessibilityLabel:I,accessibilityHint:k,testID:H,onLayout:he.onLayout,style:[Se,V,B,fe],...W,...$.hostProps,children:Fe})})}else Le=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:I,accessibilityHint:k,accessibilityRole:T,testID:H,onLayout:he.onLayout,style:[Se,V,B,fe],...W,children:Fe});return A?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):$.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Le,$.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[Se,V,B,fe,ee.preview],children:Fe}))]}):Le}));Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:i="lg",padding:s="md",bg:r,header:a,footer:n,imageSource:o,imageHeight:l=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:_,footerStyle:x,style:m,labels:p,...b})=>{const g=(0,_index.useTheme)(),j={...DEFAULT_CARD_LABELS,...p},y=paddingMap[s],v=g.space[y],R="flat"===e?g.radius.none:c??g.radius[i],f=void 0!==a||hasBuiltInHeaderContent(b),S=resolveBackground(g,r)??g.colors.surface,C="outline"===e?1:0,w="outline"===e?g.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:S,borderRadius:R,..._corners.smoothCorners,borderWidth:C,borderColor:w,overflow:"hidden"},u,m],accessibilityRole:"progressbar",accessibilityLabel:j.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==o?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,f?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:v,paddingBottom:g.space.sm},h],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:v},_],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:g.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:v,paddingTop:g.space.sm,flexDirection:"row"},x],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:r,haptic:a})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{a&&(0,_hapticUtils.triggerHaptic)(a),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:r??n.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.EmptyState=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const ActionButton=({action:e,variant:t})=>{const i=(0,_index.useTheme)(),{style:r,pressIn:s,pressOut:o}=(0,_usePressAnimation.usePressAnimation)({enabled:!0}),n=(0,_react.useMemo)(()=>buildActionStyles(i),[i]),a="primary"===t,l=(0,_SquircleFill.useSquircle)(!0,i.radius.md),fillFor=e=>a?e?i.colors["primary-hover"]:i.colors.primary:e?i.colors["surface-pressed"]:"transparent";return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:r,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>{(0,_hapticUtils.triggerHaptic)("selection"),e.onPress()},onPressIn:s,onPressOut:o,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityHint:e.accessibilityHint,testID:e.testID,onLayout:l.onLayout,style:({pressed:e})=>[n.button,a?n.buttonPrimary:n.buttonSecondary,e&&!l.active?a?n.buttonPrimaryPressed:n.buttonSecondaryPressed:null,l.active?n.buttonSquircleHost:null],children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[l.active&&l.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:l.size.width,height:l.size.height,radius:i.radius.md,fill:fillFor(t),stroke:a?void 0:i.colors.border,strokeWidth:a?0:1,outset:a?0:1}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[n.buttonText,a?n.buttonTextPrimary:n.buttonTextSecondary],numberOfLines:1,children:e.label})]})})})},EmptyState=exports.EmptyState=(0,_react.forwardRef)((e,t)=>{const i=(0,_index.useTheme)(),r=Object.keys(i.components["empty-state"]);(0,_warnInvalidValue.warnInvalidValue)("EmptyState","size",e.size,r);const{icon:s,illustration:o,title:n,description:a,action:l,secondaryAction:c,size:u="md",fill:d=!1,style:m,testID:y}=e,x=r.includes(u)?u:"md",b=(0,_react.useMemo)(()=>(0,_index.resolveEmptyStateSize)(i,x),[i,x]),p=(0,_react.useMemo)(()=>buildStyles(i),[i]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessibilityRole:"summary",testID:y,style:[p.root,{paddingVertical:b["padding-y"]},d?p.fill:null,m],children:[null!=o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginBottom:b["title-gap"]},children:(0,_react.isValidElement)(o)?o:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:o,style:{width:b["illustration-size"],height:b["illustration-size"]},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[p.iconCircle,{width:b.icon,height:b.icon,marginBottom:b["title-gap"],borderRadius:i.radius.pill,..._corners.smoothCorners}],children:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[p.title,{fontSize:b["title-text"],...(0,_index.fontFor)(i,"semibold")}],children:n}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[p.description,{fontSize:b["description-text"],marginTop:b["description-gap"]}],children:a}):null,l||c?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:p.actions,children:[l?(0,_jsxRuntime.jsx)(ActionButton,{action:l,variant:"primary"}):null,c?(0,_jsxRuntime.jsx)(ActionButton,{action:c,variant:"secondary"}):null]}):null]})});EmptyState.displayName="EmptyState";const buildStyles=e=>_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},fill:{flexGrow:1},iconCircle:{backgroundColor:e.colors["surface-disabled"],alignItems:"center",justifyContent:"center"},title:{color:e.colors["text-body"],textAlign:"center"},description:{color:e.colors["text-muted"],textAlign:"center",maxWidth:320,lineHeight:e.text.base.size*e.leading.body},actions:{flexDirection:"row",alignItems:"center",gap:e.space.sm,marginTop:e.space.lg}}),buildActionStyles=e=>_reactNative.StyleSheet.create({button:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,minHeight:42,borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden",alignItems:"center",justifyContent:"center",flexDirection:"row"},buttonPrimary:{backgroundColor:e.colors.primary},buttonPrimaryPressed:{backgroundColor:e.colors["primary-hover"]},buttonSecondary:{backgroundColor:"transparent",borderWidth:1,borderColor:e.colors.border},buttonSecondaryPressed:{backgroundColor:e.colors["surface-pressed"]},buttonSquircleHost:{backgroundColor:"transparent",borderColor:"transparent",overflow:"visible"},buttonText:{fontSize:e.text.base.size,...(0,_index.fontFor)(e,"semibold")},buttonTextPrimary:{color:e.colors["on-primary"]},buttonTextSecondary:{color:e.colors["text-body"]}});var _default=exports.default=EmptyState;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.EmptyState=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const ActionButton=({action:e,variant:t})=>{const i=(0,_index.useTheme)(),{style:r,pressIn:s,pressOut:o}=(0,_usePressAnimation.usePressAnimation)({enabled:!0}),n=(0,_react.useMemo)(()=>buildActionStyles(i),[i]),a="primary"===t,l=(0,_SquircleFill.useSquircle)(!0,i.radius.md),fillFor=e=>a?e?i.colors["primary-hover"]:i.colors.primary:e?i.colors["surface-pressed"]:"transparent";return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:r,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>{(0,_hapticUtils.triggerHaptic)("selection"),e.onPress()},onPressIn:s,onPressOut:o,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityHint:e.accessibilityHint,testID:e.testID,onLayout:l.onLayout,style:({pressed:e})=>[n.button,a?n.buttonPrimary:n.buttonSecondary,e&&!l.active?a?n.buttonPrimaryPressed:n.buttonSecondaryPressed:null,l.active?n.buttonSquircleHost:null],children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[l.active&&l.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:l.size.width,height:l.size.height,radius:i.radius.md,fill:fillFor(t),stroke:a?void 0:i.colors.border,strokeWidth:a?0:1}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[n.buttonText,a?n.buttonTextPrimary:n.buttonTextSecondary],numberOfLines:1,children:e.label})]})})})},EmptyState=exports.EmptyState=(0,_react.forwardRef)((e,t)=>{const i=(0,_index.useTheme)(),r=Object.keys(i.components["empty-state"]);(0,_warnInvalidValue.warnInvalidValue)("EmptyState","size",e.size,r);const{icon:s,illustration:o,title:n,description:a,action:l,secondaryAction:c,size:u="md",fill:d=!1,style:m,testID:y}=e,x=r.includes(u)?u:"md",b=(0,_react.useMemo)(()=>(0,_index.resolveEmptyStateSize)(i,x),[i,x]),p=(0,_react.useMemo)(()=>buildStyles(i),[i]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessibilityRole:"summary",testID:y,style:[p.root,{paddingVertical:b["padding-y"]},d?p.fill:null,m],children:[null!=o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginBottom:b["title-gap"]},children:(0,_react.isValidElement)(o)?o:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:o,style:{width:b["illustration-size"],height:b["illustration-size"]},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[p.iconCircle,{width:b.icon,height:b.icon,marginBottom:b["title-gap"],borderRadius:i.radius.pill,..._corners.smoothCorners}],children:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[p.title,{fontSize:b["title-text"],...(0,_index.fontFor)(i,"semibold")}],children:n}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[p.description,{fontSize:b["description-text"],marginTop:b["description-gap"]}],children:a}):null,l||c?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:p.actions,children:[l?(0,_jsxRuntime.jsx)(ActionButton,{action:l,variant:"primary"}):null,c?(0,_jsxRuntime.jsx)(ActionButton,{action:c,variant:"secondary"}):null]}):null]})});EmptyState.displayName="EmptyState";const buildStyles=e=>_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},fill:{flexGrow:1},iconCircle:{backgroundColor:e.colors["surface-disabled"],alignItems:"center",justifyContent:"center"},title:{color:e.colors["text-body"],textAlign:"center"},description:{color:e.colors["text-muted"],textAlign:"center",maxWidth:320,lineHeight:e.text.base.size*e.leading.body},actions:{flexDirection:"row",alignItems:"center",gap:e.space.sm,marginTop:e.space.lg}}),buildActionStyles=e=>_reactNative.StyleSheet.create({button:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,minHeight:42,borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden",alignItems:"center",justifyContent:"center",flexDirection:"row"},buttonPrimary:{backgroundColor:e.colors.primary},buttonPrimaryPressed:{backgroundColor:e.colors["primary-hover"]},buttonSecondary:{backgroundColor:"transparent",borderWidth:1,borderColor:e.colors.border},buttonSecondaryPressed:{backgroundColor:e.colors["surface-pressed"]},buttonSquircleHost:{backgroundColor:"transparent",borderColor:"transparent",overflow:"visible"},buttonText:{fontSize:e.text.base.size,...(0,_index.fontFor)(e,"semibold")},buttonTextPrimary:{color:e.colors["on-primary"]},buttonTextSecondary:{color:e.colors["text-body"]}});var _default=exports.default=EmptyState;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveVariantColors=exports.resolveFieldTextStyle=exports.pickRepresentativeBorderColor=exports.hasFieldText=exports.fieldTextAsString=exports.default=exports.RequiredPlaceholder=exports.RequiredMark=exports.FieldMessage=exports.FieldLabel=exports.FieldErrorGlyph=exports.FieldBase=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_ariaState=require("../../utils/ariaState.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_Notation=require("../Notation/Notation.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0},pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const r=e[t];if(r&&"transparent"!==r)return r}return e.bottom};exports.pickRepresentativeBorderColor=pickRepresentativeBorderColor;const resolveFieldTextStyle=(e,t={})=>{const{disabled:r=!1}=t;return{color:r?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:r?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:(0,_index.fontFor)(e,"normal")}};exports.resolveFieldTextStyle=resolveFieldTextStyle;const RequiredMark=()=>{const e=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:e.colors["danger-text"]},children:` ${e.settings.components.field?.requiredMarker??"*"}`})};exports.RequiredMark=RequiredMark;const RequiredPlaceholder=({text:e,color:t,fontSize:r,weightStyle:o,align:i="center",paddingTop:l,textAlign:s})=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{justifyContent:"top"===i?"flex-start":"center",paddingTop:l}],children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:r,...o,includeFontPadding:!1,textAlign:s},children:[e,(0,_jsxRuntime.jsx)(RequiredMark,{})]})});exports.RequiredPlaceholder=RequiredPlaceholder;const FieldErrorGlyph=({size:e,color:t})=>{const r=(0,_index.useTheme)().settings.icons.error??_defaultIcons.defaultIcons.error;return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r({size:e,color:t})})};exports.FieldErrorGlyph=FieldErrorGlyph;const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;exports.hasFieldText=hasFieldText;const fieldTextAsString=e=>"string"==typeof e?e:void 0;exports.fieldTextAsString=fieldTextAsString;const FieldLabel=({children:e,size:t="md",required:r=!1,help:o,color:i,style:l})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveFieldSize)(s,t),a=hasFieldText(o),d=(0,_Notation.useNotationInk)(l,n["label-text"],i??s.colors["field-label"]),c=(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[familyStyles.label,{color:i??s.colors["field-label"],fontSize:n["label-text"],...(0,_index.fontFor)(s,"semibold"),marginBottom:a?s.space.none:n["label-gap"]},a?familyStyles.labelShrink:null,l],children:[(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:d,children:e}),r?(0,_jsxRuntime.jsx)(RequiredMark,{}):null]});return a?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:o})]}):c};exports.FieldLabel=FieldLabel;const FieldMessage=({text:e,error:t=!1,size:r="md",style:o})=>{const i=(0,_index.useTheme)(),l=(0,_index.resolveFieldSize)(i,r),s=t?i.colors["field-message"]:i.colors["text-muted"],n=(0,_Notation.useNotationInk)(o,l["message-text"],s);return hasFieldText(e)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:i.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?(0,_jsxRuntime.jsx)(FieldErrorGlyph,{size:l["message-text"],color:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...(0,_index.fontFor)(i,"normal")},o],children:(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:n,children:e})})]}):null};exports.FieldMessage=FieldMessage;const familyStyles=_reactNative.StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}}),resolveVariantColors=(e,t)=>{let r,o,i,l,s;"outline"===t?(r=e.colors["field-bg"],o=e.colors["field-bg-focus"],i=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(r="transparent",o=void 0,i="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(r=e.colors["field-bg"],o=void 0,i=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),a=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:r,backgroundIdleFilled:r,backgroundFocused:o,backgroundError:void 0,backgroundDisabled:i,borderIdle:n,borderFocused:a,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(a)}};exports.resolveVariantColors=resolveVariantColors;const FieldBase=e=>{(0,_warnInvalidValue.warnInvalidValue)("FieldBase","variant",e.variant,["outline","filled","underline"]),(0,_warnInvalidValue.warnInvalidValue)("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:r,focused:o=!1,disabled:i=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:a=!1,trailing:d,slotAlign:c="center",slotLineHeight:u,topNotch:b,children:p,onPress:x,pressFeedback:g=!0,minHeight:m,maxHeight:h,width:f,height:_,paddingHorizontal:v,paddingLeft:R,paddingRight:y,paddingVertical:j,borderRadius:S,borderTopLeftRadius:F,borderTopRightRadius:C,borderBottomLeftRadius:T,borderBottomRightRadius:k,borderWidth:N,borderTopWidth:w,borderRightWidth:I,borderBottomWidth:q,borderLeftWidth:V,gap:L,style:B,testID:z,accessibilityRole:M,accessibilityLabel:E,accessibilityState:W,accessibilityHint:D}=e,P=(0,_index.useTheme)(),A=(0,_react.useMemo)(()=>buildStyles(),[]),H=r??P.settings.components.field?.defaultVariant??"outline",G=(0,_index.resolveFieldSize)(P,t),O=(0,_react.useMemo)(()=>resolveVariantColors(P,H),[P,H]),$=l?2:o?1:0,J=(0,_react.useRef)((0,_index.createAnimatedValue)($)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(J,{toValue:$,duration:P.motion.duration.fast,easing:_reactNative.Easing.bezier(...P.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[$,J,P.motion.duration.fast,P.motion.ease["in-out"]]);const K=[0,1,2],Q=s?O.backgroundIdleFilled:O.backgroundIdleEmpty,U=O.backgroundFocused??Q,X=O.backgroundError??Q,Y=i?O.backgroundDisabled:J.interpolate({inputRange:K,outputRange:[Q,U,X]}),Z=O.borderIdle,ee=O.borderFocused,te=O.borderError,re={top:w,right:I,bottom:q,left:V},oe={top:re.top??N??O.borderWidth.top,right:re.right??N??O.borderWidth.right,bottom:re.bottom??N??O.borderWidth.bottom,left:re.left??N??O.borderWidth.left},ie={minHeight:_??m??G["min-height"],maxHeight:h,paddingHorizontal:v??G["padding-x"],paddingVertical:j??G["padding-y"],paddingLeft:R??v??G["padding-x"],paddingRight:y??v??G["padding-x"],backgroundColor:Y,columnGap:L??P.space.md,alignItems:"top"===c?"flex-start":"center"},le="underline"===H,se=le?P.radius.none:S??G.radius,ne=le?{tl:P.radius.none,tr:P.radius.none,bl:P.radius.none,br:P.radius.none}:{tl:F??se,tr:C??se,bl:T??se,br:k??se};ie.borderTopLeftRadius=ne.tl,ie.borderTopRightRadius=ne.tr,ie.borderBottomLeftRadius=ne.bl,ie.borderBottomRightRadius=ne.br,ie.borderCurve=_corners.smoothCorners.borderCurve,ie.borderTopWidth=oe.top,ie.borderRightWidth=oe.right,ie.borderBottomWidth=oe.bottom,ie.borderLeftWidth=oe.left;const sideColor=e=>J.interpolate({inputRange:K,outputRange:[Z[e],ee[e],te[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,ae=!le&&ne.tl===ne.tr&&ne.tl===ne.bl&&ne.tl===ne.br&&sameOnEverySide(oe)&&sameOnEverySide(Z)&&sameOnEverySide(ee)&&sameOnEverySide(te)&&sameOnEverySide(O.borderDisabled),de=(0,_SquircleFill.useSquircle)(ae,ne.tl);if(de.active)ie.backgroundColor="transparent",ie.borderTopColor="transparent",ie.borderRightColor="transparent",ie.borderBottomColor="transparent",ie.borderLeftColor="transparent";else if(i){const e=O.borderDisabled;ie.borderTopColor=e.top,ie.borderRightColor=e.right,ie.borderBottomColor=e.bottom,ie.borderLeftColor=e.left}else ie.borderTopColor=sideColor("top"),ie.borderRightColor=sideColor("right"),ie.borderBottomColor=sideColor("bottom"),ie.borderLeftColor=sideColor("left");const ce=i?O.borderDisabled.top:sideColor("top"),ue=(0,_react.useRef)($);ue.current=$,(0,_react.useEffect)(()=>{J.setValue(ue.current)},[O,J]),void 0!==f&&(ie.width=f),void 0!==_&&(ie.height=_);const be={disabled:i,...W},pe="top"===c,xe=pe?{alignSelf:"flex-start",marginTop:Math.max(0,((u??G.icon)-G.icon)/2)}:null,ge=_??m??G["min-height"],me=(()=>{if(!b)return 0;const e=Math.min(ne.tl,ge/2),t=b.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),he=b&&oe.top>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-oe.top,left:b.left-oe.left,width:b.width,height:oe.top+me,backgroundColor:Y}}):null,renderInner=e=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[de.active&&de.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:de.size.width,height:de.size.height,radius:ne.tl,fill:e&&!i?P.colors["surface-pressed"]:Y,stroke:ce,strokeWidth:oe.top,outset:oe.top}):null,he,null!=n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[A.slot,xe],children:n}):null,null!=n&&a?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[A.divider,xe,{height:G.icon,backgroundColor:P.colors["field-border"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[A.content,pe?A.contentTop:null],children:p}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[A.slot,xe],children:d}):null]}),fe=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{onLayout:de.onLayout,style:[A.box,ie,B],accessibilityRole:M,accessibilityLabel:E,accessibilityHint:D,accessibilityState:be,...(0,_ariaState.ariaFromState)(be),testID:z,children:renderInner(!1)});return x&&!g?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:x,disabled:i,accessible:!1,children:fe}):x?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:x,disabled:i,accessibilityRole:M??"button",accessibilityLabel:E,accessibilityHint:D,accessibilityState:be,...(0,_ariaState.ariaFromState)(be),testID:z,children:({pressed:e})=>(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{onLayout:de.onLayout,style:[A.box,ie,!e||i||de.active?null:{backgroundColor:P.colors["surface-pressed"]},B],children:renderInner(e)})}):fe};exports.FieldBase=FieldBase,FieldBase.displayName="FieldBase";const buildStyles=()=>_reactNative.StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});var _default=exports.default=FieldBase;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveVariantColors=exports.resolveFieldTextStyle=exports.pickRepresentativeBorderColor=exports.hasFieldText=exports.fieldTextAsString=exports.default=exports.RequiredPlaceholder=exports.RequiredMark=exports.FieldMessage=exports.FieldLabel=exports.FieldErrorGlyph=exports.FieldBase=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_ariaState=require("../../utils/ariaState.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_Notation=require("../Notation/Notation.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0},pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const r=e[t];if(r&&"transparent"!==r)return r}return e.bottom};exports.pickRepresentativeBorderColor=pickRepresentativeBorderColor;const resolveFieldTextStyle=(e,t={})=>{const{disabled:r=!1}=t;return{color:r?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:r?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:(0,_index.fontFor)(e,"normal")}};exports.resolveFieldTextStyle=resolveFieldTextStyle;const RequiredMark=()=>{const e=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:e.colors["danger-text"]},children:` ${e.settings.components.field?.requiredMarker??"*"}`})};exports.RequiredMark=RequiredMark;const RequiredPlaceholder=({text:e,color:t,fontSize:r,weightStyle:o,align:i="center",paddingTop:l,textAlign:s})=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{justifyContent:"top"===i?"flex-start":"center",paddingTop:l}],children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:r,...o,includeFontPadding:!1,textAlign:s},children:[e,(0,_jsxRuntime.jsx)(RequiredMark,{})]})});exports.RequiredPlaceholder=RequiredPlaceholder;const FieldErrorGlyph=({size:e,color:t})=>{const r=(0,_index.useTheme)().settings.icons.error??_defaultIcons.defaultIcons.error;return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r({size:e,color:t})})};exports.FieldErrorGlyph=FieldErrorGlyph;const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;exports.hasFieldText=hasFieldText;const fieldTextAsString=e=>"string"==typeof e?e:void 0;exports.fieldTextAsString=fieldTextAsString;const FieldLabel=({children:e,size:t="md",required:r=!1,help:o,color:i,style:l})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveFieldSize)(s,t),a=hasFieldText(o),d=(0,_Notation.useNotationInk)(l,n["label-text"],i??s.colors["field-label"]),c=(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[familyStyles.label,{color:i??s.colors["field-label"],fontSize:n["label-text"],...(0,_index.fontFor)(s,"semibold"),marginBottom:a?s.space.none:n["label-gap"]},a?familyStyles.labelShrink:null,l],children:[(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:d,children:e}),r?(0,_jsxRuntime.jsx)(RequiredMark,{}):null]});return a?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:o})]}):c};exports.FieldLabel=FieldLabel;const FieldMessage=({text:e,error:t=!1,size:r="md",style:o})=>{const i=(0,_index.useTheme)(),l=(0,_index.resolveFieldSize)(i,r),s=t?i.colors["field-message"]:i.colors["text-muted"],n=(0,_Notation.useNotationInk)(o,l["message-text"],s);return hasFieldText(e)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:i.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?(0,_jsxRuntime.jsx)(FieldErrorGlyph,{size:l["message-text"],color:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...(0,_index.fontFor)(i,"normal")},o],children:(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:n,children:e})})]}):null};exports.FieldMessage=FieldMessage;const familyStyles=_reactNative.StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}}),resolveVariantColors=(e,t)=>{let r,o,i,l,s;"outline"===t?(r=e.colors["field-bg"],o=e.colors["field-bg-focus"],i=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(r="transparent",o=void 0,i="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(r=e.colors["field-bg"],o=void 0,i=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),a=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:r,backgroundIdleFilled:r,backgroundFocused:o,backgroundError:void 0,backgroundDisabled:i,borderIdle:n,borderFocused:a,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(a)}};exports.resolveVariantColors=resolveVariantColors;const FieldBase=e=>{(0,_warnInvalidValue.warnInvalidValue)("FieldBase","variant",e.variant,["outline","filled","underline"]),(0,_warnInvalidValue.warnInvalidValue)("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:r,focused:o=!1,disabled:i=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:a=!1,trailing:d,slotAlign:c="center",slotLineHeight:u,topNotch:b,children:p,onPress:x,pressFeedback:g=!0,minHeight:m,maxHeight:h,width:f,height:_,paddingHorizontal:v,paddingLeft:R,paddingRight:y,paddingVertical:j,borderRadius:S,borderTopLeftRadius:F,borderTopRightRadius:C,borderBottomLeftRadius:T,borderBottomRightRadius:k,borderWidth:N,borderTopWidth:w,borderRightWidth:I,borderBottomWidth:q,borderLeftWidth:V,gap:L,style:B,testID:z,accessibilityRole:M,accessibilityLabel:E,accessibilityState:W,accessibilityHint:D}=e,P=(0,_index.useTheme)(),A=(0,_react.useMemo)(()=>buildStyles(),[]),H=r??P.settings.components.field?.defaultVariant??"outline",G=(0,_index.resolveFieldSize)(P,t),O=(0,_react.useMemo)(()=>resolveVariantColors(P,H),[P,H]),$=l?2:o?1:0,J=(0,_react.useRef)((0,_index.createAnimatedValue)($)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(J,{toValue:$,duration:P.motion.duration.fast,easing:_reactNative.Easing.bezier(...P.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[$,J,P.motion.duration.fast,P.motion.ease["in-out"]]);const K=[0,1,2],Q=s?O.backgroundIdleFilled:O.backgroundIdleEmpty,U=O.backgroundFocused??Q,X=O.backgroundError??Q,Y=i?O.backgroundDisabled:J.interpolate({inputRange:K,outputRange:[Q,U,X]}),Z=O.borderIdle,ee=O.borderFocused,te=O.borderError,re={top:w,right:I,bottom:q,left:V},oe={top:re.top??N??O.borderWidth.top,right:re.right??N??O.borderWidth.right,bottom:re.bottom??N??O.borderWidth.bottom,left:re.left??N??O.borderWidth.left},ie={minHeight:_??m??G["min-height"],maxHeight:h,paddingHorizontal:v??G["padding-x"],paddingVertical:j??G["padding-y"],paddingLeft:R??v??G["padding-x"],paddingRight:y??v??G["padding-x"],backgroundColor:Y,columnGap:L??P.space.md,alignItems:"top"===c?"flex-start":"center"},le="underline"===H,se=le?P.radius.none:S??G.radius,ne=le?{tl:P.radius.none,tr:P.radius.none,bl:P.radius.none,br:P.radius.none}:{tl:F??se,tr:C??se,bl:T??se,br:k??se};ie.borderTopLeftRadius=ne.tl,ie.borderTopRightRadius=ne.tr,ie.borderBottomLeftRadius=ne.bl,ie.borderBottomRightRadius=ne.br,ie.borderCurve=_corners.smoothCorners.borderCurve,ie.borderTopWidth=oe.top,ie.borderRightWidth=oe.right,ie.borderBottomWidth=oe.bottom,ie.borderLeftWidth=oe.left;const sideColor=e=>J.interpolate({inputRange:K,outputRange:[Z[e],ee[e],te[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,ae=!le&&ne.tl===ne.tr&&ne.tl===ne.bl&&ne.tl===ne.br&&sameOnEverySide(oe)&&sameOnEverySide(Z)&&sameOnEverySide(ee)&&sameOnEverySide(te)&&sameOnEverySide(O.borderDisabled),de=(0,_SquircleFill.useSquircle)(ae,ne.tl);if(de.active)ie.backgroundColor="transparent",ie.borderTopColor="transparent",ie.borderRightColor="transparent",ie.borderBottomColor="transparent",ie.borderLeftColor="transparent";else if(i){const e=O.borderDisabled;ie.borderTopColor=e.top,ie.borderRightColor=e.right,ie.borderBottomColor=e.bottom,ie.borderLeftColor=e.left}else ie.borderTopColor=sideColor("top"),ie.borderRightColor=sideColor("right"),ie.borderBottomColor=sideColor("bottom"),ie.borderLeftColor=sideColor("left");const ce=i?O.borderDisabled.top:sideColor("top"),ue=(0,_react.useRef)($);ue.current=$,(0,_react.useEffect)(()=>{J.setValue(ue.current)},[O,J]),void 0!==f&&(ie.width=f),void 0!==_&&(ie.height=_);const be={disabled:i,...W},pe="top"===c,xe=pe?{alignSelf:"flex-start",marginTop:Math.max(0,((u??G.icon)-G.icon)/2)}:null,ge=_??m??G["min-height"],me=(()=>{if(!b)return 0;const e=Math.min(ne.tl,ge/2),t=b.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),he=b&&oe.top>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-oe.top,left:b.left-oe.left,width:b.width,height:oe.top+me,backgroundColor:Y}}):null,renderInner=e=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[de.active&&de.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:de.size.width,height:de.size.height,radius:ne.tl,fill:e&&!i?P.colors["surface-pressed"]:Y,stroke:ce,strokeWidth:oe.top}):null,he,null!=n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[A.slot,xe],children:n}):null,null!=n&&a?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[A.divider,xe,{height:G.icon,backgroundColor:P.colors["field-border"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[A.content,pe?A.contentTop:null],children:p}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[A.slot,xe],children:d}):null]}),fe=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{onLayout:de.onLayout,style:[A.box,ie,B],accessibilityRole:M,accessibilityLabel:E,accessibilityHint:D,accessibilityState:be,...(0,_ariaState.ariaFromState)(be),testID:z,children:renderInner(!1)});return x&&!g?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:x,disabled:i,accessible:!1,children:fe}):x?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:x,disabled:i,accessibilityRole:M??"button",accessibilityLabel:E,accessibilityHint:D,accessibilityState:be,...(0,_ariaState.ariaFromState)(be),testID:z,children:({pressed:e})=>(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{onLayout:de.onLayout,style:[A.box,ie,!e||i||de.active?null:{backgroundColor:P.colors["surface-pressed"]},B],children:renderInner(e)})}):fe};exports.FieldBase=FieldBase,FieldBase.displayName="FieldBase";const buildStyles=()=>_reactNative.StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});var _default=exports.default=FieldBase;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListItem=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_themeStyles=require("../../utils/themeStyles.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index2=require("../Button/index.js"),_index3=require("../IconBadge/index.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Swipeable/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=n&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?n(r,s,i):r[s]=e[s]);return r}const Chevron=({color:e})=>{const t=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(t.settings.icons.chevronRight??_defaultIcons.defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,SelectionBox=({checked:e,disabled:t})=>{const i=(0,_index.useTheme)(),s=(0,_index.resolveCheckboxSize)(i,"md")["box-size"],n=Math.round(.72*s);return(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.size.border,borderRadius:i.radius.sm,..._corners.smoothCorners,borderColor:e?i.colors.primary:i.colors.border,backgroundColor:e?i.colors.primary:t?i.colors["surface-disabled"]:"transparent"},children:e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:n,height:n,viewBox:"0 0 24 24",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors["on-primary"],strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})}):null})},isActionList=e=>Array.isArray(e)&&e.length>0&&e.every(e=>null!=e&&"object"==typeof e&&!_react.default.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>(0,_jsxRuntime.jsx)(_index2.Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,label:e.label,onPress:e.onPress},e.label)):e,ListItem=exports.ListItem=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{title:i,loading:s=!1,subtitle:n,description:r,children:l,titleLines:o=1,subtitleLines:a=1,left:c,icon:d,iconTone:u="primary",right:m,rightPlacement:x="auto",selectable:h=!1,checked:_=!1,onCheckedChange:j,actions:p,onPress:g,haptic:b,selected:y=!1,disabled:f=!1,size:v="md",divider:R=!1,chevron:w=!1,leftActions:S,rightActions:I,contextMenu:L,accessibilityLabel:k,accessibilityHint:N,style:V,containerStyle:C,titleStyle:A,subtitleStyle:q,descriptionStyle:P,leftSlotStyle:z,rightSlotStyle:B,testID:D}=e;(0,_warnInvalidValue.warnInvalidValue)("ListItem","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("ListItem","iconTone",e.iconTone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("ListItem","rightPlacement",e.rightPlacement,["auto","side","below"]);const M=(0,_index.useTheme)(),T=(0,_react.useMemo)(()=>(0,_index.resolveListItemSize)(M,v),[M,v]),F=stylesFor(M),{fontScale:W}=(0,_reactNative.useWindowDimensions)(),O=!!m&&("below"===x||"auto"===x&&W>1.2),H=(0,_useContextMenu.useContextMenu)(f?void 0:L,{haptic:b||!1,testID:D}),E=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,H.hostRef),[t,H.hostRef]),G=h||!!g,U=G||H.enabled,Z=U&&!f,{style:J,pressIn:K,pressOut:Q}=(0,_usePressAnimation.usePressAnimation)({enabled:Z}),X=(0,_useFlickGuard.useFlickGuard)(),Y=k??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,$=c??(void 0===d?null:(0,_jsxRuntime.jsx)(_index3.IconBadge,{icon:d,tone:u,size:BADGE_SIZE[v]})),ee=h?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:F.selectionLead,children:[(0,_jsxRuntime.jsx)(SelectionBox,{checked:_,disabled:f}),$?(0,_jsxRuntime.jsx)(_reactNative.View,{style:F.selectionLeadContent,children:$}):null]}):$,te=null!=p&&!1!==p&&!(Array.isArray(p)&&0===p.length),ie=R&&!te,se=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[F.row,{paddingVertical:T["padding-y"],minHeight:T["min-height"],backgroundColor:y?M.colors["surface-selected"]:"transparent"},ie?F.divider:null,f?F.disabled:null,C],children:[ee?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[F.leftSlot,z],children:ee}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:F.middle,children:[null==i||isText(i)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[F.title,{fontSize:T["title-text"],...(0,_index.fontFor)(M,"medium"),color:f?M.colors["text-disabled"]:M.colors["text-body"]},A],numberOfLines:o,children:i??" "}):i,null==n||""===n?null:isText(n)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[F.subtitle,{fontSize:T["subtitle-text"],color:f?M.colors["text-disabled"]:M.colors["text-muted"]},q],numberOfLines:a,children:n}):n,r?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[F.description,{fontSize:T["subtitle-text"],color:f?M.colors["text-disabled"]:M.colors["text-subtle"]},P],numberOfLines:2,children:r}):null,null!=l&&!1!==l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:F.body,children:l}):null,O?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[F.rightBelow,B],children:m}):null]}),m&&!O||w?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[F.rightSlot,O?null:B],children:[O?null:m,w?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m&&!O?F.chevronWithRight:null,children:(0,_jsxRuntime.jsx)(Chevron,{color:f?M.colors["text-disabled"]:M.colors["text-subtle"]})}):null]}):null]}),ne=U?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:E,onPress:e=>{Z&&G&&!X.isFlick(e)&&(b&&(0,_hapticUtils.triggerHaptic)(b),h?j?.(!_):g?.(e))},onPressIn:e=>{X.onPressIn(e),K()},onPressOut:Q,disabled:!Z,accessibilityRole:h?"checkbox":g?"button":void 0,accessibilityLabel:Y,accessibilityHint:N,accessibilityState:h?{checked:_,disabled:!Z}:{selected:y,disabled:!Z},"aria-disabled":!Z,...h?{"aria-checked":_}:{"aria-selected":y},testID:D,android_ripple:{color:M.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[V,e?F.pressed:null],...H.hostProps,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:J,children:se})}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityRole:"none",accessibilityLabel:Y,accessibilityHint:N,accessibilityState:{selected:y,disabled:f},"aria-selected":y,"aria-disabled":f,testID:D,style:V,children:se}),re=S&&S.length>0||I&&I.length>0,le=te?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[y?{backgroundColor:M.colors["surface-selected"]}:null,R?F.divider:null],children:[ne,(0,_jsxRuntime.jsx)(_reactNative.View,{style:F.actions,children:renderActions(p)})]}):ne,oe=re?(0,_jsxRuntime.jsx)(_index5.Swipeable,{leftActions:S,rightActions:I,accessibilityLabel:Y,children:le}):le;return s?(0,_jsxRuntime.jsx)(ListItemSkeleton,{...e}):H.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[oe,H.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:F.preview,children:se}))]}):oe}));ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,left:i,icon:s,right:n,chevron:r,size:l="md",containerStyle:o,style:a})=>{const c=(0,_index.useTheme)(),d=(0,_index.resolveListItemSize)(c,l),u=Math.round(1.15*d["title-text"]),m=Math.round(1.15*d["subtitle-text"]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.space.md,paddingVertical:d["padding-y"],minHeight:d["min-height"]},o,a],children:[void 0!==i||void 0!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:c.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"circle",width:40,height:40})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"70%",height:u,style:{marginBottom:c.space.xs}}),void 0!==e?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"50%",height:m,style:void 0!==t?{marginBottom:c.space.xs}:void 0}):null,void 0!==t?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"85%",height:m}):null]}),void 0!==n||r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginLeft:c.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.md},divider:{borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:e.colors.border},pressed:{backgroundColor:e.colors["surface-pressed"]},disabled:{opacity:.55},leftSlot:{marginRight:e.space.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.space.sm},body:{marginTop:e.space.xs},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.space.xs},rightSlot:{marginLeft:e.space.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm,paddingHorizontal:e.space.md,paddingBottom:e.space.md},chevronWithRight:{marginLeft:e.space.xs},preview:{flex:1,backgroundColor:e.colors.surface,borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden"},title:{letterSpacing:e["letter-spacing"].normal},subtitle:{marginTop:e.space.xxs,...(0,_index.fontFor)(e,"normal")},description:{marginTop:e.space.xxs,...(0,_index.fontFor)(e,"normal")}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=ListItem;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListItem=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_themeStyles=require("../../utils/themeStyles.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index2=require("../Button/index.js"),_index3=require("../IconBadge/index.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Swipeable/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=n&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?n(r,s,i):r[s]=e[s]);return r}const Chevron=({color:e})=>{const t=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(t.settings.icons.chevronRight??_defaultIcons.defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,SelectionBox=({checked:e,disabled:t})=>{const i=(0,_index.useTheme)(),s=(0,_index.resolveCheckboxSize)(i,"md")["box-size"],n=Math.round(.72*s);return(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.size.border,borderRadius:i.radius.sm,..._corners.smoothCorners,borderColor:e?i.colors.primary:i.colors.border,backgroundColor:e?i.colors.primary:t?i.colors["surface-disabled"]:"transparent"},children:e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:n,height:n,viewBox:"0 0 24 24",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors["on-primary"],strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})}):null})},isActionList=e=>Array.isArray(e)&&e.length>0&&e.every(e=>null!=e&&"object"==typeof e&&!_react.default.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>(0,_jsxRuntime.jsx)(_index2.Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,label:e.label,onPress:e.onPress},e.label)):e,ListItem=exports.ListItem=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{title:i,loading:s=!1,subtitle:n,description:r,children:l,titleLines:a=1,subtitleLines:o=1,left:c,icon:d,iconTone:u="primary",right:x,rightPlacement:m="auto",selectable:h=!1,checked:_=!1,onCheckedChange:j,actions:p,onPress:g,haptic:b,selected:y=!1,expanded:f,disabled:v=!1,size:R="md",divider:w=!1,chevron:S=!1,leftActions:I,rightActions:L,contextMenu:k,accessibilityLabel:N,accessibilityHint:V,style:C,containerStyle:A,titleStyle:q,subtitleStyle:P,descriptionStyle:z,leftSlotStyle:B,rightSlotStyle:D,testID:M}=e;(0,_warnInvalidValue.warnInvalidValue)("ListItem","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("ListItem","iconTone",e.iconTone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("ListItem","rightPlacement",e.rightPlacement,["auto","side","below"]);const T=(0,_index.useTheme)(),F=(0,_react.useMemo)(()=>(0,_index.resolveListItemSize)(T,R),[T,R]),W=stylesFor(T),{fontScale:O}=(0,_reactNative.useWindowDimensions)(),H=!!x&&("below"===m||"auto"===m&&O>1.2),E=(0,_useContextMenu.useContextMenu)(v?void 0:k,{haptic:b||!1,testID:M}),G=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,E.hostRef),[t,E.hostRef]),U=h||!!g,Z=U||E.enabled,J=Z&&!v,{style:K,pressIn:Q,pressOut:X}=(0,_usePressAnimation.usePressAnimation)({enabled:J}),Y=(0,_useFlickGuard.useFlickGuard)(),$=N??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,ee=c??(void 0===d?null:(0,_jsxRuntime.jsx)(_index3.IconBadge,{icon:d,tone:u,size:BADGE_SIZE[R]})),te=h?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.selectionLead,children:[(0,_jsxRuntime.jsx)(SelectionBox,{checked:_,disabled:v}),ee?(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.selectionLeadContent,children:ee}):null]}):ee,ie=null!=p&&!1!==p&&!(Array.isArray(p)&&0===p.length),se=w&&!ie,ne=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[W.row,{paddingVertical:F["padding-y"],minHeight:F["min-height"],backgroundColor:y?T.colors["surface-selected"]:"transparent"},se?W.divider:null,v?W.disabled:null,A],children:[te?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[W.leftSlot,B],children:te}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.middle,children:[null==i||isText(i)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.title,{fontSize:F["title-text"],...(0,_index.fontFor)(T,"medium"),color:v?T.colors["text-disabled"]:T.colors["text-body"]},q],numberOfLines:a,children:i??" "}):i,null==n||""===n?null:isText(n)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.subtitle,{fontSize:F["subtitle-text"],color:v?T.colors["text-disabled"]:T.colors["text-muted"]},P],numberOfLines:o,children:n}):n,r?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.description,{fontSize:F["subtitle-text"],color:v?T.colors["text-disabled"]:T.colors["text-subtle"]},z],numberOfLines:2,children:r}):null,null!=l&&!1!==l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.body,children:l}):null,H?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[W.rightBelow,D],children:x}):null]}),x&&!H||S?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[W.rightSlot,H?null:D],children:[H?null:x,S?(0,_jsxRuntime.jsx)(_reactNative.View,{style:x&&!H?W.chevronWithRight:null,children:(0,_jsxRuntime.jsx)(Chevron,{color:v?T.colors["text-disabled"]:T.colors["text-subtle"]})}):null]}):null]}),re=Z?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:G,onPress:e=>{J&&U&&!Y.isFlick(e)&&(b&&(0,_hapticUtils.triggerHaptic)(b),h?j?.(!_):g?.(e))},onPressIn:e=>{Y.onPressIn(e),Q()},onPressOut:X,disabled:!J,accessibilityRole:h?"checkbox":g?"button":void 0,accessibilityLabel:$,accessibilityHint:V,accessibilityState:h?{checked:_,disabled:!J,expanded:f}:{selected:y,disabled:!J,expanded:f},"aria-disabled":!J,"aria-expanded":f,...h?{"aria-checked":_}:{"aria-selected":y},testID:M,android_ripple:{color:T.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[C,e?W.pressed:null],...E.hostProps,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:K,children:ne})}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityRole:"none",accessibilityLabel:$,accessibilityHint:V,accessibilityState:{selected:y,disabled:v},"aria-selected":y,"aria-disabled":v,testID:M,style:C,children:ne}),le=I&&I.length>0||L&&L.length>0,ae=ie?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[y?{backgroundColor:T.colors["surface-selected"]}:null,w?W.divider:null],children:[re,(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.actions,children:renderActions(p)})]}):re,oe=le?(0,_jsxRuntime.jsx)(_index5.Swipeable,{leftActions:I,rightActions:L,accessibilityLabel:$,children:ae}):ae;return s?(0,_jsxRuntime.jsx)(ListItemSkeleton,{...e}):E.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[oe,E.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:W.preview,children:ne}))]}):oe}));ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,left:i,icon:s,right:n,chevron:r,size:l="md",containerStyle:a,style:o})=>{const c=(0,_index.useTheme)(),d=(0,_index.resolveListItemSize)(c,l),u=Math.round(1.15*d["title-text"]),x=Math.round(1.15*d["subtitle-text"]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.space.md,paddingVertical:d["padding-y"],minHeight:d["min-height"]},a,o],children:[void 0!==i||void 0!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:c.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"circle",width:40,height:40})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"70%",height:u,style:{marginBottom:c.space.xs}}),void 0!==e?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"50%",height:x,style:void 0!==t?{marginBottom:c.space.xs}:void 0}):null,void 0!==t?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"85%",height:x}):null]}),void 0!==n||r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginLeft:c.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.md},divider:{borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:e.colors.border},pressed:{backgroundColor:e.colors["surface-pressed"]},disabled:{opacity:.55},leftSlot:{marginRight:e.space.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.space.sm},body:{marginTop:e.space.xs},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.space.xs},rightSlot:{marginLeft:e.space.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm,paddingHorizontal:e.space.md,paddingBottom:e.space.md},chevronWithRight:{marginLeft:e.space.xs},preview:{flex:1,backgroundColor:e.colors.surface,borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden"},title:{letterSpacing:e["letter-spacing"].normal},subtitle:{marginTop:e.space.xxs,...(0,_index.fontFor)(e,"normal")},description:{marginTop:e.space.xxs,...(0,_index.fontFor)(e,"normal")}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=ListItem;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Select=exports.DEFAULT_SELECT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_Chevron=require("../FieldBase/Chevron.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_Notation=require("../Notation/Notation.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SELECT_LABELS=exports.DEFAULT_SELECT_LABELS={placeholder:"Select…",noSelection:"No selection",selected:e=>`Selected: ${e}`,fallbackName:"Select",sheetName:"Options"},sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t)),Select=exports.Select=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("Select","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Select","variant",e.variant,["outline","filled","underline"]);const{options:i,getOptionLabel:l,getOptionValue:n,isOptionDisabled:a,getOptionDescription:r,getOptionIcon:o,placeholder:s,onVisibleChange:c,searchable:d=!1,haptic:u,labels:x,label:_,help:p,title:h,required:S=!1,error:b,helperText:v,prefix:g,numberOfLines:m=1,disabled:f=!1,size:j="md",variant:y,leftIcon:C,rightIcon:F,chevronColor:L,chevronSize:T,borderRadius:V,accessibilityLabel:R,labelStyle:O,style:B,triggerStyle:E,textStyle:I,optionStyle:N,selectedOptionStyle:q,optionTextStyle:z,selectedOptionTextStyle:k,testID:w}=e,A=!0===e.multi,D=x?{...DEFAULT_SELECT_LABELS,...x}:DEFAULT_SELECT_LABELS,H=(0,_react.useCallback)(e=>l?l(e):e.label??"",[l]),M=(0,_react.useCallback)(e=>n?n(e):e.value,[n]),P=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),U=(0,_react.useCallback)(e=>r?r(e):e.description,[r]),$=(0,_react.useCallback)(e=>o?o(e):e.icon,[o]),G=(0,_index.useTheme)(),J=(0,_react.useMemo)(()=>buildStyles(G),[G]),K=(0,_index.resolveFieldSize)(G,j),Q=(0,_FieldBase.resolveFieldTextStyle)(G,{disabled:f}),W=y??G.settings.components.select?.defaultVariant??G.settings.components.field?.defaultVariant??"outline",X=V??K.radius,[Y,Z]=(0,_react.useState)(!1),ee=(0,_react.useMemo)(()=>{if(A){const t=e.value??[];return i.filter(e=>containsValue(t,M(e)))}const t=e.value;if(null==t)return[];const l=i.find(e=>sameSelectValue(M(e),t));return l?[l]:[]},[A,i,e.value,M]),te=(0,_react.useCallback)(()=>{if(f)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),Z(!0)},[f,u]),ie=(0,_react.useCallback)(()=>{Z(!1)},[]),le=(0,_react.useCallback)(t=>{if(P(t))return;const i=M(t),l=(0,_index2.resolveHaptic)(u,"selection");if(l&&(0,_index2.triggerHaptic)(l),A){const t=e.value??[],l=containsValue(t,i)?t.filter(e=>!sameSelectValue(e,i)):[...t,i];return void e.onChange(l)}e.onChange(i),ie()},[A,e,ie,P,M,u]),ne=0===ee.length?s??D.placeholder:ee.map(e=>H(e)).join(", "),ae=0===ee.length,re=!0===b||(0,_FieldBase.hasFieldText)(b),oe=(0,_FieldBase.hasFieldText)(_),se=(0,_FieldBase.fieldTextAsString)(_),ce=Math.round(1.4*K.text),de=(0,_react.useMemo)(()=>({fontSize:K.text,color:Q.placeholderColor}),[K.text,Q.placeholderColor]),ue={color:f?G.colors["field-icon-disabled"]:Y?G.colors["field-icon-focus"]:G.colors["field-icon"],size:K.icon,disabled:f,focused:Y,error:re},xe=0===ee.length?s??D.noSelection:D.selected(ee.map(e=>H(e)).join(", ")),pe=R??`${se??D.fallbackName}. ${xe}`;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[J.container,B],testID:w,children:[oe?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:j,required:S,help:p,style:O,children:_}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,collapsable:!1,children:(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:j,variant:W,disabled:f,error:re,filled:ee.length>0,onPress:te,borderRadius:X,paddingHorizontal:"underline"===W?G.space.none:void 0,accessibilityRole:"button",accessibilityLabel:pe,accessibilityState:{disabled:f,expanded:Y},"aria-disabled":f,"aria-expanded":Y,style:E,slotAlign:1===m?"center":"top",slotLineHeight:1===m?void 0:ce,leading:C?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_slotIcon.renderSlotIcon)(C,ue)}):null,trailing:F?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_slotIcon.renderSlotIcon)(F,ue)}):(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:L??(f?G.colors["text-disabled"]:G.colors["text-subtle"]),size:T??K.icon,open:Y,style:J.chevron}),children:[(0,_FieldBase.hasFieldText)(g)?"string"==typeof g||"number"==typeof g?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===m?void 0:ce,marginRight:G.space.xs}],children:g}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[J.prefixNode,{minHeight:1===m?void 0:ce,justifyContent:"center",marginRight:G.space.xs}],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===m?void 0:ce}],children:(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:de,children:g})})}):null,(0,_jsxRuntime.jsxs)(_index3.Text,{variant:"body",style:[J.triggerText,{color:ae?Q.placeholderColor:Q.color,fontSize:K.text,lineHeight:1===m?void 0:ce,...Q.weightStyle},I],numberOfLines:m,children:[ne,ae&&S&&!oe?(0,_jsxRuntime.jsx)(_FieldBase.RequiredMark,{}):null]})]})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:j,error:re,text:re?b:v}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{visible:Y,onClose:ie,onVisibleChange:c,haptic:u,title:h??se,accessibilityLabel:se??(oe?h:void 0)??s??D.sheetName,options:i,getOptionLabel:H,getOptionValue:M,isOptionDisabled:P,getOptionDescription:U,getOptionIcon:$,value:e.value,onChange:(e,t)=>le(t),multi:A,searchable:d,optionStyle:N,selectedOptionStyle:q,optionTextStyle:z,selectedOptionTextStyle:k,searchSelectionColor:(0,_FieldBase.resolveVariantColors)(G,W).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});var _default=exports.default=Select;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Select=exports.DEFAULT_SELECT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_Chevron=require("../FieldBase/Chevron.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_Notation=require("../Notation/Notation.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_SELECT_LABELS=exports.DEFAULT_SELECT_LABELS={placeholder:"Select…",noSelection:"No selection",selected:e=>`Selected: ${e}`,fallbackName:"Select",sheetName:"Options",searchPlaceholder:_OptionSheet.DEFAULT_OPTION_SHEET_LABELS.searchPlaceholder,empty:_OptionSheet.DEFAULT_OPTION_SHEET_LABELS.empty},sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t)),Select=exports.Select=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("Select","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Select","variant",e.variant,["outline","filled","underline"]);const{options:i,getOptionLabel:l,getOptionValue:n,isOptionDisabled:a,getOptionDescription:r,getOptionIcon:o,placeholder:s,onVisibleChange:c,searchable:d=!1,haptic:u,labels:x,label:_,help:p,title:h,required:S=!1,error:b,helperText:v,prefix:g,numberOfLines:m=1,disabled:f=!1,size:j="md",variant:y,leftIcon:L,rightIcon:F,chevronColor:T,chevronSize:C,borderRadius:O,accessibilityLabel:E,labelStyle:V,style:R,triggerStyle:B,textStyle:I,optionStyle:N,selectedOptionStyle:A,optionTextStyle:q,selectedOptionTextStyle:z,testID:k}=e,w=!0===e.multi,D=x?{...DEFAULT_SELECT_LABELS,...x}:DEFAULT_SELECT_LABELS,P=(0,_react.useCallback)(e=>l?l(e):e.label??"",[l]),H=(0,_react.useCallback)(e=>n?n(e):e.value,[n]),M=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),U=(0,_react.useCallback)(e=>r?r(e):e.description,[r]),$=(0,_react.useCallback)(e=>o?o(e):e.icon,[o]),G=(0,_index.useTheme)(),J=(0,_react.useMemo)(()=>buildStyles(G),[G]),K=(0,_index.resolveFieldSize)(G,j),Q=(0,_FieldBase.resolveFieldTextStyle)(G,{disabled:f}),W=y??G.settings.components.select?.defaultVariant??G.settings.components.field?.defaultVariant??"outline",X=O??K.radius,[Y,Z]=(0,_react.useState)(!1),ee=(0,_react.useMemo)(()=>{if(w){const t=e.value??[];return i.filter(e=>containsValue(t,H(e)))}const t=e.value;if(null==t)return[];const l=i.find(e=>sameSelectValue(H(e),t));return l?[l]:[]},[w,i,e.value,H]),te=(0,_react.useCallback)(()=>{if(f)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),Z(!0)},[f,u]),ie=(0,_react.useCallback)(()=>{Z(!1)},[]),le=(0,_react.useCallback)(t=>{if(M(t))return;const i=H(t),l=(0,_index2.resolveHaptic)(u,"selection");if(l&&(0,_index2.triggerHaptic)(l),w){const t=e.value??[],l=containsValue(t,i)?t.filter(e=>!sameSelectValue(e,i)):[...t,i];return void e.onChange(l)}e.onChange(i),ie()},[w,e,ie,M,H,u]),ne=0===ee.length?s??D.placeholder:ee.map(e=>P(e)).join(", "),ae=0===ee.length,re=!0===b||(0,_FieldBase.hasFieldText)(b),oe=(0,_FieldBase.hasFieldText)(_),se=(0,_FieldBase.fieldTextAsString)(_),ce=Math.round(1.4*K.text),de=(0,_react.useMemo)(()=>({fontSize:K.text,color:Q.placeholderColor}),[K.text,Q.placeholderColor]),ue={color:f?G.colors["field-icon-disabled"]:Y?G.colors["field-icon-focus"]:G.colors["field-icon"],size:K.icon,disabled:f,focused:Y,error:re},xe=0===ee.length?s??D.noSelection:D.selected(ee.map(e=>P(e)).join(", ")),pe=E??`${se??D.fallbackName}. ${xe}`;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[J.container,R],testID:k,children:[oe?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:j,required:S,help:p,style:V,children:_}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,collapsable:!1,children:(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:j,variant:W,disabled:f,error:re,filled:ee.length>0,onPress:te,borderRadius:X,paddingHorizontal:"underline"===W?G.space.none:void 0,accessibilityRole:"button",accessibilityLabel:pe,accessibilityState:{disabled:f,expanded:Y},"aria-disabled":f,"aria-expanded":Y,style:B,slotAlign:1===m?"center":"top",slotLineHeight:1===m?void 0:ce,leading:L?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_slotIcon.renderSlotIcon)(L,ue)}):null,trailing:F?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_slotIcon.renderSlotIcon)(F,ue)}):(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:T??(f?G.colors["text-disabled"]:G.colors["text-subtle"]),size:C??K.icon,open:Y,style:J.chevron}),children:[(0,_FieldBase.hasFieldText)(g)?"string"==typeof g||"number"==typeof g?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===m?void 0:ce,marginRight:G.space.xs}],children:g}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[J.prefixNode,{minHeight:1===m?void 0:ce,justifyContent:"center",marginRight:G.space.xs}],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===m?void 0:ce}],children:(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:de,children:g})})}):null,(0,_jsxRuntime.jsxs)(_index3.Text,{variant:"body",style:[J.triggerText,{color:ae?Q.placeholderColor:Q.color,fontSize:K.text,lineHeight:1===m?void 0:ce,...Q.weightStyle},I],numberOfLines:m,children:[ne,ae&&S&&!oe?(0,_jsxRuntime.jsx)(_FieldBase.RequiredMark,{}):null]})]})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:j,error:re,text:re?b:v}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{visible:Y,onClose:ie,onVisibleChange:c,haptic:u,title:h??se,accessibilityLabel:se??(oe?h:void 0)??s??D.sheetName,options:i,getOptionLabel:P,getOptionValue:H,isOptionDisabled:M,getOptionDescription:U,getOptionIcon:$,value:e.value,onChange:(e,t)=>le(t),multi:w,searchable:d,labels:{searchPlaceholder:D.searchPlaceholder,empty:D.empty},optionStyle:N,selectedOptionStyle:A,optionTextStyle:q,selectedOptionTextStyle:z,searchSelectionColor:(0,_FieldBase.resolveVariantColors)(G,W).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});var _default=exports.default=Select;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SquircleFill=SquircleFill,exports.useSquircle=useSquircle;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../theme/index.js"),_squircle=require("../../utils/squircle.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,r,a=Object.defineProperty,c={__proto__:null,default:e};if(Object(e)!==e)return c;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,c)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(c,r,i):c[r]=e[r]);return c}const AnimatedPath=_reactNative.Animated.createAnimatedComponent(_reactNativeSvg.Path);function SquircleFill({width:e,height:t,radius:i,fill:r,stroke:a,strokeWidth:c=0,outset:l=0,testID:n}){const s=c>0&&void 0!==a&&"transparent"!==a,u=s?c/2:0,o=(0,_index.useTheme)().cornerSmoothing,h=(0,_squircle.squirclePath)({width:e,height:t,radius:i,inset:u,smoothing:o});return(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[styles.overlay,l?{top:-l,left:-l,right:-l,bottom:-l}:null],testID:n,children:(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:e,height:t,viewBox:`0 0 ${e} ${t}`,children:(0,_jsxRuntime.jsx)(AnimatedPath,{d:h,fill:r,stroke:s?a:void 0,strokeWidth:s?c:void 0})})})}function useSquircle(e,t,i){const[r,a]=(0,_react.useState)(null),c=e&&"android"===_reactNative.Platform.OS;return{onLayout:(0,_react.useCallback)(e=>{if(c){const{width:t,height:i}=e.nativeEvent.layout;a(e=>e&&e.width===t&&e.height===i?e:{width:t,height:i})}i?.(e)},[c,i]),size:r,active:c&&null!==r&&(0,_squircle.squircleApplies)(r.width,r.height,t)}}SquircleFill.displayName="SquircleFill";const styles=_reactNative.StyleSheet.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SquircleFill=SquircleFill,exports.useSquircle=useSquircle;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../theme/index.js"),_squircle=require("../../utils/squircle.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,r,a=Object.defineProperty,c={__proto__:null,default:e};if(Object(e)!==e)return c;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,c)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(c,r,i):c[r]=e[r]);return c}const AnimatedPath=_reactNative.Animated.createAnimatedComponent(_reactNativeSvg.Path);function SquircleFill({width:e,height:t,radius:i,fill:r,stroke:a,strokeWidth:c=0,testID:n}){const s=c>0&&void 0!==a&&"transparent"!==a,l=s?c/2:0,u=(0,_index.useTheme)().cornerSmoothing,o=(0,_squircle.squirclePath)({width:e,height:t,radius:i,inset:l,smoothing:u});return(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:styles.overlay,testID:n,children:(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:e,height:t,viewBox:`0 0 ${e} ${t}`,children:(0,_jsxRuntime.jsx)(AnimatedPath,{d:o,fill:r,stroke:s?a:void 0,strokeWidth:s?c:void 0})})})}function useSquircle(e,t,i){const[r,a]=(0,_react.useState)(null),c=e&&"android"===_reactNative.Platform.OS;return{onLayout:(0,_react.useCallback)(e=>{if(c){const{width:t,height:i}=e.nativeEvent.layout;a(e=>e&&e.width===t&&e.height===i?e:{width:t,height:i})}i?.(e)},[c,i]),size:r,active:c&&null!==r&&(0,_squircle.squircleApplies)(r.width,r.height,t)}}SquircleFill.displayName="SquircleFill";const styles=_reactNative.StyleSheet.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SquircleView=void 0;var _react=require("react"),_reactNative=require("react-native"),_corners=require("../../utils/corners.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("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:t,borderColor:o,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 l="string"==typeof t&&"transparent"!==t,s=i>0&&"string"==typeof o&&"transparent"!==o;return void 0!==t&&"string"!=typeof t||i>0&&void 0!==o&&"string"!=typeof o||!l&&!s?null:{radius:e,fill:l?t:"transparent",stroke:s?o:void 0,strokeWidth:s?i:0,outset:i}},SquircleView=exports.SquircleView=(0,_react.forwardRef)(({style:r,children:e,onLayout:t,...o},i)=>{const d=_reactNative.StyleSheet.flatten(r)??{},l=readShape(d),s="number"==typeof d.borderRadius?d.borderRadius:0,a=(0,_SquircleFill.useSquircle)(s>0,s,t),u=a.active?a.size:null,n=null!==l&&null!==u;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:i,...o,onLayout:a.onLayout,style:[s>0?_corners.smoothCorners:null,r,n?styles.hostTransparent:null],children:[l&&u?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:u.width,height:u.height,radius:l.radius,fill:l.fill,stroke:l.stroke,strokeWidth:l.strokeWidth,outset:l.outset}):null,e]})});SquircleView.displayName="SquircleView";const styles=_reactNative.StyleSheet.create({hostTransparent:{backgroundColor:"transparent",borderColor:"transparent"}});var _default=exports.default=SquircleView;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SquircleView=void 0;var _react=require("react"),_reactNative=require("react-native"),_corners=require("../../utils/corners.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("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:t,borderColor:o,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 l="string"==typeof t&&"transparent"!==t,s=i>0&&"string"==typeof o&&"transparent"!==o;return void 0!==t&&"string"!=typeof t||i>0&&void 0!==o&&"string"!=typeof o||!l&&!s?null:{radius:e,fill:l?t:"transparent",stroke:s?o:void 0,strokeWidth:s?i:0}},SquircleView=exports.SquircleView=(0,_react.forwardRef)(({style:r,children:e,onLayout:t,...o},i)=>{const d=_reactNative.StyleSheet.flatten(r)??{},l=readShape(d),s="number"==typeof d.borderRadius?d.borderRadius:0,a=(0,_SquircleFill.useSquircle)(s>0,s,t),u=a.active?a.size:null,n=null!==l&&null!==u;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:i,...o,onLayout:a.onLayout,style:[s>0?_corners.smoothCorners:null,r,n?styles.hostTransparent:null],children:[l&&u?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:u.width,height:u.height,radius:l.radius,fill:l.fill,stroke:l.stroke,strokeWidth:l.strokeWidth}):null,e]})});SquircleView.displayName="SquircleView";const styles=_reactNative.StyleSheet.create({hostTransparent:{backgroundColor:"transparent",borderColor:"transparent"}});var _default=exports.default=SquircleView;
@@ -1 +1 @@
1
- "use strict";import{forwardRef}from"react";import{View}from"react-native";import{useTheme}from"../../theme/index.js";import{radiusOf,spaceOf}from"../../theme/scale.js";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 BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],space=(e,r)=>null==r?void 0:spaceOf(e,r);export const resolveBoxStyle=(e,r)=>{const l={};return null!=r.p&&(l.padding=space(e,r.p)),null!=r.px&&(l.paddingHorizontal=space(e,r.px)),null!=r.py&&(l.paddingVertical=space(e,r.py)),null!=r.pt&&(l.paddingTop=space(e,r.pt)),null!=r.pr&&(l.paddingRight=space(e,r.pr)),null!=r.pb&&(l.paddingBottom=space(e,r.pb)),null!=r.pl&&(l.paddingLeft=space(e,r.pl)),null!=r.m&&(l.margin=space(e,r.m)),null!=r.mx&&(l.marginHorizontal=space(e,r.mx)),null!=r.my&&(l.marginVertical=space(e,r.my)),null!=r.mt&&(l.marginTop=space(e,r.mt)),null!=r.mr&&(l.marginRight=space(e,r.mr)),null!=r.mb&&(l.marginBottom=space(e,r.mb)),null!=r.ml&&(l.marginLeft=space(e,r.ml)),null!=r.gap&&(l.gap=space(e,r.gap)),null!=r.bg&&(l.backgroundColor=BACKGROUND_TOKENS.includes(r.bg)?e.colors[r.bg]:r.bg),null!=r.radius&&(l.borderRadius=radiusOf(e,r.radius),l.borderCurve=smoothCorners.borderCurve),r.border&&(l.borderWidth=e.size.border,l.borderColor=e.colors.border),null!=r.flex&&(l.flex=r.flex),null!=r.align&&(l.alignItems=r.align),null!=r.justify&&(l.justifyContent=r.justify),null!=r.direction&&(l.flexDirection=r.direction),r.wrap&&(l.flexWrap="wrap"),l};const Box=forwardRef((e,r)=>{const l=useTheme(),{p:o,px:t,py:a,pt:s,pr:i,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:g,mb:f,ml:x,gap:b,bg:y,radius:h,border:j,flex:w,align:S,justify:R,direction:B,wrap:C,style:_,children:k,...v}=e,O=resolveBoxStyle(l,{p:o,px:t,py:a,pt:s,pr:i,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:g,mb:f,ml:x,gap:b,bg:y,radius:h,border:j,flex:w,align:S,justify:R,direction:B,wrap:C}),N=useSquircle(null!=h&&(null!=y||Boolean(j)),O.borderRadius,v.onLayout),z=N.active?{...O,backgroundColor:"transparent",borderColor:"transparent"}:O;return _jsxs(View,{ref:r,...v,onLayout:N.onLayout,style:[z,_],children:[N.active&&N.size?_jsx(SquircleFill,{width:N.size.width,height:N.size.height,radius:O.borderRadius,fill:O.backgroundColor??"transparent",stroke:O.borderColor,strokeWidth:O.borderWidth??0,outset:O.borderWidth??0}):null,k]})});Box.displayName="Box";const Stack=forwardRef(({gap:e="md",...r},l)=>_jsx(Box,{ref:l,direction:"column",gap:e,...r}));Stack.displayName="Stack";const Row=forwardRef(({gap:e="sm",align:r="center",...l},o)=>_jsx(Box,{ref:o,direction:"row",gap:e,align:r,...l}));Row.displayName="Row";const Spacer=({size:e,style:r,testID:l})=>{const o=useTheme();if(null!=e){const t=spaceOf(o,e);return _jsx(View,{testID:l,style:[{width:t,height:t},r]})}return _jsx(View,{testID:l,style:[{flex:1},r]})};Spacer.displayName="Spacer";export{Box,Row,Spacer,Stack};export default Box;
1
+ "use strict";import{forwardRef}from"react";import{View}from"react-native";import{useTheme}from"../../theme/index.js";import{radiusOf,spaceOf}from"../../theme/scale.js";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 BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],space=(e,r)=>null==r?void 0:spaceOf(e,r);export const resolveBoxStyle=(e,r)=>{const l={};return null!=r.p&&(l.padding=space(e,r.p)),null!=r.px&&(l.paddingHorizontal=space(e,r.px)),null!=r.py&&(l.paddingVertical=space(e,r.py)),null!=r.pt&&(l.paddingTop=space(e,r.pt)),null!=r.pr&&(l.paddingRight=space(e,r.pr)),null!=r.pb&&(l.paddingBottom=space(e,r.pb)),null!=r.pl&&(l.paddingLeft=space(e,r.pl)),null!=r.m&&(l.margin=space(e,r.m)),null!=r.mx&&(l.marginHorizontal=space(e,r.mx)),null!=r.my&&(l.marginVertical=space(e,r.my)),null!=r.mt&&(l.marginTop=space(e,r.mt)),null!=r.mr&&(l.marginRight=space(e,r.mr)),null!=r.mb&&(l.marginBottom=space(e,r.mb)),null!=r.ml&&(l.marginLeft=space(e,r.ml)),null!=r.gap&&(l.gap=space(e,r.gap)),null!=r.bg&&(l.backgroundColor=BACKGROUND_TOKENS.includes(r.bg)?e.colors[r.bg]:r.bg),null!=r.radius&&(l.borderRadius=radiusOf(e,r.radius),l.borderCurve=smoothCorners.borderCurve),r.border&&(l.borderWidth=e.size.border,l.borderColor=e.colors.border),null!=r.flex&&(l.flex=r.flex),null!=r.align&&(l.alignItems=r.align),null!=r.justify&&(l.justifyContent=r.justify),null!=r.direction&&(l.flexDirection=r.direction),r.wrap&&(l.flexWrap="wrap"),l};const Box=forwardRef((e,r)=>{const l=useTheme(),{p:o,px:t,py:a,pt:s,pr:i,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:g,mb:f,ml:x,gap:b,bg:y,radius:h,border:j,flex:w,align:S,justify:R,direction:B,wrap:C,style:_,children:k,...v}=e,O=resolveBoxStyle(l,{p:o,px:t,py:a,pt:s,pr:i,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:g,mb:f,ml:x,gap:b,bg:y,radius:h,border:j,flex:w,align:S,justify:R,direction:B,wrap:C}),N=useSquircle(null!=h&&(null!=y||Boolean(j)),O.borderRadius,v.onLayout),z=N.active?{...O,backgroundColor:"transparent",borderColor:"transparent"}:O;return _jsxs(View,{ref:r,...v,onLayout:N.onLayout,style:[z,_],children:[N.active&&N.size?_jsx(SquircleFill,{width:N.size.width,height:N.size.height,radius:O.borderRadius,fill:O.backgroundColor??"transparent",stroke:O.borderColor,strokeWidth:O.borderWidth??0}):null,k]})});Box.displayName="Box";const Stack=forwardRef(({gap:e="md",...r},l)=>_jsx(Box,{ref:l,direction:"column",gap:e,...r}));Stack.displayName="Stack";const Row=forwardRef(({gap:e="sm",align:r="center",...l},o)=>_jsx(Box,{ref:o,direction:"row",gap:e,align:r,...l}));Row.displayName="Row";const Spacer=({size:e,style:r,testID:l})=>{const o=useTheme();if(null!=e){const t=spaceOf(o,e);return _jsx(View,{testID:l,style:[{width:t,height:t},r]})}return _jsx(View,{testID:l,style:[{flex:1},r]})};Spacer.displayName="Spacer";export{Box,Row,Spacer,Stack};export default Box;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/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";export const DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});const Button=forwardRef((e,o)=>{const{label:t,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:I,accessibilityState:_,testID:T,onLayout:k,labels:v,...w}=e;warnInvalidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),warnInvalidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const j=useTheme(),F=j.settings.components.button,L=r??F?.defaultVariant??"solid",O=i??F?.defaultSize??"md",R=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...v}),[v]),A=!l&&!n,V={..._,disabled:!A,busy:n},B="link"===L,P=y??F?.defaultPressAnimation??(!B&&"scale"),z=usePressAnimation({preset:P||"scale",enabled:!1!==P&&A}),W=useFlickGuard(),E=useMemo(()=>buildStyles(j),[j]),D=useMemo(()=>resolveButtonSize(j,O),[j,O]),N=useMemo(()=>toneFor(j,s),[j,s]),H=useMemo(()=>variantFor(j,L,N,l),[j,L,N,l]),M=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?j.settings.gradients[m]??null:m,[m,l,L,j.settings.gradients]),U=StyleSheet.flatten(f)?.borderRadius,q=B?0:"number"==typeof U?U:p?j.radius.pill:D.radius,G=useSquircle(!M&&"link"!==L,q,k),K=useRef(createAnimatedValue(0)).current,[X,Y]=useState(0),[J,Q]=useState(null),Z=B?e=>Y(e.nativeEvent.layout.width):void 0,$=C??t,ee="outline"===L||"ghost"===L,oe=!ee&&!B,te={color:H.textColor,size:D.icon,disabled:l},re=b&&!B&&Boolean(d),se=j.space.xs,ie=D["min-height"]-2*se-2*H.borderWidth,ne={color:H.badgeInk,size:D["badge-icon"],disabled:l},le=n?_jsx(Spinner,{variant:"circular",size:"sm",color:re?H.badgeInk:H.textColor,accessibilityLabel:R.loading}):d?renderSlotIcon(d,re?ne:te,u):null,ae=_jsxs(View,{style:E.contentRow,children:[re?_jsx(View,{testID:"button-icon-badge",style:[E.iconLeft,E.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:H.badgeFill}],children:le}):le?_jsx(View,{style:E.iconLeft,children:le}):null,_jsxs(View,{onLayout:Z,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[E.label,{color:H.textColor,fontSize:D.text,lineHeight:Math.round(D.text*j.leading.body)},x],children:t}),B?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[E.linkUnderline,{backgroundColor:H.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:E.iconRight,children:renderSlotIcon(c,te,u)}):null]}),de=B?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(D["min-height"]),ce={top:de,bottom:de,left:B?LINK_HIT_SLOP:0,right:B?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[z.style,a?E.fullWidth:null,h],children:_jsx(Pressable,{ref:o,onPress:e=>{A&&!W.isFlick(e)&&(z.press(),g&&triggerHaptic(g),S?.(e))},onPressIn:e=>{W.onPressIn(e),z.pressIn(),B&&A&&(K.stopAnimation(),K.setValue(0),Animated.timing(K,{toValue:1,duration:j.motion.duration.slower,easing:Easing.bezier(...j.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{z.pressOut()},disabled:!A,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:I,accessibilityState:V,...ariaFromState(V),testID:T,onLayout:e=>{G.onLayout(e),B&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[E.base,{paddingHorizontal:B?0:D["padding-x"],paddingVertical:B?0:re?se:D["padding-y"],paddingLeft:re?se:void 0,minHeight:B?void 0:D["min-height"],borderRadius:q,...smoothCorners,backgroundColor:M||G.active?"transparent":H.backgroundColor,borderWidth:H.borderWidth,borderColor:G.active?"transparent":H.borderColor,opacity:n?.55:1,overflow:G.active||B?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:j.colors["surface-pressed"]}:null,a?E.fullWidth:null,f],...w,"aria-disabled":!A,"aria-busy":n,children:({pressed:e})=>_jsxs(_Fragment,{children:[G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:e&&ee?j.colors["surface-pressed"]:H.backgroundColor,stroke:H.borderColor,strokeWidth:H.borderWidth,outset:H.borderWidth}):null,M?_jsx(Gradient,{gradient:M,style:[StyleSheet.absoluteFill,{borderRadius:q,...smoothCorners}]}):null,e&&oe?G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:H.pressedTint,outset:H.borderWidth,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[E.pressedOverlay,{borderRadius:q,backgroundColor:H.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,o)=>{switch(o){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:tintOf(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:tintOf(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:tintOf(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:tintOf(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:tintOf(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,o,t,r)=>{const s=r?e.colors["text-disabled"]:t.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:t.on,badgeInk:t.base},l=r?i:{badgeFill:t.base,badgeInk:t.on};switch(o){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:t.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:t.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:t.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:t.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:t.base};default:return{backgroundColor:t.base,borderColor:"transparent",borderWidth:1,textColor:t.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,o){return variantFor(o,e.variant??"solid",toneFor(o,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});export{Button};export default Button;
1
+ "use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/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";export const DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});const Button=forwardRef((e,o)=>{const{label:t,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:I,accessibilityState:_,testID:T,onLayout:k,labels:v,...w}=e;warnInvalidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),warnInvalidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const j=useTheme(),F=j.settings.components.button,L=r??F?.defaultVariant??"solid",O=i??F?.defaultSize??"md",R=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...v}),[v]),A=!l&&!n,V={..._,disabled:!A,busy:n},B="link"===L,P=y??F?.defaultPressAnimation??(!B&&"scale"),z=usePressAnimation({preset:P||"scale",enabled:!1!==P&&A}),E=useFlickGuard(),W=useMemo(()=>buildStyles(j),[j]),D=useMemo(()=>resolveButtonSize(j,O),[j,O]),N=useMemo(()=>toneFor(j,s),[j,s]),H=useMemo(()=>variantFor(j,L,N,l),[j,L,N,l]),M=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?j.settings.gradients[m]??null:m,[m,l,L,j.settings.gradients]),U=StyleSheet.flatten(f)?.borderRadius,q=B?0:"number"==typeof U?U:p?j.radius.pill:D.radius,G=useSquircle(!M&&"link"!==L,q,k),K=useRef(createAnimatedValue(0)).current,[X,Y]=useState(0),[J,Q]=useState(null),Z=B?e=>Y(e.nativeEvent.layout.width):void 0,$=C??t,ee="outline"===L||"ghost"===L,oe=!ee&&!B,te={color:H.textColor,size:D.icon,disabled:l},re=b&&!B&&Boolean(d),se=j.space.xs,ie=D["min-height"]-2*se-2*H.borderWidth,ne={color:H.badgeInk,size:D["badge-icon"],disabled:l},le=n?_jsx(Spinner,{variant:"circular",size:"sm",color:re?H.badgeInk:H.textColor,accessibilityLabel:R.loading}):d?renderSlotIcon(d,re?ne:te,u):null,ae=_jsxs(View,{style:W.contentRow,children:[re?_jsx(View,{testID:"button-icon-badge",style:[W.iconLeft,W.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:H.badgeFill}],children:le}):le?_jsx(View,{style:W.iconLeft,children:le}):null,_jsxs(View,{onLayout:Z,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[W.label,{color:H.textColor,fontSize:D.text,lineHeight:Math.round(D.text*j.leading.body)},x],children:t}),B?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[W.linkUnderline,{backgroundColor:H.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:W.iconRight,children:renderSlotIcon(c,te,u)}):null]}),de=B?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(D["min-height"]),ce={top:de,bottom:de,left:B?LINK_HIT_SLOP:0,right:B?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[z.style,a?W.fullWidth:null,h],children:_jsx(Pressable,{ref:o,onPress:e=>{A&&!E.isFlick(e)&&(z.press(),g&&triggerHaptic(g),S?.(e))},onPressIn:e=>{E.onPressIn(e),z.pressIn(),B&&A&&(K.stopAnimation(),K.setValue(0),Animated.timing(K,{toValue:1,duration:j.motion.duration.slower,easing:Easing.bezier(...j.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{z.pressOut()},disabled:!A,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:I,accessibilityState:V,...ariaFromState(V),testID:T,onLayout:e=>{G.onLayout(e),B&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[W.base,{paddingHorizontal:B?0:D["padding-x"],paddingVertical:B?0:re?se:D["padding-y"],paddingLeft:re?se:void 0,minHeight:B?void 0:D["min-height"],borderRadius:q,...smoothCorners,backgroundColor:M||G.active?"transparent":H.backgroundColor,borderWidth:H.borderWidth,borderColor:G.active?"transparent":H.borderColor,opacity:n?.55:1,overflow:G.active||B?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:j.colors["surface-pressed"]}:null,a?W.fullWidth:null,f],...w,"aria-disabled":!A,"aria-busy":n,children:({pressed:e})=>_jsxs(_Fragment,{children:[G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:e&&ee?j.colors["surface-pressed"]:H.backgroundColor,stroke:H.borderColor,strokeWidth:H.borderWidth}):null,M?_jsx(Gradient,{gradient:M,style:[StyleSheet.absoluteFill,{borderRadius:q,...smoothCorners}]}):null,e&&oe?G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:H.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[W.pressedOverlay,{borderRadius:q,backgroundColor:H.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,o)=>{switch(o){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:tintOf(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:tintOf(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:tintOf(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:tintOf(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:tintOf(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,o,t,r)=>{const s=r?e.colors["text-disabled"]:t.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:t.on,badgeInk:t.base},l=r?i:{badgeFill:t.base,badgeInk:t.on};switch(o){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:t.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:t.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:t.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:t.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:t.base};default:return{backgroundColor:t.base,borderColor:"transparent",borderWidth:1,textColor:t.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,o){return variantFor(o,e.variant??"solid",toneFor(o,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});export{Button};export default Button;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/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 BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:i,variant:o="elevated",elevation:s="card",radius:r="lg",padding:a="md",interactive:l=!1,bg:n,header:d,title:c,titleFont:u="sans",lead:h,action:m,headerActions:p,collapsible:b=!1,collapsed:g,defaultCollapsed:y=!1,onCollapsedChange:x,collapsedSummary:f,onRemove:S,separatorHeight:v=StyleSheet.hairlineWidth,footer:j,imageSource:C,imageHeight:w=160,imageAspectRatio:_,imageOverlay:R,loading:A=!1,gradient:F,onPress:T,haptic:k,contextMenu:B,accessibilityLabel:I,accessibilityHint:L,accessibilityRole:V,style:H,containerStyle:P,headerStyle:z,bodyStyle:M,footerStyle:D,borderRadius:q,testID:E,labels:O,onLayout:W,...N}=e;warnInvalidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),warnInvalidValue("Card","radius",e.radius,["sm","md","lg","xl"]),warnInvalidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),warnInvalidValue("Card","titleFont",e.titleFont,["sans","serif"]);const G=useTheme(),U=useMemo(()=>({...DEFAULT_CARD_LABELS,...O}),[O]),K=l||"function"==typeof T,$=useContextMenu(B,{haptic:k||!1,testID:E,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),J=useMemo(()=>mergeRefs(t,$.hostRef),[t,$.hostRef]),Q=K||$.enabled,{style:X,pressIn:Y,pressOut:Z}=usePressAnimation({enabled:Q}),ee=stylesFor(G),te=Boolean(C),ie=G.space[paddingMap[a]],oe=useMemo(()=>F?"string"==typeof F?G.settings.gradients[F]??null:F:null,[F,G.settings.gradients]),se="flat"===o,re=se?G.radius.none:q??G.radius[r],ae=resolveBackground(G,n),[le,ne]=useControllableState({value:g,defaultValue:y,onChange:x}),de=b&&le,ce=hasBuiltInHeaderContent(e),ue=Boolean(d)||ce,he=useSquircle(!te&&!oe&&!se,re,W),me=StyleSheet.flatten([H,P])??{},pe=me.backgroundColor,be=me.borderColor,ge=pe??ae??("filled"===o?G.colors["bg-subtle"]:G.colors.surface),ye="outline"===o?G.size.border:0,xe=be??G.colors.border,fe="none"===s?void 0:G.shadow[s],Se="elevated"===o&&supportsBoxShadow()&&fe?toBoxShadow(fe):void 0,ve=he.active&&"elevated"===o&&!Se,je=he.active&&!ve?{backgroundColor:"transparent",borderColor:"transparent"}:null,Ce=useMemo(()=>{const e={borderRadius:ve&&he.size?squircleHostRadius(he.size.width,he.size.height,re):re,...smoothCorners,padding:te||he.active?G.space.none:ie,overflow:he.active?"visible":"hidden"};switch(o){case"flat":return{...e,backgroundColor:ae??G.colors.surface,borderBottomWidth:v,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:he.active?"transparent":ae??G.colors.surface,borderWidth:G.size.border,borderColor:he.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:he.active?"transparent":ae??G.colors["bg-subtle"]};default:return{...e,backgroundColor:ae??G.colors.surface,...Se?{boxShadow:Se}:fe}}},[G,o,fe,re,te,ie,he.active,he.size,Se,ve,ae,v]),we=useMemo(()=>({..."number"==typeof _?{width:"100%",aspectRatio:_}:{width:"100%",height:w},borderTopLeftRadius:re,borderTopRightRadius:re,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,re,_,w]),Re=c??"",Ae=_jsxs(_Fragment,{children:[_jsxs(View,{style:ee.titleColumn,children:[c?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,u),children:c}):null,h?_jsx(Text,{variant:"bodySmall",style:ee.lead,children:h}):null,de&&f?_jsx(Text,{variant:"caption",style:ee.lead,children:f}):null]}),isCardTextAction(m)?_jsx(CardTextActionButton,{action:m,haptic:k}):m?_jsx(View,{style:ee.actionNode,children:m}):null,p,b?_jsx(CardIconAction,{icon:de?"chevron-down":"chevron-up",label:`${de?U.show:U.hide} ${Re}`.trim(),expanded:!de,onPress:()=>ne(!de),haptic:k}):null,S?_jsx(CardIconAction,{icon:"trash",label:U.remove,onPress:S,color:G.colors["danger-text"],haptic:k}):null]}),Fe=_jsxs(_Fragment,{children:[ue?_jsx(View,{style:[ee.header,!d&&ee.headerRow,de&&ee.headerFolded,z],children:d??Ae}):null,de?null:_jsx(View,{style:[ue||j?ee.body:null,M],children:i}),j&&!de?_jsx(View,{style:[ee.footer,D],children:j}):null]}),Te=te?_jsxs(_Fragment,{children:[_jsxs(View,{style:ee.imageWrapper,children:[_jsx(Image,{source:C,resizeMode:"cover",style:we,accessibilityLabel:"",accessible:!1}),R?_jsx(View,{pointerEvents:"box-none",style:ee.imageOverlay,children:R}):null]}),_jsx(View,{style:{padding:ie},children:Fe})]}):Fe,ke=oe?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:oe,style:StyleSheet.absoluteFill}),Te]}):he.active&&he.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:he.size.width,height:he.size.height,radius:re,fill:ge,stroke:ye?xe:void 0,strokeWidth:ye,outset:ye}),_jsx(View,{style:[ee.squircleClip,{padding:ie,borderRadius:he.size?squircleHostRadius(he.size.width,he.size.height,re):re}],children:Te})]}):Te;let Be;if(Q){const handlePress=e=>{K&&(k&&triggerHaptic(k),T?.(e))};Be=_jsx(Animated.View,{style:X,children:_jsx(Pressable,{ref:J,onPress:handlePress,onPressIn:Y,onPressOut:Z,accessibilityRole:V??(K?"button":void 0),accessibilityLabel:I,accessibilityHint:L,testID:E,onLayout:he.onLayout,style:[Ce,H,P,je],...N,...$.hostProps,children:ke})})}else Be=_jsx(View,{ref:t,accessibilityLabel:I,accessibilityHint:L,accessibilityRole:V,testID:E,onLayout:he.onLayout,style:[Ce,H,P,je],...N,children:ke});return A?_jsx(CardSkeleton,{...e}):$.enabled?_jsxs(_Fragment,{children:[Be,$.renderSurface(_jsx(View,{style:[Ce,H,P,je,ee.preview],children:ke}))]}):Be}));Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:i="lg",padding:o="md",bg:s,header:r,footer:a,imageSource:l,imageHeight:n=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:m,footerStyle:p,style:b,labels:g,...y})=>{const x=useTheme(),f={...DEFAULT_CARD_LABELS,...g},S=paddingMap[o],v=x.space[S],j="flat"===e?x.radius.none:c??x.radius[i],C=void 0!==r||hasBuiltInHeaderContent(y),w=resolveBackground(x,s)??x.colors.surface,_="outline"===e?1:0,R="outline"===e?x.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:w,borderRadius:j,...smoothCorners,borderWidth:_,borderColor:R,overflow:"hidden"},u,b],accessibilityRole:"progressbar",accessibilityLabel:f.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,C?_jsx(View,{style:[{padding:v,paddingBottom:x.space.sm},h],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:v},m],children:_jsx(SkeletonText,{lines:3,fontSize:x.text.base.size,lastLineWidth:"55%"})}),void 0!==a?_jsx(View,{style:[{padding:v,paddingTop:x.space.sm,flexDirection:"row"},p],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:o,color:s,haptic:r})=>{const a=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===o?void 0:{expanded:o},"aria-expanded":o,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(AppIcon,{name:e,size:20,color:s??a.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
1
+ "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/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 BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:i,variant:o="elevated",elevation:s="card",radius:r="lg",padding:a="md",interactive:l=!1,bg:n,header:d,title:c,titleFont:u="sans",lead:h,action:m,headerActions:p,collapsible:b=!1,collapsed:g,defaultCollapsed:y=!1,onCollapsedChange:x,collapsedSummary:f,onRemove:S,separatorHeight:v=StyleSheet.hairlineWidth,footer:j,imageSource:C,imageHeight:w=160,imageAspectRatio:_,imageOverlay:R,loading:A=!1,gradient:F,onPress:T,haptic:k,contextMenu:B,accessibilityLabel:I,accessibilityHint:L,accessibilityRole:V,style:H,containerStyle:P,headerStyle:z,bodyStyle:M,footerStyle:D,borderRadius:q,testID:E,labels:O,onLayout:W,...N}=e;warnInvalidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),warnInvalidValue("Card","radius",e.radius,["sm","md","lg","xl"]),warnInvalidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),warnInvalidValue("Card","titleFont",e.titleFont,["sans","serif"]);const G=useTheme(),U=useMemo(()=>({...DEFAULT_CARD_LABELS,...O}),[O]),K=l||"function"==typeof T,$=useContextMenu(B,{haptic:k||!1,testID:E,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),J=useMemo(()=>mergeRefs(t,$.hostRef),[t,$.hostRef]),Q=K||$.enabled,{style:X,pressIn:Y,pressOut:Z}=usePressAnimation({enabled:Q}),ee=stylesFor(G),te=Boolean(C),ie=G.space[paddingMap[a]],oe=useMemo(()=>F?"string"==typeof F?G.settings.gradients[F]??null:F:null,[F,G.settings.gradients]),se="flat"===o,re=se?G.radius.none:q??G.radius[r],ae=resolveBackground(G,n),[le,ne]=useControllableState({value:g,defaultValue:y,onChange:x}),de=b&&le,ce=hasBuiltInHeaderContent(e),ue=Boolean(d)||ce,he=useSquircle(!te&&!oe&&!se,re,W),me=StyleSheet.flatten([H,P])??{},pe=me.backgroundColor,be=me.borderColor,ge=pe??ae??("filled"===o?G.colors["bg-subtle"]:G.colors.surface),ye="outline"===o?G.size.border:0,xe=be??G.colors.border,fe="none"===s?void 0:G.shadow[s],Se="elevated"===o&&supportsBoxShadow()&&fe?toBoxShadow(fe):void 0,ve=he.active&&"elevated"===o&&!Se,je=he.active&&!ve?{backgroundColor:"transparent",borderColor:"transparent"}:null,Ce=useMemo(()=>{const e={borderRadius:ve&&he.size?squircleHostRadius(he.size.width,he.size.height,re):re,...smoothCorners,padding:te||he.active?G.space.none:ie,overflow:he.active?"visible":"hidden"};switch(o){case"flat":return{...e,backgroundColor:ae??G.colors.surface,borderBottomWidth:v,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:he.active?"transparent":ae??G.colors.surface,borderWidth:G.size.border,borderColor:he.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:he.active?"transparent":ae??G.colors["bg-subtle"]};default:return{...e,backgroundColor:ae??G.colors.surface,...Se?{boxShadow:Se}:fe}}},[G,o,fe,re,te,ie,he.active,he.size,Se,ve,ae,v]),we=useMemo(()=>({..."number"==typeof _?{width:"100%",aspectRatio:_}:{width:"100%",height:w},borderTopLeftRadius:re,borderTopRightRadius:re,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,re,_,w]),Re=c??"",Ae=_jsxs(_Fragment,{children:[_jsxs(View,{style:ee.titleColumn,children:[c?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,u),children:c}):null,h?_jsx(Text,{variant:"bodySmall",style:ee.lead,children:h}):null,de&&f?_jsx(Text,{variant:"caption",style:ee.lead,children:f}):null]}),isCardTextAction(m)?_jsx(CardTextActionButton,{action:m,haptic:k}):m?_jsx(View,{style:ee.actionNode,children:m}):null,p,b?_jsx(CardIconAction,{icon:de?"chevron-down":"chevron-up",label:`${de?U.show:U.hide} ${Re}`.trim(),expanded:!de,onPress:()=>ne(!de),haptic:k}):null,S?_jsx(CardIconAction,{icon:"trash",label:U.remove,onPress:S,color:G.colors["danger-text"],haptic:k}):null]}),Fe=_jsxs(_Fragment,{children:[ue?_jsx(View,{style:[ee.header,!d&&ee.headerRow,de&&ee.headerFolded,z],children:d??Ae}):null,de?null:_jsx(View,{style:[ue||j?ee.body:null,M],children:i}),j&&!de?_jsx(View,{style:[ee.footer,D],children:j}):null]}),Te=te?_jsxs(_Fragment,{children:[_jsxs(View,{style:ee.imageWrapper,children:[_jsx(Image,{source:C,resizeMode:"cover",style:we,accessibilityLabel:"",accessible:!1}),R?_jsx(View,{pointerEvents:"box-none",style:ee.imageOverlay,children:R}):null]}),_jsx(View,{style:{padding:ie},children:Fe})]}):Fe,ke=oe?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:oe,style:StyleSheet.absoluteFill}),Te]}):he.active&&he.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:he.size.width,height:he.size.height,radius:re,fill:ge,stroke:ye?xe:void 0,strokeWidth:ye}),_jsx(View,{style:[ee.squircleClip,{padding:ie,borderRadius:he.size?squircleHostRadius(he.size.width,he.size.height,re):re}],children:Te})]}):Te;let Be;if(Q){const handlePress=e=>{K&&(k&&triggerHaptic(k),T?.(e))};Be=_jsx(Animated.View,{style:X,children:_jsx(Pressable,{ref:J,onPress:handlePress,onPressIn:Y,onPressOut:Z,accessibilityRole:V??(K?"button":void 0),accessibilityLabel:I,accessibilityHint:L,testID:E,onLayout:he.onLayout,style:[Ce,H,P,je],...N,...$.hostProps,children:ke})})}else Be=_jsx(View,{ref:t,accessibilityLabel:I,accessibilityHint:L,accessibilityRole:V,testID:E,onLayout:he.onLayout,style:[Ce,H,P,je],...N,children:ke});return A?_jsx(CardSkeleton,{...e}):$.enabled?_jsxs(_Fragment,{children:[Be,$.renderSurface(_jsx(View,{style:[Ce,H,P,je,ee.preview],children:ke}))]}):Be}));Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:i="lg",padding:o="md",bg:s,header:r,footer:a,imageSource:l,imageHeight:n=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:m,footerStyle:p,style:b,labels:g,...y})=>{const x=useTheme(),f={...DEFAULT_CARD_LABELS,...g},S=paddingMap[o],v=x.space[S],j="flat"===e?x.radius.none:c??x.radius[i],C=void 0!==r||hasBuiltInHeaderContent(y),w=resolveBackground(x,s)??x.colors.surface,_="outline"===e?1:0,R="outline"===e?x.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:w,borderRadius:j,...smoothCorners,borderWidth:_,borderColor:R,overflow:"hidden"},u,b],accessibilityRole:"progressbar",accessibilityLabel:f.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,C?_jsx(View,{style:[{padding:v,paddingBottom:x.space.sm},h],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:v},m],children:_jsx(SkeletonText,{lines:3,fontSize:x.text.base.size,lastLineWidth:"55%"})}),void 0!==a?_jsx(View,{style:[{padding:v,paddingTop:x.space.sm,flexDirection:"row"},p],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:o,color:s,haptic:r})=>{const a=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===o?void 0:{expanded:o},"aria-expanded":o,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(AppIcon,{name:e,size:20,color:s??a.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,isValidElement,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,Text,View}from"react-native";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,resolveEmptyStateSize,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const ActionButton=({action:e,variant:t})=>{const r=useTheme(),{style:i,pressIn:o,pressOut:s}=usePressAnimation({enabled:!0}),n=useMemo(()=>buildActionStyles(r),[r]),l="primary"===t,a=useSquircle(!0,r.radius.md),fillFor=e=>l?e?r.colors["primary-hover"]:r.colors.primary:e?r.colors["surface-pressed"]:"transparent";return _jsx(Animated.View,{style:i,children:_jsx(Pressable,{onPress:()=>{triggerHaptic("selection"),e.onPress()},onPressIn:o,onPressOut:s,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityHint:e.accessibilityHint,testID:e.testID,onLayout:a.onLayout,style:({pressed:e})=>[n.button,l?n.buttonPrimary:n.buttonSecondary,e&&!a.active?l?n.buttonPrimaryPressed:n.buttonSecondaryPressed:null,a.active?n.buttonSquircleHost:null],children:({pressed:t})=>_jsxs(_Fragment,{children:[a.active&&a.size?_jsx(SquircleFill,{width:a.size.width,height:a.size.height,radius:r.radius.md,fill:fillFor(t),stroke:l?void 0:r.colors.border,strokeWidth:l?0:1,outset:l?0:1}):null,_jsx(Text,{style:[n.buttonText,l?n.buttonTextPrimary:n.buttonTextSecondary],numberOfLines:1,children:e.label})]})})})},EmptyState=forwardRef((e,t)=>{const r=useTheme(),i=Object.keys(r.components["empty-state"]);warnInvalidValue("EmptyState","size",e.size,i);const{icon:o,illustration:s,title:n,description:l,action:a,secondaryAction:c,size:d="md",fill:u=!1,style:m,testID:y}=e,p=i.includes(d)?d:"md",b=useMemo(()=>resolveEmptyStateSize(r,p),[r,p]),g=useMemo(()=>buildStyles(r),[r]);return _jsxs(View,{ref:t,accessibilityRole:"summary",testID:y,style:[g.root,{paddingVertical:b["padding-y"]},u?g.fill:null,m],children:[null!=s?_jsx(View,{style:{marginBottom:b["title-gap"]},children:isValidElement(s)?s:_jsx(Image,{source:s,style:{width:b["illustration-size"],height:b["illustration-size"]},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):o?_jsx(View,{style:[g.iconCircle,{width:b.icon,height:b.icon,marginBottom:b["title-gap"],borderRadius:r.radius.pill,...smoothCorners}],children:o}):null,_jsx(Text,{style:[g.title,{fontSize:b["title-text"],...fontFor(r,"semibold")}],children:n}),l?_jsx(Text,{style:[g.description,{fontSize:b["description-text"],marginTop:b["description-gap"]}],children:l}):null,a||c?_jsxs(View,{style:g.actions,children:[a?_jsx(ActionButton,{action:a,variant:"primary"}):null,c?_jsx(ActionButton,{action:c,variant:"secondary"}):null]}):null]})});EmptyState.displayName="EmptyState";const buildStyles=e=>StyleSheet.create({root:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},fill:{flexGrow:1},iconCircle:{backgroundColor:e.colors["surface-disabled"],alignItems:"center",justifyContent:"center"},title:{color:e.colors["text-body"],textAlign:"center"},description:{color:e.colors["text-muted"],textAlign:"center",maxWidth:320,lineHeight:e.text.base.size*e.leading.body},actions:{flexDirection:"row",alignItems:"center",gap:e.space.sm,marginTop:e.space.lg}}),buildActionStyles=e=>StyleSheet.create({button:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,minHeight:42,borderRadius:e.radius.md,...smoothCorners,overflow:"hidden",alignItems:"center",justifyContent:"center",flexDirection:"row"},buttonPrimary:{backgroundColor:e.colors.primary},buttonPrimaryPressed:{backgroundColor:e.colors["primary-hover"]},buttonSecondary:{backgroundColor:"transparent",borderWidth:1,borderColor:e.colors.border},buttonSecondaryPressed:{backgroundColor:e.colors["surface-pressed"]},buttonSquircleHost:{backgroundColor:"transparent",borderColor:"transparent",overflow:"visible"},buttonText:{fontSize:e.text.base.size,...fontFor(e,"semibold")},buttonTextPrimary:{color:e.colors["on-primary"]},buttonTextSecondary:{color:e.colors["text-body"]}});export{EmptyState};export default EmptyState;
1
+ "use strict";import{forwardRef,isValidElement,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,Text,View}from"react-native";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,resolveEmptyStateSize,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const ActionButton=({action:e,variant:t})=>{const r=useTheme(),{style:i,pressIn:o,pressOut:s}=usePressAnimation({enabled:!0}),n=useMemo(()=>buildActionStyles(r),[r]),l="primary"===t,a=useSquircle(!0,r.radius.md),fillFor=e=>l?e?r.colors["primary-hover"]:r.colors.primary:e?r.colors["surface-pressed"]:"transparent";return _jsx(Animated.View,{style:i,children:_jsx(Pressable,{onPress:()=>{triggerHaptic("selection"),e.onPress()},onPressIn:o,onPressOut:s,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityHint:e.accessibilityHint,testID:e.testID,onLayout:a.onLayout,style:({pressed:e})=>[n.button,l?n.buttonPrimary:n.buttonSecondary,e&&!a.active?l?n.buttonPrimaryPressed:n.buttonSecondaryPressed:null,a.active?n.buttonSquircleHost:null],children:({pressed:t})=>_jsxs(_Fragment,{children:[a.active&&a.size?_jsx(SquircleFill,{width:a.size.width,height:a.size.height,radius:r.radius.md,fill:fillFor(t),stroke:l?void 0:r.colors.border,strokeWidth:l?0:1}):null,_jsx(Text,{style:[n.buttonText,l?n.buttonTextPrimary:n.buttonTextSecondary],numberOfLines:1,children:e.label})]})})})},EmptyState=forwardRef((e,t)=>{const r=useTheme(),i=Object.keys(r.components["empty-state"]);warnInvalidValue("EmptyState","size",e.size,i);const{icon:o,illustration:s,title:n,description:l,action:a,secondaryAction:c,size:d="md",fill:u=!1,style:m,testID:y}=e,p=i.includes(d)?d:"md",b=useMemo(()=>resolveEmptyStateSize(r,p),[r,p]),g=useMemo(()=>buildStyles(r),[r]);return _jsxs(View,{ref:t,accessibilityRole:"summary",testID:y,style:[g.root,{paddingVertical:b["padding-y"]},u?g.fill:null,m],children:[null!=s?_jsx(View,{style:{marginBottom:b["title-gap"]},children:isValidElement(s)?s:_jsx(Image,{source:s,style:{width:b["illustration-size"],height:b["illustration-size"]},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):o?_jsx(View,{style:[g.iconCircle,{width:b.icon,height:b.icon,marginBottom:b["title-gap"],borderRadius:r.radius.pill,...smoothCorners}],children:o}):null,_jsx(Text,{style:[g.title,{fontSize:b["title-text"],...fontFor(r,"semibold")}],children:n}),l?_jsx(Text,{style:[g.description,{fontSize:b["description-text"],marginTop:b["description-gap"]}],children:l}):null,a||c?_jsxs(View,{style:g.actions,children:[a?_jsx(ActionButton,{action:a,variant:"primary"}):null,c?_jsx(ActionButton,{action:c,variant:"secondary"}):null]}):null]})});EmptyState.displayName="EmptyState";const buildStyles=e=>StyleSheet.create({root:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},fill:{flexGrow:1},iconCircle:{backgroundColor:e.colors["surface-disabled"],alignItems:"center",justifyContent:"center"},title:{color:e.colors["text-body"],textAlign:"center"},description:{color:e.colors["text-muted"],textAlign:"center",maxWidth:320,lineHeight:e.text.base.size*e.leading.body},actions:{flexDirection:"row",alignItems:"center",gap:e.space.sm,marginTop:e.space.lg}}),buildActionStyles=e=>StyleSheet.create({button:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,minHeight:42,borderRadius:e.radius.md,...smoothCorners,overflow:"hidden",alignItems:"center",justifyContent:"center",flexDirection:"row"},buttonPrimary:{backgroundColor:e.colors.primary},buttonPrimaryPressed:{backgroundColor:e.colors["primary-hover"]},buttonSecondary:{backgroundColor:"transparent",borderWidth:1,borderColor:e.colors.border},buttonSecondaryPressed:{backgroundColor:e.colors["surface-pressed"]},buttonSquircleHost:{backgroundColor:"transparent",borderColor:"transparent",overflow:"visible"},buttonText:{fontSize:e.text.base.size,...fontFor(e,"semibold")},buttonTextPrimary:{color:e.colors["on-primary"]},buttonTextSecondary:{color:e.colors["text-body"]}});export{EmptyState};export default EmptyState;