@onekeyfe/react-native-auto-size-input 3.0.96 → 3.0.99

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.
@@ -7,345 +7,51 @@
7
7
 
8
8
  #include "HybridAutoSizeInputComponent.hpp"
9
9
 
10
- #include <string>
11
- #include <exception>
12
- #include <utility>
13
- #include <NitroModules/NitroDefines.hpp>
14
- #include <NitroModules/JSIConverter.hpp>
15
- #include <NitroModules/PropNameIDCache.hpp>
16
- #include <react/renderer/core/RawValue.h>
17
- #include <react/renderer/core/ShadowNode.h>
18
- #include <react/renderer/core/ComponentDescriptor.h>
19
- #include <react/renderer/components/view/ViewProps.h>
10
+ #include <NitroModules/NitroHash.hpp>
11
+ #include <NitroModules/ReactProp.hpp>
20
12
 
21
13
  namespace margelo::nitro::autosizeinput::views {
22
14
 
15
+ using namespace facebook;
16
+
23
17
  extern const char HybridAutoSizeInputComponentName[] = "AutoSizeInput";
24
18
 
25
19
  HybridAutoSizeInputProps::HybridAutoSizeInputProps(const react::PropsParserContext& context,
26
20
  const HybridAutoSizeInputProps& sourceProps,
27
21
  const react::RawProps& rawProps):
28
22
  react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
- mostRecentEventCount([&]() -> CachedProp<std::optional<double>> {
30
- try {
31
- const react::RawValue* rawValue = rawProps.at("mostRecentEventCount", nullptr, nullptr);
32
- if (rawValue == nullptr) return sourceProps.mostRecentEventCount;
33
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.mostRecentEventCount);
35
- } catch (const std::exception& exc) {
36
- throw std::runtime_error(std::string("AutoSizeInput.mostRecentEventCount: ") + exc.what());
37
- }
38
- }()),
39
- text([&]() -> CachedProp<std::optional<std::string>> {
40
- try {
41
- const react::RawValue* rawValue = rawProps.at("text", nullptr, nullptr);
42
- if (rawValue == nullptr) return sourceProps.text;
43
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.text);
45
- } catch (const std::exception& exc) {
46
- throw std::runtime_error(std::string("AutoSizeInput.text: ") + exc.what());
47
- }
48
- }()),
49
- prefix([&]() -> CachedProp<std::optional<std::string>> {
50
- try {
51
- const react::RawValue* rawValue = rawProps.at("prefix", nullptr, nullptr);
52
- if (rawValue == nullptr) return sourceProps.prefix;
53
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
54
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.prefix);
55
- } catch (const std::exception& exc) {
56
- throw std::runtime_error(std::string("AutoSizeInput.prefix: ") + exc.what());
57
- }
58
- }()),
59
- suffix([&]() -> CachedProp<std::optional<std::string>> {
60
- try {
61
- const react::RawValue* rawValue = rawProps.at("suffix", nullptr, nullptr);
62
- if (rawValue == nullptr) return sourceProps.suffix;
63
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
64
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.suffix);
65
- } catch (const std::exception& exc) {
66
- throw std::runtime_error(std::string("AutoSizeInput.suffix: ") + exc.what());
67
- }
68
- }()),
69
- placeholder([&]() -> CachedProp<std::optional<std::string>> {
70
- try {
71
- const react::RawValue* rawValue = rawProps.at("placeholder", nullptr, nullptr);
72
- if (rawValue == nullptr) return sourceProps.placeholder;
73
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
74
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.placeholder);
75
- } catch (const std::exception& exc) {
76
- throw std::runtime_error(std::string("AutoSizeInput.placeholder: ") + exc.what());
77
- }
78
- }()),
79
- fontSize([&]() -> CachedProp<std::optional<double>> {
80
- try {
81
- const react::RawValue* rawValue = rawProps.at("fontSize", nullptr, nullptr);
82
- if (rawValue == nullptr) return sourceProps.fontSize;
83
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
84
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.fontSize);
85
- } catch (const std::exception& exc) {
86
- throw std::runtime_error(std::string("AutoSizeInput.fontSize: ") + exc.what());
87
- }
88
- }()),
89
- minFontSize([&]() -> CachedProp<std::optional<double>> {
90
- try {
91
- const react::RawValue* rawValue = rawProps.at("minFontSize", nullptr, nullptr);
92
- if (rawValue == nullptr) return sourceProps.minFontSize;
93
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
94
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.minFontSize);
95
- } catch (const std::exception& exc) {
96
- throw std::runtime_error(std::string("AutoSizeInput.minFontSize: ") + exc.what());
97
- }
98
- }()),
99
- multiline([&]() -> CachedProp<std::optional<bool>> {
100
- try {
101
- const react::RawValue* rawValue = rawProps.at("multiline", nullptr, nullptr);
102
- if (rawValue == nullptr) return sourceProps.multiline;
103
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
104
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.multiline);
105
- } catch (const std::exception& exc) {
106
- throw std::runtime_error(std::string("AutoSizeInput.multiline: ") + exc.what());
107
- }
108
- }()),
109
- maxNumberOfLines([&]() -> CachedProp<std::optional<double>> {
110
- try {
111
- const react::RawValue* rawValue = rawProps.at("maxNumberOfLines", nullptr, nullptr);
112
- if (rawValue == nullptr) return sourceProps.maxNumberOfLines;
113
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
114
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.maxNumberOfLines);
115
- } catch (const std::exception& exc) {
116
- throw std::runtime_error(std::string("AutoSizeInput.maxNumberOfLines: ") + exc.what());
117
- }
118
- }()),
119
- textColor([&]() -> CachedProp<std::optional<std::string>> {
120
- try {
121
- const react::RawValue* rawValue = rawProps.at("textColor", nullptr, nullptr);
122
- if (rawValue == nullptr) return sourceProps.textColor;
123
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
124
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.textColor);
125
- } catch (const std::exception& exc) {
126
- throw std::runtime_error(std::string("AutoSizeInput.textColor: ") + exc.what());
127
- }
128
- }()),
129
- prefixColor([&]() -> CachedProp<std::optional<std::string>> {
130
- try {
131
- const react::RawValue* rawValue = rawProps.at("prefixColor", nullptr, nullptr);
132
- if (rawValue == nullptr) return sourceProps.prefixColor;
133
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
134
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.prefixColor);
135
- } catch (const std::exception& exc) {
136
- throw std::runtime_error(std::string("AutoSizeInput.prefixColor: ") + exc.what());
137
- }
138
- }()),
139
- suffixColor([&]() -> CachedProp<std::optional<std::string>> {
140
- try {
141
- const react::RawValue* rawValue = rawProps.at("suffixColor", nullptr, nullptr);
142
- if (rawValue == nullptr) return sourceProps.suffixColor;
143
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
144
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.suffixColor);
145
- } catch (const std::exception& exc) {
146
- throw std::runtime_error(std::string("AutoSizeInput.suffixColor: ") + exc.what());
147
- }
148
- }()),
149
- placeholderColor([&]() -> CachedProp<std::optional<std::string>> {
150
- try {
151
- const react::RawValue* rawValue = rawProps.at("placeholderColor", nullptr, nullptr);
152
- if (rawValue == nullptr) return sourceProps.placeholderColor;
153
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
154
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.placeholderColor);
155
- } catch (const std::exception& exc) {
156
- throw std::runtime_error(std::string("AutoSizeInput.placeholderColor: ") + exc.what());
157
- }
158
- }()),
159
- textAlign([&]() -> CachedProp<std::optional<std::string>> {
160
- try {
161
- const react::RawValue* rawValue = rawProps.at("textAlign", nullptr, nullptr);
162
- if (rawValue == nullptr) return sourceProps.textAlign;
163
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
164
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.textAlign);
165
- } catch (const std::exception& exc) {
166
- throw std::runtime_error(std::string("AutoSizeInput.textAlign: ") + exc.what());
167
- }
168
- }()),
169
- fontFamily([&]() -> CachedProp<std::optional<std::string>> {
170
- try {
171
- const react::RawValue* rawValue = rawProps.at("fontFamily", nullptr, nullptr);
172
- if (rawValue == nullptr) return sourceProps.fontFamily;
173
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
174
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.fontFamily);
175
- } catch (const std::exception& exc) {
176
- throw std::runtime_error(std::string("AutoSizeInput.fontFamily: ") + exc.what());
177
- }
178
- }()),
179
- fontWeight([&]() -> CachedProp<std::optional<std::string>> {
180
- try {
181
- const react::RawValue* rawValue = rawProps.at("fontWeight", nullptr, nullptr);
182
- if (rawValue == nullptr) return sourceProps.fontWeight;
183
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
184
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.fontWeight);
185
- } catch (const std::exception& exc) {
186
- throw std::runtime_error(std::string("AutoSizeInput.fontWeight: ") + exc.what());
187
- }
188
- }()),
189
- editable([&]() -> CachedProp<std::optional<bool>> {
190
- try {
191
- const react::RawValue* rawValue = rawProps.at("editable", nullptr, nullptr);
192
- if (rawValue == nullptr) return sourceProps.editable;
193
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
194
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.editable);
195
- } catch (const std::exception& exc) {
196
- throw std::runtime_error(std::string("AutoSizeInput.editable: ") + exc.what());
197
- }
198
- }()),
199
- keyboardType([&]() -> CachedProp<std::optional<std::string>> {
200
- try {
201
- const react::RawValue* rawValue = rawProps.at("keyboardType", nullptr, nullptr);
202
- if (rawValue == nullptr) return sourceProps.keyboardType;
203
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
204
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.keyboardType);
205
- } catch (const std::exception& exc) {
206
- throw std::runtime_error(std::string("AutoSizeInput.keyboardType: ") + exc.what());
207
- }
208
- }()),
209
- returnKeyType([&]() -> CachedProp<std::optional<std::string>> {
210
- try {
211
- const react::RawValue* rawValue = rawProps.at("returnKeyType", nullptr, nullptr);
212
- if (rawValue == nullptr) return sourceProps.returnKeyType;
213
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
214
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.returnKeyType);
215
- } catch (const std::exception& exc) {
216
- throw std::runtime_error(std::string("AutoSizeInput.returnKeyType: ") + exc.what());
217
- }
218
- }()),
219
- autoCorrect([&]() -> CachedProp<std::optional<bool>> {
220
- try {
221
- const react::RawValue* rawValue = rawProps.at("autoCorrect", nullptr, nullptr);
222
- if (rawValue == nullptr) return sourceProps.autoCorrect;
223
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
224
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.autoCorrect);
225
- } catch (const std::exception& exc) {
226
- throw std::runtime_error(std::string("AutoSizeInput.autoCorrect: ") + exc.what());
227
- }
228
- }()),
229
- autoCapitalize([&]() -> CachedProp<std::optional<std::string>> {
230
- try {
231
- const react::RawValue* rawValue = rawProps.at("autoCapitalize", nullptr, nullptr);
232
- if (rawValue == nullptr) return sourceProps.autoCapitalize;
233
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
234
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.autoCapitalize);
235
- } catch (const std::exception& exc) {
236
- throw std::runtime_error(std::string("AutoSizeInput.autoCapitalize: ") + exc.what());
237
- }
238
- }()),
239
- selectionColor([&]() -> CachedProp<std::optional<std::string>> {
240
- try {
241
- const react::RawValue* rawValue = rawProps.at("selectionColor", nullptr, nullptr);
242
- if (rawValue == nullptr) return sourceProps.selectionColor;
243
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
244
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.selectionColor);
245
- } catch (const std::exception& exc) {
246
- throw std::runtime_error(std::string("AutoSizeInput.selectionColor: ") + exc.what());
247
- }
248
- }()),
249
- prefixMarginRight([&]() -> CachedProp<std::optional<double>> {
250
- try {
251
- const react::RawValue* rawValue = rawProps.at("prefixMarginRight", nullptr, nullptr);
252
- if (rawValue == nullptr) return sourceProps.prefixMarginRight;
253
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
254
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.prefixMarginRight);
255
- } catch (const std::exception& exc) {
256
- throw std::runtime_error(std::string("AutoSizeInput.prefixMarginRight: ") + exc.what());
257
- }
258
- }()),
259
- suffixMarginLeft([&]() -> CachedProp<std::optional<double>> {
260
- try {
261
- const react::RawValue* rawValue = rawProps.at("suffixMarginLeft", nullptr, nullptr);
262
- if (rawValue == nullptr) return sourceProps.suffixMarginLeft;
263
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
264
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.suffixMarginLeft);
265
- } catch (const std::exception& exc) {
266
- throw std::runtime_error(std::string("AutoSizeInput.suffixMarginLeft: ") + exc.what());
267
- }
268
- }()),
269
- showBorder([&]() -> CachedProp<std::optional<bool>> {
270
- try {
271
- const react::RawValue* rawValue = rawProps.at("showBorder", nullptr, nullptr);
272
- if (rawValue == nullptr) return sourceProps.showBorder;
273
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
274
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.showBorder);
275
- } catch (const std::exception& exc) {
276
- throw std::runtime_error(std::string("AutoSizeInput.showBorder: ") + exc.what());
277
- }
278
- }()),
279
- inputBackgroundColor([&]() -> CachedProp<std::optional<std::string>> {
280
- try {
281
- const react::RawValue* rawValue = rawProps.at("inputBackgroundColor", nullptr, nullptr);
282
- if (rawValue == nullptr) return sourceProps.inputBackgroundColor;
283
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
284
- return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.inputBackgroundColor);
285
- } catch (const std::exception& exc) {
286
- throw std::runtime_error(std::string("AutoSizeInput.inputBackgroundColor: ") + exc.what());
287
- }
288
- }()),
289
- contentAutoWidth([&]() -> CachedProp<std::optional<bool>> {
290
- try {
291
- const react::RawValue* rawValue = rawProps.at("contentAutoWidth", nullptr, nullptr);
292
- if (rawValue == nullptr) return sourceProps.contentAutoWidth;
293
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
294
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.contentAutoWidth);
295
- } catch (const std::exception& exc) {
296
- throw std::runtime_error(std::string("AutoSizeInput.contentAutoWidth: ") + exc.what());
297
- }
298
- }()),
299
- contentCentered([&]() -> CachedProp<std::optional<bool>> {
300
- try {
301
- const react::RawValue* rawValue = rawProps.at("contentCentered", nullptr, nullptr);
302
- if (rawValue == nullptr) return sourceProps.contentCentered;
303
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
304
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.contentCentered);
305
- } catch (const std::exception& exc) {
306
- throw std::runtime_error(std::string("AutoSizeInput.contentCentered: ") + exc.what());
307
- }
308
- }()),
309
- onChangeText([&]() -> CachedProp<std::optional<std::function<void(const std::string& /* text */)>>> {
310
- try {
311
- const react::RawValue* rawValue = rawProps.at("onChangeText", nullptr, nullptr);
312
- if (rawValue == nullptr) return sourceProps.onChangeText;
313
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
314
- return CachedProp<std::optional<std::function<void(const std::string& /* text */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onChangeText);
315
- } catch (const std::exception& exc) {
316
- throw std::runtime_error(std::string("AutoSizeInput.onChangeText: ") + exc.what());
317
- }
318
- }()),
319
- onFocus([&]() -> CachedProp<std::optional<std::function<void()>>> {
320
- try {
321
- const react::RawValue* rawValue = rawProps.at("onFocus", nullptr, nullptr);
322
- if (rawValue == nullptr) return sourceProps.onFocus;
323
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
324
- return CachedProp<std::optional<std::function<void()>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onFocus);
325
- } catch (const std::exception& exc) {
326
- throw std::runtime_error(std::string("AutoSizeInput.onFocus: ") + exc.what());
327
- }
328
- }()),
329
- onBlur([&]() -> CachedProp<std::optional<std::function<void()>>> {
330
- try {
331
- const react::RawValue* rawValue = rawProps.at("onBlur", nullptr, nullptr);
332
- if (rawValue == nullptr) return sourceProps.onBlur;
333
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
334
- return CachedProp<std::optional<std::function<void()>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onBlur);
335
- } catch (const std::exception& exc) {
336
- throw std::runtime_error(std::string("AutoSizeInput.onBlur: ") + exc.what());
337
- }
338
- }()),
339
- hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridAutoSizeInputSpec>& /* ref */)>>> {
340
- try {
341
- const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
342
- if (rawValue == nullptr) return sourceProps.hybridRef;
343
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
344
- return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridAutoSizeInputSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
345
- } catch (const std::exception& exc) {
346
- throw std::runtime_error(std::string("AutoSizeInput.hybridRef: ") + exc.what());
347
- }
348
- }()) { }
23
+ mostRecentEventCount(nitro::ReactProp<std::optional<double>>::fromRawValue("AutoSizeInput", "mostRecentEventCount", rawProps, sourceProps.mostRecentEventCount)),
24
+ text(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "text", rawProps, sourceProps.text)),
25
+ prefix(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "prefix", rawProps, sourceProps.prefix)),
26
+ suffix(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "suffix", rawProps, sourceProps.suffix)),
27
+ placeholder(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "placeholder", rawProps, sourceProps.placeholder)),
28
+ fontSize(nitro::ReactProp<std::optional<double>>::fromRawValue("AutoSizeInput", "fontSize", rawProps, sourceProps.fontSize)),
29
+ minFontSize(nitro::ReactProp<std::optional<double>>::fromRawValue("AutoSizeInput", "minFontSize", rawProps, sourceProps.minFontSize)),
30
+ multiline(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "multiline", rawProps, sourceProps.multiline)),
31
+ maxNumberOfLines(nitro::ReactProp<std::optional<double>>::fromRawValue("AutoSizeInput", "maxNumberOfLines", rawProps, sourceProps.maxNumberOfLines)),
32
+ textColor(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "textColor", rawProps, sourceProps.textColor)),
33
+ prefixColor(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "prefixColor", rawProps, sourceProps.prefixColor)),
34
+ suffixColor(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "suffixColor", rawProps, sourceProps.suffixColor)),
35
+ placeholderColor(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "placeholderColor", rawProps, sourceProps.placeholderColor)),
36
+ textAlign(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "textAlign", rawProps, sourceProps.textAlign)),
37
+ fontFamily(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "fontFamily", rawProps, sourceProps.fontFamily)),
38
+ fontWeight(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "fontWeight", rawProps, sourceProps.fontWeight)),
39
+ editable(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "editable", rawProps, sourceProps.editable)),
40
+ keyboardType(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "keyboardType", rawProps, sourceProps.keyboardType)),
41
+ returnKeyType(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "returnKeyType", rawProps, sourceProps.returnKeyType)),
42
+ autoCorrect(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "autoCorrect", rawProps, sourceProps.autoCorrect)),
43
+ autoCapitalize(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "autoCapitalize", rawProps, sourceProps.autoCapitalize)),
44
+ selectionColor(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "selectionColor", rawProps, sourceProps.selectionColor)),
45
+ prefixMarginRight(nitro::ReactProp<std::optional<double>>::fromRawValue("AutoSizeInput", "prefixMarginRight", rawProps, sourceProps.prefixMarginRight)),
46
+ suffixMarginLeft(nitro::ReactProp<std::optional<double>>::fromRawValue("AutoSizeInput", "suffixMarginLeft", rawProps, sourceProps.suffixMarginLeft)),
47
+ showBorder(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "showBorder", rawProps, sourceProps.showBorder)),
48
+ inputBackgroundColor(nitro::ReactProp<std::optional<std::string>>::fromRawValue("AutoSizeInput", "inputBackgroundColor", rawProps, sourceProps.inputBackgroundColor)),
49
+ contentAutoWidth(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "contentAutoWidth", rawProps, sourceProps.contentAutoWidth)),
50
+ contentCentered(nitro::ReactProp<std::optional<bool>>::fromRawValue("AutoSizeInput", "contentCentered", rawProps, sourceProps.contentCentered)),
51
+ onChangeText(nitro::ReactProp<std::optional<std::function<void(const std::string& /* text */)>>>::fromRawValue("AutoSizeInput", "onChangeText", rawProps, sourceProps.onChangeText)),
52
+ onFocus(nitro::ReactProp<std::optional<std::function<void()>>>::fromRawValue("AutoSizeInput", "onFocus", rawProps, sourceProps.onFocus)),
53
+ onBlur(nitro::ReactProp<std::optional<std::function<void()>>>::fromRawValue("AutoSizeInput", "onBlur", rawProps, sourceProps.onBlur)),
54
+ hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridAutoSizeInputSpec>& /* ref */)>>>::fromRawValue("AutoSizeInput", "hybridRef", rawProps, sourceProps.hybridRef)) { }
349
55
 
