@rootnative/web 0.0.0-alpha.2 → 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.
Files changed (243) hide show
  1. package/CHANGELOG.md +66 -1
  2. package/dist/apis/AccessibilityInfo/index.d.ts +30 -0
  3. package/dist/apis/AccessibilityInfo/index.js +84 -0
  4. package/dist/apis/AccessibilityInfo/index.js.map +1 -0
  5. package/dist/apis/Alert/index.d.ts +22 -0
  6. package/dist/apis/Alert/index.js +141 -0
  7. package/dist/apis/Alert/index.js.map +1 -0
  8. package/dist/apis/AppState/index.d.ts +21 -0
  9. package/dist/apis/AppState/index.js +86 -0
  10. package/dist/apis/AppState/index.js.map +1 -0
  11. package/dist/apis/Appearance/index.d.ts +14 -0
  12. package/dist/apis/Appearance/index.js +39 -0
  13. package/dist/apis/Appearance/index.js.map +1 -0
  14. package/dist/apis/BackHandler/index.d.ts +10 -0
  15. package/dist/apis/BackHandler/index.js +16 -0
  16. package/dist/apis/BackHandler/index.js.map +1 -0
  17. package/dist/apis/Clipboard/index.d.ts +9 -0
  18. package/dist/apis/Clipboard/index.js +45 -0
  19. package/dist/apis/Clipboard/index.js.map +1 -0
  20. package/dist/apis/Dimensions/index.d.ts +19 -0
  21. package/dist/apis/Dimensions/index.js +66 -0
  22. package/dist/apis/Dimensions/index.js.map +1 -0
  23. package/dist/apis/I18nManager/index.d.ts +14 -0
  24. package/dist/apis/I18nManager/index.js +33 -0
  25. package/dist/apis/I18nManager/index.js.map +1 -0
  26. package/dist/apis/Keyboard/index.d.ts +36 -0
  27. package/dist/apis/Keyboard/index.js +149 -0
  28. package/dist/apis/Keyboard/index.js.map +1 -0
  29. package/dist/apis/Linking/index.d.ts +29 -0
  30. package/dist/apis/Linking/index.js +86 -0
  31. package/dist/apis/Linking/index.js.map +1 -0
  32. package/dist/apis/PanResponder/index.d.ts +50 -0
  33. package/dist/apis/PanResponder/index.js +239 -0
  34. package/dist/apis/PanResponder/index.js.map +1 -0
  35. package/dist/apis/PixelRatio/index.d.ts +8 -0
  36. package/dist/apis/PixelRatio/index.js +15 -0
  37. package/dist/apis/PixelRatio/index.js.map +1 -0
  38. package/dist/apis/Platform/index.d.ts +4 -0
  39. package/dist/apis/Platform/index.js +28 -0
  40. package/dist/apis/Platform/index.js.map +1 -0
  41. package/dist/apis/Platform/types.d.ts +19 -0
  42. package/dist/apis/Share/index.d.ts +30 -0
  43. package/dist/apis/Share/index.js +34 -0
  44. package/dist/apis/Share/index.js.map +1 -0
  45. package/dist/apis/StyleSheet/index.d.ts +23 -0
  46. package/dist/apis/StyleSheet/index.js +29 -0
  47. package/dist/apis/StyleSheet/index.js.map +1 -0
  48. package/dist/apis/StyleSheet/types.d.ts +328 -0
  49. package/dist/apis/Vibration/index.d.ts +9 -0
  50. package/dist/apis/Vibration/index.js +40 -0
  51. package/dist/apis/Vibration/index.js.map +1 -0
  52. package/dist/apis/processColor/index.d.ts +3 -0
  53. package/dist/apis/processColor/index.js +12 -0
  54. package/dist/apis/processColor/index.js.map +1 -0
  55. package/dist/apis/useColorScheme/index.d.ts +3 -0
  56. package/dist/apis/useColorScheme/index.js +13 -0
  57. package/dist/apis/useColorScheme/index.js.map +1 -0
  58. package/dist/apis/useWindowDimensions/index.d.ts +3 -0
  59. package/dist/apis/useWindowDimensions/index.js +19 -0
  60. package/dist/apis/useWindowDimensions/index.js.map +1 -0
  61. package/dist/assets-registry/index.d.ts +18 -0
  62. package/dist/assets-registry/index.js +12 -0
  63. package/dist/assets-registry/index.js.map +1 -0
  64. package/dist/bundler/index.js +30 -0
  65. package/dist/bundler/index.js.map +1 -0
  66. package/dist/bundler/inlinePlatformOS.js +121 -0
  67. package/dist/bundler/inlinePlatformOS.js.map +1 -0
  68. package/dist/bundler/worklets.js +61 -0
  69. package/dist/bundler/worklets.js.map +1 -0
  70. package/dist/compat/TurboModuleRegistry/index.d.ts +16 -0
  71. package/dist/compat/TurboModuleRegistry/index.js +14 -0
  72. package/dist/compat/TurboModuleRegistry/index.js.map +1 -0
  73. package/dist/compat/createElement/index.d.ts +9 -0
  74. package/dist/compat/createElement/index.js +40 -0
  75. package/dist/compat/createElement/index.js.map +1 -0
  76. package/dist/compat/findNodeHandle/index.d.ts +7 -0
  77. package/dist/compat/findNodeHandle/index.js +19 -0
  78. package/dist/compat/findNodeHandle/index.js.map +1 -0
  79. package/dist/components/ActivityIndicator/index.d.ts +5 -0
  80. package/dist/components/ActivityIndicator/index.js +74 -0
  81. package/dist/components/ActivityIndicator/index.js.map +1 -0
  82. package/dist/components/ActivityIndicator/types.d.ts +8 -0
  83. package/dist/components/Button/index.d.ts +5 -0
  84. package/dist/components/Button/index.js +48 -0
  85. package/dist/components/Button/index.js.map +1 -0
  86. package/dist/components/Button/types.d.ts +31 -0
  87. package/dist/components/FlatList/index.d.ts +5 -0
  88. package/dist/components/FlatList/index.js +433 -0
  89. package/dist/components/FlatList/index.js.map +1 -0
  90. package/dist/components/FlatList/types.d.ts +138 -0
  91. package/dist/components/FlatList/viewability.js +86 -0
  92. package/dist/components/FlatList/viewability.js.map +1 -0
  93. package/dist/components/Image/index.d.ts +7 -0
  94. package/dist/components/Image/index.js +301 -0
  95. package/dist/components/Image/index.js.map +1 -0
  96. package/dist/components/Image/source.js +97 -0
  97. package/dist/components/Image/source.js.map +1 -0
  98. package/dist/components/Image/types.d.ts +96 -0
  99. package/dist/components/KeyboardAvoidingView/index.d.ts +10 -0
  100. package/dist/components/KeyboardAvoidingView/index.js +118 -0
  101. package/dist/components/KeyboardAvoidingView/index.js.map +1 -0
  102. package/dist/components/KeyboardAvoidingView/types.d.ts +14 -0
  103. package/dist/components/Modal/index.d.ts +9 -0
  104. package/dist/components/Modal/index.js +271 -0
  105. package/dist/components/Modal/index.js.map +1 -0
  106. package/dist/components/Modal/types.d.ts +29 -0
  107. package/dist/components/Pressable/index.d.ts +5 -0
  108. package/dist/components/Pressable/index.js +106 -0
  109. package/dist/components/Pressable/index.js.map +1 -0
  110. package/dist/components/Pressable/types.d.ts +44 -0
  111. package/dist/components/RefreshControl/index.d.ts +5 -0
  112. package/dist/components/RefreshControl/index.js +176 -0
  113. package/dist/components/RefreshControl/index.js.map +1 -0
  114. package/dist/components/RefreshControl/pull.js +16 -0
  115. package/dist/components/RefreshControl/pull.js.map +1 -0
  116. package/dist/components/RefreshControl/types.d.ts +14 -0
  117. package/dist/components/ScrollView/index.d.ts +5 -0
  118. package/dist/components/ScrollView/index.js +318 -0
  119. package/dist/components/ScrollView/index.js.map +1 -0
  120. package/dist/components/ScrollView/snap.js +38 -0
  121. package/dist/components/ScrollView/snap.js.map +1 -0
  122. package/dist/components/ScrollView/types.d.ts +115 -0
  123. package/dist/components/StatusBar/index.d.ts +26 -0
  124. package/dist/components/StatusBar/index.js +113 -0
  125. package/dist/components/StatusBar/index.js.map +1 -0
  126. package/dist/components/Switch/index.d.ts +5 -0
  127. package/dist/components/Switch/index.js +89 -0
  128. package/dist/components/Switch/index.js.map +1 -0
  129. package/dist/components/Switch/types.d.ts +25 -0
  130. package/dist/components/Text/TextAncestorContext.d.ts +3 -0
  131. package/dist/components/Text/TextAncestorContext.js +6 -0
  132. package/dist/components/Text/TextAncestorContext.js.map +1 -0
  133. package/dist/components/Text/index.d.ts +6 -0
  134. package/dist/components/Text/index.js +133 -0
  135. package/dist/components/Text/index.js.map +1 -0
  136. package/dist/components/Text/types.d.ts +38 -0
  137. package/dist/components/TextInput/autocomplete.js +102 -0
  138. package/dist/components/TextInput/autocomplete.js.map +1 -0
  139. package/dist/components/TextInput/index.d.ts +8 -0
  140. package/dist/components/TextInput/index.js +290 -0
  141. package/dist/components/TextInput/index.js.map +1 -0
  142. package/dist/components/TextInput/types.d.ts +130 -0
  143. package/dist/components/TouchableHighlight/index.d.ts +5 -0
  144. package/dist/components/TouchableHighlight/index.js +109 -0
  145. package/dist/components/TouchableHighlight/index.js.map +1 -0
  146. package/dist/components/TouchableHighlight/types.d.ts +15 -0
  147. package/dist/components/TouchableNativeFeedback/index.d.ts +11 -0
  148. package/dist/components/TouchableNativeFeedback/index.js +29 -0
  149. package/dist/components/TouchableNativeFeedback/index.js.map +1 -0
  150. package/dist/components/TouchableNativeFeedback/types.d.ts +19 -0
  151. package/dist/components/TouchableOpacity/index.d.ts +5 -0
  152. package/dist/components/TouchableOpacity/index.js +122 -0
  153. package/dist/components/TouchableOpacity/index.js.map +1 -0
  154. package/dist/components/TouchableOpacity/types.d.ts +11 -0
  155. package/dist/components/TouchableWithoutFeedback/index.d.ts +5 -0
  156. package/dist/components/TouchableWithoutFeedback/index.js +70 -0
  157. package/dist/components/TouchableWithoutFeedback/index.js.map +1 -0
  158. package/dist/components/TouchableWithoutFeedback/types.d.ts +40 -0
  159. package/dist/components/View/index.d.ts +5 -0
  160. package/dist/components/View/index.js +50 -0
  161. package/dist/components/View/index.js.map +1 -0
  162. package/dist/components/View/types.d.ts +98 -0
  163. package/dist/dom/Head.d.ts +21 -0
  164. package/dist/dom/Head.js +53 -0
  165. package/dist/dom/Head.js.map +1 -0
  166. package/dist/dom/index.d.ts +2 -22
  167. package/dist/dom/index.js +1 -53
  168. package/dist/events/press/Pressability.d.ts +2 -0
  169. package/dist/events/press/Pressability.js +366 -0
  170. package/dist/events/press/Pressability.js.map +1 -0
  171. package/dist/events/press/cursorStyle.js +5 -0
  172. package/dist/events/press/cursorStyle.js.map +1 -0
  173. package/dist/events/press/index.d.ts +4 -0
  174. package/dist/events/press/mergeHandlers.js +30 -0
  175. package/dist/events/press/mergeHandlers.js.map +1 -0
  176. package/dist/events/press/types.d.ts +48 -0
  177. package/dist/events/press/usePressability.d.ts +4 -0
  178. package/dist/events/press/usePressability.js +18 -0
  179. package/dist/events/press/usePressability.js.map +1 -0
  180. package/dist/events/responderEvent.js +50 -0
  181. package/dist/events/responderEvent.js.map +1 -0
  182. package/dist/events/types.d.ts +33 -0
  183. package/dist/index.d.ts +66 -1009
  184. package/dist/index.js +43 -3872
  185. package/dist/reactNativeVersion.d.ts +7 -0
  186. package/dist/reactNativeVersion.js +10 -0
  187. package/dist/reactNativeVersion.js.map +1 -0
  188. package/dist/render/domProps.js +66 -0
  189. package/dist/render/domProps.js.map +1 -0
  190. package/dist/render/hitSlop.js +21 -0
  191. package/dist/render/hitSlop.js.map +1 -0
  192. package/dist/render/hostMethods.js +44 -0
  193. package/dist/render/hostMethods.js.map +1 -0
  194. package/dist/render/resolveTag.js +64 -0
  195. package/dist/render/resolveTag.js.map +1 -0
  196. package/dist/render/useElementLayout.js +25 -0
  197. package/dist/render/useElementLayout.js.map +1 -0
  198. package/dist/server/index.d.ts +2 -23
  199. package/dist/server/index.js +8 -4
  200. package/dist/server/index.js.map +1 -1
  201. package/dist/style/StyleRegistryContext.js +8 -0
  202. package/dist/style/StyleRegistryContext.js.map +1 -0
  203. package/dist/style/color.js +16 -0
  204. package/dist/style/color.js.map +1 -0
  205. package/dist/style/compile.js +72 -0
  206. package/dist/style/compile.js.map +1 -0
  207. package/dist/style/direction.js +33 -0
  208. package/dist/style/direction.js.map +1 -0
  209. package/dist/style/index.d.ts +25 -0
  210. package/dist/style/index.js +38 -0
  211. package/dist/style/index.js.map +1 -0
  212. package/dist/style/registry.d.ts +27 -0
  213. package/dist/{StyleRegistryContext-CAD45r4n.js → style/registry.js} +32 -10
  214. package/dist/style/registry.js.map +1 -0
  215. package/dist/style/resolveStyle.js +181 -0
  216. package/dist/style/resolveStyle.js.map +1 -0
  217. package/dist/style/shadow.js +87 -0
  218. package/dist/style/shadow.js.map +1 -0
  219. package/dist/style/splitLayoutProps.js +52 -0
  220. package/dist/style/splitLayoutProps.js.map +1 -0
  221. package/dist/style/transform.js +35 -0
  222. package/dist/style/transform.js.map +1 -0
  223. package/dist/style/types.d.ts +4 -0
  224. package/dist/style/units.js +21 -0
  225. package/dist/style/units.js.map +1 -0
  226. package/dist/style/webStyle.js +9 -0
  227. package/dist/style/webStyle.js.map +1 -0
  228. package/dist/{env-DK5Mt9yX.js → utils/env.js} +2 -2
  229. package/dist/utils/env.js.map +1 -0
  230. package/dist/utils/scrollLock.js +28 -0
  231. package/dist/utils/scrollLock.js.map +1 -0
  232. package/dist/utils/warn.js +11 -0
  233. package/dist/utils/warn.js.map +1 -0
  234. package/dist/vite/index.d.ts +9 -1
  235. package/dist/vite/index.js +71 -174
  236. package/dist/vite/index.js.map +1 -1
  237. package/llms.txt +203 -22
  238. package/package.json +16 -3
  239. package/dist/StyleRegistryContext-CAD45r4n.js.map +0 -1
  240. package/dist/dom/index.js.map +0 -1
  241. package/dist/env-DK5Mt9yX.js.map +0 -1
  242. package/dist/index.js.map +0 -1
  243. package/dist/types-BxTWbdj9.d.ts +0 -5
