@webority/mobile-ui 0.131.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 +6126 -5992
- package/dist/canvas-kit/manifest.json +48 -3
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- 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/BarChart/BarChart.js +1 -1
- package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/commonjs/components/Composer/Composer.js +1 -1
- package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
- package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/commonjs/components/Screen/Screen.js +1 -1
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/commonjs/components/Switch/Switch.js +1 -1
- package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
- package/lib/commonjs/navigation/NavigationScreen.js +1 -1
- package/lib/commonjs/network/NetworkStatusBanner.js +1 -1
- package/lib/commonjs/theme/merge.js +1 -1
- package/lib/commonjs/theme/tokens.generated.js +1 -1
- package/lib/module/components/AppBar/AppBar.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/BarChart/BarChart.js +1 -1
- package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/module/components/Composer/Composer.js +1 -1
- package/lib/module/components/FileViewer/FileViewer.js +1 -1
- package/lib/module/components/OTPInput/OTPInput.js +1 -1
- package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/module/components/Screen/Screen.js +1 -1
- package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/module/components/Switch/Switch.js +1 -1
- package/lib/module/components/WheelPicker/Wheel.js +1 -1
- package/lib/module/navigation/NavigationScreen.js +1 -1
- package/lib/module/network/NetworkStatusBanner.js +1 -1
- package/lib/module/theme/merge.js +1 -1
- package/lib/module/theme/tokens.generated.js +1 -1
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +3 -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/ChoiceGroup/ChoiceGroup.d.ts +3 -3
- package/lib/typescript/commonjs/components/Composer/Composer.d.ts +3 -0
- package/lib/typescript/commonjs/components/Screen/Screen.d.ts +4 -0
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +2 -1
- package/lib/typescript/commonjs/navigation/NavigationScreen.d.ts +2 -2
- package/lib/typescript/commonjs/network/NetworkStatusBanner.d.ts +7 -2
- package/lib/typescript/commonjs/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/commonjs/theme/types.d.ts +5 -1
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +3 -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/ChoiceGroup/ChoiceGroup.d.ts +3 -3
- package/lib/typescript/module/components/Composer/Composer.d.ts +3 -0
- package/lib/typescript/module/components/Screen/Screen.d.ts +4 -0
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +2 -1
- package/lib/typescript/module/navigation/NavigationScreen.d.ts +2 -2
- package/lib/typescript/module/network/NetworkStatusBanner.d.ts +7 -2
- package/lib/typescript/module/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/module/theme/types.d.ts +5 -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",
|
|
@@ -546,7 +546,14 @@
|
|
|
546
546
|
"name": "divider",
|
|
547
547
|
"type": "boolean",
|
|
548
548
|
"required": false,
|
|
549
|
-
"description": "Draws a hairline under the bar;
|
|
549
|
+
"description": "Draws a hairline under the bar; off by default."
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"name": "elevated",
|
|
553
|
+
"type": "boolean",
|
|
554
|
+
"required": false,
|
|
555
|
+
"description": "Draws a shadow under the bar, for content scrolled beneath it; ignored when the bar is transparent.",
|
|
556
|
+
"default": false
|
|
550
557
|
},
|
|
551
558
|
{
|
|
552
559
|
"name": "gutter",
|
|
@@ -4825,6 +4832,13 @@
|
|
|
4825
4832
|
"description": "Pad the bar for the bottom safe area, or turn off above a tab bar.",
|
|
4826
4833
|
"default": true
|
|
4827
4834
|
},
|
|
4835
|
+
{
|
|
4836
|
+
"name": "sendIcon",
|
|
4837
|
+
"type": "icon",
|
|
4838
|
+
"required": false,
|
|
4839
|
+
"description": "The icon of the send button.",
|
|
4840
|
+
"default": "send"
|
|
4841
|
+
},
|
|
4828
4842
|
{
|
|
4829
4843
|
"name": "sendReveal",
|
|
4830
4844
|
"type": "enum",
|
|
@@ -13508,6 +13522,13 @@
|
|
|
13508
13522
|
"description": "Keeps the content inside the page's side margin. List pages default to false, because their rows carry their own padding.",
|
|
13509
13523
|
"default": true
|
|
13510
13524
|
},
|
|
13525
|
+
{
|
|
13526
|
+
"name": "headerShadowOnScroll",
|
|
13527
|
+
"type": "boolean",
|
|
13528
|
+
"required": false,
|
|
13529
|
+
"description": "Shows a shadow under the fixed bar once the content scrolls, and hides it back at the top.",
|
|
13530
|
+
"default": true
|
|
13531
|
+
},
|
|
13511
13532
|
{
|
|
13512
13533
|
"name": "keyboardToolbar",
|
|
13513
13534
|
"type": "boolean",
|
|
@@ -13591,6 +13612,12 @@
|
|
|
13591
13612
|
"type": "string",
|
|
13592
13613
|
"required": false,
|
|
13593
13614
|
"description": "The app bar title."
|
|
13615
|
+
},
|
|
13616
|
+
{
|
|
13617
|
+
"name": "trailing",
|
|
13618
|
+
"type": "node",
|
|
13619
|
+
"required": false,
|
|
13620
|
+
"description": "Content at the right edge of the app bar, such as a profile avatar, in place of the last right action."
|
|
13594
13621
|
}
|
|
13595
13622
|
],
|
|
13596
13623
|
"itemsTakeAction": [],
|
|
@@ -20468,6 +20495,7 @@
|
|
|
20468
20495
|
"neutral",
|
|
20469
20496
|
"neutral-hover",
|
|
20470
20497
|
"neutral-text",
|
|
20498
|
+
"offline-fill",
|
|
20471
20499
|
"on-danger",
|
|
20472
20500
|
"on-glass",
|
|
20473
20501
|
"on-info",
|
|
@@ -20479,6 +20507,7 @@
|
|
|
20479
20507
|
"on-surface-dark",
|
|
20480
20508
|
"on-surface-dark-muted",
|
|
20481
20509
|
"on-warning",
|
|
20510
|
+
"online-fill",
|
|
20482
20511
|
"primary",
|
|
20483
20512
|
"primary-hover",
|
|
20484
20513
|
"primary-pressed",
|
|
@@ -20500,6 +20529,7 @@
|
|
|
20500
20529
|
"surface-inverse",
|
|
20501
20530
|
"surface-pressed",
|
|
20502
20531
|
"surface-selected",
|
|
20532
|
+
"switch-thumb",
|
|
20503
20533
|
"text",
|
|
20504
20534
|
"text-body",
|
|
20505
20535
|
"text-disabled",
|
|
@@ -20607,6 +20637,7 @@
|
|
|
20607
20637
|
"neutral": "Quiet unbranded fill for supporting actions such as Back, Skip and Close.",
|
|
20608
20638
|
"neutral-hover": "Neutral fill while a control is hovered.",
|
|
20609
20639
|
"neutral-text": "Text on the soft neutral background.",
|
|
20640
|
+
"offline-fill": "Fill of the offline network banner: the source red, not the contrast-darkened danger fill.",
|
|
20610
20641
|
"on-danger": "Ink on a solid danger fill.",
|
|
20611
20642
|
"on-glass": "Ink on a translucent control on a brand surface.",
|
|
20612
20643
|
"on-info": "Ink on a solid info fill.",
|
|
@@ -20618,6 +20649,7 @@
|
|
|
20618
20649
|
"on-surface-dark": "Text and icons on a surface-dark band.",
|
|
20619
20650
|
"on-surface-dark-muted": "Secondary text on a surface-dark band.",
|
|
20620
20651
|
"on-warning": "Ink on a solid warning fill.",
|
|
20652
|
+
"online-fill": "Fill of the back-online network banner: the source green, not the contrast-darkened success fill.",
|
|
20621
20653
|
"primary": "Primary fill for buttons, selected states and borders.",
|
|
20622
20654
|
"primary-hover": "Primary fill while a control is hovered or pressed.",
|
|
20623
20655
|
"primary-pressed": "Primary fill while a control is pressed.",
|
|
@@ -20639,6 +20671,7 @@
|
|
|
20639
20671
|
"surface-inverse": "Inverse band on a page, such as a dark footer or an inverse toast.",
|
|
20640
20672
|
"surface-pressed": "Wash over a surface while it is pressed.",
|
|
20641
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.",
|
|
20642
20675
|
"text": "Main heading and body ink.",
|
|
20643
20676
|
"text-body": "Body copy on a tinted surface such as an alert body.",
|
|
20644
20677
|
"text-disabled": "Text of a disabled control.",
|
|
@@ -20829,6 +20862,10 @@
|
|
|
20829
20862
|
"light": "#52525b",
|
|
20830
20863
|
"dark": "#b4b4bb"
|
|
20831
20864
|
},
|
|
20865
|
+
"offline-fill": {
|
|
20866
|
+
"light": "#e82646",
|
|
20867
|
+
"dark": "#e82646"
|
|
20868
|
+
},
|
|
20832
20869
|
"on-danger": {
|
|
20833
20870
|
"light": "#ffffff",
|
|
20834
20871
|
"dark": "#0f0f1a"
|
|
@@ -20873,6 +20910,10 @@
|
|
|
20873
20910
|
"light": "#0f0f1a",
|
|
20874
20911
|
"dark": "#0f0f1a"
|
|
20875
20912
|
},
|
|
20913
|
+
"online-fill": {
|
|
20914
|
+
"light": "#04b440",
|
|
20915
|
+
"dark": "#04b440"
|
|
20916
|
+
},
|
|
20876
20917
|
"primary": {
|
|
20877
20918
|
"light": "#5b5bd6",
|
|
20878
20919
|
"dark": "#7c7ce8"
|
|
@@ -20957,6 +20998,10 @@
|
|
|
20957
20998
|
"light": "#5b5bd61a",
|
|
20958
20999
|
"dark": "#7c7ce82e"
|
|
20959
21000
|
},
|
|
21001
|
+
"switch-thumb": {
|
|
21002
|
+
"light": "#ffffff",
|
|
21003
|
+
"dark": "#ffffff"
|
|
21004
|
+
},
|
|
20960
21005
|
"text": {
|
|
20961
21006
|
"light": "#252f4a",
|
|
20962
21007
|
"dark": "#e2e2e2"
|
|
@@ -20983,7 +21028,7 @@
|
|
|
20983
21028
|
},
|
|
20984
21029
|
"thumb": {
|
|
20985
21030
|
"light": "#ffffff",
|
|
20986
|
-
"dark": "#
|
|
21031
|
+
"dark": "#3a3e49"
|
|
20987
21032
|
},
|
|
20988
21033
|
"warning": {
|
|
20989
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.default=exports.DEFAULT_APP_BAR_LABELS=exports.AppBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_index2=require("../Menu/index.js"),_Text=require("../Text/Text.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4,DEFAULT_APP_BAR_LABELS=exports.DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"}),variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=(0,_react.forwardRef)(({action:e,side:t,badgeStyle:i,haptic:n,flush:a,onPress:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_APP_BAR_LABELS=exports.AppBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_index2=require("../Menu/index.js"),_Text=require("../Text/Text.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4,DEFAULT_APP_BAR_LABELS=exports.DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"}),variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=(0,_react.forwardRef)(({action:e,side:t,badgeStyle:i,haptic:n,flush:a,onPress:l},r)=>{const s=(0,_index.useTheme)(),{style:o,pressIn:c,pressOut:d}=(0,_usePressAnimation.usePressAnimation)({enabled:!0}),u=(0,_react.useMemo)(()=>buildActionStyles(s),[s]),p=e.badge,h=void 0!==p&&0!==p,x=void 0!==e.label;return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:o,children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:r,onPress:t=>{const i=(0,_hapticUtils.resolveHaptic)(n,"selection");i&&(0,_hapticUtils.triggerHaptic)(i),"onPress"in e&&e.onPress(),l?.(t)},onPressIn:c,onPressOut:d,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,android_ripple:{color:s.colors["surface-pressed"],borderless:!x},style:({pressed:e})=>[x?u.textButton:u.actionButton,a?null:"left"===t?u.actionLeft:u.actionRight,e&&!x?u.actionPressed:null,e&&x?u.textPressed:null],children:[x?(0,_jsxRuntime.jsx)(_Text.Text,{variant:"body",weight:"semibold",color:"link",numberOfLines:1,children:e.label}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.iconWrap,children:e.icon}),h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.badge,i],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_Text.Text,{variant:"caption",weight:"semibold",numberOfLines:1,style:u.badgeText,children:String(p)})}):null,e.dot?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:e.testID?`${e.testID}-dot`:"appbar-action-dot",style:u.dot,pointerEvents:"none"}):null]})})}),COLLAPSE_RANGE=60,AppBar=exports.AppBar=(0,_react.forwardRef)((e,t)=>{const{title:i,subtitle:n,titleAlignment:a="left",leftAction:l,rightActions:r,leading:s,trailing:o,onBack:c,gutter:d,titleVariant:u,titleOffset:p,height:h,divider:x,elevated:g=!1,variant:m="default",transparent:_=!1,scrollY:b,style:f,containerStyle:j,titleStyle:v,subtitleStyle:y,badgeStyle:A,haptic:R,labels:S,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("AppBar","variant",e.variant,["default","large","compact"]),(0,_warnInvalidValue.warnInvalidValue)("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const I=(0,_react.useMemo)(()=>({...DEFAULT_APP_BAR_LABELS,...S}),[S]),B=(0,_index.useTheme)(),L=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>variantSize(B,m),[B,m]),T=(0,_react.useMemo)(()=>buildStyles(B),[B]),P="large"===m,C=P&&void 0!==b,[z,V]=(0,_react.useState)(40),O=(0,_react.useCallback)(e=>V(e.nativeEvent.layout.height),[]),E=l??(c?{icon:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"arrow-left",size:24,color:B.colors["text-body"]}),onPress:c,accessibilityLabel:I.back}:void 0),D=o?void 0:r?.[r.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?B.space.sm:Math.max((44-(e.glyphSize??24))/2,0),W=void 0===d?null:{paddingLeft:Math.max(d-opticalInset(E),0),paddingRight:Math.max(d-opticalInset(D),0)},k=void 0!==p,F=Boolean(E)||Boolean(s),q=!k&&"left"===a&&Boolean(E),H=k||q||!F&&"left"===a,M="default"!==m||F?N.titleSize:B.text.xl.size,U=x??!1,$=_reactNative.StyleSheet.hairlineWidth,G=(0,_react.useMemo)(()=>b?{rootHeight:b.interpolate({inputRange:[0,60],outputRange:[L.top+N.height+z,L.top+N.height],extrapolate:"clamp"}),titleRowOpacity:b.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:b.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:b.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}:null,[b,L.top,N.height,z]),Z=i?u?(0,_jsxRuntime.jsx)(_Text.Text,{variant:u,align:"center"===a?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[T.titleVariant,v],children:i}):(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityRole:"header",style:[T.title,{fontSize:M,fontWeight:B.weight[N.titleWeight],textAlign:"center"===a?"center":"left"},n?T.stackedText:null,v],numberOfLines:1,children:i}):null,Y=C&&G&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[T.title,{fontSize:B.text.lg.size,fontWeight:B.weight.semibold,textAlign:"center"===a?"center":"left",opacity:G.compactTitleOpacity}],numberOfLines:1,children:i}):null,J=n?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[T.subtitle,{textAlign:"center"===a?"center":"left"},y],numberOfLines:N.subtitleLines,children:n}):null,K=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T.titleColumn,"center"===a?T.titleColumnCenter:null],children:[Z,J]}),Q=C?_reactNative.Animated.View:_reactNative.View,X=C&&G?{height:G.rootHeight,overflow:"hidden"}:P&&void 0===h?null:{height:(h??N.height)+L.top};return(0,_jsxRuntime.jsxs)(Q,{ref:t,testID:w,style:[T.root,{paddingTop:L.top,backgroundColor:_?"transparent":B.colors.surface},X,!C&&U?{borderBottomWidth:$,borderBottomColor:B.colors.border}:null,g&&!_?B.shadow.card:null,j,f],children:[C&&G&&U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[T.animatedBorder,{backgroundColor:B.colors.border,opacity:G.borderOpacity}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:P&&w?`${w}-bar-row`:void 0,style:[T.row,P?{height:N.height}:{flex:1},W],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:w?`${w}-leading-slot`:void 0,style:[T.sideSlot,H?T.sideSlotCompact:null],children:[E?(0,_jsxRuntime.jsx)(ActionButton,{action:E,side:"left",haptic:R,flush:k||q}):null,null!=s&&!1!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:T.slotNode,children:s}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[T.center,"center"===a?T.centerAligned:T.centerLeft,k?{paddingLeft:F?p:B.space.none,paddingRight:B.space.none}:H?{paddingLeft:B.space.none}:null],children:P?Y:K}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T.sideSlot,T.sideSlotRight,k?T.sideSlotCompact:null],children:[r?.map((e,t)=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:"menu"in e?(0,_jsxRuntime.jsx)(_index2.Menu,{items:e.menu,title:e.menuTitle,haptic:R,trigger:(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})}):(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})},`appbar-right-${t}`)),null!=o&&!1!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:T.slotNode,children:o}):null]})]}),P?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{testID:w?`${w}-title-row`:void 0,onLayout:C?O:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??B.space.md,paddingBottom:B.space.sm},C&&G?{opacity:G.titleRowOpacity}:null],children:K}):null]})});AppBar.displayName="AppBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{width:"100%"},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.xs},sideSlot:{flexDirection:"row",alignItems:"center",minWidth:48},sideSlotRight:{justifyContent:"flex-end"},sideSlotCompact:{minWidth:0},slotNode:{flexDirection:"row",alignItems:"center"},center:{flex:1,minWidth:0,paddingHorizontal:e.space.xs},centerAligned:{alignItems:"center"},centerLeft:{alignItems:"flex-start"},titleColumn:{flexDirection:"column",maxWidth:"100%"},titleColumnCenter:{alignItems:"center"},title:{color:e.colors["text-body"]},titleVariant:{includeFontPadding:!1,textAlignVertical:"center"},stackedText:{includeFontPadding:!1},subtitle:{includeFontPadding:!1,color:e.colors["text-subtle"],fontSize:e.text.sm.size,fontWeight:e.weight.normal},animatedBorder:{position:"absolute",left:0,right:0,bottom:0,height:_reactNative.StyleSheet.hairlineWidth}}),buildActionStyles=e=>_reactNative.StyleSheet.create({actionButton:{width:44,height:44,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},actionLeft:{marginRight:e.space.xs},actionRight:{marginLeft:e.space.xs},actionPressed:{backgroundColor:e.colors["surface-pressed"]},textButton:{minWidth:44,minHeight:44,paddingHorizontal:e.space.sm,alignItems:"center",justifyContent:"center"},textPressed:{opacity:.6},dot:{position:"absolute",top:10,right:10,width:8,height:8,borderRadius:e.radius.pill,backgroundColor:e.colors.danger},iconWrap:{alignItems:"center",justifyContent:"center"},badge:{position:"absolute",top:4,right:4,minWidth:16,height:16,paddingHorizontal:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.danger,alignItems:"center",justifyContent:"center"},badgeText:{color:e.colors["on-danger"],fontSize:e.text.xs.size,fontWeight:e.weight.semibold,lineHeight:13}});var _default=exports.default=AppBar;
|
|
@@ -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_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:p,style:b,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...p}),[p]),j=(0,_index2.useTheme)(),v=r.length,[R,g]=(0,_react.useState)(0),[w,S]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),T=null!==w&&w>=0&&w<v?w:null,C=(0,_react.useRef)(T);C.current=T;const A=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(v>0&&v<=7),V=void 0!==s&&s.length>0,E=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??STACK_TONES[t%STACK_TONES.length]):[],[V,s]),I=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),B=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),D=(0,_react.useMemo)(()=>B?B.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,B]),H=(0,_react.useMemo)(()=>B?B.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):D,[B,D]),$=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&$.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+($.max-e)/($.max-$.min)*F,[k,$.max,$.min,F]),q=G(0),W=(0,_react.useMemo)(()=>$.ticks.map(e=>u(e)),[$.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=v>0?R/v:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=r[e];return t.accessibilityLabel?t.accessibilityLabel:B&&s?`${t.label}, ${s.map((t,r)=>`${t.label} ${c(B[e][r])}`).join(", ")}`:`${t.label}, ${c(D[e])}`},[r,c,D,B,s]),K=(0,_react.useMemo)(()=>{let e=-1;return D.forEach((t,r)=>{(-1===e||t>D[e])&&(e=r)}),e},[D]),J=o??(K>=0?y.highest(r[K].label,c(D[K])):""),Y=(0,_react.useRef)({fire:N,setSelected:S,count:v,plotWidth:R});Y.current={fire:N,setSelected:S,count:v,plotWidth:R};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===A.current||(A.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{A.current=C.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(f?`${f}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),A.current=r,Y.current.setSelected(r===C.current?null:r))}).withTestId(f?`${f}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[f]),Q=(0,_react.useCallback)(e=>{if(0===v)return;const t=C.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(v-1,t+1):null===t?v-1:Math.max(0,t-1);r!==t&&(N(),S(r))},[v,N,S]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??y.chart,ie=0===v?`${ae}, ${y.noData}`:J?`${ae}, ${J}`:ae,se=null===T?J:X(T),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,E[r])}},I[r]))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=D.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==T&&T!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[R>0&&B?renderStack(B[t],t,s):null,R>0&&!B&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&R>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(B?G(H[2*t]):r)-20+2:(B?G(H[2*t+1]):r)+2},children:u(e)}):null]},t)});return 0===v?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:f,style:[styles.root,b],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:v-1,now:T??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:f,style:[styles.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===T?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r[T].label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:f?`${f}-callout`:void 0,children:c(D[T])})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:$.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:W[t]},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:f?`${f}-plot`:void 0,children:[$.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:T===t?"primary":"tertiary",weight:T===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,E[t])}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ChoiceGroup=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"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("../Radio/RadioDot.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=exports.ChoiceGroup=(0,_react.forwardRef)((e,i)=>{const{options:t,getOptionLabel:r,getOptionValue:o,isOptionDisabled:a,getOptionDescription:n,getOptionIcon:l,getOptionColor:s,renderOption:c,variant:d="card",indicatorPosition:u="trailing",direction:p="row",gap:x,wrap:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ChoiceGroup=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"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("../Radio/RadioDot.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=exports.ChoiceGroup=(0,_react.forwardRef)((e,i)=>{const{options:t,getOptionLabel:r,getOptionValue:o,isOptionDisabled:a,getOptionDescription:n,getOptionIcon:l,getOptionColor:s,renderOption:c,variant:d="card",indicatorPosition:u="trailing",direction:p="row",gap:x,wrap:h=!1,fullWidth:g,disabled:_=!1,size:m="md",labelLines:b,descriptionLines:v=2,haptic:j,accessibilityLabel:f,style:y,optionStyle:z,description:w,helperText:C,error:R,testID:V}=e,S=(0,_index2.useTheme)(),H=(0,_react.useMemo)(()=>buildStyles(S),[S]),I=(0,_react.useMemo)(()=>sizeTokensOf(S)[m],[S,m]);(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","variant",e.variant,["card","chip"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","direction",e.direction,["row","column"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),(0,_warnInvalidValue.warnInvalidValue)("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const T=(0,_react.useCallback)(e=>r?r(e):e.label??"",[r]),k=(0,_react.useCallback)(e=>o?o(e):e.value,[o]),D=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),O=(0,_react.useCallback)(e=>n?n(e):e.description,[n]),G=(0,_react.useCallback)(e=>l?l(e):e.icon,[l]),q=(0,_react.useCallback)(e=>s?s(e):e.color,[s]),L="multiple"===e.selectionMode,{min:M,max:P}=e,[N,W]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(L?[]:void 0),onChange:e.onChange}),B=Array.isArray(N)?N:[],F=(0,_react.useCallback)(e=>{const i=k(e);if(L){const e=B.includes(i);if(e&&null!=M&&B.length<=M)return;if(!e&&null!=P&&B.length>=P)return;const t=(0,_index3.resolveHaptic)(j,"selection");return t&&(0,_index3.triggerHaptic)(t),void W(e?B.filter(e=>e!==i):[...B,i])}const t=(0,_index3.resolveHaptic)(j,"selection");t&&(0,_index3.triggerHaptic)(t),W(i)},[j,L,M,P,B,W,k]),A=g??("card"===d&&"row"===p&&!h),$=h||A&&"row"===p,E=S.radius.md,surfaceFor=(e,i,t)=>i?{borderColor:S.colors.border,backgroundColor:S.colors["surface-disabled"]}:{borderColor:e?t:S.colors.border,backgroundColor:e?(0,_color.tintOf)(t,.12,S.colors["surface-selected"]):S.colors.bg},renderIcon=(e,i,t,r)=>{const o=G(e);if(null==o)return null;const a="string"==typeof o&&i?{name:o,variant:"bold"}:o;return(0,_slotIcon.renderSlotIcon)(a,{color:t,size:I.iconSize,disabled:r})},renderChip=e=>{const{option:i,selected:t,disabled:r,color:o}=e,a=r?S.colors["text-disabled"]:t?o:S.colors["text-body"],n=renderIcon(i,t,a,r);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.chip,{minHeight:I.minHeight,paddingHorizontal:I.chipPaddingHorizontal,paddingVertical:I.paddingVertical,borderRadius:S.radius.pill,..._corners.smoothCorners,borderWidth:S.size.border,...surfaceFor(t,r,o),columnGap:S.space.xs}],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{children:n}):null,(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:b,ellipsizeMode:"tail",style:[H.cardLabel,{color:a,fontSize:I.fontSize,lineHeight:Math.round(I.fontSize*S.leading.body)}],children:T(i)})]})},renderDefaultCard=e=>{const{option:i,selected:t,disabled:r,color:o}=e,a=q(i),n=r?S.colors["text-disabled"]:a??S.colors["text-body"],l=O(i),s=renderIcon(i,t,n,r),c=(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:t,color:o,disabled:r,size:m});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.card,{minHeight:I.minHeight,paddingHorizontal:I.paddingHorizontal,paddingVertical:I.paddingVertical,borderRadius:E,..._corners.smoothCorners,borderWidth:S.size.border,...surfaceFor(t,r,o),columnGap:S.space.sm}],children:["leading"===u?c:null,s?(0,_jsxRuntime.jsx)(_reactNative.View,{children:s}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.cardTextWrap,children:[(0,_jsxRuntime.jsx)(_index4.Text,{weight:"medium",numberOfLines:b,ellipsizeMode:"tail",style:[H.cardLabel,{color:n,fontSize:I.fontSize,lineHeight:Math.round(I.fontSize*S.leading.body)}],children:T(i)}),l?(0,_jsxRuntime.jsx)(_index4.Text,{numberOfLines:v,ellipsizeMode:"tail",style:[H.cardDescription,{color:t?S.colors["text-muted"]:S.colors["text-subtle"],fontSize:S.text.xs.size,lineHeight:Math.round(S.text.xs.size*S.leading.body)}],children:l}):null]}),"trailing"===u?c:null]})},J="string"==typeof R&&""!==R?R:void 0,K=!0===R||void 0!==J?null:C,Q=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:i,accessibilityRole:L?void 0:"radiogroup",accessibilityLabel:f,accessibilityState:{disabled:_},"aria-disabled":_,testID:V,style:[{flexDirection:p,gap:x??S.space.sm,flexWrap:$?"wrap":"nowrap"},y],children:t.map((e,i)=>{const t=k(e),r=L?B.includes(t):N===t,o=L&&null!=P&&!r&&B.length>=P,a=_||o||D(e),n=q(e)??S.colors.primary,l=c||"card"!==d?void 0:O(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:e.testID,onPress:()=>{a||F(e)},disabled:a,accessibilityRole:L?"checkbox":"radio",accessibilityLabel:l?`${T(e)}, ${l}`:T(e),accessibilityState:{checked:r,disabled:a},"aria-checked":r,"aria-disabled":a,style:[A?H.stretchOption:null,{opacity:a&&c?.55:1},z],children:({pressed:t})=>{const o={option:e,index:i,selected:r,pressed:t&&!a,disabled:a,color:n};return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:c?c(o):"chip"===d?renderChip(o):renderDefaultCard(o)})}},String(t))})});return(0,_ChoiceText.hasChoiceDetail)({description:w,error:J,helperText:K??void 0})?(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[w?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:S.space.xs},children:w}):null,Q,void 0!==J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:S.space.xs},children:J}):K?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",style:{marginTop:S.space.xs},children:K}):null]}):Q});ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>_reactNative.StyleSheet.create({stretchOption:{flexGrow:1,flexShrink:0,flexBasis:"auto"},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flexGrow:1,flexShrink:1,flexBasis:"auto"},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});var _default=exports.default=ChoiceGroup;
|
|
@@ -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.FileViewer=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireDefault(require("react-native-reanimated")),_NativePdfRasterizer=_interopRequireDefault(require("../../specs/NativePdfRasterizer.js")),_index=require("../../theme/index.js"),_index2=require("../Spinner/index.js"),_FileViewerImage=require("./FileViewerImage.js"),_FileViewerPage=require("./FileViewerPage.js"),_fileSource=require("./fileSource.js"),_useFileViewerZoom=require("./useFileViewerZoom.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const MAX_RENDER_SCALE=5,RENDER_OVERSCALE=1.25,RENDER_AHEAD=3,MOUNT_AROUND=2,DEFAULT_MAX_ZOOM=4,toError=e=>e instanceof Error?e:new Error(String(e)),scaleForWidth=(e,t,r)=>{if(t<=0)return 1;const i=e/t*_reactNative.PixelRatio.get()*1.25*r;return Math.round(100*Math.min(Math.max(i,1),5))/100},AnimatedScrollView=_reactNativeReanimated.default.createAnimatedComponent(_reactNative.ScrollView),FileViewerPdf=({source:e,onLoadComplete:t,onPageChanged:r,onError:i,loadingIndicator:a,zoomEnabled:l=!0,maxZoom:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FileViewer=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireDefault(require("react-native-reanimated")),_NativePdfRasterizer=_interopRequireDefault(require("../../specs/NativePdfRasterizer.js")),_index=require("../../theme/index.js"),_index2=require("../Spinner/index.js"),_FileViewerImage=require("./FileViewerImage.js"),_FileViewerPage=require("./FileViewerPage.js"),_fileSource=require("./fileSource.js"),_useFileViewerZoom=require("./useFileViewerZoom.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const MAX_RENDER_SCALE=5,RENDER_OVERSCALE=1.25,RENDER_AHEAD=3,MOUNT_AROUND=2,DEFAULT_MAX_ZOOM=4,toError=e=>e instanceof Error?e:new Error(String(e)),scaleForWidth=(e,t,r)=>{if(t<=0)return 1;const i=e/t*_reactNative.PixelRatio.get()*1.25*r;return Math.round(100*Math.min(Math.max(i,1),5))/100},AnimatedScrollView=_reactNativeReanimated.default.createAnimatedComponent(_reactNative.ScrollView),FileViewerPdf=({source:e,onLoadComplete:t,onPageChanged:r,onError:i,loadingIndicator:a,zoomEnabled:l=!0,maxZoom:n=4,style:s,testID:o,accessibilityLabel:c})=>{const u=(0,_index.useTheme)().space.sm,{width:d,height:_}=(0,_reactNative.useWindowDimensions)(),[h,f]=(0,_react.useState)({width:0,height:0}),m=h.width>0?h.width:d,[w,g]=(0,_react.useState)(0),[R,p]=(0,_react.useState)({width:612,height:792}),v=R.height/R.width,[x,j]=(0,_react.useState)({}),[V,y]=(0,_react.useState)(null),[b,E]=(0,_react.useState)(0),F=(0,_react.useRef)(0),S=(0,_react.useRef)(null),N=(0,_react.useRef)(null),P=(0,_react.useRef)(i);P.current=i;const M=(0,_react.useRef)(t);M.current=t;const q=(0,_react.useRef)(r);q.current=r;const z=(0,_react.useRef)(a);z.current=a;const C=m*v,D=C+u,Z=h.height>0?h.height:_,{scrollRef:O,scrollGesture:A,zoomGesture:L,zoomStyle:G,zoomLevel:H,resetZoom:I}=(0,_useFileViewerZoom.useFileViewerZoom)({zoomEnabled:l,maxZoom:n,viewportWidth:h.width>0?h.width:d,viewportHeight:Z,maxScroll:Math.max(0,w*D-u-Z)}),k=(0,_react.useMemo)(()=>({uri:e.uri,headers:e.headers,client:e.client,cache:e.cache}),[e.uri,e.headers,e.client,e.cache]);(0,_react.useEffect)(()=>{let e=!1;return(async()=>{if(_NativePdfRasterizer.default)try{const t=await(0,_fileSource.localPathFromSource)(k);if(e)return;const r=await _NativePdfRasterizer.default.open(t);if(e)return void await _NativePdfRasterizer.default.close(r.handle).catch(()=>{});S.current=r.handle,F.current=0,g(r.pageCount),E(0),j({}),y(null),I(),r.pageWidth>0&&r.pageHeight>0&&p({width:r.pageWidth,height:r.pageHeight}),M.current?.(r.pageCount)}catch(t){if(!e){const e=toError(t);_mobileCore.Logger.error("[@webority/mobile-ui] FileViewer failed to load.",e),P.current?.(e)}}else P.current?.(new Error("[@webority/mobile-ui] PdfRasterizer native module is not linked. Run pod install / rebuild the app after adding @webority/mobile-ui."))})(),()=>{e=!0;const t=S.current;S.current=null,t&&_NativePdfRasterizer.default?.close(t).catch(()=>{})}},[k,I]);const T=scaleForWidth(m,R.width,1),W=H>_useFileViewerZoom.ZOOM_REST?scaleForWidth(m,R.width,Math.ceil(H)):0,U=(0,_react.useRef)(T);U.current=T;const X=(0,_react.useRef)(W);X.current=W;const K=(0,_react.useRef)(T);(0,_react.useEffect)(()=>{K.current!==T&&(K.current=T,j({}))},[T]);const $=(0,_react.useCallback)(async()=>{const e=S.current;if(!e||!_NativePdfRasterizer.default||0===w)return;if(N.current===e)return;let t;if(void 0===x[b])t={page:b,scale:T,sharp:!1};else if(W>T&&null!==x[b]&&(V?.page!==b||V.scale!==W))t={page:b,scale:W,sharp:!0};else for(let e=1;e<=3&&!t;e+=1)for(const r of[b+e,b-e])if(r>=0&&r<w&&void 0===x[r]){t={page:r,scale:T,sharp:!1};break}if(!t)return;const{page:r,scale:i,sharp:a}=t;N.current=e;let l=null;try{l=await _NativePdfRasterizer.default.renderPage(e,r,i)}catch(t){S.current===e&&_mobileCore.Logger.error(`[@webority/mobile-ui] FileViewer failed to render page ${r}.`,toError(t))}finally{N.current===e&&(N.current=null)}S.current===e&&(i===(a?X.current:U.current)?a?y({page:r,scale:i,uri:l}):j(e=>({...e,[r]:l})):j(e=>({...e})))},[T,b,w,x,V,W]);(0,_react.useEffect)(()=>{$()},[$]),(0,_react.useEffect)(()=>{H<=_useFileViewerZoom.ZOOM_REST&&y(null)},[H]);const B=(0,_react.useCallback)(e=>{const{width:t,height:r}=e.nativeEvent.layout;f(e=>e.width===t&&e.height===r?e:{width:t,height:r})},[]),J=(0,_react.useCallback)(e=>{if(D<=0||0===w)return;const t=Math.min(w-1,Math.max(0,Math.round(e.nativeEvent.contentOffset.y/D)));t!==F.current&&(F.current=t,E(t),q.current?.(t+1,w))},[w,D]),Q=(0,_react.useCallback)(()=>z.current?.()??(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"lg"}),[]),Y=(0,_react.useMemo)(()=>({gap:u}),[u]),ee=(0,_react.useMemo)(()=>Array.from({length:w},(e,t)=>t),[w]),te=H>_useFileViewerZoom.ZOOM_REST;return(0,_jsxRuntime.jsxs)(_reactNativeGestureHandler.GestureHandlerRootView,{style:[styles.root,s],onLayout:B,testID:o,accessible:void 0!==c,accessibilityLabel:c,accessibilityRole:"none",children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:L,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.viewport,collapsable:!1,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.viewport,G],children:(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:A,children:(0,_jsxRuntime.jsx)(AnimatedScrollView,{ref:O,onScroll:J,scrollEventThrottle:16,scrollEnabled:!te,showsVerticalScrollIndicator:!te,contentContainerStyle:Y,children:ee.map(e=>(0,_jsxRuntime.jsx)(_FileViewerPage.FileViewerPage,{width:m,height:C,uri:te&&V?.page===e&&V.uri?V.uri:x[e],mounted:Math.abs(e-b)<=2,renderLoading:Q},e))})})})})}),0===w&&(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,styles.pagePlaceholder],children:a?a():(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"lg"})})]})},FileViewer=({kind:e="auto",...t})=>"image"===(0,_fileSource.resolveKind)(e,t.source.uri)?(0,_jsxRuntime.jsx)(_FileViewerImage.FileViewerImage,{...t}):(0,_jsxRuntime.jsx)(FileViewerPdf,{...t});exports.FileViewer=FileViewer,FileViewer.displayName="FileViewer";const styles=_reactNative.StyleSheet.create({root:{flex:1,overflow:"hidden"},viewport:{flex:1},pagePlaceholder:{flex:1,alignItems:"center",justifyContent:"center"}});var _default=exports.default=FileViewer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=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"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=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"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:a,defaultValue:i,onChange:n,onComplete:r,length:s=6,keyboardType:l="number-pad",autoFocus:o=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:p=!1,haptic:m,labels:x,onFocus:g,accessibilityLabel:f,style:h,cellStyle:v,textStyle:b,testID:y}=e;(0,_warnInvalidValue.warnInvalidValue)("OTPInput","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("OTPInput","keyboardType",e.keyboardType,["number-pad","default"]);const T=x?{...DEFAULT_OTP_INPUT_LABELS,...x}:DEFAULT_OTP_INPUT_LABELS,[j,N]=(0,_index.useControllableState)({value:a,defaultValue:i??"",onChange:n}),I=(0,_index2.useTheme)(),E=(0,_react.useMemo)(()=>buildStyles(I),[I]),A=(0,_index2.resolveOtpInputSize)(I,_),w=I.components["otp-input"][_].radius,V=(0,_react.useRef)([]),[F,P]=(0,_react.useState)(-1),[R,C]=(0,_react.useState)(0),O=(0,_react.useRef)(null),k=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,S=(0,_react.useRef)(new Map),L=(0,_react.useMemo)(()=>{const e=S.current,t=[];for(let a=0;a<s;a+=1){let i=e.get(a);i||(i=new _reactNative.Animated.Value(0),e.set(a,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),B=(0,_react.useRef)(-1),D=I.settings.components["otp-input"]?.shakeOnError??!1,z=(0,_index.useReducedMotion)(),M=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===O.current||!M||O.current||(m&&(0,_index3.triggerHaptic)("notificationError"),D&&!z&&((0,_index2.setNativeValue)(k,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(k,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:-1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:0,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0})]),e.start())),O.current=M,()=>e?.stop()},[M,k,D,m,z,I.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=B.current;if(B.current=F,e===F)return;if(-1===e&&-1===F)return;const t=[];return L.forEach((a,i)=>{const n=i===F?1:0;if(i!==F&&i!==e)return;const r=_reactNative.Animated.timing(a,{toValue:n,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!0});r.start(),t.push(r)}),()=>t.forEach(e=>{e.stop()})},[F,L,I]);const q=(0,_react.useCallback)(e=>{const t=V.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>q(0),blur:()=>{const e=V.current[F>=0?F:0];e?.blur()},clear:()=>{N(""),q(0)}}),[q,F,N]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>q(0),c);return()=>clearTimeout(e)}},[o,c,u,q]);const U=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(j.length,s);t+=1)e[t]=j[t]??"";return e},[j,s]),H=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==j&&(N(t),t.length===s&&r&&r(t))},[s,N,r,j]),W=(0,_react.useCallback)((e,t)=>{const a=t.replace(/\u200B/g,""),i=sanitizeChar(a,l);if(!i){const t=U.slice(),a=(t[e]??"").length>0;if(t[e]="",H(t.join("").slice(0,s)),!a&&e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}return}const n=U[e]??"",r=n&&i.length>s&&i.startsWith(n)?i.slice(n.length):i;if(r.length>=s){const t=r.slice(0,s),a=j.length;return H(t),t.length!==a&&m&&(0,_index3.triggerHaptic)(m),void V.current[e]?.blur()}const o=U.slice();let c=e;for(let e=0;e<i.length&&c<s;e+=1)o[c]=i[e]??"",c+=1;const u=o.join("").slice(0,s),d=j.length;H(u),u.length!==d&&m&&(0,_index3.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?V.current[e]?.blur():q(_)},[U,q,l,s,m,H,j]),$=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===(U[e]??"").length){if(e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}}else{const t=U.slice();t[e]="",H(t.join(""))}},[U,q,H]),G=(0,_react.useCallback)((e,t)=>{P(e),g?.(t)},[g]),K=(0,_react.useCallback)(()=>{P(-1)},[]),X=(0,_react.useCallback)(()=>{if(u)return;const e=U.indexOf("");q(-1===e?s-1:e)},[U,u,q,s]),J=(0,_react.useCallback)(e=>{C(e.nativeEvent.layout.width)},[]),Q=f??T.field(s),Y=R>0?Math.max(24,Math.min(A.cell,Math.floor((R-A.gap*(s-1))/s))):A.cell,Z=k.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h,onLayout:J,accessible:!0,accessibilityRole:"none",accessibilityLabel:Q,accessibilityValue:{text:a},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:X,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.row,{columnGap:A.gap,transform:[{translateX:Z}]}],children:U.map((e,t)=>{const a=F===t,i=e.length>0,n=M?I.colors["danger-border"]:I.colors["focus-ring"],r=L[t];if(!r)return null;const o=p&&i?"●":e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:Y,height:Y,radius:w,borderWidth:1.5,focused:a,error:M,filled:i,disabled:u,paddingHorizontal:I.space.none,paddingVertical:I.space.none,gap:I.space.none,style:v,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{V.current[t]=e},value:(p&&i?"":e)||"",onChangeText:e=>W(t,e),onKeyPress:e=>$(t,e),onFocus:e=>G(t,e),onBlur:K,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:i,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[E.input,{fontSize:A.text,color:I.colors["text-body"],...(0,_index2.fontFor)(I,"semibold")},b]}),p&&i?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:E.maskOverlay,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:[{fontSize:A.text},b],children:o})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.underline,{backgroundColor:n,opacity:r}]})]},`otp-cell-${t}`)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
|
|
@@ -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;
|