@webority/mobile-ui 0.16.3 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
- package/lib/commonjs/components/Card/Card.js +1 -1
- package/lib/commonjs/components/Carousel/Carousel.js +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/commonjs/components/ListItem/ListItem.js +1 -1
- package/lib/module/components/AppIcon/AppIcon.js +1 -1
- package/lib/module/components/Card/Card.js +1 -1
- package/lib/module/components/Carousel/Carousel.js +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +1 -1
- package/lib/module/components/ListItem/ListItem.js +1 -1
- package/lib/typescript/commonjs/components/Card/Card.d.ts +1 -1
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +1 -1
- package/lib/typescript/module/components/Card/Card.d.ts +1 -1
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppIcon=exports.APP_ICON_SIZES=void 0,Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _glyphsG.CURATED_ICON_NAMES}}),exports.ICONSAX_SUFFIX=void 0,Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _catalogG.ICON_NAMES}}),exports.resolveGlyph=exports.default=exports.buildIconXml=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNativeSvg=require("react-native-svg"),_index=require("../../theme/index.js"),_catalogG=require("./catalog.g.js"),_glyphsG=require("./glyphs.g.js"),_jsxRuntime=require("react/jsx-runtime");const ICONSAX_SUFFIX=exports.ICONSAX_SUFFIX="-iconsax",APP_ICON_SIZES=exports.APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36},tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppIcon=exports.APP_ICON_SIZES=void 0,Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _glyphsG.CURATED_ICON_NAMES}}),exports.ICONSAX_SUFFIX=void 0,Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _catalogG.ICON_NAMES}}),exports.resolveGlyph=exports.default=exports.buildIconXml=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNativeSvg=require("react-native-svg"),_index=require("../../theme/index.js"),_catalogG=require("./catalog.g.js"),_glyphsG=require("./glyphs.g.js"),_jsxRuntime=require("react/jsx-runtime");const ICONSAX_SUFFIX=exports.ICONSAX_SUFFIX="-iconsax",APP_ICON_SIZES=exports.APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36},tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",n=`${e}:${t}`,a=shardCache.get(n);if(void 0!==a)return a;const o=_catalogG.CATALOG_LOADERS[e]?.[t],l=o?tryRequire(o):null;return shardCache.set(n,l),l},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)},resolveGlyph=(e,r="linear")=>{if(e.endsWith(ICONSAX_SUFFIX)){const t=e.slice(0,-ICONSAX_SUFFIX.length);return t in _glyphsG.GLYPHS?resolveCatalogue(t,r):null}const t=_glyphsG.GLYPHS[e];return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};exports.resolveGlyph=resolveGlyph;const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;exports.buildIconXml=buildIconXml;const iconXmlCache=new Map,AppIcon=({name:e,size:r="md",color:t,variant:n="linear",style:a,accessibilityLabel:o,testID:l})=>{const s=(0,_index.useTheme)(),i="number"==typeof r?r:APP_ICON_SIZES[r],c=t??s.colors.text.primary,u=resolveGlyph(e,n),p=(0,_react.useMemo)(()=>{if(!u)return null;const r=`${e}|${n}|${i}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const a=buildIconXml(u,i,c);return iconXmlCache.set(r,a),a},[e,n,u,i,c]);return p?(0,_jsxRuntime.jsx)(_reactNativeSvg.SvgXml,{xml:p,width:i,height:i,style:a,accessible:null!=o,accessibilityLabel:o,accessibilityRole:null!=o?"image":void 0,testID:l}):(__DEV__&&!warned.has(e)&&(warned.add(e),_mobileCore.Logger.warn(`[AppIcon] Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run scripts/sync-icons.mjs after adding one there.`)),null)};exports.AppIcon=AppIcon,AppIcon.displayName="AppIcon";var _default=exports.default=AppIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Card=void 0;var _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"),_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("function"==typeof WeakMap)var i=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var s,a,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(s=t?r:i){if(s.has(e))return s.get(e);s.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((a=(s=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?s(o,t,a):o[t]=e[t]);return o})(e,t)}const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=exports.Card=(0,_react.forwardRef)((e,t)=>{const{children:i,variant:r="elevated",elevation:s="sm",radius:a="lg",padding:o="md",interactive:n=!1,bg:l,header:d,title:c,lead:u,action:x,headerActions:m,collapsible:h=!1,collapsed:_,defaultCollapsed:p=!1,onCollapsedChange:g,collapsedSummary:b,onRemove:y,removeLabel:j="Remove",separatorHeight:v=_reactNative.StyleSheet.hairlineWidth,footer:R,imageSource:f,imageHeight:S=160,imageAspectRatio:w,imageOverlay:C,loading:k=!1,gradient:A,onPress:q,haptic:N,contextMenu:T,accessibilityLabel:P,accessibilityHint:I,accessibilityRole:B,style:M,containerStyle:L,headerStyle:V,bodyStyle:H,footerStyle:F,borderRadius:W,testID:z,onLayout:O,...D}=e,U=(0,_index.useTheme)(),E=n||"function"==typeof q,G=(0,_useContextMenu.useContextMenu)(T,{haptic:N||!1,testID:z,accessibilityActions:D.accessibilityActions,onAccessibilityAction:D.onAccessibilityAction}),$=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,G.hostRef),[t,G.hostRef]),J=E||G.enabled,{style:K,pressIn:Q,pressOut:X}=(0,_usePressAnimation.usePressAnimation)({enabled:J}),Y=(0,_react.useMemo)(()=>buildStyles(U),[U]),Z=Boolean(f),ee=U.spacing[paddingMap[o]],te=(0,_react.useMemo)(()=>A?"string"==typeof A?U.gradients[A]??null:A:null,[A,U.gradients]),ie="flat"===r,re=ie?0:W??U.radius[a],se=resolveBackground(U,l),[ae,oe]=(0,_useControllableState.useControllableState)({value:_,defaultValue:p,onChange:g}),ne=h&&ae,le=hasBuiltInHeaderContent(e),de=Boolean(d)||le,ce=(0,_SquircleFill.useSquircle)(!Z&&!te&&!ie,re,O),ue=_reactNative.StyleSheet.flatten([M,L])??{},xe=ue.backgroundColor,me=ue.borderColor,he=xe??se??("filled"===r?U.colors.background.secondary:U.colors.background.elevated),pe="outlined"===r?U.colors.border.width:0,ge=me??U.colors.border.primary,be="elevated"===r&&(0,_shadows.supportsBoxShadow)()?(0,_shadows.toBoxShadow)(U.shadows[s]):void 0,ye=ce.active&&"elevated"===r&&!be,je=ce.active&&!ye?{backgroundColor:"transparent",borderColor:"transparent"}:null,ve=(0,_react.useMemo)(()=>{const e={borderRadius:ye&&ce.size?(0,_squircle.squircleHostRadius)(ce.size.width,ce.size.height,re):re,..._corners.smoothCorners,padding:Z?0:ee,overflow:ce.active?"visible":"hidden"};switch(r){case"flat":return{...e,backgroundColor:se??U.colors.background.elevated,borderBottomWidth:v,borderBottomColor:U.colors.border.primary};case"outlined":return{...e,backgroundColor:ce.active?"transparent":se??U.colors.background.elevated,borderWidth:U.colors.border.width,borderColor:ce.active?"transparent":U.colors.border.primary};case"filled":return{...e,backgroundColor:ce.active?"transparent":se??U.colors.background.secondary};default:return{...e,backgroundColor:se??U.colors.background.elevated,...be?{boxShadow:be}:U.shadows[s]}}},[U,r,s,re,Z,ee,ce.active,ce.size,be,ye,se,v]),Re=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:S},borderTopLeftRadius:re,borderTopRightRadius:re,borderBottomLeftRadius:0,borderBottomRightRadius:0,..._corners.smoothCorners}),[re,w,S]),fe="string"==typeof c?c:"",Se=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Y.titleColumn,children:["string"==typeof c?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:c}):c,u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:Y.lead,children:u}):null,ne&&b?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:Y.lead,children:b}):null]}),isCardTextAction(x)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:x,haptic:N}):x?(0,_jsxRuntime.jsx)(_reactNative.View,{style:Y.actionNode,children:x}):null,m,h?(0,_jsxRuntime.jsx)(CardIconAction,{icon:ne?"chevron-down":"chevron-up",label:`${ne?"Show":"Hide"} ${fe}`.trim(),expanded:!ne,onPress:()=>oe(!ne),haptic:N}):null,y?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:j,onPress:y,color:U.colors.toneText.error,haptic:N}):null]}),we=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[de?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Y.header,!d&&Y.headerRow,ne&&Y.headerFolded,V],children:d??Se}):null,ne?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[de||R?Y.body:null,H],children:i}),R&&!ne?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Y.footer,F],children:R}):null]}),Ce=Z?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Y.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:f,resizeMode:"cover",style:Re,accessibilityLabel:"",accessible:!1}),C?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:Y.imageOverlay,children:C}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:ee},children:we})]}):we,ke=te?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:te,style:_reactNative.StyleSheet.absoluteFill}),Ce]}):ce.active&&ce.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ce.size.width,height:ce.size.height,radius:re,fill:he,stroke:pe?ge:void 0,strokeWidth:pe,outset:pe}),Ce]}):Ce;let Ae;if(J){const handlePress=e=>{E&&(N&&(0,_hapticUtils.triggerHaptic)(N),q?.(e))};Ae=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:K,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:$,onPress:handlePress,onPressIn:Q,onPressOut:X,android_ripple:{color:U.colors.surface.pressed,borderless:!1},accessibilityRole:B??(E?"button":void 0),accessibilityLabel:P,accessibilityHint:I,testID:z,onLayout:ce.onLayout,style:[ve,M,L,je],...D,...G.hostProps,children:ke})})}else Ae=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:P,accessibilityHint:I,accessibilityRole:B,testID:z,onLayout:ce.onLayout,style:[ve,M,L,je],...D,children:ke});return k?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):G.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Ae,G.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[ve,M,L,je,Y.preview],children:ke}))]}):Ae});Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:i="lg",padding:r="md",bg:s,header:a,footer:o,imageSource:n,imageHeight:l=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:x,bodyStyle:m,footerStyle:h,style:_,...p})=>{const g=(0,_index.useTheme)(),b=paddingMap[r],y=g.spacing[b],j="flat"===e?0:c??g.radius[i],v=void 0!==a||hasBuiltInHeaderContent(p),R=resolveBackground(g,s)??g.colors.background.elevated,f="outlined"===e?1:0,S="outlined"===e?g.colors.border.primary:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:R,borderRadius:j,..._corners.smoothCorners,borderWidth:f,borderColor:S,overflow:"hidden"},u,_],accessibilityRole:"progressbar",accessibilityLabel:"Loading",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==n?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:y,paddingBottom:g.spacing.sm},x],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:y},m],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:14,lastLineWidth:"55%"})}),void 0!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:y,paddingTop:g.spacing.sm,flexDirection:"row"},h],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:r,color:s,haptic:a})=>{const o=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===r?void 0:{expanded:r},"aria-expanded":r,onPress:()=>{a&&(0,_hapticUtils.triggerHaptic)(a),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:s??o.colors.text.primary})})},CardTextActionButton=({action:e,haptic:t})=>{const i=(0,_index.useTheme)();return(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:i.colors.primary,children:e.label})})},iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},resolveBackground=(e,t)=>{if(null==t)return;return e.colors.background[t]??t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.spacing.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.spacing.sm},headerFolded:{marginBottom:0},titleColumn:{flex:1},lead:{marginTop:e.spacing.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.spacing.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},preview:{margin:0,marginTop:0,marginBottom:0,marginLeft:0,marginRight:0,marginStart:0,marginEnd:0,marginHorizontal:0,marginVertical:0,position:"relative",top:0,left:0,width:"100%",height:"100%"}});var _default=exports.default=Card;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Card=void 0;var _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"),_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("function"==typeof WeakMap)var i=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var s,a,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(s=t?r:i){if(s.has(e))return s.get(e);s.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((a=(s=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?s(o,t,a):o[t]=e[t]);return o})(e,t)}const 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:r="elevated",elevation:s="sm",radius:a="lg",padding:o="md",interactive:n=!1,bg:l,header:d,title:c,lead:u,action:m,headerActions:x,collapsible:h=!1,collapsed:_,defaultCollapsed:p=!1,onCollapsedChange:g,collapsedSummary:b,onRemove:y,removeLabel:j="Remove",separatorHeight:v=_reactNative.StyleSheet.hairlineWidth,footer:R,imageSource:f,imageHeight:S=160,imageAspectRatio:w,imageOverlay:C,loading:k=!1,gradient:A,onPress:q,haptic:N,contextMenu:T,accessibilityLabel:P,accessibilityHint:I,accessibilityRole:B,style:M,containerStyle:L,headerStyle:V,bodyStyle:H,footerStyle:F,borderRadius:W,testID:z,onLayout:O,...D}=e,U=(0,_index.useTheme)(),E=n||"function"==typeof q,G=(0,_useContextMenu.useContextMenu)(T,{haptic:N||!1,testID:z,accessibilityActions:D.accessibilityActions,onAccessibilityAction:D.onAccessibilityAction}),$=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,G.hostRef),[t,G.hostRef]),J=E||G.enabled,{style:K,pressIn:Q,pressOut:X}=(0,_usePressAnimation.usePressAnimation)({enabled:J}),Y=(0,_react.useMemo)(()=>buildStyles(U),[U]),Z=Boolean(f),ee=U.spacing[paddingMap[o]],te=(0,_react.useMemo)(()=>A?"string"==typeof A?U.gradients[A]??null:A:null,[A,U.gradients]),ie="flat"===r,re=ie?0:W??U.radius[a],se=resolveBackground(U,l),[ae,oe]=(0,_useControllableState.useControllableState)({value:_,defaultValue:p,onChange:g}),ne=h&&ae,le=hasBuiltInHeaderContent(e),de=Boolean(d)||le,ce=(0,_SquircleFill.useSquircle)(!Z&&!te&&!ie,re,O),ue=_reactNative.StyleSheet.flatten([M,L])??{},me=ue.backgroundColor,xe=ue.borderColor,he=me??se??("filled"===r?U.colors.background.secondary:U.colors.background.elevated),pe="outlined"===r?U.colors.border.width:0,ge=xe??U.colors.border.primary,be="elevated"===r&&(0,_shadows.supportsBoxShadow)()?(0,_shadows.toBoxShadow)(U.shadows[s]):void 0,ye=ce.active&&"elevated"===r&&!be,je=ce.active&&!ye?{backgroundColor:"transparent",borderColor:"transparent"}:null,ve=(0,_react.useMemo)(()=>{const e={borderRadius:ye&&ce.size?(0,_squircle.squircleHostRadius)(ce.size.width,ce.size.height,re):re,..._corners.smoothCorners,padding:Z?0:ee,overflow:ce.active?"visible":"hidden"};switch(r){case"flat":return{...e,backgroundColor:se??U.colors.background.elevated,borderBottomWidth:v,borderBottomColor:U.colors.border.primary};case"outlined":return{...e,backgroundColor:ce.active?"transparent":se??U.colors.background.elevated,borderWidth:U.colors.border.width,borderColor:ce.active?"transparent":U.colors.border.primary};case"filled":return{...e,backgroundColor:ce.active?"transparent":se??U.colors.background.secondary};default:return{...e,backgroundColor:se??U.colors.background.elevated,...be?{boxShadow:be}:U.shadows[s]}}},[U,r,s,re,Z,ee,ce.active,ce.size,be,ye,se,v]),Re=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:S},borderTopLeftRadius:re,borderTopRightRadius:re,borderBottomLeftRadius:0,borderBottomRightRadius:0,..._corners.smoothCorners}),[re,w,S]),fe="string"==typeof c?c:"",Se=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Y.titleColumn,children:["string"==typeof c?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:c}):c,u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:Y.lead,children:u}):null,ne&&b?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:Y.lead,children:b}):null]}),isCardTextAction(m)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:m,haptic:N}):m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:Y.actionNode,children:m}):null,x,h?(0,_jsxRuntime.jsx)(CardIconAction,{icon:ne?"chevron-down":"chevron-up",label:`${ne?"Show":"Hide"} ${fe}`.trim(),expanded:!ne,onPress:()=>oe(!ne),haptic:N}):null,y?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:j,onPress:y,color:U.colors.toneText.error,haptic:N}):null]}),we=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[de?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Y.header,!d&&Y.headerRow,ne&&Y.headerFolded,V],children:d??Se}):null,ne?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[de||R?Y.body:null,H],children:i}),R&&!ne?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Y.footer,F],children:R}):null]}),Ce=Z?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:Y.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:f,resizeMode:"cover",style:Re,accessibilityLabel:"",accessible:!1}),C?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:Y.imageOverlay,children:C}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:ee},children:we})]}):we,ke=te?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:te,style:_reactNative.StyleSheet.absoluteFill}),Ce]}):ce.active&&ce.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ce.size.width,height:ce.size.height,radius:re,fill:he,stroke:pe?ge:void 0,strokeWidth:pe,outset:pe}),Ce]}):Ce;let Ae;if(J){const handlePress=e=>{E&&(N&&(0,_hapticUtils.triggerHaptic)(N),q?.(e))};Ae=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:K,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:$,onPress:handlePress,onPressIn:Q,onPressOut:X,android_ripple:{color:U.colors.surface.pressed,borderless:!1},accessibilityRole:B??(E?"button":void 0),accessibilityLabel:P,accessibilityHint:I,testID:z,onLayout:ce.onLayout,style:[ve,M,L,je],...D,...G.hostProps,children:ke})})}else Ae=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:P,accessibilityHint:I,accessibilityRole:B,testID:z,onLayout:ce.onLayout,style:[ve,M,L,je],...D,children:ke});return k?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):G.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Ae,G.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[ve,M,L,je,Y.preview],children:ke}))]}):Ae}));Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:i="lg",padding:r="md",bg:s,header:a,footer:o,imageSource:n,imageHeight:l=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:m,bodyStyle:x,footerStyle:h,style:_,...p})=>{const g=(0,_index.useTheme)(),b=paddingMap[r],y=g.spacing[b],j="flat"===e?0:c??g.radius[i],v=void 0!==a||hasBuiltInHeaderContent(p),R=resolveBackground(g,s)??g.colors.background.elevated,f="outlined"===e?1:0,S="outlined"===e?g.colors.border.primary:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:R,borderRadius:j,..._corners.smoothCorners,borderWidth:f,borderColor:S,overflow:"hidden"},u,_],accessibilityRole:"progressbar",accessibilityLabel:"Loading",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==n?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:y,paddingBottom:g.spacing.sm},m],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:y},x],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:14,lastLineWidth:"55%"})}),void 0!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:y,paddingTop:g.spacing.sm,flexDirection:"row"},h],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:r,color:s,haptic:a})=>{const o=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===r?void 0:{expanded:r},"aria-expanded":r,onPress:()=>{a&&(0,_hapticUtils.triggerHaptic)(a),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:s??o.colors.text.primary})})},CardTextActionButton=({action:e,haptic:t})=>{const i=(0,_index.useTheme)();return(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:i.colors.primary,children:e.label})})},iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},resolveBackground=(e,t)=>{if(null==t)return;return e.colors.background[t]??t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.spacing.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.spacing.sm},headerFolded:{marginBottom:0},titleColumn:{flex:1},lead:{marginTop:e.spacing.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.spacing.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},preview:{margin:0,marginTop:0,marginBottom:0,marginLeft:0,marginRight:0,marginStart:0,marginEnd:0,marginHorizontal:0,marginVertical:0,position:"relative",top:0,left:0,width:"100%",height:"100%"}});var _default=exports.default=Card;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Carousel=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Skeleton/index.js"),_jsxRuntime=require("react/jsx-runtime");const CarouselInner=(0,_react.forwardRef)((e,t)=>{const{data:n,renderItem:r,keyExtractor:a,index:i,defaultIndex:s=0,onIndexChange:l,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:x="screen",spacing:g=0,containerStyle:_,accessibilityLabel:y,testID:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Carousel=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index3=require("../Skeleton/index.js"),_jsxRuntime=require("react/jsx-runtime");const CarouselInner=(0,_react.forwardRef)((e,t)=>{const{data:n,renderItem:r,keyExtractor:a,index:i,defaultIndex:s=0,onIndexChange:l,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:x="screen",spacing:g=0,containerStyle:_,accessibilityLabel:y,testID:p,showThumbnails:b=!1,haptic:f,renderThumbnail:S,loading:v=!1}=e,j=(0,_index.useTheme)(),R="number"==typeof i,w=d||c,[C,k]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),I="screen"===x?C:x,N=I+g,T=(0,_react.useRef)(null),A=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,E=clamp(R?i:s,0,Math.max(0,n.length-1)),[V,z]=(0,_react.useState)(E),H=(0,_react.useRef)(null),M=(0,_react.useRef)(null),P=(0,_react.useRef)(!1),W=(0,_react.useRef)(V);W.current=V;const D=(0,_react.useCallback)(e=>{const t=clamp(e,0,Math.max(0,n.length-1));z(e=>e===t?e:(l?.(t),t))},[n.length,l]),$=(0,_react.useCallback)((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);T.current?.scrollToOffset({offset:r*N,animated:t}),D(r)},[n.length,N,D]),L=(0,_react.useCallback)(()=>{if(0===n.length)return;const e=W.current+1;e>=n.length?w&&$(0,!1):$(e,!0)},[n.length,w,$]),q=(0,_react.useCallback)(()=>{if(0===n.length)return;const e=W.current-1;e<0?w&&$(n.length-1,!1):$(e,!0)},[n.length,w,$]);(0,_react.useImperativeHandle)(t,()=>({scrollTo:$,next:L,prev:q}),[$,L,q]),(0,_react.useEffect)(()=>{R&&i!==V&&$(i,!0)},[i]);const O=(0,_react.useCallback)(()=>{H.current&&(clearInterval(H.current),H.current=null)},[]),F=(0,_react.useCallback)(()=>{!c||n.length<=1||(O(),H.current=setInterval(()=>{if(P.current)return;const e=W.current+1;e>=n.length?$(0,!1):$(e,!0)},u))},[c,u,n.length,$,O]);(0,_react.useEffect)(()=>(F(),()=>{O(),M.current&&clearTimeout(M.current)}),[F,O]),(0,_react.useEffect)(()=>{const e=_reactNative.AppState.addEventListener("change",e=>{"active"!==e?(O(),M.current&&(clearTimeout(M.current),M.current=null)):F()});return()=>e.remove()},[F,O]);const X=m&&n.length>1&&"numbers"!==h||void 0!==o,B=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{x:A}}}],{useNativeDriver:!1,listener:o?e=>o(e.nativeEvent.contentOffset.x):void 0}),[A,o]),G=(0,_react.useCallback)(e=>{if(N<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/N);D(n)},[N,D]),J=(0,_react.useCallback)(()=>{P.current=!0,O(),M.current&&(clearTimeout(M.current),M.current=null)},[O]),K=(0,_react.useCallback)(()=>{P.current=!1,c&&(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{F()},1e3))},[c,F]),Q=(0,_react.useCallback)(e=>{switch(e.nativeEvent.actionName){case"increment":L();break;case"decrement":q()}},[L,q]),U=(0,_react.useMemo)(()=>buildStyles(j),[j]),Y=(0,_react.useCallback)(({item:e,index:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:I,marginRight:t===n.length-1?0:g},accessibilityElementsHidden:t!==V,importantForAccessibility:t===V?"yes":"no-hide-descendants",children:r(e,t)}),[r,I,g,n.length,V]),Z=(0,_react.useCallback)((e,t)=>String(t),[]),ee=(0,_react.useCallback)((e,t)=>({length:N,offset:N*t,index:t}),[N]);return v?(0,_jsxRuntime.jsx)(CarouselSkeleton,{...e,containerWidth:C}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[U.container,_],onLayout:e=>k(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:y??"Carousel",accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:V,text:`Slide ${V+1} of ${n.length}`},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:p,children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:T,data:n,keyExtractor:a??Z,renderItem:Y,horizontal:!0,pagingEnabled:"screen"===x&&0===g,snapToInterval:N,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:X?B:void 0,scrollEventThrottle:X?16:void 0,onMomentumScrollEnd:G,onScrollBeginDrag:J,onScrollEndDrag:K,getItemLayout:ee,initialScrollIndex:E,bounces:!1}),m&&n.length>1?(0,_jsxRuntime.jsx)(Pagination,{count:n.length,currentIndex:V,scrollX:A,slideStride:N,variant:h,theme:j}):null,b&&n.length>0?(0,_jsxRuntime.jsx)(ThumbnailStrip,{data:n,currentIndex:V,renderThumbnail:S,onSelect:e=>{const t=(0,_index2.resolveHaptic)(f,"selection");t&&(0,_index2.triggerHaptic)(t),$(e,!0)},theme:j}):null]})});CarouselInner.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:a})=>{const i="screen"===e?a||320:e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[carouselSkeletonStyles.container,r],children:[(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:i,height:160,radius:"md"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:12}],children:Array.from({length:3}).map((e,t)=>"numbers"===n?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:24,height:16,radius:"sm",style:{marginHorizontal:4}},`sk-pg-${t}`):"bars"===n?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:20,height:4,radius:2,style:{marginHorizontal:3}},`sk-pg-${t}`):(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:8,height:8,style:{marginHorizontal:4}},`sk-pg-${t}`))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const carouselSkeletonStyles=_reactNative.StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=exports.Carousel=CarouselInner;Carousel.Skeleton=CarouselSkeleton;const Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:a,theme:i})=>{if("numbers"===a)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:paginationStyles.numbersWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[paginationStyles.numbersText,{color:i.colors.text.secondary,fontSize:i.typography.fontSize.sm,fontWeight:i.typography.fontWeight.medium}],accessibilityLabel:`Slide ${t+1} of ${e}`,children:`${t+1} / ${e}`})});const s=Array.from({length:e},(e,t)=>t),l="bars"===a,o=l?24:6,c=l?36:16,u=l?3:6;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:paginationStyles.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:s.map(e=>{const a=[(e-1)*r,e*r,(e+1)*r],s=n.interpolate({inputRange:a,outputRange:[o,c,o],extrapolate:"clamp"}),l=n.interpolate({inputRange:a,outputRange:[.5,1,.5],extrapolate:"clamp"});return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[{width:s,height:u,marginHorizontal:4,borderRadius:u/2,..._corners.smoothCorners,backgroundColor:e===t?i.colors.primary:i.colors.border.primary,opacity:l}]},e)})})},ThumbnailStrip=({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:a})=>(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:thumbStyles.row,accessibilityRole:"tablist",children:e.map((e,i)=>(0,_jsxRuntime.jsx)(ThumbnailItem,{item:e,index:i,isActive:i===t,renderThumbnail:n,onPress:()=>r(i),theme:a},i))}),ThumbnailItem=({item:e,index:t,isActive:n,renderThumbnail:r,onPress:a,theme:i})=>{const s=(0,_react.useRef)((0,_index.createAnimatedValue)(n?1.1:1)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(s,{toValue:n?1.1:1,useNativeDriver:!0,friction:6,tension:80});return e.start(),()=>e.stop()},[n,s]);const l=(0,_react.useMemo)(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:e.uri},style:thumbStyles.image,resizeMode:"cover"}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[thumbStyles.placeholder,{backgroundColor:i.colors.background.secondary}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:i.colors.text.secondary,fontSize:i.typography.fontSize.xs,fontWeight:i.typography.fontWeight.semibold},children:t+1})}),[e,t,r,i]);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:a,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:`Go to slide ${t+1}`,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[thumbStyles.thumb,{borderColor:n?i.colors.primary:"transparent",transform:[{scale:s}]}],children:l})})},thumbStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:8,paddingVertical:8},thumb:{width:40,height:40,marginHorizontal:4,borderRadius:6,..._corners.smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"}}),paginationStyles=_reactNative.StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:12},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:12},numbersText:{textAlign:"center"}});var _default=exports.default=Carousel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DatePicker=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../PickerTrigger/index.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const AnimatedGestureRoot=_reactNative.Animated.createAnimatedComponent(_reactNativeGestureHandler.GestureHandlerRootView),transparentOf=e=>{const t=e.match(/^rgba?\(([^)]+)\)$/);if(!t)return"transparent";const[a,r,i]=t[1].split(",").map(e=>e.trim());return`rgba(${a}, ${r}, ${i}, 0)`},GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),isSameDay=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),toIso=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,addMonths=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),buildMonthMatrix=(e,t)=>{const a=e.getFullYear(),r=e.getMonth(),i=(new Date(a,r,1).getDay()-t+7)%7,n=[];for(let e=0;e<42;e+=1){const t=new Date(a,r,1-i+e);n.push({date:t,inMonth:t.getMonth()===r,iso:toIso(t)})}return n},weekdayLabels=(e,t)=>{const a=new Intl.DateTimeFormat(e,{weekday:"short"}),r=[];for(let e=0;e<7;e+=1){const i=new Date(1970,0,4+(t+e)%7);r.push(a.format(i))}return r},formatMonthYear=(e,t)=>new Intl.DateTimeFormat(t,{month:"long",year:"numeric"}).format(e),formatLongDate=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(e),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:i,maxDate:n,disabledDates:s,mode:o="modal",locale:l="en-IN",weekStartsOn:c=0,title:d="Select Date",confirmLabel:u="Confirm",cancelLabel:m="Cancel",style:g,containerStyle:y,headerLabelStyle:_,navButtonStyle:p,footerButtonStyle:x,haptic:h,testID:v,label:b,placeholder:f,helperText:j,error:N,required:R,disabled:D,size:w,variant:C,clearable:S,onClear:k,formatValue:P,triggerStyle:A}=e,T=void 0!==e.visible,[M,V]=(0,_react.useState)(!1),I=T?e.visible:M,F=T?v:v?`${v}-calendar`:void 0,L=(0,_index.useTheme)(),B=(0,_usePresenceMotion.usePresenceMotion)(),[Y,$]=(0,_ModalSafeArea.useModalInsets)(),z=(0,_react.useMemo)(()=>buildStyles(L),[L]),[H,W]=(0,_react.useState)(()=>startOfDay(new Date));(0,_react.useEffect)(()=>{I&&W(startOfDay(new Date))},[I]);const q=t?startOfDay(t):H,[E,O]=(0,_react.useState)(q),[G,X]=(0,_react.useState)(t?startOfDay(t):null),[Z,J]=(0,_react.useState)("days"),K=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,U=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,ee=(0,_react.useRef)(0),te=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,ae=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,re=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,ie=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,ne=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,se=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(t){const e=startOfDay(t);X(e),O(e)}else X(null)},[t]);const oe=(0,_react.useMemo)(()=>{const e=new Set;return s?.forEach(t=>e.add(toIso(startOfDay(t)))),e},[s]),le=(0,_react.useMemo)(()=>i?startOfDay(i):null,[i]),ce=(0,_react.useMemo)(()=>n?startOfDay(n):null,[n]),de=(0,_react.useCallback)(e=>!!(le&&e.getTime()<le.getTime())||(!!(ce&&e.getTime()>ce.getTime())||!!oe.has(toIso(e))),[le,ce,oe]),ue=(0,_react.useMemo)(()=>buildMonthMatrix(E,c),[E,c]),me=(0,_react.useMemo)(()=>buildYearCells(E.getFullYear()),[E]),ge=(0,_react.useMemo)(()=>buildDecadeCells(E.getFullYear()),[E]),ye=(0,_react.useMemo)(()=>weekdayLabels(l,c),[l,c]),pe=(0,_react.useMemo)(()=>{if("days"===Z)return formatMonthYear(E,l);if("years"===Z){return`${me[0]} - ${me[me.length-1]}`}return`${ge[0]} - ${ge[ge.length-1]+9}`},[E,ge,l,Z,me]),xe=(0,_react.useCallback)(e=>!!(le&&e<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),he=(0,_react.useCallback)(e=>!!(le&&e+10-1<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),ve=(0,_react.useCallback)(e=>{!1!==h&&(0,_index2.triggerHaptic)("impactLight");const t=e>0?1:-1,a=L.components.datePicker?.monthSlideDistance??32,r=L.components.datePicker?.monthSlideOutDuration??L.motion.duration.fast??140,i=L.components.datePicker?.monthSlideInDuration??L.motion.duration.fast??160,[n]=B.range(-t*a,0),[s]=B.range(t*a,0),o=B.reduced?B.duration("fast"):r,c=B.reduced?B.duration("fast"):i;_reactNative.Animated.sequence([_reactNative.Animated.parallel([_reactNative.Animated.timing(te,{toValue:n,duration:r,easing:_reactNative.Easing.out(_reactNative.Easing.quad),useNativeDriver:!0}),_reactNative.Animated.timing(ae,{toValue:0,duration:o,useNativeDriver:!0})]),_reactNative.Animated.timing(te,{toValue:s,duration:0,useNativeDriver:!0}),_reactNative.Animated.parallel([_reactNative.Animated.timing(te,{toValue:0,duration:i,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0}),_reactNative.Animated.timing(ae,{toValue:1,duration:c,useNativeDriver:!0})])]).start();const d=addMonths(E,e);O(d),_reactNative.AccessibilityInfo.announceForAccessibility(formatMonthYear(d,l))},[E,h,l,ae,te,B,L.components.datePicker,L.motion.duration.fast]),be=(0,_react.useCallback)(()=>{"days"!==Z?(!1!==h&&(0,_index2.triggerHaptic)("impactLight"),O("years"===Z?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))):ve(-1)},[ve,Z,h]),fe=(0,_react.useCallback)(()=>{"days"!==Z?(!1!==h&&(0,_index2.triggerHaptic)("impactLight"),O("years"===Z?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))):ve(1)},[ve,Z,h]),je=(0,_react.useCallback)(()=>{const[e]=B.range(.9,1),t=B.reduced?B.duration("normal"):L.components.datePicker?.viewTransitionDuration??L.motion.duration.normal??200;(0,_index.setNativeValue)(ie,0),(0,_index.setNativeValue)(ne,e),_reactNative.Animated.parallel([_reactNative.Animated.timing(ie,{toValue:1,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0}),_reactNative.Animated.timing(ne,{toValue:1,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0})]).start()},[ie,ne,B,L.components.datePicker,L.motion.duration.normal]),Ne=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(h,"selection");if(e&&(0,_index2.triggerHaptic)(e),!B.reduced){const e=L.components.datePicker?.headerPressDuration??80,t=L.components.datePicker?.headerReleaseDuration??100;_reactNative.Animated.sequence([_reactNative.Animated.timing(se,{toValue:.96,duration:e,useNativeDriver:!0}),_reactNative.Animated.timing(se,{toValue:1,duration:t,useNativeDriver:!0})]).start()}J(e=>"days"===e?"years":"years"===e?"decades":"years"),je()},[je,se,h,B.reduced,L.components.datePicker]),Re=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(h,"selection");t&&(0,_index2.triggerHaptic)(t),O(t=>new Date(e,t.getMonth(),1)),J("days"),je()},[je,h]),De=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(h,"selection");t&&(0,_index2.triggerHaptic)(t),O(t=>new Date(e+4,t.getMonth(),1)),J("years"),je()},[je,h]),we=(0,_react.useCallback)(e=>{if(de(e.date))return;const t=(0,_index2.resolveHaptic)(h,"selection");t&&(0,_index2.triggerHaptic)(t),X(e.date),e.inMonth||O(new Date(e.date.getFullYear(),e.date.getMonth(),1)),B.reduced||((0,_index.setNativeValue)(re,.7),_reactNative.Animated.spring(re,{toValue:1,damping:L.motion.spring.bouncy.damping,stiffness:L.motion.spring.bouncy.stiffness,mass:L.motion.spring.bouncy.mass,useNativeDriver:!0}).start())},[de,B.reduced,re,L.motion.spring.bouncy,h]),Ce=(0,_react.useCallback)(()=>{T||V(!1),r?.()},[T,r]),Se=(0,_react.useCallback)(()=>{"modal"===o?_reactNative.Animated.parallel([_reactNative.Animated.timing(K,{toValue:0,duration:B.duration("normal"),easing:_reactNative.Easing.bezier(...L.motion.easing.accelerate),useNativeDriver:!1}),_reactNative.Animated.timing(Q,{toValue:0,duration:B.duration("fast"),easing:_reactNative.Easing.bezier(...L.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>{Ce()}):Ce()},[K,o,Ce,B,Q,L.motion.easing.accelerate]),{handleGesture:ke,opacity:Pe}=(0,_useDragToDismiss.useDragToDismiss)({drag:U,travel:()=>ee.current||320,onDismiss:Se}),Ae=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(Q,Pe),[Q,Pe]),Te=(0,_react.useMemo)(()=>K.interpolate({inputRange:[0,1],outputRange:[transparentOf(L.colors.background.overlay),L.colors.background.overlay]}),[K,L.colors.background.overlay]);(0,_react.useEffect)(()=>{if("modal"===o&&I){K.setValue(0),(0,_index.setNativeValue)(Q,0),(0,_index.setNativeValue)(U,0),(0,_index.setNativeValue)(Pe,1);const e=B.reduced?_reactNative.Animated.timing(Q,{toValue:1,duration:B.duration("normal"),useNativeDriver:!0}):_reactNative.Animated.spring(Q,{toValue:1,damping:L.motion.spring.gentle.damping,stiffness:L.motion.spring.gentle.stiffness,mass:L.motion.spring.gentle.mass,useNativeDriver:!0}),t=_reactNative.Animated.parallel([_reactNative.Animated.timing(K,{toValue:1,duration:B.duration("normal"),easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!1}),e]);return t.start(),()=>t.stop()}},[I,o,K,B,Q,U,Pe,L.motion]);const Me=(0,_react.useCallback)(()=>{!1!==h&&(0,_index2.triggerHaptic)("selection"),Se()},[Se,h]),Ve=(0,_react.useCallback)(()=>{G&&(!1!==h&&(0,_index2.triggerHaptic)("notificationSuccess"),a?.(G),Se())},[Se,a,G,h]),Ie=Q.interpolate({inputRange:[0,1],outputRange:B.range(320,0)}),Fe=(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.titleRow,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:z.title,accessibilityRole:"header",children:d})}),Le=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[z.card,g,y],accessibilityRole:"modal"===o?void 0:"none",accessible:!1,testID:F,children:["modal"===o?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ke,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:z.grabArea,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.handle}),Fe]})}):Fe,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:z.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:be,style:({pressed:e})=>[z.navBtn,e&&z.navBtnPressed,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Previous month":"years"===Z?"Previous years":"Previous decades",hitSlop:8,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:z.navText,children:"‹"})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ne,style:[z.headerLabelWrap,_],accessibilityRole:"button",accessibilityLabel:"days"===Z?`${pe}, switch to year selection`:"years"===Z?`${pe}, switch to decade selection`:`${pe}, switch to year selection`,hitSlop:8,children:(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[z.headerLabelInner,{transform:[{scale:se}],opacity:"days"===Z?ae:1}],children:[(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[z.headerLabel,{transform:[{translateX:"days"===Z?te:0}]}],accessibilityLiveRegion:"polite",children:pe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.headerCaret,children:(L.icons?.chevronDown??_defaultIcons.defaultIcons.chevronDown)({size:L.typography.fontSize.sm,color:L.colors.text.secondary})})]})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:fe,style:({pressed:e})=>[z.navBtn,e&&z.navBtnPressed,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Next month":"years"===Z?"Next years":"Next decades",hitSlop:8,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:z.navText,children:"›"})})]}),"days"===Z?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.weekdayRow,children:ye.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.weekdayCell,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:z.weekdayText,children:e})},`${e}-${t}`))}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.grid,{opacity:ae,transform:[{translateX:te}]}],children:Array.from({length:6}).map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.gridRow,children:ue.slice(7*t,7*t+7).map(e=>{const t=de(e.date),a=!!G&&isSameDay(e.date,G),r=isSameDay(e.date,H),i=a?L.colors.primary:"transparent",n=r&&!a?L.colors.primary:"transparent",s=a?L.colors.onPrimary:e.inMonth?t?L.colors.text.disabled:L.colors.text.primary:L.colors.text.tertiary,o=t?.3:e.inMonth?1:.4;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:t,onPress:()=>we(e),accessibilityRole:"button",accessibilityLabel:formatLongDate(e.date,l),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:z.dayCell,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.dayInner,{backgroundColor:i,borderColor:n,borderWidth:r&&!a?1.5:0,opacity:o},a?{transform:[{scale:re}]}:null],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.dayText,{color:s}],children:e.date.getDate()})})},e.iso)})},`r-${t}`))})]}):"years"===Z?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.yearGrid,{opacity:ie,transform:[{scale:ne}]}],children:Array.from({length:3}).map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.gridRow,children:me.slice(4*t,4*t+4).map(e=>{const t=xe(e),a=!!G&&G.getFullYear()===e,r=H.getFullYear()===e,i=a?L.colors.primary:"transparent",n=r&&!a?L.colors.primary:"transparent",s=a?L.colors.onPrimary:t?L.colors.text.disabled:L.colors.text.primary,o=t?.3:1;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:t,onPress:()=>Re(e),accessibilityRole:"button",accessibilityLabel:`Year ${e}`,accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:z.yearCell,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[z.yearInner,{backgroundColor:i,borderColor:n,borderWidth:r&&!a?1.5:0,opacity:o}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.yearText,{color:s}],children:e})})},`year-${e}`)})},`yr-${t}`))}):(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.yearGrid,{opacity:ie,transform:[{scale:ne}]}],children:Array.from({length:3}).map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.gridRow,children:ge.slice(4*t,4*t+4).map(e=>{const t=e+10-1,a=he(e),r=!!G&&decadeStartFor(G.getFullYear())===e,i=decadeStartFor(H.getFullYear())===e,n=r?L.colors.primary:"transparent",s=i&&!r?L.colors.primary:"transparent",o=r?L.colors.onPrimary:a?L.colors.text.disabled:L.colors.text.primary,l=a?.3:1;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:a,onPress:()=>De(e),accessibilityRole:"button",accessibilityLabel:`Decade ${e} to ${t}`,accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:z.yearCell,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[z.yearInner,{backgroundColor:n,borderColor:s,borderWidth:i&&!r?1.5:0,opacity:l}],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.yearText,{color:o}],children:`${e}s`}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.decadeRangeText,{color:r?L.colors.onPrimary:L.colors.text.tertiary}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${t}`))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:z.footer,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Me,style:({pressed:e})=>[z.footerBtn,z.footerCancel,e&&z.footerBtnPressed,x],accessibilityRole:"button",accessibilityLabel:m,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.footerBtnText,{color:L.colors.text.secondary}],children:m})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ve,disabled:!G,style:({pressed:e})=>[z.footerBtn,z.footerConfirm,{backgroundColor:L.colors.primary,opacity:G?1:.5},e&&{backgroundColor:L.colors.primaryHover},x],accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{disabled:!G},"aria-disabled":!G,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.footerBtnText,{color:L.colors.onPrimary}],children:u})})]})]}),Be=t?(P??(e=>e.toLocaleDateString()))(t):void 0,Ye=!T;if("inline"===o)return I||Ye?Ye?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index3.PickerTrigger,{label:b,value:Be,placeholder:f,helperText:j,error:N,required:R,disabled:D,size:w,variant:C,clearable:S,onClear:k,onPress:()=>V(!0),triggerStyle:A,testID:v}),I?Le:null]}):Le:null;const $e=(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:I,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Se,children:(0,_jsxRuntime.jsx)(_ModalSafeArea.ModalSafeArea,{onInsets:$,children:(0,_jsxRuntime.jsxs)(AnimatedGestureRoot,{collapsable:!1,style:[z.backdrop,{backgroundColor:Te}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:Se,accessibilityLabel:"Dismiss"}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.sheetWrap,{paddingBottom:Math.max(Y.bottom,L.spacing.lg),opacity:Ae,transform:[{translateY:_reactNative.Animated.add(Ie,U)}]}],onLayout:e=>{ee.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Le}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})});return Ye?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index3.PickerTrigger,{label:b,value:Be,placeholder:f,helperText:j,error:N,required:R,disabled:D,size:w,variant:C,clearable:S,onClear:k,onPress:()=>V(!0),triggerStyle:A,testID:v}),$e]}):$e};exports.DatePicker=DatePicker;const buildStyles=e=>{const t=e.shadows.lg;return _reactNative.StyleSheet.create({backdrop:{..._reactNative.StyleSheet.absoluteFill},sheetWrap:{position:"absolute",left:0,right:0,bottom:0,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.lg},card:{backgroundColor:e.colors.background.elevated,borderRadius:e.radius.xl,..._corners.smoothCorners,padding:e.spacing.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.spacing.lg,paddingTop:e.spacing.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.full,..._corners.smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},titleRow:{marginBottom:e.spacing.sm},title:{fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.spacing.md},navBtn:{width:e.components.datePicker?.navButtonSize??36,height:e.components.datePicker?.navButtonSize??36,borderRadius:e.radius.full,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors.background.secondary},navBtnPressed:{backgroundColor:e.colors.surface.pressed},navText:{fontSize:e.components.datePicker?.navTextFontSize??22,lineHeight:e.components.datePicker?.navTextLineHeight??24,color:e.colors.text.primary,fontWeight:e.typography.fontWeight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.typography.fontSize.base,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary},headerCaret:{marginLeft:e.spacing.xs,alignItems:"center",justifyContent:"center"},weekdayRow:{flexDirection:"row",marginBottom:e.spacing.xs},weekdayCell:{flex:1,alignItems:"center",paddingVertical:e.spacing.xs},weekdayText:{fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.medium,color:e.colors.text.tertiary,letterSpacing:e.typography.letterSpacing.wide},grid:{},gridRow:{flexDirection:"row"},dayCell:{flex:1,aspectRatio:1,alignItems:"center",justifyContent:"center",padding:e.components.datePicker?.dayCellPadding??2},dayInner:{width:"100%",height:"100%",borderRadius:e.components.datePicker?.dayInnerBorderRadius??e.radius.full,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},dayText:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.components.datePicker?.yearCellPadding??4},yearInner:{width:"100%",height:"100%",borderRadius:e.components.datePicker?.yearInnerBorderRadius??e.radius.lg,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.typography.fontSize.base,fontWeight:e.typography.fontWeight.semibold},decadeRangeText:{fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.medium,marginTop:e.components.datePicker?.decadeRangeMarginTop??2},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.spacing.lg,gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg,paddingVertical:e.spacing.sm,borderRadius:e.radius.md,..._corners.smoothCorners,minHeight:e.components.datePicker?.footerButtonMinHeight??40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.semibold}})};var _default=exports.default=DatePicker;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DatePicker=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../PickerTrigger/index.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const AnimatedGestureRoot=_reactNative.Animated.createAnimatedComponent(_reactNativeGestureHandler.GestureHandlerRootView),transparentOf=e=>{const t=e.match(/^rgba?\(([^)]+)\)$/);if(!t)return"transparent";const[a,r,i]=t[1].split(",").map(e=>e.trim());return`rgba(${a}, ${r}, ${i}, 0)`},GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),isSameDay=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),toIso=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,addMonths=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),buildMonthMatrix=(e,t)=>{const a=e.getFullYear(),r=e.getMonth(),i=(new Date(a,r,1).getDay()-t+7)%7,n=[];for(let e=0;e<42;e+=1){const t=new Date(a,r,1-i+e);n.push({date:t,inMonth:t.getMonth()===r,iso:toIso(t)})}return n},weekdayLabels=(e,t)=>{const a=new Intl.DateTimeFormat(e,{weekday:"short"}),r=[];for(let e=0;e<7;e+=1){const i=new Date(1970,0,4+(t+e)%7);r.push(a.format(i))}return r},formatMonthYear=(e,t)=>new Intl.DateTimeFormat(t,{month:"long",year:"numeric"}).format(e),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:i,maxDate:n,disabledDates:s,mode:o="modal",locale:l="en-IN",weekStartsOn:c=0,title:d="Select Date",confirmLabel:u="Confirm",cancelLabel:m="Cancel",style:g,containerStyle:y,headerLabelStyle:_,navButtonStyle:p,footerButtonStyle:x,haptic:h,testID:v,label:b,placeholder:f,helperText:j,error:N,required:R,disabled:D,size:w,variant:C,clearable:S,onClear:k,formatValue:P,triggerStyle:A}=e,T=void 0!==e.visible,[M,V]=(0,_react.useState)(!1),I=T?e.visible:M,F=T?v:v?`${v}-calendar`:void 0,B=(0,_index.useTheme)(),L=(0,_usePresenceMotion.usePresenceMotion)(),[Y,$]=(0,_ModalSafeArea.useModalInsets)(),z=(0,_react.useMemo)(()=>buildStyles(B),[B]),[H,W]=(0,_react.useState)(()=>startOfDay(new Date));(0,_react.useEffect)(()=>{I&&W(startOfDay(new Date))},[I]);const q=t?startOfDay(t):H,[E,O]=(0,_react.useState)(q),[G,X]=(0,_react.useState)(t?startOfDay(t):null),[Z,J]=(0,_react.useState)("days"),K=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,U=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,ee=(0,_react.useRef)(0),te=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,ae=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,re=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,ie=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,ne=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,se=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(t){const e=startOfDay(t);X(e),O(e)}else X(null)},[t]);const oe=(0,_react.useMemo)(()=>{const e=new Set;return s?.forEach(t=>e.add(toIso(startOfDay(t)))),e},[s]),le=(0,_react.useMemo)(()=>i?startOfDay(i):null,[i]),ce=(0,_react.useMemo)(()=>n?startOfDay(n):null,[n]),de=(0,_react.useCallback)(e=>!!(le&&e.getTime()<le.getTime())||(!!(ce&&e.getTime()>ce.getTime())||!!oe.has(toIso(e))),[le,ce,oe]),ue=(0,_react.useMemo)(()=>buildMonthMatrix(E,c),[E,c]),me=(0,_react.useMemo)(()=>buildYearCells(E.getFullYear()),[E]),ge=(0,_react.useMemo)(()=>buildDecadeCells(E.getFullYear()),[E]),ye=(0,_react.useMemo)(()=>weekdayLabels(l,c),[l,c]),pe=(0,_react.useMemo)(()=>new Intl.DateTimeFormat(l,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),[l]),xe=(0,_react.useMemo)(()=>{if("days"===Z)return formatMonthYear(E,l);if("years"===Z){return`${me[0]} - ${me[me.length-1]}`}return`${ge[0]} - ${ge[ge.length-1]+9}`},[E,ge,l,Z,me]),he=(0,_react.useCallback)(e=>!!(le&&e<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),ve=(0,_react.useCallback)(e=>!!(le&&e+10-1<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),be=(0,_react.useCallback)(e=>{!1!==h&&(0,_index2.triggerHaptic)("impactLight");const t=e>0?1:-1,a=B.components.datePicker?.monthSlideDistance??32,r=B.components.datePicker?.monthSlideOutDuration??B.motion.duration.fast??140,i=B.components.datePicker?.monthSlideInDuration??B.motion.duration.fast??160,[n]=L.range(-t*a,0),[s]=L.range(t*a,0),o=L.reduced?L.duration("fast"):r,c=L.reduced?L.duration("fast"):i;_reactNative.Animated.sequence([_reactNative.Animated.parallel([_reactNative.Animated.timing(te,{toValue:n,duration:r,easing:_reactNative.Easing.out(_reactNative.Easing.quad),useNativeDriver:!0}),_reactNative.Animated.timing(ae,{toValue:0,duration:o,useNativeDriver:!0})]),_reactNative.Animated.timing(te,{toValue:s,duration:0,useNativeDriver:!0}),_reactNative.Animated.parallel([_reactNative.Animated.timing(te,{toValue:0,duration:i,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0}),_reactNative.Animated.timing(ae,{toValue:1,duration:c,useNativeDriver:!0})])]).start();const d=addMonths(E,e);O(d),_reactNative.AccessibilityInfo.announceForAccessibility(formatMonthYear(d,l))},[E,h,l,ae,te,L,B.components.datePicker,B.motion.duration.fast]),fe=(0,_react.useCallback)(()=>{"days"!==Z?(!1!==h&&(0,_index2.triggerHaptic)("impactLight"),O("years"===Z?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))):be(-1)},[be,Z,h]),je=(0,_react.useCallback)(()=>{"days"!==Z?(!1!==h&&(0,_index2.triggerHaptic)("impactLight"),O("years"===Z?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))):be(1)},[be,Z,h]),Ne=(0,_react.useCallback)(()=>{const[e]=L.range(.9,1),t=L.reduced?L.duration("normal"):B.components.datePicker?.viewTransitionDuration??B.motion.duration.normal??200;(0,_index.setNativeValue)(ie,0),(0,_index.setNativeValue)(ne,e),_reactNative.Animated.parallel([_reactNative.Animated.timing(ie,{toValue:1,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0}),_reactNative.Animated.timing(ne,{toValue:1,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0})]).start()},[ie,ne,L,B.components.datePicker,B.motion.duration.normal]),Re=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(h,"selection");if(e&&(0,_index2.triggerHaptic)(e),!L.reduced){const e=B.components.datePicker?.headerPressDuration??80,t=B.components.datePicker?.headerReleaseDuration??100;_reactNative.Animated.sequence([_reactNative.Animated.timing(se,{toValue:.96,duration:e,useNativeDriver:!0}),_reactNative.Animated.timing(se,{toValue:1,duration:t,useNativeDriver:!0})]).start()}J(e=>"days"===e?"years":"years"===e?"decades":"years"),Ne()},[Ne,se,h,L.reduced,B.components.datePicker]),De=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(h,"selection");t&&(0,_index2.triggerHaptic)(t),O(t=>new Date(e,t.getMonth(),1)),J("days"),Ne()},[Ne,h]),we=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(h,"selection");t&&(0,_index2.triggerHaptic)(t),O(t=>new Date(e+4,t.getMonth(),1)),J("years"),Ne()},[Ne,h]),Ce=(0,_react.useCallback)(e=>{if(de(e.date))return;const t=(0,_index2.resolveHaptic)(h,"selection");t&&(0,_index2.triggerHaptic)(t),X(e.date),e.inMonth||O(new Date(e.date.getFullYear(),e.date.getMonth(),1)),L.reduced||((0,_index.setNativeValue)(re,.7),_reactNative.Animated.spring(re,{toValue:1,damping:B.motion.spring.bouncy.damping,stiffness:B.motion.spring.bouncy.stiffness,mass:B.motion.spring.bouncy.mass,useNativeDriver:!0}).start())},[de,L.reduced,re,B.motion.spring.bouncy,h]),Se=(0,_react.useCallback)(()=>{T||V(!1),r?.()},[T,r]),ke=(0,_react.useCallback)(()=>{"modal"===o?_reactNative.Animated.parallel([_reactNative.Animated.timing(K,{toValue:0,duration:L.duration("normal"),easing:_reactNative.Easing.bezier(...B.motion.easing.accelerate),useNativeDriver:!1}),_reactNative.Animated.timing(Q,{toValue:0,duration:L.duration("fast"),easing:_reactNative.Easing.bezier(...B.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>{Se()}):Se()},[K,o,Se,L,Q,B.motion.easing.accelerate]),{handleGesture:Pe,opacity:Ae}=(0,_useDragToDismiss.useDragToDismiss)({drag:U,travel:()=>ee.current||320,onDismiss:ke}),Te=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(Q,Ae),[Q,Ae]),Me=(0,_react.useMemo)(()=>K.interpolate({inputRange:[0,1],outputRange:[transparentOf(B.colors.background.overlay),B.colors.background.overlay]}),[K,B.colors.background.overlay]);(0,_react.useEffect)(()=>{if("modal"===o&&I){K.setValue(0),(0,_index.setNativeValue)(Q,0),(0,_index.setNativeValue)(U,0),(0,_index.setNativeValue)(Ae,1);const e=L.reduced?_reactNative.Animated.timing(Q,{toValue:1,duration:L.duration("normal"),useNativeDriver:!0}):_reactNative.Animated.spring(Q,{toValue:1,damping:B.motion.spring.gentle.damping,stiffness:B.motion.spring.gentle.stiffness,mass:B.motion.spring.gentle.mass,useNativeDriver:!0}),t=_reactNative.Animated.parallel([_reactNative.Animated.timing(K,{toValue:1,duration:L.duration("normal"),easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!1}),e]);return t.start(),()=>t.stop()}},[I,o,K,L,Q,U,Ae,B.motion]);const Ve=(0,_react.useCallback)(()=>{!1!==h&&(0,_index2.triggerHaptic)("selection"),ke()},[ke,h]),Ie=(0,_react.useCallback)(()=>{G&&(!1!==h&&(0,_index2.triggerHaptic)("notificationSuccess"),a?.(G),ke())},[ke,a,G,h]),Fe=Q.interpolate({inputRange:[0,1],outputRange:L.range(320,0)}),Be=(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.titleRow,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:z.title,accessibilityRole:"header",children:d})}),Le=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[z.card,g,y],accessibilityRole:"modal"===o?void 0:"none",accessible:!1,testID:F,children:["modal"===o?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Pe,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:z.grabArea,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.handle}),Be]})}):Be,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:z.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:fe,style:({pressed:e})=>[z.navBtn,e&&z.navBtnPressed,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Previous month":"years"===Z?"Previous years":"Previous decades",hitSlop:8,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:z.navText,children:"‹"})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Re,style:[z.headerLabelWrap,_],accessibilityRole:"button",accessibilityLabel:"days"===Z?`${xe}, switch to year selection`:"years"===Z?`${xe}, switch to decade selection`:`${xe}, switch to year selection`,hitSlop:8,children:(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[z.headerLabelInner,{transform:[{scale:se}],opacity:"days"===Z?ae:1}],children:[(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[z.headerLabel,{transform:[{translateX:"days"===Z?te:0}]}],accessibilityLiveRegion:"polite",children:xe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.headerCaret,children:(B.icons?.chevronDown??_defaultIcons.defaultIcons.chevronDown)({size:B.typography.fontSize.sm,color:B.colors.text.secondary})})]})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:je,style:({pressed:e})=>[z.navBtn,e&&z.navBtnPressed,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Next month":"years"===Z?"Next years":"Next decades",hitSlop:8,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:z.navText,children:"›"})})]}),"days"===Z?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.weekdayRow,children:ye.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.weekdayCell,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:z.weekdayText,children:e})},`${e}-${t}`))}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.grid,{opacity:ae,transform:[{translateX:te}]}],children:Array.from({length:6}).map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.gridRow,children:ue.slice(7*t,7*t+7).map(e=>{const t=de(e.date),a=!!G&&isSameDay(e.date,G),r=isSameDay(e.date,H),i=a?B.colors.primary:"transparent",n=r&&!a?B.colors.primary:"transparent",s=a?B.colors.onPrimary:e.inMonth?t?B.colors.text.disabled:B.colors.text.primary:B.colors.text.tertiary,o=t?.3:e.inMonth?1:.4;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:t,onPress:()=>Ce(e),accessibilityRole:"button",accessibilityLabel:pe.format(e.date),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:z.dayCell,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.dayInner,{backgroundColor:i,borderColor:n,borderWidth:r&&!a?1.5:0,opacity:o},a?{transform:[{scale:re}]}:null],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.dayText,{color:s}],children:e.date.getDate()})})},e.iso)})},`r-${t}`))})]}):"years"===Z?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.yearGrid,{opacity:ie,transform:[{scale:ne}]}],children:Array.from({length:3}).map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.gridRow,children:me.slice(4*t,4*t+4).map(e=>{const t=he(e),a=!!G&&G.getFullYear()===e,r=H.getFullYear()===e,i=a?B.colors.primary:"transparent",n=r&&!a?B.colors.primary:"transparent",s=a?B.colors.onPrimary:t?B.colors.text.disabled:B.colors.text.primary,o=t?.3:1;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:t,onPress:()=>De(e),accessibilityRole:"button",accessibilityLabel:`Year ${e}`,accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:z.yearCell,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[z.yearInner,{backgroundColor:i,borderColor:n,borderWidth:r&&!a?1.5:0,opacity:o}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.yearText,{color:s}],children:e})})},`year-${e}`)})},`yr-${t}`))}):(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.yearGrid,{opacity:ie,transform:[{scale:ne}]}],children:Array.from({length:3}).map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.gridRow,children:ge.slice(4*t,4*t+4).map(e=>{const t=e+10-1,a=ve(e),r=!!G&&decadeStartFor(G.getFullYear())===e,i=decadeStartFor(H.getFullYear())===e,n=r?B.colors.primary:"transparent",s=i&&!r?B.colors.primary:"transparent",o=r?B.colors.onPrimary:a?B.colors.text.disabled:B.colors.text.primary,l=a?.3:1;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{disabled:a,onPress:()=>we(e),accessibilityRole:"button",accessibilityLabel:`Decade ${e} to ${t}`,accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:z.yearCell,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[z.yearInner,{backgroundColor:n,borderColor:s,borderWidth:i&&!r?1.5:0,opacity:l}],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.yearText,{color:o}],children:`${e}s`}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.decadeRangeText,{color:r?B.colors.onPrimary:B.colors.text.tertiary}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${t}`))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:z.footer,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ve,style:({pressed:e})=>[z.footerBtn,z.footerCancel,e&&z.footerBtnPressed,x],accessibilityRole:"button",accessibilityLabel:m,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.footerBtnText,{color:B.colors.text.secondary}],children:m})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ie,disabled:!G,style:({pressed:e})=>[z.footerBtn,z.footerConfirm,{backgroundColor:B.colors.primary,opacity:G?1:.5},e&&{backgroundColor:B.colors.primaryHover},x],accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{disabled:!G},"aria-disabled":!G,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.footerBtnText,{color:B.colors.onPrimary}],children:u})})]})]}),Ye=t?(P??(e=>e.toLocaleDateString()))(t):void 0,$e=!T;if("inline"===o)return I||$e?$e?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index3.PickerTrigger,{label:b,value:Ye,placeholder:f,helperText:j,error:N,required:R,disabled:D,size:w,variant:C,clearable:S,onClear:k,onPress:()=>V(!0),triggerStyle:A,testID:v}),I?Le:null]}):Le:null;const ze=(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:I,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:ke,children:(0,_jsxRuntime.jsx)(_ModalSafeArea.ModalSafeArea,{onInsets:$,children:(0,_jsxRuntime.jsxs)(AnimatedGestureRoot,{collapsable:!1,style:[z.backdrop,{backgroundColor:Me}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ke,accessibilityLabel:"Dismiss"}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[z.sheetWrap,{paddingBottom:Math.max(Y.bottom,B.spacing.lg),opacity:Te,transform:[{translateY:_reactNative.Animated.add(Fe,U)}]}],onLayout:e=>{ee.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Le}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})});return $e?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index3.PickerTrigger,{label:b,value:Ye,placeholder:f,helperText:j,error:N,required:R,disabled:D,size:w,variant:C,clearable:S,onClear:k,onPress:()=>V(!0),triggerStyle:A,testID:v}),ze]}):ze};exports.DatePicker=DatePicker;const buildStyles=e=>{const t=e.shadows.lg;return _reactNative.StyleSheet.create({backdrop:{..._reactNative.StyleSheet.absoluteFill},sheetWrap:{position:"absolute",left:0,right:0,bottom:0,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.lg},card:{backgroundColor:e.colors.background.elevated,borderRadius:e.radius.xl,..._corners.smoothCorners,padding:e.spacing.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.spacing.lg,paddingTop:e.spacing.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.full,..._corners.smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},titleRow:{marginBottom:e.spacing.sm},title:{fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.spacing.md},navBtn:{width:e.components.datePicker?.navButtonSize??36,height:e.components.datePicker?.navButtonSize??36,borderRadius:e.radius.full,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors.background.secondary},navBtnPressed:{backgroundColor:e.colors.surface.pressed},navText:{fontSize:e.components.datePicker?.navTextFontSize??22,lineHeight:e.components.datePicker?.navTextLineHeight??24,color:e.colors.text.primary,fontWeight:e.typography.fontWeight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.typography.fontSize.base,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary},headerCaret:{marginLeft:e.spacing.xs,alignItems:"center",justifyContent:"center"},weekdayRow:{flexDirection:"row",marginBottom:e.spacing.xs},weekdayCell:{flex:1,alignItems:"center",paddingVertical:e.spacing.xs},weekdayText:{fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.medium,color:e.colors.text.tertiary,letterSpacing:e.typography.letterSpacing.wide},grid:{},gridRow:{flexDirection:"row"},dayCell:{flex:1,aspectRatio:1,alignItems:"center",justifyContent:"center",padding:e.components.datePicker?.dayCellPadding??2},dayInner:{width:"100%",height:"100%",borderRadius:e.components.datePicker?.dayInnerBorderRadius??e.radius.full,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},dayText:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.components.datePicker?.yearCellPadding??4},yearInner:{width:"100%",height:"100%",borderRadius:e.components.datePicker?.yearInnerBorderRadius??e.radius.lg,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.typography.fontSize.base,fontWeight:e.typography.fontWeight.semibold},decadeRangeText:{fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.medium,marginTop:e.components.datePicker?.decadeRangeMarginTop??2},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.spacing.lg,gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg,paddingVertical:e.spacing.sm,borderRadius:e.radius.md,..._corners.smoothCorners,minHeight:e.components.datePicker?.footerButtonMinHeight??40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.semibold}})};var _default=exports.default=DatePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListItem=void 0;var _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"),_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("function"==typeof WeakMap)var i=new WeakMap,s=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var n,r,l={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return l;if(n=t?s:i){if(n.has(e))return n.get(e);n.set(e,l)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((r=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(r.get||r.set)?n(l,t,r):l[t]=e[t]);return l})(e,t)}const SIZE_FALLBACK={sm:{paddingVertical:"sm",titleFontSize:"sm",subtitleFontSize:"xs",minHeight:44},md:{paddingVertical:"md",titleFontSize:"base",subtitleFontSize:"sm",minHeight:56},lg:{paddingVertical:"lg",titleFontSize:"lg",subtitleFontSize:"sm",minHeight:72}},sizeFor=(e,t)=>{const i={...SIZE_FALLBACK[t],...e.components.listItem?.[t]??{}};return{paddingVertical:e.spacing[i.paddingVertical],titleSize:e.typography.fontSize[i.titleFontSize],subtitleSize:e.typography.fontSize[i.subtitleFontSize],minHeight:i.minHeight}},Chevron=({color:e})=>{const t=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(t.icons?.chevronRight??_defaultIcons.defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,DEFAULT_BOX_SIZE=20,SelectionBox=({checked:e,disabled:t})=>{const i=(0,_index.useTheme)(),s=i.components.checkbox?.md?.boxSize??20,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.colors.border.width,borderRadius:i.radius.xs,..._corners.smoothCorners,borderColor:e?i.colors.primary:i.colors.border.primary,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.onPrimary,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,title:e.label,onPress:e.onPress},e.label)):e,ListItem=exports.ListItem=(0,_react.forwardRef)((e,t)=>{const{title:i,loading:s=!1,subtitle:n,description:r,titleLines:l=1,subtitleLines:o=1,left:a,icon:c,iconTone:d="primary",right:u,rightPlacement:m="auto",selectable:x=!1,checked:h=!1,onCheckedChange:_,actions:g,onPress:p,haptic:j,selected:b=!1,disabled:y=!1,size:f="md",divider:v=!1,chevron:S=!1,leftActions:R,rightActions:w,contextMenu:I,accessibilityLabel:L,accessibilityHint:k,style:z,containerStyle:N,titleStyle:V,subtitleStyle:A,descriptionStyle:C,leftSlotStyle:F,rightSlotStyle:q,testID:B}=e,P=(0,_index.useTheme)(),D=(0,_react.useMemo)(()=>sizeFor(P,f),[P,f]),H=(0,_react.useMemo)(()=>buildStyles(P),[P]),{fontScale:M}=(0,_reactNative.useWindowDimensions)(),W=!!u&&("below"===m||"auto"===m&&M>1.2),T=(0,_useContextMenu.useContextMenu)(y?void 0:I,{haptic:j||!1,testID:B}),E=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,T.hostRef),[t,T.hostRef]),O=x||!!p,G=O||T.enabled,Z=G&&!y,{style:U,pressIn:K,pressOut:X}=(0,_usePressAnimation.usePressAnimation)({enabled:Z}),J=(0,_useFlickGuard.useFlickGuard)(),Q=L??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,Y=a??(void 0===c?null:(0,_jsxRuntime.jsx)(_index3.IconBadge,{icon:c,tone:d,size:BADGE_SIZE[f]})),$=x?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.selectionLead,children:[(0,_jsxRuntime.jsx)(SelectionBox,{checked:h,disabled:y}),Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.selectionLeadContent,children:Y}):null]}):Y,ee=null!=g&&!1!==g&&!(Array.isArray(g)&&0===g.length),te=v&&!ee,ie=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.row,{paddingVertical:D.paddingVertical,minHeight:D.minHeight,backgroundColor:b?P.colors.surface.selected:"transparent"},te?H.divider:null,y?H.disabled:null,N],children:[$?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.leftSlot,F],children:$}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.middle,children:[null==i||isText(i)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[H.title,{fontSize:D.titleSize,...(0,_index.fontFor)(P,"medium"),color:y?P.colors.text.disabled:P.colors.text.primary},V],numberOfLines:l,children:i??" "}):i,null==n||""===n?null:isText(n)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[H.subtitle,{fontSize:D.subtitleSize,color:y?P.colors.text.disabled:P.colors.text.secondary},A],numberOfLines:o,children:n}):n,r?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[H.description,{fontSize:D.subtitleSize,color:y?P.colors.text.disabled:P.colors.text.tertiary},C],numberOfLines:2,children:r}):null,W?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.rightBelow,q],children:u}):null]}),u&&!W||S?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.rightSlot,W?null:q],children:[W?null:u,S?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u&&!W?H.chevronWithRight:null,children:(0,_jsxRuntime.jsx)(Chevron,{color:y?P.colors.text.disabled:P.colors.text.tertiary})}):null]}):null]}),se=G?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[U,z],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:E,onPress:e=>{Z&&O&&!J.isFlick(e)&&(j&&(0,_hapticUtils.triggerHaptic)(j),x?_?.(!h):p?.(e))},onPressIn:e=>{J.onPressIn(e),K()},onPressOut:X,disabled:!Z,accessibilityRole:x?"checkbox":p?"button":void 0,accessibilityLabel:Q,accessibilityHint:k,accessibilityState:x?{checked:h,disabled:!Z}:{selected:b,disabled:!Z},"aria-disabled":!Z,...x?{"aria-checked":h}:{"aria-selected":b},testID:B,android_ripple:{color:P.colors.surface.pressed,borderless:!1},style:({pressed:e})=>e?H.pressed:null,...T.hostProps,children:ie})}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityRole:"none",accessibilityLabel:Q,accessibilityHint:k,accessibilityState:{selected:b,disabled:y},"aria-selected":b,"aria-disabled":y,testID:B,style:z,children:ie}),ne=R&&R.length>0||w&&w.length>0,re=ee?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[b?{backgroundColor:P.colors.surface.selected}:null,v?H.divider:null],children:[se,(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.actions,children:renderActions(g)})]}):se,le=ne?(0,_jsxRuntime.jsx)(_index5.Swipeable,{leftActions:R,rightActions:w,accessibilityLabel:Q,children:re}):re;return s?(0,_jsxRuntime.jsx)(ListItemSkeleton,{...e}):T.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[le,T.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:H.preview,children:ie}))]}):le});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=sizeFor(c,l),u=Math.round(1.15*d.titleSize),m=Math.round(1.15*d.subtitleSize);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.spacing.md,paddingVertical:d.paddingVertical,minHeight:d.minHeight},o,a],children:[void 0!==i||void 0!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:c.spacing.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.spacing.xs}}),void 0!==e?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"50%",height:m,style:void 0!==t?{marginBottom:c.spacing.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.spacing.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.spacing.md},divider:{borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:e.colors.border.primary},pressed:{backgroundColor:e.colors.surface.pressed},disabled:{opacity:.55},leftSlot:{marginRight:e.spacing.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.spacing.sm},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.spacing.xs},rightSlot:{marginLeft:e.spacing.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.spacing.sm,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.md},chevronWithRight:{marginLeft:e.spacing.xs},preview:{flex:1,backgroundColor:e.colors.background.elevated,borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden"},title:{letterSpacing:e.typography.letterSpacing.normal},subtitle:{marginTop:2,...(0,_index.fontFor)(e,"normal")},description:{marginTop:2,...(0,_index.fontFor)(e,"normal")}});var _default=exports.default=ListItem;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListItem=void 0;var _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"),_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("function"==typeof WeakMap)var i=new WeakMap,s=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var n,r,l={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return l;if(n=t?s:i){if(n.has(e))return n.get(e);n.set(e,l)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((r=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(r.get||r.set)?n(l,t,r):l[t]=e[t]);return l})(e,t)}const SIZE_FALLBACK={sm:{paddingVertical:"sm",titleFontSize:"sm",subtitleFontSize:"xs",minHeight:44},md:{paddingVertical:"md",titleFontSize:"base",subtitleFontSize:"sm",minHeight:56},lg:{paddingVertical:"lg",titleFontSize:"lg",subtitleFontSize:"sm",minHeight:72}},sizeFor=(e,t)=>{const i={...SIZE_FALLBACK[t],...e.components.listItem?.[t]??{}};return{paddingVertical:e.spacing[i.paddingVertical],titleSize:e.typography.fontSize[i.titleFontSize],subtitleSize:e.typography.fontSize[i.subtitleFontSize],minHeight:i.minHeight}},Chevron=({color:e})=>{const t=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(t.icons?.chevronRight??_defaultIcons.defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,DEFAULT_BOX_SIZE=20,SelectionBox=({checked:e,disabled:t})=>{const i=(0,_index.useTheme)(),s=i.components.checkbox?.md?.boxSize??20,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.colors.border.width,borderRadius:i.radius.xs,..._corners.smoothCorners,borderColor:e?i.colors.primary:i.colors.border.primary,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.onPrimary,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,title: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,titleLines:l=1,subtitleLines:o=1,left:a,icon:c,iconTone:d="primary",right:u,rightPlacement:m="auto",selectable:x=!1,checked:h=!1,onCheckedChange:_,actions:g,onPress:p,haptic:j,selected:b=!1,disabled:f=!1,size:y="md",divider:v=!1,chevron:S=!1,leftActions:R,rightActions:w,contextMenu:I,accessibilityLabel:L,accessibilityHint:k,style:z,containerStyle:N,titleStyle:V,subtitleStyle:A,descriptionStyle:C,leftSlotStyle:F,rightSlotStyle:q,testID:B}=e,P=(0,_index.useTheme)(),D=(0,_react.useMemo)(()=>sizeFor(P,y),[P,y]),H=(0,_react.useMemo)(()=>buildStyles(P),[P]),{fontScale:M}=(0,_reactNative.useWindowDimensions)(),W=!!u&&("below"===m||"auto"===m&&M>1.2),T=(0,_useContextMenu.useContextMenu)(f?void 0:I,{haptic:j||!1,testID:B}),E=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,T.hostRef),[t,T.hostRef]),O=x||!!p,G=O||T.enabled,Z=G&&!f,{style:U,pressIn:K,pressOut:X}=(0,_usePressAnimation.usePressAnimation)({enabled:Z}),J=(0,_useFlickGuard.useFlickGuard)(),Q=L??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,Y=a??(void 0===c?null:(0,_jsxRuntime.jsx)(_index3.IconBadge,{icon:c,tone:d,size:BADGE_SIZE[y]})),$=x?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.selectionLead,children:[(0,_jsxRuntime.jsx)(SelectionBox,{checked:h,disabled:f}),Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.selectionLeadContent,children:Y}):null]}):Y,ee=null!=g&&!1!==g&&!(Array.isArray(g)&&0===g.length),te=v&&!ee,ie=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.row,{paddingVertical:D.paddingVertical,minHeight:D.minHeight,backgroundColor:b?P.colors.surface.selected:"transparent"},te?H.divider:null,f?H.disabled:null,N],children:[$?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.leftSlot,F],children:$}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.middle,children:[null==i||isText(i)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[H.title,{fontSize:D.titleSize,...(0,_index.fontFor)(P,"medium"),color:f?P.colors.text.disabled:P.colors.text.primary},V],numberOfLines:l,children:i??" "}):i,null==n||""===n?null:isText(n)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[H.subtitle,{fontSize:D.subtitleSize,color:f?P.colors.text.disabled:P.colors.text.secondary},A],numberOfLines:o,children:n}):n,r?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[H.description,{fontSize:D.subtitleSize,color:f?P.colors.text.disabled:P.colors.text.tertiary},C],numberOfLines:2,children:r}):null,W?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.rightBelow,q],children:u}):null]}),u&&!W||S?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.rightSlot,W?null:q],children:[W?null:u,S?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u&&!W?H.chevronWithRight:null,children:(0,_jsxRuntime.jsx)(Chevron,{color:f?P.colors.text.disabled:P.colors.text.tertiary})}):null]}):null]}),se=G?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[U,z],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:E,onPress:e=>{Z&&O&&!J.isFlick(e)&&(j&&(0,_hapticUtils.triggerHaptic)(j),x?_?.(!h):p?.(e))},onPressIn:e=>{J.onPressIn(e),K()},onPressOut:X,disabled:!Z,accessibilityRole:x?"checkbox":p?"button":void 0,accessibilityLabel:Q,accessibilityHint:k,accessibilityState:x?{checked:h,disabled:!Z}:{selected:b,disabled:!Z},"aria-disabled":!Z,...x?{"aria-checked":h}:{"aria-selected":b},testID:B,android_ripple:{color:P.colors.surface.pressed,borderless:!1},style:({pressed:e})=>e?H.pressed:null,...T.hostProps,children:ie})}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityRole:"none",accessibilityLabel:Q,accessibilityHint:k,accessibilityState:{selected:b,disabled:f},"aria-selected":b,"aria-disabled":f,testID:B,style:z,children:ie}),ne=R&&R.length>0||w&&w.length>0,re=ee?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[b?{backgroundColor:P.colors.surface.selected}:null,v?H.divider:null],children:[se,(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.actions,children:renderActions(g)})]}):se,le=ne?(0,_jsxRuntime.jsx)(_index5.Swipeable,{leftActions:R,rightActions:w,accessibilityLabel:Q,children:re}):re;return s?(0,_jsxRuntime.jsx)(ListItemSkeleton,{...e}):T.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[le,T.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:H.preview,children:ie}))]}):le}));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=sizeFor(c,l),u=Math.round(1.15*d.titleSize),m=Math.round(1.15*d.subtitleSize);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.spacing.md,paddingVertical:d.paddingVertical,minHeight:d.minHeight},o,a],children:[void 0!==i||void 0!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:c.spacing.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.spacing.xs}}),void 0!==e?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"50%",height:m,style:void 0!==t?{marginBottom:c.spacing.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.spacing.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.spacing.md},divider:{borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:e.colors.border.primary},pressed:{backgroundColor:e.colors.surface.pressed},disabled:{opacity:.55},leftSlot:{marginRight:e.spacing.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.spacing.sm},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.spacing.xs},rightSlot:{marginLeft:e.spacing.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.spacing.sm,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.md},chevronWithRight:{marginLeft:e.spacing.xs},preview:{flex:1,backgroundColor:e.colors.background.elevated,borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden"},title:{letterSpacing:e.typography.letterSpacing.normal},subtitle:{marginTop:2,...(0,_index.fontFor)(e,"normal")},description:{marginTop:2,...(0,_index.fontFor)(e,"normal")}});var _default=exports.default=ListItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Logger}from"@webority/mobile-core";import{useMemo}from"react";import{SvgXml}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{CATALOG_LOADERS,ICON_NAMES}from"./catalog.g.js";import{CURATED_ICON_NAMES,GLYPHS}from"./glyphs.g.js";import{jsx as _jsx}from"react/jsx-runtime";export{CURATED_ICON_NAMES,ICON_NAMES};export const ICONSAX_SUFFIX="-iconsax";export const APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36};const tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",o=`${e}:${t}`,
|
|
1
|
+
"use strict";import{Logger}from"@webority/mobile-core";import{useMemo}from"react";import{SvgXml}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{CATALOG_LOADERS,ICON_NAMES}from"./catalog.g.js";import{CURATED_ICON_NAMES,GLYPHS}from"./glyphs.g.js";import{jsx as _jsx}from"react/jsx-runtime";export{CURATED_ICON_NAMES,ICON_NAMES};export const ICONSAX_SUFFIX="-iconsax";export const APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36};const tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",o=`${e}:${t}`,n=shardCache.get(o);if(void 0!==n)return n;const a=CATALOG_LOADERS[e]?.[t],s=a?tryRequire(a):null;return shardCache.set(o,s),s},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)};export const resolveGlyph=(e,r="linear")=>{if(e.endsWith("-iconsax")){const t=e.slice(0,-8);return t in GLYPHS?resolveCatalogue(t,r):null}const t=GLYPHS[e];return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};export const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;const iconXmlCache=new Map;export const AppIcon=({name:e,size:r="md",color:t,variant:o="linear",style:n,accessibilityLabel:a,testID:s})=>{const l=useTheme(),i="number"==typeof r?r:APP_ICON_SIZES[r],c=t??l.colors.text.primary,u=resolveGlyph(e,o),m=useMemo(()=>{if(!u)return null;const r=`${e}|${o}|${i}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const n=buildIconXml(u,i,c);return iconXmlCache.set(r,n),n},[e,o,u,i,c]);return m?_jsx(SvgXml,{xml:m,width:i,height:i,style:n,accessible:null!=a,accessibilityLabel:a,accessibilityRole:null!=a?"image":void 0,testID:s}):(__DEV__&&!warned.has(e)&&(warned.add(e),Logger.warn(`[AppIcon] Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run scripts/sync-icons.mjs after adding one there.`)),null)};AppIcon.displayName="AppIcon";export default AppIcon;
|
|
@@ -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{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{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 paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=forwardRef((e,t)=>{const{children:o,variant:i="elevated",elevation:r="sm",radius:s="lg",padding:l="md",interactive:a=!1,bg:n,header:d,title:c,lead:u,action:h,headerActions:m,collapsible:p=!1,collapsed:g,defaultCollapsed:b=!1,onCollapsedChange:y,collapsedSummary:x,onRemove:f,removeLabel:S="Remove",separatorHeight:j=StyleSheet.hairlineWidth,footer:v,imageSource:w,imageHeight:C=160,imageAspectRatio:_,imageOverlay:R,loading:k=!1,gradient:A,onPress:T,haptic:B,contextMenu:I,accessibilityLabel:H,accessibilityHint:L,accessibilityRole:P,style:V,containerStyle:F,headerStyle:M,bodyStyle:z,footerStyle:q,borderRadius:W,testID:D,onLayout:O,...E}=e,N=useTheme(),G=a||"function"==typeof T,$=useContextMenu(I,{haptic:B||!1,testID:D,accessibilityActions:E.accessibilityActions,onAccessibilityAction:E.onAccessibilityAction}),U=useMemo(()=>mergeRefs(t,$.hostRef),[t,$.hostRef]),J=G||$.enabled,{style:K,pressIn:Q,pressOut:X}=usePressAnimation({enabled:J}),Y=useMemo(()=>buildStyles(N),[N]),Z=Boolean(w),ee=N.spacing[paddingMap[l]],te=useMemo(()=>A?"string"==typeof A?N.gradients[A]??null:A:null,[A,N.gradients]),oe="flat"===i,ie=oe?0:W??N.radius[s],re=resolveBackground(N,n),[se,le]=useControllableState({value:g,defaultValue:b,onChange:y}),ae=p&&se,ne=hasBuiltInHeaderContent(e),de=Boolean(d)||ne,ce=useSquircle(!Z&&!te&&!oe,ie,O),ue=StyleSheet.flatten([V,F])??{},he=ue.backgroundColor,me=ue.borderColor,pe=he??re??("filled"===i?N.colors.background.secondary:N.colors.background.elevated),ge="outlined"===i?N.colors.border.width:0,be=me??N.colors.border.primary,ye="elevated"===i&&supportsBoxShadow()?toBoxShadow(N.shadows[r]):void 0,xe=ce.active&&"elevated"===i&&!ye,fe=ce.active&&!xe?{backgroundColor:"transparent",borderColor:"transparent"}:null,Se=useMemo(()=>{const e={borderRadius:xe&&ce.size?squircleHostRadius(ce.size.width,ce.size.height,ie):ie,...smoothCorners,padding:Z?0:ee,overflow:ce.active?"visible":"hidden"};switch(i){case"flat":return{...e,backgroundColor:re??N.colors.background.elevated,borderBottomWidth:j,borderBottomColor:N.colors.border.primary};case"outlined":return{...e,backgroundColor:ce.active?"transparent":re??N.colors.background.elevated,borderWidth:N.colors.border.width,borderColor:ce.active?"transparent":N.colors.border.primary};case"filled":return{...e,backgroundColor:ce.active?"transparent":re??N.colors.background.secondary};default:return{...e,backgroundColor:re??N.colors.background.elevated,...ye?{boxShadow:ye}:N.shadows[r]}}},[N,i,r,ie,Z,ee,ce.active,ce.size,ye,xe,re,j]),je=useMemo(()=>({..."number"==typeof _?{width:"100%",aspectRatio:_}:{width:"100%",height:C},borderTopLeftRadius:ie,borderTopRightRadius:ie,borderBottomLeftRadius:0,borderBottomRightRadius:0,...smoothCorners}),[ie,_,C]),ve="string"==typeof c?c:"",we=_jsxs(_Fragment,{children:[_jsxs(View,{style:Y.titleColumn,children:["string"==typeof c?_jsx(Text,{variant:"title",accessibilityRole:"header",children:c}):c,u?_jsx(Text,{variant:"bodySmall",style:Y.lead,children:u}):null,ae&&x?_jsx(Text,{variant:"caption",style:Y.lead,children:x}):null]}),isCardTextAction(h)?_jsx(CardTextActionButton,{action:h,haptic:B}):h?_jsx(View,{style:Y.actionNode,children:h}):null,m,p?_jsx(CardIconAction,{icon:ae?"chevron-down":"chevron-up",label:`${ae?"Show":"Hide"} ${ve}`.trim(),expanded:!ae,onPress:()=>le(!ae),haptic:B}):null,f?_jsx(CardIconAction,{icon:"trash",label:S,onPress:f,color:N.colors.toneText.error,haptic:B}):null]}),Ce=_jsxs(_Fragment,{children:[de?_jsx(View,{style:[Y.header,!d&&Y.headerRow,ae&&Y.headerFolded,M],children:d??we}):null,ae?null:_jsx(View,{style:[de||v?Y.body:null,z],children:o}),v&&!ae?_jsx(View,{style:[Y.footer,q],children:v}):null]}),Re=Z?_jsxs(_Fragment,{children:[_jsxs(View,{style:Y.imageWrapper,children:[_jsx(Image,{source:w,resizeMode:"cover",style:je,accessibilityLabel:"",accessible:!1}),R?_jsx(View,{pointerEvents:"box-none",style:Y.imageOverlay,children:R}):null]}),_jsx(View,{style:{padding:ee},children:Ce})]}):Ce,ke=te?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:te,style:StyleSheet.absoluteFill}),Re]}):ce.active&&ce.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ce.size.width,height:ce.size.height,radius:ie,fill:pe,stroke:ge?be:void 0,strokeWidth:ge,outset:ge}),Re]}):Re;let Ae;if(J){const handlePress=e=>{G&&(B&&triggerHaptic(B),T?.(e))};Ae=_jsx(Animated.View,{style:K,children:_jsx(Pressable,{ref:U,onPress:handlePress,onPressIn:Q,onPressOut:X,android_ripple:{color:N.colors.surface.pressed,borderless:!1},accessibilityRole:P??(G?"button":void 0),accessibilityLabel:H,accessibilityHint:L,testID:D,onLayout:ce.onLayout,style:[Se,V,F,fe],...E,...$.hostProps,children:ke})})}else Ae=_jsx(View,{ref:t,accessibilityLabel:H,accessibilityHint:L,accessibilityRole:P,testID:D,onLayout:ce.onLayout,style:[Se,V,F,fe],...E,children:ke});return k?_jsx(CardSkeleton,{...e}):$.enabled?_jsxs(_Fragment,{children:[Ae,$.renderSurface(_jsx(View,{style:[Se,V,F,fe,Y.preview],children:ke}))]}):Ae});Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:o="lg",padding:i="md",bg:r,header:s,footer:l,imageSource:a,imageHeight:n=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:m,footerStyle:p,style:g,...b})=>{const y=useTheme(),x=paddingMap[i],f=y.spacing[x],S="flat"===e?0:c??y.radius[o],j=void 0!==s||hasBuiltInHeaderContent(b),v=resolveBackground(y,r)??y.colors.background.elevated,w="outlined"===e?1:0,C="outlined"===e?y.colors.border.primary:void 0;return _jsxs(View,{style:[{backgroundColor:v,borderRadius:S,...smoothCorners,borderWidth:w,borderColor:C,overflow:"hidden"},u,g],accessibilityRole:"progressbar",accessibilityLabel:"Loading",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==a?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,j?_jsx(View,{style:[{padding:f,paddingBottom:y.spacing.sm},h],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:f},m],children:_jsx(SkeletonText,{lines:3,fontSize:14,lastLineWidth:"55%"})}),void 0!==l?_jsx(View,{style:[{padding:f,paddingTop:y.spacing.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:o,expanded:i,color:r,haptic:s})=>{const l=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===i?void 0:{expanded:i},"aria-expanded":i,onPress:()=>{s&&triggerHaptic(s),o()},style:iconActionStyle,children:_jsx(AppIcon,{name:e,size:20,color:r??l.colors.text.primary})})},CardTextActionButton=({action:e,haptic:t})=>{const o=useTheme();return _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:o.colors.primary,children:e.label})})},iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},resolveBackground=(e,t)=>{if(null==t)return;return e.colors.background[t]??t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.spacing.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.spacing.sm},headerFolded:{marginBottom:0},titleColumn:{flex:1},lead:{marginTop:e.spacing.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.spacing.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},preview:{margin:0,marginTop:0,marginBottom:0,marginLeft:0,marginRight:0,marginStart:0,marginEnd:0,marginHorizontal:0,marginVertical:0,position:"relative",top:0,left:0,width:"100%",height:"100%"}});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{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{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 paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:o,variant:i="elevated",elevation:r="sm",radius:s="lg",padding:l="md",interactive:a=!1,bg:n,header:d,title:c,lead:u,action:h,headerActions:m,collapsible:p=!1,collapsed:g,defaultCollapsed:b=!1,onCollapsedChange:y,collapsedSummary:x,onRemove:f,removeLabel:S="Remove",separatorHeight:j=StyleSheet.hairlineWidth,footer:v,imageSource:w,imageHeight:C=160,imageAspectRatio:_,imageOverlay:R,loading:k=!1,gradient:A,onPress:T,haptic:B,contextMenu:I,accessibilityLabel:H,accessibilityHint:L,accessibilityRole:P,style:V,containerStyle:F,headerStyle:M,bodyStyle:z,footerStyle:q,borderRadius:W,testID:D,onLayout:O,...E}=e,N=useTheme(),G=a||"function"==typeof T,$=useContextMenu(I,{haptic:B||!1,testID:D,accessibilityActions:E.accessibilityActions,onAccessibilityAction:E.onAccessibilityAction}),U=useMemo(()=>mergeRefs(t,$.hostRef),[t,$.hostRef]),J=G||$.enabled,{style:K,pressIn:Q,pressOut:X}=usePressAnimation({enabled:J}),Y=useMemo(()=>buildStyles(N),[N]),Z=Boolean(w),ee=N.spacing[paddingMap[l]],te=useMemo(()=>A?"string"==typeof A?N.gradients[A]??null:A:null,[A,N.gradients]),oe="flat"===i,ie=oe?0:W??N.radius[s],re=resolveBackground(N,n),[se,le]=useControllableState({value:g,defaultValue:b,onChange:y}),ae=p&&se,ne=hasBuiltInHeaderContent(e),de=Boolean(d)||ne,ce=useSquircle(!Z&&!te&&!oe,ie,O),ue=StyleSheet.flatten([V,F])??{},he=ue.backgroundColor,me=ue.borderColor,pe=he??re??("filled"===i?N.colors.background.secondary:N.colors.background.elevated),ge="outlined"===i?N.colors.border.width:0,be=me??N.colors.border.primary,ye="elevated"===i&&supportsBoxShadow()?toBoxShadow(N.shadows[r]):void 0,xe=ce.active&&"elevated"===i&&!ye,fe=ce.active&&!xe?{backgroundColor:"transparent",borderColor:"transparent"}:null,Se=useMemo(()=>{const e={borderRadius:xe&&ce.size?squircleHostRadius(ce.size.width,ce.size.height,ie):ie,...smoothCorners,padding:Z?0:ee,overflow:ce.active?"visible":"hidden"};switch(i){case"flat":return{...e,backgroundColor:re??N.colors.background.elevated,borderBottomWidth:j,borderBottomColor:N.colors.border.primary};case"outlined":return{...e,backgroundColor:ce.active?"transparent":re??N.colors.background.elevated,borderWidth:N.colors.border.width,borderColor:ce.active?"transparent":N.colors.border.primary};case"filled":return{...e,backgroundColor:ce.active?"transparent":re??N.colors.background.secondary};default:return{...e,backgroundColor:re??N.colors.background.elevated,...ye?{boxShadow:ye}:N.shadows[r]}}},[N,i,r,ie,Z,ee,ce.active,ce.size,ye,xe,re,j]),je=useMemo(()=>({..."number"==typeof _?{width:"100%",aspectRatio:_}:{width:"100%",height:C},borderTopLeftRadius:ie,borderTopRightRadius:ie,borderBottomLeftRadius:0,borderBottomRightRadius:0,...smoothCorners}),[ie,_,C]),ve="string"==typeof c?c:"",we=_jsxs(_Fragment,{children:[_jsxs(View,{style:Y.titleColumn,children:["string"==typeof c?_jsx(Text,{variant:"title",accessibilityRole:"header",children:c}):c,u?_jsx(Text,{variant:"bodySmall",style:Y.lead,children:u}):null,ae&&x?_jsx(Text,{variant:"caption",style:Y.lead,children:x}):null]}),isCardTextAction(h)?_jsx(CardTextActionButton,{action:h,haptic:B}):h?_jsx(View,{style:Y.actionNode,children:h}):null,m,p?_jsx(CardIconAction,{icon:ae?"chevron-down":"chevron-up",label:`${ae?"Show":"Hide"} ${ve}`.trim(),expanded:!ae,onPress:()=>le(!ae),haptic:B}):null,f?_jsx(CardIconAction,{icon:"trash",label:S,onPress:f,color:N.colors.toneText.error,haptic:B}):null]}),Ce=_jsxs(_Fragment,{children:[de?_jsx(View,{style:[Y.header,!d&&Y.headerRow,ae&&Y.headerFolded,M],children:d??we}):null,ae?null:_jsx(View,{style:[de||v?Y.body:null,z],children:o}),v&&!ae?_jsx(View,{style:[Y.footer,q],children:v}):null]}),Re=Z?_jsxs(_Fragment,{children:[_jsxs(View,{style:Y.imageWrapper,children:[_jsx(Image,{source:w,resizeMode:"cover",style:je,accessibilityLabel:"",accessible:!1}),R?_jsx(View,{pointerEvents:"box-none",style:Y.imageOverlay,children:R}):null]}),_jsx(View,{style:{padding:ee},children:Ce})]}):Ce,ke=te?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:te,style:StyleSheet.absoluteFill}),Re]}):ce.active&&ce.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ce.size.width,height:ce.size.height,radius:ie,fill:pe,stroke:ge?be:void 0,strokeWidth:ge,outset:ge}),Re]}):Re;let Ae;if(J){const handlePress=e=>{G&&(B&&triggerHaptic(B),T?.(e))};Ae=_jsx(Animated.View,{style:K,children:_jsx(Pressable,{ref:U,onPress:handlePress,onPressIn:Q,onPressOut:X,android_ripple:{color:N.colors.surface.pressed,borderless:!1},accessibilityRole:P??(G?"button":void 0),accessibilityLabel:H,accessibilityHint:L,testID:D,onLayout:ce.onLayout,style:[Se,V,F,fe],...E,...$.hostProps,children:ke})})}else Ae=_jsx(View,{ref:t,accessibilityLabel:H,accessibilityHint:L,accessibilityRole:P,testID:D,onLayout:ce.onLayout,style:[Se,V,F,fe],...E,children:ke});return k?_jsx(CardSkeleton,{...e}):$.enabled?_jsxs(_Fragment,{children:[Ae,$.renderSurface(_jsx(View,{style:[Se,V,F,fe,Y.preview],children:ke}))]}):Ae}));Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:o="lg",padding:i="md",bg:r,header:s,footer:l,imageSource:a,imageHeight:n=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:m,footerStyle:p,style:g,...b})=>{const y=useTheme(),x=paddingMap[i],f=y.spacing[x],S="flat"===e?0:c??y.radius[o],j=void 0!==s||hasBuiltInHeaderContent(b),v=resolveBackground(y,r)??y.colors.background.elevated,w="outlined"===e?1:0,C="outlined"===e?y.colors.border.primary:void 0;return _jsxs(View,{style:[{backgroundColor:v,borderRadius:S,...smoothCorners,borderWidth:w,borderColor:C,overflow:"hidden"},u,g],accessibilityRole:"progressbar",accessibilityLabel:"Loading",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==a?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,j?_jsx(View,{style:[{padding:f,paddingBottom:y.spacing.sm},h],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:f},m],children:_jsx(SkeletonText,{lines:3,fontSize:14,lastLineWidth:"55%"})}),void 0!==l?_jsx(View,{style:[{padding:f,paddingTop:y.spacing.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:o,expanded:i,color:r,haptic:s})=>{const l=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===i?void 0:{expanded:i},"aria-expanded":i,onPress:()=>{s&&triggerHaptic(s),o()},style:iconActionStyle,children:_jsx(AppIcon,{name:e,size:20,color:r??l.colors.text.primary})})},CardTextActionButton=({action:e,haptic:t})=>{const o=useTheme();return _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:o.colors.primary,children:e.label})})},iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},resolveBackground=(e,t)=>{if(null==t)return;return e.colors.background[t]??t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.spacing.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.spacing.sm},headerFolded:{marginBottom:0},titleColumn:{flex:1},lead:{marginTop:e.spacing.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.spacing.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},preview:{margin:0,marginTop:0,marginBottom:0,marginLeft:0,marginRight:0,marginStart:0,marginEnd:0,marginHorizontal:0,marginVertical:0,position:"relative",top:0,left:0,width:"100%",height:"100%"}});export{Card};export default Card;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Image,Pressable,ScrollView,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{Skeleton}from"../Skeleton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CarouselInner=forwardRef((e,t)=>{const{data:n,renderItem:r,keyExtractor:i,index:a,defaultIndex:l=0,onIndexChange:s,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:g="screen",spacing:y=0,containerStyle:p,accessibilityLabel:b,testID:f,showThumbnails:
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,AppState,Dimensions,FlatList,Image,Pressable,ScrollView,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{Skeleton}from"../Skeleton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CarouselInner=forwardRef((e,t)=>{const{data:n,renderItem:r,keyExtractor:i,index:a,defaultIndex:l=0,onIndexChange:s,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:g="screen",spacing:y=0,containerStyle:p,accessibilityLabel:b,testID:f,showThumbnails:S=!1,haptic:x,renderThumbnail:w,loading:C=!1}=e,v=useTheme(),j="number"==typeof a,k=d||c,[I,T]=useState(()=>Dimensions.get("window").width),R="screen"===g?I:g,_=R+y,A=useRef(null),V=useRef(createAnimatedValue(0)).current,E=clamp(j?a:l,0,Math.max(0,n.length-1)),[H,z]=useState(E),M=useRef(null),D=useRef(null),P=useRef(!1),W=useRef(H);W.current=H;const L=useCallback(e=>{const t=clamp(e,0,Math.max(0,n.length-1));z(e=>e===t?e:(s?.(t),t))},[n.length,s]),$=useCallback((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);A.current?.scrollToOffset({offset:r*_,animated:t}),L(r)},[n.length,_,L]),N=useCallback(()=>{if(0===n.length)return;const e=W.current+1;e>=n.length?k&&$(0,!1):$(e,!0)},[n.length,k,$]),O=useCallback(()=>{if(0===n.length)return;const e=W.current-1;e<0?k&&$(n.length-1,!1):$(e,!0)},[n.length,k,$]);useImperativeHandle(t,()=>({scrollTo:$,next:N,prev:O}),[$,N,O]),useEffect(()=>{j&&a!==H&&$(a,!0)},[a]);const F=useCallback(()=>{M.current&&(clearInterval(M.current),M.current=null)},[]),X=useCallback(()=>{!c||n.length<=1||(F(),M.current=setInterval(()=>{if(P.current)return;const e=W.current+1;e>=n.length?$(0,!1):$(e,!0)},u))},[c,u,n.length,$,F]);useEffect(()=>(X(),()=>{F(),D.current&&clearTimeout(D.current)}),[X,F]),useEffect(()=>{const e=AppState.addEventListener("change",e=>{"active"!==e?(F(),D.current&&(clearTimeout(D.current),D.current=null)):X()});return()=>e.remove()},[X,F]);const B=m&&n.length>1&&"numbers"!==h||void 0!==o,G=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{x:V}}}],{useNativeDriver:!1,listener:o?e=>o(e.nativeEvent.contentOffset.x):void 0}),[V,o]),q=useCallback(e=>{if(_<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/_);L(n)},[_,L]),J=useCallback(()=>{P.current=!0,F(),D.current&&(clearTimeout(D.current),D.current=null)},[F]),K=useCallback(()=>{P.current=!1,c&&(D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{X()},1e3))},[c,X]),Q=useCallback(e=>{switch(e.nativeEvent.actionName){case"increment":N();break;case"decrement":O()}},[N,O]),U=useMemo(()=>buildStyles(v),[v]),Y=useCallback(({item:e,index:t})=>_jsx(View,{style:{width:R,marginRight:t===n.length-1?0:y},accessibilityElementsHidden:t!==H,importantForAccessibility:t===H?"yes":"no-hide-descendants",children:r(e,t)}),[r,R,y,n.length,H]),Z=useCallback((e,t)=>String(t),[]),ee=useCallback((e,t)=>({length:_,offset:_*t,index:t}),[_]);return C?_jsx(CarouselSkeleton,{...e,containerWidth:I}):_jsxs(View,{style:[U.container,p],onLayout:e=>T(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:b??"Carousel",accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:H,text:`Slide ${H+1} of ${n.length}`},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:f,children:[_jsx(FlatList,{ref:A,data:n,keyExtractor:i??Z,renderItem:Y,horizontal:!0,pagingEnabled:"screen"===g&&0===y,snapToInterval:_,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:B?G:void 0,scrollEventThrottle:B?16:void 0,onMomentumScrollEnd:q,onScrollBeginDrag:J,onScrollEndDrag:K,getItemLayout:ee,initialScrollIndex:E,bounces:!1}),m&&n.length>1?_jsx(Pagination,{count:n.length,currentIndex:H,scrollX:V,slideStride:_,variant:h,theme:v}):null,S&&n.length>0?_jsx(ThumbnailStrip,{data:n,currentIndex:H,renderThumbnail:w,onSelect:e=>{const t=resolveHaptic(x,"selection");t&&triggerHaptic(t),$(e,!0)},theme:v}):null]})});CarouselInner.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:i})=>{const a="screen"===e?i||320:e;return _jsxs(View,{style:[carouselSkeletonStyles.container,r],children:[_jsx(Skeleton,{width:a,height:160,radius:"md"}),t?_jsx(View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:12}],children:Array.from({length:3}).map((e,t)=>_jsx(Skeleton,"numbers"===n?{width:24,height:16,radius:"sm",style:{marginHorizontal:4}}:"bars"===n?{width:20,height:4,radius:2,style:{marginHorizontal:3}}:{shape:"circle",width:8,height:8,style:{marginHorizontal:4}},`sk-pg-${t}`))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const carouselSkeletonStyles=StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=CarouselInner;Carousel.Skeleton=CarouselSkeleton;const Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:i,theme:a})=>{if("numbers"===i)return _jsx(View,{style:paginationStyles.numbersWrap,children:_jsx(Text,{style:[paginationStyles.numbersText,{color:a.colors.text.secondary,fontSize:a.typography.fontSize.sm,fontWeight:a.typography.fontWeight.medium}],accessibilityLabel:`Slide ${t+1} of ${e}`,children:`${t+1} / ${e}`})});const l=Array.from({length:e},(e,t)=>t),s="bars"===i,o=s?24:6,c=s?36:16,u=s?3:6;return _jsx(View,{style:paginationStyles.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:l.map(e=>{const i=[(e-1)*r,e*r,(e+1)*r],l=n.interpolate({inputRange:i,outputRange:[o,c,o],extrapolate:"clamp"}),s=n.interpolate({inputRange:i,outputRange:[.5,1,.5],extrapolate:"clamp"});return _jsx(Animated.View,{style:[{width:l,height:u,marginHorizontal:4,borderRadius:u/2,...smoothCorners,backgroundColor:e===t?a.colors.primary:a.colors.border.primary,opacity:s}]},e)})})},ThumbnailStrip=({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:i})=>_jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:thumbStyles.row,accessibilityRole:"tablist",children:e.map((e,a)=>_jsx(ThumbnailItem,{item:e,index:a,isActive:a===t,renderThumbnail:n,onPress:()=>r(a),theme:i},a))}),ThumbnailItem=({item:e,index:t,isActive:n,renderThumbnail:r,onPress:i,theme:a})=>{const l=useRef(createAnimatedValue(n?1.1:1)).current;useEffect(()=>{const e=Animated.spring(l,{toValue:n?1.1:1,useNativeDriver:!0,friction:6,tension:80});return e.start(),()=>e.stop()},[n,l]);const s=useMemo(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?_jsx(Image,{source:{uri:e.uri},style:thumbStyles.image,resizeMode:"cover"}):_jsx(View,{style:[thumbStyles.placeholder,{backgroundColor:a.colors.background.secondary}],children:_jsx(Text,{style:{color:a.colors.text.secondary,fontSize:a.typography.fontSize.xs,fontWeight:a.typography.fontWeight.semibold},children:t+1})}),[e,t,r,a]);return _jsx(Pressable,{onPress:i,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:`Go to slide ${t+1}`,children:_jsx(Animated.View,{style:[thumbStyles.thumb,{borderColor:n?a.colors.primary:"transparent",transform:[{scale:l}]}],children:s})})},thumbStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:8,paddingVertical:8},thumb:{width:40,height:40,marginHorizontal:4,borderRadius:6,...smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>StyleSheet.create({container:{width:"100%"}}),paginationStyles=StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:12},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:12},numbersText:{textAlign:"center"}});export{Carousel};export default Carousel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,Easing,Modal,Pressable,StyleSheet,Text,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const AnimatedGestureRoot=Animated.createAnimatedComponent(GestureHandlerRootView),transparentOf=e=>{const t=e.match(/^rgba?\(([^)]+)\)$/);if(!t)return"transparent";const[a,r,i]=t[1].split(",").map(e=>e.trim());return`rgba(${a}, ${r}, ${i}, 0)`},GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),isSameDay=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),toIso=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,addMonths=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),buildMonthMatrix=(e,t)=>{const a=e.getFullYear(),r=e.getMonth(),i=(new Date(a,r,1).getDay()-t+7)%7,o=[];for(let e=0;e<42;e+=1){const t=new Date(a,r,1-i+e);o.push({date:t,inMonth:t.getMonth()===r,iso:toIso(t)})}return o},weekdayLabels=(e,t)=>{const a=new Intl.DateTimeFormat(e,{weekday:"short"}),r=[];for(let e=0;e<7;e+=1){const i=new Date(1970,0,4+(t+e)%7);r.push(a.format(i))}return r},formatMonthYear=(e,t)=>new Intl.DateTimeFormat(t,{month:"long",year:"numeric"}).format(e),formatLongDate=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(e),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:i,maxDate:o,disabledDates:s,mode:n="modal",locale:l="en-IN",weekStartsOn:c=0,title:d="Select Date",confirmLabel:u="Confirm",cancelLabel:m="Cancel",style:g,containerStyle:y,headerLabelStyle:p,navButtonStyle:h,footerButtonStyle:f,haptic:b,testID:x,label:D,placeholder:v,helperText:w,error:C,required:S,disabled:j,size:k,variant:P,clearable:A,onClear:T,formatValue:R,triggerStyle:V}=e,_=void 0!==e.visible,[M,I]=useState(!1),F=_?e.visible:M,L=_?x:x?`${x}-calendar`:void 0,B=useTheme(),Y=usePresenceMotion(),[$,z]=useModalInsets(),N=useMemo(()=>buildStyles(B),[B]),[H,W]=useState(()=>startOfDay(new Date));useEffect(()=>{F&&W(startOfDay(new Date))},[F]);const E=t?startOfDay(t):H,[O,G]=useState(E),[q,X]=useState(t?startOfDay(t):null),[Z,J]=useState("days"),K=useRef(createAnimatedValue(0)).current,Q=useRef(createAnimatedValue(0)).current,U=useRef(createAnimatedValue(0)).current,ee=useRef(0),te=useRef(createAnimatedValue(0)).current,ae=useRef(createAnimatedValue(1)).current,re=useRef(createAnimatedValue(1)).current,ie=useRef(createAnimatedValue(1)).current,oe=useRef(createAnimatedValue(1)).current,se=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(t){const e=startOfDay(t);X(e),G(e)}else X(null)},[t]);const ne=useMemo(()=>{const e=new Set;return s?.forEach(t=>e.add(toIso(startOfDay(t)))),e},[s]),le=useMemo(()=>i?startOfDay(i):null,[i]),ce=useMemo(()=>o?startOfDay(o):null,[o]),de=useCallback(e=>!!(le&&e.getTime()<le.getTime())||(!!(ce&&e.getTime()>ce.getTime())||!!ne.has(toIso(e))),[le,ce,ne]),ue=useMemo(()=>buildMonthMatrix(O,c),[O,c]),me=useMemo(()=>buildYearCells(O.getFullYear()),[O]),ge=useMemo(()=>buildDecadeCells(O.getFullYear()),[O]),ye=useMemo(()=>weekdayLabels(l,c),[l,c]),pe=useMemo(()=>{if("days"===Z)return formatMonthYear(O,l);if("years"===Z){return`${me[0]} - ${me[me.length-1]}`}return`${ge[0]} - ${ge[ge.length-1]+9}`},[O,ge,l,Z,me]),he=useCallback(e=>!!(le&&e<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),fe=useCallback(e=>!!(le&&e+10-1<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),be=useCallback(e=>{!1!==b&&triggerHaptic("impactLight");const t=e>0?1:-1,a=B.components.datePicker?.monthSlideDistance??32,r=B.components.datePicker?.monthSlideOutDuration??B.motion.duration.fast??140,i=B.components.datePicker?.monthSlideInDuration??B.motion.duration.fast??160,[o]=Y.range(-t*a,0),[s]=Y.range(t*a,0),n=Y.reduced?Y.duration("fast"):r,c=Y.reduced?Y.duration("fast"):i;Animated.sequence([Animated.parallel([Animated.timing(te,{toValue:o,duration:r,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(ae,{toValue:0,duration:n,useNativeDriver:!0})]),Animated.timing(te,{toValue:s,duration:0,useNativeDriver:!0}),Animated.parallel([Animated.timing(te,{toValue:0,duration:i,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(ae,{toValue:1,duration:c,useNativeDriver:!0})])]).start();const d=addMonths(O,e);G(d),AccessibilityInfo.announceForAccessibility(formatMonthYear(d,l))},[O,b,l,ae,te,Y,B.components.datePicker,B.motion.duration.fast]),xe=useCallback(()=>{"days"!==Z?(!1!==b&&triggerHaptic("impactLight"),G("years"===Z?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))):be(-1)},[be,Z,b]),De=useCallback(()=>{"days"!==Z?(!1!==b&&triggerHaptic("impactLight"),G("years"===Z?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))):be(1)},[be,Z,b]),ve=useCallback(()=>{const[e]=Y.range(.9,1),t=Y.reduced?Y.duration("normal"):B.components.datePicker?.viewTransitionDuration??B.motion.duration.normal??200;setNativeValue(ie,0),setNativeValue(oe,e),Animated.parallel([Animated.timing(ie,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(oe,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0})]).start()},[ie,oe,Y,B.components.datePicker,B.motion.duration.normal]),we=useCallback(()=>{const e=resolveHaptic(b,"selection");if(e&&triggerHaptic(e),!Y.reduced){const e=B.components.datePicker?.headerPressDuration??80,t=B.components.datePicker?.headerReleaseDuration??100;Animated.sequence([Animated.timing(se,{toValue:.96,duration:e,useNativeDriver:!0}),Animated.timing(se,{toValue:1,duration:t,useNativeDriver:!0})]).start()}J(e=>"days"===e?"years":"years"===e?"decades":"years"),ve()},[ve,se,b,Y.reduced,B.components.datePicker]),Ce=useCallback(e=>{const t=resolveHaptic(b,"selection");t&&triggerHaptic(t),G(t=>new Date(e,t.getMonth(),1)),J("days"),ve()},[ve,b]),Se=useCallback(e=>{const t=resolveHaptic(b,"selection");t&&triggerHaptic(t),G(t=>new Date(e+4,t.getMonth(),1)),J("years"),ve()},[ve,b]),je=useCallback(e=>{if(de(e.date))return;const t=resolveHaptic(b,"selection");t&&triggerHaptic(t),X(e.date),e.inMonth||G(new Date(e.date.getFullYear(),e.date.getMonth(),1)),Y.reduced||(setNativeValue(re,.7),Animated.spring(re,{toValue:1,damping:B.motion.spring.bouncy.damping,stiffness:B.motion.spring.bouncy.stiffness,mass:B.motion.spring.bouncy.mass,useNativeDriver:!0}).start())},[de,Y.reduced,re,B.motion.spring.bouncy,b]),ke=useCallback(()=>{_||I(!1),r?.()},[_,r]),Pe=useCallback(()=>{"modal"===n?Animated.parallel([Animated.timing(K,{toValue:0,duration:Y.duration("normal"),easing:Easing.bezier(...B.motion.easing.accelerate),useNativeDriver:!1}),Animated.timing(Q,{toValue:0,duration:Y.duration("fast"),easing:Easing.bezier(...B.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>{ke()}):ke()},[K,n,ke,Y,Q,B.motion.easing.accelerate]),{handleGesture:Ae,opacity:Te}=useDragToDismiss({drag:U,travel:()=>ee.current||320,onDismiss:Pe}),Re=useMemo(()=>Animated.multiply(Q,Te),[Q,Te]),Ve=useMemo(()=>K.interpolate({inputRange:[0,1],outputRange:[transparentOf(B.colors.background.overlay),B.colors.background.overlay]}),[K,B.colors.background.overlay]);useEffect(()=>{if("modal"===n&&F){K.setValue(0),setNativeValue(Q,0),setNativeValue(U,0),setNativeValue(Te,1);const e=Y.reduced?Animated.timing(Q,{toValue:1,duration:Y.duration("normal"),useNativeDriver:!0}):Animated.spring(Q,{toValue:1,damping:B.motion.spring.gentle.damping,stiffness:B.motion.spring.gentle.stiffness,mass:B.motion.spring.gentle.mass,useNativeDriver:!0}),t=Animated.parallel([Animated.timing(K,{toValue:1,duration:Y.duration("normal"),easing:Easing.out(Easing.cubic),useNativeDriver:!1}),e]);return t.start(),()=>t.stop()}},[F,n,K,Y,Q,U,Te,B.motion]);const Me=useCallback(()=>{!1!==b&&triggerHaptic("selection"),Pe()},[Pe,b]),Ie=useCallback(()=>{q&&(!1!==b&&triggerHaptic("notificationSuccess"),a?.(q),Pe())},[Pe,a,q,b]),Fe=Q.interpolate({inputRange:[0,1],outputRange:Y.range(320,0)}),Le=_jsx(View,{style:N.titleRow,children:_jsx(Text,{style:N.title,accessibilityRole:"header",children:d})}),Be=_jsxs(View,{style:[N.card,g,y],accessibilityRole:"modal"===n?void 0:"none",accessible:!1,testID:L,children:["modal"===n?_jsx(GestureDetector,{gesture:Ae,children:_jsxs(View,{style:N.grabArea,children:[_jsx(View,{style:N.handle}),Le]})}):Le,_jsxs(View,{style:N.headerRow,children:[_jsx(Pressable,{onPress:xe,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,h],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Previous month":"years"===Z?"Previous years":"Previous decades",hitSlop:8,children:_jsx(Text,{style:N.navText,children:"‹"})}),_jsx(Pressable,{onPress:we,style:[N.headerLabelWrap,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?`${pe}, switch to year selection`:"years"===Z?`${pe}, switch to decade selection`:`${pe}, switch to year selection`,hitSlop:8,children:_jsxs(Animated.View,{style:[N.headerLabelInner,{transform:[{scale:se}],opacity:"days"===Z?ae:1}],children:[_jsx(Animated.Text,{style:[N.headerLabel,{transform:[{translateX:"days"===Z?te:0}]}],accessibilityLiveRegion:"polite",children:pe}),_jsx(View,{style:N.headerCaret,children:(B.icons?.chevronDown??defaultIcons.chevronDown)({size:B.typography.fontSize.sm,color:B.colors.text.secondary})})]})}),_jsx(Pressable,{onPress:De,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,h],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Next month":"years"===Z?"Next years":"Next decades",hitSlop:8,children:_jsx(Text,{style:N.navText,children:"›"})})]}),"days"===Z?_jsxs(_Fragment,{children:[_jsx(View,{style:N.weekdayRow,children:ye.map((e,t)=>_jsx(View,{style:N.weekdayCell,children:_jsx(Text,{style:N.weekdayText,children:e})},`${e}-${t}`))}),_jsx(Animated.View,{style:[N.grid,{opacity:ae,transform:[{translateX:te}]}],children:Array.from({length:6}).map((e,t)=>_jsx(View,{style:N.gridRow,children:ue.slice(7*t,7*t+7).map(e=>{const t=de(e.date),a=!!q&&isSameDay(e.date,q),r=isSameDay(e.date,H),i=a?B.colors.primary:"transparent",o=r&&!a?B.colors.primary:"transparent",s=a?B.colors.onPrimary:e.inMonth?t?B.colors.text.disabled:B.colors.text.primary:B.colors.text.tertiary,n=t?.3:e.inMonth?1:.4;return _jsx(Pressable,{disabled:t,onPress:()=>je(e),accessibilityRole:"button",accessibilityLabel:formatLongDate(e.date,l),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:N.dayCell,children:_jsx(Animated.View,{style:[N.dayInner,{backgroundColor:i,borderColor:o,borderWidth:r&&!a?1.5:0,opacity:n},a?{transform:[{scale:re}]}:null],children:_jsx(Text,{style:[N.dayText,{color:s}],children:e.date.getDate()})})},e.iso)})},`r-${t}`))})]}):_jsx(Animated.View,"years"===Z?{style:[N.yearGrid,{opacity:ie,transform:[{scale:oe}]}],children:Array.from({length:3}).map((e,t)=>_jsx(View,{style:N.gridRow,children:me.slice(4*t,4*t+4).map(e=>{const t=he(e),a=!!q&&q.getFullYear()===e,r=H.getFullYear()===e,i=a?B.colors.primary:"transparent",o=r&&!a?B.colors.primary:"transparent",s=a?B.colors.onPrimary:t?B.colors.text.disabled:B.colors.text.primary,n=t?.3:1;return _jsx(Pressable,{disabled:t,onPress:()=>Ce(e),accessibilityRole:"button",accessibilityLabel:`Year ${e}`,accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:N.yearCell,children:_jsx(View,{style:[N.yearInner,{backgroundColor:i,borderColor:o,borderWidth:r&&!a?1.5:0,opacity:n}],children:_jsx(Text,{style:[N.yearText,{color:s}],children:e})})},`year-${e}`)})},`yr-${t}`))}:{style:[N.yearGrid,{opacity:ie,transform:[{scale:oe}]}],children:Array.from({length:3}).map((e,t)=>_jsx(View,{style:N.gridRow,children:ge.slice(4*t,4*t+4).map(e=>{const t=e+10-1,a=fe(e),r=!!q&&decadeStartFor(q.getFullYear())===e,i=decadeStartFor(H.getFullYear())===e,o=r?B.colors.primary:"transparent",s=i&&!r?B.colors.primary:"transparent",n=r?B.colors.onPrimary:a?B.colors.text.disabled:B.colors.text.primary,l=a?.3:1;return _jsx(Pressable,{disabled:a,onPress:()=>Se(e),accessibilityRole:"button",accessibilityLabel:`Decade ${e} to ${t}`,accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:N.yearCell,children:_jsxs(View,{style:[N.yearInner,{backgroundColor:o,borderColor:s,borderWidth:i&&!r?1.5:0,opacity:l}],children:[_jsx(Text,{style:[N.yearText,{color:n}],children:`${e}s`}),_jsx(Text,{style:[N.decadeRangeText,{color:r?B.colors.onPrimary:B.colors.text.tertiary}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${t}`))}),_jsxs(View,{style:N.footer,children:[_jsx(Pressable,{onPress:Me,style:({pressed:e})=>[N.footerBtn,N.footerCancel,e&&N.footerBtnPressed,f],accessibilityRole:"button",accessibilityLabel:m,children:_jsx(Text,{style:[N.footerBtnText,{color:B.colors.text.secondary}],children:m})}),_jsx(Pressable,{onPress:Ie,disabled:!q,style:({pressed:e})=>[N.footerBtn,N.footerConfirm,{backgroundColor:B.colors.primary,opacity:q?1:.5},e&&{backgroundColor:B.colors.primaryHover},f],accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{disabled:!q},"aria-disabled":!q,children:_jsx(Text,{style:[N.footerBtnText,{color:B.colors.onPrimary}],children:u})})]})]}),Ye=t?(R??(e=>e.toLocaleDateString()))(t):void 0,$e=!_;if("inline"===n)return F||$e?$e?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:D,value:Ye,placeholder:v,helperText:w,error:C,required:S,disabled:j,size:k,variant:P,clearable:A,onClear:T,onPress:()=>I(!0),triggerStyle:V,testID:x}),F?Be:null]}):Be:null;const ze=_jsx(Modal,{visible:F,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Pe,children:_jsx(ModalSafeArea,{onInsets:z,children:_jsxs(AnimatedGestureRoot,{collapsable:!1,style:[N.backdrop,{backgroundColor:Ve}],children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:Pe,accessibilityLabel:"Dismiss"}),_jsx(Animated.View,{style:[N.sheetWrap,{paddingBottom:Math.max($.bottom,B.spacing.lg),opacity:Re,transform:[{translateY:Animated.add(Fe,U)}]}],onLayout:e=>{ee.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Be}),_jsx(ToastHost,{})]})})});return $e?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:D,value:Ye,placeholder:v,helperText:w,error:C,required:S,disabled:j,size:k,variant:P,clearable:A,onClear:T,onPress:()=>I(!0),triggerStyle:V,testID:x}),ze]}):ze},buildStyles=e=>{const t=e.shadows.lg;return StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},sheetWrap:{position:"absolute",left:0,right:0,bottom:0,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.lg},card:{backgroundColor:e.colors.background.elevated,borderRadius:e.radius.xl,...smoothCorners,padding:e.spacing.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.spacing.lg,paddingTop:e.spacing.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.full,...smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},titleRow:{marginBottom:e.spacing.sm},title:{fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.spacing.md},navBtn:{width:e.components.datePicker?.navButtonSize??36,height:e.components.datePicker?.navButtonSize??36,borderRadius:e.radius.full,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors.background.secondary},navBtnPressed:{backgroundColor:e.colors.surface.pressed},navText:{fontSize:e.components.datePicker?.navTextFontSize??22,lineHeight:e.components.datePicker?.navTextLineHeight??24,color:e.colors.text.primary,fontWeight:e.typography.fontWeight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.typography.fontSize.base,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary},headerCaret:{marginLeft:e.spacing.xs,alignItems:"center",justifyContent:"center"},weekdayRow:{flexDirection:"row",marginBottom:e.spacing.xs},weekdayCell:{flex:1,alignItems:"center",paddingVertical:e.spacing.xs},weekdayText:{fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.medium,color:e.colors.text.tertiary,letterSpacing:e.typography.letterSpacing.wide},grid:{},gridRow:{flexDirection:"row"},dayCell:{flex:1,aspectRatio:1,alignItems:"center",justifyContent:"center",padding:e.components.datePicker?.dayCellPadding??2},dayInner:{width:"100%",height:"100%",borderRadius:e.components.datePicker?.dayInnerBorderRadius??e.radius.full,...smoothCorners,alignItems:"center",justifyContent:"center"},dayText:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.components.datePicker?.yearCellPadding??4},yearInner:{width:"100%",height:"100%",borderRadius:e.components.datePicker?.yearInnerBorderRadius??e.radius.lg,...smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.typography.fontSize.base,fontWeight:e.typography.fontWeight.semibold},decadeRangeText:{fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.medium,marginTop:e.components.datePicker?.decadeRangeMarginTop??2},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.spacing.lg,gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg,paddingVertical:e.spacing.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:e.components.datePicker?.footerButtonMinHeight??40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.semibold}})};export{DatePicker};export default DatePicker;
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,Easing,Modal,Pressable,StyleSheet,Text,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const AnimatedGestureRoot=Animated.createAnimatedComponent(GestureHandlerRootView),transparentOf=e=>{const t=e.match(/^rgba?\(([^)]+)\)$/);if(!t)return"transparent";const[a,r,i]=t[1].split(",").map(e=>e.trim());return`rgba(${a}, ${r}, ${i}, 0)`},GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),isSameDay=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),toIso=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,addMonths=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),buildMonthMatrix=(e,t)=>{const a=e.getFullYear(),r=e.getMonth(),i=(new Date(a,r,1).getDay()-t+7)%7,o=[];for(let e=0;e<42;e+=1){const t=new Date(a,r,1-i+e);o.push({date:t,inMonth:t.getMonth()===r,iso:toIso(t)})}return o},weekdayLabels=(e,t)=>{const a=new Intl.DateTimeFormat(e,{weekday:"short"}),r=[];for(let e=0;e<7;e+=1){const i=new Date(1970,0,4+(t+e)%7);r.push(a.format(i))}return r},formatMonthYear=(e,t)=>new Intl.DateTimeFormat(t,{month:"long",year:"numeric"}).format(e),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:i,maxDate:o,disabledDates:s,mode:n="modal",locale:l="en-IN",weekStartsOn:c=0,title:d="Select Date",confirmLabel:u="Confirm",cancelLabel:m="Cancel",style:g,containerStyle:y,headerLabelStyle:p,navButtonStyle:h,footerButtonStyle:f,haptic:b,testID:x,label:D,placeholder:v,helperText:w,error:C,required:S,disabled:j,size:k,variant:P,clearable:A,onClear:T,formatValue:R,triggerStyle:V}=e,_=void 0!==e.visible,[M,I]=useState(!1),F=_?e.visible:M,B=_?x:x?`${x}-calendar`:void 0,L=useTheme(),Y=usePresenceMotion(),[$,z]=useModalInsets(),N=useMemo(()=>buildStyles(L),[L]),[H,W]=useState(()=>startOfDay(new Date));useEffect(()=>{F&&W(startOfDay(new Date))},[F]);const E=t?startOfDay(t):H,[O,G]=useState(E),[q,X]=useState(t?startOfDay(t):null),[Z,J]=useState("days"),K=useRef(createAnimatedValue(0)).current,Q=useRef(createAnimatedValue(0)).current,U=useRef(createAnimatedValue(0)).current,ee=useRef(0),te=useRef(createAnimatedValue(0)).current,ae=useRef(createAnimatedValue(1)).current,re=useRef(createAnimatedValue(1)).current,ie=useRef(createAnimatedValue(1)).current,oe=useRef(createAnimatedValue(1)).current,se=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(t){const e=startOfDay(t);X(e),G(e)}else X(null)},[t]);const ne=useMemo(()=>{const e=new Set;return s?.forEach(t=>e.add(toIso(startOfDay(t)))),e},[s]),le=useMemo(()=>i?startOfDay(i):null,[i]),ce=useMemo(()=>o?startOfDay(o):null,[o]),de=useCallback(e=>!!(le&&e.getTime()<le.getTime())||(!!(ce&&e.getTime()>ce.getTime())||!!ne.has(toIso(e))),[le,ce,ne]),ue=useMemo(()=>buildMonthMatrix(O,c),[O,c]),me=useMemo(()=>buildYearCells(O.getFullYear()),[O]),ge=useMemo(()=>buildDecadeCells(O.getFullYear()),[O]),ye=useMemo(()=>weekdayLabels(l,c),[l,c]),pe=useMemo(()=>new Intl.DateTimeFormat(l,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),[l]),he=useMemo(()=>{if("days"===Z)return formatMonthYear(O,l);if("years"===Z){return`${me[0]} - ${me[me.length-1]}`}return`${ge[0]} - ${ge[ge.length-1]+9}`},[O,ge,l,Z,me]),fe=useCallback(e=>!!(le&&e<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),be=useCallback(e=>!!(le&&e+10-1<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),xe=useCallback(e=>{!1!==b&&triggerHaptic("impactLight");const t=e>0?1:-1,a=L.components.datePicker?.monthSlideDistance??32,r=L.components.datePicker?.monthSlideOutDuration??L.motion.duration.fast??140,i=L.components.datePicker?.monthSlideInDuration??L.motion.duration.fast??160,[o]=Y.range(-t*a,0),[s]=Y.range(t*a,0),n=Y.reduced?Y.duration("fast"):r,c=Y.reduced?Y.duration("fast"):i;Animated.sequence([Animated.parallel([Animated.timing(te,{toValue:o,duration:r,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(ae,{toValue:0,duration:n,useNativeDriver:!0})]),Animated.timing(te,{toValue:s,duration:0,useNativeDriver:!0}),Animated.parallel([Animated.timing(te,{toValue:0,duration:i,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(ae,{toValue:1,duration:c,useNativeDriver:!0})])]).start();const d=addMonths(O,e);G(d),AccessibilityInfo.announceForAccessibility(formatMonthYear(d,l))},[O,b,l,ae,te,Y,L.components.datePicker,L.motion.duration.fast]),De=useCallback(()=>{"days"!==Z?(!1!==b&&triggerHaptic("impactLight"),G("years"===Z?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))):xe(-1)},[xe,Z,b]),ve=useCallback(()=>{"days"!==Z?(!1!==b&&triggerHaptic("impactLight"),G("years"===Z?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))):xe(1)},[xe,Z,b]),we=useCallback(()=>{const[e]=Y.range(.9,1),t=Y.reduced?Y.duration("normal"):L.components.datePicker?.viewTransitionDuration??L.motion.duration.normal??200;setNativeValue(ie,0),setNativeValue(oe,e),Animated.parallel([Animated.timing(ie,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(oe,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0})]).start()},[ie,oe,Y,L.components.datePicker,L.motion.duration.normal]),Ce=useCallback(()=>{const e=resolveHaptic(b,"selection");if(e&&triggerHaptic(e),!Y.reduced){const e=L.components.datePicker?.headerPressDuration??80,t=L.components.datePicker?.headerReleaseDuration??100;Animated.sequence([Animated.timing(se,{toValue:.96,duration:e,useNativeDriver:!0}),Animated.timing(se,{toValue:1,duration:t,useNativeDriver:!0})]).start()}J(e=>"days"===e?"years":"years"===e?"decades":"years"),we()},[we,se,b,Y.reduced,L.components.datePicker]),Se=useCallback(e=>{const t=resolveHaptic(b,"selection");t&&triggerHaptic(t),G(t=>new Date(e,t.getMonth(),1)),J("days"),we()},[we,b]),je=useCallback(e=>{const t=resolveHaptic(b,"selection");t&&triggerHaptic(t),G(t=>new Date(e+4,t.getMonth(),1)),J("years"),we()},[we,b]),ke=useCallback(e=>{if(de(e.date))return;const t=resolveHaptic(b,"selection");t&&triggerHaptic(t),X(e.date),e.inMonth||G(new Date(e.date.getFullYear(),e.date.getMonth(),1)),Y.reduced||(setNativeValue(re,.7),Animated.spring(re,{toValue:1,damping:L.motion.spring.bouncy.damping,stiffness:L.motion.spring.bouncy.stiffness,mass:L.motion.spring.bouncy.mass,useNativeDriver:!0}).start())},[de,Y.reduced,re,L.motion.spring.bouncy,b]),Pe=useCallback(()=>{_||I(!1),r?.()},[_,r]),Ae=useCallback(()=>{"modal"===n?Animated.parallel([Animated.timing(K,{toValue:0,duration:Y.duration("normal"),easing:Easing.bezier(...L.motion.easing.accelerate),useNativeDriver:!1}),Animated.timing(Q,{toValue:0,duration:Y.duration("fast"),easing:Easing.bezier(...L.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>{Pe()}):Pe()},[K,n,Pe,Y,Q,L.motion.easing.accelerate]),{handleGesture:Te,opacity:Re}=useDragToDismiss({drag:U,travel:()=>ee.current||320,onDismiss:Ae}),Ve=useMemo(()=>Animated.multiply(Q,Re),[Q,Re]),Me=useMemo(()=>K.interpolate({inputRange:[0,1],outputRange:[transparentOf(L.colors.background.overlay),L.colors.background.overlay]}),[K,L.colors.background.overlay]);useEffect(()=>{if("modal"===n&&F){K.setValue(0),setNativeValue(Q,0),setNativeValue(U,0),setNativeValue(Re,1);const e=Y.reduced?Animated.timing(Q,{toValue:1,duration:Y.duration("normal"),useNativeDriver:!0}):Animated.spring(Q,{toValue:1,damping:L.motion.spring.gentle.damping,stiffness:L.motion.spring.gentle.stiffness,mass:L.motion.spring.gentle.mass,useNativeDriver:!0}),t=Animated.parallel([Animated.timing(K,{toValue:1,duration:Y.duration("normal"),easing:Easing.out(Easing.cubic),useNativeDriver:!1}),e]);return t.start(),()=>t.stop()}},[F,n,K,Y,Q,U,Re,L.motion]);const Ie=useCallback(()=>{!1!==b&&triggerHaptic("selection"),Ae()},[Ae,b]),Fe=useCallback(()=>{q&&(!1!==b&&triggerHaptic("notificationSuccess"),a?.(q),Ae())},[Ae,a,q,b]),Be=Q.interpolate({inputRange:[0,1],outputRange:Y.range(320,0)}),Le=_jsx(View,{style:N.titleRow,children:_jsx(Text,{style:N.title,accessibilityRole:"header",children:d})}),Ye=_jsxs(View,{style:[N.card,g,y],accessibilityRole:"modal"===n?void 0:"none",accessible:!1,testID:B,children:["modal"===n?_jsx(GestureDetector,{gesture:Te,children:_jsxs(View,{style:N.grabArea,children:[_jsx(View,{style:N.handle}),Le]})}):Le,_jsxs(View,{style:N.headerRow,children:[_jsx(Pressable,{onPress:De,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,h],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Previous month":"years"===Z?"Previous years":"Previous decades",hitSlop:8,children:_jsx(Text,{style:N.navText,children:"‹"})}),_jsx(Pressable,{onPress:Ce,style:[N.headerLabelWrap,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?`${he}, switch to year selection`:"years"===Z?`${he}, switch to decade selection`:`${he}, switch to year selection`,hitSlop:8,children:_jsxs(Animated.View,{style:[N.headerLabelInner,{transform:[{scale:se}],opacity:"days"===Z?ae:1}],children:[_jsx(Animated.Text,{style:[N.headerLabel,{transform:[{translateX:"days"===Z?te:0}]}],accessibilityLiveRegion:"polite",children:he}),_jsx(View,{style:N.headerCaret,children:(L.icons?.chevronDown??defaultIcons.chevronDown)({size:L.typography.fontSize.sm,color:L.colors.text.secondary})})]})}),_jsx(Pressable,{onPress:ve,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,h],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Next month":"years"===Z?"Next years":"Next decades",hitSlop:8,children:_jsx(Text,{style:N.navText,children:"›"})})]}),"days"===Z?_jsxs(_Fragment,{children:[_jsx(View,{style:N.weekdayRow,children:ye.map((e,t)=>_jsx(View,{style:N.weekdayCell,children:_jsx(Text,{style:N.weekdayText,children:e})},`${e}-${t}`))}),_jsx(Animated.View,{style:[N.grid,{opacity:ae,transform:[{translateX:te}]}],children:Array.from({length:6}).map((e,t)=>_jsx(View,{style:N.gridRow,children:ue.slice(7*t,7*t+7).map(e=>{const t=de(e.date),a=!!q&&isSameDay(e.date,q),r=isSameDay(e.date,H),i=a?L.colors.primary:"transparent",o=r&&!a?L.colors.primary:"transparent",s=a?L.colors.onPrimary:e.inMonth?t?L.colors.text.disabled:L.colors.text.primary:L.colors.text.tertiary,n=t?.3:e.inMonth?1:.4;return _jsx(Pressable,{disabled:t,onPress:()=>ke(e),accessibilityRole:"button",accessibilityLabel:pe.format(e.date),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:N.dayCell,children:_jsx(Animated.View,{style:[N.dayInner,{backgroundColor:i,borderColor:o,borderWidth:r&&!a?1.5:0,opacity:n},a?{transform:[{scale:re}]}:null],children:_jsx(Text,{style:[N.dayText,{color:s}],children:e.date.getDate()})})},e.iso)})},`r-${t}`))})]}):_jsx(Animated.View,"years"===Z?{style:[N.yearGrid,{opacity:ie,transform:[{scale:oe}]}],children:Array.from({length:3}).map((e,t)=>_jsx(View,{style:N.gridRow,children:me.slice(4*t,4*t+4).map(e=>{const t=fe(e),a=!!q&&q.getFullYear()===e,r=H.getFullYear()===e,i=a?L.colors.primary:"transparent",o=r&&!a?L.colors.primary:"transparent",s=a?L.colors.onPrimary:t?L.colors.text.disabled:L.colors.text.primary,n=t?.3:1;return _jsx(Pressable,{disabled:t,onPress:()=>Se(e),accessibilityRole:"button",accessibilityLabel:`Year ${e}`,accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:N.yearCell,children:_jsx(View,{style:[N.yearInner,{backgroundColor:i,borderColor:o,borderWidth:r&&!a?1.5:0,opacity:n}],children:_jsx(Text,{style:[N.yearText,{color:s}],children:e})})},`year-${e}`)})},`yr-${t}`))}:{style:[N.yearGrid,{opacity:ie,transform:[{scale:oe}]}],children:Array.from({length:3}).map((e,t)=>_jsx(View,{style:N.gridRow,children:ge.slice(4*t,4*t+4).map(e=>{const t=e+10-1,a=be(e),r=!!q&&decadeStartFor(q.getFullYear())===e,i=decadeStartFor(H.getFullYear())===e,o=r?L.colors.primary:"transparent",s=i&&!r?L.colors.primary:"transparent",n=r?L.colors.onPrimary:a?L.colors.text.disabled:L.colors.text.primary,l=a?.3:1;return _jsx(Pressable,{disabled:a,onPress:()=>je(e),accessibilityRole:"button",accessibilityLabel:`Decade ${e} to ${t}`,accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:N.yearCell,children:_jsxs(View,{style:[N.yearInner,{backgroundColor:o,borderColor:s,borderWidth:i&&!r?1.5:0,opacity:l}],children:[_jsx(Text,{style:[N.yearText,{color:n}],children:`${e}s`}),_jsx(Text,{style:[N.decadeRangeText,{color:r?L.colors.onPrimary:L.colors.text.tertiary}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${t}`))}),_jsxs(View,{style:N.footer,children:[_jsx(Pressable,{onPress:Ie,style:({pressed:e})=>[N.footerBtn,N.footerCancel,e&&N.footerBtnPressed,f],accessibilityRole:"button",accessibilityLabel:m,children:_jsx(Text,{style:[N.footerBtnText,{color:L.colors.text.secondary}],children:m})}),_jsx(Pressable,{onPress:Fe,disabled:!q,style:({pressed:e})=>[N.footerBtn,N.footerConfirm,{backgroundColor:L.colors.primary,opacity:q?1:.5},e&&{backgroundColor:L.colors.primaryHover},f],accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{disabled:!q},"aria-disabled":!q,children:_jsx(Text,{style:[N.footerBtnText,{color:L.colors.onPrimary}],children:u})})]})]}),$e=t?(R??(e=>e.toLocaleDateString()))(t):void 0,ze=!_;if("inline"===n)return F||ze?ze?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:D,value:$e,placeholder:v,helperText:w,error:C,required:S,disabled:j,size:k,variant:P,clearable:A,onClear:T,onPress:()=>I(!0),triggerStyle:V,testID:x}),F?Ye:null]}):Ye:null;const Ne=_jsx(Modal,{visible:F,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Ae,children:_jsx(ModalSafeArea,{onInsets:z,children:_jsxs(AnimatedGestureRoot,{collapsable:!1,style:[N.backdrop,{backgroundColor:Me}],children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:Ae,accessibilityLabel:"Dismiss"}),_jsx(Animated.View,{style:[N.sheetWrap,{paddingBottom:Math.max($.bottom,L.spacing.lg),opacity:Ve,transform:[{translateY:Animated.add(Be,U)}]}],onLayout:e=>{ee.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Ye}),_jsx(ToastHost,{})]})})});return ze?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:D,value:$e,placeholder:v,helperText:w,error:C,required:S,disabled:j,size:k,variant:P,clearable:A,onClear:T,onPress:()=>I(!0),triggerStyle:V,testID:x}),Ne]}):Ne},buildStyles=e=>{const t=e.shadows.lg;return StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},sheetWrap:{position:"absolute",left:0,right:0,bottom:0,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.lg},card:{backgroundColor:e.colors.background.elevated,borderRadius:e.radius.xl,...smoothCorners,padding:e.spacing.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.spacing.lg,paddingTop:e.spacing.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.full,...smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},titleRow:{marginBottom:e.spacing.sm},title:{fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.spacing.md},navBtn:{width:e.components.datePicker?.navButtonSize??36,height:e.components.datePicker?.navButtonSize??36,borderRadius:e.radius.full,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors.background.secondary},navBtnPressed:{backgroundColor:e.colors.surface.pressed},navText:{fontSize:e.components.datePicker?.navTextFontSize??22,lineHeight:e.components.datePicker?.navTextLineHeight??24,color:e.colors.text.primary,fontWeight:e.typography.fontWeight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.typography.fontSize.base,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary},headerCaret:{marginLeft:e.spacing.xs,alignItems:"center",justifyContent:"center"},weekdayRow:{flexDirection:"row",marginBottom:e.spacing.xs},weekdayCell:{flex:1,alignItems:"center",paddingVertical:e.spacing.xs},weekdayText:{fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.medium,color:e.colors.text.tertiary,letterSpacing:e.typography.letterSpacing.wide},grid:{},gridRow:{flexDirection:"row"},dayCell:{flex:1,aspectRatio:1,alignItems:"center",justifyContent:"center",padding:e.components.datePicker?.dayCellPadding??2},dayInner:{width:"100%",height:"100%",borderRadius:e.components.datePicker?.dayInnerBorderRadius??e.radius.full,...smoothCorners,alignItems:"center",justifyContent:"center"},dayText:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.components.datePicker?.yearCellPadding??4},yearInner:{width:"100%",height:"100%",borderRadius:e.components.datePicker?.yearInnerBorderRadius??e.radius.lg,...smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.typography.fontSize.base,fontWeight:e.typography.fontWeight.semibold},decadeRangeText:{fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.medium,marginTop:e.components.datePicker?.decadeRangeMarginTop??2},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.spacing.lg,gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg,paddingVertical:e.spacing.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:e.components.datePicker?.footerButtonMinHeight??40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.semibold}})};export{DatePicker};export default DatePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,Text,useWindowDimensions,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Button}from"../Button/index.js";import{IconBadge}from"../IconBadge/index.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton}from"../Skeleton/index.js";import{Swipeable}from"../Swipeable/index.js";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SIZE_FALLBACK={sm:{paddingVertical:"sm",titleFontSize:"sm",subtitleFontSize:"xs",minHeight:44},md:{paddingVertical:"md",titleFontSize:"base",subtitleFontSize:"sm",minHeight:56},lg:{paddingVertical:"lg",titleFontSize:"lg",subtitleFontSize:"sm",minHeight:72}},sizeFor=(e,t)=>{const i={...SIZE_FALLBACK[t],...e.components.listItem?.[t]??{}};return{paddingVertical:e.spacing[i.paddingVertical],titleSize:e.typography.fontSize[i.titleFontSize],subtitleSize:e.typography.fontSize[i.subtitleFontSize],minHeight:i.minHeight}},Chevron=({color:e})=>{const t=useTheme();return _jsx(_Fragment,{children:(t.icons?.chevronRight??defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,DEFAULT_BOX_SIZE=20,SelectionBox=({checked:e,disabled:t})=>{const i=useTheme(),s=i.components.checkbox?.md?.boxSize??20,o=Math.round(.72*s);return _jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.colors.border.width,borderRadius:i.radius.xs,...smoothCorners,borderColor:e?i.colors.primary:i.colors.border.primary,backgroundColor:e?i.colors.primary:t?i.colors.surface.disabled:"transparent"},children:e?_jsx(Svg,{width:o,height:o,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors.onPrimary,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.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>_jsx(Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,title:e.label,onPress:e.onPress},e.label)):e,ListItem=forwardRef((e,t)=>{const{title:i,loading:s=!1,subtitle:o,description:n,titleLines:r=1,subtitleLines:l=1,left:a,icon:c,iconTone:d="primary",right:m,rightPlacement:h="auto",selectable:u=!1,checked:g=!1,onCheckedChange:p,actions:x,onPress:b,haptic:f,selected:y=!1,disabled:S=!1,size:j="md",divider:_=!1,chevron:w=!1,leftActions:I,rightActions:L,contextMenu:k,accessibilityLabel:v,accessibilityHint:z,style:V,containerStyle:F,titleStyle:A,subtitleStyle:C,descriptionStyle:B,leftSlotStyle:R,rightSlotStyle:H,testID:D}=e,P=useTheme(),T=useMemo(()=>sizeFor(P,j),[P,j]),E=useMemo(()=>buildStyles(P),[P]),{fontScale:M}=useWindowDimensions(),W=!!m&&("below"===h||"auto"===h&&M>1.2),O=useContextMenu(S?void 0:k,{haptic:f||!1,testID:D}),G=useMemo(()=>mergeRefs(t,O.hostRef),[t,O.hostRef]),Z=u||!!b,N=Z||O.enabled,K=N&&!S,{style:U,pressIn:X,pressOut:q}=usePressAnimation({enabled:K}),J=useFlickGuard(),Q=v??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,Y=a??(void 0===c?null:_jsx(IconBadge,{icon:c,tone:d,size:BADGE_SIZE[j]})),$=u?_jsxs(View,{style:E.selectionLead,children:[_jsx(SelectionBox,{checked:g,disabled:S}),Y?_jsx(View,{style:E.selectionLeadContent,children:Y}):null]}):Y,ee=null!=x&&!1!==x&&!(Array.isArray(x)&&0===x.length),te=_&&!ee,ie=_jsxs(View,{style:[E.row,{paddingVertical:T.paddingVertical,minHeight:T.minHeight,backgroundColor:y?P.colors.surface.selected:"transparent"},te?E.divider:null,S?E.disabled:null,F],children:[$?_jsx(View,{style:[E.leftSlot,R],children:$}):null,_jsxs(View,{style:E.middle,children:[null==i||isText(i)?_jsx(Text,{style:[E.title,{fontSize:T.titleSize,...fontFor(P,"medium"),color:S?P.colors.text.disabled:P.colors.text.primary},A],numberOfLines:r,children:i??" "}):i,null==o||""===o?null:isText(o)?_jsx(Text,{style:[E.subtitle,{fontSize:T.subtitleSize,color:S?P.colors.text.disabled:P.colors.text.secondary},C],numberOfLines:l,children:o}):o,n?_jsx(Text,{style:[E.description,{fontSize:T.subtitleSize,color:S?P.colors.text.disabled:P.colors.text.tertiary},B],numberOfLines:2,children:n}):null,W?_jsx(View,{style:[E.rightBelow,H],children:m}):null]}),m&&!W||w?_jsxs(View,{style:[E.rightSlot,W?null:H],children:[W?null:m,w?_jsx(View,{style:m&&!W?E.chevronWithRight:null,children:_jsx(Chevron,{color:S?P.colors.text.disabled:P.colors.text.tertiary})}):null]}):null]}),se=N?_jsx(Animated.View,{style:[U,V],children:_jsx(Pressable,{ref:G,onPress:e=>{K&&Z&&!J.isFlick(e)&&(f&&triggerHaptic(f),u?p?.(!g):b?.(e))},onPressIn:e=>{J.onPressIn(e),X()},onPressOut:q,disabled:!K,accessibilityRole:u?"checkbox":b?"button":void 0,accessibilityLabel:Q,accessibilityHint:z,accessibilityState:u?{checked:g,disabled:!K}:{selected:y,disabled:!K},"aria-disabled":!K,...u?{"aria-checked":g}:{"aria-selected":y},testID:D,android_ripple:{color:P.colors.surface.pressed,borderless:!1},style:({pressed:e})=>e?E.pressed:null,...O.hostProps,children:ie})}):_jsx(View,{ref:t,accessibilityRole:"none",accessibilityLabel:Q,accessibilityHint:z,accessibilityState:{selected:y,disabled:S},"aria-selected":y,"aria-disabled":S,testID:D,style:V,children:ie}),oe=I&&I.length>0||L&&L.length>0,ne=ee?_jsxs(View,{style:[y?{backgroundColor:P.colors.surface.selected}:null,_?E.divider:null],children:[se,_jsx(View,{style:E.actions,children:renderActions(x)})]}):se,re=oe?_jsx(Swipeable,{leftActions:I,rightActions:L,accessibilityLabel:Q,children:ne}):ne;return s?_jsx(ListItemSkeleton,{...e}):O.enabled?_jsxs(_Fragment,{children:[re,O.renderSurface(_jsx(View,{style:E.preview,children:ie}))]}):re});ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,left:i,icon:s,right:o,chevron:n,size:r="md",containerStyle:l,style:a})=>{const c=useTheme(),d=sizeFor(c,r),m=Math.round(1.15*d.titleSize),h=Math.round(1.15*d.subtitleSize);return _jsxs(View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.spacing.md,paddingVertical:d.paddingVertical,minHeight:d.minHeight},l,a],children:[void 0!==i||void 0!==s?_jsx(View,{style:{marginRight:c.spacing.sm},children:_jsx(Skeleton,{shape:"circle",width:40,height:40})}):null,_jsxs(View,{style:{flex:1},children:[_jsx(Skeleton,{shape:"text",width:"70%",height:m,style:{marginBottom:c.spacing.xs}}),void 0!==e?_jsx(Skeleton,{shape:"text",width:"50%",height:h,style:void 0!==t?{marginBottom:c.spacing.xs}:void 0}):null,void 0!==t?_jsx(Skeleton,{shape:"text",width:"85%",height:h}):null]}),void 0!==o||n?_jsx(View,{style:{marginLeft:c.spacing.sm},children:_jsx(Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.spacing.md},divider:{borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors.border.primary},pressed:{backgroundColor:e.colors.surface.pressed},disabled:{opacity:.55},leftSlot:{marginRight:e.spacing.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.spacing.sm},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.spacing.xs},rightSlot:{marginLeft:e.spacing.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.spacing.sm,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.md},chevronWithRight:{marginLeft:e.spacing.xs},preview:{flex:1,backgroundColor:e.colors.background.elevated,borderRadius:e.radius.md,...smoothCorners,overflow:"hidden"},title:{letterSpacing:e.typography.letterSpacing.normal},subtitle:{marginTop:2,...fontFor(e,"normal")},description:{marginTop:2,...fontFor(e,"normal")}});export{ListItem};export default ListItem;
|
|
1
|
+
"use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,Text,useWindowDimensions,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Button}from"../Button/index.js";import{IconBadge}from"../IconBadge/index.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton}from"../Skeleton/index.js";import{Swipeable}from"../Swipeable/index.js";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SIZE_FALLBACK={sm:{paddingVertical:"sm",titleFontSize:"sm",subtitleFontSize:"xs",minHeight:44},md:{paddingVertical:"md",titleFontSize:"base",subtitleFontSize:"sm",minHeight:56},lg:{paddingVertical:"lg",titleFontSize:"lg",subtitleFontSize:"sm",minHeight:72}},sizeFor=(e,t)=>{const i={...SIZE_FALLBACK[t],...e.components.listItem?.[t]??{}};return{paddingVertical:e.spacing[i.paddingVertical],titleSize:e.typography.fontSize[i.titleFontSize],subtitleSize:e.typography.fontSize[i.subtitleFontSize],minHeight:i.minHeight}},Chevron=({color:e})=>{const t=useTheme();return _jsx(_Fragment,{children:(t.icons?.chevronRight??defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,DEFAULT_BOX_SIZE=20,SelectionBox=({checked:e,disabled:t})=>{const i=useTheme(),s=i.components.checkbox?.md?.boxSize??20,o=Math.round(.72*s);return _jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.colors.border.width,borderRadius:i.radius.xs,...smoothCorners,borderColor:e?i.colors.primary:i.colors.border.primary,backgroundColor:e?i.colors.primary:t?i.colors.surface.disabled:"transparent"},children:e?_jsx(Svg,{width:o,height:o,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors.onPrimary,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.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>_jsx(Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,title:e.label,onPress:e.onPress},e.label)):e,ListItem=React.memo(forwardRef((e,t)=>{const{title:i,loading:s=!1,subtitle:o,description:n,titleLines:r=1,subtitleLines:l=1,left:a,icon:c,iconTone:d="primary",right:m,rightPlacement:h="auto",selectable:u=!1,checked:g=!1,onCheckedChange:p,actions:x,onPress:b,haptic:f,selected:y=!1,disabled:S=!1,size:j="md",divider:_=!1,chevron:w=!1,leftActions:I,rightActions:L,contextMenu:k,accessibilityLabel:v,accessibilityHint:z,style:V,containerStyle:F,titleStyle:A,subtitleStyle:C,descriptionStyle:B,leftSlotStyle:R,rightSlotStyle:H,testID:D}=e,P=useTheme(),T=useMemo(()=>sizeFor(P,j),[P,j]),E=useMemo(()=>buildStyles(P),[P]),{fontScale:M}=useWindowDimensions(),W=!!m&&("below"===h||"auto"===h&&M>1.2),O=useContextMenu(S?void 0:k,{haptic:f||!1,testID:D}),G=useMemo(()=>mergeRefs(t,O.hostRef),[t,O.hostRef]),Z=u||!!b,N=Z||O.enabled,K=N&&!S,{style:U,pressIn:X,pressOut:q}=usePressAnimation({enabled:K}),J=useFlickGuard(),Q=v??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,Y=a??(void 0===c?null:_jsx(IconBadge,{icon:c,tone:d,size:BADGE_SIZE[j]})),$=u?_jsxs(View,{style:E.selectionLead,children:[_jsx(SelectionBox,{checked:g,disabled:S}),Y?_jsx(View,{style:E.selectionLeadContent,children:Y}):null]}):Y,ee=null!=x&&!1!==x&&!(Array.isArray(x)&&0===x.length),te=_&&!ee,ie=_jsxs(View,{style:[E.row,{paddingVertical:T.paddingVertical,minHeight:T.minHeight,backgroundColor:y?P.colors.surface.selected:"transparent"},te?E.divider:null,S?E.disabled:null,F],children:[$?_jsx(View,{style:[E.leftSlot,R],children:$}):null,_jsxs(View,{style:E.middle,children:[null==i||isText(i)?_jsx(Text,{style:[E.title,{fontSize:T.titleSize,...fontFor(P,"medium"),color:S?P.colors.text.disabled:P.colors.text.primary},A],numberOfLines:r,children:i??" "}):i,null==o||""===o?null:isText(o)?_jsx(Text,{style:[E.subtitle,{fontSize:T.subtitleSize,color:S?P.colors.text.disabled:P.colors.text.secondary},C],numberOfLines:l,children:o}):o,n?_jsx(Text,{style:[E.description,{fontSize:T.subtitleSize,color:S?P.colors.text.disabled:P.colors.text.tertiary},B],numberOfLines:2,children:n}):null,W?_jsx(View,{style:[E.rightBelow,H],children:m}):null]}),m&&!W||w?_jsxs(View,{style:[E.rightSlot,W?null:H],children:[W?null:m,w?_jsx(View,{style:m&&!W?E.chevronWithRight:null,children:_jsx(Chevron,{color:S?P.colors.text.disabled:P.colors.text.tertiary})}):null]}):null]}),se=N?_jsx(Animated.View,{style:[U,V],children:_jsx(Pressable,{ref:G,onPress:e=>{K&&Z&&!J.isFlick(e)&&(f&&triggerHaptic(f),u?p?.(!g):b?.(e))},onPressIn:e=>{J.onPressIn(e),X()},onPressOut:q,disabled:!K,accessibilityRole:u?"checkbox":b?"button":void 0,accessibilityLabel:Q,accessibilityHint:z,accessibilityState:u?{checked:g,disabled:!K}:{selected:y,disabled:!K},"aria-disabled":!K,...u?{"aria-checked":g}:{"aria-selected":y},testID:D,android_ripple:{color:P.colors.surface.pressed,borderless:!1},style:({pressed:e})=>e?E.pressed:null,...O.hostProps,children:ie})}):_jsx(View,{ref:t,accessibilityRole:"none",accessibilityLabel:Q,accessibilityHint:z,accessibilityState:{selected:y,disabled:S},"aria-selected":y,"aria-disabled":S,testID:D,style:V,children:ie}),oe=I&&I.length>0||L&&L.length>0,ne=ee?_jsxs(View,{style:[y?{backgroundColor:P.colors.surface.selected}:null,_?E.divider:null],children:[se,_jsx(View,{style:E.actions,children:renderActions(x)})]}):se,re=oe?_jsx(Swipeable,{leftActions:I,rightActions:L,accessibilityLabel:Q,children:ne}):ne;return s?_jsx(ListItemSkeleton,{...e}):O.enabled?_jsxs(_Fragment,{children:[re,O.renderSurface(_jsx(View,{style:E.preview,children:ie}))]}):re}));ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,left:i,icon:s,right:o,chevron:n,size:r="md",containerStyle:l,style:a})=>{const c=useTheme(),d=sizeFor(c,r),m=Math.round(1.15*d.titleSize),h=Math.round(1.15*d.subtitleSize);return _jsxs(View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.spacing.md,paddingVertical:d.paddingVertical,minHeight:d.minHeight},l,a],children:[void 0!==i||void 0!==s?_jsx(View,{style:{marginRight:c.spacing.sm},children:_jsx(Skeleton,{shape:"circle",width:40,height:40})}):null,_jsxs(View,{style:{flex:1},children:[_jsx(Skeleton,{shape:"text",width:"70%",height:m,style:{marginBottom:c.spacing.xs}}),void 0!==e?_jsx(Skeleton,{shape:"text",width:"50%",height:h,style:void 0!==t?{marginBottom:c.spacing.xs}:void 0}):null,void 0!==t?_jsx(Skeleton,{shape:"text",width:"85%",height:h}):null]}),void 0!==o||n?_jsx(View,{style:{marginLeft:c.spacing.sm},children:_jsx(Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.spacing.md},divider:{borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors.border.primary},pressed:{backgroundColor:e.colors.surface.pressed},disabled:{opacity:.55},leftSlot:{marginRight:e.spacing.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.spacing.sm},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.spacing.xs},rightSlot:{marginLeft:e.spacing.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.spacing.sm,paddingHorizontal:e.spacing.md,paddingBottom:e.spacing.md},chevronWithRight:{marginLeft:e.spacing.xs},preview:{flex:1,backgroundColor:e.colors.background.elevated,borderRadius:e.radius.md,...smoothCorners,overflow:"hidden"},title:{letterSpacing:e.typography.letterSpacing.normal},subtitle:{marginTop:2,...fontFor(e,"normal")},description:{marginTop:2,...fontFor(e,"normal")}});export{ListItem};export default ListItem;
|
|
@@ -94,7 +94,7 @@ export interface CardProps extends Omit<PressableProps, 'style' | 'children'> {
|
|
|
94
94
|
borderRadius?: number;
|
|
95
95
|
testID?: string;
|
|
96
96
|
}
|
|
97
|
-
declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<RNView
|
|
97
|
+
declare const Card: React.MemoExoticComponent<React.ForwardRefExoticComponent<CardProps & React.RefAttributes<RNView>>> & {
|
|
98
98
|
Skeleton: React.FC<CardProps>;
|
|
99
99
|
};
|
|
100
100
|
export { Card };
|
|
@@ -108,7 +108,7 @@ export interface ListItemProps {
|
|
|
108
108
|
rightSlotStyle?: StyleProp<ViewStyle>;
|
|
109
109
|
testID?: string;
|
|
110
110
|
}
|
|
111
|
-
declare const ListItem: React.ForwardRefExoticComponent<ListItemProps & React.RefAttributes<RNView
|
|
111
|
+
declare const ListItem: React.MemoExoticComponent<React.ForwardRefExoticComponent<ListItemProps & React.RefAttributes<RNView>>> & {
|
|
112
112
|
Skeleton: React.FC<ListItemProps>;
|
|
113
113
|
};
|
|
114
114
|
export { ListItem };
|
|
@@ -94,7 +94,7 @@ export interface CardProps extends Omit<PressableProps, 'style' | 'children'> {
|
|
|
94
94
|
borderRadius?: number;
|
|
95
95
|
testID?: string;
|
|
96
96
|
}
|
|
97
|
-
declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<RNView
|
|
97
|
+
declare const Card: React.MemoExoticComponent<React.ForwardRefExoticComponent<CardProps & React.RefAttributes<RNView>>> & {
|
|
98
98
|
Skeleton: React.FC<CardProps>;
|
|
99
99
|
};
|
|
100
100
|
export { Card };
|
|
@@ -108,7 +108,7 @@ export interface ListItemProps {
|
|
|
108
108
|
rightSlotStyle?: StyleProp<ViewStyle>;
|
|
109
109
|
testID?: string;
|
|
110
110
|
}
|
|
111
|
-
declare const ListItem: React.ForwardRefExoticComponent<ListItemProps & React.RefAttributes<RNView
|
|
111
|
+
declare const ListItem: React.MemoExoticComponent<React.ForwardRefExoticComponent<ListItemProps & React.RefAttributes<RNView>>> & {
|
|
112
112
|
Skeleton: React.FC<ListItemProps>;
|
|
113
113
|
};
|
|
114
114
|
export { ListItem };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-ui",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.5",
|
|
4
4
|
"description": "Beautiful, animated, accessible React Native components, theme and form engine for Webority projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@webority/mobile-core": "0.16.
|
|
110
|
+
"@webority/mobile-core": "0.16.5"
|
|
111
111
|
},
|
|
112
112
|
"scripts": {
|
|
113
113
|
"build": "bob build && node ../../scripts/minify-lib.mjs",
|