@dloizides/ui-forms 1.39.1 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.d.mts +122 -1
- package/dist/index.d.ts +122 -1
- package/dist/index.js +497 -151
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +369 -33
- 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 React26 = 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');
|
|
@@ -12,12 +12,12 @@ var Svg = require('react-native-svg');
|
|
|
12
12
|
|
|
13
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var React26__default = /*#__PURE__*/_interopDefault(React26);
|
|
16
16
|
var Svg__default = /*#__PURE__*/_interopDefault(Svg);
|
|
17
17
|
|
|
18
18
|
// src/Field/Field.tsx
|
|
19
19
|
function attachControlId(child, candidateId, describedById) {
|
|
20
|
-
if (!
|
|
20
|
+
if (!React26__default.default.isValidElement(child) || child.type === React26__default.default.Fragment) {
|
|
21
21
|
return { node: child };
|
|
22
22
|
}
|
|
23
23
|
const props = child.props;
|
|
@@ -28,15 +28,15 @@ function attachControlId(child, candidateId, describedById) {
|
|
|
28
28
|
if (describedById !== void 0 && props.describedById === void 0) {
|
|
29
29
|
injected.describedById = describedById;
|
|
30
30
|
}
|
|
31
|
-
return { node:
|
|
31
|
+
return { node: React26__default.default.cloneElement(element, injected), controlId };
|
|
32
32
|
}
|
|
33
33
|
var IS_WEB = reactNative.Platform.OS === "web";
|
|
34
34
|
function isAttributeHost(node) {
|
|
35
35
|
return typeof node === "object" && node !== null && typeof node.setAttribute === "function";
|
|
36
36
|
}
|
|
37
37
|
function useHtmlFor(controlId) {
|
|
38
|
-
const ref =
|
|
39
|
-
|
|
38
|
+
const ref = React26.useRef(null);
|
|
39
|
+
React26.useEffect(() => {
|
|
40
40
|
const node = ref.current;
|
|
41
41
|
if (!IS_WEB || !isAttributeHost(node)) return;
|
|
42
42
|
const target = controlId !== void 0 && controlId !== "" ? node.ownerDocument?.getElementById(controlId) : null;
|
|
@@ -138,15 +138,15 @@ var labelVariantStyles = reactNative.StyleSheet.create({
|
|
|
138
138
|
function resolveLabelVariantStyle(variant) {
|
|
139
139
|
return variant === "control" ? labelVariantStyles.control : labelVariantStyles.field;
|
|
140
140
|
}
|
|
141
|
-
var FormGridContext =
|
|
142
|
-
var GapOwnedContext =
|
|
141
|
+
var FormGridContext = React26__default.default.createContext(null);
|
|
142
|
+
var GapOwnedContext = React26__default.default.createContext(false);
|
|
143
143
|
var FormGridProvider = FormGridContext.Provider;
|
|
144
144
|
var GapOwnedProvider = GapOwnedContext.Provider;
|
|
145
145
|
function useFormGridMetrics() {
|
|
146
|
-
return
|
|
146
|
+
return React26__default.default.useContext(FormGridContext);
|
|
147
147
|
}
|
|
148
148
|
function useIsGapOwned() {
|
|
149
|
-
return
|
|
149
|
+
return React26__default.default.useContext(GapOwnedContext);
|
|
150
150
|
}
|
|
151
151
|
var ERROR_LIGHT_STEPS = ["500", "600", "700"];
|
|
152
152
|
var ERROR_DARK_STEPS = ["300", "200", "400", "100", "500"];
|
|
@@ -169,7 +169,7 @@ var styles = reactNative.StyleSheet.create({
|
|
|
169
169
|
});
|
|
170
170
|
var fieldSeq = 0;
|
|
171
171
|
function useFieldIds() {
|
|
172
|
-
const [ids] =
|
|
172
|
+
const [ids] = React26__default.default.useState(() => {
|
|
173
173
|
fieldSeq += 1;
|
|
174
174
|
const seq = String(fieldSeq);
|
|
175
175
|
return {
|
|
@@ -216,7 +216,7 @@ var Field = ({
|
|
|
216
216
|
const hasLabel = labelText !== "";
|
|
217
217
|
const marker = resolveFieldMarker(required, optional);
|
|
218
218
|
const { hintId, errorId, controlId, labelId } = useFieldIds();
|
|
219
|
-
const themeStyles =
|
|
219
|
+
const themeStyles = React26__default.default.useMemo(
|
|
220
220
|
() => ({
|
|
221
221
|
label: { color: colors.textSecondary },
|
|
222
222
|
requiredMark: { color: errorColor },
|
|
@@ -268,7 +268,7 @@ var FormGrid = ({
|
|
|
268
268
|
style,
|
|
269
269
|
testID
|
|
270
270
|
}) => {
|
|
271
|
-
const metrics =
|
|
271
|
+
const metrics = React26__default.default.useMemo(() => ({ minWidth, basis }), [minWidth, basis]);
|
|
272
272
|
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 }) }) });
|
|
273
273
|
};
|
|
274
274
|
var LABEL_LINE_PLACEHOLDER = "\xA0";
|
|
@@ -353,8 +353,8 @@ var InlineFieldRow = ({
|
|
|
353
353
|
}) => {
|
|
354
354
|
const { width } = reactNative.useWindowDimensions();
|
|
355
355
|
const layout = inlineFieldRowLayout(width, fieldMaxWidth, inlineMinWidth);
|
|
356
|
-
const rowStyle =
|
|
357
|
-
const fieldStyle =
|
|
356
|
+
const rowStyle = React26.useMemo(() => [styles4.row, { gap }], [gap]);
|
|
357
|
+
const fieldStyle = React26.useMemo(() => [styles4.field, { maxWidth: layout.fieldMaxWidth }], [layout.fieldMaxWidth]);
|
|
358
358
|
if (!layout.inline)
|
|
359
359
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
360
360
|
field2,
|
|
@@ -535,7 +535,7 @@ var styles9 = reactNative.StyleSheet.create({
|
|
|
535
535
|
});
|
|
536
536
|
var sectionSeq = 0;
|
|
537
537
|
function useSectionLegendId() {
|
|
538
|
-
const [id] =
|
|
538
|
+
const [id] = React26__default.default.useState(() => {
|
|
539
539
|
sectionSeq += 1;
|
|
540
540
|
return `form-section-legend-${String(sectionSeq)}`;
|
|
541
541
|
});
|
|
@@ -793,8 +793,8 @@ function horizontalPlacement(rect2, viewportWidth) {
|
|
|
793
793
|
return { left, width };
|
|
794
794
|
}
|
|
795
795
|
function useAnchorRect(ref, enabled) {
|
|
796
|
-
const [rect2, setRect] =
|
|
797
|
-
|
|
796
|
+
const [rect2, setRect] = React26.useState(null);
|
|
797
|
+
React26.useLayoutEffect(() => {
|
|
798
798
|
if (!IS_WEB3 || !enabled) {
|
|
799
799
|
setRect(null);
|
|
800
800
|
return void 0;
|
|
@@ -843,8 +843,8 @@ function readViewportBottom() {
|
|
|
843
843
|
return viewport === null ? window.innerHeight : viewport.offsetTop + viewport.height;
|
|
844
844
|
}
|
|
845
845
|
function useVisualViewportBottom(enabled) {
|
|
846
|
-
const [bottom, setBottom] =
|
|
847
|
-
|
|
846
|
+
const [bottom, setBottom] = React26.useState(null);
|
|
847
|
+
React26.useLayoutEffect(() => {
|
|
848
848
|
if (!IS_WEB3 || !enabled) {
|
|
849
849
|
setBottom(null);
|
|
850
850
|
return void 0;
|
|
@@ -874,7 +874,7 @@ function scrollAnchorIntoView(ref, marginTop) {
|
|
|
874
874
|
scrollNodeIntoView(node, anchorScrollBlock(node.getBoundingClientRect().bottom, readViewportBottom()));
|
|
875
875
|
}
|
|
876
876
|
function useKeepAnchorInRoom(ref, marginTop, enabled) {
|
|
877
|
-
|
|
877
|
+
React26.useLayoutEffect(() => {
|
|
878
878
|
if (!IS_WEB3 || !enabled) return void 0;
|
|
879
879
|
const place = () => scrollAnchorIntoView(ref, marginTop);
|
|
880
880
|
place();
|
|
@@ -888,7 +888,7 @@ var ESCAPE_KEY = "Escape";
|
|
|
888
888
|
var LISTBOX_ROLE = { role: "listbox" };
|
|
889
889
|
var KEEP_FIELD_FOCUS = { onMouseDown: (event) => event.preventDefault() };
|
|
890
890
|
function useDismiss(anchorRef, menuRef, onDismiss) {
|
|
891
|
-
|
|
891
|
+
React26.useEffect(() => {
|
|
892
892
|
if (!IS_WEB4) return void 0;
|
|
893
893
|
const onMouseDown = (event) => {
|
|
894
894
|
const anchorNode = anchorRef.current;
|
|
@@ -910,7 +910,7 @@ function useDismiss(anchorRef, menuRef, onDismiss) {
|
|
|
910
910
|
}, [anchorRef, menuRef, onDismiss]);
|
|
911
911
|
}
|
|
912
912
|
function useKeepHighlightInView(testID, highlightedValue) {
|
|
913
|
-
|
|
913
|
+
React26.useEffect(() => {
|
|
914
914
|
if (!IS_WEB4 || highlightedValue === void 0 || highlightedValue === "") return;
|
|
915
915
|
scrollNodeIntoView(document.getElementById(optionDomId(testID, highlightedValue)), "nearest");
|
|
916
916
|
}, [testID, highlightedValue]);
|
|
@@ -929,7 +929,7 @@ function AnchoredMenu({
|
|
|
929
929
|
listbox,
|
|
930
930
|
placement
|
|
931
931
|
}) {
|
|
932
|
-
const menuRef =
|
|
932
|
+
const menuRef = React26__default.default.useRef(null);
|
|
933
933
|
useDismiss(anchorRef, menuRef, onDismiss);
|
|
934
934
|
useKeepHighlightInView(testID, listbox?.highlightedValue);
|
|
935
935
|
const rect2 = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
|
|
@@ -1004,27 +1004,27 @@ function useThemedInput(options = {}) {
|
|
|
1004
1004
|
const { hasError = false, onFocus, onBlur, editable = true } = options;
|
|
1005
1005
|
const { theme } = uiFeedback.useUi();
|
|
1006
1006
|
const { colors, palette } = theme;
|
|
1007
|
-
const [isFocused, setIsFocused] =
|
|
1008
|
-
const [isHovered, setIsHovered] =
|
|
1009
|
-
const handleFocus =
|
|
1007
|
+
const [isFocused, setIsFocused] = React26.useState(false);
|
|
1008
|
+
const [isHovered, setIsHovered] = React26.useState(false);
|
|
1009
|
+
const handleFocus = React26.useCallback(
|
|
1010
1010
|
(e) => {
|
|
1011
1011
|
setIsFocused(true);
|
|
1012
1012
|
onFocus?.(e);
|
|
1013
1013
|
},
|
|
1014
1014
|
[onFocus]
|
|
1015
1015
|
);
|
|
1016
|
-
const handleBlur =
|
|
1016
|
+
const handleBlur = React26.useCallback(
|
|
1017
1017
|
(e) => {
|
|
1018
1018
|
setIsFocused(false);
|
|
1019
1019
|
onBlur?.(e);
|
|
1020
1020
|
},
|
|
1021
1021
|
[onBlur]
|
|
1022
1022
|
);
|
|
1023
|
-
const handleHoverIn =
|
|
1024
|
-
const handleHoverOut =
|
|
1023
|
+
const handleHoverIn = React26.useCallback(() => setIsHovered(true), []);
|
|
1024
|
+
const handleHoverOut = React26.useCallback(() => setIsHovered(false), []);
|
|
1025
1025
|
const primary = palette.primary["500"];
|
|
1026
1026
|
const errorColor = fieldErrorInk(theme);
|
|
1027
|
-
const style =
|
|
1027
|
+
const style = React26.useMemo(() => {
|
|
1028
1028
|
const restBorder = hasError ? errorColor : colors.border;
|
|
1029
1029
|
const focusBorder = hasError ? errorColor : primary;
|
|
1030
1030
|
const editableBorder = isFocused ? focusBorder : isHovered ? withAlpha(colors.text, HOVER_BORDER_ALPHA) : restBorder;
|
|
@@ -1057,8 +1057,8 @@ function useThemedInput(options = {}) {
|
|
|
1057
1057
|
errorColor,
|
|
1058
1058
|
theme
|
|
1059
1059
|
]);
|
|
1060
|
-
const focusBind =
|
|
1061
|
-
const hoverBind =
|
|
1060
|
+
const focusBind = React26.useMemo(() => ({ onFocus: handleFocus, onBlur: handleBlur }), [handleFocus, handleBlur]);
|
|
1061
|
+
const hoverBind = React26.useMemo(
|
|
1062
1062
|
() => IS_WEB5 ? { onMouseEnter: handleHoverIn, onMouseLeave: handleHoverOut } : {},
|
|
1063
1063
|
[handleHoverIn, handleHoverOut]
|
|
1064
1064
|
);
|
|
@@ -1089,7 +1089,7 @@ var boxStyles = reactNative.StyleSheet.create({
|
|
|
1089
1089
|
textAlignVertical: "top"
|
|
1090
1090
|
}
|
|
1091
1091
|
});
|
|
1092
|
-
var ThemedTextInput =
|
|
1092
|
+
var ThemedTextInput = React26__default.default.forwardRef(function ThemedTextInput2({
|
|
1093
1093
|
hasError = false,
|
|
1094
1094
|
describedById,
|
|
1095
1095
|
requiredField = false,
|
|
@@ -1184,11 +1184,11 @@ function recentsEqual(a, b) {
|
|
|
1184
1184
|
|
|
1185
1185
|
// src/useRecentValues/useRecentValues.ts
|
|
1186
1186
|
function useRecentValues(key, max = DEFAULT_MAX_RECENTS) {
|
|
1187
|
-
const [recents, setRecents] =
|
|
1188
|
-
|
|
1187
|
+
const [recents, setRecents] = React26.useState(() => readRecents(key).slice(0, max));
|
|
1188
|
+
React26.useEffect(() => {
|
|
1189
1189
|
setRecents(readRecents(key).slice(0, max));
|
|
1190
1190
|
}, [key, max]);
|
|
1191
|
-
const remember =
|
|
1191
|
+
const remember = React26.useCallback(
|
|
1192
1192
|
(value) => {
|
|
1193
1193
|
setRecents((current) => {
|
|
1194
1194
|
const next = computeNextRecents(current, value, max);
|
|
@@ -1199,7 +1199,7 @@ function useRecentValues(key, max = DEFAULT_MAX_RECENTS) {
|
|
|
1199
1199
|
},
|
|
1200
1200
|
[key, max]
|
|
1201
1201
|
);
|
|
1202
|
-
const clear =
|
|
1202
|
+
const clear = React26.useCallback(() => {
|
|
1203
1203
|
clearRecents(key);
|
|
1204
1204
|
setRecents([]);
|
|
1205
1205
|
}, [key]);
|
|
@@ -1221,24 +1221,24 @@ function RecentInputField({
|
|
|
1221
1221
|
const { theme } = uiFeedback.useUi();
|
|
1222
1222
|
const { colors, palette } = theme;
|
|
1223
1223
|
const { recents, remember } = useRecentValues(recentKey, recentMax);
|
|
1224
|
-
const anchorRef =
|
|
1225
|
-
const latestText =
|
|
1226
|
-
const [isOpen, setIsOpen] =
|
|
1227
|
-
const handleChange =
|
|
1224
|
+
const anchorRef = React26.useRef(null);
|
|
1225
|
+
const latestText = React26.useRef(typeof value === "string" ? value : "");
|
|
1226
|
+
const [isOpen, setIsOpen] = React26.useState(false);
|
|
1227
|
+
const handleChange = React26.useCallback(
|
|
1228
1228
|
(text) => {
|
|
1229
1229
|
latestText.current = text;
|
|
1230
1230
|
onChangeText?.(text);
|
|
1231
1231
|
},
|
|
1232
1232
|
[onChangeText]
|
|
1233
1233
|
);
|
|
1234
|
-
const handleFocus =
|
|
1234
|
+
const handleFocus = React26.useCallback(
|
|
1235
1235
|
(event) => {
|
|
1236
1236
|
setIsOpen(true);
|
|
1237
1237
|
onFocus?.(event);
|
|
1238
1238
|
},
|
|
1239
1239
|
[onFocus]
|
|
1240
1240
|
);
|
|
1241
|
-
const handleBlur =
|
|
1241
|
+
const handleBlur = React26.useCallback(
|
|
1242
1242
|
(event) => {
|
|
1243
1243
|
const blurredText = latestText.current;
|
|
1244
1244
|
setTimeout(() => {
|
|
@@ -1249,7 +1249,7 @@ function RecentInputField({
|
|
|
1249
1249
|
},
|
|
1250
1250
|
[remember, onBlur]
|
|
1251
1251
|
);
|
|
1252
|
-
const handleSubmit =
|
|
1252
|
+
const handleSubmit = React26.useCallback(
|
|
1253
1253
|
(event) => {
|
|
1254
1254
|
remember(latestText.current);
|
|
1255
1255
|
setIsOpen(false);
|
|
@@ -1257,7 +1257,7 @@ function RecentInputField({
|
|
|
1257
1257
|
},
|
|
1258
1258
|
[remember, onSubmitEditing]
|
|
1259
1259
|
);
|
|
1260
|
-
const pick =
|
|
1260
|
+
const pick = React26.useCallback(
|
|
1261
1261
|
(picked) => {
|
|
1262
1262
|
latestText.current = picked;
|
|
1263
1263
|
onChangeText?.(picked);
|
|
@@ -1399,7 +1399,7 @@ function ChipContent({ icon, label, textStyle, numberOfLines }) {
|
|
|
1399
1399
|
}
|
|
1400
1400
|
function OutlineChip(props) {
|
|
1401
1401
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1402
|
-
const [hovered, setHovered] =
|
|
1402
|
+
const [hovered, setHovered] = React26__default.default.useState(false);
|
|
1403
1403
|
const active = selected || hovered;
|
|
1404
1404
|
const borderColor = active ? colors.primary : colors.border;
|
|
1405
1405
|
const backgroundColor = selected ? colors.tint : colors.muted;
|
|
@@ -1499,8 +1499,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
|
|
|
1499
1499
|
var NO_GROUP_PROPS = {};
|
|
1500
1500
|
function useRadioKeyboard(config) {
|
|
1501
1501
|
const { enabled, disabled, values, selectedIndex, onChange } = config;
|
|
1502
|
-
const nodes =
|
|
1503
|
-
const chipRef =
|
|
1502
|
+
const nodes = React26__default.default.useRef([]);
|
|
1503
|
+
const chipRef = React26__default.default.useCallback((index) => (node) => {
|
|
1504
1504
|
nodes.current[index] = node;
|
|
1505
1505
|
}, []);
|
|
1506
1506
|
const onKeyDown = (event) => {
|
|
@@ -1613,7 +1613,7 @@ var ChipSelector = ({
|
|
|
1613
1613
|
const isRadioGroup = !multiple && singleSelectRole === "radio";
|
|
1614
1614
|
const { theme } = uiFeedback.useUi();
|
|
1615
1615
|
const { colors, palette } = theme;
|
|
1616
|
-
const chipColors =
|
|
1616
|
+
const chipColors = React26__default.default.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
|
|
1617
1617
|
function isSelected(optionValue) {
|
|
1618
1618
|
if (multiple && Array.isArray(value))
|
|
1619
1619
|
return value.includes(optionValue);
|
|
@@ -1709,12 +1709,12 @@ var FormSwitch = ({
|
|
|
1709
1709
|
accessibilityHint
|
|
1710
1710
|
}) => {
|
|
1711
1711
|
const { theme } = uiFeedback.useUi();
|
|
1712
|
-
const
|
|
1712
|
+
const toggle2 = React26__default.default.useCallback(() => {
|
|
1713
1713
|
if (!disabled) onValueChange(!value);
|
|
1714
1714
|
}, [disabled, onValueChange, value]);
|
|
1715
1715
|
const { colors } = theme;
|
|
1716
1716
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1717
|
-
const themeStyles =
|
|
1717
|
+
const themeStyles = React26__default.default.useMemo(() => {
|
|
1718
1718
|
const labelStyle = { color: colors.text };
|
|
1719
1719
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1720
1720
|
return { label: labelStyle, description: descriptionStyle };
|
|
@@ -1731,10 +1731,10 @@ var FormSwitch = ({
|
|
|
1731
1731
|
{
|
|
1732
1732
|
accessible: false,
|
|
1733
1733
|
disabled,
|
|
1734
|
-
onPress:
|
|
1734
|
+
onPress: toggle2,
|
|
1735
1735
|
style: [styles13.container, containerStyle],
|
|
1736
1736
|
tabIndex: -1,
|
|
1737
|
-
testID
|
|
1737
|
+
testID,
|
|
1738
1738
|
children: [
|
|
1739
1739
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles13.textColumn, children: [
|
|
1740
1740
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles13.label, themeStyles.label], children: label }),
|
|
@@ -1747,7 +1747,7 @@ var FormSwitch = ({
|
|
|
1747
1747
|
accessibilityLabel: label,
|
|
1748
1748
|
accessibilityState: { checked: value, disabled },
|
|
1749
1749
|
disabled,
|
|
1750
|
-
testID
|
|
1750
|
+
testID: `${testID}-switch`,
|
|
1751
1751
|
value,
|
|
1752
1752
|
onValueChange
|
|
1753
1753
|
}
|
|
@@ -1837,8 +1837,8 @@ var FormCheckbox = ({
|
|
|
1837
1837
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
1838
1838
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
1839
1839
|
const { hintId } = useFieldIds();
|
|
1840
|
-
const [focused, setFocused] =
|
|
1841
|
-
const themeStyles =
|
|
1840
|
+
const [focused, setFocused] = React26__default.default.useState(false);
|
|
1841
|
+
const themeStyles = React26__default.default.useMemo(() => {
|
|
1842
1842
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
1843
1843
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
1844
1844
|
const ring = { borderColor: brand };
|
|
@@ -1846,7 +1846,7 @@ var FormCheckbox = ({
|
|
|
1846
1846
|
const hintStyle = { color: colors.textSecondary };
|
|
1847
1847
|
return { boxOn, boxOff, ring, label: labelStyle, hint: hintStyle };
|
|
1848
1848
|
}, [brand, colors]);
|
|
1849
|
-
const
|
|
1849
|
+
const toggle2 = () => {
|
|
1850
1850
|
const next = !value;
|
|
1851
1851
|
if (onValueChange) onValueChange(next);
|
|
1852
1852
|
if (onChange) onChange(next);
|
|
@@ -1856,7 +1856,7 @@ var FormCheckbox = ({
|
|
|
1856
1856
|
const key = event.key ?? "";
|
|
1857
1857
|
if (!ACTIVATION_KEYS.includes(key)) return;
|
|
1858
1858
|
if (typeof event.preventDefault === "function") event.preventDefault();
|
|
1859
|
-
|
|
1859
|
+
toggle2();
|
|
1860
1860
|
};
|
|
1861
1861
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown } : {};
|
|
1862
1862
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1871,7 +1871,7 @@ var FormCheckbox = ({
|
|
|
1871
1871
|
disabled,
|
|
1872
1872
|
onBlur: () => setFocused(false),
|
|
1873
1873
|
onFocus: () => setFocused(true),
|
|
1874
|
-
onPress:
|
|
1874
|
+
onPress: toggle2,
|
|
1875
1875
|
role: "checkbox",
|
|
1876
1876
|
style: [
|
|
1877
1877
|
styles14.container,
|
|
@@ -1907,10 +1907,10 @@ function nextHighlight(current, count, delta) {
|
|
|
1907
1907
|
// src/SelectControl/useSelectListbox.ts
|
|
1908
1908
|
var FORWARD = 1;
|
|
1909
1909
|
var BACKWARD = -1;
|
|
1910
|
-
function useSelectListbox({ options, isOpen, open, toggle, select }) {
|
|
1911
|
-
const [row, setRow] =
|
|
1910
|
+
function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
1911
|
+
const [row, setRow] = React26.useState(NO_HIGHLIGHT);
|
|
1912
1912
|
const highlighted = isOpen ? options[row] : void 0;
|
|
1913
|
-
|
|
1913
|
+
React26.useEffect(() => {
|
|
1914
1914
|
if (!isOpen) setRow(NO_HIGHLIGHT);
|
|
1915
1915
|
}, [isOpen]);
|
|
1916
1916
|
const onKeyDown = (event) => {
|
|
@@ -1923,7 +1923,7 @@ function useSelectListbox({ options, isOpen, open, toggle, select }) {
|
|
|
1923
1923
|
open();
|
|
1924
1924
|
setRow((current) => nextHighlight(current, options.length, key === "ArrowDown" ? FORWARD : BACKWARD));
|
|
1925
1925
|
} else if (highlighted !== void 0) select(highlighted.value);
|
|
1926
|
-
else
|
|
1926
|
+
else toggle2();
|
|
1927
1927
|
};
|
|
1928
1928
|
return { highlighted, onKeyDown };
|
|
1929
1929
|
}
|
|
@@ -1951,29 +1951,29 @@ function SelectControl({
|
|
|
1951
1951
|
}) {
|
|
1952
1952
|
const { theme } = uiFeedback.useUi();
|
|
1953
1953
|
const { colors, palette } = theme;
|
|
1954
|
-
const anchorRef =
|
|
1955
|
-
const [isOpen, setIsOpen] =
|
|
1956
|
-
const selectedLabel =
|
|
1954
|
+
const anchorRef = React26.useRef(null);
|
|
1955
|
+
const [isOpen, setIsOpen] = React26.useState(false);
|
|
1956
|
+
const selectedLabel = React26.useMemo(() => {
|
|
1957
1957
|
const found = options.find((o) => o.value === value);
|
|
1958
1958
|
return found?.label ?? placeholder;
|
|
1959
1959
|
}, [options, placeholder, value]);
|
|
1960
|
-
const close =
|
|
1960
|
+
const close = React26.useCallback(() => {
|
|
1961
1961
|
setIsOpen(false);
|
|
1962
1962
|
}, []);
|
|
1963
|
-
const open =
|
|
1963
|
+
const open = React26.useCallback(() => {
|
|
1964
1964
|
setIsOpen(true);
|
|
1965
1965
|
}, []);
|
|
1966
|
-
const
|
|
1966
|
+
const toggle2 = React26.useCallback(() => {
|
|
1967
1967
|
setIsOpen((prev) => !prev);
|
|
1968
1968
|
}, []);
|
|
1969
|
-
const select =
|
|
1969
|
+
const select = React26.useCallback(
|
|
1970
1970
|
(next) => {
|
|
1971
1971
|
onChange(next);
|
|
1972
1972
|
setIsOpen(false);
|
|
1973
1973
|
},
|
|
1974
1974
|
[onChange]
|
|
1975
1975
|
);
|
|
1976
|
-
const listbox = useSelectListbox({ options, isOpen, open, toggle, select });
|
|
1976
|
+
const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
|
|
1977
1977
|
const isListbox = menuAnchor !== void 0;
|
|
1978
1978
|
const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
|
|
1979
1979
|
const triggerAria = isListbox ? listboxTriggerAria(testID, isOpen && options.length > 0, listbox.highlighted) : {};
|
|
@@ -1990,7 +1990,7 @@ function SelectControl({
|
|
|
1990
1990
|
"aria-haspopup": isListbox ? "listbox" : "menu",
|
|
1991
1991
|
"aria-labelledby": labelledById,
|
|
1992
1992
|
onBlur: isListbox ? close : void 0,
|
|
1993
|
-
onPress:
|
|
1993
|
+
onPress: toggle2,
|
|
1994
1994
|
style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
|
|
1995
1995
|
testID: `${testID}-trigger`,
|
|
1996
1996
|
children: [
|
|
@@ -2041,17 +2041,17 @@ var SelectField = ({
|
|
|
2041
2041
|
};
|
|
2042
2042
|
var CLOSE_DELAY_MS2 = 140;
|
|
2043
2043
|
function useDelayedBlurClose(open, close) {
|
|
2044
|
-
const timerRef =
|
|
2045
|
-
const cancelClose =
|
|
2044
|
+
const timerRef = React26.useRef(null);
|
|
2045
|
+
const cancelClose = React26.useCallback(() => {
|
|
2046
2046
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
2047
2047
|
timerRef.current = null;
|
|
2048
2048
|
}, []);
|
|
2049
|
-
|
|
2050
|
-
const handleFocus =
|
|
2049
|
+
React26.useEffect(() => cancelClose, [cancelClose]);
|
|
2050
|
+
const handleFocus = React26.useCallback(() => {
|
|
2051
2051
|
cancelClose();
|
|
2052
2052
|
open();
|
|
2053
2053
|
}, [cancelClose, open]);
|
|
2054
|
-
const handleBlur =
|
|
2054
|
+
const handleBlur = React26.useCallback(() => {
|
|
2055
2055
|
cancelClose();
|
|
2056
2056
|
timerRef.current = setTimeout(close, CLOSE_DELAY_MS2);
|
|
2057
2057
|
}, [cancelClose, close]);
|
|
@@ -2094,10 +2094,10 @@ function isUnmatched(options, text) {
|
|
|
2094
2094
|
var DEFAULT_TYPEAHEAD_DEBOUNCE_MS = 250;
|
|
2095
2095
|
var IDLE = { results: [], isLoading: false, hasFailed: false, hasSettled: false };
|
|
2096
2096
|
function useTypeaheadSearch(load, query, enabled, debounceMs) {
|
|
2097
|
-
const [state, setState] =
|
|
2098
|
-
const loadRef =
|
|
2097
|
+
const [state, setState] = React26.useState(IDLE);
|
|
2098
|
+
const loadRef = React26.useRef(load);
|
|
2099
2099
|
loadRef.current = load;
|
|
2100
|
-
|
|
2100
|
+
React26.useEffect(() => {
|
|
2101
2101
|
if (!enabled) {
|
|
2102
2102
|
setState(IDLE);
|
|
2103
2103
|
return void 0;
|
|
@@ -2136,30 +2136,30 @@ function useTypeaheadRows(input, isOpen, isPicked) {
|
|
|
2136
2136
|
const query = value.trim();
|
|
2137
2137
|
const isSearching = search !== void 0 && isOpen && !isPicked && query.length >= minChars;
|
|
2138
2138
|
const found = useTypeaheadSearch(search?.load, query, isSearching, search?.debounceMs ?? DEFAULT_TYPEAHEAD_DEBOUNCE_MS);
|
|
2139
|
-
const staticRows =
|
|
2139
|
+
const staticRows = React26.useMemo(() => {
|
|
2140
2140
|
if (options === void 0 || options.some((o) => o.label === value)) return NO_ROWS;
|
|
2141
2141
|
return suggestOptions(options, value, minChars, maxSuggestions);
|
|
2142
2142
|
}, [options, value, minChars, maxSuggestions]);
|
|
2143
|
-
const foundRows =
|
|
2143
|
+
const foundRows = React26.useMemo(() => found.results.slice(0, maxSuggestions), [found.results, maxSuggestions]);
|
|
2144
2144
|
if (search === void 0) return { rows: staticRows, statusText: void 0 };
|
|
2145
2145
|
return { rows: foundRows, statusText: searchStatusText(found, search) };
|
|
2146
2146
|
}
|
|
2147
2147
|
function useTypeaheadState(input) {
|
|
2148
2148
|
const { search, value, onChange, onSubmit } = input;
|
|
2149
|
-
const [isOpen, setIsOpen] =
|
|
2150
|
-
const [picked, setPicked] =
|
|
2151
|
-
const [highlightIndex, setHighlightIndex] =
|
|
2149
|
+
const [isOpen, setIsOpen] = React26.useState(false);
|
|
2150
|
+
const [picked, setPicked] = React26.useState(null);
|
|
2151
|
+
const [highlightIndex, setHighlightIndex] = React26.useState(NO_HIGHLIGHT);
|
|
2152
2152
|
const { rows, statusText } = useTypeaheadRows(input, isOpen, picked !== null && picked.label === value);
|
|
2153
2153
|
const rowKey = rows.map((row) => row.value).join("\n");
|
|
2154
2154
|
const highlighted = isOpen ? rows[highlightIndex] : void 0;
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
const open =
|
|
2158
|
-
const close =
|
|
2155
|
+
React26.useEffect(() => setHighlightIndex(NO_HIGHLIGHT), [rowKey]);
|
|
2156
|
+
React26.useEffect(() => setPicked((current) => current !== null && current.label !== value ? null : current), [value]);
|
|
2157
|
+
const open = React26.useCallback(() => setIsOpen(true), []);
|
|
2158
|
+
const close = React26.useCallback(() => {
|
|
2159
2159
|
setIsOpen(false);
|
|
2160
2160
|
setHighlightIndex(NO_HIGHLIGHT);
|
|
2161
2161
|
}, []);
|
|
2162
|
-
const pick =
|
|
2162
|
+
const pick = React26.useCallback(
|
|
2163
2163
|
(option) => {
|
|
2164
2164
|
setPicked(option);
|
|
2165
2165
|
onChange(option.label);
|
|
@@ -2168,14 +2168,14 @@ function useTypeaheadState(input) {
|
|
|
2168
2168
|
},
|
|
2169
2169
|
[onChange, search, close]
|
|
2170
2170
|
);
|
|
2171
|
-
const selectValue =
|
|
2171
|
+
const selectValue = React26.useCallback(
|
|
2172
2172
|
(optionValue) => {
|
|
2173
2173
|
const option = rows.find((row) => row.value === optionValue);
|
|
2174
2174
|
if (option !== void 0) pick(option);
|
|
2175
2175
|
},
|
|
2176
2176
|
[rows, pick]
|
|
2177
2177
|
);
|
|
2178
|
-
const handleChange =
|
|
2178
|
+
const handleChange = React26.useCallback(
|
|
2179
2179
|
(next) => {
|
|
2180
2180
|
if (picked !== null) {
|
|
2181
2181
|
setPicked(null);
|
|
@@ -2188,7 +2188,7 @@ function useTypeaheadState(input) {
|
|
|
2188
2188
|
[picked, search, onChange]
|
|
2189
2189
|
);
|
|
2190
2190
|
const handleKeyPress = useTypeaheadKeys({ rowCount: rows.length, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick });
|
|
2191
|
-
const handleSubmit =
|
|
2191
|
+
const handleSubmit = React26.useCallback(() => {
|
|
2192
2192
|
if (highlighted !== void 0) {
|
|
2193
2193
|
pick(highlighted);
|
|
2194
2194
|
return;
|
|
@@ -2200,7 +2200,7 @@ function useTypeaheadState(input) {
|
|
|
2200
2200
|
}
|
|
2201
2201
|
function useTypeaheadKeys(input) {
|
|
2202
2202
|
const { rowCount, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick } = input;
|
|
2203
|
-
return
|
|
2203
|
+
return React26.useCallback(
|
|
2204
2204
|
(event) => {
|
|
2205
2205
|
const { key } = event.nativeEvent;
|
|
2206
2206
|
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
@@ -2237,7 +2237,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2237
2237
|
const maxSuggestions = ("search" in props ? props.search.maxResults : props.maxSuggestions) ?? DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
|
|
2238
2238
|
const { theme } = uiFeedback.useUi();
|
|
2239
2239
|
const { colors, palette } = theme;
|
|
2240
|
-
const anchorRef =
|
|
2240
|
+
const anchorRef = React26.useRef(null);
|
|
2241
2241
|
const state = useTypeaheadState({ options, search, value, minChars, maxSuggestions, onChange, onSubmit });
|
|
2242
2242
|
const { handleFocus, handleBlur } = useDelayedBlurClose(state.open, state.close);
|
|
2243
2243
|
const showMenu = state.isOpen && (state.rows.length > 0 || state.statusText !== void 0);
|
|
@@ -2290,7 +2290,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2290
2290
|
hasError ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [controlStyles.error, { color: fieldErrorInk(theme) }], testID: `${testID}-error`, children: error }) : null
|
|
2291
2291
|
] });
|
|
2292
2292
|
}
|
|
2293
|
-
var TypeaheadControl =
|
|
2293
|
+
var TypeaheadControl = React26.forwardRef(TypeaheadControlImpl);
|
|
2294
2294
|
var NATIVE_INPUT_BOX = {
|
|
2295
2295
|
borderStyle: "solid",
|
|
2296
2296
|
boxSizing: "border-box",
|
|
@@ -2567,9 +2567,9 @@ function FormStatusLine({ message, testID, style }) {
|
|
|
2567
2567
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles17.line, { color: theme.colors.text }, style], testID, children: message });
|
|
2568
2568
|
}
|
|
2569
2569
|
function useFocusFirstInvalid(refs) {
|
|
2570
|
-
const latest =
|
|
2570
|
+
const latest = React26.useRef(refs);
|
|
2571
2571
|
latest.current = refs;
|
|
2572
|
-
return
|
|
2572
|
+
return React26.useCallback((invalid) => {
|
|
2573
2573
|
const first = invalid.map((field2) => latest.current[field2].current).find((node) => node !== null);
|
|
2574
2574
|
first?.focus();
|
|
2575
2575
|
}, []);
|
|
@@ -2578,8 +2578,8 @@ function isScrollable(node) {
|
|
|
2578
2578
|
return "scrollIntoView" in Object(node);
|
|
2579
2579
|
}
|
|
2580
2580
|
function useKeepInView(trigger) {
|
|
2581
|
-
const ref =
|
|
2582
|
-
|
|
2581
|
+
const ref = React26.useRef(null);
|
|
2582
|
+
React26.useEffect(() => {
|
|
2583
2583
|
const node = ref.current;
|
|
2584
2584
|
const hasTrigger = trigger !== void 0 && trigger !== null;
|
|
2585
2585
|
if (hasTrigger && isScrollable(node)) node.scrollIntoView({ block: "nearest" });
|
|
@@ -2611,7 +2611,7 @@ var UploadWithLinkField = ({
|
|
|
2611
2611
|
const { theme } = uiFeedback.useUi();
|
|
2612
2612
|
const ring = uiButtons.useFocusRing();
|
|
2613
2613
|
const url = value ?? "";
|
|
2614
|
-
const [pasting, setPasting] =
|
|
2614
|
+
const [pasting, setPasting] = React26.useState(url !== "");
|
|
2615
2615
|
const previewBox = { borderRadius: PREVIEW_RADIUS, height: previewSize, width: previewSize };
|
|
2616
2616
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles18.root, children: [
|
|
2617
2617
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles18.title, { color: theme.colors.text }], children: labels.title }),
|
|
@@ -2669,7 +2669,7 @@ var AddOnRequest = ({
|
|
|
2669
2669
|
disabled = false,
|
|
2670
2670
|
style
|
|
2671
2671
|
}) => {
|
|
2672
|
-
const [requested, setRequested] =
|
|
2672
|
+
const [requested, setRequested] = React26.useState(false);
|
|
2673
2673
|
const remove = () => {
|
|
2674
2674
|
setRequested(false);
|
|
2675
2675
|
onRemove();
|
|
@@ -2737,8 +2737,8 @@ var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
|
2737
2737
|
return SelectSurface2;
|
|
2738
2738
|
})(SelectSurface || {});
|
|
2739
2739
|
function useAnchorRect2(anchorRef) {
|
|
2740
|
-
const [rect2, setRect] =
|
|
2741
|
-
|
|
2740
|
+
const [rect2, setRect] = React26.useState(null);
|
|
2741
|
+
React26.useEffect(() => {
|
|
2742
2742
|
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2743
2743
|
}, [anchorRef]);
|
|
2744
2744
|
return rect2;
|
|
@@ -2773,8 +2773,8 @@ function fitDropdownWidth(frame, viewportWidth) {
|
|
|
2773
2773
|
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children }) {
|
|
2774
2774
|
const { height: viewportHeight, width: viewportWidth } = reactNative.useWindowDimensions();
|
|
2775
2775
|
const anchor = useAnchorRect2(anchorRef);
|
|
2776
|
-
const [panelHeight, setPanelHeight] =
|
|
2777
|
-
const onLayout =
|
|
2776
|
+
const [panelHeight, setPanelHeight] = React26.useState(0);
|
|
2777
|
+
const onLayout = React26.useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2778
2778
|
const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight), viewportWidth);
|
|
2779
2779
|
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2780
2780
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: [
|
|
@@ -2853,23 +2853,23 @@ var SHEET_MAX_HEIGHT = 480;
|
|
|
2853
2853
|
function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
|
|
2854
2854
|
const { theme } = uiFeedback.useUi();
|
|
2855
2855
|
const { colors } = theme;
|
|
2856
|
-
const progress =
|
|
2856
|
+
const progress = React26.useRef(new reactNative.Animated.Value(0)).current;
|
|
2857
2857
|
const { durationMs } = motion;
|
|
2858
|
-
|
|
2858
|
+
React26.useEffect(() => {
|
|
2859
2859
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
2860
2860
|
}, [progress, durationMs]);
|
|
2861
|
-
const leaving =
|
|
2862
|
-
const leave =
|
|
2861
|
+
const leaving = React26.useRef(false);
|
|
2862
|
+
const leave = React26.useCallback((after) => {
|
|
2863
2863
|
if (leaving.current) return;
|
|
2864
2864
|
leaving.current = true;
|
|
2865
2865
|
if (durationMs === 0) return after();
|
|
2866
2866
|
reactNative.Animated.timing(progress, { toValue: 0, duration: durationMs, useNativeDriver: false }).start(() => after());
|
|
2867
2867
|
}, [progress, durationMs]);
|
|
2868
2868
|
const { close, pick: pickNow, submit: submitNow, onKey, sections, highlight } = state;
|
|
2869
|
-
const dismiss =
|
|
2870
|
-
const pick =
|
|
2871
|
-
const submit =
|
|
2872
|
-
const onKeyPress =
|
|
2869
|
+
const dismiss = React26.useCallback(() => leave(close), [leave, close]);
|
|
2870
|
+
const pick = React26.useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
|
|
2871
|
+
const submit = React26.useCallback(() => submitNow(pick), [submitNow, pick]);
|
|
2872
|
+
const onKeyPress = React26.useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
|
|
2873
2873
|
const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [motion.fromY, 0] });
|
|
2874
2874
|
const isSheet = motion.surface === "sheet" /* Sheet */;
|
|
2875
2875
|
const shared = { selectedValue, renderLeading, renderDetail, onPick: pick, optionHint: labels.optionHint, testID, highlight };
|
|
@@ -2906,8 +2906,8 @@ var styles25 = reactNative.StyleSheet.create({
|
|
|
2906
2906
|
empty: { padding: PANEL_PAD }
|
|
2907
2907
|
});
|
|
2908
2908
|
function useReducedMotion() {
|
|
2909
|
-
const [reduced, setReduced] =
|
|
2910
|
-
|
|
2909
|
+
const [reduced, setReduced] = React26.useState(false);
|
|
2910
|
+
React26.useEffect(() => {
|
|
2911
2911
|
let active = true;
|
|
2912
2912
|
reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
2913
2913
|
if (active) setReduced(value);
|
|
@@ -2921,8 +2921,8 @@ function useReducedMotion() {
|
|
|
2921
2921
|
return reduced;
|
|
2922
2922
|
}
|
|
2923
2923
|
function useRefocusOnClose(open, ref) {
|
|
2924
|
-
const wasOpen =
|
|
2925
|
-
|
|
2924
|
+
const wasOpen = React26.useRef(false);
|
|
2925
|
+
React26.useEffect(() => {
|
|
2926
2926
|
if (wasOpen.current && !open) ref.current?.focus();
|
|
2927
2927
|
wasOpen.current = open;
|
|
2928
2928
|
}, [open, ref]);
|
|
@@ -2955,38 +2955,38 @@ var KEY_DOWN = "ArrowDown";
|
|
|
2955
2955
|
var KEY_UP = "ArrowUp";
|
|
2956
2956
|
var KEY_ESCAPE2 = "Escape";
|
|
2957
2957
|
function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
2958
|
-
const [open, setOpen] =
|
|
2959
|
-
const [query, setQueryState] =
|
|
2960
|
-
const [rawHighlight, setHighlight] =
|
|
2961
|
-
const sections =
|
|
2958
|
+
const [open, setOpen] = React26.useState(false);
|
|
2959
|
+
const [query, setQueryState] = React26.useState("");
|
|
2960
|
+
const [rawHighlight, setHighlight] = React26.useState(-1);
|
|
2961
|
+
const sections = React26.useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
|
|
2962
2962
|
const highlight = rawHighlight < sections.flat.length ? rawHighlight : -1;
|
|
2963
2963
|
const active = sections.flat[highlight];
|
|
2964
2964
|
const { remember } = recents;
|
|
2965
|
-
const close =
|
|
2965
|
+
const close = React26.useCallback(() => {
|
|
2966
2966
|
setOpen(false);
|
|
2967
2967
|
setQueryState("");
|
|
2968
2968
|
setHighlight(-1);
|
|
2969
2969
|
onClosed();
|
|
2970
2970
|
}, [onClosed]);
|
|
2971
|
-
const pick =
|
|
2971
|
+
const pick = React26.useCallback((option) => {
|
|
2972
2972
|
remember(option.value);
|
|
2973
2973
|
onChange(option.value);
|
|
2974
2974
|
close();
|
|
2975
2975
|
}, [remember, onChange, close]);
|
|
2976
|
-
const submit =
|
|
2976
|
+
const submit = React26.useCallback((via = pick) => {
|
|
2977
2977
|
if (active !== void 0) via(active);
|
|
2978
2978
|
}, [active, pick]);
|
|
2979
|
-
const setQuery =
|
|
2979
|
+
const setQuery = React26.useCallback((next) => {
|
|
2980
2980
|
setQueryState(next);
|
|
2981
2981
|
setHighlight(highlightAfterQuery(next));
|
|
2982
2982
|
}, []);
|
|
2983
|
-
const onKey =
|
|
2983
|
+
const onKey = React26.useCallback((key) => {
|
|
2984
2984
|
const count = sections.flat.length;
|
|
2985
2985
|
if (key === KEY_DOWN) setHighlight(moveHighlight(highlight, count, 1));
|
|
2986
2986
|
if (key === KEY_UP) setHighlight(moveHighlight(highlight, count, -1));
|
|
2987
2987
|
if (key === KEY_ESCAPE2) close();
|
|
2988
2988
|
}, [sections.flat.length, highlight, close]);
|
|
2989
|
-
const openList =
|
|
2989
|
+
const openList = React26.useCallback(() => setOpen(true), []);
|
|
2990
2990
|
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
2991
2991
|
}
|
|
2992
2992
|
|
|
@@ -3010,8 +3010,8 @@ function SearchSelect(props) {
|
|
|
3010
3010
|
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger, onBlur } = props;
|
|
3011
3011
|
const { theme } = uiFeedback.useUi();
|
|
3012
3012
|
const { colors } = theme;
|
|
3013
|
-
const triggerRef =
|
|
3014
|
-
const anchorRef =
|
|
3013
|
+
const triggerRef = React26.useRef(null);
|
|
3014
|
+
const anchorRef = React26.useRef(null);
|
|
3015
3015
|
const { width } = reactNative.useWindowDimensions();
|
|
3016
3016
|
const motion = resolveSelectMotion(width, useReducedMotion());
|
|
3017
3017
|
const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
|
|
@@ -3019,9 +3019,9 @@ function SearchSelect(props) {
|
|
|
3019
3019
|
useRefocusOnClose(state.open, triggerRef);
|
|
3020
3020
|
const selected = findOption(options, value);
|
|
3021
3021
|
const onPress = state.open ? state.close : state.openList;
|
|
3022
|
-
const openRef =
|
|
3022
|
+
const openRef = React26.useRef(state.open);
|
|
3023
3023
|
openRef.current = state.open;
|
|
3024
|
-
const onTriggerBlur =
|
|
3024
|
+
const onTriggerBlur = React26.useCallback(() => {
|
|
3025
3025
|
if (!openRef.current) onBlur?.();
|
|
3026
3026
|
}, [onBlur]);
|
|
3027
3027
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles26.anchor, children: [
|
|
@@ -3071,7 +3071,7 @@ function isOutside(container, target) {
|
|
|
3071
3071
|
return !(target instanceof Node && container.contains(target));
|
|
3072
3072
|
}
|
|
3073
3073
|
function useOutsidePress(ref, onOutside) {
|
|
3074
|
-
|
|
3074
|
+
React26.useEffect(() => {
|
|
3075
3075
|
if (reactNative.Platform.OS !== "web" || typeof document === "undefined") return void 0;
|
|
3076
3076
|
const onPointerDown = (event) => {
|
|
3077
3077
|
if (isOutside(ref.current, event.target)) onOutside();
|
|
@@ -3082,7 +3082,7 @@ function useOutsidePress(ref, onOutside) {
|
|
|
3082
3082
|
}
|
|
3083
3083
|
var AFTER_SURFACE_UNMOUNT_MS = 0;
|
|
3084
3084
|
function useDeferredFocus(ref) {
|
|
3085
|
-
return
|
|
3085
|
+
return React26.useCallback(() => {
|
|
3086
3086
|
setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
|
|
3087
3087
|
}, [ref]);
|
|
3088
3088
|
}
|
|
@@ -3834,8 +3834,8 @@ var renderFlag = (option) => option.value === NO_COUNTRY2 ? null : /* @__PURE__
|
|
|
3834
3834
|
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }) {
|
|
3835
3835
|
const { theme } = uiFeedback.useUi();
|
|
3836
3836
|
const { textSecondary } = theme.colors;
|
|
3837
|
-
const options =
|
|
3838
|
-
const renderCode =
|
|
3837
|
+
const options = React26.useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
|
|
3838
|
+
const renderCode = React26.useCallback((option) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles27.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
|
|
3839
3839
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3840
3840
|
SearchSelect,
|
|
3841
3841
|
{
|
|
@@ -3857,9 +3857,9 @@ var styles27 = reactNative.StyleSheet.create({
|
|
|
3857
3857
|
code: { fontSize: CODE_FONT }
|
|
3858
3858
|
});
|
|
3859
3859
|
function useBlurVerdict(validate) {
|
|
3860
|
-
const [verdict, setVerdict] =
|
|
3861
|
-
const onEdit =
|
|
3862
|
-
const onLeave =
|
|
3860
|
+
const [verdict, setVerdict] = React26.useState(null);
|
|
3861
|
+
const onEdit = React26.useCallback(() => setVerdict(null), []);
|
|
3862
|
+
const onLeave = React26.useCallback(() => {
|
|
3863
3863
|
const next = validate();
|
|
3864
3864
|
setVerdict(next);
|
|
3865
3865
|
return next;
|
|
@@ -4013,11 +4013,11 @@ function rawCaretAfterChange(previous, previousCaret, next) {
|
|
|
4013
4013
|
|
|
4014
4014
|
// src/IbanInput/hooks/useIbanCaret.ts
|
|
4015
4015
|
function useIbanCaret(display) {
|
|
4016
|
-
const [selection, setSelection] =
|
|
4017
|
-
const onSelectionChange =
|
|
4016
|
+
const [selection, setSelection] = React26.useState({ start: display.length, end: display.length });
|
|
4017
|
+
const onSelectionChange = React26.useCallback((event) => {
|
|
4018
4018
|
setSelection(event.nativeEvent.selection);
|
|
4019
4019
|
}, []);
|
|
4020
|
-
const placeAfterEdit =
|
|
4020
|
+
const placeAfterEdit = React26.useCallback((text) => {
|
|
4021
4021
|
const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection.end, text));
|
|
4022
4022
|
setSelection({ start: caret, end: caret });
|
|
4023
4023
|
}, [display, selection.end]);
|
|
@@ -4123,19 +4123,19 @@ function rejectionMessage(rejection, none, labels) {
|
|
|
4123
4123
|
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
4124
4124
|
const { theme } = uiFeedback.useUi();
|
|
4125
4125
|
const { colors } = theme;
|
|
4126
|
-
const draft =
|
|
4127
|
-
const validate =
|
|
4126
|
+
const draft = React26.useMemo(() => draftIban(value), [value]);
|
|
4127
|
+
const validate = React26.useCallback(() => validateIban(value), [value]);
|
|
4128
4128
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
4129
4129
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
4130
4130
|
const counter = ibanCounter(draft);
|
|
4131
4131
|
const { selection, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
4132
|
-
const onChangeText =
|
|
4132
|
+
const onChangeText = React26.useCallback((text) => {
|
|
4133
4133
|
onEdit();
|
|
4134
4134
|
onVerdict?.(null);
|
|
4135
4135
|
placeAfterEdit(text);
|
|
4136
4136
|
onChange(draftIban(text).electronic);
|
|
4137
4137
|
}, [onEdit, onVerdict, placeAfterEdit, onChange]);
|
|
4138
|
-
const onBlur =
|
|
4138
|
+
const onBlur = React26.useCallback(() => {
|
|
4139
4139
|
const verdict2 = onLeave();
|
|
4140
4140
|
onVerdict?.(value === "" ? null : verdict2);
|
|
4141
4141
|
onLeft?.();
|
|
@@ -4210,16 +4210,16 @@ function validateBic(raw) {
|
|
|
4210
4210
|
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
4211
4211
|
const { theme } = uiFeedback.useUi();
|
|
4212
4212
|
const { colors } = theme;
|
|
4213
|
-
const draft =
|
|
4214
|
-
const validate =
|
|
4213
|
+
const draft = React26.useMemo(() => draftBic(value), [value]);
|
|
4214
|
+
const validate = React26.useCallback(() => validateBic(value), [value]);
|
|
4215
4215
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
4216
4216
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
4217
|
-
const onChangeText =
|
|
4217
|
+
const onChangeText = React26.useCallback((text) => {
|
|
4218
4218
|
onEdit();
|
|
4219
4219
|
onVerdict?.(null);
|
|
4220
4220
|
onChange(draftBic(text).value);
|
|
4221
4221
|
}, [onEdit, onVerdict, onChange]);
|
|
4222
|
-
const onBlur =
|
|
4222
|
+
const onBlur = React26.useCallback(() => {
|
|
4223
4223
|
const verdict2 = onLeave();
|
|
4224
4224
|
onVerdict?.(value === "" ? null : verdict2);
|
|
4225
4225
|
onLeft?.();
|
|
@@ -4253,7 +4253,344 @@ function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilit
|
|
|
4253
4253
|
/* @__PURE__ */ jsxRuntime.jsx(RejectionLine, { message, testID })
|
|
4254
4254
|
] });
|
|
4255
4255
|
}
|
|
4256
|
+
var BAR_GAP = 8;
|
|
4257
|
+
var PAD_V = 10;
|
|
4258
|
+
var PAD_H = 16;
|
|
4259
|
+
var TEXT_SIZE2 = 13;
|
|
4260
|
+
var TEXT_LINE2 = 18;
|
|
4261
|
+
var styles29 = reactNative.StyleSheet.create({
|
|
4262
|
+
bar: { borderTopWidth: 1, paddingHorizontal: PAD_H, paddingVertical: PAD_V, rowGap: BAR_GAP },
|
|
4263
|
+
actions: { flexDirection: "row", flexWrap: "wrap", gap: BAR_GAP },
|
|
4264
|
+
message: { fontSize: TEXT_SIZE2, fontWeight: "700", lineHeight: TEXT_LINE2 }
|
|
4265
|
+
});
|
|
4266
|
+
var PINNED = { position: "sticky", bottom: 0, zIndex: 1 };
|
|
4267
|
+
var actionBarPosition = (sticky, os) => sticky && os === "web" ? "sticky" : "relative";
|
|
4268
|
+
var ActionBar = ({ children, message, sticky = false, testID, style }) => {
|
|
4269
|
+
const { theme } = uiFeedback.useUi();
|
|
4270
|
+
const { colors } = theme;
|
|
4271
|
+
const pinned = actionBarPosition(sticky, reactNative.Platform.OS) === "sticky" ? PINNED : null;
|
|
4272
|
+
const hasMessage = message !== void 0 && message !== "";
|
|
4273
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles29.bar, { backgroundColor: colors.surface, borderTopColor: colors.border }, pinned, style], testID, children: [
|
|
4274
|
+
hasMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "status", style: [styles29.message, { color: colors.text }], testID: `${testID}-message`, children: message }) : null,
|
|
4275
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles29.actions, children })
|
|
4276
|
+
] });
|
|
4277
|
+
};
|
|
4278
|
+
|
|
4279
|
+
// src/GatedChecklist/isChecklistComplete.ts
|
|
4280
|
+
var isChecklistComplete = (items, checked) => items.every((item) => checked.includes(item.id));
|
|
4281
|
+
var TITLE_SIZE = 13;
|
|
4282
|
+
var TITLE_GAP = 6;
|
|
4283
|
+
var styles30 = reactNative.StyleSheet.create({
|
|
4284
|
+
title: { fontSize: TITLE_SIZE, fontWeight: "700", marginBottom: TITLE_GAP }
|
|
4285
|
+
});
|
|
4286
|
+
var GatedChecklist = ({ title, items, checked, onToggle, testID, disabled = false, children }) => {
|
|
4287
|
+
const { theme } = uiFeedback.useUi();
|
|
4288
|
+
const complete = isChecklistComplete(items, checked);
|
|
4289
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { testID, children: [
|
|
4290
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles30.title, { color: theme.colors.text }], children: title }),
|
|
4291
|
+
items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4292
|
+
FormCheckbox,
|
|
4293
|
+
{
|
|
4294
|
+
description: item.description,
|
|
4295
|
+
disabled,
|
|
4296
|
+
label: item.label,
|
|
4297
|
+
testID: `${testID}-item-${item.id}`,
|
|
4298
|
+
value: checked.includes(item.id),
|
|
4299
|
+
onValueChange: () => onToggle(item.id)
|
|
4300
|
+
},
|
|
4301
|
+
item.id
|
|
4302
|
+
)),
|
|
4303
|
+
children?.(complete)
|
|
4304
|
+
] });
|
|
4305
|
+
};
|
|
4306
|
+
var MIN_TARGET_PX2 = 44;
|
|
4307
|
+
var DOT_SIZE = 18;
|
|
4308
|
+
var DOT_INNER = 8;
|
|
4309
|
+
var ROW_GAP6 = 10;
|
|
4310
|
+
var PAD_H2 = 12;
|
|
4311
|
+
var PAD_V2 = 8;
|
|
4312
|
+
var RADIUS = 8;
|
|
4313
|
+
var LABEL_SIZE = 14;
|
|
4314
|
+
var DESCRIPTION_SIZE = 12;
|
|
4315
|
+
var DESCRIPTION_LINE = 16;
|
|
4316
|
+
var styles31 = reactNative.StyleSheet.create({
|
|
4317
|
+
row: {
|
|
4318
|
+
alignItems: "center",
|
|
4319
|
+
borderRadius: RADIUS,
|
|
4320
|
+
borderWidth: 1,
|
|
4321
|
+
columnGap: ROW_GAP6,
|
|
4322
|
+
flexDirection: "row",
|
|
4323
|
+
minHeight: MIN_TARGET_PX2,
|
|
4324
|
+
paddingHorizontal: PAD_H2,
|
|
4325
|
+
paddingVertical: PAD_V2
|
|
4326
|
+
},
|
|
4327
|
+
dot: { alignItems: "center", borderRadius: DOT_SIZE / 2, borderWidth: 2, height: DOT_SIZE, justifyContent: "center", width: DOT_SIZE },
|
|
4328
|
+
dotInner: { borderRadius: DOT_INNER / 2, height: DOT_INNER, width: DOT_INNER },
|
|
4329
|
+
text: { flex: 1, flexShrink: 1 },
|
|
4330
|
+
label: { fontSize: LABEL_SIZE, fontWeight: "600" },
|
|
4331
|
+
description: { fontSize: DESCRIPTION_SIZE, lineHeight: DESCRIPTION_LINE }
|
|
4332
|
+
});
|
|
4333
|
+
function RadioRow({ option, identity, colors, tabIndex, hostRef, onPress }) {
|
|
4334
|
+
const { checked, disabled } = identity.accessibilityState;
|
|
4335
|
+
const accent = checked ? colors.primary : colors.border;
|
|
4336
|
+
const hasDescription = option.description !== void 0 && option.description !== "";
|
|
4337
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4338
|
+
reactNative.Pressable,
|
|
4339
|
+
{
|
|
4340
|
+
ref: hostRef,
|
|
4341
|
+
accessibilityHint: option.hint,
|
|
4342
|
+
accessibilityLabel: identity.accessibilityLabel,
|
|
4343
|
+
accessibilityRole: "radio",
|
|
4344
|
+
accessibilityState: identity.accessibilityState,
|
|
4345
|
+
"aria-checked": checked,
|
|
4346
|
+
disabled,
|
|
4347
|
+
style: [styles31.row, { borderColor: accent, backgroundColor: checked ? colors.tint : colors.muted }],
|
|
4348
|
+
tabIndex,
|
|
4349
|
+
testID: identity.testID,
|
|
4350
|
+
onPress,
|
|
4351
|
+
children: [
|
|
4352
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles31.dot, { borderColor: accent }], children: checked ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles31.dotInner, { backgroundColor: colors.primary }] }) : null }),
|
|
4353
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles31.text, children: [
|
|
4354
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles31.label, { color: checked ? colors.primary : colors.textStrong }], children: option.label }),
|
|
4355
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles31.description, { color: colors.textMuted }], testID: `${identity.testID}-description`, children: option.description }) : null
|
|
4356
|
+
] })
|
|
4357
|
+
]
|
|
4358
|
+
}
|
|
4359
|
+
);
|
|
4360
|
+
}
|
|
4361
|
+
|
|
4362
|
+
// src/RadioList/utils/radioRowIdentity.ts
|
|
4363
|
+
var radioRowIdentity = (option, selected, disabled, prefix) => {
|
|
4364
|
+
const hasDescription = option.description !== void 0 && option.description !== "";
|
|
4365
|
+
return {
|
|
4366
|
+
testID: `${prefix}-${String(option.value)}`,
|
|
4367
|
+
accessibilityLabel: hasDescription ? `${option.label}, ${String(option.description)}` : option.label,
|
|
4368
|
+
accessibilityState: { checked: selected, selected, disabled }
|
|
4369
|
+
};
|
|
4370
|
+
};
|
|
4371
|
+
var ROW_GAP7 = 8;
|
|
4372
|
+
var styles32 = reactNative.StyleSheet.create({
|
|
4373
|
+
list: { rowGap: ROW_GAP7 }
|
|
4374
|
+
});
|
|
4375
|
+
function RadioList(props) {
|
|
4376
|
+
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
4377
|
+
const { theme } = uiFeedback.useUi();
|
|
4378
|
+
const colors = React26__default.default.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
4379
|
+
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
4380
|
+
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
4381
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4382
|
+
reactNative.View,
|
|
4383
|
+
{
|
|
4384
|
+
accessibilityRole: "radiogroup",
|
|
4385
|
+
style: styles32.list,
|
|
4386
|
+
...webFieldA11y({ describedById, hasError }),
|
|
4387
|
+
...radio.groupProps,
|
|
4388
|
+
children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4389
|
+
RadioRow,
|
|
4390
|
+
{
|
|
4391
|
+
colors,
|
|
4392
|
+
hostRef: radio.chipRef(index),
|
|
4393
|
+
identity: radioRowIdentity(option, index === selectedIndex, disabled, optionTestIDPrefix),
|
|
4394
|
+
option,
|
|
4395
|
+
tabIndex: radio.tabIndexFor(index),
|
|
4396
|
+
onPress: () => onChange(option.value)
|
|
4397
|
+
},
|
|
4398
|
+
String(option.value)
|
|
4399
|
+
))
|
|
4400
|
+
}
|
|
4401
|
+
) });
|
|
4402
|
+
}
|
|
4403
|
+
|
|
4404
|
+
// src/DecisionPanel/utils/decisionRules.ts
|
|
4405
|
+
var validateDecision = (outcomes, outcome, note) => {
|
|
4406
|
+
const chosen = outcomes.find((item) => item.value === outcome);
|
|
4407
|
+
if (chosen === void 0) return "choose";
|
|
4408
|
+
const noteMissing = chosen.noteRequired === true && note.trim() === "";
|
|
4409
|
+
return noteMissing ? "note" : null;
|
|
4410
|
+
};
|
|
4411
|
+
var defaultDecisionVariant = (width) => isWideFormLayout(width) ? "sticky-bar" : "choose-then-submit";
|
|
4412
|
+
var leadFirst = (outcomes, lead) => [
|
|
4413
|
+
...outcomes.filter((item) => item.value === lead),
|
|
4414
|
+
...outcomes.filter((item) => item.value !== lead)
|
|
4415
|
+
];
|
|
4416
|
+
var toneVariant = (tone) => {
|
|
4417
|
+
if (tone === "primary") return "primary";
|
|
4418
|
+
return tone === "danger" ? "danger" : "secondary";
|
|
4419
|
+
};
|
|
4420
|
+
var NOTE_LINES = 3;
|
|
4421
|
+
function DecisionNote({ state, labels, testID, disabled }) {
|
|
4422
|
+
const error = state.error === "note" ? labels.noteRequiredError : void 0;
|
|
4423
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4424
|
+
FormField,
|
|
4425
|
+
{
|
|
4426
|
+
multiline: true,
|
|
4427
|
+
editable: !disabled,
|
|
4428
|
+
error,
|
|
4429
|
+
label: labels.note,
|
|
4430
|
+
numberOfLines: NOTE_LINES,
|
|
4431
|
+
placeholder: labels.notePlaceholder,
|
|
4432
|
+
testID: `${testID}-note`,
|
|
4433
|
+
value: state.note,
|
|
4434
|
+
onChangeText: state.setNote
|
|
4435
|
+
}
|
|
4436
|
+
);
|
|
4437
|
+
}
|
|
4438
|
+
var BUTTON_BASIS = "40%";
|
|
4439
|
+
var styles33 = reactNative.StyleSheet.create({
|
|
4440
|
+
cell: { flexBasis: BUTTON_BASIS, flexGrow: 1 }
|
|
4441
|
+
});
|
|
4442
|
+
function OutcomeButtons({ outcomes, pending, disabled, testID, onPress }) {
|
|
4443
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: outcomes.map((item) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles33.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4444
|
+
uiButtons.Button,
|
|
4445
|
+
{
|
|
4446
|
+
fullWidth: true,
|
|
4447
|
+
accessibilityHint: item.hint,
|
|
4448
|
+
accessibilityLabel: item.label,
|
|
4449
|
+
disabled: disabled || pending !== null && pending !== item.value,
|
|
4450
|
+
label: item.label,
|
|
4451
|
+
loading: pending === item.value,
|
|
4452
|
+
testID: `${testID}-action-${item.value}`,
|
|
4453
|
+
variant: toneVariant(item.tone),
|
|
4454
|
+
onPress: () => onPress(item.value)
|
|
4455
|
+
}
|
|
4456
|
+
) }, item.value)) });
|
|
4457
|
+
}
|
|
4458
|
+
var retone = (item, lead) => {
|
|
4459
|
+
if (item.value === lead) return { ...item, tone: "primary" };
|
|
4460
|
+
return item.tone === "primary" ? { ...item, tone: "neutral" } : item;
|
|
4461
|
+
};
|
|
4462
|
+
function ChecksDriveDecision(props) {
|
|
4463
|
+
const { state, outcomes, labels, testID, disabled, reasons = [], leadOutcome } = props;
|
|
4464
|
+
const ordered = leadFirst(outcomes, leadOutcome).map((item) => retone(item, leadOutcome));
|
|
4465
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4466
|
+
reasons.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4467
|
+
ChipSelector,
|
|
4468
|
+
{
|
|
4469
|
+
multiple: true,
|
|
4470
|
+
chipTestIDPrefix: `${testID}-reason`,
|
|
4471
|
+
disabled,
|
|
4472
|
+
label: labels.reasons,
|
|
4473
|
+
options: reasons,
|
|
4474
|
+
testID: `${testID}-reasons`,
|
|
4475
|
+
value: state.reasons,
|
|
4476
|
+
variant: "outline",
|
|
4477
|
+
onChange: state.toggleReason
|
|
4478
|
+
}
|
|
4479
|
+
) : null,
|
|
4480
|
+
/* @__PURE__ */ jsxRuntime.jsx(DecisionNote, { ...props }),
|
|
4481
|
+
/* @__PURE__ */ jsxRuntime.jsx(ActionBar, { message: labels.message, testID: `${testID}-bar`, children: /* @__PURE__ */ jsxRuntime.jsx(OutcomeButtons, { disabled, outcomes: ordered, pending: state.pending, testID, onPress: state.submit }) })
|
|
4482
|
+
] });
|
|
4483
|
+
}
|
|
4484
|
+
function ChooseThenSubmitDecision(props) {
|
|
4485
|
+
const { state, outcomes, labels, testID, disabled } = props;
|
|
4486
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4487
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4488
|
+
RadioList,
|
|
4489
|
+
{
|
|
4490
|
+
disabled,
|
|
4491
|
+
error: state.error === "choose" ? labels.chooseError : void 0,
|
|
4492
|
+
optionTestIDPrefix: `${testID}-outcome`,
|
|
4493
|
+
options: outcomes,
|
|
4494
|
+
testID: `${testID}-outcomes`,
|
|
4495
|
+
value: state.outcome === "" ? void 0 : state.outcome,
|
|
4496
|
+
onChange: state.choose
|
|
4497
|
+
}
|
|
4498
|
+
),
|
|
4499
|
+
/* @__PURE__ */ jsxRuntime.jsx(DecisionNote, { ...props }),
|
|
4500
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4501
|
+
uiButtons.Button,
|
|
4502
|
+
{
|
|
4503
|
+
fullWidth: true,
|
|
4504
|
+
accessibilityHint: labels.submitHint,
|
|
4505
|
+
accessibilityLabel: labels.submit,
|
|
4506
|
+
disabled,
|
|
4507
|
+
label: labels.submit,
|
|
4508
|
+
loading: state.pending !== null,
|
|
4509
|
+
testID: `${testID}-submit`,
|
|
4510
|
+
onPress: () => state.submit()
|
|
4511
|
+
}
|
|
4512
|
+
)
|
|
4513
|
+
] });
|
|
4514
|
+
}
|
|
4515
|
+
function StickyBarDecision(props) {
|
|
4516
|
+
const { state, outcomes, labels, testID, disabled } = props;
|
|
4517
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4518
|
+
/* @__PURE__ */ jsxRuntime.jsx(DecisionNote, { ...props }),
|
|
4519
|
+
/* @__PURE__ */ jsxRuntime.jsx(ActionBar, { sticky: true, message: labels.message, testID: `${testID}-bar`, children: /* @__PURE__ */ jsxRuntime.jsx(OutcomeButtons, { disabled, outcomes, pending: state.pending, testID, onPress: state.submit }) })
|
|
4520
|
+
] });
|
|
4521
|
+
}
|
|
4522
|
+
var TEXT_SIZE3 = 13;
|
|
4523
|
+
var TEXT_LINE3 = 18;
|
|
4524
|
+
var styles34 = reactNative.StyleSheet.create({
|
|
4525
|
+
text: { fontSize: TEXT_SIZE3, fontWeight: "700", lineHeight: TEXT_LINE3 }
|
|
4526
|
+
});
|
|
4527
|
+
var SubmitError = ({ message, testID }) => {
|
|
4528
|
+
const { theme } = uiFeedback.useUi();
|
|
4529
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles34.text, { color: fieldErrorInk(theme) }], testID, children: message });
|
|
4530
|
+
};
|
|
4531
|
+
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
4532
|
+
function useDecisionPanel(outcomes, onSubmit) {
|
|
4533
|
+
const [outcome, setOutcome] = React26__default.default.useState("");
|
|
4534
|
+
const [note, setNote] = React26__default.default.useState("");
|
|
4535
|
+
const [reasons, setReasons] = React26__default.default.useState([]);
|
|
4536
|
+
const [checked, setChecked] = React26__default.default.useState([]);
|
|
4537
|
+
const [error, setError] = React26__default.default.useState(null);
|
|
4538
|
+
const [pending, setPending] = React26__default.default.useState(null);
|
|
4539
|
+
const submit = async (override) => {
|
|
4540
|
+
const target = override ?? outcome;
|
|
4541
|
+
const problem = validateDecision(outcomes, target, note);
|
|
4542
|
+
setError(problem);
|
|
4543
|
+
if (problem !== null || target === "") return;
|
|
4544
|
+
setPending(target);
|
|
4545
|
+
try {
|
|
4546
|
+
await onSubmit({ outcome: target, note, reasons });
|
|
4547
|
+
} catch {
|
|
4548
|
+
setError("submit");
|
|
4549
|
+
} finally {
|
|
4550
|
+
setPending(null);
|
|
4551
|
+
}
|
|
4552
|
+
};
|
|
4553
|
+
return {
|
|
4554
|
+
outcome,
|
|
4555
|
+
note,
|
|
4556
|
+
reasons,
|
|
4557
|
+
checked,
|
|
4558
|
+
error,
|
|
4559
|
+
pending,
|
|
4560
|
+
choose: (next) => {
|
|
4561
|
+
setOutcome(next);
|
|
4562
|
+
setError(null);
|
|
4563
|
+
},
|
|
4564
|
+
setNote,
|
|
4565
|
+
toggleReason: (reason) => setReasons((list) => toggle(list, reason)),
|
|
4566
|
+
toggleCheck: (id) => setChecked((list) => toggle(list, id)),
|
|
4567
|
+
submit
|
|
4568
|
+
};
|
|
4569
|
+
}
|
|
4570
|
+
var TITLE_SIZE2 = 15;
|
|
4571
|
+
var PANEL_GAP = 12;
|
|
4572
|
+
var styles35 = reactNative.StyleSheet.create({
|
|
4573
|
+
panel: { rowGap: PANEL_GAP },
|
|
4574
|
+
title: { fontSize: TITLE_SIZE2, fontWeight: "700" }
|
|
4575
|
+
});
|
|
4576
|
+
function renderVariant(variant, props) {
|
|
4577
|
+
if (variant === "sticky-bar") return /* @__PURE__ */ jsxRuntime.jsx(StickyBarDecision, { ...props });
|
|
4578
|
+
if (variant === "checks-drive") return /* @__PURE__ */ jsxRuntime.jsx(ChecksDriveDecision, { ...props });
|
|
4579
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChooseThenSubmitDecision, { ...props });
|
|
4580
|
+
}
|
|
4581
|
+
function DecisionPanel(props) {
|
|
4582
|
+
const { variant, outcomes, onSubmit, labels, testID, reasons, leadOutcome, checklist, disabled = false, style } = props;
|
|
4583
|
+
const { theme } = uiFeedback.useUi();
|
|
4584
|
+
const state = useDecisionPanel(outcomes, onSubmit);
|
|
4585
|
+
const body = (locked) => renderVariant(variant, { state, outcomes, labels, testID, disabled: disabled || locked, reasons, leadOutcome });
|
|
4586
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles35.panel, style], testID, children: [
|
|
4587
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles35.title, { color: theme.colors.text }], children: labels.title }),
|
|
4588
|
+
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),
|
|
4589
|
+
state.error === "submit" ? /* @__PURE__ */ jsxRuntime.jsx(SubmitError, { message: labels.submitError, testID: `${testID}-error` }) : null
|
|
4590
|
+
] });
|
|
4591
|
+
}
|
|
4256
4592
|
|
|
4593
|
+
exports.ActionBar = ActionBar;
|
|
4257
4594
|
exports.AddOnRequest = AddOnRequest;
|
|
4258
4595
|
exports.AlignToControl = AlignToControl;
|
|
4259
4596
|
exports.AnchoredMenu = AnchoredMenu;
|
|
@@ -4272,6 +4609,7 @@ exports.DateField = DateField;
|
|
|
4272
4609
|
exports.DateInput = DateInput;
|
|
4273
4610
|
exports.DateRangeControl = DateRangeControl;
|
|
4274
4611
|
exports.DateTimeField = DateTimeField;
|
|
4612
|
+
exports.DecisionPanel = DecisionPanel;
|
|
4275
4613
|
exports.DropdownPlacement = DropdownPlacement;
|
|
4276
4614
|
exports.FLAG_HEIGHT = FLAG_HEIGHT;
|
|
4277
4615
|
exports.FLAG_WIDTH = FLAG_WIDTH;
|
|
@@ -4287,6 +4625,7 @@ exports.FormSection = FormSection;
|
|
|
4287
4625
|
exports.FormStack = FormStack;
|
|
4288
4626
|
exports.FormStatusLine = FormStatusLine;
|
|
4289
4627
|
exports.FormSwitch = FormSwitch;
|
|
4628
|
+
exports.GatedChecklist = GatedChecklist;
|
|
4290
4629
|
exports.IBAN_MAX_LENGTH = IBAN_MAX_LENGTH;
|
|
4291
4630
|
exports.IBAN_REGISTERED_COUNTRY_COUNT = IBAN_REGISTERED_COUNTRY_COUNT;
|
|
4292
4631
|
exports.INLINE_FIELD_ROW_MIN_WIDTH = INLINE_FIELD_ROW_MIN_WIDTH;
|
|
@@ -4297,6 +4636,7 @@ exports.LINE_ITEMS_WIDE_MIN_WIDTH = LINE_ITEMS_WIDE_MIN_WIDTH;
|
|
|
4297
4636
|
exports.LineItems = LineItems;
|
|
4298
4637
|
exports.PHONE_MAX_WIDTH = PHONE_MAX_WIDTH;
|
|
4299
4638
|
exports.RESPONSIVE_FORM_DEFAULT_BREAKPOINT = RESPONSIVE_FORM_DEFAULT_BREAKPOINT;
|
|
4639
|
+
exports.RadioList = RadioList;
|
|
4300
4640
|
exports.ResponsiveFormLayout = ResponsiveFormLayout;
|
|
4301
4641
|
exports.SearchSelect = SearchSelect;
|
|
4302
4642
|
exports.SelectControl = SelectControl;
|
|
@@ -4307,12 +4647,14 @@ exports.StepperTabs = StepperTabs;
|
|
|
4307
4647
|
exports.ThemedTextInput = ThemedTextInput;
|
|
4308
4648
|
exports.TypeaheadControl = TypeaheadControl;
|
|
4309
4649
|
exports.UploadWithLinkField = UploadWithLinkField;
|
|
4650
|
+
exports.actionBarPosition = actionBarPosition;
|
|
4310
4651
|
exports.buildSearchSelectSections = buildSearchSelectSections;
|
|
4311
4652
|
exports.canRemoveLine = canRemoveLine;
|
|
4312
4653
|
exports.controlStyles = controlStyles;
|
|
4313
4654
|
exports.countryFieldOptions = countryFieldOptions;
|
|
4314
4655
|
exports.countryFlag = countryFlag;
|
|
4315
4656
|
exports.countryOptions = countryOptions;
|
|
4657
|
+
exports.defaultDecisionVariant = defaultDecisionVariant;
|
|
4316
4658
|
exports.draftBic = draftBic;
|
|
4317
4659
|
exports.draftIban = draftIban;
|
|
4318
4660
|
exports.dropdownFrame = dropdownFrame;
|
|
@@ -4326,17 +4668,20 @@ exports.ibanCounter = ibanCounter;
|
|
|
4326
4668
|
exports.ibanLengthFor = ibanLengthFor;
|
|
4327
4669
|
exports.inlineFieldRowLayout = inlineFieldRowLayout;
|
|
4328
4670
|
exports.isAddOnOpen = isAddOnOpen;
|
|
4671
|
+
exports.isChecklistComplete = isChecklistComplete;
|
|
4329
4672
|
exports.isFallbackFlag = isFallbackFlag;
|
|
4330
4673
|
exports.isFixBarVisible = isFixBarVisible;
|
|
4331
4674
|
exports.isLineItemsWide = isLineItemsWide;
|
|
4332
4675
|
exports.isOutside = isOutside;
|
|
4333
4676
|
exports.isUnmatched = isUnmatched;
|
|
4334
4677
|
exports.isWideFormLayout = isWideFormLayout;
|
|
4678
|
+
exports.leadFirst = leadFirst;
|
|
4335
4679
|
exports.lineItemColumnFlex = lineItemColumnFlex;
|
|
4336
4680
|
exports.lineNumberOf = lineNumberOf;
|
|
4337
4681
|
exports.moveHighlight = moveHighlight;
|
|
4338
4682
|
exports.nextHighlight = nextHighlight;
|
|
4339
4683
|
exports.placeDropdown = placeDropdown;
|
|
4684
|
+
exports.radioRowIdentity = radioRowIdentity;
|
|
4340
4685
|
exports.rejectionMessage = rejectionMessage;
|
|
4341
4686
|
exports.resolveGroupSelection = resolveGroupSelection;
|
|
4342
4687
|
exports.resolveSelectMotion = resolveSelectMotion;
|
|
@@ -4354,6 +4699,7 @@ exports.useReducedMotion = useReducedMotion;
|
|
|
4354
4699
|
exports.useSearchSelectState = useSearchSelectState;
|
|
4355
4700
|
exports.useThemedInput = useThemedInput;
|
|
4356
4701
|
exports.validateBic = validateBic;
|
|
4702
|
+
exports.validateDecision = validateDecision;
|
|
4357
4703
|
exports.validateIban = validateIban;
|
|
4358
4704
|
//# sourceMappingURL=index.js.map
|
|
4359
4705
|
//# sourceMappingURL=index.js.map
|