@webority/mobile-ui 0.188.1 → 0.190.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +1 -1
  2. package/dist/canvas-kit/kit.js +10 -10
  3. package/dist/canvas-kit/manifest.json +47 -24
  4. package/dist/canvas-kit/release.json +6 -6
  5. package/lib/commonjs/components/Button/Button.js +1 -1
  6. package/lib/commonjs/components/Button/index.js +1 -1
  7. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  8. package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
  9. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  10. package/lib/commonjs/components/Input/Input.js +1 -1
  11. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  12. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  13. package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
  14. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  15. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  16. package/lib/commonjs/components/Select/Select.js +1 -1
  17. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  18. package/lib/commonjs/components/Skeleton/Skeleton.js +1 -1
  19. package/lib/commonjs/components/SquircleFill/SquircleFill.js +1 -1
  20. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  21. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  22. package/lib/commonjs/index.js +1 -1
  23. package/lib/commonjs/theme/Gradient.js +1 -1
  24. package/lib/commonjs/theme/index.js +1 -1
  25. package/lib/commonjs/theme/tokens.generated.js +1 -1
  26. package/lib/commonjs/utils/squircle.js +1 -1
  27. package/lib/module/components/Button/Button.js +1 -1
  28. package/lib/module/components/Button/index.js +1 -1
  29. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  30. package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
  31. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  32. package/lib/module/components/Input/Input.js +1 -1
  33. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  34. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  35. package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
  36. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  37. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  38. package/lib/module/components/Select/Select.js +1 -1
  39. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  40. package/lib/module/components/Skeleton/Skeleton.js +1 -1
  41. package/lib/module/components/SquircleFill/SquircleFill.js +1 -1
  42. package/lib/module/components/TagInput/TagInput.js +1 -1
  43. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  44. package/lib/module/index.js +1 -1
  45. package/lib/module/theme/Gradient.js +1 -1
  46. package/lib/module/theme/index.js +1 -1
  47. package/lib/module/theme/tokens.generated.js +1 -1
  48. package/lib/module/utils/squircle.js +1 -1
  49. package/lib/typescript/commonjs/components/Button/Button.d.ts +10 -5
  50. package/lib/typescript/commonjs/components/Button/index.d.ts +2 -2
  51. package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +1 -1
  52. package/lib/typescript/commonjs/components/FieldBase/useFloatingLabel.d.ts +10 -2
  53. package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +1 -1
  54. package/lib/typescript/commonjs/components/Input/Input.d.ts +5 -2
  55. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +1 -1
  56. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -1
  57. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +1 -1
  58. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +2 -2
  59. package/lib/typescript/commonjs/components/Select/Select.d.ts +1 -1
  60. package/lib/typescript/commonjs/components/SquircleFill/SquircleFill.d.ts +7 -4
  61. package/lib/typescript/commonjs/components/index.d.ts +1 -1
  62. package/lib/typescript/commonjs/index.d.ts +1 -1
  63. package/lib/typescript/commonjs/theme/Gradient.d.ts +4 -0
  64. package/lib/typescript/commonjs/theme/componentSizes.d.ts +2 -2
  65. package/lib/typescript/commonjs/theme/index.d.ts +1 -1
  66. package/lib/typescript/commonjs/theme/tokens.generated.d.ts +8 -8
  67. package/lib/typescript/commonjs/utils/squircle.d.ts +7 -0
  68. package/lib/typescript/module/components/Button/Button.d.ts +10 -5
  69. package/lib/typescript/module/components/Button/index.d.ts +2 -2
  70. package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +1 -1
  71. package/lib/typescript/module/components/FieldBase/useFloatingLabel.d.ts +10 -2
  72. package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +1 -1
  73. package/lib/typescript/module/components/Input/Input.d.ts +5 -2
  74. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +1 -1
  75. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -1
  76. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +1 -1
  77. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +2 -2
  78. package/lib/typescript/module/components/Select/Select.d.ts +1 -1
  79. package/lib/typescript/module/components/SquircleFill/SquircleFill.d.ts +7 -4
  80. package/lib/typescript/module/components/index.d.ts +1 -1
  81. package/lib/typescript/module/index.d.ts +1 -1
  82. package/lib/typescript/module/theme/Gradient.d.ts +4 -0
  83. package/lib/typescript/module/theme/componentSizes.d.ts +2 -2
  84. package/lib/typescript/module/theme/index.d.ts +1 -1
  85. package/lib/typescript/module/theme/tokens.generated.d.ts +8 -8
  86. package/lib/typescript/module/utils/squircle.d.ts +7 -0
  87. 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.188.1"
5
+ "version": "0.190.0"
6
6
  },
7
7
  "rendererProtocolVersion": 14,
8
8
  "platform": "Phone",
@@ -1416,7 +1416,8 @@
1416
1416
  "enum": [
1417
1417
  "lg",
1418
1418
  "md",
1419
- "sm"
1419
+ "sm",
1420
+ "xl"
1420
1421
  ],
1421
1422
  "required": false,
1422
1423
  "description": "The size of the field.",
@@ -3209,11 +3210,16 @@
3209
3210
  "description": "An icon after the title."
3210
3211
  },
3211
3212
  {
3212
- "name": "rounded",
3213
- "type": "boolean",
3213
+ "name": "shape",
3214
+ "type": "enum",
3215
+ "enum": [
3216
+ "pill",
3217
+ "rounded",
3218
+ "sharp"
3219
+ ],
3214
3220
  "required": false,
3215
- "description": "Gives the button fully round ends.",
3216
- "default": false
3221
+ "description": "Corner shape: the size's rounded corner, fully round pill ends, or sharp square corners.",
3222
+ "default": "rounded"
3217
3223
  },
3218
3224
  {
3219
3225
  "name": "size",
@@ -3222,8 +3228,7 @@
3222
3228
  "lg",
3223
3229
  "md",
3224
3230
  "sm",
3225
- "xl",
3226
- "xs"
3231
+ "xl"
3227
3232
  ],
3228
3233
  "required": false,
3229
3234
  "description": "The size of the button.",
@@ -5232,7 +5237,8 @@
5232
5237
  "enum": [
5233
5238
  "lg",
5234
5239
  "md",
5235
- "sm"
5240
+ "sm",
5241
+ "xl"
5236
5242
  ],
5237
5243
  "required": false,
5238
5244
  "description": "Size of the trigger field."
@@ -5520,7 +5526,8 @@
5520
5526
  "enum": [
5521
5527
  "lg",
5522
5528
  "md",
5523
- "sm"
5529
+ "sm",
5530
+ "xl"
5524
5531
  ],
5525
5532
  "required": false,
5526
5533
  "description": "Size of the trigger field."
@@ -5981,7 +5988,8 @@
5981
5988
  "enum": [
5982
5989
  "lg",
5983
5990
  "md",
5984
- "sm"
5991
+ "sm",
5992
+ "xl"
5985
5993
  ],
5986
5994
  "required": false,
5987
5995
  "description": "Field height, padding and font size.",
@@ -8524,7 +8532,8 @@
8524
8532
  "enum": [
8525
8533
  "lg",
8526
8534
  "md",
8527
- "sm"
8535
+ "sm",
8536
+ "xl"
8528
8537
  ],
8529
8538
  "required": false,
8530
8539
  "description": "Density of the trigger text and chevron, matching the host field.",
@@ -8743,11 +8752,12 @@
8743
8752
  "name": "labelMode",
8744
8753
  "type": "enum",
8745
8754
  "enum": [
8755
+ "above",
8746
8756
  "float",
8747
8757
  "top"
8748
8758
  ],
8749
8759
  "required": false,
8750
- "description": "Where the label sits: permanently above the field, or floating inside it until focus.",
8760
+ "description": "Where the label sits: permanently above the field, floating inside it until focus and then on the top border, or floating inside it until focus and then above the box (the web's floatingLabel=\"above\").",
8751
8761
  "default": "top"
8752
8762
  },
8753
8763
  {
@@ -8850,7 +8860,8 @@
8850
8860
  "enum": [
8851
8861
  "lg",
8852
8862
  "md",
8853
- "sm"
8863
+ "sm",
8864
+ "xl"
8854
8865
  ],
8855
8866
  "required": false,
8856
8867
  "description": "The field height and text size.",
@@ -10595,7 +10606,8 @@
10595
10606
  "enum": [
10596
10607
  "lg",
10597
10608
  "md",
10598
- "sm"
10609
+ "sm",
10610
+ "xl"
10599
10611
  ],
10600
10612
  "required": false,
10601
10613
  "description": "The field height, stepper size and text size.",
@@ -11935,7 +11947,8 @@
11935
11947
  "enum": [
11936
11948
  "lg",
11937
11949
  "md",
11938
- "sm"
11950
+ "sm",
11951
+ "xl"
11939
11952
  ],
11940
11953
  "required": false,
11941
11954
  "description": "The field size.",
@@ -12073,7 +12086,8 @@
12073
12086
  "enum": [
12074
12087
  "lg",
12075
12088
  "md",
12076
- "sm"
12089
+ "sm",
12090
+ "xl"
12077
12091
  ],
12078
12092
  "required": false,
12079
12093
  "description": "The field size.",
@@ -14070,7 +14084,8 @@
14070
14084
  "enum": [
14071
14085
  "lg",
14072
14086
  "md",
14073
- "sm"
14087
+ "sm",
14088
+ "xl"
14074
14089
  ],
14075
14090
  "required": false,
14076
14091
  "description": "The field height and text size.",
@@ -14097,7 +14112,7 @@
14097
14112
  "underline"
14098
14113
  ],
14099
14114
  "required": false,
14100
- "description": "A filled pill, an outline field or a bottom line; left out, the theme chooses."
14115
+ "description": "A filled field, an outline field or a bottom line; left out, the theme chooses."
14101
14116
  }
14102
14117
  ],
14103
14118
  "itemsTakeAction": [],
@@ -14756,7 +14771,8 @@
14756
14771
  "enum": [
14757
14772
  "lg",
14758
14773
  "md",
14759
- "sm"
14774
+ "sm",
14775
+ "xl"
14760
14776
  ],
14761
14777
  "required": false,
14762
14778
  "description": "The field size.",
@@ -18600,7 +18616,8 @@
18600
18616
  "enum": [
18601
18617
  "lg",
18602
18618
  "md",
18603
- "sm"
18619
+ "sm",
18620
+ "xl"
18604
18621
  ],
18605
18622
  "required": false,
18606
18623
  "description": "The field size.",
@@ -19029,7 +19046,8 @@
19029
19046
  "enum": [
19030
19047
  "lg",
19031
19048
  "md",
19032
- "sm"
19049
+ "sm",
19050
+ "xl"
19033
19051
  ],
19034
19052
  "required": false,
19035
19053
  "description": "Field size."
@@ -21338,8 +21356,8 @@
21338
21356
  "md": 10,
21339
21357
  "none": 0,
21340
21358
  "pill": 9999,
21341
- "sm": 6,
21342
- "xl": 20
21359
+ "sm": 8,
21360
+ "xl": 16
21343
21361
  },
21344
21362
  "shadow": {
21345
21363
  "card": {
@@ -23218,6 +23236,11 @@
23218
23236
  "version": "0.181.0",
23219
23237
  "components": [],
23220
23238
  "values": {}
23239
+ },
23240
+ {
23241
+ "version": "0.189.0",
23242
+ "components": [],
23243
+ "values": {}
23221
23244
  }
23222
23245
  ]
