rnnovaui 0.8.7 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/RadioGroup/UIRadioGroup.js +158 -128
- package/src/components/Slider/UISlider.js +247 -183
- package/src/components/Switch/UISwitch.js +406 -215
- package/src/components/Switch/index.js +1 -1
- package/src/components/index.js +1 -1
- package/src/index.js +0 -1
package/package.json
CHANGED
|
@@ -38,8 +38,6 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
38
38
|
|
|
39
39
|
onChange,
|
|
40
40
|
|
|
41
|
-
name,
|
|
42
|
-
|
|
43
41
|
label,
|
|
44
42
|
helperText,
|
|
45
43
|
errorText,
|
|
@@ -55,7 +53,6 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
55
53
|
size = "md",
|
|
56
54
|
|
|
57
55
|
gap = 12,
|
|
58
|
-
optionGap,
|
|
59
56
|
|
|
60
57
|
style,
|
|
61
58
|
labelStyle,
|
|
@@ -78,9 +75,8 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
78
75
|
|
|
79
76
|
const selectedValue = isControlled ? value : internalValue;
|
|
80
77
|
|
|
81
|
-
const resolvedOrientation =
|
|
82
|
-
?
|
|
83
|
-
: "vertical";
|
|
78
|
+
const resolvedOrientation =
|
|
79
|
+
orientation === "horizontal" ? "horizontal" : "vertical";
|
|
84
80
|
|
|
85
81
|
const resolvedSize = RADIO_GROUP_SIZES[size] ? size : "md";
|
|
86
82
|
|
|
@@ -103,7 +99,7 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
103
99
|
|
|
104
100
|
const contextValue = useMemo(
|
|
105
101
|
() => ({
|
|
106
|
-
|
|
102
|
+
selectedValue,
|
|
107
103
|
|
|
108
104
|
onChange: handleChange,
|
|
109
105
|
|
|
@@ -122,8 +118,10 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
122
118
|
{...props}
|
|
123
119
|
ref={ref}
|
|
124
120
|
testID={testID}
|
|
125
|
-
style={[styles.
|
|
121
|
+
style={[styles.container, style]}
|
|
126
122
|
>
|
|
123
|
+
{/* GROUP LABEL */}
|
|
124
|
+
|
|
127
125
|
{label ? (
|
|
128
126
|
<Text
|
|
129
127
|
style={[
|
|
@@ -138,7 +136,7 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
138
136
|
labelStyle,
|
|
139
137
|
]}
|
|
140
138
|
>
|
|
141
|
-
{label}
|
|
139
|
+
{String(label)}
|
|
142
140
|
|
|
143
141
|
{required ? (
|
|
144
142
|
<Text
|
|
@@ -152,6 +150,8 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
152
150
|
</Text>
|
|
153
151
|
) : null}
|
|
154
152
|
|
|
153
|
+
{/* RADIO OPTIONS */}
|
|
154
|
+
|
|
155
155
|
<View
|
|
156
156
|
style={[
|
|
157
157
|
styles.options,
|
|
@@ -161,13 +161,23 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
161
161
|
: styles.vertical,
|
|
162
162
|
|
|
163
163
|
{
|
|
164
|
-
|
|
164
|
+
columnGap: gap,
|
|
165
|
+
|
|
166
|
+
rowGap: gap,
|
|
165
167
|
},
|
|
166
168
|
]}
|
|
167
169
|
>
|
|
168
|
-
{children
|
|
170
|
+
{React.Children.map(children, (child) => {
|
|
171
|
+
if (!React.isValidElement(child)) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return child;
|
|
176
|
+
})}
|
|
169
177
|
</View>
|
|
170
178
|
|
|
179
|
+
{/* ERROR / HELPER */}
|
|
180
|
+
|
|
171
181
|
{hasError ? (
|
|
172
182
|
<Text
|
|
173
183
|
style={[
|
|
@@ -180,7 +190,7 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
180
190
|
errorStyle,
|
|
181
191
|
]}
|
|
182
192
|
>
|
|
183
|
-
{errorText}
|
|
193
|
+
{String(errorText)}
|
|
184
194
|
</Text>
|
|
185
195
|
) : helperText ? (
|
|
186
196
|
<Text
|
|
@@ -194,7 +204,7 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
194
204
|
helperStyle,
|
|
195
205
|
]}
|
|
196
206
|
>
|
|
197
|
-
{helperText}
|
|
207
|
+
{String(helperText)}
|
|
198
208
|
</Text>
|
|
199
209
|
) : null}
|
|
200
210
|
</View>
|
|
@@ -208,8 +218,10 @@ const UIRadioGroupComponent = forwardRef(function UIRadioGroup(
|
|
|
208
218
|
|
|
209
219
|
const UIRadioOptionComponent = function UIRadioOptionComponent({
|
|
210
220
|
value,
|
|
221
|
+
|
|
211
222
|
label = "",
|
|
212
|
-
|
|
223
|
+
|
|
224
|
+
description = "",
|
|
213
225
|
|
|
214
226
|
disabled = false,
|
|
215
227
|
|
|
@@ -232,16 +244,16 @@ const UIRadioOptionComponent = function UIRadioOptionComponent({
|
|
|
232
244
|
}
|
|
233
245
|
|
|
234
246
|
const {
|
|
235
|
-
|
|
247
|
+
selectedValue,
|
|
236
248
|
onChange,
|
|
237
249
|
disabled: groupDisabled,
|
|
238
250
|
size,
|
|
239
251
|
error,
|
|
240
252
|
} = context;
|
|
241
253
|
|
|
242
|
-
const
|
|
254
|
+
const selected = selectedValue === value;
|
|
243
255
|
|
|
244
|
-
const isDisabled = groupDisabled || disabled;
|
|
256
|
+
const isDisabled = Boolean(groupDisabled || disabled);
|
|
245
257
|
|
|
246
258
|
const radioSize = getRadioSize(size);
|
|
247
259
|
|
|
@@ -256,112 +268,116 @@ const UIRadioOptionComponent = function UIRadioOptionComponent({
|
|
|
256
268
|
}, [isDisabled, onChange, value, onPress]);
|
|
257
269
|
|
|
258
270
|
return (
|
|
259
|
-
<
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
+
<Pressable
|
|
272
|
+
{...props}
|
|
273
|
+
onPress={handlePress}
|
|
274
|
+
disabled={isDisabled}
|
|
275
|
+
accessibilityRole="radio"
|
|
276
|
+
accessibilityState={{
|
|
277
|
+
checked: selected,
|
|
278
|
+
|
|
279
|
+
disabled: isDisabled,
|
|
280
|
+
}}
|
|
281
|
+
style={({ pressed }) => [
|
|
282
|
+
styles.option,
|
|
283
|
+
|
|
284
|
+
{
|
|
285
|
+
opacity: isDisabled ? 0.5 : pressed ? 0.7 : 1,
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
style,
|
|
289
|
+
]}
|
|
290
|
+
>
|
|
291
|
+
{/* RADIO CIRCLE */}
|
|
292
|
+
|
|
293
|
+
<View
|
|
294
|
+
style={[
|
|
295
|
+
styles.radio,
|
|
271
296
|
|
|
272
297
|
{
|
|
273
|
-
|
|
298
|
+
width: radioSize.outer,
|
|
299
|
+
|
|
300
|
+
height: radioSize.outer,
|
|
301
|
+
|
|
302
|
+
borderRadius: radioSize.outer / 2,
|
|
303
|
+
|
|
304
|
+
borderWidth: selected ? 2 : 1.5,
|
|
305
|
+
|
|
306
|
+
borderColor: error
|
|
307
|
+
? colors.danger || "#DC2626"
|
|
308
|
+
: selected
|
|
309
|
+
? colors.primary || "#FF5A1F"
|
|
310
|
+
: colors.borderStrong || "#D4D4D4",
|
|
274
311
|
},
|
|
275
312
|
]}
|
|
276
313
|
>
|
|
277
|
-
{
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
314
|
+
{selected ? (
|
|
315
|
+
<View
|
|
316
|
+
style={[
|
|
317
|
+
styles.radioDot,
|
|
281
318
|
|
|
282
|
-
|
|
283
|
-
|
|
319
|
+
{
|
|
320
|
+
width: radioSize.inner,
|
|
284
321
|
|
|
285
|
-
|
|
322
|
+
height: radioSize.inner,
|
|
286
323
|
|
|
287
|
-
|
|
324
|
+
borderRadius: radioSize.inner / 2,
|
|
288
325
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
326
|
+
backgroundColor: error
|
|
327
|
+
? colors.danger || "#DC2626"
|
|
328
|
+
: colors.primary || "#FF5A1F",
|
|
329
|
+
},
|
|
330
|
+
]}
|
|
331
|
+
/>
|
|
332
|
+
) : null}
|
|
333
|
+
</View>
|
|
294
334
|
|
|
295
|
-
|
|
296
|
-
},
|
|
297
|
-
]}
|
|
298
|
-
>
|
|
299
|
-
{checked ? (
|
|
300
|
-
<View
|
|
301
|
-
style={[
|
|
302
|
-
styles.radioDot,
|
|
335
|
+
{/* LABEL */}
|
|
303
336
|
|
|
304
|
-
|
|
305
|
-
|
|
337
|
+
<View style={styles.content}>
|
|
338
|
+
{label !== "" ? (
|
|
339
|
+
<Text
|
|
340
|
+
style={[
|
|
341
|
+
styles.optionLabel,
|
|
306
342
|
|
|
307
|
-
|
|
343
|
+
{
|
|
344
|
+
color: isDisabled
|
|
345
|
+
? colors.textDisabled || "#A3A3A3"
|
|
346
|
+
: colors.text || "#111111",
|
|
308
347
|
|
|
309
|
-
|
|
348
|
+
fontSize: radioSize.fontSize,
|
|
310
349
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
: colors.primary || "#FF5A1F",
|
|
314
|
-
},
|
|
315
|
-
]}
|
|
316
|
-
/>
|
|
317
|
-
) : null}
|
|
318
|
-
</View>
|
|
350
|
+
lineHeight: radioSize.lineHeight,
|
|
351
|
+
},
|
|
319
352
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
styles.description,
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
color: isDisabled
|
|
352
|
-
? colors.textDisabled || "#A3A3A3"
|
|
353
|
-
: colors.textSecondary || "#525252",
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
descriptionStyle,
|
|
357
|
-
]}
|
|
358
|
-
>
|
|
359
|
-
{String(description)}
|
|
360
|
-
</Text>
|
|
361
|
-
) : null}
|
|
362
|
-
</View>
|
|
363
|
-
</Pressable>
|
|
364
|
-
</View>
|
|
353
|
+
labelStyle,
|
|
354
|
+
]}
|
|
355
|
+
>
|
|
356
|
+
{String(label)}
|
|
357
|
+
</Text>
|
|
358
|
+
) : null}
|
|
359
|
+
|
|
360
|
+
{description !== "" &&
|
|
361
|
+
description !== null &&
|
|
362
|
+
description !== undefined ? (
|
|
363
|
+
<Text
|
|
364
|
+
style={[
|
|
365
|
+
styles.description,
|
|
366
|
+
|
|
367
|
+
{
|
|
368
|
+
color: isDisabled
|
|
369
|
+
? colors.textDisabled || "#A3A3A3"
|
|
370
|
+
: colors.textSecondary || "#525252",
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
descriptionStyle,
|
|
374
|
+
]}
|
|
375
|
+
>
|
|
376
|
+
{String(description)}
|
|
377
|
+
</Text>
|
|
378
|
+
) : null}
|
|
379
|
+
</View>
|
|
380
|
+
</Pressable>
|
|
365
381
|
);
|
|
366
382
|
};
|
|
367
383
|
|
|
@@ -390,7 +406,7 @@ function getRadioSize(size) {
|
|
|
390
406
|
case "md":
|
|
391
407
|
default:
|
|
392
408
|
return {
|
|
393
|
-
outer:
|
|
409
|
+
outer: 20,
|
|
394
410
|
inner: 9,
|
|
395
411
|
fontSize: 14,
|
|
396
412
|
lineHeight: 20,
|
|
@@ -403,12 +419,12 @@ function getRadioSize(size) {
|
|
|
403
419
|
========================================================= */
|
|
404
420
|
|
|
405
421
|
const styles = StyleSheet.create({
|
|
406
|
-
|
|
422
|
+
container: {
|
|
407
423
|
width: "100%",
|
|
408
424
|
},
|
|
409
425
|
|
|
410
426
|
groupLabel: {
|
|
411
|
-
marginBottom:
|
|
427
|
+
marginBottom: 12,
|
|
412
428
|
|
|
413
429
|
fontSize: 14,
|
|
414
430
|
|
|
@@ -421,10 +437,18 @@ const styles = StyleSheet.create({
|
|
|
421
437
|
|
|
422
438
|
options: {
|
|
423
439
|
width: "100%",
|
|
440
|
+
|
|
441
|
+
flexDirection: "row",
|
|
442
|
+
|
|
443
|
+
flexWrap: "wrap",
|
|
444
|
+
|
|
445
|
+
alignItems: "flex-start",
|
|
424
446
|
},
|
|
425
447
|
|
|
426
448
|
vertical: {
|
|
427
449
|
flexDirection: "column",
|
|
450
|
+
|
|
451
|
+
alignItems: "stretch",
|
|
428
452
|
},
|
|
429
453
|
|
|
430
454
|
horizontal: {
|
|
@@ -432,21 +456,29 @@ const styles = StyleSheet.create({
|
|
|
432
456
|
|
|
433
457
|
flexWrap: "wrap",
|
|
434
458
|
|
|
435
|
-
alignItems: "
|
|
459
|
+
alignItems: "center",
|
|
436
460
|
},
|
|
437
461
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
462
|
+
/*
|
|
463
|
+
* IMPORTANT:
|
|
464
|
+
*
|
|
465
|
+
* The option does NOT have
|
|
466
|
+
* width: "100%".
|
|
467
|
+
*
|
|
468
|
+
* Therefore horizontal options
|
|
469
|
+
* use only the width they need.
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
option: {
|
|
473
|
+
flexDirection: "row",
|
|
441
474
|
|
|
442
|
-
|
|
443
|
-
width: "100%",
|
|
475
|
+
alignItems: "center",
|
|
444
476
|
|
|
445
|
-
|
|
477
|
+
flexShrink: 0,
|
|
446
478
|
|
|
447
|
-
|
|
479
|
+
flexGrow: 0,
|
|
448
480
|
|
|
449
|
-
|
|
481
|
+
minHeight: 32,
|
|
450
482
|
},
|
|
451
483
|
|
|
452
484
|
radio: {
|
|
@@ -455,26 +487,24 @@ const styles = StyleSheet.create({
|
|
|
455
487
|
alignItems: "center",
|
|
456
488
|
|
|
457
489
|
justifyContent: "center",
|
|
458
|
-
|
|
459
|
-
marginTop: 1,
|
|
460
490
|
},
|
|
461
491
|
|
|
462
492
|
radioDot: {},
|
|
463
493
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
minWidth: 0,
|
|
494
|
+
content: {
|
|
495
|
+
flexShrink: 0,
|
|
468
496
|
|
|
469
|
-
|
|
497
|
+
flexGrow: 0,
|
|
470
498
|
|
|
471
|
-
|
|
499
|
+
marginLeft: 8,
|
|
472
500
|
},
|
|
473
501
|
|
|
474
502
|
optionLabel: {
|
|
475
503
|
fontWeight: "500",
|
|
476
504
|
|
|
477
505
|
includeFontPadding: false,
|
|
506
|
+
|
|
507
|
+
flexShrink: 0,
|
|
478
508
|
},
|
|
479
509
|
|
|
480
510
|
description: {
|