350
56
  bool HybridAutoSizeInputProps::filterObjectKeys(const std::string& propName) {
351
57
  switch (hashString(propName)) {
@@ -385,29 +91,4 @@ namespace margelo::nitro::autosizeinput::views {
385
91
  }
386
92
  }
387
93
 
388
- HybridAutoSizeInputComponentDescriptor::HybridAutoSizeInputComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
389
- : ConcreteComponentDescriptor(parameters,
390
- react::RawPropsParser()) {}
391
-
392
- std::shared_ptr<const react::Props> HybridAutoSizeInputComponentDescriptor::cloneProps(const react::PropsParserContext& context,
393
- const std::shared_ptr<const react::Props>& props,
394
- react::RawProps rawProps) const {
395
- // 1. Prepare raw props parser
396
- rawProps.parse(rawPropsParser_);
397
- // 2. Copy props with Nitro's cached copy constructor
398
- return HybridAutoSizeInputShadowNode::Props(context, /* & */ rawProps, props);
399
- }
400
-
401
- #ifdef ANDROID
402
- void HybridAutoSizeInputComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
403
- // This is called immediately after `ShadowNode` is created, cloned or in progress.
404
- // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
405
- auto& concreteShadowNode = static_cast<HybridAutoSizeInputShadowNode&>(shadowNode);
406
- const std::shared_ptr<const HybridAutoSizeInputProps>& constProps = concreteShadowNode.getConcreteSharedProps();
407
- const std::shared_ptr<HybridAutoSizeInputProps>& props = std::const_pointer_cast<HybridAutoSizeInputProps>(constProps);
408
- HybridAutoSizeInputState state{props};
409
- concreteShadowNode.setStateData(std::move(state));
410
- }
411
- #endif
412
-
413
94
  } // namespace margelo::nitro::autosizeinput::views
