@dloizides/ui-forms 1.17.0 → 1.18.0
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/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +64 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -454,7 +454,13 @@ var controlStyles = StyleSheet.create({
|
|
|
454
454
|
elevation: MENU_ELEVATION,
|
|
455
455
|
overflow: "hidden"
|
|
456
456
|
},
|
|
457
|
-
option
|
|
457
|
+
/** A menu option is a tap target, so it carries the kit floor (SHOWCASE-1). */
|
|
458
|
+
option: {
|
|
459
|
+
minHeight: MIN_TOUCH_TARGET_PX,
|
|
460
|
+
justifyContent: "center",
|
|
461
|
+
paddingHorizontal: MENU_OPT_PAD_H,
|
|
462
|
+
paddingVertical: MENU_OPT_PAD_V
|
|
463
|
+
},
|
|
458
464
|
optionText: { fontSize: OPTION_FONT },
|
|
459
465
|
error: { fontSize: ERROR_FONT, marginTop: ERROR_GAP }
|
|
460
466
|
});
|
|
@@ -1256,7 +1262,10 @@ var styles6 = StyleSheet.create({
|
|
|
1256
1262
|
flexDirection: "row",
|
|
1257
1263
|
justifyContent: "space-between",
|
|
1258
1264
|
alignItems: "center",
|
|
1259
|
-
marginBottom: 12
|
|
1265
|
+
marginBottom: 12,
|
|
1266
|
+
// The ROW is the hit box (SHOWCASE-1): RN-web renders Switch as a 40x20 box and ignores
|
|
1267
|
+
// `hitSlop`, so a pointer target smaller than the floor cannot be widened any other way.
|
|
1268
|
+
minHeight: MIN_TOUCH_TARGET_PX
|
|
1260
1269
|
},
|
|
1261
1270
|
textColumn: {
|
|
1262
1271
|
flex: 1
|
|
@@ -1280,6 +1289,9 @@ var FormSwitch = ({
|
|
|
1280
1289
|
accessibilityHint
|
|
1281
1290
|
}) => {
|
|
1282
1291
|
const { theme } = useUi();
|
|
1292
|
+
const toggle = React2.useCallback(() => {
|
|
1293
|
+
if (!disabled) onValueChange(!value);
|
|
1294
|
+
}, [disabled, onValueChange, value]);
|
|
1283
1295
|
const { colors } = theme;
|
|
1284
1296
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1285
1297
|
const themeStyles = React2.useMemo(() => {
|
|
@@ -1287,32 +1299,42 @@ var FormSwitch = ({
|
|
|
1287
1299
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1288
1300
|
return { label: labelStyle, description: descriptionStyle };
|
|
1289
1301
|
}, [colors.text, colors.textSecondary]);
|
|
1290
|
-
return
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1302
|
+
return (
|
|
1303
|
+
/*
|
|
1304
|
+
Pointer target only: the whole row toggles on press. It is NOT an a11y element and NOT a tab
|
|
1305
|
+
stop (`accessible` / `focusable` false) so the native input below stays the ONE switch. The
|
|
1306
|
+
Switch sits under `pointerEvents="none"`, so a tap on it reaches this row exactly once
|
|
1307
|
+
instead of toggling twice; keyboard focus + Space still reach the input directly.
|
|
1308
|
+
*/
|
|
1309
|
+
/* @__PURE__ */ jsxs(
|
|
1310
|
+
Pressable,
|
|
1311
|
+
{
|
|
1312
|
+
accessible: false,
|
|
1313
|
+
disabled,
|
|
1314
|
+
onPress: toggle,
|
|
1315
|
+
style: [styles6.container, containerStyle],
|
|
1316
|
+
tabIndex: -1,
|
|
1317
|
+
testID: `${testID}-row`,
|
|
1318
|
+
children: [
|
|
1319
|
+
/* @__PURE__ */ jsxs(View, { style: styles6.textColumn, children: [
|
|
1320
|
+
/* @__PURE__ */ jsx(Text, { style: [styles6.label, themeStyles.label], children: label }),
|
|
1321
|
+
hasDescription ? /* @__PURE__ */ jsx(Text, { style: [styles6.description, themeStyles.description], children: description }) : null
|
|
1322
|
+
] }),
|
|
1323
|
+
/* @__PURE__ */ jsx(View, { pointerEvents: "none", children: /* @__PURE__ */ jsx(
|
|
1324
|
+
Switch,
|
|
1325
|
+
{
|
|
1326
|
+
accessibilityHint: accessibilityHint ?? label,
|
|
1327
|
+
accessibilityLabel: label,
|
|
1328
|
+
accessibilityState: { checked: value, disabled },
|
|
1329
|
+
disabled,
|
|
1330
|
+
testID,
|
|
1331
|
+
value,
|
|
1332
|
+
onValueChange
|
|
1333
|
+
}
|
|
1334
|
+
) })
|
|
1335
|
+
]
|
|
1336
|
+
}
|
|
1337
|
+
)
|
|
1316
1338
|
);
|
|
1317
1339
|
};
|
|
1318
1340
|
var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
|
|
@@ -1326,7 +1348,14 @@ var styles7 = StyleSheet.create({
|
|
|
1326
1348
|
flexDirection: "row",
|
|
1327
1349
|
alignItems: "flex-start",
|
|
1328
1350
|
gap: 10,
|
|
1329
|
-
marginBottom: 12
|
|
1351
|
+
marginBottom: 12,
|
|
1352
|
+
// The whole row is the Pressable, so the row IS the hit box: on RN-web `hitSlop` is inert and a
|
|
1353
|
+
// one-line label measured 36px tall (SHOWCASE-1). The 20px visual box keeps its size inside.
|
|
1354
|
+
minHeight: MIN_TOUCH_TARGET_PX
|
|
1355
|
+
},
|
|
1356
|
+
/** With no hint the row is a single line, so centre it vertically inside the floor. */
|
|
1357
|
+
centered: {
|
|
1358
|
+
alignItems: "center"
|
|
1330
1359
|
},
|
|
1331
1360
|
box: {
|
|
1332
1361
|
width: BOX_SIZE,
|
|
@@ -1403,7 +1432,12 @@ var FormCheckbox = ({
|
|
|
1403
1432
|
disabled,
|
|
1404
1433
|
onPress: toggle,
|
|
1405
1434
|
role: "checkbox",
|
|
1406
|
-
style: [
|
|
1435
|
+
style: [
|
|
1436
|
+
styles7.container,
|
|
1437
|
+
hasHint ? null : styles7.centered,
|
|
1438
|
+
containerStyle,
|
|
1439
|
+
disabled ? { opacity: DISABLED_OPACITY } : null
|
|
1440
|
+
],
|
|
1407
1441
|
testID,
|
|
1408
1442
|
...keyboardProps,
|
|
1409
1443
|
children: [
|