@webority/mobile-ui 0.95.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/canvas-kit/kit.css +0 -0
  2. package/dist/canvas-kit/kit.js +52518 -0
  3. package/dist/canvas-kit/manifest.json +21091 -0
  4. package/dist/canvas-kit/release.json +25 -0
  5. package/lib/commonjs/canvasKit/index.js +1 -1
  6. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  7. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  8. package/lib/commonjs/components/Banner/Banner.js +1 -1
  9. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  10. package/lib/commonjs/components/Button/Button.js +1 -1
  11. package/lib/commonjs/components/Calendar/Calendar.js +1 -1
  12. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  13. package/lib/commonjs/components/Chip/Chip.js +1 -1
  14. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  15. package/lib/commonjs/components/EmptyState/EmptyState.meta.js +1 -1
  16. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  17. package/lib/commonjs/components/IconButton/IconButton.js +1 -1
  18. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  19. package/lib/commonjs/components/InlineSelect/InlineSelect.js +1 -1
  20. package/lib/commonjs/components/Input/Input.js +1 -1
  21. package/lib/commonjs/components/KeyboardToolbar/KeyboardToolbar.js +1 -1
  22. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  23. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  24. package/lib/commonjs/components/Radio/Radio.js +1 -1
  25. package/lib/commonjs/components/Rating/Rating.js +1 -1
  26. package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
  27. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  28. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  29. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  30. package/lib/commonjs/components/Switch/Switch.js +1 -1
  31. package/lib/commonjs/components/Text/Text.js +1 -1
  32. package/lib/commonjs/components/Toast/Toast.js +1 -1
  33. package/lib/commonjs/index.js +1 -1
  34. package/lib/commonjs/theme/index.js +1 -1
  35. package/lib/module/canvasKit/index.js +1 -1
  36. package/lib/module/components/AppBar/AppBar.js +1 -1
  37. package/lib/module/components/Avatar/Avatar.js +1 -1
  38. package/lib/module/components/Banner/Banner.js +1 -1
  39. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  40. package/lib/module/components/Button/Button.js +1 -1
  41. package/lib/module/components/Calendar/Calendar.js +1 -1
  42. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  43. package/lib/module/components/Chip/Chip.js +1 -1
  44. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  45. package/lib/module/components/EmptyState/EmptyState.meta.js +1 -1
  46. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  47. package/lib/module/components/IconButton/IconButton.js +1 -1
  48. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  49. package/lib/module/components/InlineSelect/InlineSelect.js +1 -1
  50. package/lib/module/components/Input/Input.js +1 -1
  51. package/lib/module/components/KeyboardToolbar/KeyboardToolbar.js +1 -1
  52. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  53. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  54. package/lib/module/components/Radio/Radio.js +1 -1
  55. package/lib/module/components/Rating/Rating.js +1 -1
  56. package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
  57. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  58. package/lib/module/components/SliderField/SliderField.js +1 -1
  59. package/lib/module/components/Stepper/Stepper.js +1 -1
  60. package/lib/module/components/Switch/Switch.js +1 -1
  61. package/lib/module/components/Text/Text.js +1 -1
  62. package/lib/module/components/Toast/Toast.js +1 -1
  63. package/lib/module/index.js +1 -1
  64. package/lib/module/theme/index.js +1 -1
  65. package/lib/typescript/commonjs/canvasKit/index.d.ts +20 -3
  66. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +1 -0
  67. package/lib/typescript/commonjs/components/Button/Button.meta.d.ts +1 -1
  68. package/lib/typescript/commonjs/components/Card/Card.meta.d.ts +1 -1
  69. package/lib/typescript/commonjs/components/Checkbox/Checkbox.meta.d.ts +1 -1
  70. package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.meta.d.ts +1 -1
  71. package/lib/typescript/commonjs/components/EmptyState/EmptyState.meta.d.ts +1 -1
  72. package/lib/typescript/commonjs/components/Input/Input.meta.d.ts +1 -1
  73. package/lib/typescript/commonjs/components/Radio/Radio.meta.d.ts +1 -1
  74. package/lib/typescript/commonjs/components/SearchBar/SearchBar.meta.d.ts +1 -1
  75. package/lib/typescript/commonjs/components/Switch/Switch.meta.d.ts +1 -1
  76. package/lib/typescript/commonjs/components/Text/Text.meta.d.ts +1 -1
  77. package/lib/typescript/commonjs/index.d.ts +2 -3
  78. package/lib/typescript/commonjs/theme/index.d.ts +0 -20
  79. package/lib/typescript/module/canvasKit/index.d.ts +20 -3
  80. package/lib/typescript/module/components/AppBar/AppBar.d.ts +1 -0
  81. package/lib/typescript/module/components/Button/Button.meta.d.ts +1 -1
  82. package/lib/typescript/module/components/Card/Card.meta.d.ts +1 -1
  83. package/lib/typescript/module/components/Checkbox/Checkbox.meta.d.ts +1 -1
  84. package/lib/typescript/module/components/DecimalInput/DecimalInput.meta.d.ts +1 -1
  85. package/lib/typescript/module/components/EmptyState/EmptyState.meta.d.ts +1 -1
  86. package/lib/typescript/module/components/Input/Input.meta.d.ts +1 -1
  87. package/lib/typescript/module/components/Radio/Radio.meta.d.ts +1 -1
  88. package/lib/typescript/module/components/SearchBar/SearchBar.meta.d.ts +1 -1
  89. package/lib/typescript/module/components/Switch/Switch.meta.d.ts +1 -1
  90. package/lib/typescript/module/components/Text/Text.meta.d.ts +1 -1
  91. package/lib/typescript/module/index.d.ts +2 -3
  92. package/lib/typescript/module/theme/index.d.ts +0 -20
  93. package/package.json +10 -8
  94. package/lib/commonjs/initUI.js +0 -1
  95. package/lib/module/initUI.js +0 -1
  96. package/lib/typescript/commonjs/initUI.d.ts +0 -12
  97. package/lib/typescript/module/initUI.d.ts +0 -12
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.meta=void 0;var _meta=require("../../canvasKit/meta.js");const meta=exports.meta=(0,_meta.definePhoneMeta)()({name:"EmptyState",marker:null,platforms:["phone"],acceptsChildren:!1,props:{icon:{type:"node",description:"Illustration or icon drawn in a circle above the title."},title:{type:"string",required:!0,description:"Headline message."},description:{type:"string",description:"Supporting copy under the title."},size:{type:"enum",values:["sm","md","lg"],default:"md",description:"Icon size, type scale and vertical padding."},fill:{type:"boolean",default:!1,description:"Grows to fill the space it is given and centres its content; pass it as the empty component of a list."}},omit:["action","secondaryAction"],examples:[{id:"EmptyState.medium",title:"Medium",props:{title:"No messages yet",description:"Start a conversation with anyone in your contacts.",size:"md"}},{id:"EmptyState.small",title:"Small",props:{title:"No messages yet",description:"Start a conversation with anyone in your contacts.",size:"sm"}},{id:"EmptyState.large",title:"Large",props:{title:"No messages yet",description:"Start a conversation with anyone in your contacts.",size:"lg"}},{id:"EmptyState.titleOnly",title:"Title only",props:{title:"Nothing here"}}],usage:{when:["A list, search or screen has no data yet and needs a clear next step.","A load failed and the screen shows a message with a retry action."],whenNot:[{text:"Data is still loading.",instead:"Skeleton"},{text:"A short passing message about an action.",instead:"Toast"}],do:[{note:"Say what is missing and what to do about it.",example:[{component:"EmptyState",props:{title:"No orders yet",description:"When you place an order it will show up here."}}]}],dont:[{note:"Do not leave a bare title with no explanation.",example:[{component:"EmptyState",props:{title:"Empty"}}]}],a11y:["Announced as a summary region, so write the title and description as plain sentences.","Put the meaning in the title and description, not in the icon."]}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.meta=void 0;var _meta=require("../../canvasKit/meta.js");const meta=exports.meta=(0,_meta.definePhoneMeta)()({name:"EmptyState",marker:null,platforms:["phone"],acceptsChildren:!1,props:{icon:{type:"node",description:"Illustration or icon drawn in a circle above the title."},title:{type:"string",required:!0,description:"Headline message."},description:{type:"string",description:"Supporting copy under the title."},size:{type:"enum",values:["sm","md","lg"],default:"md",description:"Icon size, type scale and vertical padding."},fill:{type:"boolean",default:!1,description:"Grows to fill the space it is given and centres its content; pass it as the empty component of a list."},action:{type:"object",description:"The main button under the message, filled in the primary colour.",fields:{label:{type:"string",required:!0,description:"The button's text."},accessibilityLabel:{type:"string",description:"The spoken label, when it differs from the text."},accessibilityHint:{type:"string",description:"What pressing the button does, spoken after the label."}}},secondaryAction:{type:"object",description:"A second, quieter button beside the main one.",fields:{label:{type:"string",required:!0,description:"The button's text."},accessibilityLabel:{type:"string",description:"The spoken label, when it differs from the text."},accessibilityHint:{type:"string",description:"What pressing the button does, spoken after the label."}}}},omit:[],examples:[{id:"EmptyState.medium",title:"Medium",props:{title:"No messages yet",description:"Start a conversation with anyone in your contacts.",size:"md"}},{id:"EmptyState.small",title:"Small",props:{title:"No messages yet",description:"Start a conversation with anyone in your contacts.",size:"sm"}},{id:"EmptyState.large",title:"Large",props:{title:"No messages yet",description:"Start a conversation with anyone in your contacts.",size:"lg"}},{id:"EmptyState.titleOnly",title:"Title only",props:{title:"Nothing here"}}],usage:{when:["A list, search or screen has no data yet and needs a clear next step.","A load failed and the screen shows a message with a retry action."],whenNot:[{text:"Data is still loading.",instead:"Skeleton"},{text:"A short passing message about an action.",instead:"Toast"}],do:[{note:"Say what is missing and what to do about it.",example:[{component:"EmptyState",props:{title:"No orders yet",description:"When you place an order it will show up here."}}]}],dont:[{note:"Do not leave a bare title with no explanation.",example:[{component:"EmptyState",props:{title:"Empty"}}]}],a11y:["Announced as a summary region, so write the title and description as plain sentences.","Put the meaning in the title and description, not in the icon."]}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.matchesAccept=exports.formatFileSize=exports.default=exports.FilePicker=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index4=require("../FieldBase/index.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index5=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");let fileIdSeq=0;const nextFileId=()=>"wfp-"+ ++fileIdSeq,DEFAULT_LABELS={trigger:"Attach file",addMore:"Add more",sheetTitle:"Add from",removeFile:e=>`Remove ${e}`,retry:"Retry upload",errorTooMany:e=>`You can attach up to ${e} files.`,errorTooLarge:(e,t)=>`${e} is larger than ${t} MB.`,errorWrongType:e=>`${e} is not an accepted file type.`},formatFileSize=e=>{if(void 0===e||e<=0)return"";const t=["B","KB","MB","GB"];let r=e,i=0;for(;r>=1024&&i<t.length-1;)r/=1024,i+=1;return`${r>=10||0===i?Math.round(r):Math.round(10*r)/10} ${t[i]}`};exports.formatFileSize=formatFileSize;const matchesAccept=(e,t)=>!t||0===t.length||!!e&&t.some(t=>"*/*"===t||"*"===t||(t.endsWith("/*")?e.startsWith(t.slice(0,t.length-1)):e===t));exports.matchesAccept=matchesAccept;const isImage=e=>!0===e.type?.startsWith("image/")||!e.type&&/\.(png|jpe?g|gif|webp|heic)$/i.test(e.name),imageSourceOf=e=>e.thumbnailUrl??(isImage(e)?e.uri??e.url:void 0),extensionOf=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?"FILE":e.slice(t+1).toUpperCase().slice(0,4)},FilePicker=exports.FilePicker=(0,_react.forwardRef)((e,t)=>{const{files:r,defaultFiles:i,onChange:s,sources:o,maxFiles:n,maxSizeMB:l,accept:a,validate:c,process:d,variant:u="card",renderFile:x,renderTrigger:m,disabled:g=!1,helperText:h,error:p,labels:_,haptic:b,onPick:y,onRemove:f,onError:j,onFilePress:v,onRetry:R,style:T,accessibilityLabel:S,testID:C}=e,F=(0,_index2.useTheme)(),w=(0,_react.useMemo)(()=>buildStyles(F),[F]),z=(0,_react.useMemo)(()=>({...DEFAULT_LABELS,..._}),[_]),N=F.radius.md,P=F.colors.primary,[k,I]=(0,_index.useControllableState)({value:r,defaultValue:i??[],onChange:s}),O=(0,_react.useRef)(k);O.current=k;const V=(0,_react.useCallback)(e=>{O.current=e,I(e)},[I]),[B,L]=(0,_react.useState)(null),[M,A]=(0,_react.useState)(!1),$=p??B??void 0,H="number"==typeof n&&k.length>=n,q=(0,_react.useCallback)((e,t)=>{0!==e.length&&(L(e[0]),e.forEach(e=>j?.(e,t)),!1!==b&&(0,_index3.triggerHaptic)("notificationError"))},[j,b]),E=(0,_react.useCallback)(async e=>{let t;try{t=await e.pick()}catch(e){return void q([e instanceof Error?e.message:String(e)])}if(!t||0===t.length)return;const r=[];let i=t.map(e=>({id:nextFileId(),name:e.name??e.uri.split("/").pop()??"file",uri:e.uri,type:e.type,size:e.size,meta:e.meta,status:"idle"}));if("number"==typeof n){const e=Math.max(0,n-O.current.length);i.length>e&&(r.push(z.errorTooMany(n)),i=i.slice(0,e))}const s=[];for(const e of i){if("number"==typeof l&&"number"==typeof e.size&&e.size>1024*l*1024){r.push(z.errorTooLarge(e.name,l));continue}if(!matchesAccept(e.type,a)){r.push(z.errorWrongType(e.name));continue}const t=c?.(e);t?r.push(t):s.push(e)}if(q(r),0===s.length)return;if(!d){V([...O.current,...s]),L(r.length>0?r[0]:null);const e=(0,_index3.resolveHaptic)(b,"selection");return e&&(0,_index3.triggerHaptic)(e),void y?.(s)}const o=s.map(e=>({...e,status:"processing"}));V([...O.current,...o]);const u=[];for(const e of o)try{const t=await d({...e,status:"idle"}),r={...t,id:e.id,status:t.status??"idle"};V(O.current.map(t=>t.id===e.id?r:t)),u.push(r)}catch(t){V(O.current.filter(t=>t.id!==e.id)),q([t instanceof Error?t.message:String(t)],e)}if(u.length>0){0===r.length&&L(null);const e=(0,_index3.resolveHaptic)(b,"selection");e&&(0,_index3.triggerHaptic)(e),y?.(u)}},[n,l,a,c,d,z,q,V,y,b]),W=(0,_react.useCallback)(e=>{if(g||H)return;const t=e?o.find(t=>t.key===e):1===o.length?o[0]:void 0;t?E(t):o.length>1&&A(!0)},[g,H,o,E]),D=(0,_react.useCallback)(e=>{if(g)return;V(O.current.filter(t=>t.id!==e.id)),L(null);const t=(0,_index3.resolveHaptic)(b,"selection");t&&(0,_index3.triggerHaptic)(t),f?.(e)},[g,V,f,b]),U=(0,_react.useCallback)(()=>{V([]),L(null)},[V]);(0,_react.useImperativeHandle)(t,()=>({open:W,clear:U}),[W,U]);const G=0===k.length?z.trigger:`${k.length} file${1===k.length?"":"s"} attached`,K=S??`Attachments. ${G}`,statusText=e=>{switch(e.status){case"processing":return"Processing…";case"uploading":return`Uploading ${Math.round(100*(e.progress??0))}%`;case"done":return"Uploaded";case"error":return e.error??"Failed";default:return""}},fileA11yLabel=e=>[e.name,formatFileSize(e.size),statusText(e)].filter(Boolean).join(", "),Y=F.settings.icons.attachment??_defaultIcons.defaultIcons.attachment,renderStatusOverlay=e=>{if("processing"===e.status)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileOverlay,{backgroundColor:F.colors.scrim}],children:(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm"})});if("uploading"===e.status){const t=Math.round(100*(e.progress??0));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.tileOverlay,{backgroundColor:F.colors.scrim}],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.tileOverlayText,{color:F.colors["on-scrim"]}],children:`${t}%`}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileProgressTrack,{backgroundColor:F.colors.border}],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileProgressFill,{width:`${t}%`,backgroundColor:F.colors.primary}]})})]})}return"done"===e.status?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.doneBadge,{backgroundColor:F.colors.success}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.doneBadgeText,{color:F.colors["on-success"]}],children:"✓"})}):null},renderThumbnail=e=>{const t=imageSourceOf(e);return t?(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:t},style:w.thumbnailImage}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.extensionTile,{backgroundColor:F.colors["bg-subtle"]}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.extensionText,{color:F.colors["text-muted"],...(0,_index2.fontFor)(F,"semibold")}],children:extensionOf(e.name)})})},removeButton=e=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>D(e),disabled:g,hitSlop:8,accessibilityRole:"button",accessibilityLabel:z.removeFile(e.name),style:[w.removeButton,{backgroundColor:F.colors.scrim}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.removeButtonText,{color:F.colors["on-scrim"]}],children:"×"})}),retryButton=e=>R&&"error"===e.status?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>R(e),disabled:g,hitSlop:8,accessibilityRole:"button",accessibilityLabel:z.retry,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.retryText,{color:F.colors.primary}],children:"↻"})}):null,renderOneFile=(e,t)=>{const r={file:e,index:t,disabled:g,remove:()=>D(e),retry:R?()=>R(e):void 0},i=x?x(r):"card"===u?(e=>{const{file:t}=e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.tile,{width:84,height:84,borderRadius:N,..._corners.smoothCorners,borderColor:"error"===t.status?F.colors.danger:F.colors.border}],children:[renderThumbnail(t),renderStatusOverlay(t),"error"===t.status?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileOverlay,{backgroundColor:F.colors.scrim}],children:retryButton(t)}):null,removeButton(t)]})})(r):(e=>{const{file:t}=e,r=statusText(t);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.listRow,{borderRadius:N,..._corners.smoothCorners,borderColor:"error"===t.status?F.colors.danger:F.colors.border,backgroundColor:F.colors.bg}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.listThumb,{borderRadius:F.radius.sm,..._corners.smoothCorners}],children:[renderThumbnail(t),"processing"===t.status?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileOverlay,{backgroundColor:F.colors.scrim}],children:(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm"})}):null]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.listTextWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{numberOfLines:1,ellipsizeMode:"middle",style:[w.listName,{color:F.colors["text-body"],fontSize:F.text.sm.size,...(0,_index2.fontFor)(F,"medium")}],children:t.name}),(0,_jsxRuntime.jsx)(_reactNative.Text,{numberOfLines:1,style:[w.listSubtitle,{color:"error"===t.status?F.colors["danger-text"]:F.colors["text-subtle"],fontSize:F.text.xs.size}],children:[formatFileSize(t.size),r].filter(Boolean).join(" · ")}),"uploading"===t.status?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.listProgressTrack,{backgroundColor:F.colors.border}],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.listProgressFill,{width:`${Math.round(100*(t.progress??0))}%`,backgroundColor:F.colors.primary}]})}):null]}),retryButton(t),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>D(t),disabled:g,hitSlop:8,accessibilityRole:"button",accessibilityLabel:z.removeFile(t.name),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.listRemoveText,{color:F.colors["text-subtle"]}],children:"×"})})]})})(r);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:v?()=>v(e):void 0,disabled:g||!v,accessibilityLabel:fileA11yLabel(e),children:i},e.id)},J={open:W,disabled:g||H,fileCount:k.length,atCapacity:H},dashedTrigger=e=>(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>W(),disabled:g||H,accessibilityRole:"button",accessibilityLabel:K,accessibilityState:{disabled:g||H},"aria-disabled":g||H,style:({pressed:t})=>[w.trigger,e?w.triggerCompact:null,{borderRadius:N,..._corners.smoothCorners,borderColor:P,backgroundColor:t?F.colors["surface-pressed"]:F.colors.bg,opacity:g||H?.55:1}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.triggerRow,children:[Y?Y({size:16,color:F.colors.primary}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.triggerText,{color:F.colors.primary,fontSize:F.text.sm.size,...(0,_index2.fontFor)(F,"medium")}],children:0===k.length?z.trigger:z.addMore})]}),!e&&h?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.helperText,{color:F.colors["text-subtle"],fontSize:F.text.xs.size}],children:h}):null]}),Q=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>W(),disabled:g||H,accessibilityRole:"button",accessibilityLabel:z.addMore,style:({pressed:e})=>[w.tile,w.addTile,{width:84,height:84,borderRadius:N,..._corners.smoothCorners,borderColor:P,backgroundColor:e?F.colors["surface-pressed"]:"transparent",opacity:g||H?.55:1}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.addTileText,{color:F.colors.primary}],children:"+"})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.container,T],testID:C,accessibilityLabel:K,children:["card"===u?0===k.length?m?m(J):dashedTrigger(!1):(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:[w.strip,{columnGap:F.space.sm}],children:[k.map(renderOneFile),m?m(J):H||g?null:Q]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{rowGap:F.space.sm},children:[m?m(J):H?null:dashedTrigger(k.length>0),k.map(renderOneFile)]}),(0,_index4.hasFieldText)($)?(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityLiveRegion:"polite",style:[w.errorText,{color:F.colors["danger-text"],fontSize:F.text.xs.size,marginTop:F.space.xxs}],children:$}):null,(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:M,onClose:()=>A(!1),title:z.sheetTitle,options:o,labelOf:e=>e.label,getValue:e=>e.key,disabledOf:()=>!1,descriptionOf:e=>e.description,iconOf:e=>e.icon,isSelected:()=>!1,onSelect:e=>{A(!1),E(e)}})]})});FilePicker.displayName="FilePicker";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},trigger:{borderWidth:1,borderStyle:"dashed",alignItems:"center",minHeight:48,paddingVertical:e.space.md,paddingHorizontal:e.space.lg},triggerCompact:{minHeight:40,paddingVertical:e.space.sm},triggerRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},triggerText:{includeFontPadding:!1},helperText:{includeFontPadding:!1,marginTop:e.space.xs,textAlign:"center"},strip:{paddingVertical:e.space.xxs},tile:{borderWidth:1,overflow:"hidden"},addTile:{borderStyle:"dashed",alignItems:"center",justifyContent:"center"},addTileText:{fontSize:e.text["3xl"].size,includeFontPadding:!1},thumbnailImage:{width:"100%",height:"100%",resizeMode:"cover"},extensionTile:{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"},extensionText:{fontSize:e.text.sm.size,letterSpacing:1,includeFontPadding:!1},tileOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},tileOverlayText:{fontSize:e.text.sm.size,includeFontPadding:!1,marginBottom:e.space.xs},tileProgressTrack:{position:"absolute",left:8,right:8,bottom:8,height:3,borderRadius:e.radius.pill,..._corners.smoothCorners,overflow:"hidden"},tileProgressFill:{height:"100%",borderRadius:e.radius.pill,..._corners.smoothCorners},doneBadge:{position:"absolute",right:4,bottom:4,width:18,height:18,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},doneBadgeText:{fontSize:e.text.xs.size,includeFontPadding:!1},removeButton:{position:"absolute",top:4,right:4,width:20,height:20,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},removeButtonText:{fontSize:e.text.sm.size,lineHeight:15,includeFontPadding:!1},retryText:{fontSize:e.text.xl.size,includeFontPadding:!1},listRow:{flexDirection:"row",alignItems:"center",borderWidth:1,padding:e.space.sm,columnGap:e.space.sm},listThumb:{width:40,height:40,overflow:"hidden"},listTextWrap:{flex:1},listName:{includeFontPadding:!1},listSubtitle:{includeFontPadding:!1,marginTop:e.space.xxs},listProgressTrack:{height:3,borderRadius:e.radius.pill,..._corners.smoothCorners,overflow:"hidden",marginTop:e.space.xs},listProgressFill:{height:"100%",borderRadius:e.radius.pill,..._corners.smoothCorners},listRemoveText:{fontSize:e.text["2xl"].size,includeFontPadding:!1,paddingHorizontal:e.space.xs},errorText:{includeFontPadding:!1}});var _default=exports.default=FilePicker;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.matchesAccept=exports.formatFileSize=exports.default=exports.FilePicker=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index4=require("../FieldBase/index.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index5=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");let fileIdSeq=0;const nextFileId=()=>"wfp-"+ ++fileIdSeq,DEFAULT_LABELS={trigger:"Attach file",addMore:"Add more",sheetTitle:"Add from",removeFile:e=>`Remove ${e}`,retry:"Retry upload",errorTooMany:e=>`You can attach up to ${e} files.`,errorTooLarge:(e,t)=>`${e} is larger than ${t} MB.`,errorWrongType:e=>`${e} is not an accepted file type.`},formatFileSize=e=>{if(void 0===e||e<=0)return"";const t=["B","KB","MB","GB"];let r=e,i=0;for(;r>=1024&&i<t.length-1;)r/=1024,i+=1;return`${r>=10||0===i?Math.round(r):Math.round(10*r)/10} ${t[i]}`};exports.formatFileSize=formatFileSize;const matchesAccept=(e,t)=>!t||0===t.length||!!e&&t.some(t=>"*/*"===t||"*"===t||(t.endsWith("/*")?e.startsWith(t.slice(0,t.length-1)):e===t));exports.matchesAccept=matchesAccept;const isImage=e=>!0===e.type?.startsWith("image/")||!e.type&&/\.(png|jpe?g|gif|webp|heic)$/i.test(e.name),imageSourceOf=e=>e.thumbnailUrl??(isImage(e)?e.uri??e.url:void 0),extensionOf=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?"FILE":e.slice(t+1).toUpperCase().slice(0,4)},FilePicker=exports.FilePicker=(0,_react.forwardRef)((e,t)=>{const{files:r,defaultFiles:i,onChange:s,sources:o,maxFiles:n,maxSizeMB:l,accept:a,validate:c,process:d,variant:u="card",renderFile:x,renderTrigger:m,disabled:h=!1,helperText:g,error:p,labels:_,haptic:b,onPick:y,onRemove:f,onError:j,onFilePress:v,onRetry:R,style:S,accessibilityLabel:T,testID:C}=e,F=(0,_index2.useTheme)(),w=(0,_react.useMemo)(()=>buildStyles(F),[F]),z=(0,_react.useMemo)(()=>({...DEFAULT_LABELS,..._}),[_]),N=F.radius.md,P=F.colors.primary,[k,I]=(0,_index.useControllableState)({value:r,defaultValue:i??[],onChange:s}),O=(0,_react.useRef)(k);O.current=k;const V=(0,_react.useCallback)(e=>{O.current=e,I(e)},[I]),[M,B]=(0,_react.useState)(null),[L,A]=(0,_react.useState)(!1),$=p??M??void 0,q="number"==typeof n&&k.length>=n,H=(0,_react.useCallback)((e,t)=>{0!==e.length&&(B(e[0]),e.forEach(e=>j?.(e,t)),!1!==b&&(0,_index3.triggerHaptic)("notificationError"))},[j,b]),E=(0,_react.useCallback)(async e=>{let t;try{t=await e.pick()}catch(e){return void H([e instanceof Error?e.message:String(e)])}if(!t||0===t.length)return;const r=[];let i=t.map(e=>({id:nextFileId(),name:e.name??e.uri.split("/").pop()??"file",uri:e.uri,type:e.type,size:e.size,meta:e.meta,status:"idle"}));if("number"==typeof n){const e=Math.max(0,n-O.current.length);i.length>e&&(r.push(z.errorTooMany(n)),i=i.slice(0,e))}const s=[];for(const e of i){if("number"==typeof l&&"number"==typeof e.size&&e.size>1024*l*1024){r.push(z.errorTooLarge(e.name,l));continue}if(!matchesAccept(e.type,a)){r.push(z.errorWrongType(e.name));continue}const t=c?.(e);t?r.push(t):s.push(e)}if(H(r),0===s.length)return;if(!d){V([...O.current,...s]),B(r.length>0?r[0]:null);const e=(0,_index3.resolveHaptic)(b,"selection");return e&&(0,_index3.triggerHaptic)(e),void y?.(s)}const o=s.map(e=>({...e,status:"processing"}));V([...O.current,...o]);const u=[];for(const e of o)try{const t=await d({...e,status:"idle"}),r={...t,id:e.id,status:t.status??"idle"};V(O.current.map(t=>t.id===e.id?r:t)),u.push(r)}catch(t){V(O.current.filter(t=>t.id!==e.id)),H([t instanceof Error?t.message:String(t)],e)}if(u.length>0){0===r.length&&B(null);const e=(0,_index3.resolveHaptic)(b,"selection");e&&(0,_index3.triggerHaptic)(e),y?.(u)}},[n,l,a,c,d,z,H,V,y,b]),W=(0,_react.useCallback)(e=>{if(h||q)return;const t=e?o.find(t=>t.key===e):1===o.length?o[0]:void 0;t?E(t):o.length>1&&A(!0)},[h,q,o,E]),D=(0,_react.useCallback)(e=>{if(h)return;V(O.current.filter(t=>t.id!==e.id)),B(null);const t=(0,_index3.resolveHaptic)(b,"selection");t&&(0,_index3.triggerHaptic)(t),f?.(e)},[h,V,f,b]),U=(0,_react.useCallback)(()=>{V([]),B(null)},[V]);(0,_react.useImperativeHandle)(t,()=>({open:W,clear:U}),[W,U]);const G=0===k.length?z.trigger:`${k.length} file${1===k.length?"":"s"} attached`,K=T??`Attachments. ${G}`,statusText=e=>{switch(e.status){case"processing":return"Processing…";case"uploading":return`Uploading ${Math.round(100*(e.progress??0))}%`;case"done":return"Uploaded";case"error":return e.error??"Failed";default:return""}},fileA11yLabel=e=>[e.name,formatFileSize(e.size),statusText(e)].filter(Boolean).join(", "),Y=F.settings.icons.attachment??_defaultIcons.defaultIcons.attachment,renderStatusOverlay=e=>{if("processing"===e.status)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileOverlay,{backgroundColor:F.colors.scrim}],children:(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm"})});if("uploading"===e.status){const t=Math.round(100*(e.progress??0));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.tileOverlay,{backgroundColor:F.colors.scrim}],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.tileOverlayText,{color:F.colors["on-scrim"]}],children:`${t}%`}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileProgressTrack,{backgroundColor:F.colors.border}],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileProgressFill,{width:`${t}%`,backgroundColor:F.colors.primary}]})})]})}return"done"===e.status?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.doneBadge,{backgroundColor:F.colors.success}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.doneBadgeText,{color:F.colors["on-success"]}],children:"✓"})}):null},renderThumbnail=e=>{const t=imageSourceOf(e);return t?(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:t},style:w.thumbnailImage}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.extensionTile,{backgroundColor:F.colors["bg-subtle"]}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.extensionText,{color:F.colors["text-muted"],...(0,_index2.fontFor)(F,"semibold")}],children:extensionOf(e.name)})})},removeButton=e=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>D(e),disabled:h,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:z.removeFile(e.name),style:[w.removeButton,{backgroundColor:F.colors.scrim}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.removeButtonText,{color:F.colors["on-scrim"]}],children:"×"})}),retryButton=e=>R&&"error"===e.status?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>R(e),disabled:h,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:z.retry,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.retryText,{color:F.colors.primary}],children:"↻"})}):null,renderOneFile=(e,t)=>{const r={file:e,index:t,disabled:h,remove:()=>D(e),retry:R?()=>R(e):void 0},i=x?x(r):"card"===u?(e=>{const{file:t}=e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.tile,{width:84,height:84,borderRadius:N,..._corners.smoothCorners,borderColor:"error"===t.status?F.colors.danger:F.colors.border}],children:[renderThumbnail(t),renderStatusOverlay(t),"error"===t.status?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileOverlay,{backgroundColor:F.colors.scrim}],children:retryButton(t)}):null,removeButton(t)]})})(r):(e=>{const{file:t}=e,r=statusText(t);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.listRow,{borderRadius:N,..._corners.smoothCorners,borderColor:"error"===t.status?F.colors.danger:F.colors.border,backgroundColor:F.colors.bg}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.listThumb,{borderRadius:F.radius.sm,..._corners.smoothCorners}],children:[renderThumbnail(t),"processing"===t.status?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.tileOverlay,{backgroundColor:F.colors.scrim}],children:(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm"})}):null]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.listTextWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{numberOfLines:1,ellipsizeMode:"middle",style:[w.listName,{color:F.colors["text-body"],fontSize:F.text.sm.size,...(0,_index2.fontFor)(F,"medium")}],children:t.name}),(0,_jsxRuntime.jsx)(_reactNative.Text,{numberOfLines:1,style:[w.listSubtitle,{color:"error"===t.status?F.colors["danger-text"]:F.colors["text-subtle"],fontSize:F.text.xs.size}],children:[formatFileSize(t.size),r].filter(Boolean).join(" · ")}),"uploading"===t.status?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.listProgressTrack,{backgroundColor:F.colors.border}],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[w.listProgressFill,{width:`${Math.round(100*(t.progress??0))}%`,backgroundColor:F.colors.primary}]})}):null]}),retryButton(t),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>D(t),disabled:h,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:z.removeFile(t.name),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.listRemoveText,{color:F.colors["text-subtle"]}],children:"×"})})]})})(r);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:v?()=>v(e):void 0,disabled:h||!v,accessibilityLabel:fileA11yLabel(e),children:i},e.id)},J={open:W,disabled:h||q,fileCount:k.length,atCapacity:q},dashedTrigger=e=>(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>W(),disabled:h||q,accessibilityRole:"button",accessibilityLabel:K,accessibilityState:{disabled:h||q},"aria-disabled":h||q,style:({pressed:t})=>[w.trigger,e?w.triggerCompact:null,{borderRadius:N,..._corners.smoothCorners,borderColor:P,backgroundColor:t?F.colors["surface-pressed"]:F.colors.bg,opacity:h||q?.55:1}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.triggerRow,children:[Y?Y({size:16,color:F.colors.primary}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.triggerText,{color:F.colors.primary,fontSize:F.text.sm.size,...(0,_index2.fontFor)(F,"medium")}],children:0===k.length?z.trigger:z.addMore})]}),!e&&g?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.helperText,{color:F.colors["text-subtle"],fontSize:F.text.xs.size}],children:g}):null]}),Q=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>W(),disabled:h||q,accessibilityRole:"button",accessibilityLabel:z.addMore,style:({pressed:e})=>[w.tile,w.addTile,{width:84,height:84,borderRadius:N,..._corners.smoothCorners,borderColor:P,backgroundColor:e?F.colors["surface-pressed"]:"transparent",opacity:h||q?.55:1}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[w.addTileText,{color:F.colors.primary}],children:"+"})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.container,S],testID:C,accessibilityLabel:K,children:["card"===u?0===k.length?m?m(J):dashedTrigger(!1):(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:[w.strip,{columnGap:F.space.sm}],children:[k.map(renderOneFile),m?m(J):q||h?null:Q]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{rowGap:F.space.sm},children:[m?m(J):q?null:dashedTrigger(k.length>0),k.map(renderOneFile)]}),(0,_index4.hasFieldText)($)?(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityLiveRegion:"polite",style:[w.errorText,{color:F.colors["danger-text"],fontSize:F.text.xs.size,marginTop:F.space.xxs}],children:$}):null,(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:L,onClose:()=>A(!1),title:z.sheetTitle,options:o,labelOf:e=>e.label,getValue:e=>e.key,disabledOf:()=>!1,descriptionOf:e=>e.description,iconOf:e=>e.icon,isSelected:()=>!1,onSelect:e=>{A(!1),E(e)}})]})});FilePicker.displayName="FilePicker";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},trigger:{borderWidth:1,borderStyle:"dashed",alignItems:"center",minHeight:48,paddingVertical:e.space.md,paddingHorizontal:e.space.lg},triggerCompact:{minHeight:40,paddingVertical:e.space.sm},triggerRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},triggerText:{includeFontPadding:!1},helperText:{includeFontPadding:!1,marginTop:e.space.xs,textAlign:"center"},strip:{paddingVertical:e.space.xxs},tile:{borderWidth:1,overflow:"hidden"},addTile:{borderStyle:"dashed",alignItems:"center",justifyContent:"center"},addTileText:{fontSize:e.text["3xl"].size,includeFontPadding:!1},thumbnailImage:{width:"100%",height:"100%",resizeMode:"cover"},extensionTile:{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"},extensionText:{fontSize:e.text.sm.size,letterSpacing:1,includeFontPadding:!1},tileOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},tileOverlayText:{fontSize:e.text.sm.size,includeFontPadding:!1,marginBottom:e.space.xs},tileProgressTrack:{position:"absolute",left:8,right:8,bottom:8,height:3,borderRadius:e.radius.pill,..._corners.smoothCorners,overflow:"hidden"},tileProgressFill:{height:"100%",borderRadius:e.radius.pill,..._corners.smoothCorners},doneBadge:{position:"absolute",right:4,bottom:4,width:18,height:18,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},doneBadgeText:{fontSize:e.text.xs.size,includeFontPadding:!1},removeButton:{position:"absolute",top:4,right:4,width:20,height:20,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},removeButtonText:{fontSize:e.text.sm.size,lineHeight:15,includeFontPadding:!1},retryText:{fontSize:e.text.xl.size,includeFontPadding:!1},listRow:{flexDirection:"row",alignItems:"center",borderWidth:1,padding:e.space.sm,columnGap:e.space.sm},listThumb:{width:40,height:40,overflow:"hidden"},listTextWrap:{flex:1},listName:{includeFontPadding:!1},listSubtitle:{includeFontPadding:!1,marginTop:e.space.xxs},listProgressTrack:{height:3,borderRadius:e.radius.pill,..._corners.smoothCorners,overflow:"hidden",marginTop:e.space.xs},listProgressFill:{height:"100%",borderRadius:e.radius.pill,..._corners.smoothCorners},listRemoveText:{fontSize:e.text["2xl"].size,includeFontPadding:!1,paddingHorizontal:e.space.xs},errorText:{includeFontPadding:!1}});var _default=exports.default=FilePicker;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.IconButton=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const GLASS_RIM_WIDTH=1,HIT_SLOP=6,SOFT_FILL_OPACITY=.14,SIZE_MAP={sm:{diameter:32,icon:16},md:{diameter:40,icon:20},lg:{diameter:48,icon:24}},toneFor=(e,s)=>{switch(s){case"secondary":return{base:e.colors.neutral,on:e.colors["on-neutral"],fg:e.colors.neutral};case"success":return{base:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"]};case"warning":return{base:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"]};case"danger":return{base:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"]};case"neutral":return{base:e.colors["bg-muted"],on:e.colors["text-body"],fg:e.colors["text-body"]};default:return{base:e.colors.primary,on:e.colors["on-primary"],fg:e.colors.primary}}},IconButton=exports.IconButton=(0,_react.forwardRef)((e,s)=>{const{icon:r,iconVariant:o,onPress:t,accessibilityLabel:n,tone:i="primary",variant:a="solid",size:c="md",shape:l="circle",active:d=!1,disabled:u=!1,loading:b=!1,haptic:_,style:m,testID:x}=e,p=(0,_index.useTheme)(),g=SIZE_MAP[c],y=u||b,{style:I,pressIn:f,pressOut:h}=(0,_usePressAnimation.usePressAnimation)({scaleTo:.92,enabled:!y}),{base:j,on:S,fg:P}=toneFor(p,i),v=d?"solid":a;let q="transparent",A="transparent",w=0,R=y?p.colors["text-disabled"]:P;"solid"===v?(q=y?p.colors["surface-disabled"]:j,R=y?p.colors["text-disabled"]:S):"soft"===v?q=y?p.colors["surface-disabled"]:(0,_color.tintOf)(j,.14,p.colors["bg-subtle"]):"outline"===v?(A=y?p.colors.border:j,w=p.size.border):"glass"===v&&(q=p.colors["glass-fill"],A=p.colors["glass-border"],w=1,R=y?p.colors["text-disabled"]:p.colors["on-glass"]);const O={color:R,size:g.icon,disabled:y},B="circle"===l?g.diameter/2:p.radius.md;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:s,onPress:e=>{if(y)return;const s=(0,_index2.resolveHaptic)(_,"selection");s&&(0,_index2.triggerHaptic)(s),t?.(e)},onPressIn:f,onPressOut:h,disabled:y,accessibilityRole:"button",accessibilityLabel:n,accessibilityState:{disabled:y,selected:d},"aria-disabled":y,"aria-selected":d,hitSlop:6,...(0,_hitSlop.hitSlopMarker)(6),testID:x,style:({pressed:e})=>[styles.base,{width:g.diameter,height:g.diameter,borderRadius:B,..._corners.smoothCorners,backgroundColor:q,borderColor:A,borderWidth:w,opacity:e&&"solid"!==v?.7:1},m],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.content,I],children:b?(0,_jsxRuntime.jsx)(_index3.Spinner,{size:"sm",color:R}):(0,_slotIcon.renderSlotIcon)(r,O,o)})})});IconButton.displayName="IconButton";const styles=_reactNative.StyleSheet.create({base:{alignItems:"center",justifyContent:"center"},content:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=IconButton;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.IconButton=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const GLASS_RIM_WIDTH=1,HIT_SLOP=6,SOFT_FILL_OPACITY=.14,SIZE_MAP={sm:{diameter:32,icon:16},md:{diameter:40,icon:20},lg:{diameter:48,icon:24}},toneFor=(e,s)=>{switch(s){case"secondary":return{base:e.colors.neutral,outline:e.colors.border,on:e.colors["on-neutral"],fg:e.colors.neutral};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"]};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"]};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"]};case"neutral":return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"]};default:return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors.primary}}},IconButton=exports.IconButton=(0,_react.forwardRef)((e,s)=>{const{icon:r,iconVariant:o,onPress:t,accessibilityLabel:n,tone:i="primary",variant:c="solid",size:l="md",shape:a="circle",active:d=!1,disabled:u=!1,loading:b=!1,haptic:_,style:m,testID:g}=e,p=(0,_index.useTheme)(),x=SIZE_MAP[l],y=u||b,{style:I,pressIn:f,pressOut:h}=(0,_usePressAnimation.usePressAnimation)({scaleTo:.92,enabled:!y}),{base:j,outline:S,on:P,fg:v}=toneFor(p,i),q=d?"solid":c;let A="transparent",w="transparent",R=0,O=y?p.colors["text-disabled"]:v;"solid"===q?(A=y?p.colors["surface-disabled"]:j,O=y?p.colors["text-disabled"]:P):"soft"===q?A=y?p.colors["surface-disabled"]:(0,_color.tintOf)(j,.14,p.colors["bg-subtle"]):"outline"===q?(w=y?p.colors.border:S,R=p.size.border):"glass"===q&&(A=p.colors["glass-fill"],w=p.colors["glass-border"],R=1,O=y?p.colors["text-disabled"]:p.colors["on-glass"]);const B={color:O,size:x.icon,disabled:y},C="circle"===a?x.diameter/2:p.radius.md;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:s,onPress:e=>{if(y)return;const s=(0,_index2.resolveHaptic)(_,"selection");s&&(0,_index2.triggerHaptic)(s),t?.(e)},onPressIn:f,onPressOut:h,disabled:y,accessibilityRole:"button",accessibilityLabel:n,accessibilityState:{disabled:y,selected:d},"aria-disabled":y,"aria-selected":d,hitSlop:6,...(0,_hitSlop.hitSlopMarker)(6),testID:g,style:({pressed:e})=>[styles.base,{width:x.diameter,height:x.diameter,borderRadius:C,..._corners.smoothCorners,backgroundColor:A,borderColor:w,borderWidth:R,opacity:e&&"solid"!==q?.7:1},m],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.content,I],children:b?(0,_jsxRuntime.jsx)(_index3.Spinner,{size:"sm",color:O}):(0,_slotIcon.renderSlotIcon)(r,B,o)})})});IconButton.displayName="IconButton";const styles=_reactNative.StyleSheet.create({base:{alignItems:"center",justifyContent:"center"},content:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=IconButton;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ImageGallery=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Carousel/index.js"),_index4=require("../Skeleton/index.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,r=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=r&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?r(n,i,a):n[i]=e[i]);return n}const MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:t=0,showThumbnails:a=!0,showCounter:i=!0,enableLightbox:r=!0,enablePinchZoom:n=!0,onIndexChange:l,haptic:s,loading:o=!1,accessibilityLabel:c,containerStyle:u,testID:d})=>{const m=(0,_index.useTheme)(),_=(0,_react.useMemo)(()=>buildStyles(m),[m]),[h,g]=(0,_react.useState)(clamp(t,0,Math.max(0,e.length-1))),[v,x]=(0,_react.useState)(!1),p=(0,_react.useCallback)(e=>{g(e),l?.(e)},[l]),b=(0,_react.useCallback)(()=>{if(!r)return;const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),x(!0)},[r,s]),R=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),x(!1)},[s]),N=(0,_react.useCallback)((t,a)=>{const i=t.alt??`Image ${a+1} of ${e.length}`;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:b,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:r?"Tap to open fullscreen":void 0,style:_.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:t.source,style:_.image,resizeMode:"cover"})})},[r,e.length,b,_]),S=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:_.thumbnailImage,resizeMode:"cover"}),[_]),y=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[_.container,u],testID:d,accessibilityLabel:c??"Image gallery",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.carouselWrap,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{data:e,defaultIndex:t,onIndexChange:p,renderItem:N,showPagination:!1,showThumbnails:a,renderThumbnail:S,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[_.counterText,{color:m.colors["on-scrim"]}],accessibilityLabel:`Image ${h+1} of ${e.length}`,children:`${h+1} / ${e.length}`})}):null]}),r?(0,_jsxRuntime.jsx)(Lightbox,{visible:v,images:e,initialIndex:h,enablePinchZoom:n,showCounter:i,onClose:R,onIndexChange:p,haptic:s}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:a,showCounter:i,containerStyle:u,testID:d}):y};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:t=!0,showCounter:a=!0,containerStyle:i,testID:r})=>{const n=(0,_index.useTheme)(),l=Math.min(e?.length||4,6);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{width:"100%"},i],testID:r,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:"100%",height:280,radius:"lg"}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:n.space.md},children:Array.from({length:l}).map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:n.space.sm}},`sk-thumb-${t}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({visible:e,images:t,initialIndex:a,enablePinchZoom:i,showCounter:r,onClose:n,onIndexChange:l,haptic:s})=>{const o=(0,_index.useTheme)(),c=(0,_react.useMemo)(()=>buildLightboxStyles(o),[o]),u=(0,_react.useRef)(null),[d,m]=(0,_react.useState)(a),_=(0,_react.useCallback)(e=>{if(e!==d){const t=(0,_index2.resolveHaptic)(s,"selection");t&&(0,_index2.triggerHaptic)(t),m(e),l(e)}},[d,l,s]),h=(0,_react.useCallback)((e,a)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:a,total:t.length,active:a===d,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s}),[d,i,t.length,s]),g=t[d]?.caption;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:e,transparent:!0,statusBarTranslucent:!0,presentationStyle:"overFullScreen",animationType:"fade",onRequestClose:n,accessibilityViewIsModal:!0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.backdrop,accessibilityViewIsModal:!0,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{ref:u,data:t,defaultIndex:a,onIndexChange:_,renderItem:h,showPagination:!1,haptic:s}),r&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[c.counterText,{color:o.colors["on-scrim"]}],accessibilityLabel:`Image ${d+1} of ${t.length}`,children:`${d+1} / ${t.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:n,accessibilityRole:"button",accessibilityLabel:"Close gallery",style:c.closeButton,hitSlop:12,children:(o.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:o.colors["on-scrim"]})}),g?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:c.captionWrap,entering:void 0,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:c.captionText,numberOfLines:3,children:g})}):null,(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})},ZoomableImage=({image:e,index:t,total:a,active:i,enabled:r,maxScale:n,minScale:l,doubleTapScale:s,haptic:o})=>{const c=_reactNative.Dimensions.get("window"),u=(0,_reactNativeReanimated.useSharedValue)(1),d=(0,_reactNativeReanimated.useSharedValue)(1),m=(0,_reactNativeReanimated.useSharedValue)(0),_=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),g=(0,_reactNativeReanimated.useSharedValue)(0),v=(0,_react.useCallback)(()=>{u.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),d.value=1,m.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=0,g.value=0},[u,d,m,_,h,g]);_react.default.useEffect(()=>{i||(u.value=(0,_reactNativeReanimated.withTiming)(1,{duration:150}),m.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),_.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),d.value=1,h.value=0,g.value=0)},[i,u,m,_,d,h,g]);const x=(0,_react.useCallback)(()=>{!1!==o&&(0,_index2.triggerHaptic)("impactLight")},[o]),p=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(r).onStart(()=>{"worklet";d.value=u.value}).onUpdate(e=>{"worklet";const t=d.value*e.scale;u.value=t<l?l+.3*(t-l):t>n?n+.2*(t-n):t}).onEnd(()=>{"worklet";return u.value<l?(u.value=(0,_reactNativeReanimated.withSpring)(l,SPRING_CONFIG),m.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),d.value=l,h.value=0,void(g.value=0)):u.value>n?(u.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),void(d.value=n)):void(d.value=u.value)}),[r,u,d,m,_,h,g,l,n]),b=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().minPointers(1).maxPointers(1).onStart(()=>{"worklet";h.value=m.value,g.value=_.value}).onUpdate(e=>{"worklet";u.value<=1||(m.value=h.value+e.translationX,_.value=g.value+e.translationY)}).onEnd(()=>{"worklet";h.value=m.value,g.value=_.value}),[u,m,_,h,g]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(x)(),u.value>1?(u.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),m.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),d.value=1,h.value=0,g.value=0):(u.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),d.value=s)}),[u,d,m,_,h,g,x,s]),N=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(p,b,R),[p,b,R]),S=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:m.value},{translateY:_.value},{scale:u.value}]}));_react.default.useEffect(()=>{i||v()},[i,v]);const y=e.alt??`Image ${t+1} of ${a}`;return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:N,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[lightboxImageStyles.container,{width:c.width}],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,S],accessibilityLabel:y,accessible:!0})})})},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,..._corners.smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"},counterText:{fontSize:e.text.sm.size,fontWeight:e.weight.semibold}}),buildLightboxStyles=e=>_reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},counterText:{fontSize:e.text.sm.size,fontWeight:e.weight.semibold},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:"#FFFFFF",fontSize:e.text.base.size,lineHeight:21,textAlign:"center"}}),lightboxImageStyles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});var _default=exports.default=ImageGallery;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ImageGallery=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Carousel/index.js"),_index4=require("../Skeleton/index.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,r=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=r&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?r(n,i,a):n[i]=e[i]);return n}const MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:t=0,showThumbnails:a=!0,showCounter:i=!0,enableLightbox:r=!0,enablePinchZoom:n=!0,onIndexChange:l,haptic:s,loading:o=!1,accessibilityLabel:c,containerStyle:u,testID:d})=>{const m=(0,_index.useTheme)(),_=(0,_react.useMemo)(()=>buildStyles(m),[m]),[h,g]=(0,_react.useState)(clamp(t,0,Math.max(0,e.length-1))),[v,x]=(0,_react.useState)(!1),p=(0,_react.useCallback)(e=>{g(e),l?.(e)},[l]),b=(0,_react.useCallback)(()=>{if(!r)return;const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),x(!0)},[r,s]),R=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),x(!1)},[s]),S=(0,_react.useCallback)((t,a)=>{const i=t.alt??`Image ${a+1} of ${e.length}`;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:b,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:r?"Tap to open fullscreen":void 0,style:_.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:t.source,style:_.image,resizeMode:"cover"})})},[r,e.length,b,_]),N=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:_.thumbnailImage,resizeMode:"cover"}),[_]),y=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[_.container,u],testID:d,accessibilityLabel:c??"Image gallery",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.carouselWrap,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{data:e,defaultIndex:t,onIndexChange:p,renderItem:S,showPagination:!1,showThumbnails:a,renderThumbnail:N,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[_.counterText,{color:m.colors["on-scrim"]}],accessibilityLabel:`Image ${h+1} of ${e.length}`,children:`${h+1} / ${e.length}`})}):null]}),r?(0,_jsxRuntime.jsx)(Lightbox,{visible:v,images:e,initialIndex:h,enablePinchZoom:n,showCounter:i,onClose:R,onIndexChange:p,haptic:s}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:a,showCounter:i,containerStyle:u,testID:d}):y};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:t=!0,showCounter:a=!0,containerStyle:i,testID:r})=>{const n=(0,_index.useTheme)(),l=Math.min(e?.length||4,6);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{width:"100%"},i],testID:r,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:"100%",height:280,radius:"lg"}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:n.space.md},children:Array.from({length:l}).map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:n.space.sm}},`sk-thumb-${t}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({visible:e,images:t,initialIndex:a,enablePinchZoom:i,showCounter:r,onClose:n,onIndexChange:l,haptic:s})=>{const o=(0,_index.useTheme)(),c=(0,_react.useMemo)(()=>buildLightboxStyles(o),[o]),u=(0,_react.useRef)(null),[d,m]=(0,_react.useState)(a),_=(0,_react.useCallback)(e=>{if(e!==d){const t=(0,_index2.resolveHaptic)(s,"selection");t&&(0,_index2.triggerHaptic)(t),m(e),l(e)}},[d,l,s]),h=(0,_react.useCallback)((e,a)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:a,total:t.length,active:a===d,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s}),[d,i,t.length,s]),g=t[d]?.caption;return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:e,transparent:!0,statusBarTranslucent:!0,presentationStyle:"overFullScreen",animationType:"fade",onRequestClose:n,accessibilityViewIsModal:!0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.backdrop,accessibilityViewIsModal:!0,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{ref:u,data:t,defaultIndex:a,onIndexChange:_,renderItem:h,showPagination:!1,haptic:s}),r&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[c.counterText,{color:o.colors["on-scrim"]}],accessibilityLabel:`Image ${d+1} of ${t.length}`,children:`${d+1} / ${t.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:n,accessibilityRole:"button",accessibilityLabel:"Close gallery",style:c.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(o.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:o.colors["on-scrim"]})}),g?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:c.captionWrap,entering:void 0,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:c.captionText,numberOfLines:3,children:g})}):null,(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})},ZoomableImage=({image:e,index:t,total:a,active:i,enabled:r,maxScale:n,minScale:l,doubleTapScale:s,haptic:o})=>{const c=_reactNative.Dimensions.get("window"),u=(0,_reactNativeReanimated.useSharedValue)(1),d=(0,_reactNativeReanimated.useSharedValue)(1),m=(0,_reactNativeReanimated.useSharedValue)(0),_=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),g=(0,_reactNativeReanimated.useSharedValue)(0),v=(0,_react.useCallback)(()=>{u.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),d.value=1,m.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=0,g.value=0},[u,d,m,_,h,g]);_react.default.useEffect(()=>{i||(u.value=(0,_reactNativeReanimated.withTiming)(1,{duration:150}),m.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),_.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),d.value=1,h.value=0,g.value=0)},[i,u,m,_,d,h,g]);const x=(0,_react.useCallback)(()=>{!1!==o&&(0,_index2.triggerHaptic)("impactLight")},[o]),p=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(r).onStart(()=>{"worklet";d.value=u.value}).onUpdate(e=>{"worklet";const t=d.value*e.scale;u.value=t<l?l+.3*(t-l):t>n?n+.2*(t-n):t}).onEnd(()=>{"worklet";return u.value<l?(u.value=(0,_reactNativeReanimated.withSpring)(l,SPRING_CONFIG),m.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),d.value=l,h.value=0,void(g.value=0)):u.value>n?(u.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),void(d.value=n)):void(d.value=u.value)}),[r,u,d,m,_,h,g,l,n]),b=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().minPointers(1).maxPointers(1).onStart(()=>{"worklet";h.value=m.value,g.value=_.value}).onUpdate(e=>{"worklet";u.value<=1||(m.value=h.value+e.translationX,_.value=g.value+e.translationY)}).onEnd(()=>{"worklet";h.value=m.value,g.value=_.value}),[u,m,_,h,g]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(x)(),u.value>1?(u.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),m.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),d.value=1,h.value=0,g.value=0):(u.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),d.value=s)}),[u,d,m,_,h,g,x,s]),S=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(p,b,R),[p,b,R]),N=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:m.value},{translateY:_.value},{scale:u.value}]}));_react.default.useEffect(()=>{i||v()},[i,v]);const y=e.alt??`Image ${t+1} of ${a}`;return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:S,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[lightboxImageStyles.container,{width:c.width}],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,N],accessibilityLabel:y,accessible:!0})})})},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,..._corners.smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"},counterText:{fontSize:e.text.sm.size,fontWeight:e.weight.semibold}}),buildLightboxStyles=e=>_reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},counterText:{fontSize:e.text.sm.size,fontWeight:e.weight.semibold},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:"#FFFFFF",fontSize:e.text.base.size,lineHeight:21,textAlign:"center"}}),lightboxImageStyles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});var _default=exports.default=ImageGallery;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.InlineSelect=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_jsxRuntime=require("react/jsx-runtime");const InlineSelect=exports.InlineSelect=(0,_react.forwardRef)((e,t)=>{const{options:i,getOptionLabel:l,getOptionValue:s,getOptionDisabled:a,getOptionDescription:r,getOptionIcon:n,value:c,onChange:o,placeholder:d,label:u,title:x,searchable:p=!1,haptic:_,disabled:b=!1,size:S="md",color:h,chevronColor:y,chevronSize:m,textStyle:g,style:j,optionStyle:v,selectedOptionStyle:O,optionTextStyle:f,selectedOptionTextStyle:C,accessibilityLabel:I,testID:R}=e,F=(0,_index.useTheme)(),k=(0,_react.useMemo)(()=>buildStyles(F),[F]),q=(0,_index.resolveFieldSize)(F,S),T=(0,_react.useCallback)(e=>l?l(e):e.label??"",[l]),N=(0,_react.useCallback)(e=>s?s(e):e.value,[s]),z=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),L=(0,_react.useCallback)(e=>r?r(e):e.description,[r]),B=(0,_react.useCallback)(e=>n?n(e):e.icon,[n]),[D,H]=(0,_react.useState)(!1),P=(0,_react.useMemo)(()=>{if(null!=c)return i.find(e=>N(e)===c)},[i,c,N]),w=(0,_react.useCallback)(e=>c===e,[c]),M=(0,_react.useCallback)(()=>{if(b)return;const e=(0,_index2.resolveHaptic)(_,"selection");e&&(0,_index2.triggerHaptic)(e),H(!0)},[b,_]),V=(0,_react.useCallback)(()=>{H(!1)},[]),$=(0,_react.useCallback)(e=>{if(z(e))return;const t=(0,_index2.resolveHaptic)(_,"selection");t&&(0,_index2.triggerHaptic)(t),o(N(e)),V()},[z,N,o,V,_]),G=b?F.colors["text-disabled"]:h??F.colors.primary,A=void 0!==P?T(P):d??"Select",E=void 0!==P?`Selected: ${T(P)}`:d??"No selection",J=I??`${u??x??"Select"}. ${E}`,K=(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:M,disabled:b,hitSlop:8,accessibilityRole:"button",accessibilityLabel:J,accessibilityState:{disabled:b,expanded:D},"aria-disabled":b,"aria-expanded":D,testID:R,style:({pressed:e})=>[k.trigger,{columnGap:F.space.xs,opacity:e&&!b?.6:1},j],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[k.triggerText,{color:G,fontSize:q.text,...(0,_index.fontFor)(F,"medium")},g],numberOfLines:1,children:A}),(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:y??G,size:m??q.icon,open:D})]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[u?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:k.labelled,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:S,children:u}),K]}):K,(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:D,onClose:V,title:x,accessibilityLabel:u??x??d??"Options",options:i,labelOf:T,getValue:N,disabledOf:z,descriptionOf:L,iconOf:B,isSelected:w,onSelect:$,searchable:p,optionStyle:v,selectedOptionStyle:O,optionTextStyle:f,selectedOptionTextStyle:C})]})});InlineSelect.displayName="InlineSelect";const buildStyles=e=>_reactNative.StyleSheet.create({labelled:{alignItems:"flex-start"},trigger:{flexDirection:"row",alignItems:"center"},triggerText:{includeFontPadding:!1}});var _default=exports.default=InlineSelect;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.InlineSelect=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_hitSlop=require("../../utils/hitSlop.js"),_Chevron=require("../FieldBase/Chevron.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_jsxRuntime=require("react/jsx-runtime");const InlineSelect=exports.InlineSelect=(0,_react.forwardRef)((e,t)=>{const{options:i,getOptionLabel:l,getOptionValue:s,getOptionDisabled:a,getOptionDescription:r,getOptionIcon:n,value:c,onChange:o,placeholder:d,label:u,title:p,searchable:x=!1,haptic:_,disabled:b=!1,size:S="md",color:h,chevronColor:y,chevronSize:j,textStyle:m,style:g,optionStyle:v,selectedOptionStyle:O,optionTextStyle:f,selectedOptionTextStyle:C,accessibilityLabel:I,testID:R}=e,k=(0,_index.useTheme)(),F=(0,_react.useMemo)(()=>buildStyles(k),[k]),q=(0,_index.resolveFieldSize)(k,S),T=(0,_react.useCallback)(e=>l?l(e):e.label??"",[l]),N=(0,_react.useCallback)(e=>s?s(e):e.value,[s]),z=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),L=(0,_react.useCallback)(e=>r?r(e):e.description,[r]),B=(0,_react.useCallback)(e=>n?n(e):e.icon,[n]),[D,H]=(0,_react.useState)(!1),M=(0,_react.useMemo)(()=>{if(null!=c)return i.find(e=>N(e)===c)},[i,c,N]),P=(0,_react.useCallback)(e=>c===e,[c]),w=(0,_react.useCallback)(()=>{if(b)return;const e=(0,_index2.resolveHaptic)(_,"selection");e&&(0,_index2.triggerHaptic)(e),H(!0)},[b,_]),V=(0,_react.useCallback)(()=>{H(!1)},[]),$=(0,_react.useCallback)(e=>{if(z(e))return;const t=(0,_index2.resolveHaptic)(_,"selection");t&&(0,_index2.triggerHaptic)(t),o(N(e)),V()},[z,N,o,V,_]),G=b?k.colors["text-disabled"]:h??k.colors.primary,A=void 0!==M?T(M):d??"Select",E=void 0!==M?`Selected: ${T(M)}`:d??"No selection",J=I??`${u??p??"Select"}. ${E}`,K=(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:w,disabled:b,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:J,accessibilityState:{disabled:b,expanded:D},"aria-disabled":b,"aria-expanded":D,testID:R,style:({pressed:e})=>[F.trigger,{columnGap:k.space.xs,opacity:e&&!b?.6:1},g],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[F.triggerText,{color:G,fontSize:q.text,...(0,_index.fontFor)(k,"medium")},m],numberOfLines:1,children:A}),(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:y??G,size:j??q.icon,open:D})]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[u?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:F.labelled,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:S,children:u}),K]}):K,(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:D,onClose:V,title:p,accessibilityLabel:u??p??d??"Options",options:i,labelOf:T,getValue:N,disabledOf:z,descriptionOf:L,iconOf:B,isSelected:P,onSelect:$,searchable:x,optionStyle:v,selectedOptionStyle:O,optionTextStyle:f,selectedOptionTextStyle:C})]})});InlineSelect.displayName="InlineSelect";const buildStyles=e=>_reactNative.StyleSheet.create({labelled:{alignItems:"flex-start"},trigger:{flexDirection:"row",alignItems:"center"},triggerText:{includeFontPadding:!1}});var _default=exports.default=InlineSelect;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Input=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Button/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_Notation=require("../Notation/Notation.js"),_jsxRuntime=require("react/jsx-runtime");const Input=exports.Input=(0,_react.forwardRef)((e,t)=>{const{label:i,help:n,placeholder:a,value:o,onChangeText:s,error:r,helperText:l,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:x=!1,multiline:p=!1,leftIcon:f,rightIcon:g,unit:_,unitStyle:m,prefix:v,prefixStyle:h,readOnly:y=!1,action:j,actionStyle:b,size:N="md",variant:R,labelMode:S,required:w=!1,maxLength:F,showCounter:I=!0,textAlign:T,format:V,parse:A,style:B,containerStyle:z,inputStyle:q,labelStyle:C,messageStyle:L,borderRadius:k,onFocus:D,onBlur:P,accessibilityLabel:H,testID:M,editable:O,...E}=e,G=(0,_index2.useTheme)(),W=(0,_react.useMemo)(()=>buildStyles(G),[G]),$=(0,_index2.resolveFieldSize)(G,N),X=G.components.input[N]["multiline-min-height"],J=Math.round($.text*G.leading.body),K=R??G.settings.components.input?.defaultVariant??G.settings.components.field?.defaultVariant??"outlined",Q=S??G.settings.components.input?.defaultLabelMode??"top",[U,Y]=(0,_react.useState)(!1),[Z,ee]=(0,_react.useState)(!1),te="password"===d||u||c,ie="password"===d||u,ne="textarea"===d||p,ae=ne?Math.round(.1*$.text):0,oe="string"==typeof o&&o.length>0,se=(0,_FieldBase.hasFieldText)(r),re=!0===r||se,le=(0,_FieldBase.hasFieldText)(l),de=se||!re&&le,ce=(0,_FieldBase.hasFieldText)(i),ue=(0,_FieldBase.hasFieldText)(v),xe=!x&&!1!==O,pe=U||oe||ue,fe=(0,_react.useRef)(null),ge=(0,_react.useMemo)(()=>(0,_index3.mergeRefs)(fe,t),[t]),me=(0,_react.useCallback)(()=>{xe&&fe.current?.focus()},[xe]),ve=ce&&"float"===Q,he=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,ye=(0,_react.useRef)((0,_index2.createAnimatedValue)(de?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(ye,{toValue:de?1:0,duration:G.motion.duration.fast,easing:_reactNative.Easing.bezier(...G.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[de,ye,G.motion.duration.fast,G.motion.ease["in-out"]]);const je=(0,_index.useReducedMotion)(),be=G.settings.components.input?.shakeOnError??!1,Ne=(0,_react.useRef)(re);(0,_react.useEffect)(()=>{if(!be)return void(Ne.current=re);let e;return re&&!Ne.current&&(je||((0,_index2.setNativeValue)(he,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(he,{toValue:1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(he,{toValue:-1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(he,{toValue:1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(he,{toValue:-1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(he,{toValue:0,duration:100,useNativeDriver:!0})]),e.start()),(0,_index3.triggerHaptic)("notificationError")),Ne.current=re,()=>e?.stop()},[re,he,be,je]);const Re=(0,_react.useCallback)(e=>{Y(!0),D?.(e)},[D]),Se=(0,_react.useCallback)(e=>{Y(!1),P?.(e)},[P]),we=(0,_react.useCallback)(()=>{(0,_index3.triggerHaptic)("selection"),ee(e=>!e)},[]),Fe=G.colors["field-caret"],Ie=k??$.radius,Te=G.settings.components.input?.tintLabelOnFocus??!1,Ve=U&&Te?G.colors["field-border-focus"]:G.colors["field-label"],Ae=he.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),Be=Boolean(g)||Boolean(_)||ie,ze="underline"===K,qe=f?$.icon+G.space.md+1+G.space.md:0,Ce=(0,_useFloatingLabel.useFloatingLabel)({label:i,enabled:ve,floated:pe,required:w,variant:K,sizeTokens:$,leadingOffset:qe,trailingOffset:Be?$.icon+G.space.sm:0,textAlign:T,paddingLeft:ze?G.space.none:$["padding-x"],lineHeight:ne?J:void 0,restNudge:ae,floatTrim:ne?2:0,color:Ve,style:C}),Le=(0,_FieldBase.resolveFieldTextStyle)(G,{disabled:x}),ke=Le.color,De=Le.placeholderColor,Pe=w&&!ce&&!oe&&"string"==typeof a&&a.length>0,He=re?r:l,Me=I&&"number"==typeof F&&"string"==typeof o?`${o.length} / ${F}`:null,Oe=re?G.colors["field-message"]:G.colors["text-muted"],Ee=(0,_Notation.useNotationInk)(L,$["message-text"],Oe),Ge=H??(0,_FieldBase.fieldTextAsString)(i)??a,We=x?G.colors["field-icon-disabled"]:U?G.colors["field-icon-focus"]:G.colors["field-icon"],$e={focused:U,disabled:x,error:re,color:We,size:$.icon},renderSlot=e=>(0,_slotIcon.renderSlotIcon)(e,$e),Xe=(()=>{if(ie){const e=(Z?G.settings.icons.eyeOff:G.settings.icons.eye)??(Z?_defaultIcons.defaultIcons.eyeOff:_defaultIcons.defaultIcons.eye);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:we,disabled:!xe,hitSlop:8,accessibilityRole:"button",accessibilityLabel:Z?"Hide password":"Show password",children:e({size:$.icon,color:We})})}const e=_?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.unit,{fontSize:$.text,color:De},m],children:_}):null,t=g?(0,_jsxRuntime.jsx)(_reactNative.View,{children:renderSlot(g)}):null;return e&&t?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.trailingRow,children:[e,t]}):e??t})(),Je=f?(0,_jsxRuntime.jsx)(_reactNative.View,{children:renderSlot(f)}):null,Ke=_reactNative.StyleSheet.flatten(h),Qe=Ke?.fontSize??$.text,Ue=Ke?.color??De,Ye=(0,_react.useMemo)(()=>({fontSize:Qe,color:Ue}),[Qe,Ue]),Ze=ue?"string"==typeof v||"number"==typeof v?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.prefix,{fontSize:$.text,color:De,marginRight:G.space.xs,lineHeight:ne?J:void 0,paddingTop:ne?ae:void 0},h],children:v}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[W.prefixNode,{marginRight:G.space.xs,minHeight:ne?J:void 0,justifyContent:"center",paddingTop:ne?ae:void 0}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.prefix,{fontSize:$.text,color:De,lineHeight:ne?J:void 0},h],children:(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:Ye,children:v})})}):null,et=j?(0,_jsxRuntime.jsx)(_index4.Button,{variant:j.variant??"outline",tone:j.tone??"primary",size:N,title:j.label,leftIcon:j.icon,loading:j.loading,disabled:x||j.disabled,onPress:j.onPress,pressAnimation:!1,testID:j.testID,style:[W.action,{minHeight:$["min-height"],alignSelf:ne?"flex-start":"stretch"},b]}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[W.container,{transform:[{translateX:Ae}]},B],children:[ce&&!ve?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:N,required:w,help:n,color:Ve,style:C,children:i}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[W.fieldRow,{columnGap:G.space.sm,alignItems:ne?"flex-start":"stretch"}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.fieldWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:N,variant:K,focused:U,disabled:x,error:re,filled:oe,minHeight:ne?X:void 0,borderRadius:Ie,leading:Je,leadingDivider:null!=f,paddingLeft:ze?G.space.none:void 0,trailing:Xe,slotAlign:ne?"top":"center",slotLineHeight:ne?J:void 0,topNotch:Ce.topNotch,onPress:me,pressFeedback:!1,style:z,children:[Ze,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:ge,style:[W.input,{color:ke,fontSize:$.text,...Le.weightStyle,paddingLeft:ze?G.space.none:void 0,minHeight:ne?X-2*$["padding-y"]:void 0,lineHeight:ne?J:void 0,paddingTop:ne?ae:void 0,textAlignVertical:ne?"top":"center"},q],textAlign:T,placeholder:ve&&!pe||Pe?void 0:a,placeholderTextColor:De,value:V&&null!=o?V(o):o,onChangeText:e=>{s&&s(A?A(e):e)},onFocus:Re,onBlur:Se,editable:xe,readOnly:y,secureTextEntry:te&&!Z,multiline:ne,autoCapitalize:te?"none":void 0,autoCorrect:!te&&void 0,maxLength:F,selectionColor:Fe,accessibilityLabel:Ge,accessibilityState:{disabled:x},"aria-disabled":x,testID:M,...E}),Pe?(0,_jsxRuntime.jsx)(_FieldBase.RequiredPlaceholder,{text:a,color:De,fontSize:$.text,weightStyle:Le.weightStyle,align:ne?"top":"center",paddingTop:ne?ae:void 0,textAlign:T}):null]})]}),Ce.node]}),et]}),de||Me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[W.footerRow,{marginTop:$["message-gap"]}],children:[de?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[W.messageRow,{columnGap:G.space.xs,opacity:ye}],accessibilityLiveRegion:re?"polite":"none",children:[re?(0,_jsxRuntime.jsx)(_FieldBase.FieldErrorGlyph,{size:$["message-text"],color:Oe}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.messageText,{color:Oe,fontSize:$["message-text"],...(0,_index2.fontFor)(G,"normal")},L],children:(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:Ee,children:He})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.footerSpacer}),Me?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.counterText,{color:G.colors["text-subtle"],fontSize:$["message-text"],...(0,_index2.fontFor)(G,"normal")}],children:Me}):null]}):null]})});Input.displayName="Input";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},fieldRow:{flexDirection:"row"},fieldWrapper:{position:"relative",overflow:"visible",flex:1},action:{flexShrink:0},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"},unit:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},footerSpacer:{flex:1},messageRow:{flex:1,flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1},counterText:{flexShrink:0,includeFontPadding:!1}});var _default=exports.default=Input;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Input=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Button/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_Notation=require("../Notation/Notation.js"),_jsxRuntime=require("react/jsx-runtime");const Input=exports.Input=(0,_react.forwardRef)((e,t)=>{const{label:i,help:n,placeholder:a,value:o,onChangeText:s,error:r,helperText:l,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:x=!1,multiline:p=!1,leftIcon:f,rightIcon:_,unit:g,unitStyle:m,prefix:h,prefixStyle:v,readOnly:j=!1,action:y,actionStyle:b,size:N="md",variant:R,labelMode:S,required:w=!1,maxLength:F,showCounter:I=!0,textAlign:T,format:V,parse:A,style:B,containerStyle:z,inputStyle:q,labelStyle:k,messageStyle:C,borderRadius:L,onFocus:D,onBlur:P,accessibilityLabel:H,testID:M,editable:O,...E}=e,G=(0,_index2.useTheme)(),W=(0,_react.useMemo)(()=>buildStyles(G),[G]),$=(0,_index2.resolveFieldSize)(G,N),X=G.components.input[N]["multiline-min-height"],J=Math.round($.text*G.leading.body),K=R??G.settings.components.input?.defaultVariant??G.settings.components.field?.defaultVariant??"outlined",Q=S??G.settings.components.input?.defaultLabelMode??"top",[U,Y]=(0,_react.useState)(!1),[Z,ee]=(0,_react.useState)(!1),te="password"===d||u||c,ie="password"===d||u,ne="textarea"===d||p,ae=ne?Math.round(.1*$.text):0,oe="string"==typeof o&&o.length>0,se=(0,_FieldBase.hasFieldText)(r),re=!0===r||se,le=(0,_FieldBase.hasFieldText)(l),de=se||!re&&le,ce=(0,_FieldBase.hasFieldText)(i),ue=(0,_FieldBase.hasFieldText)(h),xe=!x&&!1!==O,pe=U||oe||ue,fe=(0,_react.useRef)(null),ge=(0,_react.useMemo)(()=>(0,_index3.mergeRefs)(fe,t),[t]),me=(0,_react.useCallback)(()=>{xe&&fe.current?.focus()},[xe]),he=ce&&"float"===Q,ve=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,je=(0,_react.useRef)((0,_index2.createAnimatedValue)(de?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(je,{toValue:de?1:0,duration:G.motion.duration.fast,easing:_reactNative.Easing.bezier(...G.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[de,je,G.motion.duration.fast,G.motion.ease["in-out"]]);const ye=(0,_index.useReducedMotion)(),be=G.settings.components.input?.shakeOnError??!1,Ne=(0,_react.useRef)(re);(0,_react.useEffect)(()=>{if(!be)return void(Ne.current=re);let e;return re&&!Ne.current&&(ye||((0,_index2.setNativeValue)(ve,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(ve,{toValue:1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(ve,{toValue:-1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(ve,{toValue:1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(ve,{toValue:-1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(ve,{toValue:0,duration:100,useNativeDriver:!0})]),e.start()),(0,_index3.triggerHaptic)("notificationError")),Ne.current=re,()=>e?.stop()},[re,ve,be,ye]);const Re=(0,_react.useCallback)(e=>{Y(!0),D?.(e)},[D]),Se=(0,_react.useCallback)(e=>{Y(!1),P?.(e)},[P]),we=(0,_react.useCallback)(()=>{(0,_index3.triggerHaptic)("selection"),ee(e=>!e)},[]),Fe=G.colors["field-caret"],Ie=L??$.radius,Te=G.settings.components.input?.tintLabelOnFocus??!1,Ve=U&&Te?G.colors["field-border-focus"]:G.colors["field-label"],Ae=ve.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),Be=Boolean(_)||Boolean(g)||ie,ze="underline"===K,qe=f?$.icon+G.space.md+1+G.space.md:0,ke=(0,_useFloatingLabel.useFloatingLabel)({label:i,enabled:he,floated:pe,required:w,variant:K,sizeTokens:$,leadingOffset:qe,trailingOffset:Be?$.icon+G.space.sm:0,textAlign:T,paddingLeft:ze?G.space.none:$["padding-x"],lineHeight:ne?J:void 0,restNudge:ae,floatTrim:ne?2:0,color:Ve,style:k}),Ce=(0,_FieldBase.resolveFieldTextStyle)(G,{disabled:x}),Le=Ce.color,De=Ce.placeholderColor,Pe=w&&!ce&&!oe&&"string"==typeof a&&a.length>0,He=re?r:l,Me=I&&"number"==typeof F&&"string"==typeof o?`${o.length} / ${F}`:null,Oe=re?G.colors["field-message"]:G.colors["text-muted"],Ee=(0,_Notation.useNotationInk)(C,$["message-text"],Oe),Ge=H??(0,_FieldBase.fieldTextAsString)(i)??a,We=x?G.colors["field-icon-disabled"]:U?G.colors["field-icon-focus"]:G.colors["field-icon"],$e={focused:U,disabled:x,error:re,color:We,size:$.icon},renderSlot=e=>(0,_slotIcon.renderSlotIcon)(e,$e),Xe=(()=>{if(ie){const e=(Z?G.settings.icons.eyeOff:G.settings.icons.eye)??(Z?_defaultIcons.defaultIcons.eyeOff:_defaultIcons.defaultIcons.eye);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:we,disabled:!xe,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:Z?"Hide password":"Show password",children:e({size:$.icon,color:We})})}const e=g?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.unit,{fontSize:$.text,color:De},m],children:g}):null,t=_?(0,_jsxRuntime.jsx)(_reactNative.View,{children:renderSlot(_)}):null;return e&&t?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.trailingRow,children:[e,t]}):e??t})(),Je=f?(0,_jsxRuntime.jsx)(_reactNative.View,{children:renderSlot(f)}):null,Ke=_reactNative.StyleSheet.flatten(v),Qe=Ke?.fontSize??$.text,Ue=Ke?.color??De,Ye=(0,_react.useMemo)(()=>({fontSize:Qe,color:Ue}),[Qe,Ue]),Ze=ue?"string"==typeof h||"number"==typeof h?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.prefix,{fontSize:$.text,color:De,marginRight:G.space.xs,lineHeight:ne?J:void 0,paddingTop:ne?ae:void 0},v],children:h}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[W.prefixNode,{marginRight:G.space.xs,minHeight:ne?J:void 0,justifyContent:"center",paddingTop:ne?ae:void 0}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.prefix,{fontSize:$.text,color:De,lineHeight:ne?J:void 0},v],children:(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:Ye,children:h})})}):null,et=y?(0,_jsxRuntime.jsx)(_index4.Button,{variant:y.variant??"outline",tone:y.tone??"primary",size:N,title:y.label,leftIcon:y.icon,loading:y.loading,disabled:x||y.disabled,onPress:y.onPress,pressAnimation:!1,testID:y.testID,style:[W.action,{minHeight:$["min-height"],alignSelf:ne?"flex-start":"stretch"},b]}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[W.container,{transform:[{translateX:Ae}]},B],children:[ce&&!he?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:N,required:w,help:n,color:Ve,style:k,children:i}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[W.fieldRow,{columnGap:G.space.sm,alignItems:ne?"flex-start":"stretch"}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.fieldWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:N,variant:K,focused:U,disabled:x,error:re,filled:oe,minHeight:ne?X:void 0,borderRadius:Ie,leading:Je,leadingDivider:null!=f,paddingLeft:ze?G.space.none:void 0,trailing:Xe,slotAlign:ne?"top":"center",slotLineHeight:ne?J:void 0,topNotch:ke.topNotch,onPress:me,pressFeedback:!1,style:z,children:[Ze,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:ge,style:[W.input,{color:Le,fontSize:$.text,...Ce.weightStyle,paddingLeft:ze?G.space.none:void 0,minHeight:ne?X-2*$["padding-y"]:void 0,lineHeight:ne?J:void 0,paddingTop:ne?ae:void 0,textAlignVertical:ne?"top":"center"},q],textAlign:T,placeholder:he&&!pe||Pe?void 0:a,placeholderTextColor:De,value:V&&null!=o?V(o):o,onChangeText:e=>{s&&s(A?A(e):e)},onFocus:Re,onBlur:Se,editable:xe,readOnly:j,secureTextEntry:te&&!Z,multiline:ne,autoCapitalize:te?"none":void 0,autoCorrect:!te&&void 0,maxLength:F,selectionColor:Fe,accessibilityLabel:Ge,accessibilityState:{disabled:x},"aria-disabled":x,testID:M,...E}),Pe?(0,_jsxRuntime.jsx)(_FieldBase.RequiredPlaceholder,{text:a,color:De,fontSize:$.text,weightStyle:Ce.weightStyle,align:ne?"top":"center",paddingTop:ne?ae:void 0,textAlign:T}):null]})]}),ke.node]}),et]}),de||Me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[W.footerRow,{marginTop:$["message-gap"]}],children:[de?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[W.messageRow,{columnGap:G.space.xs,opacity:je}],accessibilityLiveRegion:re?"polite":"none",children:[re?(0,_jsxRuntime.jsx)(_FieldBase.FieldErrorGlyph,{size:$["message-text"],color:Oe}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.messageText,{color:Oe,fontSize:$["message-text"],...(0,_index2.fontFor)(G,"normal")},C],children:(0,_jsxRuntime.jsx)(_Notation.NotationInkContext.Provider,{value:Ee,children:He})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:W.footerSpacer}),Me?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[W.counterText,{color:G.colors["text-subtle"],fontSize:$["message-text"],...(0,_index2.fontFor)(G,"normal")}],children:Me}):null]}):null]})});Input.displayName="Input";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},fieldRow:{flexDirection:"row"},fieldWrapper:{position:"relative",overflow:"visible",flex:1},action:{flexShrink:0},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"},unit:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},footerSpacer:{flex:1},messageRow:{flex:1,flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1},counterText:{flexShrink:0,includeFontPadding:!1}});var _default=exports.default=Input;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.KeyboardToolbar=void 0;var _reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_FormContext=require("../../form/FormContext.js"),_index=require("../../theme/index.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const NavButton=({label:e,accessibilityLabel:t,onPress:r,theme:o})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:t,hitSlop:8,style:{paddingHorizontal:o.space.sm},children:(0,_jsxRuntime.jsx)(_index2.Text,{variant:"body",weight:"semibold",size:"lg",color:"link",children:e})}),KeyboardToolbar=e=>{const{doneLabel:t="Done",showNavigation:r=!0,onDone:o,onNext:i,onPrev:s,leading:a,style:l,testID:n}=e,c=(0,_index.useTheme)(),b=(0,_FormContext.useOptionalFormContext)();if(!(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.isVisible))return null;const d=o??(()=>{_reactNativeKeyboardController.KeyboardController.dismiss()}),x=s??b?.focusPrev??(()=>_reactNativeKeyboardController.KeyboardController.setFocusTo("prev")),u=i??b?.focusNext??(()=>_reactNativeKeyboardController.KeyboardController.setFocusTo("next"));return(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardStickyView,{style:styles.anchor,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:n,accessibilityRole:"toolbar",style:[styles.bar,{backgroundColor:c.colors.surface,borderTopColor:c.colors.border,paddingHorizontal:c.space.md},l],children:[r?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.nav,children:[(0,_jsxRuntime.jsx)(NavButton,{label:"‹",accessibilityLabel:"Previous field",onPress:x,theme:c}),(0,_jsxRuntime.jsx)(NavButton,{label:"›",accessibilityLabel:"Next field",onPress:u,theme:c})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{}),a,(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.spacer}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:d,accessibilityRole:"button",accessibilityLabel:t,hitSlop:8,children:(0,_jsxRuntime.jsx)(_index2.Text,{variant:"body",weight:"semibold",color:"link",children:t})})]})})};exports.KeyboardToolbar=KeyboardToolbar;const styles=_reactNative.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:0},bar:{height:44,flexDirection:"row",alignItems:"center",borderTopWidth:_reactNative.StyleSheet.hairlineWidth},nav:{flexDirection:"row",alignItems:"center"},spacer:{flex:1}});var _default=exports.default=KeyboardToolbar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.KeyboardToolbar=void 0;var _reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_FormContext=require("../../form/FormContext.js"),_index=require("../../theme/index.js"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const NavButton=({label:e,accessibilityLabel:t,onPress:r,theme:o})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:t,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:{paddingHorizontal:o.space.sm},children:(0,_jsxRuntime.jsx)(_index2.Text,{variant:"body",weight:"semibold",size:"lg",color:"link",children:e})}),KeyboardToolbar=e=>{const{doneLabel:t="Done",showNavigation:r=!0,onDone:o,onNext:i,onPrev:s,leading:a,style:l,testID:n}=e,c=(0,_index.useTheme)(),b=(0,_FormContext.useOptionalFormContext)();if(!(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.isVisible))return null;const d=o??(()=>{_reactNativeKeyboardController.KeyboardController.dismiss()}),x=s??b?.focusPrev??(()=>_reactNativeKeyboardController.KeyboardController.setFocusTo("prev")),u=i??b?.focusNext??(()=>_reactNativeKeyboardController.KeyboardController.setFocusTo("next"));return(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardStickyView,{style:styles.anchor,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:n,accessibilityRole:"toolbar",style:[styles.bar,{backgroundColor:c.colors.surface,borderTopColor:c.colors.border,paddingHorizontal:c.space.md},l],children:[r?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.nav,children:[(0,_jsxRuntime.jsx)(NavButton,{label:"‹",accessibilityLabel:"Previous field",onPress:x,theme:c}),(0,_jsxRuntime.jsx)(NavButton,{label:"›",accessibilityLabel:"Next field",onPress:u,theme:c})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{}),a,(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.spacer}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:d,accessibilityRole:"button",accessibilityLabel:t,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),children:(0,_jsxRuntime.jsx)(_index2.Text,{variant:"body",weight:"semibold",color:"link",children:t})})]})})};exports.KeyboardToolbar=KeyboardToolbar;const styles=_reactNative.StyleSheet.create({anchor:{position:"absolute",left:0,right:0,bottom:0},bar:{height:44,flexDirection:"row",alignItems:"center",borderTopWidth:_reactNative.StyleSheet.hairlineWidth},nav:{flexDirection:"row",alignItems:"center"},spacer:{flex:1}});var _default=exports.default=KeyboardToolbar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OptionSheet=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const AnimatedGestureRoot=_reactNative.Animated.createAnimatedComponent(_reactNativeGestureHandler.GestureHandlerRootView),SEARCH_ICON_SIZE=18,OptionSheet=e=>{const{open:t,onClose:i,onAfterClose:r,onOpenChange:s,title:a,options:o,sections:n,renderSectionHeader:l,renderOption:c,alphabetIndex:d=!1,searchPlaceholder:u="Search…",emptyText:p="No options",labelOf:m,getValue:h,disabledOf:x,destructiveOf:_,descriptionOf:g,iconOf:b,isSelected:f,onSelect:y,multi:v=!1,searchable:j=!1,searchSelectionColor:R,accessibilityLabel:N,optionStyle:S,selectedOptionStyle:T,optionTextStyle:w,selectedOptionTextStyle:C,testID:I}=e,V=(0,_index.useTheme)(),k=(0,_usePresenceMotion.usePresenceMotion)(),[M,z]=(0,_ModalSafeArea.useModalInsets)(),D=(0,_react.useMemo)(()=>buildStyles(V),[V]),[A,P]=(0,_react.useState)(""),L=_reactNative.Dimensions.get("window").height,H=Math.round(.7*L),[O,W]=(0,_react.useState)(t),B=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,E=(0,_react.useRef)((0,_index.createAnimatedValue)(H)).current,q=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,F=(0,_react.useMemo)(()=>k.reduced?q:_reactNative.Animated.add(E,q),[k.reduced,E,q]),G=(0,_react.useMemo)(()=>k.reduced?E.interpolate({inputRange:[0,H],outputRange:[1,0],extrapolate:"clamp"}):1,[k.reduced,E,H]),{handleGesture:$,opacity:K}=(0,_useDragToDismiss.useDragToDismiss)({drag:q,travel:H,onDismiss:i}),J=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(G,K),[G,K]),U=(0,_react.useMemo)(()=>{const e=V.colors.scrim;return B.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(e),e]})},[B,V.colors.scrim]);(0,_react.useEffect)(()=>{t&&W(!0)},[t]);const Y=(0,_react.useRef)(s);Y.current=s;const Z=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{Z.current!==t&&(Z.current=t,Y.current?.(t))},[t]);const Q=(0,_react.useRef)(r);Q.current=r;const X=(0,_react.useRef)(O);(0,_react.useEffect)(()=>{X.current&&!O&&"ios"!==_reactNative.Platform.OS&&Q.current?.(),X.current=O},[O]),(0,_react.useEffect)(()=>{if(!O)return;t&&((0,_index.setNativeValue)(q,0),(0,_index.setNativeValue)(K,1));const e=t?_reactNative.Animated.parallel([_reactNative.Animated.timing(B,{toValue:1,duration:k.duration("default"),easing:_reactNative.Easing.bezier(...V.motion.ease["in-out"]),useNativeDriver:!1}),k.reduced?_reactNative.Animated.timing(E,{toValue:0,duration:k.duration("default"),easing:_reactNative.Easing.bezier(...V.motion.ease["in-out"]),useNativeDriver:!0}):_reactNative.Animated.spring(E,{toValue:0,damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass,useNativeDriver:!0})]):_reactNative.Animated.parallel([_reactNative.Animated.timing(B,{toValue:0,duration:k.duration("default"),easing:_reactNative.Easing.bezier(...V.motion.ease["in-out"]),useNativeDriver:!1}),_reactNative.Animated.timing(E,{toValue:H,duration:k.duration("fast"),easing:_reactNative.Easing.bezier(...V.motion.ease.accelerate),useNativeDriver:!0})]);return e.start(({finished:e})=>{e&&!t&&W(!1)}),()=>e.stop()},[t,O,B,E,q,K,H,k,V.motion.ease["in-out"],V.motion.ease.accelerate,V.motion.spring.snappy]);const ee=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native(),[]),[te,ie]=(0,_react.useState)(0),re=(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.height),se=O?Math.max(0,Math.round(re)):0,ae=Math.max(M.top,_reactNative.StatusBar.currentHeight??0)+V.space.sm,oe=se>0,ne=oe?Math.max(0,Math.min(H,(te>0?te:L)-se-ae)):H;(0,_react.useEffect)(()=>{t||P("")},[t]);const le=(0,_react.useMemo)(()=>{const e=j?A.trim().toLowerCase():"",matches=t=>0===e.length||m(t).toLowerCase().includes(e)||(g(t)??"").toLowerCase().includes(e);if(!n)return o.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return n.forEach((e,i)=>{const r=e.options.filter(matches);if(0!==r.length){t.push({kind:"header",title:e.title});for(const e of r)t.push({kind:"option",option:e,section:i})}}),t},[j,A,o,n,m,g]),ce=(0,_react.useCallback)(()=>{i()},[i]),de=(0,_react.useRef)(null),ue=(0,_react.useMemo)(()=>{const e=new Map;if(!d)return e;let t=0;if(n)for(let e=le.length-1;e>=0;e-=1)if("header"===le[e].kind){t=e+1;break}for(let i=t;i<le.length;i+=1){const t=le[i];if("option"!==t.kind)continue;const r=m(t.option).trim().charAt(0).toUpperCase(),s=/^[A-Z]$/.test(r)?r:"#";e.has(s)||e.set(s,i)}return e},[d,le,n,m]),pe=d&&ue.size>0&&0===A.trim().length,me=(0,_react.useMemo)(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...ue.has("#")?["#"]:[]],[ue]),he=(0,_react.useCallback)(e=>{const t=ue.get(e);void 0!==t&&de.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[ue]),xe=(0,_react.useRef)(null),ge=(0,_react.useCallback)(()=>{null!==xe.current&&(clearTimeout(xe.current),xe.current=null)},[]),be=(0,_react.useCallback)(e=>{de.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),ge(),xe.current=setTimeout(()=>{xe.current=null,de.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[ge]);(0,_react.useEffect)(()=>(O||ge(),ge),[O,ge]);return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:O,transparent:!0,animationType:"none",onRequestClose:ce,onDismiss:()=>Q.current?.(),statusBarTranslucent:!0,navigationBarTranslucent:!0,children:(0,_jsxRuntime.jsx)(_ModalSafeArea.ModalSafeArea,{onInsets:z,children:(0,_jsxRuntime.jsxs)(AnimatedGestureRoot,{collapsable:!1,onLayout:e=>ie(e.nativeEvent.layout.height),style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:U}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ce,accessibilityRole:"button",accessibilityLabel:"Close picker"}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{testID:I,accessibilityViewIsModal:!0,accessibilityLabel:N??a??"Options",style:[D.sheet,{maxHeight:ne,bottom:se,paddingBottom:oe?V.space.lg:M.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,..._corners.smoothCorners,opacity:J,transform:[{translateY:F}],...V.shadow.modal}],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:$,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.sheetHandleRow,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.sheetHandle,{backgroundColor:V.colors.border}]})}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sheetTitle,{color:V.colors["text-body"],fontSize:V.text.lg.size,fontWeight:V.weight.semibold,paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:a}):null]})}),j?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,..._corners.smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??_defaultIcons.defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{value:A,onChangeText:P,placeholder:u,placeholderTextColor:V.colors["text-subtle"],selectionColor:R??V.colors["focus-ring"],accessibilityLabel:"Search options",style:[D.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),A.length>0?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>P(""),hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(V.settings.icons.close??_defaultIcons.defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.listWrap,pe?D.listRow:null],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ee,children:(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:de,data:le,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(h(e.option))}`,renderItem:({item:e})=>{if("header"===e.kind)return(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"header",style:[D.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:l?l(e.title):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sectionTitle,{color:V.colors["text-subtle"],fontSize:V.text.xs.size,fontWeight:V.weight.semibold}],children:e.title.toUpperCase()})});const t=e.option,i=m(t),r=h(t),s=g(t),a=b(t),o=f(r),n=x(t),d=_?.(t)??!1;return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>y(t),disabled:n,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:i,accessibilityState:{selected:o,disabled:n},"aria-selected":o,"aria-disabled":n,style:({pressed:e})=>[D.optionRow,{backgroundColor:o?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:n?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},S,o?T:null],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.optionTextWrap,children:c(t,{selected:o,disabled:n})}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.optionIcon,children:a}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.optionTextWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.optionLabel,{color:d?V.colors["danger-text"]:o?V.colors.primary:V.colors["text-body"],fontSize:V.text.base.size,fontWeight:o?V.weight.semibold:V.weight.medium},w,o?C:null],children:i}),s?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.optionDescription,{color:V.colors["text-subtle"],fontSize:V.text.sm.size}],numberOfLines:2,children:s}):null]})]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.checkbox,{borderColor:o?V.colors.primary:V.colors.border,backgroundColor:o?V.colors.primary:"transparent"}],children:o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.checkboxTick}):null}):o?"icon"===V.settings.components["option-sheet"]?.selectedMarker?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.singleSelectedIcon,children:(V.settings.icons.selectedTick??_defaultIcons.defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:be,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!pe,style:pe?D.listBesideRail:null,ListEmptyComponent:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.empty,{color:V.colors["text-subtle"],fontSize:V.text.sm.size,paddingVertical:V.space.xl}],children:p})})}),pe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:"Jump to letter",testID:"option-sheet-alphabet",children:me.map(e=>{const t=ue.has(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>he(e),disabled:!t,hitSlop:{left:8,right:8},accessibilityRole:"button",accessibilityLabel:`Jump to ${e}`,accessibilityState:{disabled:!t},"aria-disabled":!t,style:D.railLetter,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.railLetterText,{color:t?V.colors.primary:V.colors["text-subtle"],fontSize:V.text.xs.size,fontWeight:V.weight.semibold,opacity:t?1:.45}],children:e})},e)})}):null]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ce,accessibilityRole:"button",accessibilityLabel:"Done",style:({pressed:e})=>[D.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,..._corners.smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:V.colors["on-primary"],fontSize:V.text.base.size,fontWeight:V.weight.semibold},children:"Done"})})}):null]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})})};exports.OptionSheet=OptionSheet,OptionSheet.displayName="OptionSheet";const buildStyles=e=>_reactNative.StyleSheet.create({sheet:{position:"absolute",left:0,right:0,bottom:0,paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,..._corners.smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},empty:{textAlign:"center"},sheetFooter:{borderTopWidth:_reactNative.StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});var _default=exports.default=OptionSheet;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OptionSheet=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const AnimatedGestureRoot=_reactNative.Animated.createAnimatedComponent(_reactNativeGestureHandler.GestureHandlerRootView),SEARCH_ICON_SIZE=18,OptionSheet=e=>{const{open:t,onClose:i,onAfterClose:r,onOpenChange:s,title:a,options:o,sections:n,renderSectionHeader:l,renderOption:c,alphabetIndex:d=!1,searchPlaceholder:u="Search…",emptyText:p="No options",labelOf:m,getValue:h,disabledOf:_,destructiveOf:x,descriptionOf:g,iconOf:b,isSelected:f,onSelect:y,multi:v=!1,searchable:j=!1,searchSelectionColor:R,accessibilityLabel:N,optionStyle:S,selectedOptionStyle:T,optionTextStyle:w,selectedOptionTextStyle:C,testID:k}=e,I=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),[M,z]=(0,_ModalSafeArea.useModalInsets)(),D=(0,_react.useMemo)(()=>buildStyles(I),[I]),[A,P]=(0,_react.useState)(""),L=_reactNative.Dimensions.get("window").height,H=Math.round(.7*L),[O,W]=(0,_react.useState)(t),B=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,E=(0,_react.useRef)((0,_index.createAnimatedValue)(H)).current,q=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,F=(0,_react.useMemo)(()=>V.reduced?q:_reactNative.Animated.add(E,q),[V.reduced,E,q]),G=(0,_react.useMemo)(()=>V.reduced?E.interpolate({inputRange:[0,H],outputRange:[1,0],extrapolate:"clamp"}):1,[V.reduced,E,H]),{handleGesture:$,opacity:K}=(0,_useDragToDismiss.useDragToDismiss)({drag:q,travel:H,onDismiss:i}),J=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(G,K),[G,K]),U=(0,_react.useMemo)(()=>{const e=I.colors.scrim;return B.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(e),e]})},[B,I.colors.scrim]);(0,_react.useEffect)(()=>{t&&W(!0)},[t]);const Y=(0,_react.useRef)(s);Y.current=s;const Z=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{Z.current!==t&&(Z.current=t,Y.current?.(t))},[t]);const Q=(0,_react.useRef)(r);Q.current=r;const X=(0,_react.useRef)(O);(0,_react.useEffect)(()=>{X.current&&!O&&"ios"!==_reactNative.Platform.OS&&Q.current?.(),X.current=O},[O]),(0,_react.useEffect)(()=>{if(!O)return;t&&((0,_index.setNativeValue)(q,0),(0,_index.setNativeValue)(K,1));const e=t?_reactNative.Animated.parallel([_reactNative.Animated.timing(B,{toValue:1,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!1}),V.reduced?_reactNative.Animated.timing(E,{toValue:0,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!0}):_reactNative.Animated.spring(E,{toValue:0,damping:I.motion.spring.snappy.damping,stiffness:I.motion.spring.snappy.stiffness,mass:I.motion.spring.snappy.mass,useNativeDriver:!0})]):_reactNative.Animated.parallel([_reactNative.Animated.timing(B,{toValue:0,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!1}),_reactNative.Animated.timing(E,{toValue:H,duration:V.duration("fast"),easing:_reactNative.Easing.bezier(...I.motion.ease.accelerate),useNativeDriver:!0})]);return e.start(({finished:e})=>{e&&!t&&W(!1)}),()=>e.stop()},[t,O,B,E,q,K,H,V,I.motion.ease["in-out"],I.motion.ease.accelerate,I.motion.spring.snappy]);const ee=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native(),[]),[te,ie]=(0,_react.useState)(0),re=(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.height),se=O?Math.max(0,Math.round(re)):0,ae=Math.max(M.top,_reactNative.StatusBar.currentHeight??0)+I.space.sm,oe=se>0,ne=oe?Math.max(0,Math.min(H,(te>0?te:L)-se-ae)):H;(0,_react.useEffect)(()=>{t||P("")},[t]);const le=(0,_react.useMemo)(()=>{const e=j?A.trim().toLowerCase():"",matches=t=>0===e.length||m(t).toLowerCase().includes(e)||(g(t)??"").toLowerCase().includes(e);if(!n)return o.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return n.forEach((e,i)=>{const r=e.options.filter(matches);if(0!==r.length){t.push({kind:"header",title:e.title});for(const e of r)t.push({kind:"option",option:e,section:i})}}),t},[j,A,o,n,m,g]),ce=(0,_react.useCallback)(()=>{i()},[i]),de=(0,_react.useRef)(null),ue=(0,_react.useMemo)(()=>{const e=new Map;if(!d)return e;let t=0;if(n)for(let e=le.length-1;e>=0;e-=1)if("header"===le[e].kind){t=e+1;break}for(let i=t;i<le.length;i+=1){const t=le[i];if("option"!==t.kind)continue;const r=m(t.option).trim().charAt(0).toUpperCase(),s=/^[A-Z]$/.test(r)?r:"#";e.has(s)||e.set(s,i)}return e},[d,le,n,m]),pe=d&&ue.size>0&&0===A.trim().length,me=(0,_react.useMemo)(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...ue.has("#")?["#"]:[]],[ue]),he=(0,_react.useCallback)(e=>{const t=ue.get(e);void 0!==t&&de.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[ue]),xe=(0,_react.useRef)(null),ge=(0,_react.useCallback)(()=>{null!==xe.current&&(clearTimeout(xe.current),xe.current=null)},[]),be=(0,_react.useCallback)(e=>{de.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),ge(),xe.current=setTimeout(()=>{xe.current=null,de.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[ge]);(0,_react.useEffect)(()=>(O||ge(),ge),[O,ge]);return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:O,transparent:!0,animationType:"none",onRequestClose:ce,onDismiss:()=>Q.current?.(),statusBarTranslucent:!0,navigationBarTranslucent:!0,children:(0,_jsxRuntime.jsx)(_ModalSafeArea.ModalSafeArea,{onInsets:z,children:(0,_jsxRuntime.jsxs)(AnimatedGestureRoot,{collapsable:!1,onLayout:e=>ie(e.nativeEvent.layout.height),style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:U}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ce,accessibilityRole:"button",accessibilityLabel:"Close picker"}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{testID:k,accessibilityViewIsModal:!0,accessibilityLabel:N??a??"Options",style:[D.sheet,{maxHeight:ne,bottom:se,paddingBottom:oe?I.space.lg:M.bottom+I.space.lg,backgroundColor:I.colors.surface,borderTopLeftRadius:I.radius.xl,borderTopRightRadius:I.radius.xl,..._corners.smoothCorners,opacity:J,transform:[{translateY:F}],...I.shadow.modal}],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:$,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.sheetHandleRow,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.sheetHandle,{backgroundColor:I.colors.border}]})}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sheetTitle,{color:I.colors["text-body"],fontSize:I.text.lg.size,fontWeight:I.weight.semibold,paddingHorizontal:I.space.lg,marginBottom:I.space.sm}],children:a}):null]})}),j?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.searchWrap,{marginHorizontal:I.space.lg,marginBottom:I.space.sm}],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.searchBox,{backgroundColor:I.colors["bg-subtle"],borderColor:I.colors.border,borderRadius:I.radius.md,..._corners.smoothCorners,paddingHorizontal:I.space.md,gap:I.space.sm}],children:[(I.settings.icons.search??_defaultIcons.defaultIcons.search)({size:18,color:I.colors["text-subtle"]}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{value:A,onChangeText:P,placeholder:u,placeholderTextColor:I.colors["text-subtle"],selectionColor:R??I.colors["focus-ring"],accessibilityLabel:"Search options",style:[D.searchInput,{color:I.colors["text-body"],fontSize:I.text.base.size,paddingVertical:I.space.sm}]}),A.length>0?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>P(""),hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:"Clear search",children:(I.settings.icons.close??_defaultIcons.defaultIcons.close)({size:18,color:I.colors["text-muted"]})}):null]})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.listWrap,pe?D.listRow:null],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ee,children:(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:de,data:le,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(h(e.option))}`,renderItem:({item:e})=>{if("header"===e.kind)return(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"header",style:[D.sectionHeader,{paddingHorizontal:I.space.lg,paddingTop:I.space.md}],children:l?l(e.title):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sectionTitle,{color:I.colors["text-subtle"],fontSize:I.text.xs.size,fontWeight:I.weight.semibold}],children:e.title.toUpperCase()})});const t=e.option,i=m(t),r=h(t),s=g(t),a=b(t),o=f(r),n=_(t),d=x?.(t)??!1;return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>y(t),disabled:n,android_ripple:{color:I.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:i,accessibilityState:{selected:o,disabled:n},"aria-selected":o,"aria-disabled":n,style:({pressed:e})=>[D.optionRow,{backgroundColor:o?I.colors["surface-selected"]:e?I.colors["surface-pressed"]:"transparent",opacity:n?.5:1,paddingHorizontal:I.space.lg,paddingVertical:I.space.md},S,o?T:null],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.optionTextWrap,children:c(t,{selected:o,disabled:n})}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.optionIcon,children:a}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.optionTextWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.optionLabel,{color:d?I.colors["danger-text"]:o?I.colors.primary:I.colors["text-body"],fontSize:I.text.base.size,fontWeight:o?I.weight.semibold:I.weight.medium},w,o?C:null],children:i}),s?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.optionDescription,{color:I.colors["text-subtle"],fontSize:I.text.sm.size}],numberOfLines:2,children:s}):null]})]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.checkbox,{borderColor:o?I.colors.primary:I.colors.border,backgroundColor:o?I.colors.primary:"transparent"}],children:o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.checkboxTick}):null}):o?"icon"===I.settings.components["option-sheet"]?.selectedMarker?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.singleSelectedIcon,children:(I.settings.icons.selectedTick??_defaultIcons.defaultIcons.selectedTick)({size:20,color:I.colors.primary})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.singleSelectedDot,{backgroundColor:I.colors.primary}]}):null]})},onScrollToIndexFailed:be,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!pe,style:pe?D.listBesideRail:null,ListEmptyComponent:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.empty,{color:I.colors["text-subtle"],fontSize:I.text.sm.size,paddingVertical:I.space.xl}],children:p})})}),pe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.rail,{paddingRight:I.space.xs}],accessibilityRole:"list",accessibilityLabel:"Jump to letter",testID:"option-sheet-alphabet",children:me.map(e=>{const t=ue.has(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>he(e),disabled:!t,hitSlop:{left:8,right:8},...(0,_hitSlop.hitSlopMarker)({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:`Jump to ${e}`,accessibilityState:{disabled:!t},"aria-disabled":!t,style:D.railLetter,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.railLetterText,{color:t?I.colors.primary:I.colors["text-subtle"],fontSize:I.text.xs.size,fontWeight:I.weight.semibold,opacity:t?1:.45}],children:e})},e)})}):null]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.sheetFooter,{borderTopColor:I.colors["border-subtle"],paddingHorizontal:I.space.lg,paddingVertical:I.space.md}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ce,accessibilityRole:"button",accessibilityLabel:"Done",style:({pressed:e})=>[D.doneButton,{backgroundColor:e?I.colors["primary-pressed"]:I.colors.primary,borderRadius:I.radius.md,..._corners.smoothCorners,paddingVertical:I.space.sm,paddingHorizontal:I.space.lg}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:I.colors["on-primary"],fontSize:I.text.base.size,fontWeight:I.weight.semibold},children:"Done"})})}):null]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})})};exports.OptionSheet=OptionSheet,OptionSheet.displayName="OptionSheet";const buildStyles=e=>_reactNative.StyleSheet.create({sheet:{position:"absolute",left:0,right:0,bottom:0,paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,..._corners.smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},empty:{textAlign:"center"},sheetFooter:{borderTopWidth:_reactNative.StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});var _default=exports.default=OptionSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseE164=exports.formatE164=exports.default=exports.PhoneNumberInput=exports.DEFAULT_CALLING_CODES=exports.ALL_CALLING_CODES=void 0;var _mobileCore=require("@webority/mobile-core"),_countries=require("@webority/mobile-core/phone/countries"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_index4=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALLING_CODES=exports.DEFAULT_CALLING_CODES=[{iso:"IN",code:"91",label:"India"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"},{iso:"CA",code:"1",label:"Canada"},{iso:"AU",code:"61",label:"Australia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"SA",code:"966",label:"Saudi Arabia"}],ALL_CALLING_CODES=exports.ALL_CALLING_CODES=(0,_mobileCore.getPhoneCountries)().map(e=>({iso:e.iso,code:e.callingCode,label:_countries.PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label)),digitsOnly=e=>e.replace(/[^0-9]/g,""),formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;exports.formatE164=formatE164;const parseE164=(e,t,i)=>{const o=e.replace(/[^0-9]/g,"");if(!o)return null;const n=(0,_mobileCore.splitPhoneNumber)(`+${o}`);let r=n?.callingCode,l=n?.nationalNumber??"";if(!r){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(r=e.find(e=>o.startsWith(e)),!r)return null;l=o.slice(r.length)}const a=t.filter(e=>e.code===r),s=a.find(e=>e.iso===i)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:r,nationalNumber:l,iso:s}};exports.parseE164=parseE164;const planOf=e=>(0,_mobileCore.isSupportedCountry)(e)?e:null,PhoneNumberInput=exports.PhoneNumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:o,onChange:n,e164:r,onChangeE164:l,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onComplete:d,onValidityChange:b,countries:m=ALL_CALLING_CODES,popularCountries:p,popularCountriesTitle:_="Popular",allCountriesTitle:f="All countries",hiddenCountries:g,showFlag:h=!0,renderFlag:x,renderCountry:C,countrySearchPlaceholder:N,showAlphabetIndex:y,defaultIso:v="IN",validation:S="any",maxLength:L,formatAsYouType:E=!0,countryLocked:j=!1,label:I,labelMode:F="top",labelStyle:O,placeholder:T="Phone number",helperText:A,error:P,invalidMessage:R,required:D,disabled:w=!1,size:q="md",variant:k,borderRadius:M,countrySheetTitle:V="Country code",haptic:z,accessibilityLabel:B,countryAccessibilityLabel:$,onFocus:G,onBlur:U,style:W,testID:H}=e,Y=(0,_index2.useTheme)(),K=(0,_react.useMemo)(()=>buildStyles(Y),[Y]),J=(0,_react.useRef)(null),Q=(0,_react.useMemo)(()=>g?.length?m.filter(e=>!g.includes(e.iso)):m,[m,g]),X=(0,_react.useMemo)(()=>{if(!p?.length)return;const e=p.map(e=>Q.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:_,options:e},{title:f,options:Q}]:void 0},[p,_,f,Q]),Z=(0,_react.useCallback)((e,t,i)=>{if(!e)return null;if(x)return x(e);if(!h)return null;const o=(0,_mobileCore.countryFlagEmoji)(e.iso);return o?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[K.flag,{fontSize:t}],testID:i,children:o}):null},[x,h,K.flag]),ee=(0,_react.useCallback)(e=>{const t=planOf(e),i=t?(0,_mobileCore.maxNationalNumberLength)(t,!1===S?"any":S):Number.POSITIVE_INFINITY;return L?Math.min(i,L):i},[L,S]),te=(0,_react.useCallback)((e,t)=>e.slice(0,ee(t)),[ee]),ie=(0,_react.useCallback)((e,t)=>{const i=planOf(t)??void 0,o=(0,_mobileCore.splitPhoneNumber)(e,i);if(!o)return null;const n=o.country??t,r=m.find(e=>e.iso===n);return{callingCode:r?.code??o.callingCode,nationalNumber:te(o.nationalNumber,n),iso:r?.iso??n}},[m,te]),oe=(0,_react.useMemo)(()=>{const e=Q.find(e=>e.iso===v)??Q[0]??m[0],t={callingCode:e?.code??"91",nationalNumber:"",iso:e?.iso??"IN"};return"string"==typeof o?ie(o,t.iso)??t:o??t},[m,Q,v,o,ie]),ne=(0,_react.useCallback)(e=>{if(!1===S)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?(0,_mobileCore.isValidNationalNumber)(e.nationalNumber,t,S):e.nationalNumber.length>0},[S]),[re,le]=(0,_react.useState)(oe.iso),ae=(0,_react.useMemo)(()=>{if(void 0===r)return;const e=r?parseE164(r,m,re):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=m.find(e=>e.iso===re);return{callingCode:t?.code??oe.callingCode,nationalNumber:"",iso:re}},[r,m,re,oe.callingCode,te]),se=(0,_react.useCallback)(e=>{le(e.iso),n?.(e),l?.(e.nationalNumber?formatE164(e):"",{country:m.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,l,m,ne]),[ue,ce]=(0,_index.useControllableState)({value:i??ae,defaultValue:oe,onChange:se}),[de,be]=(0,_react.useState)(!1),me=(0,_react.useCallback)(()=>{w||J.current?.focus()},[w]),[pe,fe]=(0,_react.useState)(!1),[ge,he]=(0,_react.useState)(!1),[xe,Ce]=(0,_react.useState)(!1),Ne=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{xe||(Ne.current=!1)},[xe]);const ye=(0,_index2.resolveFieldSize)(Y,q),ve=(0,_index4.resolveFieldTextStyle)(Y,{disabled:w}),Se=k??Y.settings.components.field?.defaultVariant??"outlined",Le="underline"===Se,Ee=M??ye.radius,je=Y.space.md,[Ie,Fe]=(0,_react.useState)(0),Oe=Ie+je+1+je,Te=ue.nationalNumber.length>0,Ae=D&&!I&&!Te&&T.length>0,Pe=de||Te,Re=Boolean(I)&&"float"===F&&Ie>0,De=(0,_useFloatingLabel.useFloatingLabel)({label:I,enabled:Re,floated:Pe,required:D,variant:Se,sizeTokens:ye,leadingOffset:Oe,paddingLeft:Le?Y.space.none:ye["padding-x"],color:Y.colors["field-label"],style:O}),we=(0,_react.useMemo)(()=>m.find(e=>e.iso===ue.iso),[m,ue.iso]),qe=planOf(ue.iso),ke=E&&qe?(0,_mobileCore.formatPhoneAsTyped)(ue.nationalNumber,qe):ue.nationalNumber,Me=ee(ue.iso),Ve=0===ue.nationalNumber.length||pe||!Number.isFinite(Me)?void 0:ke.length+Math.max(0,Me-ue.nationalNumber.length),ze=ne(ue);(0,_react.useEffect)(()=>{Te||he(!1)},[Te]);const Be=qe?(0,_mobileCore.maxNationalNumberLength)(qe,!1===S?"any":S):Number.POSITIVE_INFINITY,$e=ue.nationalNumber.length>=Be,Ge=!1!==S&&!1!==R&&Te&&!ze&&(ge||$e),Ue="mobile"===S?"Enter a valid mobile number":"Enter a valid number",We=(0,_index4.hasFieldText)(P)?P:Ge?R||Ue:void 0,He=!0===P||(0,_index4.hasFieldText)(We),Ye=(0,_react.useRef)(ze),Ke=(0,_react.useRef)(ue);Ke.current=ue,(0,_react.useEffect)(()=>{Ye.current!==ze&&(Ye.current=ze,b?.(ze),ze&&d?.(formatE164(Ke.current)))},[ze,d,b]);const Je=(0,_react.useCallback)(e=>{if(e.includes("+")){const t=ie(e,ue.iso);if(t&&!j&&Q.some(e=>e.iso===t.iso))return void ce(t);if(t&&t.iso===ue.iso)return void ce(t)}ce({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[Q,j,ue,ie,te,ce]),Qe=(0,_react.useCallback)(e=>{const t=e;ce({callingCode:t.code,iso:t.iso,nationalNumber:te(ue.nationalNumber,t.iso)}),Ce(!1);const i=(0,_index3.resolveHaptic)(z,"selection");i&&(0,_index3.triggerHaptic)(i)},[ue,z,te,ce]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>J.current?.focus(),blur:()=>J.current?.blur(),clear:()=>ce({...Ke.current,nationalNumber:""}),isFocused:()=>J.current?.isFocused()??!1,getValue:()=>Ke.current,getE164:()=>formatE164(Ke.current),getFormatted:()=>{const e=Ke.current,t=planOf(e.iso);return t?(0,_mobileCore.formatPhoneAsTyped)(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ke.current),getCountry:()=>m.find(e=>e.iso===Ke.current.iso)}),[m,ne,ce]);const Xe=w||j,Ze=(0,_jsxRuntime.jsx)(_index4.FieldBase,{size:q,variant:Se,borderRadius:Ee,topNotch:De.topNotch,focused:de,disabled:w,error:He,filled:Te,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Le?Y.space.none:void 0,leading:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{Xe||(Ne.current=!0,Ce(!0))},disabled:Xe,accessibilityRole:"button",accessibilityLabel:$??`Country code, currently +${ue.callingCode}`,accessibilityState:{disabled:Xe},"aria-disabled":Xe,hitSlop:6,onLayout:e=>{const{width:t}=e.nativeEvent.layout;Fe(e=>e===t?e:t)},style:K.codeTrigger,testID:H?`${H}-code`:void 0,children:[Z(we,ye.text,H?`${H}-flag`:void 0),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[K.codeText,{color:ve.color,fontSize:ye.text}],children:`+${ue.callingCode}`}),j?null:(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:w?Y.colors["field-icon-disabled"]:Y.colors["field-icon"],size:ye.icon,open:xe})]}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:K.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:J,value:ke,maxLength:Ve,onChangeText:Je,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onSelectionChange:e=>{const{start:t,end:i}=e.nativeEvent.selection;fe(t!==i)},onFocus:()=>{be(!0),G?.()},onBlur:()=>{be(!1),Te&&!Ne.current&&he(!0),U?.()},editable:!w,placeholder:Re&&!Pe||Ae?void 0:T,placeholderTextColor:ve.placeholderColor,accessibilityLabel:B??I??T,selectionColor:Y.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[K.input,{color:ve.color,fontSize:ye.text,...ve.weightStyle,paddingLeft:Le?Y.space.none:void 0}],testID:H?`${H}-input`:void 0}),Ae?(0,_jsxRuntime.jsx)(_index4.RequiredPlaceholder,{text:T,color:ve.placeholderColor,fontSize:ye.text,weightStyle:ve.weightStyle}):null]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W,testID:H,children:[I&&"top"===F?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:q,required:D,children:I}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:K.fieldWrapper,children:[Ze,De.node]}),(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:q,error:He,text:He?We:A}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:xe,onClose:()=>Ce(!1),title:V,options:Q,sections:X,labelOf:e=>`${e.label} (+${e.code})`,getValue:e=>e.iso,disabledOf:()=>!1,descriptionOf:()=>{},iconOf:e=>Z(e,Y.text.lg.size),renderOption:C?(e,t)=>C(e,{selected:t.selected}):void 0,isSelected:e=>e===we?.iso,onSelect:Qe,searchable:Q.length>8,searchPlaceholder:N,alphabetIndex:y??Q.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>_reactNative.StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},flag:{includeFontPadding:!1,marginRight:e.space.xs},codeText:{...(0,_index2.fontFor)(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});var _default=exports.default=PhoneNumberInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseE164=exports.formatE164=exports.default=exports.PhoneNumberInput=exports.DEFAULT_CALLING_CODES=exports.ALL_CALLING_CODES=void 0;var _mobileCore=require("@webority/mobile-core"),_countries=require("@webority/mobile-core/phone/countries"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_hitSlop=require("../../utils/hitSlop.js"),_index4=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALLING_CODES=exports.DEFAULT_CALLING_CODES=[{iso:"IN",code:"91",label:"India"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"},{iso:"CA",code:"1",label:"Canada"},{iso:"AU",code:"61",label:"Australia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"SA",code:"966",label:"Saudi Arabia"}],ALL_CALLING_CODES=exports.ALL_CALLING_CODES=(0,_mobileCore.getPhoneCountries)().map(e=>({iso:e.iso,code:e.callingCode,label:_countries.PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label)),digitsOnly=e=>e.replace(/[^0-9]/g,""),formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;exports.formatE164=formatE164;const parseE164=(e,t,i)=>{const o=e.replace(/[^0-9]/g,"");if(!o)return null;const n=(0,_mobileCore.splitPhoneNumber)(`+${o}`);let r=n?.callingCode,l=n?.nationalNumber??"";if(!r){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(r=e.find(e=>o.startsWith(e)),!r)return null;l=o.slice(r.length)}const a=t.filter(e=>e.code===r),s=a.find(e=>e.iso===i)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:r,nationalNumber:l,iso:s}};exports.parseE164=parseE164;const planOf=e=>(0,_mobileCore.isSupportedCountry)(e)?e:null,PhoneNumberInput=exports.PhoneNumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:o,onChange:n,e164:r,onChangeE164:l,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onComplete:d,onValidityChange:b,countries:m=ALL_CALLING_CODES,popularCountries:p,popularCountriesTitle:_="Popular",allCountriesTitle:f="All countries",hiddenCountries:h,showFlag:g=!0,renderFlag:x,renderCountry:C,countrySearchPlaceholder:N,showAlphabetIndex:y,defaultIso:S="IN",validation:v="any",maxLength:L,formatAsYouType:E=!0,countryLocked:j=!1,label:I,labelMode:F="top",labelStyle:O,placeholder:T="Phone number",helperText:A,error:P,invalidMessage:R,required:D,disabled:q=!1,size:w="md",variant:k,borderRadius:M,countrySheetTitle:V="Country code",haptic:z,accessibilityLabel:B,countryAccessibilityLabel:$,onFocus:G,onBlur:U,style:W,testID:H}=e,Y=(0,_index2.useTheme)(),K=(0,_react.useMemo)(()=>buildStyles(Y),[Y]),J=(0,_react.useRef)(null),Q=(0,_react.useMemo)(()=>h?.length?m.filter(e=>!h.includes(e.iso)):m,[m,h]),X=(0,_react.useMemo)(()=>{if(!p?.length)return;const e=p.map(e=>Q.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:_,options:e},{title:f,options:Q}]:void 0},[p,_,f,Q]),Z=(0,_react.useCallback)((e,t,i)=>{if(!e)return null;if(x)return x(e);if(!g)return null;const o=(0,_mobileCore.countryFlagEmoji)(e.iso);return o?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[K.flag,{fontSize:t}],testID:i,children:o}):null},[x,g,K.flag]),ee=(0,_react.useCallback)(e=>{const t=planOf(e),i=t?(0,_mobileCore.maxNationalNumberLength)(t,!1===v?"any":v):Number.POSITIVE_INFINITY;return L?Math.min(i,L):i},[L,v]),te=(0,_react.useCallback)((e,t)=>e.slice(0,ee(t)),[ee]),ie=(0,_react.useCallback)((e,t)=>{const i=planOf(t)??void 0,o=(0,_mobileCore.splitPhoneNumber)(e,i);if(!o)return null;const n=o.country??t,r=m.find(e=>e.iso===n);return{callingCode:r?.code??o.callingCode,nationalNumber:te(o.nationalNumber,n),iso:r?.iso??n}},[m,te]),oe=(0,_react.useMemo)(()=>{const e=Q.find(e=>e.iso===S)??Q[0]??m[0],t={callingCode:e?.code??"91",nationalNumber:"",iso:e?.iso??"IN"};return"string"==typeof o?ie(o,t.iso)??t:o??t},[m,Q,S,o,ie]),ne=(0,_react.useCallback)(e=>{if(!1===v)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?(0,_mobileCore.isValidNationalNumber)(e.nationalNumber,t,v):e.nationalNumber.length>0},[v]),[re,le]=(0,_react.useState)(oe.iso),ae=(0,_react.useMemo)(()=>{if(void 0===r)return;const e=r?parseE164(r,m,re):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=m.find(e=>e.iso===re);return{callingCode:t?.code??oe.callingCode,nationalNumber:"",iso:re}},[r,m,re,oe.callingCode,te]),se=(0,_react.useCallback)(e=>{le(e.iso),n?.(e),l?.(e.nationalNumber?formatE164(e):"",{country:m.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,l,m,ne]),[ue,ce]=(0,_index.useControllableState)({value:i??ae,defaultValue:oe,onChange:se}),[de,be]=(0,_react.useState)(!1),me=(0,_react.useCallback)(()=>{q||J.current?.focus()},[q]),[pe,fe]=(0,_react.useState)(!1),[he,ge]=(0,_react.useState)(!1),[xe,Ce]=(0,_react.useState)(!1),Ne=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{xe||(Ne.current=!1)},[xe]);const ye=(0,_index2.resolveFieldSize)(Y,w),Se=(0,_index4.resolveFieldTextStyle)(Y,{disabled:q}),ve=k??Y.settings.components.field?.defaultVariant??"outlined",Le="underline"===ve,Ee=M??ye.radius,je=Y.space.md,[Ie,Fe]=(0,_react.useState)(0),Oe=Ie+je+1+je,Te=ue.nationalNumber.length>0,Ae=D&&!I&&!Te&&T.length>0,Pe=de||Te,Re=Boolean(I)&&"float"===F&&Ie>0,De=(0,_useFloatingLabel.useFloatingLabel)({label:I,enabled:Re,floated:Pe,required:D,variant:ve,sizeTokens:ye,leadingOffset:Oe,paddingLeft:Le?Y.space.none:ye["padding-x"],color:Y.colors["field-label"],style:O}),qe=(0,_react.useMemo)(()=>m.find(e=>e.iso===ue.iso),[m,ue.iso]),we=planOf(ue.iso),ke=E&&we?(0,_mobileCore.formatPhoneAsTyped)(ue.nationalNumber,we):ue.nationalNumber,Me=ee(ue.iso),Ve=0===ue.nationalNumber.length||pe||!Number.isFinite(Me)?void 0:ke.length+Math.max(0,Me-ue.nationalNumber.length),ze=ne(ue);(0,_react.useEffect)(()=>{Te||ge(!1)},[Te]);const Be=we?(0,_mobileCore.maxNationalNumberLength)(we,!1===v?"any":v):Number.POSITIVE_INFINITY,$e=ue.nationalNumber.length>=Be,Ge=!1!==v&&!1!==R&&Te&&!ze&&(he||$e),Ue="mobile"===v?"Enter a valid mobile number":"Enter a valid number",We=(0,_index4.hasFieldText)(P)?P:Ge?R||Ue:void 0,He=!0===P||(0,_index4.hasFieldText)(We),Ye=(0,_react.useRef)(ze),Ke=(0,_react.useRef)(ue);Ke.current=ue,(0,_react.useEffect)(()=>{Ye.current!==ze&&(Ye.current=ze,b?.(ze),ze&&d?.(formatE164(Ke.current)))},[ze,d,b]);const Je=(0,_react.useCallback)(e=>{if(e.includes("+")){const t=ie(e,ue.iso);if(t&&!j&&Q.some(e=>e.iso===t.iso))return void ce(t);if(t&&t.iso===ue.iso)return void ce(t)}ce({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[Q,j,ue,ie,te,ce]),Qe=(0,_react.useCallback)(e=>{const t=e;ce({callingCode:t.code,iso:t.iso,nationalNumber:te(ue.nationalNumber,t.iso)}),Ce(!1);const i=(0,_index3.resolveHaptic)(z,"selection");i&&(0,_index3.triggerHaptic)(i)},[ue,z,te,ce]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>J.current?.focus(),blur:()=>J.current?.blur(),clear:()=>ce({...Ke.current,nationalNumber:""}),isFocused:()=>J.current?.isFocused()??!1,getValue:()=>Ke.current,getE164:()=>formatE164(Ke.current),getFormatted:()=>{const e=Ke.current,t=planOf(e.iso);return t?(0,_mobileCore.formatPhoneAsTyped)(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ke.current),getCountry:()=>m.find(e=>e.iso===Ke.current.iso)}),[m,ne,ce]);const Xe=q||j,Ze=(0,_jsxRuntime.jsx)(_index4.FieldBase,{size:w,variant:ve,borderRadius:Ee,topNotch:De.topNotch,focused:de,disabled:q,error:He,filled:Te,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Le?Y.space.none:void 0,leading:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{Xe||(Ne.current=!0,Ce(!0))},disabled:Xe,accessibilityRole:"button",accessibilityLabel:$??`Country code, currently +${ue.callingCode}`,accessibilityState:{disabled:Xe},"aria-disabled":Xe,hitSlop:6,...(0,_hitSlop.hitSlopMarker)(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Fe(e=>e===t?e:t)},style:K.codeTrigger,testID:H?`${H}-code`:void 0,children:[Z(qe,ye.text,H?`${H}-flag`:void 0),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[K.codeText,{color:Se.color,fontSize:ye.text}],children:`+${ue.callingCode}`}),j?null:(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:q?Y.colors["field-icon-disabled"]:Y.colors["field-icon"],size:ye.icon,open:xe})]}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:K.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:J,value:ke,maxLength:Ve,onChangeText:Je,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onSelectionChange:e=>{const{start:t,end:i}=e.nativeEvent.selection;fe(t!==i)},onFocus:()=>{be(!0),G?.()},onBlur:()=>{be(!1),Te&&!Ne.current&&ge(!0),U?.()},editable:!q,placeholder:Re&&!Pe||Ae?void 0:T,placeholderTextColor:Se.placeholderColor,accessibilityLabel:B??I??T,selectionColor:Y.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[K.input,{color:Se.color,fontSize:ye.text,...Se.weightStyle,paddingLeft:Le?Y.space.none:void 0}],testID:H?`${H}-input`:void 0}),Ae?(0,_jsxRuntime.jsx)(_index4.RequiredPlaceholder,{text:T,color:Se.placeholderColor,fontSize:ye.text,weightStyle:Se.weightStyle}):null]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W,testID:H,children:[I&&"top"===F?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:w,required:D,children:I}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:K.fieldWrapper,children:[Ze,De.node]}),(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:w,error:He,text:He?We:A}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:xe,onClose:()=>Ce(!1),title:V,options:Q,sections:X,labelOf:e=>`${e.label} (+${e.code})`,getValue:e=>e.iso,disabledOf:()=>!1,descriptionOf:()=>{},iconOf:e=>Z(e,Y.text.lg.size),renderOption:C?(e,t)=>C(e,{selected:t.selected}):void 0,isSelected:e=>e===qe?.iso,onSelect:Qe,searchable:Q.length>8,searchPlaceholder:N,alphabetIndex:y??Q.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>_reactNative.StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},flag:{includeFontPadding:!1,marginRight:e.space.xs},codeText:{...(0,_index2.fontFor)(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});var _default=exports.default=PhoneNumberInput;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRadioGroup=exports.default=exports.RadioGroupContext=exports.Radio=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("./RadioDot.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroupContext=exports.RadioGroupContext=(0,_react.createContext)(null),useRadioGroup=()=>(0,_react.useContext)(RadioGroupContext);exports.useRadioGroup=useRadioGroup;const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;default:return e.colors.primary}},Radio=exports.Radio=(0,_react.forwardRef)((e,t)=>{const{value:i,selected:r,onChange:o,disabled:s=!1,label:a,description:l,error:c,size:d="md",tone:n="primary",accessibilityLabel:u,haptic:p,style:x,containerStyle:_,circleStyle:b,dotStyle:h,labelStyle:y,testID:R,...m}=e,C=(0,_index.useTheme)(),g=(0,_react.useMemo)(()=>buildStyles(C),[C]),f=useRadioGroup();__DEV__&&void 0===i&&_mobileCore.Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const w=f?f.selectedValue===i:!!r,S=f&&f.disabled||s,j=toneColor(C,n),v=(0,_index.spaceOf)(C,C.components.radio["label-gap"]),T=u??(0,_index2.fieldTextAsString)(a),q=!0===f?.error||!0===c||(0,_index2.hasFieldText)(c);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:e=>{if(S)return;const t=(0,_hapticUtils.resolveHaptic)(p,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),f?f.onChange(i):o?.(i)},disabled:S,accessibilityRole:"radio",accessibilityLabel:T,accessibilityHint:m.accessibilityHint??(0,_index2.fieldTextAsString)(l),accessibilityState:{checked:w,disabled:S},"aria-checked":w,"aria-disabled":S,testID:R,hitSlop:6,...m,style:({pressed:e})=>[g.row,(0,_ChoiceText.hasChoiceDetail)(l,c)?g.rowTop:null,{opacity:S?.55:e?.85:1},x,_],children:[(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:w,color:j,disabled:S&&!w,size:d,style:[!q||w||S?null:{borderColor:C.colors["field-border-error"]},b],dotStyle:h}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:a,description:l,error:c,disabled:S,labelLines:2,style:{marginLeft:v},labelStyle:y})]})});Radio.displayName="Radio";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});var _default=exports.default=Radio;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRadioGroup=exports.default=exports.RadioGroupContext=exports.Radio=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("./RadioDot.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroupContext=exports.RadioGroupContext=(0,_react.createContext)(null),useRadioGroup=()=>(0,_react.useContext)(RadioGroupContext);exports.useRadioGroup=useRadioGroup;const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;default:return e.colors.primary}},Radio=exports.Radio=(0,_react.forwardRef)((e,t)=>{const{value:i,selected:r,onChange:o,disabled:s=!1,label:a,description:l,error:c,size:d="md",tone:n="primary",accessibilityLabel:u,haptic:p,style:x,containerStyle:_,circleStyle:b,dotStyle:h,labelStyle:y,testID:R,hitSlop:m,...S}=e,C=(0,_index.useTheme)(),g=(0,_react.useMemo)(()=>buildStyles(C),[C]),f=useRadioGroup();__DEV__&&void 0===i&&_mobileCore.Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const j=f?f.selectedValue===i:!!r,w=f&&f.disabled||s,v=toneColor(C,n),T=(0,_index.spaceOf)(C,C.components.radio["label-gap"]),q=m??6,D=u??(0,_index2.fieldTextAsString)(a),G=!0===f?.error||!0===c||(0,_index2.hasFieldText)(c);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:e=>{if(w)return;const t=(0,_hapticUtils.resolveHaptic)(p,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),f?f.onChange(i):o?.(i)},disabled:w,accessibilityRole:"radio",accessibilityLabel:D,accessibilityHint:S.accessibilityHint??(0,_index2.fieldTextAsString)(l),accessibilityState:{checked:j,disabled:w},"aria-checked":j,"aria-disabled":w,testID:R,hitSlop:q,...(0,_hitSlop.hitSlopMarker)(q),...S,style:({pressed:e})=>[g.row,(0,_ChoiceText.hasChoiceDetail)(l,c)?g.rowTop:null,{opacity:w?.55:e?.85:1},x,_],children:[(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:j,color:v,disabled:w&&!j,size:d,style:[!G||j||w?null:{borderColor:C.colors["field-border-error"]},b],dotStyle:h}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:a,description:l,error:c,disabled:w,labelLines:2,style:{marginLeft:T},labelStyle:y})]})});Radio.displayName="Radio";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});var _default=exports.default=Radio;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Rating=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_index2=require("../Skeleton/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>"number"==typeof e?e:sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(e,t)=>"primary"===t?e.colors.primary:e.colors.warning,clampToStep=(e,t,i)=>{const a=Math.max(0,Math.min(t,e)),s=Math.round(a/i)*i;return Number(s.toFixed(2))},Star=({index:e,filled:t,size:i,filledColor:a,emptyColor:s,scale:n})=>{const r=Math.max(0,Math.min(1,t-e));return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[starStyles.starWrap,{width:i,height:i,transform:[{scale:n}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[starStyles.glyph,{color:s,fontSize:i,lineHeight:i}],accessible:!1,children:"☆"}),r>0?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[starStyles.fillClip,{width:i*r,height:i}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[starStyles.glyph,{color:a,fontSize:i,lineHeight:i}],accessible:!1,children:"★"})}):null]})},Rating=exports.Rating=(0,_react.forwardRef)((e,t)=>{const{value:i,onChange:a,max:s=5,allowHalf:n=!0,readonly:r=!1,size:l="md",tone:o="warning",label:c,loading:u=!1,haptic:m,accessibilityLabel:d,style:x,containerStyle:p,starContainerStyle:y,testID:_}=e,h=(0,_index.useTheme)(),g=(0,_react.useMemo)(()=>buildStyles(h),[h]),v=!r&&"function"==typeof a,f=n?.5:1,b=resolveSize(l),j=toneColorFor(h,o),S=h.colors.border,R=(0,_react.useRef)(b),w=(0,_react.useCallback)(e=>{R.current=e.nativeEvent.layout.width},[]),N=(0,_react.useRef)(new Map),C=(0,_react.useMemo)(()=>{const e=N.current,t=[];for(let i=0;i<s;i+=1){let a=e.get(i);a||(a=new _reactNative.Animated.Value(1),e.set(i,a)),t.push(a)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),k=h.settings.components.rating?.pulseOnPress??!1,z=(0,_react.useCallback)(e=>{const t=C[e];t&&_reactNative.Animated.sequence([_reactNative.Animated.timing(t,{toValue:1.2,duration:h.motion.duration.fast,easing:_reactNative.Easing.bezier(...h.motion.ease["in-out"]),useNativeDriver:!0}),_reactNative.Animated.spring(t,{toValue:1,damping:h.motion.spring.bouncy.damping,stiffness:h.motion.spring.bouncy.stiffness,mass:h.motion.spring.bouncy.mass,useNativeDriver:!0})]).start()},[h.motion,C]),M=(0,_react.useCallback)((e,t)=>{if(!v||!a)return;const i=clampToStep(e,s,f),n=(0,_hapticUtils.resolveHaptic)(m,"selection");n&&(0,_hapticUtils.triggerHaptic)(n),k&&"number"==typeof t&&z(t),a(i)},[v,a,s,f,z,m,k]),A=(0,_react.useCallback)(e=>t=>{if(!v)return;const i=R.current||b,a=t.nativeEvent.locationX??i;let s;s=n&&a<i/2?e+.5:e+1,M(s,e)},[v,b,n,M]),P=(0,_react.useCallback)(e=>{v&&("increment"===e.nativeEvent.actionName?M(i+f):"decrement"===e.nativeEvent.actionName&&M(i-f))},[v,i,f,M]),V=`${i} of ${s} stars`,E=d??c??V,q=[];for(let e=0;e<s;e+=1){const t=C[e];if(!t)continue;const a=(0,_jsxRuntime.jsx)(Star,{index:e,filled:i,size:b,filledColor:j,emptyColor:S,scale:t},e);q.push(v?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:A(e),onLayout:0===e?w:void 0,hitSlop:4,accessible:!1,style:g.starPress,children:a},e):(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:0===e?w:void 0,style:g.starPress,children:a},e))}const D=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[g.wrapper,x,p],ref:t,testID:_,children:[c?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[g.label,{color:h.colors["text-muted"],fontSize:h.text.sm.size}],children:c}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[g.row,y],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:E,accessibilityValue:v?{min:0,max:s,now:i,text:V}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?P:void 0,children:q})]});return u?(0,_jsxRuntime.jsx)(RatingSkeleton,{...e}):D});Rating.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:i,containerStyle:a,starContainerStyle:s,style:n})=>{const r=(0,_index.useTheme)(),l=resolveSize(t),o=Math.max(1,e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{alignItems:"flex-start"},a,n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==i?(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:r.space.xs}}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{flexDirection:"row"},s],children:Array.from({length:o}).map((e,t)=>(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:l,height:l,radius:Math.round(.25*l),style:t<o-1?{marginRight:r.space.xs}:void 0},`sk-star-${t}`))})]})};RatingSkeleton.displayName="RatingSkeleton",Rating.Skeleton=RatingSkeleton;const starStyles=_reactNative.StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>_reactNative.StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});var _default=exports.default=Rating;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Rating=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../Skeleton/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>"number"==typeof e?e:sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(e,t)=>"primary"===t?e.colors.primary:e.colors.warning,clampToStep=(e,t,i)=>{const s=Math.max(0,Math.min(t,e)),a=Math.round(s/i)*i;return Number(a.toFixed(2))},Star=({index:e,filled:t,size:i,filledColor:s,emptyColor:a,scale:n})=>{const r=Math.max(0,Math.min(1,t-e));return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[starStyles.starWrap,{width:i,height:i,transform:[{scale:n}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[starStyles.glyph,{color:a,fontSize:i,lineHeight:i}],accessible:!1,children:"☆"}),r>0?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[starStyles.fillClip,{width:i*r,height:i}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[starStyles.glyph,{color:s,fontSize:i,lineHeight:i}],accessible:!1,children:"★"})}):null]})},Rating=exports.Rating=(0,_react.forwardRef)((e,t)=>{const{value:i,onChange:s,max:a=5,allowHalf:n=!0,readonly:r=!1,size:l="md",tone:o="warning",label:c,loading:u=!1,haptic:m,accessibilityLabel:d,style:x,containerStyle:p,starContainerStyle:y,testID:_}=e,h=(0,_index.useTheme)(),g=(0,_react.useMemo)(()=>buildStyles(h),[h]),v=!r&&"function"==typeof s,f=n?.5:1,S=resolveSize(l),b=toneColorFor(h,o),j=h.colors.border,R=(0,_react.useRef)(S),w=(0,_react.useCallback)(e=>{R.current=e.nativeEvent.layout.width},[]),N=(0,_react.useRef)(new Map),C=(0,_react.useMemo)(()=>{const e=N.current,t=[];for(let i=0;i<a;i+=1){let s=e.get(i);s||(s=new _reactNative.Animated.Value(1),e.set(i,s)),t.push(s)}for(const t of Array.from(e.keys()))t>=a&&e.delete(t);return t},[a]),k=h.settings.components.rating?.pulseOnPress??!1,z=(0,_react.useCallback)(e=>{const t=C[e];t&&_reactNative.Animated.sequence([_reactNative.Animated.timing(t,{toValue:1.2,duration:h.motion.duration.fast,easing:_reactNative.Easing.bezier(...h.motion.ease["in-out"]),useNativeDriver:!0}),_reactNative.Animated.spring(t,{toValue:1,damping:h.motion.spring.bouncy.damping,stiffness:h.motion.spring.bouncy.stiffness,mass:h.motion.spring.bouncy.mass,useNativeDriver:!0})]).start()},[h.motion,C]),M=(0,_react.useCallback)((e,t)=>{if(!v||!s)return;const i=clampToStep(e,a,f),n=(0,_hapticUtils.resolveHaptic)(m,"selection");n&&(0,_hapticUtils.triggerHaptic)(n),k&&"number"==typeof t&&z(t),s(i)},[v,s,a,f,z,m,k]),A=(0,_react.useCallback)(e=>t=>{if(!v)return;const i=R.current||S,s=t.nativeEvent.locationX??i;let a;a=n&&s<i/2?e+.5:e+1,M(a,e)},[v,S,n,M]),P=(0,_react.useCallback)(e=>{v&&("increment"===e.nativeEvent.actionName?M(i+f):"decrement"===e.nativeEvent.actionName&&M(i-f))},[v,i,f,M]),V=`${i} of ${a} stars`,q=d??c??V,E=[];for(let e=0;e<a;e+=1){const t=C[e];if(!t)continue;const s=(0,_jsxRuntime.jsx)(Star,{index:e,filled:i,size:S,filledColor:b,emptyColor:j,scale:t},e);E.push(v?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:A(e),onLayout:0===e?w:void 0,hitSlop:4,...(0,_hitSlop.hitSlopMarker)(4),accessible:!1,style:g.starPress,children:s},e):(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:0===e?w:void 0,style:g.starPress,children:s},e))}const D=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[g.wrapper,x,p],ref:t,testID:_,children:[c?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[g.label,{color:h.colors["text-muted"],fontSize:h.text.sm.size}],children:c}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[g.row,y],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:q,accessibilityValue:v?{min:0,max:a,now:i,text:V}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?P:void 0,children:E})]});return u?(0,_jsxRuntime.jsx)(RatingSkeleton,{...e}):D});Rating.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:i,containerStyle:s,starContainerStyle:a,style:n})=>{const r=(0,_index.useTheme)(),l=resolveSize(t),o=Math.max(1,e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{alignItems:"flex-start"},s,n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==i?(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:r.space.xs}}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{flexDirection:"row"},a],children:Array.from({length:o}).map((e,t)=>(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:l,height:l,radius:Math.round(.25*l),style:t<o-1?{marginRight:r.space.xs}:void 0},`sk-star-${t}`))})]})};RatingSkeleton.displayName="RatingSkeleton",Rating.Skeleton=RatingSkeleton;const starStyles=_reactNative.StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>_reactNative.StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});var _default=exports.default=Rating;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.RichTextEditor=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"),_markdownActions=require("./markdownActions.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_META={bold:{glyph:"B",label:"Bold"},italic:{glyph:"I",label:"Italic"},strikethrough:{glyph:"S",label:"Strikethrough"},code:{glyph:"</>",label:"Inline code"},link:{glyph:"link",label:"Link"},heading1:{glyph:"H1",label:"Heading 1"},heading2:{glyph:"H2",label:"Heading 2"},bulletList:{glyph:"•",label:"Bulleted list"},numberedList:{glyph:"1.",label:"Numbered list"},quote:{glyph:">",label:"Quote"}},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5,RichTextEditor=exports.RichTextEditor=(0,_react.forwardRef)((e,t)=>{const{value:i,onChangeText:o,placeholder:l,actions:s=DEFAULT_ACTIONS,disabled:r=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:c=!1,accessibilityLabel:d,haptic:u,style:h,toolbarStyle:x,inputStyle:b,testID:_}=e,m=(0,_index.useTheme)(),g=(0,_react.useMemo)(()=>buildStyles(m),[m]),p=i??"",[y,j]=(0,_react.useState)({start:0,end:0}),[S,T]=(0,_react.useState)(!1),[R,k]=(0,_react.useState)(null),v=(0,_react.useCallback)(e=>{j(e.nativeEvent.selection),k(null)},[]),C=(0,_react.useCallback)(e=>{k(null),o?.(e)},[o]),I=(0,_react.useCallback)(e=>{if(r)return;const t=(0,_index2.resolveHaptic)(u,"selection");t&&(0,_index2.triggerHaptic)(t);const i=(0,_markdownActions.applyMarkdownAction)({text:p,selection:(0,_markdownActions.normalizeSelection)(y,p.length)},e);j(i.selection),k(i.selection),o?.(i.text)},[r,u,o,y,p]);return n?(0,_jsxRuntime.jsx)(RichTextEditorSkeleton,{actionCount:s.length,minHeight:a,style:h,testID:_}):(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:_,style:[g.container,{borderColor:S?m.colors["focus-ring"]:m.colors.border,opacity:r?.55:1},h],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[g.toolbar,x],children:s.map(e=>(0,_jsxRuntime.jsx)(ToolbarButton,{action:e,disabled:r,onPress:I,styles:g,theme:m,testID:_?`${_}-${e}`:void 0},e))}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:t,value:p,onChangeText:C,onSelectionChange:v,onFocus:()=>T(!0),onBlur:()=>T(!1),selection:R??void 0,editable:!r,autoFocus:c,multiline:!0,textAlignVertical:"top",placeholder:l,placeholderTextColor:m.colors["text-subtle"],accessibilityLabel:d,style:[g.input,{minHeight:a},b],testID:_?`${_}-input`:void 0})]})});RichTextEditor.displayName="RichTextEditor";const ToolbarButton=({action:e,disabled:t,onPress:i,styles:o,theme:l,testID:s})=>{const r=ACTION_META[e],n={color:t?l.colors["text-disabled"]:l.colors["text-body"]};return"bold"===e&&(n.fontWeight=l.weight.bold),"italic"===e&&(n.fontStyle="italic"),"strikethrough"===e&&(n.textDecorationLine="line-through"),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>i(e),disabled:t,accessibilityRole:"button",accessibilityLabel:r.label,accessibilityState:{disabled:t},"aria-disabled":t,hitSlop:4,testID:s,style:({pressed:e})=>[o.button,{backgroundColor:e?l.colors["surface-pressed"]:l.colors["bg-subtle"]}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{maxFontSizeMultiplier:Math.min(l.settings.maxFontSizeMultiplier??1.5,1.5),style:[o.buttonLabel,n],children:r.glyph})})};ToolbarButton.displayName="RichTextEditorToolbarButton";const RichTextEditorSkeleton=({actionCount:e,minHeight:t,style:i,testID:o})=>{const l=(0,_index.useTheme)(),s=(0,_react.useMemo)(()=>buildStyles(l),[l]),r=Array.from({length:Math.max(1,e)},(e,t)=>t);return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:o,style:[s.container,i],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:s.toolbar,children:r.map(e=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:34,height:30,radius:"sm"},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[s.skeletonBody,{minHeight:t}],children:[(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"94%",height:14}),(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"100%",height:14}),(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"72%",height:14})]})]})};RichTextEditorSkeleton.displayName="RichTextEditorSkeleton";const buildStyles=e=>_reactNative.StyleSheet.create({container:{borderWidth:e.size.border,borderColor:e.colors.border,borderRadius:e.radius.md,..._corners.smoothCorners,backgroundColor:e.colors.bg,overflow:"hidden"},toolbar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,padding:e.space.xs,borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:e.colors["border-subtle"],backgroundColor:e.colors["bg-subtle"]},button:{minWidth:34,height:30,paddingHorizontal:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},buttonLabel:{...(0,_index.fontFor)(e,"medium"),fontSize:e.text.sm.size},input:{...(0,_index.fontFor)(e,"normal"),color:e.colors["text-body"],fontSize:e.text.base.size,lineHeight:1.5*e.text.base.size,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},skeletonBody:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.sm}});var _default=exports.default=RichTextEditor;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.RichTextEditor=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"),_hitSlop=require("../../utils/hitSlop.js"),_index3=require("../Skeleton/index.js"),_markdownActions=require("./markdownActions.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_META={bold:{glyph:"B",label:"Bold"},italic:{glyph:"I",label:"Italic"},strikethrough:{glyph:"S",label:"Strikethrough"},code:{glyph:"</>",label:"Inline code"},link:{glyph:"link",label:"Link"},heading1:{glyph:"H1",label:"Heading 1"},heading2:{glyph:"H2",label:"Heading 2"},bulletList:{glyph:"•",label:"Bulleted list"},numberedList:{glyph:"1.",label:"Numbered list"},quote:{glyph:">",label:"Quote"}},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5,RichTextEditor=exports.RichTextEditor=(0,_react.forwardRef)((e,t)=>{const{value:i,onChangeText:o,placeholder:l,actions:s=DEFAULT_ACTIONS,disabled:r=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:c=!1,accessibilityLabel:d,haptic:u,style:h,toolbarStyle:x,inputStyle:b,testID:_}=e,p=(0,_index.useTheme)(),m=(0,_react.useMemo)(()=>buildStyles(p),[p]),g=i??"",[y,S]=(0,_react.useState)({start:0,end:0}),[j,T]=(0,_react.useState)(!1),[k,R]=(0,_react.useState)(null),v=(0,_react.useCallback)(e=>{S(e.nativeEvent.selection),R(null)},[]),C=(0,_react.useCallback)(e=>{R(null),o?.(e)},[o]),I=(0,_react.useCallback)(e=>{if(r)return;const t=(0,_index2.resolveHaptic)(u,"selection");t&&(0,_index2.triggerHaptic)(t);const i=(0,_markdownActions.applyMarkdownAction)({text:g,selection:(0,_markdownActions.normalizeSelection)(y,g.length)},e);S(i.selection),R(i.selection),o?.(i.text)},[r,u,o,y,g]);return n?(0,_jsxRuntime.jsx)(RichTextEditorSkeleton,{actionCount:s.length,minHeight:a,style:h,testID:_}):(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:_,style:[m.container,{borderColor:j?p.colors["focus-ring"]:p.colors.border,opacity:r?.55:1},h],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[m.toolbar,x],children:s.map(e=>(0,_jsxRuntime.jsx)(ToolbarButton,{action:e,disabled:r,onPress:I,styles:m,theme:p,testID:_?`${_}-${e}`:void 0},e))}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:t,value:g,onChangeText:C,onSelectionChange:v,onFocus:()=>T(!0),onBlur:()=>T(!1),selection:k??void 0,editable:!r,autoFocus:c,multiline:!0,textAlignVertical:"top",placeholder:l,placeholderTextColor:p.colors["text-subtle"],accessibilityLabel:d,style:[m.input,{minHeight:a},b],testID:_?`${_}-input`:void 0})]})});RichTextEditor.displayName="RichTextEditor";const ToolbarButton=({action:e,disabled:t,onPress:i,styles:o,theme:l,testID:s})=>{const r=ACTION_META[e],n={color:t?l.colors["text-disabled"]:l.colors["text-body"]};return"bold"===e&&(n.fontWeight=l.weight.bold),"italic"===e&&(n.fontStyle="italic"),"strikethrough"===e&&(n.textDecorationLine="line-through"),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>i(e),disabled:t,accessibilityRole:"button",accessibilityLabel:r.label,accessibilityState:{disabled:t},"aria-disabled":t,hitSlop:4,...(0,_hitSlop.hitSlopMarker)(4),testID:s,style:({pressed:e})=>[o.button,{backgroundColor:e?l.colors["surface-pressed"]:l.colors["bg-subtle"]}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{maxFontSizeMultiplier:Math.min(l.settings.maxFontSizeMultiplier??1.5,1.5),style:[o.buttonLabel,n],children:r.glyph})})};ToolbarButton.displayName="RichTextEditorToolbarButton";const RichTextEditorSkeleton=({actionCount:e,minHeight:t,style:i,testID:o})=>{const l=(0,_index.useTheme)(),s=(0,_react.useMemo)(()=>buildStyles(l),[l]),r=Array.from({length:Math.max(1,e)},(e,t)=>t);return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:o,style:[s.container,i],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:s.toolbar,children:r.map(e=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:34,height:30,radius:"sm"},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[s.skeletonBody,{minHeight:t}],children:[(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"94%",height:14}),(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"100%",height:14}),(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"72%",height:14})]})]})};RichTextEditorSkeleton.displayName="RichTextEditorSkeleton";const buildStyles=e=>_reactNative.StyleSheet.create({container:{borderWidth:e.size.border,borderColor:e.colors.border,borderRadius:e.radius.md,..._corners.smoothCorners,backgroundColor:e.colors.bg,overflow:"hidden"},toolbar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,padding:e.space.xs,borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:e.colors["border-subtle"],backgroundColor:e.colors["bg-subtle"]},button:{minWidth:34,height:30,paddingHorizontal:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},buttonLabel:{...(0,_index.fontFor)(e,"medium"),fontSize:e.text.sm.size},input:{...(0,_index.fontFor)(e,"normal"),color:e.colors["text-body"],fontSize:e.text.base.size,lineHeight:1.5*e.text.base.size,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},skeletonBody:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.sm}});var _default=exports.default=RichTextEditor;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SearchBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_useDebounce=require("../../hooks/useDebounce.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_SearchPanel=require("./SearchPanel.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=exports.SearchBar=(0,_react.forwardRef)((e,t)=>{const{value:a,onChangeText:s,onSubmit:l,onFocus:n,onBlur:c,placeholder:r="Search…",autoFocus:i=!1,disabled:o=!1,onClear:u,leftIcon:d,debounceMs:_,size:b="md",variant:h,borderRadius:p,label:g,labelMode:f="top",labelStyle:S,scopes:x,scope:m,onScopeChange:v,recents:R,recentsTitle:j="Recent searches",maxRecents:C=DEFAULT_PANEL_ROWS,onSelectRecent:y,onRemoveRecent:F,onClearRecents:k,suggestions:B,maxSuggestions:L=DEFAULT_PANEL_ROWS,onSelectSuggestion:I,haptic:q,style:E,inputStyle:P,accessibilityLabel:T,testID:N,...D}=e,z=(0,_index.useTheme)(),w=h??z.settings.components["search-bar"]?.defaultVariant??z.settings.components.field?.defaultVariant??"filled",A="underline"===w,H=(0,_index.resolveFieldSize)(z,b),U=(0,_index.radiusOf)(z,z.components["search-bar"][b].radius),M=(0,_FieldBase.resolveFieldTextStyle)(z,{disabled:o}),O=(0,_react.useRef)(null),V=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(O,t),[t]),W=(0,_react.useCallback)(()=>{o||O.current?.focus()},[o]),$=(0,_react.useMemo)(()=>buildStyles(z),[z]),K="string"==typeof a?a:"",[G,J]=(0,_react.useState)(!1),Q=(0,_react.useCallback)(e=>{J(!0),n?.(e)},[n]),X=(0,_react.useCallback)(e=>{J(!1),c?.(e)},[c]),[Y,Z]=(0,_react.useState)(K),ee=(0,_useDebounce.useDebounce)(Y,_??0);(0,_react.useEffect)(()=>{void 0!==_&&K!==Y&&Z(K)},[K,_]);const te=(0,_react.useRef)(K);(0,_react.useEffect)(()=>{void 0!==_&&ee!==te.current&&(te.current=ee,s(ee))},[ee,_,s]);const ae=(0,_react.useCallback)(e=>{void 0===_?s(e):Z(e)},[_,s]),se=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(q,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),void 0!==_&&(Z(""),te.current=""),s(""),u?.()},[q,_,s,u]),le=(0,_react.useCallback)(()=>{l?.(void 0!==_?Y:K)},[l,_,Y,K]),ne=void 0!==_?Y:K,ce=ne.length>0,[re,ie]=(0,_useControllableState.useControllableState)({value:m,defaultValue:x?.[0]?.value??"",onChange:v}),oe=(0,_react.useCallback)(e=>{ie(e);const t=x?.find(t=>t.value===e)?.label;t&&(0,_announce.announce)(`Searching ${t}`)},[x,ie]),[ue,de]=(0,_react.useState)(!1),be=(0,_react.useRef)(null),he=(0,_react.useCallback)(()=>{be.current&&(clearTimeout(be.current),be.current=null)},[]),pe=(0,_react.useCallback)(()=>{he(),de(!0)},[he]),ge=(0,_react.useCallback)(()=>{he(),be.current=setTimeout(()=>de(!1),50)},[he]);(0,_react.useEffect)(()=>he,[he]);const fe=!o&&(G||ue),Se=(0,_react.useMemo)(()=>(R??[]).slice(0,C),[R,C]),xe=(0,_react.useMemo)(()=>(B??[]).slice(0,L).map(_SearchPanel.normalizeSuggestion),[B,L]),me=fe&&!ce&&Se.length>0,ve=fe&&ce&&xe.length>0,Re=ve?xe.length:0;(0,_react.useEffect)(()=>{Re>0&&(0,_announce.announce)(1===Re?"1 suggestion":`${Re} suggestions`)},[Re]);const je=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(q,"selection");e&&(0,_hapticUtils.triggerHaptic)(e)},[q]),Ce=(0,_react.useCallback)(e=>{je(),O.current?.blur(),de(!1),y?.(e)},[je,y]),ye=(0,_react.useCallback)(e=>{je(),O.current?.blur(),de(!1),I?.(e)},[je,I]),Fe=(0,_react.useCallback)(e=>{je(),F?.(e),(0,_announce.announce)(`Removed ${e}`),W()},[je,F,W]),ke=(0,_react.useCallback)(()=>{je(),k?.(),(0,_announce.announce)("Recent searches cleared"),W()},[je,k,W]),Be={size:H.icon,color:o?z.colors["text-disabled"]:z.colors["text-subtle"],disabled:o},Le=d?(0,_slotIcon.renderSlotIcon)(d,Be):(z.settings.icons.search??_defaultIcons.defaultIcons.search)(Be),Ie=Boolean(g)&&"float"===f,qe=(0,_useFloatingLabel.useFloatingLabel)({label:g,enabled:Ie,floated:G||ce,variant:w,sizeTokens:H,leadingOffset:H.icon+z.space.md,trailingOffset:ce?H.icon+z.space.md:0,paddingLeft:A?z.space.none:H["padding-x"],color:z.colors["field-label"],style:S}),Ee=ce&&!o?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:se,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(z.settings.icons.close??_defaultIcons.defaultIcons.close)({size:H.icon,color:z.colors["text-muted"]})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E,testID:N,children:[g&&!Ie?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:b,style:S,children:g}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:$.root,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.fieldWrap,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:b,variant:w,focused:G,disabled:o,filled:ce,minHeight:H["min-height"],paddingHorizontal:A?z.space.none:H["padding-x"],borderRadius:p??U,leading:Le,trailing:Ee,topNotch:qe.topNotch,onPress:W,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:T??r,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:V,style:[$.input,{fontSize:H.text,color:M.color,...M.weightStyle},P],value:ne,onChangeText:ae,onSubmitEditing:le,onFocus:Q,onBlur:X,placeholder:!Ie||G||ce?r:void 0,placeholderTextColor:M.placeholderColor,autoFocus:i,editable:!o,returnKeyType:"search",selectionColor:(0,_FieldBase.resolveVariantColors)(z,w).borderFocusedRepresentative,accessibilityLabel:T??r,accessibilityState:{disabled:o},"aria-disabled":o,...D})}),qe.node]})}),x&&x.length>0?(0,_jsxRuntime.jsx)(_SearchPanel.SearchScopeBar,{scopes:x,scope:re||(x[0]?.value??""),disabled:o,haptic:q,onChange:oe}):null,me?(0,_jsxRuntime.jsx)(_SearchPanel.SearchRecents,{recents:Se,title:j,onSelect:Ce,onRemove:F?Fe:void 0,onClear:k?ke:void 0,onHold:pe,onRelease:ge}):null,ve?(0,_jsxRuntime.jsx)(_SearchPanel.SearchSuggestions,{suggestions:xe,query:ne,onSelect:ye,onHold:pe,onRelease:ge}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});var _default=exports.default=SearchBar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SearchBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_useDebounce=require("../../hooks/useDebounce.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_SearchPanel=require("./SearchPanel.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=exports.SearchBar=(0,_react.forwardRef)((e,t)=>{const{value:a,onChangeText:s,onSubmit:l,onFocus:n,onBlur:r,placeholder:c="Search…",autoFocus:i=!1,disabled:o=!1,onClear:u,leftIcon:d,debounceMs:_,size:b="md",variant:h,borderRadius:p,label:g,labelMode:S="top",labelStyle:f,scopes:x,scope:m,onScopeChange:v,recents:R,recentsTitle:j="Recent searches",maxRecents:C=DEFAULT_PANEL_ROWS,onSelectRecent:y,onRemoveRecent:F,onClearRecents:k,suggestions:B,maxSuggestions:L=DEFAULT_PANEL_ROWS,onSelectSuggestion:I,haptic:q,style:E,inputStyle:P,accessibilityLabel:T,testID:N,...D}=e,z=(0,_index.useTheme)(),w=h??z.settings.components["search-bar"]?.defaultVariant??z.settings.components.field?.defaultVariant??"filled",A="underline"===w,H=(0,_index.resolveFieldSize)(z,b),M=(0,_index.radiusOf)(z,z.components["search-bar"][b].radius),U=(0,_FieldBase.resolveFieldTextStyle)(z,{disabled:o}),O=(0,_react.useRef)(null),V=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(O,t),[t]),W=(0,_react.useCallback)(()=>{o||O.current?.focus()},[o]),$=(0,_react.useMemo)(()=>buildStyles(z),[z]),K="string"==typeof a?a:"",[G,J]=(0,_react.useState)(!1),Q=(0,_react.useCallback)(e=>{J(!0),n?.(e)},[n]),X=(0,_react.useCallback)(e=>{J(!1),r?.(e)},[r]),[Y,Z]=(0,_react.useState)(K),ee=(0,_useDebounce.useDebounce)(Y,_??0);(0,_react.useEffect)(()=>{void 0!==_&&K!==Y&&Z(K)},[K,_]);const te=(0,_react.useRef)(K);(0,_react.useEffect)(()=>{void 0!==_&&ee!==te.current&&(te.current=ee,s(ee))},[ee,_,s]);const ae=(0,_react.useCallback)(e=>{void 0===_?s(e):Z(e)},[_,s]),se=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(q,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),void 0!==_&&(Z(""),te.current=""),s(""),u?.()},[q,_,s,u]),le=(0,_react.useCallback)(()=>{l?.(void 0!==_?Y:K)},[l,_,Y,K]),ne=void 0!==_?Y:K,re=ne.length>0,[ce,ie]=(0,_useControllableState.useControllableState)({value:m,defaultValue:x?.[0]?.value??"",onChange:v}),oe=(0,_react.useCallback)(e=>{ie(e);const t=x?.find(t=>t.value===e)?.label;t&&(0,_announce.announce)(`Searching ${t}`)},[x,ie]),[ue,de]=(0,_react.useState)(!1),be=(0,_react.useRef)(null),he=(0,_react.useCallback)(()=>{be.current&&(clearTimeout(be.current),be.current=null)},[]),pe=(0,_react.useCallback)(()=>{he(),de(!0)},[he]),ge=(0,_react.useCallback)(()=>{he(),be.current=setTimeout(()=>de(!1),50)},[he]);(0,_react.useEffect)(()=>he,[he]);const Se=!o&&(G||ue),fe=(0,_react.useMemo)(()=>(R??[]).slice(0,C),[R,C]),xe=(0,_react.useMemo)(()=>(B??[]).slice(0,L).map(_SearchPanel.normalizeSuggestion),[B,L]),me=Se&&!re&&fe.length>0,ve=Se&&re&&xe.length>0,Re=ve?xe.length:0;(0,_react.useEffect)(()=>{Re>0&&(0,_announce.announce)(1===Re?"1 suggestion":`${Re} suggestions`)},[Re]);const je=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(q,"selection");e&&(0,_hapticUtils.triggerHaptic)(e)},[q]),Ce=(0,_react.useCallback)(e=>{je(),O.current?.blur(),de(!1),y?.(e)},[je,y]),ye=(0,_react.useCallback)(e=>{je(),O.current?.blur(),de(!1),I?.(e)},[je,I]),Fe=(0,_react.useCallback)(e=>{je(),F?.(e),(0,_announce.announce)(`Removed ${e}`),W()},[je,F,W]),ke=(0,_react.useCallback)(()=>{je(),k?.(),(0,_announce.announce)("Recent searches cleared"),W()},[je,k,W]),Be={size:H.icon,color:o?z.colors["text-disabled"]:z.colors["text-subtle"],disabled:o},Le=d?(0,_slotIcon.renderSlotIcon)(d,Be):(z.settings.icons.search??_defaultIcons.defaultIcons.search)(Be),Ie=Boolean(g)&&"float"===S,qe=(0,_useFloatingLabel.useFloatingLabel)({label:g,enabled:Ie,floated:G||re,variant:w,sizeTokens:H,leadingOffset:H.icon+z.space.md,trailingOffset:re?H.icon+z.space.md:0,paddingLeft:A?z.space.none:H["padding-x"],color:z.colors["field-label"],style:f}),Ee=re&&!o?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:se,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:"Clear search",children:(z.settings.icons.close??_defaultIcons.defaultIcons.close)({size:H.icon,color:z.colors["text-muted"]})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E,testID:N,children:[g&&!Ie?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:b,style:f,children:g}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:$.root,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.fieldWrap,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:b,variant:w,focused:G,disabled:o,filled:re,minHeight:H["min-height"],paddingHorizontal:A?z.space.none:H["padding-x"],borderRadius:p??M,leading:Le,trailing:Ee,topNotch:qe.topNotch,onPress:W,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:T??c,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:V,style:[$.input,{fontSize:H.text,color:U.color,...U.weightStyle},P],value:ne,onChangeText:ae,onSubmitEditing:le,onFocus:Q,onBlur:X,placeholder:!Ie||G||re?c:void 0,placeholderTextColor:U.placeholderColor,autoFocus:i,editable:!o,returnKeyType:"search",selectionColor:(0,_FieldBase.resolveVariantColors)(z,w).borderFocusedRepresentative,accessibilityLabel:T??c,accessibilityState:{disabled:o},"aria-disabled":o,...D})}),qe.node]})}),x&&x.length>0?(0,_jsxRuntime.jsx)(_SearchPanel.SearchScopeBar,{scopes:x,scope:ce||(x[0]?.value??""),disabled:o,haptic:q,onChange:oe}):null,me?(0,_jsxRuntime.jsx)(_SearchPanel.SearchRecents,{recents:fe,title:j,onSelect:Ce,onRemove:F?Fe:void 0,onClear:k?ke:void 0,onHold:pe,onRelease:ge}):null,ve?(0,_jsxRuntime.jsx)(_SearchPanel.SearchSuggestions,{suggestions:xe,query:ne,onSelect:ye,onHold:pe,onRelease:ge}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});var _default=exports.default=SearchBar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SliderField=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../AppIcon/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../IconButton/index.js"),_index5=require("../Slider/index.js"),_valueText=require("../Slider/valueText.js"),_index6=require("../Tooltip/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_INPUT_WIDTH=72,defaultFormatValue=e=>String(e),stepDecimals=e=>String(e).split(".")[1]?.length??0,ValueBox=({draft:e,error:t,disabled:i,width:s,accessibilityLabel:l,styles:a,style:n,testID:r})=>{const o=(0,_index2.useTheme)(),d=(0,_index2.resolveFieldSize)(o,"sm"),u=(0,_FieldBase.resolveFieldTextStyle)(o,{disabled:i}),c=(0,_react.useRef)(null),x=(0,_react.useCallback)(()=>{i||c.current?.focus()},[i]);return(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:"sm",focused:e.editing,disabled:i,error:t,filled:!0,width:s,onPress:x,pressFeedback:!1,paddingHorizontal:o.space.sm,gap:o.space.xs,trailing:t?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"info-circle",size:d.icon,color:o.colors["danger-text"]}):void 0,style:n,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:c,style:[a.boxInput,{color:u.color,fontSize:d.text,...u.weightStyle}],value:e.text,onChangeText:e.onChangeText,onFocus:e.onFocus,onBlur:e.onBlur,onSubmitEditing:e.onBlur,editable:!i,keyboardType:"decimal-pad",returnKeyType:"done",textAlign:"center",selectionColor:o.colors.primary,accessibilityLabel:l,accessibilityState:{disabled:i},"aria-disabled":i,testID:r})})},SliderField=exports.SliderField=(0,_react.forwardRef)((e,t)=>{const{label:i,unit:s,info:l,required:a=!1,helperText:n,error:r,min:o=0,max:d=100,step:u=1,disabled:c=!1,tone:x="primary",size:m,variant:_,haptic:b,showBubble:p=!0,showBounds:j=!0,showInput:h=!1,showStepper:v=!1,startIcon:y,endIcon:f,startLabel:g,endLabel:I,formatValue:S=defaultFormatValue,parseInput:T,animationDuration:R,inputWidth:w=DEFAULT_INPUT_WIDTH,accessibilityLabel:F,style:B,labelStyle:V,boundStyle:z,sliderStyle:D,inputStyle:L,testID:N}=e,q=(0,_index2.useTheme)(),C=(0,_react.useMemo)(()=>buildStyles(q),[q]),$=R??q.motion.duration.fast,A=!0===e.range,P=!0===r||(0,_FieldBase.hasFieldText)(r),W=stepDecimals(u),[M,k]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(A?[o,d]:o),onChange:e.onChange}),[H,U]=A?M:[M,d],E=(0,_valueText.clampValue)(Math.min(H,U),o,d),K=(0,_valueText.clampValue)(Math.max(H,U),o,d),O=(0,_valueText.useValueDraft)({value:E,min:o,max:d,step:u,format:S,parse:T,onChange:e=>k(A?[Math.min(e,K),K]:e)}),G=(0,_valueText.useValueDraft)({value:K,min:o,max:d,step:u,format:S,parse:T,onChange:e=>k([E,Math.max(e,E)])}),stepBy=e=>{const t=(0,_valueText.snapValue)(E+e*u,o,d,u);t!==E&&k(t)},J={color:c?q.colors["text-disabled"]:q.colors["text-muted"],size:(0,_index2.resolveFieldSize)(q,"md").icon,disabled:c},Q=[C.bubbleText,{color:(0,_valueText.sliderToneInk)(q,x),fontWeight:q.weight.semibold}],boundText=e=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[C.bound,{color:c?q.colors["text-disabled"]:q.colors["text-muted"]},z],children:e}),X={min:o,max:d,step:u,disabled:c,tone:x,size:m,variant:_,haptic:b,showLabel:!!p&&"always",renderLabel:p?e=>(0,_jsxRuntime.jsx)(_valueText.CountingText,{value:e,format:S,decimals:W,duration:$,style:Q,testID:N&&!A?`${N}-bubble`:void 0}):void 0,accessibilityLabel:F??i,style:D,testID:N?`${N}-slider`:void 0};return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[C.container,B],testID:N,children:[i?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:C.labelRow,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{required:a,style:V,children:i}),s?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[C.unit,{color:q.colors["text-subtle"]}],children:s}):null,l?(0,_jsxRuntime.jsx)(_index6.Tooltip,{content:l,trigger:"press",placement:"top",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:`About ${i}`,hitSlop:8,style:C.infoButton,children:(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"info-circle",variant:"bold",size:16,color:q.colors["text-subtle"]})})}):null]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[C.row,p?C.rowWithBubble:null],children:[y?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_index3.renderSlotIcon)(y,J)}):null,v&&!A?(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:e=>(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"minus",size:e.size,color:e.color}),onPress:()=>stepBy(-1),accessibilityLabel:"Decrease",variant:"ghost",tone:"neutral",size:"sm",disabled:c||E<=o,haptic:b,testID:N?`${N}-minus`:void 0}):null,A&&h?(0,_jsxRuntime.jsx)(ValueBox,{draft:O,error:P,disabled:c,width:w,accessibilityLabel:`${i??"Value"} low`,styles:C,style:L,testID:N?`${N}-input-low`:void 0}):j?boundText(g??S(o)):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.sliderWrap,children:A?(0,_jsxRuntime.jsx)(_index5.Slider,{...X,range:!0,value:[E,K],onChange:k}):(0,_jsxRuntime.jsx)(_index5.Slider,{...X,value:E,onChange:k})}),A&&h?(0,_jsxRuntime.jsx)(ValueBox,{draft:G,error:P,disabled:c,width:w,accessibilityLabel:`${i??"Value"} high`,styles:C,style:L,testID:N?`${N}-input-high`:void 0}):j?boundText(I??S(d)):null,v&&!A?(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:e=>(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"add",size:e.size,color:e.color}),onPress:()=>stepBy(1),accessibilityLabel:"Increase",variant:"ghost",tone:"neutral",size:"sm",disabled:c||E>=d,haptic:b,testID:N?`${N}-plus`:void 0}):null,f?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_index3.renderSlotIcon)(f,J)}):null,!A&&h?(0,_jsxRuntime.jsx)(ValueBox,{draft:O,error:P,disabled:c,width:w,accessibilityLabel:`${i??"Value"} value`,styles:C,style:L,testID:N?`${N}-input`:void 0}):null]}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{text:P?r:n,error:P})]})});SliderField.displayName="SliderField";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",gap:e.space.xs},unit:{fontSize:e.text.xs.size},infoButton:{marginLeft:e.space.xxs},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},rowWithBubble:{marginTop:e.space.lg},sliderWrap:{flex:1,paddingHorizontal:e.space.sm},bound:{fontSize:e.text.sm.size,fontVariant:["tabular-nums"]},bubbleText:{fontSize:e.text.xs.size,fontVariant:["tabular-nums"]},boxInput:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});var _default=exports.default=SliderField;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SliderField=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_hitSlop=require("../../utils/hitSlop.js"),_index3=require("../AppIcon/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../IconButton/index.js"),_index5=require("../Slider/index.js"),_valueText=require("../Slider/valueText.js"),_index6=require("../Tooltip/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_INPUT_WIDTH=72,defaultFormatValue=e=>String(e),stepDecimals=e=>String(e).split(".")[1]?.length??0,ValueBox=({draft:e,error:t,disabled:i,width:l,accessibilityLabel:s,styles:a,style:n,testID:r})=>{const o=(0,_index2.useTheme)(),d=(0,_index2.resolveFieldSize)(o,"sm"),u=(0,_FieldBase.resolveFieldTextStyle)(o,{disabled:i}),c=(0,_react.useRef)(null),x=(0,_react.useCallback)(()=>{i||c.current?.focus()},[i]);return(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:"sm",focused:e.editing,disabled:i,error:t,filled:!0,width:l,onPress:x,pressFeedback:!1,paddingHorizontal:o.space.sm,gap:o.space.xs,trailing:t?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"info-circle",size:d.icon,color:o.colors["danger-text"]}):void 0,style:n,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:c,style:[a.boxInput,{color:u.color,fontSize:d.text,...u.weightStyle}],value:e.text,onChangeText:e.onChangeText,onFocus:e.onFocus,onBlur:e.onBlur,onSubmitEditing:e.onBlur,editable:!i,keyboardType:"decimal-pad",returnKeyType:"done",textAlign:"center",selectionColor:o.colors.primary,accessibilityLabel:s,accessibilityState:{disabled:i},"aria-disabled":i,testID:r})})},SliderField=exports.SliderField=(0,_react.forwardRef)((e,t)=>{const{label:i,unit:l,info:s,required:a=!1,helperText:n,error:r,min:o=0,max:d=100,step:u=1,disabled:c=!1,tone:x="primary",size:_,variant:m,haptic:b,showBubble:p=!0,showBounds:h=!0,showInput:j=!1,showStepper:v=!1,startIcon:y,endIcon:f,startLabel:g,endLabel:S,formatValue:I=defaultFormatValue,parseInput:T,animationDuration:R,inputWidth:w=DEFAULT_INPUT_WIDTH,accessibilityLabel:F,style:B,labelStyle:V,boundStyle:z,sliderStyle:D,inputStyle:L,testID:N}=e,q=(0,_index2.useTheme)(),C=(0,_react.useMemo)(()=>buildStyles(q),[q]),$=R??q.motion.duration.fast,A=!0===e.range,M=!0===r||(0,_FieldBase.hasFieldText)(r),P=stepDecimals(u),[W,k]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(A?[o,d]:o),onChange:e.onChange}),[H,U]=A?W:[W,d],E=(0,_valueText.clampValue)(Math.min(H,U),o,d),K=(0,_valueText.clampValue)(Math.max(H,U),o,d),O=(0,_valueText.useValueDraft)({value:E,min:o,max:d,step:u,format:I,parse:T,onChange:e=>k(A?[Math.min(e,K),K]:e)}),G=(0,_valueText.useValueDraft)({value:K,min:o,max:d,step:u,format:I,parse:T,onChange:e=>k([E,Math.max(e,E)])}),stepBy=e=>{const t=(0,_valueText.snapValue)(E+e*u,o,d,u);t!==E&&k(t)},J={color:c?q.colors["text-disabled"]:q.colors["text-muted"],size:(0,_index2.resolveFieldSize)(q,"md").icon,disabled:c},Q=[C.bubbleText,{color:(0,_valueText.sliderToneInk)(q,x),fontWeight:q.weight.semibold}],boundText=e=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[C.bound,{color:c?q.colors["text-disabled"]:q.colors["text-muted"]},z],children:e}),X={min:o,max:d,step:u,disabled:c,tone:x,size:_,variant:m,haptic:b,showLabel:!!p&&"always",renderLabel:p?e=>(0,_jsxRuntime.jsx)(_valueText.CountingText,{value:e,format:I,decimals:P,duration:$,style:Q,testID:N&&!A?`${N}-bubble`:void 0}):void 0,accessibilityLabel:F??i,style:D,testID:N?`${N}-slider`:void 0};return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[C.container,B],testID:N,children:[i?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:C.labelRow,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{required:a,style:V,children:i}),l?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[C.unit,{color:q.colors["text-subtle"]}],children:l}):null,s?(0,_jsxRuntime.jsx)(_index6.Tooltip,{content:s,trigger:"press",placement:"top",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:`About ${i}`,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:C.infoButton,children:(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"info-circle",variant:"bold",size:16,color:q.colors["text-subtle"]})})}):null]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[C.row,p?C.rowWithBubble:null],children:[y?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_index3.renderSlotIcon)(y,J)}):null,v&&!A?(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:e=>(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"minus",size:e.size,color:e.color}),onPress:()=>stepBy(-1),accessibilityLabel:"Decrease",variant:"ghost",tone:"neutral",size:"sm",disabled:c||E<=o,haptic:b,testID:N?`${N}-minus`:void 0}):null,A&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:O,error:M,disabled:c,width:w,accessibilityLabel:`${i??"Value"} low`,styles:C,style:L,testID:N?`${N}-input-low`:void 0}):h?boundText(g??I(o)):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.sliderWrap,children:A?(0,_jsxRuntime.jsx)(_index5.Slider,{...X,range:!0,value:[E,K],onChange:k}):(0,_jsxRuntime.jsx)(_index5.Slider,{...X,value:E,onChange:k})}),A&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:G,error:M,disabled:c,width:w,accessibilityLabel:`${i??"Value"} high`,styles:C,style:L,testID:N?`${N}-input-high`:void 0}):h?boundText(S??I(d)):null,v&&!A?(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:e=>(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"add",size:e.size,color:e.color}),onPress:()=>stepBy(1),accessibilityLabel:"Increase",variant:"ghost",tone:"neutral",size:"sm",disabled:c||E>=d,haptic:b,testID:N?`${N}-plus`:void 0}):null,f?(0,_jsxRuntime.jsx)(_reactNative.View,{children:(0,_index3.renderSlotIcon)(f,J)}):null,!A&&j?(0,_jsxRuntime.jsx)(ValueBox,{draft:O,error:M,disabled:c,width:w,accessibilityLabel:`${i??"Value"} value`,styles:C,style:L,testID:N?`${N}-input`:void 0}):null]}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{text:M?r:n,error:M})]})});SliderField.displayName="SliderField";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",gap:e.space.xs},unit:{fontSize:e.text.xs.size},infoButton:{marginLeft:e.space.xxs},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},rowWithBubble:{marginTop:e.space.lg},sliderWrap:{flex:1,paddingHorizontal:e.space.sm},bound:{fontSize:e.text.sm.size,fontVariant:["tabular-nums"]},bubbleText:{fontSize:e.text.xs.size,fontVariant:["tabular-nums"]},boxInput:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});var _default=exports.default=SliderField;