@@ -0,0 +1,290 @@
1
+ import { toDOMProps } from "../../render/domProps.js";
2
+ import { applyNativeProps, withHostMethods } from "../../render/hostMethods.js";
3
+ import { useElementLayout } from "../../render/useElementLayout.js";
4
+ import { toCSSColor } from "../../style/color.js";
5
+ import { compileReset, compileStyle, flattenStyle, joinClassNames } from "../../style/compile.js";
6
+ import { useStyleRegistry } from "../../style/StyleRegistryContext.js";
7
+ import { hasDOM } from "../../utils/env.js";
8
+ import { toEnterKeyHint, toHTMLAutoComplete, toInputMode } from "./autocomplete.js";
9
+ import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react";
10
+ import { jsx } from "react/jsx-runtime";
11
+ // src/components/TextInput/index.tsx
12
+ const resetStyle = Object.freeze({
13
+ appearance: "none",
14
+ backgroundColor: "transparent",
15
+ border: "0 solid black",
16
+ borderRadius: 0,
17
+ boxSizing: "border-box",
18
+ color: "black",
19
+ display: "block",
20
+ fontFamily: "System",
21
+ fontSize: 14,
22
+ margin: 0,
23
+ minWidth: 0,
24
+ padding: 0,
25
+ position: "relative",
26
+ resize: "none",
27
+ textAlign: "start",
28
+ textDecoration: "none"
29
+ });
30
+ const textareaStyle = Object.freeze({
31
+ fieldSizing: "content",
32
+ overflow: "auto",
33
+ whiteSpace: "pre-wrap",
34
+ wordWrap: "break-word"
35
+ });
36
+ const supportsFieldSizing = hasDOM() && typeof CSS !== "undefined" && CSS.supports("field-sizing", "content");
37
+ const hash = (value) => {
38
+ let h = 5381;
39
+ for (let i = 0; i < value.length; i++) h = h * 33 ^ value.charCodeAt(i);
40
+ return (h >>> 0).toString(36);
41
+ };
42
+ const placeholderClass = (registry, color) => {
43
+ const css = toCSSColor(color);
44
+ if (css === void 0) return void 0;
45
+ const name = `rn-ph-${hash(css)}`;
46
+ return registry.staticClass(name, [`.${name}::placeholder{color:${css};opacity:1}`]);
47
+ };
48
+ const selectionClass = (registry, color) => {
49
+ const css = toCSSColor(color);
50
+ if (css === void 0) return void 0;
51
+ const name = `rn-sel-${hash(css)}`;
52
+ return registry.staticClass(name, [`.${name}::selection{background-color:${css}}`]);
53
+ };
54
+ const submitBehaviorOf = (submitBehavior, blurOnSubmit, multiline) => {
55
+ if (submitBehavior !== void 0) return submitBehavior;
56
+ if (multiline) return blurOnSubmit === true ? "blurAndSubmit" : "newline";
57
+ return blurOnSubmit === false ? "submit" : "blurAndSubmit";
58
+ };
59
+ const selectionOf = (field) => ({
60
+ start: field.selectionStart ?? 0,
61
+ end: field.selectionEnd ?? 0
62
+ });
63
+ const sameSelection = (a, b) => a !== null && a.start === b.start && a.end === b.end;
64
+ const isField = (node) => node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement;
65
+ function TextInputComponent(props) {
66
+ const { autoCapitalize, autoComplete, autoCorrect, autoFocus, blurOnSubmit: _blurOnSubmit, caretHidden, clearTextOnFocus: _clearTextOnFocus, contextMenuHidden: _contextMenuHidden, cursorColor, defaultValue, editable = true, enterKeyHint, inputMode, keyboardType, maxLength, multiline = false, numberOfLines, onBlur: _onBlur, onChange: _onChange, onChangeText: _onChangeText, onContentSizeChange, onContextMenu: _onContextMenu, onEndEditing: _onEndEditing, onFocus: _onFocus, onKeyDown: _onKeyDown, onKeyPress: _onKeyPress, onLayout, onScroll: _onScroll, onSelectionChange: _onSelectionChange, onSubmitEditing: _onSubmitEditing, placeholder, placeholderTextColor, readOnly, ref, returnKeyType, secureTextEntry, selectTextOnFocus: _selectTextOnFocus, selection, selectionColor, showSoftInputOnFocus, spellCheck, style, submitBehavior: _submitBehavior, textAlign, textContentType, value, allowFontScaling: _allowFontScaling, clearButtonMode: _clearButtonMode, dataDetectorTypes: _dataDetectorTypes, disableFullscreenUI: _disableFullscreenUI, enablesReturnKeyAutomatically: _enablesReturnKeyAutomatically, importantForAutofill: _importantForAutofill, inlineImageLeft: _inlineImageLeft, inlineImagePadding: _inlineImagePadding, keyboardAppearance: _keyboardAppearance, lineBreakStrategyIOS: _lineBreakStrategyIOS, maxFontSizeMultiplier: _maxFontSizeMultiplier, passwordRules: _passwordRules, rejectResponderTermination: _rejectResponderTermination, returnKeyLabel: _returnKeyLabel, scrollEnabled: _scrollEnabled, smartInsertDelete: _smartInsertDelete, textAlignVertical: _textAlignVertical, textBreakStrategy: _textBreakStrategy, underlineColorAndroid: _underlineColorAndroid, verticalAlign: _verticalAlign, ...rest } = props;
67
+ const registry = useStyleRegistry();
68
+ const field = useRef(null);
69
+ useElementLayout(field, onLayout);
70
+ const handlers = useRef(props);
71
+ useEffect(() => {
72
+ handlers.current = props;
73
+ });
74
+ const eventCount = useRef(0);
75
+ const lastSelection = useRef(null);
76
+ const lastContentSize = useRef(null);
77
+ const reportContentSize = useCallback((element) => {
78
+ const next = {
79
+ width: element.scrollWidth,
80
+ height: element.scrollHeight
81
+ };
82
+ const last = lastContentSize.current;
83
+ if (last !== null && last.width === next.width && last.height === next.height) return;
84
+ lastContentSize.current = next;
85
+ handlers.current.onContentSizeChange?.({ nativeEvent: { contentSize: next } });
86
+ }, []);
87
+ const grow = useCallback((element) => {
88
+ if (supportsFieldSizing || !(element instanceof HTMLTextAreaElement)) return;
89
+ if (handlers.current.style !== void 0) {
90
+ if (flattenStyle(handlers.current.style)?.["height"] !== void 0) return;
91
+ }
92
+ element.style.height = "auto";
93
+ element.style.height = `${element.scrollHeight}px`;
94
+ }, []);
95
+ const handleChange = useCallback((event) => {
96
+ const element = event.currentTarget;
97
+ const text = element.value;
98
+ eventCount.current += 1;
99
+ Object.assign(event.nativeEvent, {
100
+ text,
101
+ eventCount: eventCount.current
102
+ });
103
+ handlers.current.onChange?.(event);
104
+ handlers.current.onChangeText?.(text);
105
+ grow(element);
106
+ if (handlers.current.onContentSizeChange !== void 0) reportContentSize(element);
107
+ }, [grow, reportContentSize]);
108
+ const handleFocus = useCallback((event) => {
109
+ const element = event.currentTarget;
110
+ const current = handlers.current;
111
+ if (current.clearTextOnFocus === true && element.value !== "") {
112
+ element.value = "";
113
+ eventCount.current += 1;
114
+ current.onChangeText?.("");
115
+ }
116
+ if (current.selectTextOnFocus === true) element.select();
117
+ Object.assign(event.nativeEvent, {
118
+ text: element.value,
119
+ eventCount: eventCount.current
120
+ });
121
+ current.onFocus?.(event);
122
+ }, []);
123
+ const handleBlur = useCallback((event) => {
124
+ const element = event.currentTarget;
125
+ Object.assign(event.nativeEvent, {
126
+ text: element.value,
127
+ eventCount: eventCount.current
128
+ });
129
+ handlers.current.onBlur?.(event);
130
+ handlers.current.onEndEditing?.(event);
131
+ }, []);
132
+ const handleKeyDown = useCallback((event) => {
133
+ const current = handlers.current;
134
+ current.onKeyDown?.(event);
135
+ current.onKeyPress?.(event);
136
+ if (event.defaultPrevented || event.key !== "Enter" || event.shiftKey) return;
137
+ const isMultiline = current.multiline === true;
138
+ const behavior = submitBehaviorOf(current.submitBehavior, current.blurOnSubmit, isMultiline);
139
+ if (behavior === "newline") return;
140
+ if (isMultiline) event.preventDefault();
141
+ const element = event.currentTarget;
142
+ Object.assign(event.nativeEvent, { text: element.value });
143
+ current.onSubmitEditing?.(event);
144
+ if (behavior === "blurAndSubmit") element.blur();
145
+ }, []);
146
+ const handleSelect = useCallback((event) => {
147
+ const next = selectionOf(event.currentTarget);
148
+ if (sameSelection(lastSelection.current, next)) return;
149
+ lastSelection.current = next;
150
+ Object.assign(event.nativeEvent, { selection: next });
151
+ handlers.current.onSelectionChange?.(event);
152
+ }, []);
153
+ const handleScroll = useCallback((event) => {
154
+ const element = event.currentTarget;
155
+ Object.assign(event.nativeEvent, {
156
+ contentInset: {
157
+ top: 0,
158
+ left: 0,
159
+ bottom: 0,
160
+ right: 0
161
+ },
162
+ contentOffset: {
163
+ x: element.scrollLeft,
164
+ y: element.scrollTop
165
+ },
166
+ contentSize: {
167
+ width: element.scrollWidth,
168
+ height: element.scrollHeight
169
+ },
170
+ layoutMeasurement: {
171
+ width: element.clientWidth,
172
+ height: element.clientHeight
173
+ },
174
+ zoomScale: 1
175
+ });
176
+ handlers.current.onScroll?.(event);
177
+ }, []);
178
+ const handleContextMenu = useCallback((event) => {
179
+ handlers.current.onContextMenu?.(event);
180
+ if (handlers.current.contextMenuHidden === true) event.preventDefault();
181
+ }, []);
182
+ const selectionStart = selection?.start;
183
+ const selectionEnd = selection?.end ?? selection?.start;
184
+ useLayoutEffect(() => {
185
+ const element = field.current;
186
+ if (element === null || selectionStart === void 0 || selectionEnd === void 0) return;
187
+ if (element.selectionStart === selectionStart && element.selectionEnd === selectionEnd) return;
188
+ element.setSelectionRange(selectionStart, selectionEnd);
189
+ lastSelection.current = {
190
+ start: selectionStart,
191
+ end: selectionEnd
192
+ };
193
+ }, [
194
+ selectionStart,
195
+ selectionEnd,
196
+ value
197
+ ]);
198
+ useLayoutEffect(() => {
199
+ const element = field.current;
200
+ if (element === null) return;
201
+ grow(element);
202
+ }, [
203
+ grow,
204
+ value,
205
+ multiline
206
+ ]);
207
+ const wantsContentSize = onContentSizeChange !== void 0;
208
+ useEffect(() => {
209
+ const element = field.current;
210
+ if (element === null || !wantsContentSize) return;
211
+ reportContentSize(element);
212
+ const observer = new ResizeObserver(() => reportContentSize(element));
213
+ observer.observe(element);
214
+ return () => observer.disconnect();
215
+ }, [wantsContentSize, reportContentSize]);
216
+ useImperativeHandle(ref, () => {
217
+ const element = field.current;
218
+ return Object.assign(withHostMethods(element), {
219
+ clear: () => {
220
+ element.value = "";
221
+ grow(element);
222
+ handlers.current.onChangeText?.("");
223
+ },
224
+ isFocused: () => document.activeElement === element,
225
+ getNativeRef: () => element,
226
+ setNativeProps: ({ text, ...others }) => {
227
+ if (text !== void 0) element.value = text;
228
+ applyNativeProps(element, others);
229
+ grow(element);
230
+ }
231
+ });
232
+ }, [grow]);
233
+ const flat = flattenStyle(style);
234
+ const colorStyle = {};
235
+ const caret = cursorColor ?? selectionColor;
236
+ if (caretHidden === true) colorStyle["caretColor"] = "transparent";
237
+ else if (caret !== void 0) colorStyle["caretColor"] = caret;
238
+ if (textAlign !== void 0) colorStyle["textAlign"] = textAlign;
239
+ let className = joinClassNames(compileReset("rn-text-input", resetStyle, registry), multiline === true && compileReset("rn-text-input-multiline", textareaStyle, registry), compileStyle([flat, colorStyle], registry));
240
+ const placeholderName = placeholderClass(registry, placeholderTextColor);
241
+ if (placeholderName !== void 0) className = `${className} ${placeholderName}`;
242
+ const selectionName = selectionClass(registry, selectionColor);
243
+ if (selectionName !== void 0) className = `${className} ${selectionName}`;
244
+ const domProps = toDOMProps(rest);
245
+ domProps["className"] = className;
246
+ domProps["value"] = value;
247
+ domProps["defaultValue"] = defaultValue;
248
+ domProps["placeholder"] = placeholder;
249
+ domProps["readOnly"] = readOnly === true || !editable ? true : void 0;
250
+ domProps["maxLength"] = maxLength;
251
+ domProps["autoFocus"] = autoFocus;
252
+ domProps["autoCapitalize"] = autoCapitalize;
253
+ domProps["autoCorrect"] = autoCorrect === void 0 ? void 0 : autoCorrect ? "on" : "off";
254
+ domProps["spellCheck"] = spellCheck;
255
+ domProps["autoComplete"] = toHTMLAutoComplete(autoComplete, textContentType);
256
+ domProps["inputMode"] = toInputMode(inputMode, keyboardType, showSoftInputOnFocus);
257
+ domProps["enterKeyHint"] = toEnterKeyHint(enterKeyHint, returnKeyType);
258
+ domProps["dir"] ??= "auto";
259
+ domProps["onChange"] = handleChange;
260
+ domProps["onFocus"] = handleFocus;
261
+ domProps["onBlur"] = handleBlur;
262
+ domProps["onKeyDown"] = handleKeyDown;
263
+ domProps["onSelect"] = handleSelect;
264
+ domProps["onContextMenu"] = handleContextMenu;
265
+ if (multiline) {
266
+ domProps["rows"] = numberOfLines ?? 1;
267
+ domProps["onScroll"] = handleScroll;
268
+ return /* @__PURE__ */ jsx("textarea", {
269
+ ...domProps,
270
+ ref: field
271
+ });
272
+ }
273
+ domProps["type"] = secureTextEntry === true ? "password" : "text";
274
+ return /* @__PURE__ */ jsx("input", {
275
+ ...domProps,
276
+ ref: field
277
+ });
278
+ }
279
+ const TextInput = Object.assign(TextInputComponent, { State: {
280
+ currentlyFocusedInput: () => {
281
+ if (!hasDOM()) return null;
282
+ const active = document.activeElement;
283
+ return isField(active) ? active : null;
284
+ },
285
+ focusTextInput: (input) => input?.focus(),
286
+ blurTextInput: (input) => input?.blur()
287
+ } });
288
+ export { TextInput };
289
+
290
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/TextInput/index.tsx"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n type ChangeEvent,\n type FocusEvent,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type RefObject,\n type SyntheticEvent,\n type UIEvent,\n} from 'react'\n\nimport { toDOMProps } from '../../render/domProps'\nimport { applyNativeProps, withHostMethods } from '../../render/hostMethods'\nimport { useElementLayout } from '../../render/useElementLayout'\nimport { toCSSColor } from '../../style/color'\nimport { compileReset, compileStyle, flattenStyle, joinClassNames } from '../../style/compile'\nimport type { StyleRegistry } from '../../style/registry'\nimport { useStyleRegistry } from '../../style/StyleRegistryContext'\nimport { hasDOM } from '../../utils/env'\nimport { toEnterKeyHint, toHTMLAutoComplete, toInputMode } from './autocomplete'\nimport type {\n SubmitBehavior,\n TextInputChangeEvent,\n TextInputContentSizeChangeEvent,\n TextInputEndEditingEvent,\n TextInputFocusEvent,\n TextInputInstance,\n TextInputKeyPressEvent,\n TextInputProps,\n TextInputScrollEvent,\n TextInputSelection,\n TextInputSelectionChangeEvent,\n TextInputState,\n TextInputSubmitEditingEvent,\n} from './types'\n\nexport type {\n EnterKeyHint,\n InputMode,\n KeyboardType,\n ReturnKeyType,\n SubmitBehavior,\n TextInputChangeEvent,\n TextInputChangeEventData,\n TextInputContentSizeChangeEvent,\n TextInputEndEditingEvent,\n TextInputFocusEvent,\n TextInputInstance,\n TextInputKeyPressEvent,\n TextInputProps,\n TextInputScrollEvent,\n TextInputSelection,\n TextInputSelectionChangeEvent,\n TextInputState,\n TextInputSubmitEditingEvent,\n} from './types'\n\ntype Field = HTMLInputElement | HTMLTextAreaElement\n\n// What a native TextInput looks like before any style is applied: the Text\n// reset, plus the form-control resets of the browser.\nconst resetStyle = Object.freeze({\n appearance: 'none',\n backgroundColor: 'transparent',\n border: '0 solid black',\n borderRadius: 0,\n boxSizing: 'border-box',\n color: 'black',\n display: 'block',\n fontFamily: 'System',\n fontSize: 14,\n margin: 0,\n minWidth: 0,\n padding: 0,\n position: 'relative',\n resize: 'none',\n textAlign: 'start',\n textDecoration: 'none',\n})\n\n// A multiline input grows with its text, as on iOS.\nconst textareaStyle = Object.freeze({\n fieldSizing: 'content',\n overflow: 'auto',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n})\n\nconst supportsFieldSizing =\n hasDOM() && typeof CSS !== 'undefined' && CSS.supports('field-sizing', 'content')\n\n// A short stable class suffix for a color.\nconst hash = (value: string): string => {\n let h = 5381\n for (let i = 0; i < value.length; i++) h = (h * 33) ^ value.charCodeAt(i)\n return (h >>> 0).toString(36)\n}\n\nconst placeholderClass = (registry: StyleRegistry, color: unknown): string | undefined => {\n const css = toCSSColor(color)\n if (css === undefined) return undefined\n const name = `rn-ph-${hash(css)}`\n return registry.staticClass(name, [`.${name}::placeholder{color:${css};opacity:1}`])\n}\n\nconst selectionClass = (registry: StyleRegistry, color: unknown): string | undefined => {\n const css = toCSSColor(color)\n if (css === undefined) return undefined\n const name = `rn-sel-${hash(css)}`\n return registry.staticClass(name, [`.${name}::selection{background-color:${css}}`])\n}\n\nconst submitBehaviorOf = (\n submitBehavior: SubmitBehavior | undefined,\n blurOnSubmit: boolean | undefined,\n multiline: boolean,\n): SubmitBehavior => {\n if (submitBehavior !== undefined) return submitBehavior\n if (multiline) return blurOnSubmit === true ? 'blurAndSubmit' : 'newline'\n return blurOnSubmit === false ? 'submit' : 'blurAndSubmit'\n}\n\nconst selectionOf = (field: Field): TextInputSelection => ({\n start: field.selectionStart ?? 0,\n end: field.selectionEnd ?? 0,\n})\n\nconst sameSelection = (a: TextInputSelection | null, b: TextInputSelection): boolean =>\n a !== null && a.start === b.start && a.end === b.end\n\nconst isField = (node: Element | null): node is Field =>\n node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement\n\nfunction TextInputComponent(props: TextInputProps): ReactElement {\n const {\n autoCapitalize,\n autoComplete,\n autoCorrect,\n autoFocus,\n blurOnSubmit: _blurOnSubmit,\n caretHidden,\n clearTextOnFocus: _clearTextOnFocus,\n contextMenuHidden: _contextMenuHidden,\n cursorColor,\n defaultValue,\n editable = true,\n enterKeyHint,\n inputMode,\n keyboardType,\n maxLength,\n multiline = false,\n numberOfLines,\n onBlur: _onBlur,\n onChange: _onChange,\n onChangeText: _onChangeText,\n onContentSizeChange,\n onContextMenu: _onContextMenu,\n onEndEditing: _onEndEditing,\n onFocus: _onFocus,\n onKeyDown: _onKeyDown,\n onKeyPress: _onKeyPress,\n onLayout,\n onScroll: _onScroll,\n onSelectionChange: _onSelectionChange,\n onSubmitEditing: _onSubmitEditing,\n placeholder,\n placeholderTextColor,\n readOnly,\n ref,\n returnKeyType,\n secureTextEntry,\n selectTextOnFocus: _selectTextOnFocus,\n selection,\n selectionColor,\n showSoftInputOnFocus,\n spellCheck,\n style,\n submitBehavior: _submitBehavior,\n textAlign,\n textContentType,\n value,\n // Native only.\n allowFontScaling: _allowFontScaling,\n clearButtonMode: _clearButtonMode,\n dataDetectorTypes: _dataDetectorTypes,\n disableFullscreenUI: _disableFullscreenUI,\n enablesReturnKeyAutomatically: _enablesReturnKeyAutomatically,\n importantForAutofill: _importantForAutofill,\n inlineImageLeft: _inlineImageLeft,\n inlineImagePadding: _inlineImagePadding,\n keyboardAppearance: _keyboardAppearance,\n lineBreakStrategyIOS: _lineBreakStrategyIOS,\n maxFontSizeMultiplier: _maxFontSizeMultiplier,\n passwordRules: _passwordRules,\n rejectResponderTermination: _rejectResponderTermination,\n returnKeyLabel: _returnKeyLabel,\n scrollEnabled: _scrollEnabled,\n smartInsertDelete: _smartInsertDelete,\n textAlignVertical: _textAlignVertical,\n textBreakStrategy: _textBreakStrategy,\n underlineColorAndroid: _underlineColorAndroid,\n verticalAlign: _verticalAlign,\n ...rest\n } = props\n\n const registry = useStyleRegistry()\n const field = useRef<Field | null>(null)\n useElementLayout(field, onLayout)\n\n // The event handlers read the latest props from here. The `_` props above\n // only stay out of `rest`.\n const handlers = useRef(props)\n useEffect(() => {\n handlers.current = props\n })\n\n const eventCount = useRef(0)\n const lastSelection = useRef<TextInputSelection | null>(null)\n const lastContentSize = useRef<{ width: number; height: number } | null>(null)\n\n const reportContentSize = useCallback((element: Field): void => {\n const next = { width: element.scrollWidth, height: element.scrollHeight }\n const last = lastContentSize.current\n if (last !== null && last.width === next.width && last.height === next.height) return\n lastContentSize.current = next\n handlers.current.onContentSizeChange?.({\n nativeEvent: { contentSize: next },\n } as TextInputContentSizeChangeEvent)\n }, [])\n\n // The fallback for browsers without `field-sizing: content`.\n const grow = useCallback((element: Field): void => {\n if (supportsFieldSizing || !(element instanceof HTMLTextAreaElement)) return\n if (handlers.current.style !== undefined) {\n const flat = flattenStyle(handlers.current.style)\n if (flat?.['height'] !== undefined) return\n }\n element.style.height = 'auto'\n element.style.height = `${element.scrollHeight}px`\n }, [])\n\n const handleChange = useCallback(\n (event: ChangeEvent<Field>) => {\n const element = event.currentTarget\n const text = element.value\n eventCount.current += 1\n Object.assign(event.nativeEvent, { text, eventCount: eventCount.current })\n handlers.current.onChange?.(event as unknown as TextInputChangeEvent)\n handlers.current.onChangeText?.(text)\n grow(element)\n if (handlers.current.onContentSizeChange !== undefined) reportContentSize(element)\n },\n [grow, reportContentSize],\n )\n\n const handleFocus = useCallback((event: FocusEvent<Field>) => {\n const element = event.currentTarget\n const current = handlers.current\n if (current.clearTextOnFocus === true && element.value !== '') {\n element.value = ''\n eventCount.current += 1\n current.onChangeText?.('')\n }\n if (current.selectTextOnFocus === true) element.select()\n Object.assign(event.nativeEvent, { text: element.value, eventCount: eventCount.current })\n current.onFocus?.(event as unknown as TextInputFocusEvent)\n }, [])\n\n const handleBlur = useCallback((event: FocusEvent<Field>) => {\n const element = event.currentTarget\n Object.assign(event.nativeEvent, { text: element.value, eventCount: eventCount.current })\n handlers.current.onBlur?.(event as unknown as TextInputFocusEvent)\n handlers.current.onEndEditing?.(event as unknown as TextInputEndEditingEvent)\n }, [])\n\n const handleKeyDown = useCallback((event: KeyboardEvent<Field>) => {\n const current = handlers.current\n current.onKeyDown?.(event as unknown as KeyboardEvent<HTMLElement>)\n // The DOM KeyboardEvent already has `key`, and the property is read-only.\n current.onKeyPress?.(event as unknown as TextInputKeyPressEvent)\n if (event.defaultPrevented || event.key !== 'Enter' || event.shiftKey) return\n\n const isMultiline = current.multiline === true\n const behavior = submitBehaviorOf(current.submitBehavior, current.blurOnSubmit, isMultiline)\n if (behavior === 'newline') return\n // A single-line input keeps the default, so a form submits on Enter.\n if (isMultiline) event.preventDefault()\n const element = event.currentTarget\n Object.assign(event.nativeEvent, { text: element.value })\n current.onSubmitEditing?.(event as unknown as TextInputSubmitEditingEvent)\n if (behavior === 'blurAndSubmit') element.blur()\n }, [])\n\n const handleSelect = useCallback((event: SyntheticEvent<Field>) => {\n const next = selectionOf(event.currentTarget)\n if (sameSelection(lastSelection.current, next)) return\n lastSelection.current = next\n Object.assign(event.nativeEvent, { selection: next })\n handlers.current.onSelectionChange?.(event as unknown as TextInputSelectionChangeEvent)\n }, [])\n\n const handleScroll = useCallback((event: UIEvent<Field>) => {\n const element = event.currentTarget\n Object.assign(event.nativeEvent, {\n contentInset: { top: 0, left: 0, bottom: 0, right: 0 },\n contentOffset: { x: element.scrollLeft, y: element.scrollTop },\n contentSize: { width: element.scrollWidth, height: element.scrollHeight },\n layoutMeasurement: { width: element.clientWidth, height: element.clientHeight },\n zoomScale: 1,\n })\n handlers.current.onScroll?.(event as unknown as TextInputScrollEvent)\n }, [])\n\n const handleContextMenu = useCallback((event: MouseEvent<Field>) => {\n handlers.current.onContextMenu?.(event as unknown as MouseEvent<HTMLElement>)\n if (handlers.current.contextMenuHidden === true) event.preventDefault()\n }, [])\n\n // The controlled selection.\n const selectionStart = selection?.start\n const selectionEnd = selection?.end ?? selection?.start\n useLayoutEffect(() => {\n const element = field.current\n if (element === null || selectionStart === undefined || selectionEnd === undefined) return\n if (element.selectionStart === selectionStart && element.selectionEnd === selectionEnd) return\n element.setSelectionRange(selectionStart, selectionEnd)\n lastSelection.current = { start: selectionStart, end: selectionEnd }\n // A new value resets the caret in the DOM, so the effect runs on `value` too.\n // oxlint-disable-next-line react/exhaustive-effect-dependencies\n }, [selectionStart, selectionEnd, value])\n\n // Size after mount and after an outside value change.\n useLayoutEffect(() => {\n const element = field.current\n if (element === null) return\n grow(element)\n // `value` and `multiline` change the content height, so the effect runs on them.\n // oxlint-disable-next-line react/exhaustive-effect-dependencies\n }, [grow, value, multiline])\n\n const wantsContentSize = onContentSizeChange !== undefined\n useEffect(() => {\n const element = field.current\n if (element === null || !wantsContentSize) return\n reportContentSize(element)\n const observer = new ResizeObserver(() => reportContentSize(element))\n observer.observe(element)\n return () => observer.disconnect()\n }, [wantsContentSize, reportContentSize])\n\n useImperativeHandle(ref, () => {\n const element = field.current as Field\n const methods = {\n clear: () => {\n element.value = ''\n grow(element)\n handlers.current.onChangeText?.('')\n },\n isFocused: () => document.activeElement === element,\n getNativeRef: () => element,\n setNativeProps: ({ text, ...others }: Parameters<TextInputInstance['setNativeProps']>[0]) => {\n if (text !== undefined) element.value = text\n applyNativeProps(element, others)\n grow(element)\n },\n }\n return Object.assign(withHostMethods(element), methods) as TextInputInstance\n }, [grow])\n\n const flat = flattenStyle(style)\n const colorStyle: Record<string, unknown> = {}\n const caret = cursorColor ?? selectionColor\n if (caretHidden === true) colorStyle['caretColor'] = 'transparent'\n else if (caret !== undefined) colorStyle['caretColor'] = caret\n if (textAlign !== undefined) colorStyle['textAlign'] = textAlign\n\n let className = joinClassNames(\n compileReset('rn-text-input', resetStyle, registry),\n multiline === true && compileReset('rn-text-input-multiline', textareaStyle, registry),\n compileStyle([flat, colorStyle], registry),\n )\n const placeholderName = placeholderClass(registry, placeholderTextColor)\n if (placeholderName !== undefined) className = `${className} ${placeholderName}`\n const selectionName = selectionClass(registry, selectionColor)\n if (selectionName !== undefined) className = `${className} ${selectionName}`\n\n const domProps = toDOMProps(rest)\n domProps['className'] = className\n domProps['value'] = value\n domProps['defaultValue'] = defaultValue\n domProps['placeholder'] = placeholder\n domProps['readOnly'] = readOnly === true || !editable ? true : undefined\n domProps['maxLength'] = maxLength\n domProps['autoFocus'] = autoFocus\n domProps['autoCapitalize'] = autoCapitalize\n domProps['autoCorrect'] = autoCorrect === undefined ? undefined : autoCorrect ? 'on' : 'off'\n domProps['spellCheck'] = spellCheck\n domProps['autoComplete'] = toHTMLAutoComplete(autoComplete, textContentType)\n domProps['inputMode'] = toInputMode(inputMode, keyboardType, showSoftInputOnFocus)\n domProps['enterKeyHint'] = toEnterKeyHint(enterKeyHint, returnKeyType)\n domProps['dir'] ??= 'auto'\n\n domProps['onChange'] = handleChange\n domProps['onFocus'] = handleFocus\n domProps['onBlur'] = handleBlur\n domProps['onKeyDown'] = handleKeyDown\n domProps['onSelect'] = handleSelect\n domProps['onContextMenu'] = handleContextMenu\n\n if (multiline) {\n domProps['rows'] = numberOfLines ?? 1\n domProps['onScroll'] = handleScroll\n return <textarea {...domProps} ref={field as RefObject<HTMLTextAreaElement | null>} />\n }\n domProps['type'] = secureTextEntry === true ? 'password' : 'text'\n return <input {...domProps} ref={field as RefObject<HTMLInputElement | null>} />\n}\n\nconst State: TextInputState = {\n currentlyFocusedInput: () => {\n if (!hasDOM()) return null\n const active = document.activeElement\n return isField(active) ? active : null\n },\n focusTextInput: (input) => input?.focus(),\n blurTextInput: (input) => input?.blur(),\n}\n\nexport const TextInput: typeof TextInputComponent & { State: TextInputState } = Object.assign(\n TextInputComponent,\n { State },\n)\n"],"mappings":";;;;;;;;;;;AAkEA,MAAM,aAAa,OAAO,OAAO;CAC/B,YAAY;CACZ,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,WAAW;CACX,OAAO;CACP,SAAS;CACT,YAAY;CACZ,UAAU;CACV,QAAQ;CACR,UAAU;CACV,SAAS;CACT,UAAU;CACV,QAAQ;CACR,WAAW;CACX,gBAAgB;AAClB,CAAC;AAGD,MAAM,gBAAgB,OAAO,OAAO;CAClC,aAAa;CACb,UAAU;CACV,YAAY;CACZ,UAAU;AACZ,CAAC;AAED,MAAM,sBACJ,OAAO,KAAK,OAAO,QAAQ,eAAe,IAAI,SAAS,gBAAgB,SAAS;AAGlF,MAAM,QAAQ,UAA0B;CACtC,IAAI,IAAI;CACR,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,IAAK,IAAI,KAAM,MAAM,WAAW,CAAC;CACxE,QAAQ,MAAM,EAAA,CAAG,SAAS,EAAE;AAC9B;AAEA,MAAM,oBAAoB,UAAyB,UAAuC;CACxF,MAAM,MAAM,WAAW,KAAK;CAC5B,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAA;CAC9B,MAAM,OAAO,SAAS,KAAK,GAAG;CAC9B,OAAO,SAAS,YAAY,MAAM,CAAC,IAAI,KAAK,sBAAsB,IAAI,YAAY,CAAC;AACrF;AAEA,MAAM,kBAAkB,UAAyB,UAAuC;CACtF,MAAM,MAAM,WAAW,KAAK;CAC5B,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAA;CAC9B,MAAM,OAAO,UAAU,KAAK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B,SAAS,cAAc,aAAa,QAAQ,CAAC,WAAW,OAAO,KAAA;CAC/D,SAAS,eAAe;CACxB,SAAS,eAAe;CACxB,SAAS,oBAAoB;CAC7B,SAAS,iBAAiB,gBAAgB,KAAA,IAAY,KAAA,IAAY,cAAc,OAAO;CACvF,SAAS,gBAAgB;CACzB,SAAS,kBAAkB,mBAAmB,cAAc,eAAe;CAC3E,SAAS,eAAe,YAAY,WAAW,cAAc,oBAAoB;CACjF,SAAS,kBAAkB,eAAe,cAAc,aAAa;CACrE,SAAS,WAAW;CAEpB,SAAS,cAAc;CACvB,SAAS,aAAa;CACtB,SAAS,YAAY;CACrB,SAAS,eAAe;CACxB,SAAS,cAAc;CACvB,SAAS,mBAAmB;CAE5B,IAAI,WAAW;EACb,SAAS,UAAU,iBAAiB;EACpC,SAAS,cAAc;EACvB,OAAO,oBAAC,YAAD;GAAU,GAAI;GAAU,KAAK;EAAiD,CAAA;CACvF;CACA,SAAS,UAAU,oBAAoB,OAAO,aAAa;CAC3D,OAAO,oBAAC,SAAD;EAAO,GAAI;EAAU,KAAK;CAA8C,CAAA;AACjF;AAYA,MAAa,YAAmE,OAAO,OACrF,oBACA,EAAE;CAXF,6BAA6B;EAC3B,IAAI,CAAC,OAAO,GAAG,OAAO;EACtB,MAAM,SAAS,SAAS;EACxB,OAAO,QAAQ,MAAM,IAAI,SAAS;CACpC;CACA,iBAAiB,UAAU,OAAO,MAAM;CACxC,gBAAgB,UAAU,OAAO,KAAK;AAKpC,EAAM,CACV"}
@@ -0,0 +1,130 @@
1
+ import { TextStyle } from "../../apis/StyleSheet/types.js";
2
+ import { NativeSyntheticEvent } from "../../events/types.js";
3
+ import { StyleProp } from "../../style/types.js";
4
+ import { NativeScrollEvent } from "../ScrollView/types.js";
5
+ import { AccessibilityProps, DOMEventHandlers, HostMethods, LayoutChangeEvent } from "../View/types.js";
6
+ import { Ref } from "react";
7
+ export type TextInputSelection = {
8
+ start: number;
9
+ end: number;
10
+ };
11
+ export type TextInputChangeEventData = {
12
+ text: string;
13
+ eventCount: number;
14
+ target: EventTarget | null;
15
+ };
16
+ export type TextInputChangeEvent = NativeSyntheticEvent<TextInputChangeEventData>;
17
+ export type TextInputFocusEvent = NativeSyntheticEvent<TextInputChangeEventData>;
18
+ export type TextInputEndEditingEvent = NativeSyntheticEvent<{
19
+ text: string;
20
+ }>;
21
+ export type TextInputSubmitEditingEvent = NativeSyntheticEvent<{
22
+ text: string;
23
+ }>;
24
+ export type TextInputKeyPressEvent = NativeSyntheticEvent<{
25
+ key: string;
26
+ }>;
27
+ export type TextInputSelectionChangeEvent = NativeSyntheticEvent<{
28
+ selection: TextInputSelection;
29
+ }>;
30
+ export type TextInputContentSizeChangeEvent = NativeSyntheticEvent<{
31
+ contentSize: {
32
+ width: number;
33
+ height: number;
34
+ };
35
+ }>;
36
+ export type TextInputScrollEvent = NativeSyntheticEvent<NativeScrollEvent>;
37
+ export type KeyboardType = "default" | "number-pad" | "decimal-pad" | "numeric" | "email-address" | "phone-pad" | "url" | "ascii-capable" | "numbers-and-punctuation" | "name-phone-pad" | "twitter" | "web-search" | "visible-password" | "ascii-capable-number-pad";
38
+ export type InputMode = "none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url";
39
+ export type ReturnKeyType = "done" | "go" | "next" | "search" | "send" | "none" | "previous" | "default" | "emergency-call" | "google" | "join" | "route" | "yahoo";
40
+ export type EnterKeyHint = "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
41
+ export type SubmitBehavior = "submit" | "blurAndSubmit" | "newline";
42
+ export type TextInputInstance = HTMLInputElement & HTMLTextAreaElement & Omit<HostMethods, "setNativeProps"> & {
43
+ clear: () => void;
44
+ isFocused: () => boolean;
45
+ getNativeRef: () => HTMLInputElement | HTMLTextAreaElement;
46
+ setNativeProps: (props: {
47
+ text?: string | undefined;
48
+ style?: StyleProp<TextStyle> | undefined;
49
+ }) => void;
50
+ };
51
+ type ReservedDOMHandlers = "onChange" | "onFocus" | "onBlur" | "onKeyPress" | "onSelect" | "onScroll" | "onInput";
52
+ export interface TextInputProps extends AccessibilityProps, Omit<DOMEventHandlers<HTMLElement>, ReservedDOMHandlers> {
53
+ ref?: Ref<TextInputInstance> | undefined;
54
+ style?: StyleProp<TextStyle> | undefined;
55
+ id?: string | undefined;
56
+ nativeID?: string | undefined;
57
+ testID?: string | undefined;
58
+ value?: string | undefined;
59
+ defaultValue?: string | undefined;
60
+ placeholder?: string | undefined;
61
+ placeholderTextColor?: unknown;
62
+ editable?: boolean | undefined;
63
+ readOnly?: boolean | undefined;
64
+ multiline?: boolean | undefined;
65
+ numberOfLines?: number | undefined;
66
+ maxLength?: number | undefined;
67
+ secureTextEntry?: boolean | undefined;
68
+ keyboardType?: KeyboardType | undefined;
69
+ inputMode?: InputMode | undefined;
70
+ returnKeyType?: ReturnKeyType | undefined;
71
+ enterKeyHint?: EnterKeyHint | undefined;
72
+ autoCapitalize?: "none" | "sentences" | "words" | "characters" | undefined;
73
+ autoCorrect?: boolean | undefined;
74
+ spellCheck?: boolean | undefined;
75
+ autoComplete?: string | undefined;
76
+ textContentType?: string | undefined;
77
+ autoFocus?: boolean | undefined;
78
+ blurOnSubmit?: boolean | undefined;
79
+ submitBehavior?: SubmitBehavior | undefined;
80
+ selectTextOnFocus?: boolean | undefined;
81
+ clearTextOnFocus?: boolean | undefined;
82
+ selection?: {
83
+ start: number;
84
+ end?: number | undefined;
85
+ } | undefined;
86
+ selectionColor?: unknown;
87
+ cursorColor?: unknown;
88
+ caretHidden?: boolean | undefined;
89
+ contextMenuHidden?: boolean | undefined;
90
+ showSoftInputOnFocus?: boolean | undefined;
91
+ textAlign?: "left" | "center" | "right" | undefined;
92
+ onChange?: ((event: TextInputChangeEvent) => void) | undefined;
93
+ onChangeText?: ((text: string) => void) | undefined;
94
+ onFocus?: ((event: TextInputFocusEvent) => void) | undefined;
95
+ onBlur?: ((event: TextInputFocusEvent) => void) | undefined;
96
+ onEndEditing?: ((event: TextInputEndEditingEvent) => void) | undefined;
97
+ onSubmitEditing?: ((event: TextInputSubmitEditingEvent) => void) | undefined;
98
+ onKeyPress?: ((event: TextInputKeyPressEvent) => void) | undefined;
99
+ onSelectionChange?: ((event: TextInputSelectionChangeEvent) => void) | undefined;
100
+ onContentSizeChange?: ((event: TextInputContentSizeChangeEvent) => void) | undefined;
101
+ onScroll?: ((event: TextInputScrollEvent) => void) | undefined;
102
+ onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
103
+ allowFontScaling?: boolean | undefined;
104
+ clearButtonMode?: "never" | "while-editing" | "unless-editing" | "always" | undefined;
105
+ dataDetectorTypes?: unknown;
106
+ disableFullscreenUI?: boolean | undefined;
107
+ enablesReturnKeyAutomatically?: boolean | undefined;
108
+ importantForAutofill?: "auto" | "no" | "noExcludeDescendants" | "yes" | "yesExcludeDescendants" | undefined;
109
+ inlineImageLeft?: string | undefined;
110
+ inlineImagePadding?: number | undefined;
111
+ keyboardAppearance?: "default" | "light" | "dark" | undefined;
112
+ lineBreakStrategyIOS?: "none" | "standard" | "hangul-word" | "push-out" | undefined;
113
+ maxFontSizeMultiplier?: number | null | undefined;
114
+ passwordRules?: string | null | undefined;
115
+ rejectResponderTermination?: boolean | null | undefined;
116
+ returnKeyLabel?: string | undefined;
117
+ scrollEnabled?: boolean | undefined;
118
+ smartInsertDelete?: boolean | undefined;
119
+ textAlignVertical?: "auto" | "top" | "bottom" | "center" | undefined;
120
+ textBreakStrategy?: "simple" | "highQuality" | "balanced" | undefined;
121
+ underlineColorAndroid?: unknown;
122
+ verticalAlign?: "auto" | "top" | "bottom" | "middle" | undefined;
123
+ }
124
+ export type TextInputState = {
125
+ currentlyFocusedInput: () => HTMLInputElement | HTMLTextAreaElement | null;
126
+ focusTextInput: (input: HTMLElement | null | undefined) => void;
127
+ blurTextInput: (input: HTMLElement | null | undefined) => void;
128
+ };
129
+ export {};
130
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { TouchableHighlightProps } from "./types.js";
2
+ import { ReactElement } from "react";
3
+ export declare function TouchableHighlight(props: TouchableHighlightProps): ReactElement;
4
+ export type { TouchableHighlightProps };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,109 @@
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 { hitSlopClass } from "../../render/hitSlop.js";
5
+ import { useStyleRegistry } from "../../style/StyleRegistryContext.js";
6
+ import { warnOnce } from "../../utils/warn.js";
7
+ import { useViewElement } from "../View/index.js";
8
+ import { Children, Fragment, cloneElement, useEffect, useMemo, useRef, useState } from "react";
9
+ // src/components/TouchableHighlight/index.tsx
10
+ const DEFAULT_ACTIVE_OPACITY = .85;
11
+ const DEFAULT_UNDERLAY_COLOR = "black";
12
+ const notCancelableStyle = Object.freeze({ touchAction: "none" });
13
+ function TouchableHighlight(props) {
14
+ const { activeOpacity, children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hasTVPreferredFocus: _hasTVPreferredFocus, hitSlop, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, onBlur, onFocus, onHideUnderlay, onLongPress, onPress, onPressIn, onPressOut, onShowUnderlay, pressRetentionOffset, rejectResponderTermination, style, testOnly_pressed, touchSoundDisabled, underlayColor, ...rest } = props;
15
+ const [underlay, setUnderlay] = useState(false);
16
+ const hideTimer = useRef(null);
17
+ const resolvedDisabled = disabled ?? props.accessibilityState?.disabled;
18
+ const hasPressHandler = onPress != null || onPressIn != null || onPressOut != null || onLongPress != null;
19
+ const config = useMemo(() => {
20
+ const clearHideTimer = () => {
21
+ if (hideTimer.current !== null) clearTimeout(hideTimer.current);
22
+ hideTimer.current = null;
23
+ };
24
+ const show = () => {
25
+ if (!hasPressHandler) return;
26
+ setUnderlay(true);
27
+ onShowUnderlay?.();
28
+ };
29
+ const hide = () => {
30
+ clearHideTimer();
31
+ if (testOnly_pressed === true || !hasPressHandler) return;
32
+ setUnderlay(false);
33
+ onHideUnderlay?.();
34
+ };
35
+ return {
36
+ cancelable: rejectResponderTermination !== true,
37
+ disabled: resolvedDisabled,
38
+ hitSlop,
39
+ delayLongPress,
40
+ delayPressIn,
41
+ delayPressOut,
42
+ minPressDuration: 0,
43
+ pressRectOffset: pressRetentionOffset,
44
+ android_disableSound: touchSoundDisabled,
45
+ onBlur,
46
+ onFocus,
47
+ onLongPress,
48
+ onPress: (event) => {
49
+ clearHideTimer();
50
+ show();
51
+ hideTimer.current = setTimeout(hide, delayPressOut ?? 0);
52
+ onPress?.(event);
53
+ },
54
+ onPressIn: (event) => {
55
+ clearHideTimer();
56
+ show();
57
+ onPressIn?.(event);
58
+ },
59
+ onPressOut: (event) => {
60
+ if (hideTimer.current === null) hide();
61
+ onPressOut?.(event);
62
+ }
63
+ };
64
+ }, [
65
+ delayLongPress,
66
+ delayPressIn,
67
+ delayPressOut,
68
+ hasPressHandler,
69
+ hitSlop,
70
+ onBlur,
71
+ onFocus,
72
+ onHideUnderlay,
73
+ onLongPress,
74
+ onPress,
75
+ onPressIn,
76
+ onPressOut,
77
+ onShowUnderlay,
78
+ pressRetentionOffset,
79
+ rejectResponderTermination,
80
+ resolvedDisabled,
81
+ testOnly_pressed,
82
+ touchSoundDisabled
83
+ ]);
84
+ const handlers = usePressability(config);
85
+ const registry = useStyleRegistry();
86
+ useEffect(() => () => {
87
+ if (hideTimer.current !== null) clearTimeout(hideTimer.current);
88
+ }, []);
89
+ const pressed = underlay || testOnly_pressed === true;
90
+ const child = Children.only(children);
91
+ if (child.type === Fragment) warnOnce("TouchableHighlight-fragment", "TouchableHighlight does not support a Fragment as its child. Wrap the children in one View.");
92
+ const content = child.type === Fragment ? child : cloneElement(child, { style: [child.props.style, pressed && { opacity: activeOpacity ?? DEFAULT_ACTIVE_OPACITY }] });
93
+ return useViewElement({
94
+ ...rest,
95
+ ...mergeHandlers(rest, handlers),
96
+ focusable: focusable !== false && onPress !== void 0 && disabled !== true,
97
+ style: [
98
+ resolvedDisabled !== true && pointerCursorStyle,
99
+ style,
100
+ pressed && { backgroundColor: underlayColor ?? DEFAULT_UNDERLAY_COLOR },
101
+ rejectResponderTermination === true && notCancelableStyle
102
+ ],
103
+ children: content,
104
+ ...resolvedDisabled === true && { "aria-disabled": true }
105
+ }, hitSlopClass(registry, hitSlop));
106
+ }
107
+ export { TouchableHighlight };
108
+
109
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/TouchableHighlight/index.tsx"],"sourcesContent":["import {\n Children,\n Fragment,\n cloneElement,\n useEffect,\n useMemo,\n useRef,\n useState,\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 { hitSlopClass } from '../../render/hitSlop'\nimport { useStyleRegistry } from '../../style/StyleRegistryContext'\nimport { warnOnce } from '../../utils/warn'\nimport { useViewElement } from '../View'\nimport type { TouchableHighlightProps } from './types'\n\nexport type { TouchableHighlightProps } from './types'\n\nconst DEFAULT_ACTIVE_OPACITY = 0.85\nconst DEFAULT_UNDERLAY_COLOR = 'black'\n\nconst notCancelableStyle = Object.freeze({ touchAction: 'none' })\n\nexport function TouchableHighlight(props: TouchableHighlightProps): ReactElement {\n const {\n activeOpacity,\n children,\n delayLongPress,\n delayPressIn,\n delayPressOut,\n disabled,\n focusable,\n hasTVPreferredFocus: _hasTVPreferredFocus,\n hitSlop,\n nextFocusDown: _nextFocusDown,\n nextFocusForward: _nextFocusForward,\n nextFocusLeft: _nextFocusLeft,\n nextFocusRight: _nextFocusRight,\n nextFocusUp: _nextFocusUp,\n onBlur,\n onFocus,\n onHideUnderlay,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n onShowUnderlay,\n pressRetentionOffset,\n rejectResponderTermination,\n style,\n testOnly_pressed,\n touchSoundDisabled,\n underlayColor,\n ...rest\n } = props\n\n const [underlay, setUnderlay] = useState(false)\n const hideTimer = useRef<ReturnType<typeof setTimeout> | null>(null)\n // React Native reads only `disabled` and `accessibilityState` here, not `aria-disabled`.\n const resolvedDisabled = disabled ?? props.accessibilityState?.disabled\n const hasPressHandler =\n onPress != null || onPressIn != null || onPressOut != null || onLongPress != null\n\n const config = useMemo<PressabilityConfig>(() => {\n const clearHideTimer = (): void => {\n if (hideTimer.current !== null) clearTimeout(hideTimer.current)\n hideTimer.current = null\n }\n const show = (): void => {\n if (!hasPressHandler) return\n setUnderlay(true)\n onShowUnderlay?.()\n }\n const hide = (): void => {\n clearHideTimer()\n if (testOnly_pressed === true || !hasPressHandler) return\n setUnderlay(false)\n onHideUnderlay?.()\n }\n return {\n cancelable: rejectResponderTermination !== true,\n disabled: resolvedDisabled,\n hitSlop,\n delayLongPress,\n delayPressIn,\n delayPressOut,\n minPressDuration: 0,\n pressRectOffset: pressRetentionOffset,\n android_disableSound: touchSoundDisabled,\n onBlur,\n onFocus,\n onLongPress,\n // As in React Native, a press shows the underlay again and hides it after delayPressOut,\n // so even a short tap flashes it.\n onPress: (event) => {\n clearHideTimer()\n show()\n hideTimer.current = setTimeout(hide, delayPressOut ?? 0)\n onPress?.(event)\n },\n onPressIn: (event) => {\n clearHideTimer()\n show()\n onPressIn?.(event)\n },\n onPressOut: (event) => {\n if (hideTimer.current === null) hide()\n onPressOut?.(event)\n },\n }\n }, [\n delayLongPress,\n delayPressIn,\n delayPressOut,\n hasPressHandler,\n hitSlop,\n onBlur,\n onFocus,\n onHideUnderlay,\n onLongPress,\n onPress,\n onPressIn,\n onPressOut,\n onShowUnderlay,\n pressRetentionOffset,\n rejectResponderTermination,\n resolvedDisabled,\n testOnly_pressed,\n touchSoundDisabled,\n ])\n const handlers = usePressability(config)\n const registry = useStyleRegistry()\n\n useEffect(\n () => () => {\n if (hideTimer.current !== null) clearTimeout(hideTimer.current)\n },\n [],\n )\n\n const pressed = underlay || testOnly_pressed === true\n const child = Children.only(children) as ReactElement<{ style?: unknown }>\n if (child.type === Fragment) {\n warnOnce(\n 'TouchableHighlight-fragment',\n 'TouchableHighlight does not support a Fragment as its child. Wrap the children in one View.',\n )\n }\n const content =\n child.type === Fragment\n ? child\n : cloneElement(child, {\n style: [\n child.props.style,\n pressed && { opacity: activeOpacity ?? DEFAULT_ACTIVE_OPACITY },\n ],\n })\n\n return useViewElement(\n {\n ...rest,\n ...mergeHandlers(rest, handlers),\n focusable: focusable !== false && onPress !== undefined && disabled !== true,\n style: [\n resolvedDisabled !== true && pointerCursorStyle,\n style,\n pressed && { backgroundColor: underlayColor ?? DEFAULT_UNDERLAY_COLOR },\n rejectResponderTermination === true && notCancelableStyle,\n ],\n children: content,\n ...(resolvedDisabled === true && { 'aria-disabled': true }),\n },\n hitSlopClass(registry, hitSlop),\n )\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,yBAAyB;AAC/B,MAAM,yBAAyB;AAE/B,MAAM,qBAAqB,OAAO,OAAO,EAAE,aAAa,OAAO,CAAC;AAEhE,SAAgB,mBAAmB,OAA8C;CAC/E,MAAM,EACJ,eACA,UACA,gBACA,cACA,eACA,UACA,WACA,qBAAqB,sBACrB,SACA,eAAe,gBACf,kBAAkB,mBAClB,eAAe,gBACf,gBAAgB,iBAChB,aAAa,cACb,QACA,SACA,gBACA,aACA,SACA,WACA,YACA,gBACA,sBACA,4BACA,OACA,kBACA,oBACA,eACA,GAAG,SACD;CAEJ,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,YAAY,OAA6C,IAAI;CAEnE,MAAM,mBAAmB,YAAY,MAAM,oBAAoB;CAC/D,MAAM,kBACJ,WAAW,QAAQ,aAAa,QAAQ,cAAc,QAAQ,eAAe;CAE/E,MAAM,SAAS,cAAkC;EAC/C,MAAM,uBAA6B;GACjC,IAAI,UAAU,YAAY,MAAM,aAAa,U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AqB,QAAQ;GAC7B;GACA,WAAW,EAAE,iBAAiB,iBAAiB,uBAAuB;GACtE,+BAA+B,QAAQ;EACzC;EACA,UAAU;EACV,GAAI,qBAAqB,QAAQ,EAAE,iBAAiB,KAAK;CAC3D,GACA,aAAa,UAAU,OAAO,CAChC;AACF"}
@@ -0,0 +1,15 @@
1
+ import { ViewStyle } from "../../apis/StyleSheet/types.js";
2
+ import { StyleProp } from "../../style/types.js";
3
+ import { TouchablePressProps, TouchableTVProps } from "../TouchableWithoutFeedback/types.js";
4
+ import { ViewProps } from "../View/types.js";
5
+ import { ReactNode } from "react";
6
+ export interface TouchableHighlightProps extends Omit<ViewProps, "children" | "style" | "onBlur" | "onFocus">, TouchablePressProps, TouchableTVProps {
7
+ children?: ReactNode | undefined;
8
+ style?: StyleProp<ViewStyle> | undefined;
9
+ activeOpacity?: number | undefined;
10
+ underlayColor?: string | undefined;
11
+ onShowUnderlay?: (() => void) | undefined;
12
+ onHideUnderlay?: (() => void) | undefined;
13
+ testOnly_pressed?: boolean | undefined;
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { RippleBackgroundPropType, ThemeAttributeBackgroundPropType, TouchableNativeFeedbackProps } from "./types.js";
2
+ import { ReactElement } from "react";
3
+ type TouchableNativeFeedbackStatics = {
4
+ SelectableBackground: (rippleRadius?: number | null) => ThemeAttributeBackgroundPropType;
5
+ SelectableBackgroundBorderless: (rippleRadius?: number | null) => ThemeAttributeBackgroundPropType;
6
+ Ripple: (color: string, borderless: boolean, rippleRadius?: number | null) => RippleBackgroundPropType;
7
+ canUseNativeForeground: () => boolean;
8
+ };
9
+ export declare const TouchableNativeFeedback: ((props: TouchableNativeFeedbackProps) => ReactElement) & TouchableNativeFeedbackStatics;
10
+ export type { TouchableNativeFeedbackProps };
11
+ //# sourceMappingURL=index.d.ts.map