23223
23246
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.188.1",
3
+ "version": "0.190.0",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 14,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.188.1"
9
+ "version": "0.190.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "9eba63a1f53613ae1ebe66946db60e1395b036eb49ed033ca3e8816cada94720",
14
- "bytes": 674503
13
+ "sha256": "5ad0359a54b8656fe0257e0fe181466fd725e1ba2da2d0d0f47b4c69963bd296",
14
+ "bytes": 675092
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "c1a6e00bdd0a61e562fb63de439d4de3ddde59188fcda35930fca59508254e9c",
18
- "bytes": 5707966
17
+ "sha256": "01cd7138296804cf027cd28b0f48736777e4b55447c2237593a3a64f75643ba2",
18
+ "bytes": 5710590
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BUTTON_VARIANTS=exports.BUTTON_TONES=void 0,exports.Button=Button,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0,exports.isButtonTone=isButtonTone,exports.isButtonVariant=isButtonVariant;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../text/index.js"),_buttonG=require("../../text/phone/button.g.js"),_index2=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const BUTTON_VARIANTS=exports.BUTTON_VARIANTS=["solid","soft","outline","ghost","link","glass"],BUTTON_TONES=exports.BUTTON_TONES=["primary","success","warning","danger","info","neutral"];function isButtonVariant(e){return BUTTON_VARIANTS.some(t=>t===e)}function isButtonTone(e){return BUTTON_TONES.some(t=>t===e)}function Button({ref:e,...t}){const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:a=!1,fullWidth:l=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:_=!1,gradient:h,style:p,wrapperStyle:x,textStyle:m,pressAnimation:f,onPress:v,accessibilityLabel:y,accessibilityHint:T,accessibilityState:S,testID:j,onLayout:I,labels:C,...N}=t;(0,_assertValidValue.assertValidValue)("Button","variant",t.variant,["solid","soft","outline","ghost","link","glass"]),(0,_assertValidValue.assertValidValue)("Button","tone",t.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Button","size",t.size,["xs","sm","md","lg","xl"]);const R=(0,_index2.useTheme)(),k=R.settings.components.button,V=o??k?.defaultVariant??"solid",w=i??k?.defaultSize??"md",F=(0,_index.useMobileUiText)("button",_buttonG.BUTTON_TEXT),O=(0,_react.useMemo)(()=>({...F,...C}),[F,C]),[B,q]=(0,_react.useState)(!1),L=(0,_react.useRef)(!1),A=n||B,P=!a&&!A,W={...S,disabled:!P,busy:A},z="link"===V,U=f??k?.defaultPressAnimation??(!z&&"scale"),E=(0,_usePressAnimation.usePressAnimation)({preset:U||"scale",enabled:!1!==U&&P}),D=(0,_useFlickGuard.useFlickGuard)(),H=(0,_react.useMemo)(()=>buildStyles(R),[R]),M=(0,_react.useMemo)(()=>(0,_index2.resolveButtonSize)(R,w),[R,w]),G=(0,_react.useMemo)(()=>toneFor(R,s),[R,s]),K=(0,_react.useMemo)(()=>variantFor(R,V,G,a),[R,V,G,a]),X=(0,_react.useMemo)(()=>!h||a||"solid"!==V?null:"string"==typeof h?R.settings.gradients[h]??null:h,[h,a,V,R.settings.gradients]),Y=_reactNative.StyleSheet.flatten(p)?.borderRadius,J=z?0:"number"==typeof Y?Y:_?R.radius.pill:M.radius,Q=(0,_SquircleFill.useSquircle)(!X&&"link"!==V,J,I),Z=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[$,ee]=(0,_react.useState)(0),[te,re]=(0,_react.useState)(null),oe=z?e=>ee(e.nativeEvent.layout.width):void 0,settlePending=()=>{L.current=!1,q(!1)},se=y??r,ie="outline"===V||"ghost"===V,ne=!ie&&!z,ae={color:K.textColor,size:M.icon,disabled:a},le=b&&!z&&Boolean(c),ce=R.space.xs,de=M["min-height"]-2*ce-2*K.borderWidth,ue={color:K.badgeInk,size:M["badge-icon"],disabled:a},be=A?(0,_jsxRuntime.jsx)(_index3.Spinner,{variant:"circular",size:"sm",color:le?K.badgeInk:K.textColor,accessibilityLabel:O.loading}):c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(c,le?ue:ae,u)}):null,ge=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.contentRow,children:[le?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[H.iconLeft,H.iconBadge,{width:de,height:de,borderRadius:de/2,backgroundColor:K.badgeFill}],children:be}):be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.iconLeft,children:be}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:oe,children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[H.label,{color:K.textColor,fontSize:M.text,lineHeight:Math.round(M.text*R.leading.body)},m],children:r}),z?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[H.linkUnderline,{backgroundColor:K.textColor,transform:[{translateX:Z.interpolate({inputRange:[0,1],outputRange:[-$/2,0]})},{scaleX:Z.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(d,ae,u)}):null]}),he=z?null===te?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(te)):touchSlopFor(M["min-height"]),pe={top:he,bottom:he,left:z?LINK_HIT_SLOP:0,right:z?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.style,l?H.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:e,onPress:e=>{if(!P||L.current||D.isFlick(e))return;E.press();const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t);const r=v?.(e);return r instanceof Promise?(L.current=!0,q(!0),r.then(settlePending,e=>{throw settlePending(),e})):void 0},onPressIn:e=>{D.onPressIn(e),E.pressIn(),z&&P&&(Z.stopAnimation(),Z.setValue(0),_reactNative.Animated.timing(Z,{toValue:1,duration:R.motion.duration.slower,easing:_reactNative.Easing.bezier(...R.motion.ease.decelerate),useNativeDriver:_nativeDriver.nativeDriver}).start())},onPressOut:()=>{E.pressOut()},disabled:!P,hitSlop:pe,...(0,_hitSlop.hitSlopMarker)(pe),accessibilityRole:"button",accessibilityLabel:se,accessibilityHint:T,accessibilityState:W,...(0,_ariaState.ariaFromState)(W),testID:j,onLayout:e=>{Q.onLayout(e),z&&re(e.nativeEvent.layout.height)},style:({pressed:e})=>[H.base,{paddingHorizontal:z?0:M["padding-x"],paddingVertical:z?0:le?ce:M["padding-y"],paddingLeft:le?ce:void 0,minHeight:z?void 0:M["min-height"],borderRadius:J,..._corners.smoothCorners,backgroundColor:X||Q.active?"transparent":K.backgroundColor,borderWidth:K.borderWidth,borderColor:Q.active?"transparent":K.borderColor,opacity:A?.55:1,overflow:Q.active||z?"visible":"hidden"},e&&ie&&!Q.active?{backgroundColor:R.colors["surface-pressed"]}:null,l?H.fullWidth:null,p],...N,"aria-disabled":!P,"aria-busy":A,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Q.active&&Q.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:Q.size.width,height:Q.size.height,radius:J,fill:e&&ie?R.colors["surface-pressed"]:K.backgroundColor,stroke:K.borderColor,strokeWidth:K.borderWidth,hostBorderWidth:K.borderWidth}):null,X?(0,_jsxRuntime.jsx)(_index2.Gradient,{gradient:X,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:J,..._corners.smoothCorners}]}):null,e&&ne?Q.active&&Q.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:Q.size.width,height:Q.size.height,radius:J,fill:K.pressedTint,hostBorderWidth:K.borderWidth,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[H.pressedOverlay,{borderRadius:J,backgroundColor:K.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,ge]})})})}const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};case"neutral":return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},a=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...a};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:e.size.border},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BUTTON_VARIANTS=exports.BUTTON_TONES=exports.BUTTON_SHAPES=void 0,exports.Button=Button,exports.buttonLabelInk=buttonLabelInk,exports.default=void 0,exports.isButtonTone=isButtonTone,exports.isButtonVariant=isButtonVariant;var _react=require("react"),_reactNative=require("react-native"),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../text/index.js"),_buttonG=require("../../text/phone/button.g.js"),_index2=require("../../theme/index.js"),_animatedValue=require("../../theme/animatedValue.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const BUTTON_VARIANTS=exports.BUTTON_VARIANTS=["solid","soft","outline","ghost","link","glass"],BUTTON_TONES=exports.BUTTON_TONES=["primary","success","warning","danger","info","neutral"],BUTTON_SHAPES=exports.BUTTON_SHAPES=["rounded","pill","sharp"];function isButtonVariant(e){return BUTTON_VARIANTS.some(t=>t===e)}function isButtonTone(e){return BUTTON_TONES.some(t=>t===e)}function Button({ref:e,...t}){const{label:r,variant:o,tone:s="primary",size:i,loading:n=!1,disabled:a=!1,fullWidth:l=!1,leftIcon:c,rightIcon:d,iconVariant:u,leftIconBadge:b=!1,haptic:g,shape:_="rounded",gradient:h,style:p,wrapperStyle:x,textStyle:m,pressAnimation:f,onPress:v,accessibilityLabel:S,accessibilityHint:T,accessibilityState:y,testID:j,onLayout:I,labels:N,...C}=t;(0,_assertValidValue.assertValidValue)("Button","variant",t.variant,["solid","soft","outline","ghost","link","glass"]),(0,_assertValidValue.assertValidValue)("Button","tone",t.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Button","size",t.size,["sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Button","shape",t.shape,BUTTON_SHAPES);const V=(0,_index2.useTheme)(),k=V.settings.components.button,w=o??k?.defaultVariant??"solid",R=i??k?.defaultSize??"md",O=(0,_index.useMobileUiText)("button",_buttonG.BUTTON_TEXT),B=(0,_react.useMemo)(()=>({...O,...N}),[O,N]),[F,A]=(0,_react.useState)(!1),q=(0,_react.useRef)(!1),L=n||F,P=!a&&!L,E={...y,disabled:!P,busy:L},U="link"===w,W=f??k?.defaultPressAnimation??(!U&&"scale"),H=(0,_usePressAnimation.usePressAnimation)({preset:W||"scale",enabled:!1!==W&&P}),z=(0,_useFlickGuard.useFlickGuard)(),D=(0,_react.useMemo)(()=>buildStyles(V),[V]),M=(0,_react.useMemo)(()=>(0,_index2.resolveButtonSize)(V,R),[V,R]),G=(0,_react.useMemo)(()=>toneFor(V,s),[V,s]),K=(0,_react.useMemo)(()=>variantFor(V,w,G,a),[V,w,G,a]),$=(0,_react.useMemo)(()=>{if(null==h)return null;if("solid"!==w)throw new RangeError(`[@webority/mobile-ui] <Button> received a gradient with variant="${w}"; a gradient paints only the "solid" variant. Set variant="solid" or omit the gradient.`);let e;if("string"==typeof h){const t=V.settings.gradients[h];if(void 0===t){const e=Object.keys(V.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <Button> received gradient="${h}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}e=t}else e=h;return a?null:e},[h,a,w,V.settings.gradients]),X=_reactNative.StyleSheet.flatten(p)?.borderRadius,Y=U?0:"number"==typeof X?X:"pill"===_?V.radius.pill:"sharp"===_?0:M.radius,J=(0,_SquircleFill.useSquircle)(!$&&"link"!==w,Y,I,!0),Q=(0,_react.useRef)((0,_animatedValue.createAnimatedValue)(0)).current,[Z,ee]=(0,_react.useState)(0),[te,re]=(0,_react.useState)(null),oe=U?e=>ee(e.nativeEvent.layout.width):void 0,settlePending=()=>{q.current=!1,A(!1)},se=S??r,ie="outline"===w||"ghost"===w,ne=!ie&&!U,ae={color:K.textColor,size:M.icon,disabled:a},le=b&&!U&&Boolean(c),ce=V.space.xs,de=M["min-height"]-2*ce-2*K.borderWidth,ue={color:K.badgeInk,size:M["badge-icon"],disabled:a},be=L?(0,_jsxRuntime.jsx)(_index3.Spinner,{variant:"circular",size:"sm",color:le?K.badgeInk:K.textColor,accessibilityLabel:B.loading}):c?(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(c,le?ue:ae,u)}):null,ge=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.contentRow,children:[le?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"button-icon-badge",style:[D.iconLeft,D.iconBadge,{width:de,height:de,borderRadius:de/2,backgroundColor:K.badgeFill}],children:be}):be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.iconLeft,children:be}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:oe,children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[D.label,{color:K.textColor,fontSize:M.text,lineHeight:Math.round(M.text*V.leading.body)},m],children:r}),U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[D.linkUnderline,{backgroundColor:K.textColor,transform:[{translateX:Q.interpolate({inputRange:[0,1],outputRange:[-Z/2,0]})},{scaleX:Q.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(d,ae,u)}):null]}),he=U?null===te?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(te)):touchSlopFor(M["min-height"]),pe={top:he,bottom:he,left:U?LINK_HIT_SLOP:0,right:U?LINK_HIT_SLOP:0};return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[H.style,l?D.fullWidth:null,x],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:e,onPress:e=>{if(!P||q.current||z.isFlick(e))return;H.press();const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t);const r=v?.(e);return r instanceof Promise?(q.current=!0,A(!0),r.then(settlePending,e=>{throw settlePending(),e})):void 0},onPressIn:e=>{z.onPressIn(e),H.pressIn(),U&&P&&(Q.stopAnimation(),Q.setValue(0),_reactNative.Animated.timing(Q,{toValue:1,duration:V.motion.duration.slower,easing:_reactNative.Easing.bezier(...V.motion.ease.decelerate),useNativeDriver:_nativeDriver.nativeDriver}).start())},onPressOut:()=>{H.pressOut()},disabled:!P,hitSlop:pe,...(0,_hitSlop.hitSlopMarker)(pe),accessibilityRole:"button",accessibilityLabel:se,accessibilityHint:T,accessibilityState:E,...(0,_ariaState.ariaFromState)(E),testID:j,onLayout:e=>{J.onLayout(e),U&&re(e.nativeEvent.layout.height)},style:({pressed:e})=>[D.base,{paddingHorizontal:U?0:M["padding-x"],paddingVertical:U?0:le?ce:M["padding-y"],paddingLeft:le?ce:void 0,minHeight:U?void 0:M["min-height"],borderRadius:Y,..._corners.smoothCorners,backgroundColor:$||J.active?"transparent":K.backgroundColor,borderWidth:K.borderWidth,borderColor:J.active?"transparent":K.borderColor,opacity:L?.55:1,overflow:J.active||U?"visible":"hidden"},e&&ie&&!J.active?{backgroundColor:V.colors["surface-pressed"]}:null,l?D.fullWidth:null,p],...C,"aria-disabled":!P,"aria-busy":L,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[J.active&&J.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:J.size.width,height:J.size.height,radius:Y,curve:"css",fill:e&&ie?V.colors["surface-pressed"]:K.backgroundColor,stroke:K.borderColor,strokeWidth:K.borderWidth,hostBorderWidth:K.borderWidth}):null,$?(0,_jsxRuntime.jsx)(_index2.Gradient,{gradient:$,style:[_reactNative.StyleSheet.absoluteFill,{borderRadius:Y,..._corners.smoothCorners}]}):null,e&&ne?J.active&&J.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:J.size.width,height:J.size.height,radius:Y,curve:"css",fill:K.pressedTint,hostBorderWidth:K.borderWidth,testID:"button-pressed"}):(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[D.pressedOverlay,{borderRadius:Y,backgroundColor:K.pressedTint,..._corners.smoothCorners}],testID:"button-pressed"}):null,ge]})})})}const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:(0,_color.tintOf)(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:(0,_color.tintOf)(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:(0,_color.tintOf)(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:(0,_color.tintOf)(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:(0,_color.tintOf)(e.colors.info,.14,e.colors["bg-subtle"])};case"neutral":return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,r,o)=>{const s=o?e.colors["text-disabled"]:r.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=o?i:{badgeFill:r.on,badgeInk:r.base},a=o?i:{badgeFill:r.base,badgeInk:r.on};switch(t){case"solid":return{backgroundColor:o?e.colors["surface-disabled"]:r.base,borderColor:"transparent",borderWidth:1,textColor:o?e.colors["text-disabled"]:r.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:o?e.colors["surface-disabled"]:r.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"outline":return{backgroundColor:"transparent",borderColor:o?e.colors.border:r.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...a};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:o?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...a};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:o?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:_color.ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:o?e.colors["text-disabled"]:r.base};default:return{backgroundColor:r.base,borderColor:"transparent",borderWidth:1,textColor:r.on,pressedTint:e.colors["surface-pressed"],...n}}};function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>_reactNative.StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:e.size.border},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});var _default=exports.default=Button;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"BUTTON_TONES",{enumerable:!0,get:function(){return _Button.BUTTON_TONES}}),Object.defineProperty(exports,"BUTTON_VARIANTS",{enumerable:!0,get:function(){return _Button.BUTTON_VARIANTS}}),Object.defineProperty(exports,"Button",{enumerable:!0,get:function(){return _Button.Button}}),Object.defineProperty(exports,"buttonLabelInk",{enumerable:!0,get:function(){return _Button.buttonLabelInk}}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return _Button.default}}),Object.defineProperty(exports,"isButtonTone",{enumerable:!0,get:function(){return _Button.isButtonTone}}),Object.defineProperty(exports,"isButtonVariant",{enumerable:!0,get:function(){return _Button.isButtonVariant}});var cache,_Button=_interopRequireWildcard(require("./Button.js"));function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,n,o=Object.defineProperty,u={__proto__:null,default:e};if(Object(e)!==e)return u;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,u)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((r=o&&Object.getOwnPropertyDescriptor(e,n))&&(r.get||r.set)?o(u,n,r):u[n]=e[n]);return u}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"BUTTON_SHAPES",{enumerable:!0,get:function(){return _Button.BUTTON_SHAPES}}),Object.defineProperty(exports,"BUTTON_TONES",{enumerable:!0,get:function(){return _Button.BUTTON_TONES}}),Object.defineProperty(exports,"BUTTON_VARIANTS",{enumerable:!0,get:function(){return _Button.BUTTON_VARIANTS}}),Object.defineProperty(exports,"Button",{enumerable:!0,get:function(){return _Button.Button}}),Object.defineProperty(exports,"buttonLabelInk",{enumerable:!0,get:function(){return _Button.buttonLabelInk}}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return _Button.default}}),Object.defineProperty(exports,"isButtonTone",{enumerable:!0,get:function(){return _Button.isButtonTone}}),Object.defineProperty(exports,"isButtonVariant",{enumerable:!0,get:function(){return _Button.isButtonVariant}});var cache,_Button=_interopRequireWildcard(require("./Button.js"));function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,n,o=Object.defineProperty,u={__proto__:null,default:e};if(Object(e)!==e)return u;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,u)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((r=o&&Object.getOwnPropertyDescriptor(e,n))&&(r.get||r.set)?o(u,n,r):u[n]=e[n]);return u}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveVariantColors=exports.resolveFieldTextStyle=exports.pickRepresentativeBorderColor=exports.hasFieldText=exports.fieldTextAsString=exports.default=exports.RequiredPlaceholder=exports.RequiredMark=exports.FieldMessage=exports.FieldLabel=exports.FieldErrorGlyph=exports.FieldBase=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFieldErrorScroll=require("../../hooks/useFieldErrorScroll.js"),_index=require("../../theme/index.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0},pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const r=e[t];if(r&&"transparent"!==r)return r}return e.bottom};exports.pickRepresentativeBorderColor=pickRepresentativeBorderColor;const resolveFieldTextStyle=(e,t={})=>{const{disabled:r=!1}=t;return{color:r?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:r?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:(0,_index.fontFor)(e,"normal")}};exports.resolveFieldTextStyle=resolveFieldTextStyle;const RequiredMark=()=>{const e=(0,_index.useTheme)(),t=!1===e.settings.components.field?.requiredMarkerSpace?"⁠":" ";return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:e.colors["danger-text"]},..."web"===_reactNative.Platform.OS?{"aria-hidden":!0}:null,children:`${t}${e.settings.components.field?.requiredMarker??"*"}`})};exports.RequiredMark=RequiredMark;const RequiredPlaceholder=({text:e,color:t,fontSize:r,weightStyle:i,align:o="center",paddingTop:l,textAlign:s})=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{justifyContent:"top"===o?"flex-start":"center",paddingTop:l}],children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:r,...i,includeFontPadding:!1,textAlign:s},children:[e,(0,_jsxRuntime.jsx)(RequiredMark,{})]})});exports.RequiredPlaceholder=RequiredPlaceholder;const FieldErrorGlyph=({size:e,color:t})=>{const r=(0,_index.useTheme)().settings.icons.error??_defaultIcons.defaultIcons.error;return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r({size:e,color:t})})};exports.FieldErrorGlyph=FieldErrorGlyph;const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;exports.hasFieldText=hasFieldText;const fieldTextAsString=e=>"string"==typeof e?e:void 0;exports.fieldTextAsString=fieldTextAsString;const FieldLabel=({children:e,size:t="md",required:r=!1,help:i,color:o,style:l})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveFieldSize)(s,t),a=hasFieldText(i),d=(0,_textInk.useTextInk)(l,n["label-text"],o??s.colors["field-label"]),c=(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[familyStyles.label,{color:o??s.colors["field-label"],fontSize:n["label-text"],...(0,_index.fontFor)(s,"semibold"),marginBottom:a?s.space.none:n["label-gap"]},a?familyStyles.labelShrink:null,l],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:d,children:e}),r?(0,_jsxRuntime.jsx)(RequiredMark,{}):null]});return a?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:"string"==typeof i||"number"==typeof i?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.helpText,{color:s.colors["text-muted"],fontSize:n["message-text"],...(0,_index.fontFor)(s,"normal")}],children:i}):i})]}):c};exports.FieldLabel=FieldLabel;const FieldMessage=({text:e,error:t=!1,size:r="md",style:i})=>{const o=(0,_index.useTheme)(),l=(0,_index.resolveFieldSize)(o,r),s=t?o.colors["field-message"]:o.colors["text-muted"],n=(0,_textInk.useTextInk)(i,l["message-text"],s);return hasFieldText(e)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:o.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?(0,_jsxRuntime.jsx)(FieldErrorGlyph,{size:l["message-text"],color:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...(0,_index.fontFor)(o,"normal")},i],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:n,children:e})})]}):null};exports.FieldMessage=FieldMessage;const familyStyles=_reactNative.StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},helpText:{includeFontPadding:!1},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}}),resolveVariantColors=(e,t)=>{let r,i,o,l,s;"outline"===t?(r=e.colors["field-bg"],i=e.colors["field-bg-focus"],o=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(r="transparent",i=void 0,o="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(r=e.colors["field-bg"],i=void 0,o=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),a=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:r,backgroundIdleFilled:r,backgroundFocused:i,backgroundError:void 0,backgroundDisabled:o,borderIdle:n,borderFocused:a,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(a)}};exports.resolveVariantColors=resolveVariantColors;const FieldBase=e=>{(0,_assertValidValue.assertValidValue)("FieldBase","variant",e.variant,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("FieldBase","size",e.size,["sm","md","lg"]);const{size:t="md",variant:r,focused:i=!1,disabled:o=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:a=!1,trailing:d,slotAlign:c="center",slotLineHeight:u,topNotch:x,children:b,onPress:p,pressFeedback:m=!0,minHeight:h,maxHeight:g,width:f,height:_,paddingHorizontal:y,paddingLeft:v,paddingRight:R,paddingVertical:S,radius:j,borderTopLeftRadius:F,borderTopRightRadius:T,borderBottomLeftRadius:k,borderBottomRightRadius:C,borderWidth:V,borderTopWidth:I,borderRightWidth:q,borderBottomWidth:w,borderLeftWidth:B,gap:N,flushBottom:L=!1,style:z,testID:E,accessibilityRole:D,accessibilityLabel:M,accessibilityState:W,accessibilityHint:P}=e,A=(0,_index.useTheme)(),H=(0,_useFieldErrorScroll.useFieldErrorAnchor)(l),G=(0,_react.useMemo)(()=>buildStyles(),[]),O=r??A.settings.components.field?.defaultVariant??"outline",$=(0,_index.resolveFieldSize)(A,t),J=(0,_react.useMemo)(()=>resolveVariantColors(A,O),[A,O]),K=l?2:i?1:0,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(K)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Q,{toValue:K,duration:A.motion.duration.fast,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[K,Q,A.motion.duration.fast,A.motion.ease["in-out"]]);const U=[0,1,2],X=s?J.backgroundIdleFilled:J.backgroundIdleEmpty,Y=J.backgroundFocused??X,Z=J.backgroundError??X,ee=o?J.backgroundDisabled:Q.interpolate({inputRange:U,outputRange:[X,Y,Z]}),te=J.borderIdle,re=J.borderFocused,ie=J.borderError,oe={top:I,right:q,bottom:w,left:B},le={top:oe.top??V??J.borderWidth.top,right:oe.right??V??J.borderWidth.right,bottom:oe.bottom??V??J.borderWidth.bottom,left:oe.left??V??J.borderWidth.left},se="underline"===O,ne=se?A.radius.none:j?A.radius[j]:$.radius,ae=se?{tl:A.radius.none,tr:A.radius.none,bl:A.radius.none,br:A.radius.none}:{tl:F??ne,tr:T??ne,bl:k??ne,br:C??ne},sideColor=e=>Q.interpolate({inputRange:U,outputRange:[te[e],re[e],ie[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,de=!se&&ae.tl===ae.tr&&ae.tl===ae.bl&&ae.tl===ae.br&&sameOnEverySide(le)&&sameOnEverySide(te)&&sameOnEverySide(re)&&sameOnEverySide(ie)&&sameOnEverySide(J.borderDisabled),ce=(0,_SquircleFill.useSquircle)(de,ae.tl),ue=ce.active?{borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent",borderLeftColor:"transparent"}:o?{borderTopColor:J.borderDisabled.top,borderRightColor:J.borderDisabled.right,borderBottomColor:J.borderDisabled.bottom,borderLeftColor:J.borderDisabled.left}:{borderTopColor:sideColor("top"),borderRightColor:sideColor("right"),borderBottomColor:sideColor("bottom"),borderLeftColor:sideColor("left")},xe=o?J.borderDisabled.top:sideColor("top"),be={minHeight:_??h??$["min-height"],maxHeight:g,paddingHorizontal:y??$["padding-x"],paddingVertical:S??$["padding-y"],paddingLeft:v??y??$["padding-x"],paddingRight:R??y??$["padding-x"],backgroundColor:ce.active?"transparent":ee,columnGap:N??A.space.md,alignItems:"top"===c?"flex-start":"center",borderTopLeftRadius:ae.tl,borderTopRightRadius:ae.tr,borderBottomLeftRadius:ae.bl,borderBottomRightRadius:ae.br,borderCurve:_corners.smoothCorners.borderCurve,borderTopWidth:le.top,borderRightWidth:le.right,borderBottomWidth:le.bottom,borderLeftWidth:le.left,...ue,...void 0!==f?{width:f}:null,...void 0!==_?{height:_}:null},pe=(0,_react.useRef)(K);pe.current=K,(0,_react.useEffect)(()=>{Q.setValue(pe.current)},[J,Q]);const me=L?{marginBottom:A.space.none}:void 0,he={disabled:o,...W},ge="top"===c,fe=ge?{alignSelf:"flex-start",marginTop:Math.max(0,((u??$.icon)-$.icon)/2)}:null,ye=_??h??$["min-height"],ve=(()=>{if(!x)return 0;const e=Math.min(ae.tl,ye/2),t=x.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),Re=x&&le.top>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-le.top,left:x.left-le.left,width:x.width,height:le.top+ve,backgroundColor:ee}}):null,renderInner=e=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ce.active&&ce.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ce.size.width,height:ce.size.height,radius:ae.tl,fill:e&&!o?A.colors["surface-pressed"]:ee,stroke:xe,strokeWidth:le.top,hostBorderWidth:le.top}):null,Re,null!=n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:n}):null,null!=n&&a?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[G.divider,fe,{height:$.icon,backgroundColor:A.colors["field-border"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.content,ge?G.contentTop:null],children:b}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:d}):null]}),Se=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,be,p?null:me,z],accessibilityRole:D,accessibilityLabel:M,accessibilityHint:P,accessibilityState:he,...(0,_ariaState.ariaFromState)(he),testID:E,children:renderInner(!1)});return p&&!m?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,accessible:!1,style:me,testID:E?`${E}-press`:void 0,children:Se}):p?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,style:me,accessibilityRole:D??"button",accessibilityLabel:M,accessibilityHint:P,accessibilityState:he,...(0,_ariaState.ariaFromState)(he),testID:E,children:({pressed:e})=>(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,be,!e||o||ce.active?null:{backgroundColor:A.colors["surface-pressed"]},z],children:renderInner(e)})}):Se};exports.FieldBase=FieldBase,FieldBase.displayName="FieldBase";const buildStyles=()=>_reactNative.StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});var _default=exports.default=FieldBase;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveVariantColors=exports.resolveFieldTextStyle=exports.pickRepresentativeBorderColor=exports.hasFieldText=exports.fieldTextAsString=exports.default=exports.RequiredPlaceholder=exports.RequiredMark=exports.FieldMessage=exports.FieldLabel=exports.FieldErrorGlyph=exports.FieldBase=void 0;var _react=require("react"),_reactNative=require("react-native"),_useFieldErrorScroll=require("../../hooks/useFieldErrorScroll.js"),_index=require("../../theme/index.js"),_ariaState=require("../../utils/ariaState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0},pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const r=e[t];if(r&&"transparent"!==r)return r}return e.bottom};exports.pickRepresentativeBorderColor=pickRepresentativeBorderColor;const resolveFieldTextStyle=(e,t={})=>{const{disabled:r=!1}=t;return{color:r?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:r?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:(0,_index.fontFor)(e,"normal")}};exports.resolveFieldTextStyle=resolveFieldTextStyle;const RequiredMark=()=>{const e=(0,_index.useTheme)(),t=!1===e.settings.components.field?.requiredMarkerSpace?"⁠":" ";return(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:e.colors["danger-text"]},..."web"===_reactNative.Platform.OS?{"aria-hidden":!0}:null,children:`${t}${e.settings.components.field?.requiredMarker??"*"}`})};exports.RequiredMark=RequiredMark;const RequiredPlaceholder=({text:e,color:t,fontSize:r,weightStyle:i,align:o="center",paddingTop:l,textAlign:s})=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{justifyContent:"top"===o?"flex-start":"center",paddingTop:l}],children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:r,...i,includeFontPadding:!1,textAlign:s},children:[e,(0,_jsxRuntime.jsx)(RequiredMark,{})]})});exports.RequiredPlaceholder=RequiredPlaceholder;const FieldErrorGlyph=({size:e,color:t})=>{const r=(0,_index.useTheme)().settings.icons.error??_defaultIcons.defaultIcons.error;return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:r({size:e,color:t})})};exports.FieldErrorGlyph=FieldErrorGlyph;const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;exports.hasFieldText=hasFieldText;const fieldTextAsString=e=>"string"==typeof e?e:void 0;exports.fieldTextAsString=fieldTextAsString;const FieldLabel=({children:e,size:t="md",required:r=!1,help:i,color:o,style:l})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveFieldSize)(s,t),a=hasFieldText(i),d=(0,_textInk.useTextInk)(l,n["label-text"],o??s.colors["field-label"]),c=(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[familyStyles.label,{color:o??s.colors["field-label"],fontSize:n["label-text"],...(0,_index.fontFor)(s,"semibold"),marginBottom:a?s.space.none:n["label-gap"]},a?familyStyles.labelShrink:null,l],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:d,children:e}),r?(0,_jsxRuntime.jsx)(RequiredMark,{}):null]});return a?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:"string"==typeof i||"number"==typeof i?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.helpText,{color:s.colors["text-muted"],fontSize:n["message-text"],...(0,_index.fontFor)(s,"normal")}],children:i}):i})]}):c};exports.FieldLabel=FieldLabel;const FieldMessage=({text:e,error:t=!1,size:r="md",style:i})=>{const o=(0,_index.useTheme)(),l=(0,_index.resolveFieldSize)(o,r),s=t?o.colors["field-message"]:o.colors["text-muted"],n=(0,_textInk.useTextInk)(i,l["message-text"],s);return hasFieldText(e)?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:o.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?(0,_jsxRuntime.jsx)(FieldErrorGlyph,{size:l["message-text"],color:s}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...(0,_index.fontFor)(o,"normal")},i],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:n,children:e})})]}):null};exports.FieldMessage=FieldMessage;const familyStyles=_reactNative.StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},helpText:{includeFontPadding:!1},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}}),resolveVariantColors=(e,t)=>{let r,i,o,l,s;"outline"===t?(r=e.colors["field-bg"],i=e.colors["field-bg-focus"],o=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(r="transparent",i=void 0,o="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(r=e.colors["field-bg"],i=void 0,o=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),a=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:r,backgroundIdleFilled:r,backgroundFocused:i,backgroundError:void 0,backgroundDisabled:o,borderIdle:n,borderFocused:a,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(a)}};exports.resolveVariantColors=resolveVariantColors;const FieldBase=e=>{(0,_assertValidValue.assertValidValue)("FieldBase","variant",e.variant,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("FieldBase","size",e.size,["sm","md","lg","xl"]);const{size:t="md",variant:r,focused:i=!1,disabled:o=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:a=!1,trailing:d,slotAlign:c="center",slotLineHeight:u,topNotch:x,children:b,onPress:p,pressFeedback:m=!0,minHeight:h,maxHeight:g,width:f,height:_,paddingHorizontal:y,paddingLeft:v,paddingRight:R,paddingVertical:S,radius:j,borderTopLeftRadius:F,borderTopRightRadius:T,borderBottomLeftRadius:k,borderBottomRightRadius:C,borderWidth:V,borderTopWidth:I,borderRightWidth:q,borderBottomWidth:w,borderLeftWidth:B,gap:N,flushBottom:L=!1,style:z,testID:E,accessibilityRole:D,accessibilityLabel:M,accessibilityState:W,accessibilityHint:P}=e,A=(0,_index.useTheme)(),H=(0,_useFieldErrorScroll.useFieldErrorAnchor)(l),G=(0,_react.useMemo)(()=>buildStyles(),[]),O=r??A.settings.components.field?.defaultVariant??"outline",$=(0,_index.resolveFieldSize)(A,t),J=(0,_react.useMemo)(()=>resolveVariantColors(A,O),[A,O]),K=l?2:i?1:0,Q=(0,_react.useRef)((0,_index.createAnimatedValue)(K)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Q,{toValue:K,duration:A.motion.duration.fast,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[K,Q,A.motion.duration.fast,A.motion.ease["in-out"]]);const U=[0,1,2],X=s?J.backgroundIdleFilled:J.backgroundIdleEmpty,Y=J.backgroundFocused??X,Z=J.backgroundError??X,ee=o?J.backgroundDisabled:Q.interpolate({inputRange:U,outputRange:[X,Y,Z]}),te=J.borderIdle,re=J.borderFocused,ie=J.borderError,oe={top:I,right:q,bottom:w,left:B},le={top:oe.top??V??J.borderWidth.top,right:oe.right??V??J.borderWidth.right,bottom:oe.bottom??V??J.borderWidth.bottom,left:oe.left??V??J.borderWidth.left},se="underline"===O,ne=se?A.radius.none:j?A.radius[j]:$.radius,ae=se?{tl:A.radius.none,tr:A.radius.none,bl:A.radius.none,br:A.radius.none}:{tl:F??ne,tr:T??ne,bl:k??ne,br:C??ne},sideColor=e=>Q.interpolate({inputRange:U,outputRange:[te[e],re[e],ie[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,de=!se&&ae.tl===ae.tr&&ae.tl===ae.bl&&ae.tl===ae.br&&sameOnEverySide(le)&&sameOnEverySide(te)&&sameOnEverySide(re)&&sameOnEverySide(ie)&&sameOnEverySide(J.borderDisabled),ce=(0,_SquircleFill.useSquircle)(de,ae.tl,void 0,!0),ue=ce.active?{borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent",borderLeftColor:"transparent"}:o?{borderTopColor:J.borderDisabled.top,borderRightColor:J.borderDisabled.right,borderBottomColor:J.borderDisabled.bottom,borderLeftColor:J.borderDisabled.left}:{borderTopColor:sideColor("top"),borderRightColor:sideColor("right"),borderBottomColor:sideColor("bottom"),borderLeftColor:sideColor("left")},xe=o?J.borderDisabled.top:sideColor("top"),be={minHeight:_??h??$["min-height"],maxHeight:g,paddingHorizontal:y??$["padding-x"],paddingVertical:S??$["padding-y"],paddingLeft:v??y??$["padding-x"],paddingRight:R??y??$["padding-x"],backgroundColor:ce.active?"transparent":ee,columnGap:N??A.space.md,alignItems:"top"===c?"flex-start":"center",borderTopLeftRadius:ae.tl,borderTopRightRadius:ae.tr,borderBottomLeftRadius:ae.bl,borderBottomRightRadius:ae.br,borderCurve:_corners.smoothCorners.borderCurve,borderTopWidth:le.top,borderRightWidth:le.right,borderBottomWidth:le.bottom,borderLeftWidth:le.left,...ue,...void 0!==f?{width:f}:null,...void 0!==_?{height:_}:null},pe=(0,_react.useRef)(K);pe.current=K,(0,_react.useEffect)(()=>{Q.setValue(pe.current)},[J,Q]);const me=L?{marginBottom:A.space.none}:void 0,he={disabled:o,...W},ge="top"===c,fe=ge?{alignSelf:"flex-start",marginTop:Math.max(0,((u??$.icon)-$.icon)/2)}:null,ye=_??h??$["min-height"],ve=(()=>{if(!x)return 0;const e=Math.min(ae.tl,ye/2),t=x.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),Re=x&&le.top>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-le.top,left:x.left-le.left,width:x.width,height:le.top+ve,backgroundColor:ee}}):null,renderInner=e=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ce.active&&ce.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ce.size.width,height:ce.size.height,radius:ae.tl,curve:"css",fill:e&&!o?A.colors["surface-pressed"]:ee,stroke:xe,strokeWidth:le.top,hostBorderWidth:le.top}):null,Re,null!=n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:n}):null,null!=n&&a?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[G.divider,fe,{height:$.icon,backgroundColor:A.colors["field-border"]}]}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.content,ge?G.contentTop:null],children:b}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[G.slot,fe],children:d}):null]}),Se=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,be,p?null:me,z],accessibilityRole:D,accessibilityLabel:M,accessibilityHint:P,accessibilityState:he,...(0,_ariaState.ariaFromState)(he),testID:E,children:renderInner(!1)});return p&&!m?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,accessible:!1,style:me,testID:E?`${E}-press`:void 0,children:Se}):p?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:p,disabled:o,style:me,accessibilityRole:D??"button",accessibilityLabel:M,accessibilityHint:P,accessibilityState:he,...(0,_ariaState.ariaFromState)(he),testID:E,children:({pressed:e})=>(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{ref:H,onLayout:ce.onLayout,style:[G.box,be,!e||o||ce.active?null:{backgroundColor:A.colors["surface-pressed"]},z],children:renderInner(e)})}):Se};exports.FieldBase=FieldBase,FieldBase.displayName="FieldBase";const buildStyles=()=>_reactNative.StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});var _default=exports.default=FieldBase;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFloatingLabel=exports.FLOATED_LABEL_SCALE=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_textInk=require("../Text/textInk.js"),_FieldBase=require("./FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");const FLOATED_LABEL_SCALE=exports.FLOATED_LABEL_SCALE=.85,FLOATED_LABEL_LIFT=1,useFloatingLabel=({label:e,enabled:t,floated:i,required:n=!1,variant:r,sizeTokens:a,leadingOffset:o,trailingOffset:s=0,textAlign:l="left",paddingLeft:u,lineHeight:d,restNudge:c=0,floatTrim:_=0,color:x,style:g})=>{const h=(0,_index.useTheme)(),v=(0,_react.useRef)((0,_index.createAnimatedValue)(i?1:0)).current,L=(0,_react.useRef)((0,_index.createAnimatedValue)(i?1:0)).current,f="outline"===r,[p,m]=(0,_react.useState)(null);return(0,_react.useEffect)(()=>{const e=i?1:0,timing=(t,i)=>_reactNative.Animated.timing(t,{toValue:e,duration:h.motion.duration.fast,easing:_reactNative.Easing.bezier(...h.motion.ease["in-out"]),useNativeDriver:i});f||L.setValue(e);const t=f?_reactNative.Animated.parallel([timing(v,_nativeDriver.nativeDriver),timing(L,!1)]):timing(v,_nativeDriver.nativeDriver);return t.start(),()=>t.stop()},[i,f,v,L,h.motion.duration.fast,h.motion.ease["in-out"]]),(0,_react.useMemo)(()=>{if(!t||!(0,_FieldBase.hasFieldText)(e))return{node:null,topNotch:void 0};const i=d??p?.height??a.text,r=null!=d?a["padding-y"]+c:Math.max(0,(a["min-height"]-i)/2),A=-(r+i/2+1-_),E=v.interpolate({inputRange:[0,1],outputRange:[0,A]}),F=v.interpolate({inputRange:[0,1],outputRange:[1,FLOATED_LABEL_SCALE]}),R=-o,S=v.interpolate({inputRange:[0,1],outputRange:[0,R]}),T="right"===l?{right:a["padding-x"]+s,transformOrigin:"right center"}:"center"===l?{alignSelf:"center",transformOrigin:"center"}:{left:u+o,transformOrigin:"left center"},j=h.space.xs,D=p?p.width*FLOATED_LABEL_SCALE:0,O=p?"right"===l?p.width-D:"center"===l?(p.width-D)/2:0:0,b=f&&p?{left:p.x+R+O-j,width:L.interpolate({inputRange:[0,1],outputRange:[0,D+2*j]})}:void 0,N=_reactNative.StyleSheet.flatten(g),y={fontSize:N?.fontSize??a.text,color:N?.color??x};return{node:(0,_jsxRuntime.jsxs)(_reactNative.Animated.Text,{pointerEvents:"none",onLayout:e=>{const{x:t,width:i,height:n}=e.nativeEvent.layout;m(e=>e&&e.x===t&&e.width===i&&e.height===n?e:{x:t,width:i,height:n})},style:[styles.label,T,{top:r,color:x,fontSize:a.text,lineHeight:d,...(0,_index.fontFor)(h,"medium"),transform:[{translateX:S},{translateY:E},{scale:F}]},g],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:y,children:e}),n?(0,_jsxRuntime.jsx)(_FieldBase.RequiredMark,{}):null]}),topNotch:b}},[t,e,n,f,a,o,s,l,u,d,c,_,x,g,v,L,p,h])};exports.useFloatingLabel=useFloatingLabel;const styles=_reactNative.StyleSheet.create({label:{position:"absolute",zIndex:1}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFloatingLabel=exports.FLOATED_LABEL_SCALE=exports.ABOVE_LABEL_SPACE=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_textInk=require("../Text/textInk.js"),_FieldBase=require("./FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");const FLOATED_LABEL_SCALE=exports.FLOATED_LABEL_SCALE=.85,FLOATED_LABEL_LIFT=1,ABOVE_LABEL_SPACE=exports.ABOVE_LABEL_SPACE=22,ABOVE_LABEL_SCALE=.86,useFloatingLabel=({label:e,enabled:t,floated:i,placement:n="border",required:r=!1,variant:a,sizeTokens:o,leadingOffset:s,trailingOffset:l=0,textAlign:u="left",paddingLeft:_,lineHeight:d,restNudge:c=0,floatTrim:x=0,color:L,style:g})=>{const A=(0,_index.useTheme)(),E=(0,_react.useRef)((0,_index.createAnimatedValue)(i?1:0)).current,h=(0,_react.useRef)((0,_index.createAnimatedValue)(i?1:0)).current,p="outline"===a&&"border"===n,[v,f]=(0,_react.useState)(null);return(0,_react.useEffect)(()=>{const e=i?1:0,timing=(t,i)=>_reactNative.Animated.timing(t,{toValue:e,duration:A.motion.duration.fast,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:i});p||h.setValue(e);const t=p?_reactNative.Animated.parallel([timing(E,_nativeDriver.nativeDriver),timing(h,!1)]):timing(E,_nativeDriver.nativeDriver);return t.start(),()=>t.stop()},[i,p,E,h,A.motion.duration.fast,A.motion.ease["in-out"]]),(0,_react.useMemo)(()=>{if(!t||!(0,_FieldBase.hasFieldText)(e))return{node:null,topNotch:void 0};const i=d??v?.height??o.text,a=null!=d?o["padding-y"]+c:Math.max(0,(o["min-height"]-i)/2),m="above"===n,B=m?-(a+ABOVE_LABEL_SPACE):-(a+i/2+1-x),S=E.interpolate({inputRange:[0,1],outputRange:[0,B]}),F=E.interpolate({inputRange:[0,1],outputRange:[1,m?.86:FLOATED_LABEL_SCALE]}),O=m?"right"===u?o["padding-x"]+l:"center"===u?0:-(_+s):-s,R=E.interpolate({inputRange:[0,1],outputRange:[0,O]}),b="right"===u?{right:o["padding-x"]+l,transformOrigin:"right center"}:"center"===u?{alignSelf:"center",transformOrigin:"center"}:{left:_+s,transformOrigin:"left center"},T=A.space.xs,j=v?v.width*FLOATED_LABEL_SCALE:0,D=v?"right"===u?v.width-j:"center"===u?(v.width-j)/2:0:0,C=p&&v?{left:v.x+O+D-T,width:h.interpolate({inputRange:[0,1],outputRange:[0,j+2*T]})}:void 0,N=_reactNative.StyleSheet.flatten(g),y={fontSize:N?.fontSize??o.text,color:N?.color??L};return{node:(0,_jsxRuntime.jsxs)(_reactNative.Animated.Text,{pointerEvents:"none",onLayout:e=>{const{x:t,width:i,height:n}=e.nativeEvent.layout;f(e=>e&&e.x===t&&e.width===i&&e.height===n?e:{x:t,width:i,height:n})},style:[styles.label,b,{top:a,color:L,fontSize:o.text,lineHeight:d,...(0,_index.fontFor)(A,"medium"),transform:[{translateX:R},{translateY:S},{scale:F}]},g],children:[(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:y,children:e}),r?(0,_jsxRuntime.jsx)(_FieldBase.RequiredMark,{}):null]}),topNotch:C}},[t,e,r,n,p,o,s,l,u,_,d,c,x,L,g,E,h,v,A])};exports.useFloatingLabel=useFloatingLabel;const styles=_reactNative.StyleSheet.create({label:{position:"absolute",zIndex:1}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FloatingActionButton=FloatingActionButton,exports.default=exports.FloatingActionButtonGroup=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../text/index.js"),_floatingActionButtonG=require("../../text/phone/floatingActionButton.g.js"),_index2=require("../../theme/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,n,r=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((i=r&&Object.getOwnPropertyDescriptor(e,n))&&(i.get||i.set)?r(a,n,i):a[n]=e[n]);return a}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}};function FloatingActionButton({ref:e,...t}){const{icon:i,onPress:n,label:r,collapsed:a=!1,size:o="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:f,style:g,labelStyle:v,testID:h}=t;(0,_assertValidValue.assertValidValue)("FloatingActionButton","size",t.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","tone",t.tone,FAB_TONES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","position",t.position,FAB_POSITIONS);const x=!u&&!d,y=(0,_index2.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),A=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(y,o),[y,o]),j=(0,_react.useMemo)(()=>buildStyles(y),[y]),{style:N,pressIn:S,pressOut:w}=(0,_usePressAnimation.usePressAnimation)({enabled:x}),V=(0,_usePresenceMotion.usePresenceMotion)(),I=y.space[y.components["floating-action-button"]["edge-offset"]],E=y.space[y.components["floating-action-button"]["bottom-offset"]],C=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,F=V.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index2.setNativeValue)(C,1);const e=_reactNative.Animated.timing(C,{toValue:_?0:1,duration:F,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[m,_,C,F,y.motion.ease["in-out"]]);const P=A.diameter+(l??E)+R.bottom+I,B=C.interpolate({inputRange:[0,1],outputRange:V.range(P,0)}),D=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(C,N.opacity),[C,N.opacity]),T="string"==typeof r&&r.length>0,O=T&&a,k=V.reduced,M=y.space.sm,q=A["label-padding-x"],z=y.motion.duration.fast,L=y.motion.ease["in-out"],G=(0,_reactNativeReanimated.useSharedValue)(O?1:0),[H,U]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=O?1:0;return G.value=k?e:(0,_reactNativeReanimated.withTiming)(e,{duration:z,easing:_reactNativeReanimated.Easing.bezier(...L)}),()=>(0,_reactNativeReanimated.cancelAnimation)(G)},[O,k,G,z,L]);const $=(0,_react.useCallback)(e=>{const t=Math.ceil(e);U(e=>e===t?e:t)},[]),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:q*(1-G.value)}),...(0,_animatedDeps.webDeps)([q,G])),Y=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*G.value);return null===H?G.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+M)*(1-G.value)}},...(0,_animatedDeps.webDeps)([G,H,M])),Z=u?y.colors["surface-disabled"]:toneBackground(y,s),X=u?y.colors["text-disabled"]:toneForeground(y,s),J="lg"===o?"md":"sm",K=d?(0,_jsxRuntime.jsx)(_index3.Spinner,{variant:"circular",size:J,color:X}):(0,_slotIcon.renderSlotIcon)(i,{color:X,size:A.icon,disabled:u}),Q=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:I}}},[c,l,R.bottom,E,I]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Q,{transform:[{translateY:B},...N.transform],opacity:D},g],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:e,onPress:e=>{if(!x)return;const t=(0,_hapticUtils.resolveHaptic)(f,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),n()},onPressIn:S,onPressOut:w,disabled:!x,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!x,busy:d},"aria-disabled":!x,"aria-busy":d,testID:h,style:[j.base,T?{height:A.diameter,minWidth:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners}:{width:A.diameter,height:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners},y.shadow.popover,{backgroundColor:Z,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&x?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[j.pressedTint,{backgroundColor:pressedTintFor(y,s),borderRadius:A.diameter/2,..._corners.smoothCorners}]}):null,T?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[j.extendedRow,W],children:[K,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[j.labelClip,Y],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>$(e.nativeEvent.layout.width),style:[j.label,{color:X,fontSize:A.text,fontWeight:y.weight.semibold,marginLeft:M},v],numberOfLines:1,children:r})})]}):K]})})})}const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:i,actions:n,expanded:r,defaultExpanded:a=!1,onExpandedChange:o,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,style:b,secondaryActionStyle:f,labelPillStyle:g,labelStyle:v,testID:h}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_index.useMobileUiText)("floatingActionButton",_floatingActionButtonG.FLOATING_ACTION_BUTTON_TEXT),y=(0,_react.useMemo)(()=>({...x,...s}),[x,s]),R=d??y.quickActions,A=(0,_index2.useTheme)(),j=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(A,u),[A,u]),S=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),w=(0,_usePresenceMotion.usePresenceMotion)(),V=w.duration("default"),I=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],C=A.space[A.components["floating-action-button"]["secondary-gap"]],F=A.components["floating-action-button"]["stagger-ms"],P=(0,_react.useMemo)(()=>n.slice(0,6),[n]),B=P.length,D=(0,_react.useMemo)(()=>P.map((e,t)=>({action:e,index:t})).reverse(),[P]);n.forEach(e=>{(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const T=__DEV__?describeActionProblem(n):"";(0,_react.useEffect)(()=>{__DEV__&&T&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${T}`)},[T]);const O="boolean"==typeof r,[k,M]=(0,_react.useState)(a),q="boolean"==typeof r?r:k,z=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index2.setNativeValue)(z,1);const e=_reactNative.Animated.timing(z,{toValue:p?0:1,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[_,p,z,V,A.motion.ease["in-out"]]);const L=_&&p;(0,_react.useEffect)(()=>{L&&q&&(O||M(!1),o?.(!1))},[L,q,O,o]);const G=N.diameter+(l??E)+j.bottom+I,H=z.interpolate({inputRange:[0,1],outputRange:w.range(G,0)}),U=z,$=(0,_react.useRef)((0,_index2.createAnimatedValue)(q?1:0)).current,W=(0,_react.useRef)([]),[Y,Z]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=W.current;if(e.length!==B){if(e.length<B){const t=e.slice();for(let i=e.length;i<B;i+=1)t.push(new _reactNative.Animated.Value(q?1:0));W.current=t}else W.current=e.slice(0,B);Z(e=>e+1)}},[B,q]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});e.start();const t=W.current.map(e=>_reactNative.Animated.timing(e,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})),i=q?t:[...t].reverse(),n=_reactNative.Animated.stagger(F,i);return n.start(),()=>{e.stop(),n.stop()}},[q,$,V,A.motion.ease["in-out"],B,Y,F]);const X=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),O||M(e),o?.(e)},[O,o,m]),J=(0,_react.useRef)(null),K=(0,_react.useRef)(q),Q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(K.current===q)return;K.current=q;const e=Q.current;if(Q.current=!1,L||e)return;const t=J.current;t&&("web"===_reactNative.Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(q?(0,_index.pluralText)(y,"expanded",B,{label:R}):(0,_index.fillText)(y.collapsed,{label:R}))},[q,L,R,B,y]);const ee=(0,_react.useCallback)(()=>{X(!q)},[q,X]),te=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),Q.current=!0,e.onPress(),O||M(!1),o?.(!1)},[O,o,m]),ie=(0,_react.useCallback)(()=>{q&&X(!1)},[q,X]);(0,_react.useEffect)(()=>{if(!q)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(X(!1),!0));return()=>e.remove()},[q,X]),(0,_react.useEffect)(()=>{if(!q||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&X(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[q,X]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+j.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:I,alignItems:"flex-end"}}},[c,l,j.bottom,E,I]),slotOffset=e=>-(N.diameter+C)*(e+1),re=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),ae=.78*N.diameter,oe=(0,_react.useMemo)(()=>{const e=ae+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:N.diameter/2+ae/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,ae,N.diameter,A.space.sm]),se=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),ce=$.interpolate(w.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:se}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:L?"none":"box-none",style:[ne,{transform:[{translateY:H}],opacity:U},b],accessibilityRole:"menu",testID:h,children:[D.map(({action:e,index:t})=>{const i=W.current[t];if(!i)return null;const n=i.interpolate({inputRange:[0,1],outputRange:w.range(0,slotOffset(t))}),r=i.interpolate({inputRange:[0,1],outputRange:w.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),o=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[S.labelSlot,oe],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},g],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",accessibilityElementsHidden:!q,importantForAccessibility:q?"auto":"no-hide-descendants","aria-hidden":!q,style:[S.secondaryRow,re,{position:"absolute",bottom:0,opacity:i,transform:[{translateY:n},{scale:r}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>te(e),focusable:q,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[S.fabBase,A.shadow.elevated,{width:ae,height:ae,borderRadius:ae/2,..._corners.smoothCorners,backgroundColor:a},f],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:ae/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:o,size:N.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:R,accessibilityState:{expanded:q},"aria-expanded":q,style:[S.fabBase,A.shadow.popover,{width:N.diameter,height:N.diameter,borderRadius:N.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[S.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:i?void 0:{transform:[{rotate:ce}]},children:(0,_slotIcon.renderSlotIcon)(q&&i?i:t,{color:A.colors["on-primary"],size:N.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FloatingActionButton=FloatingActionButton,exports.default=exports.FloatingActionButtonGroup=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../text/index.js"),_floatingActionButtonG=require("../../text/phone/floatingActionButton.g.js"),_index2=require("../../theme/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,n,r=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((i=r&&Object.getOwnPropertyDescriptor(e,n))&&(i.get||i.set)?r(a,n,i):a[n]=e[n]);return a}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}};function FloatingActionButton({ref:e,...t}){const{icon:i,onPress:n,label:r,collapsed:a=!1,size:o="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:f,style:g,labelStyle:v,testID:h}=t;(0,_assertValidValue.assertValidValue)("FloatingActionButton","size",t.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","tone",t.tone,FAB_TONES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","position",t.position,FAB_POSITIONS);const x=!u&&!d,y=(0,_index2.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),A=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(y,o),[y,o]),j=(0,_react.useMemo)(()=>buildStyles(y),[y]),{style:S,pressIn:N,pressOut:w}=(0,_usePressAnimation.usePressAnimation)({enabled:x}),V=(0,_usePresenceMotion.usePresenceMotion)(),I=y.space[y.components["floating-action-button"]["edge-offset"]],E=y.space[y.components["floating-action-button"]["bottom-offset"]],C=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,F=V.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index2.setNativeValue)(C,1);const e=_reactNative.Animated.timing(C,{toValue:_?0:1,duration:F,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[m,_,C,F,y.motion.ease["in-out"]]);const P=A.diameter+(l??E)+R.bottom+I,B=C.interpolate({inputRange:[0,1],outputRange:V.range(P,0)}),D=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(C,S.opacity),[C,S.opacity]),T="string"==typeof r&&r.length>0,O=T&&a,k=V.reduced,M=y.space.sm,q=A["label-padding-x"],z=y.motion.duration.fast,L=y.motion.ease["in-out"],G=(0,_reactNativeReanimated.useSharedValue)(O?1:0),[H,U]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=O?1:0;return G.value=k?e:(0,_reactNativeReanimated.withTiming)(e,{duration:z,easing:_reactNativeReanimated.Easing.bezier(...L)}),()=>(0,_reactNativeReanimated.cancelAnimation)(G)},[O,k,G,z,L]);const[$,W]=(0,_react.useState)(r);$!==r&&(W(r),U(null));const Y=(0,_react.useCallback)(e=>{if(0!==G.value)return;const t=Math.ceil(e);U(e=>e===t?e:t)},[G]),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:q*(1-G.value)}),...(0,_animatedDeps.webDeps)([q,G])),X=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*G.value);return null===H?G.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+M)*(1-G.value)}},...(0,_animatedDeps.webDeps)([G,H,M])),J=u?y.colors["surface-disabled"]:toneBackground(y,s),K=u?y.colors["text-disabled"]:toneForeground(y,s),Q="lg"===o?"md":"sm",ee=d?(0,_jsxRuntime.jsx)(_index3.Spinner,{variant:"circular",size:Q,color:K}):(0,_slotIcon.renderSlotIcon)(i,{color:K,size:A.icon,disabled:u}),te=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:I}}},[c,l,R.bottom,E,I]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[te,{transform:[{translateY:B},...S.transform],opacity:D},g],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:e,onPress:e=>{if(!x)return;const t=(0,_hapticUtils.resolveHaptic)(f,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),n()},onPressIn:N,onPressOut:w,disabled:!x,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!x,busy:d},"aria-disabled":!x,"aria-busy":d,testID:h,style:[j.base,T?{height:A.diameter,minWidth:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners}:{width:A.diameter,height:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners},y.shadow.popover,{backgroundColor:J,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&x?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[j.pressedTint,{backgroundColor:pressedTintFor(y,s),borderRadius:A.diameter/2,..._corners.smoothCorners}]}):null,T?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[j.extendedRow,Z],children:[ee,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[j.labelClip,X],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>Y(e.nativeEvent.layout.width),style:[j.label,{color:K,fontSize:A.text,fontWeight:y.weight.semibold,marginLeft:M},v],numberOfLines:1,children:r})})]}):ee]})})})}const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:i,actions:n,expanded:r,defaultExpanded:a=!1,onExpandedChange:o,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,style:b,secondaryActionStyle:f,labelPillStyle:g,labelStyle:v,testID:h}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_index.useMobileUiText)("floatingActionButton",_floatingActionButtonG.FLOATING_ACTION_BUTTON_TEXT),y=(0,_react.useMemo)(()=>({...x,...s}),[x,s]),R=d??y.quickActions,A=(0,_index2.useTheme)(),j=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),S=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(A,u),[A,u]),N=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),w=(0,_usePresenceMotion.usePresenceMotion)(),V=w.duration("default"),I=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],C=A.space[A.components["floating-action-button"]["secondary-gap"]],F=A.components["floating-action-button"]["stagger-ms"],P=(0,_react.useMemo)(()=>n.slice(0,6),[n]),B=P.length,D=(0,_react.useMemo)(()=>P.map((e,t)=>({action:e,index:t})).reverse(),[P]);n.forEach(e=>{(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const T=__DEV__?describeActionProblem(n):"";(0,_react.useEffect)(()=>{__DEV__&&T&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${T}`)},[T]);const O="boolean"==typeof r,[k,M]=(0,_react.useState)(a),q="boolean"==typeof r?r:k,z=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index2.setNativeValue)(z,1);const e=_reactNative.Animated.timing(z,{toValue:p?0:1,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[_,p,z,V,A.motion.ease["in-out"]]);const L=_&&p;(0,_react.useEffect)(()=>{L&&q&&(O||M(!1),o?.(!1))},[L,q,O,o]);const G=S.diameter+(l??E)+j.bottom+I,H=z.interpolate({inputRange:[0,1],outputRange:w.range(G,0)}),U=z,$=(0,_react.useRef)((0,_index2.createAnimatedValue)(q?1:0)).current,W=(0,_react.useRef)([]),[Y,Z]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=W.current;if(e.length!==B){if(e.length<B){const t=e.slice();for(let i=e.length;i<B;i+=1)t.push(new _reactNative.Animated.Value(q?1:0));W.current=t}else W.current=e.slice(0,B);Z(e=>e+1)}},[B,q]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});e.start();const t=W.current.map(e=>_reactNative.Animated.timing(e,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})),i=q?t:[...t].reverse(),n=_reactNative.Animated.stagger(F,i);return n.start(),()=>{e.stop(),n.stop()}},[q,$,V,A.motion.ease["in-out"],B,Y,F]);const X=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),O||M(e),o?.(e)},[O,o,m]),J=(0,_react.useRef)(null),K=(0,_react.useRef)(q),Q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(K.current===q)return;K.current=q;const e=Q.current;if(Q.current=!1,L||e)return;const t=J.current;t&&("web"===_reactNative.Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(q?(0,_index.pluralText)(y,"expanded",B,{label:R}):(0,_index.fillText)(y.collapsed,{label:R}))},[q,L,R,B,y]);const ee=(0,_react.useCallback)(()=>{X(!q)},[q,X]),te=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),Q.current=!0,e.onPress(),O||M(!1),o?.(!1)},[O,o,m]),ie=(0,_react.useCallback)(()=>{q&&X(!1)},[q,X]);(0,_react.useEffect)(()=>{if(!q)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(X(!1),!0));return()=>e.remove()},[q,X]),(0,_react.useEffect)(()=>{if(!q||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&X(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[q,X]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+j.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:I,alignItems:"flex-end"}}},[c,l,j.bottom,E,I]),slotOffset=e=>-(S.diameter+C)*(e+1),re=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),ae=.78*S.diameter,oe=(0,_react.useMemo)(()=>{const e=ae+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:S.diameter/2+ae/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,ae,S.diameter,A.space.sm]),se=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),ce=$.interpolate(w.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:se}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:L?"none":"box-none",style:[ne,{transform:[{translateY:H}],opacity:U},b],accessibilityRole:"menu",testID:h,children:[D.map(({action:e,index:t})=>{const i=W.current[t];if(!i)return null;const n=i.interpolate({inputRange:[0,1],outputRange:w.range(0,slotOffset(t))}),r=i.interpolate({inputRange:[0,1],outputRange:w.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),o=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[N.labelSlot,oe],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},g],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",accessibilityElementsHidden:!q,importantForAccessibility:q?"auto":"no-hide-descendants","aria-hidden":!q,style:[N.secondaryRow,re,{position:"absolute",bottom:0,opacity:i,transform:[{translateY:n},{scale:r}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>te(e),focusable:q,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[N.fabBase,A.shadow.elevated,{width:ae,height:ae,borderRadius:ae/2,..._corners.smoothCorners,backgroundColor:a},f],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:ae/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:o,size:S.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:R,accessibilityState:{expanded:q},"aria-expanded":q,style:[N.fabBase,A.shadow.popover,{width:S.diameter,height:S.diameter,borderRadius:S.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:S.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:i?void 0:{transform:[{rotate:ce}]},children:(0,_slotIcon.renderSlotIcon)(q&&i?i:t,{color:A.colors["on-primary"],size:S.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Input=Input,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_inputG=require("../../text/phone/input.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index5=require("../Button/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");function Input(e){const{ref:t,label:i,help:n,placeholder:a,value:r,onChangeText:l,error:s,helperText:o,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:x=!1,multiline:p=!1,leftIcon:_,rightIcon:f,unit:g,unitStyle:m,prefix:v,prefixStyle:h,readOnly:y=!1,action:j,actionStyle:b,size:I="md",variant:S,labelMode:R,required:V=!1,maxLength:N,showCounter:w=!0,textAlign:T,format:F,parse:D,style:q,fieldStyle:k,inputStyle:z,labelStyle:A,messageStyle:B,radius:C,onFocus:L,onBlur:P,accessibilityLabel:M,labels:H,testID:E,editable:O,...G}=e;(0,_assertValidValue.assertValidValue)("Input","variant",S,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("Input","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Input","labelMode",R,["float","top"]),(0,_assertValidValue.assertValidValue)("Input","type",e.type,["input","password","textarea"]);const W=(0,_index2.useMobileUiText)("input",_inputG.INPUT_TEXT),$=(0,_react.useMemo)(()=>({...W,...H}),[W,H]),U=(0,_index3.useTheme)(),X=(0,_react.useMemo)(()=>buildStyles(U),[U]),J=(0,_index3.resolveFieldSize)(U,I),K=U.components.input[I]["multiline-min-height"],Q=Math.round(J.text*U.leading.body),Y=S??U.settings.components.input?.defaultVariant??U.settings.components.field?.defaultVariant??"outline",Z=R??U.settings.components.input?.defaultLabelMode??"top",[ee,te]=(0,_react.useState)(!1),[ie,ne]=(0,_react.useState)(!1),ae="password"===d||u||c,re="password"===d||u,le="textarea"===d||p,se=le?Math.round(.1*J.text):0,oe="string"==typeof r&&r.length>0,de=(0,_FieldBase.hasFieldText)(s),ce=!0===s||de,ue=(0,_FieldBase.hasFieldText)(o),xe=de||!ce&&ue,pe=(0,_FieldBase.hasFieldText)(i),fe=(0,_FieldBase.hasFieldText)(v),ge=!x&&!1!==O,me=ee||oe||fe,ve=(0,_react.useRef)(null),he=(0,_react.useMemo)(()=>(0,_index4.mergeRefs)(ve,t),[t]),ye=(0,_react.useCallback)(()=>{ge&&ve.current?.focus()},[ge]),je=pe&&"float"===Z,be=(0,_react.useRef)((0,_index3.createAnimatedValue)(0)).current,Ie=(0,_react.useRef)((0,_index3.createAnimatedValue)(xe?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Ie,{toValue:xe?1:0,duration:U.motion.duration.fast,easing:_reactNative.Easing.bezier(...U.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[xe,Ie,U.motion.duration.fast,U.motion.ease["in-out"]]);const Se=(0,_index.useReducedMotion)(),Re=U.settings.components.input?.shakeOnError??!1,Ve=(0,_react.useRef)(ce);(0,_react.useEffect)(()=>{if(!Re)return void(Ve.current=ce);let e;return ce&&!Ve.current&&(Se||((0,_index3.setNativeValue)(be,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(be,{toValue:1,duration:50,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(be,{toValue:-1,duration:50,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(be,{toValue:1,duration:50,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(be,{toValue:-1,duration:50,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(be,{toValue:0,duration:100,useNativeDriver:_nativeDriver.nativeDriver})]),e.start()),(0,_index4.triggerHaptic)("notificationError")),Ve.current=ce,()=>e?.stop()},[ce,be,Re,Se]);const Ne=(0,_react.useCallback)(e=>{te(!0),L?.(e)},[L]),we=(0,_react.useCallback)(e=>{te(!1),P?.(e)},[P]),Te=(0,_react.useCallback)(()=>{(0,_index4.triggerHaptic)("selection"),ne(e=>!e)},[]),Fe=U.colors["field-caret"],De=U.settings.components.input?.tintLabelOnFocus??!1,qe=ee&&De?U.colors["field-border-focus"]:U.colors["field-label"],ke=be.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),ze=Boolean(f)||Boolean(g)||re,Ae="underline"===Y,Be=_?J.icon+U.space.md+1+U.space.md:0,Ce=(0,_useFloatingLabel.useFloatingLabel)({label:i,enabled:je,floated:me,required:V,variant:Y,sizeTokens:J,leadingOffset:Be,trailingOffset:ze?J.icon+U.space.sm:0,textAlign:"center"===T||"right"===T?T:"left",paddingLeft:Ae?U.space.none:J["padding-x"],lineHeight:le?Q:void 0,restNudge:se,floatTrim:le?2:0,color:qe,style:A}),Le=(0,_FieldBase.resolveFieldTextStyle)(U,{disabled:x}),Pe=Le.color,Me=Le.placeholderColor,He=V&&!pe&&!oe&&"string"==typeof a&&a.length>0,Ee=ce?s:o,Oe=w&&"number"==typeof N&&"string"==typeof r?`${r.length} / ${N}`:null,Ge=ce?U.colors["field-message"]:U.colors["text-muted"],We=(0,_textInk.useTextInk)(B,J["message-text"],Ge),$e=M??(0,_FieldBase.fieldTextAsString)(i)??a,Ue=x?U.colors["field-icon-disabled"]:ee?U.colors["field-icon-focus"]:U.colors["field-icon"],Xe={focused:ee,disabled:x,error:ce,color:Ue,size:J.icon},renderSlot=e=>(0,_slotIcon.renderSlotIcon)(e,Xe),Je=(()=>{if(re){const e=(ie?U.settings.icons.eyeOff:U.settings.icons.eye)??(ie?_defaultIcons.defaultIcons.eyeOff:_defaultIcons.defaultIcons.eye);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Te,disabled:!ge,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:ie?$.hidePassword:$.showPassword,children:e({size:J.icon,color:Ue})})}const e=g?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.unit,{fontSize:J.text,color:Me},m],children:g}):null,t=f?(0,_slotIcon.slotIconView)(f,renderSlot(f)):null;return e&&t?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:X.trailingRow,children:[e,t]}):e??t})(),Ke=_?(0,_slotIcon.slotIconView)(_,renderSlot(_)):null,Qe=_reactNative.StyleSheet.flatten(h),Ye=Qe?.fontSize??J.text,Ze=Qe?.color??Me,et=(0,_react.useMemo)(()=>({fontSize:Ye,color:Ze}),[Ye,Ze]),tt=fe?"string"==typeof v||"number"==typeof v?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.prefix,{fontSize:J.text,color:Me,marginRight:U.space.xs,lineHeight:le?Q:void 0,paddingTop:le?se:void 0},h],children:v}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[X.prefixNode,{marginRight:U.space.xs,minHeight:le?Q:void 0,justifyContent:"center",paddingTop:le?se:void 0}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.prefix,{fontSize:J.text,color:Me,lineHeight:le?Q:void 0},h],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:et,children:v})})}):null,it=j?(0,_jsxRuntime.jsx)(_index5.Button,{variant:j.variant??"outline",tone:j.tone??"primary",size:I,label:j.label,leftIcon:j.icon,loading:j.loading,disabled:x||j.disabled,onPress:j.onPress,pressAnimation:!1,testID:j.testID,style:[X.action,{minHeight:J["min-height"],alignSelf:le?"flex-start":"stretch"},b]}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[X.container,{transform:[{translateX:ke}]},q],children:[pe&&!je?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:I,required:V,help:n,color:qe,style:A,children:i}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[X.fieldRow,{columnGap:U.space.sm,alignItems:le?"flex-start":"stretch"}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:X.fieldWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{testID:E?`${E}-field`:void 0,size:I,variant:Y,focused:ee,disabled:x,error:ce,filled:oe,minHeight:le?K:void 0,radius:C,leading:Ke,leadingDivider:null!=_,paddingLeft:Ae?U.space.none:void 0,trailing:Je,slotAlign:le?"top":"center",slotLineHeight:le?Q:void 0,topNotch:Ce.topNotch,onPress:ye,pressFeedback:!1,style:k,children:[tt,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:X.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:he,style:[X.input,{color:Pe,fontSize:J.text,...Le.weightStyle,paddingLeft:Ae?U.space.none:void 0,minHeight:le?K-2*J["padding-y"]:void 0,lineHeight:le?Q:void 0,paddingTop:le?se:void 0,textAlignVertical:le?"top":"center"},z],textAlign:T,placeholder:je&&!me||He?void 0:a,placeholderTextColor:Me,value:F&&null!=r?F(r):r,onChangeText:e=>{(0,_mobileCore.reportIdleActivity)(),l&&l(D?D(e):e)},onFocus:Ne,onBlur:we,editable:ge,readOnly:y,secureTextEntry:ae&&!ie,multiline:le,autoCapitalize:ae?"none":void 0,autoCorrect:!ae&&void 0,maxLength:N,selectionColor:Fe,accessibilityLabel:$e,accessibilityState:{disabled:x},"aria-disabled":x,testID:E,...G}),He&&"string"==typeof a?(0,_jsxRuntime.jsx)(_FieldBase.RequiredPlaceholder,{text:a,color:Me,fontSize:J.text,weightStyle:Le.weightStyle,align:le?"top":"center",paddingTop:le?se:void 0,textAlign:T}):null]})]}),Ce.node]}),it]}),xe||Oe?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[X.footerRow,{marginTop:J["message-gap"]}],children:[xe?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[X.messageRow,{columnGap:U.space.xs,opacity:Ie}],accessibilityLiveRegion:ce?"polite":"none",children:[ce?(0,_jsxRuntime.jsx)(_FieldBase.FieldErrorGlyph,{size:J["message-text"],color:Ge}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.messageText,{color:Ge,fontSize:J["message-text"],...(0,_index3.fontFor)(U,"normal")},B],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:We,children:Ee})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:X.footerSpacer}),Oe?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.counterText,{color:U.colors["text-subtle"],fontSize:J["message-text"],...(0,_index3.fontFor)(U,"normal")}],children:Oe}):null]}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},fieldRow:{flexDirection:"row"},fieldWrapper:{position:"relative",overflow:"visible",flex:1},action:{flexShrink:0},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"},unit:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},footerSpacer:{flex:1},messageRow:{flex:1,flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1},counterText:{flexShrink:0,includeFontPadding:!1}});var _default=exports.default=Input;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Input=Input,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_inputG=require("../../text/phone/input.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index5=require("../Button/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");function Input(e){const{ref:t,label:i,help:n,placeholder:a,value:l,onChangeText:r,error:s,helperText:o,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:x=!1,multiline:p=!1,leftIcon:_,rightIcon:f,unit:g,unitStyle:m,prefix:v,prefixStyle:h,readOnly:y=!1,action:b,actionStyle:j,size:S="md",variant:I,labelMode:R,required:V=!1,maxLength:F,showCounter:T=!0,textAlign:N,format:w,parse:D,style:A,fieldStyle:B,inputStyle:q,labelStyle:k,messageStyle:z,radius:C,onFocus:L,onBlur:P,accessibilityLabel:M,labels:E,testID:H,editable:O,...G}=e;(0,_assertValidValue.assertValidValue)("Input","variant",I,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("Input","size",e.size,["sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Input","labelMode",R,["float","top","above"]),(0,_assertValidValue.assertValidValue)("Input","type",e.type,["input","password","textarea"]);const W=(0,_index2.useMobileUiText)("input",_inputG.INPUT_TEXT),$=(0,_react.useMemo)(()=>({...W,...E}),[W,E]),U=(0,_index3.useTheme)(),X=(0,_react.useMemo)(()=>buildStyles(U),[U]),J=(0,_index3.resolveFieldSize)(U,S),K=U.components.input[S]["multiline-min-height"],Q=Math.round(J.text*U.leading.body),Y=I??U.settings.components.input?.defaultVariant??U.settings.components.field?.defaultVariant??"outline",Z=R??U.settings.components.input?.defaultLabelMode??"top",[ee,te]=(0,_react.useState)(!1),[ie,ne]=(0,_react.useState)(!1),ae="password"===d||u||c,le="password"===d||u,re="textarea"===d||p,se=re?Math.round(.1*J.text):0,oe="string"==typeof l&&l.length>0,de=(0,_FieldBase.hasFieldText)(s),ce=!0===s||de,ue=(0,_FieldBase.hasFieldText)(o),xe=de||!ce&&ue,pe=(0,_FieldBase.hasFieldText)(i),fe=(0,_FieldBase.hasFieldText)(v),ge=!x&&!1!==O,me=ee||oe||fe,ve=(0,_react.useRef)(null),he=(0,_react.useMemo)(()=>(0,_index4.mergeRefs)(ve,t),[t]),ye=(0,_react.useCallback)(()=>{ge&&ve.current?.focus()},[ge]),be=pe&&("float"===Z||"above"===Z),je=be&&"above"===Z,Se=(0,_react.useRef)((0,_index3.createAnimatedValue)(0)).current,Ie=(0,_react.useRef)((0,_index3.createAnimatedValue)(xe?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Ie,{toValue:xe?1:0,duration:U.motion.duration.fast,easing:_reactNative.Easing.bezier(...U.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[xe,Ie,U.motion.duration.fast,U.motion.ease["in-out"]]);const Re=(0,_index.useReducedMotion)(),Ve=U.settings.components.input?.shakeOnError??!1,Fe=(0,_react.useRef)(ce);(0,_react.useEffect)(()=>{if(!Ve)return void(Fe.current=ce);let e;return ce&&!Fe.current&&(Re||((0,_index3.setNativeValue)(Se,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(Se,{toValue:1,duration:50,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(Se,{toValue:-1,duration:50,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(Se,{toValue:1,duration:50,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(Se,{toValue:-1,duration:50,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(Se,{toValue:0,duration:100,useNativeDriver:_nativeDriver.nativeDriver})]),e.start()),(0,_index4.triggerHaptic)("notificationError")),Fe.current=ce,()=>e?.stop()},[ce,Se,Ve,Re]);const Te=(0,_react.useCallback)(e=>{te(!0),L?.(e)},[L]),Ne=(0,_react.useCallback)(e=>{te(!1),P?.(e)},[P]),we=(0,_react.useCallback)(()=>{(0,_index4.triggerHaptic)("selection"),ne(e=>!e)},[]),De=U.colors["field-caret"],Ae=U.settings.components.input?.tintLabelOnFocus??!1,Be=ee&&Ae?U.colors["field-border-focus"]:U.colors["field-label"],qe=Se.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),ke=Boolean(f)||Boolean(g)||le,ze="underline"===Y,Ce=_?J.icon+U.space.md+1+U.space.md:0,Le=(0,_useFloatingLabel.useFloatingLabel)({label:i,enabled:be,floated:me,placement:je?"above":"border",required:V,variant:Y,sizeTokens:J,leadingOffset:Ce,trailingOffset:ke?J.icon+U.space.sm:0,textAlign:"center"===N||"right"===N?N:"left",paddingLeft:ze?U.space.none:J["padding-x"],lineHeight:re?Q:void 0,restNudge:se,floatTrim:re?2:0,color:je?ce?U.colors["danger-text"]:ee?U.colors["primary-text"]:me?U.colors["field-label"]:(0,_FieldBase.resolveFieldTextStyle)(U,{disabled:x}).placeholderColor:Be,style:k}),Pe=(0,_FieldBase.resolveFieldTextStyle)(U,{disabled:x}),Me=Pe.color,Ee=Pe.placeholderColor,He=V&&!pe&&!oe&&"string"==typeof a&&a.length>0,Oe=ce?s:o,Ge=T&&"number"==typeof F&&"string"==typeof l?`${l.length} / ${F}`:null,We=ce?U.colors["field-message"]:U.colors["text-muted"],$e=(0,_textInk.useTextInk)(z,J["message-text"],We),Ue=M??(0,_FieldBase.fieldTextAsString)(i)??a,Xe=x?U.colors["field-icon-disabled"]:ee?U.colors["field-icon-focus"]:U.colors["field-icon"],Je={focused:ee,disabled:x,error:ce,color:Xe,size:J.icon},renderSlot=e=>(0,_slotIcon.renderSlotIcon)(e,Je),Ke=(()=>{if(le){const e=(ie?U.settings.icons.eyeOff:U.settings.icons.eye)??(ie?_defaultIcons.defaultIcons.eyeOff:_defaultIcons.defaultIcons.eye);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:we,disabled:!ge,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:ie?$.hidePassword:$.showPassword,children:e({size:J.icon,color:Xe})})}const e=g?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.unit,{fontSize:J.text,color:Ee},m],children:g}):null,t=f?(0,_slotIcon.slotIconView)(f,renderSlot(f)):null;return e&&t?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:X.trailingRow,children:[e,t]}):e??t})(),Qe=_?(0,_slotIcon.slotIconView)(_,renderSlot(_)):null,Ye=_reactNative.StyleSheet.flatten(h),Ze=Ye?.fontSize??J.text,et=Ye?.color??Ee,tt=(0,_react.useMemo)(()=>({fontSize:Ze,color:et}),[Ze,et]),it=fe?"string"==typeof v||"number"==typeof v?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.prefix,{fontSize:J.text,color:Ee,marginRight:U.space.xs,lineHeight:re?Q:void 0,paddingTop:re?se:void 0},h],children:v}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[X.prefixNode,{marginRight:U.space.xs,minHeight:re?Q:void 0,justifyContent:"center",paddingTop:re?se:void 0}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.prefix,{fontSize:J.text,color:Ee,lineHeight:re?Q:void 0},h],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:tt,children:v})})}):null,nt=b?(0,_jsxRuntime.jsx)(_index5.Button,{variant:b.variant??"outline",tone:b.tone??"primary",size:S,label:b.label,leftIcon:b.icon,loading:b.loading,disabled:x||b.disabled,onPress:b.onPress,pressAnimation:!1,testID:b.testID,style:[X.action,{minHeight:J["min-height"],alignSelf:re?"flex-start":"stretch"},j]}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[X.container,{transform:[{translateX:qe}]},A],children:[pe&&!be?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:S,required:V,help:n,color:Be,style:k,children:i}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[X.fieldRow,{columnGap:U.space.sm,alignItems:re?"flex-start":"stretch"},je?{paddingTop:_useFloatingLabel.ABOVE_LABEL_SPACE}:null],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:X.fieldWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{testID:H?`${H}-field`:void 0,size:S,variant:Y,focused:ee,disabled:x,error:ce,filled:oe,minHeight:re?K:void 0,radius:C,leading:Qe,leadingDivider:null!=_,paddingLeft:ze?U.space.none:void 0,trailing:Ke,slotAlign:re?"top":"center",slotLineHeight:re?Q:void 0,topNotch:Le.topNotch,onPress:ye,pressFeedback:!1,style:B,children:[it,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:X.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:he,style:[X.input,{color:Me,fontSize:J.text,...Pe.weightStyle,paddingLeft:ze?U.space.none:void 0,minHeight:re?K-2*J["padding-y"]:void 0,lineHeight:re?Q:void 0,paddingTop:re?se:void 0,textAlignVertical:re?"top":"center"},q],textAlign:N,placeholder:be&&!me||He?void 0:a,placeholderTextColor:Ee,value:w&&null!=l?w(l):l,onChangeText:e=>{(0,_mobileCore.reportIdleActivity)(),r&&r(D?D(e):e)},onFocus:Te,onBlur:Ne,editable:ge,readOnly:y,secureTextEntry:ae&&!ie,multiline:re,autoCapitalize:ae?"none":void 0,autoCorrect:!ae&&void 0,maxLength:F,selectionColor:De,accessibilityLabel:Ue,accessibilityState:{disabled:x},"aria-disabled":x,testID:H,...G}),He&&"string"==typeof a?(0,_jsxRuntime.jsx)(_FieldBase.RequiredPlaceholder,{text:a,color:Ee,fontSize:J.text,weightStyle:Pe.weightStyle,align:re?"top":"center",paddingTop:re?se:void 0,textAlign:N}):null]})]}),Le.node]}),nt]}),xe||Ge?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[X.footerRow,{marginTop:J["message-gap"]}],children:[xe?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[X.messageRow,{columnGap:U.space.xs,opacity:Ie}],accessibilityLiveRegion:ce?"polite":"none",children:[ce?(0,_jsxRuntime.jsx)(_FieldBase.FieldErrorGlyph,{size:J["message-text"],color:We}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.messageText,{color:We,fontSize:J["message-text"],...(0,_index3.fontFor)(U,"normal")},z],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext,{value:$e,children:Oe})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:X.footerSpacer}),Ge?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[X.counterText,{color:U.colors["text-subtle"],fontSize:J["message-text"],...(0,_index3.fontFor)(U,"normal")}],children:Ge}):null]}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},fieldRow:{flexDirection:"row"},fieldWrapper:{position:"relative",overflow:"visible",flex:1},action:{flexShrink:0},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"},unit:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},footerSpacer:{flex:1},messageRow:{flex:1,flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1},counterText:{flexShrink:0,includeFontPadding:!1}});var _default=exports.default=Input;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NumberInput=NumberInput,exports.default=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_numberInputG=require("../../text/phone/numberInput.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,r,a=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(n,r,i):n[r]=e[r]);return n}const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_LONG_PRESS_DELAY=500,DEFAULT_LONG_PRESS_INTERVAL=80,roundToPrecision=(e,t)=>{if(!Number.isFinite(e))return 0;if(t<=0)return Math.round(e);const i=10**t;return Math.round(e*i)/i},clamp=(e,t,i)=>e<t?t:e>i?i:e,formatValue=(e,t,i)=>Number.isFinite(e)?t&&i>0?e.toFixed(i):String(Math.trunc(e)):"",sanitizeTyped=(e,t)=>{if(!e)return"";let i=e.replace(/[^0-9.-]/g,"");if(i=i.replace(/(?!^)-/g,""),t){const e=i.indexOf(".");-1!==e&&(i=i.slice(0,e+1)+i.slice(e+1).replace(/\./g,""))}else i=i.replace(/\./g,"");return i};function NumberInput({ref:e,...t}){const{value:i,defaultValue:r,onChange:a,min:n=Number.NEGATIVE_INFINITY,max:s=Number.POSITIVE_INFINITY,step:l=1,allowDecimal:c=!1,precision:u=0,label:o,help:d,helperText:_,error:b,disabled:m=!1,size:x="md",variant:p="inline",unit:f,haptic:h,labels:N,accessibilityLabel:y,style:I,inputStyle:j,buttonStyle:S,unitStyle:T,labelStyle:g,textInputProps:R,testID:v}=t;(0,_assertValidValue.assertValidValue)("NumberInput","size",t.size,NUMBER_INPUT_SIZES),(0,_assertValidValue.assertValidValue)("NumberInput","variant",t.variant,NUMBER_INPUT_VARIANTS);const F=(0,_index2.useMobileUiText)("numberInput",_numberInputG.NUMBER_INPUT_TEXT),V=(0,_react.useMemo)(()=>({...F,...N}),[F,N]),[E,P]=(0,_index.useControllableState)({value:i,defaultValue:r??t.min??0,onChange:a}),L=(0,_index3.useTheme)(),C=(0,_index3.resolveFieldSize)(L,x),A=(0,_FieldBase.resolveFieldTextStyle)(L,{disabled:m}),w=(0,_react.useMemo)(()=>buildStyles(L),[L]),z=(0,_react.useRef)(null),[B,D]=(0,_react.useState)(formatValue(E,c,u)),[M,k]=(0,_react.useState)(!1),[U,q]=(0,_react.useState)(!1),O=(0,_react.useCallback)(()=>{m||z.current?.focus()},[m]),G=(0,_react.useRef)(null),W=(0,_react.useRef)(null),H=(0,_react.useCallback)(()=>{null!==G.current&&(clearTimeout(G.current),G.current=null),null!==W.current&&(clearInterval(W.current),W.current=null)},[]);(0,_react.useEffect)(()=>H,[H]),(0,_react.useEffect)(()=>{M||D(formatValue(E,c,u))},[E,c,u,M]);const Y=E<=n,$=E>=s,Z=!m,X=(0,_react.useCallback)(e=>{const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==E&&P(i)},[c,s,n,P,u,E]),J=(0,_react.useCallback)(()=>{if(!Z||Y)return;const e=(0,_index4.resolveHaptic)(h,"selection");e&&(0,_index4.triggerHaptic)(e),X(E-l)},[Y,Z,h,X,l,E]),K=(0,_react.useCallback)(()=>{if(!Z||$)return;const e=(0,_index4.resolveHaptic)(h,"selection");e&&(0,_index4.triggerHaptic)(e),X(E+l)},[$,Z,h,X,l,E]);_react.default.useImperativeHandle(e,()=>({focus:()=>z.current?.focus(),blur:()=>z.current?.blur(),clear:()=>{D(""),Number.isFinite(n)&&n>0?P(n):P(0<n?n:Math.min(s,0))}}),[s,n,P]);const Q=(0,_react.useCallback)(e=>{Z&&(H(),G.current=setTimeout(()=>{W.current=setInterval(()=>{"inc"===e?K():J()},DEFAULT_LONG_PRESS_INTERVAL)},DEFAULT_LONG_PRESS_DELAY))},[H,J,K,Z]),ee=(0,_react.useCallback)(e=>{(0,_mobileCore.reportIdleActivity)();const t=sanitizeTyped(e,c);D(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=n&&i<=s&&i!==E&&P(roundToPrecision(i,c?u:0))},[c,s,n,P,u,E]),te=(0,_react.useCallback)(()=>{k(!1),q(!1);const e=Number(B);if(""===B||!Number.isFinite(e))return void D(formatValue(E,c,u));const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==E&&P(i),D(formatValue(i,c,u))},[c,B,s,n,P,u,E]),ie=(0,_react.useCallback)(()=>{k(!0),q(!0)},[]),re=Y||m?L.colors["text-disabled"]:L.colors["text-body"],ae=$||m?L.colors["text-disabled"]:L.colors["text-body"],ne=C.icon+8,renderStepper=(e,t,i,r,a,n)=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:t,onLongPress:()=>Q(e),onPressOut:H,delayLongPress:DEFAULT_LONG_PRESS_DELAY,disabled:i,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:ne,height:ne,alignItems:"center",justifyContent:"center",borderRadius:L.radius.pill,..._corners.smoothCorners},e&&!i?{backgroundColor:L.colors["surface-pressed"]}:null,S],testID:`${v??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",weight:"semibold",style:{fontSize:C.icon,color:a,fontWeight:L.weight.semibold,lineHeight:C.icon+2},children:n})}),se=y??(0,_FieldBase.fieldTextAsString)(o)??V.input,le=!0===b||(0,_FieldBase.hasFieldText)(b),ce=(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{testID:v?`${v}-field`:void 0,size:x,disabled:m,error:le,filled:!0,focused:U,onPress:O,pressFeedback:!1,leading:renderStepper("dec",J,Y||m,V.decrease,re,"−"),trailing:renderStepper("inc",K,$||m,V.increase,ae,"+"),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:z,value:B,onChangeText:ee,onFocus:ie,onBlur:te,editable:!m,keyboardType:c?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:se,accessibilityValue:{now:Number.isFinite(E)?E:0},accessibilityState:{disabled:m},"aria-disabled":m,accessibilityActions:[{name:"increment",label:V.increase},{name:"decrement",label:V.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&K(),"decrement"===e.nativeEvent.actionName&&J()},style:[w.input,{fontSize:C.text,color:A.color,...A.weightStyle},j],...R}),f?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",style:[w.unit,{fontSize:C.text,color:A.placeholderColor},T],children:f}):null]})}),ue=(0,_FieldBase.hasFieldText)(o)?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:x,help:d,style:g,children:o}):null,oe=(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:x,error:le,text:le?b:_});return"horizontal"===p?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.horizontalContainer,I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:w.horizontalLabelWrap,children:ue}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[ce,oe]})]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[ue,ce,oe]})}const buildStyles=e=>_reactNative.StyleSheet.create({inputRow:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},input:{flex:1,textAlign:"center",padding:e.space.none,margin:e.space.none,includeFontPadding:!1},unit:{marginLeft:e.space.xs},label:{marginBottom:e.space.xs},helper:{marginTop:e.space.xs},horizontalContainer:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},horizontalLabelWrap:{flexShrink:1,paddingRight:e.space.md}});var _default=exports.default=NumberInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NumberInput=NumberInput,exports.default=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_numberInputG=require("../../text/phone/numberInput.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,r,a=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(n,r,i):n[r]=e[r]);return n}const NUMBER_INPUT_SIZES=["sm","md","lg","xl"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_LONG_PRESS_DELAY=500,DEFAULT_LONG_PRESS_INTERVAL=80,roundToPrecision=(e,t)=>{if(!Number.isFinite(e))return 0;if(t<=0)return Math.round(e);const i=10**t;return Math.round(e*i)/i},clamp=(e,t,i)=>e<t?t:e>i?i:e,formatValue=(e,t,i)=>Number.isFinite(e)?t&&i>0?e.toFixed(i):String(Math.trunc(e)):"",sanitizeTyped=(e,t)=>{if(!e)return"";let i=e.replace(/[^0-9.-]/g,"");if(i=i.replace(/(?!^)-/g,""),t){const e=i.indexOf(".");-1!==e&&(i=i.slice(0,e+1)+i.slice(e+1).replace(/\./g,""))}else i=i.replace(/\./g,"");return i};function NumberInput({ref:e,...t}){const{value:i,defaultValue:r,onChange:a,min:n=Number.NEGATIVE_INFINITY,max:s=Number.POSITIVE_INFINITY,step:l=1,allowDecimal:c=!1,precision:u=0,label:o,help:d,helperText:_,error:b,disabled:m=!1,size:x="md",variant:p="inline",unit:f,haptic:h,labels:N,accessibilityLabel:y,style:I,inputStyle:j,buttonStyle:S,unitStyle:T,labelStyle:g,textInputProps:R,testID:v}=t;(0,_assertValidValue.assertValidValue)("NumberInput","size",t.size,NUMBER_INPUT_SIZES),(0,_assertValidValue.assertValidValue)("NumberInput","variant",t.variant,NUMBER_INPUT_VARIANTS);const F=(0,_index2.useMobileUiText)("numberInput",_numberInputG.NUMBER_INPUT_TEXT),V=(0,_react.useMemo)(()=>({...F,...N}),[F,N]),[E,P]=(0,_index.useControllableState)({value:i,defaultValue:r??t.min??0,onChange:a}),L=(0,_index3.useTheme)(),C=(0,_index3.resolveFieldSize)(L,x),A=(0,_FieldBase.resolveFieldTextStyle)(L,{disabled:m}),w=(0,_react.useMemo)(()=>buildStyles(L),[L]),z=(0,_react.useRef)(null),[B,D]=(0,_react.useState)(formatValue(E,c,u)),[M,k]=(0,_react.useState)(!1),[U,q]=(0,_react.useState)(!1),O=(0,_react.useCallback)(()=>{m||z.current?.focus()},[m]),G=(0,_react.useRef)(null),W=(0,_react.useRef)(null),H=(0,_react.useCallback)(()=>{null!==G.current&&(clearTimeout(G.current),G.current=null),null!==W.current&&(clearInterval(W.current),W.current=null)},[]);(0,_react.useEffect)(()=>H,[H]),(0,_react.useEffect)(()=>{M||D(formatValue(E,c,u))},[E,c,u,M]);const Y=E<=n,$=E>=s,Z=!m,X=(0,_react.useCallback)(e=>{const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==E&&P(i)},[c,s,n,P,u,E]),J=(0,_react.useCallback)(()=>{if(!Z||Y)return;const e=(0,_index4.resolveHaptic)(h,"selection");e&&(0,_index4.triggerHaptic)(e),X(E-l)},[Y,Z,h,X,l,E]),K=(0,_react.useCallback)(()=>{if(!Z||$)return;const e=(0,_index4.resolveHaptic)(h,"selection");e&&(0,_index4.triggerHaptic)(e),X(E+l)},[$,Z,h,X,l,E]);_react.default.useImperativeHandle(e,()=>({focus:()=>z.current?.focus(),blur:()=>z.current?.blur(),clear:()=>{D(""),Number.isFinite(n)&&n>0?P(n):P(0<n?n:Math.min(s,0))}}),[s,n,P]);const Q=(0,_react.useCallback)(e=>{Z&&(H(),G.current=setTimeout(()=>{W.current=setInterval(()=>{"inc"===e?K():J()},DEFAULT_LONG_PRESS_INTERVAL)},DEFAULT_LONG_PRESS_DELAY))},[H,J,K,Z]),ee=(0,_react.useCallback)(e=>{(0,_mobileCore.reportIdleActivity)();const t=sanitizeTyped(e,c);D(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=n&&i<=s&&i!==E&&P(roundToPrecision(i,c?u:0))},[c,s,n,P,u,E]),te=(0,_react.useCallback)(()=>{k(!1),q(!1);const e=Number(B);if(""===B||!Number.isFinite(e))return void D(formatValue(E,c,u));const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==E&&P(i),D(formatValue(i,c,u))},[c,B,s,n,P,u,E]),ie=(0,_react.useCallback)(()=>{k(!0),q(!0)},[]),re=Y||m?L.colors["text-disabled"]:L.colors["text-body"],ae=$||m?L.colors["text-disabled"]:L.colors["text-body"],ne=C.icon+8,renderStepper=(e,t,i,r,a,n)=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:t,onLongPress:()=>Q(e),onPressOut:H,delayLongPress:DEFAULT_LONG_PRESS_DELAY,disabled:i,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:ne,height:ne,alignItems:"center",justifyContent:"center",borderRadius:L.radius.pill,..._corners.smoothCorners},e&&!i?{backgroundColor:L.colors["surface-pressed"]}:null,S],testID:`${v??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",weight:"semibold",style:{fontSize:C.icon,color:a,fontWeight:L.weight.semibold,lineHeight:C.icon+2},children:n})}),se=y??(0,_FieldBase.fieldTextAsString)(o)??V.input,le=!0===b||(0,_FieldBase.hasFieldText)(b),ce=(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{testID:v?`${v}-field`:void 0,size:x,disabled:m,error:le,filled:!0,focused:U,onPress:O,pressFeedback:!1,leading:renderStepper("dec",J,Y||m,V.decrease,re,"−"),trailing:renderStepper("inc",K,$||m,V.increase,ae,"+"),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:z,value:B,onChangeText:ee,onFocus:ie,onBlur:te,editable:!m,keyboardType:c?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:se,accessibilityValue:{now:Number.isFinite(E)?E:0},accessibilityState:{disabled:m},"aria-disabled":m,accessibilityActions:[{name:"increment",label:V.increase},{name:"decrement",label:V.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&K(),"decrement"===e.nativeEvent.actionName&&J()},style:[w.input,{fontSize:C.text,color:A.color,...A.weightStyle},j],...R}),f?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",style:[w.unit,{fontSize:C.text,color:A.placeholderColor},T],children:f}):null]})}),ue=(0,_FieldBase.hasFieldText)(o)?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:x,help:d,style:g,children:o}):null,oe=(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:x,error:le,text:le?b:_});return"horizontal"===p?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.horizontalContainer,I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:w.horizontalLabelWrap,children:ue}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[ce,oe]})]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[ue,ce,oe]})}const buildStyles=e=>_reactNative.StyleSheet.create({inputRow:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},input:{flex:1,textAlign:"center",padding:e.space.none,margin:e.space.none,includeFontPadding:!1},unit:{marginLeft:e.space.xs},label:{marginBottom:e.space.xs},helper:{marginTop:e.space.xs},horizontalContainer:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},horizontalLabelWrap:{flexShrink:1,paddingRight:e.space.md}});var _default=exports.default=NumberInput;