@webority/mobile-ui 0.188.1 → 0.189.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/README.md +1 -1
- package/dist/canvas-kit/kit.js +10 -10
- package/dist/canvas-kit/manifest.json +47 -24
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/Button/Button.js +1 -1
- package/lib/commonjs/components/Button/index.js +1 -1
- package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
- package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
- package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
- package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/commonjs/components/Select/Select.js +1 -1
- package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/commonjs/components/Skeleton/Skeleton.js +1 -1
- package/lib/commonjs/components/SquircleFill/SquircleFill.js +1 -1
- package/lib/commonjs/components/TagInput/TagInput.js +1 -1
- package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/theme/Gradient.js +1 -1
- package/lib/commonjs/theme/index.js +1 -1
- package/lib/commonjs/theme/tokens.generated.js +1 -1
- package/lib/commonjs/utils/squircle.js +1 -1
- package/lib/module/components/Button/Button.js +1 -1
- package/lib/module/components/Button/index.js +1 -1
- package/lib/module/components/FieldBase/FieldBase.js +1 -1
- package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/NumberInput/NumberInput.js +1 -1
- package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
- package/lib/module/components/SearchBar/SearchBar.js +1 -1
- package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/module/components/Select/Select.js +1 -1
- package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/module/components/Skeleton/Skeleton.js +1 -1
- package/lib/module/components/SquircleFill/SquircleFill.js +1 -1
- package/lib/module/components/TagInput/TagInput.js +1 -1
- package/lib/module/components/TimePicker/TimePicker.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/theme/Gradient.js +1 -1
- package/lib/module/theme/index.js +1 -1
- package/lib/module/theme/tokens.generated.js +1 -1
- package/lib/module/utils/squircle.js +1 -1
- package/lib/typescript/commonjs/components/Button/Button.d.ts +10 -5
- package/lib/typescript/commonjs/components/Button/index.d.ts +2 -2
- package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +1 -1
- package/lib/typescript/commonjs/components/FieldBase/useFloatingLabel.d.ts +10 -2
- package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +1 -1
- package/lib/typescript/commonjs/components/Input/Input.d.ts +5 -2
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -1
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +1 -1
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +2 -2
- package/lib/typescript/commonjs/components/Select/Select.d.ts +1 -1
- package/lib/typescript/commonjs/components/SquircleFill/SquircleFill.d.ts +7 -4
- package/lib/typescript/commonjs/components/index.d.ts +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/Gradient.d.ts +4 -0
- package/lib/typescript/commonjs/theme/componentSizes.d.ts +2 -2
- package/lib/typescript/commonjs/theme/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/tokens.generated.d.ts +8 -8
- package/lib/typescript/commonjs/utils/squircle.d.ts +7 -0
- package/lib/typescript/module/components/Button/Button.d.ts +10 -5
- package/lib/typescript/module/components/Button/index.d.ts +2 -2
- package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +1 -1
- package/lib/typescript/module/components/FieldBase/useFloatingLabel.d.ts +10 -2
- package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +1 -1
- package/lib/typescript/module/components/Input/Input.d.ts +5 -2
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +1 -1
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +1 -1
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +2 -2
- package/lib/typescript/module/components/Select/Select.d.ts +1 -1
- package/lib/typescript/module/components/SquircleFill/SquircleFill.d.ts +7 -4
- package/lib/typescript/module/components/index.d.ts +1 -1
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/theme/Gradient.d.ts +4 -0
- package/lib/typescript/module/theme/componentSizes.d.ts +2 -2
- package/lib/typescript/module/theme/index.d.ts +1 -1
- package/lib/typescript/module/theme/tokens.generated.d.ts +8 -8
- package/lib/typescript/module/utils/squircle.d.ts +7 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{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{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{SEARCH_BAR_TEXT}from"../../text/phone/searchBar.g.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";const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50;function SearchBar({ref:e,...l}){const{value:s,onChangeText:t,onSubmit:o,onFocus:a,onBlur:i,placeholder:r,autoFocus:n=!1,disabled:c=!1,onClear:u,leftIcon:d,debounceMs:p,size:b="md",variant:m,radius:f,label:h,labelMode:S="top",labelStyle:g,scopes:x,scope:v,onScopeChange:C,recents:y,maxRecents:j=DEFAULT_PANEL_ROWS,onSelectRecent:R,onRemove:T,onClearRecents:F,suggestions:_,maxSuggestions:k=DEFAULT_PANEL_ROWS,onSelect:B,haptic:E,labels:V,style:I,inputStyle:L,accessibilityLabel:A,testID:M,...z}=l;assertValidValue("SearchBar","size",l.size,["sm","md","lg"]),assertValidValue("SearchBar","variant",l.variant,["outline","filled","underline"]),assertValidValue("SearchBar","labelMode",l.labelMode,["top","float"]);const H=useTheme(),w=useMobileUiText("searchBar",SEARCH_BAR_TEXT),D=useMemo(()=>({...w,...V}),[w,V]),P=r??D.placeholder,O=m??H.settings.components["search-bar"]?.defaultVariant??H.settings.components.field?.defaultVariant??"filled",U="underline"===O,N=resolveFieldSize(H,b),W=f??H.components["search-bar"][b].radius,X=resolveFieldTextStyle(H,{disabled:c}),q=useRef(null),K=useMemo(()=>mergeRefs(q,e),[e]),$=useCallback(()=>{c||q.current?.focus()},[c]),G=useMemo(()=>buildStyles(H),[H]),J="string"==typeof s?s:"",[Q,Y]=useState(!1),Z=useCallback(e=>{Y(!0),a?.(e)},[a]),ee=useCallback(e=>{Y(!1),i?.(e)},[i]),[le,se]=useState(J),te=useRef(le);te.current=le;const oe=useDebounce(le,p??0);useEffect(()=>{void 0!==p&&J!==te.current&&se(J)},[J,p]);const ae=useRef(J);useEffect(()=>{void 0!==p&&oe!==ae.current&&(ae.current=oe,t(oe))},[oe,p,t]);const ie=useCallback(e=>{reportIdleActivity(),void 0===p?t(e):se(e)},[p,t]),re=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e),void 0!==p&&(se(""),ae.current=""),t(""),u?.()},[E,p,t,u]),ne=useCallback(()=>{o?.(void 0!==p?le:J)},[o,p,le,J]),ce=void 0!==p?le:J,ue=ce.length>0,[de,pe]=useControllableState({value:v,defaultValue:x?.[0]?.value??"",onChange:C}),be=useCallback(e=>{pe(e);const l=x?.find(l=>l.value===e)?.label;l&&announce(fillText(D.searching,{label:l}))},[x,pe,D]),[me,fe]=useState(!1),he=useRef(null),Se=useCallback(()=>{he.current&&(clearTimeout(he.current),he.current=null)},[]),ge=useCallback(()=>{Se(),fe(!0)},[Se]),xe=useCallback(()=>{Se(),he.current=setTimeout(()=>fe(!1),50)},[Se]);useEffect(()=>Se,[Se]);const ve=!c&&(Q||me),Ce=useMemo(()=>(y??[]).slice(0,j),[y,j]),ye=useMemo(()=>(_??[]).slice(0,k).map(normalizeSuggestion),[_,k]),je=ve&&!ue&&Ce.length>0,Re=ve&&ue&&ye.length>0,Te=Re?ye.length:0,Fe=Te>0?pluralText(D,"suggestionCount",Te):"";useEffect(()=>{Fe&&announce(Fe)},[Fe]);const ke=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e)},[E]),Be=useCallback(e=>{ke(),q.current?.blur(),fe(!1),R?.(e)},[ke,R]),Ee=useCallback(e=>{ke(),q.current?.blur(),fe(!1),B?.(e)},[ke,B]),Ve=useCallback(e=>{ke(),T?.(e),announce(fillText(D.removed,{text:e})),$()},[ke,T,$,D]),Ie=useCallback(()=>{ke(),F?.(),announce(D.recentsCleared),$()},[ke,F,$,D]),Le={size:N.icon,color:c?H.colors["text-disabled"]:H.colors["text-subtle"],disabled:c},Ae=d?renderSlotIcon(d,Le):(H.settings.icons.search??defaultIcons.search)(Le),Me=_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:Ae}),ze=Boolean(h)&&"float"===S,He=useFloatingLabel({label:h,enabled:ze,floated:Q||ue,variant:O,sizeTokens:N,leadingOffset:N.icon+H.space.md,trailingOffset:ue?N.icon+H.space.md:0,paddingLeft:U?H.space.none:N["padding-x"],color:H.colors["field-label"],style:g}),we=ue&&!c?_jsx(Pressable,{onPress:re,hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:D.clearSearch,children:(H.settings.icons.close??defaultIcons.close)({size:N.icon,color:H.colors["text-muted"]})}):null;return _jsxs(View,{style:I,testID:M,children:[h&&!ze?_jsx(FieldLabel,{size:b,style:g,children:h}):null,_jsx(View,{style:G.root,children:_jsxs(View,{style:G.fieldWrap,children:[_jsx(FieldBase,{testID:M?`${M}-field`:void 0,size:b,variant:O,focused:Q,disabled:c,filled:ue,minHeight:N["min-height"],paddingHorizontal:U?H.space.none:N["padding-x"],radius:W,leading:Me,trailing:we,topNotch:He.topNotch,onPress:$,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:A??P,children:_jsx(TextInput,{ref:K,style:[G.input,{fontSize:N.text,color:X.color,...X.weightStyle},L],value:ce,onChangeText:ie,onSubmitEditing:ne,onFocus:Z,onBlur:ee,placeholder:!ze||Q||ue?P:void 0,placeholderTextColor:X.placeholderColor,autoFocus:n,editable:!c,returnKeyType:"search",selectionColor:resolveVariantColors(H,O).borderFocusedRepresentative,accessibilityLabel:A??P,accessibilityState:{disabled:c},"aria-disabled":c,...z})}),He.node]})}),x&&x.length>0?_jsx(SearchScopeBar,{scopes:x,scope:de||(x[0]?.value??""),disabled:c,haptic:E,labels:D,onChange:be}):null,je?_jsx(SearchRecents,{recents:Ce,labels:D,onSelect:Be,onRemove:T?Ve:void 0,onClear:F?Ie:void 0,onHold:ge,onRelease:xe}):null,Re?_jsx(SearchSuggestions,{suggestions:ye,query:ce,onSelect:Ee,onHold:ge,onRelease:xe}):null]})}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
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{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{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{SEARCH_BAR_TEXT}from"../../text/phone/searchBar.g.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";const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50;function SearchBar({ref:e,...l}){const{value:s,onChangeText:t,onSubmit:o,onFocus:a,onBlur:i,placeholder:r,autoFocus:n=!1,disabled:c=!1,onClear:u,leftIcon:d,debounceMs:p,size:b="md",variant:m,radius:f,label:h,labelMode:S="top",labelStyle:g,scopes:x,scope:v,onScopeChange:C,recents:y,maxRecents:j=DEFAULT_PANEL_ROWS,onSelectRecent:R,onRemove:T,onClearRecents:F,suggestions:_,maxSuggestions:k=DEFAULT_PANEL_ROWS,onSelect:B,haptic:E,labels:V,style:I,inputStyle:L,accessibilityLabel:A,testID:M,...z}=l;assertValidValue("SearchBar","size",l.size,["sm","md","lg","xl"]),assertValidValue("SearchBar","variant",l.variant,["outline","filled","underline"]),assertValidValue("SearchBar","labelMode",l.labelMode,["top","float"]);const H=useTheme(),w=useMobileUiText("searchBar",SEARCH_BAR_TEXT),D=useMemo(()=>({...w,...V}),[w,V]),P=r??D.placeholder,O=m??H.settings.components["search-bar"]?.defaultVariant??H.settings.components.field?.defaultVariant??"filled",U="underline"===O,N=resolveFieldSize(H,b),W=f??H.components["search-bar"][b].radius,X=resolveFieldTextStyle(H,{disabled:c}),q=useRef(null),K=useMemo(()=>mergeRefs(q,e),[e]),$=useCallback(()=>{c||q.current?.focus()},[c]),G=useMemo(()=>buildStyles(H),[H]),J="string"==typeof s?s:"",[Q,Y]=useState(!1),Z=useCallback(e=>{Y(!0),a?.(e)},[a]),ee=useCallback(e=>{Y(!1),i?.(e)},[i]),[le,se]=useState(J),te=useRef(le);te.current=le;const oe=useDebounce(le,p??0);useEffect(()=>{void 0!==p&&J!==te.current&&se(J)},[J,p]);const ae=useRef(J);useEffect(()=>{void 0!==p&&oe!==ae.current&&(ae.current=oe,t(oe))},[oe,p,t]);const ie=useCallback(e=>{reportIdleActivity(),void 0===p?t(e):se(e)},[p,t]),re=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e),void 0!==p&&(se(""),ae.current=""),t(""),u?.()},[E,p,t,u]),ne=useCallback(()=>{o?.(void 0!==p?le:J)},[o,p,le,J]),ce=void 0!==p?le:J,ue=ce.length>0,[de,pe]=useControllableState({value:v,defaultValue:x?.[0]?.value??"",onChange:C}),be=useCallback(e=>{pe(e);const l=x?.find(l=>l.value===e)?.label;l&&announce(fillText(D.searching,{label:l}))},[x,pe,D]),[me,fe]=useState(!1),he=useRef(null),Se=useCallback(()=>{he.current&&(clearTimeout(he.current),he.current=null)},[]),ge=useCallback(()=>{Se(),fe(!0)},[Se]),xe=useCallback(()=>{Se(),he.current=setTimeout(()=>fe(!1),50)},[Se]);useEffect(()=>Se,[Se]);const ve=!c&&(Q||me),Ce=useMemo(()=>(y??[]).slice(0,j),[y,j]),ye=useMemo(()=>(_??[]).slice(0,k).map(normalizeSuggestion),[_,k]),je=ve&&!ue&&Ce.length>0,Re=ve&&ue&&ye.length>0,Te=Re?ye.length:0,Fe=Te>0?pluralText(D,"suggestionCount",Te):"";useEffect(()=>{Fe&&announce(Fe)},[Fe]);const ke=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e)},[E]),Be=useCallback(e=>{ke(),q.current?.blur(),fe(!1),R?.(e)},[ke,R]),Ee=useCallback(e=>{ke(),q.current?.blur(),fe(!1),B?.(e)},[ke,B]),Ve=useCallback(e=>{ke(),T?.(e),announce(fillText(D.removed,{text:e})),$()},[ke,T,$,D]),Ie=useCallback(()=>{ke(),F?.(),announce(D.recentsCleared),$()},[ke,F,$,D]),Le={size:N.icon,color:c?H.colors["text-disabled"]:H.colors["text-subtle"],disabled:c},Ae=d?renderSlotIcon(d,Le):(H.settings.icons.search??defaultIcons.search)(Le),Me=_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:Ae}),ze=Boolean(h)&&"float"===S,He=useFloatingLabel({label:h,enabled:ze,floated:Q||ue,variant:O,sizeTokens:N,leadingOffset:N.icon+H.space.md,trailingOffset:ue?N.icon+H.space.md:0,paddingLeft:U?H.space.none:N["padding-x"],color:H.colors["field-label"],style:g}),we=ue&&!c?_jsx(Pressable,{onPress:re,hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:D.clearSearch,children:(H.settings.icons.close??defaultIcons.close)({size:N.icon,color:H.colors["text-muted"]})}):null;return _jsxs(View,{style:I,testID:M,children:[h&&!ze?_jsx(FieldLabel,{size:b,style:g,children:h}):null,_jsx(View,{style:G.root,children:_jsxs(View,{style:G.fieldWrap,children:[_jsx(FieldBase,{testID:M?`${M}-field`:void 0,size:b,variant:O,focused:Q,disabled:c,filled:ue,minHeight:N["min-height"],paddingHorizontal:U?H.space.none:N["padding-x"],radius:W,leading:Me,trailing:we,topNotch:He.topNotch,onPress:$,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:A??P,children:_jsx(TextInput,{ref:K,style:[G.input,{fontSize:N.text,color:X.color,...X.weightStyle},L],value:ce,onChangeText:ie,onSubmitEditing:ne,onFocus:Z,onBlur:ee,placeholder:!ze||Q||ue?P:void 0,placeholderTextColor:X.placeholderColor,autoFocus:n,editable:!c,returnKeyType:"search",selectionColor:resolveVariantColors(H,O).borderFocusedRepresentative,accessibilityLabel:A??P,accessibilityState:{disabled:c},"aria-disabled":c,...z})}),He.node]})}),x&&x.length>0?_jsx(SearchScopeBar,{scopes:x,scope:de||(x[0]?.value??""),disabled:c,haptic:E,labels:D,onChange:be}):null,je?_jsx(SearchRecents,{recents:Ce,labels:D,onSelect:Be,onRemove:T?Ve:void 0,onClear:F?Ie:void 0,onHold:ge,onRelease:xe}):null,Re?_jsx(SearchSuggestions,{suggestions:ye,query:ce,onSelect:Ee,onHold:ge,onRelease:xe}):null]})}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{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveSegmentedControlSize,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{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldLabel,FieldMessage,hasFieldText}from"../FieldBase/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];case"info":return e.colors["info-text"]}};function SegmentedControl({ref:e,...t}){const{segments:i,label:
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveSegmentedControlSize,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{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldLabel,FieldMessage,hasFieldText}from"../FieldBase/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];case"info":return e.colors["info-text"]}};function SegmentedControl({ref:e,...t}){const{segments:i,label:r,helperText:s,error:l,value:o,defaultValue:n,onChange:a,size:d="md",fullWidth:c=!0,disabled:u=!1,tone:m="primary",variant:h="segmented",radius:g,labelLines:p=1,haptic:f,accessibilityLabel:b,style:x,segmentStyle:v,selectedIndicatorStyle:y,textStyle:S,labelStyle:w,testID:j}=t;assertValidValue("SegmentedControl","size",t.size,["sm","md","lg"]),assertValidValue("SegmentedControl","tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SegmentedControl","variant",t.variant,["underline","pills","segmented"]);const[C]=i;if(void 0===C)throw new Error("SegmentedControl needs at least one segment");const[V,k]=useControllableState({value:o,defaultValue:n??C.value,onChange:e=>{null!==e&&a?.(e)}}),F=useTheme(),I=F.components["segmented-control"],L=useMemo(()=>buildStyles(F),[F]),_=useMemo(()=>resolveSegmentedControlSize(F,d),[F,d]),z=p>=2?2:1,M=z>1,T="segmented"===h,E="underline"===h,A="pills"===h,R=T?F.space[I["track-padding"]]:0,D=Math.ceil(1.25*_.text)*(z-1),H=I["underline-height"],B=F.space[I["pill-inset"]],q="number"==typeof g?g:g?F.radius[g]:void 0,W=q??F.radius.md,P=void 0===q?F.radius.sm:Math.max(q-R,0),G=q??F.radius.pill,N=q??F.radius.none,[O,X]=useState([]),J=useRef(createAnimatedValue(0)).current,K=i.findIndex(e=>e.value===V),Q=K>=0?O[K]:void 0,U=Q?.x,Y=useCallback(e=>{const t=F.motion.spring.snappy,i=Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:nativeDriver});return i.start(),i},[F.motion.spring.snappy,J]);useEffect(()=>{X(e=>e.length===i.length||0===e.length?e:[])},[i.length]);const Z=useRef(null);useEffect(()=>{if(K<0)return void(Z.current=null);if(void 0===U)return;const e=null!==Z.current&&Z.current!==K;if(Z.current=K,!e)return void J.setValue(U);const t=Y(U);return()=>t.stop()},[K,U,Y,J]);const $=useCallback((e,t)=>{const{x:i,width:r}=t.nativeEvent.layout;X(t=>{const s=t[e];if(s&&s.x===i&&s.width===r)return t;const l=t.slice();return l[e]={x:i,width:r},l})},[]),ee=useCallback(e=>{if(u)return;if(e.value===V)return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),k(e.value)},[u,k,V,f]),te=T?F.colors.thumb:A?F.colors["primary-soft"]:F.colors.primary,ie=T?P:A?G:N,re=activeInkFor(F,m),se=F.colors["bg-muted"],le=useSquircle(T,W),oe=!0===l||hasFieldText(l),ne=oe&&!u,ae=F.colors["field-border-error"],de=F.size.border,ce=hasFieldText(r),ue=oe?l:s,me=hasFieldText(ue),he=_jsxs(View,{ref:e,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof r?r:void 0),testID:j,style:[L.track,{...M?{minHeight:_.height+D}:{height:_.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},T?{borderRadius:W,...smoothCorners,backgroundColor:le.active?"transparent":se,padding:R}:E?{borderBottomColor:ne?ae:F.colors["border-subtle"],borderBottomWidth:StyleSheet.hairlineWidth}:null,x],onLayout:le.onLayout,children:[le.active&&le.size?_jsx(SquircleFill,{width:le.size.width,height:le.size.height,radius:W,fill:se,stroke:ne?ae:void 0,strokeWidth:de,hostBorderWidth:0}):null,_jsxs(View,{style:L.row,children:[Q?_jsx(Animated.View,{pointerEvents:"none",style:[L.thumb,T?M?{top:0,bottom:0}:{top:0,height:_.height-2*R}:A?{top:B,bottom:B,left:B}:{bottom:0,height:H},{width:A?Math.max(Q.width-2*B,0):Q.width,borderRadius:ie,...smoothCorners,backgroundColor:te,transform:[{translateX:J}]},y]}):null,i.map((e,t)=>{const i=e.value===V,r=i?re:F.colors["text-subtle"],s=renderSlotIcon(e.icon,{color:r,size:_.icon,selected:i,disabled:u}),l=Boolean(s);return _jsxs(Pressable,{onPress:()=>ee(e),onLayout:e=>$(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:i,selected:i,disabled:u},"aria-checked":i,"aria-disabled":u,style:({pressed:e})=>[L.segment,M?L.segmentMultiline:null,{paddingHorizontal:_["padding-x"],opacity:e&&!i?.7:1},v],children:[l?_jsx(View,{style:L.segmentIcon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:s}):null,_jsx(Text,{variant:"label",weight:i?"semibold":"medium",style:[L.segmentLabel,M?L.segmentLabelMultiline:null,{color:r,fontSize:_.text},S,w],numberOfLines:z,children:e.label})]},String(e.value))})]}),!ne||E||le.active?null:_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{borderWidth:de,borderColor:ae,borderRadius:T?W:G,...smoothCorners}]})]});return ce||me?_jsxs(View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ce?_jsx(FieldLabel,{size:d,children:r}):null,he,me?_jsx(FieldMessage,{size:d,text:ue,error:oe}):null]}):he}const buildStyles=e=>StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flexGrow:1,flexShrink:1,flexBasis:"auto",flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:e.space.xs},segmentMultiline:{paddingVertical:e.space.xs},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});export{SegmentedControl};export default SegmentedControl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{SELECT_TEXT}from"../../text/phone/select.g.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{renderSlotIcon,slotIconView}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{selectOptionDescription,selectOptionDisabled,selectOptionIcon,selectOptionLabel,selectOptionValue}from"../OptionSheet/optionAccessors.js";import{Text}from"../Text/index.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t));function Select(e){assertValidValue("Select","size",e.size,["sm","md","lg"]),assertValidValue("Select","variant",e.variant,["outline","filled","underline"]);const{options:t,getOptionLabel:l,getOptionValue:i,isOptionDisabled:o,getOptionDescription:s,getOptionIcon:n,placeholder:r,onOpenChange:a,searchable:c=!1,haptic:d,labels:p,label:u,help:x,title:h,required:m=!1,error:f,helperText:g,prefix:S,numberOfLines:b=1,disabled:y=!1,size:v="md",variant:T,leftIcon:j,rightIcon:O,chevronColor:C,chevronSize:V,radius:F,accessibilityLabel:I,labelStyle:k,style:_,triggerStyle:z,textStyle:L,optionStyle:H,selectedOptionStyle:M,optionTextStyle:D,selectedOptionTextStyle:w,testID:P,ref:E}=e,R=!0===e.multi,A={...useMobileUiText("select",SELECT_TEXT),...p},B=useCallback(e=>l?l(e):selectOptionLabel(e),[l]),N=useCallback(e=>i?i(e):selectOptionValue(e),[i]),q=useCallback(e=>o?o(e):selectOptionDisabled(e),[o]),U=useCallback(e=>s?s(e):selectOptionDescription(e),[s]),X=useCallback(e=>n?n(e):selectOptionIcon(e),[n]),$=useTheme(),G=useMemo(()=>buildStyles($),[$]),J=resolveFieldSize($,v),K=resolveFieldTextStyle($,{disabled:y}),Q=T??$.settings.components.select?.defaultVariant??$.settings.components.field?.defaultVariant??"outline",[W,Y]=useState(!1),Z=useMemo(()=>{if(R){const l=e.value??[];return t.filter(e=>containsValue(l,N(e)))}const l=e.value;if(null==l)return[];const i=t.find(e=>sameSelectValue(N(e),l));return i?[i]:[]},[R,t,e.value,N]),ee=useCallback(()=>{if(y)return;const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),Y(!0)},[y,d]),te=useCallback(()=>{Y(!1)},[]),le=useCallback(t=>{if(q(t))return;const l=N(t),i=resolveHaptic(d,"selection");if(i&&triggerHaptic(i),R){const t=e.value??[],i=containsValue(t,l)?t.filter(e=>!sameSelectValue(e,l)):[...t,l];return void e.onChange(i)}e.onChange(l),te()},[R,e,te,q,N,d]),ie=0===Z.length?r??A.placeholder:Z.map(e=>B(e)).join(", "),oe=0===Z.length,se=!0===f||hasFieldText(f),ne=hasFieldText(u),re=fieldTextAsString(u),ae=Math.round(1.4*J.text),ce=useMemo(()=>({fontSize:J.text,color:K.placeholderColor}),[J.text,K.placeholderColor]),de={color:y?$.colors["field-icon-disabled"]:W?$.colors["field-icon-focus"]:$.colors["field-icon"],size:J.icon,disabled:y,focused:W,error:se},pe=0===Z.length?r??A.noSelection:fillText(A.selected,{summary:Z.map(e=>B(e)).join(", ")}),ue=I??`${re??A.fallbackName}. ${pe}`;return _jsxs(View,{style:[G.container,_],testID:P,children:[ne?_jsx(FieldLabel,{size:v,required:m,help:x,style:k,children:u}):null,_jsx(View,{ref:E,collapsable:!1,children:_jsxs(FieldBase,{size:v,variant:Q,disabled:y,error:se,filled:Z.length>0,onPress:ee,radius:F,paddingHorizontal:"underline"===Q?$.space.none:void 0,accessibilityRole:"button",accessibilityLabel:ue,accessibilityState:{disabled:y,expanded:W},"aria-disabled":y,"aria-expanded":W,style:z,slotAlign:1===b?"center":"top",slotLineHeight:1===b?void 0:ae,leading:j?slotIconView(j,renderSlotIcon(j,de)):null,trailing:O?slotIconView(O,renderSlotIcon(O,de)):_jsx(Chevron,{color:C??(y?$.colors["text-disabled"]:$.colors["text-subtle"]),size:V??J.icon,open:W,style:G.chevron}),children:[hasFieldText(S)?"string"==typeof S||"number"==typeof S?_jsx(Text,{variant:"body",style:[G.prefix,{color:K.placeholderColor,fontSize:J.text,lineHeight:1===b?void 0:ae,marginRight:$.space.xs}],children:S}):_jsx(View,{style:[G.prefixNode,{minHeight:1===b?void 0:ae,justifyContent:"center",marginRight:$.space.xs}],children:_jsx(Text,{variant:"body",style:[G.prefix,{color:K.placeholderColor,fontSize:J.text,lineHeight:1===b?void 0:ae}],children:_jsx(TextInkContext,{value:ce,children:S})})}):null,_jsxs(Text,{variant:"body",style:[G.triggerText,{color:oe?K.placeholderColor:K.color,fontSize:J.text,lineHeight:1===b?void 0:ae,...K.weightStyle},L],numberOfLines:b,children:[ie,oe&&m&&!ne?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:v,error:se,text:se?f:g}),_jsx(OptionSheet,{open:W,onClose:te,onOpenChange:a,haptic:d,title:h??re,accessibilityLabel:re??(ne?h:void 0)??r??A.sheetName,options:t,getOptionLabel:B,getOptionValue:N,isOptionDisabled:q,getOptionDescription:U,getOptionIcon:X,value:e.value,onChange:(e,t)=>le(t),multi:R,searchable:c,labels:{...void 0===A.searchPlaceholder?{}:{searchPlaceholder:A.searchPlaceholder},...void 0===A.empty?{}:{empty:A.empty}},optionStyle:H,selectedOptionStyle:M,optionTextStyle:D,selectedOptionTextStyle:w,searchSelectionColor:resolveVariantColors($,Q).borderFocusedRepresentative})]})}Select.displayName="Select";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});export{Select};export default Select;
|
|
1
|
+
"use strict";import{useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{SELECT_TEXT}from"../../text/phone/select.g.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{renderSlotIcon,slotIconView}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{selectOptionDescription,selectOptionDisabled,selectOptionIcon,selectOptionLabel,selectOptionValue}from"../OptionSheet/optionAccessors.js";import{Text}from"../Text/index.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t));function Select(e){assertValidValue("Select","size",e.size,["sm","md","lg","xl"]),assertValidValue("Select","variant",e.variant,["outline","filled","underline"]);const{options:t,getOptionLabel:l,getOptionValue:i,isOptionDisabled:o,getOptionDescription:s,getOptionIcon:n,placeholder:r,onOpenChange:a,searchable:c=!1,haptic:d,labels:p,label:u,help:x,title:h,required:m=!1,error:f,helperText:g,prefix:S,numberOfLines:b=1,disabled:y=!1,size:v="md",variant:T,leftIcon:j,rightIcon:O,chevronColor:C,chevronSize:V,radius:F,accessibilityLabel:I,labelStyle:k,style:_,triggerStyle:z,textStyle:L,optionStyle:H,selectedOptionStyle:M,optionTextStyle:D,selectedOptionTextStyle:w,testID:P,ref:E}=e,R=!0===e.multi,A={...useMobileUiText("select",SELECT_TEXT),...p},B=useCallback(e=>l?l(e):selectOptionLabel(e),[l]),N=useCallback(e=>i?i(e):selectOptionValue(e),[i]),q=useCallback(e=>o?o(e):selectOptionDisabled(e),[o]),U=useCallback(e=>s?s(e):selectOptionDescription(e),[s]),X=useCallback(e=>n?n(e):selectOptionIcon(e),[n]),$=useTheme(),G=useMemo(()=>buildStyles($),[$]),J=resolveFieldSize($,v),K=resolveFieldTextStyle($,{disabled:y}),Q=T??$.settings.components.select?.defaultVariant??$.settings.components.field?.defaultVariant??"outline",[W,Y]=useState(!1),Z=useMemo(()=>{if(R){const l=e.value??[];return t.filter(e=>containsValue(l,N(e)))}const l=e.value;if(null==l)return[];const i=t.find(e=>sameSelectValue(N(e),l));return i?[i]:[]},[R,t,e.value,N]),ee=useCallback(()=>{if(y)return;const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),Y(!0)},[y,d]),te=useCallback(()=>{Y(!1)},[]),le=useCallback(t=>{if(q(t))return;const l=N(t),i=resolveHaptic(d,"selection");if(i&&triggerHaptic(i),R){const t=e.value??[],i=containsValue(t,l)?t.filter(e=>!sameSelectValue(e,l)):[...t,l];return void e.onChange(i)}e.onChange(l),te()},[R,e,te,q,N,d]),ie=0===Z.length?r??A.placeholder:Z.map(e=>B(e)).join(", "),oe=0===Z.length,se=!0===f||hasFieldText(f),ne=hasFieldText(u),re=fieldTextAsString(u),ae=Math.round(1.4*J.text),ce=useMemo(()=>({fontSize:J.text,color:K.placeholderColor}),[J.text,K.placeholderColor]),de={color:y?$.colors["field-icon-disabled"]:W?$.colors["field-icon-focus"]:$.colors["field-icon"],size:J.icon,disabled:y,focused:W,error:se},pe=0===Z.length?r??A.noSelection:fillText(A.selected,{summary:Z.map(e=>B(e)).join(", ")}),ue=I??`${re??A.fallbackName}. ${pe}`;return _jsxs(View,{style:[G.container,_],testID:P,children:[ne?_jsx(FieldLabel,{size:v,required:m,help:x,style:k,children:u}):null,_jsx(View,{ref:E,collapsable:!1,children:_jsxs(FieldBase,{size:v,variant:Q,disabled:y,error:se,filled:Z.length>0,onPress:ee,radius:F,paddingHorizontal:"underline"===Q?$.space.none:void 0,accessibilityRole:"button",accessibilityLabel:ue,accessibilityState:{disabled:y,expanded:W},"aria-disabled":y,"aria-expanded":W,style:z,slotAlign:1===b?"center":"top",slotLineHeight:1===b?void 0:ae,leading:j?slotIconView(j,renderSlotIcon(j,de)):null,trailing:O?slotIconView(O,renderSlotIcon(O,de)):_jsx(Chevron,{color:C??(y?$.colors["text-disabled"]:$.colors["text-subtle"]),size:V??J.icon,open:W,style:G.chevron}),children:[hasFieldText(S)?"string"==typeof S||"number"==typeof S?_jsx(Text,{variant:"body",style:[G.prefix,{color:K.placeholderColor,fontSize:J.text,lineHeight:1===b?void 0:ae,marginRight:$.space.xs}],children:S}):_jsx(View,{style:[G.prefixNode,{minHeight:1===b?void 0:ae,justifyContent:"center",marginRight:$.space.xs}],children:_jsx(Text,{variant:"body",style:[G.prefix,{color:K.placeholderColor,fontSize:J.text,lineHeight:1===b?void 0:ae}],children:_jsx(TextInkContext,{value:ce,children:S})})}):null,_jsxs(Text,{variant:"body",style:[G.triggerText,{color:oe?K.placeholderColor:K.color,fontSize:J.text,lineHeight:1===b?void 0:ae,...K.weightStyle},L],numberOfLines:b,children:[ie,oe&&m&&!ne?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:v,error:se,text:se?f:g}),_jsx(OptionSheet,{open:W,onClose:te,onOpenChange:a,haptic:d,title:h??re,accessibilityLabel:re??(ne?h:void 0)??r??A.sheetName,options:t,getOptionLabel:B,getOptionValue:N,isOptionDisabled:q,getOptionDescription:U,getOptionIcon:X,value:e.value,onChange:(e,t)=>le(t),multi:R,searchable:c,labels:{...void 0===A.searchPlaceholder?{}:{searchPlaceholder:A.searchPlaceholder},...void 0===A.empty?{}:{empty:A.empty}},optionStyle:H,selectedOptionStyle:M,optionTextStyle:D,selectedOptionTextStyle:w,searchSelectionColor:resolveVariantColors($,Q).borderFocusedRepresentative})]})}Select.displayName="Select";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});export{Select};export default Select;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{formatDateTime}from"@webority/mobile-core";import{memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useCompetingGestures,usePanGesture}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{useMobileUiText}from"../../text/index.js";import{SIGNATURE_PAD_TEXT}from"../../text/phone/signaturePad.g.js";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,EXPANDED_CHROME=200,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:a,fontFamily:r,width:o,height:s})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:s*BASELINE_RATIO,fontSize:typedFontSize(o,n),fontFamily:r,textAnchor:"middle",fill:a,children:n}):null;function SignaturePadSurface({ref:e,...t}){const{expandable:n,initialStrokes:a,onChange:r,initialTypedName:o="",onTypedNameChange:s,defaultMode:i="draw",onModeChange:l,onEmptyChange:d,allowTyped:c=!0,signedBy:u,signedAt:p,height:m=DEFAULT_HEIGHT,maxNameLength:h=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:y,scriptFontFamily:f,labels:x,haptic:T="selection",disabled:S=!1,style:b,testID:_}=t;assertValidValue("SignaturePad","defaultMode",t.defaultMode,["draw","type"]);const w=useTheme(),E=void 0===g&&void 0===y,C=E?w.colors["text-body"]:g??lightTheme.colors["text-body"],A=E?w.colors.surface:y??lightTheme.colors.surface,v=E?lightTheme.colors["text-body"]:C,R=E?lightTheme.colors.surface:A,j=v!==C||R!==A,I=f??defaultScriptFont(),P=useMobileUiText("signaturePad",SIGNATURE_PAD_TEXT),k=useMemo(()=>({...P,...x}),[P,x]),D=useScreenReader(),L=useRef(null),M=useRef(null),[F,G]=useState(0),[N,B]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),O=useRef(N),H=useRef(N.length),V=useRef(null),$=useRef(null),[z,W]=useState(c?i:"draw"),[U,Y]=useState(o),[X,K]=useState(null),q=useRef(!1),{height:J}=useWindowDimensions(),[Q,Z]=useState(!1),[ee,te]=useState([]),ne=useRef({onChange:r,onTypedNameChange:s,onModeChange:l,onEmptyChange:d});useEffect(()=>{ne.current={onChange:r,onTypedNameChange:s,onModeChange:l,onEmptyChange:d}});const ae="draw"===z&&!S,re="draw"===z?0===N.length:0===U.trim().length,oe=useRef(null);useEffect(()=>{oe.current!==re&&(oe.current=re,ne.current.onEmptyChange?.(re))},[re]);const se=useCallback(e=>{O.current=e,B(e)},[]),ie=useCallback(()=>{K(Date.now()),ne.current.onChange?.(O.current.map(e=>e.points))},[]),le=useMemo(()=>{const pan=e=>({enabled:ae,runOnJS:!0,onBegin:e=>{V.current=pointOf(e.x,e.y)},onActivate:t=>{$.current=e,H.current+=1;const n=pointOf(t.x,t.y);se([...O.current,{id:H.current,points:[V.current??n,n]}])},onUpdate:t=>{if($.current!==e)return;const n=O.current[O.current.length-1];if(void 0===n)throw new Error("The stroke being drawn is missing.");const a=pointOf(t.x,t.y),r=n.points[n.points.length-1];if(void 0===r)throw new Error("A drawn stroke has no points.");distanceBetween(r,a)<.8||se([...O.current.slice(0,-1),{...n,points:[...n.points,a]}])},onFinalize:()=>{$.current===e&&($.current=null,ie())}});return{sidewaysConfig:{...pan("sideways"),activeOffsetX:[-6,6],failOffsetY:[-8,8]},restedConfig:{...pan("rested"),activateAfterLongPress:200}}},[ae,se,ie]),de=usePanGesture(le.sidewaysConfig),ce=usePanGesture(le.restedConfig),ue=useCompetingGestures(de,ce),pe=useCallback(e=>{W(e),ne.current.onModeChange?.(e),announce("type"===e?k.typingAnnouncement:k.drawingAnnouncement)},[k.typingAnnouncement,k.drawingAnnouncement]);useEffect(()=>{D&&c&&!q.current&&"draw"===z&&0===O.current.length&&pe("type")},[D,c,z,pe]);const me=useCallback(()=>{q.current=!0,pe("draw"===z?"type":"draw")},[z,pe]),he=useCallback(e=>{Y(e),K(Date.now()),ne.current.onTypedNameChange?.(e)},[]),ge=useCallback(()=>{"type"===z?he(""):(se([]),ie()),announce(k.clearedAnnouncement)},[z,he,se,ie,k.clearedAnnouncement]),ye=useCallback(()=>{"draw"===z&&0!==O.current.length&&(se(O.current.slice(0,-1)),ie(),announce(k.undoneAnnouncement))},[z,se,ie,k.undoneAnnouncement]),fe=useCallback(()=>{te(O.current.map(e=>e.points)),Z(!0)},[]),xe=useCallback(()=>{Z(!1)},[]),Te=useCallback(()=>{se(ee.map(e=>(H.current+=1,{id:H.current,points:[...e]}))),ie(),Z(!1)},[ee,se,ie]),Se=F||FALLBACK_WIDTH;useImperativeHandle(e,()=>({toFile:()=>new Promise((e,t)=>{if(re)return void t(new Error(k.emptyError));const n=j?M.current:L.current;if(!n)return void t(new Error("The signature pad is not on screen."));const a=Math.min(3,Math.max(1,PixelRatio.get()));n.toDataURL(n=>{writePng(n).then(e,t)},{width:Se*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:Se,height:m,mode:z,strokes:N.map(e=>e.points),typedName:U,ink:v,paper:R,strokeWidth:2.5,fontFamily:cssFontStack(I)}),clear:ge,undo:ye,isEmpty:()=>re}),[re,k.emptyError,Se,m,z,N,U,j,v,R,I,ge,ye]);const be=useMemo(()=>[{name:"undo",label:k.undo},{name:"clear",label:k.clear},...c?[{name:"toggleMode",label:"draw"===z?k.typeInstead:k.drawInstead}]:[]],[k.undo,k.clear,k.typeInstead,k.drawInstead,c,z]),we=useCallback(e=>{if(S)return;const{actionName:t}=e.nativeEvent;"undo"===t?ye():"clear"===t?ge():"toggleMode"===t&&c&&me()},[S,ye,ge,me,c]),Ee=useCallback(e=>{G(e.nativeEvent.layout.width)},[]),Ce=useMemo(()=>StyleSheet.create({root:{gap:w.space.sm},pad:{height:m,borderWidth:w.size.border,borderColor:w.colors.border,borderRadius:w.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:A,opacity:S?.5:1},baseline:{position:"absolute",left:w.space.md,right:w.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:C,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:w.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:w.space.xs},expandedRoot:{flex:1,padding:w.space.md,gap:w.space.sm,backgroundColor:w.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[w,m,A,C,S]),Ae=U.trim(),ve=p??X,Re=u&&!re?`Signed by ${u}${ve?`, ${formatDateTime(ve)}`:""}`:null,je="type"===z&&Ae?`${k.pad}. ${Ae}`:k.pad;return _jsxs(View,{style:[Ce.root,b],testID:_,children:[_jsx(GestureDetector,{gesture:ue,children:_jsxs(View,{style:Ce.pad,onLayout:Ee,accessible:!0,accessibilityRole:"image",accessibilityLabel:je,accessibilityHint:"draw"===z?k.padHint:void 0,accessibilityValue:{text:re?k.empty:k.signed},accessibilityState:{disabled:S},"aria-disabled":S,accessibilityActions:be,onAccessibilityAction:we,children:[j?_jsxs(Svg,{ref:M,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:R}),_jsx(Marks,{mode:z,strokes:N,name:Ae,color:v,fontFamily:I,width:Se,height:m})]}):null,_jsxs(Svg,{ref:L,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:A}),_jsx(Marks,{mode:z,strokes:N,name:Ae,color:C,fontFamily:I,width:Se,height:m})]}),_jsx(View,{pointerEvents:"none",style:Ce.baseline})]})}),"type"===z?_jsx(Input,{label:k.typedLabel,placeholder:k.typedPlaceholder,value:U,onChangeText:he,maxLength:h,disabled:S,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:_?`${_}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===z?k.caption:k.typedCaption}),_jsxs(View,{style:Ce.actions,children:[c?_jsx(Button,{label:"draw"===z?k.typeInstead:k.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:me,testID:_?`${_}-mode`:void 0}):_jsx(View,{}),"draw"===z?_jsxs(View,{style:Ce.trailing,children:[N.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:k.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:ye,testID:_?`${_}-undo`:void 0}),_jsx(Button,{label:k.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:ge,testID:_?`${_}-clear`:void 0})]}):null,n?_jsx(Button,{label:k.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:fe,testID:_?`${_}-expand`:void 0}):null]}):null,"type"===z&&Ae?_jsx(Button,{label:k.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:ge,testID:_?`${_}-clear`:void 0}):null]}),Re?_jsx(Text,{variant:"caption",color:"secondary",children:Re}):null,n?_jsx(Modal,{visible:Q,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:xe,children:_jsxs(ExpandedRoot,{style:Ce.expandedRoot,children:[_jsxs(View,{style:Ce.expandedBar,children:[_jsx(Button,{label:k.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,onPress:xe,testID:_?`${_}-close`:void 0}),_jsx(Button,{label:k.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,onPress:Te,testID:_?`${_}-done`:void 0})]}),Q?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:ee,onChange:te,height:Math.max(DEFAULT_HEIGHT,J-200),inkColor:g,paperColor:y,scriptFontFamily:f,labels:x,haptic:T,testID:_?`${_}-expanded`:void 0}):null]})}):null]})}const ExpandedRoot="android"===Platform.OS?GestureHandlerRootView:View;function SignaturePad({ref:e,...t}){return _jsx(SignaturePadSurface,{...t,expandable:!0,ref:e})}export{SignaturePad};export default SignaturePad;
|
|
1
|
+
"use strict";import{formatDateTime}from"@webority/mobile-core";import{memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useCompetingGestures,usePanGesture}from"react-native-gesture-handler";import{useSafeAreaInsets}from"react-native-safe-area-context";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{useMobileUiText}from"../../text/index.js";import{SIGNATURE_PAD_TEXT}from"../../text/phone/signaturePad.g.js";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,EXPANDED_CHROME=200,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},shiftStroke=(e,t)=>e.map(([e,n])=>pointOf(e,n+t)),defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:a,fontFamily:o,width:r,height:s})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:r/2,y:s*BASELINE_RATIO,fontSize:typedFontSize(r,n),fontFamily:o,textAnchor:"middle",fill:a,children:n}):null;function SignaturePadSurface({ref:e,...t}){const{expandable:n,initialStrokes:a,onChange:o,initialTypedName:r="",onTypedNameChange:s,defaultMode:i="draw",onModeChange:l,onEmptyChange:d,allowTyped:c=!0,signedBy:u,signedAt:p,height:m=DEFAULT_HEIGHT,maxNameLength:h=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:f,scriptFontFamily:y,labels:x,haptic:T="selection",disabled:S=!1,style:b,testID:_}=t;assertValidValue("SignaturePad","defaultMode",t.defaultMode,["draw","type"]);const E=useTheme(),w=void 0===g&&void 0===f,A=w?E.colors["text-body"]:g??lightTheme.colors["text-body"],C=w?E.colors.surface:f??lightTheme.colors.surface,v=w?lightTheme.colors["text-body"]:A,I=w?lightTheme.colors.surface:C,R=v!==A||I!==C,j=y??defaultScriptFont(),P=useMobileUiText("signaturePad",SIGNATURE_PAD_TEXT),k=useMemo(()=>({...P,...x}),[P,x]),D=useScreenReader(),L=useRef(null),M=useRef(null),[F,G]=useState(0),[B,N]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),O=useRef(B),H=useRef(B.length),V=useRef(null),$=useRef(null),[z,W]=useState(c?i:"draw"),[U,Y]=useState(r),[X,K]=useState(null),q=useRef(!1),{height:J}=useWindowDimensions(),Q=useSafeAreaInsets(),Z=Math.max(DEFAULT_HEIGHT,J-200-Q.top-Q.bottom),ee=(Z-m)*BASELINE_RATIO,[te,ne]=useState(!1),[ae,oe]=useState([]),re=useRef({onChange:o,onTypedNameChange:s,onModeChange:l,onEmptyChange:d});useEffect(()=>{re.current={onChange:o,onTypedNameChange:s,onModeChange:l,onEmptyChange:d}});const se="draw"===z&&!S,ie="draw"===z?0===B.length:0===U.trim().length,le=useRef(null);useEffect(()=>{le.current!==ie&&(le.current=ie,re.current.onEmptyChange?.(ie))},[ie]);const de=useCallback(e=>{O.current=e,N(e)},[]),ce=useCallback(()=>{K(Date.now()),re.current.onChange?.(O.current.map(e=>e.points))},[]),ue=useMemo(()=>{const pan=e=>({enabled:se,runOnJS:!0,onBegin:e=>{V.current=pointOf(e.x,e.y)},onActivate:t=>{$.current=e,H.current+=1;const n=pointOf(t.x,t.y);de([...O.current,{id:H.current,points:[V.current??n,n]}])},onUpdate:t=>{if($.current!==e)return;const n=O.current[O.current.length-1];if(void 0===n)throw new Error("The stroke being drawn is missing.");const a=pointOf(t.x,t.y),o=n.points[n.points.length-1];if(void 0===o)throw new Error("A drawn stroke has no points.");distanceBetween(o,a)<.8||de([...O.current.slice(0,-1),{...n,points:[...n.points,a]}])},onFinalize:()=>{$.current===e&&($.current=null,ce())}});return{sidewaysConfig:{...pan("sideways"),activeOffsetX:[-6,6],failOffsetY:[-8,8]},restedConfig:{...pan("rested"),activateAfterLongPress:200}}},[se,de,ce]),pe=usePanGesture(ue.sidewaysConfig),me=usePanGesture(ue.restedConfig),he=useCompetingGestures(pe,me),ge=useCallback(e=>{W(e),re.current.onModeChange?.(e),announce("type"===e?k.typingAnnouncement:k.drawingAnnouncement)},[k.typingAnnouncement,k.drawingAnnouncement]);useEffect(()=>{D&&c&&!q.current&&"draw"===z&&0===O.current.length&&ge("type")},[D,c,z,ge]);const fe=useCallback(()=>{q.current=!0,ge("draw"===z?"type":"draw")},[z,ge]),ye=useCallback(e=>{Y(e),K(Date.now()),re.current.onTypedNameChange?.(e)},[]),xe=useCallback(()=>{"type"===z?ye(""):(de([]),ce()),announce(k.clearedAnnouncement)},[z,ye,de,ce,k.clearedAnnouncement]),Te=useCallback(()=>{"draw"===z&&0!==O.current.length&&(de(O.current.slice(0,-1)),ce(),announce(k.undoneAnnouncement))},[z,de,ce,k.undoneAnnouncement]),Se=useCallback(()=>{oe(O.current.map(e=>shiftStroke(e.points,ee))),ne(!0)},[ee]),be=useCallback(()=>{ne(!1)},[]),Ee=useCallback(()=>{de(ae.map(e=>(H.current+=1,{id:H.current,points:shiftStroke(e,-ee)}))),ce(),ne(!1)},[ae,de,ce,ee]),we=F||FALLBACK_WIDTH;useImperativeHandle(e,()=>({toFile:()=>new Promise((e,t)=>{if(ie)return void t(new Error(k.emptyError));const n=R?M.current:L.current;if(!n)return void t(new Error("The signature pad is not on screen."));const a=Math.min(3,Math.max(1,PixelRatio.get()));n.toDataURL(n=>{writePng(n).then(e,t)},{width:we*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:we,height:m,mode:z,strokes:B.map(e=>e.points),typedName:U,ink:v,paper:I,strokeWidth:2.5,fontFamily:cssFontStack(j)}),clear:xe,undo:Te,isEmpty:()=>ie}),[ie,k.emptyError,we,m,z,B,U,R,v,I,j,xe,Te]);const Ae=useMemo(()=>[{name:"undo",label:k.undo},{name:"clear",label:k.clear},...c?[{name:"toggleMode",label:"draw"===z?k.typeInstead:k.drawInstead}]:[]],[k.undo,k.clear,k.typeInstead,k.drawInstead,c,z]),Ce=useCallback(e=>{if(S)return;const{actionName:t}=e.nativeEvent;"undo"===t?Te():"clear"===t?xe():"toggleMode"===t&&c&&fe()},[S,Te,xe,fe,c]),ve=useCallback(e=>{G(e.nativeEvent.layout.width)},[]),Ie=useMemo(()=>StyleSheet.create({root:{gap:E.space.sm},pad:{height:m,borderWidth:E.size.border,borderColor:E.colors.border,borderRadius:E.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:C,opacity:S?.5:1},baseline:{position:"absolute",left:E.space.md,right:E.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:E.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:E.space.xs},expandedRoot:{flex:1,padding:E.space.md,gap:E.space.sm,backgroundColor:E.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[E,m,C,A,S]),Re=U.trim(),je=p??X,Pe=u&&!ie?`Signed by ${u}${je?`, ${formatDateTime(je)}`:""}`:null,ke="type"===z&&Re?`${k.pad}. ${Re}`:k.pad;return _jsxs(View,{style:[Ie.root,b],testID:_,children:[_jsx(GestureDetector,{gesture:he,children:_jsxs(View,{style:Ie.pad,onLayout:ve,accessible:!0,accessibilityRole:"image",accessibilityLabel:ke,accessibilityHint:"draw"===z?k.padHint:void 0,accessibilityValue:{text:ie?k.empty:k.signed},accessibilityState:{disabled:S},"aria-disabled":S,accessibilityActions:Ae,onAccessibilityAction:Ce,children:[R?_jsxs(Svg,{ref:M,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:I}),_jsx(Marks,{mode:z,strokes:B,name:Re,color:v,fontFamily:j,width:we,height:m})]}):null,_jsxs(Svg,{ref:L,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:C}),_jsx(Marks,{mode:z,strokes:B,name:Re,color:A,fontFamily:j,width:we,height:m})]}),_jsx(View,{pointerEvents:"none",style:Ie.baseline})]})}),"type"===z?_jsx(Input,{label:k.typedLabel,placeholder:k.typedPlaceholder,value:U,onChangeText:ye,maxLength:h,disabled:S,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:_?`${_}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===z?k.caption:k.typedCaption}),_jsxs(View,{style:Ie.actions,children:[c?_jsx(Button,{label:"draw"===z?k.typeInstead:k.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:fe,testID:_?`${_}-mode`:void 0}):_jsx(View,{}),"draw"===z?_jsxs(View,{style:Ie.trailing,children:[B.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:k.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:Te,testID:_?`${_}-undo`:void 0}),_jsx(Button,{label:k.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:xe,testID:_?`${_}-clear`:void 0})]}):null,n?_jsx(Button,{label:k.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:Se,testID:_?`${_}-expand`:void 0}):null]}):null,"type"===z&&Re?_jsx(Button,{label:k.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:xe,testID:_?`${_}-clear`:void 0}):null]}),Pe?_jsx(Text,{variant:"caption",color:"secondary",children:Pe}):null,n?_jsx(Modal,{visible:te,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:be,children:_jsxs(ExpandedRoot,{style:[Ie.expandedRoot,{paddingTop:E.space.md+Q.top,paddingBottom:E.space.md+Q.bottom}],children:[_jsxs(View,{style:Ie.expandedBar,children:[_jsx(Button,{label:k.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,onPress:be,testID:_?`${_}-close`:void 0}),_jsx(Button,{label:k.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,onPress:Ee,testID:_?`${_}-done`:void 0})]}),te?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:ae,onChange:oe,height:Z,inkColor:g,paperColor:f,scriptFontFamily:y,labels:x,haptic:T,testID:_?`${_}-expanded`:void 0}):null]})}):null]})}const ExpandedRoot="android"===Platform.OS?GestureHandlerRootView:View;function SignaturePad({ref:e,...t}){return _jsx(SignaturePadSurface,{...t,expandable:!0,ref:e})}export{SignaturePad};export default SignaturePad;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo,useState}from"react";import{Animated,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useMobileUiText}from"../../text/index.js";import{SKELETON_TEXT}from"../../text/phone/skeleton.g.js";import{useTheme}from"../../theme/index.js";import{
|
|
1
|
+
"use strict";import{useMemo,useState}from"react";import{Animated,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useMobileUiText}from"../../text/index.js";import{SKELETON_TEXT}from"../../text/phone/skeleton.g.js";import{useTheme}from"../../theme/index.js";import{gradientBackground}from"../../theme/Gradient.js";import{useScreenDimensions}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{useSkeletonClock}from"./SkeletonClock.js";import{useSkeletonDefaults}from"./SkeletonProvider.js";import{jsx as _jsx}from"react/jsx-runtime";const resolveRadius=(e,t)=>"number"==typeof t?t:e.radius[t],resolveWidth=e=>void 0===e?"100%":e,radiusForShape=(e,t,s,o,i)=>{if(void 0!==i)return resolveRadius(e,i);switch(t){case"circle":return"number"==typeof s?Math.min(s,o)/2:o/2;case"rounded":return e.radius.md;default:return e.radius.sm}},Skeleton=e=>{const{shape:t="rect",width:s="100%",height:o=16,radius:i,variant:r,colors:n,labels:a,style:l,testID:u}=e;assertValidValue("Skeleton","shape",e.shape,["rect","rounded","circle","text"]),assertValidValue("Skeleton","variant",e.variant,["shimmer","pulse","none"]);const m=useTheme(),d=useSkeletonDefaults(),c=useSkeletonClock(),h=useReducedMotion(),p=r??d.variant??"shimmer",S=h&&"auto"===(d.animation??"auto");let k=p;c.enabled?S&&"shimmer"===p&&(k="pulse"):k="none";const x=n?.background??d.colors?.background??m.colors.skeleton,y=n?.highlight??d.colors?.highlight??m.colors["skeleton-highlight"],{responsive:b}=useScreenDimensions(),g=useMemo(()=>buildStyles(),[]),f=useMobileUiText("skeleton",SKELETON_TEXT),v=useMemo(()=>({...f,...a}),[f,a]),j=resolveWidth(s),M=b.size(o),T=radiusForShape(m,t,j,M,i),[w,V]=useState(0),R=useMemo(()=>w<=0?0:Math.max(48,.7*w),[w]),C=useMemo(()=>w<=0?0:c.shimmer.interpolate({inputRange:[0,1],outputRange:[-R,w]}),[c.shimmer,R,w]),D=useMemo(()=>"none"===k?null:"pulse"===k?_jsx(Animated.View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{backgroundColor:y,opacity:c.pulse.interpolate({inputRange:[0,1],outputRange:[0,.55]})}]}):w<=0?null:_jsx(Animated.View,{pointerEvents:"none",style:[g.shimmerBand,{width:R,transform:[{translateX:C}],backgroundImage:gradientBackground({colors:["transparent",y,"transparent"],locations:[0,.5,1],start:{x:0,y:.5},end:{x:1,y:.5}})}]}),[k,y,c.pulse,w,g.shimmerBand,R,C]);return _jsx(View,{onLayout:e=>{const t=e.nativeEvent.layout.width;t!==w&&V(t)},accessible:!0,accessibilityLabel:v.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",testID:u,style:[g.base,{width:j,height:M,borderRadius:T,...smoothCorners,backgroundColor:x},l],children:D})};Skeleton.displayName="Skeleton";const SkeletonCircle=({size:e,style:t,...s})=>{const{responsive:o}=useScreenDimensions(),i=o.size(e);return _jsx(Skeleton,{...s,shape:"circle",width:i,height:e,style:t})};SkeletonCircle.displayName="SkeletonCircle";const SkeletonText=({lines:e=3,lastLineWidth:t="60%",spacing:s,fontSize:o,variant:i,radius:r="sm",width:n="100%",labels:a,style:l,testID:u})=>{const m=useTheme(),d=s??m.space.xs,c=Math.max(1,e),h=useMemo(()=>Array.from({length:c},(e,t)=>({key:`sk-text-line-${t}`,index:t})),[c]);return _jsx(View,{style:l,testID:u,children:h.map(e=>{const s=e.index===c-1;return _jsx(Skeleton,{shape:"text",width:s&&c>1?t:n,height:o??m.text.base.size,radius:r,variant:i,labels:a,style:e.index<c-1?{marginBottom:d}:void 0},e.key)})})};SkeletonText.displayName="SkeletonText";const buildStyles=()=>StyleSheet.create({base:{overflow:"hidden"},shimmerBand:{position:"absolute",top:0,bottom:0,left:0}});export{Skeleton,SkeletonCircle,SkeletonText};export default Skeleton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useCallback,useState}from"react";import{Animated,Platform,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{squircleApplies,squirclePath}from"../../utils/squircle.js";import{jsx as _jsx}from"react/jsx-runtime";const AnimatedPath=Animated.createAnimatedComponent(Path);export function SquircleFill({width:t,height:e,radius:i,fill:
|
|
1
|
+
"use strict";import{useCallback,useState}from"react";import{Animated,Platform,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{cssSquirclePath,squircleApplies,squirclePath}from"../../utils/squircle.js";import{jsx as _jsx}from"react/jsx-runtime";const AnimatedPath=Animated.createAnimatedComponent(Path);export function SquircleFill({width:t,height:e,radius:i,fill:s,stroke:r,strokeWidth:o=0,hostBorderWidth:l,curve:a="figma",testID:h}){const n=o>0&&void 0!==r&&"transparent"!==r,c=n?o/2:0,u=useTheme().cornerSmoothing,m="css"===a?cssSquirclePath({width:t,height:e,radius:i,inset:c}):squirclePath({width:t,height:e,radius:i,inset:c,smoothing:u});return _jsx(View,{pointerEvents:"none",style:[styles.overlay,l>0?{top:-l,left:-l,right:-l,bottom:-l}:null],testID:h,children:_jsx(Svg,{width:"100%",height:"100%",viewBox:`0 0 ${t} ${e}`,preserveAspectRatio:"none",children:_jsx(AnimatedPath,{d:m,fill:s,...n?{stroke:r,strokeWidth:o}:{}})})})}SquircleFill.displayName="SquircleFill";export function useSquircle(t,e,i,s=!1){const[r,o]=useState(null),l=t&&(s||"android"===Platform.OS);return{onLayout:useCallback(t=>{if(l){const{width:e,height:i}=t.nativeEvent.layout;o(t=>t&&t.width===e&&t.height===i?t:{width:e,height:i})}i?.(t)},[l,i]),size:r,active:l&&null!==r&&squircleApplies(r.width,r.height,e)}}const styles=StyleSheet.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{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=({ref:e,...t})=>{const{value:s,defaultValue:l,onChange:i,placeholder:r,label:a,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:v,testID:y}=t;assertValidValue("TagInput","size",t.size,["sm","md","lg"]),assertValidValue("TagInput","variant",t.variant,["outline","filled","underline"]);const j=useTheme(),C=useMemo(()=>buildStyles(j),[j]),[F,S]=useControllableState({value:s,defaultValue:l??[],onChange:i}),[T,V]=useState(""),[w,I]=useState(!1),k=useRef(null),z=useMemo(()=>mergeRefs(k,e),[e]),_=useCallback(()=>{d||k.current?.focus()},[d]),B="number"==typeof m&&F.length>=m,R=!0===n||hasFieldText(n),H=u&&!a&&0===F.length&&0===T.length&&Boolean(r),M=useCallback(e=>{const t=f?f(e.trim()):e.trim();if(!t)return;if(B)return;if(x&&F.some(e=>e.toLowerCase()===t.toLowerCase()))return void V("");S([...F,t]),V("");const s=resolveHaptic(g,"selection");s&&triggerHaptic(s)},[B,g,S,F,f,x]),q=useCallback(e=>{const t=F.filter((t,s)=>s!==e);S(t);const s=resolveHaptic(g,"selection");s&&triggerHaptic(s)},[g,S,F]),D=useCallback(e=>{reportIdleActivity();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&&""===T&&F.length>0&&q(F.length-1)},[d,T,q,F.length]),P=useMemo(()=>F.map((e,t)=>({key:`${e}-${t}`,tag:e,index:t})),[F]),$=_jsx(FieldBase,{testID:y?`${y}-field`:void 0,size:c,variant:p,focused:w,disabled:d,error:R,filled:F.length>0||T.length>0,onPress:_,pressFeedback:!1,style:v,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:T,onChangeText:D,onKeyPress:L,onSubmitEditing:()=>M(T),onFocus:e=>{I(!0),b?.(e)},onBlur:()=>{I(!1),M(T)},editable:!d&&!B,placeholder:B||H?void 0:r,placeholderTextColor:j.colors["text-subtle"],submitBehavior:"submit",returnKeyType:"done",accessibilityLabel:a??r,style:[C.input,{color:j.colors["text-body"],fontSize:j.text.base.size}],testID:y?`${y}-input`:void 0}),H?_jsx(RequiredPlaceholder,{text:r??"",color:j.colors["text-subtle"],fontSize:j.text.base.size,weightStyle:fontFor(j,"normal")}):null]})]})});return _jsxs(View,{testID:y,children:[a?_jsx(FieldLabel,{size:c,required:u,children:a}):null,$,_jsx(FieldMessage,{size:c,error:R,text:R?n:o})]})};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
|
+
"use strict";import{reportIdleActivity}from"@webority/mobile-core";import{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=({ref:e,...t})=>{const{value:s,defaultValue:l,onChange:i,placeholder:r,label:a,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:v,testID:y}=t;assertValidValue("TagInput","size",t.size,["sm","md","lg","xl"]),assertValidValue("TagInput","variant",t.variant,["outline","filled","underline"]);const j=useTheme(),C=useMemo(()=>buildStyles(j),[j]),[F,S]=useControllableState({value:s,defaultValue:l??[],onChange:i}),[T,V]=useState(""),[w,I]=useState(!1),k=useRef(null),z=useMemo(()=>mergeRefs(k,e),[e]),_=useCallback(()=>{d||k.current?.focus()},[d]),B="number"==typeof m&&F.length>=m,R=!0===n||hasFieldText(n),H=u&&!a&&0===F.length&&0===T.length&&Boolean(r),M=useCallback(e=>{const t=f?f(e.trim()):e.trim();if(!t)return;if(B)return;if(x&&F.some(e=>e.toLowerCase()===t.toLowerCase()))return void V("");S([...F,t]),V("");const s=resolveHaptic(g,"selection");s&&triggerHaptic(s)},[B,g,S,F,f,x]),q=useCallback(e=>{const t=F.filter((t,s)=>s!==e);S(t);const s=resolveHaptic(g,"selection");s&&triggerHaptic(s)},[g,S,F]),D=useCallback(e=>{reportIdleActivity();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&&""===T&&F.length>0&&q(F.length-1)},[d,T,q,F.length]),P=useMemo(()=>F.map((e,t)=>({key:`${e}-${t}`,tag:e,index:t})),[F]),$=_jsx(FieldBase,{testID:y?`${y}-field`:void 0,size:c,variant:p,focused:w,disabled:d,error:R,filled:F.length>0||T.length>0,onPress:_,pressFeedback:!1,style:v,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:T,onChangeText:D,onKeyPress:L,onSubmitEditing:()=>M(T),onFocus:e=>{I(!0),b?.(e)},onBlur:()=>{I(!1),M(T)},editable:!d&&!B,placeholder:B||H?void 0:r,placeholderTextColor:j.colors["text-subtle"],submitBehavior:"submit",returnKeyType:"done",accessibilityLabel:a??r,style:[C.input,{color:j.colors["text-body"],fontSize:j.text.base.size}],testID:y?`${y}-input`:void 0}),H?_jsx(RequiredPlaceholder,{text:r??"",color:j.colors["text-subtle"],fontSize:j.text.base.size,weightStyle:fontFor(j,"normal")}):null]})]})});return _jsxs(View,{testID:y,children:[a?_jsx(FieldLabel,{size:c,required:u,children:a}):null,$,_jsx(FieldMessage,{size:c,error:R,text:R?n:o})]})};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{useCallback,useEffect,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{TIME_PICKER_TEXT}from"../../text/phone/timePicker.g.js";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import Button from"../Button/Button.js";import{Modal}from"../Modal/index.js";import{PickerTrigger}from"../PickerTrigger/PickerTrigger.js";import{Text}from"../Text/index.js";import{WheelPicker}from"../WheelPicker/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const range=(e,t,i=1)=>{const r=[];for(let a=e;a<=t;a+=i)r.push(a);return r},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},TimePicker=e=>{const{open:t,value:i,onChange:r,onClose:a,format:s="12h",minuteStep:l=1,labels:o,testID:n,style:m,sheetStyle:u,headerLabelStyle:c,footerButtonStyle:p,formatValue:d,haptic:h,triggerLabels:b,label:f,help:g,placeholder:y,helperText:x,error:M,required:S,disabled:T,size:k,variant:P,clearable:j,onClear:v,leftIcon:H,trailing:I,triggerStyle:_,valueStyle:V,labelStyle:C,messageStyle:D,accessibilityLabel:w}=e,B={label:f,help:g,placeholder:y,helperText:x,error:M,required:S,disabled:T,size:k,variant:P,clearable:j,onClear:v,leftIcon:H,trailing:I,triggerStyle:_,valueStyle:V,labelStyle:C,messageStyle:D,accessibilityLabel:w,style:m};assertValidValue("TimePicker","format",e.format,["12h","24h"]),assertValidValue("TimePicker","minuteStep",e.minuteStep?.toString(),["1","5","15","30"]),assertValidValue("TimePicker","size",e.size,["sm","md","lg"]),assertValidValue("TimePicker","variant",e.variant,["outline","filled","underline"]);const $=useMobileUiText("timePicker",TIME_PICKER_TEXT),A=useMemo(()=>({...$,...o}),[$,o]),F=void 0!==t,[L,E]=useState(!1),N=F?t:L,O=F?n:n?`${n}-modal`:void 0,z=useTheme(),W=useMemo(()=>buildStyles(z),[z]),R=useCallback(()=>{F?a?.():E(!1)},[F,a]),U=useMemo(()=>"24h"===s?range(0,23):range(1,12),[s]),q=useMemo(()=>range(0,59,l),[l]),K=useMemo(()=>["AM","PM"],[]),X=useMemo(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,l),{displayHour:a,period:o}=from24h(e,s);return{displayHour:a,minute:r,period:o,hour24:e}},[i,s,l]),[G,J]=useState(()=>{const e=U.indexOf(X.displayHour);return Math.max(e,0)}),[Q,Y]=useState(()=>{const e=q.indexOf(X.minute);return Math.max(e,0)}),[Z,ee]=useState(()=>"PM"===X.period?1:0);useEffect(()=>{if(!N)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,l),{displayHour:a,period:o}=from24h(e,s),n=U.indexOf(a);J(Math.max(n,0));const m=q.indexOf(r);Y(Math.max(m,0)),ee("PM"===o?1:0)},[N,i,s,l,U,q]);const te=useCallback((e,t)=>{"hour"===e?J(Math.max(0,U.indexOf(Number(t)))):"minute"===e?Y(Math.max(0,q.indexOf(Number(t)))):ee("PM"===t?1:0)},[U,q]),ie=useCallback(()=>{!1!==h&&triggerHaptic("selection"),R()},[R,h]),re=useCallback(()=>{const e=U[G]??0,t=K[Z]??"AM",i=to24h(e,t,s),a=q[Q]??0;!1!==h&&triggerHaptic("notificationSuccess"),r?.({hour:i,minute:a}),R()},[U,G,K,Z,q,Q,s,r,R,h]),ae=useMemo(()=>{const e=U[G]??0,t=q[Q]??0;if("24h"===s)return`${pad2(e)}:${pad2(t)}`;const i=K[Z]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[U,G,q,Q,K,Z,s]),se=useMemo(()=>U.map(e=>({value:e,label:pad2(e),accessibilityLabel:fillText(A.hourItem,{hour:e})})),[U,A]),le=useMemo(()=>q.map(e=>({value:e,label:pad2(e),accessibilityLabel:fillText(A.minuteItem,{minute:e})})),[q,A]),oe=useMemo(()=>K.map(e=>({value:e,label:e})),[K]),ne=useMemo(()=>{const e=[{key:"hour",label:A.hour,items:se,value:U[G]??0,separator:":",testID:"time-picker-hour"},{key:"minute",label:A.minute,items:le,value:q[Q]??0,gapAfter:"12h"===s?z.space.md:void 0,testID:"time-picker-minute"}];return"12h"===s&&e.push({key:"period",label:A.period,items:oe,value:K[Z]??"AM",testID:"time-picker-period"}),e},[se,le,oe,U,G,q,Q,K,Z,s,z.space.md,A]),me=useCallback(e=>{if("24h"===s)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[s]),ue=!F&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(d??me)(i):void 0,ce=_jsxs(Modal,{open:N,onClose:R,presentation:"bottom",accessibilityLabel:A.title,haptic:h,contentStyle:u,testID:O,children:[_jsx(Text,{variant:"title",align:"center",accessibilityRole:"header",style:[W.title,c],children:A.title}),_jsx(View,{style:W.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:fillText(A.selected,{summary:ae}),children:_jsx(Text,{variant:"h2",weight:"bold",color:"brand",style:W.summary,children:ae})}),_jsx(WheelPicker,{columns:ne,onChange:te,haptic:h,style:W.wheels}),_jsxs(View,{style:W.footer,children:[_jsx(Button,{label:A.cancel,haptic:!1,variant:"ghost",tone:"neutral",onPress:ie,style:[W.footerBtn,p],accessibilityHint:A.cancelHint,testID:"time-picker-cancel"}),_jsx(Button,{label:A.confirm,variant:"solid",tone:"primary",haptic:!1,onPress:re,style:[W.footerBtn,p],accessibilityHint:A.confirmHint,testID:"time-picker-confirm"})]})]});return F?ce:_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...B,labels:b,value:ue,onPress:()=>E(!0),testID:n}),ce]})},buildStyles=e=>StyleSheet.create({title:{marginBottom:e.space.sm},summaryWrap:{alignItems:"center",marginBottom:e.space.md},summary:{letterSpacing:e["letter-spacing"].wide},wheels:{marginBottom:e.space.lg},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg}});export{TimePicker};export default TimePicker;
|
|
1
|
+
"use strict";import{useCallback,useEffect,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{TIME_PICKER_TEXT}from"../../text/phone/timePicker.g.js";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import Button from"../Button/Button.js";import{Modal}from"../Modal/index.js";import{PickerTrigger}from"../PickerTrigger/PickerTrigger.js";import{Text}from"../Text/index.js";import{WheelPicker}from"../WheelPicker/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const range=(e,t,i=1)=>{const r=[];for(let a=e;a<=t;a+=i)r.push(a);return r},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},TimePicker=e=>{const{open:t,value:i,onChange:r,onClose:a,format:s="12h",minuteStep:l=1,labels:o,testID:n,style:m,sheetStyle:u,headerLabelStyle:c,footerButtonStyle:p,formatValue:d,haptic:h,triggerLabels:b,label:f,help:g,placeholder:y,helperText:x,error:M,required:S,disabled:T,size:k,variant:P,clearable:j,onClear:v,leftIcon:H,trailing:I,triggerStyle:_,valueStyle:V,labelStyle:C,messageStyle:D,accessibilityLabel:w}=e,B={label:f,help:g,placeholder:y,helperText:x,error:M,required:S,disabled:T,size:k,variant:P,clearable:j,onClear:v,leftIcon:H,trailing:I,triggerStyle:_,valueStyle:V,labelStyle:C,messageStyle:D,accessibilityLabel:w,style:m};assertValidValue("TimePicker","format",e.format,["12h","24h"]),assertValidValue("TimePicker","minuteStep",e.minuteStep?.toString(),["1","5","15","30"]),assertValidValue("TimePicker","size",e.size,["sm","md","lg","xl"]),assertValidValue("TimePicker","variant",e.variant,["outline","filled","underline"]);const $=useMobileUiText("timePicker",TIME_PICKER_TEXT),A=useMemo(()=>({...$,...o}),[$,o]),F=void 0!==t,[L,E]=useState(!1),N=F?t:L,O=F?n:n?`${n}-modal`:void 0,z=useTheme(),W=useMemo(()=>buildStyles(z),[z]),R=useCallback(()=>{F?a?.():E(!1)},[F,a]),U=useMemo(()=>"24h"===s?range(0,23):range(1,12),[s]),q=useMemo(()=>range(0,59,l),[l]),K=useMemo(()=>["AM","PM"],[]),X=useMemo(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,l),{displayHour:a,period:o}=from24h(e,s);return{displayHour:a,minute:r,period:o,hour24:e}},[i,s,l]),[G,J]=useState(()=>{const e=U.indexOf(X.displayHour);return Math.max(e,0)}),[Q,Y]=useState(()=>{const e=q.indexOf(X.minute);return Math.max(e,0)}),[Z,ee]=useState(()=>"PM"===X.period?1:0);useEffect(()=>{if(!N)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,l),{displayHour:a,period:o}=from24h(e,s),n=U.indexOf(a);J(Math.max(n,0));const m=q.indexOf(r);Y(Math.max(m,0)),ee("PM"===o?1:0)},[N,i,s,l,U,q]);const te=useCallback((e,t)=>{"hour"===e?J(Math.max(0,U.indexOf(Number(t)))):"minute"===e?Y(Math.max(0,q.indexOf(Number(t)))):ee("PM"===t?1:0)},[U,q]),ie=useCallback(()=>{!1!==h&&triggerHaptic("selection"),R()},[R,h]),re=useCallback(()=>{const e=U[G]??0,t=K[Z]??"AM",i=to24h(e,t,s),a=q[Q]??0;!1!==h&&triggerHaptic("notificationSuccess"),r?.({hour:i,minute:a}),R()},[U,G,K,Z,q,Q,s,r,R,h]),ae=useMemo(()=>{const e=U[G]??0,t=q[Q]??0;if("24h"===s)return`${pad2(e)}:${pad2(t)}`;const i=K[Z]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[U,G,q,Q,K,Z,s]),se=useMemo(()=>U.map(e=>({value:e,label:pad2(e),accessibilityLabel:fillText(A.hourItem,{hour:e})})),[U,A]),le=useMemo(()=>q.map(e=>({value:e,label:pad2(e),accessibilityLabel:fillText(A.minuteItem,{minute:e})})),[q,A]),oe=useMemo(()=>K.map(e=>({value:e,label:e})),[K]),ne=useMemo(()=>{const e=[{key:"hour",label:A.hour,items:se,value:U[G]??0,separator:":",testID:"time-picker-hour"},{key:"minute",label:A.minute,items:le,value:q[Q]??0,gapAfter:"12h"===s?z.space.md:void 0,testID:"time-picker-minute"}];return"12h"===s&&e.push({key:"period",label:A.period,items:oe,value:K[Z]??"AM",testID:"time-picker-period"}),e},[se,le,oe,U,G,q,Q,K,Z,s,z.space.md,A]),me=useCallback(e=>{if("24h"===s)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[s]),ue=!F&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(d??me)(i):void 0,ce=_jsxs(Modal,{open:N,onClose:R,presentation:"bottom",accessibilityLabel:A.title,haptic:h,contentStyle:u,testID:O,children:[_jsx(Text,{variant:"title",align:"center",accessibilityRole:"header",style:[W.title,c],children:A.title}),_jsx(View,{style:W.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:fillText(A.selected,{summary:ae}),children:_jsx(Text,{variant:"h2",weight:"bold",color:"brand",style:W.summary,children:ae})}),_jsx(WheelPicker,{columns:ne,onChange:te,haptic:h,style:W.wheels}),_jsxs(View,{style:W.footer,children:[_jsx(Button,{label:A.cancel,haptic:!1,variant:"ghost",tone:"neutral",onPress:ie,style:[W.footerBtn,p],accessibilityHint:A.cancelHint,testID:"time-picker-cancel"}),_jsx(Button,{label:A.confirm,variant:"solid",tone:"primary",haptic:!1,onPress:re,style:[W.footerBtn,p],accessibilityHint:A.confirmHint,testID:"time-picker-confirm"})]})]});return F?ce:_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...B,labels:b,value:ue,onPress:()=>E(!0),testID:n}),ce]})},buildStyles=e=>StyleSheet.create({title:{marginBottom:e.space.sm},summaryWrap:{alignItems:"center",marginBottom:e.space.md},summary:{letterSpacing:e["letter-spacing"].wide},wheels:{marginBottom:e.space.lg},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg}});export{TimePicker};export default TimePicker;
|
package/lib/module/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{PHONE_CHROME_INSETS}from"./canvasKit/index.js";export{Accordion,AccordionGroup,ALL_CALLING_CODES,AmountSlider,AnimatePresence,AppBar,AppLockOverlay,AsyncBlock,AuthedImage,Autocomplete,Avatar,AvatarGroup,authedImageCacheStats,Badge,Banner,BarChart,BottomNavigation,BottomSheet,Box,Button,buttonLabelInk,Calendar,Card,Carousel,Checkbox,Chip,ChoiceGroup,Composer,Confetti,ConfirmHost,clearAuthedImageCache,confirm,DatePicker,DateRangePicker,DateSeparator,DEFAULT_CALLING_CODES,DecimalInput,Descriptions,Dialog,Divider,Drawer,defineStatusMap,EmptyState,ErrorBoundary,FilePicker,FileViewer,FilterChipRow,FloatingActionButton,FloatingActionButtonGroup,ForceUpdateDialog,FormField,formatE164,formatFileSize,getAuthedImageCacheLimit,IconBadge,IconButton,IdleTimeoutDialog,ImageGallery,InlineSelect,Input,KeyboardAwareScrollView,KeyboardToolbar,ListItem,ListSection,LoaderOverlay,loader,Markdown,Menu,MessageBubble,MessageList,MODAL_DISMISS_GRACE_MS,Modal,NonModalBottomSheet,NumberInput,OnboardingPager,OptionSheet,OTPInput,OTPResendRow,OutboxEntryList,PagedList,PagedListFooter,PermissionPrompt,PhoneNumberInput,PickerTrigger,ProfileCompletion,ProfilePicker,ProgressBar,ProgressRing,Radio,RadioDot,RadioGroup,Rating,Repeater,RichTextEditor,Row,ScannerOverlay,Screen,SearchBar,SectionHeader,SegmentedControl,Select,SignaturePad,Skeleton,SkeletonCircle,SkeletonClockProvider,SkeletonContent,SkeletonList,SkeletonProvider,SkeletonSkip,SkeletonText,Slider,SliderField,SlideToConfirm,SortableList,Spacer,Sparkline,Spinner,SquircleImage,SquircleView,Stack,StatTile,StatusBadge,Stepper,Swipeable,Switch,setAuthedImageCacheLimit,Tabs,TagInput,Text,TextInkContext,Timeline,TimePicker,Toast,ToastHost,ToastProvider,Tooltip,Tour,TypingIndicator,toast,useBottomSheet,useErrorHandler,useRecentSearches,useTextInk,useToast,WheelPicker,withErrorBoundary,ZoomableImage}from"./components/index.js";export{AppIcon,ICONSAX_SUFFIX,isAppIconName}from"./components/AppIcon/index.js";export{BUTTON_TONES,BUTTON_VARIANTS,isButtonTone,isButtonVariant}from"./components/Button/index.js";export{HookFormField,useHookFormField}from"./form/index.js";export{useDebounce,useFieldChain,useReducedMotion,useRefreshControl,useScrollDirection}from"./hooks/index.js";export{NetworkStatusBanner}from"./network/index.js";export*from"./text/index.js";export{setMobileUiText,useMobileUiText}from"./text/index.js";export{fontFor,KitThemeBridge,lightTheme,makeStyles,radiusOf,ThemeProvider,useTheme,useThemeMode}from"./theme/index.js";export{announce,configureFeedback,isFeedbackEnabled,setHapticImplementation,triggerHaptic}from"./utils/index.js";
|
|
1
|
+
"use strict";export{PHONE_CHROME_INSETS}from"./canvasKit/index.js";export{Accordion,AccordionGroup,ALL_CALLING_CODES,AmountSlider,AnimatePresence,AppBar,AppLockOverlay,AsyncBlock,AuthedImage,Autocomplete,Avatar,AvatarGroup,authedImageCacheStats,Badge,Banner,BarChart,BottomNavigation,BottomSheet,Box,Button,buttonLabelInk,Calendar,Card,Carousel,Checkbox,Chip,ChoiceGroup,Composer,Confetti,ConfirmHost,clearAuthedImageCache,confirm,DatePicker,DateRangePicker,DateSeparator,DEFAULT_CALLING_CODES,DecimalInput,Descriptions,Dialog,Divider,Drawer,defineStatusMap,EmptyState,ErrorBoundary,FilePicker,FileViewer,FilterChipRow,FloatingActionButton,FloatingActionButtonGroup,ForceUpdateDialog,FormField,formatE164,formatFileSize,getAuthedImageCacheLimit,IconBadge,IconButton,IdleTimeoutDialog,ImageGallery,InlineSelect,Input,KeyboardAwareScrollView,KeyboardToolbar,ListItem,ListSection,LoaderOverlay,loader,Markdown,Menu,MessageBubble,MessageList,MODAL_DISMISS_GRACE_MS,Modal,NonModalBottomSheet,NumberInput,OnboardingPager,OptionSheet,OTPInput,OTPResendRow,OutboxEntryList,PagedList,PagedListFooter,PermissionPrompt,PhoneNumberInput,PickerTrigger,ProfileCompletion,ProfilePicker,ProgressBar,ProgressRing,Radio,RadioDot,RadioGroup,Rating,Repeater,RichTextEditor,Row,ScannerOverlay,Screen,SearchBar,SectionHeader,SegmentedControl,Select,SignaturePad,Skeleton,SkeletonCircle,SkeletonClockProvider,SkeletonContent,SkeletonList,SkeletonProvider,SkeletonSkip,SkeletonText,Slider,SliderField,SlideToConfirm,SortableList,Spacer,Sparkline,Spinner,SquircleImage,SquircleView,Stack,StatTile,StatusBadge,Stepper,Swipeable,Switch,setAuthedImageCacheLimit,Tabs,TagInput,Text,TextInkContext,Timeline,TimePicker,Toast,ToastHost,ToastProvider,Tooltip,Tour,TypingIndicator,toast,useBottomSheet,useErrorHandler,useRecentSearches,useTextInk,useToast,WheelPicker,withErrorBoundary,ZoomableImage}from"./components/index.js";export{AppIcon,ICONSAX_SUFFIX,isAppIconName}from"./components/AppIcon/index.js";export{BUTTON_SHAPES,BUTTON_TONES,BUTTON_VARIANTS,isButtonTone,isButtonVariant}from"./components/Button/index.js";export{HookFormField,useHookFormField}from"./form/index.js";export{useDebounce,useFieldChain,useReducedMotion,useRefreshControl,useScrollDirection}from"./hooks/index.js";export{NetworkStatusBanner}from"./network/index.js";export*from"./text/index.js";export{setMobileUiText,useMobileUiText}from"./text/index.js";export{fontFor,KitThemeBridge,lightTheme,makeStyles,radiusOf,ThemeProvider,useTheme,useThemeMode}from"./theme/index.js";export{announce,configureFeedback,isFeedbackEnabled,setHapticImplementation,triggerHaptic}from"./utils/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_START={x:.5,y:0},DEFAULT_END={x:.5,y:1},round=t=>Math.round(1e3*t)/1e3;export const gradientAngle=(t=DEFAULT_START,
|
|
1
|
+
"use strict";import{Platform,View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_START={x:.5,y:0},DEFAULT_END={x:.5,y:1},round=t=>Math.round(1e3*t)/1e3;export const gradientAngle=(t=DEFAULT_START,o=DEFAULT_END)=>{const r=180*Math.atan2(o.x-t.x,t.y-o.y)/Math.PI;return round((r%360+360)%360)};export const toBackgroundImage=t=>{const o=t.colors.length-1;return{type:"linear-gradient",direction:`${gradientAngle(t.start,t.end)}deg`,colorStops:t.colors.map((r,n)=>{const e=t.locations?.[n]??(0===o?0:n/o);return{color:r,positions:[`${round(100*e)}%`]}})}};export const toCssGradient=t=>{const o=toBackgroundImage(t),r=o.colorStops.map(t=>[t.color,...t.positions??[]].join(" "));return`linear-gradient(${o.direction}, ${r.join(", ")})`};export const gradientBackground=t=>"web"===Platform.OS?toCssGradient(t):[toBackgroundImage(t)];export const Gradient=({gradient:t,style:o,children:r})=>_jsx(View,{style:[{backgroundImage:gradientBackground(t)},o],children:r});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export{createAnimatedValue,setNativeValue}from"./animatedValue.js";export{resolveBadgeSize,resolveButtonSize,resolveCheckboxSize,resolveChipSize,resolveEmptyStateSize,resolveFieldSize,resolveFloatingActionButtonSize,resolveListItemSize,resolveOtpInputSize,resolveRadioSize,resolveSegmentedControlSize,resolveSliderSize,resolveSwitchSize,resolveTabsSize,validateComponentTokens}from"./componentSizes.js";export{Gradient,gradientAngle,toBackgroundImage}from"./Gradient.js";export{makeStyles}from"./makeStyles.js";export{mergeBrand}from"./merge.js";export{radiusOf,spaceOf,textOf}from"./scale.js";export{KitThemeBridge,ThemeProvider,useTheme,useThemeMode}from"./ThemeContext.js";export{fontFor}from"./textStyle.js";export{darkTheme,lightTheme}from"./tokens.js";export{COLOR_NAMES,DURATION_NAMES,EASE_NAMES,FONT_NAMES,LEADING_NAMES,LETTER_SPACING_NAMES,RADIUS_NAMES,SHADOW_NAMES,SIZE_NAMES,SPACE_NAMES,TEXT_NAMES,WEIGHT_NAMES}from"./tokens.generated.js";
|
|
1
|
+
"use strict";export{createAnimatedValue,setNativeValue}from"./animatedValue.js";export{resolveBadgeSize,resolveButtonSize,resolveCheckboxSize,resolveChipSize,resolveEmptyStateSize,resolveFieldSize,resolveFloatingActionButtonSize,resolveListItemSize,resolveOtpInputSize,resolveRadioSize,resolveSegmentedControlSize,resolveSliderSize,resolveSwitchSize,resolveTabsSize,validateComponentTokens}from"./componentSizes.js";export{Gradient,gradientAngle,gradientBackground,toBackgroundImage,toCssGradient}from"./Gradient.js";export{makeStyles}from"./makeStyles.js";export{mergeBrand}from"./merge.js";export{radiusOf,spaceOf,textOf}from"./scale.js";export{KitThemeBridge,ThemeProvider,useTheme,useThemeMode}from"./ThemeContext.js";export{fontFor}from"./textStyle.js";export{darkTheme,lightTheme}from"./tokens.js";export{COLOR_NAMES,DURATION_NAMES,EASE_NAMES,FONT_NAMES,LEADING_NAMES,LETTER_SPACING_NAMES,RADIUS_NAMES,SHADOW_NAMES,SIZE_NAMES,SPACE_NAMES,TEXT_NAMES,WEIGHT_NAMES}from"./tokens.generated.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const COLOR_NAMES=["bg","bg-subtle","bg-muted","surface","surface-inverse","surface-dark","surface-dark-border","on-surface-dark","on-surface-dark-muted","surface-ink","text","text-body","text-muted","text-subtle","text-inverse","link","border","border-subtle","field-bg","field-border","field-border-focus","focus-ring","scrim","on-scrim","thumb","primary","primary-hover","primary-pressed","primary-soft","primary-text","on-primary","primary-wash","primary-wash-strong","neutral","neutral-hover","neutral-text","on-neutral","success","success-soft","success-text","on-success","warning","warning-soft","warning-text","on-warning","danger","danger-soft","danger-border","danger-text","offline-fill","online-fill","on-danger","info","info-soft","info-text","on-info","switch-thumb","on-neutral-strong","text-disabled","surface-pressed","surface-hover","surface-selected","surface-disabled","skeleton","skeleton-highlight","glass-fill","glass-border","on-glass","glass-badge","field-bg-focus","field-bg-disabled","field-border-error","field-label","field-text","field-text-disabled","field-placeholder","field-placeholder-disabled","field-icon","field-icon-focus","field-icon-disabled","field-caret","field-message","avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"];export const SPACE_NAMES=["none","xxs","xs","sm","md","lg","xl","2xl","3xl","4xl"];export const RADIUS_NAMES=["none","sm","md","lg","xl","2xl","3xl","pill"];export const TEXT_NAMES=["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl"];export const WEIGHT_NAMES=["normal","medium","semibold","bold"];export const LEADING_NAMES=["heading","body","display"];export const LETTER_SPACING_NAMES=["tight","normal","wide"];export const FONT_NAMES=["ui","display","mono"];export const SHADOW_NAMES=["card","elevated","popover","modal","drawer"];export const DURATION_NAMES=["instant","fast","default","slow","slower"];export const EASE_NAMES=["in-out","accelerate","decelerate","sharp"];export const SIZE_NAMES=["border"];export const COMPONENT_KINDS={field:{radius:"radius","padding-x":"space","padding-y":"space","min-height":"px",text:"text",icon:"px","label-text":"text","label-gap":"space","message-text":"text","message-gap":"space"},press:{opacity:"number"},disabled:{opacity:"number"},button:{"padding-x":"space","padding-y":"space","min-height":"px",text:"text",radius:"radius",icon:"px","badge-icon":"px"},input:{"multiline-min-height":"px"},"search-bar":{radius:"radius"},"empty-state":{icon:"px","illustration-size":"px","title-text":"text","description-text":"text","padding-y":"space","title-gap":"space","description-gap":"space"},"list-item":{"padding-y":"space","title-text":"text","subtitle-text":"text","min-height":"px"},badge:{text:"text","min-width":"px",height:"px","padding-x":"space","dot-size":"px","border-width":"px","anchor-offset":"px"},chip:{"padding-x":"space","padding-y":"space",text:"text","min-height":"px","close-size":"px","close-text":"text",gap:"space",icon:"px"},checkbox:{"box-size":"px","label-gap":"space"},radio:{outer:"px",inner:"px","label-gap":"space"},switch:{"track-width":"px","track-height":"px","thumb-size":"px",padding:"space"},"otp-input":{cell:"px",text:"text",radius:"radius",gap:"space"},"segmented-control":{height:"px",text:"text","padding-x":"space",icon:"px","track-padding":"space","underline-height":"px","pill-inset":"space"},tabs:{text:"text","padding-y":"space","padding-x":"space","scrollable-padding-x":"space",icon:"px","icon-gap":"space","track-padding":"space","underline-height":"px","pill-inset":"space","disabled-opacity":"number","badge-gap":"space"},slider:{"track-height":"px","thumb-diameter":"px"},"floating-action-button":{diameter:"px",icon:"px",text:"text","label-padding-x":"space","edge-offset":"space","bottom-offset":"space","secondary-gap":"space","stagger-ms":"ms"},dialog:{"icon-wrapper-size":"px","action-button-min-height":"px"},toast:{"icon-circle-size":"px","icon-glyph-text":"text","tint-bar-width":"px","action-min-height":"px"},banner:{"tint-bar-width":"px"},screen:{gutter:"space"}};export const lightTokens={mode:"light",colors:{bg:"#ffffff","bg-subtle":"#f8f8fb","bg-muted":"#f1f1f5",surface:"#ffffff","surface-inverse":"#0f0f1a","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7","surface-ink":"#0b0e16",text:"#252f4a","text-body":"#0f0f1a","text-muted":"#52525b","text-subtle":"#62626b","text-inverse":"#ffffff",link:"#4f46e5",border:"#e5e5ec","border-subtle":"#efeff3","field-bg":"#f9fbfc","field-border":"#ebedf3","field-border-focus":"#bed2f9","focus-ring":"#4f46e5",scrim:"#0f0f1a80","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#4f46e5","primary-hover":"#4338ca","primary-pressed":"#3730a3","primary-soft":"#e0e7ff","primary-text":"#4f46e5","on-primary":"#ffffff","primary-wash":"#4f46e514","primary-wash-strong":"#4f46e533",neutral:"#f4f4f8","neutral-hover":"#e9e9f0","neutral-text":"#52525b","on-neutral":"#0f0f1a",success:"#18864f","success-soft":"#e8faee","success-text":"#147042","on-success":"#ffffff",warning:"#f59e0b","warning-soft":"#fff8e6","warning-text":"#8f5c06","on-warning":"#0f0f1a",danger:"#e12c32","danger-soft":"#ffeaef","danger-border":"#e5484d","danger-text":"#bc1b20","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#ffffff",info:"#1b6ef5","info-soft":"#e9f3ff","info-text":"#0958d9","on-info":"#ffffff","switch-thumb":"#ffffff","on-neutral-strong":"#ffffff","text-disabled":"#b4b4bb","surface-pressed":"#0f0f1a0f","surface-hover":"#0f0f1a0a","surface-selected":"#4f46e51a","surface-disabled":"#f1f1f5",skeleton:"#ebedf3","skeleton-highlight":"#f5f6fa","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#ffffff","field-bg-disabled":"#f5f6fa","field-border-error":"#fdbfce","field-label":"#242f4a","field-text":"#252f4a","field-text-disabled":"#7a8197","field-placeholder":"#626d8b","field-placeholder-disabled":"#7a8197","field-icon":"#7a849f","field-icon-focus":"#4b5675","field-icon-disabled":"#c4cada","field-caret":"#5b8dee","field-message":"#d81736","avatar-1":"#4f46e5","avatar-2":"#0a7979","avatar-3":"#a45a05","avatar-4":"#cd226e","avatar-5":"#2462eb","avatar-6":"#7c3aed","avatar-7":"#047c57","avatar-8":"#d42222"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,"2xl":18,"3xl":20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.059,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.078,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.102,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":35,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":40,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"sm","min-height":45,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}};export const darkTokens={mode:"dark",colors:{bg:"#0b0b12","bg-subtle":"#13131c","bg-muted":"#1c1c26",surface:"#1c1c26","surface-inverse":"#fafafa","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7","surface-ink":"#0b0e16",text:"#e2e2e2","text-body":"#fafafa","text-muted":"#b4b4bb","text-subtle":"#919199","text-inverse":"#0f0f1a",link:"#9292ee",border:"#27272f","border-subtle":"#1c1c26","field-bg":"#13131c","field-border":"#27272f","field-border-focus":"#3d5fb0","focus-ring":"#7c7ce8",scrim:"#000000a6","on-scrim":"#ffffff",thumb:"#3a3e49",primary:"#7c7ce8","primary-hover":"#9292ee","primary-pressed":"#a8a8f2","primary-soft":"#1f1f3d","primary-text":"#8989ea","on-primary":"#0f0f1a","primary-wash":"#7c7ce814","primary-wash-strong":"#7c7ce833",neutral:"#1f1f26","neutral-hover":"#2a2a33","neutral-text":"#b4b4bb","on-neutral":"#fafafa",success:"#30c780","success-soft":"#04b4402e","success-text":"#30c780","on-success":"#0f0f1a",warning:"#fbbf24","warning-soft":"#dfa0002e","warning-text":"#fbbf24","on-warning":"#0f0f1a",danger:"#f87171","danger-soft":"#e826462e","danger-border":"#f87171","danger-text":"#f87171","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#0f0f1a",info:"#60a5fa","info-soft":"#056ee92e","info-text":"#60a5fa","on-info":"#0f0f1a","switch-thumb":"#ffffff","on-neutral-strong":"#0f0f1a","text-disabled":"#52525b","surface-pressed":"#ffffff14","surface-hover":"#ffffff0d","surface-selected":"#7c7ce82e","surface-disabled":"#1c1c26",skeleton:"#1c1c26","skeleton-highlight":"#27272f","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#0b0b12","field-bg-disabled":"#1c1c26","field-border-error":"#8a2f42","field-label":"#e4e6ee","field-text":"#fafafa","field-text-disabled":"#71717a","field-placeholder":"#84848d","field-placeholder-disabled":"#71717a","field-icon":"#8b8b95","field-icon-focus":"#d4d4db","field-icon-disabled":"#52525b","field-caret":"#7c9ef0","field-message":"#f87171","avatar-1":"#8b8bee","avatar-2":"#2dd4bf","avatar-3":"#fcd34d","avatar-4":"#f472b6","avatar-5":"#60a5fa","avatar-6":"#a78bfa","avatar-7":"#34d399","avatar-8":"#f87171"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:6,md:10,lg:14,xl:20,"2xl":18,"3xl":20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.4,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.502,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.549,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"md","padding-x":"sm","padding-y":"sm","min-height":38,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"md","padding-x":"md","padding-y":"md","min-height":44,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"md","padding-x":"lg","padding-y":"lg","min-height":52,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{xs:{"padding-x":"sm","padding-y":"xs","min-height":28,text:"xs",radius:"md",icon:14,"badge-icon":11},sm:{"padding-x":"md","padding-y":"xs","min-height":35,text:"sm",radius:"md",icon:16,"badge-icon":16},md:{"padding-x":"lg","padding-y":"sm","min-height":40,text:"base",radius:"md",icon:18,"badge-icon":18},lg:{"padding-x":"xl","padding-y":"sm","min-height":45,text:"lg",radius:"lg",icon:20,"badge-icon":20},xl:{"padding-x":"2xl","padding-y":"md","min-height":50,text:"lg",radius:"lg",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110}},"search-bar":{sm:{radius:"pill"},md:{radius:"pill"},lg:{radius:"pill"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"sm",gap:"sm"},md:{cell:48,text:"xl",radius:"md",gap:"sm"},lg:{cell:56,text:"2xl",radius:"lg",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}};
|
|
1
|
+
"use strict";export const COLOR_NAMES=["bg","bg-subtle","bg-muted","surface","surface-inverse","surface-dark","surface-dark-border","on-surface-dark","on-surface-dark-muted","surface-ink","text","text-body","text-muted","text-subtle","text-inverse","link","border","border-subtle","field-bg","field-border","field-border-focus","focus-ring","scrim","on-scrim","thumb","primary","primary-hover","primary-pressed","primary-soft","primary-text","on-primary","primary-wash","primary-wash-strong","neutral","neutral-hover","neutral-text","on-neutral","success","success-soft","success-text","on-success","warning","warning-soft","warning-text","on-warning","danger","danger-soft","danger-border","danger-text","offline-fill","online-fill","on-danger","info","info-soft","info-text","on-info","switch-thumb","on-neutral-strong","text-disabled","surface-pressed","surface-hover","surface-selected","surface-disabled","skeleton","skeleton-highlight","glass-fill","glass-border","on-glass","glass-badge","field-bg-focus","field-bg-disabled","field-border-error","field-label","field-text","field-text-disabled","field-placeholder","field-placeholder-disabled","field-icon","field-icon-focus","field-icon-disabled","field-caret","field-message","avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"];export const SPACE_NAMES=["none","xxs","xs","sm","md","lg","xl","2xl","3xl","4xl"];export const RADIUS_NAMES=["none","sm","md","lg","xl","2xl","3xl","pill"];export const TEXT_NAMES=["xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl"];export const WEIGHT_NAMES=["normal","medium","semibold","bold"];export const LEADING_NAMES=["heading","body","display"];export const LETTER_SPACING_NAMES=["tight","normal","wide"];export const FONT_NAMES=["ui","display","mono"];export const SHADOW_NAMES=["card","elevated","popover","modal","drawer"];export const DURATION_NAMES=["instant","fast","default","slow","slower"];export const EASE_NAMES=["in-out","accelerate","decelerate","sharp"];export const SIZE_NAMES=["border"];export const COMPONENT_KINDS={field:{radius:"radius","padding-x":"space","padding-y":"space","min-height":"px",text:"text",icon:"px","label-text":"text","label-gap":"space","message-text":"text","message-gap":"space"},press:{opacity:"number"},disabled:{opacity:"number"},button:{"padding-x":"px","padding-y":"space","min-height":"px",text:"px",radius:"radius",icon:"px","badge-icon":"px"},input:{"multiline-min-height":"px"},"search-bar":{radius:"radius"},"empty-state":{icon:"px","illustration-size":"px","title-text":"text","description-text":"text","padding-y":"space","title-gap":"space","description-gap":"space"},"list-item":{"padding-y":"space","title-text":"text","subtitle-text":"text","min-height":"px"},badge:{text:"text","min-width":"px",height:"px","padding-x":"space","dot-size":"px","border-width":"px","anchor-offset":"px"},chip:{"padding-x":"space","padding-y":"space",text:"text","min-height":"px","close-size":"px","close-text":"text",gap:"space",icon:"px"},checkbox:{"box-size":"px","label-gap":"space"},radio:{outer:"px",inner:"px","label-gap":"space"},switch:{"track-width":"px","track-height":"px","thumb-size":"px",padding:"space"},"otp-input":{cell:"px",text:"text",radius:"radius",gap:"space"},"segmented-control":{height:"px",text:"text","padding-x":"space",icon:"px","track-padding":"space","underline-height":"px","pill-inset":"space"},tabs:{text:"text","padding-y":"space","padding-x":"space","scrollable-padding-x":"space",icon:"px","icon-gap":"space","track-padding":"space","underline-height":"px","pill-inset":"space","disabled-opacity":"number","badge-gap":"space"},slider:{"track-height":"px","thumb-diameter":"px"},"floating-action-button":{diameter:"px",icon:"px",text:"text","label-padding-x":"space","edge-offset":"space","bottom-offset":"space","secondary-gap":"space","stagger-ms":"ms"},dialog:{"icon-wrapper-size":"px","action-button-min-height":"px"},toast:{"icon-circle-size":"px","icon-glyph-text":"text","tint-bar-width":"px","action-min-height":"px"},banner:{"tint-bar-width":"px"},screen:{gutter:"space"}};export const lightTokens={mode:"light",colors:{bg:"#ffffff","bg-subtle":"#f8f8fb","bg-muted":"#f1f1f5",surface:"#ffffff","surface-inverse":"#0f0f1a","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7","surface-ink":"#0b0e16",text:"#252f4a","text-body":"#0f0f1a","text-muted":"#52525b","text-subtle":"#62626b","text-inverse":"#ffffff",link:"#4f46e5",border:"#e5e5ec","border-subtle":"#efeff3","field-bg":"#f9fbfc","field-border":"#ebedf3","field-border-focus":"#bed2f9","focus-ring":"#4f46e5",scrim:"#0f0f1a80","on-scrim":"#ffffff",thumb:"#ffffff",primary:"#4f46e5","primary-hover":"#4338ca","primary-pressed":"#3730a3","primary-soft":"#e0e7ff","primary-text":"#4f46e5","on-primary":"#ffffff","primary-wash":"#4f46e514","primary-wash-strong":"#4f46e533",neutral:"#f4f4f8","neutral-hover":"#e9e9f0","neutral-text":"#52525b","on-neutral":"#0f0f1a",success:"#18864f","success-soft":"#e8faee","success-text":"#147042","on-success":"#ffffff",warning:"#f59e0b","warning-soft":"#fff8e6","warning-text":"#8f5c06","on-warning":"#0f0f1a",danger:"#e12c32","danger-soft":"#ffeaef","danger-border":"#e5484d","danger-text":"#bc1b20","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#ffffff",info:"#1b6ef5","info-soft":"#e9f3ff","info-text":"#0958d9","on-info":"#ffffff","switch-thumb":"#ffffff","on-neutral-strong":"#ffffff","text-disabled":"#b4b4bb","surface-pressed":"#0f0f1a0f","surface-hover":"#0f0f1a0a","surface-selected":"#4f46e51a","surface-disabled":"#f1f1f5",skeleton:"#ebedf3","skeleton-highlight":"#f5f6fa","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#ffffff","field-bg-disabled":"#f5f6fa","field-border-error":"#fdbfce","field-label":"#242f4a","field-text":"#252f4a","field-text-disabled":"#7a8197","field-placeholder":"#626d8b","field-placeholder-disabled":"#7a8197","field-icon":"#7a849f","field-icon-focus":"#4b5675","field-icon-disabled":"#c4cada","field-caret":"#5b8dee","field-message":"#d81736","avatar-1":"#4f46e5","avatar-2":"#0a7979","avatar-3":"#a45a05","avatar-4":"#cd226e","avatar-5":"#2462eb","avatar-6":"#7c3aed","avatar-7":"#047c57","avatar-8":"#d42222"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:8,md:10,lg:14,xl:16,"2xl":18,"3xl":20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.059,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.078,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.102,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.141,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"xl","padding-x":"sm","padding-y":"xs","min-height":35,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"xl","padding-x":"md","padding-y":"sm","min-height":40,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"xl","padding-x":"lg","padding-y":"sm","min-height":45,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"},xl:{radius:"xl","padding-x":"lg","padding-y":"sm","min-height":50,text:"lg",icon:20,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{sm:{"padding-x":14,"padding-y":"xs","min-height":35,text:12,radius:"lg",icon:16,"badge-icon":16},md:{"padding-x":16,"padding-y":"sm","min-height":40,text:14,radius:"xl",icon:18,"badge-icon":18},lg:{"padding-x":18,"padding-y":"sm","min-height":45,text:16,radius:"2xl",icon:20,"badge-icon":20},xl:{"padding-x":20,"padding-y":"md","min-height":50,text:18,radius:"3xl",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110},xl:{"multiline-min-height":128}},"search-bar":{sm:{radius:"xl"},md:{radius:"xl"},lg:{radius:"xl"},xl:{radius:"xl"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"xl",gap:"sm"},md:{cell:44,text:"xl",radius:"xl",gap:"sm"},lg:{cell:52,text:"2xl",radius:"xl",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}};export const darkTokens={mode:"dark",colors:{bg:"#0b0b12","bg-subtle":"#13131c","bg-muted":"#1c1c26",surface:"#1c1c26","surface-inverse":"#fafafa","surface-dark":"#071437","surface-dark-border":"#2a3553","on-surface-dark":"#ffffff","on-surface-dark-muted":"#babdc7","surface-ink":"#0b0e16",text:"#e2e2e2","text-body":"#fafafa","text-muted":"#b4b4bb","text-subtle":"#919199","text-inverse":"#0f0f1a",link:"#9292ee",border:"#27272f","border-subtle":"#1c1c26","field-bg":"#13131c","field-border":"#27272f","field-border-focus":"#3d5fb0","focus-ring":"#7c7ce8",scrim:"#000000a6","on-scrim":"#ffffff",thumb:"#3a3e49",primary:"#7c7ce8","primary-hover":"#9292ee","primary-pressed":"#a8a8f2","primary-soft":"#1f1f3d","primary-text":"#8989ea","on-primary":"#0f0f1a","primary-wash":"#7c7ce814","primary-wash-strong":"#7c7ce833",neutral:"#1f1f26","neutral-hover":"#2a2a33","neutral-text":"#b4b4bb","on-neutral":"#fafafa",success:"#30c780","success-soft":"#04b4402e","success-text":"#30c780","on-success":"#0f0f1a",warning:"#fbbf24","warning-soft":"#dfa0002e","warning-text":"#fbbf24","on-warning":"#0f0f1a",danger:"#f87171","danger-soft":"#e826462e","danger-border":"#f87171","danger-text":"#f87171","offline-fill":"#e82646","online-fill":"#04b440","on-danger":"#0f0f1a",info:"#60a5fa","info-soft":"#056ee92e","info-text":"#60a5fa","on-info":"#0f0f1a","switch-thumb":"#ffffff","on-neutral-strong":"#0f0f1a","text-disabled":"#52525b","surface-pressed":"#ffffff14","surface-hover":"#ffffff0d","surface-selected":"#7c7ce82e","surface-disabled":"#1c1c26",skeleton:"#1c1c26","skeleton-highlight":"#27272f","glass-fill":"#ffffff47","glass-border":"#ffffff73","on-glass":"#0f0f1a","glass-badge":"#ffffff","field-bg-focus":"#0b0b12","field-bg-disabled":"#1c1c26","field-border-error":"#8a2f42","field-label":"#e4e6ee","field-text":"#fafafa","field-text-disabled":"#71717a","field-placeholder":"#84848d","field-placeholder-disabled":"#71717a","field-icon":"#8b8b95","field-icon-focus":"#d4d4db","field-icon-disabled":"#52525b","field-caret":"#7c9ef0","field-message":"#f87171","avatar-1":"#8b8bee","avatar-2":"#2dd4bf","avatar-3":"#fcd34d","avatar-4":"#f472b6","avatar-5":"#60a5fa","avatar-6":"#a78bfa","avatar-7":"#34d399","avatar-8":"#f87171"},space:{none:0,xxs:2,xs:4,sm:8,md:12,lg:16,xl:24,"2xl":32,"3xl":48,"4xl":64},radius:{none:0,sm:8,md:10,lg:14,xl:16,"2xl":18,"3xl":20,pill:9999},text:{xs:{size:11},sm:{size:13},base:{size:15},lg:{size:17},xl:{size:20},"2xl":{size:24},"3xl":{size:30},"4xl":{size:36},"5xl":{size:45},"6xl":{size:57},"7xl":{size:64},"8xl":{size:72}},weight:{normal:"400",medium:"500",semibold:"600",bold:"700"},leading:{heading:1.2,body:1.4,display:1.2},"letter-spacing":{tight:-.2,normal:0,wide:.4},font:{ui:{},display:{},mono:{}},shadow:{card:{shadowColor:"#000000",shadowOffset:{width:0,height:2},shadowOpacity:.4,shadowRadius:4,elevation:2},elevated:{shadowColor:"#000000",shadowOffset:{width:0,height:4},shadowOpacity:.502,shadowRadius:8,elevation:4},popover:{shadowColor:"#000000",shadowOffset:{width:0,height:8},shadowOpacity:.549,shadowRadius:16,elevation:8},modal:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12},drawer:{shadowColor:"#000000",shadowOffset:{width:0,height:12},shadowOpacity:.6,shadowRadius:24,elevation:12}},motion:{duration:{instant:80,fast:160,default:240,slow:360,slower:500},ease:{"in-out":[.4,0,.2,1],accelerate:[.4,0,1,1],decelerate:[0,0,.2,1],sharp:[.4,0,.6,1]}},size:{border:1},components:{field:{sm:{radius:"xl","padding-x":"sm","padding-y":"xs","min-height":35,text:"sm",icon:14,"label-text":"xs","label-gap":"xs","message-text":"xs","message-gap":"xxs"},md:{radius:"xl","padding-x":"md","padding-y":"sm","min-height":40,text:"base",icon:16,"label-text":"sm","label-gap":"xs","message-text":"sm","message-gap":"xxs"},lg:{radius:"xl","padding-x":"lg","padding-y":"sm","min-height":45,text:"lg",icon:18,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"},xl:{radius:"xl","padding-x":"lg","padding-y":"sm","min-height":50,text:"lg",icon:20,"label-text":"base","label-gap":"xs","message-text":"base","message-gap":"xxs"}},press:{opacity:.85},disabled:{opacity:.55},button:{sm:{"padding-x":14,"padding-y":"xs","min-height":35,text:12,radius:"lg",icon:16,"badge-icon":16},md:{"padding-x":16,"padding-y":"sm","min-height":40,text:14,radius:"xl",icon:18,"badge-icon":18},lg:{"padding-x":18,"padding-y":"sm","min-height":45,text:16,radius:"2xl",icon:20,"badge-icon":20},xl:{"padding-x":20,"padding-y":"md","min-height":50,text:18,radius:"3xl",icon:22,"badge-icon":22}},input:{sm:{"multiline-min-height":72},md:{"multiline-min-height":92},lg:{"multiline-min-height":110},xl:{"multiline-min-height":128}},"search-bar":{sm:{radius:"xl"},md:{radius:"xl"},lg:{radius:"xl"},xl:{radius:"xl"}},"empty-state":{sm:{icon:48,"illustration-size":96,"title-text":"lg","description-text":"sm","padding-y":"lg","title-gap":"md","description-gap":"xs"},md:{icon:64,"illustration-size":160,"title-text":"xl","description-text":"base","padding-y":"xl","title-gap":"md","description-gap":"xs"},lg:{icon:80,"illustration-size":240,"title-text":"2xl","description-text":"lg","padding-y":"2xl","title-gap":"md","description-gap":"xs"}},"list-item":{sm:{"padding-y":"sm","title-text":"sm","subtitle-text":"xs","min-height":44},md:{"padding-y":"md","title-text":"base","subtitle-text":"sm","min-height":56},lg:{"padding-y":"lg","title-text":"lg","subtitle-text":"base","min-height":72}},badge:{sm:{text:"xs","min-width":16,height:16,"padding-x":"xs","dot-size":8},md:{text:"sm","min-width":20,height:20,"padding-x":"sm","dot-size":10},"border-width":1.5,"anchor-offset":4},chip:{sm:{"padding-x":"sm","padding-y":"xs",text:"xs","min-height":26,"close-size":16,"close-text":"xs",gap:"xs",icon:14},md:{"padding-x":"md","padding-y":"xs",text:"sm","min-height":32,"close-size":18,"close-text":"sm",gap:"sm",icon:16}},checkbox:{sm:{"box-size":16},md:{"box-size":20},lg:{"box-size":24},"label-gap":"sm"},radio:{sm:{outer:16,inner:8},md:{outer:20,inner:10},lg:{outer:24,inner:12},"label-gap":"sm"},switch:{sm:{"track-width":42,"track-height":26,"thumb-size":22,padding:"xxs"},md:{"track-width":51,"track-height":31,"thumb-size":27,padding:"xxs"},lg:{"track-width":60,"track-height":36,"thumb-size":32,padding:"xxs"}},"otp-input":{sm:{cell:36,text:"base",radius:"xl",gap:"sm"},md:{cell:44,text:"xl",radius:"xl",gap:"sm"},lg:{cell:52,text:"2xl",radius:"xl",gap:"md"}},"segmented-control":{sm:{height:32,text:"sm","padding-x":"sm",icon:14},md:{height:40,text:"base","padding-x":"md",icon:16},lg:{height:48,text:"lg","padding-x":"lg",icon:18},"track-padding":"xs","underline-height":2,"pill-inset":"xs"},tabs:{sm:{text:"sm","padding-y":"sm","padding-x":"xs","scrollable-padding-x":"md",icon:16},md:{text:"base","padding-y":"md","padding-x":"sm","scrollable-padding-x":"lg",icon:18},lg:{text:"lg","padding-y":"lg","padding-x":"md","scrollable-padding-x":"xl",icon:20},"icon-gap":"xs","track-padding":"xs","underline-height":2,"pill-inset":"xs","disabled-opacity":.45,"badge-gap":"xs"},slider:{sm:{"track-height":4,"thumb-diameter":24},md:{"track-height":6,"thumb-diameter":28},lg:{"track-height":8,"thumb-diameter":32}},"floating-action-button":{sm:{diameter:40,icon:18,text:"sm","label-padding-x":"md"},md:{diameter:56,icon:22,text:"base","label-padding-x":"lg"},lg:{diameter:72,icon:28,text:"lg","label-padding-x":"xl"},"edge-offset":"xl","bottom-offset":"xl","secondary-gap":"lg","stagger-ms":50},dialog:{"icon-wrapper-size":48,"action-button-min-height":44},toast:{"icon-circle-size":28,"icon-glyph-text":"lg","tint-bar-width":0,"action-min-height":30},banner:{"tint-bar-width":0},screen:{gutter:"lg"}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const SQUIRCLE_SMOOTHING=.6;export const SQUIRCLE_MIN_RADIUS=6;export const squircleApplies=(n,m
|
|
1
|
+
"use strict";export const SQUIRCLE_SMOOTHING=.6;export const SQUIRCLE_MIN_RADIUS=6;export const squircleApplies=(n,t,m)=>m>=6&&n>0&&t>0&&2*m<Math.min(n,t);export const squircleHostRadius=(n,t,m)=>Math.min(2*m,Math.min(n,t)/2);const toRadians=n=>n*Math.PI/180,num=n=>{const t=n.toFixed(4);return"-0.0000"===t?"0.0000":t},cornerParams=(n,t,m)=>{let u=(1+t)*n;const $=m/n-1,a=Math.min(t,$);u=Math.min(u,m);const o=90*(1-a),c=Math.sin(toRadians(o/2))*n*Math.SQRT2,i=(90-o)/2,r=45*a,s=n*Math.tan(toRadians(i/2))*Math.cos(toRadians(r)),h=s*Math.tan(toRadians(r)),e=(u-c-s-h)/3;return{a:2*e,b:e,c:s,d:h,p:u,arcSectionLength:c,cornerRadius:n}},topRight=({cornerRadius:n,a:t,b:m,c:u,d:$,arcSectionLength:a})=>`c ${num(t)} 0 ${num(t+m)} 0 ${num(t+m+u)} ${num($)} a ${num(n)} ${num(n)} 0 0 1 ${num(a)} ${num(a)} c ${num($)} ${num(u)} ${num($)} ${num(m+u)} ${num($)} ${num(t+m+u)}`,bottomRight=({cornerRadius:n,a:t,b:m,c:u,d:$,arcSectionLength:a})=>`c 0 ${num(t)} 0 ${num(t+m)} ${num(-$)} ${num(t+m+u)} a ${num(n)} ${num(n)} 0 0 1 ${num(-a)} ${num(a)} c ${num(-u)} ${num($)} ${num(-(m+u))} ${num($)} ${num(-(t+m+u))} ${num($)}`,bottomLeft=({cornerRadius:n,a:t,b:m,c:u,d:$,arcSectionLength:a})=>`c ${num(-t)} 0 ${num(-(t+m))} 0 ${num(-(t+m+u))} ${num(-$)} a ${num(n)} ${num(n)} 0 0 1 ${num(-a)} ${num(-a)} c ${num(-$)} ${num(-u)} ${num(-$)} ${num(-(m+u))} ${num(-$)} ${num(-(t+m+u))}`,topLeft=({cornerRadius:n,a:t,b:m,c:u,d:$,arcSectionLength:a})=>`c 0 ${num(-t)} 0 ${num(-(t+m))} ${num($)} ${num(-(t+m+u))} a ${num(n)} ${num(n)} 0 0 1 ${num(a)} ${num(-a)} c ${num(u)} ${num(-$)} ${num(m+u)} ${num(-$)} ${num(t+m+u)} ${num(-$)}`,CSS_SQUIRCLE_STEPS=32;export function cssSquirclePath({width:n,height:t,radius:m,inset:u=0}){const $=Math.max(0,n-2*u),a=Math.max(0,t-2*u),o=Math.min(Math.max(0,m-u),Math.min($,a)/2);if(o<=0)return`M ${num(u)} ${num(u)} L ${num(u+$)} ${num(u)} L ${num(u+$)} ${num(u+a)} L ${num(u)} ${num(u+a)} Z`;const c=[],i=[[u+$-o,u+o,1,-1,!1],[u+$-o,u+a-o,1,1,!0],[u+o,u+a-o,-1,1,!1],[u+o,u+o,-1,-1,!0]];for(const[n,t,m,u,$]of i)for(let a=0;a<=32;a++){const i=($?a:32-a)/32*(Math.PI/2);c.push(`${num(n+m*o*Math.sqrt(Math.cos(i)))} ${num(t+u*o*Math.sqrt(Math.sin(i)))}`)}return`M ${c.join(" L ")} Z`}export function squirclePath({width:n,height:t,radius:m,smoothing:u=.6,inset:$=0}){const a=Math.max(0,n-2*$),o=Math.max(0,t-2*$),c=$,i=$,r=Math.max(0,m-$),s=Math.min(a,o)/2,h=Math.min(r,s);if(h<=0)return`M ${num(c)} ${num(i)} L ${num(c+a)} ${num(i)} L ${num(c+a)} ${num(i+o)} L ${num(c)} ${num(i+o)} Z`;const e=cornerParams(h,Math.min(1,Math.max(0,u)),s),{p:M}=e;return`M ${num(c+a-M)} ${num(i)} ${topRight(e)} L ${num(c+a)} ${num(i+o-M)} ${bottomRight(e)} L ${num(c+M)} ${num(i+o)} ${bottomLeft(e)} L ${num(c)} ${num(i+M)} ${topLeft(e)} Z`}
|
|
@@ -22,9 +22,11 @@ export type ButtonVariant = FillVariant | "link" | "glass";
|
|
|
22
22
|
export type ButtonTone = Tone;
|
|
23
23
|
export declare const BUTTON_VARIANTS: readonly ["solid", "soft", "outline", "ghost", "link", "glass"];
|
|
24
24
|
export declare const BUTTON_TONES: readonly ["primary", "success", "warning", "danger", "info", "neutral"];
|
|
25
|
+
export type ButtonShape = "rounded" | "pill" | "sharp";
|
|
26
|
+
export declare const BUTTON_SHAPES: readonly ["rounded", "pill", "sharp"];
|
|
25
27
|
export declare function isButtonVariant(value: unknown): value is ButtonVariant;
|
|
26
28
|
export declare function isButtonTone(value: unknown): value is ButtonTone;
|
|
27
|
-
export type ButtonSize = Size
|
|
29
|
+
export type ButtonSize = Extract<Size, "sm" | "md" | "lg" | "xl">;
|
|
28
30
|
export interface ButtonProps extends Omit<PressableProps, "style" | "children" | "onPress"> {
|
|
29
31
|
/** The label, and the button's accessible name unless `accessibilityLabel` is set. */
|
|
30
32
|
label: string;
|
|
@@ -64,7 +66,7 @@ export interface ButtonProps extends Omit<PressableProps, "style" | "children" |
|
|
|
64
66
|
* disc inverts the button's own colours: white with the icon in the tone on
|
|
65
67
|
* `solid` and `glass`, the tone with a white icon on `soft`, `outline` and
|
|
66
68
|
* `ghost`. Sized to the button height less a 4 pt inset; pair with
|
|
67
|
-
* `
|
|
69
|
+
* `shape="pill"` for the pill shape. Ignored on a `link` and without a
|
|
68
70
|
* `leftIcon`.
|
|
69
71
|
*/
|
|
70
72
|
leftIconBadge?: boolean | undefined;
|
|
@@ -72,10 +74,13 @@ export interface ButtonProps extends Omit<PressableProps, "style" | "children" |
|
|
|
72
74
|
* Haptic on press. Defaults to a light tap (`impactLight`); a `HapticType` changes it and `false` switches it off. The app-wide switch (`configureFeedback`) silences it too.
|
|
73
75
|
*/
|
|
74
76
|
haptic?: HapticType | false | undefined;
|
|
75
|
-
rounded
|
|
77
|
+
/** Corner shape, as `AppButton`: `rounded` (the size's radius as the web's CSS squircle, default), `pill` (fully round ends) or `sharp` (square corners). */
|
|
78
|
+
shape?: ButtonShape | undefined;
|
|
76
79
|
/**
|
|
77
|
-
* Optional gradient background. Pass either a key from
|
|
78
|
-
* (e.g. `"primary"`) or a `GradientDefinition` literal.
|
|
80
|
+
* Optional gradient background, for the `solid` variant only. Pass either a key from
|
|
81
|
+
* `theme.settings.gradients` (e.g. `"primary"`) or a `GradientDefinition` literal. A name the
|
|
82
|
+
* theme does not define, or a gradient on any other variant, throws a `RangeError`. A disabled
|
|
83
|
+
* button paints the flat disabled colour instead.
|
|
79
84
|
*/
|
|
80
85
|
gradient?: string | GradientDefinition | undefined;
|
|
81
86
|
style?: StyleProp<ViewStyle> | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { ButtonProps, ButtonSize, ButtonTone, ButtonVariant } from "./Button";
|
|
2
|
-
export { BUTTON_TONES, BUTTON_VARIANTS, Button, buttonLabelInk, default, isButtonTone, isButtonVariant } from "./Button";
|
|
1
|
+
export type { ButtonProps, ButtonShape, ButtonSize, ButtonTone, ButtonVariant } from "./Button";
|
|
2
|
+
export { BUTTON_SHAPES, BUTTON_TONES, BUTTON_VARIANTS, Button, buttonLabelInk, default, isButtonTone, isButtonVariant } from "./Button";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -26,7 +26,7 @@ import type { AccessibilityRole, AccessibilityState, StyleProp, TextStyle, ViewS
|
|
|
26
26
|
import { Animated } from "react-native";
|
|
27
27
|
import type { Theme } from "../../theme/types";
|
|
28
28
|
import type { FieldVariant, Size } from "../../types/vocabulary";
|
|
29
|
-
export type FieldBaseSize = Extract<Size, "sm" | "md" | "lg">;
|
|
29
|
+
export type FieldBaseSize = Extract<Size, "sm" | "md" | "lg" | "xl">;
|
|
30
30
|
export type FieldBaseVariant = FieldVariant;
|
|
31
31
|
type FieldSide = "top" | "right" | "bottom" | "left";
|
|
32
32
|
/**
|
|
@@ -19,13 +19,21 @@ import { type resolveFieldSize } from "../../theme";
|
|
|
19
19
|
import type { FieldBaseProps, FieldBaseVariant } from "./FieldBase";
|
|
20
20
|
/** The floated label's scale; the outline notch is sized from it. */
|
|
21
21
|
export declare const FLOATED_LABEL_SCALE = 0.85;
|
|
22
|
+
/** The line reserved above the box for an `above` label, as the web's `--wui-float-above-space`. */
|
|
23
|
+
export declare const ABOVE_LABEL_SPACE = 22;
|
|
22
24
|
export interface UseFloatingLabelOptions {
|
|
23
25
|
/** A string or a node; a node needs the field's explicit `accessibilityLabel`. */
|
|
24
26
|
label?: React.ReactNode | undefined;
|
|
25
27
|
/** Render at all (label present and the consumer's labelMode is 'float'). */
|
|
26
28
|
enabled: boolean;
|
|
27
|
-
/** Whether the label is up
|
|
29
|
+
/** Whether the label is up right now (focused or holding a value). */
|
|
28
30
|
floated: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Where a floated label lands: `border` cuts the outline's top border and sits on it;
|
|
33
|
+
* `above` rests on the line the consumer reserves above the box (`ABOVE_LABEL_SPACE`),
|
|
34
|
+
* clear of the border, at the field's start edge, as the web's `floatingLabel="above"`.
|
|
35
|
+
*/
|
|
36
|
+
placement?: "border" | "above" | undefined;
|
|
29
37
|
required?: boolean | undefined;
|
|
30
38
|
variant: FieldBaseVariant;
|
|
31
39
|
sizeTokens: ReturnType<typeof resolveFieldSize>;
|
|
@@ -51,5 +59,5 @@ export interface UseFloatingLabelResult {
|
|
|
51
59
|
/** Hand to FieldBase so the outline top border opens under the floated label. */
|
|
52
60
|
topNotch: FieldBaseProps["topNotch"];
|
|
53
61
|
}
|
|
54
|
-
export declare const useFloatingLabel: ({ label, enabled, floated, required, variant, sizeTokens, leadingOffset, trailingOffset, textAlign, paddingLeft, lineHeight, restNudge, floatTrim, color, style, }: UseFloatingLabelOptions) => UseFloatingLabelResult;
|
|
62
|
+
export declare const useFloatingLabel: ({ label, enabled, floated, placement, required, variant, sizeTokens, leadingOffset, trailingOffset, textAlign, paddingLeft, lineHeight, restNudge, floatTrim, color, style, }: UseFloatingLabelOptions) => UseFloatingLabelResult;
|
|
55
63
|
//# sourceMappingURL=useFloatingLabel.d.ts.map
|
|
@@ -27,7 +27,7 @@ import { type InlineSelectText } from "../../text/phone/inlineSelect.g";
|
|
|
27
27
|
import type { Size } from "../../types/vocabulary";
|
|
28
28
|
import type { HapticType } from "../../utils";
|
|
29
29
|
import type { SelectOption, SelectValue } from "../OptionSheet/OptionSheet";
|
|
30
|
-
export type InlineSelectSize = Extract<Size, "sm" | "md" | "lg">;
|
|
30
|
+
export type InlineSelectSize = Extract<Size, "sm" | "md" | "lg" | "xl">;
|
|
31
31
|
export interface InlineSelectProps<T = SelectOption> {
|
|
32
32
|
/** Same contract as Select's `options`: `SelectOption` shape by default, accessors for anything else. */
|
|
33
33
|
options: ReadonlyArray<T>;
|