@webority/mobile-ui 0.146.2 → 0.147.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 (126) hide show
  1. package/dist/canvas-kit/kit.js +4344 -4214
  2. package/dist/canvas-kit/manifest.json +1 -1
  3. package/dist/canvas-kit/release.json +5 -5
  4. package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
  5. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  6. package/lib/commonjs/components/Badge/Badge.js +1 -1
  7. package/lib/commonjs/components/Banner/Banner.js +1 -1
  8. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  9. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  10. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  11. package/lib/commonjs/components/Button/Button.js +1 -1
  12. package/lib/commonjs/components/Calendar/Calendar.js +1 -1
  13. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  14. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  15. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  16. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  17. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  18. package/lib/commonjs/components/FieldBase/Chevron.js +1 -1
  19. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  20. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  21. package/lib/commonjs/components/FormField/FormField.js +1 -1
  22. package/lib/commonjs/components/Input/Input.js +1 -1
  23. package/lib/commonjs/components/LoaderOverlay/LoaderOverlay.js +1 -1
  24. package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
  25. package/lib/commonjs/components/MessageList/MessageList.js +1 -1
  26. package/lib/commonjs/components/Modal/Modal.js +1 -1
  27. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  28. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  29. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  30. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  31. package/lib/commonjs/components/Radio/RadioDot.js +1 -1
  32. package/lib/commonjs/components/Rating/Rating.js +1 -1
  33. package/lib/commonjs/components/RichTextEditor/markdownActions.js +1 -1
  34. package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
  35. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  36. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  37. package/lib/commonjs/components/SignaturePad/signatureGeometry.js +1 -1
  38. package/lib/commonjs/components/Skeleton/SkeletonClock.js +1 -1
  39. package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
  40. package/lib/commonjs/components/Slider/valueText.js +1 -1
  41. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
  42. package/lib/commonjs/components/Sparkline/geometry.js +1 -1
  43. package/lib/commonjs/components/Spinner/Spinner.js +1 -1
  44. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  45. package/lib/commonjs/components/Switch/Switch.js +1 -1
  46. package/lib/commonjs/components/Tabs/Tabs.js +1 -1
  47. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  48. package/lib/commonjs/components/Text/Text.js +1 -1
  49. package/lib/commonjs/components/Toast/Toast.js +1 -1
  50. package/lib/commonjs/components/Toast/ToastProvider.js +1 -1
  51. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  52. package/lib/commonjs/components/Tour/Tour.js +1 -1
  53. package/lib/commonjs/form/path.js +1 -1
  54. package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
  55. package/lib/commonjs/hooks/usePressAnimation.js +1 -1
  56. package/lib/commonjs/network/NetworkStatusBanner.js +1 -1
  57. package/lib/commonjs/theme/animatedValue.js +1 -1
  58. package/lib/commonjs/theme/componentSizes.js +1 -1
  59. package/lib/commonjs/theme/merge.js +1 -1
  60. package/lib/commonjs/theme/toneInk.js +1 -1
  61. package/lib/commonjs/utils/color.js +1 -1
  62. package/lib/commonjs/utils/nativeDriver.js +1 -0
  63. package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
  64. package/lib/module/components/Avatar/Avatar.js +1 -1
  65. package/lib/module/components/Badge/Badge.js +1 -1
  66. package/lib/module/components/Banner/Banner.js +1 -1
  67. package/lib/module/components/BarChart/BarChart.js +1 -1
  68. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  69. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  70. package/lib/module/components/Button/Button.js +1 -1
  71. package/lib/module/components/Calendar/Calendar.js +1 -1
  72. package/lib/module/components/Carousel/Carousel.js +1 -1
  73. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  74. package/lib/module/components/Confetti/Confetti.js +1 -1
  75. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  76. package/lib/module/components/Drawer/Drawer.js +1 -1
  77. package/lib/module/components/FieldBase/Chevron.js +1 -1
  78. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  79. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  80. package/lib/module/components/FormField/FormField.js +1 -1
  81. package/lib/module/components/Input/Input.js +1 -1
  82. package/lib/module/components/LoaderOverlay/LoaderOverlay.js +1 -1
  83. package/lib/module/components/Menu/MenuSurface.js +1 -1
  84. package/lib/module/components/MessageList/MessageList.js +1 -1
  85. package/lib/module/components/Modal/Modal.js +1 -1
  86. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  87. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  88. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  89. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  90. package/lib/module/components/Radio/RadioDot.js +1 -1
  91. package/lib/module/components/Rating/Rating.js +1 -1
  92. package/lib/module/components/RichTextEditor/markdownActions.js +1 -1
  93. package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
  94. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  95. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  96. package/lib/module/components/SignaturePad/signatureGeometry.js +1 -1
  97. package/lib/module/components/Skeleton/SkeletonClock.js +1 -1
  98. package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
  99. package/lib/module/components/Slider/valueText.js +1 -1
  100. package/lib/module/components/Sparkline/Sparkline.js +1 -1
  101. package/lib/module/components/Sparkline/geometry.js +1 -1
  102. package/lib/module/components/Spinner/Spinner.js +1 -1
  103. package/lib/module/components/Stepper/Stepper.js +1 -1
  104. package/lib/module/components/Switch/Switch.js +1 -1
  105. package/lib/module/components/Tabs/Tabs.js +1 -1
  106. package/lib/module/components/TagInput/TagInput.js +1 -1
  107. package/lib/module/components/Text/Text.js +1 -1
  108. package/lib/module/components/Toast/Toast.js +1 -1
  109. package/lib/module/components/Toast/ToastProvider.js +1 -1
  110. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  111. package/lib/module/components/Tour/Tour.js +1 -1
  112. package/lib/module/form/path.js +1 -1
  113. package/lib/module/hooks/useDragToDismiss.js +1 -1
  114. package/lib/module/hooks/usePressAnimation.js +1 -1
  115. package/lib/module/network/NetworkStatusBanner.js +1 -1
  116. package/lib/module/theme/animatedValue.js +1 -1
  117. package/lib/module/theme/componentSizes.js +1 -1
  118. package/lib/module/theme/merge.js +1 -1
  119. package/lib/module/theme/toneInk.js +1 -1
  120. package/lib/module/utils/color.js +1 -1
  121. package/lib/module/utils/nativeDriver.js +1 -0
  122. package/lib/typescript/commonjs/theme/animatedValue.d.ts +1 -1
  123. package/lib/typescript/commonjs/utils/nativeDriver.d.ts +2 -0
  124. package/lib/typescript/module/theme/animatedValue.d.ts +1 -1
  125. package/lib/typescript/module/utils/nativeDriver.d.ts +2 -0
  126. package/package.json +7 -7
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.146.2"
5
+ "version": "0.147.0"
6
6
  },
7
7
  "rendererProtocolVersion": 13,
