@dloizides/ui-forms 1.17.0 → 1.18.1
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 +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +67 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/index.d.mts
CHANGED
|
@@ -934,12 +934,15 @@ declare const controlStyles: {
|
|
|
934
934
|
borderWidth: number;
|
|
935
935
|
borderRadius: number;
|
|
936
936
|
paddingVertical: number;
|
|
937
|
-
zIndex:
|
|
937
|
+
zIndex: 1000;
|
|
938
938
|
boxShadow: string;
|
|
939
939
|
elevation: number;
|
|
940
940
|
overflow: "hidden";
|
|
941
941
|
};
|
|
942
|
+
/** A menu option is a tap target, so it carries the kit floor (SHOWCASE-1). */
|
|
942
943
|
option: {
|
|
944
|
+
minHeight: number;
|
|
945
|
+
justifyContent: "center";
|
|
943
946
|
paddingHorizontal: number;
|
|
944
947
|
paddingVertical: number;
|
|
945
948
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -934,12 +934,15 @@ declare const controlStyles: {
|
|
|
934
934
|
borderWidth: number;
|
|
935
935
|
borderRadius: number;
|
|
936
936
|
paddingVertical: number;
|
|
937
|
-
zIndex:
|
|
937
|
+
zIndex: 1000;
|
|
938
938
|
boxShadow: string;
|
|
939
939
|
elevation: number;
|
|
940
940
|
overflow: "hidden";
|
|
941
941
|
};
|
|
942
|
+
/** A menu option is a tap target, so it carries the kit floor (SHOWCASE-1). */
|
|
942
943
|
option: {
|
|
944
|
+
minHeight: number;
|
|
945
|
+
justifyContent: "center";
|
|
943
946
|
paddingHorizontal: number;
|
|
944
947
|
paddingVertical: number;
|
|
945
948
|
};
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
var uiButtons = require('@dloizides/ui-buttons');
|
|
8
8
|
var reactDom = require('react-dom');
|
|
9
9
|
var a11y = require('@dloizides/a11y');
|
|
10
|
+
var designTokens = require('@dloizides/design-tokens');
|
|
10
11
|
|
|
11
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
|
|
@@ -398,7 +399,6 @@ var MENU_OPT_PAD_H = 12;
|
|
|
398
399
|
var MENU_OPT_PAD_V = 8;
|
|
399
400
|
var MENU_MIN_WIDTH = 160;
|
|
400
401
|
var MENU_MAX_HEIGHT = 260;
|
|
401
|
-
var MENU_Z = 1e3;
|
|
402
402
|
var MENU_ELEVATION = 8;
|
|
403
403
|
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
404
404
|
var OPTION_FONT = 14;
|
|
@@ -455,17 +455,23 @@ var controlStyles = reactNative.StyleSheet.create({
|
|
|
455
455
|
borderWidth: INPUT_BORDER,
|
|
456
456
|
borderRadius: MENU_RADIUS,
|
|
457
457
|
paddingVertical: MENU_PAD_V,
|
|
458
|
-
zIndex:
|
|
458
|
+
zIndex: designTokens.Z_INDEX.dropdown,
|
|
459
459
|
boxShadow: MENU_BOX_SHADOW,
|
|
460
460
|
elevation: MENU_ELEVATION,
|
|
461
461
|
overflow: "hidden"
|
|
462
462
|
},
|
|
463
|
-
option
|
|
463
|
+
/** A menu option is a tap target, so it carries the kit floor (SHOWCASE-1). */
|
|
464
|
+
option: {
|
|
465
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
466
|
+
justifyContent: "center",
|
|
467
|
+
paddingHorizontal: MENU_OPT_PAD_H,
|
|
468
|
+
paddingVertical: MENU_OPT_PAD_V
|
|
469
|
+
},
|
|
464
470
|
optionText: { fontSize: OPTION_FONT },
|
|
465
471
|
error: { fontSize: ERROR_FONT, marginTop: ERROR_GAP }
|
|
466
472
|
});
|
|
467
473
|
var IS_WEB3 = reactNative.Platform.OS === "web";
|
|
468
|
-
var MENU_PORTAL_Z_INDEX =
|
|
474
|
+
var MENU_PORTAL_Z_INDEX = designTokens.Z_INDEX.popover;
|
|
469
475
|
var MENU_TOP_GAP2 = 4;
|
|
470
476
|
function toDomNode(ref) {
|
|
471
477
|
const node = ref.current;
|
|
@@ -1262,7 +1268,10 @@ var styles6 = reactNative.StyleSheet.create({
|
|
|
1262
1268
|
flexDirection: "row",
|
|
1263
1269
|
justifyContent: "space-between",
|
|
1264
1270
|
alignItems: "center",
|
|
1265
|
-
marginBottom: 12
|
|
1271
|
+
marginBottom: 12,
|
|
1272
|
+
// The ROW is the hit box (SHOWCASE-1): RN-web renders Switch as a 40x20 box and ignores
|
|
1273
|
+
// `hitSlop`, so a pointer target smaller than the floor cannot be widened any other way.
|
|
1274
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX
|
|
1266
1275
|
},
|
|
1267
1276
|
textColumn: {
|
|
1268
1277
|
flex: 1
|
|
@@ -1286,6 +1295,9 @@ var FormSwitch = ({
|
|
|
1286
1295
|
accessibilityHint
|
|
1287
1296
|
}) => {
|
|
1288
1297
|
const { theme } = uiFeedback.useUi();
|
|
1298
|
+
const toggle = React2__default.default.useCallback(() => {
|
|
1299
|
+
if (!disabled) onValueChange(!value);
|
|
1300
|
+
}, [disabled, onValueChange, value]);
|
|
1289
1301
|
const { colors } = theme;
|
|
1290
1302
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1291
1303
|
const themeStyles = React2__default.default.useMemo(() => {
|
|
@@ -1293,32 +1305,42 @@ var FormSwitch = ({
|
|
|
1293
1305
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1294
1306
|
return { label: labelStyle, description: descriptionStyle };
|
|
1295
1307
|
}, [colors.text, colors.textSecondary]);
|
|
1296
|
-
return
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1308
|
+
return (
|
|
1309
|
+
/*
|
|
1310
|
+
Pointer target only: the whole row toggles on press. It is NOT an a11y element and NOT a tab
|
|
1311
|
+
stop (`accessible` / `focusable` false) so the native input below stays the ONE switch. The
|
|
1312
|
+
Switch sits under `pointerEvents="none"`, so a tap on it reaches this row exactly once
|
|
1313
|
+
instead of toggling twice; keyboard focus + Space still reach the input directly.
|
|
1314
|
+
*/
|
|
1315
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1316
|
+
reactNative.Pressable,
|
|
1317
|
+
{
|
|
1318
|
+
accessible: false,
|
|
1319
|
+
disabled,
|
|
1320
|
+
onPress: toggle,
|
|
1321
|
+
style: [styles6.container, containerStyle],
|
|
1322
|
+
tabIndex: -1,
|
|
1323
|
+
testID: `${testID}-row`,
|
|
1324
|
+
children: [
|
|
1325
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.textColumn, children: [
|
|
1326
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.label, themeStyles.label], children: label }),
|
|
1327
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.description, themeStyles.description], children: description }) : null
|
|
1328
|
+
] }),
|
|
1329
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1330
|
+
reactNative.Switch,
|
|
1331
|
+
{
|
|
1332
|
+
accessibilityHint: accessibilityHint ?? label,
|
|
1333
|
+
accessibilityLabel: label,
|
|
1334
|
+
accessibilityState: { checked: value, disabled },
|
|
1335
|
+
disabled,
|
|
1336
|
+
testID,
|
|
1337
|
+
value,
|
|
1338
|
+
onValueChange
|
|
1339
|
+
}
|
|
1340
|
+
) })
|
|
1341
|
+
]
|
|
1342
|
+
}
|
|
1343
|
+
)
|
|
1322
1344
|
);
|
|
1323
1345
|
};
|
|
1324
1346
|
var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
|
|
@@ -1332,7 +1354,14 @@ var styles7 = reactNative.StyleSheet.create({
|
|
|
1332
1354
|
flexDirection: "row",
|
|
1333
1355
|
alignItems: "flex-start",
|
|
1334
1356
|
gap: 10,
|
|
1335
|
-
marginBottom: 12
|
|
1357
|
+
marginBottom: 12,
|
|
1358
|
+
// The whole row is the Pressable, so the row IS the hit box: on RN-web `hitSlop` is inert and a
|
|
1359
|
+
// one-line label measured 36px tall (SHOWCASE-1). The 20px visual box keeps its size inside.
|
|
1360
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX
|
|
1361
|
+
},
|
|
1362
|
+
/** With no hint the row is a single line, so centre it vertically inside the floor. */
|
|
1363
|
+
centered: {
|
|
1364
|
+
alignItems: "center"
|
|
1336
1365
|
},
|
|
1337
1366
|
box: {
|
|
1338
1367
|
width: BOX_SIZE,
|
|
@@ -1409,7 +1438,12 @@ var FormCheckbox = ({
|
|
|
1409
1438
|
disabled,
|
|
1410
1439
|
onPress: toggle,
|
|
1411
1440
|
role: "checkbox",
|
|
1412
|
-
style: [
|
|
1441
|
+
style: [
|
|
1442
|
+
styles7.container,
|
|
1443
|
+
hasHint ? null : styles7.centered,
|
|
1444
|
+
containerStyle,
|
|
1445
|
+
disabled ? { opacity: DISABLED_OPACITY } : null
|
|
1446
|
+
],
|
|
1413
1447
|
testID,
|
|
1414
1448
|
...keyboardProps,
|
|
1415
1449
|
children: [
|