@webority/mobile-ui 0.128.0 → 0.129.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas-kit/kit.js +8170 -7898
- package/dist/canvas-kit/manifest.json +218 -6
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/Accordion/Accordion.js +1 -1
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
- package/lib/commonjs/components/AppIcon/catalog.g.js +1 -1
- package/lib/commonjs/components/AppIcon/glyphs.g.js +1 -1
- package/lib/commonjs/components/AppIcon/variants.g.js +1 -1
- package/lib/commonjs/components/Banner/Banner.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Box/Box.js +1 -1
- package/lib/commonjs/components/Button/Button.js +1 -1
- package/lib/commonjs/components/Card/Card.js +1 -1
- package/lib/commonjs/components/Composer/Composer.js +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
- package/lib/commonjs/components/FieldBase/ChoiceText.js +1 -1
- package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
- package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
- package/lib/commonjs/components/FileViewer/FileViewerImage.js +1 -0
- package/lib/commonjs/components/FileViewer/fileSource.js +1 -0
- package/lib/commonjs/components/FormField/FormField.js +1 -1
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/Markdown/Markdown.js +1 -1
- package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
- package/lib/commonjs/components/Modal/Modal.js +1 -1
- package/lib/commonjs/components/Notation/Notation.js +1 -1
- package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPResendRow.js +1 -0
- package/lib/commonjs/components/OTPInput/index.js +1 -1
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/commonjs/components/Radio/Radio.js +1 -1
- package/lib/commonjs/components/Rating/Rating.js +1 -1
- package/lib/commonjs/components/SectionHeader/SectionHeader.js +1 -1
- package/lib/commonjs/components/Select/Select.js +1 -1
- package/lib/commonjs/components/Text/Text.js +1 -1
- package/lib/commonjs/components/Text/textInk.js +1 -0
- package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
- package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
- package/lib/commonjs/components/index.js +1 -1
- package/lib/commonjs/components/not-drawn.json +2 -0
- package/lib/commonjs/form/HookFormField.js +1 -1
- package/lib/commonjs/hooks/index.js +1 -1
- package/lib/commonjs/hooks/useFieldErrorScroll.js +1 -0
- package/lib/commonjs/hooks/useResendCountdown.js +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/navigation/index.js +1 -1
- package/lib/commonjs/navigation/useNavigationTheme.js +1 -0
- package/lib/commonjs/utils/feedback.js +1 -1
- package/lib/commonjs/utils/hapticUtils.js +1 -1
- package/lib/module/components/Accordion/Accordion.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/AppIcon/AppIcon.js +1 -1
- package/lib/module/components/AppIcon/catalog.g.js +1 -1
- package/lib/module/components/AppIcon/glyphs.g.js +1 -1
- package/lib/module/components/AppIcon/variants.g.js +1 -1
- package/lib/module/components/Banner/Banner.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/Box/Box.js +1 -1
- package/lib/module/components/Button/Button.js +1 -1
- package/lib/module/components/Card/Card.js +1 -1
- package/lib/module/components/Composer/Composer.js +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +1 -1
- package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/module/components/Descriptions/Descriptions.js +1 -1
- package/lib/module/components/FieldBase/ChoiceText.js +1 -1
- package/lib/module/components/FieldBase/FieldBase.js +1 -1
- package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/module/components/FileViewer/FileViewer.js +1 -1
- package/lib/module/components/FileViewer/FileViewerImage.js +1 -0
- package/lib/module/components/FileViewer/fileSource.js +1 -0
- package/lib/module/components/FormField/FormField.js +1 -1
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/Markdown/Markdown.js +1 -1
- package/lib/module/components/Menu/MenuSurface.js +1 -1
- package/lib/module/components/Modal/Modal.js +1 -1
- package/lib/module/components/Notation/Notation.js +1 -1
- package/lib/module/components/NumberInput/NumberInput.js +1 -1
- package/lib/module/components/OTPInput/OTPResendRow.js +1 -0
- package/lib/module/components/OTPInput/index.js +1 -1
- package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/module/components/Radio/Radio.js +1 -1
- package/lib/module/components/Rating/Rating.js +1 -1
- package/lib/module/components/SectionHeader/SectionHeader.js +1 -1
- package/lib/module/components/Select/Select.js +1 -1
- package/lib/module/components/Text/Text.js +1 -1
- package/lib/module/components/Text/textInk.js +1 -0
- package/lib/module/components/TimePicker/TimePicker.js +1 -1
- package/lib/module/components/Tooltip/Tooltip.js +1 -1
- package/lib/module/components/index.js +1 -1
- package/lib/module/components/not-drawn.json +2 -0
- package/lib/module/form/HookFormField.js +1 -1
- package/lib/module/hooks/index.js +1 -1
- package/lib/module/hooks/useFieldErrorScroll.js +1 -0
- package/lib/module/hooks/useResendCountdown.js +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/navigation/index.js +1 -1
- package/lib/module/navigation/useNavigationTheme.js +1 -0
- package/lib/module/utils/feedback.js +1 -1
- package/lib/module/utils/hapticUtils.js +1 -1
- package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +2 -1
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +2 -1
- package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +6 -3
- package/lib/typescript/commonjs/components/AppIcon/catalog.g.d.ts +1 -1
- package/lib/typescript/commonjs/components/AppIcon/glyphs.g.d.ts +1 -0
- package/lib/typescript/commonjs/components/AppIcon/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +2 -1
- package/lib/typescript/commonjs/components/Box/Box.d.ts +2 -2
- package/lib/typescript/commonjs/components/Button/Button.d.ts +3 -0
- package/lib/typescript/commonjs/components/Calendar/calendarStyles.d.ts +4 -4
- package/lib/typescript/commonjs/components/Card/Card.d.ts +5 -4
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +2 -1
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +2 -1
- package/lib/typescript/commonjs/components/Composer/Composer.d.ts +4 -0
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +4 -14
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +4 -14
- package/lib/typescript/commonjs/components/FileViewer/FileViewer.d.ts +5 -33
- package/lib/typescript/commonjs/components/FileViewer/FileViewerImage.d.ts +5 -0
- package/lib/typescript/commonjs/components/FileViewer/fileSource.d.ts +24 -0
- package/lib/typescript/commonjs/components/FileViewer/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +3 -0
- package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +3 -1
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +10 -0
- package/lib/typescript/commonjs/components/Notation/Notation.d.ts +5 -15
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +2 -0
- package/lib/typescript/commonjs/components/OTPInput/OTPResendRow.d.ts +25 -0
- package/lib/typescript/commonjs/components/OTPInput/index.d.ts +2 -0
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +5 -0
- package/lib/typescript/commonjs/components/PickerTrigger/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +2 -0
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +2 -0
- package/lib/typescript/commonjs/components/SectionHeader/SectionHeader.d.ts +2 -0
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +2 -0
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +2 -0
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +2 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +2 -0
- package/lib/typescript/commonjs/components/Text/Text.d.ts +2 -0
- package/lib/typescript/commonjs/components/Text/textInk.d.ts +14 -0
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +4 -15
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +2 -1
- package/lib/typescript/commonjs/components/index.d.ts +5 -4
- package/lib/typescript/commonjs/form/HookFormField.d.ts +4 -4
- package/lib/typescript/commonjs/hooks/index.d.ts +4 -0
- package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +28 -0
- package/lib/typescript/commonjs/hooks/useResendCountdown.d.ts +16 -0
- package/lib/typescript/commonjs/index.d.ts +3 -3
- package/lib/typescript/commonjs/navigation/index.d.ts +1 -0
- package/lib/typescript/commonjs/navigation/useNavigationTheme.d.ts +7 -0
- package/lib/typescript/commonjs/utils/feedback.d.ts +2 -2
- package/lib/typescript/commonjs/utils/hapticUtils.d.ts +2 -0
- package/lib/typescript/module/components/Accordion/Accordion.d.ts +2 -1
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +2 -1
- package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +6 -3
- package/lib/typescript/module/components/AppIcon/catalog.g.d.ts +1 -1
- package/lib/typescript/module/components/AppIcon/glyphs.g.d.ts +1 -0
- package/lib/typescript/module/components/AppIcon/index.d.ts +1 -1
- package/lib/typescript/module/components/Banner/Banner.d.ts +2 -1
- package/lib/typescript/module/components/Box/Box.d.ts +2 -2
- package/lib/typescript/module/components/Button/Button.d.ts +3 -0
- package/lib/typescript/module/components/Calendar/calendarStyles.d.ts +4 -4
- package/lib/typescript/module/components/Card/Card.d.ts +5 -4
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +2 -1
- package/lib/typescript/module/components/Chip/Chip.d.ts +2 -1
- package/lib/typescript/module/components/Composer/Composer.d.ts +4 -0
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +4 -14
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +4 -14
- package/lib/typescript/module/components/FileViewer/FileViewer.d.ts +5 -33
- package/lib/typescript/module/components/FileViewer/FileViewerImage.d.ts +5 -0
- package/lib/typescript/module/components/FileViewer/fileSource.d.ts +24 -0
- package/lib/typescript/module/components/FileViewer/index.d.ts +1 -1
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +3 -0
- package/lib/typescript/module/components/Markdown/Markdown.d.ts +3 -1
- package/lib/typescript/module/components/Modal/Modal.d.ts +10 -0
- package/lib/typescript/module/components/Notation/Notation.d.ts +5 -15
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +2 -0
- package/lib/typescript/module/components/OTPInput/OTPResendRow.d.ts +25 -0
- package/lib/typescript/module/components/OTPInput/index.d.ts +2 -0
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +5 -0
- package/lib/typescript/module/components/PickerTrigger/index.d.ts +1 -1
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/module/components/Radio/Radio.d.ts +2 -0
- package/lib/typescript/module/components/Rating/Rating.d.ts +2 -0
- package/lib/typescript/module/components/SectionHeader/SectionHeader.d.ts +2 -0
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +2 -0
- package/lib/typescript/module/components/Slider/Slider.d.ts +2 -0
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +2 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +2 -0
- package/lib/typescript/module/components/Text/Text.d.ts +2 -0
- package/lib/typescript/module/components/Text/textInk.d.ts +14 -0
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +4 -15
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +2 -1
- package/lib/typescript/module/components/index.d.ts +5 -4
- package/lib/typescript/module/form/HookFormField.d.ts +4 -4
- package/lib/typescript/module/hooks/index.d.ts +4 -0
- package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +28 -0
- package/lib/typescript/module/hooks/useResendCountdown.d.ts +16 -0
- package/lib/typescript/module/index.d.ts +3 -3
- package/lib/typescript/module/navigation/index.d.ts +1 -0
- package/lib/typescript/module/navigation/useNavigationTheme.d.ts +7 -0
- package/lib/typescript/module/utils/feedback.d.ts +2 -2
- package/lib/typescript/module/utils/hapticUtils.d.ts +2 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,fontFor,useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{fieldTextAsString,hasFieldText,RequiredMark}from"../FieldBase/index.js";import{
|
|
1
|
+
"use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,Text,View}from"react-native";import{useFieldErrorAnchor}from"../../hooks/useFieldErrorScroll.js";import{createAnimatedValue,fontFor,useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{fieldTextAsString,hasFieldText,RequiredMark}from"../FieldBase/index.js";import{TextInkContext,useTextInk}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_FORM_FIELD_LABELS={labelWithError:(e,t)=>`${e}, error: ${t}`};const FormField=forwardRef((e,t)=>{warnInvalidValue("FormField","layout",e.layout,["stacked","inline"]);const{label:l,help:i,helperText:r,error:n,required:s=!1,children:o,layout:a="stacked",helperLines:d,labelStyle:x,helperStyle:c,errorStyle:u,containerStyle:m,inputContainerStyle:h,accessibilityLabel:f,labels:p,testID:F}=e,T=useFieldErrorAnchor(hasFieldText(n),t),S=useTheme(),b=useMemo(()=>buildStyles(S),[S]),y=useMemo(()=>({...DEFAULT_FORM_FIELD_LABELS,...p}),[p]),I=fieldTextAsString(n),k=useRef(createAnimatedValue(n?1:0)).current;useEffect(()=>{const e=Animated.timing(k,{toValue:n?1:0,duration:S.motion.duration.fast,useNativeDriver:!0});return e.start(),()=>e.stop()},[n,k,S.motion.duration.fast]);const j=useMemo(()=>{if(f)return f;const e=fieldTextAsString(l);return e?I?y.labelWithError(e,I):e:void 0},[f,l,I,y]),_=useTextInk(x,S.text.sm.size,S.colors["text-muted"]),v=useTextInk(c,S.text.sm.size,S.colors["text-subtle"]),w=useTextInk(u,S.text.sm.size,S.colors["danger-text"]),E=hasFieldText(l),L=_jsxs(Text,{style:[b.label,"inline"!==a||hasFieldText(i)?null:b.labelInline,hasFieldText(i)?b.labelShrink:null,x],children:[_jsx(TextInkContext.Provider,{value:_,children:l}),s?_jsx(RequiredMark,{}):null]}),A=E?hasFieldText(i)?_jsxs(View,{style:[b.labelRow,"inline"===a?b.labelInline:null],children:[L,_jsx(View,{style:[b.help,{marginLeft:S.space.xs}],children:i})]}):L:null,R="inline"===a?b.inputInline:b.inputStacked,g=hasFieldText(n),V=!g&&hasFieldText(r),D=s&&!E&&React.isValidElement(o)?React.cloneElement(o,{required:!0}):o;return _jsxs(View,{ref:T,style:["inline"===a?b.rootInline:b.rootStacked,m],accessibilityLabel:j,accessibilityHint:I||void 0,testID:F,children:[A,_jsx(View,{style:[R,h],children:D}),V?_jsx(Text,{style:[b.helper,c],numberOfLines:d||void 0,children:_jsx(TextInkContext.Provider,{value:v,children:r})}):null,g?_jsx(Animated.Text,{style:[b.error,{opacity:k},u],numberOfLines:d||void 0,accessibilityLiveRegion:"polite",children:_jsx(TextInkContext.Provider,{value:w,children:n})}):null]})});FormField.displayName="FormField";const buildStyles=e=>StyleSheet.create({rootStacked:{flexDirection:"column",gap:e.space.xs},rootInline:{flexDirection:"row",alignItems:"center",flexWrap:"wrap",gap:e.space.xs},label:{fontSize:e.text.sm.size,...fontFor(e,"medium"),color:e.colors["text-muted"]},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},labelInline:{width:"35%"},inputStacked:{width:"100%"},inputInline:{flex:1,minWidth:0},helper:{fontSize:e.text.sm.size,color:e.colors["text-subtle"]},error:{fontSize:e.text.sm.size,color:e.colors["danger-text"]}});export{FormField};export default FormField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{useReducedMotion}from"../../hooks/index.js";import{createAnimatedValue,fontFor,resolveFieldSize,setNativeValue,useTheme}from"../../theme/index.js";import{mergeRefs,triggerHaptic}from"../../utils/index.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Button}from"../Button/index.js";import{FieldBase,FieldErrorGlyph,FieldLabel,fieldTextAsString,hasFieldText,RequiredPlaceholder,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{useReducedMotion}from"../../hooks/index.js";import{createAnimatedValue,fontFor,resolveFieldSize,setNativeValue,useTheme}from"../../theme/index.js";import{mergeRefs,triggerHaptic}from"../../utils/index.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Button}from"../Button/index.js";import{FieldBase,FieldErrorGlyph,FieldLabel,fieldTextAsString,hasFieldText,RequiredPlaceholder,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{TextInkContext,useTextInk}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_INPUT_LABELS={showPassword:"Show password",hidePassword:"Hide password"};const Input=forwardRef((e,t)=>{const{label:i,help:n,placeholder:o,value:l,onChangeText:s,error:r,helperText:a,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:p=!1,multiline:f=!1,leftIcon:x,rightIcon:m,unit:g,unitStyle:h,prefix:y,prefixStyle:v,readOnly:b=!1,action:S,actionStyle:w,size:T="md",variant:I,labelMode:j,required:F=!1,maxLength:V,showCounter:_=!0,textAlign:R,format:A,parse:z,style:L,containerStyle:k,inputStyle:P,labelStyle:C,messageStyle:D,borderRadius:N,onFocus:E,onBlur:B,accessibilityLabel:M,labels:H,testID:O,editable:q,...G}=e;warnInvalidValue("Input","variant",I,["outline","filled","underline"]),warnInvalidValue("Input","size",e.size,["sm","md","lg"]),warnInvalidValue("Input","labelMode",j,["float","top"]),warnInvalidValue("Input","type",e.type,["input","password","textarea"]);const U=useMemo(()=>({...DEFAULT_INPUT_LABELS,...H}),[H]),W=useTheme(),$=useMemo(()=>buildStyles(W),[W]),X=resolveFieldSize(W,T),J=W.components.input[T]["multiline-min-height"],K=Math.round(X.text*W.leading.body),Q=I??W.settings.components.input?.defaultVariant??W.settings.components.field?.defaultVariant??"outline",Y=j??W.settings.components.input?.defaultLabelMode??"top",[Z,ee]=useState(!1),[te,ie]=useState(!1),ne="password"===d||u||c,oe="password"===d||u,le="textarea"===d||f,se=le?Math.round(.1*X.text):0,re="string"==typeof l&&l.length>0,ae=hasFieldText(r),de=!0===r||ae,ce=hasFieldText(a),ue=ae||!de&&ce,pe=hasFieldText(i),fe=hasFieldText(y),xe=!p&&!1!==q,me=Z||re||fe,ge=useRef(null),he=useMemo(()=>mergeRefs(ge,t),[t]),ye=useCallback(()=>{xe&&ge.current?.focus()},[xe]),ve=pe&&"float"===Y,be=useRef(createAnimatedValue(0)).current,Se=useRef(createAnimatedValue(ue?1:0)).current;useEffect(()=>{const e=Animated.timing(Se,{toValue:ue?1:0,duration:W.motion.duration.fast,easing:Easing.bezier(...W.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[ue,Se,W.motion.duration.fast,W.motion.ease["in-out"]]);const we=useReducedMotion(),Te=W.settings.components.input?.shakeOnError??!1,Ie=useRef(de);useEffect(()=>{if(!Te)return void(Ie.current=de);let e;return de&&!Ie.current&&(we||(setNativeValue(be,0),e=Animated.sequence([Animated.timing(be,{toValue:1,duration:50,useNativeDriver:!0}),Animated.timing(be,{toValue:-1,duration:50,useNativeDriver:!0}),Animated.timing(be,{toValue:1,duration:50,useNativeDriver:!0}),Animated.timing(be,{toValue:-1,duration:50,useNativeDriver:!0}),Animated.timing(be,{toValue:0,duration:100,useNativeDriver:!0})]),e.start()),triggerHaptic("notificationError")),Ie.current=de,()=>e?.stop()},[de,be,Te,we]);const je=useCallback(e=>{ee(!0),E?.(e)},[E]),Fe=useCallback(e=>{ee(!1),B?.(e)},[B]),Ve=useCallback(()=>{triggerHaptic("selection"),ie(e=>!e)},[]),Re=W.colors["field-caret"],Ae=N??X.radius,ze=W.settings.components.input?.tintLabelOnFocus??!1,Le=Z&&ze?W.colors["field-border-focus"]:W.colors["field-label"],ke=be.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),Pe=Boolean(m)||Boolean(g)||oe,Ce="underline"===Q,De=x?X.icon+W.space.md+1+W.space.md:0,Ne=useFloatingLabel({label:i,enabled:ve,floated:me,required:F,variant:Q,sizeTokens:X,leadingOffset:De,trailingOffset:Pe?X.icon+W.space.sm:0,textAlign:R,paddingLeft:Ce?W.space.none:X["padding-x"],lineHeight:le?K:void 0,restNudge:se,floatTrim:le?2:0,color:Le,style:C}),Ee=resolveFieldTextStyle(W,{disabled:p}),Be=Ee.color,Me=Ee.placeholderColor,He=F&&!pe&&!re&&"string"==typeof o&&o.length>0,Oe=de?r:a,qe=_&&"number"==typeof V&&"string"==typeof l?`${l.length} / ${V}`:null,Ge=de?W.colors["field-message"]:W.colors["text-muted"],Ue=useTextInk(D,X["message-text"],Ge),We=M??fieldTextAsString(i)??o,$e=p?W.colors["field-icon-disabled"]:Z?W.colors["field-icon-focus"]:W.colors["field-icon"],Xe={focused:Z,disabled:p,error:de,color:$e,size:X.icon},renderSlot=e=>renderSlotIcon(e,Xe),Je=(()=>{if(oe){const e=(te?W.settings.icons.eyeOff:W.settings.icons.eye)??(te?defaultIcons.eyeOff:defaultIcons.eye);return _jsx(Pressable,{onPress:Ve,disabled:!xe,hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:te?U.hidePassword:U.showPassword,children:e({size:X.icon,color:$e})})}const e=g?_jsx(Text,{style:[$.unit,{fontSize:X.text,color:Me},h],children:g}):null,t=m?_jsx(View,{children:renderSlot(m)}):null;return e&&t?_jsxs(View,{style:$.trailingRow,children:[e,t]}):e??t})(),Ke=x?_jsx(View,{children:renderSlot(x)}):null,Qe=StyleSheet.flatten(v),Ye=Qe?.fontSize??X.text,Ze=Qe?.color??Me,et=useMemo(()=>({fontSize:Ye,color:Ze}),[Ye,Ze]),tt=fe?"string"==typeof y||"number"==typeof y?_jsx(Text,{style:[$.prefix,{fontSize:X.text,color:Me,marginRight:W.space.xs,lineHeight:le?K:void 0,paddingTop:le?se:void 0},v],children:y}):_jsx(View,{style:[$.prefixNode,{marginRight:W.space.xs,minHeight:le?K:void 0,justifyContent:"center",paddingTop:le?se:void 0}],children:_jsx(Text,{style:[$.prefix,{fontSize:X.text,color:Me,lineHeight:le?K:void 0},v],children:_jsx(TextInkContext.Provider,{value:et,children:y})})}):null,it=S?_jsx(Button,{variant:S.variant??"outline",tone:S.tone??"primary",size:T,label:S.label,leftIcon:S.icon,loading:S.loading,disabled:p||S.disabled,onPress:S.onPress,pressAnimation:!1,testID:S.testID,style:[$.action,{minHeight:X["min-height"],alignSelf:le?"flex-start":"stretch"},w]}):null;return _jsxs(Animated.View,{style:[$.container,{transform:[{translateX:ke}]},L],children:[pe&&!ve?_jsx(FieldLabel,{size:T,required:F,help:n,color:Le,style:C,children:i}):null,_jsxs(View,{style:[$.fieldRow,{columnGap:W.space.sm,alignItems:le?"flex-start":"stretch"}],children:[_jsxs(View,{style:$.fieldWrapper,children:[_jsxs(FieldBase,{size:T,variant:Q,focused:Z,disabled:p,error:de,filled:re,minHeight:le?J:void 0,borderRadius:Ae,leading:Ke,leadingDivider:null!=x,paddingLeft:Ce?W.space.none:void 0,trailing:Je,slotAlign:le?"top":"center",slotLineHeight:le?K:void 0,topNotch:Ne.topNotch,onPress:ye,pressFeedback:!1,style:k,children:[tt,_jsxs(View,{style:$.inputWrap,children:[_jsx(TextInput,{ref:he,style:[$.input,{color:Be,fontSize:X.text,...Ee.weightStyle,paddingLeft:Ce?W.space.none:void 0,minHeight:le?J-2*X["padding-y"]:void 0,lineHeight:le?K:void 0,paddingTop:le?se:void 0,textAlignVertical:le?"top":"center"},P],textAlign:R,placeholder:ve&&!me||He?void 0:o,placeholderTextColor:Me,value:A&&null!=l?A(l):l,onChangeText:e=>{s&&s(z?z(e):e)},onFocus:je,onBlur:Fe,editable:xe,readOnly:b,secureTextEntry:ne&&!te,multiline:le,autoCapitalize:ne?"none":void 0,autoCorrect:!ne&&void 0,maxLength:V,selectionColor:Re,accessibilityLabel:We,accessibilityState:{disabled:p},"aria-disabled":p,testID:O,...G}),He?_jsx(RequiredPlaceholder,{text:o,color:Me,fontSize:X.text,weightStyle:Ee.weightStyle,align:le?"top":"center",paddingTop:le?se:void 0,textAlign:R}):null]})]}),Ne.node]}),it]}),ue||qe?_jsxs(View,{style:[$.footerRow,{marginTop:X["message-gap"]}],children:[ue?_jsxs(Animated.View,{style:[$.messageRow,{columnGap:W.space.xs,opacity:Se}],accessibilityLiveRegion:de?"polite":"none",children:[de?_jsx(FieldErrorGlyph,{size:X["message-text"],color:Ge}):null,_jsx(Text,{style:[$.messageText,{color:Ge,fontSize:X["message-text"],...fontFor(W,"normal")},D],children:_jsx(TextInkContext.Provider,{value:Ue,children:Oe})})]}):_jsx(View,{style:$.footerSpacer}),qe?_jsx(Text,{style:[$.counterText,{color:W.colors["text-subtle"],fontSize:X["message-text"],...fontFor(W,"normal")}],children:qe}):null]}):null]})});Input.displayName="Input";const buildStyles=e=>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}});export{Input};export default Input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{linkTarget,parseInline,parseMarkdown}from"@webority/markdown-core";import{useMemo}from"react";import{Linking,Platform,Text as RNText,ScrollView,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MONO=Platform.select({ios:"Menlo",android:"monospace",default:"monospace"}),HEADING_SCALE={1:"3xl",2:"2xl",3:"xl",4:"lg",5:"base",6:"sm"},createStyles=e=>StyleSheet.create({block:{marginBottom:e.space.sm},listRow:{flexDirection:"row",marginBottom:e.space.xs},marker:{width:e.space.lg},listText:{flex:1},quote:{borderLeftWidth:3,borderLeftColor:e.colors["border-subtle"],paddingLeft:e.space.sm,marginBottom:e.space.sm},quoteText:{color:e.colors["text-muted"],fontStyle:"italic"},code:{backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.sm,...smoothCorners,padding:e.space.sm,marginBottom:e.space.sm},codeText:{fontFamily:MONO},inlineCode:{fontFamily:MONO,backgroundColor:e.colors["bg-subtle"],color:e.colors["text-body"]},link:{color:e.colors.link,textDecorationLine:"underline"},citation:{color:e.colors.primary,fontWeight:e.weight.semibold},strong:{fontWeight:e.weight.bold},em:{fontStyle:"italic"},strike:{textDecorationLine:"line-through"},table:{borderWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border},row:{flexDirection:"row"},headerRow:{backgroundColor:e.colors["bg-subtle"]},cell:{minWidth:96,maxWidth:220,padding:e.space.xs,borderRightWidth:StyleSheet.hairlineWidth,borderBottomWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border},rule:{height:StyleSheet.hairlineWidth,backgroundColor:e.colors.border,marginVertical:e.space.md}}),withPositionKeys=e=>e.map((e,t)=>({key:t,value:e})),openHref=(e,t)=>{t?t(e):Linking.openURL(e).catch(()=>{})};function Inline({tokens:e,ctx:t}){const{styles:i}=t;return _jsx(_Fragment,{children:e.map(e=>{switch(e.type){case"text":return _jsx(RNText,{children:e.text},e.key);case"code":return _jsx(RNText,{style:i.inlineCode,children:e.text},e.key);case"strong":return _jsx(RNText,{style:i.strong,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"em":return _jsx(RNText,{style:i.em,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"strike":return _jsx(RNText,{style:i.strike,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"image":return _jsxs(RNText,{children:["[",_jsx(Inline,{tokens:e.children,ctx:t}),"]"]},e.key);case"link":return renderLink(e.key,e.href,e.children,t);case"citation":return _jsx(RNText,{style:i.citation,accessibilityRole:t.onOpenCitation?"button":void 0,accessibilityLabel:e.text,onPress:t.onOpenCitation?()=>t.onOpenCitation?.(e.text):void 0,children:e.text},e.key);default:return null}})})}function renderLink(e,t,i,n){const{styles:s,links:o,resolveLink:r,onAppLinkPress:l,onLinkPress:a}=n,
|
|
1
|
+
"use strict";import{linkTarget,parseInline,parseMarkdown}from"@webority/markdown-core";import{useMemo}from"react";import{Linking,Platform,Text as RNText,ScrollView,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MONO=Platform.select({ios:"Menlo",android:"monospace",default:"monospace"}),HEADING_SCALE={1:"3xl",2:"2xl",3:"xl",4:"lg",5:"base",6:"sm"},createStyles=e=>StyleSheet.create({block:{marginBottom:e.space.sm},listRow:{flexDirection:"row",marginBottom:e.space.xs},marker:{width:e.space.lg},listText:{flex:1},quote:{borderLeftWidth:3,borderLeftColor:e.colors["border-subtle"],paddingLeft:e.space.sm,marginBottom:e.space.sm},quoteText:{color:e.colors["text-muted"],fontStyle:"italic"},code:{backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.sm,...smoothCorners,padding:e.space.sm,marginBottom:e.space.sm},codeText:{fontFamily:MONO},inlineCode:{fontFamily:MONO,backgroundColor:e.colors["bg-subtle"],color:e.colors["text-body"]},link:{color:e.colors.link,textDecorationLine:"underline"},citation:{color:e.colors.primary,fontWeight:e.weight.semibold},strong:{fontWeight:e.weight.bold},em:{fontStyle:"italic"},strike:{textDecorationLine:"line-through"},table:{borderWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border},row:{flexDirection:"row"},headerRow:{backgroundColor:e.colors["bg-subtle"]},cell:{minWidth:96,maxWidth:220,padding:e.space.xs,borderRightWidth:StyleSheet.hairlineWidth,borderBottomWidth:StyleSheet.hairlineWidth,borderColor:e.colors.border},rule:{height:StyleSheet.hairlineWidth,backgroundColor:e.colors.border,marginVertical:e.space.md}}),withPositionKeys=e=>e.map((e,t)=>({key:t,value:e})),openHref=(e,t)=>{t?t(e):Linking.openURL(e).catch(()=>{})};function Inline({tokens:e,ctx:t}){const{styles:i}=t;return _jsx(_Fragment,{children:e.map(e=>{switch(e.type){case"text":return _jsx(RNText,{children:e.text},e.key);case"code":return _jsx(RNText,{style:i.inlineCode,children:e.text},e.key);case"strong":return _jsx(RNText,{style:i.strong,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"em":return _jsx(RNText,{style:i.em,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"strike":return _jsx(RNText,{style:i.strike,children:_jsx(Inline,{tokens:e.children,ctx:t})},e.key);case"image":return _jsxs(RNText,{children:["[",_jsx(Inline,{tokens:e.children,ctx:t}),"]"]},e.key);case"link":return renderLink(e.key,e.href,e.children,t);case"citation":return _jsx(RNText,{style:i.citation,accessibilityRole:t.onOpenCitation?"button":void 0,accessibilityLabel:e.text,onPress:t.onOpenCitation?()=>t.onOpenCitation?.(e.text):void 0,children:e.text},e.key);default:return null}})})}function renderLink(e,t,i,n){const{styles:s,links:o,resolveLink:r,onAppLinkPress:l,onLinkPress:a,onPageLinkPress:c}=n,d=_jsx(Inline,{tokens:i,ctx:n}),x=linkTarget(t,o,r);return null===x?_jsx(RNText,{children:d},e):"page"===x.kind?_jsx(RNText,c?{accessibilityRole:"link",style:s.link,onPress:()=>c(x.href),children:d}:{children:d},e):"app"===x.kind?_jsx(RNText,l?{accessibilityRole:"link",style:s.link,onPress:()=>l(x.target),children:d}:{children:d},e):_jsx(RNText,{accessibilityRole:"link",style:s.link,onPress:()=>openHref(x.href,a),children:d},e)}function RenderBlock({block:e,ctx:t}){const{theme:i,styles:n,textStyle:s,headings:o}=t;switch(e.type){case"heading":return _jsx(Text,{variant:"body",weight:"outline"===o?"semibold":"bold",size:"outline"===o?HEADING_SCALE[e.level]:void 0,accessibilityRole:"header",style:[n.block,s],children:_jsx(Inline,{tokens:parseInline(e.text,{isCitation:t.isCitation}),ctx:t})});case"paragraph":return _jsx(Text,{variant:"body",style:[n.block,s],children:_jsx(Inline,{tokens:parseInline(e.lines.join("\n"),{isCitation:t.isCitation}),ctx:t})});case"list":return _jsx(View,{children:withPositionKeys(e.items).map(({key:e,value:o})=>_jsxs(View,{style:[n.listRow,{marginLeft:o.depth*i.space.md}],children:[_jsx(Text,{variant:"body",style:[n.marker,s],children:o.ordered?`${o.number}.`:"•"}),_jsx(Text,{variant:"body",style:[n.listText,s],children:_jsx(Inline,{tokens:parseInline(o.text,{isCitation:t.isCitation}),ctx:t})})]},e))});case"table":return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:n.block,children:_jsx(View,{style:n.table,children:withPositionKeys([e.header,...e.rows]).map(({key:i,value:o})=>_jsx(View,{style:[n.row,0===i&&n.headerRow],children:withPositionKeys(e.header).map(({key:e})=>_jsx(View,{style:n.cell,children:_jsx(Text,{variant:"bodySmall",weight:0===i?"semibold":void 0,style:s,children:_jsx(Inline,{tokens:parseInline(o[e]??"",{isCitation:t.isCitation}),ctx:t})})},e))},i))})});case"code":return _jsx(ScrollView,{horizontal:!0,style:n.code,children:_jsx(Text,{variant:"body",size:"sm",selectable:!0,style:n.codeText,children:e.text})});case"quote":return _jsx(View,{style:n.quote,children:_jsx(Text,{variant:"body",style:[n.quoteText,s],children:_jsx(Inline,{tokens:parseInline(e.lines.join("\n"),{isCitation:t.isCitation}),ctx:t})})});case"rule":return _jsx(View,{style:n.rule});default:return null}}const MarkdownSkeleton=({style:e,testID:t})=>{const i=useTheme();return _jsxs(View,{style:e,testID:t,children:[_jsx(Skeleton,{shape:"text",width:"70%",height:20,style:{marginBottom:i.space.sm}}),_jsx(Skeleton,{shape:"text",width:"100%",height:14,style:{marginBottom:i.space.xs}}),_jsx(Skeleton,{shape:"text",width:"92%",height:14,style:{marginBottom:i.space.xs}}),_jsx(Skeleton,{shape:"text",width:"60%",height:14})]})};export function Markdown({children:e,links:t="web",headings:i="outline",resolveLink:n,isCitation:s,onOpenCitation:o,onAppLinkPress:r,onLinkPress:l,onPageLinkPress:a,loading:c=!1,style:d,textStyle:x,testID:h}){const k=useTheme(),m=useMemo(()=>createStyles(k),[k]),y=useMemo(()=>parseMarkdown(e??""),[e]);if(c)return _jsx(MarkdownSkeleton,{style:d,testID:h});if(0===y.length)return null;const u={theme:k,styles:m,links:t,headings:i,textStyle:x,resolveLink:n,isCitation:s,onOpenCitation:o,onAppLinkPress:r,onLinkPress:l,onPageLinkPress:a};return _jsx(View,{style:d,testID:h,children:y.map(e=>_jsx(RenderBlock,{block:e,ctx:u},e.key))})}Markdown.displayName="Markdown";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{claimAnchoredSurface,computePlacement,PLACEMENT_MARGIN,placementRoom}from"../../utils/placement.js";import{Breakpoints}from"../../utils/responsive.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Row}from"../Box/index.js";import{Divider}from"../Divider/index.js";import{ListItem}from"../ListItem/index.js";import{Modal}from"../Modal/index.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{OptionSheet}from"../OptionSheet/index.js";import{Text}from"../Text/index.js";import{FOCUS_DELAY_MS,focusHost}from"./focusHost.js";import{visibleGroups,visibleTopActions,wantsSheet}from"./menuModel.js";import{webOnly}from"./webOnly.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MENU_MIN_WIDTH=180,MENU_MAX_WIDTH=280,TOP_ACTION_MIN_HEIGHT=64,ICON_SIZE=20,PREVIEW_LIFT=1.02,BACK_KEY="__menu-back",TOP_PREFIX="__menu-top:";export const MenuSurface=e=>{const{open:t,anchor:s,items:o,title:i,topActions:n,placement:r,presentation:l,unavailable:a,context:c=!1,preview:u,onClose:d,restoreFocusTo:m,haptic:p,accessibilityLabel:f,labels:b,testID:h}=e,x=useTheme(),y=useMemo(()=>buildStyles(x),[x]),v=useSafeAreaInsets(),[g,_]=useModalInsets(),w=useMemo(()=>({...v,top:g.top,bottom:g.bottom}),[v,g]),j=useWindowDimensions(),A=usePresenceMotion(),I=A.duration("fast"),k=useMemo(()=>visibleGroups(o,a),[o,a]),S=useMemo(()=>visibleTopActions(n,a),[n,a]),E="sheet"===l||"auto"===l&&j.width<Breakpoints.lg&&wantsSheet(k,S),[M,C]=useState(null),[D,R]=useState(null),T=useRef(d);T.current=d;const L=useRef(m);L.current=m;const O=useRef(null),P=useRef(!1),V=useRef(!1),H=useRef(new Map),N=useRef(null),B=useCallback(()=>{if(!P.current)return;P.current=!1;const e=O.current;O.current=null,e?e():focusHost(L.current?.())},[]);useEffect(()=>{if(t)return V.current=!0,P.current=!1,O.current=null,claimAnchoredSurface(()=>T.current());V.current&&(V.current=!1,P.current=!0,C(null),R(null))},[t]);const F=useCallback(e=>{if(e.disabled)return;const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),e.key!==BACK_KEY?e.submenu?C(e):(O.current=e.onPress??null,T.current()):C(null)},[p]),K=useMemo(()=>({width:j.width,height:j.height,insets:w}),[j.width,j.height,w]),$=useMemo(()=>{if(!s||!D)return null;const e=s.x+s.width/2>K.width/2?"end":"start";return computePlacement(s,D,K,r,{align:e})},[s,D,K,r]);let z=K.height-w.top-w.bottom-2*PLACEMENT_MARGIN;if(s&&$){const e=placementRoom(s,K);z="top"===$.placement?e.above:e.below}const G=Math.min(280,K.width-w.left-w.right-2*PLACEMENT_MARGIN),W=t&&null!==$,Y=useRef(createAnimatedValue(0)).current,U=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!W)return setNativeValue(Y,0),void setNativeValue(U,1);const e=[Animated.timing(Y,{toValue:1,duration:I,easing:Easing.bezier(...x.motion.ease.decelerate),useNativeDriver:!0})];c&&!A.reduced&&e.push(Animated.spring(U,{toValue:1.02,damping:x.motion.spring.snappy.damping,stiffness:x.motion.spring.snappy.stiffness,mass:x.motion.spring.snappy.mass,useNativeDriver:!0}));const t=Animated.parallel(e);return t.start(),()=>t.stop()},[W,c,A.reduced,Y,U,x.motion,I]);const X=useCallback(e=>{const{width:t,height:s}=e.nativeEvent.layout;R(e=>e&&e.width===t&&e.height===s?e:{width:t,height:s})},[]),Z=c&&"top"===$?.placement,q=M?.submenu?[M.submenu]:k,J=Z?[...q].reverse().map(e=>[...e].reverse()):q,Q=[];if(M)Q.push({key:BACK_KEY,label:M.label});else for(const e of S)Q.push({key:`${TOP_PREFIX}${e.key}`,label:e.label,item:e});for(const e of J)for(const t of e)Q.push({key:t.key,label:t.label,item:t});const ee=Q[0]?.key;useEffect(()=>{if(!W||E||!ee)return;const e=setTimeout(()=>focusHost(H.current.get(ee)),FOCUS_DELAY_MS);return()=>clearTimeout(e)},[W,E,ee]);const setItemRef=e=>t=>{t?H.current.set(e,t):H.current.delete(e)},te=webOnly({onKeyDown:e=>{const t=e.key??e.nativeEvent?.key??"",s=Q.length,o=Q.findIndex(e=>e.key===N.current);let i=-1;if("ArrowDown"===t)i=(o+1)%s;else if("ArrowUp"===t)i=o<=0?s-1:o-1;else if("Home"===t)i=0;else if("End"===t)i=s-1;else{if("ArrowLeft"===t&&M)return e.preventDefault?.(),void C(null);if("ArrowRight"===t&&Q[o]?.item?.submenu)return e.preventDefault?.(),void F(Q[o].item);if(1===t.length&&""!==t.trim()){const e=t.toLowerCase();for(let t=1;t<=s;t+=1){const n=(o+t)%s;if(Q[n].label.toLowerCase().startsWith(e)){i=n;break}}}}i>=0&&(e.preventDefault?.(),(e=>{const t=Q[e];t&&focusHost(H.current.get(t.key))})(i))}});if(E){const e=M?.submenu?[{key:BACK_KEY,label:b.back,icon:"chevron-left"},...M.submenu]:[...S,...k.flat()],s=[...new Set(e.filter(e=>e.checked).map(e=>e.key))];return _jsx(OptionSheet,{visible:t,onClose:d,onAfterClose:B,title:M?.label??i,options:e,getOptionLabel:e=>e.label,getOptionValue:e=>e.key,isOptionDisabled:e=>Boolean(e.disabled),destructiveOf:e=>Boolean(e.destructive),getOptionDescription:e=>e.description,getOptionIcon:e=>{const t=e;return renderSlotIcon(t.icon,{color:t.destructive?x.colors["danger-text"]:x.colors["text-muted"],size:20,disabled:Boolean(t.disabled)})},value:s,onChange:(e,t)=>F(t),accessibilityLabel:f??i,testID:h?`${h}-sheet`:void 0})}const inkFor=e=>e.disabled?x.colors["text-disabled"]:e.destructive?x.colors["danger-text"]:x.colors["text-body"],inkRoleFor=e=>e.disabled?"disabled":e.destructive?"danger":"primary",se=_jsxs(_Fragment,M?{children:[_jsx(ListItem,{ref:setItemRef(BACK_KEY),variant:"menu",onPress:()=>C(null),onFocus:()=>{N.current=BACK_KEY},accessibilityLabel:`${b.back}, ${M.label}`,left:_jsx(View,{style:y.icon,children:_jsx(AppIcon,{name:"chevron-left",size:20,color:x.colors["text-muted"]})}),title:_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:1,children:M.label})}),_jsx(Divider,{spacing:"none"})]}:{children:[i?_jsx(Text,{variant:"caption",color:"secondary",accessibilityRole:"header",numberOfLines:2,style:y.title,children:i}):null,S.length>0?_jsxs(_Fragment,{children:[_jsx(View,{style:y.topRow,children:S.map(e=>{const t=`${TOP_PREFIX}${e.key}`,s=Boolean(e.disabled),o=inkFor(e);return _jsxs(Pressable,{ref:setItemRef(t),onPress:()=>F(e),onFocus:()=>{N.current=t},disabled:s,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel??e.label,accessibilityState:{disabled:s},"aria-disabled":s,testID:e.testID,style:({pressed:e})=>[y.topAction,e?y.pressed:null],children:[renderSlotIcon(e.icon,{color:o,size:20,disabled:s}),_jsx(Text,{variant:"caption",color:inkRoleFor(e),numberOfLines:1,children:e.label})]},t)})}),_jsx(Divider,{spacing:"none"})]}):null]});return _jsxs(Modal,{visible:t,onClose:d,presentation:"fullScreen",bare:!0,backdropOpacity:c?void 0:0,haptic:!1,labels:{close:b.close},onInsetsChange:_,onDismissed:B,testID:h?`${h}-modal`:void 0,children:[c&&u&&s?_jsx(Animated.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[y.preview,{left:s.x,top:s.y,width:s.width,height:s.height,transform:[{scale:U}]}],children:u}):null,_jsx(Animated.View,{accessibilityRole:"menu",accessibilityLabel:M?.label??f??i,onLayout:X,testID:h?`${h}-menu`:void 0,...te,style:[y.anchored,{left:$?.x??0,top:$?.y??0,maxWidth:G,opacity:W?Y:0}],children:_jsx(View,{style:y.surface,children:_jsxs(View,{style:[y.clip,{maxHeight:z}],children:[se,_jsx(ScrollView,{style:y.scroll,bounces:!1,keyboardShouldPersistTaps:"handled",children:J.map((e,t)=>{const s=e.some(e=>null!=e.icon);return _jsxs(View,{children:[t>0?_jsx(Divider,{spacing:"none"}):null,e.map(e=>((e,t)=>{const s=Boolean(e.disabled),o=inkFor(e),i=e.detail||e.checked||e.submenu?_jsxs(Row,{gap:"md",children:[e.detail?_jsx(Text,{variant:"caption",color:"tertiary",children:e.detail}):null,e.checked?_jsx(AppIcon,{name:"check",size:20,color:x.colors.primary}):null,e.submenu?_jsx(AppIcon,{name:"chevron-right",size:20,color:x.colors["text-subtle"]}):null]}):void 0;return _jsx(ListItem,{ref:setItemRef(e.key),variant:"menu",onPress:()=>F(e),onFocus:()=>{N.current=e.key},disabled:s,checked:e.checked,accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,rightPlacement:"side",left:t?_jsx(View,{style:y.icon,children:renderSlotIcon(e.icon,{color:o,size:20,disabled:s})}):void 0,title:_jsx(Text,{variant:"body",color:inkRoleFor(e),numberOfLines:2,children:e.label}),subtitle:e.description?_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:2,children:e.description}):void 0,right:i},e.key)})(e,s))]},e[0].key)})})]})})})]})};const buildStyles=e=>StyleSheet.create({preview:{position:"absolute"},anchored:{position:"absolute",minWidth:180},surface:{backgroundColor:e.colors.surface,borderRadius:e.radius.md,...smoothCorners,...e.shadow.popover},clip:{borderRadius:e.radius.md,...smoothCorners,overflow:"hidden"},scroll:{flexGrow:0,flexShrink:1},title:{paddingHorizontal:e.space.md,paddingTop:e.space.sm,paddingBottom:e.space.xs},pressed:{backgroundColor:e.colors["surface-pressed"]},icon:{width:20,alignItems:"center"},topRow:{flexDirection:"row",padding:e.space.xs,gap:e.space.xs},topAction:{flexGrow:1,flexBasis:0,alignItems:"center",justifyContent:"center",gap:e.space.xs,minHeight:64,borderRadius:e.radius.sm,...smoothCorners}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,Dimensions,Easing,Keyboard,Platform,Pressable,Modal as RNModal,StyleSheet,useWindowDimensions,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{transparentOf,withAlpha}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{computePlacement,placementMaxHeight,placementRoom}from"../../utils/placement.js";import{squircleHostRadius}from"../../utils/squircle.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_MODAL_LABELS=Object.freeze({close:"Close modal"});const MODAL_PRESENTATIONS=["centered","bottom","fullScreen","anchored"];export const MODAL_DISMISS_GRACE_MS=300;const SCALE_START_VALUE=.9,Modal=forwardRef((e,t)=>{warnInvalidValue("Modal","presentation",e.presentation,MODAL_PRESENTATIONS);const{visible:o,onClose:
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,Dimensions,Easing,Keyboard,Platform,Pressable,Modal as RNModal,StyleSheet,useWindowDimensions,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{transparentOf,withAlpha}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{computePlacement,placementMaxHeight,placementRoom}from"../../utils/placement.js";import{squircleHostRadius}from"../../utils/squircle.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_MODAL_LABELS=Object.freeze({close:"Close modal"});const MODAL_PRESENTATIONS=["centered","bottom","fullScreen","anchored"];export const MODAL_DISMISS_GRACE_MS=300;const SCALE_START_VALUE=.9,Modal=forwardRef((e,t)=>{warnInvalidValue("Modal","presentation",e.presentation,MODAL_PRESENTATIONS);const{visible:o,onClose:r,presentation:s="centered",backdropOpacity:n,backdropPressClose:i=!0,animationDuration:a,animateMount:l=!0,accessibilityLabel:c,hardwareBackPress:u=!0,children:d,contentStyle:m,backdropStyle:f,restoreFocusRef:p,onDismissed:h,haptic:g,labels:b,anchor:S,placement:A="auto",align:y="center",testID:v,bare:x=!1,onInsetsChange:M}=e,w=useTheme(),C=useMemo(()=>({...DEFAULT_MODAL_LABELS,...b}),[b]),R=usePresenceMotion(),[V,j]=useModalInsets();useEffect(()=>{M?.(V)},[V,M]);const{width:E,height:T}=useWindowDimensions(),[D,_]=useState({width:0,height:0}),L=a??R.duration("default"),I=Dimensions.get("window").height,N=useRef(!l&&o),H=N.current,P=useRef(createAnimatedValue(H?1:.9)).current,k=useRef(createAnimatedValue(H?1:0)).current,O=useRef(createAnimatedValue(H?0:I)).current,z=useRef(createAnimatedValue(H?1:0)).current,W=useRef(null),q=useRef(!1),[F,B]=useState(o),U=useMemo(()=>buildStyles(w),[w]),K=useMemo(()=>{if("anchored"!==s||void 0===S)return null;const e={width:E,height:T,insets:{top:V.top,bottom:V.bottom,left:0,right:0}},t=computePlacement(S,D,e,A,{align:y});return{...t,maxHeight:placementMaxHeight(t.placement,placementRoom(S,e))}},[s,S,D,A,y,E,T,V.top,V.bottom]),G=useMemo(()=>{const e=w.colors.scrim;return"number"!=typeof n?"anchored"===s?transparentOf(e):e:withAlpha(e,n)??e},[w.colors.scrim,n,s]),Y=useMemo(()=>z.interpolate({inputRange:[0,1],outputRange:[transparentOf(G),G]}),[z,G]);useEffect(()=>{o&&(Keyboard.dismiss(),B(!0))},[o]),useEffect(()=>{const e=[];if(o&&F&&N.current)N.current=!1;else if(o&&F){const t=Animated.timing(z,{toValue:1,duration:R.duration("default"),useNativeDriver:!1});if(t.start(),e.push(t),R.reduced||"anchored"===s){k.setValue(0),O.setValue(0),P.setValue(1);const t=Animated.timing(k,{toValue:1,duration:L,useNativeDriver:!0});t.start(),e.push(t)}else if("bottom"===s){k.setValue(1);const t=Animated.spring(O,{toValue:0,damping:w.motion.spring.gentle.damping,stiffness:w.motion.spring.gentle.stiffness,mass:w.motion.spring.gentle.mass,useNativeDriver:!0});t.start(),e.push(t)}else{const t=Animated.parallel([Animated.spring(P,{toValue:1,damping:w.motion.spring.gentle.damping,stiffness:w.motion.spring.gentle.stiffness,mass:w.motion.spring.gentle.mass,useNativeDriver:!0}),Animated.timing(k,{toValue:1,duration:L,useNativeDriver:!0})]);t.start(),e.push(t)}}else if(F){const t=R.duration("fast"),o=Easing.bezier(...w.motion.ease.accelerate),r=Animated.timing(k,{toValue:0,duration:t,easing:o,useNativeDriver:!0}),n=R.reduced||"anchored"===s?r:"bottom"===s?Animated.timing(O,{toValue:I,duration:t,easing:o,useNativeDriver:!0}):Animated.parallel([Animated.timing(P,{toValue:.9,duration:t,easing:o,useNativeDriver:!0}),r]),i=Animated.parallel([n,Animated.timing(z,{toValue:0,duration:R.duration("default"),useNativeDriver:!1})]);i.start(({finished:e})=>{e&&(O.setValue(I),B(!1))}),e.push(i)}return()=>e.forEach(e=>{e.stop()})},[o,F,s,L,P,k,z,O,I,w.motion.spring.gentle.damping,w.motion.spring.gentle.stiffness,w.motion.spring.gentle.mass,R,w.motion.ease.accelerate]),useEffect(()=>{if("web"===Platform.OS)return;let e,t;return o?(e=setTimeout(()=>{W.current&&AccessibilityInfo.sendAccessibilityEvent(W.current,"focus")},150),q.current=!0):q.current&&(q.current=!1,p?.current&&(t=setTimeout(()=>{const e=p.current;e&&AccessibilityInfo.sendAccessibilityEvent(e,"focus")},L))),()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[o,L,p]);const J=useRef(h);J.current=h;const Q=useRef(!1);useEffect(()=>{if(o)return void(Q.current=!0);if(!Q.current)return;Q.current=!1;const e=setTimeout(()=>J.current?.(),300);return()=>clearTimeout(e)},[o]);const X=useCallback(()=>{if(!i)return;const e=resolveHaptic(g,"selection");e&&triggerHaptic(e),r()},[i,r,g]),Z=useCallback(()=>{u&&r()},[u,r]),$=useSquircle(!x&&"bottom"!==s&&"fullScreen"!==s&&"anchored"!==s,w.radius.xl),ee=useCallback(e=>{$.onLayout(e);const{width:t,height:o}=e.nativeEvent.layout;_(e=>e.width===t&&e.height===o?e:{width:t,height:o})},[$.onLayout]),te=useMemo(()=>x?"bottom"===s?U.bottomContent:"fullScreen"===s?U.fullScreenContent:U.bareCentredContent:"anchored"===s?[U.anchoredContent,{left:K?.x,top:K?.y,maxHeight:K?.maxHeight,backgroundColor:w.colors.surface,borderRadius:w.radius.lg,...smoothCorners},w.shadow.modal]:"fullScreen"===s?[U.fullScreenContent,{backgroundColor:w.colors.surface}]:"bottom"===s?[U.bottomContent,{backgroundColor:w.colors.surface,borderTopLeftRadius:w.radius.xl,borderTopRightRadius:w.radius.xl,...smoothCorners,paddingTop:w.space.lg,paddingHorizontal:w.space.lg,paddingBottom:w.space.lg+V.bottom},w.shadow.modal]:[U.centeredContent,{backgroundColor:w.colors.surface,borderRadius:$.active&&$.size?squircleHostRadius($.size.width,$.size.height,w.radius.xl):w.radius.xl,...smoothCorners,padding:w.space.xl},w.shadow.modal],[s,w,U,V.bottom,$.active,$.size,K,x]),oe=useMemo(()=>"anchored"===s?U.anchoredWrapper:"bottom"===s?U.bottomWrapper:"fullScreen"===s?U.fullScreenWrapper:U.centeredWrapper,[s,U]),re=useMemo(()=>"bottom"===s?{opacity:k,transform:[{translateY:O}]}:"fullScreen"===s||"anchored"===s?{opacity:k}:{opacity:k,transform:[{scale:P}]},[s,P,k,O]);if("anchored"===s&&void 0===S)throw new Error('[@webority/mobile-ui] Modal: presentation "anchored" needs an anchor.');if(x&&"anchored"===s)throw new Error('[@webority/mobile-ui] Modal: presentation "anchored" bare does not combine with presentation anchored.');return _jsx(RNModal,{visible:F,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Z,testID:v,children:_jsx(View,{ref:e=>{W.current=e,"function"==typeof t?t(e):t&&(t.current=e)},style:U.root,accessible:!1,accessibilityViewIsModal:!0,accessibilityRole:"alert",accessibilityLabel:c,children:_jsxs(ModalSafeArea,{onInsets:j,children:[_jsxs(Animated.View,{collapsable:!1,style:[StyleSheet.absoluteFill,oe,{backgroundColor:Y},f],children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:X,accessibilityRole:i?"button":void 0,accessibilityLabel:i?C.close:void 0,accessible:!!i&&void 0,importantForAccessibility:i?void 0:"no",disabled:!i}),_jsxs(Animated.View,{style:[te,re,D.height>0||"anchored"!==s?null:U.unmeasured,m],onLayout:ee,pointerEvents:x&&"fullScreen"===s?"box-none":"auto",needsOffscreenAlphaCompositing:!0,children:[$.active&&$.size?_jsx(SquircleFill,{width:$.size.width,height:$.size.height,radius:w.radius.xl,fill:w.colors.surface}):null,d]})]}),_jsx(ToastHost,{})]})})})});Modal.displayName="Modal";const buildStyles=e=>StyleSheet.create({root:{flex:1},centeredWrapper:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},centeredContent:{maxWidth:"90%",width:"90%"},bottomWrapper:{flex:1,justifyContent:"flex-end"},bottomContent:{width:"100%"},fullScreenWrapper:{flex:1},fullScreenContent:{flex:1},anchoredWrapper:{flex:1},anchoredContent:{position:"absolute"},unmeasured:{opacity:0},bareCentredContent:{alignSelf:"center"}});export{Modal};export default Modal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{Fragment,useContext}from"react";import{Text as RNText,StyleSheet,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SUBSCRIPTED=/(?<![A-Za-z0-9_])([A-Za-z])_([A-Za-z0-9]+)(?![A-Za-z0-9_])/g;export const parseNotation=t=>{const e=String(t??""),o=[];let s=0;for(const t of e.matchAll(SUBSCRIPTED)){const n=t.index??0;n>s&&o.push({text:e.slice(s,n)}),o.push({text:t[1],sub:t[2]}),s=n+t[0].length}return s<e.length&&o.push({text:e.slice(s)}),o};const SUB_DROP=.4,Subscript=({children:t,color:e})=>{const o=useTheme(),s=useContext(TextInkContext),n=Math.round(.75*(s?.fontSize??o.text.sm.size));return _jsx(View,{style:{transform:[{translateY:Math.round(.4*n)}]},children:_jsx(RNText,{maxFontSizeMultiplier:o.settings.maxFontSizeMultiplier,style:[styles.sub,{fontSize:n,lineHeight:n,color:e??s?.color??o.colors["text-body"],...fontFor(o,"normal")}],children:t})})},renderNotation=(t,e)=>parseNotation(t).map((t,o)=>t.sub?_jsxs(Fragment,{children:[t.text,_jsx(Subscript,{color:e,children:t.sub})]},o):_jsx(Fragment,{children:t.text},o));export const Notation=({text:t,base:e,sub:o,desc:s,color:n,testID:r})=>null!=e?_jsxs(RNText,{testID:r,children:[e,o?_jsx(Subscript,{color:n,children:o}):null,s?` ${s}`:null]}):_jsx(RNText,{testID:r,children:"string"==typeof t||null==t?renderNotation(t??"",n):t.map((t,e)=>_jsx(Fragment,"string"==typeof t?{children:renderNotation(t,n)}:{children:t.verbatim},e))});Notation.inlineText=!0;export const sym=(t,e,o,s)=>_jsx(Notation,{base:t,sub:e,desc:o,color:s});const styles=StyleSheet.create({sub:{includeFontPadding:!1}});export default Notation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"];export const DEFAULT_NUMBER_INPUT_LABELS=Object.freeze({decrease:"Decrease",increase:"Increase",input:"Number input"});const 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},NumberInput=forwardRef((e,t)=>{const{value:i,defaultValue:l,onChange:s,min:r=Number.NEGATIVE_INFINITY,max:n=Number.POSITIVE_INFINITY,step:a=1,allowDecimal:o=!1,precision:c=0,label:u,help:d,helperText:b,error:m,disabled:p=!1,size:f="md",variant:x="inline",unit:h,haptic:y,labels:S,accessibilityLabel:I,style:T,containerStyle:N,inputStyle:g,buttonStyle:_,unitStyle:F,labelStyle:j,textInputProps:v,testID:E}=e;warnInvalidValue("NumberInput","size",e.size,NUMBER_INPUT_SIZES),warnInvalidValue("NumberInput","variant",e.variant,NUMBER_INPUT_VARIANTS);const R=useMemo(()=>({...DEFAULT_NUMBER_INPUT_LABELS,...S}),[S]),[C,w]=useControllableState({value:i,defaultValue:l??e.min??0,onChange:s}),L=useTheme(),P=resolveFieldSize(L,f),V=resolveFieldTextStyle(L,{disabled:p}),z=useMemo(()=>buildStyles(L),[L]),A=useRef(null),[U,k]=useState(formatValue(C,o,c)),[B,M]=useState(!1),[D,H]=useState(!1),O=useCallback(()=>{p||A.current?.focus()},[p]),G=useRef(null),W=useRef(null),Y=useCallback(()=>{null!==G.current&&(clearTimeout(G.current),G.current=null),null!==W.current&&(clearInterval(W.current),W.current=null)},[]);useEffect(()=>Y,[Y]),useEffect(()=>{B||k(formatValue(C,o,c))},[C,o,c,B]);const Z=C<=r,$=C>=n,q=!p,J=useCallback(e=>{const t=roundToPrecision(e,o?c:0),i=clamp(t,r,n);i!==C&&w(i)},[o,n,r,w,c,C]),K=useCallback(()=>{if(!q||Z)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),J(C-a)},[Z,q,y,J,a,C]),Q=useCallback(()=>{if(!q||$)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),J(C+a)},[$,q,y,J,a,C]);React.useImperativeHandle(t,()=>({focus:()=>A.current?.focus(),blur:()=>A.current?.blur(),clear:()=>{k(""),Number.isFinite(r)&&r>0?w(r):w(0<r?r:0>n?n:0)}}),[n,r,w]);const X=useCallback(e=>{q&&(Y(),G.current=setTimeout(()=>{W.current=setInterval(()=>{"inc"===e?Q():K()},80)},500))},[Y,K,Q,q]),ee=useCallback(e=>{const t=sanitizeTyped(e,o);k(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=r&&i<=n&&i!==C&&w(roundToPrecision(i,o?c:0))},[o,n,r,w,c,C]),te=useCallback(()=>{M(!1),H(!1);const e=Number(U);if(""===U||!Number.isFinite(e))return void k(formatValue(C,o,c));const t=roundToPrecision(e,o?c:0),i=clamp(t,r,n);i!==C&&w(i),k(formatValue(i,o,c))},[o,U,n,r,w,c,C]),ie=useCallback(()=>{M(!0),H(!0)},[]),le=Z||p?L.colors["text-disabled"]:L.colors["text-body"],se=$||p?L.colors["text-disabled"]:L.colors["text-body"],re=P.icon+8,renderStepper=(e,t,i,l,s,r)=>_jsx(Pressable,{onPress:t,onLongPress:()=>X(e),onPressOut:Y,delayLongPress:500,disabled:i,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:re,height:re,alignItems:"center",justifyContent:"center",borderRadius:L.radius.pill,...smoothCorners},e&&!i?{backgroundColor:L.colors["surface-pressed"]}:null,_],testID:`${E??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:_jsx(Text,{variant:"body",weight:"semibold",style:{fontSize:P.icon,color:s,fontWeight:L.weight.semibold,lineHeight:P.icon+2},children:r})}),ne=I??fieldTextAsString(u)??R.input,ae=!0===m||hasFieldText(m),oe=_jsx(FieldBase,{size:f,disabled:p,error:ae,filled:!0,focused:D,onPress:O,pressFeedback:!1,leading:renderStepper("dec",K,Z||p,R.decrease,le,"−"),trailing:renderStepper("inc",Q,$||p,R.increase,se,"+"),children:_jsxs(View,{style:z.inputRow,children:[_jsx(TextInput,{ref:A,value:U,onChangeText:ee,onFocus:ie,onBlur:te,editable:!p,keyboardType:o?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:ne,accessibilityValue:{now:Number.isFinite(C)?C:0},accessibilityState:{disabled:p},"aria-disabled":p,accessibilityActions:[{name:"increment",label:R.increase},{name:"decrement",label:R.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&Q(),"decrement"===e.nativeEvent.actionName&&K()},style:[z.input,{fontSize:P.text,color:V.color,...V.weightStyle},g],...v}),h?_jsx(Text,{variant:"bodySmall",style:[z.unit,{fontSize:P.text,color:V.placeholderColor},F],children:h}):null]})}),ce=hasFieldText(u)?_jsx(FieldLabel,{size:f,help:d,style:j,children:u}):null,ue=_jsx(FieldMessage,{size:f,error:ae,text:ae?m:b});return _jsxs(View,"horizontal"===x?{style:[z.horizontalContainer,T
|
|
1
|
+
"use strict";import React,{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"];export const DEFAULT_NUMBER_INPUT_LABELS=Object.freeze({decrease:"Decrease",increase:"Increase",input:"Number input"});const 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},NumberInput=forwardRef((e,t)=>{const{value:i,defaultValue:l,onChange:s,min:r=Number.NEGATIVE_INFINITY,max:n=Number.POSITIVE_INFINITY,step:a=1,allowDecimal:o=!1,precision:c=0,label:u,help:d,helperText:b,error:m,disabled:p=!1,size:f="md",variant:x="inline",unit:h,haptic:y,labels:S,accessibilityLabel:I,style:T,containerStyle:N,inputStyle:g,buttonStyle:_,unitStyle:F,labelStyle:j,textInputProps:v,testID:E}=e;warnInvalidValue("NumberInput","size",e.size,NUMBER_INPUT_SIZES),warnInvalidValue("NumberInput","variant",e.variant,NUMBER_INPUT_VARIANTS);const R=useMemo(()=>({...DEFAULT_NUMBER_INPUT_LABELS,...S}),[S]),[C,w]=useControllableState({value:i,defaultValue:l??e.min??0,onChange:s}),L=useTheme(),P=resolveFieldSize(L,f),V=resolveFieldTextStyle(L,{disabled:p}),z=useMemo(()=>buildStyles(L),[L]),A=useRef(null),[U,k]=useState(formatValue(C,o,c)),[B,M]=useState(!1),[D,H]=useState(!1),O=useCallback(()=>{p||A.current?.focus()},[p]),G=useRef(null),W=useRef(null),Y=useCallback(()=>{null!==G.current&&(clearTimeout(G.current),G.current=null),null!==W.current&&(clearInterval(W.current),W.current=null)},[]);useEffect(()=>Y,[Y]),useEffect(()=>{B||k(formatValue(C,o,c))},[C,o,c,B]);const Z=C<=r,$=C>=n,q=!p,J=useCallback(e=>{const t=roundToPrecision(e,o?c:0),i=clamp(t,r,n);i!==C&&w(i)},[o,n,r,w,c,C]),K=useCallback(()=>{if(!q||Z)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),J(C-a)},[Z,q,y,J,a,C]),Q=useCallback(()=>{if(!q||$)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),J(C+a)},[$,q,y,J,a,C]);React.useImperativeHandle(t,()=>({focus:()=>A.current?.focus(),blur:()=>A.current?.blur(),clear:()=>{k(""),Number.isFinite(r)&&r>0?w(r):w(0<r?r:0>n?n:0)}}),[n,r,w]);const X=useCallback(e=>{q&&(Y(),G.current=setTimeout(()=>{W.current=setInterval(()=>{"inc"===e?Q():K()},80)},500))},[Y,K,Q,q]),ee=useCallback(e=>{const t=sanitizeTyped(e,o);k(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=r&&i<=n&&i!==C&&w(roundToPrecision(i,o?c:0))},[o,n,r,w,c,C]),te=useCallback(()=>{M(!1),H(!1);const e=Number(U);if(""===U||!Number.isFinite(e))return void k(formatValue(C,o,c));const t=roundToPrecision(e,o?c:0),i=clamp(t,r,n);i!==C&&w(i),k(formatValue(i,o,c))},[o,U,n,r,w,c,C]),ie=useCallback(()=>{M(!0),H(!0)},[]),le=Z||p?L.colors["text-disabled"]:L.colors["text-body"],se=$||p?L.colors["text-disabled"]:L.colors["text-body"],re=P.icon+8,renderStepper=(e,t,i,l,s,r)=>_jsx(Pressable,{onPress:t,onLongPress:()=>X(e),onPressOut:Y,delayLongPress:500,disabled:i,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:re,height:re,alignItems:"center",justifyContent:"center",borderRadius:L.radius.pill,...smoothCorners},e&&!i?{backgroundColor:L.colors["surface-pressed"]}:null,_],testID:`${E??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:_jsx(Text,{variant:"body",weight:"semibold",style:{fontSize:P.icon,color:s,fontWeight:L.weight.semibold,lineHeight:P.icon+2},children:r})}),ne=I??fieldTextAsString(u)??R.input,ae=!0===m||hasFieldText(m),oe=_jsx(FieldBase,{size:f,disabled:p,error:ae,filled:!0,focused:D,onPress:O,pressFeedback:!1,leading:renderStepper("dec",K,Z||p,R.decrease,le,"−"),trailing:renderStepper("inc",Q,$||p,R.increase,se,"+"),children:_jsxs(View,{style:z.inputRow,children:[_jsx(TextInput,{ref:A,value:U,onChangeText:ee,onFocus:ie,onBlur:te,editable:!p,keyboardType:o?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:ne,accessibilityValue:{now:Number.isFinite(C)?C:0},accessibilityState:{disabled:p},"aria-disabled":p,accessibilityActions:[{name:"increment",label:R.increase},{name:"decrement",label:R.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&Q(),"decrement"===e.nativeEvent.actionName&&K()},style:[z.input,{fontSize:P.text,color:V.color,...V.weightStyle},g],...v}),h?_jsx(Text,{variant:"bodySmall",style:[z.unit,{fontSize:P.text,color:V.placeholderColor},F],children:h}):null]})}),ce=hasFieldText(u)?_jsx(FieldLabel,{size:f,help:d,style:j,children:u}):null,ue=_jsx(FieldMessage,{size:f,error:ae,text:ae?m:b});return _jsxs(View,"horizontal"===x?{style:[z.horizontalContainer,N,T],testID:E,accessibilityState:{disabled:p},"aria-disabled":p,children:[_jsx(View,{style:z.horizontalLabelWrap,children:ce}),_jsxs(View,{children:[oe,ue]})]}:{style:[N,T],testID:E,accessibilityState:{disabled:p},"aria-disabled":p,children:[ce,oe,ue]})});NumberInput.displayName="NumberInput";const buildStyles=e=>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}});export{NumberInput};export default NumberInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{View}from"react-native";import{makeStyles}from"../../theme/index.js";import{Button}from"../Button/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_OTP_RESEND_ROW_LABELS=Object.freeze({expiresIn:e=>`Code expires in ${e}`,expired:"Code expired",resendIn:e=>`Resend code in ${e}`,resendWaitSpoken:e=>`You can ask for a new code in ${e} seconds`,resend:"Resend code",sendNew:"Send a new code"});const TOUCH_TARGET=44,countdownText=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,useStyles=makeStyles(e=>({row:{alignItems:"center",columnGap:e.space.md,flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",minHeight:44,rowGap:e.space.xs,width:"100%"}})),OTPResendRow=({resendSecondsLeft:e,expirySecondsLeft:n,onResend:s,resending:t=!1,labels:o,style:r,testID:i})=>{const d=useStyles(),a=o?{...DEFAULT_OTP_RESEND_ROW_LABELS,...o}:DEFAULT_OTP_RESEND_ROW_LABELS,x=0===n,c=x||0===e;return _jsxs(View,{style:[d.row,r],children:[null==n?_jsx(View,{}):_jsx(Text,{variant:"caption",testID:i?`${i}-expiry`:void 0,children:x?a.expired:a.expiresIn(countdownText(n))}),c?_jsx(Button,{variant:"link",label:x?a.sendNew:a.resend,onPress:s,disabled:t,testID:i?`${i}-resend`:void 0}):_jsx(Text,{variant:"caption",accessibilityLabel:a.resendWaitSpoken(e),testID:i?`${i}-resend-wait`:void 0,children:a.resendIn(countdownText(e))})]})};OTPResendRow.displayName="OTPResendRow";export{OTPResendRow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{DEFAULT_OTP_INPUT_LABELS,default,OTPInput}from"./OTPInput.js";
|
|
1
|
+
"use strict";export{DEFAULT_OTP_INPUT_LABELS,default,OTPInput}from"./OTPInput.js";export{DEFAULT_OTP_RESEND_ROW_LABELS,OTPResendRow}from"./OTPResendRow.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,Gradient,setNativeValue,useTheme}from"../../theme/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"});const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=tintOf(e,0,"transparent"),r=tintOf(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=forwardRef((e,t)=>{const r=useTheme(),s=useReducedMotion(),{progress:a,label:o,showPercent:i=!1,valueLabel:n,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:m,barColor:g,gradient:p,segments:f,animated:y=!0,style:h,containerStyle:b,barStyle:w,accessibilityLabel:x,labels:R,testID:A}=e;warnInvalidValue("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const _=useMemo(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...R}),[R]),j=l??"number"!=typeof a,E=clampProgress(a),v=useRef(createAnimatedValue(E)).current,V=useRef(createAnimatedValue(0)).current,S=useRef(createAnimatedValue(0)).current,T=useRef(0),N=useMemo(()=>buildStyles(r),[r]),O=c??r.radius.pill,I=m??r.colors["surface-disabled"],L=g??toneColor(r,d),B=useMemo(()=>p?"string"==typeof p?r.settings.gradients[p]??null:p:null,[p,r.settings.gradients]),C=useMemo(()=>glowOf(L),[L]),D=Array.isArray(f)&&f.length>0;useEffect(()=>{j||(y?Animated.timing(v,{toValue:E,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():v.setValue(E))},[y,E,v,j,r]),useEffect(()=>{if(!j)return;setNativeValue(V,0);const e=Animated.loop(Animated.timing(V,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}));return e.start(),()=>{e.stop()}},[j,V]);const M=v.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),P=V.interpolate({inputRange:[0,1],outputRange:[-1,1]}),k=V.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=i&&!j&&!D,F=null!=o||G||null!=n,U=_jsx(View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:x??("string"==typeof o?o:void 0),accessibilityValue:j?{text:_.loading}:{min:0,max:100,now:Math.round(100*E)},testID:A,onLayout:e=>{const t=e.nativeEvent.layout.width;T.current=t,setNativeValue(S,t)},style:[N.track,{height:u,borderRadius:O,...smoothCorners,backgroundColor:I},h
|
|
1
|
+
"use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,Gradient,setNativeValue,useTheme}from"../../theme/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"});const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=tintOf(e,0,"transparent"),r=tintOf(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=forwardRef((e,t)=>{const r=useTheme(),s=useReducedMotion(),{progress:a,label:o,showPercent:i=!1,valueLabel:n,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:m,barColor:g,gradient:p,segments:f,animated:y=!0,style:h,containerStyle:b,barStyle:w,accessibilityLabel:x,labels:R,testID:A}=e;warnInvalidValue("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const _=useMemo(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...R}),[R]),j=l??"number"!=typeof a,E=clampProgress(a),v=useRef(createAnimatedValue(E)).current,V=useRef(createAnimatedValue(0)).current,S=useRef(createAnimatedValue(0)).current,T=useRef(0),N=useMemo(()=>buildStyles(r),[r]),O=c??r.radius.pill,I=m??r.colors["surface-disabled"],L=g??toneColor(r,d),B=useMemo(()=>p?"string"==typeof p?r.settings.gradients[p]??null:p:null,[p,r.settings.gradients]),C=useMemo(()=>glowOf(L),[L]),D=Array.isArray(f)&&f.length>0;useEffect(()=>{j||(y?Animated.timing(v,{toValue:E,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():v.setValue(E))},[y,E,v,j,r]),useEffect(()=>{if(!j)return;setNativeValue(V,0);const e=Animated.loop(Animated.timing(V,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}));return e.start(),()=>{e.stop()}},[j,V]);const M=v.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),P=V.interpolate({inputRange:[0,1],outputRange:[-1,1]}),k=V.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=i&&!j&&!D,F=null!=o||G||null!=n,U=_jsx(View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:x??("string"==typeof o?o:void 0),accessibilityValue:j?{text:_.loading}:{min:0,max:100,now:Math.round(100*E)},testID:A,onLayout:e=>{const t=e.nativeEvent.layout.width;T.current=t,setNativeValue(S,t)},style:[N.track,{height:u,borderRadius:O,...smoothCorners,backgroundColor:I},b,h],children:D?_jsx(View,{style:[N.segments,{height:u}],children:(f??[]).map((e,t)=>_jsx(View,{style:{width:100*clampProgress(e.value)+"%",height:u,backgroundColor:e.color??toneColor(r,e.tone??"primary")}},t))}):_jsx(Animated.View,j?{style:[N.indeterminateBar,{height:u,width:s?"100%":"30%",opacity:s?k:1,transform:s?[]:[{translateX:Animated.multiply(P,S)}]},w],children:_jsx(Gradient,{gradient:C,style:StyleSheet.absoluteFill})}:{style:[N.determinateBar,{height:u,borderRadius:O,...smoothCorners,backgroundColor:B?"transparent":L,width:M,overflow:B?"hidden":void 0},w],children:B?_jsx(Gradient,{gradient:B,style:StyleSheet.absoluteFill}):null})});return F?_jsxs(View,{style:N.wrapper,children:[_jsxs(View,{style:[N.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof o||"number"==typeof o?_jsx(Text,{variant:"label",color:"primary",style:N.label,children:o}):_jsx(View,{style:N.label,children:o}),null!=n?"string"==typeof n||"number"==typeof n?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:n}):n:G?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*E)}%`}):null]}),U]}):U});ProgressBar.displayName="ProgressBar";const buildStyles=e=>StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});export{ProgressBar};export default ProgressBar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Logger}from"@webority/mobile-core";import{createContext,forwardRef,useContext,useMemo}from"react";import{Pressable,StyleSheet}from"react-native";import{spaceOf,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{fieldTextAsString,hasFieldText}from"../FieldBase/index.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"./RadioDot.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const RadioGroupContext=createContext(null);export const useRadioGroup=()=>useContext(RadioGroupContext);const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},Radio=forwardRef((e,t)=>{const{value:o,selected:r,onChange:i,disabled:s=!1,label:a,helperText:l,description:n,error:c,size:d="md",tone:p="primary",accessibilityLabel:u,haptic:m,style:h,containerStyle:x,circleStyle:f,dotStyle:b,labelStyle:y,testID:g,hitSlop:S,...w}=e;warnInvalidValue("Radio","size",e.size,["sm","md","lg"]),warnInvalidValue("Radio","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const R=useTheme(),C=useMemo(()=>buildStyles(R),[R]),j=useRadioGroup();__DEV__&&void 0===o&&Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const T=j?j.selectedValue===o:!!r,v=j&&j.disabled||s,D=toneColor(R,p),_=spaceOf(R,R.components.radio["label-gap"]),I=S??6,H=u??fieldTextAsString(a),V="string"==typeof c?c:void 0,k={description:n,helperText:l,error:V},L=!0===j?.error||!0===c||hasFieldText(c);return _jsxs(Pressable,{ref:t,onPress:e=>{if(v)return;const t=resolveHaptic(m,"selection");t&&triggerHaptic(t),j?j.onChange(o):i?.(o)},disabled:v,accessibilityRole:"radio",accessibilityLabel:H,accessibilityHint:w.accessibilityHint??fieldTextAsString(l??n),accessibilityState:{checked:T,disabled:v},"aria-checked":T,"aria-disabled":v,testID:g,hitSlop:I,...hitSlopMarker(I),...w,style:({pressed:e})=>[C.row,hasChoiceDetail(k)?C.rowTop:null,{opacity:v?.55:e?.85:1},h
|
|
1
|
+
"use strict";import{Logger}from"@webority/mobile-core";import{createContext,forwardRef,useContext,useMemo}from"react";import{Pressable,StyleSheet}from"react-native";import{spaceOf,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{fieldTextAsString,hasFieldText}from"../FieldBase/index.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"./RadioDot.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const RadioGroupContext=createContext(null);export const useRadioGroup=()=>useContext(RadioGroupContext);const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},Radio=forwardRef((e,t)=>{const{value:o,selected:r,onChange:i,disabled:s=!1,label:a,helperText:l,description:n,error:c,size:d="md",tone:p="primary",accessibilityLabel:u,haptic:m,style:h,containerStyle:x,circleStyle:f,dotStyle:b,labelStyle:y,testID:g,hitSlop:S,...w}=e;warnInvalidValue("Radio","size",e.size,["sm","md","lg"]),warnInvalidValue("Radio","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const R=useTheme(),C=useMemo(()=>buildStyles(R),[R]),j=useRadioGroup();__DEV__&&void 0===o&&Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const T=j?j.selectedValue===o:!!r,v=j&&j.disabled||s,D=toneColor(R,p),_=spaceOf(R,R.components.radio["label-gap"]),I=S??6,H=u??fieldTextAsString(a),V="string"==typeof c?c:void 0,k={description:n,helperText:l,error:V},L=!0===j?.error||!0===c||hasFieldText(c);return _jsxs(Pressable,{ref:t,onPress:e=>{if(v)return;const t=resolveHaptic(m,"selection");t&&triggerHaptic(t),j?j.onChange(o):i?.(o)},disabled:v,accessibilityRole:"radio",accessibilityLabel:H,accessibilityHint:w.accessibilityHint??fieldTextAsString(l??n),accessibilityState:{checked:T,disabled:v},"aria-checked":T,"aria-disabled":v,testID:g,hitSlop:I,...hitSlopMarker(I),...w,style:({pressed:e})=>[C.row,hasChoiceDetail(k)?C.rowTop:null,{opacity:v?.55:e?.85:1},x,h],children:[_jsx(RadioDot,{selected:T,color:D,disabled:v&&!T,size:d,style:[!L||T||v?null:{borderColor:R.colors["field-border-error"]},f],dotStyle:b}),_jsx(ChoiceText,{label:a,helperText:l,description:n,error:V,disabled:v,style:{marginLeft:_},labelStyle:y})]})});Radio.displayName="Radio";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});export{Radio};export default Radio;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RATING_SIZES=["sm","md","lg"],RATING_TONES=["primary","success","warning","danger","info","neutral"];export const DEFAULT_RATING_LABELS=Object.freeze({value:(e,t)=>`${e} of ${t} stars`});const sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(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["text-muted"];default:return e.colors.primary}},clampToStep=(e,t,s)=>{const i=Math.max(0,Math.min(t,e)),n=Math.round(i/s)*s;return Number(n.toFixed(2))},Star=({index:e,filled:t,size:s,filledColor:i,emptyColor:n,scale:a})=>{const r=Math.max(0,Math.min(1,t-e));return _jsxs(Animated.View,{style:[starStyles.starWrap,{width:s,height:s,transform:[{scale:a}]}],children:[_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:n,fontSize:s,lineHeight:s}],accessible:!1,children:"☆"}),r>0?_jsx(View,{pointerEvents:"none",style:[starStyles.fillClip,{width:s*r,height:s}],children:_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:i,fontSize:s,lineHeight:s}],accessible:!1,children:"★"})}):null]})},Rating=forwardRef((e,t)=>{const{value:s,onChange:i,max:n=5,allowHalf:a=!0,readonly:r=!1,size:o="md",tone:l="warning",label:c,loading:m=!1,haptic:u,labels:d,accessibilityLabel:p,style:y,containerStyle:g,starContainerStyle:f,testID:h}=e;warnInvalidValue("Rating","size",e.size,RATING_SIZES),warnInvalidValue("Rating","tone",e.tone,RATING_TONES);const x=useMemo(()=>({...DEFAULT_RATING_LABELS,...d}),[d]),S=useTheme(),b=useMemo(()=>buildStyles(S),[S]),v=!r&&"function"==typeof i,w=a?.5:1,j=resolveSize(o),R=toneColorFor(S,l),_=S.colors.border,A=useRef(j),k=useCallback(e=>{A.current=e.nativeEvent.layout.width},[]),T=useRef(new Map),C=useMemo(()=>{const e=T.current,t=[];for(let s=0;s<n;s+=1){let i=e.get(s);i||(i=new Animated.Value(1),e.set(s,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=n&&e.delete(t);return t},[n]),E=S.settings.components.rating?.pulseOnPress??!1,I=useCallback(e=>{const t=C[e];t&&Animated.sequence([Animated.timing(t,{toValue:1.2,duration:S.motion.duration.fast,easing:Easing.bezier(...S.motion.ease["in-out"]),useNativeDriver:!0}),Animated.spring(t,{toValue:1,damping:S.motion.spring.bouncy.damping,stiffness:S.motion.spring.bouncy.stiffness,mass:S.motion.spring.bouncy.mass,useNativeDriver:!0})]).start()},[S.motion,C]),M=useCallback((e,t)=>{if(!v||!i)return;const s=clampToStep(e,n,w),a=resolveHaptic(u,"selection");a&&triggerHaptic(a),E&&"number"==typeof t&&I(t),i(s)},[v,i,n,w,I,u,E]),V=useCallback(e=>t=>{if(!v)return;const s=A.current||j,i=t.nativeEvent.locationX??s;let n;n=a&&i<s/2?e+.5:e+1,M(n,e)},[v,j,a,M]),z=useCallback(e=>{v&&("increment"===e.nativeEvent.actionName?M(s+w):"decrement"===e.nativeEvent.actionName&&M(s-w))},[v,s,w,M]),N=x.value(s,n),L=p??c??N,P=[];for(let e=0;e<n;e+=1){const t=C[e];if(!t)continue;const i=_jsx(Star,{index:e,filled:s,size:j,filledColor:R,emptyColor:_,scale:t},e);P.push(v?_jsx(Pressable,{onPress:V(e),onLayout:0===e?k:void 0,hitSlop:4,...hitSlopMarker(4),accessible:!1,style:b.starPress,children:i},e):_jsx(View,{onLayout:0===e?k:void 0,style:b.starPress,children:i},e))}const D=_jsxs(View,{style:[b.wrapper,y
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RATING_SIZES=["sm","md","lg"],RATING_TONES=["primary","success","warning","danger","info","neutral"];export const DEFAULT_RATING_LABELS=Object.freeze({value:(e,t)=>`${e} of ${t} stars`});const sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(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["text-muted"];default:return e.colors.primary}},clampToStep=(e,t,s)=>{const i=Math.max(0,Math.min(t,e)),n=Math.round(i/s)*s;return Number(n.toFixed(2))},Star=({index:e,filled:t,size:s,filledColor:i,emptyColor:n,scale:a})=>{const r=Math.max(0,Math.min(1,t-e));return _jsxs(Animated.View,{style:[starStyles.starWrap,{width:s,height:s,transform:[{scale:a}]}],children:[_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:n,fontSize:s,lineHeight:s}],accessible:!1,children:"☆"}),r>0?_jsx(View,{pointerEvents:"none",style:[starStyles.fillClip,{width:s*r,height:s}],children:_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:i,fontSize:s,lineHeight:s}],accessible:!1,children:"★"})}):null]})},Rating=forwardRef((e,t)=>{const{value:s,onChange:i,max:n=5,allowHalf:a=!0,readonly:r=!1,size:o="md",tone:l="warning",label:c,loading:m=!1,haptic:u,labels:d,accessibilityLabel:p,style:y,containerStyle:g,starContainerStyle:f,testID:h}=e;warnInvalidValue("Rating","size",e.size,RATING_SIZES),warnInvalidValue("Rating","tone",e.tone,RATING_TONES);const x=useMemo(()=>({...DEFAULT_RATING_LABELS,...d}),[d]),S=useTheme(),b=useMemo(()=>buildStyles(S),[S]),v=!r&&"function"==typeof i,w=a?.5:1,j=resolveSize(o),R=toneColorFor(S,l),_=S.colors.border,A=useRef(j),k=useCallback(e=>{A.current=e.nativeEvent.layout.width},[]),T=useRef(new Map),C=useMemo(()=>{const e=T.current,t=[];for(let s=0;s<n;s+=1){let i=e.get(s);i||(i=new Animated.Value(1),e.set(s,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=n&&e.delete(t);return t},[n]),E=S.settings.components.rating?.pulseOnPress??!1,I=useCallback(e=>{const t=C[e];t&&Animated.sequence([Animated.timing(t,{toValue:1.2,duration:S.motion.duration.fast,easing:Easing.bezier(...S.motion.ease["in-out"]),useNativeDriver:!0}),Animated.spring(t,{toValue:1,damping:S.motion.spring.bouncy.damping,stiffness:S.motion.spring.bouncy.stiffness,mass:S.motion.spring.bouncy.mass,useNativeDriver:!0})]).start()},[S.motion,C]),M=useCallback((e,t)=>{if(!v||!i)return;const s=clampToStep(e,n,w),a=resolveHaptic(u,"selection");a&&triggerHaptic(a),E&&"number"==typeof t&&I(t),i(s)},[v,i,n,w,I,u,E]),V=useCallback(e=>t=>{if(!v)return;const s=A.current||j,i=t.nativeEvent.locationX??s;let n;n=a&&i<s/2?e+.5:e+1,M(n,e)},[v,j,a,M]),z=useCallback(e=>{v&&("increment"===e.nativeEvent.actionName?M(s+w):"decrement"===e.nativeEvent.actionName&&M(s-w))},[v,s,w,M]),N=x.value(s,n),L=p??c??N,P=[];for(let e=0;e<n;e+=1){const t=C[e];if(!t)continue;const i=_jsx(Star,{index:e,filled:s,size:j,filledColor:R,emptyColor:_,scale:t},e);P.push(v?_jsx(Pressable,{onPress:V(e),onLayout:0===e?k:void 0,hitSlop:4,...hitSlopMarker(4),accessible:!1,style:b.starPress,children:i},e):_jsx(View,{onLayout:0===e?k:void 0,style:b.starPress,children:i},e))}const D=_jsxs(View,{style:[b.wrapper,g,y],ref:t,testID:h,children:[c?_jsx(Text,{variant:"bodySmall",color:"secondary",style:b.label,children:c}):null,_jsx(View,{style:[b.row,f],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:L,accessibilityValue:v?{min:0,max:n,now:s,text:N}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?z:void 0,children:P})]});return m?_jsx(RatingSkeleton,{...e}):D});Rating.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:s,containerStyle:i,starContainerStyle:n,style:a})=>{const r=useTheme(),o=resolveSize(t),l=Math.max(1,e);return _jsxs(View,{style:[{alignItems:"flex-start"},i,a],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==s?_jsx(Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:r.space.xs}}):null,_jsx(View,{style:[{flexDirection:"row"},n],children:Array.from({length:l}).map((e,t)=>_jsx(Skeleton,{width:o,height:o,radius:Math.round(.25*o),style:t<l-1?{marginRight:r.space.xs}:void 0},`sk-star-${t}`))})]})};RatingSkeleton.displayName="RatingSkeleton",Rating.Skeleton=RatingSkeleton;const starStyles=StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});export{Rating};export default Rating;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo}from"react";import{View}from"react-native";import{useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Button}from"../Button/index.js";import{RequiredMark}from"../FieldBase/index.js";import{Text}from"../Text/Text.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SECTION_HEADER_LABELS=Object.freeze({required:e=>`${e}, required`});export const SectionHeader=e=>{const{children:t,variant:r,flush:i,
|
|
1
|
+
"use strict";import{useMemo}from"react";import{View}from"react-native";import{useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Button}from"../Button/index.js";import{RequiredMark}from"../FieldBase/index.js";import{Text}from"../Text/Text.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SECTION_HEADER_LABELS=Object.freeze({required:e=>`${e}, required`});export const SectionHeader=e=>{const{children:t,variant:r,flush:i,flushBottom:s=!1,required:a=!1,action:o,labels:n,style:l,testID:m}=e;warnInvalidValue("SectionHeader","variant",e.variant,["title","caps","sub"]);const c=useTheme(),u=c.settings.components["section-header"],d=r??u?.defaultVariant??"title",p=i??u?.defaultFlush??!1,x=useMemo(()=>({...DEFAULT_SECTION_HEADER_LABELS,...n}),[n]),f=useMemo(()=>({marginTop:p?0:c.space.lg,marginBottom:s?0:c.space.sm}),[c,p,s]),v=useMemo(()=>({flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:c.space.sm}),[c]),h=useMemo(()=>({flex:1}),[]),j="caps"===d?{variant:"overline",color:"tertiary",weight:void 0}:"sub"===d?{variant:"label",color:"primary",weight:"semibold"}:{variant:"title",color:void 0,weight:void 0},b=_jsxs(Text,{variant:j.variant,color:j.color,weight:j.weight,accessibilityRole:"header",accessibilityLabel:a&&"string"==typeof t?x.required(t):void 0,style:o?h:[f,l],testID:m,children:[t,a?_jsx(RequiredMark,{}):null]});return o?_jsxs(View,{style:[v,f,l],children:[b,_jsx(Button,{variant:"link",size:"sm",label:o.label,onPress:o.onPress,testID:o.testID})]}):b};export default SectionHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{DEFAULT_OPTION_SHEET_LABELS,OptionSheet}from"../OptionSheet/OptionSheet.js";import{Text}from"../Text/index.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SELECT_LABELS={placeholder:"Select…",noSelection:"No selection",selected:e=>`Selected: ${e}`,fallbackName:"Select",sheetName:"Options",searchPlaceholder:DEFAULT_OPTION_SHEET_LABELS.searchPlaceholder,empty:DEFAULT_OPTION_SHEET_LABELS.empty};const sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t)),Select=forwardRef((e,t)=>{warnInvalidValue("Select","size",e.size,["sm","md","lg"]),warnInvalidValue("Select","variant",e.variant,["outline","filled","underline"]);const{options:l,getOptionLabel:i,getOptionValue:o,isOptionDisabled:r,getOptionDescription:n,getOptionIcon:s,placeholder:a,onVisibleChange:c,searchable:d=!1,haptic:p,labels:u,label:h,help:x,title:S,required:m=!1,error:f,helperText:b,prefix:g,numberOfLines:v=1,disabled:y=!1,size:T="md",variant:C,leftIcon:j,rightIcon:L,chevronColor:_,chevronSize:F,borderRadius:O,accessibilityLabel:V,labelStyle:E,style:I,triggerStyle:k,textStyle:z,optionStyle:A,selectedOptionStyle:H,optionTextStyle:w,selectedOptionTextStyle:P,testID:D}=e,B=!0===e.multi,N=u?{...DEFAULT_SELECT_LABELS,...u}:DEFAULT_SELECT_LABELS,R=useCallback(e=>i?i(e):e.label??"",[i]),M=useCallback(e=>o?o(e):e.value,[o]),U=useCallback(e=>r?r(e):!0===e.disabled,[r]),q=useCallback(e=>n?n(e):e.description,[n]),$=useCallback(e=>s?s(e):e.icon,[s]),G=useTheme(),J=useMemo(()=>buildStyles(G),[G]),K=resolveFieldSize(G,T),Q=resolveFieldTextStyle(G,{disabled:y}),W=C??G.settings.components.select?.defaultVariant??G.settings.components.field?.defaultVariant??"outline",X=O??K.radius,[Y,Z]=useState(!1),ee=useMemo(()=>{if(B){const t=e.value??[];return l.filter(e=>containsValue(t,M(e)))}const t=e.value;if(null==t)return[];const i=l.find(e=>sameSelectValue(M(e),t));return i?[i]:[]},[B,l,e.value,M]),te=useCallback(()=>{if(y)return;const e=resolveHaptic(p,"selection");e&&triggerHaptic(e),Z(!0)},[y,p]),le=useCallback(()=>{Z(!1)},[]),ie=useCallback(t=>{if(U(t))return;const l=M(t),i=resolveHaptic(p,"selection");if(i&&triggerHaptic(i),B){const t=e.value??[],i=containsValue(t,l)?t.filter(e=>!sameSelectValue(e,l)):[...t,l];return void e.onChange(i)}e.onChange(l),le()},[B,e,le,U,M,p]),oe=0===ee.length?a??N.placeholder:ee.map(e=>R(e)).join(", "),re=0===ee.length,ne=!0===f||hasFieldText(f),se=hasFieldText(h),ae=fieldTextAsString(h),ce=Math.round(1.4*K.text),de=useMemo(()=>({fontSize:K.text,color:Q.placeholderColor}),[K.text,Q.placeholderColor]),pe={color:y?G.colors["field-icon-disabled"]:Y?G.colors["field-icon-focus"]:G.colors["field-icon"],size:K.icon,disabled:y,focused:Y,error:ne},ue=0===ee.length?a??N.noSelection:N.selected(ee.map(e=>R(e)).join(", ")),he=V??`${ae??N.fallbackName}. ${ue}`;return _jsxs(View,{style:[J.container,I],testID:D,children:[se?_jsx(FieldLabel,{size:T,required:m,help:x,style:E,children:h}):null,_jsx(View,{ref:t,collapsable:!1,children:_jsxs(FieldBase,{size:T,variant:W,disabled:y,error:ne,filled:ee.length>0,onPress:te,borderRadius:X,paddingHorizontal:"underline"===W?G.space.none:void 0,accessibilityRole:"button",accessibilityLabel:he,accessibilityState:{disabled:y,expanded:Y},"aria-disabled":y,"aria-expanded":Y,style:k,slotAlign:1===v?"center":"top",slotLineHeight:1===v?void 0:ce,leading:j?_jsx(View,{children:renderSlotIcon(j,pe)}):null,trailing:L?_jsx(View,{children:renderSlotIcon(L,pe)}):_jsx(Chevron,{color:_??(y?G.colors["text-disabled"]:G.colors["text-subtle"]),size:F??K.icon,open:Y,style:J.chevron}),children:[hasFieldText(g)?"string"==typeof g||"number"==typeof g?_jsx(Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===v?void 0:ce,marginRight:G.space.xs}],children:g}):_jsx(View,{style:[J.prefixNode,{minHeight:1===v?void 0:ce,justifyContent:"center",marginRight:G.space.xs}],children:_jsx(Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===v?void 0:ce}],children:_jsx(TextInkContext.Provider,{value:de,children:g})})}):null,_jsxs(Text,{variant:"body",style:[J.triggerText,{color:re?Q.placeholderColor:Q.color,fontSize:K.text,lineHeight:1===v?void 0:ce,...Q.weightStyle},z],numberOfLines:v,children:[oe,re&&m&&!se?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:T,error:ne,text:ne?f:b}),_jsx(OptionSheet,{visible:Y,onClose:le,onVisibleChange:c,haptic:p,title:S??ae,accessibilityLabel:ae??(se?S:void 0)??a??N.sheetName,options:l,getOptionLabel:R,getOptionValue:M,isOptionDisabled:U,getOptionDescription:q,getOptionIcon:$,value:e.value,onChange:(e,t)=>ie(t),multi:B,searchable:d,labels:{searchPlaceholder:N.searchPlaceholder,empty:N.empty},optionStyle:A,selectedOptionStyle:H,optionTextStyle:w,selectedOptionTextStyle:P,searchSelectionColor:resolveVariantColors(G,W).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});export{Select};export default Select;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useMemo}from"react";import{Text as RNText}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{TEXT_NAMES}from"../../theme/tokens.generated.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{
|
|
1
|
+
"use strict";import{forwardRef,useMemo}from"react";import{Text as RNText}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{TEXT_NAMES}from"../../theme/tokens.generated.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{TextInkContext,useTextInk}from"./textInk.js";import{jsx as _jsx}from"react/jsx-runtime";const VARIANTS={display:{size:"4xl",weight:"bold",line:"display",color:"primary",heading:!0,fontFamily:"display"},h1:{size:"3xl",weight:"bold",line:"heading",color:"primary",heading:!0,fontFamily:"display"},h2:{size:"2xl",weight:"semibold",line:"heading",color:"primary",heading:!0,fontFamily:"display"},h3:{size:"xl",weight:"semibold",line:"heading",color:"primary",heading:!0},title:{size:"lg",weight:"semibold",line:"body",color:"primary",fontFamily:"display"},body:{size:"base",weight:"normal",line:"body",color:"primary"},bodySmall:{size:"sm",weight:"normal",line:"body",color:"secondary"},caption:{size:"xs",weight:"normal",line:"body",color:"tertiary"},label:{size:"sm",weight:"medium",line:"body",color:"secondary"},overline:{size:"xs",weight:"semibold",line:"body",color:"secondary",uppercase:!0,letterSpacing:"wide"}},TEXT_ROLE_COLOR={textStrong:"text",primary:"text-body",secondary:"text-muted",tertiary:"text-subtle",inverse:"text-inverse",disabled:"text-disabled",link:"link",brand:"primary-text"},SEMANTIC={success:!0,warning:!0,danger:!0,info:!0,neutral:!0},COLOR_NAMES=["primary","secondary","tertiary","inverse","disabled","link","textStrong","brand","success","warning","danger","info","neutral"];export const resolveColor=(e,t)=>Object.hasOwn(TEXT_ROLE_COLOR,t)?e.colors[TEXT_ROLE_COLOR[t]]:Object.hasOwn(SEMANTIC,t)?e.colors[`${t}-text`]:t;const resolveVariantColor=(e,t)=>Object.hasOwn(TEXT_ROLE_COLOR,t)||Object.hasOwn(SEMANTIC,t)?resolveColor(e,t):e.colors[t],decorationOf=(e,t)=>e&&t?"underline line-through":e?"underline":t?"line-through":void 0,Text=forwardRef((e,t)=>{const{variant:i="body",color:o,weight:r,size:n,align:a,italic:l,underline:s,strikethrough:d,style:c,children:m,...x}=e,g=useTheme(),y=Object.hasOwn(VARIANTS,i),h=g.settings.textVariants,p=!y&&h&&Object.hasOwn(h,i)?h[i]:void 0;y||p||warnInvalidValue("Text","variant",e.variant,[...Object.keys(VARIANTS),...Object.keys(h??{})]),warnInvalidValue("Text","color",o,COLOR_NAMES),warnInvalidValue("Text","size",n,TEXT_NAMES);const u=void 0!==o&&COLOR_NAMES.includes(o)?o:void 0,b=useMemo(()=>{if(p){const e=n??p.size,t=g.text[e].size;return{fontSize:t,lineHeight:p.lineHeight??Math.round(t*g.leading[p.heading?"heading":"body"]),color:void 0!==u?resolveColor(g,u):p.color?resolveVariantColor(g,p.color):resolveColor(g,"primary"),textAlign:a,textTransform:p.uppercase?"uppercase":void 0,letterSpacing:p.letterSpacing?g["letter-spacing"][p.letterSpacing]:void 0,fontStyle:l||p.italic?"italic":void 0,fontVariant:p.fontVariant,textDecorationLine:decorationOf(s,d),...fontFor(g,r??p.weight??"normal",p.fontFamily)}}const e=VARIANTS[y?i:"body"],t=g.text[n??e.size].size;return{fontSize:t,lineHeight:Math.round(t*g.leading[e.line]),color:resolveColor(g,u??e.color),textAlign:a,textTransform:e.uppercase?"uppercase":void 0,letterSpacing:e.letterSpacing?g["letter-spacing"][e.letterSpacing]:void 0,fontStyle:l?"italic":void 0,textDecorationLine:decorationOf(s,d),...fontFor(g,r??e.weight,e.fontFamily)}},[g,p,y,i,u,r,n,a,l,s,d]),T=useTextInk([b,c],g.text.base.size,g.colors["text-body"]),f=y?VARIANTS[i].heading:p?.heading,O="string"==typeof m||"number"==typeof m;return _jsx(RNText,{ref:t,style:[b,c],maxFontSizeMultiplier:g.settings.maxFontSizeMultiplier,accessibilityRole:f?"header":x.accessibilityRole,...x,children:O?m:_jsx(TextInkContext.Provider,{value:T,children:m})})});Text.displayName="Text";export{Text};export default Text;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";import{createContext,useMemo}from"react";import{StyleSheet}from"react-native";export const TextInkContext=createContext(null);export const useTextInk=(t,e,o)=>{const r=StyleSheet.flatten(t),n=r?.fontSize??e,c=r?.color??o;return useMemo(()=>({fontSize:n,color:c}),[n,c])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import Button from"../Button/Button.js";import{Modal}from"../Modal/index.js";import{PickerTrigger}from"../PickerTrigger/PickerTrigger.js";import{Text}from"../Text/index.js";import{WheelPicker}from"../WheelPicker/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_TIME_PICKER_LABELS=Object.freeze({title:"Select Time",confirm:"Confirm",cancel:"Cancel",selected:e=>`Selected ${e}`,hour:"Hour",minute:"Minute",period:"Period",hourItem:e=>`Hour ${e}`,minuteItem:e=>`${e} minutes`,cancelHint:"Dismiss without changes",confirmHint:"Confirm selected time"});const range=(e,t,i=1)=>{const r=[];for(let a=e;a<=t;a+=i)r.push(a);return r},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},TimePicker=e=>{const{visible:t,value:i,onChange:r,onClose:a,format:
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import Button from"../Button/Button.js";import{Modal}from"../Modal/index.js";import{PickerTrigger}from"../PickerTrigger/PickerTrigger.js";import{Text}from"../Text/index.js";import{WheelPicker}from"../WheelPicker/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_TIME_PICKER_LABELS=Object.freeze({title:"Select Time",confirm:"Confirm",cancel:"Cancel",selected:e=>`Selected ${e}`,hour:"Hour",minute:"Minute",period:"Period",hourItem:e=>`Hour ${e}`,minuteItem:e=>`${e} minutes`,cancelHint:"Dismiss without changes",confirmHint:"Confirm selected time"});const range=(e,t,i=1)=>{const r=[];for(let a=e;a<=t;a+=i)r.push(a);return r},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},TimePicker=e=>{const{visible:t,value:i,onChange:r,onClose:a,format:l="12h",minuteStep:s=1,labels:o,testID:n,style:u,containerStyle:m,headerLabelStyle:c,footerButtonStyle:p,formatValue:d,haptic:h,triggerLabels:b,label:g,help:f,placeholder:y,helperText:M,error:x,required:S,disabled:v,size:k,variant:T,clearable:I,onClear:P,leadingIcon:j,trailing:H,triggerStyle:_,valueStyle:w,labelStyle:C,messageStyle:D,accessibilityLabel:L}=e,B={label:g,help:f,placeholder:y,helperText:M,error:x,required:S,disabled:v,size:k,variant:T,clearable:I,onClear:P,leadingIcon:j,trailing:H,triggerStyle:_,valueStyle:w,labelStyle:C,messageStyle:D,accessibilityLabel:L};warnInvalidValue("TimePicker","format",e.format,["12h","24h"]),warnInvalidValue("TimePicker","minuteStep",e.minuteStep?.toString(),["1","5","15","30"]),warnInvalidValue("TimePicker","size",e.size,["sm","md","lg"]),warnInvalidValue("TimePicker","variant",e.variant,["outline","filled","underline"]);const $=useMemo(()=>({...DEFAULT_TIME_PICKER_LABELS,...o}),[o]),A=void 0!==e.visible,[F,E]=useState(!1),V=A?t:F,N=A?n:n?`${n}-modal`:void 0,O=useTheme(),z=useMemo(()=>buildStyles(O),[O]),W=useCallback(()=>{A?a?.():E(!1)},[A,a]),R=useMemo(()=>"24h"===l?range(0,23):range(1,12),[l]),U=useMemo(()=>range(0,59,s),[s]),q=useMemo(()=>["AM","PM"],[]),K=useMemo(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,s),{displayHour:a,period:o}=from24h(e,l);return{displayHour:a,minute:r,period:o,hour24:e}},[i,l,s]),[G,J]=useState(()=>{const e=R.indexOf(K.displayHour);return e>=0?e:0}),[Q,X]=useState(()=>{const e=U.indexOf(K.minute);return e>=0?e:0}),[Y,Z]=useState(()=>"PM"===K.period?1:0);useEffect(()=>{if(!V)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,s),{displayHour:a,period:o}=from24h(e,l),n=R.indexOf(a);J(n>=0?n:0);const u=U.indexOf(r);X(u>=0?u:0),Z("PM"===o?1:0)},[V,i,l,s,R,U]);const ee=useCallback((e,t)=>{"hour"===e?J(Math.max(0,R.indexOf(Number(t)))):"minute"===e?X(Math.max(0,U.indexOf(Number(t)))):Z("PM"===t?1:0)},[R,U]),te=useCallback(()=>{!1!==h&&triggerHaptic("selection"),W()},[W,h]),ie=useCallback(()=>{const e=R[G]??0,t=q[Y]??"AM",i=to24h(e,t,l),a=U[Q]??0;!1!==h&&triggerHaptic("notificationSuccess"),r?.({hour:i,minute:a}),W()},[R,G,q,Y,U,Q,l,r,W,h]),re=useMemo(()=>{const e=R[G]??0,t=U[Q]??0;if("24h"===l)return`${pad2(e)}:${pad2(t)}`;const i=q[Y]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[R,G,U,Q,q,Y,l]),ae=useMemo(()=>R.map(e=>({value:e,label:pad2(e),accessibilityLabel:$.hourItem(e)})),[R,$]),le=useMemo(()=>U.map(e=>({value:e,label:pad2(e),accessibilityLabel:$.minuteItem(e)})),[U,$]),se=useMemo(()=>q.map(e=>({value:e,label:e})),[q]),oe=useMemo(()=>{const e=[{key:"hour",label:$.hour,items:ae,value:R[G]??0,separator:":",testID:"time-picker-hour"},{key:"minute",label:$.minute,items:le,value:U[Q]??0,gapAfter:"12h"===l?O.space.md:void 0,testID:"time-picker-minute"}];return"12h"===l&&e.push({key:"period",label:$.period,items:se,value:q[Y]??"AM",testID:"time-picker-period"}),e},[ae,le,se,R,G,U,Q,q,Y,l,O.space.md,$]),ne=useCallback(e=>{if("24h"===l)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[l]),ue=!A&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(d??ne)(i):void 0,me=_jsxs(Modal,{visible:V,onClose:W,presentation:"bottom",accessibilityLabel:$.title,haptic:h,contentStyle:[m,u],testID:N,children:[_jsx(Text,{variant:"title",align:"center",accessibilityRole:"header",style:[z.title,c],children:$.title}),_jsx(View,{style:z.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:$.selected(re),children:_jsx(Text,{variant:"h2",weight:"bold",color:"brand",style:z.summary,children:re})}),_jsx(WheelPicker,{columns:oe,onChange:ee,haptic:h,style:z.wheels}),_jsxs(View,{style:z.footer,children:[_jsx(Button,{label:$.cancel,haptic:!1,variant:"ghost",tone:"neutral",onPress:te,style:[z.footerBtn,p],accessibilityHint:$.cancelHint,testID:"time-picker-cancel"}),_jsx(Button,{label:$.confirm,variant:"solid",tone:"primary",haptic:!1,onPress:ie,style:[z.footerBtn,p],accessibilityHint:$.confirmHint,testID:"time-picker-confirm"})]})]});return A?me:_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...B,labels:b,value:ue,onPress:()=>E(!0),testID:n}),me]})},buildStyles=e=>StyleSheet.create({title:{marginBottom:e.space.sm},summaryWrap:{alignItems:"center",marginBottom:e.space.md},summary:{letterSpacing:e["letter-spacing"].wide},wheels:{marginBottom:e.space.lg},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg}});export{TimePicker};export default TimePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,
|
|
1
|
+
"use strict";import React,{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{claimAnchoredSurface}from"../../utils/placement.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{FOCUS_DELAY_MS,focusHost}from"../Menu/focusHost.js";import{Modal}from"../Modal/index.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{RichTooltipBody}from"./RichTooltipBody.js";import{resolveTooltipPosition}from"./tooltipPosition.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_TOOLTIP_LABELS=Object.freeze({close:"Close tooltip",longPressHint:"Long press for more info",fallbackName:"Tooltip"});const PRESS_AUTO_HIDE_MS=4e3,ARROW_HALF_WIDTH=4,ARROW_HEIGHT=6,ARROW_CORNER_PADDING=12,DEFAULT_MAX_WIDTH=240,RICH_MAX_WIDTH=280,MESSAGE_LINE_HEIGHT=18,EXIT_DURATION_MS=150,Tooltip=e=>{const{content:t,children:o,variant:r="plain",title:s,action:n,placement:i="auto",visible:a,onVisibleChange:l,hideOnContentPress:u=!0,maxWidth:c,showArrow:m=!0,accessibilityLabel:f,style:p,containerStyle:d,arrowStyle:h,messageStyle:g,labels:b,testID:T}=e;warnInvalidValue("Tooltip","variant",e.variant,["plain","rich"]),warnInvalidValue("Tooltip","placement",e.placement,["top","bottom","left","right","auto"]),warnInvalidValue("Tooltip","trigger",e.trigger,["longPress","press","manual"]);const S="rich"===r,w=e.trigger??(S?"press":"longPress"),y=useMemo(()=>({...DEFAULT_TOOLTIP_LABELS,...b}),[b]),R=useTheme(),A=usePresenceMotion(),v=useSafeAreaInsets(),[_,x]=useModalInsets(),j=useMemo(()=>({...v,top:_.top,bottom:_.bottom}),[v,_]),C=useWindowDimensions(),E=useMemo(()=>buildStyles(R),[R]),I=R.space.sm,M=R.space.sm,P=c??(S?280:240),L="press"===w&&!S,O=(R.settings.components.tooltip?.enableScaleAnimation??!1)&&!A.reduced,V="manual"===w||"boolean"==typeof a,[D,H]=useState(!1),W=V?Boolean(a):D,[k,N]=useState(null),[F,B]=useState({width:0,height:0}),U=useRef(null),z=useRef(null),G=useRef(null),X=useRef(null),Y=useRef(null),q=useRef(!1),J=useRef(!1),K=useRef(createAnimatedValue(W||!O?1:.85)).current,Q=useRef(createAnimatedValue(W?1:0)).current,Z=useRef(null),$=useRef(!1),[ee,te]=useState(W),oe=useCallback(e=>{V||H(e),l?.(e)},[V,l]),re=useCallback(()=>{U.current&&U.current.measureInWindow((e,t,o,r)=>{N({x:e,y:t,width:o,height:r})})},[]),se=useCallback(e=>{re(),oe(!0)},[re,oe]),ne=useCallback(()=>{oe(!1)},[oe]),ie=useRef(ne);ie.current=ne;const ae=useCallback(()=>{if(!q.current)return;q.current=!1;const e=Y.current;Y.current=null,e?e():S&&focusHost(z.current??U.current)},[S]);useEffect(()=>{if(W)return J.current=!0,q.current=!1,claimAnchoredSurface(()=>ie.current());J.current&&(J.current=!1,q.current=!0)},[W]),useEffect(()=>{W&&te(!0)},[W]);const le=useCallback(()=>{Y.current=n?.onPress??null,ne()},[n,ne]);useEffect(()=>{if(!$.current)return $.current=!0,W&&(re(),L&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{ne()},4e3))),()=>{Z.current&&(clearTimeout(Z.current),Z.current=null)};let e;if(W){re();const t=[Animated.timing(Q,{toValue:1,duration:A.duration("fast"),useNativeDriver:!0})];O?t.push(Animated.spring(K,{toValue:1,damping:R.motion.spring.snappy.damping,stiffness:R.motion.spring.snappy.stiffness,mass:R.motion.spring.snappy.mass,useNativeDriver:!0})):setNativeValue(K,1),e=Animated.parallel(t),e.start(),L&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{ne()},4e3))}else{const t=[Animated.timing(Q,{toValue:0,duration:A.reduced?A.duration("fast"):150,easing:Easing.bezier(...R.motion.ease.accelerate),useNativeDriver:!0})];O&&t.push(Animated.timing(K,{toValue:.85,duration:150,easing:Easing.bezier(...R.motion.ease.accelerate),useNativeDriver:!0})),e=Animated.parallel(t),e.start(({finished:e})=>{e&&te(!1)}),Z.current&&(clearTimeout(Z.current),Z.current=null)}return()=>{e?.stop(),Z.current&&(clearTimeout(Z.current),Z.current=null)}},[W]);const handleContentLayout=e=>{const{width:t,height:o}=e.nativeEvent.layout;t===F.width&&o===F.height||B({width:t,height:o})},ue=useMemo(()=>resolveTooltipPosition({anchor:k,size:F,placement:i,rich:S,viewport:{width:C.width,height:C.height,insets:j},maxWidth:P,gap:I,padding:M,arrowCornerPadding:12}),[k,F,i,S,C.width,C.height,j,P,I,M]),ce=null!==k&&F.width>0,me=W&&ce;useEffect(()=>{if(!S||!me)return;const e="web"===Platform.OS?X:G,t=setTimeout(()=>focusHost(e.current),FOCUS_DELAY_MS);return()=>clearTimeout(t)},[S,me]),useEffect(()=>{!S&&me&&"ios"===Platform.OS&&"string"==typeof t&&announce(t)},[S,me,t]);const fe=o.props,pe=useMemo(()=>mergeRefs(fe.ref,z),[fe.ref]),de={};"longPress"!==w||fe.contextMenu?"press"===w&&(de.onPress=e=>{fe.onPress?.(e),se(e)}):(de.onLongPress=se,de.accessibilityHint=y.longPressHint),S&&(de.ref=pe);const he=React.cloneElement(o,de),ge=f??("string"==typeof t?t:y.fallbackName),be=useMemo(()=>{if(!m)return null;const e={position:"absolute",width:0,height:0,backgroundColor:"transparent",borderStyle:"solid",borderLeftWidth:4,borderRightWidth:4,borderBottomWidth:6,borderTopWidth:0,borderLeftColor:"transparent",borderRightColor:"transparent",borderTopColor:"transparent",borderBottomColor:S?R.colors.surface:R.colors["surface-inverse"]};return"top"===ue.placement?{...e,bottom:-6,left:ue.arrowOffset-4,transform:[{rotate:"180deg"}]}:"bottom"===ue.placement?{...e,top:-6,left:ue.arrowOffset-4}:"left"===ue.placement?{...e,right:-6,top:ue.arrowOffset-4,transform:[{rotate:"90deg"}]}:{...e,left:-6,top:ue.arrowOffset-4,transform:[{rotate:"-90deg"}]}},[m,ue,R,S]),Te={position:"absolute",top:ue.top,left:ue.left,maxWidth:P,opacity:W&&!ce?0:Q,transform:[{scale:K}]},Se=be?_jsx(View,{style:[be,h],pointerEvents:"none"}):null;return _jsxs(_Fragment,{children:[_jsx(View,{ref:U,collapsable:!1,onLayout:re,testID:T,children:he}),_jsxs(Modal,{visible:ee,onClose:ne,presentation:"fullScreen",bare:!0,backdropOpacity:0,backdropPressClose:u,haptic:!1,labels:{close:y.close},onInsetsChange:x,onDismissed:ae,children:[ee&&S?_jsxs(Animated.View,{onLayout:handleContentLayout,style:[Te,d,p],children:[_jsx(RichTooltipBody,{title:s,content:t,action:n,onAction:le,focusRef:G,actionRef:X,messageStyle:g}),Se]}):null,ee&&!S?_jsxs(Animated.View,{accessibilityRole:"web"===Platform.OS?"tooltip":void 0,accessibilityLiveRegion:"polite",accessibilityLabel:ge,onLayout:handleContentLayout,style:[Te,d,p],children:[_jsx(View,{style:[E.tooltip,{backgroundColor:R.colors["surface-inverse"],borderRadius:R.radius.md,...smoothCorners,paddingHorizontal:R.space.md,paddingVertical:R.space.sm,...R.shadow.popover,shadowColor:R.shadow.popover.shadowColor}],children:"string"==typeof t?_jsx(Text,{variant:"bodySmall",color:"inverse",style:{lineHeight:18,...StyleSheet.flatten(g)},children:t}):t}),Se]}):null]})]})},buildStyles=e=>StyleSheet.create({tooltip:{overflow:"hidden"}});export{Tooltip};export default Tooltip;
|