@rootnative/web 0.0.0-alpha.3 → 0.0.0-alpha.4
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/CHANGELOG.md +21 -1
- package/dist/apis/AccessibilityInfo/index.d.ts +30 -0
- package/dist/apis/AccessibilityInfo/index.js +84 -0
- package/dist/apis/AccessibilityInfo/index.js.map +1 -0
- package/dist/apis/Alert/index.d.ts +22 -0
- package/dist/apis/Alert/index.js +141 -0
- package/dist/apis/Alert/index.js.map +1 -0
- package/dist/apis/AppState/index.d.ts +21 -0
- package/dist/apis/AppState/index.js +86 -0
- package/dist/apis/AppState/index.js.map +1 -0
- package/dist/apis/Appearance/index.d.ts +14 -0
- package/dist/apis/Appearance/index.js +39 -0
- package/dist/apis/Appearance/index.js.map +1 -0
- package/dist/apis/BackHandler/index.d.ts +10 -0
- package/dist/apis/BackHandler/index.js +16 -0
- package/dist/apis/BackHandler/index.js.map +1 -0
- package/dist/apis/Clipboard/index.d.ts +9 -0
- package/dist/apis/Clipboard/index.js +45 -0
- package/dist/apis/Clipboard/index.js.map +1 -0
- package/dist/apis/Dimensions/index.d.ts +19 -0
- package/dist/apis/Dimensions/index.js +66 -0
- package/dist/apis/Dimensions/index.js.map +1 -0
- package/dist/apis/I18nManager/index.d.ts +14 -0
- package/dist/apis/I18nManager/index.js +33 -0
- package/dist/apis/I18nManager/index.js.map +1 -0
- package/dist/apis/Keyboard/index.d.ts +36 -0
- package/dist/apis/Keyboard/index.js +149 -0
- package/dist/apis/Keyboard/index.js.map +1 -0
- package/dist/apis/Linking/index.d.ts +29 -0
- package/dist/apis/Linking/index.js +86 -0
- package/dist/apis/Linking/index.js.map +1 -0
- package/dist/apis/PanResponder/index.d.ts +50 -0
- package/dist/apis/PanResponder/index.js +239 -0
- package/dist/apis/PanResponder/index.js.map +1 -0
- package/dist/apis/PixelRatio/index.d.ts +8 -0
- package/dist/apis/PixelRatio/index.js +15 -0
- package/dist/apis/PixelRatio/index.js.map +1 -0
- package/dist/apis/Platform/index.d.ts +4 -0
- package/dist/apis/Platform/index.js +28 -0
- package/dist/apis/Platform/index.js.map +1 -0
- package/dist/apis/Platform/types.d.ts +19 -0
- package/dist/apis/Share/index.d.ts +30 -0
- package/dist/apis/Share/index.js +34 -0
- package/dist/apis/Share/index.js.map +1 -0
- package/dist/apis/StyleSheet/index.d.ts +23 -0
- package/dist/apis/StyleSheet/index.js +29 -0
- package/dist/apis/StyleSheet/index.js.map +1 -0
- package/dist/apis/StyleSheet/types.d.ts +328 -0
- package/dist/apis/Vibration/index.d.ts +9 -0
- package/dist/apis/Vibration/index.js +40 -0
- package/dist/apis/Vibration/index.js.map +1 -0
- package/dist/apis/processColor/index.d.ts +3 -0
- package/dist/apis/processColor/index.js +12 -0
- package/dist/apis/processColor/index.js.map +1 -0
- package/dist/apis/useColorScheme/index.d.ts +3 -0
- package/dist/apis/useColorScheme/index.js +13 -0
- package/dist/apis/useColorScheme/index.js.map +1 -0
- package/dist/apis/useWindowDimensions/index.d.ts +3 -0
- package/dist/apis/useWindowDimensions/index.js +19 -0
- package/dist/apis/useWindowDimensions/index.js.map +1 -0
- package/dist/bundler/index.js +30 -0
- package/dist/bundler/index.js.map +1 -0
- package/dist/bundler/inlinePlatformOS.js +121 -0
- package/dist/bundler/inlinePlatformOS.js.map +1 -0
- package/dist/bundler/worklets.js +61 -0
- package/dist/bundler/worklets.js.map +1 -0
- package/dist/compat/TurboModuleRegistry/index.d.ts +16 -0
- package/dist/compat/TurboModuleRegistry/index.js +14 -0
- package/dist/compat/TurboModuleRegistry/index.js.map +1 -0
- package/dist/compat/createElement/index.d.ts +9 -0
- package/dist/compat/createElement/index.js +40 -0
- package/dist/compat/createElement/index.js.map +1 -0
- package/dist/compat/findNodeHandle/index.d.ts +7 -0
- package/dist/compat/findNodeHandle/index.js +19 -0
- package/dist/compat/findNodeHandle/index.js.map +1 -0
- package/dist/components/ActivityIndicator/index.d.ts +5 -0
- package/dist/components/ActivityIndicator/index.js +74 -0
- package/dist/components/ActivityIndicator/index.js.map +1 -0
- package/dist/components/ActivityIndicator/types.d.ts +8 -0
- package/dist/components/Button/index.d.ts +5 -0
- package/dist/components/Button/index.js +48 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/types.d.ts +31 -0
- package/dist/components/FlatList/index.d.ts +5 -0
- package/dist/components/FlatList/index.js +433 -0
- package/dist/components/FlatList/index.js.map +1 -0
- package/dist/components/FlatList/types.d.ts +138 -0
- package/dist/components/FlatList/viewability.js +86 -0
- package/dist/components/FlatList/viewability.js.map +1 -0
- package/dist/components/Image/index.d.ts +7 -0
- package/dist/components/Image/index.js +301 -0
- package/dist/components/Image/index.js.map +1 -0
- package/dist/components/Image/source.js +97 -0
- package/dist/components/Image/source.js.map +1 -0
- package/dist/components/Image/types.d.ts +96 -0
- package/dist/components/KeyboardAvoidingView/index.d.ts +10 -0
- package/dist/components/KeyboardAvoidingView/index.js +118 -0
- package/dist/components/KeyboardAvoidingView/index.js.map +1 -0
- package/dist/components/KeyboardAvoidingView/types.d.ts +14 -0
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.js +271 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/types.d.ts +29 -0
- package/dist/components/Pressable/index.d.ts +5 -0
- package/dist/components/Pressable/index.js +106 -0
- package/dist/components/Pressable/index.js.map +1 -0
- package/dist/components/Pressable/types.d.ts +44 -0
- package/dist/components/RefreshControl/index.d.ts +5 -0
- package/dist/components/RefreshControl/index.js +176 -0
- package/dist/components/RefreshControl/index.js.map +1 -0
- package/dist/components/RefreshControl/pull.js +16 -0
- package/dist/components/RefreshControl/pull.js.map +1 -0
- package/dist/components/RefreshControl/types.d.ts +14 -0
- package/dist/components/ScrollView/index.d.ts +5 -0
- package/dist/components/ScrollView/index.js +318 -0
- package/dist/components/ScrollView/index.js.map +1 -0
- package/dist/components/ScrollView/snap.js +38 -0
- package/dist/components/ScrollView/snap.js.map +1 -0
- package/dist/components/ScrollView/types.d.ts +115 -0
- package/dist/components/StatusBar/index.d.ts +26 -0
- package/dist/components/StatusBar/index.js +113 -0
- package/dist/components/StatusBar/index.js.map +1 -0
- package/dist/components/Switch/index.d.ts +5 -0
- package/dist/components/Switch/index.js +89 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Switch/types.d.ts +25 -0
- package/dist/components/Text/TextAncestorContext.d.ts +3 -0
- package/dist/components/Text/TextAncestorContext.js +6 -0
- package/dist/components/Text/TextAncestorContext.js.map +1 -0
- package/dist/components/Text/index.d.ts +6 -0
- package/dist/components/Text/index.js +133 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/Text/types.d.ts +38 -0
- package/dist/components/TextInput/autocomplete.js +102 -0
- package/dist/components/TextInput/autocomplete.js.map +1 -0
- package/dist/components/TextInput/index.d.ts +8 -0
- package/dist/components/TextInput/index.js +290 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/TextInput/types.d.ts +130 -0
- package/dist/components/TouchableHighlight/index.d.ts +5 -0
- package/dist/components/TouchableHighlight/index.js +109 -0
- package/dist/components/TouchableHighlight/index.js.map +1 -0
- package/dist/components/TouchableHighlight/types.d.ts +15 -0
- package/dist/components/TouchableNativeFeedback/index.d.ts +11 -0
- package/dist/components/TouchableNativeFeedback/index.js +29 -0
- package/dist/components/TouchableNativeFeedback/index.js.map +1 -0
- package/dist/components/TouchableNativeFeedback/types.d.ts +19 -0
- package/dist/components/TouchableOpacity/index.d.ts +5 -0
- package/dist/components/TouchableOpacity/index.js +122 -0
- package/dist/components/TouchableOpacity/index.js.map +1 -0
- package/dist/components/TouchableOpacity/types.d.ts +11 -0
- package/dist/components/TouchableWithoutFeedback/index.d.ts +5 -0
- package/dist/components/TouchableWithoutFeedback/index.js +70 -0
- package/dist/components/TouchableWithoutFeedback/index.js.map +1 -0
- package/dist/components/TouchableWithoutFeedback/types.d.ts +40 -0
- package/dist/components/View/index.d.ts +5 -0
- package/dist/components/View/index.js +50 -0
- package/dist/components/View/index.js.map +1 -0
- package/dist/components/View/types.d.ts +98 -0
- package/dist/dom/Head.d.ts +21 -0
- package/dist/dom/Head.js +53 -0
- package/dist/dom/Head.js.map +1 -0
- package/dist/dom/index.d.ts +2 -22
- package/dist/dom/index.js +1 -53
- package/dist/events/press/Pressability.d.ts +2 -0
- package/dist/events/press/Pressability.js +366 -0
- package/dist/events/press/Pressability.js.map +1 -0
- package/dist/events/press/cursorStyle.js +5 -0
- package/dist/events/press/cursorStyle.js.map +1 -0
- package/dist/events/press/index.d.ts +4 -0
- package/dist/events/press/mergeHandlers.js +30 -0
- package/dist/events/press/mergeHandlers.js.map +1 -0
- package/dist/events/press/types.d.ts +48 -0
- package/dist/events/press/usePressability.d.ts +4 -0
- package/dist/events/press/usePressability.js +18 -0
- package/dist/events/press/usePressability.js.map +1 -0
- package/dist/events/responderEvent.js +50 -0
- package/dist/events/responderEvent.js.map +1 -0
- package/dist/events/types.d.ts +33 -0
- package/dist/index.d.ts +66 -1597
- package/dist/index.js +42 -4864
- package/dist/reactNativeVersion.d.ts +7 -0
- package/dist/reactNativeVersion.js +10 -0
- package/dist/reactNativeVersion.js.map +1 -0
- package/dist/render/domProps.js +66 -0
- package/dist/render/domProps.js.map +1 -0
- package/dist/render/hitSlop.js +21 -0
- package/dist/render/hitSlop.js.map +1 -0
- package/dist/render/hostMethods.js +44 -0
- package/dist/render/hostMethods.js.map +1 -0
- package/dist/render/resolveTag.js +64 -0
- package/dist/render/resolveTag.js.map +1 -0
- package/dist/render/useElementLayout.js +25 -0
- package/dist/render/useElementLayout.js.map +1 -0
- package/dist/server/index.d.ts +2 -27
- package/dist/server/index.js +2 -2
- package/dist/{StyleRegistryContext-ROsMlY4O.js → style/StyleRegistryContext.js} +3 -3
- package/dist/style/StyleRegistryContext.js.map +1 -0
- package/dist/style/color.js +16 -0
- package/dist/style/color.js.map +1 -0
- package/dist/style/compile.js +72 -0
- package/dist/style/compile.js.map +1 -0
- package/dist/style/direction.js +33 -0
- package/dist/style/direction.js.map +1 -0
- package/dist/style/index.d.ts +1 -1
- package/dist/style/index.js +5 -2
- package/dist/style/index.js.map +1 -1
- package/dist/style/registry.d.ts +27 -0
- package/dist/{registry-Aa_Od5m0.js → style/registry.js} +3 -3
- package/dist/style/registry.js.map +1 -0
- package/dist/style/resolveStyle.js +181 -0
- package/dist/style/resolveStyle.js.map +1 -0
- package/dist/style/shadow.js +87 -0
- package/dist/style/shadow.js.map +1 -0
- package/dist/style/splitLayoutProps.js +52 -0
- package/dist/style/splitLayoutProps.js.map +1 -0
- package/dist/style/transform.js +35 -0
- package/dist/style/transform.js.map +1 -0
- package/dist/style/types.d.ts +4 -0
- package/dist/style/units.js +21 -0
- package/dist/style/units.js.map +1 -0
- package/dist/style/webStyle.js +9 -0
- package/dist/style/webStyle.js.map +1 -0
- package/dist/{env-DK5Mt9yX.js → utils/env.js} +2 -2
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/scrollLock.js +28 -0
- package/dist/utils/scrollLock.js.map +1 -0
- package/dist/utils/warn.js +11 -0
- package/dist/utils/warn.js.map +1 -0
- package/dist/vite/index.js +4 -202
- package/dist/vite/index.js.map +1 -1
- package/llms.txt +20 -0
- package/package.json +4 -3
- package/dist/StyleRegistryContext-ROsMlY4O.js.map +0 -1
- package/dist/compile-CVUjQrR9.js +0 -400
- package/dist/compile-CVUjQrR9.js.map +0 -1
- package/dist/dom/index.js.map +0 -1
- package/dist/env-DK5Mt9yX.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/registry-Aa_Od5m0.js.map +0 -1
- package/dist/types-BxTWbdj9.d.ts +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/StatusBar/index.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nimport { toCSSColor } from '../../style/color'\nimport { hasDOM } from '../../utils/env'\n\nexport type StatusBarStyle = 'default' | 'light-content' | 'dark-content'\n\nexport type StatusBarAnimation = 'none' | 'fade' | 'slide'\n\nexport type StatusBarProps = {\n animated?: boolean | undefined\n backgroundColor?: unknown\n barStyle?: StatusBarStyle | null | undefined\n hidden?: boolean | undefined\n networkActivityIndicatorVisible?: boolean | undefined\n showHideTransition?: StatusBarAnimation | undefined\n translucent?: boolean | undefined\n}\n\ntype Entry = StatusBarProps\n\n// The browser has one status bar equivalent: the `theme-color` meta, which\n// mobile browsers paint around the page. The stack works as on native: the\n// last mounted StatusBar wins, and `set*` calls write the base entry.\nconst stack: Entry[] = []\nconst base: Entry = {}\n\nconst merged = (): Entry => {\n const out: Entry = { ...base }\n for (const entry of stack) {\n for (const key in entry) {\n const value = (entry as Record<string, unknown>)[key]\n if (value !== undefined) (out as Record<string, unknown>)[key] = value\n }\n }\n return out\n}\n\nconst themeColorMeta = (): HTMLMetaElement | null => {\n if (!hasDOM()) return null\n let meta = document.head.querySelector<HTMLMetaElement>('meta[name=\"theme-color\"]:not([media])')\n if (meta === null) {\n meta = document.createElement('meta')\n meta.name = 'theme-color'\n document.head.appendChild(meta)\n }\n return meta\n}\n\nlet originalThemeColor: string | null | undefined\n\nconst apply = (): void => {\n const meta = themeColorMeta()\n if (meta === null) return\n if (originalThemeColor === undefined) originalThemeColor = meta.getAttribute('content')\n const color = toCSSColor(merged().backgroundColor)\n if (color !== undefined) meta.setAttribute('content', color)\n else if (originalThemeColor === null) meta.removeAttribute('content')\n else meta.setAttribute('content', originalThemeColor)\n}\n\nconst pushStackEntry = (props: StatusBarProps): Entry => {\n const entry: Entry = { ...props }\n stack.push(entry)\n apply()\n return entry\n}\n\nconst popStackEntry = (entry: Entry): void => {\n const index = stack.indexOf(entry)\n if (index !== -1) stack.splice(index, 1)\n apply()\n}\n\nconst replaceStackEntry = (entry: Entry, props: StatusBarProps): Entry => {\n const index = stack.indexOf(entry)\n const next: Entry = { ...props }\n if (index === -1) stack.push(next)\n else stack[index] = next\n apply()\n return next\n}\n\nfunction StatusBarComponent(props: StatusBarProps): null {\n const entry = useRef<Entry | null>(null)\n const {\n animated,\n backgroundColor,\n barStyle,\n hidden,\n networkActivityIndicatorVisible,\n showHideTransition,\n translucent,\n } = props\n\n useEffect(() => {\n const next = {\n animated,\n backgroundColor,\n barStyle,\n hidden,\n networkActivityIndicatorVisible,\n showHideTransition,\n translucent,\n }\n entry.current =\n entry.current === null ? pushStackEntry(next) : replaceStackEntry(entry.current, next)\n }, [\n animated,\n backgroundColor,\n barStyle,\n hidden,\n networkActivityIndicatorVisible,\n showHideTransition,\n translucent,\n ])\n\n useEffect(() => {\n return () => {\n if (entry.current !== null) popStackEntry(entry.current)\n entry.current = null\n }\n }, [])\n\n return null\n}\n\nexport type StatusBarStatics = {\n currentHeight: number | null\n setBarStyle: (style: StatusBarStyle, animated?: boolean) => void\n setBackgroundColor: (color: unknown, animated?: boolean) => void\n setHidden: (hidden: boolean, animation?: StatusBarAnimation) => void\n setTranslucent: (translucent: boolean) => void\n setNetworkActivityIndicatorVisible: (visible: boolean) => void\n pushStackEntry: (props: StatusBarProps) => StatusBarProps\n popStackEntry: (entry: StatusBarProps) => void\n replaceStackEntry: (entry: StatusBarProps, props: StatusBarProps) => StatusBarProps\n}\n\nconst statics: StatusBarStatics = {\n // The browser has no status bar, so there is no height to offset.\n currentHeight: null,\n\n setBarStyle: (style: StatusBarStyle, _animated?: boolean): void => {\n base.barStyle = style\n apply()\n },\n setBackgroundColor: (color: unknown, _animated?: boolean): void => {\n base.backgroundColor = color\n apply()\n },\n setHidden: (hidden: boolean, _animation?: StatusBarAnimation): void => {\n base.hidden = hidden\n apply()\n },\n setTranslucent: (translucent: boolean): void => {\n base.translucent = translucent\n apply()\n },\n setNetworkActivityIndicatorVisible: (visible: boolean): void => {\n base.networkActivityIndicatorVisible = visible\n apply()\n },\n pushStackEntry,\n popStackEntry,\n replaceStackEntry,\n}\n\nexport const StatusBar: typeof StatusBarComponent & StatusBarStatics = Object.assign(\n StatusBarComponent,\n statics,\n)\n\n// For tests.\nexport const resetStatusBar = (): void => {\n stack.length = 0\n for (const key in base) delete (base as Record<string, unknown>)[key]\n if (hasDOM()) {\n document.head.querySelector('meta[name=\"theme-color\"]:not([media])')?.remove()\n }\n originalThemeColor = undefined\n}\n"],"mappings":";;;;AAwBA,MAAM,QAAiB,CAAC;AACxB,MAAM,OAAc,CAAC;AAErB,MAAM,eAAsB;CAC1B,MAAM,MAAa,EAAE,GAAG,KAAK;CAC7B,KAAK,MAAM,SAAS,OAClB,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,QAAS,MAAkC;EACjD,IAAI,UAAU,KAAA,GAAW,IAAiC,OAAO;CACnE;CAEF,OAAO;AACT;AAEA,MAAM,uBAA+C;CACnD,IAAI,CAAC,OAAO,GAAG,OAAO;CACtB,IAAI,OAAO,SAAS,KAAK,cAA+B,yCAAuC;CAC/F,IAAI,SAAS,MAAM;EACjB,OAAO,SAAS,cAAc,MAAM;EACpC,KAAK,OAAO;EACZ,SAAS,KAAK,YAAY,IAAI;CAChC;CACA,OAAO;AACT;AAEA,IAAI;AAEJ,MAAM,cAAoB;CACxB,MAAM,OAAO,eAAe;CAC5B,IAAI,SAAS,MAAM;CACnB,IAAI,uBAAuB,KAAA,GAAW,qBAAqB,KAAK,aAAa,SAAS;CACtF,MAAM,QAAQ,WAAW,OAAO,CAAC,CAAC,eAAe;CACjD,IAAI,UAAU,KAAA,GAAW,KAAK,aAAa,WAAW,KAAK;MACtD,IAAI,uBAAuB,MAAM,KAAK,gBAAgB,SAAS;MAC/D,KAAK,aAAa,WAAW,kBAAkB;AACtD;AAEA,MAAM,kBAAkB,UAAiC;CACvD,MAAM,QAAe,EAAE,GAAG,MAAM;CAChC,MAAM,KAAK,KAAK;CAChB,MAAM;CACN,OAAO;AACT;AAEA,MAAM,iBAAiB,UAAuB;CAC5C,MAAM,QAAQ,MAAM,QAAQ,KAAK;CACjC,IAAI,UAAU,IAAI,MAAM,OAAO,OAAO,CAAC;CACvC,MAAM;AACR;AAEA,MAAM,qBAAqB,OAAc,UAAiC;CACxE,MAAM,QAAQ,MAAM,QAAQ,KAAK;CACjC,MAAM,OAAc,EAAE,GAAG,MAAM;CAC/B,IAAI,UAAU,IAAI,MAAM,KAAK,IAAI;MAC5B,MAAM,SAAS;CACpB,MAAM;CACN,OAAO;AACT;AAEA,SAAS,mBAAmB,OAA6B;CACvD,MAAM,QAAQ,OAAqB,IAAI;CACvC,MAAM,EACJ,UACA,iBACA,UACA,QACA,iCACA,oBACA,gBACE;CAEJ,gBAAgB;EACd,MAAM,OAAO;GACX;GACA;GACA;GACA;GACA;GACA;GACA;EACF;EACA,MAAM,UACJ,MAAM,YAAY,OAAO,eAAe,IAAI,IAAI,kBAAkB,MAAM,SAAS,IAAI;CACzF,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,gBAAgB;EACd,aAAa;GACX,IAAI,MAAM,YAAY,MAAM,cAAc,MAAM,OAAO;GACvD,MAAM,UAAU;EAClB;CACF,GAAG,CAAC,CAAC;CAEL,OAAO;AACT;AA2CA,MAAa,YAA0D,OAAO,OAC5E,oBACA;CA7BA,eAAe;CAEf,cAAc,OAAuB,cAA8B;EACjE,KAAK,WAAW;EAChB,MAAM;CACR;CACA,qBAAqB,OAAgB,cAA8B;EACjE,KAAK,kBAAkB;EACvB,MAAM;CACR;CACA,YAAY,QAAiB,eAA0C;EACrE,KAAK,SAAS;EACd,MAAM;CACR;CACA,iBAAiB,gBAA+B;EAC9C,KAAK,cAAc;EACnB,MAAM;CACR;CACA,qCAAqC,YAA2B;EAC9D,KAAK,kCAAkC;EACvC,MAAM;CACR;CACA;CACA;CACA;AAKA,CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SwitchChangeEvent, SwitchChangeEventData, SwitchProps } from "./types.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
export declare function Switch(props: SwitchProps): ReactElement;
|
|
4
|
+
export type { SwitchChangeEvent, SwitchChangeEventData, SwitchProps };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { StyleSheet } from "../../apis/StyleSheet/index.js";
|
|
2
|
+
import { toDOMProps } from "../../render/domProps.js";
|
|
3
|
+
import { toCSSColor } from "../../style/color.js";
|
|
4
|
+
import { useStyleRegistry } from "../../style/StyleRegistryContext.js";
|
|
5
|
+
import { View } from "../View/index.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/components/Switch/index.tsx
|
|
8
|
+
const TRACK_OFF = "#939393";
|
|
9
|
+
const TRACK_ON = "#A3D3CF";
|
|
10
|
+
const THUMB_OFF = "#FAFAFA";
|
|
11
|
+
const THUMB_ON = "#009688";
|
|
12
|
+
const INPUT_CLASS = "rn-switch-input";
|
|
13
|
+
const RULES = [
|
|
14
|
+
`.${INPUT_CLASS}{position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;opacity:0;cursor:pointer;z-index:1}`,
|
|
15
|
+
`.${INPUT_CLASS}:disabled{cursor:default}`,
|
|
16
|
+
".rn-switch-track{height:70%;border-radius:9999px;transition:background-color .15s}",
|
|
17
|
+
".rn-switch-row{position:absolute;inset:0;display:flex;border-radius:9999px}",
|
|
18
|
+
".rn-switch-spacer{flex-grow:0;transition:flex-grow .15s}",
|
|
19
|
+
".rn-switch-thumb{height:100%;aspect-ratio:1;border-radius:50%;box-shadow:0 1px 3px rgba(0,0,0,.5);transition:background-color .15s}",
|
|
20
|
+
`.${INPUT_CLASS}:checked~.rn-switch-row>.rn-switch-spacer{flex-grow:1}`,
|
|
21
|
+
`.${INPUT_CLASS}:focus-visible~.rn-switch-row{outline:auto;outline-offset:2px}`,
|
|
22
|
+
"@media (prefers-reduced-motion:reduce){.rn-switch-track,.rn-switch-spacer,.rn-switch-thumb{transition:none}}"
|
|
23
|
+
];
|
|
24
|
+
function Switch(props) {
|
|
25
|
+
const { accessibilityRole, accessibilityState, disabled, ios_backgroundColor: _iosBackgroundColor, onChange, onLayout, onTintColor: _onTintColor, onValueChange, pointerEvents, ref, role, style, thumbColor, thumbTintColor: _thumbTintColor, tintColor: _tintColor, trackColor, value, ...rest } = props;
|
|
26
|
+
const inputClass = useStyleRegistry().staticClass(INPUT_CLASS, RULES);
|
|
27
|
+
const on = value === true;
|
|
28
|
+
const resolvedDisabled = disabled ?? accessibilityState?.disabled;
|
|
29
|
+
const state = resolvedDisabled === accessibilityState?.disabled ? accessibilityState : {
|
|
30
|
+
...accessibilityState,
|
|
31
|
+
disabled: resolvedDisabled
|
|
32
|
+
};
|
|
33
|
+
const handleChange = (event) => {
|
|
34
|
+
const next = event.target.checked;
|
|
35
|
+
Object.assign(event.nativeEvent, { value: next });
|
|
36
|
+
onChange?.(event);
|
|
37
|
+
onValueChange?.(next);
|
|
38
|
+
};
|
|
39
|
+
const inputProps = toDOMProps({
|
|
40
|
+
...rest,
|
|
41
|
+
accessibilityState: state
|
|
42
|
+
});
|
|
43
|
+
inputProps["role"] = role ?? accessibilityRole ?? "switch";
|
|
44
|
+
const track = toCSSColor(on ? trackColor?.true : trackColor?.false) ?? (on ? TRACK_ON : TRACK_OFF);
|
|
45
|
+
const thumb = toCSSColor(thumbColor) ?? (on ? THUMB_ON : THUMB_OFF);
|
|
46
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
47
|
+
onLayout,
|
|
48
|
+
pointerEvents,
|
|
49
|
+
style: [
|
|
50
|
+
styles.root,
|
|
51
|
+
style,
|
|
52
|
+
resolvedDisabled === true && styles.disabled
|
|
53
|
+
],
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsx("input", {
|
|
56
|
+
...inputProps,
|
|
57
|
+
checked: on,
|
|
58
|
+
className: inputClass,
|
|
59
|
+
disabled: resolvedDisabled === true,
|
|
60
|
+
onChange: handleChange,
|
|
61
|
+
ref,
|
|
62
|
+
type: "checkbox"
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ jsx("div", {
|
|
65
|
+
className: "rn-switch-track",
|
|
66
|
+
style: { backgroundColor: track }
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsxs("div", {
|
|
69
|
+
className: "rn-switch-row",
|
|
70
|
+
children: [/* @__PURE__ */ jsx("div", { className: "rn-switch-spacer" }), /* @__PURE__ */ jsx("div", {
|
|
71
|
+
className: "rn-switch-thumb",
|
|
72
|
+
style: { backgroundColor: thumb }
|
|
73
|
+
})]
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const styles = StyleSheet.create({
|
|
79
|
+
root: {
|
|
80
|
+
alignSelf: "flex-start",
|
|
81
|
+
width: 40,
|
|
82
|
+
height: 20,
|
|
83
|
+
justifyContent: "center"
|
|
84
|
+
},
|
|
85
|
+
disabled: { opacity: .5 }
|
|
86
|
+
});
|
|
87
|
+
export { Switch };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import type { ChangeEvent, ReactElement } from 'react'\n\nimport { StyleSheet } from '../../apis/StyleSheet'\nimport { toDOMProps } from '../../render/domProps'\nimport { toCSSColor } from '../../style/color'\nimport { useStyleRegistry } from '../../style/StyleRegistryContext'\nimport { View } from '../View'\nimport type { SwitchChangeEvent, SwitchProps } from './types'\n\nexport type { SwitchChangeEvent, SwitchChangeEventData, SwitchProps } from './types'\n\n// The colors of React Native's Switch on Android, with the default theme.\nconst TRACK_OFF = '#939393'\nconst TRACK_ON = '#A3D3CF'\nconst THUMB_OFF = '#FAFAFA'\nconst THUMB_ON = '#009688'\n\nconst INPUT_CLASS = 'rn-switch-input'\n// The input covers the switch and is transparent, so the browser gives the press, the keyboard,\n// the focus, and the label. The elements after it draw the switch from the state of the input.\nconst RULES = [\n `.${INPUT_CLASS}{position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;opacity:0;cursor:pointer;z-index:1}`,\n `.${INPUT_CLASS}:disabled{cursor:default}`,\n '.rn-switch-track{height:70%;border-radius:9999px;transition:background-color .15s}',\n '.rn-switch-row{position:absolute;inset:0;display:flex;border-radius:9999px}',\n // A spacer that grows moves the thumb to the end, in both writing directions and at each size.\n '.rn-switch-spacer{flex-grow:0;transition:flex-grow .15s}',\n '.rn-switch-thumb{height:100%;aspect-ratio:1;border-radius:50%;box-shadow:0 1px 3px rgba(0,0,0,.5);transition:background-color .15s}',\n `.${INPUT_CLASS}:checked~.rn-switch-row>.rn-switch-spacer{flex-grow:1}`,\n `.${INPUT_CLASS}:focus-visible~.rn-switch-row{outline:auto;outline-offset:2px}`,\n '@media (prefers-reduced-motion:reduce){.rn-switch-track,.rn-switch-spacer,.rn-switch-thumb{transition:none}}',\n]\n\nexport function Switch(props: SwitchProps): ReactElement {\n const {\n accessibilityRole,\n accessibilityState,\n disabled,\n ios_backgroundColor: _iosBackgroundColor,\n onChange,\n onLayout,\n onTintColor: _onTintColor,\n onValueChange,\n pointerEvents,\n ref,\n role,\n style,\n thumbColor,\n thumbTintColor: _thumbTintColor,\n tintColor: _tintColor,\n trackColor,\n value,\n ...rest\n } = props\n\n const registry = useStyleRegistry()\n const inputClass = registry.staticClass(INPUT_CLASS, RULES)\n\n const on = value === true\n const resolvedDisabled = disabled ?? accessibilityState?.disabled\n // As in React Native, the state follows the resolved value, so `disabled={false}` wins.\n const state =\n resolvedDisabled === accessibilityState?.disabled\n ? accessibilityState\n : { ...accessibilityState, disabled: resolvedDisabled }\n\n // `checked` is controlled, so React puts the input back when `value` doesn't follow a press.\n // That's the native behavior: the switch shows `value`.\n const handleChange = (event: ChangeEvent<HTMLInputElement>): void => {\n const next = event.target.checked\n Object.assign(event.nativeEvent, { value: next })\n onChange?.(event as unknown as SwitchChangeEvent)\n onValueChange?.(next)\n }\n\n const inputProps = toDOMProps({ ...rest, accessibilityState: state })\n inputProps['role'] = role ?? accessibilityRole ?? 'switch'\n\n const track = toCSSColor(on ? trackColor?.true : trackColor?.false) ?? (on ? TRACK_ON : TRACK_OFF)\n const thumb = toCSSColor(thumbColor) ?? (on ? THUMB_ON : THUMB_OFF)\n\n return (\n <View\n onLayout={onLayout}\n pointerEvents={pointerEvents}\n style={[styles.root, style, resolvedDisabled === true && styles.disabled]}\n >\n <input\n {...inputProps}\n checked={on}\n className={inputClass}\n disabled={resolvedDisabled === true}\n onChange={handleChange}\n ref={ref}\n type=\"checkbox\"\n />\n <div className=\"rn-switch-track\" style={{ backgroundColor: track }} />\n <div className=\"rn-switch-row\">\n <div className=\"rn-switch-spacer\" />\n <div className=\"rn-switch-thumb\" style={{ backgroundColor: thumb }} />\n </div>\n </View>\n )\n}\n\nconst styles = StyleSheet.create({\n root: { alignSelf: 'flex-start', width: 40, height: 20, justifyContent: 'center' },\n disabled: { opacity: 0.5 },\n})\n"],"mappings":";;;;;;;AAYA,MAAM,YAAY;AAClB,MAAM,WAAW;AACjB,MAAM,YAAY;AAClB,MAAM,WAAW;AAEjB,MAAM,cAAc;AAGpB,MAAM,QAAQ;CACZ,IAAI,YAAY;CAChB,IAAI,YAAY;CAChB;CACA;CAEA;CACA;CACA,IAAI,YAAY;CAChB,IAAI,YAAY;CAChB;AACF;AAEA,SAAgB,OAAO,OAAkC;CACvD,MAAM,EACJ,mBACA,oBACA,UACA,qBAAqB,qBACrB,UACA,UACA,aAAa,cACb,eACA,eACA,KACA,MACA,OACA,YACA,gBAAgB,iBAChB,WAAW,YACX,YACA,OACA,GAAG,SACD;CAGJ,MAAM,aADW,iBACS,CAAC,CAAC,YAAY,aAAa,KAAK;CAE1D,MAAM,KAAK,UAAU;CACrB,MAAM,mBAAmB,YAAY,oBAAoB;CAEzD,MAAM,QACJ,qBAAqB,oBAAoB,WACrC,qBACA;EAAE,GAAG;EAAoB,UAAU;CAAiB;CAI1D,MAAM,gBAAgB,UAA+C;EACnE,MAAM,OAAO,MAAM,OAAO;EAC1B,OAAO,OAAO,MAAM,aAAa,EAAE,OAAO,KAAK,CAAC;EAChD,WAAW,KAAqC;EAChD,gBAAgB,IAAI;CACtB;CAEA,MAAM,aAAa,WAAW;EAAE,GAAG;EAAM,oBAAoB;CAAM,CAAC;CACpE,WAAW,UAAU,QAAQ,qBAAqB;CAElD,MAAM,QAAQ,WAAW,KAAK,YAAY,OAAO,YAAY,KAAK,MAAM,KAAK,WAAW;CACxF,MAAM,QAAQ,WAAW,UAAU,MAAM,KAAK,WAAW;CAEzD,OACE,qBAAC,MAAD;EACY;EACK;EACf,OAAO;GAAC,OAAO;GAAM;GAAO,qBAAqB,QAAQ,OAAO;EAAQ;EAH1E,UAAA;GAKE,oBAAC,SAAD;IACE,GAAI;IACJ,SAAS;IACT,WAAW;IACX,UAAU,qBAAqB;IAC/B,UAAU;IACL;IACL,MAAK;GACN,CAAA;GACD,oBAAC,OAAD;IAAK,WAAU;IAAkB,OAAO,EAAE,iBAAiB,MAAM;GAAI,CAAA;GACrE,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,OAAD,EAAK,WAAU,mBAAoB,CAAA,GACnC,oBAAC,OAAD;KAAK,WAAU;KAAkB,OAAO,EAAE,iBAAiB,MAAM;IAAI,CAAA,CAClE;;EACD;;AAEV;AAEA,MAAM,SAAS,WAAW,OAAO;CAC/B,MAAM;EAAE,WAAW;EAAc,OAAO;EAAI,QAAQ;EAAI,gBAAgB;CAAS;CACjF,UAAU,EAAE,SAAS,GAAI;AAC3B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NativeSyntheticEvent } from "../../events/types.js";
|
|
2
|
+
import { ViewProps } from "../View/types.js";
|
|
3
|
+
import { Ref } from "react";
|
|
4
|
+
export type SwitchChangeEventData = {
|
|
5
|
+
value: boolean;
|
|
6
|
+
target: EventTarget | null;
|
|
7
|
+
};
|
|
8
|
+
export type SwitchChangeEvent = NativeSyntheticEvent<SwitchChangeEventData>;
|
|
9
|
+
export interface SwitchProps extends Omit<ViewProps, "children" | "onChange" | "ref"> {
|
|
10
|
+
ref?: Ref<HTMLInputElement> | undefined;
|
|
11
|
+
value?: boolean | undefined;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
|
+
onChange?: ((event: SwitchChangeEvent) => unknown) | undefined;
|
|
14
|
+
onValueChange?: ((value: boolean) => unknown) | undefined;
|
|
15
|
+
thumbColor?: string | undefined;
|
|
16
|
+
trackColor?: Readonly<{
|
|
17
|
+
false?: string | null | undefined;
|
|
18
|
+
true?: string | null | undefined;
|
|
19
|
+
}> | undefined;
|
|
20
|
+
ios_backgroundColor?: string | undefined;
|
|
21
|
+
onTintColor?: string | undefined;
|
|
22
|
+
thumbTintColor?: string | undefined;
|
|
23
|
+
tintColor?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAncestorContext.js","names":[],"sources":["../../../src/components/Text/TextAncestorContext.ts"],"sourcesContent":["import { createContext, type Context } from 'react'\n\n// True inside a Text, so a nested Text renders inline and inherits.\nexport const TextAncestorContext: Context<boolean> = createContext(false)\n"],"mappings":";;AAGA,MAAa,sBAAwC,cAAc,KAAK"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PressEvent, TextInstance, TextProps } from "./types.js";
|
|
2
|
+
import { TextAncestorContext } from "./TextAncestorContext.js";
|
|
3
|
+
import { ReactElement } from "react";
|
|
4
|
+
export declare function Text(props: TextProps): ReactElement;
|
|
5
|
+
export { type PressEvent, TextAncestorContext, type TextInstance, type TextProps };
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { pointerCursorStyle } from "../../events/press/cursorStyle.js";
|
|
2
|
+
import { usePressability } from "../../events/press/usePressability.js";
|
|
3
|
+
import { mergeHandlers } from "../../events/press/mergeHandlers.js";
|
|
4
|
+
import { toDOMProps } from "../../render/domProps.js";
|
|
5
|
+
import { withHostMethods } from "../../render/hostMethods.js";
|
|
6
|
+
import { resolveTag } from "../../render/resolveTag.js";
|
|
7
|
+
import { useElementLayout } from "../../render/useElementLayout.js";
|
|
8
|
+
import { toCSSColor } from "../../style/color.js";
|
|
9
|
+
import { compileReset, compileStyle, joinClassNames, pointerEventsStyle } from "../../style/compile.js";
|
|
10
|
+
import { useStyleRegistry } from "../../style/StyleRegistryContext.js";
|
|
11
|
+
import { TextAncestorContext } from "./TextAncestorContext.js";
|
|
12
|
+
import { createElement, useContext, useImperativeHandle, useMemo, useRef } from "react";
|
|
13
|
+
// src/components/Text/index.tsx
|
|
14
|
+
const resetStyle = Object.freeze({
|
|
15
|
+
backgroundColor: "transparent",
|
|
16
|
+
border: "0 solid black",
|
|
17
|
+
boxSizing: "border-box",
|
|
18
|
+
color: "black",
|
|
19
|
+
display: "inline",
|
|
20
|
+
fontFamily: "System",
|
|
21
|
+
fontSize: 14,
|
|
22
|
+
listStyle: "none",
|
|
23
|
+
margin: 0,
|
|
24
|
+
padding: 0,
|
|
25
|
+
position: "relative",
|
|
26
|
+
textAlign: "start",
|
|
27
|
+
textDecoration: "none",
|
|
28
|
+
whiteSpace: "pre-wrap",
|
|
29
|
+
wordWrap: "break-word"
|
|
30
|
+
});
|
|
31
|
+
const nestedResetStyle = Object.freeze({
|
|
32
|
+
color: "inherit",
|
|
33
|
+
font: "inherit",
|
|
34
|
+
textAlign: "inherit",
|
|
35
|
+
textDecoration: "inherit",
|
|
36
|
+
whiteSpace: "inherit"
|
|
37
|
+
});
|
|
38
|
+
const singleLineStyle = Object.freeze({
|
|
39
|
+
maxWidth: "100%",
|
|
40
|
+
overflow: "hidden",
|
|
41
|
+
overflowWrap: "normal",
|
|
42
|
+
textOverflow: "ellipsis",
|
|
43
|
+
whiteSpace: "nowrap"
|
|
44
|
+
});
|
|
45
|
+
const multiLineStyles = /* @__PURE__ */ new Map();
|
|
46
|
+
const multiLineStyle = (lines) => {
|
|
47
|
+
let style = multiLineStyles.get(lines);
|
|
48
|
+
if (style === void 0) {
|
|
49
|
+
style = Object.freeze({
|
|
50
|
+
display: "-webkit-box",
|
|
51
|
+
maxWidth: "100%",
|
|
52
|
+
WebkitBoxOrient: "vertical",
|
|
53
|
+
WebkitLineClamp: lines,
|
|
54
|
+
overflow: "hidden"
|
|
55
|
+
});
|
|
56
|
+
multiLineStyles.set(lines, style);
|
|
57
|
+
}
|
|
58
|
+
return style;
|
|
59
|
+
};
|
|
60
|
+
const clipStyle = Object.freeze({ textOverflow: "clip" });
|
|
61
|
+
const notSelectableStyle = Object.freeze({ userSelect: "none" });
|
|
62
|
+
const selectionClass = (registry, color) => {
|
|
63
|
+
const css = toCSSColor(color);
|
|
64
|
+
if (css === void 0) return void 0;
|
|
65
|
+
const name = `rn-sel-${css.replace(/[^a-z0-9]/g, "")}`;
|
|
66
|
+
return registry.staticClass(name, [`.${name}::selection{background-color:${css}}`]);
|
|
67
|
+
};
|
|
68
|
+
function Text(props) {
|
|
69
|
+
const { children, disabled, ellipsizeMode, numberOfLines, onBlur, onFocus, onLayout, onLongPress, onPress, onPressIn, onPressOut, pointerEvents, pressRetentionOffset, ref, selectable, selectionColor, style, suppressHighlighting: _suppressHighlighting, ...rest } = props;
|
|
70
|
+
const nested = useContext(TextAncestorContext);
|
|
71
|
+
const element = useRef(null);
|
|
72
|
+
useImperativeHandle(ref, () => withHostMethods(element.current), []);
|
|
73
|
+
useElementLayout(element, onLayout);
|
|
74
|
+
const registry = useStyleRegistry();
|
|
75
|
+
const pressable = (onPress != null || onLongPress != null) && disabled !== true;
|
|
76
|
+
const config = useMemo(() => pressable ? {
|
|
77
|
+
pressRectOffset: pressRetentionOffset,
|
|
78
|
+
onBlur,
|
|
79
|
+
onFocus,
|
|
80
|
+
onLongPress,
|
|
81
|
+
onPress,
|
|
82
|
+
onPressIn,
|
|
83
|
+
onPressOut
|
|
84
|
+
} : null, [
|
|
85
|
+
pressable,
|
|
86
|
+
pressRetentionOffset,
|
|
87
|
+
onBlur,
|
|
88
|
+
onFocus,
|
|
89
|
+
onLongPress,
|
|
90
|
+
onPress,
|
|
91
|
+
onPressIn,
|
|
92
|
+
onPressOut
|
|
93
|
+
]);
|
|
94
|
+
const handlers = usePressability(config);
|
|
95
|
+
const roleProps = pressable && rest.role === void 0 && rest.accessibilityRole === void 0 ? {
|
|
96
|
+
...rest,
|
|
97
|
+
role: "link"
|
|
98
|
+
} : rest;
|
|
99
|
+
const { tag, role } = resolveTag(roleProps, "span", children != null);
|
|
100
|
+
const lineStyle = numberOfLines === void 0 || numberOfLines < 1 ? void 0 : numberOfLines === 1 ? singleLineStyle : multiLineStyle(numberOfLines);
|
|
101
|
+
const pointerStyle = pointerEvents === void 0 ? void 0 : pointerEventsStyle[pointerEvents];
|
|
102
|
+
let className = joinClassNames(nested ? compileReset("rn-text-nested", nestedResetStyle, registry) : compileReset("rn-text", resetStyle, registry), compileStyle([
|
|
103
|
+
pressable && pointerCursorStyle,
|
|
104
|
+
style,
|
|
105
|
+
lineStyle,
|
|
106
|
+
ellipsizeMode === "clip" && clipStyle,
|
|
107
|
+
selectable === false && notSelectableStyle,
|
|
108
|
+
pointerStyle
|
|
109
|
+
], registry));
|
|
110
|
+
if (selectionColor !== void 0) {
|
|
111
|
+
const extra = selectionClass(registry, selectionColor);
|
|
112
|
+
if (extra !== void 0) className = `${className} ${extra}`;
|
|
113
|
+
}
|
|
114
|
+
const domProps = toDOMProps(rest);
|
|
115
|
+
if (role !== void 0) domProps["role"] = role;
|
|
116
|
+
if (tag.length === 2 && tag[0] === "h") delete domProps["aria-level"];
|
|
117
|
+
if (tag === "button") domProps["type"] = "button";
|
|
118
|
+
if (disabled === true) domProps["aria-disabled"] = true;
|
|
119
|
+
if (pressable && handlers !== null) {
|
|
120
|
+
Object.assign(domProps, mergeHandlers(rest, handlers));
|
|
121
|
+
if (domProps["tabIndex"] === void 0 && tag !== "a" && tag !== "button") domProps["tabIndex"] = 0;
|
|
122
|
+
} else {
|
|
123
|
+
if (onFocus !== void 0) domProps["onFocus"] = onFocus;
|
|
124
|
+
if (onBlur !== void 0) domProps["onBlur"] = onBlur;
|
|
125
|
+
}
|
|
126
|
+
domProps["className"] = className;
|
|
127
|
+
domProps["ref"] = element;
|
|
128
|
+
const content = nested ? children : createElement(TextAncestorContext.Provider, { value: true }, children);
|
|
129
|
+
return createElement(tag, domProps, content);
|
|
130
|
+
}
|
|
131
|
+
export { Text, TextAncestorContext };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Text/index.tsx"],"sourcesContent":["import {\n createElement,\n useContext,\n useImperativeHandle,\n useMemo,\n useRef,\n type ReactElement,\n} from 'react'\n\nimport { pointerCursorStyle, usePressability } from '../../events/press'\nimport { mergeHandlers } from '../../events/press/mergeHandlers'\nimport type { PressabilityConfig } from '../../events/press/types'\nimport { toDOMProps } from '../../render/domProps'\nimport { withHostMethods } from '../../render/hostMethods'\nimport { resolveTag } from '../../render/resolveTag'\nimport { useElementLayout } from '../../render/useElementLayout'\nimport { toCSSColor } from '../../style/color'\nimport { compileReset, compileStyle, joinClassNames, pointerEventsStyle } from '../../style/compile'\nimport type { StyleRegistry } from '../../style/registry'\nimport { useStyleRegistry } from '../../style/StyleRegistryContext'\nimport { TextAncestorContext } from './TextAncestorContext'\nimport type { TextProps } from './types'\n\nexport { TextAncestorContext } from './TextAncestorContext'\nexport type { PressEvent, TextInstance, TextProps } from './types'\n\n// What a native Text looks like before any style is applied.\nconst resetStyle = Object.freeze({\n backgroundColor: 'transparent',\n border: '0 solid black',\n boxSizing: 'border-box',\n color: 'black',\n display: 'inline',\n fontFamily: 'System',\n fontSize: 14,\n listStyle: 'none',\n margin: 0,\n padding: 0,\n position: 'relative',\n textAlign: 'start',\n textDecoration: 'none',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n})\n\n// A Text inside a Text inherits everything from its parent.\nconst nestedResetStyle = Object.freeze({\n color: 'inherit',\n font: 'inherit',\n textAlign: 'inherit',\n textDecoration: 'inherit',\n whiteSpace: 'inherit',\n})\n\n// On native, Yoga measures a Text at most as wide as its parent, also with `flexShrink: 0`.\n// `maxWidth` does the same here. The reset's `break-word` has no use on a line that doesn't wrap.\nconst singleLineStyle = Object.freeze({\n maxWidth: '100%',\n overflow: 'hidden',\n overflowWrap: 'normal',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n})\n\n// The style objects of Text are frozen and reused, so `compileStyle` caches their classes.\nconst multiLineStyles = new Map<number, Readonly<Record<string, unknown>>>()\nconst multiLineStyle = (lines: number): Readonly<Record<string, unknown>> => {\n let style = multiLineStyles.get(lines)\n if (style === undefined) {\n style = Object.freeze({\n display: '-webkit-box',\n maxWidth: '100%',\n WebkitBoxOrient: 'vertical',\n WebkitLineClamp: lines,\n overflow: 'hidden',\n })\n multiLineStyles.set(lines, style)\n }\n return style\n}\n\nconst clipStyle = Object.freeze({ textOverflow: 'clip' })\nconst notSelectableStyle = Object.freeze({ userSelect: 'none' })\n\nconst selectionClass = (registry: StyleRegistry, color: string): string | undefined => {\n const css = toCSSColor(color)\n if (css === undefined) return undefined\n const name = `rn-sel-${css.replace(/[^a-z0-9]/g, '')}`\n return registry.staticClass(name, [`.${name}::selection{background-color:${css}}`])\n}\n\nexport function Text(props: TextProps): ReactElement {\n const {\n children,\n disabled,\n ellipsizeMode,\n numberOfLines,\n onBlur,\n onFocus,\n onLayout,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n pointerEvents,\n pressRetentionOffset,\n ref,\n selectable,\n selectionColor,\n style,\n suppressHighlighting: _suppressHighlighting,\n ...rest\n } = props\n\n const nested = useContext(TextAncestorContext)\n const element = useRef<HTMLElement | null>(null)\n useImperativeHandle(ref, () => withHostMethods(element.current as HTMLElement), [])\n useElementLayout(element, onLayout)\n const registry = useStyleRegistry()\n\n // As in React Native, onPress or onLongPress makes a Text pressable. onPressIn and onPressOut\n // alone don't.\n const pressable = (onPress != null || onLongPress != null) && disabled !== true\n const config = useMemo<PressabilityConfig | null>(\n () =>\n pressable\n ? {\n pressRectOffset: pressRetentionOffset,\n onBlur,\n onFocus,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n }\n : null,\n [pressable, pressRetentionOffset, onBlur, onFocus, onLongPress, onPress, onPressIn, onPressOut],\n )\n const handlers = usePressability(config)\n\n // As in React Native, a pressable Text with no role is a link.\n const roleProps =\n pressable && rest.role === undefined && rest.accessibilityRole === undefined\n ? { ...rest, role: 'link' as const }\n : rest\n const { tag, role } = resolveTag(roleProps, 'span', children != null)\n\n const lineStyle =\n numberOfLines === undefined || numberOfLines < 1\n ? undefined\n : numberOfLines === 1\n ? singleLineStyle\n : multiLineStyle(numberOfLines)\n const pointerStyle = pointerEvents === undefined ? undefined : pointerEventsStyle[pointerEvents]\n\n let className = joinClassNames(\n nested\n ? compileReset('rn-text-nested', nestedResetStyle, registry)\n : compileReset('rn-text', resetStyle, registry),\n compileStyle(\n [\n pressable && pointerCursorStyle,\n style,\n lineStyle,\n ellipsizeMode === 'clip' && clipStyle,\n selectable === false && notSelectableStyle,\n pointerStyle,\n ],\n registry,\n ),\n )\n if (selectionColor !== undefined) {\n const extra = selectionClass(registry, selectionColor)\n if (extra !== undefined) className = `${className} ${extra}`\n }\n\n const domProps = toDOMProps(rest)\n if (role !== undefined) domProps['role'] = role\n if (tag.length === 2 && tag[0] === 'h') delete domProps['aria-level']\n // A button submits its form by default. A React Native button never does.\n if (tag === 'button') domProps['type'] = 'button'\n if (disabled === true) domProps['aria-disabled'] = true\n if (pressable && handlers !== null) {\n Object.assign(domProps, mergeHandlers(rest, handlers))\n // A link has to be reachable by keyboard. The press responder presses it on Enter and Space.\n if (domProps['tabIndex'] === undefined && tag !== 'a' && tag !== 'button') {\n domProps['tabIndex'] = 0\n }\n } else {\n if (onFocus !== undefined) domProps['onFocus'] = onFocus\n if (onBlur !== undefined) domProps['onBlur'] = onBlur\n }\n domProps['className'] = className\n domProps['ref'] = element\n\n const content = nested\n ? children\n : createElement(TextAncestorContext.Provider, { value: true }, children)\n return createElement(tag, domProps, content)\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TextStyle } from "../../apis/StyleSheet/types.js";
|
|
2
|
+
import { RectOrSize } from "../../events/press/types.js";
|
|
3
|
+
import { GestureResponderEvent } from "../../events/types.js";
|
|
4
|
+
import { StyleProp } from "../../style/types.js";
|
|
5
|
+
import { AccessibilityProps, DOMEventHandlers, HostInstance, LayoutChangeEvent } from "../View/types.js";
|
|
6
|
+
import { ReactNode, Ref } from "react";
|
|
7
|
+
export type TextInstance = HostInstance;
|
|
8
|
+
/** @deprecated Use `GestureResponderEvent`, the type that React Native gives `onPress`. */
|
|
9
|
+
export type PressEvent = GestureResponderEvent;
|
|
10
|
+
export interface TextProps extends AccessibilityProps, DOMEventHandlers<HTMLElement> {
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
style?: StyleProp<TextStyle> | undefined;
|
|
13
|
+
ref?: Ref<TextInstance> | undefined;
|
|
14
|
+
id?: string | undefined;
|
|
15
|
+
nativeID?: string | undefined;
|
|
16
|
+
testID?: string | undefined;
|
|
17
|
+
tabIndex?: 0 | -1 | undefined;
|
|
18
|
+
disabled?: boolean | undefined;
|
|
19
|
+
numberOfLines?: number | undefined;
|
|
20
|
+
ellipsizeMode?: "clip" | "head" | "middle" | "tail" | undefined;
|
|
21
|
+
selectable?: boolean | undefined;
|
|
22
|
+
selectionColor?: string | undefined;
|
|
23
|
+
pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
|
|
24
|
+
onPress?: ((event: GestureResponderEvent) => void) | undefined;
|
|
25
|
+
onPressIn?: ((event: GestureResponderEvent) => void) | undefined;
|
|
26
|
+
onPressOut?: ((event: GestureResponderEvent) => void) | undefined;
|
|
27
|
+
onLongPress?: ((event: GestureResponderEvent) => void) | undefined;
|
|
28
|
+
pressRetentionOffset?: RectOrSize | undefined;
|
|
29
|
+
suppressHighlighting?: boolean | undefined;
|
|
30
|
+
onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
|
|
31
|
+
"aria-level"?: number | undefined;
|
|
32
|
+
href?: string | undefined;
|
|
33
|
+
target?: "_blank" | "_self" | "_parent" | "_top" | undefined;
|
|
34
|
+
rel?: string | undefined;
|
|
35
|
+
download?: string | boolean | undefined;
|
|
36
|
+
lang?: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// src/components/TextInput/autocomplete.ts
|
|
2
|
+
const reactNativeToHTML = {
|
|
3
|
+
"address-line1": "address-line1",
|
|
4
|
+
"address-line2": "address-line2",
|
|
5
|
+
"birthdate-day": "bday-day",
|
|
6
|
+
"birthdate-full": "bday",
|
|
7
|
+
"birthdate-month": "bday-month",
|
|
8
|
+
"birthdate-year": "bday-year",
|
|
9
|
+
"cc-middle-name": "cc-additional-name",
|
|
10
|
+
gender: "sex",
|
|
11
|
+
"name-family": "family-name",
|
|
12
|
+
"name-given": "given-name",
|
|
13
|
+
"name-middle": "additional-name",
|
|
14
|
+
"name-middle-initial": "additional-name",
|
|
15
|
+
"name-prefix": "honorific-prefix",
|
|
16
|
+
"name-suffix": "honorific-suffix",
|
|
17
|
+
"postal-address": "street-address",
|
|
18
|
+
"postal-address-country": "country",
|
|
19
|
+
"postal-address-extended": "address-line2",
|
|
20
|
+
"postal-address-extended-postal-code": "postal-code",
|
|
21
|
+
"postal-address-locality": "address-level2",
|
|
22
|
+
"postal-address-region": "address-level1",
|
|
23
|
+
"sms-otp": "one-time-code",
|
|
24
|
+
"tel-device": "tel",
|
|
25
|
+
"username-new": "username"
|
|
26
|
+
};
|
|
27
|
+
const textContentTypeToHTML = {
|
|
28
|
+
none: "off",
|
|
29
|
+
URL: "url",
|
|
30
|
+
addressCity: "address-level2",
|
|
31
|
+
addressCityAndState: "address-level1",
|
|
32
|
+
addressState: "address-level1",
|
|
33
|
+
birthdate: "bday",
|
|
34
|
+
birthdateDay: "bday-day",
|
|
35
|
+
birthdateMonth: "bday-month",
|
|
36
|
+
birthdateYear: "bday-year",
|
|
37
|
+
countryName: "country-name",
|
|
38
|
+
creditCardExpiration: "cc-exp",
|
|
39
|
+
creditCardExpirationMonth: "cc-exp-month",
|
|
40
|
+
creditCardExpirationYear: "cc-exp-year",
|
|
41
|
+
creditCardFamilyName: "cc-family-name",
|
|
42
|
+
creditCardGivenName: "cc-given-name",
|
|
43
|
+
creditCardMiddleName: "cc-additional-name",
|
|
44
|
+
creditCardName: "cc-name",
|
|
45
|
+
creditCardNumber: "cc-number",
|
|
46
|
+
creditCardSecurityCode: "cc-csc",
|
|
47
|
+
creditCardType: "cc-type",
|
|
48
|
+
emailAddress: "email",
|
|
49
|
+
familyName: "family-name",
|
|
50
|
+
fullStreetAddress: "street-address",
|
|
51
|
+
givenName: "given-name",
|
|
52
|
+
jobTitle: "organization-title",
|
|
53
|
+
location: "street-address",
|
|
54
|
+
middleName: "additional-name",
|
|
55
|
+
name: "name",
|
|
56
|
+
namePrefix: "honorific-prefix",
|
|
57
|
+
nameSuffix: "honorific-suffix",
|
|
58
|
+
newPassword: "new-password",
|
|
59
|
+
nickname: "nickname",
|
|
60
|
+
oneTimeCode: "one-time-code",
|
|
61
|
+
organizationName: "organization",
|
|
62
|
+
password: "current-password",
|
|
63
|
+
postalCode: "postal-code",
|
|
64
|
+
streetAddressLine1: "address-line1",
|
|
65
|
+
streetAddressLine2: "address-line2",
|
|
66
|
+
sublocality: "address-level3",
|
|
67
|
+
telephoneNumber: "tel",
|
|
68
|
+
username: "username"
|
|
69
|
+
};
|
|
70
|
+
const toHTMLAutoComplete = (autoComplete, textContentType) => {
|
|
71
|
+
if (autoComplete !== void 0) return reactNativeToHTML[autoComplete] ?? autoComplete;
|
|
72
|
+
if (textContentType !== void 0) return textContentTypeToHTML[textContentType];
|
|
73
|
+
};
|
|
74
|
+
const keyboardTypeToInputMode = {
|
|
75
|
+
"decimal-pad": "decimal",
|
|
76
|
+
"email-address": "email",
|
|
77
|
+
"number-pad": "numeric",
|
|
78
|
+
numeric: "numeric",
|
|
79
|
+
"numbers-and-punctuation": "decimal",
|
|
80
|
+
"phone-pad": "tel",
|
|
81
|
+
url: "url",
|
|
82
|
+
"web-search": "search"
|
|
83
|
+
};
|
|
84
|
+
const toInputMode = (inputMode, keyboardType, showSoftInputOnFocus) => {
|
|
85
|
+
if (showSoftInputOnFocus === false) return "none";
|
|
86
|
+
if (inputMode !== void 0) return inputMode;
|
|
87
|
+
if (keyboardType !== void 0) return keyboardTypeToInputMode[keyboardType];
|
|
88
|
+
};
|
|
89
|
+
const returnKeyTypeToEnterKeyHint = {
|
|
90
|
+
done: "done",
|
|
91
|
+
go: "go",
|
|
92
|
+
next: "next",
|
|
93
|
+
search: "search",
|
|
94
|
+
send: "send"
|
|
95
|
+
};
|
|
96
|
+
const toEnterKeyHint = (enterKeyHint, returnKeyType) => {
|
|
97
|
+
if (enterKeyHint !== void 0) return enterKeyHint;
|
|
98
|
+
if (returnKeyType !== void 0) return returnKeyTypeToEnterKeyHint[returnKeyType];
|
|
99
|
+
};
|
|
100
|
+
export { toEnterKeyHint, toHTMLAutoComplete, toInputMode };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=autocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autocomplete.js","names":[],"sources":["../../../src/components/TextInput/autocomplete.ts"],"sourcesContent":["// React Native `autoComplete` values that differ from the HTML autocomplete\n// tokens. Every other value is already an HTML token and passes through.\nconst reactNativeToHTML: Record<string, string> = {\n 'address-line1': 'address-line1',\n 'address-line2': 'address-line2',\n 'birthdate-day': 'bday-day',\n 'birthdate-full': 'bday',\n 'birthdate-month': 'bday-month',\n 'birthdate-year': 'bday-year',\n 'cc-middle-name': 'cc-additional-name',\n gender: 'sex',\n 'name-family': 'family-name',\n 'name-given': 'given-name',\n 'name-middle': 'additional-name',\n 'name-middle-initial': 'additional-name',\n 'name-prefix': 'honorific-prefix',\n 'name-suffix': 'honorific-suffix',\n 'postal-address': 'street-address',\n 'postal-address-country': 'country',\n 'postal-address-extended': 'address-line2',\n 'postal-address-extended-postal-code': 'postal-code',\n 'postal-address-locality': 'address-level2',\n 'postal-address-region': 'address-level1',\n 'sms-otp': 'one-time-code',\n 'tel-device': 'tel',\n 'username-new': 'username',\n}\n\n// iOS `textContentType` values, for an app that sets only that prop.\nconst textContentTypeToHTML: Record<string, string> = {\n none: 'off',\n URL: 'url',\n addressCity: 'address-level2',\n addressCityAndState: 'address-level1',\n addressState: 'address-level1',\n birthdate: 'bday',\n birthdateDay: 'bday-day',\n birthdateMonth: 'bday-month',\n birthdateYear: 'bday-year',\n countryName: 'country-name',\n creditCardExpiration: 'cc-exp',\n creditCardExpirationMonth: 'cc-exp-month',\n creditCardExpirationYear: 'cc-exp-year',\n creditCardFamilyName: 'cc-family-name',\n creditCardGivenName: 'cc-given-name',\n creditCardMiddleName: 'cc-additional-name',\n creditCardName: 'cc-name',\n creditCardNumber: 'cc-number',\n creditCardSecurityCode: 'cc-csc',\n creditCardType: 'cc-type',\n emailAddress: 'email',\n familyName: 'family-name',\n fullStreetAddress: 'street-address',\n givenName: 'given-name',\n jobTitle: 'organization-title',\n location: 'street-address',\n middleName: 'additional-name',\n name: 'name',\n namePrefix: 'honorific-prefix',\n nameSuffix: 'honorific-suffix',\n newPassword: 'new-password',\n nickname: 'nickname',\n oneTimeCode: 'one-time-code',\n organizationName: 'organization',\n password: 'current-password',\n postalCode: 'postal-code',\n streetAddressLine1: 'address-line1',\n streetAddressLine2: 'address-line2',\n sublocality: 'address-level3',\n telephoneNumber: 'tel',\n username: 'username',\n}\n\nexport const toHTMLAutoComplete = (\n autoComplete: string | undefined,\n textContentType: string | undefined,\n): string | undefined => {\n if (autoComplete !== undefined) return reactNativeToHTML[autoComplete] ?? autoComplete\n if (textContentType !== undefined) return textContentTypeToHTML[textContentType]\n return undefined\n}\n\nconst keyboardTypeToInputMode: Record<string, string> = {\n 'decimal-pad': 'decimal',\n 'email-address': 'email',\n 'number-pad': 'numeric',\n numeric: 'numeric',\n 'numbers-and-punctuation': 'decimal',\n 'phone-pad': 'tel',\n url: 'url',\n 'web-search': 'search',\n}\n\nexport const toInputMode = (\n inputMode: string | undefined,\n keyboardType: string | undefined,\n showSoftInputOnFocus: boolean | undefined,\n): string | undefined => {\n if (showSoftInputOnFocus === false) return 'none'\n if (inputMode !== undefined) return inputMode\n if (keyboardType !== undefined) return keyboardTypeToInputMode[keyboardType]\n return undefined\n}\n\nconst returnKeyTypeToEnterKeyHint: Record<string, string> = {\n done: 'done',\n go: 'go',\n next: 'next',\n search: 'search',\n send: 'send',\n}\n\nexport const toEnterKeyHint = (\n enterKeyHint: string | undefined,\n returnKeyType: string | undefined,\n): string | undefined => {\n if (enterKeyHint !== undefined) return enterKeyHint\n if (returnKeyType !== undefined) return returnKeyTypeToEnterKeyHint[returnKeyType]\n return undefined\n}\n"],"mappings":";AAEA,MAAM,oBAA4C;CAChD,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CACjB,kBAAkB;CAClB,mBAAmB;CACnB,kBAAkB;CAClB,kBAAkB;CAClB,QAAQ;CACR,eAAe;CACf,cAAc;CACd,eAAe;CACf,uBAAuB;CACvB,eAAe;CACf,eAAe;CACf,kBAAkB;CAClB,0BAA0B;CAC1B,2BAA2B;CAC3B,uCAAuC;CACvC,2BAA2B;CAC3B,yBAAyB;CACzB,WAAW;CACX,cAAc;CACd,gBAAgB;AAClB;AAGA,MAAM,wBAAgD;CACpD,MAAM;CACN,KAAK;CACL,aAAa;CACb,qBAAqB;CACrB,cAAc;CACd,WAAW;CACX,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,aAAa;CACb,sBAAsB;CACtB,2BAA2B;CAC3B,0BAA0B;CAC1B,sBAAsB;CACtB,qBAAqB;CACrB,sBAAsB;CACtB,gBAAgB;CAChB,kBAAkB;CAClB,wBAAwB;CACxB,gBAAgB;CAChB,cAAc;CACd,YAAY;CACZ,mBAAmB;CACnB,WAAW;CACX,UAAU;CACV,UAAU;CACV,YAAY;CACZ,MAAM;CACN,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,UAAU;CACV,aAAa;CACb,kBAAkB;CAClB,UAAU;CACV,YAAY;CACZ,oBAAoB;CACpB,oBAAoB;CACpB,aAAa;CACb,iBAAiB;CACjB,UAAU;AACZ;AAEA,MAAa,sBACX,cACA,oBACuB;CACvB,IAAI,iBAAiB,KAAA,GAAW,OAAO,kBAAkB,iBAAiB;CAC1E,IAAI,oBAAoB,KAAA,GAAW,OAAO,sBAAsB;AAElE;AAEA,MAAM,0BAAkD;CACtD,eAAe;CACf,iBAAiB;CACjB,cAAc;CACd,SAAS;CACT,2BAA2B;CAC3B,aAAa;CACb,KAAK;CACL,cAAc;AAChB;AAEA,MAAa,eACX,WACA,cACA,yBACuB;CACvB,IAAI,yBAAyB,OAAO,OAAO;CAC3C,IAAI,cAAc,KAAA,GAAW,OAAO;CACpC,IAAI,iBAAiB,KAAA,GAAW,OAAO,wBAAwB;AAEjE;AAEA,MAAM,8BAAsD;CAC1D,MAAM;CACN,IAAI;CACJ,MAAM;CACN,QAAQ;CACR,MAAM;AACR;AAEA,MAAa,kBACX,cACA,kBACuB;CACvB,IAAI,iBAAiB,KAAA,GAAW,OAAO;CACvC,IAAI,kBAAkB,KAAA,GAAW,OAAO,4BAA4B;AAEtE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EnterKeyHint, InputMode, KeyboardType, ReturnKeyType, SubmitBehavior, TextInputChangeEvent, TextInputChangeEventData, TextInputContentSizeChangeEvent, TextInputEndEditingEvent, TextInputFocusEvent, TextInputInstance, TextInputKeyPressEvent, TextInputProps, TextInputScrollEvent, TextInputSelection, TextInputSelectionChangeEvent, TextInputState, TextInputSubmitEditingEvent } from "./types.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
declare function TextInputComponent(props: TextInputProps): ReactElement;
|
|
4
|
+
export declare const TextInput: typeof TextInputComponent & {
|
|
5
|
+
State: TextInputState;
|
|
6
|
+
};
|
|
7
|
+
export type { EnterKeyHint, InputMode, KeyboardType, ReturnKeyType, SubmitBehavior, TextInputChangeEvent, TextInputChangeEventData, TextInputContentSizeChangeEvent, TextInputEndEditingEvent, TextInputFocusEvent, TextInputInstance, TextInputKeyPressEvent, TextInputProps, TextInputScrollEvent, TextInputSelection, TextInputSelectionChangeEvent, TextInputState, TextInputSubmitEditingEvent };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|