@dloizides/ui-forms 1.48.0 → 1.49.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 +7 -0
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +440 -351
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +252 -163
- 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 React39 = 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');
|
|
@@ -14,12 +14,12 @@ var Svg = require('react-native-svg');
|
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var React39__default = /*#__PURE__*/_interopDefault(React39);
|
|
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 (!React39__default.default.isValidElement(child) || child.type === React39__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: React39__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 = React39.useRef(null);
|
|
41
|
+
React39.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;
|
|
@@ -148,15 +148,15 @@ var labelVariantStyles = reactNative.StyleSheet.create({
|
|
|
148
148
|
function resolveLabelVariantStyle(variant) {
|
|
149
149
|
return labelVariantStyles[variant ?? "field"] ?? labelVariantStyles.field;
|
|
150
150
|
}
|
|
151
|
-
var FormGridContext =
|
|
152
|
-
var GapOwnedContext =
|
|
151
|
+
var FormGridContext = React39__default.default.createContext(null);
|
|
152
|
+
var GapOwnedContext = React39__default.default.createContext(false);
|
|
153
153
|
var FormGridProvider = FormGridContext.Provider;
|
|
154
154
|
var GapOwnedProvider = GapOwnedContext.Provider;
|
|
155
155
|
function useFormGridMetrics() {
|
|
156
|
-
return
|
|
156
|
+
return React39__default.default.useContext(FormGridContext);
|
|
157
157
|
}
|
|
158
158
|
function useIsGapOwned() {
|
|
159
|
-
return
|
|
159
|
+
return React39__default.default.useContext(GapOwnedContext);
|
|
160
160
|
}
|
|
161
161
|
var ERROR_LIGHT_STEPS = ["500", "600", "700"];
|
|
162
162
|
var ERROR_DARK_STEPS = ["300", "200", "400", "100", "500"];
|
|
@@ -179,7 +179,7 @@ var styles = reactNative.StyleSheet.create({
|
|
|
179
179
|
});
|
|
180
180
|
var fieldSeq = 0;
|
|
181
181
|
function useFieldIds() {
|
|
182
|
-
const [ids] =
|
|
182
|
+
const [ids] = React39__default.default.useState(() => {
|
|
183
183
|
fieldSeq += 1;
|
|
184
184
|
const seq = String(fieldSeq);
|
|
185
185
|
return {
|
|
@@ -226,7 +226,7 @@ var Field = ({
|
|
|
226
226
|
const hasLabel = labelText !== "";
|
|
227
227
|
const marker = resolveFieldMarker(required, optional);
|
|
228
228
|
const { hintId, errorId, controlId, labelId } = useFieldIds();
|
|
229
|
-
const themeStyles =
|
|
229
|
+
const themeStyles = React39__default.default.useMemo(
|
|
230
230
|
() => ({
|
|
231
231
|
label: { color: colors.textSecondary },
|
|
232
232
|
requiredMark: { color: errorColor },
|
|
@@ -278,7 +278,7 @@ var FormGrid = ({
|
|
|
278
278
|
style,
|
|
279
279
|
testID
|
|
280
280
|
}) => {
|
|
281
|
-
const metrics =
|
|
281
|
+
const metrics = React39__default.default.useMemo(() => ({ minWidth, basis }), [minWidth, basis]);
|
|
282
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 }) }) });
|
|
283
283
|
};
|
|
284
284
|
var LABEL_LINE_PLACEHOLDER = "\xA0";
|
|
@@ -363,8 +363,8 @@ var InlineFieldRow = ({
|
|
|
363
363
|
}) => {
|
|
364
364
|
const { width } = reactNative.useWindowDimensions();
|
|
365
365
|
const layout = inlineFieldRowLayout(width, fieldMaxWidth, inlineMinWidth);
|
|
366
|
-
const rowStyle =
|
|
367
|
-
const fieldStyle =
|
|
366
|
+
const rowStyle = React39.useMemo(() => [styles4.row, { gap }], [gap]);
|
|
367
|
+
const fieldStyle = React39.useMemo(() => [styles4.field, { maxWidth: layout.fieldMaxWidth }], [layout.fieldMaxWidth]);
|
|
368
368
|
if (!layout.inline)
|
|
369
369
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
370
370
|
field2,
|
|
@@ -545,7 +545,7 @@ var styles9 = reactNative.StyleSheet.create({
|
|
|
545
545
|
});
|
|
546
546
|
var sectionSeq = 0;
|
|
547
547
|
function useSectionLegendId() {
|
|
548
|
-
const [id] =
|
|
548
|
+
const [id] = React39__default.default.useState(() => {
|
|
549
549
|
sectionSeq += 1;
|
|
550
550
|
return `form-section-legend-${String(sectionSeq)}`;
|
|
551
551
|
});
|
|
@@ -803,8 +803,8 @@ function horizontalPlacement(rect2, viewportWidth) {
|
|
|
803
803
|
return { left, width };
|
|
804
804
|
}
|
|
805
805
|
function useAnchorRect(ref, enabled) {
|
|
806
|
-
const [rect2, setRect] =
|
|
807
|
-
|
|
806
|
+
const [rect2, setRect] = React39.useState(null);
|
|
807
|
+
React39.useLayoutEffect(() => {
|
|
808
808
|
if (!IS_WEB3 || !enabled) {
|
|
809
809
|
setRect(null);
|
|
810
810
|
return void 0;
|
|
@@ -853,8 +853,8 @@ function readViewportBottom() {
|
|
|
853
853
|
return viewport === null ? window.innerHeight : viewport.offsetTop + viewport.height;
|
|
854
854
|
}
|
|
855
855
|
function useVisualViewportBottom(enabled) {
|
|
856
|
-
const [bottom, setBottom] =
|
|
857
|
-
|
|
856
|
+
const [bottom, setBottom] = React39.useState(null);
|
|
857
|
+
React39.useLayoutEffect(() => {
|
|
858
858
|
if (!IS_WEB3 || !enabled) {
|
|
859
859
|
setBottom(null);
|
|
860
860
|
return void 0;
|
|
@@ -884,7 +884,7 @@ function scrollAnchorIntoView(ref, marginTop) {
|
|
|
884
884
|
scrollNodeIntoView(node, anchorScrollBlock(node.getBoundingClientRect().bottom, readViewportBottom()));
|
|
885
885
|
}
|
|
886
886
|
function useKeepAnchorInRoom(ref, marginTop, enabled) {
|
|
887
|
-
|
|
887
|
+
React39.useLayoutEffect(() => {
|
|
888
888
|
if (!IS_WEB3 || !enabled) return void 0;
|
|
889
889
|
const place = () => scrollAnchorIntoView(ref, marginTop);
|
|
890
890
|
place();
|
|
@@ -898,7 +898,7 @@ var ESCAPE_KEY = "Escape";
|
|
|
898
898
|
var LISTBOX_ROLE = { role: "listbox" };
|
|
899
899
|
var KEEP_FIELD_FOCUS = { onMouseDown: (event) => event.preventDefault() };
|
|
900
900
|
function useDismiss(anchorRef, menuRef, onDismiss) {
|
|
901
|
-
|
|
901
|
+
React39.useEffect(() => {
|
|
902
902
|
if (!IS_WEB4) return void 0;
|
|
903
903
|
const onMouseDown = (event) => {
|
|
904
904
|
const anchorNode = anchorRef.current;
|
|
@@ -920,7 +920,7 @@ function useDismiss(anchorRef, menuRef, onDismiss) {
|
|
|
920
920
|
}, [anchorRef, menuRef, onDismiss]);
|
|
921
921
|
}
|
|
922
922
|
function useKeepHighlightInView(testID, highlightedValue) {
|
|
923
|
-
|
|
923
|
+
React39.useEffect(() => {
|
|
924
924
|
if (!IS_WEB4 || highlightedValue === void 0 || highlightedValue === "") return;
|
|
925
925
|
scrollNodeIntoView(document.getElementById(optionDomId(testID, highlightedValue)), "nearest");
|
|
926
926
|
}, [testID, highlightedValue]);
|
|
@@ -939,7 +939,7 @@ function AnchoredMenu({
|
|
|
939
939
|
listbox,
|
|
940
940
|
placement
|
|
941
941
|
}) {
|
|
942
|
-
const menuRef =
|
|
942
|
+
const menuRef = React39__default.default.useRef(null);
|
|
943
943
|
useDismiss(anchorRef, menuRef, onDismiss);
|
|
944
944
|
useKeepHighlightInView(testID, listbox?.highlightedValue);
|
|
945
945
|
const rect2 = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
|
|
@@ -1014,27 +1014,27 @@ function useThemedInput(options = {}) {
|
|
|
1014
1014
|
const { hasError = false, onFocus, onBlur, editable = true } = options;
|
|
1015
1015
|
const { theme } = uiFeedback.useUi();
|
|
1016
1016
|
const { colors, palette } = theme;
|
|
1017
|
-
const [isFocused, setIsFocused] =
|
|
1018
|
-
const [isHovered, setIsHovered] =
|
|
1019
|
-
const handleFocus =
|
|
1017
|
+
const [isFocused, setIsFocused] = React39.useState(false);
|
|
1018
|
+
const [isHovered, setIsHovered] = React39.useState(false);
|
|
1019
|
+
const handleFocus = React39.useCallback(
|
|
1020
1020
|
(e) => {
|
|
1021
1021
|
setIsFocused(true);
|
|
1022
1022
|
onFocus?.(e);
|
|
1023
1023
|
},
|
|
1024
1024
|
[onFocus]
|
|
1025
1025
|
);
|
|
1026
|
-
const handleBlur =
|
|
1026
|
+
const handleBlur = React39.useCallback(
|
|
1027
1027
|
(e) => {
|
|
1028
1028
|
setIsFocused(false);
|
|
1029
1029
|
onBlur?.(e);
|
|
1030
1030
|
},
|
|
1031
1031
|
[onBlur]
|
|
1032
1032
|
);
|
|
1033
|
-
const handleHoverIn =
|
|
1034
|
-
const handleHoverOut =
|
|
1033
|
+
const handleHoverIn = React39.useCallback(() => setIsHovered(true), []);
|
|
1034
|
+
const handleHoverOut = React39.useCallback(() => setIsHovered(false), []);
|
|
1035
1035
|
const primary = palette.primary["500"];
|
|
1036
1036
|
const errorColor = fieldErrorInk(theme);
|
|
1037
|
-
const style =
|
|
1037
|
+
const style = React39.useMemo(() => {
|
|
1038
1038
|
const restBorder = hasError ? errorColor : colors.border;
|
|
1039
1039
|
const focusBorder = hasError ? errorColor : primary;
|
|
1040
1040
|
const editableBorder = isFocused ? focusBorder : isHovered ? withAlpha(colors.text, HOVER_BORDER_ALPHA) : restBorder;
|
|
@@ -1067,8 +1067,8 @@ function useThemedInput(options = {}) {
|
|
|
1067
1067
|
errorColor,
|
|
1068
1068
|
theme
|
|
1069
1069
|
]);
|
|
1070
|
-
const focusBind =
|
|
1071
|
-
const hoverBind =
|
|
1070
|
+
const focusBind = React39.useMemo(() => ({ onFocus: handleFocus, onBlur: handleBlur }), [handleFocus, handleBlur]);
|
|
1071
|
+
const hoverBind = React39.useMemo(
|
|
1072
1072
|
() => IS_WEB5 ? { onMouseEnter: handleHoverIn, onMouseLeave: handleHoverOut } : {},
|
|
1073
1073
|
[handleHoverIn, handleHoverOut]
|
|
1074
1074
|
);
|
|
@@ -1099,7 +1099,7 @@ var boxStyles = reactNative.StyleSheet.create({
|
|
|
1099
1099
|
textAlignVertical: "top"
|
|
1100
1100
|
}
|
|
1101
1101
|
});
|
|
1102
|
-
var ThemedTextInput =
|
|
1102
|
+
var ThemedTextInput = React39__default.default.forwardRef(function ThemedTextInput2({
|
|
1103
1103
|
hasError = false,
|
|
1104
1104
|
describedById,
|
|
1105
1105
|
requiredField = false,
|
|
@@ -1194,11 +1194,11 @@ function recentsEqual(a, b) {
|
|
|
1194
1194
|
|
|
1195
1195
|
// src/useRecentValues/useRecentValues.ts
|
|
1196
1196
|
function useRecentValues(key, max = DEFAULT_MAX_RECENTS) {
|
|
1197
|
-
const [recents, setRecents] =
|
|
1198
|
-
|
|
1197
|
+
const [recents, setRecents] = React39.useState(() => readRecents(key).slice(0, max));
|
|
1198
|
+
React39.useEffect(() => {
|
|
1199
1199
|
setRecents(readRecents(key).slice(0, max));
|
|
1200
1200
|
}, [key, max]);
|
|
1201
|
-
const remember =
|
|
1201
|
+
const remember = React39.useCallback(
|
|
1202
1202
|
(value) => {
|
|
1203
1203
|
setRecents((current) => {
|
|
1204
1204
|
const next = computeNextRecents(current, value, max);
|
|
@@ -1209,7 +1209,7 @@ function useRecentValues(key, max = DEFAULT_MAX_RECENTS) {
|
|
|
1209
1209
|
},
|
|
1210
1210
|
[key, max]
|
|
1211
1211
|
);
|
|
1212
|
-
const clear =
|
|
1212
|
+
const clear = React39.useCallback(() => {
|
|
1213
1213
|
clearRecents(key);
|
|
1214
1214
|
setRecents([]);
|
|
1215
1215
|
}, [key]);
|
|
@@ -1231,24 +1231,24 @@ function RecentInputField({
|
|
|
1231
1231
|
const { theme } = uiFeedback.useUi();
|
|
1232
1232
|
const { colors, palette } = theme;
|
|
1233
1233
|
const { recents, remember } = useRecentValues(recentKey, recentMax);
|
|
1234
|
-
const anchorRef =
|
|
1235
|
-
const latestText =
|
|
1236
|
-
const [isOpen, setIsOpen] =
|
|
1237
|
-
const handleChange =
|
|
1234
|
+
const anchorRef = React39.useRef(null);
|
|
1235
|
+
const latestText = React39.useRef(typeof value === "string" ? value : "");
|
|
1236
|
+
const [isOpen, setIsOpen] = React39.useState(false);
|
|
1237
|
+
const handleChange = React39.useCallback(
|
|
1238
1238
|
(text) => {
|
|
1239
1239
|
latestText.current = text;
|
|
1240
1240
|
onChangeText?.(text);
|
|
1241
1241
|
},
|
|
1242
1242
|
[onChangeText]
|
|
1243
1243
|
);
|
|
1244
|
-
const handleFocus =
|
|
1244
|
+
const handleFocus = React39.useCallback(
|
|
1245
1245
|
(event) => {
|
|
1246
1246
|
setIsOpen(true);
|
|
1247
1247
|
onFocus?.(event);
|
|
1248
1248
|
},
|
|
1249
1249
|
[onFocus]
|
|
1250
1250
|
);
|
|
1251
|
-
const handleBlur =
|
|
1251
|
+
const handleBlur = React39.useCallback(
|
|
1252
1252
|
(event) => {
|
|
1253
1253
|
const blurredText = latestText.current;
|
|
1254
1254
|
setTimeout(() => {
|
|
@@ -1259,7 +1259,7 @@ function RecentInputField({
|
|
|
1259
1259
|
},
|
|
1260
1260
|
[remember, onBlur]
|
|
1261
1261
|
);
|
|
1262
|
-
const handleSubmit =
|
|
1262
|
+
const handleSubmit = React39.useCallback(
|
|
1263
1263
|
(event) => {
|
|
1264
1264
|
remember(latestText.current);
|
|
1265
1265
|
setIsOpen(false);
|
|
@@ -1267,7 +1267,7 @@ function RecentInputField({
|
|
|
1267
1267
|
},
|
|
1268
1268
|
[remember, onSubmitEditing]
|
|
1269
1269
|
);
|
|
1270
|
-
const pick =
|
|
1270
|
+
const pick = React39.useCallback(
|
|
1271
1271
|
(picked) => {
|
|
1272
1272
|
latestText.current = picked;
|
|
1273
1273
|
onChangeText?.(picked);
|
|
@@ -1323,8 +1323,8 @@ function rowsForText(text, inputWidth, minRows) {
|
|
|
1323
1323
|
|
|
1324
1324
|
// src/FormField/useAutoGrowRows.ts
|
|
1325
1325
|
function useAutoGrowRows(text, minRows) {
|
|
1326
|
-
const [inputWidth, setInputWidth] =
|
|
1327
|
-
const onLayout =
|
|
1326
|
+
const [inputWidth, setInputWidth] = React39.useState(NARROWEST_INPUT_WIDTH);
|
|
1327
|
+
const onLayout = React39.useCallback((event) => {
|
|
1328
1328
|
setInputWidth(event.nativeEvent.layout.width);
|
|
1329
1329
|
}, []);
|
|
1330
1330
|
return { numberOfLines: rowsForText(text, inputWidth, minRows), onLayout };
|
|
@@ -1501,7 +1501,7 @@ function ChipContent(props) {
|
|
|
1501
1501
|
}
|
|
1502
1502
|
function OutlineChip(props) {
|
|
1503
1503
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1504
|
-
const [hovered, setHovered] =
|
|
1504
|
+
const [hovered, setHovered] = React39__default.default.useState(false);
|
|
1505
1505
|
const active = selected || hovered;
|
|
1506
1506
|
const borderColor = active ? colors.primary : colors.border;
|
|
1507
1507
|
const fill = chipFill({
|
|
@@ -1615,8 +1615,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
|
|
|
1615
1615
|
var NO_GROUP_PROPS = {};
|
|
1616
1616
|
function useRadioKeyboard(config) {
|
|
1617
1617
|
const { enabled, disabled, values, selectedIndex, onChange } = config;
|
|
1618
|
-
const nodes =
|
|
1619
|
-
const chipRef =
|
|
1618
|
+
const nodes = React39__default.default.useRef([]);
|
|
1619
|
+
const chipRef = React39__default.default.useCallback((index) => (node) => {
|
|
1620
1620
|
nodes.current[index] = node;
|
|
1621
1621
|
}, []);
|
|
1622
1622
|
const onKeyDown = (event) => {
|
|
@@ -1731,7 +1731,7 @@ var ChipSelector = ({
|
|
|
1731
1731
|
const isRadioGroup = !multiple && singleSelectRole === "radio";
|
|
1732
1732
|
const { theme } = uiFeedback.useUi();
|
|
1733
1733
|
const { colors, palette } = theme;
|
|
1734
|
-
const chipColors =
|
|
1734
|
+
const chipColors = React39__default.default.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
|
|
1735
1735
|
function isSelected(optionValue) {
|
|
1736
1736
|
if (multiple && Array.isArray(value))
|
|
1737
1737
|
return value.includes(optionValue);
|
|
@@ -1790,8 +1790,95 @@ var ChipSelector = ({
|
|
|
1790
1790
|
}
|
|
1791
1791
|
);
|
|
1792
1792
|
};
|
|
1793
|
-
var
|
|
1793
|
+
var BOX_SLOT_PAD_H = 10;
|
|
1794
1794
|
var styles14 = reactNative.StyleSheet.create({
|
|
1795
|
+
row: {
|
|
1796
|
+
minWidth: a11y.MIN_TOUCH_TARGET_PX,
|
|
1797
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
1798
|
+
alignItems: "center",
|
|
1799
|
+
justifyContent: "center"
|
|
1800
|
+
},
|
|
1801
|
+
box: {
|
|
1802
|
+
alignSelf: "stretch",
|
|
1803
|
+
alignItems: "center",
|
|
1804
|
+
justifyContent: "center",
|
|
1805
|
+
paddingHorizontal: BOX_SLOT_PAD_H
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
var SwitchSlot = ({
|
|
1809
|
+
label,
|
|
1810
|
+
value,
|
|
1811
|
+
onValueChange,
|
|
1812
|
+
disabled,
|
|
1813
|
+
testID,
|
|
1814
|
+
accessibilityHint,
|
|
1815
|
+
activeTrackColor,
|
|
1816
|
+
inBox = false
|
|
1817
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "none", style: inBox ? styles14.box : styles14.row, testID: `${testID}-hitbox`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1818
|
+
reactNative.Switch,
|
|
1819
|
+
{
|
|
1820
|
+
accessibilityHint: accessibilityHint ?? label,
|
|
1821
|
+
accessibilityLabel: label,
|
|
1822
|
+
accessibilityState: { checked: value, disabled },
|
|
1823
|
+
disabled,
|
|
1824
|
+
testID: `${testID}-switch`,
|
|
1825
|
+
trackColor: activeTrackColor === void 0 ? void 0 : { true: activeTrackColor },
|
|
1826
|
+
value,
|
|
1827
|
+
onValueChange
|
|
1828
|
+
}
|
|
1829
|
+
) });
|
|
1830
|
+
var BOX_RADIUS = 8;
|
|
1831
|
+
var BOX_PAD_LEFT = 10;
|
|
1832
|
+
var BOX_BORDER = 1;
|
|
1833
|
+
var STATE_FONT_SIZE = 13;
|
|
1834
|
+
var styles15 = reactNative.StyleSheet.create({
|
|
1835
|
+
box: {
|
|
1836
|
+
flexDirection: "row",
|
|
1837
|
+
alignItems: "center",
|
|
1838
|
+
justifyContent: "space-between",
|
|
1839
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
1840
|
+
borderWidth: BOX_BORDER,
|
|
1841
|
+
borderRadius: BOX_RADIUS,
|
|
1842
|
+
paddingLeft: BOX_PAD_LEFT
|
|
1843
|
+
},
|
|
1844
|
+
state: {
|
|
1845
|
+
flex: 1,
|
|
1846
|
+
fontSize: STATE_FONT_SIZE
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
var FormSwitchBox = ({
|
|
1850
|
+
stateLabel,
|
|
1851
|
+
description,
|
|
1852
|
+
containerStyle,
|
|
1853
|
+
...slot
|
|
1854
|
+
}) => {
|
|
1855
|
+
const { colors } = uiFeedback.useUi().theme;
|
|
1856
|
+
const { disabled, onValueChange, value } = slot;
|
|
1857
|
+
const toggle2 = React39__default.default.useCallback(() => {
|
|
1858
|
+
if (!disabled) onValueChange(!value);
|
|
1859
|
+
}, [disabled, onValueChange, value]);
|
|
1860
|
+
const boxColors = React39__default.default.useMemo(
|
|
1861
|
+
() => ({ borderColor: colors.border, backgroundColor: colors.surface }),
|
|
1862
|
+
[colors.border, colors.surface]
|
|
1863
|
+
);
|
|
1864
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Field, { containerStyle, hint: description, label: slot.label, labelVariant: "control", children: () => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1865
|
+
reactNative.Pressable,
|
|
1866
|
+
{
|
|
1867
|
+
accessible: false,
|
|
1868
|
+
disabled,
|
|
1869
|
+
style: [styles15.box, boxColors],
|
|
1870
|
+
tabIndex: -1,
|
|
1871
|
+
testID: slot.testID,
|
|
1872
|
+
onPress: toggle2,
|
|
1873
|
+
children: [
|
|
1874
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles15.state, { color: colors.text }], children: stateLabel ?? "" }),
|
|
1875
|
+
/* @__PURE__ */ jsxRuntime.jsx(SwitchSlot, { ...slot, inBox: true })
|
|
1876
|
+
]
|
|
1877
|
+
}
|
|
1878
|
+
) });
|
|
1879
|
+
};
|
|
1880
|
+
var DESCRIPTION_FONT_SIZE2 = 12;
|
|
1881
|
+
var styles16 = reactNative.StyleSheet.create({
|
|
1795
1882
|
container: {
|
|
1796
1883
|
flexDirection: "row",
|
|
1797
1884
|
justifyContent: "space-between",
|
|
@@ -1801,12 +1888,6 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1801
1888
|
// `hitSlop`, so a pointer target smaller than the floor cannot be widened any other way.
|
|
1802
1889
|
minHeight: a11y.MIN_TOUCH_TARGET_PX
|
|
1803
1890
|
},
|
|
1804
|
-
switchSlot: {
|
|
1805
|
-
minWidth: a11y.MIN_TOUCH_TARGET_PX,
|
|
1806
|
-
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
1807
|
-
alignItems: "center",
|
|
1808
|
-
justifyContent: "center"
|
|
1809
|
-
},
|
|
1810
1891
|
textColumn: {
|
|
1811
1892
|
flex: 1
|
|
1812
1893
|
},
|
|
@@ -1818,23 +1899,24 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1818
1899
|
marginTop: 2
|
|
1819
1900
|
}
|
|
1820
1901
|
});
|
|
1821
|
-
var
|
|
1902
|
+
var FormSwitchRow = ({
|
|
1822
1903
|
label,
|
|
1823
1904
|
value,
|
|
1824
1905
|
onValueChange,
|
|
1825
1906
|
disabled = false,
|
|
1826
1907
|
description,
|
|
1827
1908
|
containerStyle,
|
|
1828
|
-
testID
|
|
1829
|
-
accessibilityHint
|
|
1909
|
+
testID,
|
|
1910
|
+
accessibilityHint,
|
|
1911
|
+
activeTrackColor
|
|
1830
1912
|
}) => {
|
|
1831
1913
|
const { theme } = uiFeedback.useUi();
|
|
1832
|
-
const toggle2 =
|
|
1914
|
+
const toggle2 = React39__default.default.useCallback(() => {
|
|
1833
1915
|
if (!disabled) onValueChange(!value);
|
|
1834
1916
|
}, [disabled, onValueChange, value]);
|
|
1835
1917
|
const { colors } = theme;
|
|
1836
1918
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1837
|
-
const themeStyles =
|
|
1919
|
+
const themeStyles = React39__default.default.useMemo(() => {
|
|
1838
1920
|
const labelStyle = { color: colors.text };
|
|
1839
1921
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1840
1922
|
return { label: labelStyle, description: descriptionStyle };
|
|
@@ -1852,38 +1934,45 @@ var FormSwitch = ({
|
|
|
1852
1934
|
accessible: false,
|
|
1853
1935
|
disabled,
|
|
1854
1936
|
onPress: toggle2,
|
|
1855
|
-
style: [
|
|
1937
|
+
style: [styles16.container, containerStyle],
|
|
1856
1938
|
tabIndex: -1,
|
|
1857
1939
|
testID,
|
|
1858
1940
|
children: [
|
|
1859
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1860
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1861
|
-
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1941
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.textColumn, children: [
|
|
1942
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles16.label, themeStyles.label], children: label }),
|
|
1943
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles16.description, themeStyles.description], children: description }) : null
|
|
1862
1944
|
] }),
|
|
1863
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1864
|
-
|
|
1945
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1946
|
+
SwitchSlot,
|
|
1865
1947
|
{
|
|
1866
|
-
accessibilityHint
|
|
1867
|
-
|
|
1868
|
-
accessibilityState: { checked: value, disabled },
|
|
1948
|
+
accessibilityHint,
|
|
1949
|
+
activeTrackColor,
|
|
1869
1950
|
disabled,
|
|
1870
|
-
|
|
1951
|
+
label,
|
|
1952
|
+
testID,
|
|
1871
1953
|
value,
|
|
1872
1954
|
onValueChange
|
|
1873
1955
|
}
|
|
1874
|
-
)
|
|
1956
|
+
)
|
|
1875
1957
|
]
|
|
1876
1958
|
}
|
|
1877
1959
|
)
|
|
1878
1960
|
);
|
|
1879
1961
|
};
|
|
1962
|
+
var FormSwitch = ({
|
|
1963
|
+
variant = "row",
|
|
1964
|
+
stateLabel,
|
|
1965
|
+
testID = "form-switch",
|
|
1966
|
+
disabled = false,
|
|
1967
|
+
...props
|
|
1968
|
+
}) => variant === "box" ? /* @__PURE__ */ jsxRuntime.jsx(FormSwitchBox, { ...props, disabled, stateLabel, testID }) : /* @__PURE__ */ jsxRuntime.jsx(FormSwitchRow, { ...props, disabled, testID });
|
|
1880
1969
|
|
|
1881
1970
|
// src/FormCheckbox/checkboxColors.ts
|
|
1882
1971
|
var checkboxBoxColors = (colors, brand, checked) => checked ? { backgroundColor: brand, borderColor: brand } : { backgroundColor: "transparent", borderColor: colors.textSecondary };
|
|
1883
1972
|
var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
|
|
1884
1973
|
var HINT_FONT_SIZE2 = 12;
|
|
1885
1974
|
var BOX_SIZE = 20;
|
|
1886
|
-
var
|
|
1975
|
+
var BOX_RADIUS2 = 5;
|
|
1887
1976
|
var TICK_WIDTH = 6;
|
|
1888
1977
|
var TICK_HEIGHT = 10;
|
|
1889
1978
|
var TICK_STROKE = 2;
|
|
@@ -1892,7 +1981,7 @@ var DISABLED_OPACITY = 0.5;
|
|
|
1892
1981
|
var FOCUS_RING_WIDTH = 2;
|
|
1893
1982
|
var WEB_NO_DEFAULT_OUTLINE = { outlineStyle: "none" };
|
|
1894
1983
|
var FOCUS_RING_INSET = -6;
|
|
1895
|
-
var
|
|
1984
|
+
var styles17 = reactNative.StyleSheet.create({
|
|
1896
1985
|
container: {
|
|
1897
1986
|
flexDirection: "row",
|
|
1898
1987
|
alignItems: "flex-start",
|
|
@@ -1909,7 +1998,7 @@ var styles15 = reactNative.StyleSheet.create({
|
|
|
1909
1998
|
box: {
|
|
1910
1999
|
width: BOX_SIZE,
|
|
1911
2000
|
height: BOX_SIZE,
|
|
1912
|
-
borderRadius:
|
|
2001
|
+
borderRadius: BOX_RADIUS2,
|
|
1913
2002
|
borderWidth: 2,
|
|
1914
2003
|
alignItems: "center",
|
|
1915
2004
|
justifyContent: "center",
|
|
@@ -1923,7 +2012,7 @@ var styles15 = reactNative.StyleSheet.create({
|
|
|
1923
2012
|
right: FOCUS_RING_INSET,
|
|
1924
2013
|
bottom: FOCUS_RING_INSET,
|
|
1925
2014
|
borderWidth: FOCUS_RING_WIDTH,
|
|
1926
|
-
borderRadius:
|
|
2015
|
+
borderRadius: BOX_RADIUS2 - FOCUS_RING_INSET
|
|
1927
2016
|
},
|
|
1928
2017
|
tick: {
|
|
1929
2018
|
width: TICK_WIDTH,
|
|
@@ -1963,8 +2052,8 @@ var FormCheckbox = ({
|
|
|
1963
2052
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
1964
2053
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
1965
2054
|
const { hintId } = useFieldIds();
|
|
1966
|
-
const [focused, setFocused] =
|
|
1967
|
-
const themeStyles =
|
|
2055
|
+
const [focused, setFocused] = React39__default.default.useState(false);
|
|
2056
|
+
const themeStyles = React39__default.default.useMemo(() => {
|
|
1968
2057
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
1969
2058
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
1970
2059
|
const ring = { borderColor: brand };
|
|
@@ -2000,8 +2089,8 @@ var FormCheckbox = ({
|
|
|
2000
2089
|
onPress: toggle2,
|
|
2001
2090
|
role: "checkbox",
|
|
2002
2091
|
style: [
|
|
2003
|
-
|
|
2004
|
-
hasHint ? null :
|
|
2092
|
+
styles17.container,
|
|
2093
|
+
hasHint ? null : styles17.centered,
|
|
2005
2094
|
containerStyle,
|
|
2006
2095
|
disabled ? { opacity: DISABLED_OPACITY } : null,
|
|
2007
2096
|
reactNative.Platform.OS === "web" ? WEB_NO_DEFAULT_OUTLINE : null
|
|
@@ -2009,13 +2098,13 @@ var FormCheckbox = ({
|
|
|
2009
2098
|
testID,
|
|
2010
2099
|
...keyboardProps,
|
|
2011
2100
|
children: [
|
|
2012
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
2013
|
-
focused ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "none", style: [
|
|
2014
|
-
value ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityElementsHidden: true, pointerEvents: "none", style: [
|
|
2101
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles17.box, value ? themeStyles.boxOn : themeStyles.boxOff], testID: `${testID}-box`, children: [
|
|
2102
|
+
focused ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "none", style: [styles17.focusRing, themeStyles.ring], testID: `${testID}-focus-ring` }) : null,
|
|
2103
|
+
value ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityElementsHidden: true, pointerEvents: "none", style: [styles17.tick, { borderColor: colors.surface }], testID: `${testID}-tick` }) : null
|
|
2015
2104
|
] }),
|
|
2016
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2017
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2018
|
-
hasHint ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { nativeID: hintId, style: [
|
|
2105
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles17.textColumn, children: [
|
|
2106
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles17.label, themeStyles.label], children: label }),
|
|
2107
|
+
hasHint ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { nativeID: hintId, style: [styles17.hint, themeStyles.hint], children: hintText }) : null
|
|
2019
2108
|
] })
|
|
2020
2109
|
]
|
|
2021
2110
|
}
|
|
@@ -2089,9 +2178,9 @@ function nextHighlight(current, count, delta) {
|
|
|
2089
2178
|
var FORWARD = 1;
|
|
2090
2179
|
var BACKWARD = -1;
|
|
2091
2180
|
function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
2092
|
-
const [row, setRow] =
|
|
2181
|
+
const [row, setRow] = React39.useState(NO_HIGHLIGHT);
|
|
2093
2182
|
const highlighted = isOpen ? options[row] : void 0;
|
|
2094
|
-
|
|
2183
|
+
React39.useEffect(() => {
|
|
2095
2184
|
if (!isOpen) setRow(NO_HIGHLIGHT);
|
|
2096
2185
|
}, [isOpen]);
|
|
2097
2186
|
const onKeyDown = (event) => {
|
|
@@ -2136,22 +2225,22 @@ function MenuSelectControl({
|
|
|
2136
2225
|
}) {
|
|
2137
2226
|
const { theme } = uiFeedback.useUi();
|
|
2138
2227
|
const { colors, palette } = theme;
|
|
2139
|
-
const anchorRef =
|
|
2140
|
-
const [isOpen, setIsOpen] =
|
|
2141
|
-
const selectedLabel =
|
|
2228
|
+
const anchorRef = React39.useRef(null);
|
|
2229
|
+
const [isOpen, setIsOpen] = React39.useState(false);
|
|
2230
|
+
const selectedLabel = React39.useMemo(() => {
|
|
2142
2231
|
const found = options.find((o) => o.value === value);
|
|
2143
2232
|
return found?.label ?? placeholder;
|
|
2144
2233
|
}, [options, placeholder, value]);
|
|
2145
|
-
const close =
|
|
2234
|
+
const close = React39.useCallback(() => {
|
|
2146
2235
|
setIsOpen(false);
|
|
2147
2236
|
}, []);
|
|
2148
|
-
const open =
|
|
2237
|
+
const open = React39.useCallback(() => {
|
|
2149
2238
|
setIsOpen(true);
|
|
2150
2239
|
}, []);
|
|
2151
|
-
const toggle2 =
|
|
2240
|
+
const toggle2 = React39.useCallback(() => {
|
|
2152
2241
|
setIsOpen((prev) => !prev);
|
|
2153
2242
|
}, []);
|
|
2154
|
-
const select =
|
|
2243
|
+
const select = React39.useCallback(
|
|
2155
2244
|
(next) => {
|
|
2156
2245
|
onChange(next);
|
|
2157
2246
|
setIsOpen(false);
|
|
@@ -2231,7 +2320,7 @@ var CHIP_PAD_H = 8;
|
|
|
2231
2320
|
var CHIP_PAD_V = 4;
|
|
2232
2321
|
var CHIP_RADIUS = 999;
|
|
2233
2322
|
var CHIP_FONT = 13;
|
|
2234
|
-
var
|
|
2323
|
+
var styles18 = reactNative.StyleSheet.create({
|
|
2235
2324
|
chip: {
|
|
2236
2325
|
flexDirection: "row",
|
|
2237
2326
|
alignItems: "center",
|
|
@@ -2252,12 +2341,12 @@ function SelectedChip({ option, colors, removeLabel, removeHint, onRemove, testI
|
|
|
2252
2341
|
accessibilityLabel: removeLabel,
|
|
2253
2342
|
accessibilityRole: "button",
|
|
2254
2343
|
hitSlop: CHIP_HIT_SLOP,
|
|
2255
|
-
style: [
|
|
2344
|
+
style: [styles18.chip, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
2256
2345
|
testID,
|
|
2257
2346
|
onPress: () => onRemove(option.value),
|
|
2258
2347
|
children: [
|
|
2259
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [
|
|
2260
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [
|
|
2348
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles18.text, { color: colors.text }], children: option.label }),
|
|
2349
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [styles18.text, { color: colors.text }], children: REMOVE_GLYPH })
|
|
2261
2350
|
]
|
|
2262
2351
|
}
|
|
2263
2352
|
);
|
|
@@ -2280,7 +2369,7 @@ var CHEVRON_DOWN2 = "\u25BE";
|
|
|
2280
2369
|
var CHEVRON_UP2 = "\u25B4";
|
|
2281
2370
|
var BOX_GAP = 6;
|
|
2282
2371
|
var TRIGGER_MIN_WIDTH = 96;
|
|
2283
|
-
var
|
|
2372
|
+
var styles19 = reactNative.StyleSheet.create({
|
|
2284
2373
|
box: { flexWrap: "wrap", justifyContent: "flex-start", gap: BOX_GAP },
|
|
2285
2374
|
trigger: {
|
|
2286
2375
|
flexGrow: 1,
|
|
@@ -2294,27 +2383,27 @@ var styles17 = reactNative.StyleSheet.create({
|
|
|
2294
2383
|
function MultiSelectBox(props) {
|
|
2295
2384
|
const { label, accessibilityHint, values, options, onChange, placeholder, chipLabels, testID, labelId } = props;
|
|
2296
2385
|
const { colors, palette } = uiFeedback.useUi().theme;
|
|
2297
|
-
const anchorRef =
|
|
2298
|
-
const [isOpen, setIsOpen] =
|
|
2386
|
+
const anchorRef = React39.useRef(null);
|
|
2387
|
+
const [isOpen, setIsOpen] = React39.useState(false);
|
|
2299
2388
|
const chosen = selectedOptions(options, values);
|
|
2300
2389
|
const remaining = remainingOptions(options, values);
|
|
2301
|
-
const close =
|
|
2390
|
+
const close = React39.useCallback(() => {
|
|
2302
2391
|
setIsOpen(false);
|
|
2303
2392
|
}, []);
|
|
2304
|
-
const toggle2 =
|
|
2393
|
+
const toggle2 = React39.useCallback(() => {
|
|
2305
2394
|
setIsOpen((prev) => !prev);
|
|
2306
2395
|
}, []);
|
|
2307
|
-
const add =
|
|
2396
|
+
const add = React39.useCallback((next) => {
|
|
2308
2397
|
onChange(addValue(values, next));
|
|
2309
2398
|
setIsOpen(false);
|
|
2310
2399
|
}, [onChange, values]);
|
|
2311
|
-
const remove =
|
|
2400
|
+
const remove = React39.useCallback((value) => {
|
|
2312
2401
|
onChange(removeValue(values, value));
|
|
2313
2402
|
}, [onChange, values]);
|
|
2314
2403
|
const chipColors = { text: colors.text, border: colors.border, surface: colors.surface };
|
|
2315
2404
|
const summary = chosen.map((option) => option.label).join(", ");
|
|
2316
2405
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: controlStyles.anchor, children: [
|
|
2317
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.selectTrigger,
|
|
2406
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.selectTrigger, styles19.box, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], testID: `${testID}-box`, children: [
|
|
2318
2407
|
chosen.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2319
2408
|
SelectedChip,
|
|
2320
2409
|
{
|
|
@@ -2338,7 +2427,7 @@ function MultiSelectBox(props) {
|
|
|
2338
2427
|
"aria-haspopup": "menu",
|
|
2339
2428
|
"aria-labelledby": labelId,
|
|
2340
2429
|
disabled: remaining.length === 0,
|
|
2341
|
-
style:
|
|
2430
|
+
style: styles19.trigger,
|
|
2342
2431
|
testID: `${testID}-trigger`,
|
|
2343
2432
|
onPress: toggle2,
|
|
2344
2433
|
children: [
|
|
@@ -2366,17 +2455,17 @@ function MultiSelectBox(props) {
|
|
|
2366
2455
|
var MultiSelectField = ({ labelVariant, hint, error, ...boxProps }) => /* @__PURE__ */ jsxRuntime.jsx(Field, { error, hint, label: boxProps.label, labelVariant, children: ({ labelId }) => /* @__PURE__ */ jsxRuntime.jsx(MultiSelectBox, { ...boxProps, labelId }) });
|
|
2367
2456
|
var CLOSE_DELAY_MS2 = 140;
|
|
2368
2457
|
function useDelayedBlurClose(open, close) {
|
|
2369
|
-
const timerRef =
|
|
2370
|
-
const cancelClose =
|
|
2458
|
+
const timerRef = React39.useRef(null);
|
|
2459
|
+
const cancelClose = React39.useCallback(() => {
|
|
2371
2460
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
2372
2461
|
timerRef.current = null;
|
|
2373
2462
|
}, []);
|
|
2374
|
-
|
|
2375
|
-
const handleFocus =
|
|
2463
|
+
React39.useEffect(() => cancelClose, [cancelClose]);
|
|
2464
|
+
const handleFocus = React39.useCallback(() => {
|
|
2376
2465
|
cancelClose();
|
|
2377
2466
|
open();
|
|
2378
2467
|
}, [cancelClose, open]);
|
|
2379
|
-
const handleBlur =
|
|
2468
|
+
const handleBlur = React39.useCallback(() => {
|
|
2380
2469
|
cancelClose();
|
|
2381
2470
|
timerRef.current = setTimeout(close, CLOSE_DELAY_MS2);
|
|
2382
2471
|
}, [cancelClose, close]);
|
|
@@ -2419,10 +2508,10 @@ function isUnmatched(options, text) {
|
|
|
2419
2508
|
var DEFAULT_TYPEAHEAD_DEBOUNCE_MS = 250;
|
|
2420
2509
|
var IDLE = { results: [], isLoading: false, hasFailed: false, hasSettled: false };
|
|
2421
2510
|
function useTypeaheadSearch(load, query, enabled, debounceMs) {
|
|
2422
|
-
const [state, setState] =
|
|
2423
|
-
const loadRef =
|
|
2511
|
+
const [state, setState] = React39.useState(IDLE);
|
|
2512
|
+
const loadRef = React39.useRef(load);
|
|
2424
2513
|
loadRef.current = load;
|
|
2425
|
-
|
|
2514
|
+
React39.useEffect(() => {
|
|
2426
2515
|
if (!enabled) {
|
|
2427
2516
|
setState(IDLE);
|
|
2428
2517
|
return void 0;
|
|
@@ -2461,30 +2550,30 @@ function useTypeaheadRows(input, isOpen, isPicked) {
|
|
|
2461
2550
|
const query = value.trim();
|
|
2462
2551
|
const isSearching = search !== void 0 && isOpen && !isPicked && query.length >= minChars;
|
|
2463
2552
|
const found = useTypeaheadSearch(search?.load, query, isSearching, search?.debounceMs ?? DEFAULT_TYPEAHEAD_DEBOUNCE_MS);
|
|
2464
|
-
const staticRows =
|
|
2553
|
+
const staticRows = React39.useMemo(() => {
|
|
2465
2554
|
if (options === void 0 || options.some((o) => o.label === value)) return NO_ROWS;
|
|
2466
2555
|
return suggestOptions(options, value, minChars, maxSuggestions);
|
|
2467
2556
|
}, [options, value, minChars, maxSuggestions]);
|
|
2468
|
-
const foundRows =
|
|
2557
|
+
const foundRows = React39.useMemo(() => found.results.slice(0, maxSuggestions), [found.results, maxSuggestions]);
|
|
2469
2558
|
if (search === void 0) return { rows: staticRows, statusText: void 0 };
|
|
2470
2559
|
return { rows: foundRows, statusText: searchStatusText(found, search) };
|
|
2471
2560
|
}
|
|
2472
2561
|
function useTypeaheadState(input) {
|
|
2473
2562
|
const { search, value, onChange, onSubmit } = input;
|
|
2474
|
-
const [isOpen, setIsOpen] =
|
|
2475
|
-
const [picked, setPicked] =
|
|
2476
|
-
const [highlightIndex, setHighlightIndex] =
|
|
2563
|
+
const [isOpen, setIsOpen] = React39.useState(false);
|
|
2564
|
+
const [picked, setPicked] = React39.useState(null);
|
|
2565
|
+
const [highlightIndex, setHighlightIndex] = React39.useState(NO_HIGHLIGHT);
|
|
2477
2566
|
const { rows, statusText } = useTypeaheadRows(input, isOpen, picked !== null && picked.label === value);
|
|
2478
2567
|
const rowKey = rows.map((row) => row.value).join("\n");
|
|
2479
2568
|
const highlighted = isOpen ? rows[highlightIndex] : void 0;
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
const open =
|
|
2483
|
-
const close =
|
|
2569
|
+
React39.useEffect(() => setHighlightIndex(NO_HIGHLIGHT), [rowKey]);
|
|
2570
|
+
React39.useEffect(() => setPicked((current) => current !== null && current.label !== value ? null : current), [value]);
|
|
2571
|
+
const open = React39.useCallback(() => setIsOpen(true), []);
|
|
2572
|
+
const close = React39.useCallback(() => {
|
|
2484
2573
|
setIsOpen(false);
|
|
2485
2574
|
setHighlightIndex(NO_HIGHLIGHT);
|
|
2486
2575
|
}, []);
|
|
2487
|
-
const pick =
|
|
2576
|
+
const pick = React39.useCallback(
|
|
2488
2577
|
(option) => {
|
|
2489
2578
|
setPicked(option);
|
|
2490
2579
|
onChange(option.label);
|
|
@@ -2493,14 +2582,14 @@ function useTypeaheadState(input) {
|
|
|
2493
2582
|
},
|
|
2494
2583
|
[onChange, search, close]
|
|
2495
2584
|
);
|
|
2496
|
-
const selectValue =
|
|
2585
|
+
const selectValue = React39.useCallback(
|
|
2497
2586
|
(optionValue) => {
|
|
2498
2587
|
const option = rows.find((row) => row.value === optionValue);
|
|
2499
2588
|
if (option !== void 0) pick(option);
|
|
2500
2589
|
},
|
|
2501
2590
|
[rows, pick]
|
|
2502
2591
|
);
|
|
2503
|
-
const handleChange =
|
|
2592
|
+
const handleChange = React39.useCallback(
|
|
2504
2593
|
(next) => {
|
|
2505
2594
|
if (picked !== null) {
|
|
2506
2595
|
setPicked(null);
|
|
@@ -2513,7 +2602,7 @@ function useTypeaheadState(input) {
|
|
|
2513
2602
|
[picked, search, onChange]
|
|
2514
2603
|
);
|
|
2515
2604
|
const handleKeyPress = useTypeaheadKeys({ rowCount: rows.length, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick });
|
|
2516
|
-
const handleSubmit =
|
|
2605
|
+
const handleSubmit = React39.useCallback(() => {
|
|
2517
2606
|
if (highlighted !== void 0) {
|
|
2518
2607
|
pick(highlighted);
|
|
2519
2608
|
return;
|
|
@@ -2525,7 +2614,7 @@ function useTypeaheadState(input) {
|
|
|
2525
2614
|
}
|
|
2526
2615
|
function useTypeaheadKeys(input) {
|
|
2527
2616
|
const { rowCount, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick } = input;
|
|
2528
|
-
return
|
|
2617
|
+
return React39.useCallback(
|
|
2529
2618
|
(event) => {
|
|
2530
2619
|
const { key } = event.nativeEvent;
|
|
2531
2620
|
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
@@ -2562,7 +2651,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2562
2651
|
const maxSuggestions = ("search" in props ? props.search.maxResults : props.maxSuggestions) ?? DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
|
|
2563
2652
|
const { theme } = uiFeedback.useUi();
|
|
2564
2653
|
const { colors, palette } = theme;
|
|
2565
|
-
const anchorRef =
|
|
2654
|
+
const anchorRef = React39.useRef(null);
|
|
2566
2655
|
const state = useTypeaheadState({ options, search, value, minChars, maxSuggestions, onChange, onSubmit });
|
|
2567
2656
|
const { handleFocus, handleBlur } = useDelayedBlurClose(state.open, state.close);
|
|
2568
2657
|
const showMenu = state.isOpen && (state.rows.length > 0 || state.statusText !== void 0);
|
|
@@ -2615,7 +2704,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2615
2704
|
hasError ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [controlStyles.error, { color: fieldErrorInk(theme) }], testID: `${testID}-error`, children: error }) : null
|
|
2616
2705
|
] });
|
|
2617
2706
|
}
|
|
2618
|
-
var TypeaheadControl =
|
|
2707
|
+
var TypeaheadControl = React39.forwardRef(TypeaheadControlImpl);
|
|
2619
2708
|
var NATIVE_INPUT_BOX = {
|
|
2620
2709
|
borderStyle: "solid",
|
|
2621
2710
|
boxSizing: "border-box",
|
|
@@ -2703,7 +2792,7 @@ function tabStops(container) {
|
|
|
2703
2792
|
}
|
|
2704
2793
|
function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
2705
2794
|
const colors = usePickerColors();
|
|
2706
|
-
const ref =
|
|
2795
|
+
const ref = React39.useRef(null);
|
|
2707
2796
|
const onKeyDown = (event) => {
|
|
2708
2797
|
if (event.key === "Escape") {
|
|
2709
2798
|
event.preventDefault();
|
|
@@ -2726,8 +2815,8 @@ function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
|
2726
2815
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-testid": testID, "data-variant": sheet ? "sheet" : "popover", style, onKeyDown, children });
|
|
2727
2816
|
}
|
|
2728
2817
|
function useAnchorRect2(anchorRef) {
|
|
2729
|
-
const [rect2, setRect] =
|
|
2730
|
-
|
|
2818
|
+
const [rect2, setRect] = React39.useState(null);
|
|
2819
|
+
React39.useEffect(() => {
|
|
2731
2820
|
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2732
2821
|
}, [anchorRef]);
|
|
2733
2822
|
return rect2;
|
|
@@ -2770,32 +2859,32 @@ function fitDropdownWidth(frame, viewportWidth, minWidth = MIN_PANEL_WIDTH) {
|
|
|
2770
2859
|
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children, minWidth, scale, accessibilityLabel, preferBelow = false }) {
|
|
2771
2860
|
const { height: viewportHeight, width: viewportWidth } = reactNative.useWindowDimensions();
|
|
2772
2861
|
const anchor = useAnchorRect2(anchorRef);
|
|
2773
|
-
const [panelHeight, setPanelHeight] =
|
|
2774
|
-
const onLayout =
|
|
2862
|
+
const [panelHeight, setPanelHeight] = React39.useState(0);
|
|
2863
|
+
const onLayout = React39.useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2775
2864
|
const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight, preferBelow), viewportWidth, minWidth);
|
|
2776
2865
|
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2777
2866
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: [
|
|
2778
2867
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2779
|
-
frame !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [
|
|
2868
|
+
frame !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles20.dropdown, place, { opacity: progress, transform: scale === void 0 ? [{ translateY }] : [{ translateY }, { scale }] }, scale === void 0 ? null : styles20.growFromField], testID: `${testID}-dropdown-${frame.placement}`, onLayout, children }) : null
|
|
2780
2869
|
] });
|
|
2781
2870
|
}
|
|
2782
|
-
var
|
|
2871
|
+
var styles20 = reactNative.StyleSheet.create({
|
|
2783
2872
|
dropdown: { position: "absolute" },
|
|
2784
2873
|
growFromField: { transformOrigin: "top left" }
|
|
2785
2874
|
});
|
|
2786
2875
|
function SheetSurface({ translateY, onDismiss, closeLabel, closeHint, testID, children, progress, scale, accessibilityLabel }) {
|
|
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:
|
|
2876
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles21.backdrop, children: [
|
|
2788
2877
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2789
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { testID: `${testID}-sheet`, style: [
|
|
2878
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { testID: `${testID}-sheet`, style: [styles21.sheet, { transform: scale === void 0 ? [{ translateY }] : [{ translateY }, { scale }] }, progress === void 0 ? null : { opacity: progress }], children })
|
|
2790
2879
|
] }) });
|
|
2791
2880
|
}
|
|
2792
|
-
var
|
|
2881
|
+
var styles21 = reactNative.StyleSheet.create({
|
|
2793
2882
|
backdrop: { flex: 1, justifyContent: "flex-end" },
|
|
2794
2883
|
sheet: { width: "100%", alignSelf: "stretch" }
|
|
2795
2884
|
});
|
|
2796
2885
|
function useReducedMotion() {
|
|
2797
|
-
const [reduced, setReduced] =
|
|
2798
|
-
|
|
2886
|
+
const [reduced, setReduced] = React39.useState(false);
|
|
2887
|
+
React39.useEffect(() => {
|
|
2799
2888
|
let active = true;
|
|
2800
2889
|
reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
2801
2890
|
if (active) setReduced(value);
|
|
@@ -3006,14 +3095,14 @@ function weekFirstDay(locale) {
|
|
|
3006
3095
|
return MONDAY3;
|
|
3007
3096
|
}
|
|
3008
3097
|
}
|
|
3009
|
-
var DatePickerContext =
|
|
3098
|
+
var DatePickerContext = React39.createContext({ labels: DEFAULT_DATE_PICKER_LABELS });
|
|
3010
3099
|
function DatePickerProvider({ labels, locale, today, display, children }) {
|
|
3011
|
-
const value =
|
|
3100
|
+
const value = React39.useMemo(() => ({ labels: { ...DEFAULT_DATE_PICKER_LABELS, ...labels }, locale, today, display }), [labels, locale, today, display]);
|
|
3012
3101
|
return /* @__PURE__ */ jsxRuntime.jsx(DatePickerContext.Provider, { value, children });
|
|
3013
3102
|
}
|
|
3014
3103
|
function useDatePickerConfig() {
|
|
3015
|
-
const config =
|
|
3016
|
-
const firstDay =
|
|
3104
|
+
const config = React39.useContext(DatePickerContext);
|
|
3105
|
+
const firstDay = React39.useMemo(() => weekFirstDay(config.locale), [config.locale]);
|
|
3017
3106
|
return { labels: config.labels, locale: config.locale, today: config.today ?? todayIso(), firstDay, display: config.display ?? "long" /* Long */ };
|
|
3018
3107
|
}
|
|
3019
3108
|
|
|
@@ -3036,8 +3125,8 @@ function monthSlideStyle(entered, reduced, direction) {
|
|
|
3036
3125
|
}
|
|
3037
3126
|
function useOpenProgress() {
|
|
3038
3127
|
const { durationMs, fromScale } = resolveOpenMotion(useReducedMotion());
|
|
3039
|
-
const progress =
|
|
3040
|
-
|
|
3128
|
+
const progress = React39.useRef(new reactNative.Animated.Value(0)).current;
|
|
3129
|
+
React39.useEffect(() => {
|
|
3041
3130
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
3042
3131
|
}, [progress, durationMs]);
|
|
3043
3132
|
return {
|
|
@@ -3083,16 +3172,16 @@ function dayDomId(testID, iso) {
|
|
|
3083
3172
|
}
|
|
3084
3173
|
function useGridFocus(initial, bounds, testID, onPick) {
|
|
3085
3174
|
const { firstDay } = useDatePickerConfig();
|
|
3086
|
-
const [focusedDay, setFocusedDay] =
|
|
3087
|
-
const focusPending =
|
|
3175
|
+
const [focusedDay, setFocusedDay] = React39.useState(initial);
|
|
3176
|
+
const focusPending = React39.useRef(true);
|
|
3088
3177
|
const { min, max } = bounds;
|
|
3089
|
-
|
|
3178
|
+
React39.useEffect(() => {
|
|
3090
3179
|
if (!focusPending.current) return;
|
|
3091
3180
|
focusPending.current = false;
|
|
3092
3181
|
document.getElementById(dayDomId(testID, focusedDay))?.focus();
|
|
3093
3182
|
}, [focusedDay, testID]);
|
|
3094
|
-
const moveTo =
|
|
3095
|
-
const onDayKey =
|
|
3183
|
+
const moveTo = React39.useCallback((iso) => setFocusedDay(clampToBounds(iso, min, max)), [min, max]);
|
|
3184
|
+
const onDayKey = React39.useCallback(
|
|
3096
3185
|
(event, iso) => {
|
|
3097
3186
|
if (event.key === "Enter" || event.key === " ") {
|
|
3098
3187
|
event.preventDefault();
|
|
@@ -3179,8 +3268,8 @@ function MonthGrid({ month, selection: selection2, focusedDay, bounds, testID, o
|
|
|
3179
3268
|
const { labels, locale, today, firstDay } = useDatePickerConfig();
|
|
3180
3269
|
const colors = usePickerColors();
|
|
3181
3270
|
const parts = parseIso(month) ?? FALLBACK;
|
|
3182
|
-
const weeks =
|
|
3183
|
-
const weekdays =
|
|
3271
|
+
const weeks = React39.useMemo(() => buildMonthGrid(parts.year, parts.month, firstDay), [parts.year, parts.month, firstDay]);
|
|
3272
|
+
const weekdays = React39.useMemo(() => weekdayNames(locale, firstDay), [locale, firstDay]);
|
|
3184
3273
|
const title = formatMonthYear(month, locale);
|
|
3185
3274
|
const end = selection2.to === "" ? selection2.from : selection2.to;
|
|
3186
3275
|
const stateOf = (iso) => ({
|
|
@@ -3219,7 +3308,7 @@ function MonthHeader({ focusedDay, bounds, testID, onMove }) {
|
|
|
3219
3308
|
const { labels, locale } = useDatePickerConfig();
|
|
3220
3309
|
const colors = usePickerColors();
|
|
3221
3310
|
const parts = parseIso(focusedDay) ?? FALLBACK2;
|
|
3222
|
-
const names =
|
|
3311
|
+
const names = React39.useMemo(() => monthNames(locale), [locale]);
|
|
3223
3312
|
const setMonthYear = (year, month) => onMove(toIso({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) }));
|
|
3224
3313
|
const selectStyle = { minHeight: a11y.MIN_TOUCH_TARGET_PX, border: "none", background: "transparent", color: colors.text, fontWeight: BOLD3, fontSize: FONT2, fontFamily: "inherit", cursor: "pointer" };
|
|
3225
3314
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
@@ -3240,8 +3329,8 @@ function PickerFooter({ summary, children }) {
|
|
|
3240
3329
|
] });
|
|
3241
3330
|
}
|
|
3242
3331
|
function useEntered(key, reduced) {
|
|
3243
|
-
const [enteredKey, setEnteredKey] =
|
|
3244
|
-
|
|
3332
|
+
const [enteredKey, setEnteredKey] = React39.useState(null);
|
|
3333
|
+
React39.useEffect(() => {
|
|
3245
3334
|
if (reduced) return void 0;
|
|
3246
3335
|
let inner = 0;
|
|
3247
3336
|
const outer = requestAnimationFrame(() => {
|
|
@@ -3256,8 +3345,8 @@ function useEntered(key, reduced) {
|
|
|
3256
3345
|
}
|
|
3257
3346
|
function useMonthSlide(month) {
|
|
3258
3347
|
const reduced = useReducedMotion();
|
|
3259
|
-
const previous =
|
|
3260
|
-
const direction =
|
|
3348
|
+
const previous = React39.useRef(month);
|
|
3349
|
+
const direction = React39.useRef(0);
|
|
3261
3350
|
if (previous.current !== month) {
|
|
3262
3351
|
direction.current = month > previous.current ? 1 : -1;
|
|
3263
3352
|
previous.current = month;
|
|
@@ -3267,7 +3356,7 @@ function useMonthSlide(month) {
|
|
|
3267
3356
|
}
|
|
3268
3357
|
function SingleCalendar({ value, bounds, testID, onCommit }) {
|
|
3269
3358
|
const { labels, today } = useDatePickerConfig();
|
|
3270
|
-
const [draft, setDraft] =
|
|
3359
|
+
const [draft, setDraft] = React39.useState(value);
|
|
3271
3360
|
const grid = useGridFocus(clampToBounds(value !== "" ? value : today, bounds.min, bounds.max), bounds, testID, setDraft);
|
|
3272
3361
|
const month = monthStart(grid.focusedDay);
|
|
3273
3362
|
const motion = useMonthSlide(month);
|
|
@@ -3288,8 +3377,8 @@ function useIsPhone() {
|
|
|
3288
3377
|
return !isWideFormLayout(reactNative.useWindowDimensions().width);
|
|
3289
3378
|
}
|
|
3290
3379
|
function useReturnFocus(open, target) {
|
|
3291
|
-
const wasOpen =
|
|
3292
|
-
|
|
3380
|
+
const wasOpen = React39.useRef(open);
|
|
3381
|
+
React39.useEffect(() => {
|
|
3293
3382
|
const closed = wasOpen.current && !open;
|
|
3294
3383
|
wasOpen.current = open;
|
|
3295
3384
|
if (!closed) return void 0;
|
|
@@ -3299,9 +3388,9 @@ function useReturnFocus(open, target) {
|
|
|
3299
3388
|
}
|
|
3300
3389
|
function useTypedDate({ value, onChange, bounds, format, onError, rangeMessage, editOnType = false }) {
|
|
3301
3390
|
const { labels, locale } = useDatePickerConfig();
|
|
3302
|
-
const [editing, setEditing] =
|
|
3303
|
-
const [text, setText] =
|
|
3304
|
-
|
|
3391
|
+
const [editing, setEditing] = React39.useState(false);
|
|
3392
|
+
const [text, setText] = React39.useState("");
|
|
3393
|
+
React39.useEffect(() => {
|
|
3305
3394
|
setText((current) => {
|
|
3306
3395
|
const parsed = current.trim() === "" ? "" : parseTyped(current, locale);
|
|
3307
3396
|
if (parsed === null || parsed === value) return current;
|
|
@@ -3421,16 +3510,16 @@ function DatePickerInput({ fieldProps, context, onTypedError }) {
|
|
|
3421
3510
|
const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
|
|
3422
3511
|
const { labels, display } = useDatePickerConfig();
|
|
3423
3512
|
const phone = useIsPhone();
|
|
3424
|
-
const [open, setOpen] =
|
|
3425
|
-
const anchorRef =
|
|
3426
|
-
const inputRef =
|
|
3513
|
+
const [open, setOpen] = React39.useState(false);
|
|
3514
|
+
const anchorRef = React39.useRef(null);
|
|
3515
|
+
const inputRef = React39.useRef(null);
|
|
3427
3516
|
const bounds = { min, max };
|
|
3428
3517
|
const typed = useTypedDate({ value, onChange, bounds, format: displayFormatter(display), onError: onTypedError, editOnType: true });
|
|
3429
3518
|
const edit = typedEditBind(typed);
|
|
3430
3519
|
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
|
|
3431
3520
|
const focus = focusBind;
|
|
3432
3521
|
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError, required });
|
|
3433
|
-
const close =
|
|
3522
|
+
const close = React39.useCallback(() => setOpen(false), []);
|
|
3434
3523
|
useReturnFocus(open, inputRef);
|
|
3435
3524
|
const commit = (iso) => {
|
|
3436
3525
|
onTypedError?.(void 0);
|
|
@@ -3506,7 +3595,7 @@ function TemporalInput({ fieldProps, context, webInputType, onTypedError }) {
|
|
|
3506
3595
|
}
|
|
3507
3596
|
function TemporalField({ fieldProps, webInputType }) {
|
|
3508
3597
|
const { label, required, hint, error } = fieldProps;
|
|
3509
|
-
const [typedError, setTypedError] =
|
|
3598
|
+
const [typedError, setTypedError] = React39.useState(void 0);
|
|
3510
3599
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error: error ?? typedError, hint, label, required, children: (context) => /* @__PURE__ */ jsxRuntime.jsx(TemporalInput, { context, fieldProps, webInputType, onTypedError: setTypedError }) });
|
|
3511
3600
|
}
|
|
3512
3601
|
function DateField(props) {
|
|
@@ -3635,17 +3724,17 @@ function useRangeSummary(draft) {
|
|
|
3635
3724
|
}
|
|
3636
3725
|
function RangeCalendar({ value, bounds, phone, testID, onApply, onCancel }) {
|
|
3637
3726
|
const { labels, today } = useDatePickerConfig();
|
|
3638
|
-
const [draft, setDraft] =
|
|
3727
|
+
const [draft, setDraft] = React39.useState(value);
|
|
3639
3728
|
const initialDay = clampToBounds(value.from !== "" ? value.from : today, bounds.min, bounds.max);
|
|
3640
|
-
const pickDraft =
|
|
3729
|
+
const pickDraft = React39.useCallback((iso) => setDraft((current) => pickRangeDay(current, iso)), []);
|
|
3641
3730
|
const focus = useGridFocus(initialDay, bounds, testID, pickDraft);
|
|
3642
3731
|
const visible = phone ? PHONE_MONTHS : DESKTOP_MONTHS;
|
|
3643
|
-
const [first, setFirst] =
|
|
3732
|
+
const [first, setFirst] = React39.useState(() => monthStart(phone ? initialDay : addMonths(initialDay, 1 - DESKTOP_MONTHS)));
|
|
3644
3733
|
const focusMonth = monthStart(focus.focusedDay);
|
|
3645
3734
|
const last = addMonths(first, visible - 1);
|
|
3646
3735
|
const motion = useMonthSlide(first);
|
|
3647
3736
|
const summary = useRangeSummary(draft);
|
|
3648
|
-
|
|
3737
|
+
React39.useEffect(() => {
|
|
3649
3738
|
if (focusMonth < first) setFirst(focusMonth);
|
|
3650
3739
|
else if (focusMonth > last) setFirst(addMonths(focusMonth, 1 - visible));
|
|
3651
3740
|
}, [focusMonth, first, last, visible]);
|
|
@@ -3694,18 +3783,18 @@ function orNone(value) {
|
|
|
3694
3783
|
function WebDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, testID, context, onTypedError }) {
|
|
3695
3784
|
const { labels } = useDatePickerConfig();
|
|
3696
3785
|
const phone = useIsPhone();
|
|
3697
|
-
const [open, setOpen] =
|
|
3698
|
-
const [fromError, setFromError] =
|
|
3699
|
-
const [toError, setToError] =
|
|
3700
|
-
const anchorRef =
|
|
3701
|
-
const fromRef =
|
|
3786
|
+
const [open, setOpen] = React39.useState(false);
|
|
3787
|
+
const [fromError, setFromError] = React39.useState(void 0);
|
|
3788
|
+
const [toError, setToError] = React39.useState(void 0);
|
|
3789
|
+
const anchorRef = React39.useRef(null);
|
|
3790
|
+
const fromRef = React39.useRef(null);
|
|
3702
3791
|
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 });
|
|
3703
3792
|
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 });
|
|
3704
3793
|
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: true });
|
|
3705
3794
|
const focus = focusBind;
|
|
3706
3795
|
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError });
|
|
3707
|
-
|
|
3708
|
-
const close =
|
|
3796
|
+
React39.useEffect(() => onTypedError(fromError ?? toError), [fromError, toError, onTypedError]);
|
|
3797
|
+
const close = React39.useCallback(() => setOpen(false), []);
|
|
3709
3798
|
useReturnFocus(open, fromRef);
|
|
3710
3799
|
const onKeyDown = (event) => {
|
|
3711
3800
|
if (event.key === "ArrowDown" && event.altKey) {
|
|
@@ -3789,7 +3878,7 @@ function DateRangeControl({
|
|
|
3789
3878
|
}) {
|
|
3790
3879
|
const hint = accessibilityHint ?? `${fromLabel} \u2013 ${toLabel}`;
|
|
3791
3880
|
const { labels } = useDatePickerConfig();
|
|
3792
|
-
const [typedError, setTypedError] =
|
|
3881
|
+
const [typedError, setTypedError] = React39.useState(void 0);
|
|
3793
3882
|
if (!IS_WEB9) {
|
|
3794
3883
|
return /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(NativeDateRange, { fromLabel, hint, style, testID, toLabel, value, onChange, onSubmit }) });
|
|
3795
3884
|
}
|
|
@@ -3829,7 +3918,7 @@ var ROW_GAP = 4;
|
|
|
3829
3918
|
var TAB_PADDING = 4;
|
|
3830
3919
|
var INDICATOR_WIDTH = 2;
|
|
3831
3920
|
var TAB_FONT_SIZE = 12;
|
|
3832
|
-
var
|
|
3921
|
+
var styles22 = reactNative.StyleSheet.create({
|
|
3833
3922
|
row: { flexDirection: "row", flexWrap: "nowrap", gap: ROW_GAP },
|
|
3834
3923
|
tab: {
|
|
3835
3924
|
borderBottomWidth: INDICATOR_WIDTH,
|
|
@@ -3869,13 +3958,13 @@ var StepperTab = ({
|
|
|
3869
3958
|
accessibilityRole: "tab",
|
|
3870
3959
|
accessibilityState: { selected },
|
|
3871
3960
|
"aria-selected": selected,
|
|
3872
|
-
style: [
|
|
3961
|
+
style: [styles22.tab, { borderBottomColor: indicator }, ring.ringStyle],
|
|
3873
3962
|
testID,
|
|
3874
3963
|
onBlur: ring.onBlur,
|
|
3875
3964
|
onFocus: ring.onFocus,
|
|
3876
3965
|
onPress: () => onStep(step.key),
|
|
3877
3966
|
...webKeyProps,
|
|
3878
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
3967
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles22.text, { color: theme.colors.text }, selected ? styles22.textSelected : void 0], children: step.label })
|
|
3879
3968
|
}
|
|
3880
3969
|
);
|
|
3881
3970
|
};
|
|
@@ -3885,7 +3974,7 @@ var StepperTabs = ({
|
|
|
3885
3974
|
onStep,
|
|
3886
3975
|
stepHint,
|
|
3887
3976
|
testID
|
|
3888
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", style:
|
|
3977
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", style: styles22.row, testID, children: steps.map((step) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3889
3978
|
StepperTab,
|
|
3890
3979
|
{
|
|
3891
3980
|
hint: stepHint,
|
|
@@ -3904,7 +3993,7 @@ function resolveStepNeighbours(steps, current) {
|
|
|
3904
3993
|
return { previous: steps[index - 1] ?? null, next: steps[index + 1] ?? null };
|
|
3905
3994
|
}
|
|
3906
3995
|
var ROW_GAP2 = 8;
|
|
3907
|
-
var
|
|
3996
|
+
var styles23 = reactNative.StyleSheet.create({
|
|
3908
3997
|
cell: { flex: 1, minWidth: 0 },
|
|
3909
3998
|
row: { flexDirection: "row", gap: ROW_GAP2 }
|
|
3910
3999
|
});
|
|
@@ -3916,8 +4005,8 @@ var StepperNav = ({
|
|
|
3916
4005
|
testID
|
|
3917
4006
|
}) => {
|
|
3918
4007
|
const { previous, next } = resolveStepNeighbours(steps, current);
|
|
3919
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
3920
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
4008
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles23.row, testID, children: [
|
|
4009
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles23.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3921
4010
|
uiButtons.Button,
|
|
3922
4011
|
{
|
|
3923
4012
|
fullWidth: true,
|
|
@@ -3933,7 +4022,7 @@ var StepperNav = ({
|
|
|
3933
4022
|
}
|
|
3934
4023
|
}
|
|
3935
4024
|
) }),
|
|
3936
|
-
next === null ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
4025
|
+
next === null ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles23.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3937
4026
|
uiButtons.Button,
|
|
3938
4027
|
{
|
|
3939
4028
|
fullWidth: true,
|
|
@@ -3948,18 +4037,18 @@ var StepperNav = ({
|
|
|
3948
4037
|
] });
|
|
3949
4038
|
};
|
|
3950
4039
|
var STATUS_FONT = 16;
|
|
3951
|
-
var
|
|
4040
|
+
var styles24 = reactNative.StyleSheet.create({
|
|
3952
4041
|
line: { fontSize: STATUS_FONT }
|
|
3953
4042
|
});
|
|
3954
4043
|
function FormStatusLine({ message, testID, style }) {
|
|
3955
4044
|
const { theme } = uiFeedback.useUi();
|
|
3956
4045
|
if (message === null || message === void 0 || message === "") return null;
|
|
3957
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
4046
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles24.line, { color: theme.colors.text }, style], testID, children: message });
|
|
3958
4047
|
}
|
|
3959
4048
|
function useFocusFirstInvalid(refs) {
|
|
3960
|
-
const latest =
|
|
4049
|
+
const latest = React39.useRef(refs);
|
|
3961
4050
|
latest.current = refs;
|
|
3962
|
-
return
|
|
4051
|
+
return React39.useCallback((invalid) => {
|
|
3963
4052
|
const first = invalid.map((field2) => latest.current[field2].current).find((node) => node !== null);
|
|
3964
4053
|
first?.focus();
|
|
3965
4054
|
}, []);
|
|
@@ -4010,10 +4099,10 @@ function withoutField(state, field2) {
|
|
|
4010
4099
|
}
|
|
4011
4100
|
function useServerFieldErrors(options) {
|
|
4012
4101
|
const { fields, refs, formatCode } = options;
|
|
4013
|
-
const [state, setState] =
|
|
4102
|
+
const [state, setState] = React39.useState(EMPTY_STATE);
|
|
4014
4103
|
const focusFirst = useFocusFirstInvalid(refs ?? NO_REFS);
|
|
4015
4104
|
const hasRefs = refs !== void 0;
|
|
4016
|
-
const apply =
|
|
4105
|
+
const apply = React39.useCallback(
|
|
4017
4106
|
(error) => {
|
|
4018
4107
|
const assigned = assignServerErrors(apiClientBase.parseFieldErrors(error), fields, formatCode);
|
|
4019
4108
|
setState({ byField: assigned.byField, formError: assigned.formError });
|
|
@@ -4024,17 +4113,17 @@ function useServerFieldErrors(options) {
|
|
|
4024
4113
|
},
|
|
4025
4114
|
[fields, formatCode, focusFirst, hasRefs]
|
|
4026
4115
|
);
|
|
4027
|
-
const clear =
|
|
4028
|
-
const reset =
|
|
4029
|
-
const errorFor =
|
|
4116
|
+
const clear = React39.useCallback((field2) => setState((current) => withoutField(current, field2)), []);
|
|
4117
|
+
const reset = React39.useCallback(() => setState(EMPTY_STATE), []);
|
|
4118
|
+
const errorFor = React39.useCallback((field2) => state.byField[field2], [state.byField]);
|
|
4030
4119
|
return { errorFor, apply, clear, formError: state.formError, reset };
|
|
4031
4120
|
}
|
|
4032
4121
|
function isScrollable(node) {
|
|
4033
4122
|
return "scrollIntoView" in Object(node);
|
|
4034
4123
|
}
|
|
4035
4124
|
function useKeepInView(trigger) {
|
|
4036
|
-
const ref =
|
|
4037
|
-
|
|
4125
|
+
const ref = React39.useRef(null);
|
|
4126
|
+
React39.useEffect(() => {
|
|
4038
4127
|
const node = ref.current;
|
|
4039
4128
|
const hasTrigger = trigger !== void 0 && trigger !== null;
|
|
4040
4129
|
if (hasTrigger && isScrollable(node)) node.scrollIntoView({ block: "nearest" });
|
|
@@ -4043,7 +4132,7 @@ function useKeepInView(trigger) {
|
|
|
4043
4132
|
}
|
|
4044
4133
|
var IS_WEB10 = reactNative.Platform.OS === "web";
|
|
4045
4134
|
var INPUT_FONT2 = 14;
|
|
4046
|
-
var
|
|
4135
|
+
var styles25 = reactNative.StyleSheet.create({
|
|
4047
4136
|
nativeButton: { minHeight: a11y.MIN_TOUCH_TARGET_PX, minWidth: a11y.MIN_TOUCH_TARGET_PX, justifyContent: "center" },
|
|
4048
4137
|
nativeText: { fontSize: INPUT_FONT2 }
|
|
4049
4138
|
});
|
|
@@ -4071,10 +4160,10 @@ function FileInput({
|
|
|
4071
4160
|
accessibilityRole: "button",
|
|
4072
4161
|
accessibilityState: { disabled },
|
|
4073
4162
|
disabled,
|
|
4074
|
-
style:
|
|
4163
|
+
style: styles25.nativeButton,
|
|
4075
4164
|
testID,
|
|
4076
4165
|
onPress: onNativePick,
|
|
4077
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4166
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles25.nativeText, { color: colors.text }], children: nativeLabel ?? accessibilityLabel })
|
|
4078
4167
|
}
|
|
4079
4168
|
);
|
|
4080
4169
|
}
|
|
@@ -4104,7 +4193,7 @@ var PREVIEW_RADIUS = 8;
|
|
|
4104
4193
|
var GAP6 = 8;
|
|
4105
4194
|
var TITLE_FONT_SIZE = 14;
|
|
4106
4195
|
var HELP_FONT_SIZE = 13;
|
|
4107
|
-
var
|
|
4196
|
+
var styles26 = reactNative.StyleSheet.create({
|
|
4108
4197
|
help: { flex: 1, fontSize: HELP_FONT_SIZE },
|
|
4109
4198
|
root: { gap: GAP6 },
|
|
4110
4199
|
tile: { alignItems: "center", flexDirection: "row", gap: GAP6 },
|
|
@@ -4124,13 +4213,13 @@ var UploadWithLinkField = ({
|
|
|
4124
4213
|
const { theme } = uiFeedback.useUi();
|
|
4125
4214
|
const ring = uiButtons.useFocusRing();
|
|
4126
4215
|
const url = value ?? "";
|
|
4127
|
-
const [pasting, setPasting] =
|
|
4216
|
+
const [pasting, setPasting] = React39.useState(url !== "");
|
|
4128
4217
|
const previewBox = { borderRadius: PREVIEW_RADIUS, height: previewSize, width: previewSize };
|
|
4129
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4130
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4131
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4218
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles26.root, children: [
|
|
4219
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles26.title, { color: theme.colors.text }], children: labels.title }),
|
|
4220
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles26.tile, children: [
|
|
4132
4221
|
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` }),
|
|
4133
|
-
labels.help === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4222
|
+
labels.help === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles26.help, { color: theme.colors.text }], children: labels.help })
|
|
4134
4223
|
] }),
|
|
4135
4224
|
uploadControl,
|
|
4136
4225
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4141,12 +4230,12 @@ var UploadWithLinkField = ({
|
|
|
4141
4230
|
accessibilityRole: "button",
|
|
4142
4231
|
accessibilityState: { expanded: pasting },
|
|
4143
4232
|
"aria-expanded": pasting,
|
|
4144
|
-
style: [
|
|
4233
|
+
style: [styles26.toggle, ring.ringStyle],
|
|
4145
4234
|
testID: `${testID}-paste`,
|
|
4146
4235
|
onBlur: ring.onBlur,
|
|
4147
4236
|
onFocus: ring.onFocus,
|
|
4148
4237
|
onPress: () => setPasting(!pasting),
|
|
4149
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4238
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles26.toggleText, { color: theme.colors.text }], children: labels.pasteToggle })
|
|
4150
4239
|
}
|
|
4151
4240
|
),
|
|
4152
4241
|
pasting ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4165,7 +4254,7 @@ var UploadWithLinkField = ({
|
|
|
4165
4254
|
};
|
|
4166
4255
|
var ACTION_GAP = 8;
|
|
4167
4256
|
var GROUP_GAP = 16;
|
|
4168
|
-
var
|
|
4257
|
+
var styles27 = reactNative.StyleSheet.create({
|
|
4169
4258
|
action: { alignItems: "flex-start", marginTop: ACTION_GAP },
|
|
4170
4259
|
group: { marginBottom: GROUP_GAP }
|
|
4171
4260
|
});
|
|
@@ -4182,13 +4271,13 @@ var AddOnRequest = ({
|
|
|
4182
4271
|
disabled = false,
|
|
4183
4272
|
style
|
|
4184
4273
|
}) => {
|
|
4185
|
-
const [requested, setRequested] =
|
|
4274
|
+
const [requested, setRequested] = React39.useState(false);
|
|
4186
4275
|
const remove = () => {
|
|
4187
4276
|
setRequested(false);
|
|
4188
4277
|
onRemove();
|
|
4189
4278
|
};
|
|
4190
4279
|
if (!isAddOnOpen(hasValue, requested))
|
|
4191
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
4280
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles27.action, style], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4192
4281
|
uiButtons.Button,
|
|
4193
4282
|
{
|
|
4194
4283
|
accessibilityHint: addHint,
|
|
@@ -4200,9 +4289,9 @@ var AddOnRequest = ({
|
|
|
4200
4289
|
onPress: () => setRequested(true)
|
|
4201
4290
|
}
|
|
4202
4291
|
) });
|
|
4203
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4292
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles27.group, style], testID, children: [
|
|
4204
4293
|
children,
|
|
4205
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
4294
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles27.action, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4206
4295
|
uiButtons.Button,
|
|
4207
4296
|
{
|
|
4208
4297
|
accessibilityHint: removeHint,
|
|
@@ -4219,7 +4308,7 @@ var AddOnRequest = ({
|
|
|
4219
4308
|
var ROW_GAP3 = 8;
|
|
4220
4309
|
var TEXT_SIZE = 13;
|
|
4221
4310
|
var TEXT_LINE = 18;
|
|
4222
|
-
var
|
|
4311
|
+
var styles28 = reactNative.StyleSheet.create({
|
|
4223
4312
|
row: { alignItems: "center", columnGap: ROW_GAP3, flexDirection: "row", justifyContent: "space-between" },
|
|
4224
4313
|
text: { flexShrink: 1, fontSize: TEXT_SIZE, fontWeight: "700", lineHeight: TEXT_LINE }
|
|
4225
4314
|
});
|
|
@@ -4227,8 +4316,8 @@ var isFixBarVisible = (count) => count > 0;
|
|
|
4227
4316
|
var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) => {
|
|
4228
4317
|
const { theme } = uiFeedback.useUi();
|
|
4229
4318
|
if (!isFixBarVisible(count)) return null;
|
|
4230
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4231
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
4319
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles28.row, style], testID, children: [
|
|
4320
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles28.text, { color: fieldErrorInk(theme) }], testID: `${testID}-count`, children: message }),
|
|
4232
4321
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4233
4322
|
uiButtons.Button,
|
|
4234
4323
|
{
|
|
@@ -4266,21 +4355,21 @@ function OptionRow2({ option, active, current, renderLeading, renderDetail, onPi
|
|
|
4266
4355
|
accessibilityLabel: option.label,
|
|
4267
4356
|
accessibilityRole: "button",
|
|
4268
4357
|
accessibilityState: { selected: active, checked: current },
|
|
4269
|
-
style: [
|
|
4358
|
+
style: [styles29.row, active ? { backgroundColor: colors.surface } : null],
|
|
4270
4359
|
testID: `${testID}-option-${option.value}`,
|
|
4271
4360
|
onPress: () => onPick(option),
|
|
4272
4361
|
children: [
|
|
4273
4362
|
renderLeading?.(option),
|
|
4274
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4275
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4276
|
-
detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4363
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles29.label, children: [
|
|
4364
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles29.primary, { color: colors.text }], children: option.label }),
|
|
4365
|
+
detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles29.secondary, { color: colors.textSecondary }], children: option.detail }) : null
|
|
4277
4366
|
] }),
|
|
4278
4367
|
renderDetail?.(option)
|
|
4279
4368
|
]
|
|
4280
4369
|
}
|
|
4281
4370
|
);
|
|
4282
4371
|
}
|
|
4283
|
-
var
|
|
4372
|
+
var styles29 = reactNative.StyleSheet.create({
|
|
4284
4373
|
row: { minHeight: a11y.MIN_TOUCH_TARGET_PX, flexDirection: "row", alignItems: "center", gap: ROW_GAP4, paddingHorizontal: ROW_PAD_H },
|
|
4285
4374
|
label: { flex: 1 },
|
|
4286
4375
|
primary: { fontSize: OPTION_FONT2, flexShrink: 1 },
|
|
@@ -4294,11 +4383,11 @@ function OptionSection({ title, options, offset, highlight, selectedValue, ...ro
|
|
|
4294
4383
|
const { colors } = theme;
|
|
4295
4384
|
if (options.length === 0) return null;
|
|
4296
4385
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
4297
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
4386
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles30.header, { color: colors.textSecondary }], children: title }),
|
|
4298
4387
|
options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(OptionRow2, { ...row, active: offset + index === highlight, current: option.value === selectedValue, option }, option.value))
|
|
4299
4388
|
] });
|
|
4300
4389
|
}
|
|
4301
|
-
var
|
|
4390
|
+
var styles30 = reactNative.StyleSheet.create({
|
|
4302
4391
|
header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
|
|
4303
4392
|
});
|
|
4304
4393
|
var KEY_ESCAPE = "Escape";
|
|
@@ -4308,27 +4397,27 @@ var SHEET_MAX_HEIGHT2 = 480;
|
|
|
4308
4397
|
function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
|
|
4309
4398
|
const { theme } = uiFeedback.useUi();
|
|
4310
4399
|
const { colors } = theme;
|
|
4311
|
-
const progress =
|
|
4400
|
+
const progress = React39.useRef(new reactNative.Animated.Value(0)).current;
|
|
4312
4401
|
const { durationMs } = motion;
|
|
4313
|
-
|
|
4402
|
+
React39.useEffect(() => {
|
|
4314
4403
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
4315
4404
|
}, [progress, durationMs]);
|
|
4316
|
-
const leaving =
|
|
4317
|
-
const leave =
|
|
4405
|
+
const leaving = React39.useRef(false);
|
|
4406
|
+
const leave = React39.useCallback((after) => {
|
|
4318
4407
|
if (leaving.current) return;
|
|
4319
4408
|
leaving.current = true;
|
|
4320
4409
|
if (durationMs === 0) return after();
|
|
4321
4410
|
reactNative.Animated.timing(progress, { toValue: 0, duration: durationMs, useNativeDriver: false }).start(() => after());
|
|
4322
4411
|
}, [progress, durationMs]);
|
|
4323
4412
|
const { close, pick: pickNow, submit: submitNow, onKey, sections, highlight } = state;
|
|
4324
|
-
const dismiss =
|
|
4325
|
-
const pick =
|
|
4326
|
-
const submit =
|
|
4327
|
-
const onKeyPress =
|
|
4413
|
+
const dismiss = React39.useCallback(() => leave(close), [leave, close]);
|
|
4414
|
+
const pick = React39.useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
|
|
4415
|
+
const submit = React39.useCallback(() => submitNow(pick), [submitNow, pick]);
|
|
4416
|
+
const onKeyPress = React39.useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
|
|
4328
4417
|
const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [motion.fromY, 0] });
|
|
4329
4418
|
const isSheet = motion.surface === "sheet" /* Sheet */;
|
|
4330
4419
|
const shared = { selectedValue, renderLeading, renderDetail, onPick: pick, optionHint: labels.optionHint, testID, highlight };
|
|
4331
|
-
const list = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4420
|
+
const list = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles31.panel, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }], testID: `${testID}-panel`, children: [
|
|
4332
4421
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4333
4422
|
reactNative.TextInput,
|
|
4334
4423
|
{
|
|
@@ -4345,24 +4434,24 @@ function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, re
|
|
|
4345
4434
|
onSubmitEditing: submit
|
|
4346
4435
|
}
|
|
4347
4436
|
),
|
|
4348
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", style: isSheet ?
|
|
4437
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", style: isSheet ? styles31.sheetList : styles31.dropList, children: [
|
|
4349
4438
|
/* @__PURE__ */ jsxRuntime.jsx(OptionSection, { ...shared, offset: 0, options: sections.recent, title: labels.recent }),
|
|
4350
4439
|
/* @__PURE__ */ jsxRuntime.jsx(OptionSection, { ...shared, offset: sections.recent.length, options: sections.all, title: labels.all }),
|
|
4351
|
-
sections.flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4440
|
+
sections.flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles31.empty, { color: colors.textSecondary }], children: labels.empty }) : null
|
|
4352
4441
|
] })
|
|
4353
4442
|
] });
|
|
4354
4443
|
if (!isSheet) return /* @__PURE__ */ jsxRuntime.jsx(DropdownSurface, { anchorRef, closeHint: labels.closeHint, closeLabel: labels.close, progress, testID, translateY, onDismiss: dismiss, children: list });
|
|
4355
4444
|
return /* @__PURE__ */ jsxRuntime.jsx(SheetSurface, { closeHint: labels.closeHint, closeLabel: labels.close, testID, translateY, onDismiss: dismiss, children: list });
|
|
4356
4445
|
}
|
|
4357
|
-
var
|
|
4446
|
+
var styles31 = reactNative.StyleSheet.create({
|
|
4358
4447
|
panel: { borderWidth: 1, borderRadius: PANEL_RADIUS, padding: PANEL_PAD, gap: PANEL_PAD },
|
|
4359
4448
|
dropList: { maxHeight: MENU_MAX_HEIGHT },
|
|
4360
4449
|
sheetList: { maxHeight: SHEET_MAX_HEIGHT2 },
|
|
4361
4450
|
empty: { padding: PANEL_PAD }
|
|
4362
4451
|
});
|
|
4363
4452
|
function useRefocusOnClose(open, ref) {
|
|
4364
|
-
const wasOpen =
|
|
4365
|
-
|
|
4453
|
+
const wasOpen = React39.useRef(false);
|
|
4454
|
+
React39.useEffect(() => {
|
|
4366
4455
|
if (wasOpen.current && !open) ref.current?.focus();
|
|
4367
4456
|
wasOpen.current = open;
|
|
4368
4457
|
}, [open, ref]);
|
|
@@ -4395,38 +4484,38 @@ var KEY_DOWN = "ArrowDown";
|
|
|
4395
4484
|
var KEY_UP = "ArrowUp";
|
|
4396
4485
|
var KEY_ESCAPE2 = "Escape";
|
|
4397
4486
|
function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
4398
|
-
const [open, setOpen] =
|
|
4399
|
-
const [query, setQueryState] =
|
|
4400
|
-
const [rawHighlight, setHighlight] =
|
|
4401
|
-
const sections =
|
|
4487
|
+
const [open, setOpen] = React39.useState(false);
|
|
4488
|
+
const [query, setQueryState] = React39.useState("");
|
|
4489
|
+
const [rawHighlight, setHighlight] = React39.useState(-1);
|
|
4490
|
+
const sections = React39.useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
|
|
4402
4491
|
const highlight = rawHighlight < sections.flat.length ? rawHighlight : -1;
|
|
4403
4492
|
const active = sections.flat[highlight];
|
|
4404
4493
|
const { remember } = recents;
|
|
4405
|
-
const close =
|
|
4494
|
+
const close = React39.useCallback(() => {
|
|
4406
4495
|
setOpen(false);
|
|
4407
4496
|
setQueryState("");
|
|
4408
4497
|
setHighlight(-1);
|
|
4409
4498
|
onClosed();
|
|
4410
4499
|
}, [onClosed]);
|
|
4411
|
-
const pick =
|
|
4500
|
+
const pick = React39.useCallback((option) => {
|
|
4412
4501
|
remember(option.value);
|
|
4413
4502
|
onChange(option.value);
|
|
4414
4503
|
close();
|
|
4415
4504
|
}, [remember, onChange, close]);
|
|
4416
|
-
const submit =
|
|
4505
|
+
const submit = React39.useCallback((via = pick) => {
|
|
4417
4506
|
if (active !== void 0) via(active);
|
|
4418
4507
|
}, [active, pick]);
|
|
4419
|
-
const setQuery =
|
|
4508
|
+
const setQuery = React39.useCallback((next) => {
|
|
4420
4509
|
setQueryState(next);
|
|
4421
4510
|
setHighlight(highlightAfterQuery(next));
|
|
4422
4511
|
}, []);
|
|
4423
|
-
const onKey =
|
|
4512
|
+
const onKey = React39.useCallback((key) => {
|
|
4424
4513
|
const count = sections.flat.length;
|
|
4425
4514
|
if (key === KEY_DOWN) setHighlight(moveHighlight(highlight, count, 1));
|
|
4426
4515
|
if (key === KEY_UP) setHighlight(moveHighlight(highlight, count, -1));
|
|
4427
4516
|
if (key === KEY_ESCAPE2) close();
|
|
4428
4517
|
}, [sections.flat.length, highlight, close]);
|
|
4429
|
-
const openList =
|
|
4518
|
+
const openList = React39.useCallback(() => setOpen(true), []);
|
|
4430
4519
|
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
4431
4520
|
}
|
|
4432
4521
|
|
|
@@ -4450,8 +4539,8 @@ function SearchSelect(props) {
|
|
|
4450
4539
|
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger, onBlur } = props;
|
|
4451
4540
|
const { theme } = uiFeedback.useUi();
|
|
4452
4541
|
const { colors } = theme;
|
|
4453
|
-
const triggerRef =
|
|
4454
|
-
const anchorRef =
|
|
4542
|
+
const triggerRef = React39.useRef(null);
|
|
4543
|
+
const anchorRef = React39.useRef(null);
|
|
4455
4544
|
const { width } = reactNative.useWindowDimensions();
|
|
4456
4545
|
const motion = resolveSelectMotion(width, useReducedMotion());
|
|
4457
4546
|
const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
|
|
@@ -4459,12 +4548,12 @@ function SearchSelect(props) {
|
|
|
4459
4548
|
useRefocusOnClose(state.open, triggerRef);
|
|
4460
4549
|
const selected = findOption(options, value);
|
|
4461
4550
|
const onPress = state.open ? state.close : state.openList;
|
|
4462
|
-
const openRef =
|
|
4551
|
+
const openRef = React39.useRef(state.open);
|
|
4463
4552
|
openRef.current = state.open;
|
|
4464
|
-
const onTriggerBlur =
|
|
4553
|
+
const onTriggerBlur = React39.useCallback(() => {
|
|
4465
4554
|
if (!openRef.current) onBlur?.();
|
|
4466
4555
|
}, [onBlur]);
|
|
4467
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style:
|
|
4556
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles32.anchor, children: [
|
|
4468
4557
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4469
4558
|
reactNative.Pressable,
|
|
4470
4559
|
{
|
|
@@ -4473,7 +4562,7 @@ function SearchSelect(props) {
|
|
|
4473
4562
|
accessibilityLabel,
|
|
4474
4563
|
accessibilityRole: "button",
|
|
4475
4564
|
accessibilityState: { expanded: state.open },
|
|
4476
|
-
style: renderTrigger === void 0 ? [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }] :
|
|
4565
|
+
style: renderTrigger === void 0 ? [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }] : styles32.customTrigger,
|
|
4477
4566
|
testID,
|
|
4478
4567
|
onBlur: onTriggerBlur,
|
|
4479
4568
|
onPress,
|
|
@@ -4485,7 +4574,7 @@ function SearchSelect(props) {
|
|
|
4485
4574
|
}
|
|
4486
4575
|
function FieldBoxContent({ selected, placeholder, colors, renderLeading, renderDetail }) {
|
|
4487
4576
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4488
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4577
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles32.value, children: [
|
|
4489
4578
|
selected !== null && renderLeading !== void 0 ? renderLeading(selected) : null,
|
|
4490
4579
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: selected === null ? colors.textSecondary : colors.text }], children: selected?.label ?? placeholder }),
|
|
4491
4580
|
selected !== null ? /* @__PURE__ */ jsxRuntime.jsx(SelectedDetail, { colors, option: selected, renderDetail }) : null
|
|
@@ -4498,7 +4587,7 @@ function SelectedDetail({ option, colors, renderDetail }) {
|
|
|
4498
4587
|
if (option.detail === void 0) return null;
|
|
4499
4588
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [controlStyles.selectTriggerText, { color: colors.textSecondary }], children: option.detail });
|
|
4500
4589
|
}
|
|
4501
|
-
var
|
|
4590
|
+
var styles32 = reactNative.StyleSheet.create({
|
|
4502
4591
|
anchor: { position: "relative" },
|
|
4503
4592
|
customTrigger: { minHeight: MIN_TOUCH, minWidth: MIN_TOUCH, alignSelf: "flex-start", justifyContent: "center" },
|
|
4504
4593
|
value: { flex: 1, flexDirection: "row", alignItems: "center", gap: VALUE_GAP }
|
|
@@ -4511,7 +4600,7 @@ function isOutside(container, target) {
|
|
|
4511
4600
|
return !(target instanceof Node && container.contains(target));
|
|
4512
4601
|
}
|
|
4513
4602
|
function useOutsidePress(ref, onOutside) {
|
|
4514
|
-
|
|
4603
|
+
React39.useEffect(() => {
|
|
4515
4604
|
if (reactNative.Platform.OS !== "web" || typeof document === "undefined") return void 0;
|
|
4516
4605
|
const onPointerDown = (event) => {
|
|
4517
4606
|
if (isOutside(ref.current, event.target)) onOutside();
|
|
@@ -4522,7 +4611,7 @@ function useOutsidePress(ref, onOutside) {
|
|
|
4522
4611
|
}
|
|
4523
4612
|
var AFTER_SURFACE_UNMOUNT_MS = 0;
|
|
4524
4613
|
function useDeferredFocus(ref) {
|
|
4525
|
-
return
|
|
4614
|
+
return React39.useCallback(() => {
|
|
4526
4615
|
setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
|
|
4527
4616
|
}, [ref]);
|
|
4528
4617
|
}
|
|
@@ -5274,8 +5363,8 @@ var renderFlag = (option) => option.value === NO_COUNTRY2 ? null : /* @__PURE__
|
|
|
5274
5363
|
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }) {
|
|
5275
5364
|
const { theme } = uiFeedback.useUi();
|
|
5276
5365
|
const { textSecondary } = theme.colors;
|
|
5277
|
-
const options =
|
|
5278
|
-
const renderCode =
|
|
5366
|
+
const options = React39.useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
|
|
5367
|
+
const renderCode = React39.useCallback((option) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles33.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
|
|
5279
5368
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5280
5369
|
SearchSelect,
|
|
5281
5370
|
{
|
|
@@ -5293,13 +5382,13 @@ function CountryField({ value, onChange, accessibilityLabel, accessibilityHint,
|
|
|
5293
5382
|
}
|
|
5294
5383
|
);
|
|
5295
5384
|
}
|
|
5296
|
-
var
|
|
5385
|
+
var styles33 = reactNative.StyleSheet.create({
|
|
5297
5386
|
code: { fontSize: CODE_FONT }
|
|
5298
5387
|
});
|
|
5299
5388
|
function useBlurVerdict(validate) {
|
|
5300
|
-
const [verdict, setVerdict] =
|
|
5301
|
-
const onEdit =
|
|
5302
|
-
const onLeave =
|
|
5389
|
+
const [verdict, setVerdict] = React39.useState(null);
|
|
5390
|
+
const onEdit = React39.useCallback(() => setVerdict(null), []);
|
|
5391
|
+
const onLeave = React39.useCallback(() => {
|
|
5303
5392
|
const next = validate();
|
|
5304
5393
|
setVerdict(next);
|
|
5305
5394
|
return next;
|
|
@@ -5453,11 +5542,11 @@ function rawCaretAfterChange(previous, previousCaret, next) {
|
|
|
5453
5542
|
|
|
5454
5543
|
// src/IbanInput/hooks/useIbanCaret.ts
|
|
5455
5544
|
function useIbanCaret(display) {
|
|
5456
|
-
const [selection2, setSelection] =
|
|
5457
|
-
const onSelectionChange =
|
|
5545
|
+
const [selection2, setSelection] = React39.useState({ start: display.length, end: display.length });
|
|
5546
|
+
const onSelectionChange = React39.useCallback((event) => {
|
|
5458
5547
|
setSelection(event.nativeEvent.selection);
|
|
5459
5548
|
}, []);
|
|
5460
|
-
const placeAfterEdit =
|
|
5549
|
+
const placeAfterEdit = React39.useCallback((text) => {
|
|
5461
5550
|
const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection2.end, text));
|
|
5462
5551
|
setSelection({ start: caret, end: caret });
|
|
5463
5552
|
}, [display, selection2.end]);
|
|
@@ -5549,9 +5638,9 @@ var LINE_GAP = 4;
|
|
|
5549
5638
|
function RejectionLine({ message, testID }) {
|
|
5550
5639
|
const { theme } = uiFeedback.useUi();
|
|
5551
5640
|
if (message === null) return null;
|
|
5552
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", style: [
|
|
5641
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", style: [styles34.line, { color: fieldErrorInk(theme) }], testID: `${testID}-rejection`, children: message });
|
|
5553
5642
|
}
|
|
5554
|
-
var
|
|
5643
|
+
var styles34 = reactNative.StyleSheet.create({
|
|
5555
5644
|
line: { marginTop: LINE_GAP }
|
|
5556
5645
|
});
|
|
5557
5646
|
|
|
@@ -5563,19 +5652,19 @@ function rejectionMessage(rejection, none, labels) {
|
|
|
5563
5652
|
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
5564
5653
|
const { theme } = uiFeedback.useUi();
|
|
5565
5654
|
const { colors } = theme;
|
|
5566
|
-
const draft =
|
|
5567
|
-
const validate =
|
|
5655
|
+
const draft = React39.useMemo(() => draftIban(value), [value]);
|
|
5656
|
+
const validate = React39.useCallback(() => validateIban(value), [value]);
|
|
5568
5657
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5569
5658
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5570
5659
|
const counter = ibanCounter(draft);
|
|
5571
5660
|
const { selection: selection2, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
5572
|
-
const onChangeText =
|
|
5661
|
+
const onChangeText = React39.useCallback((text) => {
|
|
5573
5662
|
onEdit();
|
|
5574
5663
|
onVerdict?.(null);
|
|
5575
5664
|
placeAfterEdit(text);
|
|
5576
5665
|
onChange(draftIban(text).electronic);
|
|
5577
5666
|
}, [onEdit, onVerdict, placeAfterEdit, onChange]);
|
|
5578
|
-
const onBlur =
|
|
5667
|
+
const onBlur = React39.useCallback(() => {
|
|
5579
5668
|
const verdict2 = onLeave();
|
|
5580
5669
|
onVerdict?.(value === "" ? null : verdict2);
|
|
5581
5670
|
onLeft?.();
|
|
@@ -5650,16 +5739,16 @@ function validateBic(raw) {
|
|
|
5650
5739
|
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
5651
5740
|
const { theme } = uiFeedback.useUi();
|
|
5652
5741
|
const { colors } = theme;
|
|
5653
|
-
const draft =
|
|
5654
|
-
const validate =
|
|
5742
|
+
const draft = React39.useMemo(() => draftBic(value), [value]);
|
|
5743
|
+
const validate = React39.useCallback(() => validateBic(value), [value]);
|
|
5655
5744
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5656
5745
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5657
|
-
const onChangeText =
|
|
5746
|
+
const onChangeText = React39.useCallback((text) => {
|
|
5658
5747
|
onEdit();
|
|
5659
5748
|
onVerdict?.(null);
|
|
5660
5749
|
onChange(draftBic(text).value);
|
|
5661
5750
|
}, [onEdit, onVerdict, onChange]);
|
|
5662
|
-
const onBlur =
|
|
5751
|
+
const onBlur = React39.useCallback(() => {
|
|
5663
5752
|
const verdict2 = onLeave();
|
|
5664
5753
|
onVerdict?.(value === "" ? null : verdict2);
|
|
5665
5754
|
onLeft?.();
|
|
@@ -5698,7 +5787,7 @@ var PAD_V = 10;
|
|
|
5698
5787
|
var PAD_H = 16;
|
|
5699
5788
|
var TEXT_SIZE2 = 13;
|
|
5700
5789
|
var TEXT_LINE2 = 18;
|
|
5701
|
-
var
|
|
5790
|
+
var styles35 = reactNative.StyleSheet.create({
|
|
5702
5791
|
bar: { borderTopWidth: 1, paddingHorizontal: PAD_H, paddingVertical: PAD_V, rowGap: BAR_GAP },
|
|
5703
5792
|
actions: { flexDirection: "row", flexWrap: "wrap", gap: BAR_GAP },
|
|
5704
5793
|
message: { fontSize: TEXT_SIZE2, fontWeight: "700", lineHeight: TEXT_LINE2 }
|
|
@@ -5710,9 +5799,9 @@ var ActionBar = ({ children, message, sticky = false, testID, style }) => {
|
|
|
5710
5799
|
const { colors } = theme;
|
|
5711
5800
|
const pinned = actionBarPosition(sticky, reactNative.Platform.OS) === "sticky" ? PINNED : null;
|
|
5712
5801
|
const hasMessage = message !== void 0 && message !== "";
|
|
5713
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
5714
|
-
hasMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "status", style: [
|
|
5715
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
5802
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles35.bar, { backgroundColor: colors.surface, borderTopColor: colors.border }, pinned, style], testID, children: [
|
|
5803
|
+
hasMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "status", style: [styles35.message, { color: colors.text }], testID: `${testID}-message`, children: message }) : null,
|
|
5804
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles35.actions, children })
|
|
5716
5805
|
] });
|
|
5717
5806
|
};
|
|
5718
5807
|
|
|
@@ -5720,14 +5809,14 @@ var ActionBar = ({ children, message, sticky = false, testID, style }) => {
|
|
|
5720
5809
|
var isChecklistComplete = (items, checked) => items.every((item) => checked.includes(item.id));
|
|
5721
5810
|
var TITLE_SIZE = 13;
|
|
5722
5811
|
var TITLE_GAP = 6;
|
|
5723
|
-
var
|
|
5812
|
+
var styles36 = reactNative.StyleSheet.create({
|
|
5724
5813
|
title: { fontSize: TITLE_SIZE, fontWeight: "700", marginBottom: TITLE_GAP }
|
|
5725
5814
|
});
|
|
5726
5815
|
var GatedChecklist = ({ title, items, checked, onToggle, testID, disabled = false, children }) => {
|
|
5727
5816
|
const { theme } = uiFeedback.useUi();
|
|
5728
5817
|
const complete = isChecklistComplete(items, checked);
|
|
5729
5818
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { testID, children: [
|
|
5730
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
5819
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles36.title, { color: theme.colors.text }], children: title }),
|
|
5731
5820
|
items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5732
5821
|
FormCheckbox,
|
|
5733
5822
|
{
|
|
@@ -5753,7 +5842,7 @@ var RADIUS2 = 8;
|
|
|
5753
5842
|
var LABEL_SIZE = 14;
|
|
5754
5843
|
var DESCRIPTION_SIZE = 12;
|
|
5755
5844
|
var DESCRIPTION_LINE = 16;
|
|
5756
|
-
var
|
|
5845
|
+
var styles37 = reactNative.StyleSheet.create({
|
|
5757
5846
|
row: {
|
|
5758
5847
|
alignItems: "center",
|
|
5759
5848
|
borderRadius: RADIUS2,
|
|
@@ -5784,15 +5873,15 @@ function RadioRow({ option, identity, colors, tabIndex, hostRef, onPress }) {
|
|
|
5784
5873
|
accessibilityState: identity.accessibilityState,
|
|
5785
5874
|
"aria-checked": checked,
|
|
5786
5875
|
disabled,
|
|
5787
|
-
style: [
|
|
5876
|
+
style: [styles37.row, { borderColor: accent, backgroundColor: checked ? colors.tint : colors.muted }],
|
|
5788
5877
|
tabIndex,
|
|
5789
5878
|
testID: identity.testID,
|
|
5790
5879
|
onPress,
|
|
5791
5880
|
children: [
|
|
5792
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
5793
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
5794
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
5795
|
-
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
5881
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles37.dot, { borderColor: accent }], children: checked ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles37.dotInner, { backgroundColor: colors.primary }] }) : null }),
|
|
5882
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles37.text, children: [
|
|
5883
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles37.label, { color: checked ? colors.primary : colors.textStrong }], children: option.label }),
|
|
5884
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles37.description, { color: colors.textMuted }], testID: `${identity.testID}-description`, children: option.description }) : null
|
|
5796
5885
|
] })
|
|
5797
5886
|
]
|
|
5798
5887
|
}
|
|
@@ -5809,20 +5898,20 @@ var radioRowIdentity = (option, selected, disabled, prefix) => {
|
|
|
5809
5898
|
};
|
|
5810
5899
|
};
|
|
5811
5900
|
var ROW_GAP7 = 8;
|
|
5812
|
-
var
|
|
5901
|
+
var styles38 = reactNative.StyleSheet.create({
|
|
5813
5902
|
list: { rowGap: ROW_GAP7 }
|
|
5814
5903
|
});
|
|
5815
5904
|
function RadioList(props) {
|
|
5816
5905
|
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
5817
5906
|
const { theme } = uiFeedback.useUi();
|
|
5818
|
-
const colors =
|
|
5907
|
+
const colors = React39__default.default.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
5819
5908
|
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
5820
5909
|
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
5821
5910
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5822
5911
|
reactNative.View,
|
|
5823
5912
|
{
|
|
5824
5913
|
accessibilityRole: "radiogroup",
|
|
5825
|
-
style:
|
|
5914
|
+
style: styles38.list,
|
|
5826
5915
|
...webFieldA11y({ describedById, hasError }),
|
|
5827
5916
|
...radio.groupProps,
|
|
5828
5917
|
children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5876,11 +5965,11 @@ function DecisionNote({ state, labels, testID, disabled }) {
|
|
|
5876
5965
|
);
|
|
5877
5966
|
}
|
|
5878
5967
|
var BUTTON_BASIS = "40%";
|
|
5879
|
-
var
|
|
5968
|
+
var styles39 = reactNative.StyleSheet.create({
|
|
5880
5969
|
cell: { flexBasis: BUTTON_BASIS, flexGrow: 1 }
|
|
5881
5970
|
});
|
|
5882
5971
|
function OutcomeButtons({ outcomes, pending, disabled, testID, onPress }) {
|
|
5883
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: outcomes.map((item) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
5972
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: outcomes.map((item) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles39.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5884
5973
|
uiButtons.Button,
|
|
5885
5974
|
{
|
|
5886
5975
|
fullWidth: true,
|
|
@@ -5961,21 +6050,21 @@ function StickyBarDecision(props) {
|
|
|
5961
6050
|
}
|
|
5962
6051
|
var TEXT_SIZE3 = 13;
|
|
5963
6052
|
var TEXT_LINE3 = 18;
|
|
5964
|
-
var
|
|
6053
|
+
var styles40 = reactNative.StyleSheet.create({
|
|
5965
6054
|
text: { fontSize: TEXT_SIZE3, fontWeight: "700", lineHeight: TEXT_LINE3 }
|
|
5966
6055
|
});
|
|
5967
6056
|
var SubmitError = ({ message, testID }) => {
|
|
5968
6057
|
const { theme } = uiFeedback.useUi();
|
|
5969
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
6058
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles40.text, { color: fieldErrorInk(theme) }], testID, children: message });
|
|
5970
6059
|
};
|
|
5971
6060
|
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
5972
6061
|
function useDecisionPanel(outcomes, onSubmit) {
|
|
5973
|
-
const [outcome, setOutcome] =
|
|
5974
|
-
const [note, setNote] =
|
|
5975
|
-
const [reasons, setReasons] =
|
|
5976
|
-
const [checked, setChecked] =
|
|
5977
|
-
const [error, setError] =
|
|
5978
|
-
const [pending, setPending] =
|
|
6062
|
+
const [outcome, setOutcome] = React39__default.default.useState("");
|
|
6063
|
+
const [note, setNote] = React39__default.default.useState("");
|
|
6064
|
+
const [reasons, setReasons] = React39__default.default.useState([]);
|
|
6065
|
+
const [checked, setChecked] = React39__default.default.useState([]);
|
|
6066
|
+
const [error, setError] = React39__default.default.useState(null);
|
|
6067
|
+
const [pending, setPending] = React39__default.default.useState(null);
|
|
5979
6068
|
const submit = async (override) => {
|
|
5980
6069
|
const target = override ?? outcome;
|
|
5981
6070
|
const problem = validateDecision(outcomes, target, note);
|
|
@@ -6009,7 +6098,7 @@ function useDecisionPanel(outcomes, onSubmit) {
|
|
|
6009
6098
|
}
|
|
6010
6099
|
var TITLE_SIZE2 = 15;
|
|
6011
6100
|
var PANEL_GAP = 12;
|
|
6012
|
-
var
|
|
6101
|
+
var styles41 = reactNative.StyleSheet.create({
|
|
6013
6102
|
panel: { rowGap: PANEL_GAP },
|
|
6014
6103
|
title: { fontSize: TITLE_SIZE2, fontWeight: "700" }
|
|
6015
6104
|
});
|
|
@@ -6023,8 +6112,8 @@ function DecisionPanel(props) {
|
|
|
6023
6112
|
const { theme } = uiFeedback.useUi();
|
|
6024
6113
|
const state = useDecisionPanel(outcomes, onSubmit);
|
|
6025
6114
|
const body = (locked) => renderVariant(variant, { state, outcomes, labels, testID, disabled: disabled || locked, reasons, leadOutcome });
|
|
6026
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
6027
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
6115
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles41.panel, style], testID, children: [
|
|
6116
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles41.title, { color: theme.colors.text }], children: labels.title }),
|
|
6028
6117
|
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),
|
|
6029
6118
|
state.error === "submit" ? /* @__PURE__ */ jsxRuntime.jsx(SubmitError, { message: labels.submitError, testID: `${testID}-error` }) : null
|
|
6030
6119
|
] });
|
|
@@ -6057,16 +6146,16 @@ var POP_FROM = 0.6;
|
|
|
6057
6146
|
var POP_PEAK = 1.12;
|
|
6058
6147
|
var POP_UP_MS = 160;
|
|
6059
6148
|
var POP_SETTLE_MS = 100;
|
|
6060
|
-
var
|
|
6149
|
+
var styles42 = reactNative.StyleSheet.create({
|
|
6061
6150
|
mark: { width: MARK_SIZE, height: MARK_SIZE, borderRadius: MARK_SIZE / 2, alignItems: "center", justifyContent: "center" },
|
|
6062
6151
|
ring: { borderWidth: RING_WIDTH }
|
|
6063
6152
|
});
|
|
6064
6153
|
function RuleMark({ tone, colors }) {
|
|
6065
6154
|
const reduced = useReducedMotion();
|
|
6066
|
-
const scale =
|
|
6067
|
-
const wasMet =
|
|
6155
|
+
const scale = React39.useRef(new reactNative.Animated.Value(1)).current;
|
|
6156
|
+
const wasMet = React39.useRef(tone === "met" /* Met */);
|
|
6068
6157
|
const met = tone === "met" /* Met */;
|
|
6069
|
-
|
|
6158
|
+
React39.useEffect(() => {
|
|
6070
6159
|
const turnedMet = met && !wasMet.current;
|
|
6071
6160
|
wasMet.current = met;
|
|
6072
6161
|
if (!turnedMet || reduced) return;
|
|
@@ -6077,8 +6166,8 @@ function RuleMark({ tone, colors }) {
|
|
|
6077
6166
|
]).start();
|
|
6078
6167
|
}, [met, reduced, scale]);
|
|
6079
6168
|
const color = colors.mark[tone];
|
|
6080
|
-
const shape = met ? { backgroundColor: color } : [
|
|
6081
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: { transform: [{ scale }] }, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
6169
|
+
const shape = met ? { backgroundColor: color } : [styles42.ring, { borderColor: color }];
|
|
6170
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: { transform: [{ scale }] }, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles42.mark, shape], children: met ? /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.onMark, name: "check", size: CHECK_SIZE2 }) : null }) });
|
|
6082
6171
|
}
|
|
6083
6172
|
var GAP8 = 6;
|
|
6084
6173
|
var ROW_GAP8 = 8;
|
|
@@ -6090,7 +6179,7 @@ var CHIP_PAD_V2 = 4;
|
|
|
6090
6179
|
var CHIP_PAD_H2 = 10;
|
|
6091
6180
|
var CHIP_BORDER2 = 1;
|
|
6092
6181
|
var HALF4 = "50%";
|
|
6093
|
-
var
|
|
6182
|
+
var styles43 = reactNative.StyleSheet.create({
|
|
6094
6183
|
column: { gap: GAP8 },
|
|
6095
6184
|
row: { flexDirection: "row", alignItems: "center", gap: ROW_GAP8 },
|
|
6096
6185
|
text: { fontSize: FONT5, lineHeight: LINE, flexShrink: 1 },
|
|
@@ -6106,31 +6195,31 @@ function RuleList({ rules, flagUnmet, colors, testID, listStyle, itemStyle, outl
|
|
|
6106
6195
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { role: "list", style: listStyle, testID, children: rules.map((rule) => {
|
|
6107
6196
|
const tone = ruleTone(rule.met, flagUnmet);
|
|
6108
6197
|
const outline = outlined ? { borderColor: colors.mark[tone] } : null;
|
|
6109
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "listitem", style: [
|
|
6198
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "listitem", style: [styles43.row, itemStyle, outline], testID: `${testID}-${rule.id}`, ...{ dataSet: { tone } }, children: [
|
|
6110
6199
|
/* @__PURE__ */ jsxRuntime.jsx(RuleMark, { colors, tone }),
|
|
6111
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
6200
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles43.text, { color: colors.text[tone] }], children: rule.label })
|
|
6112
6201
|
] }, rule.id);
|
|
6113
6202
|
}) });
|
|
6114
6203
|
}
|
|
6115
6204
|
function RulesChecklist(props) {
|
|
6116
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, listStyle:
|
|
6205
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, listStyle: styles43.column });
|
|
6117
6206
|
}
|
|
6118
6207
|
function RulesChips(props) {
|
|
6119
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, outlined: true, itemStyle:
|
|
6208
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, outlined: true, itemStyle: styles43.chip, listStyle: styles43.chips });
|
|
6120
6209
|
}
|
|
6121
6210
|
function RulesMeterGrid(props) {
|
|
6122
6211
|
const { rules, flagUnmet, colors, testID } = props;
|
|
6123
6212
|
const metCount = rules.filter((rule) => rule.met).length;
|
|
6124
6213
|
const unfilled = flagUnmet ? colors.mark.refused : colors.track;
|
|
6125
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
6126
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
6127
|
-
/* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, itemStyle:
|
|
6214
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles43.column, children: [
|
|
6215
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles43.meter, testID: `${testID}-meter`, children: rules.map((rule, index) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles43.segment, { backgroundColor: index < metCount ? colors.mark.met : unfilled }] }, rule.id)) }),
|
|
6216
|
+
/* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, itemStyle: styles43.cell, listStyle: styles43.grid })
|
|
6128
6217
|
] });
|
|
6129
6218
|
}
|
|
6130
6219
|
function RulesSentence({ rules, flagUnmet, colors, testID }) {
|
|
6131
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
6220
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles43.text, { color: colors.text.unmet }], testID, children: rules.map((rule, index) => {
|
|
6132
6221
|
const tone = ruleTone(rule.met, flagUnmet);
|
|
6133
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: [{ color: colors.text[tone] }, rule.met ?
|
|
6222
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: [{ color: colors.text[tone] }, rule.met ? styles43.metPhrase : null], testID: `${testID}-${rule.id}`, ...{ dataSet: { tone } }, children: [
|
|
6134
6223
|
index > 0 ? ", " : "",
|
|
6135
6224
|
rule.label
|
|
6136
6225
|
] }, rule.id);
|
|
@@ -6149,7 +6238,7 @@ function PasswordRules({ display, ...variant }) {
|
|
|
6149
6238
|
}
|
|
6150
6239
|
}
|
|
6151
6240
|
var ICON_SIZE = 20;
|
|
6152
|
-
var
|
|
6241
|
+
var styles44 = reactNative.StyleSheet.create({
|
|
6153
6242
|
button: { width: a11y.MIN_TOUCH_TARGET_PX, height: a11y.MIN_TOUCH_TARGET_PX, alignItems: "center", justifyContent: "center" }
|
|
6154
6243
|
});
|
|
6155
6244
|
function RevealToggle({ revealed, onToggle, onPressIn, showLabel, hideLabel, color, testID }) {
|
|
@@ -6161,7 +6250,7 @@ function RevealToggle({ revealed, onToggle, onPressIn, showLabel, hideLabel, col
|
|
|
6161
6250
|
accessibilityLabel: label,
|
|
6162
6251
|
accessibilityRole: "button",
|
|
6163
6252
|
"aria-pressed": revealed,
|
|
6164
|
-
style:
|
|
6253
|
+
style: styles44.button,
|
|
6165
6254
|
testID,
|
|
6166
6255
|
onPress: onToggle,
|
|
6167
6256
|
onPressIn,
|
|
@@ -6181,9 +6270,9 @@ function ruleAnnouncement(changed, labels) {
|
|
|
6181
6270
|
|
|
6182
6271
|
// src/PasswordField/usePasswordRuleAnnouncement.ts
|
|
6183
6272
|
function usePasswordRuleAnnouncement(rules, labels) {
|
|
6184
|
-
const previous =
|
|
6185
|
-
const [message, setMessage] =
|
|
6186
|
-
|
|
6273
|
+
const previous = React39.useRef(rules);
|
|
6274
|
+
const [message, setMessage] = React39.useState("");
|
|
6275
|
+
React39.useEffect(() => {
|
|
6187
6276
|
const changed = changedRules(previous.current, rules);
|
|
6188
6277
|
previous.current = rules;
|
|
6189
6278
|
if (changed.length > 0) setMessage(ruleAnnouncement(changed, labels));
|
|
@@ -6200,7 +6289,7 @@ function ruleColorsFrom(palette) {
|
|
|
6200
6289
|
}
|
|
6201
6290
|
function useRuleColors(override) {
|
|
6202
6291
|
const { theme } = uiFeedback.useUi();
|
|
6203
|
-
return
|
|
6292
|
+
return React39.useMemo(() => {
|
|
6204
6293
|
if (override !== void 0) return ruleColorsFrom(override);
|
|
6205
6294
|
return ruleColorsFrom({
|
|
6206
6295
|
success: theme.semantic.success?.["500"] ?? theme.colors.text,
|
|
@@ -6215,7 +6304,7 @@ function useRuleColors(override) {
|
|
|
6215
6304
|
var RULES_GAP = 8;
|
|
6216
6305
|
var TOGGLE_INSET = 48;
|
|
6217
6306
|
var NO_RULES = [];
|
|
6218
|
-
var
|
|
6307
|
+
var styles45 = reactNative.StyleSheet.create({
|
|
6219
6308
|
inputRow: { position: "relative", justifyContent: "center" },
|
|
6220
6309
|
input: { paddingRight: TOGGLE_INSET },
|
|
6221
6310
|
toggle: { position: "absolute", right: 0, top: 0, bottom: 0, justifyContent: "center" },
|
|
@@ -6227,16 +6316,16 @@ function joinIds(...ids) {
|
|
|
6227
6316
|
return joined === "" ? void 0 : joined;
|
|
6228
6317
|
}
|
|
6229
6318
|
function useCaretKeepingToggle(inputRef, initialLength) {
|
|
6230
|
-
const [revealed, setRevealed] =
|
|
6231
|
-
const selection2 =
|
|
6232
|
-
const hadFocus =
|
|
6233
|
-
const onSelectionChange =
|
|
6319
|
+
const [revealed, setRevealed] = React39.useState(false);
|
|
6320
|
+
const selection2 = React39.useRef({ start: initialLength, end: initialLength });
|
|
6321
|
+
const hadFocus = React39.useRef(false);
|
|
6322
|
+
const onSelectionChange = React39.useCallback((event) => {
|
|
6234
6323
|
selection2.current = event.nativeEvent.selection;
|
|
6235
6324
|
}, []);
|
|
6236
|
-
const onPressIn =
|
|
6325
|
+
const onPressIn = React39.useCallback(() => {
|
|
6237
6326
|
hadFocus.current = inputRef.current?.isFocused?.() ?? false;
|
|
6238
6327
|
}, [inputRef]);
|
|
6239
|
-
const onToggle =
|
|
6328
|
+
const onToggle = React39.useCallback(() => {
|
|
6240
6329
|
setRevealed((current) => !current);
|
|
6241
6330
|
if (!hadFocus.current) return;
|
|
6242
6331
|
const node = inputRef.current;
|
|
@@ -6248,16 +6337,16 @@ function useCaretKeepingToggle(inputRef, initialLength) {
|
|
|
6248
6337
|
}, [inputRef]);
|
|
6249
6338
|
return { revealed, onPressIn, onToggle, onSelectionChange };
|
|
6250
6339
|
}
|
|
6251
|
-
var PasswordField =
|
|
6252
|
-
const inputRef =
|
|
6253
|
-
|
|
6340
|
+
var PasswordField = React39__default.default.forwardRef(function PasswordField2({ label, value, onChangeText, labels, testID, rules = NO_RULES, rulesDisplay = "meterGrid" /* MeterGrid */, flagUnmet = false, error, colors: colorOverride, inputProps }, ref) {
|
|
6341
|
+
const inputRef = React39.useRef(null);
|
|
6342
|
+
React39.useImperativeHandle(ref, () => inputRef.current);
|
|
6254
6343
|
const toggle2 = useCaretKeepingToggle(inputRef, value.length);
|
|
6255
6344
|
const colors = useRuleColors(colorOverride);
|
|
6256
6345
|
const announcement = usePasswordRuleAnnouncement(rules, labels);
|
|
6257
6346
|
const rulesId = `${testID}-rules`;
|
|
6258
6347
|
const hasRules = rules.length > 0;
|
|
6259
6348
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, label, testID: `${testID}-field`, children: (context) => /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
6260
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
6349
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles45.inputRow, children: [
|
|
6261
6350
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6262
6351
|
ThemedTextInput,
|
|
6263
6352
|
{
|
|
@@ -6269,18 +6358,18 @@ var PasswordField = React38__default.default.forwardRef(function PasswordField2(
|
|
|
6269
6358
|
hasError: context.hasError || flagUnmet && rules.some((rule) => !rule.met),
|
|
6270
6359
|
id: context.controlId,
|
|
6271
6360
|
secureTextEntry: !toggle2.revealed,
|
|
6272
|
-
style: [
|
|
6361
|
+
style: [styles45.input, inputProps?.style],
|
|
6273
6362
|
testID,
|
|
6274
6363
|
value,
|
|
6275
6364
|
onChangeText,
|
|
6276
6365
|
onSelectionChange: toggle2.onSelectionChange
|
|
6277
6366
|
}
|
|
6278
6367
|
),
|
|
6279
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
6368
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles45.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 }) })
|
|
6280
6369
|
] }),
|
|
6281
|
-
hasRules ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { nativeID: rulesId, style:
|
|
6370
|
+
hasRules ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { nativeID: rulesId, style: styles45.rules, children: [
|
|
6282
6371
|
/* @__PURE__ */ jsxRuntime.jsx(PasswordRules, { colors, display: rulesDisplay, flagUnmet, rules, testID: rulesId }),
|
|
6283
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-live": "polite", accessibilityLiveRegion: "polite", style:
|
|
6372
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-live": "polite", accessibilityLiveRegion: "polite", style: styles45.live, testID: `${testID}-announce`, children: announcement })
|
|
6284
6373
|
] }) : null
|
|
6285
6374
|
] }) });
|
|
6286
6375
|
});
|