@webority/mobile-ui 0.163.0 → 0.165.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/LICENSE.txt +1 -1
- package/android/src/newarch/java/com/webority/mobileui/pdfrasterizer/PdfRasterizerModule.kt +4 -4
- package/dist/canvas-kit/kit.js +5 -5
- package/dist/canvas-kit/manifest.json +11 -1
- package/dist/canvas-kit/release.json +6 -6
- package/ios/PdfRasterizer.mm +3 -3
- package/lib/commonjs/components/Avatar/Avatar.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/Card/Card.js +1 -1
- package/lib/commonjs/components/Carousel/Carousel.js +1 -1
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
- package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/MessageBubble/MessageBubble.js +1 -1
- package/lib/commonjs/components/Modal/Modal.js +1 -1
- package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
- package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
- package/lib/commonjs/components/Screen/Screen.js +1 -1
- package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
- package/lib/commonjs/components/Slider/Slider.js +1 -1
- package/lib/commonjs/components/SliderField/SliderField.js +1 -1
- package/lib/commonjs/components/TagInput/TagInput.js +1 -1
- package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
- package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
- package/lib/commonjs/theme/merge.js +1 -1
- package/lib/commonjs/utils/warnUnknownProps.js +1 -1
- package/lib/module/components/Avatar/Avatar.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/Card/Card.js +1 -1
- package/lib/module/components/Carousel/Carousel.js +1 -1
- package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/module/components/FieldBase/FieldBase.js +1 -1
- package/lib/module/components/IconBadge/IconBadge.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/MessageBubble/MessageBubble.js +1 -1
- package/lib/module/components/Modal/Modal.js +1 -1
- package/lib/module/components/NumberInput/NumberInput.js +1 -1
- package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
- package/lib/module/components/Screen/Screen.js +1 -1
- package/lib/module/components/SearchBar/SearchBar.js +1 -1
- package/lib/module/components/Slider/Slider.js +1 -1
- package/lib/module/components/SliderField/SliderField.js +1 -1
- package/lib/module/components/TagInput/TagInput.js +1 -1
- package/lib/module/components/Tooltip/Tooltip.js +1 -1
- package/lib/module/hooks/useDragToDismiss.js +1 -1
- package/lib/module/theme/merge.js +1 -1
- package/lib/module/utils/warnUnknownProps.js +1 -1
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +1 -0
- package/lib/typescript/commonjs/components/Autocomplete/Autocomplete.d.ts +1 -1
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +2 -1
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +5 -4
- package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +2 -1
- package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +4 -4
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/lib/typescript/commonjs/components/Descriptions/Descriptions.d.ts +2 -2
- package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +1 -1
- package/lib/typescript/commonjs/components/FieldBase/Chevron.d.ts +1 -1
- package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +14 -13
- package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +10 -10
- package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +2 -2
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +1 -1
- package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +2 -2
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +2 -1
- package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +7 -7
- package/lib/typescript/commonjs/components/Input/Input.d.ts +3 -2
- package/lib/typescript/commonjs/components/Menu/Menu.d.ts +1 -1
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +2 -1
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +1 -0
- package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +5 -5
- package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -0
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -4
- package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +2 -1
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +1 -1
- package/lib/typescript/commonjs/components/Radio/RadioDot.d.ts +2 -2
- package/lib/typescript/commonjs/components/Repeater/Repeater.d.ts +2 -2
- package/lib/typescript/commonjs/components/RichTextEditor/markdownActions.d.ts +3 -3
- package/lib/typescript/commonjs/components/Screen/Screen.d.ts +1 -0
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +2 -1
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +1 -1
- package/lib/typescript/commonjs/components/Select/Select.d.ts +6 -6
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +3 -3
- package/lib/typescript/commonjs/components/Skeleton/SkeletonClock.d.ts +3 -3
- package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +6 -6
- package/lib/typescript/commonjs/components/Skeleton/SkeletonList.d.ts +2 -2
- package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +5 -5
- package/lib/typescript/commonjs/components/Skeleton/SkeletonSkip.d.ts +2 -2
- package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +1 -1
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +5 -0
- package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +1 -0
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +2 -2
- package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +2 -1
- package/lib/typescript/commonjs/components/Timeline/Timeline.d.ts +8 -8
- package/lib/typescript/commonjs/components/ZoomableImage/ZoomableImage.d.ts +4 -4
- package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +2 -0
- package/lib/typescript/commonjs/specs/NativePdfRasterizer.d.ts +4 -4
- package/lib/typescript/commonjs/theme/animatedValue.d.ts +4 -4
- package/lib/typescript/commonjs/theme/types.d.ts +9 -3
- package/lib/typescript/commonjs/utils/feedback.d.ts +3 -3
- package/lib/typescript/commonjs/utils/warnUnknownProps.d.ts +2 -2
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +1 -0
- package/lib/typescript/module/components/Autocomplete/Autocomplete.d.ts +1 -1
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +2 -1
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +5 -4
- package/lib/typescript/module/components/Carousel/Carousel.d.ts +2 -1
- package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +4 -4
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/lib/typescript/module/components/Descriptions/Descriptions.d.ts +2 -2
- package/lib/typescript/module/components/Drawer/Drawer.d.ts +1 -1
- package/lib/typescript/module/components/FieldBase/Chevron.d.ts +1 -1
- package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +14 -13
- package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +10 -10
- package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +2 -2
- package/lib/typescript/module/components/FormField/FormField.d.ts +1 -1
- package/lib/typescript/module/components/IconButton/IconButton.d.ts +2 -2
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +2 -1
- package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +7 -7
- package/lib/typescript/module/components/Input/Input.d.ts +3 -2
- package/lib/typescript/module/components/Menu/Menu.d.ts +1 -1
- package/lib/typescript/module/components/Modal/Modal.d.ts +2 -1
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +1 -0
- package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +5 -5
- package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -0
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -4
- package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +2 -1
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +1 -1
- package/lib/typescript/module/components/Radio/RadioDot.d.ts +2 -2
- package/lib/typescript/module/components/Repeater/Repeater.d.ts +2 -2
- package/lib/typescript/module/components/RichTextEditor/markdownActions.d.ts +3 -3
- package/lib/typescript/module/components/Screen/Screen.d.ts +1 -0
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +2 -1
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +1 -1
- package/lib/typescript/module/components/Select/Select.d.ts +6 -6
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +3 -3
- package/lib/typescript/module/components/Skeleton/SkeletonClock.d.ts +3 -3
- package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +6 -6
- package/lib/typescript/module/components/Skeleton/SkeletonList.d.ts +2 -2
- package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +5 -5
- package/lib/typescript/module/components/Skeleton/SkeletonSkip.d.ts +2 -2
- package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +1 -1
- package/lib/typescript/module/components/Slider/Slider.d.ts +5 -0
- package/lib/typescript/module/components/SliderField/SliderField.d.ts +1 -0
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +2 -2
- package/lib/typescript/module/components/TagInput/TagInput.d.ts +2 -1
- package/lib/typescript/module/components/Timeline/Timeline.d.ts +8 -8
- package/lib/typescript/module/components/ZoomableImage/ZoomableImage.d.ts +4 -4
- package/lib/typescript/module/hooks/useDragToDismiss.d.ts +2 -0
- package/lib/typescript/module/specs/NativePdfRasterizer.d.ts +4 -4
- package/lib/typescript/module/theme/animatedValue.d.ts +4 -4
- package/lib/typescript/module/theme/types.d.ts +9 -3
- package/lib/typescript/module/utils/feedback.d.ts +3 -3
- package/lib/typescript/module/utils/warnUnknownProps.d.ts +2 -2
- package/package.json +9 -10
- package/src/specs/NativePdfRasterizer.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{useDebounce}from"../../hooks/useDebounce.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldBase,FieldLabel,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{normalizeSuggestion,SearchRecents,SearchScopeBar,SearchSuggestions}from"./SearchPanel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SEARCH_BAR_LABELS=Object.freeze({placeholder:"Search…",recents:"Recent searches",clearAll:"Clear all",clearAllRecents:"Clear all recent searches",searchAgain:"Searches again",removeRecent:e=>`Remove ${e} from recent searches`,scope:"Search scope",clearSearch:"Clear search",searching:e=>`Searching ${e}`,suggestionCount:e=>1===e?"1 suggestion":`${e} suggestions`,removed:e=>`Removed ${e}`,recentsCleared:"Recent searches cleared"});const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=forwardRef((e,s)=>{const{value:l,onChangeText:a,onSubmit:t,onFocus:o,onBlur:r,placeholder:n,autoFocus:i=!1,disabled:c=!1,onClear:u,leftIcon:d,debounceMs:p,size:h="md",variant:b,radius:m,label:f,labelMode:S="top",labelStyle:g,scopes:v,scope:C,onScopeChange:x,recents:R,maxRecents:j=DEFAULT_PANEL_ROWS,onSelectRecent:y,onRemove:F,onClearRecents:_,suggestions:L,maxSuggestions:k=DEFAULT_PANEL_ROWS,onSelect:B,haptic:E,labels:A,style:V,inputStyle:T,accessibilityLabel:
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{useDebounce}from"../../hooks/useDebounce.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldBase,FieldLabel,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{normalizeSuggestion,SearchRecents,SearchScopeBar,SearchSuggestions}from"./SearchPanel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SEARCH_BAR_LABELS=Object.freeze({placeholder:"Search…",recents:"Recent searches",clearAll:"Clear all",clearAllRecents:"Clear all recent searches",searchAgain:"Searches again",removeRecent:e=>`Remove ${e} from recent searches`,scope:"Search scope",clearSearch:"Clear search",searching:e=>`Searching ${e}`,suggestionCount:e=>1===e?"1 suggestion":`${e} suggestions`,removed:e=>`Removed ${e}`,recentsCleared:"Recent searches cleared"});const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=forwardRef((e,s)=>{const{value:l,onChangeText:a,onSubmit:t,onFocus:o,onBlur:r,placeholder:n,autoFocus:i=!1,disabled:c=!1,onClear:u,leftIcon:d,debounceMs:p,size:h="md",variant:b,radius:m,label:f,labelMode:S="top",labelStyle:g,scopes:v,scope:C,onScopeChange:x,recents:R,maxRecents:j=DEFAULT_PANEL_ROWS,onSelectRecent:y,onRemove:F,onClearRecents:_,suggestions:L,maxSuggestions:k=DEFAULT_PANEL_ROWS,onSelect:B,haptic:E,labels:A,style:V,inputStyle:T,accessibilityLabel:I,testID:z,...H}=e;assertValidValue("SearchBar","size",e.size,["sm","md","lg"]),assertValidValue("SearchBar","variant",e.variant,["outline","filled","underline"]),assertValidValue("SearchBar","labelMode",e.labelMode,["top","float"]);const D=useTheme(),M=useMemo(()=>({...DEFAULT_SEARCH_BAR_LABELS,...A}),[A]),w=n??M.placeholder,P=b??D.settings.components["search-bar"]?.defaultVariant??D.settings.components.field?.defaultVariant??"filled",O="underline"===P,N=resolveFieldSize(D,h),U=m??D.components["search-bar"][h].radius,W=resolveFieldTextStyle(D,{disabled:c}),$=useRef(null),q=useMemo(()=>mergeRefs($,s),[s]),K=useCallback(()=>{c||$.current?.focus()},[c]),G=useMemo(()=>buildStyles(D),[D]),J="string"==typeof l?l:"",[Q,X]=useState(!1),Y=useCallback(e=>{X(!0),o?.(e)},[o]),Z=useCallback(e=>{X(!1),r?.(e)},[r]),[ee,se]=useState(J),le=useRef(ee);le.current=ee;const ae=useDebounce(ee,p??0);useEffect(()=>{void 0!==p&&J!==le.current&&se(J)},[J,p]);const te=useRef(J);useEffect(()=>{void 0!==p&&ae!==te.current&&(te.current=ae,a(ae))},[ae,p,a]);const oe=useCallback(e=>{void 0===p?a(e):se(e)},[p,a]),re=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e),void 0!==p&&(se(""),te.current=""),a(""),u?.()},[E,p,a,u]),ne=useCallback(()=>{t?.(void 0!==p?ee:J)},[t,p,ee,J]),ie=void 0!==p?ee:J,ce=ie.length>0,[ue,de]=useControllableState({value:C,defaultValue:v?.[0]?.value??"",onChange:x}),pe=useCallback(e=>{de(e);const s=v?.find(s=>s.value===e)?.label;s&&announce(M.searching(s))},[v,de,M]),[he,be]=useState(!1),me=useRef(null),fe=useCallback(()=>{me.current&&(clearTimeout(me.current),me.current=null)},[]),Se=useCallback(()=>{fe(),be(!0)},[fe]),ge=useCallback(()=>{fe(),me.current=setTimeout(()=>be(!1),50)},[fe]);useEffect(()=>fe,[fe]);const ve=!c&&(Q||he),Ce=useMemo(()=>(R??[]).slice(0,j),[R,j]),xe=useMemo(()=>(L??[]).slice(0,k).map(normalizeSuggestion),[L,k]),Re=ve&&!ce&&Ce.length>0,je=ve&&ce&&xe.length>0,ye=je?xe.length:0,Fe=ye>0?M.suggestionCount(ye):"";useEffect(()=>{Fe&&announce(Fe)},[Fe]);const Le=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e)},[E]),ke=useCallback(e=>{Le(),$.current?.blur(),be(!1),y?.(e)},[Le,y]),Be=useCallback(e=>{Le(),$.current?.blur(),be(!1),B?.(e)},[Le,B]),Ee=useCallback(e=>{Le(),F?.(e),announce(M.removed(e)),K()},[Le,F,K,M]),Ae=useCallback(()=>{Le(),_?.(),announce(M.recentsCleared),K()},[Le,_,K,M]),Ve={size:N.icon,color:c?D.colors["text-disabled"]:D.colors["text-subtle"],disabled:c},Te=d?renderSlotIcon(d,Ve):(D.settings.icons.search??defaultIcons.search)(Ve),Ie=_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:Te}),ze=Boolean(f)&&"float"===S,He=useFloatingLabel({label:f,enabled:ze,floated:Q||ce,variant:P,sizeTokens:N,leadingOffset:N.icon+D.space.md,trailingOffset:ce?N.icon+D.space.md:0,paddingLeft:O?D.space.none:N["padding-x"],color:D.colors["field-label"],style:g}),De=ce&&!c?_jsx(Pressable,{onPress:re,hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:M.clearSearch,children:(D.settings.icons.close??defaultIcons.close)({size:N.icon,color:D.colors["text-muted"]})}):null;return _jsxs(View,{style:V,testID:z,children:[f&&!ze?_jsx(FieldLabel,{size:h,style:g,children:f}):null,_jsx(View,{style:G.root,children:_jsxs(View,{style:G.fieldWrap,children:[_jsx(FieldBase,{testID:z?`${z}-field`:void 0,size:h,variant:P,focused:Q,disabled:c,filled:ce,minHeight:N["min-height"],paddingHorizontal:O?D.space.none:N["padding-x"],radius:U,leading:Ie,trailing:De,topNotch:He.topNotch,onPress:K,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:I??w,children:_jsx(TextInput,{ref:q,style:[G.input,{fontSize:N.text,color:W.color,...W.weightStyle},T],value:ie,onChangeText:oe,onSubmitEditing:ne,onFocus:Y,onBlur:Z,placeholder:!ze||Q||ce?w:void 0,placeholderTextColor:W.placeholderColor,autoFocus:i,editable:!c,returnKeyType:"search",selectionColor:resolveVariantColors(D,P).borderFocusedRepresentative,accessibilityLabel:I??w,accessibilityState:{disabled:c},"aria-disabled":c,...H})}),He.node]})}),v&&v.length>0?_jsx(SearchScopeBar,{scopes:v,scope:ue||(v[0]?.value??""),disabled:c,haptic:E,labels:M,onChange:pe}):null,Re?_jsx(SearchRecents,{recents:Ce,labels:M,onSelect:ke,onRemove:F?Ee:void 0,onClear:_?Ae:void 0,onHold:Se,onRelease:ge}):null,je?_jsx(SearchSuggestions,{suggestions:xe,query:ie,onSelect:Be,onHold:Se,onRelease:ge}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});export{SearchBar};export default SearchBar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Platform,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{scheduleOnRN}from"react-native-worklets";import{useControllableState}from"../../hooks/index.js";import{resolveSliderSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{sliderToneInk}from"./valueText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,s=String(i).split(".")[1]?.length??0,n=s>0?Number(r.toFixed(s)):r;return clamp(n,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),isPair=e=>Array.isArray(e),Slider=forwardRef((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:s=!1,tone:n="primary",size:o="md",variant:l="default",showLabel:u=!1,snapThumb:c=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:g,containerStyle:f,trackStyle:p,fillStyle:v,thumbStyle:w,labelStyle:y,thumbPressScale:S,labelShowDuration:k,labelOpacity:C,testID:x}=e;assertValidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",e.size,["sm","md","lg"]),assertValidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const A=useTheme(),V=useMemo(()=>{const e=resolveSliderSize(A,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[A,o]),j=useMemo(()=>"default"===l?V:VARIANT_SIZE_MAP[l][o],[V,o,l]),M="inset"===l?j.trackHeight/2:0,_=A.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,R=k??A.motion.duration.fast,H=C??1,E=useMemo(()=>buildStyles(A,j),[A,j]),O=useMemo(()=>({damping:A.motion.spring.snappy.damping,stiffness:A.motion.spring.snappy.stiffness,mass:A.motion.spring.snappy.mass}),[A.motion.spring.snappy]),[T,P]=useState(0),N=A.colors[n],I=sliderToneInk(A,n),W=!0===e.range,L=useCallback(t=>{if(!0!==e.range){if(Array.isArray(t))throw new Error("Slider received a range value in single mode.");e.onChange?.(t)}else{if(!Array.isArray(t))throw new Error("Slider received a single value in range mode.");e.onChange?.(t)}},[e.onChange,e.range]),[X,B]=useControllableState({value:e.value,defaultValue:e.defaultValue??(W?[a,i]:a),onChange:L}),F=useSharedValue(0),G=useSharedValue(0),z=useSharedValue(isPair(X)?X[0]:X),U=useSharedValue(isPair(X)?X[1]:X),Z=useSharedValue(0),$=useSharedValue(0),J=useSharedValue(1),q=useSharedValue(1),K="always"===u,Q=useSharedValue(K?1:0),Y=useSharedValue(K?1:0),ee=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(F),cancelAnimation(G),cancelAnimation(J),cancelAnimation(q),cancelAnimation(Q),cancelAnimation(Y)},[F,G,J,q,Q,Y]);const te=useCallback((e,t)=>{const r=t-2*M;return i===a||r<=0?M:M+(e-a)/(i-a)*r},[a,i,M]),ae=useCallback((e,t)=>{const s=t-2*M;if(s<=0)return a;const n=clamp((e-M)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,M]),ie=useRef(!1),re=A.motion.duration.fast,se=useRef(X);se.current=X;const ne=useRef(T);ne.current=T;const oe=useCallback((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:re,easing:Easing.out(Easing.cubic)}):t,a=se.current;if(isPair(a)){const[e,i]=a,r=Math.min(e,i),s=Math.max(e,i);z.value=r,U.value=s,F.value=place(te(r,t)),G.value=place(te(s,t))}else{const e=a;z.value=e,U.value=e,F.value=place(te(e,t))}},[te,z,U,F,G,re]),[le,ue]=useState(0),ce=useRef(!1),de=useCallback(e=>{ie.current=e,e||(ce.current=!0,ue(e=>e+1))},[]);useEffect(()=>{if(ie.current)return;const e=ce.current;ce.current=!1,oe(e)},[JSON.stringify(X),T,le,oe]);const me=useCallback(e=>{const t=e.nativeEvent.layout.width;$.value=t,P(t)},[$]),he=useCallback((e,t)=>{B(W?[e,t]:e)},[W,B]),be=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),ge=useRef(he);ge.current=he;const fe=useRef(be);fe.current=be;const pe=useCallback((e,t)=>ge.current(e,t),[]),ve=useCallback(()=>fe.current(),[]),we=Math.max(0,(44-j.thumbDiameter)/2),ye=we>0?we:void 0,Se=useCallback(e=>{const t="low"===e?F:G,n="low"===e?z:U,o="low"===e?U:z,l="low"===e?J:q,d="low"===e?Q:Y,m="low"===e,h=a,b=i,g=r,f=ee,p=W,v=D,w=_,y=!0===u,S=c,k=H,C=R,x=O,A=M,follow=e=>{"worklet";const a=$.value-2*A;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(Z.value+e,A),$.value-A);let r=h+(i-A)/a*(b-h);g>0&&(r=Math.round((r-h)/g)*g+h,r=Math.round(r*f)/f),r=Math.min(Math.max(r,h),b),p&&(m&&r>o.value&&(r=o.value),!m&&r<o.value&&(r=o.value)),t.value=S||b===h?b===h?A:A+(r-h)/(b-h)*a:p?m?Math.min(i,G.value):Math.max(i,F.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||scheduleOnRN(ve),scheduleOnRN(pe,z.value,U.value))};return{enabled:!s,minDistance:0,...void 0===ye?{}:{hitSlop:ye},onActivate:()=>{"worklet";scheduleOnRN(de,!0),Z.value=t.value,w&&(l.value=withSpring(v,x)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),scheduleOnRN(ve)},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,x)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))},onFinalize:()=>{"worklet";scheduleOnRN(de,!1)}}},[s,a,i,r,ee,W,D,_,u,c,H,R,O,M,ye,pe,ve,de,F,G,z,U,J,q,Q,Y,Z,$]),ke=useMemo(()=>Se("low"),[Se]),Ce=useMemo(()=>Se("high"),[Se]),xe=usePanGesture(ke),Ae=usePanGesture(Ce),Ve=useCallback(e=>{if(s||W||T<=0)return;const t=clamp(e.nativeEvent.locationX,0,T),a=ae(t,T);a!==z.value&&(be(),z.value=a,F.value=withTiming(te(a,T),{duration:A.motion.duration.fast,easing:Easing.out(Easing.cubic)}),he(a,a))},[s,W,T,ae,te,he,be,F,z,A.motion.duration.fast]),je=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*ee)/ee:t;if(W){const e=Math.round((z.value+n)*ee)/ee,t=clamp(e,a,U.value);t!==z.value&&(z.value=t,F.value=te(t,T),be(),he(t,U.value))}else{const e=Math.round((z.value+n)*ee)/ee,t=clamp(e,a,i);t!==z.value&&(z.value=t,F.value=te(t,T),be(),he(t,t))}},[s,r,ee,W,a,i,te,T,F,z,U,he,be]),Me=j.thumbDiameter/2,De=s?A.colors["surface-disabled"]:N,Re="inset"===l?{backgroundColor:De,borderColor:A.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:De,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:A.colors.surface,borderColor:De},He=useAnimatedStyle(()=>{const e=$.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=s?.55:1;if(W){const a=Math.max(0,G.value-F.value+2*M);return{opacity:t,transform:[{translateX:F.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:F.value+M-e},{scaleX:1}]}},[$,s,W,G,F,M]),Ee=useAnimatedStyle(()=>({transform:[{translateX:F.value-Me},{scale:J.value}]}),[F,Me,J]),Oe=useAnimatedStyle(()=>({transform:[{translateX:G.value-Me},{scale:q.value}]}),[G,Me,q]),Te=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),Pe=useAnimatedStyle(()=>({opacity:Y.value}),[Y]),clampDisplay=e=>clamp(e,a,i),Ne=clampDisplay(isPair(X)?Math.min(...X):X),Ie=clampDisplay(isPair(X)?Math.max(...X):X);return _jsx(View,{ref:t,style:[E.container,f,g],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:W?{min:a,max:i,now:Ne,text:`${Ne} to ${Ie}`}:{min:a,max:i,now:Ne},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:je,children:_jsx(Pressable,{onPress:Ve,disabled:s||W,style:E.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:E.trackWrap,onLayout:me,children:[_jsxs(View,{style:E.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[E.track,{backgroundColor:s?A.colors["surface-disabled"]:A.colors.border},p]}),_jsx(Animated.View,{style:[E.fill,{backgroundColor:s?A.colors["surface-disabled"]:N},v,He]})]}),_jsx(GestureDetector,{gesture:xe,children:_jsx(Animated.View,{style:[E.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Me,...smoothCorners,opacity:s?.55:1},Re,w,Ee],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[E.bubbleWrap,Te],pointerEvents:"none",children:[_jsx(View,{style:[E.bubble,{backgroundColor:N}],children:m?m(Ne):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:I},y],numberOfLines:1,children:d(Ne)})}),_jsx(View,{style:[E.bubbleCaret,{backgroundColor:N}]})]}):null})}),W?_jsx(GestureDetector,{gesture:Ae,children:_jsx(Animated.View,{style:[E.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Me,...smoothCorners,opacity:s?.55:1},Re,w,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[E.bubbleWrap,Pe],pointerEvents:"none",children:[_jsx(View,{style:[E.bubble,{backgroundColor:N}],children:m?m(Ie):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:I},y],numberOfLines:1,children:d(Ie)})}),_jsx(View,{style:[E.bubbleCaret,{backgroundColor:N}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,...smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,...smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,...smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,...smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,...smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",...Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};export{Slider};export default Slider;
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Platform,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{scheduleOnRN}from"react-native-worklets";import{useControllableState}from"../../hooks/index.js";import{resolveSliderSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{sliderToneInk}from"./valueText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,s=String(i).split(".")[1]?.length??0,n=s>0?Number(r.toFixed(s)):r;return clamp(n,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),isPair=e=>Array.isArray(e),Slider=forwardRef((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:s=!1,tone:n="primary",size:o="md",variant:l="default",showLabel:u=!1,snapThumb:c=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:g,containerStyle:p,trackStyle:f,fillStyle:v,thumbStyle:w,labelStyle:y,thumbPressScale:S,labelShowDuration:k,labelOpacity:C,testID:x}=e;assertValidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",e.size,["sm","md","lg"]),assertValidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const A=useTheme(),V=useMemo(()=>{const e=resolveSliderSize(A,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[A,o]),D=useMemo(()=>"default"===l?V:VARIANT_SIZE_MAP[l][o],[V,o,l]),j="inset"===l?D.trackHeight/2:0,M=A.settings.components.slider?.thumbPressAnimation??!1,_=S??1.1,R=k??A.motion.duration.fast,H=C??1,E=useMemo(()=>buildStyles(A,D),[A,D]),O=useMemo(()=>({damping:A.motion.spring.snappy.damping,stiffness:A.motion.spring.snappy.stiffness,mass:A.motion.spring.snappy.mass}),[A.motion.spring.snappy]),[T,I]=useState(0),P=A.colors[n],N=sliderToneInk(A,n),W=!0===e.range,L=useCallback(t=>{if(!0!==e.range){if(Array.isArray(t))throw new Error("Slider received a range value in single mode.");e.onChange?.(t)}else{if(!Array.isArray(t))throw new Error("Slider received a single value in range mode.");e.onChange?.(t)}},[e.onChange,e.range]),[X,B]=useControllableState({value:e.value,defaultValue:e.defaultValue??(W?[a,i]:a),onChange:L}),F=useSharedValue(0),G=useSharedValue(0),z=useSharedValue(isPair(X)?X[0]:X),$=useSharedValue(isPair(X)?X[1]:X),U=useSharedValue(0),Z=useSharedValue(0),J=useSharedValue(1),q=useSharedValue(1),K="always"===u,Q=useSharedValue(K?1:0),Y=useSharedValue(K?1:0),ee=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(F),cancelAnimation(G),cancelAnimation(J),cancelAnimation(q),cancelAnimation(Q),cancelAnimation(Y)},[F,G,J,q,Q,Y]);const te=useCallback((e,t)=>{const r=t-2*j;return i===a||r<=0?j:j+(e-a)/(i-a)*r},[a,i,j]),ae=useCallback((e,t)=>{const s=t-2*j;if(s<=0)return a;const n=clamp((e-j)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,j]),ie=useRef(!1),re=A.motion.duration.fast,se=useRef(X);se.current=X;const ne=useRef(T);ne.current=T;const oe=useCallback((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:re,easing:Easing.out(Easing.cubic)}):t,a=se.current;if(isPair(a)){const[e,i]=a,r=Math.min(e,i),s=Math.max(e,i);z.value=r,$.value=s,F.value=place(te(r,t)),G.value=place(te(s,t))}else{const e=a;z.value=e,$.value=e,F.value=place(te(e,t))}},[te,z,$,F,G,re]),[le,ue]=useState(0),ce=useRef(!1),de=useCallback(e=>{ie.current=e,e||(ce.current=!0,ue(e=>e+1))},[]);useEffect(()=>{if(ie.current)return;const e=ce.current;ce.current=!1,oe(e)},[JSON.stringify(X),T,le,oe]);const me=useCallback(e=>{const t=e.nativeEvent.layout.width;Z.value=t,I(t)},[Z]),he=useCallback((e,t)=>{B(W?[e,t]:e)},[W,B]),be=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),ge=useRef(he);ge.current=he;const pe=useRef(be);pe.current=be;const fe=useCallback((e,t)=>ge.current(e,t),[]),ve=useCallback(()=>pe.current(),[]),we=Math.max(0,(44-D.thumbDiameter)/2),ye=we>0?we:void 0,Se=useCallback(e=>{const t="low"===e?F:G,n="low"===e?z:$,o="low"===e?$:z,l="low"===e?J:q,d="low"===e?Q:Y,m="low"===e,h=a,b=i,g=r,p=ee,f=W,v=_,w=M,y=!0===u,S=c,k=H,C=R,A=O,V=j,D=m&&x?`${x}-pan`:void 0,follow=e=>{"worklet";const a=Z.value-2*V;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(U.value+e,V),Z.value-V);let r=h+(i-V)/a*(b-h);g>0&&(r=Math.round((r-h)/g)*g+h,r=Math.round(r*p)/p),r=Math.min(Math.max(r,h),b),f&&(m&&r>o.value&&(r=o.value),!m&&r<o.value&&(r=o.value)),t.value=S||b===h?b===h?V:V+(r-h)/(b-h)*a:f?m?Math.min(i,G.value):Math.max(i,F.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||scheduleOnRN(ve),scheduleOnRN(fe,z.value,$.value))};return{enabled:!s,minDistance:0,testID:D,...void 0===ye?{}:{hitSlop:ye},onActivate:()=>{"worklet";scheduleOnRN(de,!0),U.value=t.value,w&&(l.value=withSpring(v,A)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),scheduleOnRN(ve)},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,A)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))},onFinalize:()=>{"worklet";scheduleOnRN(de,!1)}}},[s,a,i,r,ee,W,_,M,u,c,H,R,O,j,ye,x,fe,ve,de,F,G,z,$,J,q,Q,Y,U,Z]),ke=useMemo(()=>Se("low"),[Se]),Ce=useMemo(()=>Se("high"),[Se]),xe=usePanGesture(ke),Ae=usePanGesture(Ce),Ve=useCallback(e=>{if(s||W||T<=0)return;const t=clamp(e.nativeEvent.locationX,0,T),a=ae(t,T);a!==z.value&&(be(),z.value=a,F.value=withTiming(te(a,T),{duration:A.motion.duration.fast,easing:Easing.out(Easing.cubic)}),he(a,a))},[s,W,T,ae,te,he,be,F,z,A.motion.duration.fast]),De=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*ee)/ee:t;if(W){const e=Math.round((z.value+n)*ee)/ee,t=clamp(e,a,$.value);t!==z.value&&(z.value=t,F.value=te(t,T),be(),he(t,$.value))}else{const e=Math.round((z.value+n)*ee)/ee,t=clamp(e,a,i);t!==z.value&&(z.value=t,F.value=te(t,T),be(),he(t,t))}},[s,r,ee,W,a,i,te,T,F,z,$,he,be]),je=D.thumbDiameter/2,Me=s?A.colors["surface-disabled"]:P,Re="inset"===l?{backgroundColor:Me,borderColor:A.colors.surface,borderWidth:Math.max(2,Math.round(.3*D.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Me,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:A.colors.surface,borderColor:Me},He=useAnimatedStyle(()=>{const e=Z.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=s?.55:1;if(W){const a=Math.max(0,G.value-F.value+2*j);return{opacity:t,transform:[{translateX:F.value-j},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:F.value+j-e},{scaleX:1}]}},[Z,s,W,G,F,j]),Ee=useAnimatedStyle(()=>({transform:[{translateX:F.value-je},{scale:J.value}]}),[F,je,J]),Oe=useAnimatedStyle(()=>({transform:[{translateX:G.value-je},{scale:q.value}]}),[G,je,q]),Te=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),Ie=useAnimatedStyle(()=>({opacity:Y.value}),[Y]),clampDisplay=e=>clamp(e,a,i),Pe=clampDisplay(isPair(X)?Math.min(...X):X),Ne=clampDisplay(isPair(X)?Math.max(...X):X);return _jsx(View,{ref:t,style:[E.container,p,g],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:W?{min:a,max:i,now:Pe,text:`${Pe} to ${Ne}`}:{min:a,max:i,now:Pe},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:De,children:_jsx(Pressable,{onPress:Ve,disabled:s||W,style:E.trackTouch,testID:x?`${x}-track-press`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:E.trackWrap,onLayout:me,testID:x?`${x}-track`:void 0,children:[_jsxs(View,{style:E.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[E.track,{backgroundColor:s?A.colors["surface-disabled"]:A.colors.border},f]}),_jsx(Animated.View,{style:[E.fill,{backgroundColor:s?A.colors["surface-disabled"]:P},v,He],testID:x?`${x}-fill`:void 0})]}),_jsx(GestureDetector,{gesture:xe,children:_jsx(Animated.View,{style:[E.thumb,{width:D.thumbDiameter,height:D.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},Re,w,Ee],testID:x?`${x}-thumb`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[E.bubbleWrap,Te],pointerEvents:"none",children:[_jsx(View,{style:[E.bubble,{backgroundColor:P}],children:m?m(Pe):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:N},y],numberOfLines:1,children:d(Pe)})}),_jsx(View,{style:[E.bubbleCaret,{backgroundColor:P}]})]}):null})}),W?_jsx(GestureDetector,{gesture:Ae,children:_jsx(Animated.View,{style:[E.thumb,{width:D.thumbDiameter,height:D.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},Re,w,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[E.bubbleWrap,Ie],pointerEvents:"none",children:[_jsx(View,{style:[E.bubble,{backgroundColor:P}],children:m?m(Ne):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:N},y],numberOfLines:1,children:d(Ne)})}),_jsx(View,{style:[E.bubbleCaret,{backgroundColor:P}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,...smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,...smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,...smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,...smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,...smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",...Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};export{Slider};export default Slider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{AppIcon,renderSlotIcon}from"../AppIcon/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{Slider}from"../Slider/index.js";import{CountingText,clampValue,sliderToneInk,snapValue,useValueDraft}from"../Slider/valueText.js";import{Text}from"../Text/index.js";import{Tooltip}from"../Tooltip/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SLIDER_FIELD_LABELS=Object.freeze({about:e=>`About ${e}`,decrease:"Decrease",increase:"Increase",fallbackName:"Value",low:e=>`${e} low`,high:e=>`${e} high`,current:e=>`${e} value`});const DEFAULT_INPUT_WIDTH=72,defaultFormatValue=e=>String(e),stepDecimals=e=>String(e).split(".")[1]?.length??0,ValueBox=({draft:e,error:l,disabled:t,width:i,accessibilityLabel:a,styles:s,style:r,testID:o})=>{const
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{AppIcon,renderSlotIcon}from"../AppIcon/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{Slider}from"../Slider/index.js";import{CountingText,clampValue,sliderToneInk,snapValue,useValueDraft}from"../Slider/valueText.js";import{Text}from"../Text/index.js";import{Tooltip}from"../Tooltip/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SLIDER_FIELD_LABELS=Object.freeze({about:e=>`About ${e}`,decrease:"Decrease",increase:"Increase",fallbackName:"Value",low:e=>`${e} low`,high:e=>`${e} high`,current:e=>`${e} value`});const DEFAULT_INPUT_WIDTH=72,defaultFormatValue=e=>String(e),stepDecimals=e=>String(e).split(".")[1]?.length??0,ValueBox=({draft:e,error:l,disabled:t,width:i,accessibilityLabel:a,styles:s,style:r,testID:o,fieldTestID:n})=>{const d=useTheme(),c=resolveFieldSize(d,"sm"),u=resolveFieldTextStyle(d,{disabled:t}),m=useRef(null),p=useCallback(()=>{t||m.current?.focus()},[t]);return _jsx(FieldBase,{testID:n,size:"sm",focused:e.editing,disabled:t,error:l,filled:!0,width:i,onPress:p,pressFeedback:!1,paddingHorizontal:d.space.sm,gap:d.space.xs,trailing:l?_jsx(AppIcon,{name:"info-circle",size:c.icon,color:d.colors["danger-text"]}):void 0,style:r,children:_jsx(TextInput,{ref:m,style:[s.boxInput,{color:u.color,fontSize:c.text,...u.weightStyle}],value:e.text,onChangeText:e.onChangeText,onFocus:e.onFocus,onBlur:e.onBlur,onSubmitEditing:e.onBlur,editable:!t,keyboardType:"decimal-pad",returnKeyType:"done",textAlign:"center",selectionColor:d.colors.primary,accessibilityLabel:a,accessibilityState:{disabled:t},"aria-disabled":t,testID:o})})},SliderField=forwardRef((e,l)=>{const{label:t,unit:i,info:a,required:s=!1,helperText:r,error:o,min:n=0,max:d=100,step:c=1,disabled:u=!1,tone:m="primary",size:p,variant:b,haptic:x,showBubble:h=!0,showBounds:f=!0,showInput:y=!1,showStepper:g=!1,leftIcon:I,rightIcon:S,startLabel:j,endLabel:v,formatValue:T=defaultFormatValue,parseInput:w,animationDuration:F,inputWidth:V=DEFAULT_INPUT_WIDTH,labels:_,accessibilityLabel:D,style:L,labelStyle:B,boundStyle:z,sliderStyle:A,inputStyle:C,testID:k}=e;assertValidValue("SliderField","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SliderField","size",e.size,["sm","md","lg"]),assertValidValue("SliderField","variant",e.variant,["default","inset","minimal","bar"]);const $=useMemo(()=>({...DEFAULT_SLIDER_FIELD_LABELS,..._}),[_]),E=useTheme(),M=useMemo(()=>buildStyles(E),[E]),R=F??E.motion.duration.fast,P=!0===e.range,N=!0===o||hasFieldText(o),W=stepDecimals(c),U=useCallback(l=>{if(!0!==e.range){if(Array.isArray(l))throw new Error("SliderField received a range value in single mode.");e.onChange?.(l)}else{if(!Array.isArray(l))throw new Error("SliderField received a single value in range mode.");e.onChange?.(l)}},[e.onChange,e.range]),[H,q]=useControllableState({value:e.value,defaultValue:e.defaultValue??(P?[n,d]:n),onChange:U}),[K,O]=Array.isArray(H)?H:[H,d],G=clampValue(Math.min(K,O),n,d),J=clampValue(Math.max(K,O),n,d),Q=useValueDraft({value:G,min:n,max:d,step:c,format:T,parse:w,onChange:e=>q(P?[Math.min(e,J),J]:e)}),X=useValueDraft({value:J,min:n,max:d,step:c,format:T,parse:w,onChange:e=>q([G,Math.max(e,G)])}),stepBy=e=>{const l=snapValue(G+e*c,n,d,c);l!==G&&q(l)},Y={color:u?E.colors["text-disabled"]:E.colors["text-muted"],size:resolveFieldSize(E,"md").icon,disabled:u},Z=[M.bubbleText,{color:sliderToneInk(E,m)}],boundText=e=>_jsx(Text,{variant:"bodySmall",style:[M.bound,{color:u?E.colors["text-disabled"]:E.colors["text-muted"]},z],children:e}),ee={min:n,max:d,step:c,disabled:u,tone:m,size:p,variant:b,haptic:x,showLabel:!!h&&"always",renderLabel:h?e=>_jsx(CountingText,{value:e,format:T,decimals:W,duration:R,style:Z,testID:k&&!P?`${k}-bubble`:void 0}):void 0,accessibilityLabel:D??t,style:A,testID:k?`${k}-slider`:void 0};return _jsxs(View,{ref:l,style:[M.container,L],testID:k,children:[t?_jsxs(View,{style:M.labelRow,children:[_jsx(FieldLabel,{required:s,style:B,children:t}),i?_jsx(Text,{variant:"caption",style:{color:E.colors["text-subtle"]},children:i}):null,a?_jsx(Tooltip,{content:a,trigger:"press",placement:"top",children:_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:$.about(t),hitSlop:8,...hitSlopMarker(8),style:M.infoButton,children:_jsx(AppIcon,{name:"info-circle",variant:"bold",size:16,color:E.colors["text-subtle"]})})}):null]}):null,_jsxs(View,{style:[M.row,h?M.rowWithBubble:null],children:[I?_jsx(View,{children:renderSlotIcon(I,Y)}):null,g&&!P?_jsx(IconButton,{icon:e=>_jsx(AppIcon,{name:"minus",size:e.size,color:e.color}),onPress:()=>stepBy(-1),accessibilityLabel:$.decrease,variant:"ghost",tone:"neutral",size:"sm",disabled:u||G<=n,haptic:x,testID:k?`${k}-minus`:void 0}):null,P&&y?_jsx(ValueBox,{draft:Q,error:N,disabled:u,width:V,accessibilityLabel:$.low(t??$.fallbackName),styles:M,style:C,testID:k?`${k}-input-low`:void 0,fieldTestID:k?`${k}-field-low`:void 0}):f?boundText(j??T(n)):null,_jsx(View,{style:M.sliderWrap,children:_jsx(Slider,P?{...ee,range:!0,value:[G,J],onChange:q}:{...ee,value:G,onChange:q})}),P&&y?_jsx(ValueBox,{draft:X,error:N,disabled:u,width:V,accessibilityLabel:$.high(t??$.fallbackName),styles:M,style:C,testID:k?`${k}-input-high`:void 0,fieldTestID:k?`${k}-field-high`:void 0}):f?boundText(v??T(d)):null,g&&!P?_jsx(IconButton,{icon:e=>_jsx(AppIcon,{name:"add",size:e.size,color:e.color}),onPress:()=>stepBy(1),accessibilityLabel:$.increase,variant:"ghost",tone:"neutral",size:"sm",disabled:u||G>=d,haptic:x,testID:k?`${k}-plus`:void 0}):null,S?_jsx(View,{children:renderSlotIcon(S,Y)}):null,!P&&y?_jsx(ValueBox,{draft:Q,error:N,disabled:u,width:V,accessibilityLabel:$.current(t??$.fallbackName),styles:M,style:C,testID:k?`${k}-input`:void 0,fieldTestID:k?`${k}-field`:void 0}):null]}),_jsx(FieldMessage,{text:N?o:r,error:N})]})});SliderField.displayName="SliderField";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",gap:e.space.xs},infoButton:{marginLeft:e.space.xxs},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},rowWithBubble:{marginTop:e.space.lg},sliderWrap:{flex:1,paddingHorizontal:e.space.sm},bound:{fontVariant:["tabular-nums"]},bubbleText:{fontVariant:["tabular-nums"]},boxInput:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});export{SliderField};export default SliderField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fontFor,useTheme}from"../../theme/index.js";import{mergeRefs,resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{Chip}from"../Chip/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,RequiredPlaceholder}from"../FieldBase/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const TagInput=forwardRef((e,t)=>{const{value:s,defaultValue:l,onChange:a,placeholder:i,label:r,helperText:o,error:n,required:u,disabled:d=!1,size:c="md",variant:p,maxTags:m,unique:x=!0,transform:f,separators:h=[","],haptic:g,onFocus:b,style:j,testID:
|
|
1
|
+
"use strict";import{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fontFor,useTheme}from"../../theme/index.js";import{mergeRefs,resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{Chip}from"../Chip/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,RequiredPlaceholder}from"../FieldBase/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const TagInput=forwardRef((e,t)=>{const{value:s,defaultValue:l,onChange:a,placeholder:i,label:r,helperText:o,error:n,required:u,disabled:d=!1,size:c="md",variant:p,maxTags:m,unique:x=!0,transform:f,separators:h=[","],haptic:g,onFocus:b,style:j,testID:v}=e;assertValidValue("TagInput","size",e.size,["sm","md","lg"]),assertValidValue("TagInput","variant",e.variant,["outline","filled","underline"]);const y=useTheme(),C=useMemo(()=>buildStyles(y),[y]),[T,F]=useControllableState({value:s,defaultValue:l??[],onChange:a}),[S,V]=useState(""),[w,I]=useState(!1),k=useRef(null),z=useMemo(()=>mergeRefs(k,t),[t]),_=useCallback(()=>{d||k.current?.focus()},[d]),B="number"==typeof m&&T.length>=m,R=!0===n||hasFieldText(n),H=u&&!r&&0===T.length&&0===S.length&&Boolean(i),M=useCallback(e=>{const t=f?f(e.trim()):e.trim();if(!t)return;if(B)return;if(x&&T.some(e=>e.toLowerCase()===t.toLowerCase()))return void V("");F([...T,t]),V("");const s=resolveHaptic(g,"selection");s&&triggerHaptic(s)},[B,g,F,T,f,x]),q=useCallback(e=>{const t=T.filter((t,s)=>s!==e);F(t);const s=resolveHaptic(g,"selection");s&&triggerHaptic(s)},[g,F,T]),D=useCallback(e=>{const t=h.find(t=>t.length>0&&e.includes(t));t?M(e.slice(0,e.indexOf(t))):V(e)},[M,h]),L=useCallback(e=>{d||"Backspace"===e.nativeEvent.key&&""===S&&T.length>0&&q(T.length-1)},[d,S,q,T.length]),P=useMemo(()=>T.map((e,t)=>({key:`${e}-${t}`,tag:e,index:t})),[T]),$=_jsx(FieldBase,{testID:v?`${v}-field`:void 0,size:c,variant:p,focused:w,disabled:d,error:R,filled:T.length>0||S.length>0,onPress:_,pressFeedback:!1,style:j,children:_jsxs(View,{style:C.wrap,children:[P.map(({key:e,tag:t,index:s})=>_jsx(Chip,{label:t,size:"sm",onRemove:d?void 0:()=>q(s),haptic:g},e)),_jsxs(View,{style:C.inputBox,children:[_jsx(TextInput,{ref:z,value:S,onChangeText:D,onKeyPress:L,onSubmitEditing:()=>M(S),onFocus:e=>{I(!0),b?.(e)},onBlur:()=>{I(!1),M(S)},editable:!d&&!B,placeholder:B||H?void 0:i,placeholderTextColor:y.colors["text-subtle"],submitBehavior:"submit",returnKeyType:"done",accessibilityLabel:r??i,style:[C.input,{color:y.colors["text-body"],fontSize:y.text.base.size}],testID:v?`${v}-input`:void 0}),H?_jsx(RequiredPlaceholder,{text:i??"",color:y.colors["text-subtle"],fontSize:y.text.base.size,weightStyle:fontFor(y,"normal")}):null]})]})});return _jsxs(View,{testID:v,children:[r?_jsx(FieldLabel,{size:c,required:u,children:r}):null,$,_jsx(FieldMessage,{size:c,error:R,text:R?n:o})]})});TagInput.displayName="TagInput";const buildStyles=e=>StyleSheet.create({wrap:{flex:1,flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,paddingVertical:e.space.xs},inputBox:{flexGrow:1,minWidth:80},input:{...fontFor(e,"normal"),padding:e.space.none}});export default TagInput;
|
|
@@ -1 +1 @@
|
|
|
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{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{claimAnchoredSurface}from"../../utils/placement.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:r,variant:o="plain",title:s,action:n,placement:i="auto",open:a,onOpenChange:l,hideOnContentPress:u=!0,maxWidth:c,showArrow:m=!0,accessibilityLabel:d,style:p,containerStyle:f,arrowStyle:h,messageStyle:g,labels:b,testID:T}=e;assertValidValue("Tooltip","variant",e.variant,["plain","rich"]),assertValidValue("Tooltip","placement",e.placement,["top","bottom","left","right","auto"]),assertValidValue("Tooltip","trigger",e.trigger,["longPress","press","manual"]);const v="rich"===o,S=e.trigger??(v?"press":"longPress"),A=useMemo(()=>({...DEFAULT_TOOLTIP_LABELS,...b}),[b]),R=useTheme(),y=usePresenceMotion(),_=useSafeAreaInsets(),[w,j]=useModalInsets(),x=useMemo(()=>({..._,top:w.top,bottom:w.bottom}),[_,w]),C=useWindowDimensions(),
|
|
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{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{claimAnchoredSurface}from"../../utils/placement.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:r,variant:o="plain",title:s,action:n,placement:i="auto",open:a,onOpenChange:l,hideOnContentPress:u=!0,maxWidth:c,showArrow:m=!0,accessibilityLabel:d,style:p,containerStyle:f,arrowStyle:h,messageStyle:g,labels:b,testID:T}=e;assertValidValue("Tooltip","variant",e.variant,["plain","rich"]),assertValidValue("Tooltip","placement",e.placement,["top","bottom","left","right","auto"]),assertValidValue("Tooltip","trigger",e.trigger,["longPress","press","manual"]);const v="rich"===o,S=e.trigger??(v?"press":"longPress"),A=useMemo(()=>({...DEFAULT_TOOLTIP_LABELS,...b}),[b]),R=useTheme(),y=usePresenceMotion(),_=useSafeAreaInsets(),[w,j]=useModalInsets(),x=useMemo(()=>({..._,top:w.top,bottom:w.bottom}),[_,w]),C=useWindowDimensions(),D=useMemo(()=>buildStyles(R),[R]),E=R.space.sm,M=R.space.sm,P=c??(v?280:240),V="press"===S&&!v,H=(R.settings.components.tooltip?.enableScaleAnimation??!1)&&!y.reduced,L="manual"===S||"boolean"==typeof a,[O,I]=useState(!1),W=L?Boolean(a):O,[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||!H?1:.85)).current,Q=useRef(createAnimatedValue(W?1:0)).current,Z=useRef(null),$=useRef(!1),[ee,te]=useState(W),re=useCallback(e=>{L||I(e),l?.(e)},[L,l]),oe=useCallback(()=>{U.current&&U.current.measureInWindow((e,t,r,o)=>{N({x:e,y:t,width:r,height:o})})},[]),se=useCallback(e=>{oe(),re(!0)},[oe,re]),ne=useCallback(()=>{re(!1)},[re]),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():v&&focusHost(z.current??U.current)},[v]);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]),ue=useRef({autoHide:V,scaleAnimates:H,presence:y,theme:R,handleHide:ne});ue.current={autoHide:V,scaleAnimates:H,presence:y,theme:R,handleHide:ne},useEffect(()=>{const{autoHide:e,scaleAnimates:t,presence:r,theme:o,handleHide:s}=ue.current;if(!$.current)return $.current=!0,W&&(oe(),e&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{s()},4e3))),()=>{Z.current&&(clearTimeout(Z.current),Z.current=null)};let n;if(W){oe();const i=[Animated.timing(Q,{toValue:1,duration:r.duration("fast"),useNativeDriver:nativeDriver})];t?i.push(Animated.spring(K,{toValue:1,damping:o.motion.spring.snappy.damping,stiffness:o.motion.spring.snappy.stiffness,mass:o.motion.spring.snappy.mass,useNativeDriver:nativeDriver})):setNativeValue(K,1),n=Animated.parallel(i),n.start(),e&&(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{s()},4e3))}else{const e=[Animated.timing(Q,{toValue:0,duration:r.reduced?r.duration("fast"):150,easing:Easing.bezier(...o.motion.ease.accelerate),useNativeDriver:nativeDriver})];t&&e.push(Animated.timing(K,{toValue:.85,duration:150,easing:Easing.bezier(...o.motion.ease.accelerate),useNativeDriver:nativeDriver})),n=Animated.parallel(e),n.start(({finished:e})=>{e&&te(!1)}),Z.current&&(clearTimeout(Z.current),Z.current=null)}return()=>{n?.stop(),Z.current&&(clearTimeout(Z.current),Z.current=null)}},[W,oe,Q,K]);const handleContentLayout=e=>{const{width:t,height:r}=e.nativeEvent.layout;t===F.width&&r===F.height||B({width:t,height:r})},ce=useMemo(()=>resolveTooltipPosition({anchor:k,size:F,placement:i,rich:v,viewport:{width:C.width,height:C.height,insets:x},maxWidth:P,gap:E,padding:M,arrowCornerPadding:12}),[k,F,i,v,C.width,C.height,x,P,E,M]),me=null!==k&&F.width>0,de=W&&me;useEffect(()=>{if(!v||!de)return;const e="web"===Platform.OS?X:G,t=setTimeout(()=>focusHost(e.current),FOCUS_DELAY_MS);return()=>clearTimeout(t)},[v,de]),useEffect(()=>{!v&&de&&"ios"===Platform.OS&&"string"==typeof t&&announce(t)},[v,de,t]);const pe=r.props,fe=useMemo(()=>mergeRefs(pe.ref,z),[pe.ref]),he={};"longPress"!==S||pe.contextMenu?"press"===S&&(he.onPress=e=>{pe.onPress?.(e),se(e)}):(he.onLongPress=se,he.accessibilityHint=A.longPressHint),v&&(he.ref=fe);const ge=React.cloneElement(r,he),be=d??("string"==typeof t?t:A.fallbackName),Te=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:v?R.colors.surface:R.colors["surface-inverse"]};return"top"===ce.placement?{...e,bottom:-6,left:ce.arrowOffset-4,transform:[{rotate:"180deg"}]}:"bottom"===ce.placement?{...e,top:-6,left:ce.arrowOffset-4}:"left"===ce.placement?{...e,right:-6,top:ce.arrowOffset-4,transform:[{rotate:"90deg"}]}:{...e,left:-6,top:ce.arrowOffset-4,transform:[{rotate:"-90deg"}]}},[m,ce,R,v]),ve={position:"absolute",top:ce.top,left:ce.left,maxWidth:P,opacity:W&&!me?0:Q,transform:[{scale:K}]},Se=Te?_jsx(View,{style:[Te,h],pointerEvents:"none"}):null;return _jsxs(_Fragment,{children:[_jsx(View,{ref:U,collapsable:!1,onLayout:oe,testID:T,children:ge}),_jsxs(Modal,{open:ee,onClose:ne,presentation:"fullScreen",bare:!0,backdropOpacity:0,backdropPressClose:u,haptic:!1,labels:{close:A.close},onInsetsChange:j,onDismissed:ae,testID:T,children:[ee&&v?_jsxs(Animated.View,{onLayout:handleContentLayout,style:[ve,f,p],children:[_jsx(RichTooltipBody,{title:s,content:t,action:n,onAction:le,focusRef:G,actionRef:X,messageStyle:g}),Se]}):null,ee&&!v?_jsxs(Animated.View,{accessibilityRole:"web"===Platform.OS?"tooltip":void 0,accessibilityLiveRegion:"polite",accessibilityLabel:be,onLayout:handleContentLayout,style:[ve,f,p],children:[_jsx(View,{style:[D.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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo,useRef}from"react";import{Animated,Easing}from"react-native";import{usePanGesture}from"react-native-gesture-handler";import{createAnimatedValue,setNativeValue,useTheme}from"../theme/index.js";import{nativeDriver}from"../utils/nativeDriver.js";import{usePresenceMotion}from"./usePresenceMotion.js";export const DRAG_DISMISS_DISTANCE=100;export const DRAG_DISMISS_VELOCITY=.5;export const createDragToDismissController=({drag:e,travel:t,onDismiss:a,opacity:i},r
|
|
1
|
+
"use strict";import{useMemo,useRef}from"react";import{Animated,Easing}from"react-native";import{usePanGesture}from"react-native-gesture-handler";import{createAnimatedValue,setNativeValue,useTheme}from"../theme/index.js";import{nativeDriver}from"../utils/nativeDriver.js";import{usePresenceMotion}from"./usePresenceMotion.js";export const DRAG_DISMISS_DISTANCE=100;export const DRAG_DISMISS_VELOCITY=.5;export const createDragToDismissController=({drag:e,travel:t,onDismiss:a,opacity:i},s,r)=>{const{snappy:n}=s.spring,springBack=()=>Animated.spring(e,{toValue:0,damping:n.damping,stiffness:n.stiffness,mass:n.mass,useNativeDriver:nativeDriver}).start(),o=!0===r?.reduced?i:void 0,u=r?.duration("default")??s.duration.default;return{move:t=>{setNativeValue(e,Math.max(0,t))},release:(i,r)=>{if(i>100||r>.5){if(o)return void Animated.timing(o,{toValue:0,duration:u,easing:Easing.bezier(...s.ease.accelerate),useNativeDriver:nativeDriver}).start(()=>a());Animated.timing(e,{toValue:"function"==typeof t?t():t,duration:s.duration.fast,easing:Easing.bezier(...s.ease.accelerate),useNativeDriver:nativeDriver}).start(()=>a())}else springBack()},cancel:springBack}};export const useDragToDismiss=e=>{const{drag:t,travel:a,onDismiss:i,contentAtTop:s,scrollGesture:r,testID:n}=e,{motion:o}=useTheme(),u=usePresenceMotion(),c=useRef(createAnimatedValue(1)).current,l=useMemo(()=>createDragToDismissController({drag:t,travel:a,onDismiss:i,opacity:c},o,u),[t,a,i,c,o,u]),m=useMemo(()=>({runOnJS:!0,activeOffsetY:6,failOffsetX:[-12,12],testID:n?`${n}-pan`:void 0,onUpdate:e=>l.move(e.translationY),onDeactivate:e=>l.release(e.translationY,e.velocityY/1e3),onFinalize:e=>{e.canceled&&l.cancel()}}),[l,n]),v=usePanGesture(m),f=useMemo(()=>{let e=0,t=!1;return{runOnJS:!0,activeOffsetY:8,failOffsetX:[-12,12],simultaneousWith:r,onBegin:()=>{e=0,t=!1},onUpdate:a=>{if(!t){if(s&&!s())return;t=!0,e=a.translationY}l.move(a.translationY-e)},onDeactivate:a=>{t&&l.release(a.translationY-e,a.velocityY/1e3)},onFinalize:e=>{e.canceled&&t&&l.cancel()}}},[l,s,r]),d=usePanGesture(f);return useMemo(()=>({handleGesture:v,sheetGesture:d,opacity:c}),[v,d,c])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{hasKey,isOneOf,isRecord,keysOf}from"../utils/guards.js";import{validateComponentTokens}from"./componentSizes.js";import{COLOR_NAMES,FONT_NAMES,RADIUS_NAMES,WEIGHT_NAMES}from"./tokens.generated.js";import{deriveSolidFill,deriveStateFills,deriveToneInk}from"./toneInk.js";const HINT="Run webority upgrade to rename old names.",BRAND_KEYS=["colors","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0,headerShadowOnScroll:!0}},isPlainObject=o=>"object"==typeof o&&null!==o&&!Array.isArray(o),validateBrand=o=>{if(void 0===o)return;if(!isPlainObject(o))throw new Error(`A brand is an object of colors, radius and font; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o))if(!BRAND_KEYS.includes(e))throw new Error(`A brand sets colors, radius and font only; ${e} is not allowed (allowed: colors, radius, font). ${HINT}`);const e=o.
|
|
1
|
+
"use strict";import{hasKey,isOneOf,isRecord,keysOf}from"../utils/guards.js";import{validateComponentTokens}from"./componentSizes.js";import{COLOR_NAMES,FONT_NAMES,RADIUS_NAMES,WEIGHT_NAMES}from"./tokens.generated.js";import{deriveSolidFill,deriveStateFills,deriveToneInk}from"./toneInk.js";const HINT="Run webority upgrade to rename old names.",BRAND_KEYS=["colors","descriptions","radius","font"],COLOR_MODES=["light","dark"],FIXED_RADII=["none","pill"],RADIUS_ALLOWED="sm, md, lg, xl",SETTINGS_KEYS=["icons","gradients","textVariants","maxFontSizeMultiplier","components"],COMPONENT_SETTING_KEYS={field:{defaultVariant:!0,requiredMarker:!0},input:{defaultVariant:!0,defaultLabelMode:!0,tintLabelOnFocus:!0,shakeOnError:!0},"search-bar":{defaultVariant:!0},select:{defaultVariant:!0},"otp-input":{shakeOnError:!0},"option-sheet":{selectedMarker:!0},"profile-picker":{defaultTone:!0,defaultVariant:!0,defaultAvatarTone:!0},slider:{thumbPressAnimation:!0},rating:{pulseOnPress:!0},stepper:{pulseAnimation:!0},tooltip:{enableScaleAnimation:!0},toast:{enableSwipeDismiss:!0,defaultDurationMs:!0},button:{defaultVariant:!0,defaultSize:!0,defaultPressAnimation:!0},card:{defaultVariant:!0,defaultPadding:!0,defaultRadius:!0,defaultTitleFont:!0},"section-header":{defaultVariant:!0,defaultFlush:!0},"empty-state":{defaultSize:!0,defaultVariant:!0},screen:{tabBarFloats:!0,headerShadowOnScroll:!0}},isPlainObject=o=>"object"==typeof o&&null!==o&&!Array.isArray(o),validateBrand=o=>{if(void 0===o)return;if(!isPlainObject(o))throw new Error(`A brand is an object of colors, radius and font; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o))if(!BRAND_KEYS.includes(e))throw new Error(`A brand sets colors, descriptions, radius and font only; ${e} is not allowed (allowed: colors, descriptions, radius, font). ${HINT}`);const e=o.descriptions;if(void 0!==e){if(!isPlainObject(e))throw new Error(`A brand's descriptions is an object of colour names to a description; got ${typeof e}. ${HINT}`);for(const o of Object.keys(e)){const t=e[o];if("string"!=typeof t||""===t)throw new Error(`description of colour ${o} must be a non-empty string.`)}}const t=o.colors;if(void 0!==t&&!isPlainObject(t))throw new Error(`A brand's colors is an object of light and dark; got ${typeof t}. ${HINT}`);if(isRecord(t))for(const o of Object.keys(t)){if(!COLOR_MODES.includes(o))throw new Error(`A brand sets colours under light and dark only; ${o} is not allowed (allowed: light, dark). ${HINT}`);const n=t[o];if(void 0===n)throw new Error(`A brand's ${o} colours are missing. ${HINT}`);if(!isRecord(n))throw new Error(`A brand's ${o} colours is an object of colour names; got ${typeof n}. ${HINT}`);for(const o of Object.keys(n)){const t=isRecord(e)&&"string"==typeof e[o];if(!isOneOf(COLOR_NAMES,o)&&!t)throw new Error(`unknown colour ${o}; allowed: ${COLOR_NAMES.join(", ")}. ${HINT}`);if(void 0!==n[o]&&"string"!=typeof n[o])throw new Error(`colour ${o} must be a string; got ${typeof n[o]}.`)}}const n=o.radius;if(void 0!==n){if(!isPlainObject(n))throw new Error(`A brand's radius is an object of radius names; got ${typeof n}. ${HINT}`);for(const o of Object.keys(n)){const e=n[o];if(!isOneOf(RADIUS_NAMES,o))throw new Error(`unknown radius ${o}; allowed: ${RADIUS_ALLOWED}. ${HINT}`);if(FIXED_RADII.includes(o))throw new Error(`radius ${o} is fixed by the library; allowed: ${RADIUS_ALLOWED}.`);if("number"!=typeof e||!Number.isFinite(e))throw new Error(`radius ${o} must be a number; got ${typeof e}.`)}}const r=o.font;if(void 0!==r){if(!isPlainObject(r))throw new Error(`A brand's font is an object of font names; got ${typeof r}. ${HINT}`);for(const o of Object.keys(r)){if(!isOneOf(FONT_NAMES,o))throw new Error(`unknown font ${o}; allowed: ${FONT_NAMES.join(", ")}. ${HINT}`);const e=r[o];if(!isPlainObject(e))throw new Error(`font ${o} must be an object of weights; got ${typeof e}. ${HINT}`);for(const t of Object.keys(e)){if(!isOneOf(WEIGHT_NAMES,t))throw new Error(`unknown font weight ${t} in font ${o}; allowed: ${WEIGHT_NAMES.join(", ")}. ${HINT}`);const n=e[t];if("string"!=typeof n||0===n.length)throw new Error(`font ${o} weight ${t} must be a non-empty string.`)}}}},validateSettings=o=>{if(void 0===o)return;if(!isPlainObject(o))throw new Error(`Theme settings is an object; got ${typeof o}. ${HINT}`);for(const e of Object.keys(o))if(!isOneOf(SETTINGS_KEYS,e))throw new Error(`Theme settings take ${SETTINGS_KEYS.join(", ")} only; ${e} is not allowed. ${HINT}`);const e=o.components;if(void 0!==e){if(!isPlainObject(e))throw new Error(`Theme settings components is an object of component names; got ${typeof e}. ${HINT}`);for(const o of Object.keys(e)){if(!hasKey(COMPONENT_SETTING_KEYS,o))throw new Error(`unknown component ${o} in theme settings; allowed: ${Object.keys(COMPONENT_SETTING_KEYS).join(", ")}. ${HINT}`);const t=e[o];if(void 0===t)continue;if(!isPlainObject(t))throw new Error(`theme settings for ${o} is an object; got ${typeof t}. ${HINT}`);const n=COMPONENT_SETTING_KEYS[o];for(const e of Object.keys(t))if(!(e in n))throw new Error(`unknown setting ${e} for ${o}; allowed: ${Object.keys(n).join(", ")}. ${HINT}`)}}},TONES=["primary","success","warning","danger","info"],setComponentSettings=(o,e,t)=>{o[e]=t},mergeComponentSettings=(o,e,t)=>({...hasKey(o,t)?o[t]:void 0,...void 0!==e&&hasKey(e,t)?e[t]:void 0});export const mergeBrand=(o,e,t)=>{validateBrand(e),validateSettings(t);const n={};for(const[t,r]of Object.entries(e?.colors?.[o.mode]??{}))void 0!==r&&(n[t]=r);const r={...o.colors,...n},colorOf=o=>{const e=r[o];if(void 0===e)throw new Error(`The theme has no colour ${o}.`);return e},i={...o.radius,...e?.radius},s={...o.font};if(void 0!==e?.font)for(const t of keysOf(e.font))s[t]={...o.font[t],...e.font[t]};const a=[colorOf("bg"),colorOf("bg-subtle"),colorOf("bg-muted")],f={};for(const e of TONES){const t="string"==typeof n[e];let r=colorOf(e);if(t||"string"==typeof n[`on-${e}`]){const o=deriveSolidFill(r,colorOf(`on-${e}`));o!==r&&(f[e]=o,r=o)}if(t&&"string"!=typeof n[`${e}-text`]&&(f[`${e}-text`]=deriveToneInk(r,a,o.mode)),"primary"===e&&(t||void 0!==f.primary)){const e=deriveStateFills(r,colorOf("on-primary"),{fill:o.colors.primary,hover:o.colors["primary-hover"],pressed:o.colors["primary-pressed"]});"string"!=typeof n["primary-hover"]&&(f["primary-hover"]=e.hover),"string"!=typeof n["primary-pressed"]&&(f["primary-pressed"]=e.pressed)}}const d=o.settings.components,l=t?.components,c={},u=new Set([...keysOf(d),...void 0===l?[]:keysOf(l)]);for(const o of u)setComponentSettings(c,o,mergeComponentSettings(d,l,o));const p=t?.maxFontSizeMultiplier??o.settings.maxFontSizeMultiplier,O={icons:{...o.settings.icons,...t?.icons},gradients:{...o.settings.gradients,...t?.gradients},textVariants:{...o.settings.textVariants,...t?.textVariants},components:c,...void 0===p?{}:{maxFontSizeMultiplier:p}},m={...o.colors,...Object.fromEntries(Object.entries(n).filter(([o])=>!isOneOf(COLOR_NAMES,o))),...Object.fromEntries(COLOR_NAMES.map(o=>[o,f[o]??colorOf(o)]))},w={...o,colors:m,radius:i,font:s,settings:O};return validateComponentTokens(w),w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Logger}from"@webority/mobile-core";export const warnUnknownProps=(e,o)=>{if(!__DEV__||!o)return;const r=Object.keys(o).filter(e=>!isAllowed(e));0!==r.length&&Logger.warn(`[${e}] received prop(s) it does not accept: ${r.join(", ")}. They were ignored
|
|
1
|
+
"use strict";import{Logger}from"@webority/mobile-core";export const warnUnknownProps=(e,o)=>{if(!__DEV__||!o)return;const r=Object.keys(o).filter(e=>!isAllowed(e));0!==r.length&&Logger.warn(`[${e}] received prop(s) it does not accept: ${r.join(", ")}. They were ignored: check for a rename or a typo against the component's props.`)};const ALLOWED_EXACT=new Set(["children","key","ref","style","testID","collapsable","nativeID","pointerEvents","removeClippedSubviews","renderToHardwareTextureAndroid","shouldRasterizeIOS","needsOffscreenAlphaCompositing","hitSlop","onLayout","importantForAccessibility","role"]),ALLOWED_PREFIXES=["accessibility","aria-","on","data-"],isAllowed=e=>ALLOWED_EXACT.has(e)||ALLOWED_PREFIXES.some(o=>e.startsWith(o));
|
|
@@ -126,6 +126,7 @@ export interface AppBarProps {
|
|
|
126
126
|
* to override the default.
|
|
127
127
|
*/
|
|
128
128
|
haptic?: HapticType | false | undefined;
|
|
129
|
+
/** The bar's root testID; the large variant's title row is `${testID}-title-row`. */
|
|
129
130
|
testID?: string | undefined;
|
|
130
131
|
}
|
|
131
132
|
declare const AppBar: React.ForwardRefExoticComponent<AppBarProps & React.RefAttributes<HostInstance>>;
|
|
@@ -27,7 +27,7 @@ export interface AutocompleteProps<T = string> {
|
|
|
27
27
|
minChars?: number | undefined;
|
|
28
28
|
/** Cap the number of suggestions shown. Default 8. */
|
|
29
29
|
maxResults?: number | undefined;
|
|
30
|
-
/** Show a loading spinner in the dropdown
|
|
30
|
+
/** Show a loading spinner in the dropdown, e.g. while fetching remote results. */
|
|
31
31
|
loading?: boolean | undefined;
|
|
32
32
|
/** `'client'` filters `options` locally; `'none'` shows them as-is (for server-side search). Default `'client'`. */
|
|
33
33
|
filterMode?: "client" | "none" | undefined;
|
|
@@ -63,7 +63,7 @@ export interface AvatarProps {
|
|
|
63
63
|
/**
|
|
64
64
|
* Custom component used to render the image instead of the built-in `<Image>`.
|
|
65
65
|
* Receives {@link AvatarImageProps}. Use this when `source` points at a secured
|
|
66
|
-
* endpoint that needs auth headers / token refresh / caching
|
|
66
|
+
* endpoint that needs auth headers / token refresh / caching: plug in the
|
|
67
67
|
* app's authenticated image loader. On error it should call `onError`, which
|
|
68
68
|
* triggers the initials fallback. When omitted, expo-image's `<Image>` is used.
|
|
69
69
|
*/
|
|
@@ -139,6 +139,7 @@ export interface AvatarProps {
|
|
|
139
139
|
textStyle?: StyleProp<TextStyle> | undefined;
|
|
140
140
|
/** Spoken text in its default English. Override any key to translate it or to change its wording. */
|
|
141
141
|
labels?: Partial<AvatarLabels> | undefined;
|
|
142
|
+
/** Test id of the root; the built-in picture is `<testID>-image`. */
|
|
142
143
|
testID?: string | undefined;
|
|
143
144
|
}
|
|
144
145
|
declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HostInstance>> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BottomSheet
|
|
2
|
+
* BottomSheet: Reanimated 3 + Gesture Handler 3 implementation.
|
|
3
3
|
*
|
|
4
4
|
* A polished, theme-aware bottom sheet with multi-snap-point support,
|
|
5
5
|
* UI-thread driven pan gestures, and native-driver spring animations.
|
|
@@ -152,7 +152,7 @@ export interface BottomSheetProps {
|
|
|
152
152
|
/**
|
|
153
153
|
* Sticky region pinned to the bottom of the sheet, above the safe-area
|
|
154
154
|
* inset. Does not scroll with `children`, and rides up with the keyboard
|
|
155
|
-
* when `keyboardBehavior='shift'` (no extra wiring needed
|
|
155
|
+
* when `keyboardBehavior='shift'` (no extra wiring needed; the whole sheet
|
|
156
156
|
* shifts). Typical use: action button rows.
|
|
157
157
|
*/
|
|
158
158
|
footer?: React.ReactNode | undefined;
|
|
@@ -163,17 +163,18 @@ export interface BottomSheetProps {
|
|
|
163
163
|
children?: React.ReactNode | undefined;
|
|
164
164
|
accessibilityLabel?: string | undefined;
|
|
165
165
|
accessibilityViewIsModal?: boolean | undefined;
|
|
166
|
+
/** Test handle root; the inner ScrollView, when `scrollable`, is `${testID}-scroll`. */
|
|
166
167
|
testID?: string | undefined;
|
|
167
168
|
}
|
|
168
169
|
/**
|
|
169
|
-
* State + actions exposed to anything rendered inside a `<BottomSheet
|
|
170
|
+
* State + actions exposed to anything rendered inside a `<BottomSheet>`,
|
|
170
171
|
* including the `header` and `footer` slots. Read via `useBottomSheet()`.
|
|
171
172
|
*
|
|
172
173
|
* `snapIndex` is the JS-thread mirror of the current snap point. -1 means the
|
|
173
174
|
* sheet is closed (mid-close-animation included). Use it to drive footer
|
|
174
175
|
* button enable state, conditional headers, etc. If you need per-frame
|
|
175
176
|
* progress (e.g. fade a header in as the sheet expands), reach for the
|
|
176
|
-
* animated value via a future enhancement
|
|
177
|
+
* animated value via a future enhancement, not exposed today to keep the
|
|
177
178
|
* surface minimal.
|
|
178
179
|
*/
|
|
179
180
|
export interface BottomSheetContextValue {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Carousel
|
|
2
|
+
* Carousel: generic horizontal carousel with pagination, auto-play, and looping.
|
|
3
3
|
*
|
|
4
4
|
* Backed by a virtualized FlatList for memory efficiency. Dot and bar
|
|
5
5
|
* pagination track the scroll gesture through `Animated.event`.
|
|
@@ -52,6 +52,7 @@ export interface CarouselProps<T = unknown> {
|
|
|
52
52
|
spacing?: number | undefined;
|
|
53
53
|
containerStyle?: StyleProp<ViewStyle> | undefined;
|
|
54
54
|
accessibilityLabel?: string | undefined;
|
|
55
|
+
/** Also derives `${testID}-list` for the slide FlatList. */
|
|
55
56
|
testID?: string | undefined;
|
|
56
57
|
/** Render a horizontal strip of 40x40 thumbnails below the carousel. */
|
|
57
58
|
showThumbnails?: boolean | undefined;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ChoiceGroup
|
|
2
|
+
* ChoiceGroup: headless choice group (one option, or `selectionMode="multiple"` for many) with templated options.
|
|
3
3
|
*
|
|
4
4
|
* The component owns the BEHAVIOUR: selection state (controlled or
|
|
5
5
|
* uncontrolled), per-option press handling, haptics, radio/radiogroup a11y,
|
|
6
6
|
* and row/column/wrap layout. Each option's LOOK comes from a template:
|
|
7
7
|
*
|
|
8
|
-
* - `card` (default): a bordered card
|
|
8
|
+
* - `card` (default): a bordered card: label (+ optional icon /
|
|
9
9
|
* description) with a RadioDot after the content (or before it, with
|
|
10
10
|
* `indicatorPosition="leading"`), tinted with the option's colour when
|
|
11
11
|
* selected. The "Hot / Warm / Cold" status-picker pattern works
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* indicator inside a custom layout.
|
|
20
20
|
*
|
|
21
21
|
* Cross-option visuals (a single indicator sliding BETWEEN options, joined
|
|
22
|
-
* segments) are out of scope by design
|
|
22
|
+
* segments) are out of scope by design; that's SegmentedControl.
|
|
23
23
|
*
|
|
24
24
|
* Same data contract as Select: `ChoiceOption[]` by default, `getOption*`
|
|
25
25
|
* accessors for custom shapes.
|
|
@@ -82,7 +82,7 @@ interface BaseChoiceGroupProps<T = ChoiceOption> {
|
|
|
82
82
|
getOptionColor?: ((option: T) => string | undefined) | undefined;
|
|
83
83
|
/**
|
|
84
84
|
* Custom option template. The library still owns press handling, haptics
|
|
85
|
-
* and a11y
|
|
85
|
+
* and a11y: the template only paints. Selected-state styling is the
|
|
86
86
|
* template's job (it gets the booleans).
|
|
87
87
|
*/
|
|
88
88
|
renderOption?: ((state: ChoiceOptionState<T>) => React.ReactNode) | undefined;
|
|
@@ -17,7 +17,7 @@ export interface DateRangePickerLabels {
|
|
|
17
17
|
}
|
|
18
18
|
export declare const DEFAULT_DATE_RANGE_PICKER_LABELS: Readonly<DateRangePickerLabels>;
|
|
19
19
|
/**
|
|
20
|
-
* DateRangePicker
|
|
20
|
+
* DateRangePicker: supports two usage modes:
|
|
21
21
|
*
|
|
22
22
|
* 1. Controlled-modal mode (pass `open` + `onClose`): renders only the
|
|
23
23
|
* modal; parent owns open/close state.
|
|
@@ -63,6 +63,7 @@ export interface DateRangePickerProps extends PickerTriggerPassThroughProps {
|
|
|
63
63
|
navButtonStyle?: StyleProp<ViewStyle> | undefined;
|
|
64
64
|
/** Style override for the cancel/confirm footer buttons. */
|
|
65
65
|
footerButtonStyle?: StyleProp<ViewStyle> | undefined;
|
|
66
|
+
/** The handle / title row's drag gesture is `${testID}-pan`. */
|
|
66
67
|
testID?: string | undefined;
|
|
67
68
|
}
|
|
68
69
|
declare const DateRangePicker: ForwardRefExoticComponent<DateRangePickerProps & RefAttributes<HostInstance>>;
|
|
@@ -29,7 +29,7 @@ export interface DescriptionItem {
|
|
|
29
29
|
}
|
|
30
30
|
export interface DescriptionsProps {
|
|
31
31
|
items: ReadonlyArray<DescriptionItem>;
|
|
32
|
-
/** 1 stacks label above value; 2 puts them side by side. Default 1
|
|
32
|
+
/** 1 stacks label above value; 2 puts them side by side. Default 1, since phone widths are narrow. */
|
|
33
33
|
columns?: 1 | 2 | undefined;
|
|
34
34
|
size?: DescriptionsSize | undefined;
|
|
35
35
|
/** Hairlines between rows. */
|
|
@@ -44,7 +44,7 @@ export interface DescriptionsProps {
|
|
|
44
44
|
testID?: string | undefined;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* A labelled key-value list for record detail
|
|
47
|
+
* A labelled key-value list for record detail: the "what are this thing's
|
|
48
48
|
* fields" view that every detail screen needs and that ListItem (a tappable row
|
|
49
49
|
* with a title) is the wrong shape for.
|
|
50
50
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Drawer
|
|
2
|
+
* Drawer: slide-in side drawer (left / right / top / bottom).
|
|
3
3
|
*
|
|
4
4
|
* Built on Reanimated 4 and Gesture Handler 3's hooks: gestures and animations run on the
|
|
5
5
|
* UI thread for buttery 60/120fps motion. Mirrors the BottomSheet ergonomics:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Chevron
|
|
2
|
+
* Chevron: the shared dropdown indicator for the field family.
|
|
3
3
|
*
|
|
4
4
|
* One glyph for Select, InlineSelect, PickerTrigger and PhoneNumberInput so
|
|
5
5
|
* the indicator never drifts between trigger components. It is the design
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* FieldBase
|
|
2
|
+
* FieldBase: the unified field-box primitive.
|
|
3
3
|
*
|
|
4
4
|
* Every input-like control in the library (Input, Select, SearchBar,
|
|
5
5
|
* NumberInput, OTPInput cell, PickerTrigger) composes FieldBase so the
|
|
6
6
|
* height / radius / padding / border / fill / focus + disabled + error
|
|
7
7
|
* states stay identical across the library. Differences (pill SearchBar,
|
|
8
8
|
* OTP underline, NumberInput steppers) become explicit overrides via
|
|
9
|
-
* props or via theme tokens
|
|
9
|
+
* props or via theme tokens; never accidental drift.
|
|
10
10
|
*
|
|
11
11
|
* Responsibilities:
|
|
12
12
|
* - Resolve size dimensions from `theme.components.field`.
|
|
@@ -45,11 +45,11 @@ export interface FieldBaseProps {
|
|
|
45
45
|
* (`theme.settings.components.field.defaultVariant`) via this prop. Default `'outline'`.
|
|
46
46
|
*/
|
|
47
47
|
variant?: FieldBaseVariant | undefined;
|
|
48
|
-
/** Parent-controlled focus state
|
|
48
|
+
/** Parent-controlled focus state; drives the border + fill animation. */
|
|
49
49
|
focused?: boolean | undefined;
|
|
50
|
-
/** Disabled state
|
|
50
|
+
/** Disabled state; wins over `focused` / `error`. */
|
|
51
51
|
disabled?: boolean | undefined;
|
|
52
|
-
/** Error state
|
|
52
|
+
/** Error state; visually wins over `focused`. */
|
|
53
53
|
error?: boolean | undefined;
|
|
54
54
|
/** Whether the field currently holds a value. Affects idle-empty vs idle-filled fill. */
|
|
55
55
|
filled?: boolean | undefined;
|
|
@@ -104,9 +104,9 @@ export interface FieldBaseProps {
|
|
|
104
104
|
minHeight?: number | undefined;
|
|
105
105
|
/** Override `maxHeight` (rarely needed). */
|
|
106
106
|
maxHeight?: number | undefined;
|
|
107
|
-
/** Fixed pixel width
|
|
107
|
+
/** Fixed pixel width: used by OTP cells. Suppresses default `flex: 1`. */
|
|
108
108
|
width?: number | undefined;
|
|
109
|
-
/** Fixed pixel height
|
|
109
|
+
/** Fixed pixel height: used by OTP cells. Wins over `minHeight`. */
|
|
110
110
|
height?: number | undefined;
|
|
111
111
|
/** Override horizontal padding. */
|
|
112
112
|
paddingHorizontal?: number | undefined;
|
|
@@ -126,7 +126,7 @@ export interface FieldBaseProps {
|
|
|
126
126
|
borderBottomLeftRadius?: number | undefined;
|
|
127
127
|
/** Bottom-right corner radius. Wins over `radius`. */
|
|
128
128
|
borderBottomRightRadius?: number | undefined;
|
|
129
|
-
/** Override border width (shorthand
|
|
129
|
+
/** Override border width (shorthand for all four sides). OTP uses 1.5; everything else inherits `size.border`. */
|
|
130
130
|
borderWidth?: number | undefined;
|
|
131
131
|
/** Top border width. Wins over `borderWidth`. */
|
|
132
132
|
borderTopWidth?: number | undefined;
|
|
@@ -141,6 +141,7 @@ export interface FieldBaseProps {
|
|
|
141
141
|
/** Drop the room below the field, for a field that sits tight on the content under it. */
|
|
142
142
|
flushBottom?: boolean | undefined;
|
|
143
143
|
style?: StyleProp<ViewStyle> | undefined;
|
|
144
|
+
/** Also derives `${testID}-press`, the box-press Pressable wrapping the field when `onPress` is set. */
|
|
144
145
|
testID?: string | undefined;
|
|
145
146
|
accessibilityRole?: AccessibilityRole | undefined;
|
|
146
147
|
accessibilityLabel?: string | undefined;
|
|
@@ -151,7 +152,7 @@ export interface FieldBaseProps {
|
|
|
151
152
|
* Resolved text styling for the editable / displayed content inside a field.
|
|
152
153
|
* Single source of truth so every field component (Input, NumberInput,
|
|
153
154
|
* Select, SearchBar, PickerTrigger) renders identical colour + weight +
|
|
154
|
-
* fontFamily for value text
|
|
155
|
+
* fontFamily for value text, and reads the placeholder colour from the
|
|
155
156
|
* same place. OTPInput intentionally overrides this with its own semibold
|
|
156
157
|
* display weight.
|
|
157
158
|
*/
|
|
@@ -260,15 +261,15 @@ export declare const FieldMessage: React.FC<{
|
|
|
260
261
|
* width is expanded to a 4-side record by the time the box renders, so the
|
|
261
262
|
* animation pipeline can treat per-side and shorthand the same way.
|
|
262
263
|
* `borderFocusedRepresentative` is a single colour pulled from the focused
|
|
263
|
-
* sides
|
|
264
|
+
* sides; exposed for consumers (Input's selectionColor) that need to mirror
|
|
264
265
|
* the visible focus indicator without re-resolving per side.
|
|
265
266
|
*/
|
|
266
267
|
interface ResolvedFieldColors {
|
|
267
268
|
backgroundIdleEmpty: string;
|
|
268
269
|
backgroundIdleFilled: string;
|
|
269
|
-
/** Optional override fill while focused
|
|
270
|
+
/** Optional override fill while focused; when undefined, focus animates from idle to idle (no fill change). */
|
|
270
271
|
backgroundFocused: string | undefined;
|
|
271
|
-
/** Optional override fill while in error
|
|
272
|
+
/** Optional override fill while in error; when undefined, error animates from idle to idle. */
|
|
272
273
|
backgroundError: string | undefined;
|
|
273
274
|
backgroundDisabled: string;
|
|
274
275
|
borderIdle: Record<FieldSide, string>;
|
|
@@ -276,7 +277,7 @@ interface ResolvedFieldColors {
|
|
|
276
277
|
borderError: Record<FieldSide, string>;
|
|
277
278
|
borderDisabled: Record<FieldSide, string>;
|
|
278
279
|
borderWidth: Record<FieldSide, number>;
|
|
279
|
-
/** Single representative colour from `borderFocused
|
|
280
|
+
/** Single representative colour from `borderFocused`: first non-transparent side, bottom-priority. */
|
|
280
281
|
borderFocusedRepresentative: string;
|
|
281
282
|
}
|
|
282
283
|
/**
|