@@ -7,14 +7,15 @@
7
7
 
8
8
  #pragma once
9
9
 
10
- #include <optional>
11
- #include <NitroModules/NitroDefines.hpp>
12
- #include <NitroModules/NitroHash.hpp>
13
- #include <NitroModules/CachedProp.hpp>
14
- #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
- #include <react/renderer/core/PropsParserContext.h>
10
+ #include <NitroModules/ReactProp.hpp>
11
+ #include <NitroModules/ViewComponentDescriptor.hpp>
12
+ #include <NitroModules/ViewPropsHolderState.hpp>
16
13
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
14
  #include <react/renderer/components/view/ViewProps.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/core/RawProps.h>
17
+
18
+ #include <string>
18
19
 
19
20
  #include <optional>
20
21
  #include <string>
@@ -42,38 +43,110 @@ namespace margelo::nitro::autosizeinput::views {
42
43
  const react::RawProps& rawProps);
43
44
 
44
45
  public:
45
- CachedProp<std::optional<double>> mostRecentEventCount;
46
- CachedProp<std::optional<std::string>> text;
47
- CachedProp<std::optional<std::string>> prefix;
48
- CachedProp<std::optional<std::string>> suffix;
49
- CachedProp<std::optional<std::string>> placeholder;
50
- CachedProp<std::optional<double>> fontSize;
51
- CachedProp<std::optional<double>> minFontSize;
52
- CachedProp<std::optional<bool>> multiline;
53
- CachedProp<std::optional<double>> maxNumberOfLines;
54
- CachedProp<std::optional<std::string>> textColor;
55
- CachedProp<std::optional<std::string>> prefixColor;
56
- CachedProp<std::optional<std::string>> suffixColor;
57
- CachedProp<std::optional<std::string>> placeholderColor;
58
- CachedProp<std::optional<std::string>> textAlign;
59
- CachedProp<std::optional<std::string>> fontFamily;
60
- CachedProp<std::optional<std::string>> fontWeight;
61
- CachedProp<std::optional<bool>> editable;
62
- CachedProp<std::optional<std::string>> keyboardType;
63
- CachedProp<std::optional<std::string>> returnKeyType;
64
- CachedProp<std::optional<bool>> autoCorrect;
65
- CachedProp<std::optional<std::string>> autoCapitalize;
66
- CachedProp<std::optional<std::string>> selectionColor;
67
- CachedProp<std::optional<double>> prefixMarginRight;
68
- CachedProp<std::optional<double>> suffixMarginLeft;
69
- CachedProp<std::optional<bool>> showBorder;
70
- CachedProp<std::optional<std::string>> inputBackgroundColor;
71
- CachedProp<std::optional<bool>> contentAutoWidth;
72
- CachedProp<std::optional<bool>> contentCentered;
73
- CachedProp<std::optional<std::function<void(const std::string& /* text */)>>> onChangeText;
74
- CachedProp<std::optional<std::function<void()>>> onFocus;
75
- CachedProp<std::optional<std::function<void()>>> onBlur;
76
- CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridAutoSizeInputSpec>& /* ref */)>>> hybridRef;
46
+ nitro::ReactProp<std::optional<double>> mostRecentEventCount;
47
+ nitro::ReactProp<std::optional<std::string>> text;
48
+ nitro::ReactProp<std::optional<std::string>> prefix;
49
+ nitro::ReactProp<std::optional<std::string>> suffix;
50
+ nitro::ReactProp<std::optional<std::string>> placeholder;
51
+ nitro::ReactProp<std::optional<double>> fontSize;
52
+ nitro::ReactProp<std::optional<double>> minFontSize;
53
+ nitro::ReactProp<std::optional<bool>> multiline;
54
+ nitro::ReactProp<std::optional<double>> maxNumberOfLines;
55
+ nitro::ReactProp<std::optional<std::string>> textColor;
56
+ nitro::ReactProp<std::optional<std::string>> prefixColor;
57
+ nitro::ReactProp<std::optional<std::string>> suffixColor;
58
+ nitro::ReactProp<std::optional<std::string>> placeholderColor;
59
+ nitro::ReactProp<std::optional<std::string>> textAlign;
60
+ nitro::ReactProp<std::optional<std::string>> fontFamily;
61
+ nitro::ReactProp<std::optional<std::string>> fontWeight;
62
+ nitro::ReactProp<std::optional<bool>> editable;
63
+ nitro::ReactProp<std::optional<std::string>> keyboardType;
64
+ nitro::ReactProp<std::optional<std::string>> returnKeyType;
65
+ nitro::ReactProp<std::optional<bool>> autoCorrect;
66
+ nitro::ReactProp<std::optional<std::string>> autoCapitalize;
67
+ nitro::ReactProp<std::optional<std::string>> selectionColor;
68
+ nitro::ReactProp<std::optional<double>> prefixMarginRight;
69
+ nitro::ReactProp<std::optional<double>> suffixMarginLeft;
70
+ nitro::ReactProp<std::optional<bool>> showBorder;
71
+ nitro::ReactProp<std::optional<std::string>> inputBackgroundColor;
72
+ nitro::ReactProp<std::optional<bool>> contentAutoWidth;
73
+ nitro::ReactProp<std::optional<bool>> contentCentered;
74
+ nitro::ReactProp<std::optional<std::function<void(const std::string& /* text */)>>> onChangeText;
75
+ nitro::ReactProp<std::optional<std::function<void()>>> onFocus;
76
+ nitro::ReactProp<std::optional<std::function<void()>>> onBlur;
77
+ nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridAutoSizeInputSpec>& /* ref */)>>> hybridRef;
78
+
79
+ [[nodiscard]]
80
+ bool hasSameProps(const HybridAutoSizeInputProps& other) const noexcept {
81
+ return mostRecentEventCount.hasSameValue(other.mostRecentEventCount) &&
82
+ text.hasSameValue(other.text) &&
83
+ prefix.hasSameValue(other.prefix) &&
84
+ suffix.hasSameValue(other.suffix) &&
85
+ placeholder.hasSameValue(other.placeholder) &&
86
+ fontSize.hasSameValue(other.fontSize) &&
87
+ minFontSize.hasSameValue(other.minFontSize) &&
88
+ multiline.hasSameValue(other.multiline) &&
89
+ maxNumberOfLines.hasSameValue(other.maxNumberOfLines) &&
90
+ textColor.hasSameValue(other.textColor) &&
91
+ prefixColor.hasSameValue(other.prefixColor) &&
92
+ suffixColor.hasSameValue(other.suffixColor) &&
93
+ placeholderColor.hasSameValue(other.placeholderColor) &&
94
+ textAlign.hasSameValue(other.textAlign) &&
95
+ fontFamily.hasSameValue(other.fontFamily) &&
96
+ fontWeight.hasSameValue(other.fontWeight) &&
97
+ editable.hasSameValue(other.editable) &&
98
+ keyboardType.hasSameValue(other.keyboardType) &&
99
+ returnKeyType.hasSameValue(other.returnKeyType) &&
100
+ autoCorrect.hasSameValue(other.autoCorrect) &&
101
+ autoCapitalize.hasSameValue(other.autoCapitalize) &&
102
+ selectionColor.hasSameValue(other.selectionColor) &&
103
+ prefixMarginRight.hasSameValue(other.prefixMarginRight) &&
104
+ suffixMarginLeft.hasSameValue(other.suffixMarginLeft) &&
105
+ showBorder.hasSameValue(other.showBorder) &&
106
+ inputBackgroundColor.hasSameValue(other.inputBackgroundColor) &&
107
+ contentAutoWidth.hasSameValue(other.contentAutoWidth) &&
108
+ contentCentered.hasSameValue(other.contentCentered) &&
109
+ onChangeText.hasSameValue(other.onChangeText) &&
110
+ onFocus.hasSameValue(other.onFocus) &&
111
+ onBlur.hasSameValue(other.onBlur) &&
112
+ hybridRef.hasSameValue(other.hybridRef);
113
+ }
114
+
115
+ [[nodiscard]]
116
+ bool hasAnyProvidedProps() const noexcept {
117
+ return mostRecentEventCount.isProvided() ||
118
+ text.isProvided() ||
119
+ prefix.isProvided() ||
120
+ suffix.isProvided() ||
121
+ placeholder.isProvided() ||
122
+ fontSize.isProvided() ||
123
+ minFontSize.isProvided() ||
124
+ multiline.isProvided() ||
125
+ maxNumberOfLines.isProvided() ||
126
+ textColor.isProvided() ||
127
+ prefixColor.isProvided() ||
128
+ suffixColor.isProvided() ||
129
+ placeholderColor.isProvided() ||
130
+ textAlign.isProvided() ||
131
+ fontFamily.isProvided() ||
132
+ fontWeight.isProvided() ||
133
+ editable.isProvided() ||
134
+ keyboardType.isProvided() ||
135
+ returnKeyType.isProvided() ||
136
+ autoCorrect.isProvided() ||
137
+ autoCapitalize.isProvided() ||
138
+ selectionColor.isProvided() ||
139
+ prefixMarginRight.isProvided() ||
140
+ suffixMarginLeft.isProvided() ||
141
+ showBorder.isProvided() ||
142
+ inputBackgroundColor.isProvided() ||
143
+ contentAutoWidth.isProvided() ||
144
+ contentCentered.isProvided() ||
145
+ onChangeText.isProvided() ||
146
+ onFocus.isProvided() ||
147
+ onBlur.isProvided() ||
148
+ hybridRef.isProvided();
149
+ }
77
150
 
