@webority/mobile-ui 0.132.0 → 0.133.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.
- package/dist/canvas-kit/kit.js +1626 -1596
- package/dist/canvas-kit/manifest.json +15 -2
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
- package/lib/commonjs/components/AuthedImage/imageStore.js +1 -0
- package/lib/commonjs/components/AuthedImage/imageStore.web.js +1 -0
- package/lib/commonjs/components/Composer/Composer.js +1 -1
- package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/commonjs/components/Switch/Switch.js +1 -1
- package/lib/commonjs/theme/tokens.generated.js +1 -1
- package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
- package/lib/module/components/AuthedImage/imageStore.js +1 -0
- package/lib/module/components/AuthedImage/imageStore.web.js +1 -0
- package/lib/module/components/Composer/Composer.js +1 -1
- package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/module/components/Switch/Switch.js +1 -1
- package/lib/module/theme/tokens.generated.js +1 -1
- package/lib/typescript/commonjs/components/AuthedImage/imageStore.d.ts +7 -0
- package/lib/typescript/commonjs/components/AuthedImage/imageStore.web.d.ts +7 -0
- package/lib/typescript/commonjs/components/Composer/Composer.d.ts +3 -0
- package/lib/typescript/commonjs/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/module/components/AuthedImage/imageStore.d.ts +7 -0
- package/lib/typescript/module/components/AuthedImage/imageStore.web.d.ts +7 -0
- package/lib/typescript/module/components/Composer/Composer.d.ts +3 -0
- package/lib/typescript/module/theme/tokens.generated.d.ts +1 -1
- package/package.json +7 -7
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"kind": "WeborityPhone",
|
|
3
3
|
"library": {
|
|
4
4
|
"name": "@webority/mobile-ui",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.133.0"
|
|
6
6
|
},
|
|
7
7
|
"rendererProtocolVersion": 13,
|
|
8
8
|
"platform": "Phone",
|
|
@@ -4832,6 +4832,13 @@
|
|
|
4832
4832
|
"description": "Pad the bar for the bottom safe area, or turn off above a tab bar.",
|
|
4833
4833
|
"default": true
|
|
4834
4834
|
},
|
|
4835
|
+
{
|
|
4836
|
+
"name": "sendIcon",
|
|
4837
|
+
"type": "icon",
|
|
4838
|
+
"required": false,
|
|
4839
|
+
"description": "The icon of the send button.",
|
|
4840
|
+
"default": "send"
|
|
4841
|
+
},
|
|
4835
4842
|
{
|
|
4836
4843
|
"name": "sendReveal",
|
|
4837
4844
|
"type": "enum",
|
|
@@ -20522,6 +20529,7 @@
|
|
|
20522
20529
|
"surface-inverse",
|
|
20523
20530
|
"surface-pressed",
|
|
20524
20531
|
"surface-selected",
|
|
20532
|
+
"switch-thumb",
|
|
20525
20533
|
"text",
|
|
20526
20534
|
"text-body",
|
|
20527
20535
|
"text-disabled",
|
|
@@ -20663,6 +20671,7 @@
|
|
|
20663
20671
|
"surface-inverse": "Inverse band on a page, such as a dark footer or an inverse toast.",
|
|
20664
20672
|
"surface-pressed": "Wash over a surface while it is pressed.",
|
|
20665
20673
|
"surface-selected": "Wash over a selected surface such as a chosen list row.",
|
|
20674
|
+
"switch-thumb": "Knob of an on/off switch, white in both modes.",
|
|
20666
20675
|
"text": "Main heading and body ink.",
|
|
20667
20676
|
"text-body": "Body copy on a tinted surface such as an alert body.",
|
|
20668
20677
|
"text-disabled": "Text of a disabled control.",
|
|
@@ -20989,6 +20998,10 @@
|
|
|
20989
20998
|
"light": "#5b5bd61a",
|
|
20990
20999
|
"dark": "#7c7ce82e"
|
|
20991
21000
|
},
|
|
21001
|
+
"switch-thumb": {
|
|
21002
|
+
"light": "#ffffff",
|
|
21003
|
+
"dark": "#ffffff"
|
|
21004
|
+
},
|
|
20992
21005
|
"text": {
|
|
20993
21006
|
"light": "#252f4a",
|
|
20994
21007
|
"dark": "#e2e2e2"
|
|
@@ -21015,7 +21028,7 @@
|
|
|
21015
21028
|
},
|
|
21016
21029
|
"thumb": {
|
|
21017
21030
|
"light": "#ffffff",
|
|
21018
|
-
"dark": "#
|
|
21031
|
+
"dark": "#3a3e49"
|
|
21019
21032
|
},
|
|
21020
21033
|
"warning": {
|
|
21021
21034
|
"light": "#f59e0b",
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webority-phone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.133.0",
|
|
4
4
|
"platform": "Phone",
|
|
5
5
|
"kitModuleVersion": 2,
|
|
6
6
|
"rendererProtocolVersion": 13,
|
|
7
7
|
"library": {
|
|
8
8
|
"name": "@webority/mobile-ui",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.133.0"
|
|
10
10
|
},
|
|
11
11
|
"files": {
|
|
12
12
|
"manifest.json": {
|
|
13
|
-
"sha256": "
|
|
14
|
-
"bytes":
|
|
13
|
+
"sha256": "b162bbd39238c17412c39a8c70888cb8252d03fcf8ba95e1ac72d4ee7370ef11",
|
|
14
|
+
"bytes": 663823
|
|
15
15
|
},
|
|
16
16
|
"kit.js": {
|
|
17
|
-
"sha256": "
|
|
18
|
-
"bytes":
|
|
17
|
+
"sha256": "a75d6d7ebe4fdfdb55863d16edc0eb9fac10f27a3bd8580f750c8129ea5d5949",
|
|
18
|
+
"bytes": 6111202
|
|
19
19
|
},
|
|
20
20
|
"kit.css": {
|
|
21
21
|
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.touchEntry=exports.setAuthedImageCacheLimit=exports.removeEntry=exports.releaseFetch=exports.readEntry=exports.isPermanentRefusal=exports.isFresh=exports.getAuthedImageCacheLimit=exports.flushAuthedImageIndex=exports.deriveCacheKey=exports.clearAuthedImageCache=exports.authedImageCacheStats=exports.acquireFetch=exports.DEFAULT_TTL_MS=exports.AuthedImageHttpError=void 0;var _mobileCore=require("@webority/mobile-core"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.touchEntry=exports.setAuthedImageCacheLimit=exports.removeEntry=exports.releaseFetch=exports.readEntry=exports.isPermanentRefusal=exports.isFresh=exports.getAuthedImageCacheLimit=exports.flushAuthedImageIndex=exports.deriveCacheKey=exports.clearAuthedImageCache=exports.authedImageCacheStats=exports.acquireFetch=exports.DEFAULT_TTL_MS=exports.AuthedImageHttpError=void 0;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native"),_hashString=require("../../utils/hashString.js"),_imageStore=require("./imageStore");const INDEX_KEY="@webority/authed-image/v2/index",LEGACY_PREFIX="@webority/authed-image/v1/",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3,DEFAULT_TTL_MS=exports.DEFAULT_TTL_MS=6048e5;let byteCeiling=52428800;const setAuthedImageCacheLimit=e=>{if(!Number.isFinite(e)||e<=0)throw new Error(`[@webority/mobile-ui] setAuthedImageCacheLimit() needs a positive number of bytes, received ${String(e)}. Pass e.g. 50 * 1024 * 1024 for 50 MB.`);byteCeiling=e};exports.setAuthedImageCacheLimit=setAuthedImageCacheLimit;const getAuthedImageCacheLimit=()=>byteCeiling;exports.getAuthedImageCacheLimit=getAuthedImageCacheLimit;const deriveCacheKey=(e,t)=>(0,_hashString.hashString)(t??e);exports.deriveCacheKey=deriveCacheKey;const toMeta=({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s})=>({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s});let index=null,indexBytes=0,indexLoad=null,persistTimer=null,persistTarget=null,appStateSub=null;const persistIndex=async e=>{if(!(0,_mobileCore.isStorageAvailable)())return;const t={};for(const[r,s]of e)t[r]={...s,persistedAccessAt:s.lastAccessedAt};if(await _mobileCore.Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=_reactNative.AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))},flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};exports.flushAuthedImageIndex=flushAuthedImageIndex;const removeLegacyEntries=async()=>{const e=(await _mobileCore.Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await _mobileCore.Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of(0,_imageStore.listImageNames)())t.has(e)||(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!(0,_mobileCore.isStorageAvailable)())return e;const t=await _mobileCore.Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{for(const[r,s]of Object.entries(JSON.parse(t)))e.set(r,s)}catch{}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,r]of e)(0,_imageStore.imageExists)(r.fileName)||e.delete(t);return index=e,indexBytes=[...e.values()].reduce((e,t)=>e+t.bytes,0),e}).finally(()=>{indexLoad=null})),indexLoad),deleteFile=e=>{try{(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}},readEntry=async e=>{const t=await loadIndex(),r=t.get(e);return r?(0,_imageStore.imageExists)(r.fileName)?{fileUri:(0,_imageStore.imageUri)(r.fileName),meta:toMeta(r)}:(t.delete(e),indexBytes-=r.bytes,schedulePersist(t),null):null};exports.readEntry=readEntry;const removeEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(t.delete(e),indexBytes-=r.bytes,deleteFile(r.fileName),schedulePersist(t))};exports.removeEntry=removeEntry;class AuthedImageHttpError extends Error{constructor(e,t){super(e),this.name="AuthedImageHttpError",this.status=t}}exports.AuthedImageHttpError=AuthedImageHttpError;const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;exports.isPermanentRefusal=isPermanentRefusal;const isFresh=(e,t,r=Date.now())=>r-e.fetchedAt<t;exports.isFresh=isFresh;const touchEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(r.lastAccessedAt=Date.now(),r.lastAccessedAt-r.persistedAccessAt>=36e5&&schedulePersist(t))};exports.touchEntry=touchEntry;const evictIfNeeded=e=>{let t=indexBytes;if(t<=byteCeiling)return 0;const r=[...e].sort(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);let s=0;for(const[i,a]of r){if(t<=byteCeiling)break;e.delete(i),indexBytes-=a.bytes,deleteFile(a.fileName),t-=a.bytes,s+=1}return s},clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,(0,_imageStore.clearImages)(),(0,_mobileCore.isStorageAvailable)()&&await _mobileCore.Storage.removeItem(INDEX_KEY)};exports.clearAuthedImageCache=clearAuthedImageCache;const authedImageCacheStats=async()=>{const e=await loadIndex();let t=0;for(const r of e.values())t+=r.bytes;return{entries:e.size,bytes:t}};exports.authedImageCacheStats=authedImageCacheStats;const responseHeader=(e,t)=>{if(!e||"object"!=typeof e)return;const r=e.get,s="function"==typeof r?r.call(e,t):e[t];return"string"==typeof s?s:void 0},originOf=e=>{const t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);return t?t[1].toLowerCase():null},isOwnApiAddress=e=>{const t=originOf(e);if(null===t)return!0;const r=(0,_mobileCore.getConfigValue)("baseUrl");return"string"==typeof r&&originOf(r)===t},fetchAndStore=async(e,t,r)=>{const s={Accept:"image/*",...t.headers};if(!t.client&&t.authenticated&&isOwnApiAddress(t.uri)){const e=await(0,_mobileCore.getToken)(_mobileCore.ACCESS_TOKEN_KEY);e?.token&&(s.Authorization=`Bearer ${e.token}`)}const i=t.client??_mobileCore.publicClient;let a;try{a=await i.get(t.uri,{headers:s,responseType:"arraybuffer",signal:r})}catch(e){const r=e?.response?.status;if("number"!=typeof r)throw e;throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered ${r}. Check the URL and whether the request needs to be signed in (pass the signed-in client as \`client\`, or authenticated={false} for public media).`,r)}const o=new Uint8Array(a.data??new ArrayBuffer(0));if(0===o.byteLength)throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered with an empty body, so the address holds no image.`,404);const n=responseHeader(a.headers,"content-type"),l=(n?n.split(";")[0].trim():"")||"image/jpeg",c=await loadIndex(),d=Date.now(),u=`${e}-${d.toString(36)}`;let h;try{h=(0,_imageStore.writeImage)(u,o,l)}catch(e){throw new Error(`[@webority/mobile-ui] AuthedImage fetched "${t.uri}" but could not write it to the app's cache folder: ${e instanceof Error?e.message:String(e)}. The device may be out of storage.`)}const m={fetchedAt:d,bytes:o.byteLength,contentType:l,lastAccessedAt:d,fileName:u,persistedAccessAt:d},g=c.get(e);g&&(indexBytes-=g.bytes),c.set(e,m),indexBytes+=m.bytes,g&&g.fileName!==u&&deleteFile(g.fileName);const p=evictIfNeeded(c);return schedulePersist(c),p>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:h,meta:toMeta(m)}},inFlight=new Map,acquireFetch=(e,t)=>{const r=inFlight.get(e);if(r)return r.waiters+=1,r;const s=new AbortController,i={controller:s,waiters:1,promise:Promise.resolve()};return i.promise=fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)}),inFlight.set(e,i),i};exports.acquireFetch=acquireFetch;const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};exports.releaseFetch=releaseFetch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeImage=exports.listImageNames=exports.imageUri=exports.imageExists=exports.deleteImage=exports.clearImages=void 0;var _expoFileSystem=require("expo-file-system");const FOLDER="authed-images",imageFile=e=>new _expoFileSystem.File(_expoFileSystem.Paths.cache,FOLDER,e),writeImage=(e,t,s)=>{const i=imageFile(e);return i.create({intermediates:!0,overwrite:!0}),i.write(t),i.uri};exports.writeImage=writeImage;const imageUri=e=>imageFile(e).uri;exports.imageUri=imageUri;const imageExists=e=>imageFile(e).exists;exports.imageExists=imageExists;const deleteImage=e=>{const t=imageFile(e);t.exists&&t.delete()};exports.deleteImage=deleteImage;const listImageNames=()=>{const e=new _expoFileSystem.Directory(_expoFileSystem.Paths.cache,FOLDER);return e.exists?e.list().map(e=>e.uri.slice(e.uri.lastIndexOf("/")+1)):[]};exports.listImageNames=listImageNames;const clearImages=()=>{const e=new _expoFileSystem.Directory(_expoFileSystem.Paths.cache,FOLDER);e.exists&&e.delete()};exports.clearImages=clearImages;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeImage=exports.listImageNames=exports.imageUri=exports.imageExists=exports.deleteImage=exports.clearImages=void 0;const urls=new Map,writeImage=(e,s,t)=>{const r=urls.get(e);void 0!==r&&URL.revokeObjectURL(r);const a=URL.createObjectURL(new Blob([s],{type:t}));return urls.set(e,a),a};exports.writeImage=writeImage;const imageUri=e=>urls.get(e)??"";exports.imageUri=imageUri;const imageExists=e=>urls.has(e);exports.imageExists=imageExists;const deleteImage=e=>{const s=urls.get(e);void 0!==s&&(URL.revokeObjectURL(s),urls.delete(e))};exports.deleteImage=deleteImage;const listImageNames=()=>[...urls.keys()];exports.listImageNames=listImageNames;const clearImages=()=>{for(const e of urls.values())URL.revokeObjectURL(e);urls.clear()};exports.clearImages=clearImages;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_COMPOSER_LABELS=exports.Composer=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useControllableState=require("../../hooks/useControllableState.js"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index2=require("../IconButton/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_COMPOSER_LABELS=exports.DEFAULT_COMPOSER_LABELS=Object.freeze({send:"Send",message:"Message"}),MIN_BOX=44,RING_MS=900,RING_WIDTH=1.5,Composer=exports.Composer=(0,_react.forwardRef)(({onSend:e,value:t,onChangeText:a,placeholder:i,accessibilityLabel:o,hint:r,labels:s,loading:n=!1,onStop:l,stopLabel:d="Stop",disabled:c=!1,canSend:u,ring:_=!1,sendReveal:b="always",
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_COMPOSER_LABELS=exports.Composer=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useControllableState=require("../../hooks/useControllableState.js"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index2=require("../IconButton/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_COMPOSER_LABELS=exports.DEFAULT_COMPOSER_LABELS=Object.freeze({send:"Send",message:"Message"}),MIN_BOX=44,RING_MS=900,RING_WIDTH=1.5,Composer=exports.Composer=(0,_react.forwardRef)(({onSend:e,value:t,onChangeText:a,placeholder:i,accessibilityLabel:o,hint:r,labels:s,loading:n=!1,onStop:l,stopLabel:d="Stop",disabled:c=!1,canSend:u,ring:_=!1,sendReveal:b="always",sendIcon:p="send",maxLength:m,maxLines:x=5,leading:g,trailing:v,above:h,below:S,keyboardAware:C=!0,keyboardOffset:f,safeArea:y=!0,autoFocus:N,haptic:R,style:j,testID:A},L)=>{const E=(0,_index.useTheme)(),O=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),M=(0,_react.useMemo)(()=>buildStyles(E),[E]),w=s?{...DEFAULT_COMPOSER_LABELS,...s}:DEFAULT_COMPOSER_LABELS,[D,I]=(0,_useControllableState.useControllableState)({value:t,defaultValue:"",onChange:a}),T=D.trim(),B=n&&void 0!==l,F=n||c||!(u??""!==T),q=y?O.bottom:0,k=f??q,V=(0,_FieldBase.resolveFieldTextStyle)(E,{disabled:c}),P=E.text.base.size,z=Math.round(P*E.leading.body),H=(44-z)/2,U=z*x+2*H,[W,K]=(0,_react.useState)(void 0),$=(0,_react.useCallback)(e=>{const t=e.nativeEvent.contentSize.height+2*H;K(Math.min(Math.max(t,44),U))},[H,U]),G=(0,_useReducedMotion.useReducedMotion)(),X=(0,_react.useRef)(new _reactNative.Animated.Value(0)).current;(0,_react.useEffect)(()=>{if(!_||G)return void X.setValue(_?1:0);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(X,{toValue:1,duration:900,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:!1}),_reactNative.Animated.timing(X,{toValue:0,duration:900,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:!1})]));return e.start(),()=>e.stop()},[_,G,X]);const J=_?{borderWidth:1.5,borderColor:X.interpolate({inputRange:[0,1],outputRange:[E.colors["border-subtle"],E.colors.primary]})}:null,Q="always"===b||n||""!==D||!0===u,Y=(0,_react.useCallback)(()=>{B?l?.():F||(I(""),e(T))},[B,l,F,I,e,T]),Z=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[M.bar,{paddingBottom:E.space.sm+q},j],testID:A,children:[h,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:M.row,children:[g,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[M.box,c?M.boxDisabled:null,J],testID:A?`${A}-box`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:L,value:D,onChangeText:I,multiline:!0,maxLength:m,editable:!c,autoFocus:N,placeholder:i??w.message,placeholderTextColor:V.placeholderColor,selectionColor:E.colors["field-caret"],accessibilityLabel:o??i??w.message,accessibilityHint:r,accessibilityState:{disabled:c},"aria-disabled":c,onContentSizeChange:"web"===_reactNative.Platform.OS?$:void 0,style:[M.input,{color:V.color,...V.weightStyle,fontSize:P,lineHeight:z,paddingVertical:H,maxHeight:U,height:"web"===_reactNative.Platform.OS?W:void 0}],testID:A?`${A}-input`:void 0})}),v,Q?(0,_jsxRuntime.jsx)(_index2.IconButton,{icon:B?"stop":p,accessibilityLabel:B?d:w.send,variant:"solid",tone:"primary",disabled:B?c:F,loading:n&&!B,haptic:R,onPress:Y,testID:A?`${A}-send`:void 0}):null]}),S]});return C?(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardStickyView,{offset:{closed:0,opened:k},children:Z}):Z});Composer.displayName="Composer";const buildStyles=e=>_reactNative.StyleSheet.create({bar:{gap:e.space.xs,paddingHorizontal:e.space.md,paddingTop:e.space.sm,backgroundColor:e.colors.bg,borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:e.colors["border-subtle"]},row:{flexDirection:"row",alignItems:"flex-end",gap:e.space.sm},box:{flex:1,minHeight:44,justifyContent:"center",backgroundColor:e.colors["field-bg"],borderRadius:e.radius.pill,..._corners.smoothCorners,paddingHorizontal:e.space.md},boxDisabled:{backgroundColor:e.colors["field-bg-disabled"]},input:{margin:e.space.none,paddingHorizontal:e.space.none,includeFontPadding:!1,textAlignVertical:"top"}});var _default=exports.default=Composer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ScannerOverlay=exports.DEFAULT_SCANNER_OVERLAY_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../IconButton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ScannerOverlay=exports.DEFAULT_SCANNER_OVERLAY_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../IconButton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}],DEFAULT_SCANNER_OVERLAY_LABELS=exports.DEFAULT_SCANNER_OVERLAY_LABELS=Object.freeze({hint:"Point the camera at the code",found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."}),ScannerOverlay=exports.ScannerOverlay=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:n,state:i="scanning",helperText:a,labels:r,torch:s=!1,onTorchChange:o,onManualEntry:l,onGallery:c,onPermissionAction:u,frameSize:d=DEFAULT_FRAME,haptic:m,style:_,testID:h}=e,x=(0,_index.useTheme)(),p=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),v=(0,_useReducedMotion.useReducedMotion)(),f=(0,_react.useMemo)(()=>buildStyles(x),[x]),g=(0,_react.useMemo)(()=>({...DEFAULT_SCANNER_OVERLAY_LABELS,...r}),[r]),y=a??g.hint,[j,b]=(0,_react.useState)({width:0,height:0}),[R,A]=(0,_react.useState)(0),E="scanning"===i||"found"===i||"invalid"===i,N=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,S=x.motion.duration.slower,w=x.motion.duration.default;(0,_react.useEffect)(()=>{if(N.setValue(1),v)return;let e;return"scanning"===i&&S>0?e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(N,{toValue:1.03,duration:2*S,useNativeDriver:!0}),_reactNative.Animated.timing(N,{toValue:1,duration:2*S,useNativeDriver:!0})])):"found"===i&&w>0&&(N.setValue(1.08),e=_reactNative.Animated.timing(N,{toValue:1,duration:w,useNativeDriver:!0})),e?.start(),()=>e?.stop()},[i,v,S,w,N]);const V=(0,_react.useRef)(i);(0,_react.useEffect)(()=>{V.current!==i&&(V.current=i,!1!==m&&("found"===i?(0,_hapticUtils.triggerHaptic)("notificationSuccess"):"invalid"===i&&(0,_hapticUtils.triggerHaptic)("notificationError")))},[i,m]);const{found:C,invalid:L}=g,{noPermissionTitle:M,noPermissionMessage:O}=g,{noCameraTitle:I,noCameraMessage:P}=g;(0,_react.useEffect)(()=>{switch(i){case"scanning":(0,_announce.announce)(y);break;case"found":(0,_announce.announce)(C);break;case"invalid":(0,_announce.announce)(L,{polite:!1});break;case"noPermission":(0,_announce.announce)(`${M}. ${O}`);break;case"noCamera":(0,_announce.announce)(`${I}. ${P}`)}},[i,y,C,L,M,O,I,P]);const k=Math.max(240,Math.min(d,j.width-2*x.space.xl)),q=(j.width-k)/2,F=Math.max(x.space.md,(j.height-R-k)/2),B=j.width>0&&j.height>0,D={borderColor:"found"===i?x.colors.success:"invalid"===i?x.colors.danger:x.colors["on-scrim"],width:32,height:32},U="found"===i||"invalid"===i?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[f.pill,{backgroundColor:"found"===i?x.colors.success:x.colors.danger}],children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===i?x.colors["on-success"]:x.colors["on-danger"]},children:"found"===i?C:L})}):(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",align:"center",style:{color:x.colors["on-scrim"]},children:y}),z=E&&null!=o,H=E?"glass":"outline";return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,testID:h,onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;b(e=>e.width===t&&e.height===n?e:{width:t,height:n})},style:[f.root,!E&&{backgroundColor:x.colors.bg},_],children:[E?(0,_jsxRuntime.jsx)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,children:n}):null,E&&B?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",style:_reactNative.StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[f.scrim,{left:0,right:0,top:0,height:F}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[f.scrim,{left:0,right:0,top:F+k,bottom:0}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[f.scrim,{left:0,width:q,top:F,height:k}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[f.scrim,{left:q+k,right:0,top:F,height:k}]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{position:"absolute",left:q,top:F,width:k,height:k,transform:[{scale:N}]},children:CORNERS.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[f.mark,D,e.style]},e.key))})]})}):null,E?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:f.panel,children:(0,_jsxRuntime.jsx)(_index4.EmptyState,{fill:!0,icon:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"noPermission"===i?"camera":"camera-slash",size:48,color:x.colors["text-subtle"]}),title:"noPermission"===i?M:I,description:"noPermission"===i?O:P,action:"noPermission"===i&&u?{label:g.permissionAction,onPress:u}:void 0})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"box-none",onLayout:e=>{const{height:t}=e.nativeEvent.layout;A(e=>e===t?e:t)},style:[f.bar,{paddingBottom:Math.max(p.bottom,x.space.md)}],children:[E&&B?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:f.message,children:U}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:f.actions,children:[z?(0,_jsxRuntime.jsx)(_index5.IconButton,{icon:s?"flash":"flash-slash",variant:"glass",size:"lg",active:s,haptic:m,accessibilityLabel:s?g.torchOff:g.torchOn,onPress:()=>o?.(!s)}):null,c?(0,_jsxRuntime.jsx)(_index3.Button,{label:g.gallery,leftIcon:"gallery",variant:H,tone:"neutral",size:"lg",haptic:m,onPress:c}):null,l?(0,_jsxRuntime.jsx)(_index3.Button,{label:g.manualEntry,leftIcon:"keyboard",variant:H,tone:"neutral",size:"lg",haptic:m,onPress:l}):null]})]})]})});ScannerOverlay.displayName="ScannerOverlay";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.scrim},mark:{position:"absolute"},message:{alignItems:"center",paddingHorizontal:e.space.xl},pill:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners},panel:{..._reactNative.StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.space.sm,paddingHorizontal:e.space.md},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.space.sm}});var _default=exports.default=ScannerOverlay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SegmentedControl=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../FieldBase/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];default:return e.colors["info-text"]}},SegmentedControl=exports.SegmentedControl=(0,_react.forwardRef)((e,t)=>{const{segments:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SegmentedControl=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../FieldBase/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];default:return e.colors["info-text"]}},SegmentedControl=exports.SegmentedControl=(0,_react.forwardRef)((e,t)=>{const{segments:i,label:r,helperText:n,error:l,value:s,defaultValue:a,onChange:o,size:d="md",fullWidth:c=!0,disabled:u=!1,tone:m="primary",variant:x="segmented",radius:h,labelLines:g=1,haptic:_,accessibilityLabel:b,style:p,containerStyle:v,segmentStyle:f,selectedIndicatorStyle:y,textStyle:S,labelStyle:j,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","variant",e.variant,["underline","pills","segmented"]);const[I,C]=(0,_index.useControllableState)({value:s,defaultValue:a??i[0]?.value,onChange:o}),R=(0,_index2.useTheme)(),V=R.components["segmented-control"],q=(0,_react.useMemo)(()=>buildStyles(R),[R]),k=(0,_react.useMemo)(()=>(0,_index2.resolveSegmentedControlSize)(R,d),[R,d]),F=g>=2?2:1,L=F>1,N="segmented"===x,z="underline"===x,M="pills"===x,T=N?R.space[V["track-padding"]]:0,E=Math.ceil(1.25*k.text)*(F-1),A=V["underline-height"],D=R.space[V["pill-inset"]],H="number"==typeof h?h:h?R.radius[h]:void 0,B=H??R.radius.md,W=void 0===H?R.radius.sm:Math.max(H-T,0),P=H??R.radius.pill,O=H??R.radius.none,[G,X]=(0,_react.useState)([]),J=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,K=Math.max(0,i.findIndex(e=>e.value===I)),Q=G[K],U=Q?.x,Y=(0,_react.useCallback)(e=>{const t=R.motion.spring.snappy,i=_reactNative.Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!0});return i.start(),i},[R.motion.spring.snappy,J]);(0,_react.useEffect)(()=>{X(e=>e.length===i.length||0===e.length?e:[])},[i.length]);const Z=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(void 0===U)return;const e=null!==Z.current&&Z.current!==K;if(Z.current=K,!e)return void J.setValue(U);const t=Y(U);return()=>t.stop()},[K,U,Y,J]);const $=(0,_react.useCallback)((e,t)=>{const{x:i,width:r}=t.nativeEvent.layout;X(t=>{const n=t[e];if(n&&n.x===i&&n.width===r)return t;const l=t.slice();return l[e]={x:i,width:r},l})},[]),ee=(0,_react.useCallback)(e=>{if(u)return;if(e.value===I)return;const t=(0,_index3.resolveHaptic)(_,"selection");t&&(0,_index3.triggerHaptic)(t),C(e.value)},[u,C,I,_]),te=N?R.colors.thumb:M?R.colors["primary-soft"]:R.colors.primary,ie=N?W:M?P:O,re=activeInkFor(R,m),ne=R.colors["bg-muted"],le=(0,_SquircleFill.useSquircle)(N,B),se=!0===l||(0,_index4.hasFieldText)(l),ae=se&&!u,oe=R.colors["field-border-error"],de=R.size.border,ce=(0,_index4.hasFieldText)(r),ue=se?l:n,me=(0,_index4.hasFieldText)(ue),xe=b??("string"==typeof r?r:void 0),he=(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:xe,testID:w,style:[q.track,{...L?{minHeight:k.height+E}:{height:k.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},N?{borderRadius:B,..._corners.smoothCorners,backgroundColor:le.active?"transparent":ne,padding:T}:z?{borderBottomColor:ae?oe:R.colors["border-subtle"],borderBottomWidth:_reactNative.StyleSheet.hairlineWidth}:null,v,p],onLayout:le.onLayout,children:[le.active&&le.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:le.size.width,height:le.size.height,radius:B,fill:ne,stroke:ae?oe:void 0,strokeWidth:de}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:q.row,children:[Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[q.thumb,N?L?{top:0,bottom:0}:{top:0,height:k.height-2*T}:M?{top:D,bottom:D,left:D}:{bottom:0,height:A},{width:M?Math.max(Q.width-2*D,0):Q.width,borderRadius:ie,..._corners.smoothCorners,backgroundColor:te,transform:[{translateX:J}]},y]}):null,i.map((e,t)=>{const i=e.value===I,r=i?re:R.colors["text-subtle"],n=(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:k.icon,selected:i,disabled:u});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>ee(e),onLayout:e=>$(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:i,selected:i,disabled:u},"aria-checked":i,"aria-disabled":u,style:({pressed:e})=>[q.segment,L?q.segmentMultiline:null,{paddingHorizontal:k["padding-x"],opacity:e&&!i?.7:1},f],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:q.segmentIcon,children:n}):null,(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:i?"semibold":"medium",style:[q.segmentLabel,L?q.segmentLabelMultiline:null,{color:r,fontSize:k.text},S,j],numberOfLines:F,children:e.label})]},String(e.value))})]}),!ae||z||le.active?null:(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{borderWidth:de,borderColor:oe,borderRadius:N?B:P,..._corners.smoothCorners}]})]});return ce||me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ce?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:d,children:r}):null,he,me?(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:d,text:ue,error:se}):null]}):he});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>_reactNative.StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flexGrow:1,flexShrink:1,flexBasis:"auto",flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:e.space.xs},segmentMultiline:{paddingVertical:e.space.xs},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});var _default=exports.default=SegmentedControl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Switch=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},Switch=exports.Switch=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:s,disabled:a=!1,size:n="md",tone:o="primary",label:l,description:c,helperText:d,error:u,layout:p="inline",accessibilityLabel:h,haptic:_="selection",bounce:m=!1,style:x,containerStyle:b,trackStyle:f,thumbStyle:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Switch=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},Switch=exports.Switch=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:s,disabled:a=!1,size:n="md",tone:o="primary",label:l,description:c,helperText:d,error:u,layout:p="inline",accessibilityLabel:h,haptic:_="selection",bounce:m=!1,style:x,containerStyle:b,trackStyle:f,thumbStyle:w,testID:g,hitSlop:y,...v}=e,S=(0,_index2.useTheme)(),j=Object.keys(S.components.switch);(0,_warnInvalidValue.warnInvalidValue)("Switch","size",e.size,j),(0,_warnInvalidValue.warnInvalidValue)("Switch","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Switch","layout",e.layout,["inline","row"]);const[R,N]=(0,_index.useControllableState)({value:i,defaultValue:r??!1,onChange:s}),T=j.includes(n)?n:"md",V=(0,_react.useMemo)(()=>(0,_index2.resolveSwitchSize)(S,T),[S,T]),C=S.colors["switch-thumb"],k=(0,_react.useMemo)(()=>buildStyles(S),[S]),A="dark"===S.mode?S.colors.neutral:S.colors["surface-disabled"],I=toneColor(S,o),q=y??8,F=(0,_react.useRef)((0,_index2.createAnimatedValue)(R?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.spring(F,{toValue:R?1:0,damping:S.motion.spring.snappy.damping,stiffness:S.motion.spring.snappy.stiffness,mass:S.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[R,F,S.motion.spring.snappy]);const B=(0,_react.useRef)((0,_index2.createAnimatedValue)(R?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(B,{toValue:R?1:0,duration:S.motion.duration.fast,easing:_reactNative.Easing.out(_reactNative.Easing.ease),useNativeDriver:!1});return e.start(),()=>e.stop()},[R,B,S.motion.duration.fast]);const D=V.padding,z=V["track-width"]-V["thumb-size"]-V.padding,E=F.interpolate({inputRange:[0,1],outputRange:[D,z]}),H=B.interpolate({inputRange:[0,1],outputRange:[A,I]}),P=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,M=(0,_react.useRef)(!0);(0,_react.useEffect)(()=>{if(!m)return;if(M.current)return void(M.current=!1);const e=_reactNative.Animated.sequence([_reactNative.Animated.spring(P,{toValue:1.15,damping:10,stiffness:220,mass:1,useNativeDriver:!0}),_reactNative.Animated.spring(P,{toValue:1,damping:14,stiffness:240,mass:1,useNativeDriver:!0})]);return e.start(),()=>e.stop()},[R,m,P]);const handlePress=e=>{a||(!1!==_&&(0,_hapticUtils.triggerHaptic)(_),N(!R),v.onPressOut?.(e))},L=h??(0,_FieldBase.fieldTextAsString)(l),O="string"==typeof u?u:void 0,U=(0,_ChoiceText.hasChoiceDetail)({description:c,error:O,helperText:d}),W=(0,_FieldBase.hasFieldText)(l)||U,X=(!0===u||(0,_FieldBase.hasFieldText)(u))&&!R&&!a,G="row"===p&&W,J=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[k.track,{width:V["track-width"],height:V["track-height"],borderRadius:S.radius.pill,..._corners.smoothCorners,backgroundColor:H},f],children:[X?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[k.errorRing,{borderRadius:S.radius.pill,..._corners.smoothCorners,borderWidth:S.size.border,borderColor:S.colors["field-border-error"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[k.thumb,S.shadow.card,{backgroundColor:C,width:V["thumb-size"],height:V["thumb-size"],borderRadius:S.radius.pill,..._corners.smoothCorners,transform:[{translateX:E},{scale:P}]},w]})]});if(G)return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:handlePress,disabled:a,accessibilityRole:"switch",accessibilityLabel:L,accessibilityHint:v.accessibilityHint??(0,_FieldBase.fieldTextAsString)(c),accessibilityState:{checked:R,disabled:a},"aria-checked":R,"aria-disabled":a,testID:g,hitSlop:y,...null==y?{}:(0,_hitSlop.hitSlopMarker)(y),...v,style:({pressed:e})=>[k.row,k.spreadRow,U?k.rowTop:null,{opacity:a?.55:e?.9:1},b,x],children:[(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:l,description:c,helperText:d,error:O,disabled:a,style:k.spreadText}),J]});const K=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:handlePress,disabled:a,accessibilityRole:"switch",accessibilityLabel:L,accessibilityHint:v.accessibilityHint??(0,_FieldBase.fieldTextAsString)(c),accessibilityState:{checked:R,disabled:a},"aria-checked":R,"aria-disabled":a,testID:g,hitSlop:q,...(0,_hitSlop.hitSlopMarker)(q),...v,style:({pressed:e})=>[{opacity:a?.55:e?.9:1},W?null:x],children:J});return W?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[k.row,U?k.rowTop:null,b,x],children:[K,(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:l,description:c,helperText:d,error:O,disabled:a,style:k.text})]}):b?(0,_jsxRuntime.jsx)(_reactNative.View,{style:b,children:K}):K});Switch.displayName="Switch";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},track:{justifyContent:"center"},thumb:{position:"absolute",top:2},errorRing:{..._reactNative.StyleSheet.absoluteFill},rowTop:{alignItems:"flex-start"},text:{marginLeft:e.space.sm},spreadRow:{minHeight:44,justifyContent:"space-between"},spreadText:{flex:1,marginRight:e.space.md}});var _default=exports.default=Switch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.lightTokens=exports.darkTokens=exports.WEIGHT_NAMES=exports.TEXT_NAMES=exports.SPACE_NAMES=exports.SIZE_NAMES=exports.SHADOW_NAMES=exports.RADIUS_NAMES=exports.LETTER_SPACING_NAMES=exports.LEADING_NAMES=exports.FONT_NAMES=exports.EASE_NAMES=exports.DURATION_NAMES=exports.COMPONENT_KINDS=exports.COLOR_NAMES=void 0;const COLOR_NAMES=exports.COLOR_NAMES=["bg","bg-subtle","bg-muted","surface","surface-inverse","surface-dark","surface-dark-border","on-surface-dark","on-surface-dark-muted","text","text-body","text-muted","text-subtle","text-inverse","link","border","border-subtle","field-bg","field-border","field-border-focus","focus-ring","scrim","on-scrim","thumb","primary","primary-hover","primary-soft","primary-text","on-primary","primary-wash","primary-wash-strong","neutral","neutral-hover","neutral-text","on-neutral","success","success-soft","success-text","on-success","warning","warning-soft","warning-text","on-warning","danger","danger-soft","danger-border","danger-text","offline-fill","online-fill","on-danger","info","info-soft","info-text","on-info","primary-pressed","on-neutral-strong","text-disabled","surface-pressed","surface-hover","surface-selected","surface-disabled","skeleton","skeleton-highlight","glass-fill","glass-border","on-glass","glass-badge","field-bg-focus","field-bg-disabled","field-border-error","field-label","field-text","field-text-disabled","field-placeholder","field-placeholder-disabled","field-icon","field-icon-focus","field-icon-disabled","field-caret","field-message","avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],SPACE_NAMES=exports.SPACE_NAMES=["none","xxs","xs","sm","md","lg","xl","2xl","3xl","4xl"],RADIUS_NAMES=exports.RADIUS_NAMES=["none","sm","md","lg","xl","pill"],TEXT_NAMES=exports.TEXT_NAMES=["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl"],WEIGHT_NAMES=exports.WEIGHT_NAMES=["normal","medium","semibold","bold"],LEADING_NAMES=exports.LEADING_NAMES=["heading","body","display"],LETTER_SPACING_NAMES=exports.LETTER_SPACING_NAMES=["tight","normal","wide"],FONT_NAMES=exports.FONT_NAMES=["ui","display","mono"],SHADOW_NAMES=exports.SHADOW_NAMES=["card","elevated","popover","modal","drawer"],DURATION_NAMES=exports.DURATION_NAMES=["instant","fast","default","slow","slower"],EASE_NAMES=exports.EASE_NAMES=["in-out","accelerate","decelerate","sharp"],SIZE_NAMES=exports.SIZE_NAMES=["border"],COMPONENT_KINDS=exports.COMPONENT_KINDS={field:{radius:"radius","padding-x":"space","padding-y":"space","min-height":"px",text:"text",icon:"px","label-text":"text","label-gap":"space","message-text":"text","message-gap":"space"},press:{opacity:"number"},disabled:{opacity:"number"},button:{"padding-x":"space","padding-y":"space","min-height":"px",text:"text",radius:"radius",icon:"px","badge-icon":"px"},input:{"multiline-min-height":"px"},"search-bar":{radius:"radius"},"empty-state":{icon:"px","illustration-size":"px","title-text":"text","description-text":"text","padding-y":"space","title-gap":"space","description-gap":"space"},"list-item":{"padding-y":"space","title-text":"text","subtitle-text":"text","min-height":"px"},badge:{text:"text","min-width":"px",height:"px","padding-x":"space","dot-size":"px","border-width":"px","anchor-offset":"px"},chip:{"padding-x":"space","padding-y":"space",text:"text","min-height":"px","close-size":"px","close-text":"text",gap:"space",icon:"px"},checkbox:{"box-size":"px","label-gap":"space"},radio:{outer:"px",inner:"px","label-gap":"space"},switch:{"track-width":"px","track-height":"px","thumb-size":"px",padding:"space"},"otp-input":{cell:"px",text:"text",radius:"radius",gap:"space"},"segmented-control":{height:"px",text:"text","padding-x":"space",icon:"px","track-padding":"space","underline-height":"px","pill-inset":"space"},tabs:{text:"text","padding-y":"space","padding-x":"space","scrollable-padding-x":"space",icon:"px","icon-gap":"space","track-padding":"space","underline-height":"px","pill-inset":"space","disabled-opacity":"number","badge-gap":"space"},slider:{"track-height":"px","thumb-diameter":"px"},"floating-action-button":{diameter:"px",icon:"px",text:"text","label-padding-x":"space","edge-offset":"space","bottom-offset":"space","secondary-gap":"space","stagger-ms":"ms"},dialog:{"icon-wrapper-size":"px","action-button-min-height":"px"},toast:{"icon-circle-size":"px","icon-glyph-text":"text","tint-bar-width":"px","action-min-height":"px"},banner:{"tint-bar-width":"px"},screen:{gutter:"space"}},lightTokens=exports.lightTokens={mode:"light",colors:{bg:"#ffffff","bg-subtle":"#f8f8fb","bg-muted":"#f1f1f5",surface:"#ffffff","surface-inverse":"#0f0f1a","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7",text:"#252f4a","text-body":"#0f0f1a","text-muted":"#52525b","text-subtle":"#62626b","text-inverse":"#ffffff",link:"#5b5bd6",border:"#e5e5ec","border-subtle":"#efeff3","field-bg":"#f9fbfc","field-border":"#ebedf3","field-border-focus":"#bed2f9","focus-ring":"#5b5bd6",scrim:"#0f0f1a80","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#5b5bd6","primary-hover":"#4f4fbf","primary-soft":"#eeeefc","primary-text":"#4f4fd3","on-primary":"#ffffff","primary-wash":"#5b5bd614","primary-wash-strong":"#5b5bd633",neutral:"#f4f4f8","neutral-hover":"#e9e9f0","neutral-text":"#52525b","on-neutral":"#0f0f1a",success:"#18864f","success-soft":"#e8faee","success-text":"#147042","on-success":"#ffffff",warning:"#f59e0b","warning-soft":"#fff8e6","warning-text":"#8f5c06","on-warning":"#0f0f1a",danger:"#e12c32","danger-soft":"#ffeaef","danger-border":"#e5484d","danger-text":"#bc1b20","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#ffffff",info:"#1b6ef5","info-soft":"#e9f3ff","info-text":"#0958d9","on-info":"#ffffff","primary-pressed":"#4040a8","on-neutral-strong":"#ffffff","text-disabled":"#b4b4bb","surface-pressed":"#0f0f1a0f","surface-hover":"#0f0f1a0a","surface-selected":"#5b5bd61a","surface-disabled":"#f1f1f5",skeleton:"#ebedf3","skeleton-highlight":"#f5f6fa","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#ffffff","field-bg-disabled":"#f5f6fa","field-border-error":"#fdbfce","field-label":"#242f4a","field-text":"#252f4a","field-text-disabled":"#7a8197","field-placeholder":"#626d8b","field-placeholder-disabled":"#7a8197","field-icon":"#7a849f","field-icon-focus":"#4b5675","field-icon-disabled":"#c4cada","field-caret":"#5b8dee","field-message":"#d81736","avatar-1":"#5b5bd6","avatar-2":"#0a7979","avatar-3":"#a45a05","avatar-4":"#cd226e","avatar-5":"#2462eb","avatar-6":"#7c3aed","avatar-7":"#047c57","avatar-8":"#d42222"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.059,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.078,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.102,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":34,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":44,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":58,text:"xl",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}},darkTokens=exports.darkTokens={mode:"dark",colors:{bg:"#0b0b12","bg-subtle":"#13131c","bg-muted":"#1c1c26",surface:"#1c1c26","surface-inverse":"#fafafa","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7",text:"#e2e2e2","text-body":"#fafafa","text-muted":"#b4b4bb","text-subtle":"#919199","text-inverse":"#0f0f1a",link:"#9292ee",border:"#27272f","border-subtle":"#1c1c26","field-bg":"#13131c","field-border":"#27272f","field-border-focus":"#3d5fb0","focus-ring":"#7c7ce8",scrim:"#000000a6","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#7c7ce8","primary-hover":"#9292ee","primary-soft":"#1f1f3d","primary-text":"#8989ea","on-primary":"#0f0f1a","primary-wash":"#7c7ce814","primary-wash-strong":"#7c7ce833",neutral:"#1f1f26","neutral-hover":"#2a2a33","neutral-text":"#b4b4bb","on-neutral":"#fafafa",success:"#30c780","success-soft":"#04b4402e","success-text":"#30c780","on-success":"#0f0f1a",warning:"#fbbf24","warning-soft":"#dfa0002e","warning-text":"#fbbf24","on-warning":"#0f0f1a",danger:"#f87171","danger-soft":"#e826462e","danger-border":"#f87171","danger-text":"#f87171","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#0f0f1a",info:"#60a5fa","info-soft":"#056ee92e","info-text":"#60a5fa","on-info":"#0f0f1a","primary-pressed":"#a8a8f2","on-neutral-strong":"#0f0f1a","text-disabled":"#52525b","surface-pressed":"#ffffff14","surface-hover":"#ffffff0d","surface-selected":"#7c7ce82e","surface-disabled":"#1c1c26",skeleton:"#1c1c26","skeleton-highlight":"#27272f","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#0b0b12","field-bg-disabled":"#1c1c26","field-border-error":"#8a2f42","field-label":"#e4e6ee","field-text":"#fafafa","field-text-disabled":"#71717a","field-placeholder":"#84848d","field-placeholder-disabled":"#71717a","field-icon":"#8b8b95","field-icon-focus":"#d4d4db","field-icon-disabled":"#52525b","field-caret":"#7c9ef0","field-message":"#f87171","avatar-1":"#8b8bee","avatar-2":"#2dd4bf","avatar-3":"#fcd34d","avatar-4":"#f472b6","avatar-5":"#60a5fa","avatar-6":"#a78bfa","avatar-7":"#34d399","avatar-8":"#f87171"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.4,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.502,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.549,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":34,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":44,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":58,text:"xl",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.lightTokens=exports.darkTokens=exports.WEIGHT_NAMES=exports.TEXT_NAMES=exports.SPACE_NAMES=exports.SIZE_NAMES=exports.SHADOW_NAMES=exports.RADIUS_NAMES=exports.LETTER_SPACING_NAMES=exports.LEADING_NAMES=exports.FONT_NAMES=exports.EASE_NAMES=exports.DURATION_NAMES=exports.COMPONENT_KINDS=exports.COLOR_NAMES=void 0;const COLOR_NAMES=exports.COLOR_NAMES=["bg","bg-subtle","bg-muted","surface","surface-inverse","surface-dark","surface-dark-border","on-surface-dark","on-surface-dark-muted","text","text-body","text-muted","text-subtle","text-inverse","link","border","border-subtle","field-bg","field-border","field-border-focus","focus-ring","scrim","on-scrim","thumb","primary","primary-hover","primary-soft","primary-text","on-primary","primary-wash","primary-wash-strong","neutral","neutral-hover","neutral-text","on-neutral","success","success-soft","success-text","on-success","warning","warning-soft","warning-text","on-warning","danger","danger-soft","danger-border","danger-text","offline-fill","online-fill","on-danger","info","info-soft","info-text","on-info","primary-pressed","switch-thumb","on-neutral-strong","text-disabled","surface-pressed","surface-hover","surface-selected","surface-disabled","skeleton","skeleton-highlight","glass-fill","glass-border","on-glass","glass-badge","field-bg-focus","field-bg-disabled","field-border-error","field-label","field-text","field-text-disabled","field-placeholder","field-placeholder-disabled","field-icon","field-icon-focus","field-icon-disabled","field-caret","field-message","avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],SPACE_NAMES=exports.SPACE_NAMES=["none","xxs","xs","sm","md","lg","xl","2xl","3xl","4xl"],RADIUS_NAMES=exports.RADIUS_NAMES=["none","sm","md","lg","xl","pill"],TEXT_NAMES=exports.TEXT_NAMES=["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl"],WEIGHT_NAMES=exports.WEIGHT_NAMES=["normal","medium","semibold","bold"],LEADING_NAMES=exports.LEADING_NAMES=["heading","body","display"],LETTER_SPACING_NAMES=exports.LETTER_SPACING_NAMES=["tight","normal","wide"],FONT_NAMES=exports.FONT_NAMES=["ui","display","mono"],SHADOW_NAMES=exports.SHADOW_NAMES=["card","elevated","popover","modal","drawer"],DURATION_NAMES=exports.DURATION_NAMES=["instant","fast","default","slow","slower"],EASE_NAMES=exports.EASE_NAMES=["in-out","accelerate","decelerate","sharp"],SIZE_NAMES=exports.SIZE_NAMES=["border"],COMPONENT_KINDS=exports.COMPONENT_KINDS={field:{radius:"radius","padding-x":"space","padding-y":"space","min-height":"px",text:"text",icon:"px","label-text":"text","label-gap":"space","message-text":"text","message-gap":"space"},press:{opacity:"number"},disabled:{opacity:"number"},button:{"padding-x":"space","padding-y":"space","min-height":"px",text:"text",radius:"radius",icon:"px","badge-icon":"px"},input:{"multiline-min-height":"px"},"search-bar":{radius:"radius"},"empty-state":{icon:"px","illustration-size":"px","title-text":"text","description-text":"text","padding-y":"space","title-gap":"space","description-gap":"space"},"list-item":{"padding-y":"space","title-text":"text","subtitle-text":"text","min-height":"px"},badge:{text:"text","min-width":"px",height:"px","padding-x":"space","dot-size":"px","border-width":"px","anchor-offset":"px"},chip:{"padding-x":"space","padding-y":"space",text:"text","min-height":"px","close-size":"px","close-text":"text",gap:"space",icon:"px"},checkbox:{"box-size":"px","label-gap":"space"},radio:{outer:"px",inner:"px","label-gap":"space"},switch:{"track-width":"px","track-height":"px","thumb-size":"px",padding:"space"},"otp-input":{cell:"px",text:"text",radius:"radius",gap:"space"},"segmented-control":{height:"px",text:"text","padding-x":"space",icon:"px","track-padding":"space","underline-height":"px","pill-inset":"space"},tabs:{text:"text","padding-y":"space","padding-x":"space","scrollable-padding-x":"space",icon:"px","icon-gap":"space","track-padding":"space","underline-height":"px","pill-inset":"space","disabled-opacity":"number","badge-gap":"space"},slider:{"track-height":"px","thumb-diameter":"px"},"floating-action-button":{diameter:"px",icon:"px",text:"text","label-padding-x":"space","edge-offset":"space","bottom-offset":"space","secondary-gap":"space","stagger-ms":"ms"},dialog:{"icon-wrapper-size":"px","action-button-min-height":"px"},toast:{"icon-circle-size":"px","icon-glyph-text":"text","tint-bar-width":"px","action-min-height":"px"},banner:{"tint-bar-width":"px"},screen:{gutter:"space"}},lightTokens=exports.lightTokens={mode:"light",colors:{bg:"#ffffff","bg-subtle":"#f8f8fb","bg-muted":"#f1f1f5",surface:"#ffffff","surface-inverse":"#0f0f1a","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7",text:"#252f4a","text-body":"#0f0f1a","text-muted":"#52525b","text-subtle":"#62626b","text-inverse":"#ffffff",link:"#5b5bd6",border:"#e5e5ec","border-subtle":"#efeff3","field-bg":"#f9fbfc","field-border":"#ebedf3","field-border-focus":"#bed2f9","focus-ring":"#5b5bd6",scrim:"#0f0f1a80","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#5b5bd6","primary-hover":"#4f4fbf","primary-soft":"#eeeefc","primary-text":"#4f4fd3","on-primary":"#ffffff","primary-wash":"#5b5bd614","primary-wash-strong":"#5b5bd633",neutral:"#f4f4f8","neutral-hover":"#e9e9f0","neutral-text":"#52525b","on-neutral":"#0f0f1a",success:"#18864f","success-soft":"#e8faee","success-text":"#147042","on-success":"#ffffff",warning:"#f59e0b","warning-soft":"#fff8e6","warning-text":"#8f5c06","on-warning":"#0f0f1a",danger:"#e12c32","danger-soft":"#ffeaef","danger-border":"#e5484d","danger-text":"#bc1b20","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#ffffff",info:"#1b6ef5","info-soft":"#e9f3ff","info-text":"#0958d9","on-info":"#ffffff","primary-pressed":"#4040a8","switch-thumb":"#ffffff","on-neutral-strong":"#ffffff","text-disabled":"#b4b4bb","surface-pressed":"#0f0f1a0f","surface-hover":"#0f0f1a0a","surface-selected":"#5b5bd61a","surface-disabled":"#f1f1f5",skeleton:"#ebedf3","skeleton-highlight":"#f5f6fa","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#ffffff","field-bg-disabled":"#f5f6fa","field-border-error":"#fdbfce","field-label":"#242f4a","field-text":"#252f4a","field-text-disabled":"#7a8197","field-placeholder":"#626d8b","field-placeholder-disabled":"#7a8197","field-icon":"#7a849f","field-icon-focus":"#4b5675","field-icon-disabled":"#c4cada","field-caret":"#5b8dee","field-message":"#d81736","avatar-1":"#5b5bd6","avatar-2":"#0a7979","avatar-3":"#a45a05","avatar-4":"#cd226e","avatar-5":"#2462eb","avatar-6":"#7c3aed","avatar-7":"#047c57","avatar-8":"#d42222"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.059,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.078,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.102,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":34,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":44,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":58,text:"xl",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}},darkTokens=exports.darkTokens={mode:"dark",colors:{bg:"#0b0b12","bg-subtle":"#13131c","bg-muted":"#1c1c26",surface:"#1c1c26","surface-inverse":"#fafafa","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7",text:"#e2e2e2","text-body":"#fafafa","text-muted":"#b4b4bb","text-subtle":"#919199","text-inverse":"#0f0f1a",link:"#9292ee",border:"#27272f","border-subtle":"#1c1c26","field-bg":"#13131c","field-border":"#27272f","field-border-focus":"#3d5fb0","focus-ring":"#7c7ce8",scrim:"#000000a6","on-scrim":"#ffffff",thumb:"#3a3e49",primary:"#7c7ce8","primary-hover":"#9292ee","primary-soft":"#1f1f3d","primary-text":"#8989ea","on-primary":"#0f0f1a","primary-wash":"#7c7ce814","primary-wash-strong":"#7c7ce833",neutral:"#1f1f26","neutral-hover":"#2a2a33","neutral-text":"#b4b4bb","on-neutral":"#fafafa",success:"#30c780","success-soft":"#04b4402e","success-text":"#30c780","on-success":"#0f0f1a",warning:"#fbbf24","warning-soft":"#dfa0002e","warning-text":"#fbbf24","on-warning":"#0f0f1a",danger:"#f87171","danger-soft":"#e826462e","danger-border":"#f87171","danger-text":"#f87171","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#0f0f1a",info:"#60a5fa","info-soft":"#056ee92e","info-text":"#60a5fa","on-info":"#0f0f1a","primary-pressed":"#a8a8f2","switch-thumb":"#ffffff","on-neutral-strong":"#0f0f1a","text-disabled":"#52525b","surface-pressed":"#ffffff14","surface-hover":"#ffffff0d","surface-selected":"#7c7ce82e","surface-disabled":"#1c1c26",skeleton:"#1c1c26","skeleton-highlight":"#27272f","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#0b0b12","field-bg-disabled":"#1c1c26","field-border-error":"#8a2f42","field-label":"#e4e6ee","field-text":"#fafafa","field-text-disabled":"#71717a","field-placeholder":"#84848d","field-placeholder-disabled":"#71717a","field-icon":"#8b8b95","field-icon-focus":"#d4d4db","field-icon-disabled":"#52525b","field-caret":"#7c9ef0","field-message":"#f87171","avatar-1":"#8b8bee","avatar-2":"#2dd4bf","avatar-3":"#fcd34d","avatar-4":"#f472b6","avatar-5":"#60a5fa","avatar-6":"#a78bfa","avatar-7":"#34d399","avatar-8":"#f87171"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.4,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.502,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.549,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":34,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":44,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":58,text:"xl",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{ACCESS_TOKEN_KEY,getConfigValue,getToken,isStorageAvailable,Logger,publicClient,Storage}from"@webority/mobile-core";import{
|
|
1
|
+
"use strict";import{ACCESS_TOKEN_KEY,getConfigValue,getToken,isStorageAvailable,Logger,publicClient,Storage}from"@webority/mobile-core";import{AppState}from"react-native";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;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{for(const[s,r]of Object.entries(JSON.parse(t)))e.set(s,r)}catch{}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),this.name="AuthedImageHttpError",this.status=t}}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(!e||"object"!=typeof 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);return t?t[1].toLowerCase():null},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=e?.response?.status;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).`,s)}const n=new Uint8Array(a.data??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.`,404);const o=responseHeader(a.headers,"content-type"),l=(o?o.split(";")[0].trim():"")||"image/jpeg",c=await loadIndex(),d=Date.now(),u=`${e}-${d.toString(36)}`;let g;try{g=writeImage(u,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.`)}const m={fetchedAt:d,bytes:n.byteLength,contentType:l,lastAccessedAt:d,fileName:u,persistedAccessAt:d},h=c.get(e);h&&(indexBytes-=h.bytes),c.set(e,m),indexBytes+=m.bytes,h&&h.fileName!==u&&deleteFile(h.fileName);const p=evictIfNeeded(c);return schedulePersist(c),p>0&&Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:g,meta:toMeta(m)}},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:Promise.resolve()};return i.promise=fetchAndStore(e,t,r.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)}),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())};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{Directory,File,Paths}from"expo-file-system";const FOLDER="authed-images",imageFile=e=>new File(Paths.cache,FOLDER,e);export const writeImage=(e,t,i)=>{const s=imageFile(e);return s.create({intermediates:!0,overwrite:!0}),s.write(t),s.uri};export const imageUri=e=>imageFile(e).uri;export const imageExists=e=>imageFile(e).exists;export const deleteImage=e=>{const t=imageFile(e);t.exists&&t.delete()};export const listImageNames=()=>{const e=new Directory(Paths.cache,FOLDER);return e.exists?e.list().map(e=>e.uri.slice(e.uri.lastIndexOf("/")+1)):[]};export const clearImages=()=>{const e=new Directory(Paths.cache,FOLDER);e.exists&&e.delete()};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const urls=new Map;export const writeImage=(e,t,s)=>{const r=urls.get(e);void 0!==r&&URL.revokeObjectURL(r);const o=URL.createObjectURL(new Blob([t],{type:s}));return urls.set(e,o),o};export const imageUri=e=>urls.get(e)??"";export const imageExists=e=>urls.has(e);export const deleteImage=e=>{const t=urls.get(e);void 0!==t&&(URL.revokeObjectURL(t),urls.delete(e))};export const listImageNames=()=>[...urls.keys()];export const clearImages=()=>{for(const e of urls.values())URL.revokeObjectURL(e);urls.clear()};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Platform,StyleSheet,TextInput,View}from"react-native";import{KeyboardStickyView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useControllableState}from"../../hooks/useControllableState.js";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_COMPOSER_LABELS=Object.freeze({send:"Send",message:"Message"});const MIN_BOX=44,RING_MS=900,RING_WIDTH=1.5;export const Composer=forwardRef(({onSend:e,value:t,onChangeText:o,placeholder:a,accessibilityLabel:s,hint:i,labels:r,loading:n=!1,onStop:l,stopLabel:d="Stop",disabled:c=!1,canSend:u,ring:m=!1,sendReveal:p="always",
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Platform,StyleSheet,TextInput,View}from"react-native";import{KeyboardStickyView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useControllableState}from"../../hooks/useControllableState.js";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_COMPOSER_LABELS=Object.freeze({send:"Send",message:"Message"});const MIN_BOX=44,RING_MS=900,RING_WIDTH=1.5;export const Composer=forwardRef(({onSend:e,value:t,onChangeText:o,placeholder:a,accessibilityLabel:s,hint:i,labels:r,loading:n=!1,onStop:l,stopLabel:d="Stop",disabled:c=!1,canSend:u,ring:m=!1,sendReveal:p="always",sendIcon:b="send",maxLength:g,maxLines:f=5,leading:h,trailing:x,above:S,below:y,keyboardAware:C=!0,keyboardOffset:v,safeArea:j=!0,autoFocus:w,haptic:A,style:I,testID:E},_)=>{const L=useTheme(),R=useSafeAreaInsets(),T=useMemo(()=>buildStyles(L),[L]),D=r?{...DEFAULT_COMPOSER_LABELS,...r}:DEFAULT_COMPOSER_LABELS,[M,k]=useControllableState({value:t,defaultValue:"",onChange:o}),O=M.trim(),V=n&&void 0!==l,B=n||c||!(u??""!==O),F=j?R.bottom:0,z=v??F,H=resolveFieldTextStyle(L,{disabled:c}),P=L.text.base.size,N=Math.round(P*L.leading.body),W=(44-N)/2,U=N*f+2*W,[$,G]=useState(void 0),K=useCallback(e=>{const t=e.nativeEvent.contentSize.height+2*W;G(Math.min(Math.max(t,44),U))},[W,U]),q=useReducedMotion(),X=useRef(new Animated.Value(0)).current;useEffect(()=>{if(!m||q)return void X.setValue(m?1:0);const e=Animated.loop(Animated.sequence([Animated.timing(X,{toValue:1,duration:900,easing:Easing.inOut(Easing.ease),useNativeDriver:!1}),Animated.timing(X,{toValue:0,duration:900,easing:Easing.inOut(Easing.ease),useNativeDriver:!1})]));return e.start(),()=>e.stop()},[m,q,X]);const J=m?{borderWidth:1.5,borderColor:X.interpolate({inputRange:[0,1],outputRange:[L.colors["border-subtle"],L.colors.primary]})}:null,Q="always"===p||n||""!==M||!0===u,Y=useCallback(()=>{V?l?.():B||(k(""),e(O))},[V,l,B,k,e,O]),Z=_jsxs(View,{style:[T.bar,{paddingBottom:L.space.sm+F},I],testID:E,children:[S,_jsxs(View,{style:T.row,children:[h,_jsx(Animated.View,{style:[T.box,c?T.boxDisabled:null,J],testID:E?`${E}-box`:void 0,children:_jsx(TextInput,{ref:_,value:M,onChangeText:k,multiline:!0,maxLength:g,editable:!c,autoFocus:w,placeholder:a??D.message,placeholderTextColor:H.placeholderColor,selectionColor:L.colors["field-caret"],accessibilityLabel:s??a??D.message,accessibilityHint:i,accessibilityState:{disabled:c},"aria-disabled":c,onContentSizeChange:"web"===Platform.OS?K:void 0,style:[T.input,{color:H.color,...H.weightStyle,fontSize:P,lineHeight:N,paddingVertical:W,maxHeight:U,height:"web"===Platform.OS?$:void 0}],testID:E?`${E}-input`:void 0})}),x,Q?_jsx(IconButton,{icon:V?"stop":b,accessibilityLabel:V?d:D.send,variant:"solid",tone:"primary",disabled:V?c:B,loading:n&&!V,haptic:A,onPress:Y,testID:E?`${E}-send`:void 0}):null]}),y]});return C?_jsx(KeyboardStickyView,{offset:{closed:0,opened:z},children:Z}):Z});Composer.displayName="Composer";const buildStyles=e=>StyleSheet.create({bar:{gap:e.space.xs,paddingHorizontal:e.space.md,paddingTop:e.space.sm,backgroundColor:e.colors.bg,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:e.colors["border-subtle"]},row:{flexDirection:"row",alignItems:"flex-end",gap:e.space.sm},box:{flex:1,minHeight:44,justifyContent:"center",backgroundColor:e.colors["field-bg"],borderRadius:e.radius.pill,...smoothCorners,paddingHorizontal:e.space.md},boxDisabled:{backgroundColor:e.colors["field-bg-disabled"]},input:{margin:e.space.none,paddingHorizontal:e.space.none,includeFontPadding:!1,textAlignVertical:"top"}});export default Composer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{EmptyState}from"../EmptyState/index.js";import{IconButton}from"../IconButton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,
|
|
1
|
+
"use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{EmptyState}from"../EmptyState/index.js";import{IconButton}from"../IconButton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}];export const DEFAULT_SCANNER_OVERLAY_LABELS=Object.freeze({hint:"Point the camera at the code",found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."});const ScannerOverlay=forwardRef((e,t)=>{warnInvalidValue("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:o,state:n="scanning",helperText:i,labels:s,torch:a=!1,onTorchChange:r,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:m=DEFAULT_FRAME,haptic:u,style:h,testID:f}=e,p=useTheme(),g=useSafeAreaInsets(),y=useReducedMotion(),x=useMemo(()=>buildStyles(p),[p]),b=useMemo(()=>({...DEFAULT_SCANNER_OVERLAY_LABELS,...s}),[s]),j=i??b.hint,[v,S]=useState({width:0,height:0}),[w,A]=useState(0),E="scanning"===n||"found"===n||"invalid"===n,_=useRef(createAnimatedValue(1)).current,V=p.motion.duration.slower,C=p.motion.duration.default;useEffect(()=>{if(_.setValue(1),y)return;let e;return"scanning"===n&&V>0?e=Animated.loop(Animated.sequence([Animated.timing(_,{toValue:1.03,duration:2*V,useNativeDriver:!0}),Animated.timing(_,{toValue:1,duration:2*V,useNativeDriver:!0})])):"found"===n&&C>0&&(_.setValue(1.08),e=Animated.timing(_,{toValue:1,duration:C,useNativeDriver:!0})),e?.start(),()=>e?.stop()},[n,y,V,C,_]);const R=useRef(n);useEffect(()=>{R.current!==n&&(R.current=n,!1!==u&&("found"===n?triggerHaptic("notificationSuccess"):"invalid"===n&&triggerHaptic("notificationError")))},[n,u]);const{found:M,invalid:I}=b,{noPermissionTitle:L,noPermissionMessage:P}=b,{noCameraTitle:k,noCameraMessage:N}=b;useEffect(()=>{switch(n){case"scanning":announce(j);break;case"found":announce(M);break;case"invalid":announce(I,{polite:!1});break;case"noPermission":announce(`${L}. ${P}`);break;case"noCamera":announce(`${k}. ${N}`)}},[n,j,M,I,L,P,k,N]);const O=Math.max(240,Math.min(m,v.width-2*p.space.xl)),F=(v.width-O)/2,B=Math.max(p.space.md,(v.height-w-O)/2),D=v.width>0&&v.height>0,H={borderColor:"found"===n?p.colors.success:"invalid"===n?p.colors.danger:p.colors["on-scrim"],width:32,height:32},z="found"===n||"invalid"===n?_jsx(View,{style:[x.pill,{backgroundColor:"found"===n?p.colors.success:p.colors.danger}],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===n?p.colors["on-success"]:p.colors["on-danger"]},children:"found"===n?M:I})}):_jsx(Text,{variant:"bodySmall",align:"center",style:{color:p.colors["on-scrim"]},children:j}),W=E&&null!=r,U=E?"glass":"outline";return _jsxs(View,{ref:t,testID:f,onLayout:e=>{const{width:t,height:o}=e.nativeEvent.layout;S(e=>e.width===t&&e.height===o?e:{width:t,height:o})},style:[x.root,!E&&{backgroundColor:p.colors.bg},h],children:[E?_jsx(View,{style:StyleSheet.absoluteFill,children:o}):null,E&&D?_jsx(_Fragment,{children:_jsxs(View,{pointerEvents:"none",style:StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[_jsx(View,{style:[x.scrim,{left:0,right:0,top:0,height:B}]}),_jsx(View,{style:[x.scrim,{left:0,right:0,top:B+O,bottom:0}]}),_jsx(View,{style:[x.scrim,{left:0,width:F,top:B,height:O}]}),_jsx(View,{style:[x.scrim,{left:F+O,right:0,top:B,height:O}]}),_jsx(Animated.View,{style:{position:"absolute",left:F,top:B,width:O,height:O,transform:[{scale:_}]},children:CORNERS.map(e=>_jsx(View,{style:[x.mark,H,e.style]},e.key))})]})}):null,E?null:_jsx(View,{style:x.panel,children:_jsx(EmptyState,{fill:!0,icon:_jsx(AppIcon,{name:"noPermission"===n?"camera":"camera-slash",size:48,color:p.colors["text-subtle"]}),title:"noPermission"===n?L:k,description:"noPermission"===n?P:N,action:"noPermission"===n&&d?{label:b.permissionAction,onPress:d}:void 0})}),_jsxs(View,{pointerEvents:"box-none",onLayout:e=>{const{height:t}=e.nativeEvent.layout;A(e=>e===t?e:t)},style:[x.bar,{paddingBottom:Math.max(g.bottom,p.space.md)}],children:[E&&D?_jsx(View,{pointerEvents:"none",style:x.message,children:z}):null,_jsxs(View,{style:x.actions,children:[W?_jsx(IconButton,{icon:a?"flash":"flash-slash",variant:"glass",size:"lg",active:a,haptic:u,accessibilityLabel:a?b.torchOff:b.torchOn,onPress:()=>r?.(!a)}):null,c?_jsx(Button,{label:b.gallery,leftIcon:"gallery",variant:U,tone:"neutral",size:"lg",haptic:u,onPress:c}):null,l?_jsx(Button,{label:b.manualEntry,leftIcon:"keyboard",variant:U,tone:"neutral",size:"lg",haptic:u,onPress:l}):null]})]})]})});ScannerOverlay.displayName="ScannerOverlay";const buildStyles=e=>StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.scrim},mark:{position:"absolute"},message:{alignItems:"center",paddingHorizontal:e.space.xl},pill:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,...smoothCorners},panel:{...StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.space.sm,paddingHorizontal:e.space.md},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.space.sm}});export{ScannerOverlay};export default ScannerOverlay;
|