@dloizides/ui-forms 1.19.0 → 1.20.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/CHANGELOG.md +437 -429
- package/dist/index.d.mts +33 -2
- package/dist/index.d.ts +33 -2
- package/dist/index.js +100 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React2, { useState, useCallback, useMemo, useEffect, useRef, useLayoutEffect } from 'react';
|
|
2
|
-
import { Platform, StyleSheet, TextInput, View, Text, ScrollView, Pressable, Switch, TouchableOpacity } from 'react-native';
|
|
2
|
+
import { Platform, StyleSheet, TextInput, View, Text, useWindowDimensions, ScrollView, Pressable, Switch, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useUi } from '@dloizides/ui-feedback';
|
|
4
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { Z_INDEX, focusRingOutline, readableScaleInk } from '@dloizides/design-tokens';
|
|
6
6
|
import { themeFocusRingColor, Button } from '@dloizides/ui-buttons';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
@@ -247,6 +247,7 @@ var FORM_GRID_DEFAULT_MIN_WIDTH = 220;
|
|
|
247
247
|
var FORM_GRID_DEFAULT_BASIS = 260;
|
|
248
248
|
var styles2 = StyleSheet.create({
|
|
249
249
|
grid: {
|
|
250
|
+
alignItems: "flex-start",
|
|
250
251
|
flexDirection: "row",
|
|
251
252
|
flexWrap: "wrap"
|
|
252
253
|
}
|
|
@@ -262,6 +263,36 @@ var FormGrid = ({
|
|
|
262
263
|
const metrics = React2.useMemo(() => ({ minWidth, basis }), [minWidth, basis]);
|
|
263
264
|
return /* @__PURE__ */ jsx(FormGridProvider, { value: metrics, children: /* @__PURE__ */ jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsx(View, { style: [styles2.grid, { gap }, style], testID, children }) }) });
|
|
264
265
|
};
|
|
266
|
+
var LABEL_LINE_PLACEHOLDER = "\xA0";
|
|
267
|
+
var styles3 = StyleSheet.create({
|
|
268
|
+
labelLine: {
|
|
269
|
+
userSelect: "none"
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
var AlignToControl = ({
|
|
273
|
+
children,
|
|
274
|
+
labelVariant,
|
|
275
|
+
spacing,
|
|
276
|
+
style,
|
|
277
|
+
testID
|
|
278
|
+
}) => {
|
|
279
|
+
const spacingStyles = fieldSpacingStyleSet(resolveFieldSpacing(spacing, useIsGapOwned()));
|
|
280
|
+
const labelLineTestID = testID !== void 0 ? `${testID}-label-line` : void 0;
|
|
281
|
+
return /* @__PURE__ */ jsxs(View, { style: [spacingStyles.container, style], testID, children: [
|
|
282
|
+
/* @__PURE__ */ jsx(
|
|
283
|
+
Text,
|
|
284
|
+
{
|
|
285
|
+
accessibilityElementsHidden: true,
|
|
286
|
+
"aria-hidden": true,
|
|
287
|
+
importantForAccessibility: "no",
|
|
288
|
+
style: [spacingStyles.label, resolveLabelVariantStyle(labelVariant), styles3.labelLine],
|
|
289
|
+
testID: labelLineTestID,
|
|
290
|
+
children: LABEL_LINE_PLACEHOLDER
|
|
291
|
+
}
|
|
292
|
+
),
|
|
293
|
+
children
|
|
294
|
+
] });
|
|
295
|
+
};
|
|
265
296
|
var GROW = 1;
|
|
266
297
|
var NO_GROW = 0;
|
|
267
298
|
var FormCell = ({
|
|
@@ -269,6 +300,7 @@ var FormCell = ({
|
|
|
269
300
|
minWidth,
|
|
270
301
|
basis,
|
|
271
302
|
grow = true,
|
|
303
|
+
alignToControl = false,
|
|
272
304
|
style,
|
|
273
305
|
testID
|
|
274
306
|
}) => {
|
|
@@ -280,11 +312,54 @@ var FormCell = ({
|
|
|
280
312
|
flexBasis: resolvedBasis,
|
|
281
313
|
flexGrow: grow ? GROW : NO_GROW
|
|
282
314
|
};
|
|
283
|
-
return /* @__PURE__ */ jsx(View, { style: [cellStyle, style], testID, children });
|
|
315
|
+
return /* @__PURE__ */ jsx(View, { style: [cellStyle, style], testID, children: alignToControl ? /* @__PURE__ */ jsx(AlignToControl, { children }) : children });
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
// src/InlineFieldRow/inlineFieldRowLayout.ts
|
|
319
|
+
var INLINE_FIELD_ROW_MIN_WIDTH = 1024;
|
|
320
|
+
function inlineFieldRowLayout(windowWidth, fieldMaxWidth, inlineMinWidth = INLINE_FIELD_ROW_MIN_WIDTH) {
|
|
321
|
+
const inline = windowWidth >= inlineMinWidth;
|
|
322
|
+
return { inline, fieldMaxWidth: inline ? fieldMaxWidth : void 0 };
|
|
323
|
+
}
|
|
324
|
+
var styles4 = StyleSheet.create({
|
|
325
|
+
action: {
|
|
326
|
+
flexShrink: 0
|
|
327
|
+
},
|
|
328
|
+
field: {
|
|
329
|
+
flexBasis: 0,
|
|
330
|
+
flexGrow: 1,
|
|
331
|
+
flexShrink: 1
|
|
332
|
+
},
|
|
333
|
+
row: {
|
|
334
|
+
alignItems: "flex-start",
|
|
335
|
+
flexDirection: "row"
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
var InlineFieldRow = ({
|
|
339
|
+
field,
|
|
340
|
+
action,
|
|
341
|
+
fieldMaxWidth,
|
|
342
|
+
inlineMinWidth,
|
|
343
|
+
gap = FORM_GRID_DEFAULT_GAP,
|
|
344
|
+
testID
|
|
345
|
+
}) => {
|
|
346
|
+
const { width } = useWindowDimensions();
|
|
347
|
+
const layout = inlineFieldRowLayout(width, fieldMaxWidth, inlineMinWidth);
|
|
348
|
+
const rowStyle = useMemo(() => [styles4.row, { gap }], [gap]);
|
|
349
|
+
const fieldStyle = useMemo(() => [styles4.field, { maxWidth: layout.fieldMaxWidth }], [layout.fieldMaxWidth]);
|
|
350
|
+
if (!layout.inline)
|
|
351
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
352
|
+
field,
|
|
353
|
+
action
|
|
354
|
+
] });
|
|
355
|
+
return /* @__PURE__ */ jsxs(View, { style: rowStyle, testID, children: [
|
|
356
|
+
/* @__PURE__ */ jsx(View, { style: fieldStyle, children: field }),
|
|
357
|
+
/* @__PURE__ */ jsx(AlignToControl, { style: styles4.action, children: action })
|
|
358
|
+
] });
|
|
284
359
|
};
|
|
285
360
|
var SECTION_GAP = 10;
|
|
286
361
|
var DESCRIPTION_FONT_SIZE = 12;
|
|
287
|
-
var
|
|
362
|
+
var styles5 = StyleSheet.create({
|
|
288
363
|
section: {
|
|
289
364
|
gap: SECTION_GAP
|
|
290
365
|
},
|
|
@@ -319,7 +394,7 @@ var FormSection = ({
|
|
|
319
394
|
// The section spaces its children with `gap`, so it owns their vertical rhythm exactly as a
|
|
320
395
|
// `FormGrid` owns a row's — without this a `Field` placed directly in a section would stack its
|
|
321
396
|
// 16px margin on the section's gap and recreate the F3 bug one level up.
|
|
322
|
-
/* @__PURE__ */ jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxs(View, { role: "group", style: [
|
|
397
|
+
/* @__PURE__ */ jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxs(View, { role: "group", style: [styles5.section, style], testID, ...a11y, children: [
|
|
323
398
|
hasTitle ? /* @__PURE__ */ jsx(
|
|
324
399
|
Text,
|
|
325
400
|
{
|
|
@@ -328,13 +403,13 @@ var FormSection = ({
|
|
|
328
403
|
children: title
|
|
329
404
|
}
|
|
330
405
|
) : null,
|
|
331
|
-
hasDescription ? /* @__PURE__ */ jsx(Text, { style: [
|
|
406
|
+
hasDescription ? /* @__PURE__ */ jsx(Text, { style: [styles5.description, { color: colors.textSecondary }], children: description }) : null,
|
|
332
407
|
children
|
|
333
408
|
] }) })
|
|
334
409
|
);
|
|
335
410
|
};
|
|
336
411
|
var ACTIONS_GAP = 12;
|
|
337
|
-
var
|
|
412
|
+
var styles6 = StyleSheet.create({
|
|
338
413
|
container: {
|
|
339
414
|
flexDirection: "row",
|
|
340
415
|
justifyContent: "flex-end",
|
|
@@ -354,7 +429,7 @@ var FormActions = ({
|
|
|
354
429
|
saveTestID = "save-button",
|
|
355
430
|
cancelTestID = "cancel-button",
|
|
356
431
|
testID
|
|
357
|
-
}) => /* @__PURE__ */ jsxs(View, { style: [
|
|
432
|
+
}) => /* @__PURE__ */ jsxs(View, { style: [styles6.container, containerStyle], testID, children: [
|
|
358
433
|
typeof onCancel === "function" ? /* @__PURE__ */ jsx(
|
|
359
434
|
Button,
|
|
360
435
|
{
|
|
@@ -1174,7 +1249,7 @@ function chipIdentity(option, selected, config) {
|
|
|
1174
1249
|
ariaChecked: isRadio ? selected : void 0
|
|
1175
1250
|
};
|
|
1176
1251
|
}
|
|
1177
|
-
var
|
|
1252
|
+
var styles7 = StyleSheet.create({
|
|
1178
1253
|
chipContainer: {
|
|
1179
1254
|
flexDirection: "row",
|
|
1180
1255
|
flexWrap: "wrap",
|
|
@@ -1260,7 +1335,7 @@ var ChipSelector = ({
|
|
|
1260
1335
|
View,
|
|
1261
1336
|
{
|
|
1262
1337
|
accessibilityRole: isRadioGroup ? "radiogroup" : void 0,
|
|
1263
|
-
style:
|
|
1338
|
+
style: styles7.chipContainer,
|
|
1264
1339
|
...webFieldA11y({ describedById, hasError }),
|
|
1265
1340
|
...radio.groupProps,
|
|
1266
1341
|
children: options.map(renderChip)
|
|
@@ -1270,7 +1345,7 @@ var ChipSelector = ({
|
|
|
1270
1345
|
);
|
|
1271
1346
|
};
|
|
1272
1347
|
var DESCRIPTION_FONT_SIZE2 = 12;
|
|
1273
|
-
var
|
|
1348
|
+
var styles8 = StyleSheet.create({
|
|
1274
1349
|
container: {
|
|
1275
1350
|
flexDirection: "row",
|
|
1276
1351
|
justifyContent: "space-between",
|
|
@@ -1331,15 +1406,15 @@ var FormSwitch = ({
|
|
|
1331
1406
|
accessible: false,
|
|
1332
1407
|
disabled,
|
|
1333
1408
|
onPress: toggle,
|
|
1334
|
-
style: [
|
|
1409
|
+
style: [styles8.container, containerStyle],
|
|
1335
1410
|
tabIndex: -1,
|
|
1336
1411
|
testID: `${testID}-row`,
|
|
1337
1412
|
children: [
|
|
1338
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
1339
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
1340
|
-
hasDescription ? /* @__PURE__ */ jsx(Text, { style: [
|
|
1413
|
+
/* @__PURE__ */ jsxs(View, { style: styles8.textColumn, children: [
|
|
1414
|
+
/* @__PURE__ */ jsx(Text, { style: [styles8.label, themeStyles.label], children: label }),
|
|
1415
|
+
hasDescription ? /* @__PURE__ */ jsx(Text, { style: [styles8.description, themeStyles.description], children: description }) : null
|
|
1341
1416
|
] }),
|
|
1342
|
-
/* @__PURE__ */ jsx(View, { pointerEvents: "none", style:
|
|
1417
|
+
/* @__PURE__ */ jsx(View, { pointerEvents: "none", style: styles8.switchSlot, testID: `${testID}-hitbox`, children: /* @__PURE__ */ jsx(
|
|
1343
1418
|
Switch,
|
|
1344
1419
|
{
|
|
1345
1420
|
accessibilityHint: accessibilityHint ?? label,
|
|
@@ -1362,7 +1437,7 @@ var BOX_SIZE = 20;
|
|
|
1362
1437
|
var BOX_RADIUS = 5;
|
|
1363
1438
|
var CHECK_FONT_SIZE = 14;
|
|
1364
1439
|
var DISABLED_OPACITY = 0.5;
|
|
1365
|
-
var
|
|
1440
|
+
var styles9 = StyleSheet.create({
|
|
1366
1441
|
container: {
|
|
1367
1442
|
flexDirection: "row",
|
|
1368
1443
|
alignItems: "flex-start",
|
|
@@ -1454,18 +1529,18 @@ var FormCheckbox = ({
|
|
|
1454
1529
|
onPress: toggle,
|
|
1455
1530
|
role: "checkbox",
|
|
1456
1531
|
style: [
|
|
1457
|
-
|
|
1458
|
-
hasHint ? null :
|
|
1532
|
+
styles9.container,
|
|
1533
|
+
hasHint ? null : styles9.centered,
|
|
1459
1534
|
containerStyle,
|
|
1460
1535
|
disabled ? { opacity: DISABLED_OPACITY } : null
|
|
1461
1536
|
],
|
|
1462
1537
|
testID,
|
|
1463
1538
|
...keyboardProps,
|
|
1464
1539
|
children: [
|
|
1465
|
-
/* @__PURE__ */ jsx(View, { style: [
|
|
1466
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
1467
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
1468
|
-
hasHint ? /* @__PURE__ */ jsx(Text, { nativeID: hintId, style: [
|
|
1540
|
+
/* @__PURE__ */ jsx(View, { style: [styles9.box, value ? themeStyles.boxOn : themeStyles.boxOff], children: value ? /* @__PURE__ */ jsx(Text, { style: [styles9.check, { color: colors.surface }], accessibilityElementsHidden: true, children: "\u2713" }) : null }),
|
|
1541
|
+
/* @__PURE__ */ jsxs(View, { style: styles9.textColumn, children: [
|
|
1542
|
+
/* @__PURE__ */ jsx(Text, { style: [styles9.label, themeStyles.label], children: label }),
|
|
1543
|
+
hasHint ? /* @__PURE__ */ jsx(Text, { nativeID: hintId, style: [styles9.hint, themeStyles.hint], children: hintText }) : null
|
|
1469
1544
|
] })
|
|
1470
1545
|
]
|
|
1471
1546
|
}
|
|
@@ -1757,6 +1832,6 @@ function toggleGroupSelection(selected, groupKeys, order) {
|
|
|
1757
1832
|
return order === void 0 ? merged : order.filter((key) => merged.includes(key));
|
|
1758
1833
|
}
|
|
1759
1834
|
|
|
1760
|
-
export { AnchoredMenu, ChipSelector, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeControl, Field, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormSwitch, SelectControl, ThemedTextInput, TypeaheadControl, controlStyles, groupAriaChecked, isUnmatched, resolveGroupSelection, suggestOptions, toggleGroupSelection, useRecentValues, useThemedInput };
|
|
1835
|
+
export { AlignToControl, AnchoredMenu, ChipSelector, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeControl, Field, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormSwitch, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, SelectControl, ThemedTextInput, TypeaheadControl, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, suggestOptions, toggleGroupSelection, useRecentValues, useThemedInput };
|
|
1761
1836
|
//# sourceMappingURL=index.mjs.map
|
|
1762
1837
|
//# sourceMappingURL=index.mjs.map
|