@webority/mobile-ui 0.176.0 → 0.178.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 (42) hide show
  1. package/dist/canvas-kit/kit.js +10 -10
  2. package/dist/canvas-kit/manifest.json +6 -1
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
  5. package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
  6. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  7. package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
  8. package/lib/commonjs/components/Screen/Screen.js +1 -1
  9. package/lib/commonjs/components/Toast/Toast.js +1 -1
  10. package/lib/commonjs/hooks/usePressAnimation.js +1 -1
  11. package/lib/commonjs/theme/ThemeContext.js +1 -1
  12. package/lib/commonjs/theme/merge.js +1 -1
  13. package/lib/commonjs/utils/contentPadding.js +1 -0
  14. package/lib/module/components/AppIcon/AppIcon.js +1 -1
  15. package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
  16. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  17. package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
  18. package/lib/module/components/Screen/Screen.js +1 -1
  19. package/lib/module/components/Toast/Toast.js +1 -1
  20. package/lib/module/hooks/usePressAnimation.js +1 -1
  21. package/lib/module/theme/ThemeContext.js +1 -1
  22. package/lib/module/theme/merge.js +1 -1
  23. package/lib/module/utils/contentPadding.js +1 -0
  24. package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +1 -1
  25. package/lib/typescript/commonjs/components/AuthedImage/authedImageCache.d.ts +3 -1
  26. package/lib/typescript/commonjs/components/FieldBase/Chevron.d.ts +1 -2
  27. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -1
  28. package/lib/typescript/commonjs/components/Skeleton/SkeletonClock.d.ts +4 -5
  29. package/lib/typescript/commonjs/components/Toast/Toast.d.ts +0 -2
  30. package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +1 -7
  31. package/lib/typescript/commonjs/theme/ThemeContext.d.ts +2 -0
  32. package/lib/typescript/commonjs/utils/contentPadding.d.ts +4 -0
  33. package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +1 -1
  34. package/lib/typescript/module/components/AuthedImage/authedImageCache.d.ts +3 -1
  35. package/lib/typescript/module/components/FieldBase/Chevron.d.ts +1 -2
  36. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -1
  37. package/lib/typescript/module/components/Skeleton/SkeletonClock.d.ts +4 -5
  38. package/lib/typescript/module/components/Toast/Toast.d.ts +0 -2
  39. package/lib/typescript/module/hooks/usePressAnimation.d.ts +1 -7
  40. package/lib/typescript/module/theme/ThemeContext.d.ts +2 -0
  41. package/lib/typescript/module/utils/contentPadding.d.ts +4 -0
  42. package/package.json +8 -8
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.176.0"
5
+ "version": "0.178.0"
6
6
  },
7
7
  "rendererProtocolVersion": 14,
8
8
  "platform": "Phone",
@@ -23191,6 +23191,11 @@
23191
23191
  "version": "0.172.0",
23192
23192
  "components": [],
23193
23193
  "values": {}
23194
+ },
23195
+ {
23196
+ "version": "0.177.0",
23197
+ "components": [],
23198
+ "values": {}
23194
23199
  }
23195
23200
  ]
