@rehagro/ui 1.0.31 → 1.0.32
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/dist/native.d.mts +85 -1
- package/dist/native.d.ts +85 -1
- package/dist/native.js +209 -0
- package/dist/native.js.map +1 -1
- package/dist/native.mjs +207 -1
- package/dist/native.mjs.map +1 -1
- package/package.json +1 -1
package/dist/native.mjs
CHANGED
|
@@ -1280,7 +1280,213 @@ var Select = forwardRef(function Select2(props, ref) {
|
|
|
1280
1280
|
)
|
|
1281
1281
|
] });
|
|
1282
1282
|
});
|
|
1283
|
+
var RadioGroupContext = createContext(null);
|
|
1284
|
+
var useRadioGroup = () => useContext(RadioGroupContext);
|
|
1285
|
+
var PRESET_COLORS4 = /* @__PURE__ */ new Set([
|
|
1286
|
+
"primary",
|
|
1287
|
+
"secondary",
|
|
1288
|
+
"danger",
|
|
1289
|
+
"warning",
|
|
1290
|
+
"success",
|
|
1291
|
+
"info"
|
|
1292
|
+
]);
|
|
1293
|
+
var isPresetColor4 = (color) => PRESET_COLORS4.has(color);
|
|
1294
|
+
var resolveColor = (color, theme) => {
|
|
1295
|
+
if (isPresetColor4(color)) {
|
|
1296
|
+
return theme[color] ?? "#16a34a";
|
|
1297
|
+
}
|
|
1298
|
+
return color;
|
|
1299
|
+
};
|
|
1300
|
+
var outerSizeMap = {
|
|
1301
|
+
sm: 16,
|
|
1302
|
+
md: 20,
|
|
1303
|
+
lg: 24
|
|
1304
|
+
};
|
|
1305
|
+
var innerSizeMap = {
|
|
1306
|
+
sm: 8,
|
|
1307
|
+
md: 10,
|
|
1308
|
+
lg: 12
|
|
1309
|
+
};
|
|
1310
|
+
var labelSizeMap = {
|
|
1311
|
+
sm: 14,
|
|
1312
|
+
md: 14,
|
|
1313
|
+
lg: 16
|
|
1314
|
+
};
|
|
1315
|
+
var descriptionSizeMap = {
|
|
1316
|
+
sm: 12,
|
|
1317
|
+
md: 12,
|
|
1318
|
+
lg: 14
|
|
1319
|
+
};
|
|
1320
|
+
var gapMap = {
|
|
1321
|
+
sm: 8,
|
|
1322
|
+
md: 12,
|
|
1323
|
+
lg: 16
|
|
1324
|
+
};
|
|
1325
|
+
var Radio = forwardRef(function Radio2({
|
|
1326
|
+
size = "md",
|
|
1327
|
+
label,
|
|
1328
|
+
description,
|
|
1329
|
+
color = "primary",
|
|
1330
|
+
disabled,
|
|
1331
|
+
checked: controlledChecked,
|
|
1332
|
+
defaultChecked = false,
|
|
1333
|
+
onChange,
|
|
1334
|
+
style,
|
|
1335
|
+
accessibilityLabel,
|
|
1336
|
+
...rest
|
|
1337
|
+
}, ref) {
|
|
1338
|
+
const theme = useRehagroTheme();
|
|
1339
|
+
const isControlled = controlledChecked !== void 0;
|
|
1340
|
+
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
1341
|
+
const isChecked = isControlled ? controlledChecked : internalChecked;
|
|
1342
|
+
const resolvedColor = resolveColor(color, theme);
|
|
1343
|
+
const handlePress = useCallback(() => {
|
|
1344
|
+
if (disabled) return;
|
|
1345
|
+
if (!isControlled) setInternalChecked(true);
|
|
1346
|
+
onChange?.(true);
|
|
1347
|
+
}, [disabled, isControlled, onChange]);
|
|
1348
|
+
const outerSize = outerSizeMap[size];
|
|
1349
|
+
const innerSize = innerSizeMap[size];
|
|
1350
|
+
const outerStyle = {
|
|
1351
|
+
width: outerSize,
|
|
1352
|
+
height: outerSize,
|
|
1353
|
+
borderRadius: outerSize / 2,
|
|
1354
|
+
borderWidth: theme.borderWidthSm ?? 1,
|
|
1355
|
+
borderColor: isChecked ? resolvedColor : theme.border ?? "#d1d5db",
|
|
1356
|
+
backgroundColor: theme.surface ?? "#ffffff",
|
|
1357
|
+
alignItems: "center",
|
|
1358
|
+
justifyContent: "center"
|
|
1359
|
+
};
|
|
1360
|
+
const innerStyle = {
|
|
1361
|
+
width: innerSize,
|
|
1362
|
+
height: innerSize,
|
|
1363
|
+
borderRadius: innerSize / 2,
|
|
1364
|
+
backgroundColor: resolvedColor
|
|
1365
|
+
};
|
|
1366
|
+
const accessibilityText = accessibilityLabel ?? (typeof label === "string" ? label : void 0);
|
|
1367
|
+
return /* @__PURE__ */ jsxs(
|
|
1368
|
+
Pressable,
|
|
1369
|
+
{
|
|
1370
|
+
ref,
|
|
1371
|
+
onPress: handlePress,
|
|
1372
|
+
disabled,
|
|
1373
|
+
accessibilityRole: "radio",
|
|
1374
|
+
accessibilityState: { checked: isChecked, disabled: !!disabled },
|
|
1375
|
+
accessibilityLabel: accessibilityText,
|
|
1376
|
+
style: [
|
|
1377
|
+
{
|
|
1378
|
+
flexDirection: "row",
|
|
1379
|
+
alignItems: "flex-start",
|
|
1380
|
+
gap: 8,
|
|
1381
|
+
opacity: disabled ? 0.5 : 1
|
|
1382
|
+
},
|
|
1383
|
+
style
|
|
1384
|
+
],
|
|
1385
|
+
...rest,
|
|
1386
|
+
children: [
|
|
1387
|
+
/* @__PURE__ */ jsx(View, { style: outerStyle, children: isChecked && /* @__PURE__ */ jsx(View, { style: innerStyle }) }),
|
|
1388
|
+
(label || description) && /* @__PURE__ */ jsxs(View, { style: { flex: 1, gap: 2 }, children: [
|
|
1389
|
+
label && /* @__PURE__ */ jsx(
|
|
1390
|
+
Text,
|
|
1391
|
+
{
|
|
1392
|
+
style: {
|
|
1393
|
+
fontSize: labelSizeMap[size],
|
|
1394
|
+
color: theme.text,
|
|
1395
|
+
...theme.fontFamilyBody ? { fontFamily: theme.fontFamilyBody } : {}
|
|
1396
|
+
},
|
|
1397
|
+
children: label
|
|
1398
|
+
}
|
|
1399
|
+
),
|
|
1400
|
+
description && /* @__PURE__ */ jsx(
|
|
1401
|
+
Text,
|
|
1402
|
+
{
|
|
1403
|
+
style: {
|
|
1404
|
+
fontSize: descriptionSizeMap[size],
|
|
1405
|
+
color: theme.textMuted,
|
|
1406
|
+
...theme.fontFamilyBody ? { fontFamily: theme.fontFamilyBody } : {}
|
|
1407
|
+
},
|
|
1408
|
+
children: description
|
|
1409
|
+
}
|
|
1410
|
+
)
|
|
1411
|
+
] })
|
|
1412
|
+
]
|
|
1413
|
+
}
|
|
1414
|
+
);
|
|
1415
|
+
});
|
|
1416
|
+
var RadioOption = forwardRef(function RadioOption2({ value, size, color, disabled, ...rest }, ref) {
|
|
1417
|
+
const group = useRadioGroup();
|
|
1418
|
+
const mergedSize = size ?? group?.size ?? "md";
|
|
1419
|
+
const mergedColor = color ?? group?.color ?? "primary";
|
|
1420
|
+
const mergedDisabled = disabled ?? group?.disabled ?? false;
|
|
1421
|
+
const isChecked = group?.value === value;
|
|
1422
|
+
const handleChange = () => {
|
|
1423
|
+
group?.onChange?.(value);
|
|
1424
|
+
};
|
|
1425
|
+
return /* @__PURE__ */ jsx(
|
|
1426
|
+
Radio,
|
|
1427
|
+
{
|
|
1428
|
+
ref,
|
|
1429
|
+
size: mergedSize,
|
|
1430
|
+
color: mergedColor,
|
|
1431
|
+
disabled: mergedDisabled,
|
|
1432
|
+
checked: isChecked,
|
|
1433
|
+
onChange: handleChange,
|
|
1434
|
+
...rest
|
|
1435
|
+
}
|
|
1436
|
+
);
|
|
1437
|
+
});
|
|
1438
|
+
var RadioGroup = forwardRef(function RadioGroup2({
|
|
1439
|
+
children,
|
|
1440
|
+
value,
|
|
1441
|
+
defaultValue,
|
|
1442
|
+
onChange,
|
|
1443
|
+
size = "md",
|
|
1444
|
+
orientation = "vertical",
|
|
1445
|
+
color = "primary",
|
|
1446
|
+
disabled = false,
|
|
1447
|
+
gap = "md",
|
|
1448
|
+
style
|
|
1449
|
+
}, ref) {
|
|
1450
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
1451
|
+
const isControlled = value !== void 0;
|
|
1452
|
+
const currentValue = isControlled ? value : internalValue;
|
|
1453
|
+
const handleChange = useCallback(
|
|
1454
|
+
(newValue) => {
|
|
1455
|
+
if (!isControlled) setInternalValue(newValue);
|
|
1456
|
+
onChange?.(newValue);
|
|
1457
|
+
},
|
|
1458
|
+
[isControlled, onChange]
|
|
1459
|
+
);
|
|
1460
|
+
return /* @__PURE__ */ jsx(
|
|
1461
|
+
RadioGroupContext.Provider,
|
|
1462
|
+
{
|
|
1463
|
+
value: {
|
|
1464
|
+
value: currentValue,
|
|
1465
|
+
onChange: handleChange,
|
|
1466
|
+
size,
|
|
1467
|
+
color,
|
|
1468
|
+
disabled
|
|
1469
|
+
},
|
|
1470
|
+
children: /* @__PURE__ */ jsx(
|
|
1471
|
+
View,
|
|
1472
|
+
{
|
|
1473
|
+
ref,
|
|
1474
|
+
accessibilityRole: "radiogroup",
|
|
1475
|
+
style: [
|
|
1476
|
+
{
|
|
1477
|
+
flexDirection: orientation === "vertical" ? "column" : "row",
|
|
1478
|
+
flexWrap: orientation === "horizontal" ? "wrap" : "nowrap",
|
|
1479
|
+
gap: gapMap[gap]
|
|
1480
|
+
},
|
|
1481
|
+
style
|
|
1482
|
+
],
|
|
1483
|
+
children
|
|
1484
|
+
}
|
|
1485
|
+
)
|
|
1486
|
+
}
|
|
1487
|
+
);
|
|
1488
|
+
});
|
|
1283
1489
|
|
|
1284
|
-
export { ActivityIndicator3 as ActivityIndicator, Avatar, Button, Card2 as Card, CardContent, CardFooter, CardHeader, Checkbox, IconButton, RehagroNativeProvider, Select, Tag, Text5 as Text, TextInput, useRehagroTheme };
|
|
1490
|
+
export { ActivityIndicator3 as ActivityIndicator, Avatar, Button, Card2 as Card, CardContent, CardFooter, CardHeader, Checkbox, IconButton, Radio, RadioGroup, RadioOption, RehagroNativeProvider, Select, Tag, Text5 as Text, TextInput, useRehagroTheme };
|
|
1285
1491
|
//# sourceMappingURL=native.mjs.map
|
|
1286
1492
|
//# sourceMappingURL=native.mjs.map
|