@dloizides/ui-forms 1.46.0 → 1.48.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 +13 -0
- package/dist/index.d.mts +35 -6
- package/dist/index.d.ts +35 -6
- package/dist/index.js +546 -335
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +363 -153
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React38 = require('react');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
var uiFeedback = require('@dloizides/ui-feedback');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -8,18 +8,18 @@ var designTokens = require('@dloizides/design-tokens');
|
|
|
8
8
|
var uiButtons = require('@dloizides/ui-buttons');
|
|
9
9
|
var reactDom = require('react-dom');
|
|
10
10
|
var a11y = require('@dloizides/a11y');
|
|
11
|
+
var uiIcons = require('@dloizides/ui-icons');
|
|
11
12
|
var apiClientBase = require('@dloizides/api-client-base');
|
|
12
13
|
var Svg = require('react-native-svg');
|
|
13
|
-
var uiIcons = require('@dloizides/ui-icons');
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var React38__default = /*#__PURE__*/_interopDefault(React38);
|
|
18
18
|
var Svg__default = /*#__PURE__*/_interopDefault(Svg);
|
|
19
19
|
|
|
20
20
|
// src/Field/Field.tsx
|
|
21
21
|
function attachControlId(child, candidateId, describedById) {
|
|
22
|
-
if (!
|
|
22
|
+
if (!React38__default.default.isValidElement(child) || child.type === React38__default.default.Fragment) {
|
|
23
23
|
return { node: child };
|
|
24
24
|
}
|
|
25
25
|
const props = child.props;
|
|
@@ -30,15 +30,15 @@ function attachControlId(child, candidateId, describedById) {
|
|
|
30
30
|
if (describedById !== void 0 && props.describedById === void 0) {
|
|
31
31
|
injected.describedById = describedById;
|
|
32
32
|
}
|
|
33
|
-
return { node:
|
|
33
|
+
return { node: React38__default.default.cloneElement(element, injected), controlId };
|
|
34
34
|
}
|
|
35
35
|
var IS_WEB = reactNative.Platform.OS === "web";
|
|
36
36
|
function isAttributeHost(node) {
|
|
37
37
|
return typeof node === "object" && node !== null && typeof node.setAttribute === "function";
|
|
38
38
|
}
|
|
39
39
|
function useHtmlFor(controlId) {
|
|
40
|
-
const ref =
|
|
41
|
-
|
|
40
|
+
const ref = React38.useRef(null);
|
|
41
|
+
React38.useEffect(() => {
|
|
42
42
|
const node = ref.current;
|
|
43
43
|
if (!IS_WEB || !isAttributeHost(node)) return;
|
|
44
44
|
const target = controlId !== void 0 && controlId !== "" ? node.ownerDocument?.getElementById(controlId) : null;
|
|
@@ -125,6 +125,8 @@ var FIELD_FONT_WEIGHT = "600";
|
|
|
125
125
|
var CONTROL_FONT_SIZE = 11;
|
|
126
126
|
var CONTROL_FONT_WEIGHT = "700";
|
|
127
127
|
var CONTROL_LETTER_SPACING = 0.4;
|
|
128
|
+
var CAPTION_FONT_SIZE = 12;
|
|
129
|
+
var CAPTION_FONT_WEIGHT = "600";
|
|
128
130
|
var labelVariantStyles = reactNative.StyleSheet.create({
|
|
129
131
|
field: {
|
|
130
132
|
fontSize: FIELD_FONT_SIZE,
|
|
@@ -135,20 +137,26 @@ var labelVariantStyles = reactNative.StyleSheet.create({
|
|
|
135
137
|
fontWeight: CONTROL_FONT_WEIGHT,
|
|
136
138
|
letterSpacing: CONTROL_LETTER_SPACING,
|
|
137
139
|
textTransform: "uppercase"
|
|
140
|
+
},
|
|
141
|
+
caption: {
|
|
142
|
+
fontSize: CAPTION_FONT_SIZE,
|
|
143
|
+
fontWeight: CAPTION_FONT_WEIGHT,
|
|
144
|
+
letterSpacing: CONTROL_LETTER_SPACING,
|
|
145
|
+
textTransform: "uppercase"
|
|
138
146
|
}
|
|
139
147
|
});
|
|
140
148
|
function resolveLabelVariantStyle(variant) {
|
|
141
|
-
return variant
|
|
149
|
+
return labelVariantStyles[variant ?? "field"] ?? labelVariantStyles.field;
|
|
142
150
|
}
|
|
143
|
-
var FormGridContext =
|
|
144
|
-
var GapOwnedContext =
|
|
151
|
+
var FormGridContext = React38__default.default.createContext(null);
|
|
152
|
+
var GapOwnedContext = React38__default.default.createContext(false);
|
|
145
153
|
var FormGridProvider = FormGridContext.Provider;
|
|
146
154
|
var GapOwnedProvider = GapOwnedContext.Provider;
|
|
147
155
|
function useFormGridMetrics() {
|
|
148
|
-
return
|
|
156
|
+
return React38__default.default.useContext(FormGridContext);
|
|
149
157
|
}
|
|
150
158
|
function useIsGapOwned() {
|
|
151
|
-
return
|
|
159
|
+
return React38__default.default.useContext(GapOwnedContext);
|
|
152
160
|
}
|
|
153
161
|
var ERROR_LIGHT_STEPS = ["500", "600", "700"];
|
|
154
162
|
var ERROR_DARK_STEPS = ["300", "200", "400", "100", "500"];
|
|
@@ -171,7 +179,7 @@ var styles = reactNative.StyleSheet.create({
|
|
|
171
179
|
});
|
|
172
180
|
var fieldSeq = 0;
|
|
173
181
|
function useFieldIds() {
|
|
174
|
-
const [ids] =
|
|
182
|
+
const [ids] = React38__default.default.useState(() => {
|
|
175
183
|
fieldSeq += 1;
|
|
176
184
|
const seq = String(fieldSeq);
|
|
177
185
|
return {
|
|
@@ -218,7 +226,7 @@ var Field = ({
|
|
|
218
226
|
const hasLabel = labelText !== "";
|
|
219
227
|
const marker = resolveFieldMarker(required, optional);
|
|
220
228
|
const { hintId, errorId, controlId, labelId } = useFieldIds();
|
|
221
|
-
const themeStyles =
|
|
229
|
+
const themeStyles = React38__default.default.useMemo(
|
|
222
230
|
() => ({
|
|
223
231
|
label: { color: colors.textSecondary },
|
|
224
232
|
requiredMark: { color: errorColor },
|
|
@@ -270,7 +278,7 @@ var FormGrid = ({
|
|
|
270
278
|
style,
|
|
271
279
|
testID
|
|
272
280
|
}) => {
|
|
273
|
-
const metrics =
|
|
281
|
+
const metrics = React38__default.default.useMemo(() => ({ minWidth, basis }), [minWidth, basis]);
|
|
274
282
|
return /* @__PURE__ */ jsxRuntime.jsx(FormGridProvider, { value: metrics, children: /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles2.grid, { gap }, style], testID, children }) }) });
|
|
275
283
|
};
|
|
276
284
|
var LABEL_LINE_PLACEHOLDER = "\xA0";
|
|
@@ -355,8 +363,8 @@ var InlineFieldRow = ({
|
|
|
355
363
|
}) => {
|
|
356
364
|
const { width } = reactNative.useWindowDimensions();
|
|
357
365
|
const layout = inlineFieldRowLayout(width, fieldMaxWidth, inlineMinWidth);
|
|
358
|
-
const rowStyle =
|
|
359
|
-
const fieldStyle =
|
|
366
|
+
const rowStyle = React38.useMemo(() => [styles4.row, { gap }], [gap]);
|
|
367
|
+
const fieldStyle = React38.useMemo(() => [styles4.field, { maxWidth: layout.fieldMaxWidth }], [layout.fieldMaxWidth]);
|
|
360
368
|
if (!layout.inline)
|
|
361
369
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
362
370
|
field2,
|
|
@@ -537,7 +545,7 @@ var styles9 = reactNative.StyleSheet.create({
|
|
|
537
545
|
});
|
|
538
546
|
var sectionSeq = 0;
|
|
539
547
|
function useSectionLegendId() {
|
|
540
|
-
const [id] =
|
|
548
|
+
const [id] = React38__default.default.useState(() => {
|
|
541
549
|
sectionSeq += 1;
|
|
542
550
|
return `form-section-legend-${String(sectionSeq)}`;
|
|
543
551
|
});
|
|
@@ -795,8 +803,8 @@ function horizontalPlacement(rect2, viewportWidth) {
|
|
|
795
803
|
return { left, width };
|
|
796
804
|
}
|
|
797
805
|
function useAnchorRect(ref, enabled) {
|
|
798
|
-
const [rect2, setRect] =
|
|
799
|
-
|
|
806
|
+
const [rect2, setRect] = React38.useState(null);
|
|
807
|
+
React38.useLayoutEffect(() => {
|
|
800
808
|
if (!IS_WEB3 || !enabled) {
|
|
801
809
|
setRect(null);
|
|
802
810
|
return void 0;
|
|
@@ -845,8 +853,8 @@ function readViewportBottom() {
|
|
|
845
853
|
return viewport === null ? window.innerHeight : viewport.offsetTop + viewport.height;
|
|
846
854
|
}
|
|
847
855
|
function useVisualViewportBottom(enabled) {
|
|
848
|
-
const [bottom, setBottom] =
|
|
849
|
-
|
|
856
|
+
const [bottom, setBottom] = React38.useState(null);
|
|
857
|
+
React38.useLayoutEffect(() => {
|
|
850
858
|
if (!IS_WEB3 || !enabled) {
|
|
851
859
|
setBottom(null);
|
|
852
860
|
return void 0;
|
|
@@ -876,7 +884,7 @@ function scrollAnchorIntoView(ref, marginTop) {
|
|
|
876
884
|
scrollNodeIntoView(node, anchorScrollBlock(node.getBoundingClientRect().bottom, readViewportBottom()));
|
|
877
885
|
}
|
|
878
886
|
function useKeepAnchorInRoom(ref, marginTop, enabled) {
|
|
879
|
-
|
|
887
|
+
React38.useLayoutEffect(() => {
|
|
880
888
|
if (!IS_WEB3 || !enabled) return void 0;
|
|
881
889
|
const place = () => scrollAnchorIntoView(ref, marginTop);
|
|
882
890
|
place();
|
|
@@ -890,7 +898,7 @@ var ESCAPE_KEY = "Escape";
|
|
|
890
898
|
var LISTBOX_ROLE = { role: "listbox" };
|
|
891
899
|
var KEEP_FIELD_FOCUS = { onMouseDown: (event) => event.preventDefault() };
|
|
892
900
|
function useDismiss(anchorRef, menuRef, onDismiss) {
|
|
893
|
-
|
|
901
|
+
React38.useEffect(() => {
|
|
894
902
|
if (!IS_WEB4) return void 0;
|
|
895
903
|
const onMouseDown = (event) => {
|
|
896
904
|
const anchorNode = anchorRef.current;
|
|
@@ -912,7 +920,7 @@ function useDismiss(anchorRef, menuRef, onDismiss) {
|
|
|
912
920
|
}, [anchorRef, menuRef, onDismiss]);
|
|
913
921
|
}
|
|
914
922
|
function useKeepHighlightInView(testID, highlightedValue) {
|
|
915
|
-
|
|
923
|
+
React38.useEffect(() => {
|
|
916
924
|
if (!IS_WEB4 || highlightedValue === void 0 || highlightedValue === "") return;
|
|
917
925
|
scrollNodeIntoView(document.getElementById(optionDomId(testID, highlightedValue)), "nearest");
|
|
918
926
|
}, [testID, highlightedValue]);
|
|
@@ -931,7 +939,7 @@ function AnchoredMenu({
|
|
|
931
939
|
listbox,
|
|
932
940
|
placement
|
|
933
941
|
}) {
|
|
934
|
-
const menuRef =
|
|
942
|
+
const menuRef = React38__default.default.useRef(null);
|
|
935
943
|
useDismiss(anchorRef, menuRef, onDismiss);
|
|
936
944
|
useKeepHighlightInView(testID, listbox?.highlightedValue);
|
|
937
945
|
const rect2 = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
|
|
@@ -1006,27 +1014,27 @@ function useThemedInput(options = {}) {
|
|
|
1006
1014
|
const { hasError = false, onFocus, onBlur, editable = true } = options;
|
|
1007
1015
|
const { theme } = uiFeedback.useUi();
|
|
1008
1016
|
const { colors, palette } = theme;
|
|
1009
|
-
const [isFocused, setIsFocused] =
|
|
1010
|
-
const [isHovered, setIsHovered] =
|
|
1011
|
-
const handleFocus =
|
|
1017
|
+
const [isFocused, setIsFocused] = React38.useState(false);
|
|
1018
|
+
const [isHovered, setIsHovered] = React38.useState(false);
|
|
1019
|
+
const handleFocus = React38.useCallback(
|
|
1012
1020
|
(e) => {
|
|
1013
1021
|
setIsFocused(true);
|
|
1014
1022
|
onFocus?.(e);
|
|
1015
1023
|
},
|
|
1016
1024
|
[onFocus]
|
|
1017
1025
|
);
|
|
1018
|
-
const handleBlur =
|
|
1026
|
+
const handleBlur = React38.useCallback(
|
|
1019
1027
|
(e) => {
|
|
1020
1028
|
setIsFocused(false);
|
|
1021
1029
|
onBlur?.(e);
|
|
1022
1030
|
},
|
|
1023
1031
|
[onBlur]
|
|
1024
1032
|
);
|
|
1025
|
-
const handleHoverIn =
|
|
1026
|
-
const handleHoverOut =
|
|
1033
|
+
const handleHoverIn = React38.useCallback(() => setIsHovered(true), []);
|
|
1034
|
+
const handleHoverOut = React38.useCallback(() => setIsHovered(false), []);
|
|
1027
1035
|
const primary = palette.primary["500"];
|
|
1028
1036
|
const errorColor = fieldErrorInk(theme);
|
|
1029
|
-
const style =
|
|
1037
|
+
const style = React38.useMemo(() => {
|
|
1030
1038
|
const restBorder = hasError ? errorColor : colors.border;
|
|
1031
1039
|
const focusBorder = hasError ? errorColor : primary;
|
|
1032
1040
|
const editableBorder = isFocused ? focusBorder : isHovered ? withAlpha(colors.text, HOVER_BORDER_ALPHA) : restBorder;
|
|
@@ -1059,8 +1067,8 @@ function useThemedInput(options = {}) {
|
|
|
1059
1067
|
errorColor,
|
|
1060
1068
|
theme
|
|
1061
1069
|
]);
|
|
1062
|
-
const focusBind =
|
|
1063
|
-
const hoverBind =
|
|
1070
|
+
const focusBind = React38.useMemo(() => ({ onFocus: handleFocus, onBlur: handleBlur }), [handleFocus, handleBlur]);
|
|
1071
|
+
const hoverBind = React38.useMemo(
|
|
1064
1072
|
() => IS_WEB5 ? { onMouseEnter: handleHoverIn, onMouseLeave: handleHoverOut } : {},
|
|
1065
1073
|
[handleHoverIn, handleHoverOut]
|
|
1066
1074
|
);
|
|
@@ -1091,7 +1099,7 @@ var boxStyles = reactNative.StyleSheet.create({
|
|
|
1091
1099
|
textAlignVertical: "top"
|
|
1092
1100
|
}
|
|
1093
1101
|
});
|
|
1094
|
-
var ThemedTextInput =
|
|
1102
|
+
var ThemedTextInput = React38__default.default.forwardRef(function ThemedTextInput2({
|
|
1095
1103
|
hasError = false,
|
|
1096
1104
|
describedById,
|
|
1097
1105
|
requiredField = false,
|
|
@@ -1186,11 +1194,11 @@ function recentsEqual(a, b) {
|
|
|
1186
1194
|
|
|
1187
1195
|
// src/useRecentValues/useRecentValues.ts
|
|
1188
1196
|
function useRecentValues(key, max = DEFAULT_MAX_RECENTS) {
|
|
1189
|
-
const [recents, setRecents] =
|
|
1190
|
-
|
|
1197
|
+
const [recents, setRecents] = React38.useState(() => readRecents(key).slice(0, max));
|
|
1198
|
+
React38.useEffect(() => {
|
|
1191
1199
|
setRecents(readRecents(key).slice(0, max));
|
|
1192
1200
|
}, [key, max]);
|
|
1193
|
-
const remember =
|
|
1201
|
+
const remember = React38.useCallback(
|
|
1194
1202
|
(value) => {
|
|
1195
1203
|
setRecents((current) => {
|
|
1196
1204
|
const next = computeNextRecents(current, value, max);
|
|
@@ -1201,7 +1209,7 @@ function useRecentValues(key, max = DEFAULT_MAX_RECENTS) {
|
|
|
1201
1209
|
},
|
|
1202
1210
|
[key, max]
|
|
1203
1211
|
);
|
|
1204
|
-
const clear =
|
|
1212
|
+
const clear = React38.useCallback(() => {
|
|
1205
1213
|
clearRecents(key);
|
|
1206
1214
|
setRecents([]);
|
|
1207
1215
|
}, [key]);
|
|
@@ -1223,24 +1231,24 @@ function RecentInputField({
|
|
|
1223
1231
|
const { theme } = uiFeedback.useUi();
|
|
1224
1232
|
const { colors, palette } = theme;
|
|
1225
1233
|
const { recents, remember } = useRecentValues(recentKey, recentMax);
|
|
1226
|
-
const anchorRef =
|
|
1227
|
-
const latestText =
|
|
1228
|
-
const [isOpen, setIsOpen] =
|
|
1229
|
-
const handleChange =
|
|
1234
|
+
const anchorRef = React38.useRef(null);
|
|
1235
|
+
const latestText = React38.useRef(typeof value === "string" ? value : "");
|
|
1236
|
+
const [isOpen, setIsOpen] = React38.useState(false);
|
|
1237
|
+
const handleChange = React38.useCallback(
|
|
1230
1238
|
(text) => {
|
|
1231
1239
|
latestText.current = text;
|
|
1232
1240
|
onChangeText?.(text);
|
|
1233
1241
|
},
|
|
1234
1242
|
[onChangeText]
|
|
1235
1243
|
);
|
|
1236
|
-
const handleFocus =
|
|
1244
|
+
const handleFocus = React38.useCallback(
|
|
1237
1245
|
(event) => {
|
|
1238
1246
|
setIsOpen(true);
|
|
1239
1247
|
onFocus?.(event);
|
|
1240
1248
|
},
|
|
1241
1249
|
[onFocus]
|
|
1242
1250
|
);
|
|
1243
|
-
const handleBlur =
|
|
1251
|
+
const handleBlur = React38.useCallback(
|
|
1244
1252
|
(event) => {
|
|
1245
1253
|
const blurredText = latestText.current;
|
|
1246
1254
|
setTimeout(() => {
|
|
@@ -1251,7 +1259,7 @@ function RecentInputField({
|
|
|
1251
1259
|
},
|
|
1252
1260
|
[remember, onBlur]
|
|
1253
1261
|
);
|
|
1254
|
-
const handleSubmit =
|
|
1262
|
+
const handleSubmit = React38.useCallback(
|
|
1255
1263
|
(event) => {
|
|
1256
1264
|
remember(latestText.current);
|
|
1257
1265
|
setIsOpen(false);
|
|
@@ -1259,7 +1267,7 @@ function RecentInputField({
|
|
|
1259
1267
|
},
|
|
1260
1268
|
[remember, onSubmitEditing]
|
|
1261
1269
|
);
|
|
1262
|
-
const pick =
|
|
1270
|
+
const pick = React38.useCallback(
|
|
1263
1271
|
(picked) => {
|
|
1264
1272
|
latestText.current = picked;
|
|
1265
1273
|
onChangeText?.(picked);
|
|
@@ -1315,8 +1323,8 @@ function rowsForText(text, inputWidth, minRows) {
|
|
|
1315
1323
|
|
|
1316
1324
|
// src/FormField/useAutoGrowRows.ts
|
|
1317
1325
|
function useAutoGrowRows(text, minRows) {
|
|
1318
|
-
const [inputWidth, setInputWidth] =
|
|
1319
|
-
const onLayout =
|
|
1326
|
+
const [inputWidth, setInputWidth] = React38.useState(NARROWEST_INPUT_WIDTH);
|
|
1327
|
+
const onLayout = React38.useCallback((event) => {
|
|
1320
1328
|
setInputWidth(event.nativeEvent.layout.width);
|
|
1321
1329
|
}, []);
|
|
1322
1330
|
return { numberOfLines: rowsForText(text, inputWidth, minRows), onLayout };
|
|
@@ -1330,6 +1338,7 @@ var PlainFormField = ({
|
|
|
1330
1338
|
recentKey,
|
|
1331
1339
|
recentMax,
|
|
1332
1340
|
inputRef,
|
|
1341
|
+
labelVariant,
|
|
1333
1342
|
...textInputProps
|
|
1334
1343
|
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1335
1344
|
Field,
|
|
@@ -1337,6 +1346,7 @@ var PlainFormField = ({
|
|
|
1337
1346
|
containerStyle,
|
|
1338
1347
|
error,
|
|
1339
1348
|
label: labelHidden ? void 0 : label,
|
|
1349
|
+
labelVariant,
|
|
1340
1350
|
required,
|
|
1341
1351
|
children: ({ describedById, hasError, controlId }) => {
|
|
1342
1352
|
const inputProps = {
|
|
@@ -1407,19 +1417,57 @@ function chipLabelLayout(labelWrap) {
|
|
|
1407
1417
|
return { boxStyle: CAPPED_BOX, textStyle: SHRINKING_TEXT, numberOfLines: SINGLE_LINE };
|
|
1408
1418
|
return { boxStyle: void 0, textStyle: void 0, numberOfLines: void 0 };
|
|
1409
1419
|
}
|
|
1420
|
+
var MIN_TARGET_PX = 44;
|
|
1421
|
+
var COMPACT_PAD_V = 4;
|
|
1422
|
+
var COMPACT_PAD_H = 10;
|
|
1423
|
+
var COMPACT_FONT_SIZE = 12;
|
|
1424
|
+
var COMPACT_LINE_HEIGHT = 18;
|
|
1425
|
+
var CHIP_BORDER = 1;
|
|
1426
|
+
var chipSizeStyles = reactNative.StyleSheet.create({
|
|
1427
|
+
compactHitBox: {
|
|
1428
|
+
minHeight: MIN_TARGET_PX,
|
|
1429
|
+
minWidth: MIN_TARGET_PX,
|
|
1430
|
+
justifyContent: "center",
|
|
1431
|
+
alignItems: "center"
|
|
1432
|
+
},
|
|
1433
|
+
compactVisual: {
|
|
1434
|
+
paddingVertical: COMPACT_PAD_V,
|
|
1435
|
+
paddingHorizontal: COMPACT_PAD_H,
|
|
1436
|
+
minHeight: 0,
|
|
1437
|
+
minWidth: 0,
|
|
1438
|
+
borderWidth: CHIP_BORDER
|
|
1439
|
+
},
|
|
1440
|
+
compactText: {
|
|
1441
|
+
fontSize: COMPACT_FONT_SIZE,
|
|
1442
|
+
fontWeight: "600",
|
|
1443
|
+
lineHeight: COMPACT_LINE_HEIGHT
|
|
1444
|
+
}
|
|
1445
|
+
});
|
|
1446
|
+
|
|
1447
|
+
// src/ChipSelector/utils/chipLook.ts
|
|
1448
|
+
function chipFill({ selected, selectedFill, ink, rest }) {
|
|
1449
|
+
if (!selected || selectedFill === void 0)
|
|
1450
|
+
return { ...rest, checkColor: void 0 };
|
|
1451
|
+
return { backgroundColor: selectedFill, textColor: ink, checkColor: ink };
|
|
1452
|
+
}
|
|
1453
|
+
function chipSizeLook(size) {
|
|
1454
|
+
if (size !== "compact")
|
|
1455
|
+
return { hitBox: void 0, visual: void 0, text: void 0 };
|
|
1456
|
+
return { hitBox: chipSizeStyles.compactHitBox, visual: chipSizeStyles.compactVisual, text: chipSizeStyles.compactText };
|
|
1457
|
+
}
|
|
1410
1458
|
var SOLID_RADIUS = 20;
|
|
1411
1459
|
var OUTLINE_RADIUS = 999;
|
|
1412
1460
|
var OUTLINE_PAD_H = 12;
|
|
1413
1461
|
var OUTLINE_PAD_V = 5;
|
|
1414
1462
|
var OUTLINE_FONT_SIZE = 13;
|
|
1415
1463
|
var CHIP_ICON_GAP = 6;
|
|
1416
|
-
var
|
|
1464
|
+
var MIN_TARGET_PX2 = 44;
|
|
1417
1465
|
var chipStyles = reactNative.StyleSheet.create({
|
|
1418
1466
|
chip: {
|
|
1419
1467
|
paddingHorizontal: 12,
|
|
1420
1468
|
paddingVertical: 6,
|
|
1421
|
-
minHeight:
|
|
1422
|
-
minWidth:
|
|
1469
|
+
minHeight: MIN_TARGET_PX2,
|
|
1470
|
+
minWidth: MIN_TARGET_PX2,
|
|
1423
1471
|
justifyContent: "center",
|
|
1424
1472
|
borderRadius: SOLID_RADIUS,
|
|
1425
1473
|
backgroundColor: TRANSPARENT_COLOR,
|
|
@@ -1428,8 +1476,8 @@ var chipStyles = reactNative.StyleSheet.create({
|
|
|
1428
1476
|
chipOutline: {
|
|
1429
1477
|
paddingHorizontal: OUTLINE_PAD_H,
|
|
1430
1478
|
paddingVertical: OUTLINE_PAD_V,
|
|
1431
|
-
minHeight:
|
|
1432
|
-
minWidth:
|
|
1479
|
+
minHeight: MIN_TARGET_PX2,
|
|
1480
|
+
minWidth: MIN_TARGET_PX2,
|
|
1433
1481
|
justifyContent: "center",
|
|
1434
1482
|
borderRadius: OUTLINE_RADIUS,
|
|
1435
1483
|
borderWidth: 1
|
|
@@ -1438,22 +1486,31 @@ var chipStyles = reactNative.StyleSheet.create({
|
|
|
1438
1486
|
chipText: {},
|
|
1439
1487
|
chipTextOutline: { fontSize: OUTLINE_FONT_SIZE }
|
|
1440
1488
|
});
|
|
1441
|
-
|
|
1489
|
+
var CHECK_SIZE = 12;
|
|
1490
|
+
function ChipContent(props) {
|
|
1491
|
+
const { icon, label, textStyle, numberOfLines, checkColor } = props;
|
|
1442
1492
|
const text = /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines, style: textStyle, children: label });
|
|
1443
|
-
|
|
1493
|
+
const hasIcon = icon !== void 0 && icon !== null;
|
|
1494
|
+
if (!hasIcon && checkColor === void 0)
|
|
1444
1495
|
return text;
|
|
1445
1496
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: chipStyles.chipContent, children: [
|
|
1446
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, children:
|
|
1497
|
+
checkColor === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, testID: props.checkTestID, children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: checkColor, name: "check", size: CHECK_SIZE }) }),
|
|
1498
|
+
hasIcon ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, children: icon }) : null,
|
|
1447
1499
|
text
|
|
1448
1500
|
] });
|
|
1449
1501
|
}
|
|
1450
1502
|
function OutlineChip(props) {
|
|
1451
1503
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1452
|
-
const [hovered, setHovered] =
|
|
1504
|
+
const [hovered, setHovered] = React38__default.default.useState(false);
|
|
1453
1505
|
const active = selected || hovered;
|
|
1454
1506
|
const borderColor = active ? colors.primary : colors.border;
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1507
|
+
const fill = chipFill({
|
|
1508
|
+
selected,
|
|
1509
|
+
selectedFill: props.selectedFill,
|
|
1510
|
+
ink: colors.textStrong,
|
|
1511
|
+
rest: { backgroundColor: selected ? colors.tint : colors.muted, textColor: active ? colors.primary : colors.textMuted }
|
|
1512
|
+
});
|
|
1513
|
+
const sized = chipSizeLook(props.size);
|
|
1457
1514
|
const layout = chipLabelLayout(option.labelWrap);
|
|
1458
1515
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1459
1516
|
reactNative.Pressable,
|
|
@@ -1467,19 +1524,21 @@ function OutlineChip(props) {
|
|
|
1467
1524
|
"aria-pressed": props.ariaPressed,
|
|
1468
1525
|
disabled,
|
|
1469
1526
|
hitSlop: CHIP_HIT_SLOP,
|
|
1470
|
-
style: layout.boxStyle,
|
|
1527
|
+
style: [sized.hitBox, layout.boxStyle],
|
|
1471
1528
|
tabIndex: props.tabIndex,
|
|
1472
1529
|
testID,
|
|
1473
1530
|
onHoverIn: () => setHovered(true),
|
|
1474
1531
|
onHoverOut: () => setHovered(false),
|
|
1475
1532
|
onPress,
|
|
1476
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chipStyles.chipOutline, { borderColor, backgroundColor }, layout.boxStyle], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1533
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chipStyles.chipOutline, sized.visual, { borderColor, backgroundColor: fill.backgroundColor }, layout.boxStyle], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1477
1534
|
ChipContent,
|
|
1478
1535
|
{
|
|
1536
|
+
checkColor: fill.checkColor,
|
|
1537
|
+
checkTestID: `${testID}-check`,
|
|
1479
1538
|
icon: option.icon,
|
|
1480
1539
|
label: option.label,
|
|
1481
1540
|
numberOfLines: layout.numberOfLines,
|
|
1482
|
-
textStyle: [chipStyles.chipText, chipStyles.chipTextOutline, { color: textColor }, layout.textStyle]
|
|
1541
|
+
textStyle: [chipStyles.chipText, chipStyles.chipTextOutline, sized.text, { color: fill.textColor }, layout.textStyle]
|
|
1483
1542
|
}
|
|
1484
1543
|
) })
|
|
1485
1544
|
}
|
|
@@ -1487,8 +1546,13 @@ function OutlineChip(props) {
|
|
|
1487
1546
|
}
|
|
1488
1547
|
function SolidChip(props) {
|
|
1489
1548
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1549
|
+
const fill = chipFill({
|
|
1550
|
+
selected,
|
|
1551
|
+
selectedFill: props.selectedFill,
|
|
1552
|
+
ink: colors.textStrong,
|
|
1553
|
+
rest: { backgroundColor: selected ? colors.primary : TRANSPARENT_COLOR, textColor: selected ? colors.onPrimary : colors.textStrong }
|
|
1554
|
+
});
|
|
1555
|
+
const sized = chipSizeLook(props.size);
|
|
1492
1556
|
const layout = chipLabelLayout(option.labelWrap);
|
|
1493
1557
|
const rovingTabStop = { tabIndex: props.tabIndex };
|
|
1494
1558
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1503,17 +1567,19 @@ function SolidChip(props) {
|
|
|
1503
1567
|
"aria-pressed": props.ariaPressed,
|
|
1504
1568
|
disabled,
|
|
1505
1569
|
hitSlop: CHIP_HIT_SLOP,
|
|
1506
|
-
style: layout.boxStyle,
|
|
1570
|
+
style: [sized.hitBox, layout.boxStyle],
|
|
1507
1571
|
testID,
|
|
1508
1572
|
onPress,
|
|
1509
1573
|
...rovingTabStop,
|
|
1510
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chipStyles.chip, { borderColor: colors.border, backgroundColor }, layout.boxStyle], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1574
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chipStyles.chip, sized.visual, { borderColor: colors.border, backgroundColor: fill.backgroundColor }, layout.boxStyle], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1511
1575
|
ChipContent,
|
|
1512
1576
|
{
|
|
1577
|
+
checkColor: fill.checkColor,
|
|
1578
|
+
checkTestID: `${testID}-check`,
|
|
1513
1579
|
icon: option.icon,
|
|
1514
1580
|
label: option.label,
|
|
1515
1581
|
numberOfLines: layout.numberOfLines,
|
|
1516
|
-
textStyle: [chipStyles.chipText, { color: textColor }, layout.textStyle]
|
|
1582
|
+
textStyle: [chipStyles.chipText, sized.text, { color: fill.textColor }, layout.textStyle]
|
|
1517
1583
|
}
|
|
1518
1584
|
) })
|
|
1519
1585
|
}
|
|
@@ -1549,8 +1615,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
|
|
|
1549
1615
|
var NO_GROUP_PROPS = {};
|
|
1550
1616
|
function useRadioKeyboard(config) {
|
|
1551
1617
|
const { enabled, disabled, values, selectedIndex, onChange } = config;
|
|
1552
|
-
const nodes =
|
|
1553
|
-
const chipRef =
|
|
1618
|
+
const nodes = React38__default.default.useRef([]);
|
|
1619
|
+
const chipRef = React38__default.default.useCallback((index) => (node) => {
|
|
1554
1620
|
nodes.current[index] = node;
|
|
1555
1621
|
}, []);
|
|
1556
1622
|
const onKeyDown = (event) => {
|
|
@@ -1658,12 +1724,14 @@ var ChipSelector = ({
|
|
|
1658
1724
|
testID,
|
|
1659
1725
|
chipTestIDPrefix = DEFAULT_CHIP_TESTID_PREFIX,
|
|
1660
1726
|
optionAccessibilityHint,
|
|
1661
|
-
singleSelectRole = "button"
|
|
1727
|
+
singleSelectRole = "button",
|
|
1728
|
+
size = "default",
|
|
1729
|
+
selectedFill
|
|
1662
1730
|
}) => {
|
|
1663
1731
|
const isRadioGroup = !multiple && singleSelectRole === "radio";
|
|
1664
1732
|
const { theme } = uiFeedback.useUi();
|
|
1665
1733
|
const { colors, palette } = theme;
|
|
1666
|
-
const chipColors =
|
|
1734
|
+
const chipColors = React38__default.default.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
|
|
1667
1735
|
function isSelected(optionValue) {
|
|
1668
1736
|
if (multiple && Array.isArray(value))
|
|
1669
1737
|
return value.includes(optionValue);
|
|
@@ -1683,6 +1751,8 @@ var ChipSelector = ({
|
|
|
1683
1751
|
disabled,
|
|
1684
1752
|
option,
|
|
1685
1753
|
selected,
|
|
1754
|
+
size,
|
|
1755
|
+
selectedFill,
|
|
1686
1756
|
...chipIdentity(option, selected, {
|
|
1687
1757
|
prefix: chipTestIDPrefix,
|
|
1688
1758
|
hint: optionAccessibilityHint,
|
|
@@ -1759,12 +1829,12 @@ var FormSwitch = ({
|
|
|
1759
1829
|
accessibilityHint
|
|
1760
1830
|
}) => {
|
|
1761
1831
|
const { theme } = uiFeedback.useUi();
|
|
1762
|
-
const toggle2 =
|
|
1832
|
+
const toggle2 = React38__default.default.useCallback(() => {
|
|
1763
1833
|
if (!disabled) onValueChange(!value);
|
|
1764
1834
|
}, [disabled, onValueChange, value]);
|
|
1765
1835
|
const { colors } = theme;
|
|
1766
1836
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1767
|
-
const themeStyles =
|
|
1837
|
+
const themeStyles = React38__default.default.useMemo(() => {
|
|
1768
1838
|
const labelStyle = { color: colors.text };
|
|
1769
1839
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1770
1840
|
return { label: labelStyle, description: descriptionStyle };
|
|
@@ -1893,8 +1963,8 @@ var FormCheckbox = ({
|
|
|
1893
1963
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
1894
1964
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
1895
1965
|
const { hintId } = useFieldIds();
|
|
1896
|
-
const [focused, setFocused] =
|
|
1897
|
-
const themeStyles =
|
|
1966
|
+
const [focused, setFocused] = React38__default.default.useState(false);
|
|
1967
|
+
const themeStyles = React38__default.default.useMemo(() => {
|
|
1898
1968
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
1899
1969
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
1900
1970
|
const ring = { borderColor: brand };
|
|
@@ -2019,9 +2089,9 @@ function nextHighlight(current, count, delta) {
|
|
|
2019
2089
|
var FORWARD = 1;
|
|
2020
2090
|
var BACKWARD = -1;
|
|
2021
2091
|
function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
2022
|
-
const [row, setRow] =
|
|
2092
|
+
const [row, setRow] = React38.useState(NO_HIGHLIGHT);
|
|
2023
2093
|
const highlighted = isOpen ? options[row] : void 0;
|
|
2024
|
-
|
|
2094
|
+
React38.useEffect(() => {
|
|
2025
2095
|
if (!isOpen) setRow(NO_HIGHLIGHT);
|
|
2026
2096
|
}, [isOpen]);
|
|
2027
2097
|
const onKeyDown = (event) => {
|
|
@@ -2066,22 +2136,22 @@ function MenuSelectControl({
|
|
|
2066
2136
|
}) {
|
|
2067
2137
|
const { theme } = uiFeedback.useUi();
|
|
2068
2138
|
const { colors, palette } = theme;
|
|
2069
|
-
const anchorRef =
|
|
2070
|
-
const [isOpen, setIsOpen] =
|
|
2071
|
-
const selectedLabel =
|
|
2139
|
+
const anchorRef = React38.useRef(null);
|
|
2140
|
+
const [isOpen, setIsOpen] = React38.useState(false);
|
|
2141
|
+
const selectedLabel = React38.useMemo(() => {
|
|
2072
2142
|
const found = options.find((o) => o.value === value);
|
|
2073
2143
|
return found?.label ?? placeholder;
|
|
2074
2144
|
}, [options, placeholder, value]);
|
|
2075
|
-
const close =
|
|
2145
|
+
const close = React38.useCallback(() => {
|
|
2076
2146
|
setIsOpen(false);
|
|
2077
2147
|
}, []);
|
|
2078
|
-
const open =
|
|
2148
|
+
const open = React38.useCallback(() => {
|
|
2079
2149
|
setIsOpen(true);
|
|
2080
2150
|
}, []);
|
|
2081
|
-
const toggle2 =
|
|
2151
|
+
const toggle2 = React38.useCallback(() => {
|
|
2082
2152
|
setIsOpen((prev) => !prev);
|
|
2083
2153
|
}, []);
|
|
2084
|
-
const select =
|
|
2154
|
+
const select = React38.useCallback(
|
|
2085
2155
|
(next) => {
|
|
2086
2156
|
onChange(next);
|
|
2087
2157
|
setIsOpen(false);
|
|
@@ -2138,10 +2208,11 @@ var SelectField = ({
|
|
|
2138
2208
|
value,
|
|
2139
2209
|
options,
|
|
2140
2210
|
onChange,
|
|
2141
|
-
testID
|
|
2211
|
+
testID,
|
|
2212
|
+
labelVariant
|
|
2142
2213
|
}) => {
|
|
2143
2214
|
const selected = options.find((option) => option.value === value)?.label ?? "";
|
|
2144
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Field, { label, children: ({ labelId }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2215
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Field, { label, labelVariant, children: ({ labelId }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2145
2216
|
SelectControl,
|
|
2146
2217
|
{
|
|
2147
2218
|
accessibilityHint,
|
|
@@ -2154,19 +2225,158 @@ var SelectField = ({
|
|
|
2154
2225
|
}
|
|
2155
2226
|
) });
|
|
2156
2227
|
};
|
|
2228
|
+
var REMOVE_GLYPH = "\xD7";
|
|
2229
|
+
var CHIP_GAP = 4;
|
|
2230
|
+
var CHIP_PAD_H = 8;
|
|
2231
|
+
var CHIP_PAD_V = 4;
|
|
2232
|
+
var CHIP_RADIUS = 999;
|
|
2233
|
+
var CHIP_FONT = 13;
|
|
2234
|
+
var styles16 = reactNative.StyleSheet.create({
|
|
2235
|
+
chip: {
|
|
2236
|
+
flexDirection: "row",
|
|
2237
|
+
alignItems: "center",
|
|
2238
|
+
gap: CHIP_GAP,
|
|
2239
|
+
paddingHorizontal: CHIP_PAD_H,
|
|
2240
|
+
paddingVertical: CHIP_PAD_V,
|
|
2241
|
+
borderWidth: 1,
|
|
2242
|
+
borderRadius: CHIP_RADIUS,
|
|
2243
|
+
maxWidth: "100%"
|
|
2244
|
+
},
|
|
2245
|
+
text: { fontSize: CHIP_FONT, flexShrink: 1 }
|
|
2246
|
+
});
|
|
2247
|
+
function SelectedChip({ option, colors, removeLabel, removeHint, onRemove, testID }) {
|
|
2248
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2249
|
+
reactNative.Pressable,
|
|
2250
|
+
{
|
|
2251
|
+
accessibilityHint: removeHint,
|
|
2252
|
+
accessibilityLabel: removeLabel,
|
|
2253
|
+
accessibilityRole: "button",
|
|
2254
|
+
hitSlop: CHIP_HIT_SLOP,
|
|
2255
|
+
style: [styles16.chip, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
2256
|
+
testID,
|
|
2257
|
+
onPress: () => onRemove(option.value),
|
|
2258
|
+
children: [
|
|
2259
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles16.text, { color: colors.text }], children: option.label }),
|
|
2260
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [styles16.text, { color: colors.text }], children: REMOVE_GLYPH })
|
|
2261
|
+
]
|
|
2262
|
+
}
|
|
2263
|
+
);
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
// src/MultiSelectField/utils/multiSelectValues.ts
|
|
2267
|
+
function addValue(values, value) {
|
|
2268
|
+
return values.includes(value) ? [...values] : [...values, value];
|
|
2269
|
+
}
|
|
2270
|
+
function removeValue(values, value) {
|
|
2271
|
+
return values.filter((current) => current !== value);
|
|
2272
|
+
}
|
|
2273
|
+
function selectedOptions(options, values) {
|
|
2274
|
+
return values.flatMap((value) => options.filter((option) => option.value === value));
|
|
2275
|
+
}
|
|
2276
|
+
function remainingOptions(options, values) {
|
|
2277
|
+
return options.filter((option) => !values.includes(option.value));
|
|
2278
|
+
}
|
|
2279
|
+
var CHEVRON_DOWN2 = "\u25BE";
|
|
2280
|
+
var CHEVRON_UP2 = "\u25B4";
|
|
2281
|
+
var BOX_GAP = 6;
|
|
2282
|
+
var TRIGGER_MIN_WIDTH = 96;
|
|
2283
|
+
var styles17 = reactNative.StyleSheet.create({
|
|
2284
|
+
box: { flexWrap: "wrap", justifyContent: "flex-start", gap: BOX_GAP },
|
|
2285
|
+
trigger: {
|
|
2286
|
+
flexGrow: 1,
|
|
2287
|
+
flexDirection: "row",
|
|
2288
|
+
alignItems: "center",
|
|
2289
|
+
justifyContent: "space-between",
|
|
2290
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
2291
|
+
minWidth: TRIGGER_MIN_WIDTH
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
function MultiSelectBox(props) {
|
|
2295
|
+
const { label, accessibilityHint, values, options, onChange, placeholder, chipLabels, testID, labelId } = props;
|
|
2296
|
+
const { colors, palette } = uiFeedback.useUi().theme;
|
|
2297
|
+
const anchorRef = React38.useRef(null);
|
|
2298
|
+
const [isOpen, setIsOpen] = React38.useState(false);
|
|
2299
|
+
const chosen = selectedOptions(options, values);
|
|
2300
|
+
const remaining = remainingOptions(options, values);
|
|
2301
|
+
const close = React38.useCallback(() => {
|
|
2302
|
+
setIsOpen(false);
|
|
2303
|
+
}, []);
|
|
2304
|
+
const toggle2 = React38.useCallback(() => {
|
|
2305
|
+
setIsOpen((prev) => !prev);
|
|
2306
|
+
}, []);
|
|
2307
|
+
const add = React38.useCallback((next) => {
|
|
2308
|
+
onChange(addValue(values, next));
|
|
2309
|
+
setIsOpen(false);
|
|
2310
|
+
}, [onChange, values]);
|
|
2311
|
+
const remove = React38.useCallback((value) => {
|
|
2312
|
+
onChange(removeValue(values, value));
|
|
2313
|
+
}, [onChange, values]);
|
|
2314
|
+
const chipColors = { text: colors.text, border: colors.border, surface: colors.surface };
|
|
2315
|
+
const summary = chosen.map((option) => option.label).join(", ");
|
|
2316
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: controlStyles.anchor, children: [
|
|
2317
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.selectTrigger, styles17.box, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], testID: `${testID}-box`, children: [
|
|
2318
|
+
chosen.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2319
|
+
SelectedChip,
|
|
2320
|
+
{
|
|
2321
|
+
colors: chipColors,
|
|
2322
|
+
option,
|
|
2323
|
+
removeHint: chipLabels.removeHint,
|
|
2324
|
+
removeLabel: chipLabels.removeLabel(option.label),
|
|
2325
|
+
testID: `${testID}-chip-${option.value}`,
|
|
2326
|
+
onRemove: remove
|
|
2327
|
+
},
|
|
2328
|
+
option.value
|
|
2329
|
+
)),
|
|
2330
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2331
|
+
reactNative.Pressable,
|
|
2332
|
+
{
|
|
2333
|
+
accessibilityHint,
|
|
2334
|
+
accessibilityLabel: `${label}: ${summary}`,
|
|
2335
|
+
accessibilityRole: "button",
|
|
2336
|
+
accessibilityState: { expanded: isOpen, disabled: remaining.length === 0 },
|
|
2337
|
+
"aria-expanded": isOpen,
|
|
2338
|
+
"aria-haspopup": "menu",
|
|
2339
|
+
"aria-labelledby": labelId,
|
|
2340
|
+
disabled: remaining.length === 0,
|
|
2341
|
+
style: styles17.trigger,
|
|
2342
|
+
testID: `${testID}-trigger`,
|
|
2343
|
+
onPress: toggle2,
|
|
2344
|
+
children: [
|
|
2345
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: colors.textSecondary }], children: placeholder }),
|
|
2346
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: isOpen ? CHEVRON_UP2 : CHEVRON_DOWN2 })
|
|
2347
|
+
]
|
|
2348
|
+
}
|
|
2349
|
+
)
|
|
2350
|
+
] }),
|
|
2351
|
+
isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2352
|
+
AnchoredMenu,
|
|
2353
|
+
{
|
|
2354
|
+
anchorRef,
|
|
2355
|
+
colors: { text: colors.text, border: colors.border, surface: colors.surface, brand: palette.primary["500"] },
|
|
2356
|
+
optionHint: accessibilityHint,
|
|
2357
|
+
options: remaining,
|
|
2358
|
+
selectedValue: "",
|
|
2359
|
+
testID,
|
|
2360
|
+
onDismiss: close,
|
|
2361
|
+
onSelect: add
|
|
2362
|
+
}
|
|
2363
|
+
) : null
|
|
2364
|
+
] });
|
|
2365
|
+
}
|
|
2366
|
+
var MultiSelectField = ({ labelVariant, hint, error, ...boxProps }) => /* @__PURE__ */ jsxRuntime.jsx(Field, { error, hint, label: boxProps.label, labelVariant, children: ({ labelId }) => /* @__PURE__ */ jsxRuntime.jsx(MultiSelectBox, { ...boxProps, labelId }) });
|
|
2157
2367
|
var CLOSE_DELAY_MS2 = 140;
|
|
2158
2368
|
function useDelayedBlurClose(open, close) {
|
|
2159
|
-
const timerRef =
|
|
2160
|
-
const cancelClose =
|
|
2369
|
+
const timerRef = React38.useRef(null);
|
|
2370
|
+
const cancelClose = React38.useCallback(() => {
|
|
2161
2371
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
2162
2372
|
timerRef.current = null;
|
|
2163
2373
|
}, []);
|
|
2164
|
-
|
|
2165
|
-
const handleFocus =
|
|
2374
|
+
React38.useEffect(() => cancelClose, [cancelClose]);
|
|
2375
|
+
const handleFocus = React38.useCallback(() => {
|
|
2166
2376
|
cancelClose();
|
|
2167
2377
|
open();
|
|
2168
2378
|
}, [cancelClose, open]);
|
|
2169
|
-
const handleBlur =
|
|
2379
|
+
const handleBlur = React38.useCallback(() => {
|
|
2170
2380
|
cancelClose();
|
|
2171
2381
|
timerRef.current = setTimeout(close, CLOSE_DELAY_MS2);
|
|
2172
2382
|
}, [cancelClose, close]);
|
|
@@ -2209,10 +2419,10 @@ function isUnmatched(options, text) {
|
|
|
2209
2419
|
var DEFAULT_TYPEAHEAD_DEBOUNCE_MS = 250;
|
|
2210
2420
|
var IDLE = { results: [], isLoading: false, hasFailed: false, hasSettled: false };
|
|
2211
2421
|
function useTypeaheadSearch(load, query, enabled, debounceMs) {
|
|
2212
|
-
const [state, setState] =
|
|
2213
|
-
const loadRef =
|
|
2422
|
+
const [state, setState] = React38.useState(IDLE);
|
|
2423
|
+
const loadRef = React38.useRef(load);
|
|
2214
2424
|
loadRef.current = load;
|
|
2215
|
-
|
|
2425
|
+
React38.useEffect(() => {
|
|
2216
2426
|
if (!enabled) {
|
|
2217
2427
|
setState(IDLE);
|
|
2218
2428
|
return void 0;
|
|
@@ -2251,30 +2461,30 @@ function useTypeaheadRows(input, isOpen, isPicked) {
|
|
|
2251
2461
|
const query = value.trim();
|
|
2252
2462
|
const isSearching = search !== void 0 && isOpen && !isPicked && query.length >= minChars;
|
|
2253
2463
|
const found = useTypeaheadSearch(search?.load, query, isSearching, search?.debounceMs ?? DEFAULT_TYPEAHEAD_DEBOUNCE_MS);
|
|
2254
|
-
const staticRows =
|
|
2464
|
+
const staticRows = React38.useMemo(() => {
|
|
2255
2465
|
if (options === void 0 || options.some((o) => o.label === value)) return NO_ROWS;
|
|
2256
2466
|
return suggestOptions(options, value, minChars, maxSuggestions);
|
|
2257
2467
|
}, [options, value, minChars, maxSuggestions]);
|
|
2258
|
-
const foundRows =
|
|
2468
|
+
const foundRows = React38.useMemo(() => found.results.slice(0, maxSuggestions), [found.results, maxSuggestions]);
|
|
2259
2469
|
if (search === void 0) return { rows: staticRows, statusText: void 0 };
|
|
2260
2470
|
return { rows: foundRows, statusText: searchStatusText(found, search) };
|
|
2261
2471
|
}
|
|
2262
2472
|
function useTypeaheadState(input) {
|
|
2263
2473
|
const { search, value, onChange, onSubmit } = input;
|
|
2264
|
-
const [isOpen, setIsOpen] =
|
|
2265
|
-
const [picked, setPicked] =
|
|
2266
|
-
const [highlightIndex, setHighlightIndex] =
|
|
2474
|
+
const [isOpen, setIsOpen] = React38.useState(false);
|
|
2475
|
+
const [picked, setPicked] = React38.useState(null);
|
|
2476
|
+
const [highlightIndex, setHighlightIndex] = React38.useState(NO_HIGHLIGHT);
|
|
2267
2477
|
const { rows, statusText } = useTypeaheadRows(input, isOpen, picked !== null && picked.label === value);
|
|
2268
2478
|
const rowKey = rows.map((row) => row.value).join("\n");
|
|
2269
2479
|
const highlighted = isOpen ? rows[highlightIndex] : void 0;
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
const open =
|
|
2273
|
-
const close =
|
|
2480
|
+
React38.useEffect(() => setHighlightIndex(NO_HIGHLIGHT), [rowKey]);
|
|
2481
|
+
React38.useEffect(() => setPicked((current) => current !== null && current.label !== value ? null : current), [value]);
|
|
2482
|
+
const open = React38.useCallback(() => setIsOpen(true), []);
|
|
2483
|
+
const close = React38.useCallback(() => {
|
|
2274
2484
|
setIsOpen(false);
|
|
2275
2485
|
setHighlightIndex(NO_HIGHLIGHT);
|
|
2276
2486
|
}, []);
|
|
2277
|
-
const pick =
|
|
2487
|
+
const pick = React38.useCallback(
|
|
2278
2488
|
(option) => {
|
|
2279
2489
|
setPicked(option);
|
|
2280
2490
|
onChange(option.label);
|
|
@@ -2283,14 +2493,14 @@ function useTypeaheadState(input) {
|
|
|
2283
2493
|
},
|
|
2284
2494
|
[onChange, search, close]
|
|
2285
2495
|
);
|
|
2286
|
-
const selectValue =
|
|
2496
|
+
const selectValue = React38.useCallback(
|
|
2287
2497
|
(optionValue) => {
|
|
2288
2498
|
const option = rows.find((row) => row.value === optionValue);
|
|
2289
2499
|
if (option !== void 0) pick(option);
|
|
2290
2500
|
},
|
|
2291
2501
|
[rows, pick]
|
|
2292
2502
|
);
|
|
2293
|
-
const handleChange =
|
|
2503
|
+
const handleChange = React38.useCallback(
|
|
2294
2504
|
(next) => {
|
|
2295
2505
|
if (picked !== null) {
|
|
2296
2506
|
setPicked(null);
|
|
@@ -2303,7 +2513,7 @@ function useTypeaheadState(input) {
|
|
|
2303
2513
|
[picked, search, onChange]
|
|
2304
2514
|
);
|
|
2305
2515
|
const handleKeyPress = useTypeaheadKeys({ rowCount: rows.length, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick });
|
|
2306
|
-
const handleSubmit =
|
|
2516
|
+
const handleSubmit = React38.useCallback(() => {
|
|
2307
2517
|
if (highlighted !== void 0) {
|
|
2308
2518
|
pick(highlighted);
|
|
2309
2519
|
return;
|
|
@@ -2315,7 +2525,7 @@ function useTypeaheadState(input) {
|
|
|
2315
2525
|
}
|
|
2316
2526
|
function useTypeaheadKeys(input) {
|
|
2317
2527
|
const { rowCount, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick } = input;
|
|
2318
|
-
return
|
|
2528
|
+
return React38.useCallback(
|
|
2319
2529
|
(event) => {
|
|
2320
2530
|
const { key } = event.nativeEvent;
|
|
2321
2531
|
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
@@ -2352,7 +2562,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2352
2562
|
const maxSuggestions = ("search" in props ? props.search.maxResults : props.maxSuggestions) ?? DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
|
|
2353
2563
|
const { theme } = uiFeedback.useUi();
|
|
2354
2564
|
const { colors, palette } = theme;
|
|
2355
|
-
const anchorRef =
|
|
2565
|
+
const anchorRef = React38.useRef(null);
|
|
2356
2566
|
const state = useTypeaheadState({ options, search, value, minChars, maxSuggestions, onChange, onSubmit });
|
|
2357
2567
|
const { handleFocus, handleBlur } = useDelayedBlurClose(state.open, state.close);
|
|
2358
2568
|
const showMenu = state.isOpen && (state.rows.length > 0 || state.statusText !== void 0);
|
|
@@ -2405,7 +2615,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2405
2615
|
hasError ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [controlStyles.error, { color: fieldErrorInk(theme) }], testID: `${testID}-error`, children: error }) : null
|
|
2406
2616
|
] });
|
|
2407
2617
|
}
|
|
2408
|
-
var TypeaheadControl =
|
|
2618
|
+
var TypeaheadControl = React38.forwardRef(TypeaheadControlImpl);
|
|
2409
2619
|
var NATIVE_INPUT_BOX = {
|
|
2410
2620
|
borderStyle: "solid",
|
|
2411
2621
|
boxSizing: "border-box",
|
|
@@ -2493,7 +2703,7 @@ function tabStops(container) {
|
|
|
2493
2703
|
}
|
|
2494
2704
|
function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
2495
2705
|
const colors = usePickerColors();
|
|
2496
|
-
const ref =
|
|
2706
|
+
const ref = React38.useRef(null);
|
|
2497
2707
|
const onKeyDown = (event) => {
|
|
2498
2708
|
if (event.key === "Escape") {
|
|
2499
2709
|
event.preventDefault();
|
|
@@ -2516,8 +2726,8 @@ function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
|
2516
2726
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-testid": testID, "data-variant": sheet ? "sheet" : "popover", style, onKeyDown, children });
|
|
2517
2727
|
}
|
|
2518
2728
|
function useAnchorRect2(anchorRef) {
|
|
2519
|
-
const [rect2, setRect] =
|
|
2520
|
-
|
|
2729
|
+
const [rect2, setRect] = React38.useState(null);
|
|
2730
|
+
React38.useEffect(() => {
|
|
2521
2731
|
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2522
2732
|
}, [anchorRef]);
|
|
2523
2733
|
return rect2;
|
|
@@ -2560,32 +2770,32 @@ function fitDropdownWidth(frame, viewportWidth, minWidth = MIN_PANEL_WIDTH) {
|
|
|
2560
2770
|
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children, minWidth, scale, accessibilityLabel, preferBelow = false }) {
|
|
2561
2771
|
const { height: viewportHeight, width: viewportWidth } = reactNative.useWindowDimensions();
|
|
2562
2772
|
const anchor = useAnchorRect2(anchorRef);
|
|
2563
|
-
const [panelHeight, setPanelHeight] =
|
|
2564
|
-
const onLayout =
|
|
2773
|
+
const [panelHeight, setPanelHeight] = React38.useState(0);
|
|
2774
|
+
const onLayout = React38.useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2565
2775
|
const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight, preferBelow), viewportWidth, minWidth);
|
|
2566
2776
|
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2567
2777
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: [
|
|
2568
2778
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2569
|
-
frame !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [
|
|
2779
|
+
frame !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles18.dropdown, place, { opacity: progress, transform: scale === void 0 ? [{ translateY }] : [{ translateY }, { scale }] }, scale === void 0 ? null : styles18.growFromField], testID: `${testID}-dropdown-${frame.placement}`, onLayout, children }) : null
|
|
2570
2780
|
] });
|
|
2571
2781
|
}
|
|
2572
|
-
var
|
|
2782
|
+
var styles18 = reactNative.StyleSheet.create({
|
|
2573
2783
|
dropdown: { position: "absolute" },
|
|
2574
2784
|
growFromField: { transformOrigin: "top left" }
|
|
2575
2785
|
});
|
|
2576
2786
|
function SheetSurface({ translateY, onDismiss, closeLabel, closeHint, testID, children, progress, scale, accessibilityLabel }) {
|
|
2577
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2787
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles19.backdrop, children: [
|
|
2578
2788
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2579
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { testID: `${testID}-sheet`, style: [
|
|
2789
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { testID: `${testID}-sheet`, style: [styles19.sheet, { transform: scale === void 0 ? [{ translateY }] : [{ translateY }, { scale }] }, progress === void 0 ? null : { opacity: progress }], children })
|
|
2580
2790
|
] }) });
|
|
2581
2791
|
}
|
|
2582
|
-
var
|
|
2792
|
+
var styles19 = reactNative.StyleSheet.create({
|
|
2583
2793
|
backdrop: { flex: 1, justifyContent: "flex-end" },
|
|
2584
2794
|
sheet: { width: "100%", alignSelf: "stretch" }
|
|
2585
2795
|
});
|
|
2586
2796
|
function useReducedMotion() {
|
|
2587
|
-
const [reduced, setReduced] =
|
|
2588
|
-
|
|
2797
|
+
const [reduced, setReduced] = React38.useState(false);
|
|
2798
|
+
React38.useEffect(() => {
|
|
2589
2799
|
let active = true;
|
|
2590
2800
|
reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
2591
2801
|
if (active) setReduced(value);
|
|
@@ -2796,14 +3006,14 @@ function weekFirstDay(locale) {
|
|
|
2796
3006
|
return MONDAY3;
|
|
2797
3007
|
}
|
|
2798
3008
|
}
|
|
2799
|
-
var DatePickerContext =
|
|
3009
|
+
var DatePickerContext = React38.createContext({ labels: DEFAULT_DATE_PICKER_LABELS });
|
|
2800
3010
|
function DatePickerProvider({ labels, locale, today, display, children }) {
|
|
2801
|
-
const value =
|
|
3011
|
+
const value = React38.useMemo(() => ({ labels: { ...DEFAULT_DATE_PICKER_LABELS, ...labels }, locale, today, display }), [labels, locale, today, display]);
|
|
2802
3012
|
return /* @__PURE__ */ jsxRuntime.jsx(DatePickerContext.Provider, { value, children });
|
|
2803
3013
|
}
|
|
2804
3014
|
function useDatePickerConfig() {
|
|
2805
|
-
const config =
|
|
2806
|
-
const firstDay =
|
|
3015
|
+
const config = React38.useContext(DatePickerContext);
|
|
3016
|
+
const firstDay = React38.useMemo(() => weekFirstDay(config.locale), [config.locale]);
|
|
2807
3017
|
return { labels: config.labels, locale: config.locale, today: config.today ?? todayIso(), firstDay, display: config.display ?? "long" /* Long */ };
|
|
2808
3018
|
}
|
|
2809
3019
|
|
|
@@ -2826,8 +3036,8 @@ function monthSlideStyle(entered, reduced, direction) {
|
|
|
2826
3036
|
}
|
|
2827
3037
|
function useOpenProgress() {
|
|
2828
3038
|
const { durationMs, fromScale } = resolveOpenMotion(useReducedMotion());
|
|
2829
|
-
const progress =
|
|
2830
|
-
|
|
3039
|
+
const progress = React38.useRef(new reactNative.Animated.Value(0)).current;
|
|
3040
|
+
React38.useEffect(() => {
|
|
2831
3041
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
2832
3042
|
}, [progress, durationMs]);
|
|
2833
3043
|
return {
|
|
@@ -2873,16 +3083,16 @@ function dayDomId(testID, iso) {
|
|
|
2873
3083
|
}
|
|
2874
3084
|
function useGridFocus(initial, bounds, testID, onPick) {
|
|
2875
3085
|
const { firstDay } = useDatePickerConfig();
|
|
2876
|
-
const [focusedDay, setFocusedDay] =
|
|
2877
|
-
const focusPending =
|
|
3086
|
+
const [focusedDay, setFocusedDay] = React38.useState(initial);
|
|
3087
|
+
const focusPending = React38.useRef(true);
|
|
2878
3088
|
const { min, max } = bounds;
|
|
2879
|
-
|
|
3089
|
+
React38.useEffect(() => {
|
|
2880
3090
|
if (!focusPending.current) return;
|
|
2881
3091
|
focusPending.current = false;
|
|
2882
3092
|
document.getElementById(dayDomId(testID, focusedDay))?.focus();
|
|
2883
3093
|
}, [focusedDay, testID]);
|
|
2884
|
-
const moveTo =
|
|
2885
|
-
const onDayKey =
|
|
3094
|
+
const moveTo = React38.useCallback((iso) => setFocusedDay(clampToBounds(iso, min, max)), [min, max]);
|
|
3095
|
+
const onDayKey = React38.useCallback(
|
|
2886
3096
|
(event, iso) => {
|
|
2887
3097
|
if (event.key === "Enter" || event.key === " ") {
|
|
2888
3098
|
event.preventDefault();
|
|
@@ -2969,8 +3179,8 @@ function MonthGrid({ month, selection: selection2, focusedDay, bounds, testID, o
|
|
|
2969
3179
|
const { labels, locale, today, firstDay } = useDatePickerConfig();
|
|
2970
3180
|
const colors = usePickerColors();
|
|
2971
3181
|
const parts = parseIso(month) ?? FALLBACK;
|
|
2972
|
-
const weeks =
|
|
2973
|
-
const weekdays =
|
|
3182
|
+
const weeks = React38.useMemo(() => buildMonthGrid(parts.year, parts.month, firstDay), [parts.year, parts.month, firstDay]);
|
|
3183
|
+
const weekdays = React38.useMemo(() => weekdayNames(locale, firstDay), [locale, firstDay]);
|
|
2974
3184
|
const title = formatMonthYear(month, locale);
|
|
2975
3185
|
const end = selection2.to === "" ? selection2.from : selection2.to;
|
|
2976
3186
|
const stateOf = (iso) => ({
|
|
@@ -3009,7 +3219,7 @@ function MonthHeader({ focusedDay, bounds, testID, onMove }) {
|
|
|
3009
3219
|
const { labels, locale } = useDatePickerConfig();
|
|
3010
3220
|
const colors = usePickerColors();
|
|
3011
3221
|
const parts = parseIso(focusedDay) ?? FALLBACK2;
|
|
3012
|
-
const names =
|
|
3222
|
+
const names = React38.useMemo(() => monthNames(locale), [locale]);
|
|
3013
3223
|
const setMonthYear = (year, month) => onMove(toIso({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) }));
|
|
3014
3224
|
const selectStyle = { minHeight: a11y.MIN_TOUCH_TARGET_PX, border: "none", background: "transparent", color: colors.text, fontWeight: BOLD3, fontSize: FONT2, fontFamily: "inherit", cursor: "pointer" };
|
|
3015
3225
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
@@ -3030,8 +3240,8 @@ function PickerFooter({ summary, children }) {
|
|
|
3030
3240
|
] });
|
|
3031
3241
|
}
|
|
3032
3242
|
function useEntered(key, reduced) {
|
|
3033
|
-
const [enteredKey, setEnteredKey] =
|
|
3034
|
-
|
|
3243
|
+
const [enteredKey, setEnteredKey] = React38.useState(null);
|
|
3244
|
+
React38.useEffect(() => {
|
|
3035
3245
|
if (reduced) return void 0;
|
|
3036
3246
|
let inner = 0;
|
|
3037
3247
|
const outer = requestAnimationFrame(() => {
|
|
@@ -3046,8 +3256,8 @@ function useEntered(key, reduced) {
|
|
|
3046
3256
|
}
|
|
3047
3257
|
function useMonthSlide(month) {
|
|
3048
3258
|
const reduced = useReducedMotion();
|
|
3049
|
-
const previous =
|
|
3050
|
-
const direction =
|
|
3259
|
+
const previous = React38.useRef(month);
|
|
3260
|
+
const direction = React38.useRef(0);
|
|
3051
3261
|
if (previous.current !== month) {
|
|
3052
3262
|
direction.current = month > previous.current ? 1 : -1;
|
|
3053
3263
|
previous.current = month;
|
|
@@ -3057,7 +3267,7 @@ function useMonthSlide(month) {
|
|
|
3057
3267
|
}
|
|
3058
3268
|
function SingleCalendar({ value, bounds, testID, onCommit }) {
|
|
3059
3269
|
const { labels, today } = useDatePickerConfig();
|
|
3060
|
-
const [draft, setDraft] =
|
|
3270
|
+
const [draft, setDraft] = React38.useState(value);
|
|
3061
3271
|
const grid = useGridFocus(clampToBounds(value !== "" ? value : today, bounds.min, bounds.max), bounds, testID, setDraft);
|
|
3062
3272
|
const month = monthStart(grid.focusedDay);
|
|
3063
3273
|
const motion = useMonthSlide(month);
|
|
@@ -3078,8 +3288,8 @@ function useIsPhone() {
|
|
|
3078
3288
|
return !isWideFormLayout(reactNative.useWindowDimensions().width);
|
|
3079
3289
|
}
|
|
3080
3290
|
function useReturnFocus(open, target) {
|
|
3081
|
-
const wasOpen =
|
|
3082
|
-
|
|
3291
|
+
const wasOpen = React38.useRef(open);
|
|
3292
|
+
React38.useEffect(() => {
|
|
3083
3293
|
const closed = wasOpen.current && !open;
|
|
3084
3294
|
wasOpen.current = open;
|
|
3085
3295
|
if (!closed) return void 0;
|
|
@@ -3089,9 +3299,9 @@ function useReturnFocus(open, target) {
|
|
|
3089
3299
|
}
|
|
3090
3300
|
function useTypedDate({ value, onChange, bounds, format, onError, rangeMessage, editOnType = false }) {
|
|
3091
3301
|
const { labels, locale } = useDatePickerConfig();
|
|
3092
|
-
const [editing, setEditing] =
|
|
3093
|
-
const [text, setText] =
|
|
3094
|
-
|
|
3302
|
+
const [editing, setEditing] = React38.useState(false);
|
|
3303
|
+
const [text, setText] = React38.useState("");
|
|
3304
|
+
React38.useEffect(() => {
|
|
3095
3305
|
setText((current) => {
|
|
3096
3306
|
const parsed = current.trim() === "" ? "" : parseTyped(current, locale);
|
|
3097
3307
|
if (parsed === null || parsed === value) return current;
|
|
@@ -3211,16 +3421,16 @@ function DatePickerInput({ fieldProps, context, onTypedError }) {
|
|
|
3211
3421
|
const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
|
|
3212
3422
|
const { labels, display } = useDatePickerConfig();
|
|
3213
3423
|
const phone = useIsPhone();
|
|
3214
|
-
const [open, setOpen] =
|
|
3215
|
-
const anchorRef =
|
|
3216
|
-
const inputRef =
|
|
3424
|
+
const [open, setOpen] = React38.useState(false);
|
|
3425
|
+
const anchorRef = React38.useRef(null);
|
|
3426
|
+
const inputRef = React38.useRef(null);
|
|
3217
3427
|
const bounds = { min, max };
|
|
3218
3428
|
const typed = useTypedDate({ value, onChange, bounds, format: displayFormatter(display), onError: onTypedError, editOnType: true });
|
|
3219
3429
|
const edit = typedEditBind(typed);
|
|
3220
3430
|
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
|
|
3221
3431
|
const focus = focusBind;
|
|
3222
3432
|
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError, required });
|
|
3223
|
-
const close =
|
|
3433
|
+
const close = React38.useCallback(() => setOpen(false), []);
|
|
3224
3434
|
useReturnFocus(open, inputRef);
|
|
3225
3435
|
const commit = (iso) => {
|
|
3226
3436
|
onTypedError?.(void 0);
|
|
@@ -3296,7 +3506,7 @@ function TemporalInput({ fieldProps, context, webInputType, onTypedError }) {
|
|
|
3296
3506
|
}
|
|
3297
3507
|
function TemporalField({ fieldProps, webInputType }) {
|
|
3298
3508
|
const { label, required, hint, error } = fieldProps;
|
|
3299
|
-
const [typedError, setTypedError] =
|
|
3509
|
+
const [typedError, setTypedError] = React38.useState(void 0);
|
|
3300
3510
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error: error ?? typedError, hint, label, required, children: (context) => /* @__PURE__ */ jsxRuntime.jsx(TemporalInput, { context, fieldProps, webInputType, onTypedError: setTypedError }) });
|
|
3301
3511
|
}
|
|
3302
3512
|
function DateField(props) {
|
|
@@ -3425,17 +3635,17 @@ function useRangeSummary(draft) {
|
|
|
3425
3635
|
}
|
|
3426
3636
|
function RangeCalendar({ value, bounds, phone, testID, onApply, onCancel }) {
|
|
3427
3637
|
const { labels, today } = useDatePickerConfig();
|
|
3428
|
-
const [draft, setDraft] =
|
|
3638
|
+
const [draft, setDraft] = React38.useState(value);
|
|
3429
3639
|
const initialDay = clampToBounds(value.from !== "" ? value.from : today, bounds.min, bounds.max);
|
|
3430
|
-
const pickDraft =
|
|
3640
|
+
const pickDraft = React38.useCallback((iso) => setDraft((current) => pickRangeDay(current, iso)), []);
|
|
3431
3641
|
const focus = useGridFocus(initialDay, bounds, testID, pickDraft);
|
|
3432
3642
|
const visible = phone ? PHONE_MONTHS : DESKTOP_MONTHS;
|
|
3433
|
-
const [first, setFirst] =
|
|
3643
|
+
const [first, setFirst] = React38.useState(() => monthStart(phone ? initialDay : addMonths(initialDay, 1 - DESKTOP_MONTHS)));
|
|
3434
3644
|
const focusMonth = monthStart(focus.focusedDay);
|
|
3435
3645
|
const last = addMonths(first, visible - 1);
|
|
3436
3646
|
const motion = useMonthSlide(first);
|
|
3437
3647
|
const summary = useRangeSummary(draft);
|
|
3438
|
-
|
|
3648
|
+
React38.useEffect(() => {
|
|
3439
3649
|
if (focusMonth < first) setFirst(focusMonth);
|
|
3440
3650
|
else if (focusMonth > last) setFirst(addMonths(focusMonth, 1 - visible));
|
|
3441
3651
|
}, [focusMonth, first, last, visible]);
|
|
@@ -3484,18 +3694,18 @@ function orNone(value) {
|
|
|
3484
3694
|
function WebDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, testID, context, onTypedError }) {
|
|
3485
3695
|
const { labels } = useDatePickerConfig();
|
|
3486
3696
|
const phone = useIsPhone();
|
|
3487
|
-
const [open, setOpen] =
|
|
3488
|
-
const [fromError, setFromError] =
|
|
3489
|
-
const [toError, setToError] =
|
|
3490
|
-
const anchorRef =
|
|
3491
|
-
const fromRef =
|
|
3697
|
+
const [open, setOpen] = React38.useState(false);
|
|
3698
|
+
const [fromError, setFromError] = React38.useState(void 0);
|
|
3699
|
+
const [toError, setToError] = React38.useState(void 0);
|
|
3700
|
+
const anchorRef = React38.useRef(null);
|
|
3701
|
+
const fromRef = React38.useRef(null);
|
|
3492
3702
|
const from = useTypedDate({ value: value.from, onChange: (next) => onChange({ from: next, to: value.to }), bounds: { max: orNone(value.to) }, format: formatShort, onError: setFromError, rangeMessage: labels.rangeOrder, editOnType: true });
|
|
3493
3703
|
const to = useTypedDate({ value: value.to, onChange: (next) => onChange({ from: value.from, to: next }), bounds: { min: orNone(value.from) }, format: formatShort, onError: setToError, rangeMessage: labels.rangeOrder, editOnType: true });
|
|
3494
3704
|
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: true });
|
|
3495
3705
|
const focus = focusBind;
|
|
3496
3706
|
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError });
|
|
3497
|
-
|
|
3498
|
-
const close =
|
|
3707
|
+
React38.useEffect(() => onTypedError(fromError ?? toError), [fromError, toError, onTypedError]);
|
|
3708
|
+
const close = React38.useCallback(() => setOpen(false), []);
|
|
3499
3709
|
useReturnFocus(open, fromRef);
|
|
3500
3710
|
const onKeyDown = (event) => {
|
|
3501
3711
|
if (event.key === "ArrowDown" && event.altKey) {
|
|
@@ -3579,7 +3789,7 @@ function DateRangeControl({
|
|
|
3579
3789
|
}) {
|
|
3580
3790
|
const hint = accessibilityHint ?? `${fromLabel} \u2013 ${toLabel}`;
|
|
3581
3791
|
const { labels } = useDatePickerConfig();
|
|
3582
|
-
const [typedError, setTypedError] =
|
|
3792
|
+
const [typedError, setTypedError] = React38.useState(void 0);
|
|
3583
3793
|
if (!IS_WEB9) {
|
|
3584
3794
|
return /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(NativeDateRange, { fromLabel, hint, style, testID, toLabel, value, onChange, onSubmit }) });
|
|
3585
3795
|
}
|
|
@@ -3619,7 +3829,7 @@ var ROW_GAP = 4;
|
|
|
3619
3829
|
var TAB_PADDING = 4;
|
|
3620
3830
|
var INDICATOR_WIDTH = 2;
|
|
3621
3831
|
var TAB_FONT_SIZE = 12;
|
|
3622
|
-
var
|
|
3832
|
+
var styles20 = reactNative.StyleSheet.create({
|
|
3623
3833
|
row: { flexDirection: "row", flexWrap: "nowrap", gap: ROW_GAP },
|
|
3624
3834
|
tab: {
|
|
3625
3835
|
borderBottomWidth: INDICATOR_WIDTH,
|
|
@@ -3659,13 +3869,13 @@ var StepperTab = ({
|
|
|
3659
3869
|
accessibilityRole: "tab",
|
|
3660
3870
|
accessibilityState: { selected },
|
|
3661
3871
|
"aria-selected": selected,
|
|
3662
|
-
style: [
|
|
3872
|
+
style: [styles20.tab, { borderBottomColor: indicator }, ring.ringStyle],
|
|
3663
3873
|
testID,
|
|
3664
3874
|
onBlur: ring.onBlur,
|
|
3665
3875
|
onFocus: ring.onFocus,
|
|
3666
3876
|
onPress: () => onStep(step.key),
|
|
3667
3877
|
...webKeyProps,
|
|
3668
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
3878
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.text, { color: theme.colors.text }, selected ? styles20.textSelected : void 0], children: step.label })
|
|
3669
3879
|
}
|
|
3670
3880
|
);
|
|
3671
3881
|
};
|
|
@@ -3675,7 +3885,7 @@ var StepperTabs = ({
|
|
|
3675
3885
|
onStep,
|
|
3676
3886
|
stepHint,
|
|
3677
3887
|
testID
|
|
3678
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", style:
|
|
3888
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", style: styles20.row, testID, children: steps.map((step) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3679
3889
|
StepperTab,
|
|
3680
3890
|
{
|
|
3681
3891
|
hint: stepHint,
|
|
@@ -3694,7 +3904,7 @@ function resolveStepNeighbours(steps, current) {
|
|
|
3694
3904
|
return { previous: steps[index - 1] ?? null, next: steps[index + 1] ?? null };
|
|
3695
3905
|
}
|
|
3696
3906
|
var ROW_GAP2 = 8;
|
|
3697
|
-
var
|
|
3907
|
+
var styles21 = reactNative.StyleSheet.create({
|
|
3698
3908
|
cell: { flex: 1, minWidth: 0 },
|
|
3699
3909
|
row: { flexDirection: "row", gap: ROW_GAP2 }
|
|
3700
3910
|
});
|
|
@@ -3706,8 +3916,8 @@ var StepperNav = ({
|
|
|
3706
3916
|
testID
|
|
3707
3917
|
}) => {
|
|
3708
3918
|
const { previous, next } = resolveStepNeighbours(steps, current);
|
|
3709
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
3710
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
3919
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles21.row, testID, children: [
|
|
3920
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles21.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3711
3921
|
uiButtons.Button,
|
|
3712
3922
|
{
|
|
3713
3923
|
fullWidth: true,
|
|
@@ -3723,7 +3933,7 @@ var StepperNav = ({
|
|
|
3723
3933
|
}
|
|
3724
3934
|
}
|
|
3725
3935
|
) }),
|
|
3726
|
-
next === null ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
3936
|
+
next === null ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles21.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3727
3937
|
uiButtons.Button,
|
|
3728
3938
|
{
|
|
3729
3939
|
fullWidth: true,
|
|
@@ -3738,18 +3948,18 @@ var StepperNav = ({
|
|
|
3738
3948
|
] });
|
|
3739
3949
|
};
|
|
3740
3950
|
var STATUS_FONT = 16;
|
|
3741
|
-
var
|
|
3951
|
+
var styles22 = reactNative.StyleSheet.create({
|
|
3742
3952
|
line: { fontSize: STATUS_FONT }
|
|
3743
3953
|
});
|
|
3744
3954
|
function FormStatusLine({ message, testID, style }) {
|
|
3745
3955
|
const { theme } = uiFeedback.useUi();
|
|
3746
3956
|
if (message === null || message === void 0 || message === "") return null;
|
|
3747
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
3957
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles22.line, { color: theme.colors.text }, style], testID, children: message });
|
|
3748
3958
|
}
|
|
3749
3959
|
function useFocusFirstInvalid(refs) {
|
|
3750
|
-
const latest =
|
|
3960
|
+
const latest = React38.useRef(refs);
|
|
3751
3961
|
latest.current = refs;
|
|
3752
|
-
return
|
|
3962
|
+
return React38.useCallback((invalid) => {
|
|
3753
3963
|
const first = invalid.map((field2) => latest.current[field2].current).find((node) => node !== null);
|
|
3754
3964
|
first?.focus();
|
|
3755
3965
|
}, []);
|
|
@@ -3800,10 +4010,10 @@ function withoutField(state, field2) {
|
|
|
3800
4010
|
}
|
|
3801
4011
|
function useServerFieldErrors(options) {
|
|
3802
4012
|
const { fields, refs, formatCode } = options;
|
|
3803
|
-
const [state, setState] =
|
|
4013
|
+
const [state, setState] = React38.useState(EMPTY_STATE);
|
|
3804
4014
|
const focusFirst = useFocusFirstInvalid(refs ?? NO_REFS);
|
|
3805
4015
|
const hasRefs = refs !== void 0;
|
|
3806
|
-
const apply =
|
|
4016
|
+
const apply = React38.useCallback(
|
|
3807
4017
|
(error) => {
|
|
3808
4018
|
const assigned = assignServerErrors(apiClientBase.parseFieldErrors(error), fields, formatCode);
|
|
3809
4019
|
setState({ byField: assigned.byField, formError: assigned.formError });
|
|
@@ -3814,17 +4024,17 @@ function useServerFieldErrors(options) {
|
|
|
3814
4024
|
},
|
|
3815
4025
|
[fields, formatCode, focusFirst, hasRefs]
|
|
3816
4026
|
);
|
|
3817
|
-
const clear =
|
|
3818
|
-
const reset =
|
|
3819
|
-
const errorFor =
|
|
4027
|
+
const clear = React38.useCallback((field2) => setState((current) => withoutField(current, field2)), []);
|
|
4028
|
+
const reset = React38.useCallback(() => setState(EMPTY_STATE), []);
|
|
4029
|
+
const errorFor = React38.useCallback((field2) => state.byField[field2], [state.byField]);
|
|
3820
4030
|
return { errorFor, apply, clear, formError: state.formError, reset };
|
|
3821
4031
|
}
|
|
3822
4032
|
function isScrollable(node) {
|
|
3823
4033
|
return "scrollIntoView" in Object(node);
|
|
3824
4034
|
}
|
|
3825
4035
|
function useKeepInView(trigger) {
|
|
3826
|
-
const ref =
|
|
3827
|
-
|
|
4036
|
+
const ref = React38.useRef(null);
|
|
4037
|
+
React38.useEffect(() => {
|
|
3828
4038
|
const node = ref.current;
|
|
3829
4039
|
const hasTrigger = trigger !== void 0 && trigger !== null;
|
|
3830
4040
|
if (hasTrigger && isScrollable(node)) node.scrollIntoView({ block: "nearest" });
|
|
@@ -3833,7 +4043,7 @@ function useKeepInView(trigger) {
|
|
|
3833
4043
|
}
|
|
3834
4044
|
var IS_WEB10 = reactNative.Platform.OS === "web";
|
|
3835
4045
|
var INPUT_FONT2 = 14;
|
|
3836
|
-
var
|
|
4046
|
+
var styles23 = reactNative.StyleSheet.create({
|
|
3837
4047
|
nativeButton: { minHeight: a11y.MIN_TOUCH_TARGET_PX, minWidth: a11y.MIN_TOUCH_TARGET_PX, justifyContent: "center" },
|
|
3838
4048
|
nativeText: { fontSize: INPUT_FONT2 }
|
|
3839
4049
|
});
|
|
@@ -3861,10 +4071,10 @@ function FileInput({
|
|
|
3861
4071
|
accessibilityRole: "button",
|
|
3862
4072
|
accessibilityState: { disabled },
|
|
3863
4073
|
disabled,
|
|
3864
|
-
style:
|
|
4074
|
+
style: styles23.nativeButton,
|
|
3865
4075
|
testID,
|
|
3866
4076
|
onPress: onNativePick,
|
|
3867
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4077
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles23.nativeText, { color: colors.text }], children: nativeLabel ?? accessibilityLabel })
|
|
3868
4078
|
}
|
|
3869
4079
|
);
|
|
3870
4080
|
}
|
|
@@ -3894,7 +4104,7 @@ var PREVIEW_RADIUS = 8;
|
|
|
3894
4104
|
var GAP6 = 8;
|
|
3895
4105
|
var TITLE_FONT_SIZE = 14;
|
|
3896
4106
|
var HELP_FONT_SIZE = 13;
|
|
3897
|
-
var
|
|
4107
|
+
var styles24 = reactNative.StyleSheet.create({
|
|
3898
4108
|
help: { flex: 1, fontSize: HELP_FONT_SIZE },
|
|
3899
4109
|
root: { gap: GAP6 },
|
|
3900
4110
|
tile: { alignItems: "center", flexDirection: "row", gap: GAP6 },
|
|
@@ -3914,13 +4124,13 @@ var UploadWithLinkField = ({
|
|
|
3914
4124
|
const { theme } = uiFeedback.useUi();
|
|
3915
4125
|
const ring = uiButtons.useFocusRing();
|
|
3916
4126
|
const url = value ?? "";
|
|
3917
|
-
const [pasting, setPasting] =
|
|
4127
|
+
const [pasting, setPasting] = React38.useState(url !== "");
|
|
3918
4128
|
const previewBox = { borderRadius: PREVIEW_RADIUS, height: previewSize, width: previewSize };
|
|
3919
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
3920
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
3921
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4129
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles24.root, children: [
|
|
4130
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles24.title, { color: theme.colors.text }], children: labels.title }),
|
|
4131
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles24.tile, children: [
|
|
3922
4132
|
url === "" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [previewBox, { backgroundColor: theme.colors.border }] }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Image, { accessible: false, source: { uri: url }, style: previewBox, testID: `${testID}-preview` }),
|
|
3923
|
-
labels.help === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4133
|
+
labels.help === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles24.help, { color: theme.colors.text }], children: labels.help })
|
|
3924
4134
|
] }),
|
|
3925
4135
|
uploadControl,
|
|
3926
4136
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3931,12 +4141,12 @@ var UploadWithLinkField = ({
|
|
|
3931
4141
|
accessibilityRole: "button",
|
|
3932
4142
|
accessibilityState: { expanded: pasting },
|
|
3933
4143
|
"aria-expanded": pasting,
|
|
3934
|
-
style: [
|
|
4144
|
+
style: [styles24.toggle, ring.ringStyle],
|
|
3935
4145
|
testID: `${testID}-paste`,
|
|
3936
4146
|
onBlur: ring.onBlur,
|
|
3937
4147
|
onFocus: ring.onFocus,
|
|
3938
4148
|
onPress: () => setPasting(!pasting),
|
|
3939
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4149
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles24.toggleText, { color: theme.colors.text }], children: labels.pasteToggle })
|
|
3940
4150
|
}
|
|
3941
4151
|
),
|
|
3942
4152
|
pasting ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3955,7 +4165,7 @@ var UploadWithLinkField = ({
|
|
|
3955
4165
|
};
|
|
3956
4166
|
var ACTION_GAP = 8;
|
|
3957
4167
|
var GROUP_GAP = 16;
|
|
3958
|
-
var
|
|
4168
|
+
var styles25 = reactNative.StyleSheet.create({
|
|
3959
4169
|
action: { alignItems: "flex-start", marginTop: ACTION_GAP },
|
|
3960
4170
|
group: { marginBottom: GROUP_GAP }
|
|
3961
4171
|
});
|
|
@@ -3972,13 +4182,13 @@ var AddOnRequest = ({
|
|
|
3972
4182
|
disabled = false,
|
|
3973
4183
|
style
|
|
3974
4184
|
}) => {
|
|
3975
|
-
const [requested, setRequested] =
|
|
4185
|
+
const [requested, setRequested] = React38.useState(false);
|
|
3976
4186
|
const remove = () => {
|
|
3977
4187
|
setRequested(false);
|
|
3978
4188
|
onRemove();
|
|
3979
4189
|
};
|
|
3980
4190
|
if (!isAddOnOpen(hasValue, requested))
|
|
3981
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
4191
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles25.action, style], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3982
4192
|
uiButtons.Button,
|
|
3983
4193
|
{
|
|
3984
4194
|
accessibilityHint: addHint,
|
|
@@ -3990,9 +4200,9 @@ var AddOnRequest = ({
|
|
|
3990
4200
|
onPress: () => setRequested(true)
|
|
3991
4201
|
}
|
|
3992
4202
|
) });
|
|
3993
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4203
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles25.group, style], testID, children: [
|
|
3994
4204
|
children,
|
|
3995
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
4205
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles25.action, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3996
4206
|
uiButtons.Button,
|
|
3997
4207
|
{
|
|
3998
4208
|
accessibilityHint: removeHint,
|
|
@@ -4009,7 +4219,7 @@ var AddOnRequest = ({
|
|
|
4009
4219
|
var ROW_GAP3 = 8;
|
|
4010
4220
|
var TEXT_SIZE = 13;
|
|
4011
4221
|
var TEXT_LINE = 18;
|
|
4012
|
-
var
|
|
4222
|
+
var styles26 = reactNative.StyleSheet.create({
|
|
4013
4223
|
row: { alignItems: "center", columnGap: ROW_GAP3, flexDirection: "row", justifyContent: "space-between" },
|
|
4014
4224
|
text: { flexShrink: 1, fontSize: TEXT_SIZE, fontWeight: "700", lineHeight: TEXT_LINE }
|
|
4015
4225
|
});
|
|
@@ -4017,8 +4227,8 @@ var isFixBarVisible = (count) => count > 0;
|
|
|
4017
4227
|
var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) => {
|
|
4018
4228
|
const { theme } = uiFeedback.useUi();
|
|
4019
4229
|
if (!isFixBarVisible(count)) return null;
|
|
4020
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4021
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
4230
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles26.row, style], testID, children: [
|
|
4231
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles26.text, { color: fieldErrorInk(theme) }], testID: `${testID}-count`, children: message }),
|
|
4022
4232
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4023
4233
|
uiButtons.Button,
|
|
4024
4234
|
{
|
|
@@ -4056,21 +4266,21 @@ function OptionRow2({ option, active, current, renderLeading, renderDetail, onPi
|
|
|
4056
4266
|
accessibilityLabel: option.label,
|
|
4057
4267
|
accessibilityRole: "button",
|
|
4058
4268
|
accessibilityState: { selected: active, checked: current },
|
|
4059
|
-
style: [
|
|
4269
|
+
style: [styles27.row, active ? { backgroundColor: colors.surface } : null],
|
|
4060
4270
|
testID: `${testID}-option-${option.value}`,
|
|
4061
4271
|
onPress: () => onPick(option),
|
|
4062
4272
|
children: [
|
|
4063
4273
|
renderLeading?.(option),
|
|
4064
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4065
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4066
|
-
detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4274
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles27.label, children: [
|
|
4275
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles27.primary, { color: colors.text }], children: option.label }),
|
|
4276
|
+
detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles27.secondary, { color: colors.textSecondary }], children: option.detail }) : null
|
|
4067
4277
|
] }),
|
|
4068
4278
|
renderDetail?.(option)
|
|
4069
4279
|
]
|
|
4070
4280
|
}
|
|
4071
4281
|
);
|
|
4072
4282
|
}
|
|
4073
|
-
var
|
|
4283
|
+
var styles27 = reactNative.StyleSheet.create({
|
|
4074
4284
|
row: { minHeight: a11y.MIN_TOUCH_TARGET_PX, flexDirection: "row", alignItems: "center", gap: ROW_GAP4, paddingHorizontal: ROW_PAD_H },
|
|
4075
4285
|
label: { flex: 1 },
|
|
4076
4286
|
primary: { fontSize: OPTION_FONT2, flexShrink: 1 },
|
|
@@ -4084,11 +4294,11 @@ function OptionSection({ title, options, offset, highlight, selectedValue, ...ro
|
|
|
4084
4294
|
const { colors } = theme;
|
|
4085
4295
|
if (options.length === 0) return null;
|
|
4086
4296
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
4087
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
4297
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles28.header, { color: colors.textSecondary }], children: title }),
|
|
4088
4298
|
options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(OptionRow2, { ...row, active: offset + index === highlight, current: option.value === selectedValue, option }, option.value))
|
|
4089
4299
|
] });
|
|
4090
4300
|
}
|
|
4091
|
-
var
|
|
4301
|
+
var styles28 = reactNative.StyleSheet.create({
|
|
4092
4302
|
header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
|
|
4093
4303
|
});
|
|
4094
4304
|
var KEY_ESCAPE = "Escape";
|
|
@@ -4098,27 +4308,27 @@ var SHEET_MAX_HEIGHT2 = 480;
|
|
|
4098
4308
|
function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
|
|
4099
4309
|
const { theme } = uiFeedback.useUi();
|
|
4100
4310
|
const { colors } = theme;
|
|
4101
|
-
const progress =
|
|
4311
|
+
const progress = React38.useRef(new reactNative.Animated.Value(0)).current;
|
|
4102
4312
|
const { durationMs } = motion;
|
|
4103
|
-
|
|
4313
|
+
React38.useEffect(() => {
|
|
4104
4314
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
4105
4315
|
}, [progress, durationMs]);
|
|
4106
|
-
const leaving =
|
|
4107
|
-
const leave =
|
|
4316
|
+
const leaving = React38.useRef(false);
|
|
4317
|
+
const leave = React38.useCallback((after) => {
|
|
4108
4318
|
if (leaving.current) return;
|
|
4109
4319
|
leaving.current = true;
|
|
4110
4320
|
if (durationMs === 0) return after();
|
|
4111
4321
|
reactNative.Animated.timing(progress, { toValue: 0, duration: durationMs, useNativeDriver: false }).start(() => after());
|
|
4112
4322
|
}, [progress, durationMs]);
|
|
4113
4323
|
const { close, pick: pickNow, submit: submitNow, onKey, sections, highlight } = state;
|
|
4114
|
-
const dismiss =
|
|
4115
|
-
const pick =
|
|
4116
|
-
const submit =
|
|
4117
|
-
const onKeyPress =
|
|
4324
|
+
const dismiss = React38.useCallback(() => leave(close), [leave, close]);
|
|
4325
|
+
const pick = React38.useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
|
|
4326
|
+
const submit = React38.useCallback(() => submitNow(pick), [submitNow, pick]);
|
|
4327
|
+
const onKeyPress = React38.useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
|
|
4118
4328
|
const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [motion.fromY, 0] });
|
|
4119
4329
|
const isSheet = motion.surface === "sheet" /* Sheet */;
|
|
4120
4330
|
const shared = { selectedValue, renderLeading, renderDetail, onPick: pick, optionHint: labels.optionHint, testID, highlight };
|
|
4121
|
-
const list = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4331
|
+
const list = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles29.panel, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }], testID: `${testID}-panel`, children: [
|
|
4122
4332
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4123
4333
|
reactNative.TextInput,
|
|
4124
4334
|
{
|
|
@@ -4135,24 +4345,24 @@ function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, re
|
|
|
4135
4345
|
onSubmitEditing: submit
|
|
4136
4346
|
}
|
|
4137
4347
|
),
|
|
4138
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", style: isSheet ?
|
|
4348
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", style: isSheet ? styles29.sheetList : styles29.dropList, children: [
|
|
4139
4349
|
/* @__PURE__ */ jsxRuntime.jsx(OptionSection, { ...shared, offset: 0, options: sections.recent, title: labels.recent }),
|
|
4140
4350
|
/* @__PURE__ */ jsxRuntime.jsx(OptionSection, { ...shared, offset: sections.recent.length, options: sections.all, title: labels.all }),
|
|
4141
|
-
sections.flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4351
|
+
sections.flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles29.empty, { color: colors.textSecondary }], children: labels.empty }) : null
|
|
4142
4352
|
] })
|
|
4143
4353
|
] });
|
|
4144
4354
|
if (!isSheet) return /* @__PURE__ */ jsxRuntime.jsx(DropdownSurface, { anchorRef, closeHint: labels.closeHint, closeLabel: labels.close, progress, testID, translateY, onDismiss: dismiss, children: list });
|
|
4145
4355
|
return /* @__PURE__ */ jsxRuntime.jsx(SheetSurface, { closeHint: labels.closeHint, closeLabel: labels.close, testID, translateY, onDismiss: dismiss, children: list });
|
|
4146
4356
|
}
|
|
4147
|
-
var
|
|
4357
|
+
var styles29 = reactNative.StyleSheet.create({
|
|
4148
4358
|
panel: { borderWidth: 1, borderRadius: PANEL_RADIUS, padding: PANEL_PAD, gap: PANEL_PAD },
|
|
4149
4359
|
dropList: { maxHeight: MENU_MAX_HEIGHT },
|
|
4150
4360
|
sheetList: { maxHeight: SHEET_MAX_HEIGHT2 },
|
|
4151
4361
|
empty: { padding: PANEL_PAD }
|
|
4152
4362
|
});
|
|
4153
4363
|
function useRefocusOnClose(open, ref) {
|
|
4154
|
-
const wasOpen =
|
|
4155
|
-
|
|
4364
|
+
const wasOpen = React38.useRef(false);
|
|
4365
|
+
React38.useEffect(() => {
|
|
4156
4366
|
if (wasOpen.current && !open) ref.current?.focus();
|
|
4157
4367
|
wasOpen.current = open;
|
|
4158
4368
|
}, [open, ref]);
|
|
@@ -4185,38 +4395,38 @@ var KEY_DOWN = "ArrowDown";
|
|
|
4185
4395
|
var KEY_UP = "ArrowUp";
|
|
4186
4396
|
var KEY_ESCAPE2 = "Escape";
|
|
4187
4397
|
function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
4188
|
-
const [open, setOpen] =
|
|
4189
|
-
const [query, setQueryState] =
|
|
4190
|
-
const [rawHighlight, setHighlight] =
|
|
4191
|
-
const sections =
|
|
4398
|
+
const [open, setOpen] = React38.useState(false);
|
|
4399
|
+
const [query, setQueryState] = React38.useState("");
|
|
4400
|
+
const [rawHighlight, setHighlight] = React38.useState(-1);
|
|
4401
|
+
const sections = React38.useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
|
|
4192
4402
|
const highlight = rawHighlight < sections.flat.length ? rawHighlight : -1;
|
|
4193
4403
|
const active = sections.flat[highlight];
|
|
4194
4404
|
const { remember } = recents;
|
|
4195
|
-
const close =
|
|
4405
|
+
const close = React38.useCallback(() => {
|
|
4196
4406
|
setOpen(false);
|
|
4197
4407
|
setQueryState("");
|
|
4198
4408
|
setHighlight(-1);
|
|
4199
4409
|
onClosed();
|
|
4200
4410
|
}, [onClosed]);
|
|
4201
|
-
const pick =
|
|
4411
|
+
const pick = React38.useCallback((option) => {
|
|
4202
4412
|
remember(option.value);
|
|
4203
4413
|
onChange(option.value);
|
|
4204
4414
|
close();
|
|
4205
4415
|
}, [remember, onChange, close]);
|
|
4206
|
-
const submit =
|
|
4416
|
+
const submit = React38.useCallback((via = pick) => {
|
|
4207
4417
|
if (active !== void 0) via(active);
|
|
4208
4418
|
}, [active, pick]);
|
|
4209
|
-
const setQuery =
|
|
4419
|
+
const setQuery = React38.useCallback((next) => {
|
|
4210
4420
|
setQueryState(next);
|
|
4211
4421
|
setHighlight(highlightAfterQuery(next));
|
|
4212
4422
|
}, []);
|
|
4213
|
-
const onKey =
|
|
4423
|
+
const onKey = React38.useCallback((key) => {
|
|
4214
4424
|
const count = sections.flat.length;
|
|
4215
4425
|
if (key === KEY_DOWN) setHighlight(moveHighlight(highlight, count, 1));
|
|
4216
4426
|
if (key === KEY_UP) setHighlight(moveHighlight(highlight, count, -1));
|
|
4217
4427
|
if (key === KEY_ESCAPE2) close();
|
|
4218
4428
|
}, [sections.flat.length, highlight, close]);
|
|
4219
|
-
const openList =
|
|
4429
|
+
const openList = React38.useCallback(() => setOpen(true), []);
|
|
4220
4430
|
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
4221
4431
|
}
|
|
4222
4432
|
|
|
@@ -4240,8 +4450,8 @@ function SearchSelect(props) {
|
|
|
4240
4450
|
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger, onBlur } = props;
|
|
4241
4451
|
const { theme } = uiFeedback.useUi();
|
|
4242
4452
|
const { colors } = theme;
|
|
4243
|
-
const triggerRef =
|
|
4244
|
-
const anchorRef =
|
|
4453
|
+
const triggerRef = React38.useRef(null);
|
|
4454
|
+
const anchorRef = React38.useRef(null);
|
|
4245
4455
|
const { width } = reactNative.useWindowDimensions();
|
|
4246
4456
|
const motion = resolveSelectMotion(width, useReducedMotion());
|
|
4247
4457
|
const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
|
|
@@ -4249,12 +4459,12 @@ function SearchSelect(props) {
|
|
|
4249
4459
|
useRefocusOnClose(state.open, triggerRef);
|
|
4250
4460
|
const selected = findOption(options, value);
|
|
4251
4461
|
const onPress = state.open ? state.close : state.openList;
|
|
4252
|
-
const openRef =
|
|
4462
|
+
const openRef = React38.useRef(state.open);
|
|
4253
4463
|
openRef.current = state.open;
|
|
4254
|
-
const onTriggerBlur =
|
|
4464
|
+
const onTriggerBlur = React38.useCallback(() => {
|
|
4255
4465
|
if (!openRef.current) onBlur?.();
|
|
4256
4466
|
}, [onBlur]);
|
|
4257
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style:
|
|
4467
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles30.anchor, children: [
|
|
4258
4468
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4259
4469
|
reactNative.Pressable,
|
|
4260
4470
|
{
|
|
@@ -4263,7 +4473,7 @@ function SearchSelect(props) {
|
|
|
4263
4473
|
accessibilityLabel,
|
|
4264
4474
|
accessibilityRole: "button",
|
|
4265
4475
|
accessibilityState: { expanded: state.open },
|
|
4266
|
-
style: renderTrigger === void 0 ? [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }] :
|
|
4476
|
+
style: renderTrigger === void 0 ? [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }] : styles30.customTrigger,
|
|
4267
4477
|
testID,
|
|
4268
4478
|
onBlur: onTriggerBlur,
|
|
4269
4479
|
onPress,
|
|
@@ -4275,7 +4485,7 @@ function SearchSelect(props) {
|
|
|
4275
4485
|
}
|
|
4276
4486
|
function FieldBoxContent({ selected, placeholder, colors, renderLeading, renderDetail }) {
|
|
4277
4487
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4278
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4488
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles30.value, children: [
|
|
4279
4489
|
selected !== null && renderLeading !== void 0 ? renderLeading(selected) : null,
|
|
4280
4490
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: selected === null ? colors.textSecondary : colors.text }], children: selected?.label ?? placeholder }),
|
|
4281
4491
|
selected !== null ? /* @__PURE__ */ jsxRuntime.jsx(SelectedDetail, { colors, option: selected, renderDetail }) : null
|
|
@@ -4288,7 +4498,7 @@ function SelectedDetail({ option, colors, renderDetail }) {
|
|
|
4288
4498
|
if (option.detail === void 0) return null;
|
|
4289
4499
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [controlStyles.selectTriggerText, { color: colors.textSecondary }], children: option.detail });
|
|
4290
4500
|
}
|
|
4291
|
-
var
|
|
4501
|
+
var styles30 = reactNative.StyleSheet.create({
|
|
4292
4502
|
anchor: { position: "relative" },
|
|
4293
4503
|
customTrigger: { minHeight: MIN_TOUCH, minWidth: MIN_TOUCH, alignSelf: "flex-start", justifyContent: "center" },
|
|
4294
4504
|
value: { flex: 1, flexDirection: "row", alignItems: "center", gap: VALUE_GAP }
|
|
@@ -4301,7 +4511,7 @@ function isOutside(container, target) {
|
|
|
4301
4511
|
return !(target instanceof Node && container.contains(target));
|
|
4302
4512
|
}
|
|
4303
4513
|
function useOutsidePress(ref, onOutside) {
|
|
4304
|
-
|
|
4514
|
+
React38.useEffect(() => {
|
|
4305
4515
|
if (reactNative.Platform.OS !== "web" || typeof document === "undefined") return void 0;
|
|
4306
4516
|
const onPointerDown = (event) => {
|
|
4307
4517
|
if (isOutside(ref.current, event.target)) onOutside();
|
|
@@ -4312,7 +4522,7 @@ function useOutsidePress(ref, onOutside) {
|
|
|
4312
4522
|
}
|
|
4313
4523
|
var AFTER_SURFACE_UNMOUNT_MS = 0;
|
|
4314
4524
|
function useDeferredFocus(ref) {
|
|
4315
|
-
return
|
|
4525
|
+
return React38.useCallback(() => {
|
|
4316
4526
|
setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
|
|
4317
4527
|
}, [ref]);
|
|
4318
4528
|
}
|
|
@@ -5064,8 +5274,8 @@ var renderFlag = (option) => option.value === NO_COUNTRY2 ? null : /* @__PURE__
|
|
|
5064
5274
|
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }) {
|
|
5065
5275
|
const { theme } = uiFeedback.useUi();
|
|
5066
5276
|
const { textSecondary } = theme.colors;
|
|
5067
|
-
const options =
|
|
5068
|
-
const renderCode =
|
|
5277
|
+
const options = React38.useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
|
|
5278
|
+
const renderCode = React38.useCallback((option) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles31.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
|
|
5069
5279
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5070
5280
|
SearchSelect,
|
|
5071
5281
|
{
|
|
@@ -5083,13 +5293,13 @@ function CountryField({ value, onChange, accessibilityLabel, accessibilityHint,
|
|
|
5083
5293
|
}
|
|
5084
5294
|
);
|
|
5085
5295
|
}
|
|
5086
|
-
var
|
|
5296
|
+
var styles31 = reactNative.StyleSheet.create({
|
|
5087
5297
|
code: { fontSize: CODE_FONT }
|
|
5088
5298
|
});
|
|
5089
5299
|
function useBlurVerdict(validate) {
|
|
5090
|
-
const [verdict, setVerdict] =
|
|
5091
|
-
const onEdit =
|
|
5092
|
-
const onLeave =
|
|
5300
|
+
const [verdict, setVerdict] = React38.useState(null);
|
|
5301
|
+
const onEdit = React38.useCallback(() => setVerdict(null), []);
|
|
5302
|
+
const onLeave = React38.useCallback(() => {
|
|
5093
5303
|
const next = validate();
|
|
5094
5304
|
setVerdict(next);
|
|
5095
5305
|
return next;
|
|
@@ -5243,11 +5453,11 @@ function rawCaretAfterChange(previous, previousCaret, next) {
|
|
|
5243
5453
|
|
|
5244
5454
|
// src/IbanInput/hooks/useIbanCaret.ts
|
|
5245
5455
|
function useIbanCaret(display) {
|
|
5246
|
-
const [selection2, setSelection] =
|
|
5247
|
-
const onSelectionChange =
|
|
5456
|
+
const [selection2, setSelection] = React38.useState({ start: display.length, end: display.length });
|
|
5457
|
+
const onSelectionChange = React38.useCallback((event) => {
|
|
5248
5458
|
setSelection(event.nativeEvent.selection);
|
|
5249
5459
|
}, []);
|
|
5250
|
-
const placeAfterEdit =
|
|
5460
|
+
const placeAfterEdit = React38.useCallback((text) => {
|
|
5251
5461
|
const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection2.end, text));
|
|
5252
5462
|
setSelection({ start: caret, end: caret });
|
|
5253
5463
|
}, [display, selection2.end]);
|
|
@@ -5339,9 +5549,9 @@ var LINE_GAP = 4;
|
|
|
5339
5549
|
function RejectionLine({ message, testID }) {
|
|
5340
5550
|
const { theme } = uiFeedback.useUi();
|
|
5341
5551
|
if (message === null) return null;
|
|
5342
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", style: [
|
|
5552
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", style: [styles32.line, { color: fieldErrorInk(theme) }], testID: `${testID}-rejection`, children: message });
|
|
5343
5553
|
}
|
|
5344
|
-
var
|
|
5554
|
+
var styles32 = reactNative.StyleSheet.create({
|
|
5345
5555
|
line: { marginTop: LINE_GAP }
|
|
5346
5556
|
});
|
|
5347
5557
|
|
|
@@ -5353,19 +5563,19 @@ function rejectionMessage(rejection, none, labels) {
|
|
|
5353
5563
|
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
5354
5564
|
const { theme } = uiFeedback.useUi();
|
|
5355
5565
|
const { colors } = theme;
|
|
5356
|
-
const draft =
|
|
5357
|
-
const validate =
|
|
5566
|
+
const draft = React38.useMemo(() => draftIban(value), [value]);
|
|
5567
|
+
const validate = React38.useCallback(() => validateIban(value), [value]);
|
|
5358
5568
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5359
5569
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5360
5570
|
const counter = ibanCounter(draft);
|
|
5361
5571
|
const { selection: selection2, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
5362
|
-
const onChangeText =
|
|
5572
|
+
const onChangeText = React38.useCallback((text) => {
|
|
5363
5573
|
onEdit();
|
|
5364
5574
|
onVerdict?.(null);
|
|
5365
5575
|
placeAfterEdit(text);
|
|
5366
5576
|
onChange(draftIban(text).electronic);
|
|
5367
5577
|
}, [onEdit, onVerdict, placeAfterEdit, onChange]);
|
|
5368
|
-
const onBlur =
|
|
5578
|
+
const onBlur = React38.useCallback(() => {
|
|
5369
5579
|
const verdict2 = onLeave();
|
|
5370
5580
|
onVerdict?.(value === "" ? null : verdict2);
|
|
5371
5581
|
onLeft?.();
|
|
@@ -5440,16 +5650,16 @@ function validateBic(raw) {
|
|
|
5440
5650
|
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
5441
5651
|
const { theme } = uiFeedback.useUi();
|
|
5442
5652
|
const { colors } = theme;
|
|
5443
|
-
const draft =
|
|
5444
|
-
const validate =
|
|
5653
|
+
const draft = React38.useMemo(() => draftBic(value), [value]);
|
|
5654
|
+
const validate = React38.useCallback(() => validateBic(value), [value]);
|
|
5445
5655
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5446
5656
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5447
|
-
const onChangeText =
|
|
5657
|
+
const onChangeText = React38.useCallback((text) => {
|
|
5448
5658
|
onEdit();
|
|
5449
5659
|
onVerdict?.(null);
|
|
5450
5660
|
onChange(draftBic(text).value);
|
|
5451
5661
|
}, [onEdit, onVerdict, onChange]);
|
|
5452
|
-
const onBlur =
|
|
5662
|
+
const onBlur = React38.useCallback(() => {
|
|
5453
5663
|
const verdict2 = onLeave();
|
|
5454
5664
|
onVerdict?.(value === "" ? null : verdict2);
|
|
5455
5665
|
onLeft?.();
|
|
@@ -5488,7 +5698,7 @@ var PAD_V = 10;
|
|
|
5488
5698
|
var PAD_H = 16;
|
|
5489
5699
|
var TEXT_SIZE2 = 13;
|
|
5490
5700
|
var TEXT_LINE2 = 18;
|
|
5491
|
-
var
|
|
5701
|
+
var styles33 = reactNative.StyleSheet.create({
|
|
5492
5702
|
bar: { borderTopWidth: 1, paddingHorizontal: PAD_H, paddingVertical: PAD_V, rowGap: BAR_GAP },
|
|
5493
5703
|
actions: { flexDirection: "row", flexWrap: "wrap", gap: BAR_GAP },
|
|
5494
5704
|
message: { fontSize: TEXT_SIZE2, fontWeight: "700", lineHeight: TEXT_LINE2 }
|
|
@@ -5500,9 +5710,9 @@ var ActionBar = ({ children, message, sticky = false, testID, style }) => {
|
|
|
5500
5710
|
const { colors } = theme;
|
|
5501
5711
|
const pinned = actionBarPosition(sticky, reactNative.Platform.OS) === "sticky" ? PINNED : null;
|
|
5502
5712
|
const hasMessage = message !== void 0 && message !== "";
|
|
5503
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
5504
|
-
hasMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "status", style: [
|
|
5505
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
5713
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles33.bar, { backgroundColor: colors.surface, borderTopColor: colors.border }, pinned, style], testID, children: [
|
|
5714
|
+
hasMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "status", style: [styles33.message, { color: colors.text }], testID: `${testID}-message`, children: message }) : null,
|
|
5715
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles33.actions, children })
|
|
5506
5716
|
] });
|
|
5507
5717
|
};
|
|
5508
5718
|
|
|
@@ -5510,14 +5720,14 @@ var ActionBar = ({ children, message, sticky = false, testID, style }) => {
|
|
|
5510
5720
|
var isChecklistComplete = (items, checked) => items.every((item) => checked.includes(item.id));
|
|
5511
5721
|
var TITLE_SIZE = 13;
|
|
5512
5722
|
var TITLE_GAP = 6;
|
|
5513
|
-
var
|
|
5723
|
+
var styles34 = reactNative.StyleSheet.create({
|
|
5514
5724
|
title: { fontSize: TITLE_SIZE, fontWeight: "700", marginBottom: TITLE_GAP }
|
|
5515
5725
|
});
|
|
5516
5726
|
var GatedChecklist = ({ title, items, checked, onToggle, testID, disabled = false, children }) => {
|
|
5517
5727
|
const { theme } = uiFeedback.useUi();
|
|
5518
5728
|
const complete = isChecklistComplete(items, checked);
|
|
5519
5729
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { testID, children: [
|
|
5520
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
5730
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles34.title, { color: theme.colors.text }], children: title }),
|
|
5521
5731
|
items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5522
5732
|
FormCheckbox,
|
|
5523
5733
|
{
|
|
@@ -5533,7 +5743,7 @@ var GatedChecklist = ({ title, items, checked, onToggle, testID, disabled = fals
|
|
|
5533
5743
|
children?.(complete)
|
|
5534
5744
|
] });
|
|
5535
5745
|
};
|
|
5536
|
-
var
|
|
5746
|
+
var MIN_TARGET_PX3 = 44;
|
|
5537
5747
|
var DOT_SIZE = 18;
|
|
5538
5748
|
var DOT_INNER = 8;
|
|
5539
5749
|
var ROW_GAP6 = 10;
|
|
@@ -5543,14 +5753,14 @@ var RADIUS2 = 8;
|
|
|
5543
5753
|
var LABEL_SIZE = 14;
|
|
5544
5754
|
var DESCRIPTION_SIZE = 12;
|
|
5545
5755
|
var DESCRIPTION_LINE = 16;
|
|
5546
|
-
var
|
|
5756
|
+
var styles35 = reactNative.StyleSheet.create({
|
|
5547
5757
|
row: {
|
|
5548
5758
|
alignItems: "center",
|
|
5549
5759
|
borderRadius: RADIUS2,
|
|
5550
5760
|
borderWidth: 1,
|
|
5551
5761
|
columnGap: ROW_GAP6,
|
|
5552
5762
|
flexDirection: "row",
|
|
5553
|
-
minHeight:
|
|
5763
|
+
minHeight: MIN_TARGET_PX3,
|
|
5554
5764
|
paddingHorizontal: PAD_H2,
|
|
5555
5765
|
paddingVertical: PAD_V2
|
|
5556
5766
|
},
|
|
@@ -5574,15 +5784,15 @@ function RadioRow({ option, identity, colors, tabIndex, hostRef, onPress }) {
|
|
|
5574
5784
|
accessibilityState: identity.accessibilityState,
|
|
5575
5785
|
"aria-checked": checked,
|
|
5576
5786
|
disabled,
|
|
5577
|
-
style: [
|
|
5787
|
+
style: [styles35.row, { borderColor: accent, backgroundColor: checked ? colors.tint : colors.muted }],
|
|
5578
5788
|
tabIndex,
|
|
5579
5789
|
testID: identity.testID,
|
|
5580
5790
|
onPress,
|
|
5581
5791
|
children: [
|
|
5582
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
5583
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
5584
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
5585
|
-
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
5792
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles35.dot, { borderColor: accent }], children: checked ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles35.dotInner, { backgroundColor: colors.primary }] }) : null }),
|
|
5793
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles35.text, children: [
|
|
5794
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles35.label, { color: checked ? colors.primary : colors.textStrong }], children: option.label }),
|
|
5795
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles35.description, { color: colors.textMuted }], testID: `${identity.testID}-description`, children: option.description }) : null
|
|
5586
5796
|
] })
|
|
5587
5797
|
]
|
|
5588
5798
|
}
|
|
@@ -5599,20 +5809,20 @@ var radioRowIdentity = (option, selected, disabled, prefix) => {
|
|
|
5599
5809
|
};
|
|
5600
5810
|
};
|
|
5601
5811
|
var ROW_GAP7 = 8;
|
|
5602
|
-
var
|
|
5812
|
+
var styles36 = reactNative.StyleSheet.create({
|
|
5603
5813
|
list: { rowGap: ROW_GAP7 }
|
|
5604
5814
|
});
|
|
5605
5815
|
function RadioList(props) {
|
|
5606
5816
|
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
5607
5817
|
const { theme } = uiFeedback.useUi();
|
|
5608
|
-
const colors =
|
|
5818
|
+
const colors = React38__default.default.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
5609
5819
|
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
5610
5820
|
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
5611
5821
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5612
5822
|
reactNative.View,
|
|
5613
5823
|
{
|
|
5614
5824
|
accessibilityRole: "radiogroup",
|
|
5615
|
-
style:
|
|
5825
|
+
style: styles36.list,
|
|
5616
5826
|
...webFieldA11y({ describedById, hasError }),
|
|
5617
5827
|
...radio.groupProps,
|
|
5618
5828
|
children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5666,11 +5876,11 @@ function DecisionNote({ state, labels, testID, disabled }) {
|
|
|
5666
5876
|
);
|
|
5667
5877
|
}
|
|
5668
5878
|
var BUTTON_BASIS = "40%";
|
|
5669
|
-
var
|
|
5879
|
+
var styles37 = reactNative.StyleSheet.create({
|
|
5670
5880
|
cell: { flexBasis: BUTTON_BASIS, flexGrow: 1 }
|
|
5671
5881
|
});
|
|
5672
5882
|
function OutcomeButtons({ outcomes, pending, disabled, testID, onPress }) {
|
|
5673
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: outcomes.map((item) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
5883
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: outcomes.map((item) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles37.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5674
5884
|
uiButtons.Button,
|
|
5675
5885
|
{
|
|
5676
5886
|
fullWidth: true,
|
|
@@ -5751,21 +5961,21 @@ function StickyBarDecision(props) {
|
|
|
5751
5961
|
}
|
|
5752
5962
|
var TEXT_SIZE3 = 13;
|
|
5753
5963
|
var TEXT_LINE3 = 18;
|
|
5754
|
-
var
|
|
5964
|
+
var styles38 = reactNative.StyleSheet.create({
|
|
5755
5965
|
text: { fontSize: TEXT_SIZE3, fontWeight: "700", lineHeight: TEXT_LINE3 }
|
|
5756
5966
|
});
|
|
5757
5967
|
var SubmitError = ({ message, testID }) => {
|
|
5758
5968
|
const { theme } = uiFeedback.useUi();
|
|
5759
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
5969
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles38.text, { color: fieldErrorInk(theme) }], testID, children: message });
|
|
5760
5970
|
};
|
|
5761
5971
|
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
5762
5972
|
function useDecisionPanel(outcomes, onSubmit) {
|
|
5763
|
-
const [outcome, setOutcome] =
|
|
5764
|
-
const [note, setNote] =
|
|
5765
|
-
const [reasons, setReasons] =
|
|
5766
|
-
const [checked, setChecked] =
|
|
5767
|
-
const [error, setError] =
|
|
5768
|
-
const [pending, setPending] =
|
|
5973
|
+
const [outcome, setOutcome] = React38__default.default.useState("");
|
|
5974
|
+
const [note, setNote] = React38__default.default.useState("");
|
|
5975
|
+
const [reasons, setReasons] = React38__default.default.useState([]);
|
|
5976
|
+
const [checked, setChecked] = React38__default.default.useState([]);
|
|
5977
|
+
const [error, setError] = React38__default.default.useState(null);
|
|
5978
|
+
const [pending, setPending] = React38__default.default.useState(null);
|
|
5769
5979
|
const submit = async (override) => {
|
|
5770
5980
|
const target = override ?? outcome;
|
|
5771
5981
|
const problem = validateDecision(outcomes, target, note);
|
|
@@ -5799,7 +6009,7 @@ function useDecisionPanel(outcomes, onSubmit) {
|
|
|
5799
6009
|
}
|
|
5800
6010
|
var TITLE_SIZE2 = 15;
|
|
5801
6011
|
var PANEL_GAP = 12;
|
|
5802
|
-
var
|
|
6012
|
+
var styles39 = reactNative.StyleSheet.create({
|
|
5803
6013
|
panel: { rowGap: PANEL_GAP },
|
|
5804
6014
|
title: { fontSize: TITLE_SIZE2, fontWeight: "700" }
|
|
5805
6015
|
});
|
|
@@ -5813,8 +6023,8 @@ function DecisionPanel(props) {
|
|
|
5813
6023
|
const { theme } = uiFeedback.useUi();
|
|
5814
6024
|
const state = useDecisionPanel(outcomes, onSubmit);
|
|
5815
6025
|
const body = (locked) => renderVariant(variant, { state, outcomes, labels, testID, disabled: disabled || locked, reasons, leadOutcome });
|
|
5816
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
5817
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
6026
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles39.panel, style], testID, children: [
|
|
6027
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles39.title, { color: theme.colors.text }], children: labels.title }),
|
|
5818
6028
|
checklist !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(GatedChecklist, { checked: state.checked, items: checklist.items, testID: `${testID}-checklist`, title: checklist.title, onToggle: state.toggleCheck, children: (complete) => body(!complete) }) : body(false),
|
|
5819
6029
|
state.error === "submit" ? /* @__PURE__ */ jsxRuntime.jsx(SubmitError, { message: labels.submitError, testID: `${testID}-error` }) : null
|
|
5820
6030
|
] });
|
|
@@ -5841,22 +6051,22 @@ function ruleTone(met, flagUnmet) {
|
|
|
5841
6051
|
return flagUnmet ? "refused" /* Refused */ : "unmet" /* Unmet */;
|
|
5842
6052
|
}
|
|
5843
6053
|
var MARK_SIZE = 16;
|
|
5844
|
-
var
|
|
6054
|
+
var CHECK_SIZE2 = 12;
|
|
5845
6055
|
var RING_WIDTH = 1.5;
|
|
5846
6056
|
var POP_FROM = 0.6;
|
|
5847
6057
|
var POP_PEAK = 1.12;
|
|
5848
6058
|
var POP_UP_MS = 160;
|
|
5849
6059
|
var POP_SETTLE_MS = 100;
|
|
5850
|
-
var
|
|
6060
|
+
var styles40 = reactNative.StyleSheet.create({
|
|
5851
6061
|
mark: { width: MARK_SIZE, height: MARK_SIZE, borderRadius: MARK_SIZE / 2, alignItems: "center", justifyContent: "center" },
|
|
5852
6062
|
ring: { borderWidth: RING_WIDTH }
|
|
5853
6063
|
});
|
|
5854
6064
|
function RuleMark({ tone, colors }) {
|
|
5855
6065
|
const reduced = useReducedMotion();
|
|
5856
|
-
const scale =
|
|
5857
|
-
const wasMet =
|
|
6066
|
+
const scale = React38.useRef(new reactNative.Animated.Value(1)).current;
|
|
6067
|
+
const wasMet = React38.useRef(tone === "met" /* Met */);
|
|
5858
6068
|
const met = tone === "met" /* Met */;
|
|
5859
|
-
|
|
6069
|
+
React38.useEffect(() => {
|
|
5860
6070
|
const turnedMet = met && !wasMet.current;
|
|
5861
6071
|
wasMet.current = met;
|
|
5862
6072
|
if (!turnedMet || reduced) return;
|
|
@@ -5867,8 +6077,8 @@ function RuleMark({ tone, colors }) {
|
|
|
5867
6077
|
]).start();
|
|
5868
6078
|
}, [met, reduced, scale]);
|
|
5869
6079
|
const color = colors.mark[tone];
|
|
5870
|
-
const shape = met ? { backgroundColor: color } : [
|
|
5871
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: { transform: [{ scale }] }, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
6080
|
+
const shape = met ? { backgroundColor: color } : [styles40.ring, { borderColor: color }];
|
|
6081
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: { transform: [{ scale }] }, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles40.mark, shape], children: met ? /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.onMark, name: "check", size: CHECK_SIZE2 }) : null }) });
|
|
5872
6082
|
}
|
|
5873
6083
|
var GAP8 = 6;
|
|
5874
6084
|
var ROW_GAP8 = 8;
|
|
@@ -5876,11 +6086,11 @@ var FONT5 = 14;
|
|
|
5876
6086
|
var LINE = 20;
|
|
5877
6087
|
var METER_HEIGHT = 4;
|
|
5878
6088
|
var RADIUS3 = 999;
|
|
5879
|
-
var
|
|
5880
|
-
var
|
|
5881
|
-
var
|
|
6089
|
+
var CHIP_PAD_V2 = 4;
|
|
6090
|
+
var CHIP_PAD_H2 = 10;
|
|
6091
|
+
var CHIP_BORDER2 = 1;
|
|
5882
6092
|
var HALF4 = "50%";
|
|
5883
|
-
var
|
|
6093
|
+
var styles41 = reactNative.StyleSheet.create({
|
|
5884
6094
|
column: { gap: GAP8 },
|
|
5885
6095
|
row: { flexDirection: "row", alignItems: "center", gap: ROW_GAP8 },
|
|
5886
6096
|
text: { fontSize: FONT5, lineHeight: LINE, flexShrink: 1 },
|
|
@@ -5889,38 +6099,38 @@ var styles39 = reactNative.StyleSheet.create({
|
|
|
5889
6099
|
grid: { flexDirection: "row", flexWrap: "wrap", rowGap: GAP8 },
|
|
5890
6100
|
cell: { flexBasis: HALF4, maxWidth: HALF4, paddingRight: GAP8 },
|
|
5891
6101
|
chips: { flexDirection: "row", flexWrap: "wrap", gap: GAP8 },
|
|
5892
|
-
chip: { borderRadius: RADIUS3, borderWidth:
|
|
6102
|
+
chip: { borderRadius: RADIUS3, borderWidth: CHIP_BORDER2, paddingVertical: CHIP_PAD_V2, paddingHorizontal: CHIP_PAD_H2 },
|
|
5893
6103
|
metPhrase: { fontWeight: "700", textDecorationLine: "underline" }
|
|
5894
6104
|
});
|
|
5895
6105
|
function RuleList({ rules, flagUnmet, colors, testID, listStyle, itemStyle, outlined = false }) {
|
|
5896
6106
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { role: "list", style: listStyle, testID, children: rules.map((rule) => {
|
|
5897
6107
|
const tone = ruleTone(rule.met, flagUnmet);
|
|
5898
6108
|
const outline = outlined ? { borderColor: colors.mark[tone] } : null;
|
|
5899
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "listitem", style: [
|
|
6109
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "listitem", style: [styles41.row, itemStyle, outline], testID: `${testID}-${rule.id}`, ...{ dataSet: { tone } }, children: [
|
|
5900
6110
|
/* @__PURE__ */ jsxRuntime.jsx(RuleMark, { colors, tone }),
|
|
5901
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
6111
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles41.text, { color: colors.text[tone] }], children: rule.label })
|
|
5902
6112
|
] }, rule.id);
|
|
5903
6113
|
}) });
|
|
5904
6114
|
}
|
|
5905
6115
|
function RulesChecklist(props) {
|
|
5906
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, listStyle:
|
|
6116
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, listStyle: styles41.column });
|
|
5907
6117
|
}
|
|
5908
6118
|
function RulesChips(props) {
|
|
5909
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, outlined: true, itemStyle:
|
|
6119
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, outlined: true, itemStyle: styles41.chip, listStyle: styles41.chips });
|
|
5910
6120
|
}
|
|
5911
6121
|
function RulesMeterGrid(props) {
|
|
5912
6122
|
const { rules, flagUnmet, colors, testID } = props;
|
|
5913
6123
|
const metCount = rules.filter((rule) => rule.met).length;
|
|
5914
6124
|
const unfilled = flagUnmet ? colors.mark.refused : colors.track;
|
|
5915
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
5916
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
5917
|
-
/* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, itemStyle:
|
|
6125
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles41.column, children: [
|
|
6126
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles41.meter, testID: `${testID}-meter`, children: rules.map((rule, index) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles41.segment, { backgroundColor: index < metCount ? colors.mark.met : unfilled }] }, rule.id)) }),
|
|
6127
|
+
/* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, itemStyle: styles41.cell, listStyle: styles41.grid })
|
|
5918
6128
|
] });
|
|
5919
6129
|
}
|
|
5920
6130
|
function RulesSentence({ rules, flagUnmet, colors, testID }) {
|
|
5921
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
6131
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles41.text, { color: colors.text.unmet }], testID, children: rules.map((rule, index) => {
|
|
5922
6132
|
const tone = ruleTone(rule.met, flagUnmet);
|
|
5923
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: [{ color: colors.text[tone] }, rule.met ?
|
|
6133
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: [{ color: colors.text[tone] }, rule.met ? styles41.metPhrase : null], testID: `${testID}-${rule.id}`, ...{ dataSet: { tone } }, children: [
|
|
5924
6134
|
index > 0 ? ", " : "",
|
|
5925
6135
|
rule.label
|
|
5926
6136
|
] }, rule.id);
|
|
@@ -5939,7 +6149,7 @@ function PasswordRules({ display, ...variant }) {
|
|
|
5939
6149
|
}
|
|
5940
6150
|
}
|
|
5941
6151
|
var ICON_SIZE = 20;
|
|
5942
|
-
var
|
|
6152
|
+
var styles42 = reactNative.StyleSheet.create({
|
|
5943
6153
|
button: { width: a11y.MIN_TOUCH_TARGET_PX, height: a11y.MIN_TOUCH_TARGET_PX, alignItems: "center", justifyContent: "center" }
|
|
5944
6154
|
});
|
|
5945
6155
|
function RevealToggle({ revealed, onToggle, onPressIn, showLabel, hideLabel, color, testID }) {
|
|
@@ -5951,7 +6161,7 @@ function RevealToggle({ revealed, onToggle, onPressIn, showLabel, hideLabel, col
|
|
|
5951
6161
|
accessibilityLabel: label,
|
|
5952
6162
|
accessibilityRole: "button",
|
|
5953
6163
|
"aria-pressed": revealed,
|
|
5954
|
-
style:
|
|
6164
|
+
style: styles42.button,
|
|
5955
6165
|
testID,
|
|
5956
6166
|
onPress: onToggle,
|
|
5957
6167
|
onPressIn,
|
|
@@ -5971,9 +6181,9 @@ function ruleAnnouncement(changed, labels) {
|
|
|
5971
6181
|
|
|
5972
6182
|
// src/PasswordField/usePasswordRuleAnnouncement.ts
|
|
5973
6183
|
function usePasswordRuleAnnouncement(rules, labels) {
|
|
5974
|
-
const previous =
|
|
5975
|
-
const [message, setMessage] =
|
|
5976
|
-
|
|
6184
|
+
const previous = React38.useRef(rules);
|
|
6185
|
+
const [message, setMessage] = React38.useState("");
|
|
6186
|
+
React38.useEffect(() => {
|
|
5977
6187
|
const changed = changedRules(previous.current, rules);
|
|
5978
6188
|
previous.current = rules;
|
|
5979
6189
|
if (changed.length > 0) setMessage(ruleAnnouncement(changed, labels));
|
|
@@ -5990,7 +6200,7 @@ function ruleColorsFrom(palette) {
|
|
|
5990
6200
|
}
|
|
5991
6201
|
function useRuleColors(override) {
|
|
5992
6202
|
const { theme } = uiFeedback.useUi();
|
|
5993
|
-
return
|
|
6203
|
+
return React38.useMemo(() => {
|
|
5994
6204
|
if (override !== void 0) return ruleColorsFrom(override);
|
|
5995
6205
|
return ruleColorsFrom({
|
|
5996
6206
|
success: theme.semantic.success?.["500"] ?? theme.colors.text,
|
|
@@ -6005,7 +6215,7 @@ function useRuleColors(override) {
|
|
|
6005
6215
|
var RULES_GAP = 8;
|
|
6006
6216
|
var TOGGLE_INSET = 48;
|
|
6007
6217
|
var NO_RULES = [];
|
|
6008
|
-
var
|
|
6218
|
+
var styles43 = reactNative.StyleSheet.create({
|
|
6009
6219
|
inputRow: { position: "relative", justifyContent: "center" },
|
|
6010
6220
|
input: { paddingRight: TOGGLE_INSET },
|
|
6011
6221
|
toggle: { position: "absolute", right: 0, top: 0, bottom: 0, justifyContent: "center" },
|
|
@@ -6017,16 +6227,16 @@ function joinIds(...ids) {
|
|
|
6017
6227
|
return joined === "" ? void 0 : joined;
|
|
6018
6228
|
}
|
|
6019
6229
|
function useCaretKeepingToggle(inputRef, initialLength) {
|
|
6020
|
-
const [revealed, setRevealed] =
|
|
6021
|
-
const selection2 =
|
|
6022
|
-
const hadFocus =
|
|
6023
|
-
const onSelectionChange =
|
|
6230
|
+
const [revealed, setRevealed] = React38.useState(false);
|
|
6231
|
+
const selection2 = React38.useRef({ start: initialLength, end: initialLength });
|
|
6232
|
+
const hadFocus = React38.useRef(false);
|
|
6233
|
+
const onSelectionChange = React38.useCallback((event) => {
|
|
6024
6234
|
selection2.current = event.nativeEvent.selection;
|
|
6025
6235
|
}, []);
|
|
6026
|
-
const onPressIn =
|
|
6236
|
+
const onPressIn = React38.useCallback(() => {
|
|
6027
6237
|
hadFocus.current = inputRef.current?.isFocused?.() ?? false;
|
|
6028
6238
|
}, [inputRef]);
|
|
6029
|
-
const onToggle =
|
|
6239
|
+
const onToggle = React38.useCallback(() => {
|
|
6030
6240
|
setRevealed((current) => !current);
|
|
6031
6241
|
if (!hadFocus.current) return;
|
|
6032
6242
|
const node = inputRef.current;
|
|
@@ -6038,16 +6248,16 @@ function useCaretKeepingToggle(inputRef, initialLength) {
|
|
|
6038
6248
|
}, [inputRef]);
|
|
6039
6249
|
return { revealed, onPressIn, onToggle, onSelectionChange };
|
|
6040
6250
|
}
|
|
6041
|
-
var PasswordField =
|
|
6042
|
-
const inputRef =
|
|
6043
|
-
|
|
6251
|
+
var PasswordField = React38__default.default.forwardRef(function PasswordField2({ label, value, onChangeText, labels, testID, rules = NO_RULES, rulesDisplay = "meterGrid" /* MeterGrid */, flagUnmet = false, error, colors: colorOverride, inputProps }, ref) {
|
|
6252
|
+
const inputRef = React38.useRef(null);
|
|
6253
|
+
React38.useImperativeHandle(ref, () => inputRef.current);
|
|
6044
6254
|
const toggle2 = useCaretKeepingToggle(inputRef, value.length);
|
|
6045
6255
|
const colors = useRuleColors(colorOverride);
|
|
6046
6256
|
const announcement = usePasswordRuleAnnouncement(rules, labels);
|
|
6047
6257
|
const rulesId = `${testID}-rules`;
|
|
6048
6258
|
const hasRules = rules.length > 0;
|
|
6049
6259
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, label, testID: `${testID}-field`, children: (context) => /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
6050
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
6260
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles43.inputRow, children: [
|
|
6051
6261
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6052
6262
|
ThemedTextInput,
|
|
6053
6263
|
{
|
|
@@ -6059,18 +6269,18 @@ var PasswordField = React37__default.default.forwardRef(function PasswordField2(
|
|
|
6059
6269
|
hasError: context.hasError || flagUnmet && rules.some((rule) => !rule.met),
|
|
6060
6270
|
id: context.controlId,
|
|
6061
6271
|
secureTextEntry: !toggle2.revealed,
|
|
6062
|
-
style: [
|
|
6272
|
+
style: [styles43.input, inputProps?.style],
|
|
6063
6273
|
testID,
|
|
6064
6274
|
value,
|
|
6065
6275
|
onChangeText,
|
|
6066
6276
|
onSelectionChange: toggle2.onSelectionChange
|
|
6067
6277
|
}
|
|
6068
6278
|
),
|
|
6069
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
6279
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles43.toggle, children: /* @__PURE__ */ jsxRuntime.jsx(RevealToggle, { color: colors.text.unmet, hideLabel: labels.hide, revealed: toggle2.revealed, showLabel: labels.show, testID: `${testID}-reveal`, onPressIn: toggle2.onPressIn, onToggle: toggle2.onToggle }) })
|
|
6070
6280
|
] }),
|
|
6071
|
-
hasRules ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { nativeID: rulesId, style:
|
|
6281
|
+
hasRules ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { nativeID: rulesId, style: styles43.rules, children: [
|
|
6072
6282
|
/* @__PURE__ */ jsxRuntime.jsx(PasswordRules, { colors, display: rulesDisplay, flagUnmet, rules, testID: rulesId }),
|
|
6073
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-live": "polite", accessibilityLiveRegion: "polite", style:
|
|
6283
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-live": "polite", accessibilityLiveRegion: "polite", style: styles43.live, testID: `${testID}-announce`, children: announcement })
|
|
6074
6284
|
] }) : null
|
|
6075
6285
|
] }) });
|
|
6076
6286
|
});
|
|
@@ -6123,6 +6333,7 @@ exports.IbanRejection = IbanRejection;
|
|
|
6123
6333
|
exports.InlineFieldRow = InlineFieldRow;
|
|
6124
6334
|
exports.LINE_ITEMS_WIDE_MIN_WIDTH = LINE_ITEMS_WIDE_MIN_WIDTH;
|
|
6125
6335
|
exports.LineItems = LineItems;
|
|
6336
|
+
exports.MultiSelectField = MultiSelectField;
|
|
6126
6337
|
exports.PHONE_MAX_WIDTH = PHONE_MAX_WIDTH;
|
|
6127
6338
|
exports.PasswordField = PasswordField;
|
|
6128
6339
|
exports.PasswordRules = PasswordRules;
|