78
151
  private:
79
152
  static bool filterObjectKeys(const std::string& propName);
@@ -82,32 +155,7 @@ namespace margelo::nitro::autosizeinput::views {
82
155
  /**
83
156
  * State for the "AutoSizeInput" View.
84
157
  */
85
- class HybridAutoSizeInputState final {
86
- public:
87
- HybridAutoSizeInputState() = default;
88
- explicit HybridAutoSizeInputState(const std::shared_ptr<HybridAutoSizeInputProps>& props):
89
- _props(props) {}
90
-
91
- public:
92
- [[nodiscard]]
93
- const std::shared_ptr<HybridAutoSizeInputProps>& getProps() const {
94
- return _props;
95
- }
96
-
97
- public:
98
- #ifdef ANDROID
99
- HybridAutoSizeInputState(const HybridAutoSizeInputState& /* previousState */, folly::dynamic /* data */) {}
100
- folly::dynamic getDynamic() const {
101
- throw std::runtime_error("HybridAutoSizeInputState does not support folly!");
102
- }
103
- react::MapBuffer getMapBuffer() const {
104
- throw std::runtime_error("HybridAutoSizeInputState does not support MapBuffer!");
105
- };
106
- #endif
107
-
108
- private:
109
- std::shared_ptr<HybridAutoSizeInputProps> _props;
110
- };
158
+ using HybridAutoSizeInputState = nitro::ViewPropsHolderState<HybridAutoSizeInputProps>;
111
159
 
112
160
  /**
113
161
  * The Shadow Node for the "AutoSizeInput" View.
@@ -120,21 +168,7 @@ namespace margelo::nitro::autosizeinput::views {
120
168
  /**
121
169
  * The Component Descriptor for the "AutoSizeInput" View.
122
170
  */
123
- class HybridAutoSizeInputComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridAutoSizeInputShadowNode> {
124
- public:
125
- explicit HybridAutoSizeInputComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
126
-
127
- public:
128
- /**
129
- * A faster path for cloning props - reuses the caching logic from `HybridAutoSizeInputProps`.
130
- */
131
- std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
132
- const std::shared_ptr<const react::Props>& props,
133
- react::RawProps rawProps) const override;
134
- #ifdef ANDROID
135
- void adopt(react::ShadowNode& shadowNode) const override;
136
- #endif
137
- };
171
+ using HybridAutoSizeInputComponentDescriptor = nitro::ViewComponentDescriptor<HybridAutoSizeInputShadowNode>;
138
172
 
139
173
  /* The actual view for "AutoSizeInput" needs to be implemented in platform-specific code. */
140
174