@dloizides/ui-forms 1.48.0 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +449 -354
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +261 -166
- 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 };
|
|
@@ -1455,6 +1455,9 @@ function chipSizeLook(size) {
|
|
|
1455
1455
|
return { hitBox: void 0, visual: void 0, text: void 0 };
|
|
1456
1456
|
return { hitBox: chipSizeStyles.compactHitBox, visual: chipSizeStyles.compactVisual, text: chipSizeStyles.compactText };
|
|
1457
1457
|
}
|
|
1458
|
+
function restBorderColor(colors, tone) {
|
|
1459
|
+
return tone === "strong" ? colors.borderStrong : colors.border;
|
|
1460
|
+
}
|
|
1458
1461
|
var SOLID_RADIUS = 20;
|
|
1459
1462
|
var OUTLINE_RADIUS = 999;
|
|
1460
1463
|
var OUTLINE_PAD_H = 12;
|
|
@@ -1501,9 +1504,9 @@ function ChipContent(props) {
|
|
|
1501
1504
|
}
|
|
1502
1505
|
function OutlineChip(props) {
|
|
1503
1506
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1504
|
-
const [hovered, setHovered] =
|
|
1507
|
+
const [hovered, setHovered] = React39__default.default.useState(false);
|
|
1505
1508
|
const active = selected || hovered;
|
|
1506
|
-
const borderColor = active ? colors.primary : colors.
|
|
1509
|
+
const borderColor = active ? colors.primary : restBorderColor(colors, props.outlineTone);
|
|
1507
1510
|
const fill = chipFill({
|
|
1508
1511
|
selected,
|
|
1509
1512
|
selectedFill: props.selectedFill,
|
|
@@ -1571,7 +1574,7 @@ function SolidChip(props) {
|
|
|
1571
1574
|
testID,
|
|
1572
1575
|
onPress,
|
|
1573
1576
|
...rovingTabStop,
|
|
1574
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chipStyles.chip, sized.visual, { borderColor: colors.border, backgroundColor: fill.backgroundColor }, layout.boxStyle], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1577
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chipStyles.chip, sized.visual, { borderColor: selected ? colors.border : restBorderColor(colors, props.outlineTone), backgroundColor: fill.backgroundColor }, layout.boxStyle], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1575
1578
|
ChipContent,
|
|
1576
1579
|
{
|
|
1577
1580
|
checkColor: fill.checkColor,
|
|
@@ -1615,8 +1618,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
|
|
|
1615
1618
|
var NO_GROUP_PROPS = {};
|
|
1616
1619
|
function useRadioKeyboard(config) {
|
|
1617
1620
|
const { enabled, disabled, values, selectedIndex, onChange } = config;
|
|
1618
|
-
const nodes =
|
|
1619
|
-
const chipRef =
|
|
1621
|
+
const nodes = React39__default.default.useRef([]);
|
|
1622
|
+
const chipRef = React39__default.default.useCallback((index) => (node) => {
|
|
1620
1623
|
nodes.current[index] = node;
|
|
1621
1624
|
}, []);
|
|
1622
1625
|
const onKeyDown = (event) => {
|
|
@@ -1669,6 +1672,7 @@ function buildChipColors(colors, palette) {
|
|
|
1669
1672
|
const primary = palette.primary[500];
|
|
1670
1673
|
return {
|
|
1671
1674
|
border: colors.border,
|
|
1675
|
+
borderStrong: colors.textSecondary,
|
|
1672
1676
|
textStrong: colors.text,
|
|
1673
1677
|
textMuted: colors.textSecondary,
|
|
1674
1678
|
primary,
|
|
@@ -1726,12 +1730,13 @@ var ChipSelector = ({
|
|
|
1726
1730
|
optionAccessibilityHint,
|
|
1727
1731
|
singleSelectRole = "button",
|
|
1728
1732
|
size = "default",
|
|
1729
|
-
selectedFill
|
|
1733
|
+
selectedFill,
|
|
1734
|
+
outlineTone = "default"
|
|
1730
1735
|
}) => {
|
|
1731
1736
|
const isRadioGroup = !multiple && singleSelectRole === "radio";
|
|
1732
1737
|
const { theme } = uiFeedback.useUi();
|
|
1733
1738
|
const { colors, palette } = theme;
|
|
1734
|
-
const chipColors =
|
|
1739
|
+
const chipColors = React39__default.default.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
|
|
1735
1740
|
function isSelected(optionValue) {
|
|
1736
1741
|
if (multiple && Array.isArray(value))
|
|
1737
1742
|
return value.includes(optionValue);
|
|
@@ -1753,6 +1758,7 @@ var ChipSelector = ({
|
|
|
1753
1758
|
selected,
|
|
1754
1759
|
size,
|
|
1755
1760
|
selectedFill,
|
|
1761
|
+
outlineTone,
|
|
1756
1762
|
...chipIdentity(option, selected, {
|
|
1757
1763
|
prefix: chipTestIDPrefix,
|
|
1758
1764
|
hint: optionAccessibilityHint,
|
|
@@ -1790,8 +1796,95 @@ var ChipSelector = ({
|
|
|
1790
1796
|
}
|
|
1791
1797
|
);
|
|
1792
1798
|
};
|
|
1793
|
-
var
|
|
1799
|
+
var BOX_SLOT_PAD_H = 10;
|
|
1794
1800
|
var styles14 = reactNative.StyleSheet.create({
|
|
1801
|
+
row: {
|
|
1802
|
+
minWidth: a11y.MIN_TOUCH_TARGET_PX,
|
|
1803
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
1804
|
+
alignItems: "center",
|
|
1805
|
+
justifyContent: "center"
|
|
1806
|
+
},
|
|
1807
|
+
box: {
|
|
1808
|
+
alignSelf: "stretch",
|
|
1809
|
+
alignItems: "center",
|
|
1810
|
+
justifyContent: "center",
|
|
1811
|
+
paddingHorizontal: BOX_SLOT_PAD_H
|
|
1812
|
+
}
|
|
1813
|
+
});
|
|
1814
|
+
var SwitchSlot = ({
|
|
1815
|
+
label,
|
|
1816
|
+
value,
|
|
1817
|
+
onValueChange,
|
|
1818
|
+
disabled,
|
|
1819
|
+
testID,
|
|
1820
|
+
accessibilityHint,
|
|
1821
|
+
activeTrackColor,
|
|
1822
|
+
inBox = false
|
|
1823
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "none", style: inBox ? styles14.box : styles14.row, testID: `${testID}-hitbox`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1824
|
+
reactNative.Switch,
|
|
1825
|
+
{
|
|
1826
|
+
accessibilityHint: accessibilityHint ?? label,
|
|
1827
|
+
accessibilityLabel: label,
|
|
1828
|
+
accessibilityState: { checked: value, disabled },
|
|
1829
|
+
disabled,
|
|
1830
|
+
testID: `${testID}-switch`,
|
|
1831
|
+
trackColor: activeTrackColor === void 0 ? void 0 : { true: activeTrackColor },
|
|
1832
|
+
value,
|
|
1833
|
+
onValueChange
|
|
1834
|
+
}
|
|
1835
|
+
) });
|
|
1836
|
+
var BOX_RADIUS = 8;
|
|
1837
|
+
var BOX_PAD_LEFT = 10;
|
|
1838
|
+
var BOX_BORDER = 1;
|
|
1839
|
+
var STATE_FONT_SIZE = 13;
|
|
1840
|
+
var styles15 = reactNative.StyleSheet.create({
|
|
1841
|
+
box: {
|
|
1842
|
+
flexDirection: "row",
|
|
1843
|
+
alignItems: "center",
|
|
1844
|
+
justifyContent: "space-between",
|
|
1845
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
1846
|
+
borderWidth: BOX_BORDER,
|
|
1847
|
+
borderRadius: BOX_RADIUS,
|
|
1848
|
+
paddingLeft: BOX_PAD_LEFT
|
|
1849
|
+
},
|
|
1850
|
+
state: {
|
|
1851
|
+
flex: 1,
|
|
1852
|
+
fontSize: STATE_FONT_SIZE
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
var FormSwitchBox = ({
|
|
1856
|
+
stateLabel,
|
|
1857
|
+
description,
|
|
1858
|
+
containerStyle,
|
|
1859
|
+
...slot
|
|
1860
|
+
}) => {
|
|
1861
|
+
const { colors } = uiFeedback.useUi().theme;
|
|
1862
|
+
const { disabled, onValueChange, value } = slot;
|
|
1863
|
+
const toggle2 = React39__default.default.useCallback(() => {
|
|
1864
|
+
if (!disabled) onValueChange(!value);
|
|
1865
|
+
}, [disabled, onValueChange, value]);
|
|
1866
|
+
const boxColors = React39__default.default.useMemo(
|
|
1867
|
+
() => ({ borderColor: colors.border, backgroundColor: colors.surface }),
|
|
1868
|
+
[colors.border, colors.surface]
|
|
1869
|
+
);
|
|
1870
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Field, { containerStyle, hint: description, label: slot.label, labelVariant: "control", children: () => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1871
|
+
reactNative.Pressable,
|
|
1872
|
+
{
|
|
1873
|
+
accessible: false,
|
|
1874
|
+
disabled,
|
|
1875
|
+
style: [styles15.box, boxColors],
|
|
1876
|
+
tabIndex: -1,
|
|
1877
|
+
testID: slot.testID,
|
|
1878
|
+
onPress: toggle2,
|
|
1879
|
+
children: [
|
|
1880
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles15.state, { color: colors.text }], children: stateLabel ?? "" }),
|
|
1881
|
+
/* @__PURE__ */ jsxRuntime.jsx(SwitchSlot, { ...slot, inBox: true })
|
|
1882
|
+
]
|
|
1883
|
+
}
|
|
1884
|
+
) });
|
|
1885
|
+
};
|
|
1886
|
+
var DESCRIPTION_FONT_SIZE2 = 12;
|
|
1887
|
+
var styles16 = reactNative.StyleSheet.create({
|
|
1795
1888
|
container: {
|
|
1796
1889
|
flexDirection: "row",
|
|
1797
1890
|
justifyContent: "space-between",
|
|
@@ -1801,12 +1894,6 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1801
1894
|
// `hitSlop`, so a pointer target smaller than the floor cannot be widened any other way.
|
|
1802
1895
|
minHeight: a11y.MIN_TOUCH_TARGET_PX
|
|
1803
1896
|
},
|
|
1804
|
-
switchSlot: {
|
|
1805
|
-
minWidth: a11y.MIN_TOUCH_TARGET_PX,
|
|
1806
|
-
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
1807
|
-
alignItems: "center",
|
|
1808
|
-
justifyContent: "center"
|
|
1809
|
-
},
|
|
1810
1897
|
textColumn: {
|
|
1811
1898
|
flex: 1
|
|
1812
1899
|
},
|
|
@@ -1818,23 +1905,24 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1818
1905
|
marginTop: 2
|
|
1819
1906
|
}
|
|
1820
1907
|
});
|
|
1821
|
-
var
|
|
1908
|
+
var FormSwitchRow = ({
|
|
1822
1909
|
label,
|
|
1823
1910
|
value,
|
|
1824
1911
|
onValueChange,
|
|
1825
1912
|
disabled = false,
|
|
1826
1913
|
description,
|
|
1827
1914
|
containerStyle,
|
|
1828
|
-
testID
|
|
1829
|
-
accessibilityHint
|
|
1915
|
+
testID,
|
|
1916
|
+
accessibilityHint,
|
|
1917
|
+
activeTrackColor
|
|
1830
1918
|
}) => {
|
|
1831
1919
|
const { theme } = uiFeedback.useUi();
|
|
1832
|
-
const toggle2 =
|
|
1920
|
+
const toggle2 = React39__default.default.useCallback(() => {
|
|
1833
1921
|
if (!disabled) onValueChange(!value);
|
|
1834
1922
|
}, [disabled, onValueChange, value]);
|
|
1835
1923
|
const { colors } = theme;
|
|
1836
1924
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1837
|
-
const themeStyles =
|
|
1925
|
+
const themeStyles = React39__default.default.useMemo(() => {
|
|
1838
1926
|
const labelStyle = { color: colors.text };
|
|
1839
1927
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1840
1928
|
return { label: labelStyle, description: descriptionStyle };
|
|
@@ -1852,38 +1940,45 @@ var FormSwitch = ({
|
|
|
1852
1940
|
accessible: false,
|
|
1853
1941
|
disabled,
|
|
1854
1942
|
onPress: toggle2,
|
|
1855
|
-
style: [
|
|
1943
|
+
style: [styles16.container, containerStyle],
|
|
1856
1944
|
tabIndex: -1,
|
|
1857
1945
|
testID,
|
|
1858
1946
|
children: [
|
|
1859
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1860
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1861
|
-
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1947
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.textColumn, children: [
|
|
1948
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles16.label, themeStyles.label], children: label }),
|
|
1949
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles16.description, themeStyles.description], children: description }) : null
|
|
1862
1950
|
] }),
|
|
1863
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1864
|
-
|
|
1951
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1952
|
+
SwitchSlot,
|
|
1865
1953
|
{
|
|
1866
|
-
accessibilityHint
|
|
1867
|
-
|
|
1868
|
-
accessibilityState: { checked: value, disabled },
|
|
1954
|
+
accessibilityHint,
|
|
1955
|
+
activeTrackColor,
|
|
1869
1956
|
disabled,
|
|
1870
|
-
|
|
1957
|
+
label,
|
|
1958
|
+
testID,
|
|
1871
1959
|
value,
|
|
1872
1960
|
onValueChange
|
|
1873
1961
|
}
|
|
1874
|
-
)
|
|
1962
|
+
)
|
|
1875
1963
|
]
|
|
1876
1964
|
}
|
|
1877
1965
|
)
|
|
1878
1966
|
);
|
|
1879
1967
|
};
|
|
1968
|
+
var FormSwitch = ({
|
|
1969
|
+
variant = "row",
|
|
1970
|
+
stateLabel,
|
|
1971
|
+
testID = "form-switch",
|
|
1972
|
+
disabled = false,
|
|
1973
|
+
...props
|
|
1974
|
+
}) => variant === "box" ? /* @__PURE__ */ jsxRuntime.jsx(FormSwitchBox, { ...props, disabled, stateLabel, testID }) : /* @__PURE__ */ jsxRuntime.jsx(FormSwitchRow, { ...props, disabled, testID });
|
|
1880
1975
|
|
|
1881
1976
|
// src/FormCheckbox/checkboxColors.ts
|
|
1882
1977
|
var checkboxBoxColors = (colors, brand, checked) => checked ? { backgroundColor: brand, borderColor: brand } : { backgroundColor: "transparent", borderColor: colors.textSecondary };
|
|
1883
1978
|
var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
|
|
1884
1979
|
var HINT_FONT_SIZE2 = 12;
|
|
1885
1980
|
var BOX_SIZE = 20;
|
|
1886
|
-
var
|
|
1981
|
+
var BOX_RADIUS2 = 5;
|
|
1887
1982
|
var TICK_WIDTH = 6;
|
|
1888
1983
|
var TICK_HEIGHT = 10;
|
|
1889
1984
|
var TICK_STROKE = 2;
|
|
@@ -1892,7 +1987,7 @@ var DISABLED_OPACITY = 0.5;
|
|
|
1892
1987
|
var FOCUS_RING_WIDTH = 2;
|
|
1893
1988
|
var WEB_NO_DEFAULT_OUTLINE = { outlineStyle: "none" };
|
|
1894
1989
|
var FOCUS_RING_INSET = -6;
|
|
1895
|
-
var
|
|
1990
|
+
var styles17 = reactNative.StyleSheet.create({
|
|
1896
1991
|
container: {
|
|
1897
1992
|
flexDirection: "row",
|
|
1898
1993
|
alignItems: "flex-start",
|
|
@@ -1909,7 +2004,7 @@ var styles15 = reactNative.StyleSheet.create({
|
|
|
1909
2004
|
box: {
|
|
1910
2005
|
width: BOX_SIZE,
|
|
1911
2006
|
height: BOX_SIZE,
|
|
1912
|
-
borderRadius:
|
|
2007
|
+
borderRadius: BOX_RADIUS2,
|
|
1913
2008
|
borderWidth: 2,
|
|
1914
2009
|
alignItems: "center",
|
|
1915
2010
|
justifyContent: "center",
|
|
@@ -1923,7 +2018,7 @@ var styles15 = reactNative.StyleSheet.create({
|
|
|
1923
2018
|
right: FOCUS_RING_INSET,
|
|
1924
2019
|
bottom: FOCUS_RING_INSET,
|
|
1925
2020
|
borderWidth: FOCUS_RING_WIDTH,
|
|
1926
|
-
borderRadius:
|
|
2021
|
+
borderRadius: BOX_RADIUS2 - FOCUS_RING_INSET
|
|
1927
2022
|
},
|
|
1928
2023
|
tick: {
|
|
1929
2024
|
width: TICK_WIDTH,
|
|
@@ -1963,8 +2058,8 @@ var FormCheckbox = ({
|
|
|
1963
2058
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
1964
2059
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
1965
2060
|
const { hintId } = useFieldIds();
|
|
1966
|
-
const [focused, setFocused] =
|
|
1967
|
-
const themeStyles =
|
|
2061
|
+
const [focused, setFocused] = React39__default.default.useState(false);
|
|
2062
|
+
const themeStyles = React39__default.default.useMemo(() => {
|
|
1968
2063
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
1969
2064
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
1970
2065
|
const ring = { borderColor: brand };
|
|
@@ -2000,8 +2095,8 @@ var FormCheckbox = ({
|
|
|
2000
2095
|
onPress: toggle2,
|
|
2001
2096
|
role: "checkbox",
|
|
2002
2097
|
style: [
|
|
2003
|
-
|
|
2004
|
-
hasHint ? null :
|
|
2098
|
+
styles17.container,
|
|
2099
|
+
hasHint ? null : styles17.centered,
|
|
2005
2100
|
containerStyle,
|
|
2006
2101
|
disabled ? { opacity: DISABLED_OPACITY } : null,
|
|
2007
2102
|
reactNative.Platform.OS === "web" ? WEB_NO_DEFAULT_OUTLINE : null
|
|
@@ -2009,13 +2104,13 @@ var FormCheckbox = ({
|
|
|
2009
2104
|
testID,
|
|
2010
2105
|
...keyboardProps,
|
|
2011
2106
|
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: [
|
|
2107
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles17.box, value ? themeStyles.boxOn : themeStyles.boxOff], testID: `${testID}-box`, children: [
|
|
2108
|
+
focused ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "none", style: [styles17.focusRing, themeStyles.ring], testID: `${testID}-focus-ring` }) : null,
|
|
2109
|
+
value ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityElementsHidden: true, pointerEvents: "none", style: [styles17.tick, { borderColor: colors.surface }], testID: `${testID}-tick` }) : null
|
|
2015
2110
|
] }),
|
|
2016
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2017
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2018
|
-
hasHint ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { nativeID: hintId, style: [
|
|
2111
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles17.textColumn, children: [
|
|
2112
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles17.label, themeStyles.label], children: label }),
|
|
2113
|
+
hasHint ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { nativeID: hintId, style: [styles17.hint, themeStyles.hint], children: hintText }) : null
|
|
2019
2114
|
] })
|
|
2020
2115
|
]
|
|
2021
2116
|
}
|
|
@@ -2089,9 +2184,9 @@ function nextHighlight(current, count, delta) {
|
|
|
2089
2184
|
var FORWARD = 1;
|
|
2090
2185
|
var BACKWARD = -1;
|
|
2091
2186
|
function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
2092
|
-
const [row, setRow] =
|
|
2187
|
+
const [row, setRow] = React39.useState(NO_HIGHLIGHT);
|
|
2093
2188
|
const highlighted = isOpen ? options[row] : void 0;
|
|
2094
|
-
|
|
2189
|
+
React39.useEffect(() => {
|
|
2095
2190
|
if (!isOpen) setRow(NO_HIGHLIGHT);
|
|
2096
2191
|
}, [isOpen]);
|
|
2097
2192
|
const onKeyDown = (event) => {
|
|
@@ -2136,22 +2231,22 @@ function MenuSelectControl({
|
|
|
2136
2231
|
}) {
|
|
2137
2232
|
const { theme } = uiFeedback.useUi();
|
|
2138
2233
|
const { colors, palette } = theme;
|
|
2139
|
-
const anchorRef =
|
|
2140
|
-
const [isOpen, setIsOpen] =
|
|
2141
|
-
const selectedLabel =
|
|
2234
|
+
const anchorRef = React39.useRef(null);
|
|
2235
|
+
const [isOpen, setIsOpen] = React39.useState(false);
|
|
2236
|
+
const selectedLabel = React39.useMemo(() => {
|
|
2142
2237
|
const found = options.find((o) => o.value === value);
|
|
2143
2238
|
return found?.label ?? placeholder;
|
|
2144
2239
|
}, [options, placeholder, value]);
|
|
2145
|
-
const close =
|
|
2240
|
+
const close = React39.useCallback(() => {
|
|
2146
2241
|
setIsOpen(false);
|
|
2147
2242
|
}, []);
|
|
2148
|
-
const open =
|
|
2243
|
+
const open = React39.useCallback(() => {
|
|
2149
2244
|
setIsOpen(true);
|
|
2150
2245
|
}, []);
|
|
2151
|
-
const toggle2 =
|
|
2246
|
+
const toggle2 = React39.useCallback(() => {
|
|
2152
2247
|
setIsOpen((prev) => !prev);
|
|
2153
2248
|
}, []);
|
|
2154
|
-
const select =
|
|
2249
|
+
const select = React39.useCallback(
|
|
2155
2250
|
(next) => {
|
|
2156
2251
|
onChange(next);
|
|
2157
2252
|
setIsOpen(false);
|
|
@@ -2231,7 +2326,7 @@ var CHIP_PAD_H = 8;
|
|
|
2231
2326
|
var CHIP_PAD_V = 4;
|
|
2232
2327
|
var CHIP_RADIUS = 999;
|
|
2233
2328
|
var CHIP_FONT = 13;
|
|
2234
|
-
var
|
|
2329
|
+
var styles18 = reactNative.StyleSheet.create({
|
|
2235
2330
|
chip: {
|
|
2236
2331
|
flexDirection: "row",
|
|
2237
2332
|
alignItems: "center",
|
|
@@ -2252,12 +2347,12 @@ function SelectedChip({ option, colors, removeLabel, removeHint, onRemove, testI
|
|
|
2252
2347
|
accessibilityLabel: removeLabel,
|
|
2253
2348
|
accessibilityRole: "button",
|
|
2254
2349
|
hitSlop: CHIP_HIT_SLOP,
|
|
2255
|
-
style: [
|
|
2350
|
+
style: [styles18.chip, { borderColor: colors.border, backgroundColor: colors.surface }],
|
|
2256
2351
|
testID,
|
|
2257
2352
|
onPress: () => onRemove(option.value),
|
|
2258
2353
|
children: [
|
|
2259
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [
|
|
2260
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [
|
|
2354
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles18.text, { color: colors.text }], children: option.label }),
|
|
2355
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [styles18.text, { color: colors.text }], children: REMOVE_GLYPH })
|
|
2261
2356
|
]
|
|
2262
2357
|
}
|
|
2263
2358
|
);
|
|
@@ -2280,7 +2375,7 @@ var CHEVRON_DOWN2 = "\u25BE";
|
|
|
2280
2375
|
var CHEVRON_UP2 = "\u25B4";
|
|
2281
2376
|
var BOX_GAP = 6;
|
|
2282
2377
|
var TRIGGER_MIN_WIDTH = 96;
|
|
2283
|
-
var
|
|
2378
|
+
var styles19 = reactNative.StyleSheet.create({
|
|
2284
2379
|
box: { flexWrap: "wrap", justifyContent: "flex-start", gap: BOX_GAP },
|
|
2285
2380
|
trigger: {
|
|
2286
2381
|
flexGrow: 1,
|
|
@@ -2294,27 +2389,27 @@ var styles17 = reactNative.StyleSheet.create({
|
|
|
2294
2389
|
function MultiSelectBox(props) {
|
|
2295
2390
|
const { label, accessibilityHint, values, options, onChange, placeholder, chipLabels, testID, labelId } = props;
|
|
2296
2391
|
const { colors, palette } = uiFeedback.useUi().theme;
|
|
2297
|
-
const anchorRef =
|
|
2298
|
-
const [isOpen, setIsOpen] =
|
|
2392
|
+
const anchorRef = React39.useRef(null);
|
|
2393
|
+
const [isOpen, setIsOpen] = React39.useState(false);
|
|
2299
2394
|
const chosen = selectedOptions(options, values);
|
|
2300
2395
|
const remaining = remainingOptions(options, values);
|
|
2301
|
-
const close =
|
|
2396
|
+
const close = React39.useCallback(() => {
|
|
2302
2397
|
setIsOpen(false);
|
|
2303
2398
|
}, []);
|
|
2304
|
-
const toggle2 =
|
|
2399
|
+
const toggle2 = React39.useCallback(() => {
|
|
2305
2400
|
setIsOpen((prev) => !prev);
|
|
2306
2401
|
}, []);
|
|
2307
|
-
const add =
|
|
2402
|
+
const add = React39.useCallback((next) => {
|
|
2308
2403
|
onChange(addValue(values, next));
|
|
2309
2404
|
setIsOpen(false);
|
|
2310
2405
|
}, [onChange, values]);
|
|
2311
|
-
const remove =
|
|
2406
|
+
const remove = React39.useCallback((value) => {
|
|
2312
2407
|
onChange(removeValue(values, value));
|
|
2313
2408
|
}, [onChange, values]);
|
|
2314
2409
|
const chipColors = { text: colors.text, border: colors.border, surface: colors.surface };
|
|
2315
2410
|
const summary = chosen.map((option) => option.label).join(", ");
|
|
2316
2411
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: controlStyles.anchor, children: [
|
|
2317
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.selectTrigger,
|
|
2412
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.selectTrigger, styles19.box, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], testID: `${testID}-box`, children: [
|
|
2318
2413
|
chosen.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2319
2414
|
SelectedChip,
|
|
2320
2415
|
{
|
|
@@ -2338,7 +2433,7 @@ function MultiSelectBox(props) {
|
|
|
2338
2433
|
"aria-haspopup": "menu",
|
|
2339
2434
|
"aria-labelledby": labelId,
|
|
2340
2435
|
disabled: remaining.length === 0,
|
|
2341
|
-
style:
|
|
2436
|
+
style: styles19.trigger,
|
|
2342
2437
|
testID: `${testID}-trigger`,
|
|
2343
2438
|
onPress: toggle2,
|
|
2344
2439
|
children: [
|
|
@@ -2366,17 +2461,17 @@ function MultiSelectBox(props) {
|
|
|
2366
2461
|
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
2462
|
var CLOSE_DELAY_MS2 = 140;
|
|
2368
2463
|
function useDelayedBlurClose(open, close) {
|
|
2369
|
-
const timerRef =
|
|
2370
|
-
const cancelClose =
|
|
2464
|
+
const timerRef = React39.useRef(null);
|
|
2465
|
+
const cancelClose = React39.useCallback(() => {
|
|
2371
2466
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
2372
2467
|
timerRef.current = null;
|
|
2373
2468
|
}, []);
|
|
2374
|
-
|
|
2375
|
-
const handleFocus =
|
|
2469
|
+
React39.useEffect(() => cancelClose, [cancelClose]);
|
|
2470
|
+
const handleFocus = React39.useCallback(() => {
|
|
2376
2471
|
cancelClose();
|
|
2377
2472
|
open();
|
|
2378
2473
|
}, [cancelClose, open]);
|
|
2379
|
-
const handleBlur =
|
|
2474
|
+
const handleBlur = React39.useCallback(() => {
|
|
2380
2475
|
cancelClose();
|
|
2381
2476
|
timerRef.current = setTimeout(close, CLOSE_DELAY_MS2);
|
|
2382
2477
|
}, [cancelClose, close]);
|
|
@@ -2419,10 +2514,10 @@ function isUnmatched(options, text) {
|
|
|
2419
2514
|
var DEFAULT_TYPEAHEAD_DEBOUNCE_MS = 250;
|
|
2420
2515
|
var IDLE = { results: [], isLoading: false, hasFailed: false, hasSettled: false };
|
|
2421
2516
|
function useTypeaheadSearch(load, query, enabled, debounceMs) {
|
|
2422
|
-
const [state, setState] =
|
|
2423
|
-
const loadRef =
|
|
2517
|
+
const [state, setState] = React39.useState(IDLE);
|
|
2518
|
+
const loadRef = React39.useRef(load);
|
|
2424
2519
|
loadRef.current = load;
|
|
2425
|
-
|
|
2520
|
+
React39.useEffect(() => {
|
|
2426
2521
|
if (!enabled) {
|
|
2427
2522
|
setState(IDLE);
|
|
2428
2523
|
return void 0;
|
|
@@ -2461,30 +2556,30 @@ function useTypeaheadRows(input, isOpen, isPicked) {
|
|
|
2461
2556
|
const query = value.trim();
|
|
2462
2557
|
const isSearching = search !== void 0 && isOpen && !isPicked && query.length >= minChars;
|
|
2463
2558
|
const found = useTypeaheadSearch(search?.load, query, isSearching, search?.debounceMs ?? DEFAULT_TYPEAHEAD_DEBOUNCE_MS);
|
|
2464
|
-
const staticRows =
|
|
2559
|
+
const staticRows = React39.useMemo(() => {
|
|
2465
2560
|
if (options === void 0 || options.some((o) => o.label === value)) return NO_ROWS;
|
|
2466
2561
|
return suggestOptions(options, value, minChars, maxSuggestions);
|
|
2467
2562
|
}, [options, value, minChars, maxSuggestions]);
|
|
2468
|
-
const foundRows =
|
|
2563
|
+
const foundRows = React39.useMemo(() => found.results.slice(0, maxSuggestions), [found.results, maxSuggestions]);
|
|
2469
2564
|
if (search === void 0) return { rows: staticRows, statusText: void 0 };
|
|
2470
2565
|
return { rows: foundRows, statusText: searchStatusText(found, search) };
|
|
2471
2566
|
}
|
|
2472
2567
|
function useTypeaheadState(input) {
|
|
2473
2568
|
const { search, value, onChange, onSubmit } = input;
|
|
2474
|
-
const [isOpen, setIsOpen] =
|
|
2475
|
-
const [picked, setPicked] =
|
|
2476
|
-
const [highlightIndex, setHighlightIndex] =
|
|
2569
|
+
const [isOpen, setIsOpen] = React39.useState(false);
|
|
2570
|
+
const [picked, setPicked] = React39.useState(null);
|
|
2571
|
+
const [highlightIndex, setHighlightIndex] = React39.useState(NO_HIGHLIGHT);
|
|
2477
2572
|
const { rows, statusText } = useTypeaheadRows(input, isOpen, picked !== null && picked.label === value);
|
|
2478
2573
|
const rowKey = rows.map((row) => row.value).join("\n");
|
|
2479
2574
|
const highlighted = isOpen ? rows[highlightIndex] : void 0;
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
const open =
|
|
2483
|
-
const close =
|
|
2575
|
+
React39.useEffect(() => setHighlightIndex(NO_HIGHLIGHT), [rowKey]);
|
|
2576
|
+
React39.useEffect(() => setPicked((current) => current !== null && current.label !== value ? null : current), [value]);
|
|
2577
|
+
const open = React39.useCallback(() => setIsOpen(true), []);
|
|
2578
|
+
const close = React39.useCallback(() => {
|
|
2484
2579
|
setIsOpen(false);
|
|
2485
2580
|
setHighlightIndex(NO_HIGHLIGHT);
|
|
2486
2581
|
}, []);
|
|
2487
|
-
const pick =
|
|
2582
|
+
const pick = React39.useCallback(
|
|
2488
2583
|
(option) => {
|
|
2489
2584
|
setPicked(option);
|
|
2490
2585
|
onChange(option.label);
|
|
@@ -2493,14 +2588,14 @@ function useTypeaheadState(input) {
|
|
|
2493
2588
|
},
|
|
2494
2589
|
[onChange, search, close]
|
|
2495
2590
|
);
|
|
2496
|
-
const selectValue =
|
|
2591
|
+
const selectValue = React39.useCallback(
|
|
2497
2592
|
(optionValue) => {
|
|
2498
2593
|
const option = rows.find((row) => row.value === optionValue);
|
|
2499
2594
|
if (option !== void 0) pick(option);
|
|
2500
2595
|
},
|
|
2501
2596
|
[rows, pick]
|
|
2502
2597
|
);
|
|
2503
|
-
const handleChange =
|
|
2598
|
+
const handleChange = React39.useCallback(
|
|
2504
2599
|
(next) => {
|
|
2505
2600
|
if (picked !== null) {
|
|
2506
2601
|
setPicked(null);
|
|
@@ -2513,7 +2608,7 @@ function useTypeaheadState(input) {
|
|
|
2513
2608
|
[picked, search, onChange]
|
|
2514
2609
|
);
|
|
2515
2610
|
const handleKeyPress = useTypeaheadKeys({ rowCount: rows.length, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick });
|
|
2516
|
-
const handleSubmit =
|
|
2611
|
+
const handleSubmit = React39.useCallback(() => {
|
|
2517
2612
|
if (highlighted !== void 0) {
|
|
2518
2613
|
pick(highlighted);
|
|
2519
2614
|
return;
|
|
@@ -2525,7 +2620,7 @@ function useTypeaheadState(input) {
|
|
|
2525
2620
|
}
|
|
2526
2621
|
function useTypeaheadKeys(input) {
|
|
2527
2622
|
const { rowCount, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick } = input;
|
|
2528
|
-
return
|
|
2623
|
+
return React39.useCallback(
|
|
2529
2624
|
(event) => {
|
|
2530
2625
|
const { key } = event.nativeEvent;
|
|
2531
2626
|
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
@@ -2562,7 +2657,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2562
2657
|
const maxSuggestions = ("search" in props ? props.search.maxResults : props.maxSuggestions) ?? DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
|
|
2563
2658
|
const { theme } = uiFeedback.useUi();
|
|
2564
2659
|
const { colors, palette } = theme;
|
|
2565
|
-
const anchorRef =
|
|
2660
|
+
const anchorRef = React39.useRef(null);
|
|
2566
2661
|
const state = useTypeaheadState({ options, search, value, minChars, maxSuggestions, onChange, onSubmit });
|
|
2567
2662
|
const { handleFocus, handleBlur } = useDelayedBlurClose(state.open, state.close);
|
|
2568
2663
|
const showMenu = state.isOpen && (state.rows.length > 0 || state.statusText !== void 0);
|
|
@@ -2615,7 +2710,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2615
2710
|
hasError ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [controlStyles.error, { color: fieldErrorInk(theme) }], testID: `${testID}-error`, children: error }) : null
|
|
2616
2711
|
] });
|
|
2617
2712
|
}
|
|
2618
|
-
var TypeaheadControl =
|
|
2713
|
+
var TypeaheadControl = React39.forwardRef(TypeaheadControlImpl);
|
|
2619
2714
|
var NATIVE_INPUT_BOX = {
|
|
2620
2715
|
borderStyle: "solid",
|
|
2621
2716
|
boxSizing: "border-box",
|
|
@@ -2703,7 +2798,7 @@ function tabStops(container) {
|
|
|
2703
2798
|
}
|
|
2704
2799
|
function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
2705
2800
|
const colors = usePickerColors();
|
|
2706
|
-
const ref =
|
|
2801
|
+
const ref = React39.useRef(null);
|
|
2707
2802
|
const onKeyDown = (event) => {
|
|
2708
2803
|
if (event.key === "Escape") {
|
|
2709
2804
|
event.preventDefault();
|
|
@@ -2726,8 +2821,8 @@ function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
|
2726
2821
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-testid": testID, "data-variant": sheet ? "sheet" : "popover", style, onKeyDown, children });
|
|
2727
2822
|
}
|
|
2728
2823
|
function useAnchorRect2(anchorRef) {
|
|
2729
|
-
const [rect2, setRect] =
|
|
2730
|
-
|
|
2824
|
+
const [rect2, setRect] = React39.useState(null);
|
|
2825
|
+
React39.useEffect(() => {
|
|
2731
2826
|
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2732
2827
|
}, [anchorRef]);
|
|
2733
2828
|
return rect2;
|
|
@@ -2770,32 +2865,32 @@ function fitDropdownWidth(frame, viewportWidth, minWidth = MIN_PANEL_WIDTH) {
|
|
|
2770
2865
|
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children, minWidth, scale, accessibilityLabel, preferBelow = false }) {
|
|
2771
2866
|
const { height: viewportHeight, width: viewportWidth } = reactNative.useWindowDimensions();
|
|
2772
2867
|
const anchor = useAnchorRect2(anchorRef);
|
|
2773
|
-
const [panelHeight, setPanelHeight] =
|
|
2774
|
-
const onLayout =
|
|
2868
|
+
const [panelHeight, setPanelHeight] = React39.useState(0);
|
|
2869
|
+
const onLayout = React39.useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2775
2870
|
const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight, preferBelow), viewportWidth, minWidth);
|
|
2776
2871
|
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2777
2872
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: [
|
|
2778
2873
|
/* @__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: [
|
|
2874
|
+
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
2875
|
] });
|
|
2781
2876
|
}
|
|
2782
|
-
var
|
|
2877
|
+
var styles20 = reactNative.StyleSheet.create({
|
|
2783
2878
|
dropdown: { position: "absolute" },
|
|
2784
2879
|
growFromField: { transformOrigin: "top left" }
|
|
2785
2880
|
});
|
|
2786
2881
|
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:
|
|
2882
|
+
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
2883
|
/* @__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: [
|
|
2884
|
+
/* @__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
2885
|
] }) });
|
|
2791
2886
|
}
|
|
2792
|
-
var
|
|
2887
|
+
var styles21 = reactNative.StyleSheet.create({
|
|
2793
2888
|
backdrop: { flex: 1, justifyContent: "flex-end" },
|
|
2794
2889
|
sheet: { width: "100%", alignSelf: "stretch" }
|
|
2795
2890
|
});
|
|
2796
2891
|
function useReducedMotion() {
|
|
2797
|
-
const [reduced, setReduced] =
|
|
2798
|
-
|
|
2892
|
+
const [reduced, setReduced] = React39.useState(false);
|
|
2893
|
+
React39.useEffect(() => {
|
|
2799
2894
|
let active = true;
|
|
2800
2895
|
reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
2801
2896
|
if (active) setReduced(value);
|
|
@@ -3006,14 +3101,14 @@ function weekFirstDay(locale) {
|
|
|
3006
3101
|
return MONDAY3;
|
|
3007
3102
|
}
|
|
3008
3103
|
}
|
|
3009
|
-
var DatePickerContext =
|
|
3104
|
+
var DatePickerContext = React39.createContext({ labels: DEFAULT_DATE_PICKER_LABELS });
|
|
3010
3105
|
function DatePickerProvider({ labels, locale, today, display, children }) {
|
|
3011
|
-
const value =
|
|
3106
|
+
const value = React39.useMemo(() => ({ labels: { ...DEFAULT_DATE_PICKER_LABELS, ...labels }, locale, today, display }), [labels, locale, today, display]);
|
|
3012
3107
|
return /* @__PURE__ */ jsxRuntime.jsx(DatePickerContext.Provider, { value, children });
|
|
3013
3108
|
}
|
|
3014
3109
|
function useDatePickerConfig() {
|
|
3015
|
-
const config =
|
|
3016
|
-
const firstDay =
|
|
3110
|
+
const config = React39.useContext(DatePickerContext);
|
|
3111
|
+
const firstDay = React39.useMemo(() => weekFirstDay(config.locale), [config.locale]);
|
|
3017
3112
|
return { labels: config.labels, locale: config.locale, today: config.today ?? todayIso(), firstDay, display: config.display ?? "long" /* Long */ };
|
|
3018
3113
|
}
|
|
3019
3114
|
|
|
@@ -3036,8 +3131,8 @@ function monthSlideStyle(entered, reduced, direction) {
|
|
|
3036
3131
|
}
|
|
3037
3132
|
function useOpenProgress() {
|
|
3038
3133
|
const { durationMs, fromScale } = resolveOpenMotion(useReducedMotion());
|
|
3039
|
-
const progress =
|
|
3040
|
-
|
|
3134
|
+
const progress = React39.useRef(new reactNative.Animated.Value(0)).current;
|
|
3135
|
+
React39.useEffect(() => {
|
|
3041
3136
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
3042
3137
|
}, [progress, durationMs]);
|
|
3043
3138
|
return {
|
|
@@ -3083,16 +3178,16 @@ function dayDomId(testID, iso) {
|
|
|
3083
3178
|
}
|
|
3084
3179
|
function useGridFocus(initial, bounds, testID, onPick) {
|
|
3085
3180
|
const { firstDay } = useDatePickerConfig();
|
|
3086
|
-
const [focusedDay, setFocusedDay] =
|
|
3087
|
-
const focusPending =
|
|
3181
|
+
const [focusedDay, setFocusedDay] = React39.useState(initial);
|
|
3182
|
+
const focusPending = React39.useRef(true);
|
|
3088
3183
|
const { min, max } = bounds;
|
|
3089
|
-
|
|
3184
|
+
React39.useEffect(() => {
|
|
3090
3185
|
if (!focusPending.current) return;
|
|
3091
3186
|
focusPending.current = false;
|
|
3092
3187
|
document.getElementById(dayDomId(testID, focusedDay))?.focus();
|
|
3093
3188
|
}, [focusedDay, testID]);
|
|
3094
|
-
const moveTo =
|
|
3095
|
-
const onDayKey =
|
|
3189
|
+
const moveTo = React39.useCallback((iso) => setFocusedDay(clampToBounds(iso, min, max)), [min, max]);
|
|
3190
|
+
const onDayKey = React39.useCallback(
|
|
3096
3191
|
(event, iso) => {
|
|
3097
3192
|
if (event.key === "Enter" || event.key === " ") {
|
|
3098
3193
|
event.preventDefault();
|
|
@@ -3179,8 +3274,8 @@ function MonthGrid({ month, selection: selection2, focusedDay, bounds, testID, o
|
|
|
3179
3274
|
const { labels, locale, today, firstDay } = useDatePickerConfig();
|
|
3180
3275
|
const colors = usePickerColors();
|
|
3181
3276
|
const parts = parseIso(month) ?? FALLBACK;
|
|
3182
|
-
const weeks =
|
|
3183
|
-
const weekdays =
|
|
3277
|
+
const weeks = React39.useMemo(() => buildMonthGrid(parts.year, parts.month, firstDay), [parts.year, parts.month, firstDay]);
|
|
3278
|
+
const weekdays = React39.useMemo(() => weekdayNames(locale, firstDay), [locale, firstDay]);
|
|
3184
3279
|
const title = formatMonthYear(month, locale);
|
|
3185
3280
|
const end = selection2.to === "" ? selection2.from : selection2.to;
|
|
3186
3281
|
const stateOf = (iso) => ({
|
|
@@ -3219,7 +3314,7 @@ function MonthHeader({ focusedDay, bounds, testID, onMove }) {
|
|
|
3219
3314
|
const { labels, locale } = useDatePickerConfig();
|
|
3220
3315
|
const colors = usePickerColors();
|
|
3221
3316
|
const parts = parseIso(focusedDay) ?? FALLBACK2;
|
|
3222
|
-
const names =
|
|
3317
|
+
const names = React39.useMemo(() => monthNames(locale), [locale]);
|
|
3223
3318
|
const setMonthYear = (year, month) => onMove(toIso({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) }));
|
|
3224
3319
|
const selectStyle = { minHeight: a11y.MIN_TOUCH_TARGET_PX, border: "none", background: "transparent", color: colors.text, fontWeight: BOLD3, fontSize: FONT2, fontFamily: "inherit", cursor: "pointer" };
|
|
3225
3320
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
@@ -3240,8 +3335,8 @@ function PickerFooter({ summary, children }) {
|
|
|
3240
3335
|
] });
|
|
3241
3336
|
}
|
|
3242
3337
|
function useEntered(key, reduced) {
|
|
3243
|
-
const [enteredKey, setEnteredKey] =
|
|
3244
|
-
|
|
3338
|
+
const [enteredKey, setEnteredKey] = React39.useState(null);
|
|
3339
|
+
React39.useEffect(() => {
|
|
3245
3340
|
if (reduced) return void 0;
|
|
3246
3341
|
let inner = 0;
|
|
3247
3342
|
const outer = requestAnimationFrame(() => {
|
|
@@ -3256,8 +3351,8 @@ function useEntered(key, reduced) {
|
|
|
3256
3351
|
}
|
|
3257
3352
|
function useMonthSlide(month) {
|
|
3258
3353
|
const reduced = useReducedMotion();
|
|
3259
|
-
const previous =
|
|
3260
|
-
const direction =
|
|
3354
|
+
const previous = React39.useRef(month);
|
|
3355
|
+
const direction = React39.useRef(0);
|
|
3261
3356
|
if (previous.current !== month) {
|
|
3262
3357
|
direction.current = month > previous.current ? 1 : -1;
|
|
3263
3358
|
previous.current = month;
|
|
@@ -3267,7 +3362,7 @@ function useMonthSlide(month) {
|
|
|
3267
3362
|
}
|
|
3268
3363
|
function SingleCalendar({ value, bounds, testID, onCommit }) {
|
|
3269
3364
|
const { labels, today } = useDatePickerConfig();
|
|
3270
|
-
const [draft, setDraft] =
|
|
3365
|
+
const [draft, setDraft] = React39.useState(value);
|
|
3271
3366
|
const grid = useGridFocus(clampToBounds(value !== "" ? value : today, bounds.min, bounds.max), bounds, testID, setDraft);
|
|
3272
3367
|
const month = monthStart(grid.focusedDay);
|
|
3273
3368
|
const motion = useMonthSlide(month);
|
|
@@ -3288,8 +3383,8 @@ function useIsPhone() {
|
|
|
3288
3383
|
return !isWideFormLayout(reactNative.useWindowDimensions().width);
|
|
3289
3384
|
}
|
|
3290
3385
|
function useReturnFocus(open, target) {
|
|
3291
|
-
const wasOpen =
|
|
3292
|
-
|
|
3386
|
+
const wasOpen = React39.useRef(open);
|
|
3387
|
+
React39.useEffect(() => {
|
|
3293
3388
|
const closed = wasOpen.current && !open;
|
|
3294
3389
|
wasOpen.current = open;
|
|
3295
3390
|
if (!closed) return void 0;
|
|
@@ -3299,9 +3394,9 @@ function useReturnFocus(open, target) {
|
|
|
3299
3394
|
}
|
|
3300
3395
|
function useTypedDate({ value, onChange, bounds, format, onError, rangeMessage, editOnType = false }) {
|
|
3301
3396
|
const { labels, locale } = useDatePickerConfig();
|
|
3302
|
-
const [editing, setEditing] =
|
|
3303
|
-
const [text, setText] =
|
|
3304
|
-
|
|
3397
|
+
const [editing, setEditing] = React39.useState(false);
|
|
3398
|
+
const [text, setText] = React39.useState("");
|
|
3399
|
+
React39.useEffect(() => {
|
|
3305
3400
|
setText((current) => {
|
|
3306
3401
|
const parsed = current.trim() === "" ? "" : parseTyped(current, locale);
|
|
3307
3402
|
if (parsed === null || parsed === value) return current;
|
|
@@ -3421,16 +3516,16 @@ function DatePickerInput({ fieldProps, context, onTypedError }) {
|
|
|
3421
3516
|
const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
|
|
3422
3517
|
const { labels, display } = useDatePickerConfig();
|
|
3423
3518
|
const phone = useIsPhone();
|
|
3424
|
-
const [open, setOpen] =
|
|
3425
|
-
const anchorRef =
|
|
3426
|
-
const inputRef =
|
|
3519
|
+
const [open, setOpen] = React39.useState(false);
|
|
3520
|
+
const anchorRef = React39.useRef(null);
|
|
3521
|
+
const inputRef = React39.useRef(null);
|
|
3427
3522
|
const bounds = { min, max };
|
|
3428
3523
|
const typed = useTypedDate({ value, onChange, bounds, format: displayFormatter(display), onError: onTypedError, editOnType: true });
|
|
3429
3524
|
const edit = typedEditBind(typed);
|
|
3430
3525
|
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
|
|
3431
3526
|
const focus = focusBind;
|
|
3432
3527
|
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError, required });
|
|
3433
|
-
const close =
|
|
3528
|
+
const close = React39.useCallback(() => setOpen(false), []);
|
|
3434
3529
|
useReturnFocus(open, inputRef);
|
|
3435
3530
|
const commit = (iso) => {
|
|
3436
3531
|
onTypedError?.(void 0);
|
|
@@ -3506,7 +3601,7 @@ function TemporalInput({ fieldProps, context, webInputType, onTypedError }) {
|
|
|
3506
3601
|
}
|
|
3507
3602
|
function TemporalField({ fieldProps, webInputType }) {
|
|
3508
3603
|
const { label, required, hint, error } = fieldProps;
|
|
3509
|
-
const [typedError, setTypedError] =
|
|
3604
|
+
const [typedError, setTypedError] = React39.useState(void 0);
|
|
3510
3605
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error: error ?? typedError, hint, label, required, children: (context) => /* @__PURE__ */ jsxRuntime.jsx(TemporalInput, { context, fieldProps, webInputType, onTypedError: setTypedError }) });
|
|
3511
3606
|
}
|
|
3512
3607
|
function DateField(props) {
|
|
@@ -3635,17 +3730,17 @@ function useRangeSummary(draft) {
|
|
|
3635
3730
|
}
|
|
3636
3731
|
function RangeCalendar({ value, bounds, phone, testID, onApply, onCancel }) {
|
|
3637
3732
|
const { labels, today } = useDatePickerConfig();
|
|
3638
|
-
const [draft, setDraft] =
|
|
3733
|
+
const [draft, setDraft] = React39.useState(value);
|
|
3639
3734
|
const initialDay = clampToBounds(value.from !== "" ? value.from : today, bounds.min, bounds.max);
|
|
3640
|
-
const pickDraft =
|
|
3735
|
+
const pickDraft = React39.useCallback((iso) => setDraft((current) => pickRangeDay(current, iso)), []);
|
|
3641
3736
|
const focus = useGridFocus(initialDay, bounds, testID, pickDraft);
|
|
3642
3737
|
const visible = phone ? PHONE_MONTHS : DESKTOP_MONTHS;
|
|
3643
|
-
const [first, setFirst] =
|
|
3738
|
+
const [first, setFirst] = React39.useState(() => monthStart(phone ? initialDay : addMonths(initialDay, 1 - DESKTOP_MONTHS)));
|
|
3644
3739
|
const focusMonth = monthStart(focus.focusedDay);
|
|
3645
3740
|
const last = addMonths(first, visible - 1);
|
|
3646
3741
|
const motion = useMonthSlide(first);
|
|
3647
3742
|
const summary = useRangeSummary(draft);
|
|
3648
|
-
|
|
3743
|
+
React39.useEffect(() => {
|
|
3649
3744
|
if (focusMonth < first) setFirst(focusMonth);
|
|
3650
3745
|
else if (focusMonth > last) setFirst(addMonths(focusMonth, 1 - visible));
|
|
3651
3746
|
}, [focusMonth, first, last, visible]);
|
|
@@ -3694,18 +3789,18 @@ function orNone(value) {
|
|
|
3694
3789
|
function WebDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, testID, context, onTypedError }) {
|
|
3695
3790
|
const { labels } = useDatePickerConfig();
|
|
3696
3791
|
const phone = useIsPhone();
|
|
3697
|
-
const [open, setOpen] =
|
|
3698
|
-
const [fromError, setFromError] =
|
|
3699
|
-
const [toError, setToError] =
|
|
3700
|
-
const anchorRef =
|
|
3701
|
-
const fromRef =
|
|
3792
|
+
const [open, setOpen] = React39.useState(false);
|
|
3793
|
+
const [fromError, setFromError] = React39.useState(void 0);
|
|
3794
|
+
const [toError, setToError] = React39.useState(void 0);
|
|
3795
|
+
const anchorRef = React39.useRef(null);
|
|
3796
|
+
const fromRef = React39.useRef(null);
|
|
3702
3797
|
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
3798
|
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
3799
|
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: true });
|
|
3705
3800
|
const focus = focusBind;
|
|
3706
3801
|
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError });
|
|
3707
|
-
|
|
3708
|
-
const close =
|
|
3802
|
+
React39.useEffect(() => onTypedError(fromError ?? toError), [fromError, toError, onTypedError]);
|
|
3803
|
+
const close = React39.useCallback(() => setOpen(false), []);
|
|
3709
3804
|
useReturnFocus(open, fromRef);
|
|
3710
3805
|
const onKeyDown = (event) => {
|
|
3711
3806
|
if (event.key === "ArrowDown" && event.altKey) {
|
|
@@ -3789,7 +3884,7 @@ function DateRangeControl({
|
|
|
3789
3884
|
}) {
|
|
3790
3885
|
const hint = accessibilityHint ?? `${fromLabel} \u2013 ${toLabel}`;
|
|
3791
3886
|
const { labels } = useDatePickerConfig();
|
|
3792
|
-
const [typedError, setTypedError] =
|
|
3887
|
+
const [typedError, setTypedError] = React39.useState(void 0);
|
|
3793
3888
|
if (!IS_WEB9) {
|
|
3794
3889
|
return /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(NativeDateRange, { fromLabel, hint, style, testID, toLabel, value, onChange, onSubmit }) });
|
|
3795
3890
|
}
|
|
@@ -3829,7 +3924,7 @@ var ROW_GAP = 4;
|
|
|
3829
3924
|
var TAB_PADDING = 4;
|
|
3830
3925
|
var INDICATOR_WIDTH = 2;
|
|
3831
3926
|
var TAB_FONT_SIZE = 12;
|
|
3832
|
-
var
|
|
3927
|
+
var styles22 = reactNative.StyleSheet.create({
|
|
3833
3928
|
row: { flexDirection: "row", flexWrap: "nowrap", gap: ROW_GAP },
|
|
3834
3929
|
tab: {
|
|
3835
3930
|
borderBottomWidth: INDICATOR_WIDTH,
|
|
@@ -3869,13 +3964,13 @@ var StepperTab = ({
|
|
|
3869
3964
|
accessibilityRole: "tab",
|
|
3870
3965
|
accessibilityState: { selected },
|
|
3871
3966
|
"aria-selected": selected,
|
|
3872
|
-
style: [
|
|
3967
|
+
style: [styles22.tab, { borderBottomColor: indicator }, ring.ringStyle],
|
|
3873
3968
|
testID,
|
|
3874
3969
|
onBlur: ring.onBlur,
|
|
3875
3970
|
onFocus: ring.onFocus,
|
|
3876
3971
|
onPress: () => onStep(step.key),
|
|
3877
3972
|
...webKeyProps,
|
|
3878
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
3973
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles22.text, { color: theme.colors.text }, selected ? styles22.textSelected : void 0], children: step.label })
|
|
3879
3974
|
}
|
|
3880
3975
|
);
|
|
3881
3976
|
};
|
|
@@ -3885,7 +3980,7 @@ var StepperTabs = ({
|
|
|
3885
3980
|
onStep,
|
|
3886
3981
|
stepHint,
|
|
3887
3982
|
testID
|
|
3888
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", style:
|
|
3983
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", style: styles22.row, testID, children: steps.map((step) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3889
3984
|
StepperTab,
|
|
3890
3985
|
{
|
|
3891
3986
|
hint: stepHint,
|
|
@@ -3904,7 +3999,7 @@ function resolveStepNeighbours(steps, current) {
|
|
|
3904
3999
|
return { previous: steps[index - 1] ?? null, next: steps[index + 1] ?? null };
|
|
3905
4000
|
}
|
|
3906
4001
|
var ROW_GAP2 = 8;
|
|
3907
|
-
var
|
|
4002
|
+
var styles23 = reactNative.StyleSheet.create({
|
|
3908
4003
|
cell: { flex: 1, minWidth: 0 },
|
|
3909
4004
|
row: { flexDirection: "row", gap: ROW_GAP2 }
|
|
3910
4005
|
});
|
|
@@ -3916,8 +4011,8 @@ var StepperNav = ({
|
|
|
3916
4011
|
testID
|
|
3917
4012
|
}) => {
|
|
3918
4013
|
const { previous, next } = resolveStepNeighbours(steps, current);
|
|
3919
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
3920
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
4014
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles23.row, testID, children: [
|
|
4015
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles23.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3921
4016
|
uiButtons.Button,
|
|
3922
4017
|
{
|
|
3923
4018
|
fullWidth: true,
|
|
@@ -3933,7 +4028,7 @@ var StepperNav = ({
|
|
|
3933
4028
|
}
|
|
3934
4029
|
}
|
|
3935
4030
|
) }),
|
|
3936
|
-
next === null ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
4031
|
+
next === null ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles23.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3937
4032
|
uiButtons.Button,
|
|
3938
4033
|
{
|
|
3939
4034
|
fullWidth: true,
|
|
@@ -3948,18 +4043,18 @@ var StepperNav = ({
|
|
|
3948
4043
|
] });
|
|
3949
4044
|
};
|
|
3950
4045
|
var STATUS_FONT = 16;
|
|
3951
|
-
var
|
|
4046
|
+
var styles24 = reactNative.StyleSheet.create({
|
|
3952
4047
|
line: { fontSize: STATUS_FONT }
|
|
3953
4048
|
});
|
|
3954
4049
|
function FormStatusLine({ message, testID, style }) {
|
|
3955
4050
|
const { theme } = uiFeedback.useUi();
|
|
3956
4051
|
if (message === null || message === void 0 || message === "") return null;
|
|
3957
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
4052
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles24.line, { color: theme.colors.text }, style], testID, children: message });
|
|
3958
4053
|
}
|
|
3959
4054
|
function useFocusFirstInvalid(refs) {
|
|
3960
|
-
const latest =
|
|
4055
|
+
const latest = React39.useRef(refs);
|
|
3961
4056
|
latest.current = refs;
|
|
3962
|
-
return
|
|
4057
|
+
return React39.useCallback((invalid) => {
|
|
3963
4058
|
const first = invalid.map((field2) => latest.current[field2].current).find((node) => node !== null);
|
|
3964
4059
|
first?.focus();
|
|
3965
4060
|
}, []);
|
|
@@ -4010,10 +4105,10 @@ function withoutField(state, field2) {
|
|
|
4010
4105
|
}
|
|
4011
4106
|
function useServerFieldErrors(options) {
|
|
4012
4107
|
const { fields, refs, formatCode } = options;
|
|
4013
|
-
const [state, setState] =
|
|
4108
|
+
const [state, setState] = React39.useState(EMPTY_STATE);
|
|
4014
4109
|
const focusFirst = useFocusFirstInvalid(refs ?? NO_REFS);
|
|
4015
4110
|
const hasRefs = refs !== void 0;
|
|
4016
|
-
const apply =
|
|
4111
|
+
const apply = React39.useCallback(
|
|
4017
4112
|
(error) => {
|
|
4018
4113
|
const assigned = assignServerErrors(apiClientBase.parseFieldErrors(error), fields, formatCode);
|
|
4019
4114
|
setState({ byField: assigned.byField, formError: assigned.formError });
|
|
@@ -4024,17 +4119,17 @@ function useServerFieldErrors(options) {
|
|
|
4024
4119
|
},
|
|
4025
4120
|
[fields, formatCode, focusFirst, hasRefs]
|
|
4026
4121
|
);
|
|
4027
|
-
const clear =
|
|
4028
|
-
const reset =
|
|
4029
|
-
const errorFor =
|
|
4122
|
+
const clear = React39.useCallback((field2) => setState((current) => withoutField(current, field2)), []);
|
|
4123
|
+
const reset = React39.useCallback(() => setState(EMPTY_STATE), []);
|
|
4124
|
+
const errorFor = React39.useCallback((field2) => state.byField[field2], [state.byField]);
|
|
4030
4125
|
return { errorFor, apply, clear, formError: state.formError, reset };
|
|
4031
4126
|
}
|
|
4032
4127
|
function isScrollable(node) {
|
|
4033
4128
|
return "scrollIntoView" in Object(node);
|
|
4034
4129
|
}
|
|
4035
4130
|
function useKeepInView(trigger) {
|
|
4036
|
-
const ref =
|
|
4037
|
-
|
|
4131
|
+
const ref = React39.useRef(null);
|
|
4132
|
+
React39.useEffect(() => {
|
|
4038
4133
|
const node = ref.current;
|
|
4039
4134
|
const hasTrigger = trigger !== void 0 && trigger !== null;
|
|
4040
4135
|
if (hasTrigger && isScrollable(node)) node.scrollIntoView({ block: "nearest" });
|
|
@@ -4043,7 +4138,7 @@ function useKeepInView(trigger) {
|
|
|
4043
4138
|
}
|
|
4044
4139
|
var IS_WEB10 = reactNative.Platform.OS === "web";
|
|
4045
4140
|
var INPUT_FONT2 = 14;
|
|
4046
|
-
var
|
|
4141
|
+
var styles25 = reactNative.StyleSheet.create({
|
|
4047
4142
|
nativeButton: { minHeight: a11y.MIN_TOUCH_TARGET_PX, minWidth: a11y.MIN_TOUCH_TARGET_PX, justifyContent: "center" },
|
|
4048
4143
|
nativeText: { fontSize: INPUT_FONT2 }
|
|
4049
4144
|
});
|
|
@@ -4071,10 +4166,10 @@ function FileInput({
|
|
|
4071
4166
|
accessibilityRole: "button",
|
|
4072
4167
|
accessibilityState: { disabled },
|
|
4073
4168
|
disabled,
|
|
4074
|
-
style:
|
|
4169
|
+
style: styles25.nativeButton,
|
|
4075
4170
|
testID,
|
|
4076
4171
|
onPress: onNativePick,
|
|
4077
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4172
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles25.nativeText, { color: colors.text }], children: nativeLabel ?? accessibilityLabel })
|
|
4078
4173
|
}
|
|
4079
4174
|
);
|
|
4080
4175
|
}
|
|
@@ -4104,7 +4199,7 @@ var PREVIEW_RADIUS = 8;
|
|
|
4104
4199
|
var GAP6 = 8;
|
|
4105
4200
|
var TITLE_FONT_SIZE = 14;
|
|
4106
4201
|
var HELP_FONT_SIZE = 13;
|
|
4107
|
-
var
|
|
4202
|
+
var styles26 = reactNative.StyleSheet.create({
|
|
4108
4203
|
help: { flex: 1, fontSize: HELP_FONT_SIZE },
|
|
4109
4204
|
root: { gap: GAP6 },
|
|
4110
4205
|
tile: { alignItems: "center", flexDirection: "row", gap: GAP6 },
|
|
@@ -4124,13 +4219,13 @@ var UploadWithLinkField = ({
|
|
|
4124
4219
|
const { theme } = uiFeedback.useUi();
|
|
4125
4220
|
const ring = uiButtons.useFocusRing();
|
|
4126
4221
|
const url = value ?? "";
|
|
4127
|
-
const [pasting, setPasting] =
|
|
4222
|
+
const [pasting, setPasting] = React39.useState(url !== "");
|
|
4128
4223
|
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:
|
|
4224
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles26.root, children: [
|
|
4225
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles26.title, { color: theme.colors.text }], children: labels.title }),
|
|
4226
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles26.tile, children: [
|
|
4132
4227
|
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: [
|
|
4228
|
+
labels.help === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles26.help, { color: theme.colors.text }], children: labels.help })
|
|
4134
4229
|
] }),
|
|
4135
4230
|
uploadControl,
|
|
4136
4231
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4141,12 +4236,12 @@ var UploadWithLinkField = ({
|
|
|
4141
4236
|
accessibilityRole: "button",
|
|
4142
4237
|
accessibilityState: { expanded: pasting },
|
|
4143
4238
|
"aria-expanded": pasting,
|
|
4144
|
-
style: [
|
|
4239
|
+
style: [styles26.toggle, ring.ringStyle],
|
|
4145
4240
|
testID: `${testID}-paste`,
|
|
4146
4241
|
onBlur: ring.onBlur,
|
|
4147
4242
|
onFocus: ring.onFocus,
|
|
4148
4243
|
onPress: () => setPasting(!pasting),
|
|
4149
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4244
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles26.toggleText, { color: theme.colors.text }], children: labels.pasteToggle })
|
|
4150
4245
|
}
|
|
4151
4246
|
),
|
|
4152
4247
|
pasting ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4165,7 +4260,7 @@ var UploadWithLinkField = ({
|
|
|
4165
4260
|
};
|
|
4166
4261
|
var ACTION_GAP = 8;
|
|
4167
4262
|
var GROUP_GAP = 16;
|
|
4168
|
-
var
|
|
4263
|
+
var styles27 = reactNative.StyleSheet.create({
|
|
4169
4264
|
action: { alignItems: "flex-start", marginTop: ACTION_GAP },
|
|
4170
4265
|
group: { marginBottom: GROUP_GAP }
|
|
4171
4266
|
});
|
|
@@ -4182,13 +4277,13 @@ var AddOnRequest = ({
|
|
|
4182
4277
|
disabled = false,
|
|
4183
4278
|
style
|
|
4184
4279
|
}) => {
|
|
4185
|
-
const [requested, setRequested] =
|
|
4280
|
+
const [requested, setRequested] = React39.useState(false);
|
|
4186
4281
|
const remove = () => {
|
|
4187
4282
|
setRequested(false);
|
|
4188
4283
|
onRemove();
|
|
4189
4284
|
};
|
|
4190
4285
|
if (!isAddOnOpen(hasValue, requested))
|
|
4191
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
4286
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles27.action, style], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4192
4287
|
uiButtons.Button,
|
|
4193
4288
|
{
|
|
4194
4289
|
accessibilityHint: addHint,
|
|
@@ -4200,9 +4295,9 @@ var AddOnRequest = ({
|
|
|
4200
4295
|
onPress: () => setRequested(true)
|
|
4201
4296
|
}
|
|
4202
4297
|
) });
|
|
4203
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4298
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles27.group, style], testID, children: [
|
|
4204
4299
|
children,
|
|
4205
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
4300
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles27.action, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4206
4301
|
uiButtons.Button,
|
|
4207
4302
|
{
|
|
4208
4303
|
accessibilityHint: removeHint,
|
|
@@ -4219,7 +4314,7 @@ var AddOnRequest = ({
|
|
|
4219
4314
|
var ROW_GAP3 = 8;
|
|
4220
4315
|
var TEXT_SIZE = 13;
|
|
4221
4316
|
var TEXT_LINE = 18;
|
|
4222
|
-
var
|
|
4317
|
+
var styles28 = reactNative.StyleSheet.create({
|
|
4223
4318
|
row: { alignItems: "center", columnGap: ROW_GAP3, flexDirection: "row", justifyContent: "space-between" },
|
|
4224
4319
|
text: { flexShrink: 1, fontSize: TEXT_SIZE, fontWeight: "700", lineHeight: TEXT_LINE }
|
|
4225
4320
|
});
|
|
@@ -4227,8 +4322,8 @@ var isFixBarVisible = (count) => count > 0;
|
|
|
4227
4322
|
var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) => {
|
|
4228
4323
|
const { theme } = uiFeedback.useUi();
|
|
4229
4324
|
if (!isFixBarVisible(count)) return null;
|
|
4230
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4231
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
4325
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles28.row, style], testID, children: [
|
|
4326
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles28.text, { color: fieldErrorInk(theme) }], testID: `${testID}-count`, children: message }),
|
|
4232
4327
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4233
4328
|
uiButtons.Button,
|
|
4234
4329
|
{
|
|
@@ -4266,21 +4361,21 @@ function OptionRow2({ option, active, current, renderLeading, renderDetail, onPi
|
|
|
4266
4361
|
accessibilityLabel: option.label,
|
|
4267
4362
|
accessibilityRole: "button",
|
|
4268
4363
|
accessibilityState: { selected: active, checked: current },
|
|
4269
|
-
style: [
|
|
4364
|
+
style: [styles29.row, active ? { backgroundColor: colors.surface } : null],
|
|
4270
4365
|
testID: `${testID}-option-${option.value}`,
|
|
4271
4366
|
onPress: () => onPick(option),
|
|
4272
4367
|
children: [
|
|
4273
4368
|
renderLeading?.(option),
|
|
4274
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4275
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4276
|
-
detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
4369
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles29.label, children: [
|
|
4370
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles29.primary, { color: colors.text }], children: option.label }),
|
|
4371
|
+
detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles29.secondary, { color: colors.textSecondary }], children: option.detail }) : null
|
|
4277
4372
|
] }),
|
|
4278
4373
|
renderDetail?.(option)
|
|
4279
4374
|
]
|
|
4280
4375
|
}
|
|
4281
4376
|
);
|
|
4282
4377
|
}
|
|
4283
|
-
var
|
|
4378
|
+
var styles29 = reactNative.StyleSheet.create({
|
|
4284
4379
|
row: { minHeight: a11y.MIN_TOUCH_TARGET_PX, flexDirection: "row", alignItems: "center", gap: ROW_GAP4, paddingHorizontal: ROW_PAD_H },
|
|
4285
4380
|
label: { flex: 1 },
|
|
4286
4381
|
primary: { fontSize: OPTION_FONT2, flexShrink: 1 },
|
|
@@ -4294,11 +4389,11 @@ function OptionSection({ title, options, offset, highlight, selectedValue, ...ro
|
|
|
4294
4389
|
const { colors } = theme;
|
|
4295
4390
|
if (options.length === 0) return null;
|
|
4296
4391
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
4297
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
4392
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles30.header, { color: colors.textSecondary }], children: title }),
|
|
4298
4393
|
options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(OptionRow2, { ...row, active: offset + index === highlight, current: option.value === selectedValue, option }, option.value))
|
|
4299
4394
|
] });
|
|
4300
4395
|
}
|
|
4301
|
-
var
|
|
4396
|
+
var styles30 = reactNative.StyleSheet.create({
|
|
4302
4397
|
header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
|
|
4303
4398
|
});
|
|
4304
4399
|
var KEY_ESCAPE = "Escape";
|
|
@@ -4308,27 +4403,27 @@ var SHEET_MAX_HEIGHT2 = 480;
|
|
|
4308
4403
|
function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
|
|
4309
4404
|
const { theme } = uiFeedback.useUi();
|
|
4310
4405
|
const { colors } = theme;
|
|
4311
|
-
const progress =
|
|
4406
|
+
const progress = React39.useRef(new reactNative.Animated.Value(0)).current;
|
|
4312
4407
|
const { durationMs } = motion;
|
|
4313
|
-
|
|
4408
|
+
React39.useEffect(() => {
|
|
4314
4409
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
4315
4410
|
}, [progress, durationMs]);
|
|
4316
|
-
const leaving =
|
|
4317
|
-
const leave =
|
|
4411
|
+
const leaving = React39.useRef(false);
|
|
4412
|
+
const leave = React39.useCallback((after) => {
|
|
4318
4413
|
if (leaving.current) return;
|
|
4319
4414
|
leaving.current = true;
|
|
4320
4415
|
if (durationMs === 0) return after();
|
|
4321
4416
|
reactNative.Animated.timing(progress, { toValue: 0, duration: durationMs, useNativeDriver: false }).start(() => after());
|
|
4322
4417
|
}, [progress, durationMs]);
|
|
4323
4418
|
const { close, pick: pickNow, submit: submitNow, onKey, sections, highlight } = state;
|
|
4324
|
-
const dismiss =
|
|
4325
|
-
const pick =
|
|
4326
|
-
const submit =
|
|
4327
|
-
const onKeyPress =
|
|
4419
|
+
const dismiss = React39.useCallback(() => leave(close), [leave, close]);
|
|
4420
|
+
const pick = React39.useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
|
|
4421
|
+
const submit = React39.useCallback(() => submitNow(pick), [submitNow, pick]);
|
|
4422
|
+
const onKeyPress = React39.useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
|
|
4328
4423
|
const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [motion.fromY, 0] });
|
|
4329
4424
|
const isSheet = motion.surface === "sheet" /* Sheet */;
|
|
4330
4425
|
const shared = { selectedValue, renderLeading, renderDetail, onPick: pick, optionHint: labels.optionHint, testID, highlight };
|
|
4331
|
-
const list = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
4426
|
+
const list = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles31.panel, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }], testID: `${testID}-panel`, children: [
|
|
4332
4427
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4333
4428
|
reactNative.TextInput,
|
|
4334
4429
|
{
|
|
@@ -4345,24 +4440,24 @@ function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, re
|
|
|
4345
4440
|
onSubmitEditing: submit
|
|
4346
4441
|
}
|
|
4347
4442
|
),
|
|
4348
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", style: isSheet ?
|
|
4443
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", style: isSheet ? styles31.sheetList : styles31.dropList, children: [
|
|
4349
4444
|
/* @__PURE__ */ jsxRuntime.jsx(OptionSection, { ...shared, offset: 0, options: sections.recent, title: labels.recent }),
|
|
4350
4445
|
/* @__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: [
|
|
4446
|
+
sections.flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles31.empty, { color: colors.textSecondary }], children: labels.empty }) : null
|
|
4352
4447
|
] })
|
|
4353
4448
|
] });
|
|
4354
4449
|
if (!isSheet) return /* @__PURE__ */ jsxRuntime.jsx(DropdownSurface, { anchorRef, closeHint: labels.closeHint, closeLabel: labels.close, progress, testID, translateY, onDismiss: dismiss, children: list });
|
|
4355
4450
|
return /* @__PURE__ */ jsxRuntime.jsx(SheetSurface, { closeHint: labels.closeHint, closeLabel: labels.close, testID, translateY, onDismiss: dismiss, children: list });
|
|
4356
4451
|
}
|
|
4357
|
-
var
|
|
4452
|
+
var styles31 = reactNative.StyleSheet.create({
|
|
4358
4453
|
panel: { borderWidth: 1, borderRadius: PANEL_RADIUS, padding: PANEL_PAD, gap: PANEL_PAD },
|
|
4359
4454
|
dropList: { maxHeight: MENU_MAX_HEIGHT },
|
|
4360
4455
|
sheetList: { maxHeight: SHEET_MAX_HEIGHT2 },
|
|
4361
4456
|
empty: { padding: PANEL_PAD }
|
|
4362
4457
|
});
|
|
4363
4458
|
function useRefocusOnClose(open, ref) {
|
|
4364
|
-
const wasOpen =
|
|
4365
|
-
|
|
4459
|
+
const wasOpen = React39.useRef(false);
|
|
4460
|
+
React39.useEffect(() => {
|
|
4366
4461
|
if (wasOpen.current && !open) ref.current?.focus();
|
|
4367
4462
|
wasOpen.current = open;
|
|
4368
4463
|
}, [open, ref]);
|
|
@@ -4395,38 +4490,38 @@ var KEY_DOWN = "ArrowDown";
|
|
|
4395
4490
|
var KEY_UP = "ArrowUp";
|
|
4396
4491
|
var KEY_ESCAPE2 = "Escape";
|
|
4397
4492
|
function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
4398
|
-
const [open, setOpen] =
|
|
4399
|
-
const [query, setQueryState] =
|
|
4400
|
-
const [rawHighlight, setHighlight] =
|
|
4401
|
-
const sections =
|
|
4493
|
+
const [open, setOpen] = React39.useState(false);
|
|
4494
|
+
const [query, setQueryState] = React39.useState("");
|
|
4495
|
+
const [rawHighlight, setHighlight] = React39.useState(-1);
|
|
4496
|
+
const sections = React39.useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
|
|
4402
4497
|
const highlight = rawHighlight < sections.flat.length ? rawHighlight : -1;
|
|
4403
4498
|
const active = sections.flat[highlight];
|
|
4404
4499
|
const { remember } = recents;
|
|
4405
|
-
const close =
|
|
4500
|
+
const close = React39.useCallback(() => {
|
|
4406
4501
|
setOpen(false);
|
|
4407
4502
|
setQueryState("");
|
|
4408
4503
|
setHighlight(-1);
|
|
4409
4504
|
onClosed();
|
|
4410
4505
|
}, [onClosed]);
|
|
4411
|
-
const pick =
|
|
4506
|
+
const pick = React39.useCallback((option) => {
|
|
4412
4507
|
remember(option.value);
|
|
4413
4508
|
onChange(option.value);
|
|
4414
4509
|
close();
|
|
4415
4510
|
}, [remember, onChange, close]);
|
|
4416
|
-
const submit =
|
|
4511
|
+
const submit = React39.useCallback((via = pick) => {
|
|
4417
4512
|
if (active !== void 0) via(active);
|
|
4418
4513
|
}, [active, pick]);
|
|
4419
|
-
const setQuery =
|
|
4514
|
+
const setQuery = React39.useCallback((next) => {
|
|
4420
4515
|
setQueryState(next);
|
|
4421
4516
|
setHighlight(highlightAfterQuery(next));
|
|
4422
4517
|
}, []);
|
|
4423
|
-
const onKey =
|
|
4518
|
+
const onKey = React39.useCallback((key) => {
|
|
4424
4519
|
const count = sections.flat.length;
|
|
4425
4520
|
if (key === KEY_DOWN) setHighlight(moveHighlight(highlight, count, 1));
|
|
4426
4521
|
if (key === KEY_UP) setHighlight(moveHighlight(highlight, count, -1));
|
|
4427
4522
|
if (key === KEY_ESCAPE2) close();
|
|
4428
4523
|
}, [sections.flat.length, highlight, close]);
|
|
4429
|
-
const openList =
|
|
4524
|
+
const openList = React39.useCallback(() => setOpen(true), []);
|
|
4430
4525
|
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
4431
4526
|
}
|
|
4432
4527
|
|
|
@@ -4450,8 +4545,8 @@ function SearchSelect(props) {
|
|
|
4450
4545
|
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger, onBlur } = props;
|
|
4451
4546
|
const { theme } = uiFeedback.useUi();
|
|
4452
4547
|
const { colors } = theme;
|
|
4453
|
-
const triggerRef =
|
|
4454
|
-
const anchorRef =
|
|
4548
|
+
const triggerRef = React39.useRef(null);
|
|
4549
|
+
const anchorRef = React39.useRef(null);
|
|
4455
4550
|
const { width } = reactNative.useWindowDimensions();
|
|
4456
4551
|
const motion = resolveSelectMotion(width, useReducedMotion());
|
|
4457
4552
|
const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
|
|
@@ -4459,12 +4554,12 @@ function SearchSelect(props) {
|
|
|
4459
4554
|
useRefocusOnClose(state.open, triggerRef);
|
|
4460
4555
|
const selected = findOption(options, value);
|
|
4461
4556
|
const onPress = state.open ? state.close : state.openList;
|
|
4462
|
-
const openRef =
|
|
4557
|
+
const openRef = React39.useRef(state.open);
|
|
4463
4558
|
openRef.current = state.open;
|
|
4464
|
-
const onTriggerBlur =
|
|
4559
|
+
const onTriggerBlur = React39.useCallback(() => {
|
|
4465
4560
|
if (!openRef.current) onBlur?.();
|
|
4466
4561
|
}, [onBlur]);
|
|
4467
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style:
|
|
4562
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles32.anchor, children: [
|
|
4468
4563
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4469
4564
|
reactNative.Pressable,
|
|
4470
4565
|
{
|
|
@@ -4473,7 +4568,7 @@ function SearchSelect(props) {
|
|
|
4473
4568
|
accessibilityLabel,
|
|
4474
4569
|
accessibilityRole: "button",
|
|
4475
4570
|
accessibilityState: { expanded: state.open },
|
|
4476
|
-
style: renderTrigger === void 0 ? [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }] :
|
|
4571
|
+
style: renderTrigger === void 0 ? [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }] : styles32.customTrigger,
|
|
4477
4572
|
testID,
|
|
4478
4573
|
onBlur: onTriggerBlur,
|
|
4479
4574
|
onPress,
|
|
@@ -4485,7 +4580,7 @@ function SearchSelect(props) {
|
|
|
4485
4580
|
}
|
|
4486
4581
|
function FieldBoxContent({ selected, placeholder, colors, renderLeading, renderDetail }) {
|
|
4487
4582
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4488
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
4583
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles32.value, children: [
|
|
4489
4584
|
selected !== null && renderLeading !== void 0 ? renderLeading(selected) : null,
|
|
4490
4585
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: selected === null ? colors.textSecondary : colors.text }], children: selected?.label ?? placeholder }),
|
|
4491
4586
|
selected !== null ? /* @__PURE__ */ jsxRuntime.jsx(SelectedDetail, { colors, option: selected, renderDetail }) : null
|
|
@@ -4498,7 +4593,7 @@ function SelectedDetail({ option, colors, renderDetail }) {
|
|
|
4498
4593
|
if (option.detail === void 0) return null;
|
|
4499
4594
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [controlStyles.selectTriggerText, { color: colors.textSecondary }], children: option.detail });
|
|
4500
4595
|
}
|
|
4501
|
-
var
|
|
4596
|
+
var styles32 = reactNative.StyleSheet.create({
|
|
4502
4597
|
anchor: { position: "relative" },
|
|
4503
4598
|
customTrigger: { minHeight: MIN_TOUCH, minWidth: MIN_TOUCH, alignSelf: "flex-start", justifyContent: "center" },
|
|
4504
4599
|
value: { flex: 1, flexDirection: "row", alignItems: "center", gap: VALUE_GAP }
|
|
@@ -4511,7 +4606,7 @@ function isOutside(container, target) {
|
|
|
4511
4606
|
return !(target instanceof Node && container.contains(target));
|
|
4512
4607
|
}
|
|
4513
4608
|
function useOutsidePress(ref, onOutside) {
|
|
4514
|
-
|
|
4609
|
+
React39.useEffect(() => {
|
|
4515
4610
|
if (reactNative.Platform.OS !== "web" || typeof document === "undefined") return void 0;
|
|
4516
4611
|
const onPointerDown = (event) => {
|
|
4517
4612
|
if (isOutside(ref.current, event.target)) onOutside();
|
|
@@ -4522,7 +4617,7 @@ function useOutsidePress(ref, onOutside) {
|
|
|
4522
4617
|
}
|
|
4523
4618
|
var AFTER_SURFACE_UNMOUNT_MS = 0;
|
|
4524
4619
|
function useDeferredFocus(ref) {
|
|
4525
|
-
return
|
|
4620
|
+
return React39.useCallback(() => {
|
|
4526
4621
|
setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
|
|
4527
4622
|
}, [ref]);
|
|
4528
4623
|
}
|
|
@@ -5274,8 +5369,8 @@ var renderFlag = (option) => option.value === NO_COUNTRY2 ? null : /* @__PURE__
|
|
|
5274
5369
|
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }) {
|
|
5275
5370
|
const { theme } = uiFeedback.useUi();
|
|
5276
5371
|
const { textSecondary } = theme.colors;
|
|
5277
|
-
const options =
|
|
5278
|
-
const renderCode =
|
|
5372
|
+
const options = React39.useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
|
|
5373
|
+
const renderCode = React39.useCallback((option) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles33.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
|
|
5279
5374
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5280
5375
|
SearchSelect,
|
|
5281
5376
|
{
|
|
@@ -5293,13 +5388,13 @@ function CountryField({ value, onChange, accessibilityLabel, accessibilityHint,
|
|
|
5293
5388
|
}
|
|
5294
5389
|
);
|
|
5295
5390
|
}
|
|
5296
|
-
var
|
|
5391
|
+
var styles33 = reactNative.StyleSheet.create({
|
|
5297
5392
|
code: { fontSize: CODE_FONT }
|
|
5298
5393
|
});
|
|
5299
5394
|
function useBlurVerdict(validate) {
|
|
5300
|
-
const [verdict, setVerdict] =
|
|
5301
|
-
const onEdit =
|
|
5302
|
-
const onLeave =
|
|
5395
|
+
const [verdict, setVerdict] = React39.useState(null);
|
|
5396
|
+
const onEdit = React39.useCallback(() => setVerdict(null), []);
|
|
5397
|
+
const onLeave = React39.useCallback(() => {
|
|
5303
5398
|
const next = validate();
|
|
5304
5399
|
setVerdict(next);
|
|
5305
5400
|
return next;
|
|
@@ -5453,11 +5548,11 @@ function rawCaretAfterChange(previous, previousCaret, next) {
|
|
|
5453
5548
|
|
|
5454
5549
|
// src/IbanInput/hooks/useIbanCaret.ts
|
|
5455
5550
|
function useIbanCaret(display) {
|
|
5456
|
-
const [selection2, setSelection] =
|
|
5457
|
-
const onSelectionChange =
|
|
5551
|
+
const [selection2, setSelection] = React39.useState({ start: display.length, end: display.length });
|
|
5552
|
+
const onSelectionChange = React39.useCallback((event) => {
|
|
5458
5553
|
setSelection(event.nativeEvent.selection);
|
|
5459
5554
|
}, []);
|
|
5460
|
-
const placeAfterEdit =
|
|
5555
|
+
const placeAfterEdit = React39.useCallback((text) => {
|
|
5461
5556
|
const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection2.end, text));
|
|
5462
5557
|
setSelection({ start: caret, end: caret });
|
|
5463
5558
|
}, [display, selection2.end]);
|
|
@@ -5549,9 +5644,9 @@ var LINE_GAP = 4;
|
|
|
5549
5644
|
function RejectionLine({ message, testID }) {
|
|
5550
5645
|
const { theme } = uiFeedback.useUi();
|
|
5551
5646
|
if (message === null) return null;
|
|
5552
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", style: [
|
|
5647
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", style: [styles34.line, { color: fieldErrorInk(theme) }], testID: `${testID}-rejection`, children: message });
|
|
5553
5648
|
}
|
|
5554
|
-
var
|
|
5649
|
+
var styles34 = reactNative.StyleSheet.create({
|
|
5555
5650
|
line: { marginTop: LINE_GAP }
|
|
5556
5651
|
});
|
|
5557
5652
|
|
|
@@ -5563,19 +5658,19 @@ function rejectionMessage(rejection, none, labels) {
|
|
|
5563
5658
|
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
5564
5659
|
const { theme } = uiFeedback.useUi();
|
|
5565
5660
|
const { colors } = theme;
|
|
5566
|
-
const draft =
|
|
5567
|
-
const validate =
|
|
5661
|
+
const draft = React39.useMemo(() => draftIban(value), [value]);
|
|
5662
|
+
const validate = React39.useCallback(() => validateIban(value), [value]);
|
|
5568
5663
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5569
5664
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5570
5665
|
const counter = ibanCounter(draft);
|
|
5571
5666
|
const { selection: selection2, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
5572
|
-
const onChangeText =
|
|
5667
|
+
const onChangeText = React39.useCallback((text) => {
|
|
5573
5668
|
onEdit();
|
|
5574
5669
|
onVerdict?.(null);
|
|
5575
5670
|
placeAfterEdit(text);
|
|
5576
5671
|
onChange(draftIban(text).electronic);
|
|
5577
5672
|
}, [onEdit, onVerdict, placeAfterEdit, onChange]);
|
|
5578
|
-
const onBlur =
|
|
5673
|
+
const onBlur = React39.useCallback(() => {
|
|
5579
5674
|
const verdict2 = onLeave();
|
|
5580
5675
|
onVerdict?.(value === "" ? null : verdict2);
|
|
5581
5676
|
onLeft?.();
|
|
@@ -5650,16 +5745,16 @@ function validateBic(raw) {
|
|
|
5650
5745
|
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
5651
5746
|
const { theme } = uiFeedback.useUi();
|
|
5652
5747
|
const { colors } = theme;
|
|
5653
|
-
const draft =
|
|
5654
|
-
const validate =
|
|
5748
|
+
const draft = React39.useMemo(() => draftBic(value), [value]);
|
|
5749
|
+
const validate = React39.useCallback(() => validateBic(value), [value]);
|
|
5655
5750
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5656
5751
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5657
|
-
const onChangeText =
|
|
5752
|
+
const onChangeText = React39.useCallback((text) => {
|
|
5658
5753
|
onEdit();
|
|
5659
5754
|
onVerdict?.(null);
|
|
5660
5755
|
onChange(draftBic(text).value);
|
|
5661
5756
|
}, [onEdit, onVerdict, onChange]);
|
|
5662
|
-
const onBlur =
|
|
5757
|
+
const onBlur = React39.useCallback(() => {
|
|
5663
5758
|
const verdict2 = onLeave();
|
|
5664
5759
|
onVerdict?.(value === "" ? null : verdict2);
|
|
5665
5760
|
onLeft?.();
|
|
@@ -5698,7 +5793,7 @@ var PAD_V = 10;
|
|
|
5698
5793
|
var PAD_H = 16;
|
|
5699
5794
|
var TEXT_SIZE2 = 13;
|
|
5700
5795
|
var TEXT_LINE2 = 18;
|
|
5701
|
-
var
|
|
5796
|
+
var styles35 = reactNative.StyleSheet.create({
|
|
5702
5797
|
bar: { borderTopWidth: 1, paddingHorizontal: PAD_H, paddingVertical: PAD_V, rowGap: BAR_GAP },
|
|
5703
5798
|
actions: { flexDirection: "row", flexWrap: "wrap", gap: BAR_GAP },
|
|
5704
5799
|
message: { fontSize: TEXT_SIZE2, fontWeight: "700", lineHeight: TEXT_LINE2 }
|
|
@@ -5710,9 +5805,9 @@ var ActionBar = ({ children, message, sticky = false, testID, style }) => {
|
|
|
5710
5805
|
const { colors } = theme;
|
|
5711
5806
|
const pinned = actionBarPosition(sticky, reactNative.Platform.OS) === "sticky" ? PINNED : null;
|
|
5712
5807
|
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:
|
|
5808
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles35.bar, { backgroundColor: colors.surface, borderTopColor: colors.border }, pinned, style], testID, children: [
|
|
5809
|
+
hasMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "status", style: [styles35.message, { color: colors.text }], testID: `${testID}-message`, children: message }) : null,
|
|
5810
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles35.actions, children })
|
|
5716
5811
|
] });
|
|
5717
5812
|
};
|
|
5718
5813
|
|
|
@@ -5720,14 +5815,14 @@ var ActionBar = ({ children, message, sticky = false, testID, style }) => {
|
|
|
5720
5815
|
var isChecklistComplete = (items, checked) => items.every((item) => checked.includes(item.id));
|
|
5721
5816
|
var TITLE_SIZE = 13;
|
|
5722
5817
|
var TITLE_GAP = 6;
|
|
5723
|
-
var
|
|
5818
|
+
var styles36 = reactNative.StyleSheet.create({
|
|
5724
5819
|
title: { fontSize: TITLE_SIZE, fontWeight: "700", marginBottom: TITLE_GAP }
|
|
5725
5820
|
});
|
|
5726
5821
|
var GatedChecklist = ({ title, items, checked, onToggle, testID, disabled = false, children }) => {
|
|
5727
5822
|
const { theme } = uiFeedback.useUi();
|
|
5728
5823
|
const complete = isChecklistComplete(items, checked);
|
|
5729
5824
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { testID, children: [
|
|
5730
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
5825
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles36.title, { color: theme.colors.text }], children: title }),
|
|
5731
5826
|
items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5732
5827
|
FormCheckbox,
|
|
5733
5828
|
{
|
|
@@ -5753,7 +5848,7 @@ var RADIUS2 = 8;
|
|
|
5753
5848
|
var LABEL_SIZE = 14;
|
|
5754
5849
|
var DESCRIPTION_SIZE = 12;
|
|
5755
5850
|
var DESCRIPTION_LINE = 16;
|
|
5756
|
-
var
|
|
5851
|
+
var styles37 = reactNative.StyleSheet.create({
|
|
5757
5852
|
row: {
|
|
5758
5853
|
alignItems: "center",
|
|
5759
5854
|
borderRadius: RADIUS2,
|
|
@@ -5784,15 +5879,15 @@ function RadioRow({ option, identity, colors, tabIndex, hostRef, onPress }) {
|
|
|
5784
5879
|
accessibilityState: identity.accessibilityState,
|
|
5785
5880
|
"aria-checked": checked,
|
|
5786
5881
|
disabled,
|
|
5787
|
-
style: [
|
|
5882
|
+
style: [styles37.row, { borderColor: accent, backgroundColor: checked ? colors.tint : colors.muted }],
|
|
5788
5883
|
tabIndex,
|
|
5789
5884
|
testID: identity.testID,
|
|
5790
5885
|
onPress,
|
|
5791
5886
|
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: [
|
|
5887
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles37.dot, { borderColor: accent }], children: checked ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles37.dotInner, { backgroundColor: colors.primary }] }) : null }),
|
|
5888
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles37.text, children: [
|
|
5889
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles37.label, { color: checked ? colors.primary : colors.textStrong }], children: option.label }),
|
|
5890
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles37.description, { color: colors.textMuted }], testID: `${identity.testID}-description`, children: option.description }) : null
|
|
5796
5891
|
] })
|
|
5797
5892
|
]
|
|
5798
5893
|
}
|
|
@@ -5809,20 +5904,20 @@ var radioRowIdentity = (option, selected, disabled, prefix) => {
|
|
|
5809
5904
|
};
|
|
5810
5905
|
};
|
|
5811
5906
|
var ROW_GAP7 = 8;
|
|
5812
|
-
var
|
|
5907
|
+
var styles38 = reactNative.StyleSheet.create({
|
|
5813
5908
|
list: { rowGap: ROW_GAP7 }
|
|
5814
5909
|
});
|
|
5815
5910
|
function RadioList(props) {
|
|
5816
5911
|
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
5817
5912
|
const { theme } = uiFeedback.useUi();
|
|
5818
|
-
const colors =
|
|
5913
|
+
const colors = React39__default.default.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
5819
5914
|
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
5820
5915
|
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
5821
5916
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5822
5917
|
reactNative.View,
|
|
5823
5918
|
{
|
|
5824
5919
|
accessibilityRole: "radiogroup",
|
|
5825
|
-
style:
|
|
5920
|
+
style: styles38.list,
|
|
5826
5921
|
...webFieldA11y({ describedById, hasError }),
|
|
5827
5922
|
...radio.groupProps,
|
|
5828
5923
|
children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5876,11 +5971,11 @@ function DecisionNote({ state, labels, testID, disabled }) {
|
|
|
5876
5971
|
);
|
|
5877
5972
|
}
|
|
5878
5973
|
var BUTTON_BASIS = "40%";
|
|
5879
|
-
var
|
|
5974
|
+
var styles39 = reactNative.StyleSheet.create({
|
|
5880
5975
|
cell: { flexBasis: BUTTON_BASIS, flexGrow: 1 }
|
|
5881
5976
|
});
|
|
5882
5977
|
function OutcomeButtons({ outcomes, pending, disabled, testID, onPress }) {
|
|
5883
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: outcomes.map((item) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
5978
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: outcomes.map((item) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles39.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5884
5979
|
uiButtons.Button,
|
|
5885
5980
|
{
|
|
5886
5981
|
fullWidth: true,
|
|
@@ -5961,21 +6056,21 @@ function StickyBarDecision(props) {
|
|
|
5961
6056
|
}
|
|
5962
6057
|
var TEXT_SIZE3 = 13;
|
|
5963
6058
|
var TEXT_LINE3 = 18;
|
|
5964
|
-
var
|
|
6059
|
+
var styles40 = reactNative.StyleSheet.create({
|
|
5965
6060
|
text: { fontSize: TEXT_SIZE3, fontWeight: "700", lineHeight: TEXT_LINE3 }
|
|
5966
6061
|
});
|
|
5967
6062
|
var SubmitError = ({ message, testID }) => {
|
|
5968
6063
|
const { theme } = uiFeedback.useUi();
|
|
5969
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [
|
|
6064
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles40.text, { color: fieldErrorInk(theme) }], testID, children: message });
|
|
5970
6065
|
};
|
|
5971
6066
|
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
5972
6067
|
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] =
|
|
6068
|
+
const [outcome, setOutcome] = React39__default.default.useState("");
|
|
6069
|
+
const [note, setNote] = React39__default.default.useState("");
|
|
6070
|
+
const [reasons, setReasons] = React39__default.default.useState([]);
|
|
6071
|
+
const [checked, setChecked] = React39__default.default.useState([]);
|
|
6072
|
+
const [error, setError] = React39__default.default.useState(null);
|
|
6073
|
+
const [pending, setPending] = React39__default.default.useState(null);
|
|
5979
6074
|
const submit = async (override) => {
|
|
5980
6075
|
const target = override ?? outcome;
|
|
5981
6076
|
const problem = validateDecision(outcomes, target, note);
|
|
@@ -6009,7 +6104,7 @@ function useDecisionPanel(outcomes, onSubmit) {
|
|
|
6009
6104
|
}
|
|
6010
6105
|
var TITLE_SIZE2 = 15;
|
|
6011
6106
|
var PANEL_GAP = 12;
|
|
6012
|
-
var
|
|
6107
|
+
var styles41 = reactNative.StyleSheet.create({
|
|
6013
6108
|
panel: { rowGap: PANEL_GAP },
|
|
6014
6109
|
title: { fontSize: TITLE_SIZE2, fontWeight: "700" }
|
|
6015
6110
|
});
|
|
@@ -6023,8 +6118,8 @@ function DecisionPanel(props) {
|
|
|
6023
6118
|
const { theme } = uiFeedback.useUi();
|
|
6024
6119
|
const state = useDecisionPanel(outcomes, onSubmit);
|
|
6025
6120
|
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: [
|
|
6121
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles41.panel, style], testID, children: [
|
|
6122
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles41.title, { color: theme.colors.text }], children: labels.title }),
|
|
6028
6123
|
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
6124
|
state.error === "submit" ? /* @__PURE__ */ jsxRuntime.jsx(SubmitError, { message: labels.submitError, testID: `${testID}-error` }) : null
|
|
6030
6125
|
] });
|
|
@@ -6057,16 +6152,16 @@ var POP_FROM = 0.6;
|
|
|
6057
6152
|
var POP_PEAK = 1.12;
|
|
6058
6153
|
var POP_UP_MS = 160;
|
|
6059
6154
|
var POP_SETTLE_MS = 100;
|
|
6060
|
-
var
|
|
6155
|
+
var styles42 = reactNative.StyleSheet.create({
|
|
6061
6156
|
mark: { width: MARK_SIZE, height: MARK_SIZE, borderRadius: MARK_SIZE / 2, alignItems: "center", justifyContent: "center" },
|
|
6062
6157
|
ring: { borderWidth: RING_WIDTH }
|
|
6063
6158
|
});
|
|
6064
6159
|
function RuleMark({ tone, colors }) {
|
|
6065
6160
|
const reduced = useReducedMotion();
|
|
6066
|
-
const scale =
|
|
6067
|
-
const wasMet =
|
|
6161
|
+
const scale = React39.useRef(new reactNative.Animated.Value(1)).current;
|
|
6162
|
+
const wasMet = React39.useRef(tone === "met" /* Met */);
|
|
6068
6163
|
const met = tone === "met" /* Met */;
|
|
6069
|
-
|
|
6164
|
+
React39.useEffect(() => {
|
|
6070
6165
|
const turnedMet = met && !wasMet.current;
|
|
6071
6166
|
wasMet.current = met;
|
|
6072
6167
|
if (!turnedMet || reduced) return;
|
|
@@ -6077,8 +6172,8 @@ function RuleMark({ tone, colors }) {
|
|
|
6077
6172
|
]).start();
|
|
6078
6173
|
}, [met, reduced, scale]);
|
|
6079
6174
|
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: [
|
|
6175
|
+
const shape = met ? { backgroundColor: color } : [styles42.ring, { borderColor: color }];
|
|
6176
|
+
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
6177
|
}
|
|
6083
6178
|
var GAP8 = 6;
|
|
6084
6179
|
var ROW_GAP8 = 8;
|
|
@@ -6090,7 +6185,7 @@ var CHIP_PAD_V2 = 4;
|
|
|
6090
6185
|
var CHIP_PAD_H2 = 10;
|
|
6091
6186
|
var CHIP_BORDER2 = 1;
|
|
6092
6187
|
var HALF4 = "50%";
|
|
6093
|
-
var
|
|
6188
|
+
var styles43 = reactNative.StyleSheet.create({
|
|
6094
6189
|
column: { gap: GAP8 },
|
|
6095
6190
|
row: { flexDirection: "row", alignItems: "center", gap: ROW_GAP8 },
|
|
6096
6191
|
text: { fontSize: FONT5, lineHeight: LINE, flexShrink: 1 },
|
|
@@ -6106,31 +6201,31 @@ function RuleList({ rules, flagUnmet, colors, testID, listStyle, itemStyle, outl
|
|
|
6106
6201
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { role: "list", style: listStyle, testID, children: rules.map((rule) => {
|
|
6107
6202
|
const tone = ruleTone(rule.met, flagUnmet);
|
|
6108
6203
|
const outline = outlined ? { borderColor: colors.mark[tone] } : null;
|
|
6109
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "listitem", style: [
|
|
6204
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "listitem", style: [styles43.row, itemStyle, outline], testID: `${testID}-${rule.id}`, ...{ dataSet: { tone } }, children: [
|
|
6110
6205
|
/* @__PURE__ */ jsxRuntime.jsx(RuleMark, { colors, tone }),
|
|
6111
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
6206
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles43.text, { color: colors.text[tone] }], children: rule.label })
|
|
6112
6207
|
] }, rule.id);
|
|
6113
6208
|
}) });
|
|
6114
6209
|
}
|
|
6115
6210
|
function RulesChecklist(props) {
|
|
6116
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, listStyle:
|
|
6211
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, listStyle: styles43.column });
|
|
6117
6212
|
}
|
|
6118
6213
|
function RulesChips(props) {
|
|
6119
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, outlined: true, itemStyle:
|
|
6214
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, outlined: true, itemStyle: styles43.chip, listStyle: styles43.chips });
|
|
6120
6215
|
}
|
|
6121
6216
|
function RulesMeterGrid(props) {
|
|
6122
6217
|
const { rules, flagUnmet, colors, testID } = props;
|
|
6123
6218
|
const metCount = rules.filter((rule) => rule.met).length;
|
|
6124
6219
|
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:
|
|
6220
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles43.column, children: [
|
|
6221
|
+
/* @__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)) }),
|
|
6222
|
+
/* @__PURE__ */ jsxRuntime.jsx(RuleList, { ...props, itemStyle: styles43.cell, listStyle: styles43.grid })
|
|
6128
6223
|
] });
|
|
6129
6224
|
}
|
|
6130
6225
|
function RulesSentence({ rules, flagUnmet, colors, testID }) {
|
|
6131
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
6226
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles43.text, { color: colors.text.unmet }], testID, children: rules.map((rule, index) => {
|
|
6132
6227
|
const tone = ruleTone(rule.met, flagUnmet);
|
|
6133
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: [{ color: colors.text[tone] }, rule.met ?
|
|
6228
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: [{ color: colors.text[tone] }, rule.met ? styles43.metPhrase : null], testID: `${testID}-${rule.id}`, ...{ dataSet: { tone } }, children: [
|
|
6134
6229
|
index > 0 ? ", " : "",
|
|
6135
6230
|
rule.label
|
|
6136
6231
|
] }, rule.id);
|
|
@@ -6149,7 +6244,7 @@ function PasswordRules({ display, ...variant }) {
|
|
|
6149
6244
|
}
|
|
6150
6245
|
}
|
|
6151
6246
|
var ICON_SIZE = 20;
|
|
6152
|
-
var
|
|
6247
|
+
var styles44 = reactNative.StyleSheet.create({
|
|
6153
6248
|
button: { width: a11y.MIN_TOUCH_TARGET_PX, height: a11y.MIN_TOUCH_TARGET_PX, alignItems: "center", justifyContent: "center" }
|
|
6154
6249
|
});
|
|
6155
6250
|
function RevealToggle({ revealed, onToggle, onPressIn, showLabel, hideLabel, color, testID }) {
|
|
@@ -6161,7 +6256,7 @@ function RevealToggle({ revealed, onToggle, onPressIn, showLabel, hideLabel, col
|
|
|
6161
6256
|
accessibilityLabel: label,
|
|
6162
6257
|
accessibilityRole: "button",
|
|
6163
6258
|
"aria-pressed": revealed,
|
|
6164
|
-
style:
|
|
6259
|
+
style: styles44.button,
|
|
6165
6260
|
testID,
|
|
6166
6261
|
onPress: onToggle,
|
|
6167
6262
|
onPressIn,
|
|
@@ -6181,9 +6276,9 @@ function ruleAnnouncement(changed, labels) {
|
|
|
6181
6276
|
|
|
6182
6277
|
// src/PasswordField/usePasswordRuleAnnouncement.ts
|
|
6183
6278
|
function usePasswordRuleAnnouncement(rules, labels) {
|
|
6184
|
-
const previous =
|
|
6185
|
-
const [message, setMessage] =
|
|
6186
|
-
|
|
6279
|
+
const previous = React39.useRef(rules);
|
|
6280
|
+
const [message, setMessage] = React39.useState("");
|
|
6281
|
+
React39.useEffect(() => {
|
|
6187
6282
|
const changed = changedRules(previous.current, rules);
|
|
6188
6283
|
previous.current = rules;
|
|
6189
6284
|
if (changed.length > 0) setMessage(ruleAnnouncement(changed, labels));
|
|
@@ -6200,7 +6295,7 @@ function ruleColorsFrom(palette) {
|
|
|
6200
6295
|
}
|
|
6201
6296
|
function useRuleColors(override) {
|
|
6202
6297
|
const { theme } = uiFeedback.useUi();
|
|
6203
|
-
return
|
|
6298
|
+
return React39.useMemo(() => {
|
|
6204
6299
|
if (override !== void 0) return ruleColorsFrom(override);
|
|
6205
6300
|
return ruleColorsFrom({
|
|
6206
6301
|
success: theme.semantic.success?.["500"] ?? theme.colors.text,
|
|
@@ -6215,7 +6310,7 @@ function useRuleColors(override) {
|
|
|
6215
6310
|
var RULES_GAP = 8;
|
|
6216
6311
|
var TOGGLE_INSET = 48;
|
|
6217
6312
|
var NO_RULES = [];
|
|
6218
|
-
var
|
|
6313
|
+
var styles45 = reactNative.StyleSheet.create({
|
|
6219
6314
|
inputRow: { position: "relative", justifyContent: "center" },
|
|
6220
6315
|
input: { paddingRight: TOGGLE_INSET },
|
|
6221
6316
|
toggle: { position: "absolute", right: 0, top: 0, bottom: 0, justifyContent: "center" },
|
|
@@ -6227,16 +6322,16 @@ function joinIds(...ids) {
|
|
|
6227
6322
|
return joined === "" ? void 0 : joined;
|
|
6228
6323
|
}
|
|
6229
6324
|
function useCaretKeepingToggle(inputRef, initialLength) {
|
|
6230
|
-
const [revealed, setRevealed] =
|
|
6231
|
-
const selection2 =
|
|
6232
|
-
const hadFocus =
|
|
6233
|
-
const onSelectionChange =
|
|
6325
|
+
const [revealed, setRevealed] = React39.useState(false);
|
|
6326
|
+
const selection2 = React39.useRef({ start: initialLength, end: initialLength });
|
|
6327
|
+
const hadFocus = React39.useRef(false);
|
|
6328
|
+
const onSelectionChange = React39.useCallback((event) => {
|
|
6234
6329
|
selection2.current = event.nativeEvent.selection;
|
|
6235
6330
|
}, []);
|
|
6236
|
-
const onPressIn =
|
|
6331
|
+
const onPressIn = React39.useCallback(() => {
|
|
6237
6332
|
hadFocus.current = inputRef.current?.isFocused?.() ?? false;
|
|
6238
6333
|
}, [inputRef]);
|
|
6239
|
-
const onToggle =
|
|
6334
|
+
const onToggle = React39.useCallback(() => {
|
|
6240
6335
|
setRevealed((current) => !current);
|
|
6241
6336
|
if (!hadFocus.current) return;
|
|
6242
6337
|
const node = inputRef.current;
|
|
@@ -6248,16 +6343,16 @@ function useCaretKeepingToggle(inputRef, initialLength) {
|
|
|
6248
6343
|
}, [inputRef]);
|
|
6249
6344
|
return { revealed, onPressIn, onToggle, onSelectionChange };
|
|
6250
6345
|
}
|
|
6251
|
-
var PasswordField =
|
|
6252
|
-
const inputRef =
|
|
6253
|
-
|
|
6346
|
+
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) {
|
|
6347
|
+
const inputRef = React39.useRef(null);
|
|
6348
|
+
React39.useImperativeHandle(ref, () => inputRef.current);
|
|
6254
6349
|
const toggle2 = useCaretKeepingToggle(inputRef, value.length);
|
|
6255
6350
|
const colors = useRuleColors(colorOverride);
|
|
6256
6351
|
const announcement = usePasswordRuleAnnouncement(rules, labels);
|
|
6257
6352
|
const rulesId = `${testID}-rules`;
|
|
6258
6353
|
const hasRules = rules.length > 0;
|
|
6259
6354
|
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:
|
|
6355
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles45.inputRow, children: [
|
|
6261
6356
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6262
6357
|
ThemedTextInput,
|
|
6263
6358
|
{
|
|
@@ -6269,18 +6364,18 @@ var PasswordField = React38__default.default.forwardRef(function PasswordField2(
|
|
|
6269
6364
|
hasError: context.hasError || flagUnmet && rules.some((rule) => !rule.met),
|
|
6270
6365
|
id: context.controlId,
|
|
6271
6366
|
secureTextEntry: !toggle2.revealed,
|
|
6272
|
-
style: [
|
|
6367
|
+
style: [styles45.input, inputProps?.style],
|
|
6273
6368
|
testID,
|
|
6274
6369
|
value,
|
|
6275
6370
|
onChangeText,
|
|
6276
6371
|
onSelectionChange: toggle2.onSelectionChange
|
|
6277
6372
|
}
|
|
6278
6373
|
),
|
|
6279
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
6374
|
+
/* @__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
6375
|
] }),
|
|
6281
|
-
hasRules ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { nativeID: rulesId, style:
|
|
6376
|
+
hasRules ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { nativeID: rulesId, style: styles45.rules, children: [
|
|
6282
6377
|
/* @__PURE__ */ jsxRuntime.jsx(PasswordRules, { colors, display: rulesDisplay, flagUnmet, rules, testID: rulesId }),
|
|
6283
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-live": "polite", accessibilityLiveRegion: "polite", style:
|
|
6378
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-live": "polite", accessibilityLiveRegion: "polite", style: styles45.live, testID: `${testID}-announce`, children: announcement })
|
|
6284
6379
|
] }) : null
|
|
6285
6380
|
] }) });
|
|
6286
6381
|
});
|