8
8
  "platform": "Phone",
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.146.2",
3
+ "version": "0.147.0",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 13,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.146.2"
9
+ "version": "0.147.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "0ce4c3e31133d79082ef3d1b903241fb405bc21b485310513b20fc68744ab13f",
13
+ "sha256": "8398133fa90a30a61ea4c6ce55fe27e63e9d8b938a7ea15d377c9ee36a40a52b",
14
14
  "bytes": 664145
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "affcb1989eaa60241c63ca2478741d54c4e576cd837086eb3f37f4c6df8e16b1",
18
- "bytes": 6136410
17
+ "sha256": "f9880a739dd251faa138774e239fa42d998e881831e4aed56f172cfc95d5a58f",
18
+ "bytes": 6141937
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.touchEntry=exports.setAuthedImageCacheLimit=exports.removeEntry=exports.releaseFetch=exports.readEntry=exports.isPermanentRefusal=exports.isFresh=exports.getAuthedImageCacheLimit=exports.flushAuthedImageIndex=exports.deriveCacheKey=exports.clearAuthedImageCache=exports.authedImageCacheStats=exports.acquireFetch=exports.DEFAULT_TTL_MS=exports.AuthedImageHttpError=void 0;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native"),_hashString=require("../../utils/hashString.js"),_imageStore=require("./imageStore");const INDEX_KEY="@webority/authed-image/v2/index",LEGACY_PREFIX="@webority/authed-image/v1/",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3,DEFAULT_TTL_MS=exports.DEFAULT_TTL_MS=6048e5;let byteCeiling=52428800;const setAuthedImageCacheLimit=e=>{if(!Number.isFinite(e)||e<=0)throw new Error(`[@webority/mobile-ui] setAuthedImageCacheLimit() needs a positive number of bytes, received ${String(e)}. Pass e.g. 50 * 1024 * 1024 for 50 MB.`);byteCeiling=e};exports.setAuthedImageCacheLimit=setAuthedImageCacheLimit;const getAuthedImageCacheLimit=()=>byteCeiling;exports.getAuthedImageCacheLimit=getAuthedImageCacheLimit;const deriveCacheKey=(e,t)=>(0,_hashString.hashString)(t??e);exports.deriveCacheKey=deriveCacheKey;const toMeta=({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s})=>({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s});let index=null,indexBytes=0,indexLoad=null,persistTimer=null,persistTarget=null,appStateSub=null;const persistIndex=async e=>{if(!(0,_mobileCore.isStorageAvailable)())return;const t={};for(const[r,s]of e)t[r]={...s,persistedAccessAt:s.lastAccessedAt};if(await _mobileCore.Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=_reactNative.AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))},flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};exports.flushAuthedImageIndex=flushAuthedImageIndex;const removeLegacyEntries=async()=>{const e=(await _mobileCore.Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await _mobileCore.Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of(0,_imageStore.listImageNames)())t.has(e)||(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!(0,_mobileCore.isStorageAvailable)())return e;const t=await _mobileCore.Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{for(const[r,s]of Object.entries(JSON.parse(t)))e.set(r,s)}catch{}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,r]of e)(0,_imageStore.imageExists)(r.fileName)||e.delete(t);return index=e,indexBytes=[...e.values()].reduce((e,t)=>e+t.bytes,0),e}).finally(()=>{indexLoad=null})),indexLoad),deleteFile=e=>{try{(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}},readEntry=async e=>{const t=await loadIndex(),r=t.get(e);return r?(0,_imageStore.imageExists)(r.fileName)?{fileUri:(0,_imageStore.imageUri)(r.fileName),meta:toMeta(r)}:(t.delete(e),indexBytes-=r.bytes,schedulePersist(t),null):null};exports.readEntry=readEntry;const removeEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(t.delete(e),indexBytes-=r.bytes,deleteFile(r.fileName),schedulePersist(t))};exports.removeEntry=removeEntry;class AuthedImageHttpError extends Error{constructor(e,t){super(e),this.name="AuthedImageHttpError",this.status=t}}exports.AuthedImageHttpError=AuthedImageHttpError;const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;exports.isPermanentRefusal=isPermanentRefusal;const isFresh=(e,t,r=Date.now())=>r-e.fetchedAt<t;exports.isFresh=isFresh;const touchEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(r.lastAccessedAt=Date.now(),r.lastAccessedAt-r.persistedAccessAt>=36e5&&schedulePersist(t))};exports.touchEntry=touchEntry;const evictIfNeeded=e=>{let t=indexBytes;if(t<=byteCeiling)return 0;const r=[...e].sort(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);let s=0;for(const[i,a]of r){if(t<=byteCeiling)break;e.delete(i),indexBytes-=a.bytes,deleteFile(a.fileName),t-=a.bytes,s+=1}return s},clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,(0,_imageStore.clearImages)(),(0,_mobileCore.isStorageAvailable)()&&await _mobileCore.Storage.removeItem(INDEX_KEY)};exports.clearAuthedImageCache=clearAuthedImageCache;const authedImageCacheStats=async()=>{const e=await loadIndex();let t=0;for(const r of e.values())t+=r.bytes;return{entries:e.size,bytes:t}};exports.authedImageCacheStats=authedImageCacheStats;const responseHeader=(e,t)=>{if(!e||"object"!=typeof e)return;const r=e.get,s="function"==typeof r?r.call(e,t):e[t];return"string"==typeof s?s:void 0},originOf=e=>{const t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);return t?t[1].toLowerCase():null},isOwnApiAddress=e=>{const t=originOf(e);if(null===t)return!0;const r=(0,_mobileCore.getConfigValue)("baseUrl");return"string"==typeof r&&originOf(r)===t},fetchAndStore=async(e,t,r)=>{const s={Accept:"image/*",...t.headers};if(!t.client&&t.authenticated&&isOwnApiAddress(t.uri)){const e=await(0,_mobileCore.getToken)(_mobileCore.ACCESS_TOKEN_KEY);e?.token&&(s.Authorization=`Bearer ${e.token}`)}const i=t.client??_mobileCore.publicClient;let a;try{a=await i.get(t.uri,{headers:s,responseType:"arraybuffer",signal:r})}catch(e){const r=e?.response?.status;if("number"!=typeof r)throw e;throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered ${r}. Check the URL and whether the request needs to be signed in (pass the signed-in client as \`client\`, or authenticated={false} for public media).`,r)}const o=new Uint8Array(a.data??new ArrayBuffer(0));if(0===o.byteLength)throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered with an empty body, so the address holds no image.`,404);const n=responseHeader(a.headers,"content-type"),l=(n?n.split(";")[0].trim():"")||"image/jpeg",c=await loadIndex(),d=Date.now(),u=`${e}-${d.toString(36)}`;let h;try{h=(0,_imageStore.writeImage)(u,o,l)}catch(e){throw new Error(`[@webority/mobile-ui] AuthedImage fetched "${t.uri}" but could not write it to the app's cache folder: ${e instanceof Error?e.message:String(e)}. The device may be out of storage.`)}const m={fetchedAt:d,bytes:o.byteLength,contentType:l,lastAccessedAt:d,fileName:u,persistedAccessAt:d},g=c.get(e);g&&(indexBytes-=g.bytes),c.set(e,m),indexBytes+=m.bytes,g&&g.fileName!==u&&deleteFile(g.fileName);const p=evictIfNeeded(c);return schedulePersist(c),p>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:h,meta:toMeta(m)}},inFlight=new Map,acquireFetch=(e,t)=>{const r=inFlight.get(e);if(r)return r.waiters+=1,r;const s=new AbortController,i={controller:s,waiters:1,promise:Promise.resolve()};return i.promise=fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)}),inFlight.set(e,i),i};exports.acquireFetch=acquireFetch;const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};exports.releaseFetch=releaseFetch;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.touchEntry=exports.setAuthedImageCacheLimit=exports.removeEntry=exports.releaseFetch=exports.readEntry=exports.isPermanentRefusal=exports.isFresh=exports.getAuthedImageCacheLimit=exports.flushAuthedImageIndex=exports.deriveCacheKey=exports.clearAuthedImageCache=exports.authedImageCacheStats=exports.acquireFetch=exports.DEFAULT_TTL_MS=exports.AuthedImageHttpError=void 0;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native"),_hashString=require("../../utils/hashString.js"),_imageStore=require("./imageStore");const INDEX_KEY="@webority/authed-image/v2/index",LEGACY_PREFIX="@webority/authed-image/v1/",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3,DEFAULT_TTL_MS=exports.DEFAULT_TTL_MS=6048e5;let byteCeiling=52428800;const setAuthedImageCacheLimit=e=>{if(!Number.isFinite(e)||e<=0)throw new Error(`[@webority/mobile-ui] setAuthedImageCacheLimit() needs a positive number of bytes, received ${String(e)}. Pass e.g. 50 * 1024 * 1024 for 50 MB.`);byteCeiling=e};exports.setAuthedImageCacheLimit=setAuthedImageCacheLimit;const getAuthedImageCacheLimit=()=>byteCeiling;exports.getAuthedImageCacheLimit=getAuthedImageCacheLimit;const deriveCacheKey=(e,t)=>(0,_hashString.hashString)(t??e);exports.deriveCacheKey=deriveCacheKey;const toMeta=({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s})=>({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s});let index=null,indexBytes=0,indexLoad=null,persistTimer=null,persistTarget=null,appStateSub=null;const persistIndex=async e=>{if(!(0,_mobileCore.isStorageAvailable)())return;const t={};for(const[r,s]of e)t[r]={...s,persistedAccessAt:s.lastAccessedAt};if(await _mobileCore.Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=_reactNative.AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))},flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};exports.flushAuthedImageIndex=flushAuthedImageIndex;const removeLegacyEntries=async()=>{const e=(await _mobileCore.Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await _mobileCore.Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of(0,_imageStore.listImageNames)())t.has(e)||(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!(0,_mobileCore.isStorageAvailable)())return e;const t=await _mobileCore.Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{for(const[r,s]of Object.entries(JSON.parse(t)))e.set(r,s)}catch{}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,r]of e)(0,_imageStore.imageExists)(r.fileName)||e.delete(t);return index=e,indexBytes=[...e.values()].reduce((e,t)=>e+t.bytes,0),e}).finally(()=>{indexLoad=null})),indexLoad),deleteFile=e=>{try{(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}},readEntry=async e=>{const t=await loadIndex(),r=t.get(e);return r?(0,_imageStore.imageExists)(r.fileName)?{fileUri:(0,_imageStore.imageUri)(r.fileName),meta:toMeta(r)}:(t.delete(e),indexBytes-=r.bytes,schedulePersist(t),null):null};exports.readEntry=readEntry;const removeEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(t.delete(e),indexBytes-=r.bytes,deleteFile(r.fileName),schedulePersist(t))};exports.removeEntry=removeEntry;class AuthedImageHttpError extends Error{constructor(e,t){super(e),this.name="AuthedImageHttpError",this.status=t}}exports.AuthedImageHttpError=AuthedImageHttpError;const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;exports.isPermanentRefusal=isPermanentRefusal;const isFresh=(e,t,r=Date.now())=>r-e.fetchedAt<t;exports.isFresh=isFresh;const touchEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(r.lastAccessedAt=Date.now(),r.lastAccessedAt-r.persistedAccessAt>=36e5&&schedulePersist(t))};exports.touchEntry=touchEntry;const evictIfNeeded=e=>{let t=indexBytes;if(t<=byteCeiling)return 0;const r=[...e].sort(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);let s=0;for(const[i,a]of r){if(t<=byteCeiling)break;e.delete(i),indexBytes-=a.bytes,deleteFile(a.fileName),t-=a.bytes,s+=1}return s},clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,(0,_imageStore.clearImages)(),(0,_mobileCore.isStorageAvailable)()&&await _mobileCore.Storage.removeItem(INDEX_KEY)};exports.clearAuthedImageCache=clearAuthedImageCache;const authedImageCacheStats=async()=>{const e=await loadIndex();let t=0;for(const r of e.values())t+=r.bytes;return{entries:e.size,bytes:t}};exports.authedImageCacheStats=authedImageCacheStats;const responseHeader=(e,t)=>{if(!e||"object"!=typeof e)return;const r=e.get,s="function"==typeof r?r.call(e,t):e[t];return"string"==typeof s?s:void 0},originOf=e=>{const t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);if(null===t)return null;const r=t[1];if(void 0===r)throw new Error("originOf: the origin pattern always captures group 1 when it matches");return r.toLowerCase()},mediaTypeOf=e=>{const[t]=e.split(";");if(void 0===t)throw new Error("mediaTypeOf: String.split always returns at least one part");return t.trim()},isOwnApiAddress=e=>{const t=originOf(e);if(null===t)return!0;const r=(0,_mobileCore.getConfigValue)("baseUrl");return"string"==typeof r&&originOf(r)===t},fetchAndStore=async(e,t,r)=>{const s={Accept:"image/*",...t.headers};if(!t.client&&t.authenticated&&isOwnApiAddress(t.uri)){const e=await(0,_mobileCore.getToken)(_mobileCore.ACCESS_TOKEN_KEY);e?.token&&(s.Authorization=`Bearer ${e.token}`)}const i=t.client??_mobileCore.publicClient;let a;try{a=await i.get(t.uri,{headers:s,responseType:"arraybuffer",signal:r})}catch(e){const r=e?.response?.status;if("number"!=typeof r)throw e;throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered ${r}. Check the URL and whether the request needs to be signed in (pass the signed-in client as \`client\`, or authenticated={false} for public media).`,r)}const o=new Uint8Array(a.data??new ArrayBuffer(0));if(0===o.byteLength)throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered with an empty body, so the address holds no image.`,404);const n=responseHeader(a.headers,"content-type"),l=(n?mediaTypeOf(n):"")||"image/jpeg",c=await loadIndex(),d=Date.now(),u=`${e}-${d.toString(36)}`;let h;try{h=(0,_imageStore.writeImage)(u,o,l)}catch(e){throw new Error(`[@webority/mobile-ui] AuthedImage fetched "${t.uri}" but could not write it to the app's cache folder: ${e instanceof Error?e.message:String(e)}. The device may be out of storage.`)}const m={fetchedAt:d,bytes:o.byteLength,contentType:l,lastAccessedAt:d,fileName:u,persistedAccessAt:d},g=c.get(e);g&&(indexBytes-=g.bytes),c.set(e,m),indexBytes+=m.bytes,g&&g.fileName!==u&&deleteFile(g.fileName);const p=evictIfNeeded(c);return schedulePersist(c),p>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:h,meta:toMeta(m)}},inFlight=new Map,acquireFetch=(e,t)=>{const r=inFlight.get(e);if(r)return r.waiters+=1,r;const s=new AbortController,i={controller:s,waiters:1,promise:Promise.resolve()};return i.promise=fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)}),inFlight.set(e,i),i};exports.acquireFetch=acquireFetch;const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};exports.releaseFetch=releaseFetch;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};default:return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,s)=>{switch(t){case"circle":return r/2;case"rounded":return s?e.radius[s]:Math.max(e.radius.sm,Math.round(.22*r));default:return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean);return 0===t.length?"":1===t.length?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[1].charAt(0)).toUpperCase()},hashColor=(e,t)=>{if(!e)return t[0];let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t[Math.abs(r)%t.length]},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;default:return e.colors["text-subtle"]}},Avatar=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:s,imageClient:a,name:o,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:h,status:m=null,statusPosition:g="bottomRight",tone:p,backgroundColor:_,color:b,fontSize:v,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:V,style:j,textStyle:S,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[M,w]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(o),[o]),D=(0,_react.useMemo)(()=>p?avatarToneColors(L,p):null,[L,p]),G=(0,_react.useMemo)(()=>_||(D?.background??L.colors[hashColor(o??"",AVATAR_COLORS)]),[_,D,o,L]),U=b??D?.color??L.colors["on-primary"],q=r?keyOfSource(r):null,P=null!==q&&q!==M,$=!P&&""===F&&null!=h,B=b??D?.color??L.colors["text-subtle"],W=v??Math.max(L.text.xs.size,Math.round(.4*E)),H=Math.max(8,Math.round(.25*E)),Y=isRingStatus(m),X=E-2*(Y?3:k),J=Y?resolveRadius(L,n,X,c):Math.max(0,O-k),K=$?(0,_slotIcon.renderSlotIcon)(h,{color:B,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(L,m):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=_??D?.background??L.colors["bg-muted"],re=P?"contain"===d?"transparent":L.colors["bg-muted"]:$?te:G,se=C??"avatar",ae=o?T.avatarOf(o):T.avatar,oe="verified"===m?`, ${T.verified}`:"pending"===m?`, ${T.pendingVerification}`:"",ie=A??`${ae}${oe}`,ne="function"==typeof y||"function"==typeof f,le=A??`${o||ae}${oe}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=V??ce,de=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:Y?0:k,borderColor:N,backgroundColor:Y?"transparent":re},j],he=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:X,height:X,borderRadius:J,..._corners.smoothCorners,borderWidth:Y?k:0,borderColor:N,backgroundColor:Y?re:"transparent"}],children:P?(()=>{const e={width:X,height:X,borderRadius:J,..._corners.smoothCorners},onError=()=>w(q),t=uriOfSource(r);return s?(0,_jsxRuntime.jsx)(s,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):a&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:a,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:U,fontSize:W,lineHeight:Math.round(W*L.leading.body)},S],children:F??" "})}),"verified"===m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,m&&!Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:H,height:H,borderRadius:H/2,..._corners.smoothCorners,backgroundColor:statusColor(L,m),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),me=ne?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:ue,...(0,_hitSlop.hitSlopMarker)(ue),accessibilityRole:"button",accessibilityLabel:le,testID:C,style:({pressed:e})=>[de,e?styles.pressed:null],children:he}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:C,children:he});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):me});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:s})=>{const a=r??resolveSize(e),o="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:o,width:a,height:a,style:s})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:s,children:a})=>{const o=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:o.radius.pill,borderColor:r,borderWidth:s,opacity:i}],children:a})},AvatarGroup=e=>{const{children:t,max:r=4,size:s="md",spacing:a="normal",overflowVariant:o="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),m=h.length,g=h.slice(0,r),p=Math.max(0,m-r),_=p>0,b=-d.space[SPACING_OFFSET[a]],v=d.colors.surface,x=i??u.groupOf(m),A=(0,_react.useMemo)(()=>resolveSize(s),[s]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,a=(0,_react.cloneElement)(e,{size:s,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:b,borderColor:v,borderWidth:1.5,children:a},r)}),_?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:b,borderColor:v,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===o?u.moreCount(p):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===o?`+${p}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,s)=>{switch(t){case"circle":return r/2;case"rounded":return s?e.radius[s]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,s]=t;return void 0===r?"":void 0===s?r.charAt(0).toUpperCase():(r.charAt(0)+s.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const s=t[Math.abs(r)%t.length];if(void 0===s)throw new Error("The avatar colour palette is empty.");return s},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},Avatar=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:s,imageClient:a,name:o,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:h=null,statusPosition:g="bottomRight",tone:p,backgroundColor:_,color:v,fontSize:b,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:V,style:j,textStyle:S,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[M,w]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(o),[o]),D=(0,_react.useMemo)(()=>p?avatarToneColors(L,p):null,[L,p]),q=(0,_react.useMemo)(()=>_||(D?.background??L.colors[hashColor(o??"",AVATAR_COLORS)]),[_,D,o,L]),G=v??D?.color??L.colors["on-primary"],U=r?keyOfSource(r):null,P=null!==U&&U!==M,$=!P&&""===F&&null!=m,B=v??D?.color??L.colors["text-subtle"],W=b??Math.max(L.text.xs.size,Math.round(.4*E)),H=Math.max(8,Math.round(.25*E)),Y=isRingStatus(h),X=E-2*(Y?3:k),J=Y?resolveRadius(L,n,X,c):Math.max(0,O-k),K=$?(0,_slotIcon.renderSlotIcon)(m,{color:B,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(L,h):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=_??D?.background??L.colors["bg-muted"],re=P?"contain"===d?"transparent":L.colors["bg-muted"]:$?te:q,se=C??"avatar",ae=o?T.avatarOf(o):T.avatar,oe="verified"===h?`, ${T.verified}`:"pending"===h?`, ${T.pendingVerification}`:"",ie=A??`${ae}${oe}`,ne="function"==typeof y||"function"==typeof f,le=A??`${o||ae}${oe}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=V??ce,de=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:Y?0:k,borderColor:N,backgroundColor:Y?"transparent":re},j],me=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:X,height:X,borderRadius:J,..._corners.smoothCorners,borderWidth:Y?k:0,borderColor:N,backgroundColor:Y?re:"transparent"}],children:P?(()=>{const e={width:X,height:X,borderRadius:J,..._corners.smoothCorners},onError=()=>w(U),t=uriOfSource(r);return s?(0,_jsxRuntime.jsx)(s,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):a&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:a,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:G,fontSize:W,lineHeight:Math.round(W*L.leading.body)},S],children:F??" "})}),"verified"===h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,h&&!Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:H,height:H,borderRadius:H/2,..._corners.smoothCorners,backgroundColor:statusColor(L,h),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),he=ne?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:ue,...(0,_hitSlop.hitSlopMarker)(ue),accessibilityRole:"button",accessibilityLabel:le,testID:C,style:({pressed:e})=>[de,e?styles.pressed:null],children:me}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:C,children:me});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):he});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:s})=>{const a=r??resolveSize(e),o="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:o,width:a,height:a,style:s})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:s,children:a})=>{const o=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:_nativeDriver.nativeDriver});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:o.radius.pill,borderColor:r,borderWidth:s,opacity:i}],children:a})},AvatarGroup=e=>{const{children:t,max:r=4,size:s="md",spacing:a="normal",overflowVariant:o="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),m=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),h=m.length,g=m.slice(0,r),p=Math.max(0,h-r),_=p>0,v=-d.space[SPACING_OFFSET[a]],b=d.colors.surface,x=i??u.groupOf(h),A=(0,_react.useMemo)(()=>resolveSize(s),[s]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,a=(0,_react.cloneElement)(e,{size:s,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:v,borderColor:b,borderWidth:1.5,children:a},r)}),_?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:v,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===o?u.moreCount(p):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===o?`+${p}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BADGE_LABELS=exports.Badge=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BADGE_LABELS=exports.DEFAULT_BADGE_LABELS=Object.freeze({indicator:"Notification indicator",unread:e=>`${e} unread`}),toneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors.primary,text:e.colors["on-primary"]};case"success":return{background:e.colors.success,text:e.colors["on-success"]};case"warning":return{background:e.colors.warning,text:e.colors["on-warning"]};case"info":return{background:e.colors.info,text:e.colors["on-info"]};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-body"]};default:return{background:e.colors.danger,text:e.colors["on-danger"]}}},softToneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors["primary-soft"],text:e.colors.primary};case"success":return{background:e.colors["success-soft"],text:e.colors.success};case"warning":return{background:e.colors["warning-soft"],text:e.colors.warning};case"info":return{background:e.colors["info-soft"],text:e.colors.info};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-muted"]};default:return{background:e.colors["danger-soft"],text:e.colors.danger}}},anchorPosition=(e,t)=>{const r=-t;switch(e){case"topLeft":return{top:r,left:r};case"bottomRight":return{bottom:r,right:r};case"bottomLeft":return{bottom:r,left:r};default:return{top:r,right:r}}},formatValue=(e,t)=>{if(null==e)return null;if("number"==typeof e)return e<=0?null:e>t?`${t}+`:String(e);const r=String(e);return 0===r.length?null:r},Badge=exports.Badge=(0,_react.forwardRef)((e,t)=>{const{value:r,max:i=99,variant:o="standard",tone:a="danger",size:s="sm",fill:n="solid",accessible:l=!0,invisible:d=!1,loading:c=!1,children:u,anchor:g="topRight",pulse:h=!1,accessibilityLabel:m,labels:x,style:f,badgeStyle:_,textStyle:b,testID:p}=e;(0,_assertValidValue.assertValidValue)("Badge","variant",e.variant,["standard","dot"]),(0,_assertValidValue.assertValidValue)("Badge","tone",e.tone,["primary","success","warning","danger","neutral","info"]),(0,_assertValidValue.assertValidValue)("Badge","size",e.size,["sm","md"]),(0,_assertValidValue.assertValidValue)("Badge","anchor",e.anchor,["topRight","topLeft","bottomRight","bottomLeft"]),(0,_assertValidValue.assertValidValue)("Badge","fill",e.fill,["solid","soft"]);const v=(0,_react.useMemo)(()=>({...DEFAULT_BADGE_LABELS,...x}),[x]),y=(0,_index.useTheme)(),V=(0,_react.useMemo)(()=>"soft"===n?softToneFor(y,a):toneFor(y,a),[y,a,n]),w=(0,_index.resolveBadgeSize)(y,s),j=y.components.badge["border-width"],B=y.components.badge["anchor-offset"],S="dot"===o?null:formatValue(r,i),k=!d&&("dot"===o||null!==S),L=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!h||!k)return void(0,_index.setNativeValue)(L,1);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(L,{toValue:1.15,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:1,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:!0})]));return e.start(),()=>{e.stop()}},[h,k,L,y]);const R="dot"===o,A=R?"image":"text",N=m??(R?v.indicator:S?v.unread(S):void 0),z=k?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.badge,R?{width:w["dot-size"],height:w["dot-size"],borderRadius:w["dot-size"]/2,..._corners.smoothCorners,paddingHorizontal:0}:{minWidth:w["min-width"],minHeight:w.height,borderRadius:y.radius.pill,..._corners.smoothCorners,paddingHorizontal:w["padding-x"]},{backgroundColor:V.background,transform:[{scale:L}]},u?{position:"absolute",borderWidth:j,borderColor:y.colors.surface,...anchorPosition(g,B)}:null,_],accessible:l,importantForAccessibility:l?void 0:"no-hide-descendants",accessibilityElementsHidden:!l||void 0,accessibilityRole:l?A:void 0,accessibilityLabel:l?N:void 0,children:R||null===S?null:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",weight:"soft"===n?"semibold":"bold",numberOfLines:1,style:[styles.text,{color:V.text,fontSize:w.text,lineHeight:Math.round(w.text*y.leading.body)},b],children:S??" "})}):null,E=u?(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[styles.wrapper,f],testID:p,children:[u,z]}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:f,testID:p,children:z});return c?(0,_jsxRuntime.jsx)(BadgeSkeleton,{...e}):E});Badge.displayName="Badge";const BadgeSkeleton=({variant:e="standard",size:t="md",children:r,anchor:i,style:o,badgeStyle:a})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveBadgeSize)(s,t);if("dot"===e)return(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"circle",width:n["dot-size"],height:n["dot-size"],style:[a,o]});const l=n.height/2;if(void 0!==r){const e="topLeft"===i?{top:-n.height/2,left:-n.height/2}:"bottomRight"===i?{bottom:-n.height/2,right:-n.height/2}:"bottomLeft"===i?{bottom:-n.height/2,left:-n.height/2}:{top:-n.height/2,right:-n.height/2};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.wrapper,o],children:[r,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{position:"absolute"},e],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:a})})]})}return(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:[a,o]})};BadgeSkeleton.displayName="BadgeSkeleton",Badge.Skeleton=BadgeSkeleton;const styles=_reactNative.StyleSheet.create({wrapper:{position:"relative",alignSelf:"flex-start"},badge:{alignItems:"center",justifyContent:"center",flexDirection:"row"},text:{textAlign:"center",includeFontPadding:!1}});var _default=exports.default=Badge;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BADGE_LABELS=exports.Badge=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BADGE_LABELS=exports.DEFAULT_BADGE_LABELS=Object.freeze({indicator:"Notification indicator",unread:e=>`${e} unread`}),toneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors.primary,text:e.colors["on-primary"]};case"success":return{background:e.colors.success,text:e.colors["on-success"]};case"warning":return{background:e.colors.warning,text:e.colors["on-warning"]};case"info":return{background:e.colors.info,text:e.colors["on-info"]};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-body"]};default:return{background:e.colors.danger,text:e.colors["on-danger"]}}},softToneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors["primary-soft"],text:e.colors.primary};case"success":return{background:e.colors["success-soft"],text:e.colors.success};case"warning":return{background:e.colors["warning-soft"],text:e.colors.warning};case"info":return{background:e.colors["info-soft"],text:e.colors.info};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-muted"]};default:return{background:e.colors["danger-soft"],text:e.colors.danger}}},anchorPosition=(e,t)=>{const r=-t;switch(e){case"topLeft":return{top:r,left:r};case"bottomRight":return{bottom:r,right:r};case"bottomLeft":return{bottom:r,left:r};default:return{top:r,right:r}}},formatValue=(e,t)=>{if(null==e)return null;if("number"==typeof e)return e<=0?null:e>t?`${t}+`:String(e);const r=String(e);return 0===r.length?null:r},Badge=exports.Badge=(0,_react.forwardRef)((e,t)=>{const{value:r,max:i=99,variant:o="standard",tone:a="danger",size:s="sm",fill:n="solid",accessible:l=!0,invisible:d=!1,loading:c=!1,children:u,anchor:g="topRight",pulse:h=!1,accessibilityLabel:m,labels:x,style:_,badgeStyle:f,textStyle:b,testID:v}=e;(0,_assertValidValue.assertValidValue)("Badge","variant",e.variant,["standard","dot"]),(0,_assertValidValue.assertValidValue)("Badge","tone",e.tone,["primary","success","warning","danger","neutral","info"]),(0,_assertValidValue.assertValidValue)("Badge","size",e.size,["sm","md"]),(0,_assertValidValue.assertValidValue)("Badge","anchor",e.anchor,["topRight","topLeft","bottomRight","bottomLeft"]),(0,_assertValidValue.assertValidValue)("Badge","fill",e.fill,["solid","soft"]);const p=(0,_react.useMemo)(()=>({...DEFAULT_BADGE_LABELS,...x}),[x]),y=(0,_index.useTheme)(),V=(0,_react.useMemo)(()=>"soft"===n?softToneFor(y,a):toneFor(y,a),[y,a,n]),j=(0,_index.resolveBadgeSize)(y,s),w=y.components.badge["border-width"],B=y.components.badge["anchor-offset"],S="dot"===o?null:formatValue(r,i),k=!d&&("dot"===o||null!==S),L=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!h||!k)return void(0,_index.setNativeValue)(L,1);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(L,{toValue:1.15,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(L,{toValue:1,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})]));return e.start(),()=>{e.stop()}},[h,k,L,y]);const R="dot"===o,A=R?"image":"text",D=m??(R?p.indicator:S?p.unread(S):void 0),N=k?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.badge,R?{width:j["dot-size"],height:j["dot-size"],borderRadius:j["dot-size"]/2,..._corners.smoothCorners,paddingHorizontal:0}:{minWidth:j["min-width"],minHeight:j.height,borderRadius:y.radius.pill,..._corners.smoothCorners,paddingHorizontal:j["padding-x"]},{backgroundColor:V.background,transform:[{scale:L}]},u?{position:"absolute",borderWidth:w,borderColor:y.colors.surface,...anchorPosition(g,B)}:null,f],accessible:l,importantForAccessibility:l?void 0:"no-hide-descendants",accessibilityElementsHidden:!l||void 0,accessibilityRole:l?A:void 0,accessibilityLabel:l?D:void 0,children:R||null===S?null:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",weight:"soft"===n?"semibold":"bold",numberOfLines:1,style:[styles.text,{color:V.text,fontSize:j.text,lineHeight:Math.round(j.text*y.leading.body)},b],children:S??" "})}):null,z=u?(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[styles.wrapper,_],testID:v,children:[u,N]}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:_,testID:v,children:N});return c?(0,_jsxRuntime.jsx)(BadgeSkeleton,{...e}):z});Badge.displayName="Badge";const BadgeSkeleton=({variant:e="standard",size:t="md",children:r,anchor:i,style:o,badgeStyle:a})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveBadgeSize)(s,t);if("dot"===e)return(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"circle",width:n["dot-size"],height:n["dot-size"],style:[a,o]});const l=n.height/2;if(void 0!==r){const e="topLeft"===i?{top:-n.height/2,left:-n.height/2}:"bottomRight"===i?{bottom:-n.height/2,right:-n.height/2}:"bottomLeft"===i?{bottom:-n.height/2,left:-n.height/2}:{top:-n.height/2,right:-n.height/2};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.wrapper,o],children:[r,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{position:"absolute"},e],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:a})})]})}return(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:[a,o]})};BadgeSkeleton.displayName="BadgeSkeleton",Badge.Skeleton=BadgeSkeleton;const styles=_reactNative.StyleSheet.create({wrapper:{position:"relative",alignSelf:"flex-start"},badge:{alignItems:"center",justifyContent:"center",flexDirection:"row"},text:{textAlign:"center",includeFontPadding:!1}});var _default=exports.default=Badge;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),Banner=exports.Banner=(0,_react.forwardRef)((e,t)=>{const{title:r,message:i,tone:s="neutral",variant:n="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:x=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:g,style:h,containerStyle:y,iconCircleStyle:b,tintBarStyle:f,closeButtonStyle:j,actionButtonStyle:R,testID:v}=e;(0,_assertValidValue.assertValidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_assertValidValue.assertValidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const w=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),B=(0,_react.useMemo)(()=>buildStyles(w),[w]),S=(0,_react.useMemo)(()=>tintFor(w,s),[w,s]),N=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...g}),[g]),[C,k]=V.range(-20,0),A=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?C:0)).current,L=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?0:u?1:0)).current,[I,E]=(0,_react.useState)(u),D=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>{if(D.current&&(D.current=!1,!m))return;let e;return u?(E(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(A,{toValue:k,duration:w.motion.duration.default,useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:1,duration:V.duration("default"),useNativeDriver:!0})]),e.start()):I&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(A,{toValue:C,duration:w.motion.duration.fast,useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:0,duration:V.duration("fast"),useNativeDriver:!0})]),e.start(()=>{E(!1)})),()=>e?.stop()},[u]),!I)return null;const T=r??" ",q="string"==typeof i?i??" ":"",H="wash"===n,M="bar"!==n,z="alert"===p?"danger"===s?"assertive":"polite":"none",P=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:z,accessibilityLabel:_,testID:v,style:[B.container,{backgroundColor:M?S.soft:w.colors["bg-subtle"],borderRadius:H?w.radius.sm:w.radius.md,..._corners.smoothCorners,padding:w.space.md,opacity:L,transform:[{translateY:A}]},y,h],children:[!H&&w.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[B.tintBar,{backgroundColor:S.bar},f]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.row,void 0===r&&B.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(a,{color:S.ink,size:w.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:S.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[B.iconGlyph,{color:S.ink}],children:S.glyph}),style:[B.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.textBlock,children:[r||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...H?{color:S.ink}:null},children:T}):null,"string"==typeof i||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?w.space.xxs:0},children:q||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?w.space.xxs:0},children:i})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[B.closeBtn,{backgroundColor:e?w.colors["surface-pressed"]:"transparent"},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.actionsRow,children:o.map((e,t)=>{(0,_assertValidValue.assertValidValue)("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","action.variant",e.variant,["solid","outline","ghost"]),(0,_assertValidValue.assertValidValue)("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",i=e.variant??"ghost",s="primary"===r?S.glyphColor:"neutral"===r?w.colors["text-muted"]:w.colors[r],n="primary"===r?S.ink:"neutral"===r?w.colors["text-muted"]:w.colors[`${r}-text`],a="primary"===r?S.on:"neutral"===r?w.colors["on-neutral-strong"]:w.colors[`on-${r}`],o="solid"===i;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=(0,_hapticUtils.resolveHaptic)(d,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:({pressed:t})=>[B.actionBtn,"md"===e.size&&B.actionBtnMd,"outline"===i&&{borderWidth:1,borderColor:n},{backgroundColor:o?s:t?w.colors["surface-pressed"]:"transparent",opacity:o&&t?.85:1},R],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:n},children:e.label})},`${e.label}-${t}`)})}):null]});return x?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):P});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:i,style:s})=>{const n=(0,_index.useTheme)(),a=!1!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,..._corners.smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},i,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:n.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:n.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return _reactNative.StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),Banner=exports.Banner=(0,_react.forwardRef)((e,t)=>{const{title:r,message:i,tone:s="neutral",variant:n="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:x=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:g,style:h,containerStyle:y,iconCircleStyle:b,tintBarStyle:v,closeButtonStyle:j,actionButtonStyle:f,testID:R}=e;(0,_assertValidValue.assertValidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_assertValidValue.assertValidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const w=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),B=(0,_react.useMemo)(()=>buildStyles(w),[w]),S=(0,_react.useMemo)(()=>tintFor(w,s),[w,s]),N=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...g}),[g]),[C,k]=V.range(-20,0),D=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?C:0)).current,A=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?0:u?1:0)).current,[L,I]=(0,_react.useState)(u),E=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>{if(E.current&&(E.current=!1,!m))return;let e;return u?(I(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(D,{toValue:k,duration:w.motion.duration.default,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(A,{toValue:1,duration:V.duration("default"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start()):L&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(D,{toValue:C,duration:w.motion.duration.fast,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(A,{toValue:0,duration:V.duration("fast"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start(()=>{I(!1)})),()=>e?.stop()},[u]),!L)return null;const T=r??" ",q="string"==typeof i?i??" ":"",H="wash"===n,M="bar"!==n,z="alert"===p?"danger"===s?"assertive":"polite":"none",P=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:z,accessibilityLabel:_,testID:R,style:[B.container,{backgroundColor:M?S.soft:w.colors["bg-subtle"],borderRadius:H?w.radius.sm:w.radius.md,..._corners.smoothCorners,padding:w.space.md,opacity:A,transform:[{translateY:D}]},y,h],children:[!H&&w.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[B.tintBar,{backgroundColor:S.bar},v]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.row,void 0===r&&B.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(a,{color:S.ink,size:w.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:S.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[B.iconGlyph,{color:S.ink}],children:S.glyph}),style:[B.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.textBlock,children:[r||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...H?{color:S.ink}:null},children:T}):null,"string"==typeof i||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?w.space.xxs:0},children:q||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?w.space.xxs:0},children:i})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[B.closeBtn,{backgroundColor:e?w.colors["surface-pressed"]:"transparent"},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.actionsRow,children:o.map((e,t)=>{(0,_assertValidValue.assertValidValue)("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","action.variant",e.variant,["solid","outline","ghost"]),(0,_assertValidValue.assertValidValue)("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",i=e.variant??"ghost",s="primary"===r?S.glyphColor:"neutral"===r?w.colors["text-muted"]:w.colors[r],n="primary"===r?S.ink:"neutral"===r?w.colors["text-muted"]:w.colors[`${r}-text`],a="primary"===r?S.on:"neutral"===r?w.colors["on-neutral-strong"]:w.colors[`on-${r}`],o="solid"===i;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=(0,_hapticUtils.resolveHaptic)(d,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:({pressed:t})=>[B.actionBtn,"md"===e.size&&B.actionBtnMd,"outline"===i&&{borderWidth:1,borderColor:n},{backgroundColor:o?s:t?w.colors["surface-pressed"]:"transparent",opacity:o&&t?.85:1},f],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:n},children:e.label})},`${e.label}-${t}`)})}):null]});return x?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):P});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:i,style:s})=>{const n=(0,_index.useTheme)(),a=!1!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,..._corners.smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},i,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:n.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:n.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return _reactNative.StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:p,style:b,testID:f}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...p}),[p]),j=(0,_index2.useTheme)(),R=r.length,[v,g]=(0,_react.useState)(0),[S,T]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),C=null!==S&&S>=0&&S<R?S:null,w=(0,_react.useRef)(C);w.current=C;const A=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(R>0&&R<=7),V=void 0!==s&&s.length>0,E=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??STACK_TONES[t%STACK_TONES.length]):[],[V,s]),B=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),D=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),H=(0,_react.useMemo)(()=>D?D.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,D]),I=(0,_react.useMemo)(()=>D?D.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):H,[D,H]),$=(0,_react.useMemo)(()=>(0,_scale.barScale)(I),[I]),k=L?20:6,O=L&&$.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+($.max-e)/($.max-$.min)*F,[k,$.max,$.min,F]),q=G(0),W=(0,_react.useMemo)(()=>$.ticks.map(e=>u(e)),[$.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=R>0?v/R:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=r[e];return t.accessibilityLabel?t.accessibilityLabel:D&&s?`${t.label}, ${s.map((t,r)=>`${t.label} ${c(D[e][r])}`).join(", ")}`:`${t.label}, ${c(H[e])}`},[r,c,H,D,s]),K=(0,_react.useMemo)(()=>{let e=-1;return H.forEach((t,r)=>{(-1===e||t>H[e])&&(e=r)}),e},[H]),J=o??(K>=0?y.highest(r[K].label,c(H[K])):""),Y=(0,_react.useRef)({fire:N,setSelected:T,count:R,plotWidth:v});Y.current={fire:N,setSelected:T,count:R,plotWidth:v};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===A.current||(A.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{A.current=w.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(f?`${f}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),A.current=r,Y.current.setSelected(r===w.current?null:r))}).withTestId(f?`${f}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[f]),Q=(0,_react.useCallback)(e=>{if(0===R)return;const t=w.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(R-1,t+1):null===t?R-1:Math.max(0,t-1);r!==t&&(N(),T(r))},[R,N,T]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??y.chart,ie=0===R?`${ae}, ${y.noData}`:J?`${ae}, ${J}`:ae,se=null===C?J:X(C),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,E[r])}},B[r]))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=H.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==C&&C!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[v>0&&D?renderStack(D[t],t,s):null,v>0&&!D&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&v>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(D?G(I[2*t]):r)-20+2:(D?G(I[2*t+1]):r)+2},children:u(e)}):null]},t)});return 0===R?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:f,style:[styles.root,b],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:R-1,now:C??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:f,style:[styles.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===C?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r[C].label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:f?`${f}-callout`:void 0,children:c(H[C])})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:$.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:W[t]},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:f?`${f}-plot`:void 0,children:[$.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:C===t?"primary":"tertiary",weight:C===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,E[t])}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,entryAt=(e,t)=>{const r=e[t];if(void 0===r)throw new Error(`BarChart has no entry at index ${t}.`);return r},defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:y,style:p,testID:b}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...y}),[y]),j=(0,_index2.useTheme)(),R=r.length,[v,A]=(0,_react.useState)(0),[g,w]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),C=null!==g&&g>=0&&g<R?g:null,S=(0,_react.useRef)(C);S.current=C;const T=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(R>0&&R<=7),V=void 0!==s&&s.length>0,B=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??entryAt(STACK_TONES,t%STACK_TONES.length)):[],[V,s]),E=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),D=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),$=(0,_react.useMemo)(()=>D?D.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,D]),H=(0,_react.useMemo)(()=>D?D.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):$,[D,$]),I=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&I.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+(I.max-e)/(I.max-I.min)*F,[k,I.max,I.min,F]),q=G(0),W=(0,_react.useMemo)(()=>I.ticks.map(e=>u(e)),[I.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=R>0?v/R:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=entryAt(r,e);if(t.accessibilityLabel)return t.accessibilityLabel;if(D&&s){const r=entryAt(D,e);return`${t.label}, ${s.map((e,t)=>`${e.label} ${c(entryAt(r,t))}`).join(", ")}`}return`${t.label}, ${c(entryAt($,e))}`},[r,c,$,D,s]),K=(0,_react.useMemo)(()=>{let e=-1,t=0;for(const[r,a]of $.entries())(-1===e||a>t)&&(e=r,t=a);return e},[$]),J=o??(K>=0?f.highest(entryAt(r,K).label,c(entryAt($,K))):""),Y=(0,_react.useRef)({fire:N,setSelected:w,count:R,plotWidth:v});Y.current={fire:N,setSelected:w,count:R,plotWidth:v};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===T.current||(T.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{T.current=S.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(b?`${b}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),T.current=r,Y.current.setSelected(r===S.current?null:r))}).withTestId(b?`${b}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[b]),Q=(0,_react.useCallback)(e=>{if(0===R)return;const t=S.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(R-1,t+1):null===t?R-1:Math.max(0,t-1);r!==t&&(N(),w(r))},[R,N,w]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);A(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??f.chart,ie=0===R?`${ae}, ${f.noData}`:J?`${ae}, ${J}`:ae,se=null===C?J:X(C),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,entryAt(B,r))}},entryAt(E,r)))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=$.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==C&&C!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[v>0&&D?renderStack(entryAt(D,t),t,s):null,v>0&&!D&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&v>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(D?G(entryAt(H,2*t)):r)-20+2:(D?G(entryAt(H,2*t+1)):r)+2},children:u(e)}):null]},t)});return 0===R?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:b,style:[styles.root,p],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:R-1,now:C??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:b,style:[styles.root,p],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===C?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:entryAt(r,C).label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:b?`${b}-callout`:void 0,children:c(entryAt($,C))})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:I.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:entryAt(W,t)},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:b?`${b}-plot`:void 0,children:[I.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:C===t?"primary":"tertiary",weight:C===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,entryAt(B,t))}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.BottomNavigation=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_shadows=require("../../utils/shadows.js"),_index3=require("../AppIcon/index.js"),_index4=require("../Badge/index.js"),_index5=require("../Text/index.js"),_useScreenReaderEnabled=require("./useScreenReaderEnabled.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=n&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?n(r,a,i):r[a]=e[a]);return r}const DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"}),DEFAULT_ICON_SIZE=18,DEFAULT_LABEL_MAX_FONT_SCALE=1.2,ICON_WRAP_AIR=4,PILL_AIR=8,DEFAULT_PILL_MAX_WIDTH=64,TILE_MAX_WIDTH=96,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__center_action__",EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,badgeVariantOf=e=>null==e||!1===e?null:!0===e||"·"===e?"dot":"number"==typeof e?e>0?"standard":null:e.length>0?"standard":null,badgeAccessibilitySuffix=(e,t)=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${t.unread(e)}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=exports.BottomNavigation=(0,_react.forwardRef)((e,t)=>{const{tabs:i,centerAction:a,activeTab:n,onChange:r,haptic:o="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:h,marginHorizontal:_,marginVertical:m,paddingHorizontal:g,paddingVertical:b,border:x,minimizeOnScroll:f=!1,scrollDirection:y="idle",accessory:v,style:R,indicatorStyle:N,labelStyle:j,labelMaxFontScale:A,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),(0,_assertValidValue.assertValidValue)("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const E=(0,_react.useMemo)(()=>S?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...S}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[S]),I=(0,_index.useTheme)(),T=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),V=(0,_react.useMemo)(()=>buildStyles(I),[I]),L=h??18,M=L+4+8,B=I.space.lg,C=I.space.lg,D=I.radius.xl,O=(0,_useReducedMotion.useReducedMotion)(),k=(0,_useScreenReaderEnabled.useScreenReaderEnabled)(f),[P,z]=_react.default.useState(null);(0,_react.useEffect)(()=>{null!==P&&P!==y&&z(null)},[P,y]);const F=f&&!k&&"down"===y&&null===P,[H,W]=_react.default.useState(F);(0,_react.useEffect)(()=>{H!==F&&(O||"web"===_reactNative.Platform.OS||_reactNative.LayoutAnimation.configureNext(_reactNative.LayoutAnimation.Presets.easeInEaseOut),W(F))},[H,F,O]);const q="function"==typeof v?v({minimized:H}):v,U=null!=q&&!1!==q,$=H&&U,[X,G]=_react.default.useState(0),Z=U&&!$?X+I.space.xs:0,Y="tile"===l,K="floating"===l||Y,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||K||ee,ie=Math.max(0,i.findIndex(e=>e.key===n)),[ae,ne]=_react.default.useState(0),[re,oe]=_react.default.useState(0),se=a?Math.ceil(i.length/2):i.length,le=i.length+(a?1:0),[de,ce]=_react.default.useState({width:0,height:0}),ue=a?.size??48,pe=void 0!==a?.gap,he=Math.max(0,a?.gap??0),me=pe?(de.width||ue)+2*he:0,ge=pe?i.length>0?Math.max(0,ae-me)/i.length:0:le>0?ae/le:0,be=pe?me:ge,xe=(0,_react.useRef)((0,_index.createAnimatedValue)(ie)).current,fe=(0,_react.useRef)({}),ye=(0,_react.useRef)({});i.forEach(e=>{fe.current[e.key]||(fe.current[e.key]=new _reactNative.Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=(0,_index.createAnimatedValue)(e.key===n?1:0))});const ve=ge>0?Y?Math.min(ge-4,96):Math.min(ge-B,64):0,Re=ge>0?(ge-ve)/2:0,Ne=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!H&&!1!==e.showLabel&&e.label.trim().length>0,je=i[ie],Ae=je&&!hasLabel(je)&&re>0?re/2:I.space.xs+(L+4)/2,Se=Ae-14-24,we=Math.max(0,re-4),Ee=Y?2:Ae-M/2,Ie=(0,_react.useRef)(ie);(0,_react.useEffect)(()=>{if(Ie.current===ie)return;Ie.current=ie;const e=_reactNative.Animated.spring(xe,{toValue:ie,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[ie,xe]);const Te=Math.max(1,i.length-1),Ve=(0,_react.useMemo)(()=>{const e=[],t=[];for(let i=0;i<=Te;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Te,se,ge,be]),Le=i.map(e=>e.key).join(" "),Me=J||Q;(0,_react.useEffect)(()=>{const e=Le.split(" ").flatMap(e=>{const t=e===n?1:0,i=ye.current[e];return i?Me?[_reactNative.Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=_reactNative.Animated.parallel(e);return t.start(),()=>t.stop()},[n,Le,Me]);const popIcon=e=>{_reactNative.Animated.sequence([_reactNative.Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:!0}),_reactNative.Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:!0})]).start()},Be=(0,_react.useRef)(new _reactNative.Animated.Value(1)).current,{colors:Ce}=I,De=ee?Ce.primary:Ce.surface,Oe=ee?Ce["on-primary"]:Ce.primary,ke=ee?Ce["on-primary"]:Y?Ce["text-body"]:Ce["text-subtle"],Pe=ee?Ce["on-primary"]:Ce["primary-soft"],ze=ee?Ce.primary:J?Ce["on-primary"]:Oe,Fe=_??C,He=m??(K?C:0),We=He>0,qe=b??I.space.sm,Ue=g??(K?I.space.sm:I.space.xs),$e=We?qe:Math.max(qe,T.bottom),Xe=We?Math.max(He,T.bottom>0?T.bottom+I.space.sm:0):0,Ge="pill"===c,Ze=K?re+Z+2*qe+2*_reactNative.StyleSheet.hairlineWidth:re+Z+qe+$e,Ye=Ge?re>0?Ze/2:I.radius.pill:c??(Y?I.radius.pill:K?D:I.radius.none),Ke=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Ke?Math.min(Ye,e/2):t,Je="underline"===l?Math.max(Ue,Ge&&0===re?0:Ye):Ue,Qe=p??"none",et="none"===Qe?void 0:I.shadow[Qe],tt=void 0===et?null:(0,_shadows.supportsBoxShadow)()?{boxShadow:(0,_shadows.toBoxShadow)(et)}:et,it=x?_reactNative.StyleSheet.hairlineWidth:0,at=ee?Ce.primary:Ce.border,nt=a?.lift??0,rt=qe+it+Z,ot=a&&re>0?Math.max(0,(de.height||ue)/2+nt-re/2-rt):0,st=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCell,pe?{flex:0,marginHorizontal:he}:null],pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{if(!a)return;const e=a.haptic??o;!1!==e&&(0,_index2.triggerHaptic)(e),popIcon(Be),a.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ce(e=>e.width===t&&e.height===i?e:{width:t,height:i})},accessibilityRole:"button",accessibilityLabel:a.label,hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.centerPressable,{top:-nt},e?{opacity:.85}:null],testID:a.testID??(w?`${w}-center`:void 0),children:[a.content?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Be}]},children:a.content}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCircle,{width:ue,height:ue,borderRadius:I.radius.pill,..._corners.smoothCorners,backgroundColor:a.color??Ce.primary}],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Be}]},children:(0,_index3.renderSlotIcon)(a.icon??"add",{color:a.iconColor??Ce["on-primary"],size:a.iconSize??24,disabled:!1})})}),(lt=a,s&&!H&&lt.label.trim().length>0?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,{color:ke,opacity:ee?.7:1},j],children:a.label}):null)]})},CENTER_KEY):null;var lt;const dt=U?(0,_jsxRuntime.jsx)(_reactNative.View,{style:$?V.accessoryInline:V.accessoryStacked,onLayout:e=>G(e.nativeEvent.layout.height),testID:w?`${w}-accessory`:void 0,children:q}):null,ct=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$?[V.tabRow,V.tabRowInline]:V.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ne(t),oe(i)},children:[te&&ve>0&&(!Y||we>0)?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.pill,{width:ve,height:Y?we:M,left:Re,top:Ee,backgroundColor:Pe,borderRadius:Y?activeBgRadius(we,we/2):activeBgRadius(M,I.radius.pill),..._corners.smoothCorners,transform:[{translateX:Ve}]},N]}):null,J&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.bubble,I.shadow.elevated,{width:48,height:48,borderRadius:I.radius.pill,..._corners.smoothCorners,left:Ne,top:Se,backgroundColor:Ce.primary,borderColor:Ce.surface,transform:[{translateX:Ve}]},N]}):null,(ut=i.map(e=>{const t=e.key===n,i=t?Oe:ke,a=t?ze:ke,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=fe.current[e.key],c=ye.current[e.key],u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,E),h=ee&&!t?.7:1,_=J&&t||ee?Ce.primary:Ce.surface,m=hasLabel(e),g=m&&(!Q||t),b=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[V.iconWrap,{width:L+4,height:L+4,opacity:h,transform:[{scale:d}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_index3.renderSlotIcon)(l,{color:a,size:L,focused:t,disabled:!1})}),u?(0,_jsxRuntime.jsx)(_index4.Badge,{variant:u,value:"standard"===u?e.badge:void 0,tone:"danger",accessible:!1,style:"dot"===u?V.badgeDotPosition:V.badgePillPosition,badgeStyle:["dot"===u?V.badgeDot:V.badgePill,{borderColor:_}],textStyle:V.badgeText}):null]}),x=J?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:b}):b,f=g?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,Q?V.labelInline:null,{color:i,opacity:Q?c:h,fontWeight:t?I.weight.semibold:I.weight.normal},j],children:e.label}):null,v=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>(e=>{H&&z(y),e.key!==n&&!1!==o&&(0,_index2.triggerHaptic)(o);const t=fe.current[e.key];t&&popIcon(t),r(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:E.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.tab,Y?V.tabTile:null,e?{opacity:.85}:null],testID:w?`${w}-tab-${e.key}`:void 0,children:Q?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[V.expandPill,{height:M,paddingHorizontal:t&&m?I.space.md:Math.max(0,(M-(L+4))/2)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[V.expandFill,{borderRadius:activeBgRadius(M,M/2),..._corners.smoothCorners,backgroundColor:t?Ce["primary-soft"]:"transparent"},t?N:null]}),x,f]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[x,f]})},e.key);return Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,m?1.5:1]})},children:v},e.key):v}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.underline,"top"===d?V.underlineTop:V.underlineBottom,"top"===d?{top:-qe-Z}:{bottom:-qe},{width:ge,height:3,backgroundColor:Ce.primary,transform:[{translateX:Ve}]},N]}):null]});var ut;return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,testID:w,accessibilityRole:"tablist",style:[V.outer,{paddingHorizontal:Fe,paddingTop:Math.max(He,ot),paddingBottom:Xe},R],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[K?V.floatingBar:V.dockedBar,$?V.barInline:null,tt,{backgroundColor:De,borderColor:at,borderRadius:Ye,..._corners.smoothCorners},K?{borderWidth:it,paddingHorizontal:Ue,paddingVertical:qe}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:qe,paddingBottom:$e}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>_reactNative.StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:e.space.xs},floatingBar:{paddingVertical:e.space.sm,paddingHorizontal:e.space.sm},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.space.xs},accessoryInline:{flexShrink:0,marginRight:e.space.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:e.space.xs,gap:e.space.xs},tabTile:{paddingVertical:e.space.sm,gap:e.space.xxs},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerPressable:{alignItems:"center",maxWidth:"100%",gap:e.space.xs},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.text.xs.size,lineHeight:e.text.xs.size*e.leading.heading,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.text.sm.size,lineHeight:e.text.sm.size*e.leading.heading,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.space.xs},expandFill:{position:"absolute",top:0,right:0,bottom:0,left:0,overflow:"hidden"},pill:{position:"absolute",left:0},bubble:{position:"absolute",left:0,borderWidth:3},underline:{position:"absolute",left:0,height:3},underlineBottom:{borderTopLeftRadius:e.radius.none,borderTopRightRadius:e.radius.none,..._corners.smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,..._corners.smoothCorners},badgePillPosition:{position:"absolute",top:-4,right:-8},badgePill:{minWidth:18,height:18,paddingHorizontal:e.space.xs,paddingVertical:e.space.xxs,borderWidth:1.5},badgeDotPosition:{position:"absolute",top:-2,right:-2},badgeDot:{width:10,height:10,borderRadius:e.radius.pill,borderWidth:1.5},badgeText:{lineHeight:13}});var _default=exports.default=BottomNavigation;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.BottomNavigation=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_shadows=require("../../utils/shadows.js"),_index3=require("../AppIcon/index.js"),_index4=require("../Badge/index.js"),_index5=require("../Text/index.js"),_useScreenReaderEnabled=require("./useScreenReaderEnabled.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=n&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?n(r,a,i):r[a]=e[a]);return r}const DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"}),DEFAULT_ICON_SIZE=18,DEFAULT_LABEL_MAX_FONT_SCALE=1.2,ICON_WRAP_AIR=4,PILL_AIR=8,DEFAULT_PILL_MAX_WIDTH=64,TILE_MAX_WIDTH=96,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__center_action__",EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,badgeVariantOf=e=>null==e||!1===e?null:!0===e||"·"===e?"dot":"number"==typeof e?e>0?"standard":null:e.length>0?"standard":null,badgeAccessibilitySuffix=(e,t)=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${t.unread(e)}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=exports.BottomNavigation=(0,_react.forwardRef)((e,t)=>{const{tabs:i,centerAction:a,activeTab:n,onChange:r,haptic:o="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:h,marginHorizontal:_,marginVertical:m,paddingHorizontal:g,paddingVertical:b,border:x,minimizeOnScroll:f=!1,scrollDirection:v="idle",accessory:y,style:R,indicatorStyle:N,labelStyle:j,labelMaxFontScale:A,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),(0,_assertValidValue.assertValidValue)("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const E=(0,_react.useMemo)(()=>S?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...S}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[S]),I=(0,_index.useTheme)(),T=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),V=(0,_react.useMemo)(()=>buildStyles(I),[I]),L=h??18,D=L+4+8,M=I.space.lg,B=I.space.lg,C=I.radius.xl,k=(0,_useReducedMotion.useReducedMotion)(),O=(0,_useScreenReaderEnabled.useScreenReaderEnabled)(f),[P,z]=_react.default.useState(null);(0,_react.useEffect)(()=>{null!==P&&P!==v&&z(null)},[P,v]);const F=f&&!O&&"down"===v&&null===P,[H,W]=_react.default.useState(F);(0,_react.useEffect)(()=>{H!==F&&(k||"web"===_reactNative.Platform.OS||_reactNative.LayoutAnimation.configureNext(_reactNative.LayoutAnimation.Presets.easeInEaseOut),W(F))},[H,F,k]);const q="function"==typeof y?y({minimized:H}):y,U=null!=q&&!1!==q,$=H&&U,[X,G]=_react.default.useState(0),Z=U&&!$?X+I.space.xs:0,Y="tile"===l,K="floating"===l||Y,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||K||ee,ie=Math.max(0,i.findIndex(e=>e.key===n)),[ae,ne]=_react.default.useState(0),[re,oe]=_react.default.useState(0),se=a?Math.ceil(i.length/2):i.length,le=i.length+(a?1:0),[de,ce]=_react.default.useState({width:0,height:0}),ue=a?.size??48,pe=void 0!==a?.gap,he=Math.max(0,a?.gap??0),me=pe?(de.width||ue)+2*he:0,ge=pe?i.length>0?Math.max(0,ae-me)/i.length:0:le>0?ae/le:0,be=pe?me:ge,xe=(0,_react.useRef)((0,_index.createAnimatedValue)(ie)).current,fe=(0,_react.useRef)({}),ve=(0,_react.useRef)({});i.forEach(e=>{fe.current[e.key]||(fe.current[e.key]=new _reactNative.Animated.Value(1)),ve.current[e.key]||(ve.current[e.key]=(0,_index.createAnimatedValue)(e.key===n?1:0))});const ye=ge>0?Y?Math.min(ge-4,96):Math.min(ge-M,64):0,Re=ge>0?(ge-ye)/2:0,Ne=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!H&&!1!==e.showLabel&&e.label.trim().length>0,je=i[ie],Ae=je&&!hasLabel(je)&&re>0?re/2:I.space.xs+(L+4)/2,Se=Ae-14-24,we=Math.max(0,re-4),Ee=Y?2:Ae-D/2,Ie=(0,_react.useRef)(ie);(0,_react.useEffect)(()=>{if(Ie.current===ie)return;Ie.current=ie;const e=_reactNative.Animated.spring(xe,{toValue:ie,tension:120,friction:14,useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[ie,xe]);const Te=Math.max(1,i.length-1),Ve=(0,_react.useMemo)(()=>{const e=[],t=[];for(let i=0;i<=Te;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Te,se,ge,be]),Le=i.map(e=>e.key).join(" "),De=J||Q;(0,_react.useEffect)(()=>{const e=Le.split(" ").flatMap(e=>{const t=e===n?1:0,i=ve.current[e];return i?De?[_reactNative.Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=_reactNative.Animated.parallel(e);return t.start(),()=>t.stop()},[n,Le,De]);const popIcon=e=>{_reactNative.Animated.sequence([_reactNative.Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:_nativeDriver.nativeDriver})]).start()},Me=(0,_react.useRef)(new _reactNative.Animated.Value(1)).current,{colors:Be}=I,Ce=ee?Be.primary:Be.surface,ke=ee?Be["on-primary"]:Be.primary,Oe=ee?Be["on-primary"]:Y?Be["text-body"]:Be["text-subtle"],Pe=ee?Be["on-primary"]:Be["primary-soft"],ze=ee?Be.primary:J?Be["on-primary"]:ke,Fe=_??B,He=m??(K?B:0),We=He>0,qe=b??I.space.sm,Ue=g??(K?I.space.sm:I.space.xs),$e=We?qe:Math.max(qe,T.bottom),Xe=We?Math.max(He,T.bottom>0?T.bottom+I.space.sm:0):0,Ge="pill"===c,Ze=K?re+Z+2*qe+2*_reactNative.StyleSheet.hairlineWidth:re+Z+qe+$e,Ye=Ge?re>0?Ze/2:I.radius.pill:c??(Y?I.radius.pill:K?C:I.radius.none),Ke=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Ke?Math.min(Ye,e/2):t,Je="underline"===l?Math.max(Ue,Ge&&0===re?0:Ye):Ue,Qe=p??"none",et="none"===Qe?void 0:I.shadow[Qe],tt=void 0===et?null:(0,_shadows.supportsBoxShadow)()?{boxShadow:(0,_shadows.toBoxShadow)(et)}:et,it=x?_reactNative.StyleSheet.hairlineWidth:0,at=ee?Be.primary:Be.border,nt=a?.lift??0,rt=qe+it+Z,ot=a&&re>0?Math.max(0,(de.height||ue)/2+nt-re/2-rt):0,st=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCell,pe?{flex:0,marginHorizontal:he}:null],pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{if(!a)return;const e=a.haptic??o;!1!==e&&(0,_index2.triggerHaptic)(e),popIcon(Me),a.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ce(e=>e.width===t&&e.height===i?e:{width:t,height:i})},accessibilityRole:"button",accessibilityLabel:a.label,hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.centerPressable,{top:-nt},e?{opacity:.85}:null],testID:a.testID??(w?`${w}-center`:void 0),children:[a.content?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Me}]},children:a.content}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCircle,{width:ue,height:ue,borderRadius:I.radius.pill,..._corners.smoothCorners,backgroundColor:a.color??Be.primary}],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Me}]},children:(0,_index3.renderSlotIcon)(a.icon??"add",{color:a.iconColor??Be["on-primary"],size:a.iconSize??24,disabled:!1})})}),(lt=a,s&&!H&&lt.label.trim().length>0?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,{color:Oe,opacity:ee?.7:1},j],children:a.label}):null)]})},CENTER_KEY):null;var lt;const dt=U?(0,_jsxRuntime.jsx)(_reactNative.View,{style:$?V.accessoryInline:V.accessoryStacked,onLayout:e=>G(e.nativeEvent.layout.height),testID:w?`${w}-accessory`:void 0,children:q}):null,ct=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$?[V.tabRow,V.tabRowInline]:V.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ne(t),oe(i)},children:[te&&ye>0&&(!Y||we>0)?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.pill,{width:ye,height:Y?we:D,left:Re,top:Ee,backgroundColor:Pe,borderRadius:Y?activeBgRadius(we,we/2):activeBgRadius(D,I.radius.pill),..._corners.smoothCorners,transform:[{translateX:Ve}]},N]}):null,J&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.bubble,I.shadow.elevated,{width:48,height:48,borderRadius:I.radius.pill,..._corners.smoothCorners,left:Ne,top:Se,backgroundColor:Be.primary,borderColor:Be.surface,transform:[{translateX:Ve}]},N]}):null,(ut=i.map(e=>{const t=e.key===n,i=t?ke:Oe,a=t?ze:Oe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=fe.current[e.key],c=ve.current[e.key];if(void 0===d||void 0===c)throw new Error(`BottomNavigation has no animation values for tab "${e.key}".`);const u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,E),h=ee&&!t?.7:1,_=J&&t||ee?Be.primary:Be.surface,m=hasLabel(e),g=m&&(!Q||t),b=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[V.iconWrap,{width:L+4,height:L+4,opacity:h,transform:[{scale:d}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_index3.renderSlotIcon)(l,{color:a,size:L,focused:t,disabled:!1})}),u?(0,_jsxRuntime.jsx)(_index4.Badge,{variant:u,value:"standard"===u?e.badge:void 0,tone:"danger",accessible:!1,style:"dot"===u?V.badgeDotPosition:V.badgePillPosition,badgeStyle:["dot"===u?V.badgeDot:V.badgePill,{borderColor:_}],textStyle:V.badgeText}):null]}),x=J?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:b}):b,f=g?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,Q?V.labelInline:null,{color:i,opacity:Q?c:h,fontWeight:t?I.weight.semibold:I.weight.normal},j],children:e.label}):null,y=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>(e=>{H&&z(v),e.key!==n&&!1!==o&&(0,_index2.triggerHaptic)(o);const t=fe.current[e.key];t&&popIcon(t),r(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:E.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.tab,Y?V.tabTile:null,e?{opacity:.85}:null],testID:w?`${w}-tab-${e.key}`:void 0,children:Q?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[V.expandPill,{height:D,paddingHorizontal:t&&m?I.space.md:Math.max(0,(D-(L+4))/2)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[V.expandFill,{borderRadius:activeBgRadius(D,D/2),..._corners.smoothCorners,backgroundColor:t?Be["primary-soft"]:"transparent"},t?N:null]}),x,f]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[x,f]})},e.key);return Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,m?1.5:1]})},children:y},e.key):y}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.underline,"top"===d?V.underlineTop:V.underlineBottom,"top"===d?{top:-qe-Z}:{bottom:-qe},{width:ge,height:3,backgroundColor:Be.primary,transform:[{translateX:Ve}]},N]}):null]});var ut;return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,testID:w,accessibilityRole:"tablist",style:[V.outer,{paddingHorizontal:Fe,paddingTop:Math.max(He,ot),paddingBottom:Xe},R],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[K?V.floatingBar:V.dockedBar,$?V.barInline:null,tt,{backgroundColor:Ce,borderColor:at,borderRadius:Ye,..._corners.smoothCorners},K?{borderWidth:it,paddingHorizontal:Ue,paddingVertical:qe}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:qe,paddingBottom:$e}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>_reactNative.StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:e.space.xs},floatingBar:{paddingVertical:e.space.sm,paddingHorizontal:e.space.sm},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.space.xs},accessoryInline:{flexShrink:0,marginRight:e.space.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:e.space.xs,gap:e.space.xs},tabTile:{paddingVertical:e.space.sm,gap:e.space.xxs},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerPressable:{alignItems:"center",maxWidth:"100%",gap:e.space.xs},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.text.xs.size,lineHeight:e.text.xs.size*e.leading.heading,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.text.sm.size,lineHeight:e.text.sm.size*e.leading.heading,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.space.xs},expandFill:{position:"absolute",top:0,right:0,bottom:0,left:0,overflow:"hidden"},pill:{position:"absolute",left:0},bubble:{position:"absolute",left:0,borderWidth:3},underline:{position:"absolute",left:0,height:3},underlineBottom:{borderTopLeftRadius:e.radius.none,borderTopRightRadius:e.radius.none,..._corners.smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,..._corners.smoothCorners},badgePillPosition:{position:"absolute",top:-4,right:-8},badgePill:{minWidth:18,height:18,paddingHorizontal:e.space.xs,paddingVertical:e.space.xxs,borderWidth:1.5},badgeDotPosition:{position:"absolute",top:-2,right:-2},badgeDot:{width:10,height:10,borderRadius:e.radius.pill,borderWidth:1.5},badgeText:{lineHeight:13}});var _default=exports.default=BottomNavigation;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:j,actions:C,actionsLayout:w="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=j||null!=d,L=null!=C&&C.length>0,P=null!=M||L,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(P?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[je,Ce]=(0,_react.useState)(!1),[we,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[Te,ke]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===D?we:Te;const Ie=(0,_react.useRef)(u);Ie.current=u;const Le=(0,_react.useRef)(r);Le.current=r;const Pe=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(Ce(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!we:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,we,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),Ce(!0)):ke(!0),a<0&&Ae.current?(be.value=r,ye.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,s,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=xe.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,s,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Pe.current)return void t?.();const n=r();"boolean"!=typeof n?(Pe.current=!0,a?.(),n.then(a=>{Pe.current=!1,a&&De.current&&Be.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{Le.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Le.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(B?`${B}-content-gesture`:"bottom-sheet-content-gesture"),[B]),st=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value;if(a.velocityY>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,e[0]);let o=0,s=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const a=Math.abs(n-e[t]);a<s&&(s=a,o=t)}const i=e[0];r&&n-i>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(o,e[o])})},[fe,pe,c,nt,tt,at,B,be]),{height:it}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?it.value:0,[ct,it]),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,lt,F,ut,dt,be,Z,ye,tt]),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[lt,K,F,ut,dt,be,Z,tt,Se]),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,B]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!we)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:A??mt,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:st,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,j]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:T}):T}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[L?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:C??[],layout:w})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:je,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:w,actions:j,actionsLayout:C="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=w||null!=d,L=null!=j&&j.length>0,P=null!=M||L,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(P?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[we,je]=(0,_react.useState)(!1),[Ce,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[Te,ke]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===D?Ce:Te;const Ie=(0,_react.useRef)(u);Ie.current=u;const Le=(0,_react.useRef)(r);Le.current=r;const Pe=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(je(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!Ce:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,Ce,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),je(!0)):ke(!0),a<0&&Ae.current?(be.value=r,ye.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,s,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=xe.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,s,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Pe.current)return void t?.();const n=r();"boolean"!=typeof n?(Pe.current=!0,a?.(),n.then(a=>{Pe.current=!1,a&&De.current&&Be.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{Le.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Le.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(B?`${B}-content-gesture`:"bottom-sheet-content-gesture"),[B]),st=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value,o=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t);if(o>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(n-t);e<l&&(l=e,c=t,i=u),u++}r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(i,c)})},[fe,pe,c,nt,tt,at,B,be]),{height:it}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?it.value:0,[ct,it]),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,lt,F,ut,dt,be,Z,ye,tt]),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[lt,K,F,ut,dt,be,Z,tt,Se]),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,B]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!Ce)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:A??mt,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:st,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,w]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:T}):T}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[L?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:we,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_BUTTON_LABELS=exports.Button=void 0,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BUTTON_LABELS=exports.DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"}),Button=exports.Button=(0,_react.forwardRef)((e,t)=>{const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:a=!1,fullWidth:l=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:p,style:h,containerStyle:x,textStyle:m,pressAnimation:f,onPress:y,accessibilityLabel:v,accessibilityHint:S,accessibilityState:j,testID:C,onLayout:I,labels:L,...k}=e;(0,_assertValidValue.assertValidValue)("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),(0,_assertValidValue.assertValidValue)("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Button","size",e.size,["xs","sm","md","lg","xl"]);const T=(0,_index.useTheme)(),F=T.settings.components.button,R=o??F?.defaultVariant??"solid",V=i??F?.defaultSize??"md",w=(0,_react.useMemo)(()=>({...DEFAULT_BUTTON_LABELS,...L}),[L]),N=!a&&!n,A={...j,disabled:!N,busy:n},q="link"===R,O=f??F?.defaultPressAnimation??(!q&&"scale"),B=(0,_usePressAnimation.usePressAnimation)({preset:O||"scale",enabled:!1!==O&&N}),E=(0,_useFlickGuard.useFlickGuard)(),P=(0,_react.useMemo)(()=>buildStyles(T),[T]),z=(0,_react.useMemo)(()=>(0,_index.resolveButtonSize)(T,V),[T,V]),W=(0,_react.useMemo)(()=>toneFor(T,s),[T,s]),D=(0,_react.useMemo)(()=>variantFor(T,R,W,a),[T,R,W,a]),H=(0,_react.useMemo)(()=>!p||a||"solid"!==R?null:"string"==typeof p?T.settings.gradients[p]??null:p,[p,a,R,T.settings.gradients]),U=_reactNative.StyleSheet.flatten(h)?.borderRadius,M=q?0:"number"==typeof U?U:_?T.radius.pill:z.radius,G=(0,_SquircleFill.useSquircle)(!H&&"link"!==R,M,I),K=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[X,Y]=(0,_react.useState)(0),[J,Q]=(0,_react.useState)(null),Z=q?e=>Y(e.nativeEvent.layout.width):void 0,$=v??r,ee="outline"===R||"ghost"===R,te=!ee&&!q,re={color:D.textColor,size:z.icon,disabled:a},oe=b&&!q&&Boolean(c),se=T.space.xs,ie=z["min-height"]-2*se-2*D.borderWidth,ne={color:D.badgeInk,size:z["badge-icon"],disabled:a},ae=n?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:"sm",color:oe?D.badgeInk:D.textColor,accessibilityLabel:w.loading}):c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(c,oe?ne:re,u)}):null,le=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:P.contentRow,children:[oe?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[P.iconLeft,P.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:D.badgeFill}],children:ae}):ae?(0,_jsxRuntime.jsx)(_reactNative.View,{style:P.iconLeft,children:ae}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:Z,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[P.label,{color:D.textColor,fontSize:z.text,lineHeight:Math.round(z.text*T.leading.body)},m],children:r}),q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[P.linkUnderline,{backgroundColor:D.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:P.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(d,re,u)}):null]}),ce=q?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(z["min-height"]),de={top:ce,bottom:ce,left:q?LINK_HIT_SLOP:0,right:q?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[B.style,l?P.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!N||E.isFlick(e))return;B.press();const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)},onPressIn:e=>{E.onPressIn(e),B.pressIn(),q&&N&&(K.stopAnimation(),K.setValue(0),_reactNative.Animated.timing(K,{toValue:1,duration:T.motion.duration.slower,easing:_reactNative.Easing.bezier(...T.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{B.pressOut()},disabled:!N,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:S,accessibilityState:A,...(0,_ariaState.ariaFromState)(A),testID:C,onLayout:e=>{G.onLayout(e),q&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[P.base,{paddingHorizontal:q?0:z["padding-x"],paddingVertical:q?0:oe?se:z["padding-y"],paddingLeft:oe?se:void 0,minHeight:q?void 0:z["min-height"],borderRadius:M,..._corners.smoothCorners,backgroundColor:H||G.active?"transparent":D.backgroundColor,borderWidth:D.borderWidth,borderColor:G.active?"transparent":D.borderColor,opacity:n?.55:1,overflow:G.active||q?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:T.colors["surface-pressed"]}:null,l?P.fullWidth:null,h],...k,"aria-disabled":!N,"aria-busy":n,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:e&&ee?T.colors["surface-pressed"]:D.backgroundColor,stroke:D.borderColor,strokeWidth:D.borderWidth}):null,H?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:H,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:M,..._corners.smoothCorners}]}):null,e&&te?G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:D.pressedTint,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[P.pressedOverlay,{borderRadius:M,backgroundColor:D.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,le]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},a=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...a};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_BUTTON_LABELS=exports.Button=void 0,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BUTTON_LABELS=exports.DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"}),Button=exports.Button=(0,_react.forwardRef)((e,t)=>{const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:a=!1,fullWidth:l=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:p,style:h,containerStyle:x,textStyle:m,pressAnimation:f,onPress:v,accessibilityLabel:y,accessibilityHint:j,accessibilityState:S,testID:C,onLayout:I,labels:L,...k}=e;(0,_assertValidValue.assertValidValue)("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),(0,_assertValidValue.assertValidValue)("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Button","size",e.size,["xs","sm","md","lg","xl"]);const T=(0,_index.useTheme)(),F=T.settings.components.button,R=o??F?.defaultVariant??"solid",V=i??F?.defaultSize??"md",w=(0,_react.useMemo)(()=>({...DEFAULT_BUTTON_LABELS,...L}),[L]),N=!a&&!n,q={...S,disabled:!N,busy:n},A="link"===R,O=f??F?.defaultPressAnimation??(!A&&"scale"),B=(0,_usePressAnimation.usePressAnimation)({preset:O||"scale",enabled:!1!==O&&N}),D=(0,_useFlickGuard.useFlickGuard)(),E=(0,_react.useMemo)(()=>buildStyles(T),[T]),P=(0,_react.useMemo)(()=>(0,_index.resolveButtonSize)(T,V),[T,V]),z=(0,_react.useMemo)(()=>toneFor(T,s),[T,s]),W=(0,_react.useMemo)(()=>variantFor(T,R,z,a),[T,R,z,a]),H=(0,_react.useMemo)(()=>!p||a||"solid"!==R?null:"string"==typeof p?T.settings.gradients[p]??null:p,[p,a,R,T.settings.gradients]),U=_reactNative.StyleSheet.flatten(h)?.borderRadius,M=A?0:"number"==typeof U?U:_?T.radius.pill:P.radius,G=(0,_SquircleFill.useSquircle)(!H&&"link"!==R,M,I),K=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[X,Y]=(0,_react.useState)(0),[J,Q]=(0,_react.useState)(null),Z=A?e=>Y(e.nativeEvent.layout.width):void 0,$=y??r,ee="outline"===R||"ghost"===R,te=!ee&&!A,re={color:W.textColor,size:P.icon,disabled:a},oe=b&&!A&&Boolean(c),se=T.space.xs,ie=P["min-height"]-2*se-2*W.borderWidth,ne={color:W.badgeInk,size:P["badge-icon"],disabled:a},ae=n?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:"sm",color:oe?W.badgeInk:W.textColor,accessibilityLabel:w.loading}):c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(c,oe?ne:re,u)}):null,le=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.contentRow,children:[oe?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[E.iconLeft,E.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:W.badgeFill}],children:ae}):ae?(0,_jsxRuntime.jsx)(_reactNative.View,{style:E.iconLeft,children:ae}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:Z,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[E.label,{color:W.textColor,fontSize:P.text,lineHeight:Math.round(P.text*T.leading.body)},m],children:r}),A?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[E.linkUnderline,{backgroundColor:W.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:E.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(d,re,u)}):null]}),ce=A?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(P["min-height"]),de={top:ce,bottom:ce,left:A?LINK_HIT_SLOP:0,right:A?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[B.style,l?E.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!N||D.isFlick(e))return;B.press();const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),v?.(e)},onPressIn:e=>{D.onPressIn(e),B.pressIn(),A&&N&&(K.stopAnimation(),K.setValue(0),_reactNative.Animated.timing(K,{toValue:1,duration:T.motion.duration.slower,easing:_reactNative.Easing.bezier(...T.motion.ease.decelerate),useNativeDriver:_nativeDriver.nativeDriver}).start())},onPressOut:()=>{B.pressOut()},disabled:!N,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:j,accessibilityState:q,...(0,_ariaState.ariaFromState)(q),testID:C,onLayout:e=>{G.onLayout(e),A&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[E.base,{paddingHorizontal:A?0:P["padding-x"],paddingVertical:A?0:oe?se:P["padding-y"],paddingLeft:oe?se:void 0,minHeight:A?void 0:P["min-height"],borderRadius:M,..._corners.smoothCorners,backgroundColor:H||G.active?"transparent":W.backgroundColor,borderWidth:W.borderWidth,borderColor:G.active?"transparent":W.borderColor,opacity:n?.55:1,overflow:G.active||A?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:T.colors["surface-pressed"]}:null,l?E.fullWidth:null,h],...k,"aria-disabled":!N,"aria-busy":n,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:e&&ee?T.colors["surface-pressed"]:W.backgroundColor,stroke:W.borderColor,strokeWidth:W.borderWidth}):null,H?(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:H,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:M,..._corners.smoothCorners}]}):null,e&&te?G.active&&G.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:G.size.width,height:G.size.height,radius:M,fill:W.pressedTint,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[E.pressedOverlay,{borderRadius:M,backgroundColor:W.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,le]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};case"neutral":return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},a=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...a};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CALENDAR_LABELS=exports.Calendar=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"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_index4=require("../Text/index.js"),_CalendarDay=require("./CalendarDay.js"),_calendarDates=require("./calendarDates.js"),_calendarStyles=require("./calendarStyles.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALENDAR_LABELS=exports.DEFAULT_CALENDAR_LABELS=Object.freeze({previousMonth:"Previous month",nextMonth:"Next month",marked:"Marked"}),MAX_DOTS=3,DAY_TEXT_MAX_SCALE=1.5,toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"primary":return e.colors.primary;default:return e.colors["text-muted"]}},Calendar=exports.Calendar=(0,_react.forwardRef)((e,t)=>{const{selectionMode:a="single",value:r,onChange:i,month:s,onMonthChange:n,minDate:l,maxDate:o,disabledDates:c,weekStartsOn:d=0,locale:u="en-IN",marks:_,cellSize:m,haptic:x,accessibilityLabel:h,onTitlePress:y,labels:v,style:p,headerLabelStyle:g,navButtonStyle:b,testID:D}=e;(0,_assertValidValue.assertValidValue)("Calendar","selectionMode",e.selectionMode,["single","range"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_CALENDAR_LABELS,...v}),[v]),M=f.marked,j=(0,_index2.useTheme)(),S=(0,_index.usePresenceMotion)(),N=(0,_react.useMemo)(()=>(0,_calendarStyles.buildCalendarStyles)(j),[j]),[L,A]=(0,_index.useControllableState)({value:s?(0,_calendarDates.startOfMonth)(s):void 0,defaultValue:(0,_calendarDates.startOfMonth)(r?.start??new Date),onChange:n}),R=12*L.getFullYear()+L.getMonth(),T=r?.start?(0,_calendarDates.startOfDay)(r.start):null,C="range"===a&&r?.end?(0,_calendarDates.startOfDay)(r.end):null,w=T?.getTime()??null,E=C?.getTime()??null,k=(0,_calendarDates.toIso)(new Date),V=l?(0,_calendarDates.startOfDay)(l).getTime():null,I=o?(0,_calendarDates.startOfDay)(o).getTime():null,q=(0,_react.useMemo)(()=>new Set((c??[]).map(e=>(0,_calendarDates.toIso)(e))),[c]),F=(0,_react.useCallback)(e=>null!==V&&e.getTime()<V||null!==I&&e.getTime()>I||q.has((0,_calendarDates.toIso)(e)),[V,I,q]),O=(0,_react.useMemo)(()=>{const e=new Map;for(const t of _??[]){const a=t.date;let r=e.get(a);r||(r={dots:[],spoken:[]},e.set(a,r)),r.dots.length<3&&r.dots.push({key:`${t.tone}-${r.dots.length}`,color:toneColor(j,t.tone)}),r.spoken.push(t.label??M)}return e},[_,j,M]),P=(0,_react.useMemo)(()=>(0,_calendarDates.buildMonthMatrix)(new Date(Math.floor(R/12),R%12,1),d),[R,d]),B=(0,_react.useMemo)(()=>(0,_calendarDates.weekdayLabels)(u,d),[u,d]),z=(0,_react.useMemo)(()=>new Intl.DateTimeFormat(u,{month:"long",year:"numeric"}),[u]),$=(0,_react.useMemo)(()=>new Intl.DateTimeFormat(u,{weekday:"short",day:"numeric",month:"long"}),[u]),H=z.format(L),U=null===V||(0,_calendarDates.startOfMonth)(new Date(V)).getTime()<L.getTime(),X=null===I||(0,_calendarDates.startOfMonth)(new Date(I)).getTime()>L.getTime(),Z=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,Y=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,G=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>G.current?.stop(),[]);const W=(0,_react.useCallback)(e=>{!1!==x&&(0,_index3.triggerHaptic)("impactLight");const t=j.motion.duration.fast,a=j.motion.duration.fast,[r]=S.range(32*-e,0),[i]=S.range(32*e,0),s=S.reduced?S.duration("fast"):t,n=S.reduced?S.duration("fast"):a;G.current?.stop(),G.current=_reactNative.Animated.sequence([_reactNative.Animated.parallel([_reactNative.Animated.timing(Z,{toValue:r,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.quad),useNativeDriver:!0}),_reactNative.Animated.timing(Y,{toValue:0,duration:s,useNativeDriver:!0})]),_reactNative.Animated.timing(Z,{toValue:i,duration:0,useNativeDriver:!0}),_reactNative.Animated.parallel([_reactNative.Animated.timing(Z,{toValue:0,duration:a,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0}),_reactNative.Animated.timing(Y,{toValue:1,duration:n,useNativeDriver:!0})])]),G.current.start();const l=(0,_calendarDates.addMonths)(L,e);A(l),_reactNative.AccessibilityInfo.announceForAccessibility(z.format(l))},[x,L,Y,z,Z,S,A,j]),J=(0,_react.useCallback)(()=>W(-1),[W]),K=(0,_react.useCallback)(()=>W(1),[W]),pressDay=e=>{if(F(e.date))return;const t=(0,_index3.resolveHaptic)(x,"selection");t&&(0,_index3.triggerHaptic)(t);const r=e.date;"single"===a||!T||C||r.getTime()<T.getTime()?i({start:r}):i({start:T,end:r}),e.inMonth||A((0,_calendarDates.startOfMonth)(r))},Q=(0,_react.useRef)(pressDay);(0,_react.useLayoutEffect)(()=>{Q.current=pressDay});const ee=(0,_react.useCallback)(e=>Q.current(e),[]),te=void 0===m?void 0:Math.max(m,_calendarStyles.MIN_CELL_SIZE),ae=(0,_react.useMemo)(()=>void 0===te?{flex:1}:{width:te},[te]),re=(0,_react.useMemo)(()=>void 0===te?{flex:1,aspectRatio:1,minHeight:_calendarStyles.MIN_CELL_SIZE}:{width:te,height:te},[te]),ie=Math.max(j.space.sm,(_calendarStyles.MIN_CELL_SIZE-_calendarStyles.NAV_BUTTON_SIZE)/2),se=Math.min(j.settings.maxFontSizeMultiplier??1.5,1.5),ne=[];for(let e=0;e<_calendarDates.GRID_CELLS;e+=7)ne.push(P.slice(e,e+7));const le=(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",accessibilityLabel:h?`${h}, ${H}`:void 0,style:N.headerLabel,children:H});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[N.root,p],testID:D,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:N.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:J,disabled:!U,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,!U&&N.navBtnDisabled,b],accessibilityRole:"button",accessibilityLabel:f.previousMonth,accessibilityState:{disabled:!U},"aria-disabled":!U,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",style:N.navText,maxFontSizeMultiplier:se,children:"‹"})}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[N.headerLabelWrap,{opacity:Y,transform:[{translateX:Z}]},g],children:y?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:y,accessibilityRole:"button",accessibilityLabel:h?`${h}, ${H}`:H,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:le}):le}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:K,disabled:!X,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,!X&&N.navBtnDisabled,b],accessibilityRole:"button",accessibilityLabel:f.nextMonth,accessibilityState:{disabled:!X},"aria-disabled":!X,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",style:N.navText,maxFontSizeMultiplier:se,children:"›"})})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:N.weekdayRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:B.map(({weekday:e,label:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.weekdayCell,ae],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",style:N.weekdayText,maxFontSizeMultiplier:se,children:t})},e))}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{opacity:Y,transform:[{translateX:Z}]},children:ne.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:N.gridRow,children:e.map(e=>{const t=e.date.getTime(),r=null!==w&&t===w,i=null!==E&&t===E,s=null!==w&&null!==E&&t>=w&&t<=E,n=s&&!r&&!i,l=e.iso===k,o=O.get(e.iso),c=[$.format(e.date),...o?.spoken??[]];return l&&c.push("today"),"range"===a&&(r&&i?c.push("start and end of your range"):r?c.push("start of your range"):i?c.push("end of your range"):n&&c.push("in your range")),(0,_jsxRuntime.jsx)(_CalendarDay.CalendarDay,{cell:e,accessibilityLabel:c.join(", "),disabled:F(e.date),edge:r||i,mid:n,barLeft:s&&(i||n)&&!(r&&i),barRight:s&&(r||n)&&!(r&&i),today:l,dots:o?.dots,cellStyle:re,styles:N,maxFontSizeMultiplier:se,onPressDay:ee},e.iso)})},e[0].iso))})]})});Calendar.displayName="Calendar";var _default=exports.default=Calendar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CALENDAR_LABELS=exports.Calendar=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"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index4=require("../Text/index.js"),_CalendarDay=require("./CalendarDay.js"),_calendarDates=require("./calendarDates.js"),_calendarStyles=require("./calendarStyles.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALENDAR_LABELS=exports.DEFAULT_CALENDAR_LABELS=Object.freeze({previousMonth:"Previous month",nextMonth:"Next month",marked:"Marked"}),MAX_DOTS=3,DAY_TEXT_MAX_SCALE=1.5,toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"primary":return e.colors.primary;case"neutral":return e.colors["text-muted"]}},Calendar=exports.Calendar=(0,_react.forwardRef)((e,t)=>{const{selectionMode:a="single",value:r,onChange:i,month:s,onMonthChange:n,minDate:l,maxDate:o,disabledDates:c,weekStartsOn:d=0,locale:u="en-IN",marks:_,cellSize:m,haptic:v,accessibilityLabel:x,onTitlePress:h,labels:y,style:D,headerLabelStyle:p,navButtonStyle:g,testID:b}=e;(0,_assertValidValue.assertValidValue)("Calendar","selectionMode",e.selectionMode,["single","range"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_CALENDAR_LABELS,...y}),[y]),M=f.marked,j=(0,_index2.useTheme)(),S=(0,_index.usePresenceMotion)(),N=(0,_react.useMemo)(()=>(0,_calendarStyles.buildCalendarStyles)(j),[j]),[L,A]=(0,_index.useControllableState)({value:s?(0,_calendarDates.startOfMonth)(s):void 0,defaultValue:(0,_calendarDates.startOfMonth)(r?.start??new Date),onChange:n}),R=12*L.getFullYear()+L.getMonth(),T=r?.start?(0,_calendarDates.startOfDay)(r.start):null,C="range"===a&&r?.end?(0,_calendarDates.startOfDay)(r.end):null,w=T?.getTime()??null,E=C?.getTime()??null,k=(0,_calendarDates.toIso)(new Date),V=l?(0,_calendarDates.startOfDay)(l).getTime():null,I=o?(0,_calendarDates.startOfDay)(o).getTime():null,q=(0,_react.useMemo)(()=>new Set((c??[]).map(e=>(0,_calendarDates.toIso)(e))),[c]),F=(0,_react.useCallback)(e=>null!==V&&e.getTime()<V||null!==I&&e.getTime()>I||q.has((0,_calendarDates.toIso)(e)),[V,I,q]),O=(0,_react.useMemo)(()=>{const e=new Map;for(const t of _??[]){const a=t.date;let r=e.get(a);r||(r={dots:[],spoken:[]},e.set(a,r)),r.dots.length<3&&r.dots.push({key:`${t.tone}-${r.dots.length}`,color:toneColor(j,t.tone)}),r.spoken.push(t.label??M)}return e},[_,j,M]),P=(0,_react.useMemo)(()=>(0,_calendarDates.buildMonthMatrix)(new Date(Math.floor(R/12),R%12,1),d),[R,d]),B=(0,_react.useMemo)(()=>(0,_calendarDates.weekdayLabels)(u,d),[u,d]),z=(0,_react.useMemo)(()=>new Intl.DateTimeFormat(u,{month:"long",year:"numeric"}),[u]),$=(0,_react.useMemo)(()=>new Intl.DateTimeFormat(u,{weekday:"short",day:"numeric",month:"long"}),[u]),H=z.format(L),U=null===V||(0,_calendarDates.startOfMonth)(new Date(V)).getTime()<L.getTime(),X=null===I||(0,_calendarDates.startOfMonth)(new Date(I)).getTime()>L.getTime(),Z=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,Y=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,G=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>G.current?.stop(),[]);const W=(0,_react.useCallback)(e=>{!1!==v&&(0,_index3.triggerHaptic)("impactLight");const t=j.motion.duration.fast,a=j.motion.duration.fast,[r]=S.range(32*-e,0),[i]=S.range(32*e,0),s=S.reduced?S.duration("fast"):t,n=S.reduced?S.duration("fast"):a;G.current?.stop(),G.current=_reactNative.Animated.sequence([_reactNative.Animated.parallel([_reactNative.Animated.timing(Z,{toValue:r,duration:t,easing:_reactNative.Easing.out(_reactNative.Easing.quad),useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(Y,{toValue:0,duration:s,useNativeDriver:_nativeDriver.nativeDriver})]),_reactNative.Animated.timing(Z,{toValue:i,duration:0,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.parallel([_reactNative.Animated.timing(Z,{toValue:0,duration:a,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(Y,{toValue:1,duration:n,useNativeDriver:_nativeDriver.nativeDriver})])]),G.current.start();const l=(0,_calendarDates.addMonths)(L,e);A(l),_reactNative.AccessibilityInfo.announceForAccessibility(z.format(l))},[v,L,Y,z,Z,S,A,j]),J=(0,_react.useCallback)(()=>W(-1),[W]),K=(0,_react.useCallback)(()=>W(1),[W]),pressDay=e=>{if(F(e.date))return;const t=(0,_index3.resolveHaptic)(v,"selection");t&&(0,_index3.triggerHaptic)(t);const r=e.date;"single"===a||!T||C||r.getTime()<T.getTime()?i({start:r}):i({start:T,end:r}),e.inMonth||A((0,_calendarDates.startOfMonth)(r))},Q=(0,_react.useRef)(pressDay);(0,_react.useLayoutEffect)(()=>{Q.current=pressDay});const ee=(0,_react.useCallback)(e=>Q.current(e),[]),te=void 0===m?void 0:Math.max(m,_calendarStyles.MIN_CELL_SIZE),ae=(0,_react.useMemo)(()=>void 0===te?{flex:1}:{width:te},[te]),re=(0,_react.useMemo)(()=>void 0===te?{flex:1,aspectRatio:1,minHeight:_calendarStyles.MIN_CELL_SIZE}:{width:te,height:te},[te]),ie=Math.max(j.space.sm,(_calendarStyles.MIN_CELL_SIZE-_calendarStyles.NAV_BUTTON_SIZE)/2),se=Math.min(j.settings.maxFontSizeMultiplier??1.5,1.5),ne=[];for(let e=0;e<_calendarDates.GRID_CELLS;e+=7)ne.push(P.slice(e,e+7));const le=(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",accessibilityLabel:x?`${x}, ${H}`:void 0,style:N.headerLabel,children:H});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[N.root,D],testID:b,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:N.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:J,disabled:!U,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,!U&&N.navBtnDisabled,g],accessibilityRole:"button",accessibilityLabel:f.previousMonth,accessibilityState:{disabled:!U},"aria-disabled":!U,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",style:N.navText,maxFontSizeMultiplier:se,children:"‹"})}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[N.headerLabelWrap,{opacity:Y,transform:[{translateX:Z}]},p],children:h?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:h,accessibilityRole:"button",accessibilityLabel:x?`${x}, ${H}`:H,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:le}):le}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:K,disabled:!X,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,!X&&N.navBtnDisabled,g],accessibilityRole:"button",accessibilityLabel:f.nextMonth,accessibilityState:{disabled:!X},"aria-disabled":!X,hitSlop:ie,...(0,_hitSlop.hitSlopMarker)(ie),children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",style:N.navText,maxFontSizeMultiplier:se,children:"›"})})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:N.weekdayRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:B.map(({weekday:e,label:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.weekdayCell,ae],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",style:N.weekdayText,maxFontSizeMultiplier:se,children:t})},e))}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{opacity:Y,transform:[{translateX:Z}]},children:ne.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:N.gridRow,children:e.map(e=>{const t=e.date.getTime(),r=null!==w&&t===w,i=null!==E&&t===E,s=null!==w&&null!==E&&t>=w&&t<=E,n=s&&!r&&!i,l=e.iso===k,o=O.get(e.iso),c=[$.format(e.date),...o?.spoken??[]];return l&&c.push("today"),"range"===a&&(r&&i?c.push("start and end of your range"):r?c.push("start of your range"):i?c.push("end of your range"):n&&c.push("in your range")),(0,_jsxRuntime.jsx)(_CalendarDay.CalendarDay,{cell:e,accessibilityLabel:c.join(", "),disabled:F(e.date),edge:r||i,mid:n,barLeft:s&&(i||n)&&!(r&&i),barRight:s&&(r||n)&&!(r&&i),today:l,dots:o?.dots,cellStyle:re,styles:N,maxFontSizeMultiplier:se,onPressDay:ee},e.iso)})},e.map(e=>e.iso).join(",")))})]})});Calendar.displayName="Calendar";var _default=exports.default=Calendar;