23196
23201
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.176.0",
3
+ "version": "0.178.0",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 14,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.176.0"
9
+ "version": "0.178.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "45c172386b4bcea3f0761d346d4017950c55c22ee9b98a7b303c1c241ef3d74a",
14
- "bytes": 673889
13
+ "sha256": "b1b6fdbf3dd84820055fa1bf15888feae9f849daae49401792a07a93417438cb",
14
+ "bytes": 673973
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "3186dae6313f440e13ded0ce6d3ee741949d140c54a80a332c65c4503a1d67c5",
18
- "bytes": 5706440
17
+ "sha256": "e5e7cf22291bb7d7e009301037624a8b650c36595b6f7bdedb075a630a7b3e8e",
18
+ "bytes": 5706179
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppIcon=exports.APP_ICON_SIZES=void 0,Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _glyphsG.CURATED_ICON_NAMES}}),exports.ICONSAX_SUFFIX=void 0,Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _catalogG.ICON_NAMES}}),exports.default=exports.buildIconXml=void 0,exports.isAppIconName=isAppIconName,exports.resolveGlyph=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNativeSvg=require("react-native-svg"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_guards=require("../../utils/guards.js"),_Text=require("../Text/Text.js"),_catalogG=require("./catalog.g.js"),_glyphsG=require("./glyphs.g.js"),_jsxRuntime=require("react/jsx-runtime");const ICONSAX_SUFFIX=exports.ICONSAX_SUFFIX="-iconsax";function isAppIconName(e){return"string"==typeof e&&(!!_catalogG.ICON_NAMES.some(r=>r===e)||e.endsWith(ICONSAX_SUFFIX)&&_glyphsG.CURATED_ICON_NAMES.some(r=>r===e.slice(0,-ICONSAX_SUFFIX.length)))}const APP_ICON_SIZES=exports.APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36},tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",o=`${e}:${t}`,a=shardCache.get(o);if(void 0!==a)return a;const s=_catalogG.CATALOG_LOADERS[e]?.[t],n=s?tryRequire(s):null;return shardCache.set(o,n),n},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)},resolveGlyph=(e,r="linear")=>{if(e.endsWith(ICONSAX_SUFFIX)){const t=e.slice(0,-ICONSAX_SUFFIX.length);return t in _glyphsG.GLYPHS?resolveCatalogue(t,r):null}const t=(0,_guards.hasKey)(_glyphsG.GLYPHS,e)?_glyphsG.GLYPHS[e]:void 0;return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};exports.resolveGlyph=resolveGlyph;const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;exports.buildIconXml=buildIconXml;const iconXmlCache=new Map,AppIcon=({name:e,size:r="md",color:t,variant:o="linear",style:a,accessibilityLabel:s,testID:n})=>{const l=(0,_index.useTheme)();"string"==typeof r&&(0,_assertValidValue.assertValidValue)("AppIcon","size",r,Object.keys(APP_ICON_SIZES)),(0,_assertValidValue.assertValidValue)("AppIcon","variant",o,["linear","bold","bulk","broken","outline","twotone"]);const i="number"==typeof r?r:APP_ICON_SIZES[r]??APP_ICON_SIZES.md,c=void 0===t?l.colors["text-body"]:(0,_Text.resolveColor)(l,t),u=resolveGlyph(e,o),d=(0,_react.useMemo)(()=>{if(!u)return null;const r=`${e}|${o}|${i}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const a=buildIconXml(u,i,c);return iconXmlCache.set(r,a),a},[e,o,u,i,c]);if(!d)return __DEV__&&!warned.has(e)&&(warned.add(e),_mobileCore.Logger.warn(`[@webority/mobile-ui] AppIcon: Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run node scripts/gen-icons.mjs after adding one there.`)),null;const p=null!=s?{accessibilityLabel:s,accessibilityRole:"image"}:{};return(0,_jsxRuntime.jsx)(_reactNativeSvg.SvgXml,{xml:d,width:i,height:i,...void 0!==a?{style:a}:{},accessible:null!=s,...p,...void 0!==n?{testID:n}:{}})};exports.AppIcon=AppIcon,AppIcon.displayName="AppIcon";var _default=exports.default=AppIcon;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppIcon=exports.APP_ICON_SIZES=void 0,Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _glyphsG.CURATED_ICON_NAMES}}),exports.ICONSAX_SUFFIX=void 0,Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _catalogG.ICON_NAMES}}),exports.default=exports.buildIconXml=void 0,exports.isAppIconName=isAppIconName,exports.resolveGlyph=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNativeSvg=require("react-native-svg"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_guards=require("../../utils/guards.js"),_Text=require("../Text/Text.js"),_catalogG=require("./catalog.g.js"),_glyphsG=require("./glyphs.g.js"),_jsxRuntime=require("react/jsx-runtime");const ICONSAX_SUFFIX=exports.ICONSAX_SUFFIX="-iconsax";function isAppIconName(e){return"string"==typeof e&&(!!_catalogG.ICON_NAMES.some(r=>r===e)||e.endsWith(ICONSAX_SUFFIX)&&_glyphsG.CURATED_ICON_NAMES.some(r=>r===e.slice(0,-ICONSAX_SUFFIX.length)))}const APP_ICON_SIZES=exports.APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36},tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",o=`${e}:${t}`,a=shardCache.get(o);if(void 0!==a)return a;const s=_catalogG.CATALOG_LOADERS[e]?.[t],n=s?tryRequire(s):null;return shardCache.set(o,n),n},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)},resolveGlyph=(e,r="linear")=>{if(e.endsWith(ICONSAX_SUFFIX)){const t=e.slice(0,-ICONSAX_SUFFIX.length);return t in _glyphsG.GLYPHS?resolveCatalogue(t,r):null}const t=(0,_guards.hasKey)(_glyphsG.GLYPHS,e)?_glyphsG.GLYPHS[e]:void 0;return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};exports.resolveGlyph=resolveGlyph;const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;exports.buildIconXml=buildIconXml;const iconXmlCache=new Map,AppIcon=({name:e,size:r="md",color:t,variant:o="linear",style:a,accessibilityLabel:s,testID:n})=>{const l=(0,_index.useTheme)();"string"==typeof r&&(0,_assertValidValue.assertValidValue)("AppIcon","size",r,Object.keys(APP_ICON_SIZES)),(0,_assertValidValue.assertValidValue)("AppIcon","variant",o,["linear","bold","bulk","broken","outline","twotone"]);const i="number"==typeof r?r:APP_ICON_SIZES[r]??APP_ICON_SIZES.md,c=void 0===t?l.colors["text-body"]:(0,_Text.resolveColor)(l,t),u=resolveGlyph(e,o),d=(0,_react.useMemo)(()=>{if(!u)return null;const r=`${e}|${o}|${i}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const a=buildIconXml(u,i,c);return iconXmlCache.set(r,a),a},[e,o,u,i,c]);if(!d)return __DEV__&&!warned.has(e)&&(warned.add(e),_mobileCore.Logger.warn(`[@webority/mobile-ui] AppIcon: Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run node scripts/gen-icons.mts after adding one there.`)),null;const p=null!=s?{accessibilityLabel:s,accessibilityRole:"image"}:{};return(0,_jsxRuntime.jsx)(_reactNativeSvg.SvgXml,{xml:d,width:i,height:i,...void 0!==a?{style:a}:{},accessible:null!=s,...p,...void 0!==n?{testID:n}:{}})};exports.AppIcon=AppIcon,AppIcon.displayName="AppIcon";var _default=exports.default=AppIcon;
@@ -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"),_guards=require("../../utils/guards.js"),_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,isIndexEntry=e=>(0,_guards.isRecord)(e)&&"number"==typeof e.fetchedAt&&"number"==typeof e.bytes&&"string"==typeof e.contentType&&"number"==typeof e.lastAccessedAt&&"string"==typeof e.fileName&&"number"==typeof e.persistedAccessAt;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{const r=JSON.parse(t);if((0,_guards.isRecord)(r))for(const[t,s]of Object.entries(r))isIndexEntry(s)&&e.set(t,s)}catch(e){if(!(e instanceof SyntaxError))throw e}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,t),this.name="AuthedImageHttpError",this.status=t.status}}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(!(0,_guards.isRecord)(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=(0,_guards.isRecord)(e)&&(0,_guards.isRecord)(e.response)?e.response.status:void 0;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).`,{status:r,cause:e})}const{data:o}=a;if(null!=o&&!(o instanceof ArrayBuffer))throw new Error(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the client returned ${typeof o} instead of raw bytes. Pass a client that honours \`responseType: "arraybuffer"\`.`);const n=new Uint8Array(o??new ArrayBuffer(0));if(0===n.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.`,{status:404});const c=responseHeader(a.headers,"content-type"),l=(c?mediaTypeOf(c):"")||"image/jpeg",d=await loadIndex(),u=Date.now(),h=`${e}-${u.toString(36)}`;let m;try{m=await(0,_imageStore.writeImage)(h,n,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.`,{cause:e})}const g={fetchedAt:u,bytes:n.byteLength,contentType:l,lastAccessedAt:u,fileName:h,persistedAccessAt:u},p=d.get(e);p&&(indexBytes-=p.bytes),d.set(e,g),indexBytes+=g.bytes,p&&p.fileName!==h&&deleteFile(p.fileName);const y=evictIfNeeded(d);return schedulePersist(d),y>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${y} cached image(s) over the byte ceiling`),{fileUri:m,meta:toMeta(g)}},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:fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)})};return 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"),_guards=require("../../utils/guards.js"),_hashString=require("../../utils/hashString.js"),_imageStore=require("./imageStore");const INDEX_KEY="@webority/authed-image/v2/index",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3,DEFAULT_TTL_MS=exports.DEFAULT_TTL_MS=6048e5,isIndexEntry=e=>(0,_guards.isRecord)(e)&&"number"==typeof e.fetchedAt&&"number"==typeof e.bytes&&"string"==typeof e.contentType&&"number"==typeof e.lastAccessedAt&&"string"==typeof e.fileName&&"number"==typeof e.persistedAccessAt;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=>{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 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,t=await _mobileCore.Storage.getItem(INDEX_KEY);if(!t)return e;try{const r=JSON.parse(t);if((0,_guards.isRecord)(r))for(const[t,s]of Object.entries(r))isIndexEntry(s)&&e.set(t,s)}catch(e){if(!(e instanceof SyntaxError))throw e}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,{cause:t.cause}),this.name="AuthedImageHttpError",this.status=t.status}}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)(),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(!(0,_guards.isRecord)(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=(0,_guards.isRecord)(e)&&(0,_guards.isRecord)(e.response)?e.response.status:void 0;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).`,{status:r,cause:e})}const{data:o}=a;if(null!=o&&!(o instanceof ArrayBuffer))throw new Error(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the client returned ${typeof o} instead of raw bytes. Pass a client that honours \`responseType: "arraybuffer"\`.`);const n=new Uint8Array(o??new ArrayBuffer(0));if(0===n.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.`,{status:404});const c=responseHeader(a.headers,"content-type"),d=(c?mediaTypeOf(c):"")||"image/jpeg",l=await loadIndex(),u=Date.now(),h=`${e}-${u.toString(36)}`;let m;try{m=await(0,_imageStore.writeImage)(h,n,d)}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.`,{cause:e})}const g={fetchedAt:u,bytes:n.byteLength,contentType:d,lastAccessedAt:u,fileName:h,persistedAccessAt:u},p=l.get(e);p&&(indexBytes-=p.bytes),l.set(e,g),indexBytes+=g.bytes,p&&p.fileName!==h&&deleteFile(p.fileName);const y=evictIfNeeded(l);return schedulePersist(l),y>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${y} cached image(s) over the byte ceiling`),{fileUri:m,meta:toMeta(g)}},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:fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)})};return 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.FloatingActionButton=FloatingActionButton,exports.default=exports.FloatingActionButtonGroup=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../text/index.js"),_floatingActionButtonG=require("../../text/phone/floatingActionButton.g.js"),_index2=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,n,o=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(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((i=o&&Object.getOwnPropertyDescriptor(e,n))&&(i.get||i.set)?o(r,n,i):r[n]=e[n]);return r}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(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"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}};function FloatingActionButton({ref:e,...t}){const{icon:i,onPress:n,label:o,collapsed:r=!1,size:a="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:f,style:g,labelStyle:v,testID:h}=t;(0,_assertValidValue.assertValidValue)("FloatingActionButton","size",t.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","tone",t.tone,FAB_TONES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","position",t.position,FAB_POSITIONS);const x=!u&&!d,y=(0,_index2.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),A=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(y,a),[y,a]),j=(0,_react.useMemo)(()=>buildStyles(y),[y]),{scale:N,opacity:S,pressIn:w,pressOut:V}=(0,_usePressAnimation.usePressAnimation)({enabled:x}),I=(0,_usePresenceMotion.usePresenceMotion)(),E=y.space[y.components["floating-action-button"]["edge-offset"]],C=y.space[y.components["floating-action-button"]["bottom-offset"]],F=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,P=I.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index2.setNativeValue)(F,1);const e=_reactNative.Animated.timing(F,{toValue:_?0:1,duration:P,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[m,_,F,P,y.motion.ease["in-out"]]);const B=A.diameter+(l??C)+R.bottom+E,T=F.interpolate({inputRange:[0,1],outputRange:I.range(B,0)}),D=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(F,S),[F,S]),O="string"==typeof o&&o.length>0,k=O&&r,M=I.reduced,q=y.space.sm,z=A["label-padding-x"],L=y.motion.duration.fast,G=y.motion.ease["in-out"],H=(0,_reactNativeReanimated.useSharedValue)(k?1:0),[U,$]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=k?1:0;return H.value=M?e:(0,_reactNativeReanimated.withTiming)(e,{duration:L,easing:_reactNativeReanimated.Easing.bezier(...G)}),()=>(0,_reactNativeReanimated.cancelAnimation)(H)},[k,M,H,L,G]);const W=(0,_react.useCallback)(e=>{const t=Math.ceil(e);$(e=>e===t?e:t)},[]),Y=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:z*(1-H.value)}),[z,H]),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*H.value);return null===U?H.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(U+q)*(1-H.value)}},[H,U,q]),X=u?y.colors["surface-disabled"]:toneBackground(y,s),J=u?y.colors["text-disabled"]:toneForeground(y,s),K="lg"===a?"md":"sm",Q=d?(0,_jsxRuntime.jsx)(_index3.Spinner,{variant:"circular",size:K,color:J}):(0,_slotIcon.renderSlotIcon)(i,{color:J,size:A.icon,disabled:u}),ee=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??C)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:E};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:E}}},[c,l,R.bottom,C,E]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[ee,{transform:[{translateY:T},{scale:N}],opacity:D},g],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:e,onPress:e=>{if(!x)return;const t=(0,_hapticUtils.resolveHaptic)(f,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),n()},onPressIn:w,onPressOut:V,disabled:!x,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!x,busy:d},"aria-disabled":!x,"aria-busy":d,testID:h,style:[j.base,O?{height:A.diameter,minWidth:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners}:{width:A.diameter,height:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners},y.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&x?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[j.pressedTint,{backgroundColor:pressedTintFor(y,s),borderRadius:A.diameter/2,..._corners.smoothCorners}]}):null,O?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[j.extendedRow,Y],children:[Q,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[j.labelClip,Z],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>W(e.nativeEvent.layout.width),style:[j.label,{color:J,fontSize:A.text,fontWeight:y.weight.semibold,marginLeft:q},v],numberOfLines:1,children:o})})]}):Q]})})})}const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:i,actions:n,expanded:o,defaultExpanded:r=!1,onExpandedChange:a,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,style:b,secondaryActionStyle:f,labelPillStyle:g,labelStyle:v,testID:h}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_index.useMobileUiText)("floatingActionButton",_floatingActionButtonG.FLOATING_ACTION_BUTTON_TEXT),y=(0,_react.useMemo)(()=>({...x,...s}),[x,s]),R=d??y.quickActions,A=(0,_index2.useTheme)(),j=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(A,u),[A,u]),S=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),w=(0,_usePresenceMotion.usePresenceMotion)(),V=w.duration("default"),I=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],C=A.space[A.components["floating-action-button"]["secondary-gap"]],F=A.components["floating-action-button"]["stagger-ms"],P=(0,_react.useMemo)(()=>n.slice(0,6),[n]),B=P.length,T=(0,_react.useMemo)(()=>P.map((e,t)=>({action:e,index:t})).reverse(),[P]);n.forEach(e=>{(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const D=__DEV__?describeActionProblem(n):"";(0,_react.useEffect)(()=>{__DEV__&&D&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${D}`)},[D]);const O="boolean"==typeof o,[k,M]=(0,_react.useState)(r),q="boolean"==typeof o?o:k,z=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index2.setNativeValue)(z,1);const e=_reactNative.Animated.timing(z,{toValue:p?0:1,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[_,p,z,V,A.motion.ease["in-out"]]);const L=_&&p;(0,_react.useEffect)(()=>{L&&q&&(O||M(!1),a?.(!1))},[L,q,O,a]);const G=N.diameter+(l??E)+j.bottom+I,H=z.interpolate({inputRange:[0,1],outputRange:w.range(G,0)}),U=z,$=(0,_react.useRef)((0,_index2.createAnimatedValue)(q?1:0)).current,W=(0,_react.useRef)([]),[Y,Z]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=W.current;if(e.length!==B){if(e.length<B){const t=e.slice();for(let i=e.length;i<B;i+=1)t.push(new _reactNative.Animated.Value(q?1:0));W.current=t}else W.current=e.slice(0,B);Z(e=>e+1)}},[B,q]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});e.start();const t=W.current.map(e=>_reactNative.Animated.timing(e,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})),i=q?t:[...t].reverse(),n=_reactNative.Animated.stagger(F,i);return n.start(),()=>{e.stop(),n.stop()}},[q,$,V,A.motion.ease["in-out"],B,Y,F]);const X=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),O||M(e),a?.(e)},[O,a,m]),J=(0,_react.useRef)(null),K=(0,_react.useRef)(q),Q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(K.current===q)return;K.current=q;const e=Q.current;if(Q.current=!1,L||e)return;const t=J.current;t&&("web"===_reactNative.Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(q?(0,_index.pluralText)(y,"expanded",B,{label:R}):(0,_index.fillText)(y.collapsed,{label:R}))},[q,L,R,B,y]);const ee=(0,_react.useCallback)(()=>{X(!q)},[q,X]),te=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),Q.current=!0,e.onPress(),O||M(!1),a?.(!1)},[O,a,m]),ie=(0,_react.useCallback)(()=>{q&&X(!1)},[q,X]);(0,_react.useEffect)(()=>{if(!q)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(X(!1),!0));return()=>e.remove()},[q,X]),(0,_react.useEffect)(()=>{if(!q||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&X(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[q,X]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+j.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:I,alignItems:"flex-end"}}},[c,l,j.bottom,E,I]),slotOffset=e=>-(N.diameter+C)*(e+1),oe=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),re=.78*N.diameter,ae=(0,_react.useMemo)(()=>{const e=re+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:N.diameter/2+re/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,re,N.diameter,A.space.sm]),se=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),ce=$.interpolate(w.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:se}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:L?"none":"box-none",style:[ne,{transform:[{translateY:H}],opacity:U},b],accessibilityRole:"menu",testID:h,children:[T.map(({action:e,index:t})=>{const i=W.current[t];if(!i)return null;const n=i.interpolate({inputRange:[0,1],outputRange:w.range(0,slotOffset(t))}),o=i.interpolate({inputRange:[0,1],outputRange:w.range(.6,1)}),r=toneBackground(A,e.tone??"primary"),a=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[S.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},g],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",accessibilityElementsHidden:!q,importantForAccessibility:q?"auto":"no-hide-descendants","aria-hidden":!q,style:[S.secondaryRow,oe,{position:"absolute",bottom:0,opacity:i,transform:[{translateY:n},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>te(e),focusable:q,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[S.fabBase,A.shadow.elevated,{width:re,height:re,borderRadius:re/2,..._corners.smoothCorners,backgroundColor:r},f],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:re/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:a,size:N.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:R,accessibilityState:{expanded:q},"aria-expanded":q,style:[S.fabBase,A.shadow.popover,{width:N.diameter,height:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:i?void 0:{transform:[{rotate:ce}]},children:(0,_slotIcon.renderSlotIcon)(q&&i?i:t,{color:A.colors["on-primary"],size:N.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FloatingActionButton=FloatingActionButton,exports.default=exports.FloatingActionButtonGroup=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../text/index.js"),_floatingActionButtonG=require("../../text/phone/floatingActionButton.g.js"),_index2=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,n,o=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(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((i=o&&Object.getOwnPropertyDescriptor(e,n))&&(i.get||i.set)?o(r,n,i):r[n]=e[n]);return r}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(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"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}};function FloatingActionButton({ref:e,...t}){const{icon:i,onPress:n,label:o,collapsed:r=!1,size:a="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:f,style:g,labelStyle:v,testID:h}=t;(0,_assertValidValue.assertValidValue)("FloatingActionButton","size",t.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","tone",t.tone,FAB_TONES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","position",t.position,FAB_POSITIONS);const x=!u&&!d,y=(0,_index2.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),A=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(y,a),[y,a]),j=(0,_react.useMemo)(()=>buildStyles(y),[y]),{style:N,pressIn:S,pressOut:w}=(0,_usePressAnimation.usePressAnimation)({enabled:x}),V=(0,_usePresenceMotion.usePresenceMotion)(),I=y.space[y.components["floating-action-button"]["edge-offset"]],E=y.space[y.components["floating-action-button"]["bottom-offset"]],C=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,F=V.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index2.setNativeValue)(C,1);const e=_reactNative.Animated.timing(C,{toValue:_?0:1,duration:F,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[m,_,C,F,y.motion.ease["in-out"]]);const P=A.diameter+(l??E)+R.bottom+I,B=C.interpolate({inputRange:[0,1],outputRange:V.range(P,0)}),T=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(C,N.opacity),[C,N.opacity]),D="string"==typeof o&&o.length>0,O=D&&r,k=V.reduced,M=y.space.sm,q=A["label-padding-x"],z=y.motion.duration.fast,L=y.motion.ease["in-out"],G=(0,_reactNativeReanimated.useSharedValue)(O?1:0),[H,U]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=O?1:0;return G.value=k?e:(0,_reactNativeReanimated.withTiming)(e,{duration:z,easing:_reactNativeReanimated.Easing.bezier(...L)}),()=>(0,_reactNativeReanimated.cancelAnimation)(G)},[O,k,G,z,L]);const $=(0,_react.useCallback)(e=>{const t=Math.ceil(e);U(e=>e===t?e:t)},[]),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:q*(1-G.value)}),[q,G]),Y=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*G.value);return null===H?G.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+M)*(1-G.value)}},[G,H,M]),Z=u?y.colors["surface-disabled"]:toneBackground(y,s),X=u?y.colors["text-disabled"]:toneForeground(y,s),J="lg"===a?"md":"sm",K=d?(0,_jsxRuntime.jsx)(_index3.Spinner,{variant:"circular",size:J,color:X}):(0,_slotIcon.renderSlotIcon)(i,{color:X,size:A.icon,disabled:u}),Q=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:I}}},[c,l,R.bottom,E,I]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Q,{transform:[{translateY:B},...N.transform],opacity:T},g],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:e,onPress:e=>{if(!x)return;const t=(0,_hapticUtils.resolveHaptic)(f,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),n()},onPressIn:S,onPressOut:w,disabled:!x,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!x,busy:d},"aria-disabled":!x,"aria-busy":d,testID:h,style:[j.base,D?{height:A.diameter,minWidth:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners}:{width:A.diameter,height:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners},y.shadow.popover,{backgroundColor:Z,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&x?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[j.pressedTint,{backgroundColor:pressedTintFor(y,s),borderRadius:A.diameter/2,..._corners.smoothCorners}]}):null,D?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[j.extendedRow,W],children:[K,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[j.labelClip,Y],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>$(e.nativeEvent.layout.width),style:[j.label,{color:X,fontSize:A.text,fontWeight:y.weight.semibold,marginLeft:M},v],numberOfLines:1,children:o})})]}):K]})})})}const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:i,actions:n,expanded:o,defaultExpanded:r=!1,onExpandedChange:a,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,style:b,secondaryActionStyle:f,labelPillStyle:g,labelStyle:v,testID:h}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_index.useMobileUiText)("floatingActionButton",_floatingActionButtonG.FLOATING_ACTION_BUTTON_TEXT),y=(0,_react.useMemo)(()=>({...x,...s}),[x,s]),R=d??y.quickActions,A=(0,_index2.useTheme)(),j=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(A,u),[A,u]),S=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),w=(0,_usePresenceMotion.usePresenceMotion)(),V=w.duration("default"),I=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],C=A.space[A.components["floating-action-button"]["secondary-gap"]],F=A.components["floating-action-button"]["stagger-ms"],P=(0,_react.useMemo)(()=>n.slice(0,6),[n]),B=P.length,T=(0,_react.useMemo)(()=>P.map((e,t)=>({action:e,index:t})).reverse(),[P]);n.forEach(e=>{(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const D=__DEV__?describeActionProblem(n):"";(0,_react.useEffect)(()=>{__DEV__&&D&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${D}`)},[D]);const O="boolean"==typeof o,[k,M]=(0,_react.useState)(r),q="boolean"==typeof o?o:k,z=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index2.setNativeValue)(z,1);const e=_reactNative.Animated.timing(z,{toValue:p?0:1,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[_,p,z,V,A.motion.ease["in-out"]]);const L=_&&p;(0,_react.useEffect)(()=>{L&&q&&(O||M(!1),a?.(!1))},[L,q,O,a]);const G=N.diameter+(l??E)+j.bottom+I,H=z.interpolate({inputRange:[0,1],outputRange:w.range(G,0)}),U=z,$=(0,_react.useRef)((0,_index2.createAnimatedValue)(q?1:0)).current,W=(0,_react.useRef)([]),[Y,Z]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=W.current;if(e.length!==B){if(e.length<B){const t=e.slice();for(let i=e.length;i<B;i+=1)t.push(new _reactNative.Animated.Value(q?1:0));W.current=t}else W.current=e.slice(0,B);Z(e=>e+1)}},[B,q]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});e.start();const t=W.current.map(e=>_reactNative.Animated.timing(e,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})),i=q?t:[...t].reverse(),n=_reactNative.Animated.stagger(F,i);return n.start(),()=>{e.stop(),n.stop()}},[q,$,V,A.motion.ease["in-out"],B,Y,F]);const X=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),O||M(e),a?.(e)},[O,a,m]),J=(0,_react.useRef)(null),K=(0,_react.useRef)(q),Q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(K.current===q)return;K.current=q;const e=Q.current;if(Q.current=!1,L||e)return;const t=J.current;t&&("web"===_reactNative.Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(q?(0,_index.pluralText)(y,"expanded",B,{label:R}):(0,_index.fillText)(y.collapsed,{label:R}))},[q,L,R,B,y]);const ee=(0,_react.useCallback)(()=>{X(!q)},[q,X]),te=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),Q.current=!0,e.onPress(),O||M(!1),a?.(!1)},[O,a,m]),ie=(0,_react.useCallback)(()=>{q&&X(!1)},[q,X]);(0,_react.useEffect)(()=>{if(!q)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(X(!1),!0));return()=>e.remove()},[q,X]),(0,_react.useEffect)(()=>{if(!q||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&X(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[q,X]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+j.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:I,alignItems:"flex-end"}}},[c,l,j.bottom,E,I]),slotOffset=e=>-(N.diameter+C)*(e+1),oe=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),re=.78*N.diameter,ae=(0,_react.useMemo)(()=>{const e=re+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:N.diameter/2+re/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,re,N.diameter,A.space.sm]),se=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),ce=$.interpolate(w.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:se}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:L?"none":"box-none",style:[ne,{transform:[{translateY:H}],opacity:U},b],accessibilityRole:"menu",testID:h,children:[T.map(({action:e,index:t})=>{const i=W.current[t];if(!i)return null;const n=i.interpolate({inputRange:[0,1],outputRange:w.range(0,slotOffset(t))}),o=i.interpolate({inputRange:[0,1],outputRange:w.range(.6,1)}),r=toneBackground(A,e.tone??"primary"),a=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[S.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},g],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",accessibilityElementsHidden:!q,importantForAccessibility:q?"auto":"no-hide-descendants","aria-hidden":!q,style:[S.secondaryRow,oe,{position:"absolute",bottom:0,opacity:i,transform:[{translateY:n},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>te(e),focusable:q,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[S.fabBase,A.shadow.elevated,{width:re,height:re,borderRadius:re/2,..._corners.smoothCorners,backgroundColor:r},f],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:re/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:a,size:N.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:R,accessibilityState:{expanded:q},"aria-expanded":q,style:[S.fabBase,A.shadow.popover,{width:N.diameter,height:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:i?void 0:{transform:[{rotate:ce}]},children:(0,_slotIcon.renderSlotIcon)(q&&i?i:t,{color:A.colors["on-primary"],size:N.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KeyboardAwareScrollView=KeyboardAwareScrollView,exports.default=void 0;var _reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_index=require("../../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const tapAreaStyle={flexGrow:1},CHILD_LAYOUT_KEYS=["gap","rowGap","columnGap","flexDirection","flexWrap","alignItems","alignContent","justifyContent"],childLayout=e=>{const r=_reactNative.StyleSheet.flatten(e),t={};for(const e of CHILD_LAYOUT_KEYS)void 0!==r?.[e]&&Object.assign(t,{[e]:r[e]});return t};function KeyboardAwareScrollView({ref:e,...r}){const{children:t,bottomOffset:o=24,extraKeyboardSpace:a=0,safeAreaEdges:i=["bottom"],refreshing:n=!1,onRefresh:s,dismissOnTapOutside:l=!0,contentContainerStyle:d,refreshControl:c,...u}=r,f=(0,_index.useTheme)(),y=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),b=i.includes("bottom"),p={paddingBottom:b?y.bottom:0,...i.includes("top")?{paddingTop:y.top}:null,...i.includes("left")?{paddingLeft:y.left}:null,...i.includes("right")?{paddingRight:y.right}:null},x=c??(s?(0,_jsxRuntime.jsx)(_reactNative.RefreshControl,{refreshing:n,onRefresh:s,tintColor:f.colors.primary,colors:[f.colors.primary],progressBackgroundColor:f.colors.surface,titleColor:f.colors["text-muted"]}):void 0);return(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardAwareScrollView,{ref:e,bottomOffset:o,extraKeyboardSpace:a-(b?y.bottom:0),disableScrollOnKeyboardHide:!0,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"none",contentContainerStyle:[d,p],refreshControl:x,...u,children:l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessible:!1,onPress:_reactNative.Keyboard.dismiss,style:[tapAreaStyle,childLayout(d)],children:t}):t})}var _default=exports.default=KeyboardAwareScrollView;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KeyboardAwareScrollView=KeyboardAwareScrollView,exports.default=void 0;var _reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_index=require("../../theme/index.js"),_contentPadding=require("../../utils/contentPadding.js"),_jsxRuntime=require("react/jsx-runtime");const tapAreaStyle={flexGrow:1},CHILD_LAYOUT_KEYS=["gap","rowGap","columnGap","flexDirection","flexWrap","alignItems","alignContent","justifyContent"],childLayout=e=>{const t=_reactNative.StyleSheet.flatten(e),r={};for(const e of CHILD_LAYOUT_KEYS)void 0!==t?.[e]&&Object.assign(r,{[e]:t[e]});return r};function KeyboardAwareScrollView({ref:e,...t}){const{children:r,bottomOffset:o=24,extraKeyboardSpace:a=0,safeAreaEdges:n=["bottom"],refreshing:i=!1,onRefresh:s,dismissOnTapOutside:l=!0,contentContainerStyle:d,refreshControl:c,...u}=t,f=(0,_index.useTheme)(),b=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),y=n.includes("bottom"),p={paddingBottom:(0,_contentPadding.bottomPaddingOf)(d)+(y?b.bottom:0),...n.includes("top")?{paddingTop:b.top}:null,...n.includes("left")?{paddingLeft:b.left}:null,...n.includes("right")?{paddingRight:b.right}:null},x=c??(s?(0,_jsxRuntime.jsx)(_reactNative.RefreshControl,{refreshing:i,onRefresh:s,tintColor:f.colors.primary,colors:[f.colors.primary],progressBackgroundColor:f.colors.surface,titleColor:f.colors["text-muted"]}):void 0);return(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardAwareScrollView,{ref:e,bottomOffset:o,extraKeyboardSpace:a-(y?b.bottom:0),disableScrollOnKeyboardHide:!0,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"none",contentContainerStyle:[d,p],refreshControl:x,...u,children:l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessible:!1,onPress:_reactNative.Keyboard.dismiss,style:[tapAreaStyle,childLayout(d)],children:r}):r})}var _default=exports.default=KeyboardAwareScrollView;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Screen=Screen;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=require("react-native-reanimated"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useRefreshControl=require("../../hooks/useRefreshControl.js"),_index=require("../../theme/index.js"),_index2=require("../AppBar/index.js"),_index3=require("../KeyboardAwareScrollView/index.js"),_index4=require("../KeyboardToolbar/index.js"),_index5=require("../PagedList/index.js"),_ScrollHost=require("./ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{},topPaddingOf=e=>{const t=_reactNative.StyleSheet.flatten(e),r=t?.paddingTop??t?.paddingVertical??t?.padding;return"number"==typeof r?r:0},buildStyles=e=>_reactNative.StyleSheet.create({flex:{flex:1},root:{flex:1,backgroundColor:e.colors.bg},overlay:{position:"absolute",top:0,left:0,right:0},headerRaised:{zIndex:1},footer:{backgroundColor:e.colors.bg,borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:e.colors.border}});function Screen(e){const{title:t,subtitle:r,largeTitle:o=!0,headerShadowOnScroll:a,onBack:n,rightActions:i,leading:l,trailing:s,children:c,onRefresh:d,refreshing:u=!1,footer:f,scroll:_=!0,list:v,edges:p=DEFAULT_EDGES,keyboardToolbar:g=!0,bottomInset:h=0,gutter:x,floatingAction:m,scrollRef:S,onScroll:b,contentContainerStyle:y,testID:R}=e,C=(0,_index.useTheme)(),j=x??void 0===v,T=C.space[C.components.screen.gutter],E=j?T:0,N=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),L=(0,_react.useMemo)(()=>buildStyles(C),[C]),[O]=(0,_react.useState)(()=>new _reactNative.Animated.Value(0)),[V,k]=(0,_react.useState)(0),[w,A]=(0,_react.useState)(0),q=void 0!==n,B=(0,_react.useRef)(n);B.current=n;const H=Boolean(t||r||n||l||s||i?.length),D=o&&void 0!==t,M=D&&(void 0!==v||_),z=M?V:0,I=H&&!M&&(a??C.settings.components.screen?.headerShadowOnScroll??!0),[K,P]=(0,_react.useState)(!1),F=(0,_react.useRef)(I);F.current=I;const headerGap=e=>e>0?e:H?C.space.lg:0,W=void 0!==f,{refreshControl:G}=(0,_useRefreshControl.useRefreshControl)({onRefresh:d??noop,refreshing:u}),U=d?(0,_react.cloneElement)(G,{progressViewOffset:z}):void 0,Y=(0,_reactNativeReanimated.useSharedValue)(0),$=(0,_reactNativeReanimated.useSharedValue)(0),J=(0,_reactNativeReanimated.useSharedValue)(0),Q=(0,_reactNativeReanimated.useSharedValue)(0),X=(0,_react.useRef)(null),Z=(0,_react.useRef)(0),ee=(0,_react.useRef)(0),te=(0,_react.useMemo)(()=>({top:Y,bottom:$,offset:J,maxOffset:Q,scrollTo:e=>{const t=X.current;t instanceof _reactNative.FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[Y,$,J,Q]),re=(0,_react.useCallback)(e=>{X.current=e,"function"==typeof S?S(e):S&&(S.current=e)},[S]),oe=(0,_react.useCallback)(()=>{Q.value=Math.max(0,Z.current-ee.current)},[Q]),ae=(0,_react.useRef)(b);ae.current=b;const ne=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{y:O}}}],{useNativeDriver:!1,listener:e=>{if(J.value=e.nativeEvent.contentOffset.y,F.current){const t=e.nativeEvent.contentOffset.y>0;P(e=>e===t?e:t)}ae.current?.(e)}}),[O,J]),ie=(0,_react.useCallback)(e=>{const{height:t}=e.nativeEvent.layout;k(e=>Math.max(e,t))},[]),le=(0,_react.useCallback)(e=>{A(e.nativeEvent.layout.height)},[]);(0,_react.useEffect)(()=>{if(!q)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(B.current?.(),!0));return()=>e.remove()},[q]);const se=p.includes("left")?N.left:0,ce=p.includes("right")?N.right:0,de=p.includes("bottom")?N.bottom:0,ue=p.includes("top")&&!H?N.top:0,fe=C.space[C.components["floating-action-button"]["bottom-offset"]],ve=m?.props.bottomOffset??fe,pe=m?(0,_index.resolveFloatingActionButtonSize)(C,m.props.size??"md").diameter+ve+C.space.lg:0,ge=W?Math.max(0,w-N.bottom):h,he=m?(0,_react.cloneElement)(m,{bottomOffset:ve+ge,position:m.props.position??"bottomRight"}):null,xe=W?pe:Math.max(de,m?pe+N.bottom:0),me=h+xe-(W?0:de),Se=p.filter(e=>"top"!==e&&!("bottom"===e&&W)),be=H?(0,_jsxRuntime.jsx)(_reactNative.View,{style:M?L.overlay:I?L.headerRaised:void 0,onLayout:M?ie:void 0,children:(0,_jsxRuntime.jsx)(_index2.AppBar,{title:t,subtitle:r,variant:D?"large":"default",scrollY:M?O:void 0,elevated:I&&K,onBack:n,rightActions:i,leading:l,trailing:s,gutter:T,testID:R?`${R}-app-bar`:void 0})}):null,ye=(0,_react.useCallback)(()=>{const e=X.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,r,o)=>{ee.current=o,Y.value=t+z,$.value=t+o,oe()})},[z,Y,$,oe]);(0,_react.useEffect)(()=>{ye()},[ye]);const Re=(0,_react.useCallback)((e,t)=>{Z.current=t,oe()},[oe]);let Ce;if(void 0!==v){const e=topPaddingOf([v.contentContainerStyle,y]);Ce=(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext,{value:te,children:(0,_jsxRuntime.jsx)(_index5.PagedList,{...v,ref:re,onRefresh:v.state?void 0:d,refreshing:v.state?void 0:u,progressViewOffset:z,placeholderStyle:[L.flex,{paddingTop:z+headerGap(e)}],onScroll:ne,onLayout:e=>{ye(),v.onLayout?.(e)},onContentSizeChange:(e,t)=>{Re(e,t),v.onContentSizeChange?.(e,t)},scrollEventThrottle:SCROLL_EVENT_THROTTLE,style:L.flex,contentContainerStyle:[{paddingTop:z,paddingLeft:se+E,paddingRight:ce+E},{paddingBottom:h+xe},v.contentContainerStyle,y,{paddingTop:z+headerGap(e)}]})})}else Ce=_?(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext,{value:te,children:(0,_jsxRuntime.jsxs)(_index3.KeyboardAwareScrollView,{ref:re,refreshControl:U,onScroll:ne,scrollEventThrottle:SCROLL_EVENT_THROTTLE,onLayout:ye,onContentSizeChange:Re,safeAreaEdges:Se,style:L.flex,contentContainerStyle:[{paddingHorizontal:E},y,{paddingTop:z+headerGap(topPaddingOf(y))}],children:[c,me>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:me}}):null]})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.flex,{paddingLeft:se+E,paddingRight:ce+E,paddingBottom:h+xe},y],children:c});const je=W?(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardStickyView,{onLayout:le,style:[L.footer,{paddingLeft:se+T,paddingRight:ce+T,paddingBottom:de+h}],children:f}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:R,style:[L.root,{paddingTop:ue}],children:[M?null:be,Ce,je,he,void 0!==v?c:null,M?be:null,g?(0,_jsxRuntime.jsx)(_index4.KeyboardToolbar,{}):null]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Screen=Screen;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=require("react-native-reanimated"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useRefreshControl=require("../../hooks/useRefreshControl.js"),_index=require("../../theme/index.js"),_contentPadding=require("../../utils/contentPadding.js"),_index2=require("../AppBar/index.js"),_index3=require("../KeyboardAwareScrollView/index.js"),_index4=require("../KeyboardToolbar/index.js"),_index5=require("../PagedList/index.js"),_ScrollHost=require("./ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{},buildStyles=e=>_reactNative.StyleSheet.create({flex:{flex:1},root:{flex:1,backgroundColor:e.colors.bg},overlay:{position:"absolute",top:0,left:0,right:0},headerRaised:{zIndex:1},footer:{backgroundColor:e.colors.bg,borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:e.colors.border}});function Screen(e){const{title:t,subtitle:o,largeTitle:r=!0,headerShadowOnScroll:n,onBack:a,rightActions:i,leading:l,trailing:s,children:c,onRefresh:d,refreshing:u=!1,footer:f,scroll:_=!0,list:g,edges:v=DEFAULT_EDGES,keyboardToolbar:h=!0,bottomInset:p=0,gutter:x,floatingAction:m,scrollRef:S,onScroll:b,contentContainerStyle:R,testID:y}=e,C=(0,_index.useTheme)(),j=x??void 0===g,T=C.space[C.components.screen.gutter],E=j?T:0,N=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),L=(0,_react.useMemo)(()=>buildStyles(C),[C]),[O]=(0,_react.useState)(()=>new _reactNative.Animated.Value(0)),[V,k]=(0,_react.useState)(0),[w,A]=(0,_react.useState)(0),q=void 0!==a,P=(0,_react.useRef)(a);P.current=a;const B=Boolean(t||o||a||l||s||i?.length),H=r&&void 0!==t,D=H&&(void 0!==g||_),M=D?V:0,z=B&&!D&&(n??C.settings.components.screen?.headerShadowOnScroll??!0),[I,K]=(0,_react.useState)(!1),F=(0,_react.useRef)(z);F.current=z;const headerGap=e=>e>0?e:B?C.space.lg:0,W=void 0!==f,{refreshControl:G}=(0,_useRefreshControl.useRefreshControl)({onRefresh:d??noop,refreshing:u}),U=d?(0,_react.cloneElement)(G,{progressViewOffset:M}):void 0,Y=(0,_reactNativeReanimated.useSharedValue)(0),$=(0,_reactNativeReanimated.useSharedValue)(0),J=(0,_reactNativeReanimated.useSharedValue)(0),Q=(0,_reactNativeReanimated.useSharedValue)(0),X=(0,_react.useRef)(null),Z=(0,_react.useRef)(0),ee=(0,_react.useRef)(0),te=(0,_react.useMemo)(()=>({top:Y,bottom:$,offset:J,maxOffset:Q,scrollTo:e=>{const t=X.current;t instanceof _reactNative.FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[Y,$,J,Q]),oe=(0,_react.useCallback)(e=>{X.current=e,"function"==typeof S?S(e):S&&(S.current=e)},[S]),re=(0,_react.useCallback)(()=>{Q.value=Math.max(0,Z.current-ee.current)},[Q]),ne=(0,_react.useRef)(b);ne.current=b;const ae=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{y:O}}}],{useNativeDriver:!1,listener:e=>{if(J.value=e.nativeEvent.contentOffset.y,F.current){const t=e.nativeEvent.contentOffset.y>0;K(e=>e===t?e:t)}ne.current?.(e)}}),[O,J]),ie=(0,_react.useCallback)(e=>{const{height:t}=e.nativeEvent.layout;k(e=>Math.max(e,t))},[]),le=(0,_react.useCallback)(e=>{A(e.nativeEvent.layout.height)},[]);(0,_react.useEffect)(()=>{if(!q)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(P.current?.(),!0));return()=>e.remove()},[q]);const se=v.includes("left")?N.left:0,ce=v.includes("right")?N.right:0,de=v.includes("bottom")?N.bottom:0,ue=v.includes("top")&&!B?N.top:0,fe=C.space[C.components["floating-action-button"]["bottom-offset"]],ge=m?.props.bottomOffset??fe,ve=m?(0,_index.resolveFloatingActionButtonSize)(C,m.props.size??"md").diameter+ge+C.space.lg:0,he=W?Math.max(0,w-N.bottom):p,pe=m?(0,_react.cloneElement)(m,{bottomOffset:ge+he,position:m.props.position??"bottomRight"}):null,xe=W?ve:Math.max(de,m?ve+N.bottom:0),me=p+xe-(W?0:de),Se=v.filter(e=>"top"!==e&&!("bottom"===e&&W)),be=B?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D?L.overlay:z?L.headerRaised:void 0,onLayout:D?ie:void 0,children:(0,_jsxRuntime.jsx)(_index2.AppBar,{title:t,subtitle:o,variant:H?"large":"default",scrollY:D?O:void 0,elevated:z&&I,onBack:a,rightActions:i,leading:l,trailing:s,gutter:T,testID:y?`${y}-app-bar`:void 0})}):null,Re=(0,_react.useCallback)(()=>{const e=X.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,o,r)=>{ee.current=r,Y.value=t+M,$.value=t+r,re()})},[M,Y,$,re]);(0,_react.useEffect)(()=>{Re()},[Re]);const ye=(0,_react.useCallback)((e,t)=>{Z.current=t,re()},[re]);let Ce;if(void 0!==g){const e=(0,_contentPadding.topPaddingOf)([g.contentContainerStyle,R]);Ce=(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext,{value:te,children:(0,_jsxRuntime.jsx)(_index5.PagedList,{...g,ref:oe,onRefresh:g.state?void 0:d,refreshing:g.state?void 0:u,progressViewOffset:M,placeholderStyle:[L.flex,{paddingTop:M+headerGap(e)}],onScroll:ae,onLayout:e=>{Re(),g.onLayout?.(e)},onContentSizeChange:(e,t)=>{ye(e,t),g.onContentSizeChange?.(e,t)},scrollEventThrottle:SCROLL_EVENT_THROTTLE,style:L.flex,contentContainerStyle:[{paddingTop:M,paddingLeft:se+E,paddingRight:ce+E},g.contentContainerStyle,R,{paddingTop:M+headerGap(e),paddingBottom:(0,_contentPadding.bottomPaddingOf)([g.contentContainerStyle,R])+p+xe}]})})}else Ce=_?(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext,{value:te,children:(0,_jsxRuntime.jsxs)(_index3.KeyboardAwareScrollView,{ref:oe,refreshControl:U,onScroll:ae,scrollEventThrottle:SCROLL_EVENT_THROTTLE,onLayout:Re,onContentSizeChange:ye,safeAreaEdges:Se,style:L.flex,contentContainerStyle:[{paddingHorizontal:E},R,{paddingTop:M+headerGap((0,_contentPadding.topPaddingOf)(R))}],children:[c,me>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:me}}):null]})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.flex,{paddingLeft:se+E,paddingRight:ce+E},R,{paddingBottom:(0,_contentPadding.bottomPaddingOf)(R)+p+xe}],children:c});const je=W?(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardStickyView,{onLayout:le,style:[L.footer,{paddingLeft:se+T,paddingRight:ce+T,paddingBottom:de+p}],children:f}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:y,style:[L.root,{paddingTop:ue}],children:[D?null:be,Ce,je,pe,void 0!==g?c:null,D?be:null,h?(0,_jsxRuntime.jsx)(_index4.KeyboardToolbar,{}):null]})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Toast=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_toastG=require("../../text/phone/toast.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SWIPE_DISMISS_THRESHOLD=80,SWIPE_VELOCITY_THRESHOLD=.5,STACK_OFFSET=8,STACK_SCALE_STEP=.04,DEFAULT_AUTO_DISMISS_MS=3e3,WEB_ACTION_MIN_DURATION_MS=8e3,COUNTDOWN_BAR_HEIGHT=3,ACTION_HIT_SLOP={top:10,bottom:10,left:10,right:10},Toast=({toast:e,index:t,onClose:i,shownAt:a,runtime:r})=>{const n=(0,_index2.useTheme)(),s=(0,_usePresenceMotion.usePresenceMotion)(),o=s.duration("fast");(0,_assertValidValue.assertValidValue)("Toast","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Toast","position",e.position,["top","bottom"]);const c=e.tone??"neutral",u=e.position??"bottom",l=(0,_index.useMobileUiText)("toast",_toastG.TOAST_TEXT),d=r?.labels,m=(0,_react.useMemo)(()=>d??l,[d,l]),v=(0,_react.useMemo)(()=>[{name:"dismiss",label:m.dismiss}],[m]),_=(0,_react.useMemo)(()=>buildStyles(n),[n]),p=(0,_react.useMemo)(()=>tintFor(n,c),[n,c]),g=(0,_react.useMemo)(()=>inkFor(n,c),[n,c]),x=n.components.toast["icon-circle-size"],h=n.text[n.components.toast["icon-glyph-text"]].size,f=n.components.toast["tint-bar-width"],b=n.settings.components.toast?.defaultDurationMs??3e3,N=n.settings.components.toast?.enableSwipeDismiss??!0,D="top"===u?-120:120,y=(0,_react.useRef)((0,_index2.createAnimatedValue)(s.reduced?0:D)).current,A=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,w=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,M=(0,_react.useRef)(!1),T="top"===u?8*t:8*-t,V=Math.max(1-.04*t,.9),R=(0,_react.useRef)((0,_index2.createAnimatedValue)(T)).current;(0,_react.useEffect)(()=>{(0,_index2.setNativeValue)(R,T)},[T,R]);const S=(0,_react.useMemo)(()=>_reactNative.Animated.add(y,R),[y,R]),j=void 0!==e.action,C=e.duration??b,E=C>0&&j&&"web"===_reactNative.Platform.OS?Math.max(C,8e3):C,P=E<=0||j&&!0===r?.screenReaderOn,O=!0===e.countdown&&!P,I=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,k=(0,_react.useRef)({initialised:!1,timer:null,remaining:0,startedAt:0}),L=(0,_react.useRef)({touch:!1,pan:!1,hover:!1}),H=(0,_react.useRef)(()=>{}),q=(0,_react.useRef)({id:e.id,totalMs:E,shownAt:a,runtime:r,persistent:P,animateBar:!1});q.current={id:e.id,totalMs:E,shownAt:a,runtime:r,persistent:P,animateBar:O&&!s.reduced};const B=(0,_react.useCallback)(()=>{const e=k.current,t=q.current,i=L.current;if(!e.initialised){e.initialised=!0;const i=t.runtime?.readRemaining(t.id),a=void 0===t.shownAt?0:Date.now()-t.shownAt;e.remaining=i??(t.totalMs>0?Math.max(t.totalMs-a,0):0),t.totalMs>0&&e.remaining<t.totalMs&&(0,_index2.setNativeValue)(I,e.remaining/t.totalMs)}const a=!(t.persistent||M.current||i.touch||i.pan||i.hover);a&&null===e.timer?(e.startedAt=Date.now(),e.timer=setTimeout(()=>{e.timer=null,e.remaining=0,H.current()},e.remaining),t.animateBar&&_reactNative.Animated.timing(I,{toValue:0,duration:e.remaining,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}).start()):a||null===e.timer||(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0),I.stopAnimation())},[I]),dismiss=()=>{if(M.current)return;M.current=!0,B();const t=[_reactNative.Animated.timing(w,{toValue:0,duration:o,easing:_reactNative.Easing.bezier(...n.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver})];s.reduced||t.push(_reactNative.Animated.timing(y,{toValue:D,duration:n.motion.duration.fast,easing:_reactNative.Easing.bezier(...n.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver})),_reactNative.Animated.parallel(t).start(()=>i(e.id))};H.current=dismiss;const F=(0,_react.useRef)({reduced:s.reduced,fadeMs:o});F.current={reduced:s.reduced,fadeMs:o},(0,_react.useEffect)(()=>{const e=F.current,t=e.reduced?_reactNative.Animated.timing(w,{toValue:1,duration:e.fadeMs,useNativeDriver:_nativeDriver.nativeDriver}):_reactNative.Animated.parallel([_reactNative.Animated.spring(y,{toValue:0,damping:18,stiffness:180,mass:1,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(w,{toValue:1,duration:e.fadeMs,useNativeDriver:_nativeDriver.nativeDriver})]);return t.start(),()=>t.stop()},[w,y]),(0,_react.useEffect)(()=>{B()},[P,B]),(0,_react.useEffect)(()=>()=>{const e=k.current,t=q.current;null!==e.timer&&(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0)),I.stopAnimation(),e.initialised&&t.totalMs>0&&!M.current&&t.runtime?.writeRemaining(t.id,e.remaining)},[I]);const G=(0,_react.useCallback)((e,t)=>{L.current[e]=t,B()},[B]),z=(0,_react.useCallback)(()=>G("touch",!0),[G]),$=(0,_react.useCallback)(e=>G("touch",(e.nativeEvent.touches?.length??0)>0),[G]),U=(0,_react.useCallback)(()=>G("hover",!0),[G]),W=(0,_react.useCallback)(()=>G("hover",!1),[G]),X=(0,_react.useMemo)(()=>_reactNative.PanResponder.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>Math.abs(t.dy)&&Math.abs(t.dx)>6,onPanResponderGrant:()=>G("pan",!0),onPanResponderMove:(e,t)=>{(0,_index2.setNativeValue)(A,t.dx);const i=1-.7*Math.min(Math.abs(t.dx)/200,1);(0,_index2.setNativeValue)(w,i)},onPanResponderTerminate:()=>{if(G("pan",!1),s.reduced)return(0,_index2.setNativeValue)(A,0),void _reactNative.Animated.timing(w,{toValue:1,duration:o,useNativeDriver:_nativeDriver.nativeDriver}).start();_reactNative.Animated.parallel([_reactNative.Animated.spring(A,{toValue:0,damping:n.motion.spring.snappy.damping,stiffness:n.motion.spring.snappy.stiffness,mass:n.motion.spring.snappy.mass,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(w,{toValue:1,duration:o,useNativeDriver:_nativeDriver.nativeDriver})]).start()},onPanResponderRelease:(t,a)=>{if(Math.abs(a.dx)>80||Math.abs(a.vx)>.5){const t=a.dx>=0?1:-1;M.current=!0,G("pan",!1);const r=[_reactNative.Animated.timing(w,{toValue:0,duration:o,useNativeDriver:_nativeDriver.nativeDriver})];s.reduced||r.push(_reactNative.Animated.timing(A,{toValue:500*t,duration:n.motion.duration.fast,useNativeDriver:_nativeDriver.nativeDriver})),_reactNative.Animated.parallel(r).start(()=>i(e.id))}else G("pan",!1),s.reduced?((0,_index2.setNativeValue)(A,0),_reactNative.Animated.timing(w,{toValue:1,duration:o,useNativeDriver:_nativeDriver.nativeDriver}).start()):_reactNative.Animated.parallel([_reactNative.Animated.spring(A,{toValue:0,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.spring(w,{toValue:1,useNativeDriver:_nativeDriver.nativeDriver})]).start()}}),[A,w,G,o,s.reduced,n.motion.duration.fast,n.motion.spring.snappy.damping,n.motion.spring.snappy.stiffness,n.motion.spring.snappy.mass,i,e.id]),K={accessibilityActions:v,onAccessibilityAction:e=>{"dismiss"===e.nativeEvent.actionName&&dismiss()}},[Y,J]=(0,_react.useState)(0),Q=(0,_react.useMemo)(()=>I.interpolate({inputRange:[0,1],outputRange:[-Y,0]}),[I,Y]),Z=e.description?`${e.message}. ${e.description}`:e.message,ee=e.action&&O?`${e.action.label}, ${(0,_index.fillText)(m.seconds,{count:Math.ceil(E/1e3)})}`:e.action?.label;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{...N?X.panHandlers:{},...j?{}:{accessible:!0,...K},..."web"===_reactNative.Platform.OS?{onPointerEnter:U,onPointerLeave:W}:{},onTouchStart:z,onTouchEnd:$,onTouchCancel:$,accessibilityLabel:Z,testID:e.testID,style:[_.container,{backgroundColor:n.colors.surface,borderRadius:n.radius.lg,..._corners.smoothCorners,padding:n.space.md,...n.shadow.elevated,opacity:w,transform:[{translateY:S},{translateX:A},{scale:V}]},e.style],children:[f>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_.tintBar,{width:f,backgroundColor:p}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.row,children:[(()=>{if(e.icon)return e.icon;const t=defaultGlyph(c);return t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_.iconCircle,{width:x,height:x,borderRadius:n.radius.pill,..._corners.smoothCorners,backgroundColor:`${p}22`},e.iconCircleStyle],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[_.iconGlyph,{color:g,fontSize:h}],accessible:!1,children:t})}):null})(),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.textBlock,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",weight:"semibold",style:[e.textStyle,e.messageStyle],numberOfLines:2,children:e.message}),e.description?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:_.description,numberOfLines:3,children:e.description}):null]}),e.action?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:ee,hitSlop:ACTION_HIT_SLOP,...(0,_hitSlop.hitSlopMarker)(ACTION_HIT_SLOP),...K,onPress:()=>{e.action?.onPress(),dismiss()},style:({pressed:t})=>[_.actionBtn,{backgroundColor:t?n.colors["surface-pressed"]:"transparent"},e.actionButtonStyle],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:{color:p},numberOfLines:1,children:e.action.label})}):null]}),O?(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",onLayout:e=>J(e.nativeEvent.layout.width),testID:"toast-countdown",style:[_.countdownTrack,{backgroundColor:`${p}22`}],children:[s.reduced?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_.countdownFill,{backgroundColor:p}]}):null,!s.reduced&&Y>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[_.countdownFill,{backgroundColor:p,transform:[{translateX:Q}]}]}):null]}):null]})};exports.Toast=Toast;const tintFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"danger":return e.colors.danger;case"warning":return e.colors.warning;case"info":return e.colors.info;case"neutral":return e.colors["text-body"]}},inkFor=(e,t)=>{switch(t){case"primary":return e.colors["primary-text"];case"success":return e.colors["success-text"];case"danger":return e.colors["danger-text"];case"warning":return e.colors["warning-text"];case"info":return e.colors["info-text"];case"neutral":return e.colors["text-body"]}},defaultGlyph=e=>{switch(e){case"success":return"✓";case"danger":return"×";case"warning":return"!";case"info":return"i";case"primary":case"neutral":return""}},buildStyles=e=>_reactNative.StyleSheet.create({container:{overflow:"hidden",marginVertical:e.space.xs},tintBar:{position:"absolute",left:0,top:0,bottom:0},row:{flexDirection:"row",alignItems:"center",paddingLeft:e.space.sm},iconCircle:{alignItems:"center",justifyContent:"center",marginRight:e.space.md},iconGlyph:{fontWeight:"700",lineHeight:Math.round(e.text[e.components.toast["icon-glyph-text"]].size*e.leading.heading)},textBlock:{flex:1,paddingRight:e.space.sm},description:{marginTop:e.space.xxs},countdownTrack:{position:"absolute",left:0,right:0,bottom:0,height:3,overflow:"hidden"},countdownFill:{position:"absolute",left:0,right:0,top:0,bottom:0},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,minHeight:e.components.toast["action-min-height"],borderRadius:e.radius.md,..._corners.smoothCorners,marginLeft:e.space.sm}});var _default=exports.default=Toast;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Toast=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_toastG=require("../../text/phone/toast.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SWIPE_DISMISS_THRESHOLD=80,SWIPE_VELOCITY_THRESHOLD=.5,STACK_OFFSET=8,STACK_SCALE_STEP=.04,DEFAULT_AUTO_DISMISS_MS=3e3,WEB_ACTION_MIN_DURATION_MS=8e3,COUNTDOWN_BAR_HEIGHT=3,ACTION_HIT_SLOP={top:10,bottom:10,left:10,right:10},Toast=({toast:e,index:t,onClose:i,shownAt:a,runtime:r})=>{const n=(0,_index2.useTheme)(),s=(0,_usePresenceMotion.usePresenceMotion)(),o=s.duration("fast");(0,_assertValidValue.assertValidValue)("Toast","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Toast","position",e.position,["top","bottom"]);const c=e.tone??"neutral",u=e.position??"bottom",l=(0,_index.useMobileUiText)("toast",_toastG.TOAST_TEXT),d=r?.labels,m=(0,_react.useMemo)(()=>d??l,[d,l]),v=(0,_react.useMemo)(()=>[{name:"dismiss",label:m.dismiss}],[m]),_=(0,_react.useMemo)(()=>buildStyles(n),[n]),p=(0,_react.useMemo)(()=>tintFor(n,c),[n,c]),g=(0,_react.useMemo)(()=>inkFor(n,c),[n,c]),x=n.components.toast["icon-circle-size"],h=n.text[n.components.toast["icon-glyph-text"]].size,f=n.components.toast["tint-bar-width"],b=n.settings.components.toast?.defaultDurationMs??3e3,N=n.settings.components.toast?.enableSwipeDismiss??!0,D="top"===u?-120:120,y=(0,_react.useRef)((0,_index2.createAnimatedValue)(s.reduced?0:D)).current,A=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,w=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,M=(0,_react.useRef)(!1),T="top"===u?8*t:8*-t,V=Math.max(1-.04*t,.9),R=(0,_react.useRef)((0,_index2.createAnimatedValue)(T)).current;(0,_react.useEffect)(()=>{(0,_index2.setNativeValue)(R,T)},[T,R]);const S=(0,_react.useMemo)(()=>_reactNative.Animated.add(y,R),[y,R]),j=void 0!==e.action,C=e.duration??b,E=C>0&&j&&"web"===_reactNative.Platform.OS?Math.max(C,8e3):C,P=E<=0||j&&!0===r?.screenReaderOn,O=!0===e.countdown&&!P,I=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,k=(0,_react.useRef)({initialised:!1,timer:null,remaining:0,startedAt:0}),L=(0,_react.useRef)({touch:!1,pan:!1,hover:!1}),H=(0,_react.useRef)(()=>{}),q=(0,_react.useRef)({id:e.id,totalMs:E,shownAt:a,runtime:r,persistent:P,animateBar:!1});q.current={id:e.id,totalMs:E,shownAt:a,runtime:r,persistent:P,animateBar:O&&!s.reduced};const B=(0,_react.useCallback)(()=>{const e=k.current,t=q.current,i=L.current;if(!e.initialised){e.initialised=!0;const i=t.runtime?.readRemaining(t.id),a=void 0===t.shownAt?0:Date.now()-t.shownAt;e.remaining=i??(t.totalMs>0?Math.max(t.totalMs-a,0):0),t.totalMs>0&&e.remaining<t.totalMs&&(0,_index2.setNativeValue)(I,e.remaining/t.totalMs)}const a=!(t.persistent||M.current||i.touch||i.pan||i.hover);a&&null===e.timer?(e.startedAt=Date.now(),e.timer=setTimeout(()=>{e.timer=null,e.remaining=0,H.current()},e.remaining),t.animateBar&&_reactNative.Animated.timing(I,{toValue:0,duration:e.remaining,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}).start()):a||null===e.timer||(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0),I.stopAnimation())},[I]),dismiss=()=>{if(M.current)return;M.current=!0,B();const t=[_reactNative.Animated.timing(w,{toValue:0,duration:o,easing:_reactNative.Easing.bezier(...n.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver})];s.reduced||t.push(_reactNative.Animated.timing(y,{toValue:D,duration:n.motion.duration.fast,easing:_reactNative.Easing.bezier(...n.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver})),_reactNative.Animated.parallel(t).start(()=>i(e.id))};H.current=dismiss;const F=(0,_react.useRef)({reduced:s.reduced,fadeMs:o});F.current={reduced:s.reduced,fadeMs:o},(0,_react.useEffect)(()=>{const e=F.current,t=e.reduced?_reactNative.Animated.timing(w,{toValue:1,duration:e.fadeMs,useNativeDriver:_nativeDriver.nativeDriver}):_reactNative.Animated.parallel([_reactNative.Animated.spring(y,{toValue:0,damping:18,stiffness:180,mass:1,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(w,{toValue:1,duration:e.fadeMs,useNativeDriver:_nativeDriver.nativeDriver})]);return t.start(),()=>t.stop()},[w,y]),(0,_react.useEffect)(()=>{B()},[P,B]),(0,_react.useEffect)(()=>()=>{const e=k.current,t=q.current;null!==e.timer&&(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0)),I.stopAnimation(),e.initialised&&t.totalMs>0&&!M.current&&t.runtime?.writeRemaining(t.id,e.remaining)},[I]);const G=(0,_react.useCallback)((e,t)=>{L.current[e]=t,B()},[B]),z=(0,_react.useCallback)(()=>G("touch",!0),[G]),$=(0,_react.useCallback)(e=>G("touch",(e.nativeEvent.touches?.length??0)>0),[G]),U=(0,_react.useCallback)(()=>G("hover",!0),[G]),W=(0,_react.useCallback)(()=>G("hover",!1),[G]),X=(0,_react.useMemo)(()=>_reactNative.PanResponder.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>Math.abs(t.dy)&&Math.abs(t.dx)>6,onPanResponderGrant:()=>G("pan",!0),onPanResponderMove:(e,t)=>{(0,_index2.setNativeValue)(A,t.dx);const i=1-.7*Math.min(Math.abs(t.dx)/200,1);(0,_index2.setNativeValue)(w,i)},onPanResponderTerminate:()=>{if(G("pan",!1),s.reduced)return(0,_index2.setNativeValue)(A,0),void _reactNative.Animated.timing(w,{toValue:1,duration:o,useNativeDriver:_nativeDriver.nativeDriver}).start();_reactNative.Animated.parallel([_reactNative.Animated.spring(A,{toValue:0,damping:n.motion.spring.snappy.damping,stiffness:n.motion.spring.snappy.stiffness,mass:n.motion.spring.snappy.mass,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(w,{toValue:1,duration:o,useNativeDriver:_nativeDriver.nativeDriver})]).start()},onPanResponderRelease:(t,a)=>{if(Math.abs(a.dx)>80||Math.abs(a.vx)>.5){const t=a.dx>=0?1:-1;M.current=!0,G("pan",!1);const r=[_reactNative.Animated.timing(w,{toValue:0,duration:o,useNativeDriver:_nativeDriver.nativeDriver})];s.reduced||r.push(_reactNative.Animated.timing(A,{toValue:500*t,duration:n.motion.duration.fast,useNativeDriver:_nativeDriver.nativeDriver})),_reactNative.Animated.parallel(r).start(()=>i(e.id))}else G("pan",!1),s.reduced?((0,_index2.setNativeValue)(A,0),_reactNative.Animated.timing(w,{toValue:1,duration:o,useNativeDriver:_nativeDriver.nativeDriver}).start()):_reactNative.Animated.parallel([_reactNative.Animated.spring(A,{toValue:0,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.spring(w,{toValue:1,useNativeDriver:_nativeDriver.nativeDriver})]).start()}}),[A,w,G,o,s.reduced,n.motion.duration.fast,n.motion.spring.snappy.damping,n.motion.spring.snappy.stiffness,n.motion.spring.snappy.mass,i,e.id]),K={accessibilityActions:v,onAccessibilityAction:e=>{"dismiss"===e.nativeEvent.actionName&&dismiss()}},[Y,J]=(0,_react.useState)(0),Q=(0,_react.useMemo)(()=>I.interpolate({inputRange:[0,1],outputRange:[-Y,0]}),[I,Y]),Z=e.description?`${e.message}. ${e.description}`:e.message,ee=e.action&&O?`${e.action.label}, ${(0,_index.fillText)(m.seconds,{count:Math.ceil(E/1e3)})}`:e.action?.label;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{...N?X.panHandlers:{},...j?{}:{accessible:!0,...K},..."web"===_reactNative.Platform.OS?{onPointerEnter:U,onPointerLeave:W}:{},onTouchStart:z,onTouchEnd:$,onTouchCancel:$,accessibilityLabel:Z,testID:e.testID,style:[_.container,{backgroundColor:n.colors.surface,borderRadius:n.radius.lg,..._corners.smoothCorners,padding:n.space.md,...n.shadow.elevated,opacity:w,transform:[{translateY:S},{translateX:A},{scale:V}]},e.style],children:[f>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_.tintBar,{width:f,backgroundColor:p}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.row,children:[(()=>{if(e.icon)return e.icon;const t=defaultGlyph(c);return t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_.iconCircle,{width:x,height:x,borderRadius:n.radius.pill,..._corners.smoothCorners,backgroundColor:`${p}22`},e.iconCircleStyle],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[_.iconGlyph,{color:g,fontSize:h}],accessible:!1,children:t})}):null})(),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.textBlock,children:[(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",weight:"semibold",style:e.textStyle,numberOfLines:2,children:e.message}),e.description?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:_.description,numberOfLines:3,children:e.description}):null]}),e.action?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:ee,hitSlop:ACTION_HIT_SLOP,...(0,_hitSlop.hitSlopMarker)(ACTION_HIT_SLOP),...K,onPress:()=>{e.action?.onPress(),dismiss()},style:({pressed:t})=>[_.actionBtn,{backgroundColor:t?n.colors["surface-pressed"]:"transparent"},e.actionButtonStyle],children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:{color:p},numberOfLines:1,children:e.action.label})}):null]}),O?(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",onLayout:e=>J(e.nativeEvent.layout.width),testID:"toast-countdown",style:[_.countdownTrack,{backgroundColor:`${p}22`}],children:[s.reduced?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_.countdownFill,{backgroundColor:p}]}):null,!s.reduced&&Y>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[_.countdownFill,{backgroundColor:p,transform:[{translateX:Q}]}]}):null]}):null]})};exports.Toast=Toast;const tintFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"danger":return e.colors.danger;case"warning":return e.colors.warning;case"info":return e.colors.info;case"neutral":return e.colors["text-body"]}},inkFor=(e,t)=>{switch(t){case"primary":return e.colors["primary-text"];case"success":return e.colors["success-text"];case"danger":return e.colors["danger-text"];case"warning":return e.colors["warning-text"];case"info":return e.colors["info-text"];case"neutral":return e.colors["text-body"]}},defaultGlyph=e=>{switch(e){case"success":return"✓";case"danger":return"×";case"warning":return"!";case"info":return"i";case"primary":case"neutral":return""}},buildStyles=e=>_reactNative.StyleSheet.create({container:{overflow:"hidden",marginVertical:e.space.xs},tintBar:{position:"absolute",left:0,top:0,bottom:0},row:{flexDirection:"row",alignItems:"center",paddingLeft:e.space.sm},iconCircle:{alignItems:"center",justifyContent:"center",marginRight:e.space.md},iconGlyph:{fontWeight:"700",lineHeight:Math.round(e.text[e.components.toast["icon-glyph-text"]].size*e.leading.heading)},textBlock:{flex:1,paddingRight:e.space.sm},description:{marginTop:e.space.xxs},countdownTrack:{position:"absolute",left:0,right:0,bottom:0,height:3,overflow:"hidden"},countdownFill:{position:"absolute",left:0,right:0,top:0,bottom:0},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,minHeight:e.components.toast["action-min-height"],borderRadius:e.radius.md,..._corners.smoothCorners,marginLeft:e.space.sm}});var _default=exports.default=Toast;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.usePressAnimation=exports.PRESS_ANIMATION_PRESETS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../theme/index.js"),_animatedValue=require("../theme/animatedValue.js"),_nativeDriver=require("../utils/nativeDriver.js"),_usePresenceMotion=require("./usePresenceMotion.js");const PRESS_ANIMATION_PRESETS=exports.PRESS_ANIMATION_PRESETS=["scale","bounce","fade","sink","pulse","dim"],FADE_TO=.6,DIM_TO=.7,SINK_BY=2,PULSE_TO=1.05,DEFAULT_SCALE_TO={scale:.97,bounce:.92,fade:1,sink:1,pulse:1,dim:1},usePressAnimation=({preset:e="scale",scaleTo:a,pressDuration:t,enabled:s=!0}={})=>{const i=(0,_index.useTheme)(),r=(0,_usePresenceMotion.usePresenceMotion)(),n=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(1)).current,c=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(1)).current,u=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,o=r.reduced?"dim"===e?"dim":"fade":e,_=a??DEFAULT_SCALE_TO[o],l=t??r.duration("fast"),m=(0,_react.useCallback)((e,a,t)=>_reactNative.Animated.timing(e,{toValue:a,duration:l,easing:_reactNative.Easing.bezier(...t),useNativeDriver:_nativeDriver.nativeDriver}),[l]),d=(0,_react.useCallback)((e,a,t)=>_reactNative.Animated.spring(e,{toValue:a,damping:i.motion.spring[t].damping,stiffness:i.motion.spring[t].stiffness,mass:i.motion.spring[t].mass,useNativeDriver:_nativeDriver.nativeDriver}),[i]),v=(0,_react.useCallback)(()=>{if(s)switch(o){case"scale":case"bounce":m(n,_,i.motion.ease["in-out"]).start();break;case"fade":m(c,.6,i.motion.ease["in-out"]).start();break;case"dim":(0,_index.setNativeValue)(c,.7);break;case"sink":m(u,2,i.motion.ease["in-out"]).start()}},[s,o,_,n,c,u,i,m]),p=(0,_react.useCallback)(()=>{if(s)switch(o){case"scale":d(n,1,"snappy").start();break;case"bounce":d(n,1,"bouncy").start();break;case"fade":m(c,1,i.motion.ease.decelerate).start();break;case"dim":(0,_index.setNativeValue)(c,1);break;case"sink":d(u,0,"snappy").start()}},[s,o,n,c,u,i,m,d]),A=(0,_react.useCallback)(()=>{s&&"pulse"===o&&_reactNative.Animated.sequence([_reactNative.Animated.timing(n,{toValue:1.05,duration:i.motion.duration.instant,easing:_reactNative.Easing.bezier(...i.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver}),d(n,1,"snappy")]).start()},[s,o,n,i,d]),b=(0,_react.useMemo)(()=>({transform:[{scale:n},{translateY:u}],opacity:c}),[n,u,c]);return{scale:n,opacity:c,translateY:u,style:b,pressIn:v,pressOut:p,press:A}};exports.usePressAnimation=usePressAnimation;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.usePressAnimation=exports.PRESS_ANIMATION_PRESETS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../theme/index.js"),_animatedValue=require("../theme/animatedValue.js"),_nativeDriver=require("../utils/nativeDriver.js"),_usePresenceMotion=require("./usePresenceMotion.js");const PRESS_ANIMATION_PRESETS=exports.PRESS_ANIMATION_PRESETS=["scale","bounce","fade","sink","pulse","dim"],FADE_TO=.6,DIM_TO=.7,SINK_BY=2,PULSE_TO=1.05,DEFAULT_SCALE_TO={scale:.97,bounce:.92,fade:1,sink:1,pulse:1,dim:1},usePressAnimation=({preset:e="scale",scaleTo:a,pressDuration:t,enabled:s=!0}={})=>{const i=(0,_index.useTheme)(),r=(0,_usePresenceMotion.usePresenceMotion)(),n=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(1)).current,c=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(1)).current,u=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,o=r.reduced?"dim"===e?"dim":"fade":e,_=a??DEFAULT_SCALE_TO[o],m=t??r.duration("fast"),d=(0,_react.useCallback)((e,a,t)=>_reactNative.Animated.timing(e,{toValue:a,duration:m,easing:_reactNative.Easing.bezier(...t),useNativeDriver:_nativeDriver.nativeDriver}),[m]),l=(0,_react.useCallback)((e,a,t)=>_reactNative.Animated.spring(e,{toValue:a,damping:i.motion.spring[t].damping,stiffness:i.motion.spring[t].stiffness,mass:i.motion.spring[t].mass,useNativeDriver:_nativeDriver.nativeDriver}),[i]),v=(0,_react.useCallback)(()=>{if(s)switch(o){case"scale":case"bounce":d(n,_,i.motion.ease["in-out"]).start();break;case"fade":d(c,.6,i.motion.ease["in-out"]).start();break;case"dim":(0,_index.setNativeValue)(c,.7);break;case"sink":d(u,2,i.motion.ease["in-out"]).start()}},[s,o,_,n,c,u,i,d]),p=(0,_react.useCallback)(()=>{if(s)switch(o){case"scale":l(n,1,"snappy").start();break;case"bounce":l(n,1,"bouncy").start();break;case"fade":d(c,1,i.motion.ease.decelerate).start();break;case"dim":(0,_index.setNativeValue)(c,1);break;case"sink":l(u,0,"snappy").start()}},[s,o,n,c,u,i,d,l]),A=(0,_react.useCallback)(()=>{s&&"pulse"===o&&_reactNative.Animated.sequence([_reactNative.Animated.timing(n,{toValue:1.05,duration:i.motion.duration.instant,easing:_reactNative.Easing.bezier(...i.motion.ease.accelerate),useNativeDriver:_nativeDriver.nativeDriver}),l(n,1,"snappy")]).start()},[s,o,n,i,l]);return{style:(0,_react.useMemo)(()=>({transform:[{scale:n},{translateY:u}],opacity:c}),[n,u,c]),pressIn:v,pressOut:p,press:A}};exports.usePressAnimation=usePressAnimation;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useThemeMode=exports.useTheme=exports.ThemeProvider=exports.KitThemeBridge=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_useReducedMotion=require("../hooks/useReducedMotion.js"),_guards=require("../utils/guards.js"),_merge=require("./merge.js"),_tokens=require("./tokens.js"),_jsxRuntime=require("react/jsx-runtime");const REDUCED_SPRING={damping:100,stiffness:1e3,mass:1},collapseMotion=e=>({...e,duration:{instant:0,fast:0,default:0,slow:0,slower:0},spring:{gentle:REDUCED_SPRING,bouncy:REDUCED_SPRING,snappy:REDUCED_SPRING}}),isPreference=e=>"light"===e||"dark"===e||"system"===e,COLOR_MODES=["light","dark"],colorModeOf=e=>(0,_guards.isOneOf)(COLOR_MODES,e)?e:"light",defaultValue={theme:_tokens.lightTheme,mode:"light",preference:"system",setPreference:()=>{},toggleColorMode:()=>{}},ThemeContext=(0,_react.createContext)(defaultValue),ThemeProvider=e=>{const{children:r,initialPreference:t="system",persistKey:o,brand:s,settings:n,...i}=e;if(Object.keys(i).length>0)throw new Error("ThemeProvider takes only these props: children, initialPreference, persistKey, brand, settings (mobile-ui 0.89.0). Run webority upgrade 0.89.0 to move an app.");const[c,a]=(0,_react.useState)(t),d=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(!o)return;let e=!0;return _mobileCore.Storage.getItem(o).then(r=>{e&&!d.current&&isPreference(r)&&a(r)}),()=>{e=!1}},[o]);const m=(0,_react.useCallback)(e=>{d.current=!0,a(e)},[]);(0,_react.useEffect)(()=>{o&&d.current&&_mobileCore.Storage.setItem(o,c)},[o,c]);const[u,l]=(0,_react.useState)(()=>colorModeOf(_reactNative.Appearance.getColorScheme()));(0,_react.useEffect)(()=>{const e=_reactNative.Appearance.addChangeListener(({colorScheme:e})=>{l(colorModeOf(e))});return()=>e.remove()},[]);const h="system"===c?u:c,g=(0,_useReducedMotion.useReducedMotion)(),_=(0,_react.useMemo)(()=>{const e="dark"===h?_tokens.darkTheme:_tokens.lightTheme,r=s||n?(0,_merge.mergeBrand)(e,s,n):e;return g?{...r,motion:collapseMotion(r.motion)}:r},[h,s,n,g]),f=(0,_react.useMemo)(()=>({theme:_,mode:h,preference:c,setPreference:m,toggleColorMode:()=>m(e=>"system"===e?"dark"===u?"light":"dark":"dark"===e?"light":"dark")}),[_,h,c,u,m]);return(0,_jsxRuntime.jsx)(ThemeContext,{value:f,children:r})};exports.ThemeProvider=ThemeProvider;const KitThemeBridge=({mode:e,brand:r,children:t})=>{const o=(0,_useReducedMotion.useReducedMotion)();if("light"!==e&&"dark"!==e)throw new Error('KitThemeBridge takes mode "light" or "dark".');const s=(0,_react.useMemo)(()=>{const t="dark"===e?_tokens.darkTheme:_tokens.lightTheme,s=r?(0,_merge.mergeBrand)(t,r,void 0):t;return o?{...s,motion:collapseMotion(s.motion)}:s},[e,r,o]),n=(0,_react.useMemo)(()=>({theme:s,mode:e,preference:e,setPreference:()=>{},toggleColorMode:()=>{}}),[s,e]);return(0,_jsxRuntime.jsx)(ThemeContext,{value:n,children:t})};exports.KitThemeBridge=KitThemeBridge;const useTheme=()=>(0,_react.useContext)(ThemeContext).theme;exports.useTheme=useTheme;const useThemeMode=()=>{const e=(0,_react.useContext)(ThemeContext);return{mode:e.mode,preference:e.preference,setPreference:e.setPreference,toggleColorMode:e.toggleColorMode}};exports.useThemeMode=useThemeMode;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useThemeMode=exports.useTheme=exports.ThemeProvider=exports.KitThemeBridge=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_useReducedMotion=require("../hooks/useReducedMotion.js"),_assertValidValue=require("../utils/assertValidValue.js"),_guards=require("../utils/guards.js"),_merge=require("./merge.js"),_tokens=require("./tokens.js"),_jsxRuntime=require("react/jsx-runtime");const REDUCED_SPRING={damping:100,stiffness:1e3,mass:1},collapseMotion=e=>({...e,duration:{instant:0,fast:0,default:0,slow:0,slower:0},spring:{gentle:REDUCED_SPRING,bouncy:REDUCED_SPRING,snappy:REDUCED_SPRING}}),isPreference=e=>"light"===e||"dark"===e||"system"===e,COLOR_MODES=["light","dark"],colorModeOf=e=>(0,_guards.isOneOf)(COLOR_MODES,e)?e:"light",fixedModeError=e=>new Error(`ThemeProvider: the colour mode is fixed to ${e} by the mode prop`),defaultValue={theme:_tokens.lightTheme,mode:"light",preference:"system",setPreference:()=>{},toggleColorMode:()=>{}},ThemeContext=(0,_react.createContext)(defaultValue),ThemeProvider=e=>{const{children:r,mode:t,initialPreference:o="system",persistKey:s,brand:i,settings:n,...d}=e;if(Object.keys(d).length>0)throw new Error("ThemeProvider takes only these props: children, mode, initialPreference, persistKey, brand, settings.");if((0,_assertValidValue.assertValidValue)("ThemeProvider","mode",t,COLOR_MODES),void 0!==t&&(void 0!==s||void 0!==e.initialPreference))throw new Error("ThemeProvider: mode fixes the colour mode, so persistKey and initialPreference cannot be passed with it");const[a,c]=(0,_react.useState)(o),m=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(!s||void 0!==t)return;let e=!0;return _mobileCore.Storage.getItem(s).then(r=>{e&&!m.current&&isPreference(r)&&c(r)}),()=>{e=!1}},[s,t]);const u=(0,_react.useCallback)(e=>{if(void 0!==t)throw fixedModeError(t);m.current=!0,c(e)},[t]);(0,_react.useEffect)(()=>{s&&m.current&&_mobileCore.Storage.setItem(s,a)},[s,a]);const[l,h]=(0,_react.useState)(()=>colorModeOf(_reactNative.Appearance.getColorScheme()));(0,_react.useEffect)(()=>{if(void 0!==t)return;const e=_reactNative.Appearance.addChangeListener(({colorScheme:e})=>{h(colorModeOf(e))});return()=>e.remove()},[t]);const _=t??("system"===a?l:a),f=(0,_useReducedMotion.useReducedMotion)(),g=(0,_react.useMemo)(()=>{const e="dark"===_?_tokens.darkTheme:_tokens.lightTheme,r=i||n?(0,_merge.mergeBrand)(e,i,n):e;return f?{...r,motion:collapseMotion(r.motion)}:r},[_,i,n,f]),p=(0,_react.useMemo)(()=>({theme:g,mode:_,preference:t??a,setPreference:u,toggleColorMode:()=>{if(void 0!==t)throw fixedModeError(t);u(e=>"system"===e?"dark"===l?"light":"dark":"dark"===e?"light":"dark")}}),[g,_,a,l,u,t]);return(0,_jsxRuntime.jsx)(ThemeContext,{value:p,children:r})};exports.ThemeProvider=ThemeProvider;const KitThemeBridge=({mode:e,brand:r,children:t})=>{const o=(0,_useReducedMotion.useReducedMotion)();if("light"!==e&&"dark"!==e)throw new Error('KitThemeBridge takes mode "light" or "dark".');const s=(0,_react.useMemo)(()=>{const t="dark"===e?_tokens.darkTheme:_tokens.lightTheme,s=r?(0,_merge.mergeBrand)(t,r,void 0):t;return o?{...s,motion:collapseMotion(s.motion)}:s},[e,r,o]),i=(0,_react.useMemo)(()=>({theme:s,mode:e,preference:e,setPreference:()=>{},toggleColorMode:()=>{}}),[s,e]);return(0,_jsxRuntime.jsx)(ThemeContext,{value:i,children:t})};exports.KitThemeBridge=KitThemeBridge;const useTheme=()=>(0,_react.useContext)(ThemeContext).theme;exports.useTheme=useTheme;const useThemeMode=()=>{const e=(0,_react.useContext)(ThemeContext);return{mode:e.mode,preference:e.preference,setPreference:e.setPreference,toggleColorMode:e.toggleColorMode}};exports.useThemeMode=useThemeMode;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeBrand=void 0;var _guards=require("../utils/guards.js"),_componentSizes=require("./componentSizes.js"),_tokensGenerated=require("./tokens.generated.js"),_toneInk=require("./toneInk.js");const HINT="Run webority upgrade to rename old names.",BRAND_KEYS=["colors","descriptions","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0,headerShadowOnScroll:!0}},isPlainObject=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),validateBrand=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`A brand is an object of colors, radius and font; got ${typeof e}. ${HINT}`);for(const o of Object.keys(e))if(!BRAND_KEYS.includes(o))throw new Error(`A brand sets colors, descriptions, radius and font only; ${o} is not allowed (allowed: colors, descriptions, radius, font). ${HINT}`);const o=e.descriptions;if(void 0!==o){if(!isPlainObject(o))throw new Error(`A brand's descriptions is an object of colour names to a description; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o)){const t=o[e];if("string"!=typeof t||""===t)throw new Error(`description of colour ${e} must be a non-empty string.`)}}const t=e.colors;if(void 0!==t&&!isPlainObject(t))throw new Error(`A brand's colors is an object of light and dark; got ${typeof t}. ${HINT}`);if((0,_guards.isRecord)(t))for(const e of Object.keys(t)){if(!COLOR_MODES.includes(e))throw new Error(`A brand sets colours under light and dark only; ${e} is not allowed (allowed: light, dark). ${HINT}`);const r=t[e];if(void 0===r)throw new Error(`A brand's ${e} colours are missing. ${HINT}`);if(!(0,_guards.isRecord)(r))throw new Error(`A brand's ${e} colours is an object of colour names; got ${typeof r}. ${HINT}`);for(const e of Object.keys(r)){const t=(0,_guards.isRecord)(o)&&"string"==typeof o[e];if(!(0,_guards.isOneOf)(_tokensGenerated.COLOR_NAMES,e)&&!t)throw new Error(`unknown colour ${e}; allowed: ${_tokensGenerated.COLOR_NAMES.join(", ")}. ${HINT}`);if(void 0!==r[e]&&"string"!=typeof r[e])throw new Error(`colour ${e} must be a string; got ${typeof r[e]}.`)}}const r=e.radius;if(void 0!==r){if(!isPlainObject(r))throw new Error(`A brand's radius is an object of radius names; got ${typeof r}. ${HINT}`);for(const e of Object.keys(r)){const o=r[e];if(!(0,_guards.isOneOf)(_tokensGenerated.RADIUS_NAMES,e))throw new Error(`unknown radius ${e}; allowed: ${RADIUS_ALLOWED}. ${HINT}`);if(FIXED_RADII.includes(e))throw new Error(`radius ${e} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof o||!Number.isFinite(o))throw new Error(`radius ${e} must be a number; got ${typeof o}.`)}}const n=e.font;if(void 0!==n){if(!isPlainObject(n))throw new Error(`A brand's font is an object of font names; got ${typeof n}. ${HINT}`);for(const e of Object.keys(n)){if(!(0,_guards.isOneOf)(_tokensGenerated.FONT_NAMES,e))throw new Error(`unknown font ${e}; allowed: ${_tokensGenerated.FONT_NAMES.join(", ")}. ${HINT}`);const o=n[e];if(!isPlainObject(o))throw new Error(`font ${e} must be an object of weights; got ${typeof o}. ${HINT}`);for(const t of Object.keys(o)){if(!(0,_guards.isOneOf)(_tokensGenerated.WEIGHT_NAMES,t))throw new Error(`unknown font weight ${t} in font ${e}; allowed: ${_tokensGenerated.WEIGHT_NAMES.join(", ")}. ${HINT}`);const r=o[t];if("string"!=typeof r||0===r.length)throw new Error(`font ${e} weight ${t} must be a non-empty string.`)}}}},validateSettings=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`Theme settings is an object; got ${typeof e}. ${HINT}`);for(const o of Object.keys(e))if(!(0,_guards.isOneOf)(SETTINGS_KEYS,o))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${o} is not allowed. ${HINT}`);const o=e.components;if(void 0!==o){if(!isPlainObject(o))throw new Error(`Theme settings components is an object of component names; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o)){if(!(0,_guards.hasKey)(COMPONENT_SETTING_KEYS,e))throw new Error(`unknown component ${e} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}. ${HINT}`);const t=o[e];if(void 0===t)continue;if(!isPlainObject(t))throw new Error(`theme settings for ${e} is an object; got ${typeof t}. ${HINT}`);const r=COMPONENT_SETTING_KEYS[e];for(const o of Object.keys(t))if(!(o in r))throw new Error(`unknown setting ${o} for ${e}; allowed: ${Object.keys(r).join(", ")}. ${HINT}`)}}},TONES=["primary","success","warning","danger","info"],setComponentSettings=(e,o,t)=>{e[o]=t},mergeComponentSettings=(e,o,t)=>({...(0,_guards.hasKey)(e,t)?e[t]:void 0,...void 0!==o&&(0,_guards.hasKey)(o,t)?o[t]:void 0}),mergeBrand=(e,o,t)=>{validateBrand(o),validateSettings(t);const r={};for(const[t,n]of Object.entries(o?.colors?.[e.mode]??{}))void 0!==n&&(r[t]=n);const n={...e.colors,...r},colorOf=e=>{const o=n[e];if(void 0===o)throw new Error(`The theme has no colour ${e}.`);return o},s={...e.radius,...o?.radius},i={...e.font};if(void 0!==o?.font)for(const t of(0,_guards.keysOf)(o.font))i[t]={...e.font[t],...o.font[t]};const a=[colorOf("bg"),colorOf("bg-subtle"),colorOf("bg-muted")],d={};for(const o of TONES){const t="string"==typeof r[o];let n=colorOf(o);if(t||"string"==typeof r[`on-${o}`]){const e=(0,_toneInk.deriveSolidFill)(n,colorOf(`on-${o}`));e!==n&&(d[o]=e,n=e)}if(t&&"string"!=typeof r[`${o}-text`]&&(d[`${o}-text`]=(0,_toneInk.deriveToneInk)(n,a,e.mode)),"primary"===o&&(t||void 0!==d.primary)){const o=(0,_toneInk.deriveStateFills)(n,colorOf("on-primary"),{fill:e.colors.primary,hover:e.colors["primary-hover"],pressed:e.colors["primary-pressed"]});"string"!=typeof r["primary-hover"]&&(d["primary-hover"]=o.hover),"string"!=typeof r["primary-pressed"]&&(d["primary-pressed"]=o.pressed)}}const f=e.settings.components,c=t?.components,l={},u=new Set([...(0,_guards.keysOf)(f),...void 0===c?[]:(0,_guards.keysOf)(c)]);for(const e of u)setComponentSettings(l,e,mergeComponentSettings(f,c,e));const g=t?.maxFontSizeMultiplier??e.settings.maxFontSizeMultiplier,p={icons:{...e.settings.icons,...t?.icons},gradients:{...e.settings.gradients,...t?.gradients},textVariants:{...e.settings.textVariants,...t?.textVariants},components:l,...void 0===g?{}:{maxFontSizeMultiplier:g}},w={...e.colors,...Object.fromEntries(Object.entries(r).filter(([e])=>!(0,_guards.isOneOf)(_tokensGenerated.COLOR_NAMES,e))),...Object.fromEntries(_tokensGenerated.COLOR_NAMES.map(e=>[e,d[e]??colorOf(e)]))},m={...e,colors:w,radius:s,font:i,settings:p};return(0,_componentSizes.validateComponentTokens)(m),m};exports.mergeBrand=mergeBrand;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mergeBrand=void 0;var _guards=require("../utils/guards.js"),_componentSizes=require("./componentSizes.js"),_tokensGenerated=require("./tokens.generated.js"),_toneInk=require("./toneInk.js");const BRAND_KEYS=["colors","descriptions","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0,headerShadowOnScroll:!0}},isPlainObject=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),validateBrand=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`A brand is an object of colors, radius and font; got ${typeof e}.`);for(const o of Object.keys(e))if(!BRAND_KEYS.includes(o))throw new Error(`A brand sets colors, descriptions, radius and font only; ${o} is not allowed (allowed: colors, descriptions, radius, font).`);const o=e.descriptions;if(void 0!==o){if(!isPlainObject(o))throw new Error(`A brand's descriptions is an object of colour names to a description; got ${typeof o}.`);for(const e of Object.keys(o)){const t=o[e];if("string"!=typeof t||""===t)throw new Error(`description of colour ${e} must be a non-empty string.`)}}const t=e.colors;if(void 0!==t&&!isPlainObject(t))throw new Error(`A brand's colors is an object of light and dark; got ${typeof t}.`);if((0,_guards.isRecord)(t))for(const e of Object.keys(t)){if(!COLOR_MODES.includes(e))throw new Error(`A brand sets colours under light and dark only; ${e} is not allowed (allowed: light, dark).`);const r=t[e];if(void 0===r)throw new Error(`A brand's ${e} colours are missing.`);if(!(0,_guards.isRecord)(r))throw new Error(`A brand's ${e} colours is an object of colour names; got ${typeof r}.`);for(const e of Object.keys(r)){const t=(0,_guards.isRecord)(o)&&"string"==typeof o[e];if(!(0,_guards.isOneOf)(_tokensGenerated.COLOR_NAMES,e)&&!t)throw new Error(`unknown colour ${e}; allowed: ${_tokensGenerated.COLOR_NAMES.join(", ")}.`);if(void 0!==r[e]&&"string"!=typeof r[e])throw new Error(`colour ${e} must be a string; got ${typeof r[e]}.`)}}const r=e.radius;if(void 0!==r){if(!isPlainObject(r))throw new Error(`A brand's radius is an object of radius names; got ${typeof r}.`);for(const e of Object.keys(r)){const o=r[e];if(!(0,_guards.isOneOf)(_tokensGenerated.RADIUS_NAMES,e))throw new Error(`unknown radius ${e}; allowed: ${RADIUS_ALLOWED}.`);if(FIXED_RADII.includes(e))throw new Error(`radius ${e} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof o||!Number.isFinite(o))throw new Error(`radius ${e} must be a number; got ${typeof o}.`)}}const n=e.font;if(void 0!==n){if(!isPlainObject(n))throw new Error(`A brand's font is an object of font names; got ${typeof n}.`);for(const e of Object.keys(n)){if(!(0,_guards.isOneOf)(_tokensGenerated.FONT_NAMES,e))throw new Error(`unknown font ${e}; allowed: ${_tokensGenerated.FONT_NAMES.join(", ")}.`);const o=n[e];if(!isPlainObject(o))throw new Error(`font ${e} must be an object of weights; got ${typeof o}.`);for(const t of Object.keys(o)){if(!(0,_guards.isOneOf)(_tokensGenerated.WEIGHT_NAMES,t))throw new Error(`unknown font weight ${t} in font ${e}; allowed: ${_tokensGenerated.WEIGHT_NAMES.join(", ")}.`);const r=o[t];if("string"!=typeof r||0===r.length)throw new Error(`font ${e} weight ${t} must be a non-empty string.`)}}}},validateSettings=e=>{if(void 0===e)return;if(!isPlainObject(e))throw new Error(`Theme settings is an object; got ${typeof e}.`);for(const o of Object.keys(e))if(!(0,_guards.isOneOf)(SETTINGS_KEYS,o))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${o} is not allowed.`);const o=e.components;if(void 0!==o){if(!isPlainObject(o))throw new Error(`Theme settings components is an object of component names; got ${typeof o}.`);for(const e of Object.keys(o)){if(!(0,_guards.hasKey)(COMPONENT_SETTING_KEYS,e))throw new Error(`unknown component ${e} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}.`);const t=o[e];if(void 0===t)continue;if(!isPlainObject(t))throw new Error(`theme settings for ${e} is an object; got ${typeof t}.`);const r=COMPONENT_SETTING_KEYS[e];for(const o of Object.keys(t))if(!(o in r))throw new Error(`unknown setting ${o} for ${e}; allowed: ${Object.keys(r).join(", ")}.`)}}},TONES=["primary","success","warning","danger","info"],setComponentSettings=(e,o,t)=>{e[o]=t},mergeComponentSettings=(e,o,t)=>({...(0,_guards.hasKey)(e,t)?e[t]:void 0,...void 0!==o&&(0,_guards.hasKey)(o,t)?o[t]:void 0}),mergeBrand=(e,o,t)=>{validateBrand(o),validateSettings(t);const r={};for(const[t,n]of Object.entries(o?.colors?.[e.mode]??{}))void 0!==n&&(r[t]=n);const n={...e.colors,...r},colorOf=e=>{const o=n[e];if(void 0===o)throw new Error(`The theme has no colour ${e}.`);return o},s={...e.radius,...o?.radius},i={...e.font};if(void 0!==o?.font)for(const t of(0,_guards.keysOf)(o.font))i[t]={...e.font[t],...o.font[t]};const a=[colorOf("bg"),colorOf("bg-subtle"),colorOf("bg-muted")],d={};for(const o of TONES){const t="string"==typeof r[o];let n=colorOf(o);if(t||"string"==typeof r[`on-${o}`]){const e=(0,_toneInk.deriveSolidFill)(n,colorOf(`on-${o}`));e!==n&&(d[o]=e,n=e)}if(t&&"string"!=typeof r[`${o}-text`]&&(d[`${o}-text`]=(0,_toneInk.deriveToneInk)(n,a,e.mode)),"primary"===o&&(t||void 0!==d.primary)){const o=(0,_toneInk.deriveStateFills)(n,colorOf("on-primary"),{fill:e.colors.primary,hover:e.colors["primary-hover"],pressed:e.colors["primary-pressed"]});"string"!=typeof r["primary-hover"]&&(d["primary-hover"]=o.hover),"string"!=typeof r["primary-pressed"]&&(d["primary-pressed"]=o.pressed)}}const f=e.settings.components,c=t?.components,l={},u=new Set([...(0,_guards.keysOf)(f),...void 0===c?[]:(0,_guards.keysOf)(c)]);for(const e of u)setComponentSettings(l,e,mergeComponentSettings(f,c,e));const g=t?.maxFontSizeMultiplier??e.settings.maxFontSizeMultiplier,p={icons:{...e.settings.icons,...t?.icons},gradients:{...e.settings.gradients,...t?.gradients},textVariants:{...e.settings.textVariants,...t?.textVariants},components:l,...void 0===g?{}:{maxFontSizeMultiplier:g}},w={...e.colors,...Object.fromEntries(Object.entries(r).filter(([e])=>!(0,_guards.isOneOf)(_tokensGenerated.COLOR_NAMES,e))),...Object.fromEntries(_tokensGenerated.COLOR_NAMES.map(e=>[e,d[e]??colorOf(e)]))},O={...e,colors:w,radius:s,font:i,settings:p};return(0,_componentSizes.validateComponentTokens)(O),O};exports.mergeBrand=mergeBrand;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.topPaddingOf=exports.bottomPaddingOf=void 0;var _reactNative=require("react-native");const edgePaddingOf=(t,d)=>{const e=_reactNative.StyleSheet.flatten(t),o=e?.[d]??e?.paddingVertical??e?.padding;return"number"==typeof o?o:0},topPaddingOf=t=>edgePaddingOf(t,"paddingTop");exports.topPaddingOf=topPaddingOf;const bottomPaddingOf=t=>edgePaddingOf(t,"paddingBottom");exports.bottomPaddingOf=bottomPaddingOf;
@@ -1 +1 @@
1
- "use strict";import{Logger}from"@webority/mobile-core";import{useMemo}from"react";import{SvgXml}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hasKey}from"../../utils/guards.js";import{resolveColor}from"../Text/Text.js";import{CATALOG_LOADERS,ICON_NAMES}from"./catalog.g.js";import{CURATED_ICON_NAMES,GLYPHS}from"./glyphs.g.js";import{jsx as _jsx}from"react/jsx-runtime";export{CURATED_ICON_NAMES,ICON_NAMES};export const ICONSAX_SUFFIX="-iconsax";export function isAppIconName(e){return"string"==typeof e&&(!!ICON_NAMES.some(r=>r===e)||e.endsWith("-iconsax")&&CURATED_ICON_NAMES.some(r=>r===e.slice(0,-8)))}export const APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36};const tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",o=`${e}:${t}`,s=shardCache.get(o);if(void 0!==s)return s;const a=CATALOG_LOADERS[e]?.[t],n=a?tryRequire(a):null;return shardCache.set(o,n),n},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)};export const resolveGlyph=(e,r="linear")=>{if(e.endsWith("-iconsax")){const t=e.slice(0,-8);return t in GLYPHS?resolveCatalogue(t,r):null}const t=hasKey(GLYPHS,e)?GLYPHS[e]:void 0;return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};export const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;const iconXmlCache=new Map;export const AppIcon=({name:e,size:r="md",color:t,variant:o="linear",style:s,accessibilityLabel:a,testID:n})=>{const i=useTheme();"string"==typeof r&&assertValidValue("AppIcon","size",r,Object.keys(APP_ICON_SIZES)),assertValidValue("AppIcon","variant",o,["linear","bold","bulk","broken","outline","twotone"]);const l="number"==typeof r?r:APP_ICON_SIZES[r]??APP_ICON_SIZES.md,c=void 0===t?i.colors["text-body"]:resolveColor(i,t),u=resolveGlyph(e,o),m=useMemo(()=>{if(!u)return null;const r=`${e}|${o}|${l}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const s=buildIconXml(u,l,c);return iconXmlCache.set(r,s),s},[e,o,u,l,c]);if(!m)return __DEV__&&!warned.has(e)&&(warned.add(e),Logger.warn(`[@webority/mobile-ui] AppIcon: Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run node scripts/gen-icons.mjs after adding one there.`)),null;return _jsx(SvgXml,{xml:m,width:l,height:l,...void 0!==s?{style:s}:{},accessible:null!=a,...null!=a?{accessibilityLabel:a,accessibilityRole:"image"}:{},...void 0!==n?{testID:n}:{}})};AppIcon.displayName="AppIcon";export default AppIcon;
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{useMemo}from"react";import{SvgXml}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hasKey}from"../../utils/guards.js";import{resolveColor}from"../Text/Text.js";import{CATALOG_LOADERS,ICON_NAMES}from"./catalog.g.js";import{CURATED_ICON_NAMES,GLYPHS}from"./glyphs.g.js";import{jsx as _jsx}from"react/jsx-runtime";export{CURATED_ICON_NAMES,ICON_NAMES};export const ICONSAX_SUFFIX="-iconsax";export function isAppIconName(e){return"string"==typeof e&&(!!ICON_NAMES.some(r=>r===e)||e.endsWith("-iconsax")&&CURATED_ICON_NAMES.some(r=>r===e.slice(0,-8)))}export const APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36};const tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",o=`${e}:${t}`,s=shardCache.get(o);if(void 0!==s)return s;const a=CATALOG_LOADERS[e]?.[t],n=a?tryRequire(a):null;return shardCache.set(o,n),n},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)};export const resolveGlyph=(e,r="linear")=>{if(e.endsWith("-iconsax")){const t=e.slice(0,-8);return t in GLYPHS?resolveCatalogue(t,r):null}const t=hasKey(GLYPHS,e)?GLYPHS[e]:void 0;return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};export const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;const iconXmlCache=new Map;export const AppIcon=({name:e,size:r="md",color:t,variant:o="linear",style:s,accessibilityLabel:a,testID:n})=>{const i=useTheme();"string"==typeof r&&assertValidValue("AppIcon","size",r,Object.keys(APP_ICON_SIZES)),assertValidValue("AppIcon","variant",o,["linear","bold","bulk","broken","outline","twotone"]);const l="number"==typeof r?r:APP_ICON_SIZES[r]??APP_ICON_SIZES.md,c=void 0===t?i.colors["text-body"]:resolveColor(i,t),u=resolveGlyph(e,o),m=useMemo(()=>{if(!u)return null;const r=`${e}|${o}|${l}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const s=buildIconXml(u,l,c);return iconXmlCache.set(r,s),s},[e,o,u,l,c]);if(!m)return __DEV__&&!warned.has(e)&&(warned.add(e),Logger.warn(`[@webority/mobile-ui] AppIcon: Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run node scripts/gen-icons.mts after adding one there.`)),null;return _jsx(SvgXml,{xml:m,width:l,height:l,...void 0!==s?{style:s}:{},accessible:null!=a,...null!=a?{accessibilityLabel:a,accessibilityRole:"image"}:{},...void 0!==n?{testID:n}:{}})};AppIcon.displayName="AppIcon";export default AppIcon;
@@ -1 +1 @@
1
- "use strict";import{ACCESS_TOKEN_KEY,getConfigValue,getToken,isStorageAvailable,Logger,publicClient,Storage}from"@webority/mobile-core";import{AppState}from"react-native";import{isRecord}from"../../utils/guards.js";import{hashString}from"../../utils/hashString.js";import{clearImages,deleteImage,imageExists,imageUri,listImageNames,writeImage}from"./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;export const DEFAULT_TTL_MS=6048e5;const isIndexEntry=e=>isRecord(e)&&"number"==typeof e.fetchedAt&&"number"==typeof e.bytes&&"string"==typeof e.contentType&&"number"==typeof e.lastAccessedAt&&"string"==typeof e.fileName&&"number"==typeof e.persistedAccessAt;let byteCeiling=52428800;export 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};export const getAuthedImageCacheLimit=()=>byteCeiling;export const deriveCacheKey=(e,t)=>hashString(t??e);const toMeta=({fetchedAt:e,bytes:t,contentType:s,lastAccessedAt:r})=>({fetchedAt:e,bytes:t,contentType:s,lastAccessedAt:r});let index=null,indexBytes=0,indexLoad=null,persistTimer=null,persistTarget=null,appStateSub=null;const persistIndex=async e=>{if(!isStorageAvailable())return;const t={};for(const[s,r]of e)t[s]={...r,persistedAccessAt:r.lastAccessedAt};if(await Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))};export const flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};const removeLegacyEntries=async()=>{const e=(await Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of listImageNames())t.has(e)||deleteImage(e)}catch(e){Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!isStorageAvailable())return e;const t=await Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{const s=JSON.parse(t);if(isRecord(s))for(const[t,r]of Object.entries(s))isIndexEntry(r)&&e.set(t,r)}catch(e){if(!(e instanceof SyntaxError))throw e}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,s]of e)imageExists(s.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{deleteImage(e)}catch(e){Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}};export const readEntry=async e=>{const t=await loadIndex(),s=t.get(e);return s?imageExists(s.fileName)?{fileUri:imageUri(s.fileName),meta:toMeta(s)}:(t.delete(e),indexBytes-=s.bytes,schedulePersist(t),null):null};export const removeEntry=async e=>{const t=await loadIndex(),s=t.get(e);s&&(t.delete(e),indexBytes-=s.bytes,deleteFile(s.fileName),schedulePersist(t))};export class AuthedImageHttpError extends Error{constructor(e,t){super(e,t),this.name="AuthedImageHttpError",this.status=t.status}}export const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;export const isFresh=(e,t,s=Date.now())=>s-e.fetchedAt<t;export const touchEntry=async e=>{const t=await loadIndex(),s=t.get(e);s&&(s.lastAccessedAt=Date.now(),s.lastAccessedAt-s.persistedAccessAt>=36e5&&schedulePersist(t))};const evictIfNeeded=e=>{let t=indexBytes;if(t<=byteCeiling)return 0;const s=[...e].sort(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);let r=0;for(const[i,a]of s){if(t<=byteCeiling)break;e.delete(i),indexBytes-=a.bytes,deleteFile(a.fileName),t-=a.bytes,r+=1}return r};export const clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,clearImages(),isStorageAvailable()&&await Storage.removeItem(INDEX_KEY)};export const authedImageCacheStats=async()=>{const e=await loadIndex();let t=0;for(const s of e.values())t+=s.bytes;return{entries:e.size,bytes:t}};const responseHeader=(e,t)=>{if(!isRecord(e))return;const s=e.get,r="function"==typeof s?s.call(e,t):e[t];return"string"==typeof r?r:void 0},originOf=e=>{const t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);if(null===t)return null;const s=t[1];if(void 0===s)throw new Error("originOf: the origin pattern always captures group 1 when it matches");return s.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 s=getConfigValue("baseUrl");return"string"==typeof s&&originOf(s)===t},fetchAndStore=async(e,t,s)=>{const r={Accept:"image/*",...t.headers};if(!t.client&&t.authenticated&&isOwnApiAddress(t.uri)){const e=await getToken(ACCESS_TOKEN_KEY);e?.token&&(r.Authorization=`Bearer ${e.token}`)}const i=t.client??publicClient;let a;try{a=await i.get(t.uri,{headers:r,responseType:"arraybuffer",signal:s})}catch(e){const s=isRecord(e)&&isRecord(e.response)?e.response.status:void 0;if("number"!=typeof s)throw e;throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered ${s}. 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).`,{status:s,cause:e})}const{data:n}=a;if(null!=n&&!(n instanceof ArrayBuffer))throw new Error(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the client returned ${typeof n} instead of raw bytes. Pass a client that honours \`responseType: "arraybuffer"\`.`);const o=new Uint8Array(n??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.`,{status:404});const c=responseHeader(a.headers,"content-type"),l=(c?mediaTypeOf(c):"")||"image/jpeg",d=await loadIndex(),u=Date.now(),g=`${e}-${u.toString(36)}`;let m;try{m=await writeImage(g,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.`,{cause:e})}const h={fetchedAt:u,bytes:o.byteLength,contentType:l,lastAccessedAt:u,fileName:g,persistedAccessAt:u},f=d.get(e);f&&(indexBytes-=f.bytes),d.set(e,h),indexBytes+=h.bytes,f&&f.fileName!==g&&deleteFile(f.fileName);const p=evictIfNeeded(d);return schedulePersist(d),p>0&&Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:m,meta:toMeta(h)}},inFlight=new Map;export const acquireFetch=(e,t)=>{const s=inFlight.get(e);if(s)return s.waiters+=1,s;const r=new AbortController,i={controller:r,waiters:1,promise:fetchAndStore(e,t,r.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)})};return inFlight.set(e,i),i};export const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};
1
+ "use strict";import{ACCESS_TOKEN_KEY,getConfigValue,getToken,Logger,publicClient,Storage}from"@webority/mobile-core";import{AppState}from"react-native";import{isRecord}from"../../utils/guards.js";import{hashString}from"../../utils/hashString.js";import{clearImages,deleteImage,imageExists,imageUri,listImageNames,writeImage}from"./imageStore";const INDEX_KEY="@webority/authed-image/v2/index",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3;export const DEFAULT_TTL_MS=6048e5;const isIndexEntry=e=>isRecord(e)&&"number"==typeof e.fetchedAt&&"number"==typeof e.bytes&&"string"==typeof e.contentType&&"number"==typeof e.lastAccessedAt&&"string"==typeof e.fileName&&"number"==typeof e.persistedAccessAt;let byteCeiling=52428800;export 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};export const getAuthedImageCacheLimit=()=>byteCeiling;export const deriveCacheKey=(e,t)=>hashString(t??e);const toMeta=({fetchedAt:e,bytes:t,contentType:s,lastAccessedAt:r})=>({fetchedAt:e,bytes:t,contentType:s,lastAccessedAt:r});let index=null,indexBytes=0,indexLoad=null,persistTimer=null,persistTarget=null,appStateSub=null;const persistIndex=async e=>{const t={};for(const[s,r]of e)t[s]={...r,persistedAccessAt:r.lastAccessedAt};if(await Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))};export const flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};const removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of listImageNames())t.has(e)||deleteImage(e)}catch(e){Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map,t=await Storage.getItem(INDEX_KEY);if(!t)return e;try{const s=JSON.parse(t);if(isRecord(s))for(const[t,r]of Object.entries(s))isIndexEntry(r)&&e.set(t,r)}catch(e){if(!(e instanceof SyntaxError))throw e}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,s]of e)imageExists(s.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{deleteImage(e)}catch(e){Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}};export const readEntry=async e=>{const t=await loadIndex(),s=t.get(e);return s?imageExists(s.fileName)?{fileUri:imageUri(s.fileName),meta:toMeta(s)}:(t.delete(e),indexBytes-=s.bytes,schedulePersist(t),null):null};export const removeEntry=async e=>{const t=await loadIndex(),s=t.get(e);s&&(t.delete(e),indexBytes-=s.bytes,deleteFile(s.fileName),schedulePersist(t))};export class AuthedImageHttpError extends Error{constructor(e,t){super(e,{cause:t.cause}),this.name="AuthedImageHttpError",this.status=t.status}}export const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;export const isFresh=(e,t,s=Date.now())=>s-e.fetchedAt<t;export const touchEntry=async e=>{const t=await loadIndex(),s=t.get(e);s&&(s.lastAccessedAt=Date.now(),s.lastAccessedAt-s.persistedAccessAt>=36e5&&schedulePersist(t))};const evictIfNeeded=e=>{let t=indexBytes;if(t<=byteCeiling)return 0;const s=[...e].sort(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);let r=0;for(const[i,n]of s){if(t<=byteCeiling)break;e.delete(i),indexBytes-=n.bytes,deleteFile(n.fileName),t-=n.bytes,r+=1}return r};export const clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,clearImages(),await Storage.removeItem(INDEX_KEY)};export const authedImageCacheStats=async()=>{const e=await loadIndex();let t=0;for(const s of e.values())t+=s.bytes;return{entries:e.size,bytes:t}};const responseHeader=(e,t)=>{if(!isRecord(e))return;const s=e.get,r="function"==typeof s?s.call(e,t):e[t];return"string"==typeof r?r:void 0},originOf=e=>{const t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);if(null===t)return null;const s=t[1];if(void 0===s)throw new Error("originOf: the origin pattern always captures group 1 when it matches");return s.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 s=getConfigValue("baseUrl");return"string"==typeof s&&originOf(s)===t},fetchAndStore=async(e,t,s)=>{const r={Accept:"image/*",...t.headers};if(!t.client&&t.authenticated&&isOwnApiAddress(t.uri)){const e=await getToken(ACCESS_TOKEN_KEY);e?.token&&(r.Authorization=`Bearer ${e.token}`)}const i=t.client??publicClient;let n;try{n=await i.get(t.uri,{headers:r,responseType:"arraybuffer",signal:s})}catch(e){const s=isRecord(e)&&isRecord(e.response)?e.response.status:void 0;if("number"!=typeof s)throw e;throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered ${s}. 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).`,{status:s,cause:e})}const{data:a}=n;if(null!=a&&!(a instanceof ArrayBuffer))throw new Error(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the client returned ${typeof a} instead of raw bytes. Pass a client that honours \`responseType: "arraybuffer"\`.`);const o=new Uint8Array(a??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.`,{status:404});const c=responseHeader(n.headers,"content-type"),l=(c?mediaTypeOf(c):"")||"image/jpeg",d=await loadIndex(),u=Date.now(),g=`${e}-${u.toString(36)}`;let m;try{m=await writeImage(g,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.`,{cause:e})}const h={fetchedAt:u,bytes:o.byteLength,contentType:l,lastAccessedAt:u,fileName:g,persistedAccessAt:u},p=d.get(e);p&&(indexBytes-=p.bytes),d.set(e,h),indexBytes+=h.bytes,p&&p.fileName!==g&&deleteFile(p.fileName);const f=evictIfNeeded(d);return schedulePersist(d),f>0&&Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${f} cached image(s) over the byte ceiling`),{fileUri:m,meta:toMeta(h)}},inFlight=new Map;export const acquireFetch=(e,t)=>{const s=inFlight.get(e);if(s)return s.waiters+=1,s;const r=new AbortController,i={controller:r,waiters:1,promise:fetchAndStore(e,t,r.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)})};return inFlight.set(e,i),i};export const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};
@@ -1 +1 @@
1
- "use strict";import{Logger}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,BackHandler,Easing,Platform,Pressable,StyleSheet,Text,View}from"react-native";import Reanimated,{cancelAnimation,Easing as ReanimatedEasing,useAnimatedStyle,useSharedValue,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{FLOATING_ACTION_BUTTON_TEXT}from"../../text/phone/floatingActionButton.g.js";import{createAnimatedValue,resolveFloatingActionButtonSize,setNativeValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{ACCENT_PRESSED_TINT}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(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"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}};function FloatingActionButton({ref:e,...t}){const{icon:o,onPress:n,label:i,collapsed:s=!1,size:r="md",tone:a="primary",position:l,bottomOffset:c,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:p=!1,accessibilityLabel:f,accessibilityHint:b,haptic:g,style:h,labelStyle:y,testID:A}=t;assertValidValue("FloatingActionButton","size",t.size,FAB_SIZES),assertValidValue("FloatingActionButton","tone",t.tone,FAB_TONES),assertValidValue("FloatingActionButton","position",t.position,FAB_POSITIONS);const S=!u&&!d,x=useTheme(),v=useSafeAreaInsets(),w=useMemo(()=>resolveFloatingActionButtonSize(x,r),[x,r]),_=useMemo(()=>buildStyles(x),[x]),{scale:E,opacity:I,pressIn:R,pressOut:T}=usePressAnimation({enabled:S}),j=usePresenceMotion(),C=x.space[x.components["floating-action-button"]["edge-offset"]],F=x.space[x.components["floating-action-button"]["bottom-offset"]],V=useRef(createAnimatedValue(1)).current,B=j.duration("default");useEffect(()=>{if(!m)return void setNativeValue(V,1);const e=Animated.timing(V,{toValue:p?0:1,duration:B,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[m,p,V,B,x.motion.ease["in-out"]]);const P=w.diameter+(c??F)+v.bottom+C,k=V.interpolate({inputRange:[0,1],outputRange:j.range(P,0)}),D=useMemo(()=>Animated.multiply(V,I),[V,I]),O="string"==typeof i&&i.length>0,N=O&&s,L=j.reduced,z=x.space.sm,M=w["label-padding-x"],H=x.motion.duration.fast,G=x.motion.ease["in-out"],$=useSharedValue(N?1:0),[U,W]=useState(null);useEffect(()=>{const e=N?1:0;return $.value=L?e:withTiming(e,{duration:H,easing:ReanimatedEasing.bezier(...G)}),()=>cancelAnimation($)},[N,L,$,H,G]);const X=useCallback(e=>{const t=Math.ceil(e);W(e=>e===t?e:t)},[]),Y=useAnimatedStyle(()=>({paddingHorizontal:M*(1-$.value)}),[M,$]),Z=useAnimatedStyle(()=>{const e=Math.max(0,1-2*$.value);return null===U?$.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(U+z)*(1-$.value)}},[$,U,z]),q=u?x.colors["surface-disabled"]:toneBackground(x,a),J=u?x.colors["text-disabled"]:toneForeground(x,a),K=d?_jsx(Spinner,{variant:"circular",size:"lg"===r?"md":"sm",color:J}):renderSlotIcon(o,{color:J,size:w.icon,disabled:u}),Q=useMemo(()=>{if(!l)return null;const e=(c??F)+v.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:C};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:C}}},[l,c,v.bottom,F,C]);return _jsx(Animated.View,{style:[Q,{transform:[{translateY:k},{scale:E}],opacity:D},h],pointerEvents:m&&p?"none":"auto",children:_jsx(Pressable,{ref:e,onPress:e=>{if(!S)return;const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t),n()},onPressIn:R,onPressOut:T,disabled:!S,accessibilityRole:"button",accessibilityLabel:f,accessibilityHint:b,accessibilityState:{disabled:!S,busy:d},"aria-disabled":!S,"aria-busy":d,testID:A,style:[_.base,O?{height:w.diameter,minWidth:w.diameter,borderRadius:w.diameter/2,...smoothCorners}:{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,...smoothCorners},x.shadow.popover,{backgroundColor:q,opacity:u||d?.55:1}],children:({pressed:e})=>_jsxs(_Fragment,{children:[e&&S?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[_.pressedTint,{backgroundColor:pressedTintFor(x,a),borderRadius:w.diameter/2,...smoothCorners}]}):null,O?_jsxs(Reanimated.View,{style:[_.extendedRow,Y],children:[K,_jsx(Reanimated.View,{style:[_.labelClip,Z],children:_jsx(Text,{onLayout:e=>X(e.nativeEvent.layout.width),style:[_.label,{color:J,fontSize:w.text,fontWeight:x.weight.semibold,marginLeft:z},y],numberOfLines:1,children:i})})]}):K]})})})}const buildStyles=e=>StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:o,actions:n,expanded:i,defaultExpanded:s=!1,onExpandedChange:r,labels:a,position:l="bottomRight",bottomOffset:c,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:p=!1,isScrolling:f=!1,style:b,secondaryActionStyle:g,labelPillStyle:h,labelStyle:y,testID:A}=e;assertValidValue("FloatingActionButtonGroup","size",e.size,FAB_SIZES),assertValidValue("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const S=useMobileUiText("floatingActionButton",FLOATING_ACTION_BUTTON_TEXT),x=useMemo(()=>({...S,...a}),[S,a]),v=d??x.quickActions,w=useTheme(),_=useSafeAreaInsets(),E=useMemo(()=>resolveFloatingActionButtonSize(w,u),[w,u]),I=useMemo(()=>buildGroupStyles(w),[w]),R=usePresenceMotion(),T=R.duration("default"),j=w.space[w.components["floating-action-button"]["edge-offset"]],C=w.space[w.components["floating-action-button"]["bottom-offset"]],F=w.space[w.components["floating-action-button"]["secondary-gap"]],V=w.components["floating-action-button"]["stagger-ms"],B=useMemo(()=>n.slice(0,6),[n]),P=B.length,k=useMemo(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);n.forEach(e=>{assertValidValue("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const D=__DEV__?describeActionProblem(n):"";useEffect(()=>{__DEV__&&D&&Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${D}`)},[D]);const O="boolean"==typeof i,[N,L]=useState(s),z="boolean"==typeof i?i:N,M=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!p)return void setNativeValue(M,1);const e=Animated.timing(M,{toValue:f?0:1,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[p,f,M,T,w.motion.ease["in-out"]]);const H=p&&f;useEffect(()=>{H&&z&&(O||L(!1),r?.(!1))},[H,z,O,r]);const G=E.diameter+(c??C)+_.bottom+j,$=M.interpolate({inputRange:[0,1],outputRange:R.range(G,0)}),U=M,W=useRef(createAnimatedValue(z?1:0)).current,X=useRef([]),[Y,Z]=useState(0);useEffect(()=>{const e=X.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let o=e.length;o<P;o+=1)t.push(new Animated.Value(z?1:0));X.current=t}else X.current=e.slice(0,P);Z(e=>e+1)}},[P,z]),useEffect(()=>{const e=Animated.timing(W,{toValue:z?1:0,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver});e.start();const t=X.current.map(e=>Animated.timing(e,{toValue:z?1:0,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver})),o=z?t:[...t].reverse(),n=Animated.stagger(V,o);return n.start(),()=>{e.stop(),n.stop()}},[z,W,T,w.motion.ease["in-out"],P,Y,V]);const q=useCallback(e=>{const t=resolveHaptic(m,"impactLight");t&&triggerHaptic(t),O||L(e),r?.(e)},[O,r,m]),J=useRef(null),K=useRef(z),Q=useRef(!1);useEffect(()=>{if(K.current===z)return;K.current=z;const e=Q.current;if(Q.current=!1,H||e)return;const t=J.current;t&&("web"===Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():AccessibilityInfo.sendAccessibilityEvent(t,"focus")),announce(z?pluralText(x,"expanded",P,{label:v}):fillText(x.collapsed,{label:v}))},[z,H,v,P,x]);const ee=useCallback(()=>{q(!z)},[z,q]),te=useCallback(e=>{!1!==m&&triggerHaptic("selection"),Q.current=!0,e.onPress(),O||L(!1),r?.(!1)},[O,r,m]),oe=useCallback(()=>{z&&q(!1)},[z,q]);useEffect(()=>{if(!z)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(q(!1),!0));return()=>e.remove()},[z,q]),useEffect(()=>{if(!z||"web"!==Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&q(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[z,q]);const ne=useMemo(()=>{const e=(c??C)+_.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:j,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:j,alignItems:"flex-end"}}},[l,c,_.bottom,C,j]),slotOffset=e=>-(E.diameter+F)*(e+1),ie=useMemo(()=>{switch(l){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[l]),se=.78*E.diameter,re=useMemo(()=>{const e=se+w.space.sm;switch(l){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:E.diameter/2+se/2+w.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[l,se,E.diameter,w.space.sm]),ae=W.interpolate({inputRange:[0,1],outputRange:[0,.4]}),le=W.interpolate(R.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return _jsxs(_Fragment,{children:[z?_jsx(Animated.View,{pointerEvents:z?"auto":"none",style:[StyleSheet.absoluteFill,{backgroundColor:w.colors.scrim,opacity:ae}],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:oe,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:A?`${A}-backdrop`:void 0})}):null,_jsxs(Animated.View,{pointerEvents:H?"none":"box-none",style:[ne,{transform:[{translateY:$}],opacity:U},b],accessibilityRole:"menu",testID:A,children:[k.map(({action:e,index:t})=>{const o=X.current[t];if(!o)return null;const n=o.interpolate({inputRange:[0,1],outputRange:R.range(0,slotOffset(t))}),i=o.interpolate({inputRange:[0,1],outputRange:R.range(.6,1)}),s=toneBackground(w,e.tone??"primary"),r=toneForeground(w,e.tone??"primary"),a=e.label?_jsx(View,{pointerEvents:"none",style:[I.labelSlot,re],testID:A?`${A}-label-${e.key}`:void 0,children:_jsx(View,{style:[I.labelPill,w.shadow.card,{backgroundColor:w.colors.surface,paddingHorizontal:w.space.sm,paddingVertical:w.space.xs,borderRadius:w.radius.sm,...smoothCorners},h],children:_jsx(Text,{style:[{color:w.colors["text-body"],fontSize:w.text.sm.size,fontWeight:w.weight.medium},y],numberOfLines:1,children:e.label})})}):null;return _jsxs(Animated.View,{pointerEvents:z?"auto":"none",accessibilityElementsHidden:!z,importantForAccessibility:z?"auto":"no-hide-descendants","aria-hidden":!z,style:[I.secondaryRow,ie,{position:"absolute",bottom:0,opacity:o,transform:[{translateY:n},{scale:i}]}],children:[_jsx(Pressable,{onPress:()=>te(e),focusable:z,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[I.fabBase,w.shadow.elevated,{width:se,height:se,borderRadius:se/2,...smoothCorners,backgroundColor:s},g],testID:A?`${A}-action-${e.key}`:void 0,children:({pressed:t})=>_jsxs(_Fragment,{children:[t?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:pressedTintFor(w,e.tone??"primary"),borderRadius:se/2,...smoothCorners}]}):null,renderSlotIcon(e.icon,{color:r,size:E.icon,disabled:!1})]})}),a]},e.key)}),_jsx(Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:v,accessibilityState:{expanded:z},"aria-expanded":z,style:[I.fabBase,w.shadow.popover,{width:E.diameter,height:E.diameter,borderRadius:E.diameter/2,...smoothCorners,backgroundColor:w.colors.primary}],testID:A?`${A}-primary`:void 0,children:({pressed:e})=>_jsxs(_Fragment,{children:[e?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:ACCENT_PRESSED_TINT,borderRadius:E.diameter/2,...smoothCorners}]}):null,_jsx(Animated.View,{style:o?void 0:{transform:[{rotate:le}]},children:renderSlotIcon(z&&o?o:t,{color:w.colors["on-primary"],size:E.icon,disabled:!1})})]})})]})]})},buildGroupStyles=e=>StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});export{FloatingActionButton,FloatingActionButtonGroup};export default FloatingActionButton;
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,BackHandler,Easing,Platform,Pressable,StyleSheet,Text,View}from"react-native";import Reanimated,{cancelAnimation,Easing as ReanimatedEasing,useAnimatedStyle,useSharedValue,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{FLOATING_ACTION_BUTTON_TEXT}from"../../text/phone/floatingActionButton.g.js";import{createAnimatedValue,resolveFloatingActionButtonSize,setNativeValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{ACCENT_PRESSED_TINT}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(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"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}};function FloatingActionButton({ref:e,...t}){const{icon:o,onPress:n,label:i,collapsed:s=!1,size:r="md",tone:a="primary",position:l,bottomOffset:c,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:p=!1,accessibilityLabel:f,accessibilityHint:b,haptic:g,style:h,labelStyle:y,testID:A}=t;assertValidValue("FloatingActionButton","size",t.size,FAB_SIZES),assertValidValue("FloatingActionButton","tone",t.tone,FAB_TONES),assertValidValue("FloatingActionButton","position",t.position,FAB_POSITIONS);const S=!u&&!d,x=useTheme(),v=useSafeAreaInsets(),w=useMemo(()=>resolveFloatingActionButtonSize(x,r),[x,r]),_=useMemo(()=>buildStyles(x),[x]),{style:E,pressIn:I,pressOut:R}=usePressAnimation({enabled:S}),T=usePresenceMotion(),j=x.space[x.components["floating-action-button"]["edge-offset"]],C=x.space[x.components["floating-action-button"]["bottom-offset"]],F=useRef(createAnimatedValue(1)).current,V=T.duration("default");useEffect(()=>{if(!m)return void setNativeValue(F,1);const e=Animated.timing(F,{toValue:p?0:1,duration:V,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[m,p,F,V,x.motion.ease["in-out"]]);const B=w.diameter+(c??C)+v.bottom+j,P=F.interpolate({inputRange:[0,1],outputRange:T.range(B,0)}),k=useMemo(()=>Animated.multiply(F,E.opacity),[F,E.opacity]),D="string"==typeof i&&i.length>0,O=D&&s,N=T.reduced,L=x.space.sm,z=w["label-padding-x"],M=x.motion.duration.fast,H=x.motion.ease["in-out"],G=useSharedValue(O?1:0),[$,U]=useState(null);useEffect(()=>{const e=O?1:0;return G.value=N?e:withTiming(e,{duration:M,easing:ReanimatedEasing.bezier(...H)}),()=>cancelAnimation(G)},[O,N,G,M,H]);const W=useCallback(e=>{const t=Math.ceil(e);U(e=>e===t?e:t)},[]),X=useAnimatedStyle(()=>({paddingHorizontal:z*(1-G.value)}),[z,G]),Y=useAnimatedStyle(()=>{const e=Math.max(0,1-2*G.value);return null===$?G.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:($+L)*(1-G.value)}},[G,$,L]),Z=u?x.colors["surface-disabled"]:toneBackground(x,a),q=u?x.colors["text-disabled"]:toneForeground(x,a),J=d?_jsx(Spinner,{variant:"circular",size:"lg"===r?"md":"sm",color:q}):renderSlotIcon(o,{color:q,size:w.icon,disabled:u}),K=useMemo(()=>{if(!l)return null;const e=(c??C)+v.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:j};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:j}}},[l,c,v.bottom,C,j]);return _jsx(Animated.View,{style:[K,{transform:[{translateY:P},...E.transform],opacity:k},h],pointerEvents:m&&p?"none":"auto",children:_jsx(Pressable,{ref:e,onPress:e=>{if(!S)return;const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t),n()},onPressIn:I,onPressOut:R,disabled:!S,accessibilityRole:"button",accessibilityLabel:f,accessibilityHint:b,accessibilityState:{disabled:!S,busy:d},"aria-disabled":!S,"aria-busy":d,testID:A,style:[_.base,D?{height:w.diameter,minWidth:w.diameter,borderRadius:w.diameter/2,...smoothCorners}:{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,...smoothCorners},x.shadow.popover,{backgroundColor:Z,opacity:u||d?.55:1}],children:({pressed:e})=>_jsxs(_Fragment,{children:[e&&S?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[_.pressedTint,{backgroundColor:pressedTintFor(x,a),borderRadius:w.diameter/2,...smoothCorners}]}):null,D?_jsxs(Reanimated.View,{style:[_.extendedRow,X],children:[J,_jsx(Reanimated.View,{style:[_.labelClip,Y],children:_jsx(Text,{onLayout:e=>W(e.nativeEvent.layout.width),style:[_.label,{color:q,fontSize:w.text,fontWeight:x.weight.semibold,marginLeft:L},y],numberOfLines:1,children:i})})]}):J]})})})}const buildStyles=e=>StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:o,actions:n,expanded:i,defaultExpanded:s=!1,onExpandedChange:r,labels:a,position:l="bottomRight",bottomOffset:c,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:p=!1,isScrolling:f=!1,style:b,secondaryActionStyle:g,labelPillStyle:h,labelStyle:y,testID:A}=e;assertValidValue("FloatingActionButtonGroup","size",e.size,FAB_SIZES),assertValidValue("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const S=useMobileUiText("floatingActionButton",FLOATING_ACTION_BUTTON_TEXT),x=useMemo(()=>({...S,...a}),[S,a]),v=d??x.quickActions,w=useTheme(),_=useSafeAreaInsets(),E=useMemo(()=>resolveFloatingActionButtonSize(w,u),[w,u]),I=useMemo(()=>buildGroupStyles(w),[w]),R=usePresenceMotion(),T=R.duration("default"),j=w.space[w.components["floating-action-button"]["edge-offset"]],C=w.space[w.components["floating-action-button"]["bottom-offset"]],F=w.space[w.components["floating-action-button"]["secondary-gap"]],V=w.components["floating-action-button"]["stagger-ms"],B=useMemo(()=>n.slice(0,6),[n]),P=B.length,k=useMemo(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);n.forEach(e=>{assertValidValue("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const D=__DEV__?describeActionProblem(n):"";useEffect(()=>{__DEV__&&D&&Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${D}`)},[D]);const O="boolean"==typeof i,[N,L]=useState(s),z="boolean"==typeof i?i:N,M=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!p)return void setNativeValue(M,1);const e=Animated.timing(M,{toValue:f?0:1,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[p,f,M,T,w.motion.ease["in-out"]]);const H=p&&f;useEffect(()=>{H&&z&&(O||L(!1),r?.(!1))},[H,z,O,r]);const G=E.diameter+(c??C)+_.bottom+j,$=M.interpolate({inputRange:[0,1],outputRange:R.range(G,0)}),U=M,W=useRef(createAnimatedValue(z?1:0)).current,X=useRef([]),[Y,Z]=useState(0);useEffect(()=>{const e=X.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let o=e.length;o<P;o+=1)t.push(new Animated.Value(z?1:0));X.current=t}else X.current=e.slice(0,P);Z(e=>e+1)}},[P,z]),useEffect(()=>{const e=Animated.timing(W,{toValue:z?1:0,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver});e.start();const t=X.current.map(e=>Animated.timing(e,{toValue:z?1:0,duration:T,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver})),o=z?t:[...t].reverse(),n=Animated.stagger(V,o);return n.start(),()=>{e.stop(),n.stop()}},[z,W,T,w.motion.ease["in-out"],P,Y,V]);const q=useCallback(e=>{const t=resolveHaptic(m,"impactLight");t&&triggerHaptic(t),O||L(e),r?.(e)},[O,r,m]),J=useRef(null),K=useRef(z),Q=useRef(!1);useEffect(()=>{if(K.current===z)return;K.current=z;const e=Q.current;if(Q.current=!1,H||e)return;const t=J.current;t&&("web"===Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():AccessibilityInfo.sendAccessibilityEvent(t,"focus")),announce(z?pluralText(x,"expanded",P,{label:v}):fillText(x.collapsed,{label:v}))},[z,H,v,P,x]);const ee=useCallback(()=>{q(!z)},[z,q]),te=useCallback(e=>{!1!==m&&triggerHaptic("selection"),Q.current=!0,e.onPress(),O||L(!1),r?.(!1)},[O,r,m]),oe=useCallback(()=>{z&&q(!1)},[z,q]);useEffect(()=>{if(!z)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(q(!1),!0));return()=>e.remove()},[z,q]),useEffect(()=>{if(!z||"web"!==Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&q(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[z,q]);const ne=useMemo(()=>{const e=(c??C)+_.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:j,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:j,alignItems:"flex-end"}}},[l,c,_.bottom,C,j]),slotOffset=e=>-(E.diameter+F)*(e+1),ie=useMemo(()=>{switch(l){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[l]),se=.78*E.diameter,re=useMemo(()=>{const e=se+w.space.sm;switch(l){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:E.diameter/2+se/2+w.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[l,se,E.diameter,w.space.sm]),ae=W.interpolate({inputRange:[0,1],outputRange:[0,.4]}),le=W.interpolate(R.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return _jsxs(_Fragment,{children:[z?_jsx(Animated.View,{pointerEvents:z?"auto":"none",style:[StyleSheet.absoluteFill,{backgroundColor:w.colors.scrim,opacity:ae}],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:oe,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:A?`${A}-backdrop`:void 0})}):null,_jsxs(Animated.View,{pointerEvents:H?"none":"box-none",style:[ne,{transform:[{translateY:$}],opacity:U},b],accessibilityRole:"menu",testID:A,children:[k.map(({action:e,index:t})=>{const o=X.current[t];if(!o)return null;const n=o.interpolate({inputRange:[0,1],outputRange:R.range(0,slotOffset(t))}),i=o.interpolate({inputRange:[0,1],outputRange:R.range(.6,1)}),s=toneBackground(w,e.tone??"primary"),r=toneForeground(w,e.tone??"primary"),a=e.label?_jsx(View,{pointerEvents:"none",style:[I.labelSlot,re],testID:A?`${A}-label-${e.key}`:void 0,children:_jsx(View,{style:[I.labelPill,w.shadow.card,{backgroundColor:w.colors.surface,paddingHorizontal:w.space.sm,paddingVertical:w.space.xs,borderRadius:w.radius.sm,...smoothCorners},h],children:_jsx(Text,{style:[{color:w.colors["text-body"],fontSize:w.text.sm.size,fontWeight:w.weight.medium},y],numberOfLines:1,children:e.label})})}):null;return _jsxs(Animated.View,{pointerEvents:z?"auto":"none",accessibilityElementsHidden:!z,importantForAccessibility:z?"auto":"no-hide-descendants","aria-hidden":!z,style:[I.secondaryRow,ie,{position:"absolute",bottom:0,opacity:o,transform:[{translateY:n},{scale:i}]}],children:[_jsx(Pressable,{onPress:()=>te(e),focusable:z,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[I.fabBase,w.shadow.elevated,{width:se,height:se,borderRadius:se/2,...smoothCorners,backgroundColor:s},g],testID:A?`${A}-action-${e.key}`:void 0,children:({pressed:t})=>_jsxs(_Fragment,{children:[t?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:pressedTintFor(w,e.tone??"primary"),borderRadius:se/2,...smoothCorners}]}):null,renderSlotIcon(e.icon,{color:r,size:E.icon,disabled:!1})]})}),a]},e.key)}),_jsx(Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:v,accessibilityState:{expanded:z},"aria-expanded":z,style:[I.fabBase,w.shadow.popover,{width:E.diameter,height:E.diameter,borderRadius:E.diameter/2,...smoothCorners,backgroundColor:w.colors.primary}],testID:A?`${A}-primary`:void 0,children:({pressed:e})=>_jsxs(_Fragment,{children:[e?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:ACCENT_PRESSED_TINT,borderRadius:E.diameter/2,...smoothCorners}]}):null,_jsx(Animated.View,{style:o?void 0:{transform:[{rotate:le}]},children:renderSlotIcon(z&&o?o:t,{color:w.colors["on-primary"],size:E.icon,disabled:!1})})]})})]})]})},buildGroupStyles=e=>StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});export{FloatingActionButton,FloatingActionButtonGroup};export default FloatingActionButton;
@@ -1 +1 @@
1
- "use strict";import{Keyboard,Pressable,RefreshControl,StyleSheet}from"react-native";import{KeyboardAwareScrollView as ControllerScrollView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useTheme}from"../../theme/index.js";import{jsx as _jsx}from"react/jsx-runtime";const tapAreaStyle={flexGrow:1},CHILD_LAYOUT_KEYS=["gap","rowGap","columnGap","flexDirection","flexWrap","alignItems","alignContent","justifyContent"],childLayout=e=>{const r=StyleSheet.flatten(e),o={};for(const e of CHILD_LAYOUT_KEYS)void 0!==r?.[e]&&Object.assign(o,{[e]:r[e]});return o};function KeyboardAwareScrollView({ref:e,...r}){const{children:o,bottomOffset:t=24,extraKeyboardSpace:s=0,safeAreaEdges:l=["bottom"],refreshing:a=!1,onRefresh:n,dismissOnTapOutside:i=!0,contentContainerStyle:d,refreshControl:c,...f}=r,m=useTheme(),p=useSafeAreaInsets(),u=l.includes("bottom"),y={paddingBottom:u?p.bottom:0,...l.includes("top")?{paddingTop:p.top}:null,...l.includes("left")?{paddingLeft:p.left}:null,...l.includes("right")?{paddingRight:p.right}:null},b=c??(n?_jsx(RefreshControl,{refreshing:a,onRefresh:n,tintColor:m.colors.primary,colors:[m.colors.primary],progressBackgroundColor:m.colors.surface,titleColor:m.colors["text-muted"]}):void 0);return _jsx(ControllerScrollView,{ref:e,bottomOffset:t,extraKeyboardSpace:s-(u?p.bottom:0),disableScrollOnKeyboardHide:!0,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"none",contentContainerStyle:[d,y],refreshControl:b,...f,children:i?_jsx(Pressable,{accessible:!1,onPress:Keyboard.dismiss,style:[tapAreaStyle,childLayout(d)],children:o}):o})}export{KeyboardAwareScrollView};export default KeyboardAwareScrollView;
1
+ "use strict";import{Keyboard,Pressable,RefreshControl,StyleSheet}from"react-native";import{KeyboardAwareScrollView as ControllerScrollView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useTheme}from"../../theme/index.js";import{bottomPaddingOf}from"../../utils/contentPadding.js";import{jsx as _jsx}from"react/jsx-runtime";const tapAreaStyle={flexGrow:1},CHILD_LAYOUT_KEYS=["gap","rowGap","columnGap","flexDirection","flexWrap","alignItems","alignContent","justifyContent"],childLayout=e=>{const o=StyleSheet.flatten(e),r={};for(const e of CHILD_LAYOUT_KEYS)void 0!==o?.[e]&&Object.assign(r,{[e]:o[e]});return r};function KeyboardAwareScrollView({ref:e,...o}){const{children:r,bottomOffset:t=24,extraKeyboardSpace:s=0,safeAreaEdges:a=["bottom"],refreshing:l=!1,onRefresh:n,dismissOnTapOutside:i=!0,contentContainerStyle:d,refreshControl:c,...f}=o,m=useTheme(),p=useSafeAreaInsets(),u=a.includes("bottom"),b={paddingBottom:bottomPaddingOf(d)+(u?p.bottom:0),...a.includes("top")?{paddingTop:p.top}:null,...a.includes("left")?{paddingLeft:p.left}:null,...a.includes("right")?{paddingRight:p.right}:null},y=c??(n?_jsx(RefreshControl,{refreshing:l,onRefresh:n,tintColor:m.colors.primary,colors:[m.colors.primary],progressBackgroundColor:m.colors.surface,titleColor:m.colors["text-muted"]}):void 0);return _jsx(ControllerScrollView,{ref:e,bottomOffset:t,extraKeyboardSpace:s-(u?p.bottom:0),disableScrollOnKeyboardHide:!0,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"none",contentContainerStyle:[d,b],refreshControl:y,...f,children:i?_jsx(Pressable,{accessible:!1,onPress:Keyboard.dismiss,style:[tapAreaStyle,childLayout(d)],children:r}):r})}export{KeyboardAwareScrollView};export default KeyboardAwareScrollView;