@dloizides/ui-forms 1.52.0 → 1.54.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 +4 -0
- package/dist/index.d.mts +31 -3
- package/dist/index.d.ts +31 -3
- package/dist/index.js +329 -249
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +138 -60
- 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 React40 = 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');
|
|
@@ -9,17 +9,17 @@ var uiButtons = require('@dloizides/ui-buttons');
|
|
|
9
9
|
var reactDom = require('react-dom');
|
|
10
10
|
var a11y = require('@dloizides/a11y');
|
|
11
11
|
var uiIcons = require('@dloizides/ui-icons');
|
|
12
|
-
var apiClientBase = require('@dloizides/api-client-base');
|
|
13
12
|
var Svg = require('react-native-svg');
|
|
13
|
+
var apiClientBase = require('@dloizides/api-client-base');
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var React40__default = /*#__PURE__*/_interopDefault(React40);
|
|
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 (!React40__default.default.isValidElement(child) || child.type === React40__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: React40__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 = React40.useRef(null);
|
|
41
|
+
React40.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 = React40__default.default.createContext(null);
|
|
152
|
+
var GapOwnedContext = React40__default.default.createContext(false);
|
|
153
153
|
var FormGridProvider = FormGridContext.Provider;
|
|
154
154
|
var GapOwnedProvider = GapOwnedContext.Provider;
|
|
155
155
|
function useFormGridMetrics() {
|
|
156
|
-
return
|
|
156
|
+
return React40__default.default.useContext(FormGridContext);
|
|
157
157
|
}
|
|
158
158
|
function useIsGapOwned() {
|
|
159
|
-
return
|
|
159
|
+
return React40__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] = React40__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 = React40__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 = React40__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 = React40.useMemo(() => [styles4.row, { gap }], [gap]);
|
|
367
|
+
const fieldStyle = React40.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] = React40__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] = React40.useState(null);
|
|
807
|
+
React40.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] = React40.useState(null);
|
|
857
|
+
React40.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
|
+
React40.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
|
+
React40.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
|
+
React40.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 = React40__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] = React40.useState(false);
|
|
1018
|
+
const [isHovered, setIsHovered] = React40.useState(false);
|
|
1019
|
+
const handleFocus = React40.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 = React40.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 = React40.useCallback(() => setIsHovered(true), []);
|
|
1034
|
+
const handleHoverOut = React40.useCallback(() => setIsHovered(false), []);
|
|
1035
1035
|
const primary = palette.primary["500"];
|
|
1036
1036
|
const errorColor = fieldErrorInk(theme);
|
|
1037
|
-
const style =
|
|
1037
|
+
const style = React40.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 = React40.useMemo(() => ({ onFocus: handleFocus, onBlur: handleBlur }), [handleFocus, handleBlur]);
|
|
1071
|
+
const hoverBind = React40.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 = React40__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] = React40.useState(() => readRecents(key).slice(0, max));
|
|
1198
|
+
React40.useEffect(() => {
|
|
1199
1199
|
setRecents(readRecents(key).slice(0, max));
|
|
1200
1200
|
}, [key, max]);
|
|
1201
|
-
const remember =
|
|
1201
|
+
const remember = React40.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 = React40.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 = React40.useRef(null);
|
|
1235
|
+
const latestText = React40.useRef(typeof value === "string" ? value : "");
|
|
1236
|
+
const [isOpen, setIsOpen] = React40.useState(false);
|
|
1237
|
+
const handleChange = React40.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 = React40.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 = React40.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 = React40.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 = React40.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] = React40.useState(NARROWEST_INPUT_WIDTH);
|
|
1327
|
+
const onLayout = React40.useCallback((event) => {
|
|
1328
1328
|
setInputWidth(event.nativeEvent.layout.width);
|
|
1329
1329
|
}, []);
|
|
1330
1330
|
return { numberOfLines: rowsForText(text, inputWidth, minRows), onLayout };
|
|
@@ -1508,6 +1508,13 @@ function chipBoxFill(size, backgroundColor) {
|
|
|
1508
1508
|
function restBorderColor(colors, tone) {
|
|
1509
1509
|
return tone === "strong" ? colors.borderStrong : colors.border;
|
|
1510
1510
|
}
|
|
1511
|
+
function outlineRest(colors, look) {
|
|
1512
|
+
if (look.selected) return { backgroundColor: colors.tint, textColor: colors.primary };
|
|
1513
|
+
const surface = look.tone === "surface";
|
|
1514
|
+
const backgroundColor = surface ? colors.surface : colors.muted;
|
|
1515
|
+
if (look.active) return { backgroundColor, textColor: colors.primary };
|
|
1516
|
+
return { backgroundColor, textColor: surface ? colors.textStrong : colors.textMuted };
|
|
1517
|
+
}
|
|
1511
1518
|
var SOLID_RADIUS = 20;
|
|
1512
1519
|
var OUTLINE_RADIUS = 999;
|
|
1513
1520
|
var OUTLINE_PAD_H = 12;
|
|
@@ -1554,7 +1561,7 @@ function ChipContent(props) {
|
|
|
1554
1561
|
}
|
|
1555
1562
|
function OutlineChip(props) {
|
|
1556
1563
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1557
|
-
const [hovered, setHovered] =
|
|
1564
|
+
const [hovered, setHovered] = React40__default.default.useState(false);
|
|
1558
1565
|
const active = selected || hovered;
|
|
1559
1566
|
const borderColor = active ? colors.primary : restBorderColor(colors, props.outlineTone);
|
|
1560
1567
|
const fill = chipFill({
|
|
@@ -1562,7 +1569,7 @@ function OutlineChip(props) {
|
|
|
1562
1569
|
selectedFill: props.selectedFill,
|
|
1563
1570
|
ink: colors.textStrong,
|
|
1564
1571
|
onDarkInk: colors.onPrimary,
|
|
1565
|
-
rest: {
|
|
1572
|
+
rest: outlineRest(colors, { tone: props.outlineTone, selected, active })
|
|
1566
1573
|
});
|
|
1567
1574
|
const sized = chipSizeLook(props.size);
|
|
1568
1575
|
const layout = chipLabelLayout(option.labelWrap);
|
|
@@ -1670,8 +1677,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
|
|
|
1670
1677
|
var NO_GROUP_PROPS = {};
|
|
1671
1678
|
function useRadioKeyboard(config) {
|
|
1672
1679
|
const { enabled, disabled, values, selectedIndex, onChange } = config;
|
|
1673
|
-
const nodes =
|
|
1674
|
-
const chipRef =
|
|
1680
|
+
const nodes = React40__default.default.useRef([]);
|
|
1681
|
+
const chipRef = React40__default.default.useCallback((index) => (node) => {
|
|
1675
1682
|
nodes.current[index] = node;
|
|
1676
1683
|
}, []);
|
|
1677
1684
|
const onKeyDown = (event) => {
|
|
@@ -1730,6 +1737,7 @@ function buildChipColors(colors, palette) {
|
|
|
1730
1737
|
primary,
|
|
1731
1738
|
onPrimary: onBrandInk(palette),
|
|
1732
1739
|
muted: colors.background,
|
|
1740
|
+
surface: colors.surface ?? colors.background,
|
|
1733
1741
|
tint: withAlpha2(primary, OUTLINE_TINT_ALPHA)
|
|
1734
1742
|
};
|
|
1735
1743
|
}
|
|
@@ -1789,7 +1797,7 @@ var ChipSelector = ({
|
|
|
1789
1797
|
const isRadioGroup = !multiple && singleSelectRole === "radio";
|
|
1790
1798
|
const { theme } = uiFeedback.useUi();
|
|
1791
1799
|
const { colors, palette } = theme;
|
|
1792
|
-
const chipColors =
|
|
1800
|
+
const chipColors = React40__default.default.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
|
|
1793
1801
|
function isSelected(optionValue) {
|
|
1794
1802
|
if (multiple && Array.isArray(value))
|
|
1795
1803
|
return value.includes(optionValue);
|
|
@@ -1914,10 +1922,10 @@ var FormSwitchBox = ({
|
|
|
1914
1922
|
}) => {
|
|
1915
1923
|
const { colors } = uiFeedback.useUi().theme;
|
|
1916
1924
|
const { disabled, onValueChange, value } = slot;
|
|
1917
|
-
const toggle2 =
|
|
1925
|
+
const toggle2 = React40__default.default.useCallback(() => {
|
|
1918
1926
|
if (!disabled) onValueChange(!value);
|
|
1919
1927
|
}, [disabled, onValueChange, value]);
|
|
1920
|
-
const boxColors =
|
|
1928
|
+
const boxColors = React40__default.default.useMemo(
|
|
1921
1929
|
() => ({ borderColor: colors.border, backgroundColor: colors.surface }),
|
|
1922
1930
|
[colors.border, colors.surface]
|
|
1923
1931
|
);
|
|
@@ -1971,12 +1979,12 @@ var FormSwitchRow = ({
|
|
|
1971
1979
|
activeTrackColor
|
|
1972
1980
|
}) => {
|
|
1973
1981
|
const { theme } = uiFeedback.useUi();
|
|
1974
|
-
const toggle2 =
|
|
1982
|
+
const toggle2 = React40__default.default.useCallback(() => {
|
|
1975
1983
|
if (!disabled) onValueChange(!value);
|
|
1976
1984
|
}, [disabled, onValueChange, value]);
|
|
1977
1985
|
const { colors } = theme;
|
|
1978
1986
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1979
|
-
const themeStyles =
|
|
1987
|
+
const themeStyles = React40__default.default.useMemo(() => {
|
|
1980
1988
|
const labelStyle = { color: colors.text };
|
|
1981
1989
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1982
1990
|
return { label: labelStyle, description: descriptionStyle };
|
|
@@ -2112,8 +2120,8 @@ var FormCheckbox = ({
|
|
|
2112
2120
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
2113
2121
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
2114
2122
|
const { hintId } = useFieldIds();
|
|
2115
|
-
const [focused, setFocused] =
|
|
2116
|
-
const themeStyles =
|
|
2123
|
+
const [focused, setFocused] = React40__default.default.useState(false);
|
|
2124
|
+
const themeStyles = React40__default.default.useMemo(() => {
|
|
2117
2125
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
2118
2126
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
2119
2127
|
const ring = { borderColor: brand };
|
|
@@ -2170,6 +2178,63 @@ var FormCheckbox = ({
|
|
|
2170
2178
|
}
|
|
2171
2179
|
);
|
|
2172
2180
|
};
|
|
2181
|
+
|
|
2182
|
+
// src/SearchSelect/SelectSurface.ts
|
|
2183
|
+
var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
2184
|
+
SelectSurface2["Sheet"] = "sheet";
|
|
2185
|
+
SelectSurface2["Dropdown"] = "dropdown";
|
|
2186
|
+
return SelectSurface2;
|
|
2187
|
+
})(SelectSurface || {});
|
|
2188
|
+
|
|
2189
|
+
// src/SearchSelect/utils/searchSelectMotion.ts
|
|
2190
|
+
var PHONE_MAX_WIDTH = 600;
|
|
2191
|
+
var SHEET_TRAVEL_PX = 320;
|
|
2192
|
+
var DROPDOWN_TRAVEL_PX = -8;
|
|
2193
|
+
var SHEET_MS = 240;
|
|
2194
|
+
var DROPDOWN_MS = 160;
|
|
2195
|
+
function resolveSelectMotion(width, reducedMotion) {
|
|
2196
|
+
const isPhone = width < PHONE_MAX_WIDTH;
|
|
2197
|
+
const surface = isPhone ? "sheet" /* Sheet */ : "dropdown" /* Dropdown */;
|
|
2198
|
+
if (reducedMotion) return { surface, fromY: 0, durationMs: 0 };
|
|
2199
|
+
return isPhone ? { surface, fromY: SHEET_TRAVEL_PX, durationMs: SHEET_MS } : { surface, fromY: DROPDOWN_TRAVEL_PX, durationMs: DROPDOWN_MS };
|
|
2200
|
+
}
|
|
2201
|
+
var FIELD_DESKTOP_HEIGHT = 38;
|
|
2202
|
+
var FIELD_PHONE_HEIGHT = 44;
|
|
2203
|
+
var FIELD_PAD_H = 10;
|
|
2204
|
+
var FIELD_FONT = 13;
|
|
2205
|
+
var FIELD_RADIUS = 8;
|
|
2206
|
+
var FIELD_CHEVRON_ROOM = 30;
|
|
2207
|
+
var CHEVRON_BOX = 16;
|
|
2208
|
+
var DEFAULT_CONFIG = { look: "default" };
|
|
2209
|
+
var SelectLookContext = React40.createContext(DEFAULT_CONFIG);
|
|
2210
|
+
function SelectLookProvider({ look, borderColor, children }) {
|
|
2211
|
+
const value = React40.useMemo(() => ({ look, borderColor }), [look, borderColor]);
|
|
2212
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectLookContext.Provider, { value, children });
|
|
2213
|
+
}
|
|
2214
|
+
function selectLookMetrics({ look, borderColor }, windowWidth) {
|
|
2215
|
+
if (look === "default") {
|
|
2216
|
+
return void 0;
|
|
2217
|
+
}
|
|
2218
|
+
const isPhone = windowWidth < PHONE_MAX_WIDTH;
|
|
2219
|
+
return {
|
|
2220
|
+
height: isPhone ? FIELD_PHONE_HEIGHT : FIELD_DESKTOP_HEIGHT,
|
|
2221
|
+
paddingHorizontal: FIELD_PAD_H,
|
|
2222
|
+
paddingVertical: 0,
|
|
2223
|
+
fontSize: FIELD_FONT,
|
|
2224
|
+
borderRadius: FIELD_RADIUS,
|
|
2225
|
+
chevronRoom: FIELD_CHEVRON_ROOM,
|
|
2226
|
+
borderColor
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
function useSelectLookMetrics() {
|
|
2230
|
+
const config = React40.useContext(SelectLookContext);
|
|
2231
|
+
const { width } = reactNative.useWindowDimensions();
|
|
2232
|
+
return selectLookMetrics(config, width);
|
|
2233
|
+
}
|
|
2234
|
+
function chevronDataUri(color) {
|
|
2235
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="${color}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l4 4 4-4"/></svg>`;
|
|
2236
|
+
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
2237
|
+
}
|
|
2173
2238
|
var NATIVE_SELECT_BOX = {
|
|
2174
2239
|
borderStyle: "solid",
|
|
2175
2240
|
boxSizing: "border-box",
|
|
@@ -2177,12 +2242,36 @@ var NATIVE_SELECT_BOX = {
|
|
|
2177
2242
|
width: "100%"
|
|
2178
2243
|
};
|
|
2179
2244
|
var FIT_SELECT_BOX = { width: "auto", maxWidth: "none" };
|
|
2245
|
+
var ONE_LINE_BOX = { maxWidth: "100%", minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" };
|
|
2246
|
+
var CHEVRON_INSET = 10;
|
|
2180
2247
|
var fitStyles = reactNative.StyleSheet.create({
|
|
2181
|
-
anchor: { alignSelf: "flex-start", flexShrink: 0 }
|
|
2248
|
+
anchor: { alignSelf: "flex-start", flexShrink: 0 },
|
|
2249
|
+
oneLine: { maxWidth: "100%", minWidth: 0, flexShrink: 1 }
|
|
2182
2250
|
});
|
|
2183
2251
|
function nativeSelectBox(fit) {
|
|
2184
2252
|
return fit ? { ...NATIVE_SELECT_BOX, ...FIT_SELECT_BOX } : NATIVE_SELECT_BOX;
|
|
2185
2253
|
}
|
|
2254
|
+
function lookSelectStyle(fit, m, colors) {
|
|
2255
|
+
return {
|
|
2256
|
+
...nativeSelectBox(fit),
|
|
2257
|
+
...ONE_LINE_BOX,
|
|
2258
|
+
height: m.height,
|
|
2259
|
+
borderWidth: 1,
|
|
2260
|
+
borderRadius: m.borderRadius,
|
|
2261
|
+
fontSize: m.fontSize,
|
|
2262
|
+
paddingBlock: m.paddingVertical,
|
|
2263
|
+
paddingInlineStart: m.paddingHorizontal,
|
|
2264
|
+
paddingInlineEnd: m.chevronRoom,
|
|
2265
|
+
borderColor: m.borderColor ?? colors.border,
|
|
2266
|
+
backgroundColor: colors.background,
|
|
2267
|
+
color: colors.text,
|
|
2268
|
+
appearance: "none",
|
|
2269
|
+
backgroundImage: chevronDataUri(colors.chevron),
|
|
2270
|
+
backgroundRepeat: "no-repeat",
|
|
2271
|
+
backgroundPosition: `right ${String(CHEVRON_INSET)}px center`,
|
|
2272
|
+
backgroundSize: "16px 16px"
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2186
2275
|
function nativeSelectStyle(fit, borderColor, backgroundColor, color) {
|
|
2187
2276
|
const trigger = reactNative.StyleSheet.flatten(controlStyles.selectTrigger);
|
|
2188
2277
|
const text = reactNative.StyleSheet.flatten(controlStyles.selectTriggerText);
|
|
@@ -2216,14 +2305,16 @@ function NativeSelect({
|
|
|
2216
2305
|
const hasMatch = options.some((o) => o.value === value);
|
|
2217
2306
|
const textColor = hasMatch ? colors.text : colors.textSecondary;
|
|
2218
2307
|
const fit = native === "fit";
|
|
2308
|
+
const metrics = useSelectLookMetrics();
|
|
2309
|
+
const selectStyle = metrics === void 0 ? nativeSelectStyle(fit, colors.border, colors.surfaceElevated, textColor) : lookSelectStyle(fit, metrics, { border: colors.border, background: colors.surfaceElevated, text: textColor, chevron: colors.textSecondary });
|
|
2219
2310
|
const handleChange = (event) => onChange(event.target.value);
|
|
2220
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, style], children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2311
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, metrics === void 0 ? void 0 : fitStyles.oneLine, style], children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2221
2312
|
"select",
|
|
2222
2313
|
{
|
|
2223
2314
|
"aria-label": accessibilityLabel,
|
|
2224
2315
|
"aria-labelledby": labelledById,
|
|
2225
2316
|
"data-testid": testID,
|
|
2226
|
-
style:
|
|
2317
|
+
style: selectStyle,
|
|
2227
2318
|
title: accessibilityHint,
|
|
2228
2319
|
value,
|
|
2229
2320
|
onChange: handleChange,
|
|
@@ -2234,6 +2325,9 @@ function NativeSelect({
|
|
|
2234
2325
|
}
|
|
2235
2326
|
) });
|
|
2236
2327
|
}
|
|
2328
|
+
function SelectChevron({ color, open }) {
|
|
2329
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Svg__default.default, { "aria-hidden": true, fill: "none", height: CHEVRON_BOX, stroke: color, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.6, viewBox: "0 0 16 16", width: CHEVRON_BOX, children: /* @__PURE__ */ jsxRuntime.jsx(Svg.Path, { d: open ? "M4 10l4-4 4 4" : "M4 6l4 4 4-4" }) });
|
|
2330
|
+
}
|
|
2237
2331
|
|
|
2238
2332
|
// src/controls/nextHighlight.ts
|
|
2239
2333
|
var NO_HIGHLIGHT = -1;
|
|
@@ -2247,9 +2341,9 @@ function nextHighlight(current, count, delta) {
|
|
|
2247
2341
|
var FORWARD = 1;
|
|
2248
2342
|
var BACKWARD = -1;
|
|
2249
2343
|
function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
2250
|
-
const [row, setRow] =
|
|
2344
|
+
const [row, setRow] = React40.useState(NO_HIGHLIGHT);
|
|
2251
2345
|
const highlighted = isOpen ? options[row] : void 0;
|
|
2252
|
-
|
|
2346
|
+
React40.useEffect(() => {
|
|
2253
2347
|
if (!isOpen) setRow(NO_HIGHLIGHT);
|
|
2254
2348
|
}, [isOpen]);
|
|
2255
2349
|
const onKeyDown = (event) => {
|
|
@@ -2269,6 +2363,9 @@ function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
|
2269
2363
|
var IS_WEB7 = reactNative.Platform.OS === "web";
|
|
2270
2364
|
var CHEVRON_DOWN = "\u25BE";
|
|
2271
2365
|
var CHEVRON_UP = "\u25B4";
|
|
2366
|
+
function lookTriggerBox(m) {
|
|
2367
|
+
return m === void 0 ? void 0 : { minHeight: m.height, height: m.height, paddingHorizontal: m.paddingHorizontal, paddingVertical: m.paddingVertical, borderRadius: m.borderRadius };
|
|
2368
|
+
}
|
|
2272
2369
|
function listboxTriggerAria(testID, hasList, highlighted) {
|
|
2273
2370
|
return {
|
|
2274
2371
|
role: "combobox",
|
|
@@ -2294,28 +2391,29 @@ function MenuSelectControl({
|
|
|
2294
2391
|
}) {
|
|
2295
2392
|
const { theme } = uiFeedback.useUi();
|
|
2296
2393
|
const { colors, palette } = theme;
|
|
2297
|
-
const anchorRef =
|
|
2298
|
-
const [isOpen, setIsOpen] =
|
|
2299
|
-
const selectedLabel =
|
|
2394
|
+
const anchorRef = React40.useRef(null);
|
|
2395
|
+
const [isOpen, setIsOpen] = React40.useState(false);
|
|
2396
|
+
const selectedLabel = React40.useMemo(() => {
|
|
2300
2397
|
const found = options.find((o) => o.value === value);
|
|
2301
2398
|
return found?.label ?? placeholder;
|
|
2302
2399
|
}, [options, placeholder, value]);
|
|
2303
|
-
const close =
|
|
2400
|
+
const close = React40.useCallback(() => {
|
|
2304
2401
|
setIsOpen(false);
|
|
2305
2402
|
}, []);
|
|
2306
|
-
const open =
|
|
2403
|
+
const open = React40.useCallback(() => {
|
|
2307
2404
|
setIsOpen(true);
|
|
2308
2405
|
}, []);
|
|
2309
|
-
const toggle2 =
|
|
2406
|
+
const toggle2 = React40.useCallback(() => {
|
|
2310
2407
|
setIsOpen((prev) => !prev);
|
|
2311
2408
|
}, []);
|
|
2312
|
-
const select =
|
|
2409
|
+
const select = React40.useCallback(
|
|
2313
2410
|
(next) => {
|
|
2314
2411
|
onChange(next);
|
|
2315
2412
|
setIsOpen(false);
|
|
2316
2413
|
},
|
|
2317
2414
|
[onChange]
|
|
2318
2415
|
);
|
|
2416
|
+
const metrics = useSelectLookMetrics();
|
|
2319
2417
|
const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
|
|
2320
2418
|
const isListbox = menuAnchor !== void 0;
|
|
2321
2419
|
const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
|
|
@@ -2334,11 +2432,11 @@ function MenuSelectControl({
|
|
|
2334
2432
|
"aria-labelledby": labelledById,
|
|
2335
2433
|
onBlur: isListbox ? close : void 0,
|
|
2336
2434
|
onPress: toggle2,
|
|
2337
|
-
style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2435
|
+
style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: metrics?.borderColor ?? colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2338
2436
|
testID: `${testID}-trigger`,
|
|
2339
2437
|
children: [
|
|
2340
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: value === "" ? colors.textSecondary : colors.text }], children: selectedLabel }),
|
|
2341
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: isOpen ? CHEVRON_UP : CHEVRON_DOWN })
|
|
2438
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, metrics === void 0 ? void 0 : { fontSize: metrics.fontSize }, { color: value === "" ? colors.textSecondary : colors.text }], children: selectedLabel }),
|
|
2439
|
+
metrics === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: isOpen ? CHEVRON_UP : CHEVRON_DOWN }) : /* @__PURE__ */ jsxRuntime.jsx(SelectChevron, { color: colors.textSecondary, open: isOpen })
|
|
2342
2440
|
]
|
|
2343
2441
|
}
|
|
2344
2442
|
),
|
|
@@ -2452,21 +2550,21 @@ var styles19 = reactNative.StyleSheet.create({
|
|
|
2452
2550
|
function MultiSelectBox(props) {
|
|
2453
2551
|
const { label, accessibilityHint, values, options, onChange, placeholder, chipLabels, testID, labelId } = props;
|
|
2454
2552
|
const { colors, palette } = uiFeedback.useUi().theme;
|
|
2455
|
-
const anchorRef =
|
|
2456
|
-
const [isOpen, setIsOpen] =
|
|
2553
|
+
const anchorRef = React40.useRef(null);
|
|
2554
|
+
const [isOpen, setIsOpen] = React40.useState(false);
|
|
2457
2555
|
const chosen = selectedOptions(options, values);
|
|
2458
2556
|
const remaining = remainingOptions(options, values);
|
|
2459
|
-
const close =
|
|
2557
|
+
const close = React40.useCallback(() => {
|
|
2460
2558
|
setIsOpen(false);
|
|
2461
2559
|
}, []);
|
|
2462
|
-
const toggle2 =
|
|
2560
|
+
const toggle2 = React40.useCallback(() => {
|
|
2463
2561
|
setIsOpen((prev) => !prev);
|
|
2464
2562
|
}, []);
|
|
2465
|
-
const add =
|
|
2563
|
+
const add = React40.useCallback((next) => {
|
|
2466
2564
|
onChange(addValue(values, next));
|
|
2467
2565
|
setIsOpen(false);
|
|
2468
2566
|
}, [onChange, values]);
|
|
2469
|
-
const remove =
|
|
2567
|
+
const remove = React40.useCallback((value) => {
|
|
2470
2568
|
onChange(removeValue(values, value));
|
|
2471
2569
|
}, [onChange, values]);
|
|
2472
2570
|
const chipColors = { text: colors.text, border: colors.border, surface: colors.surface };
|
|
@@ -2524,17 +2622,17 @@ function MultiSelectBox(props) {
|
|
|
2524
2622
|
var MultiSelectField = ({ labelVariant, hint, error, ...boxProps }) => /* @__PURE__ */ jsxRuntime.jsx(Field, { error, hint, label: boxProps.label, labelVariant, children: ({ labelId }) => /* @__PURE__ */ jsxRuntime.jsx(MultiSelectBox, { ...boxProps, labelId }) });
|
|
2525
2623
|
var CLOSE_DELAY_MS2 = 140;
|
|
2526
2624
|
function useDelayedBlurClose(open, close) {
|
|
2527
|
-
const timerRef =
|
|
2528
|
-
const cancelClose =
|
|
2625
|
+
const timerRef = React40.useRef(null);
|
|
2626
|
+
const cancelClose = React40.useCallback(() => {
|
|
2529
2627
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
2530
2628
|
timerRef.current = null;
|
|
2531
2629
|
}, []);
|
|
2532
|
-
|
|
2533
|
-
const handleFocus =
|
|
2630
|
+
React40.useEffect(() => cancelClose, [cancelClose]);
|
|
2631
|
+
const handleFocus = React40.useCallback(() => {
|
|
2534
2632
|
cancelClose();
|
|
2535
2633
|
open();
|
|
2536
2634
|
}, [cancelClose, open]);
|
|
2537
|
-
const handleBlur =
|
|
2635
|
+
const handleBlur = React40.useCallback(() => {
|
|
2538
2636
|
cancelClose();
|
|
2539
2637
|
timerRef.current = setTimeout(close, CLOSE_DELAY_MS2);
|
|
2540
2638
|
}, [cancelClose, close]);
|
|
@@ -2577,10 +2675,10 @@ function isUnmatched(options, text) {
|
|
|
2577
2675
|
var DEFAULT_TYPEAHEAD_DEBOUNCE_MS = 250;
|
|
2578
2676
|
var IDLE = { results: [], isLoading: false, hasFailed: false, hasSettled: false };
|
|
2579
2677
|
function useTypeaheadSearch(load, query, enabled, debounceMs) {
|
|
2580
|
-
const [state, setState] =
|
|
2581
|
-
const loadRef =
|
|
2678
|
+
const [state, setState] = React40.useState(IDLE);
|
|
2679
|
+
const loadRef = React40.useRef(load);
|
|
2582
2680
|
loadRef.current = load;
|
|
2583
|
-
|
|
2681
|
+
React40.useEffect(() => {
|
|
2584
2682
|
if (!enabled) {
|
|
2585
2683
|
setState(IDLE);
|
|
2586
2684
|
return void 0;
|
|
@@ -2619,30 +2717,30 @@ function useTypeaheadRows(input, isOpen, isPicked) {
|
|
|
2619
2717
|
const query = value.trim();
|
|
2620
2718
|
const isSearching = search !== void 0 && isOpen && !isPicked && query.length >= minChars;
|
|
2621
2719
|
const found = useTypeaheadSearch(search?.load, query, isSearching, search?.debounceMs ?? DEFAULT_TYPEAHEAD_DEBOUNCE_MS);
|
|
2622
|
-
const staticRows =
|
|
2720
|
+
const staticRows = React40.useMemo(() => {
|
|
2623
2721
|
if (options === void 0 || options.some((o) => o.label === value)) return NO_ROWS;
|
|
2624
2722
|
return suggestOptions(options, value, minChars, maxSuggestions);
|
|
2625
2723
|
}, [options, value, minChars, maxSuggestions]);
|
|
2626
|
-
const foundRows =
|
|
2724
|
+
const foundRows = React40.useMemo(() => found.results.slice(0, maxSuggestions), [found.results, maxSuggestions]);
|
|
2627
2725
|
if (search === void 0) return { rows: staticRows, statusText: void 0 };
|
|
2628
2726
|
return { rows: foundRows, statusText: searchStatusText(found, search) };
|
|
2629
2727
|
}
|
|
2630
2728
|
function useTypeaheadState(input) {
|
|
2631
2729
|
const { search, value, onChange, onSubmit } = input;
|
|
2632
|
-
const [isOpen, setIsOpen] =
|
|
2633
|
-
const [picked, setPicked] =
|
|
2634
|
-
const [highlightIndex, setHighlightIndex] =
|
|
2730
|
+
const [isOpen, setIsOpen] = React40.useState(false);
|
|
2731
|
+
const [picked, setPicked] = React40.useState(null);
|
|
2732
|
+
const [highlightIndex, setHighlightIndex] = React40.useState(NO_HIGHLIGHT);
|
|
2635
2733
|
const { rows, statusText } = useTypeaheadRows(input, isOpen, picked !== null && picked.label === value);
|
|
2636
2734
|
const rowKey = rows.map((row) => row.value).join("\n");
|
|
2637
2735
|
const highlighted = isOpen ? rows[highlightIndex] : void 0;
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
const open =
|
|
2641
|
-
const close =
|
|
2736
|
+
React40.useEffect(() => setHighlightIndex(NO_HIGHLIGHT), [rowKey]);
|
|
2737
|
+
React40.useEffect(() => setPicked((current) => current !== null && current.label !== value ? null : current), [value]);
|
|
2738
|
+
const open = React40.useCallback(() => setIsOpen(true), []);
|
|
2739
|
+
const close = React40.useCallback(() => {
|
|
2642
2740
|
setIsOpen(false);
|
|
2643
2741
|
setHighlightIndex(NO_HIGHLIGHT);
|
|
2644
2742
|
}, []);
|
|
2645
|
-
const pick =
|
|
2743
|
+
const pick = React40.useCallback(
|
|
2646
2744
|
(option) => {
|
|
2647
2745
|
setPicked(option);
|
|
2648
2746
|
onChange(option.label);
|
|
@@ -2651,14 +2749,14 @@ function useTypeaheadState(input) {
|
|
|
2651
2749
|
},
|
|
2652
2750
|
[onChange, search, close]
|
|
2653
2751
|
);
|
|
2654
|
-
const selectValue =
|
|
2752
|
+
const selectValue = React40.useCallback(
|
|
2655
2753
|
(optionValue) => {
|
|
2656
2754
|
const option = rows.find((row) => row.value === optionValue);
|
|
2657
2755
|
if (option !== void 0) pick(option);
|
|
2658
2756
|
},
|
|
2659
2757
|
[rows, pick]
|
|
2660
2758
|
);
|
|
2661
|
-
const handleChange =
|
|
2759
|
+
const handleChange = React40.useCallback(
|
|
2662
2760
|
(next) => {
|
|
2663
2761
|
if (picked !== null) {
|
|
2664
2762
|
setPicked(null);
|
|
@@ -2671,7 +2769,7 @@ function useTypeaheadState(input) {
|
|
|
2671
2769
|
[picked, search, onChange]
|
|
2672
2770
|
);
|
|
2673
2771
|
const handleKeyPress = useTypeaheadKeys({ rowCount: rows.length, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick });
|
|
2674
|
-
const handleSubmit =
|
|
2772
|
+
const handleSubmit = React40.useCallback(() => {
|
|
2675
2773
|
if (highlighted !== void 0) {
|
|
2676
2774
|
pick(highlighted);
|
|
2677
2775
|
return;
|
|
@@ -2683,7 +2781,7 @@ function useTypeaheadState(input) {
|
|
|
2683
2781
|
}
|
|
2684
2782
|
function useTypeaheadKeys(input) {
|
|
2685
2783
|
const { rowCount, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick } = input;
|
|
2686
|
-
return
|
|
2784
|
+
return React40.useCallback(
|
|
2687
2785
|
(event) => {
|
|
2688
2786
|
const { key } = event.nativeEvent;
|
|
2689
2787
|
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
@@ -2720,7 +2818,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2720
2818
|
const maxSuggestions = ("search" in props ? props.search.maxResults : props.maxSuggestions) ?? DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
|
|
2721
2819
|
const { theme } = uiFeedback.useUi();
|
|
2722
2820
|
const { colors, palette } = theme;
|
|
2723
|
-
const anchorRef =
|
|
2821
|
+
const anchorRef = React40.useRef(null);
|
|
2724
2822
|
const state = useTypeaheadState({ options, search, value, minChars, maxSuggestions, onChange, onSubmit });
|
|
2725
2823
|
const { handleFocus, handleBlur } = useDelayedBlurClose(state.open, state.close);
|
|
2726
2824
|
const showMenu = state.isOpen && (state.rows.length > 0 || state.statusText !== void 0);
|
|
@@ -2773,7 +2871,7 @@ function TypeaheadControlImpl(props, ref) {
|
|
|
2773
2871
|
hasError ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [controlStyles.error, { color: fieldErrorInk(theme) }], testID: `${testID}-error`, children: error }) : null
|
|
2774
2872
|
] });
|
|
2775
2873
|
}
|
|
2776
|
-
var TypeaheadControl =
|
|
2874
|
+
var TypeaheadControl = React40.forwardRef(TypeaheadControlImpl);
|
|
2777
2875
|
var NATIVE_INPUT_BOX = {
|
|
2778
2876
|
borderStyle: "solid",
|
|
2779
2877
|
boxSizing: "border-box",
|
|
@@ -2861,7 +2959,7 @@ function tabStops(container) {
|
|
|
2861
2959
|
}
|
|
2862
2960
|
function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
2863
2961
|
const colors = usePickerColors();
|
|
2864
|
-
const ref =
|
|
2962
|
+
const ref = React40.useRef(null);
|
|
2865
2963
|
const onKeyDown = (event) => {
|
|
2866
2964
|
if (event.key === "Escape") {
|
|
2867
2965
|
event.preventDefault();
|
|
@@ -2884,8 +2982,8 @@ function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
|
2884
2982
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-testid": testID, "data-variant": sheet ? "sheet" : "popover", style, onKeyDown, children });
|
|
2885
2983
|
}
|
|
2886
2984
|
function useAnchorRect2(anchorRef) {
|
|
2887
|
-
const [rect2, setRect] =
|
|
2888
|
-
|
|
2985
|
+
const [rect2, setRect] = React40.useState(null);
|
|
2986
|
+
React40.useEffect(() => {
|
|
2889
2987
|
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2890
2988
|
}, [anchorRef]);
|
|
2891
2989
|
return rect2;
|
|
@@ -2928,8 +3026,8 @@ function fitDropdownWidth(frame, viewportWidth, minWidth = MIN_PANEL_WIDTH) {
|
|
|
2928
3026
|
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children, minWidth, scale, accessibilityLabel, preferBelow = false }) {
|
|
2929
3027
|
const { height: viewportHeight, width: viewportWidth } = reactNative.useWindowDimensions();
|
|
2930
3028
|
const anchor = useAnchorRect2(anchorRef);
|
|
2931
|
-
const [panelHeight, setPanelHeight] =
|
|
2932
|
-
const onLayout =
|
|
3029
|
+
const [panelHeight, setPanelHeight] = React40.useState(0);
|
|
3030
|
+
const onLayout = React40.useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2933
3031
|
const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight, preferBelow), viewportWidth, minWidth);
|
|
2934
3032
|
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2935
3033
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: [
|
|
@@ -2952,8 +3050,8 @@ var styles21 = reactNative.StyleSheet.create({
|
|
|
2952
3050
|
sheet: { width: "100%", alignSelf: "stretch" }
|
|
2953
3051
|
});
|
|
2954
3052
|
function useReducedMotion() {
|
|
2955
|
-
const [reduced, setReduced] =
|
|
2956
|
-
|
|
3053
|
+
const [reduced, setReduced] = React40.useState(false);
|
|
3054
|
+
React40.useEffect(() => {
|
|
2957
3055
|
let active = true;
|
|
2958
3056
|
reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
2959
3057
|
if (active) setReduced(value);
|
|
@@ -3164,14 +3262,14 @@ function weekFirstDay(locale) {
|
|
|
3164
3262
|
return MONDAY3;
|
|
3165
3263
|
}
|
|
3166
3264
|
}
|
|
3167
|
-
var DatePickerContext =
|
|
3265
|
+
var DatePickerContext = React40.createContext({ labels: DEFAULT_DATE_PICKER_LABELS });
|
|
3168
3266
|
function DatePickerProvider({ labels, locale, today, display, children }) {
|
|
3169
|
-
const value =
|
|
3267
|
+
const value = React40.useMemo(() => ({ labels: { ...DEFAULT_DATE_PICKER_LABELS, ...labels }, locale, today, display }), [labels, locale, today, display]);
|
|
3170
3268
|
return /* @__PURE__ */ jsxRuntime.jsx(DatePickerContext.Provider, { value, children });
|
|
3171
3269
|
}
|
|
3172
3270
|
function useDatePickerConfig() {
|
|
3173
|
-
const config =
|
|
3174
|
-
const firstDay =
|
|
3271
|
+
const config = React40.useContext(DatePickerContext);
|
|
3272
|
+
const firstDay = React40.useMemo(() => weekFirstDay(config.locale), [config.locale]);
|
|
3175
3273
|
return { labels: config.labels, locale: config.locale, today: config.today ?? todayIso(), firstDay, display: config.display ?? "long" /* Long */ };
|
|
3176
3274
|
}
|
|
3177
3275
|
|
|
@@ -3194,8 +3292,8 @@ function monthSlideStyle(entered, reduced, direction) {
|
|
|
3194
3292
|
}
|
|
3195
3293
|
function useOpenProgress() {
|
|
3196
3294
|
const { durationMs, fromScale } = resolveOpenMotion(useReducedMotion());
|
|
3197
|
-
const progress =
|
|
3198
|
-
|
|
3295
|
+
const progress = React40.useRef(new reactNative.Animated.Value(0)).current;
|
|
3296
|
+
React40.useEffect(() => {
|
|
3199
3297
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
3200
3298
|
}, [progress, durationMs]);
|
|
3201
3299
|
return {
|
|
@@ -3241,16 +3339,16 @@ function dayDomId(testID, iso) {
|
|
|
3241
3339
|
}
|
|
3242
3340
|
function useGridFocus(initial, bounds, testID, onPick) {
|
|
3243
3341
|
const { firstDay } = useDatePickerConfig();
|
|
3244
|
-
const [focusedDay, setFocusedDay] =
|
|
3245
|
-
const focusPending =
|
|
3342
|
+
const [focusedDay, setFocusedDay] = React40.useState(initial);
|
|
3343
|
+
const focusPending = React40.useRef(true);
|
|
3246
3344
|
const { min, max } = bounds;
|
|
3247
|
-
|
|
3345
|
+
React40.useEffect(() => {
|
|
3248
3346
|
if (!focusPending.current) return;
|
|
3249
3347
|
focusPending.current = false;
|
|
3250
3348
|
document.getElementById(dayDomId(testID, focusedDay))?.focus();
|
|
3251
3349
|
}, [focusedDay, testID]);
|
|
3252
|
-
const moveTo =
|
|
3253
|
-
const onDayKey =
|
|
3350
|
+
const moveTo = React40.useCallback((iso) => setFocusedDay(clampToBounds(iso, min, max)), [min, max]);
|
|
3351
|
+
const onDayKey = React40.useCallback(
|
|
3254
3352
|
(event, iso) => {
|
|
3255
3353
|
if (event.key === "Enter" || event.key === " ") {
|
|
3256
3354
|
event.preventDefault();
|
|
@@ -3337,8 +3435,8 @@ function MonthGrid({ month, selection: selection2, focusedDay, bounds, testID, o
|
|
|
3337
3435
|
const { labels, locale, today, firstDay } = useDatePickerConfig();
|
|
3338
3436
|
const colors = usePickerColors();
|
|
3339
3437
|
const parts = parseIso(month) ?? FALLBACK;
|
|
3340
|
-
const weeks =
|
|
3341
|
-
const weekdays =
|
|
3438
|
+
const weeks = React40.useMemo(() => buildMonthGrid(parts.year, parts.month, firstDay), [parts.year, parts.month, firstDay]);
|
|
3439
|
+
const weekdays = React40.useMemo(() => weekdayNames(locale, firstDay), [locale, firstDay]);
|
|
3342
3440
|
const title = formatMonthYear(month, locale);
|
|
3343
3441
|
const end = selection2.to === "" ? selection2.from : selection2.to;
|
|
3344
3442
|
const stateOf = (iso) => ({
|
|
@@ -3377,7 +3475,7 @@ function MonthHeader({ focusedDay, bounds, testID, onMove }) {
|
|
|
3377
3475
|
const { labels, locale } = useDatePickerConfig();
|
|
3378
3476
|
const colors = usePickerColors();
|
|
3379
3477
|
const parts = parseIso(focusedDay) ?? FALLBACK2;
|
|
3380
|
-
const names =
|
|
3478
|
+
const names = React40.useMemo(() => monthNames(locale), [locale]);
|
|
3381
3479
|
const setMonthYear = (year, month) => onMove(toIso({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) }));
|
|
3382
3480
|
const selectStyle = { minHeight: a11y.MIN_TOUCH_TARGET_PX, border: "none", background: "transparent", color: colors.text, fontWeight: BOLD3, fontSize: FONT2, fontFamily: "inherit", cursor: "pointer" };
|
|
3383
3481
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
@@ -3398,8 +3496,8 @@ function PickerFooter({ summary, children }) {
|
|
|
3398
3496
|
] });
|
|
3399
3497
|
}
|
|
3400
3498
|
function useEntered(key, reduced) {
|
|
3401
|
-
const [enteredKey, setEnteredKey] =
|
|
3402
|
-
|
|
3499
|
+
const [enteredKey, setEnteredKey] = React40.useState(null);
|
|
3500
|
+
React40.useEffect(() => {
|
|
3403
3501
|
if (reduced) return void 0;
|
|
3404
3502
|
let inner = 0;
|
|
3405
3503
|
const outer = requestAnimationFrame(() => {
|
|
@@ -3414,8 +3512,8 @@ function useEntered(key, reduced) {
|
|
|
3414
3512
|
}
|
|
3415
3513
|
function useMonthSlide(month) {
|
|
3416
3514
|
const reduced = useReducedMotion();
|
|
3417
|
-
const previous =
|
|
3418
|
-
const direction =
|
|
3515
|
+
const previous = React40.useRef(month);
|
|
3516
|
+
const direction = React40.useRef(0);
|
|
3419
3517
|
if (previous.current !== month) {
|
|
3420
3518
|
direction.current = month > previous.current ? 1 : -1;
|
|
3421
3519
|
previous.current = month;
|
|
@@ -3425,7 +3523,7 @@ function useMonthSlide(month) {
|
|
|
3425
3523
|
}
|
|
3426
3524
|
function SingleCalendar({ value, bounds, testID, onCommit }) {
|
|
3427
3525
|
const { labels, today } = useDatePickerConfig();
|
|
3428
|
-
const [draft, setDraft] =
|
|
3526
|
+
const [draft, setDraft] = React40.useState(value);
|
|
3429
3527
|
const grid = useGridFocus(clampToBounds(value !== "" ? value : today, bounds.min, bounds.max), bounds, testID, setDraft);
|
|
3430
3528
|
const month = monthStart(grid.focusedDay);
|
|
3431
3529
|
const motion = useMonthSlide(month);
|
|
@@ -3446,8 +3544,8 @@ function useIsPhone() {
|
|
|
3446
3544
|
return !isWideFormLayout(reactNative.useWindowDimensions().width);
|
|
3447
3545
|
}
|
|
3448
3546
|
function useReturnFocus(open, target) {
|
|
3449
|
-
const wasOpen =
|
|
3450
|
-
|
|
3547
|
+
const wasOpen = React40.useRef(open);
|
|
3548
|
+
React40.useEffect(() => {
|
|
3451
3549
|
const closed = wasOpen.current && !open;
|
|
3452
3550
|
wasOpen.current = open;
|
|
3453
3551
|
if (!closed) return void 0;
|
|
@@ -3457,9 +3555,9 @@ function useReturnFocus(open, target) {
|
|
|
3457
3555
|
}
|
|
3458
3556
|
function useTypedDate({ value, onChange, bounds, format, onError, rangeMessage, editOnType = false }) {
|
|
3459
3557
|
const { labels, locale } = useDatePickerConfig();
|
|
3460
|
-
const [editing, setEditing] =
|
|
3461
|
-
const [text, setText] =
|
|
3462
|
-
|
|
3558
|
+
const [editing, setEditing] = React40.useState(false);
|
|
3559
|
+
const [text, setText] = React40.useState("");
|
|
3560
|
+
React40.useEffect(() => {
|
|
3463
3561
|
setText((current) => {
|
|
3464
3562
|
const parsed = current.trim() === "" ? "" : parseTyped(current, locale);
|
|
3465
3563
|
if (parsed === null || parsed === value) return current;
|
|
@@ -3579,16 +3677,16 @@ function DatePickerInput({ fieldProps, context, onTypedError }) {
|
|
|
3579
3677
|
const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
|
|
3580
3678
|
const { labels, display } = useDatePickerConfig();
|
|
3581
3679
|
const phone = useIsPhone();
|
|
3582
|
-
const [open, setOpen] =
|
|
3583
|
-
const anchorRef =
|
|
3584
|
-
const inputRef =
|
|
3680
|
+
const [open, setOpen] = React40.useState(false);
|
|
3681
|
+
const anchorRef = React40.useRef(null);
|
|
3682
|
+
const inputRef = React40.useRef(null);
|
|
3585
3683
|
const bounds = { min, max };
|
|
3586
3684
|
const typed = useTypedDate({ value, onChange, bounds, format: displayFormatter(display), onError: onTypedError, editOnType: true });
|
|
3587
3685
|
const edit = typedEditBind(typed);
|
|
3588
3686
|
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
|
|
3589
3687
|
const focus = focusBind;
|
|
3590
3688
|
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError, required });
|
|
3591
|
-
const close =
|
|
3689
|
+
const close = React40.useCallback(() => setOpen(false), []);
|
|
3592
3690
|
useReturnFocus(open, inputRef);
|
|
3593
3691
|
const commit = (iso) => {
|
|
3594
3692
|
onTypedError?.(void 0);
|
|
@@ -3664,7 +3762,7 @@ function TemporalInput({ fieldProps, context, webInputType, onTypedError }) {
|
|
|
3664
3762
|
}
|
|
3665
3763
|
function TemporalField({ fieldProps, webInputType }) {
|
|
3666
3764
|
const { label, required, hint, error } = fieldProps;
|
|
3667
|
-
const [typedError, setTypedError] =
|
|
3765
|
+
const [typedError, setTypedError] = React40.useState(void 0);
|
|
3668
3766
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error: error ?? typedError, hint, label, required, children: (context) => /* @__PURE__ */ jsxRuntime.jsx(TemporalInput, { context, fieldProps, webInputType, onTypedError: setTypedError }) });
|
|
3669
3767
|
}
|
|
3670
3768
|
function DateField(props) {
|
|
@@ -3793,17 +3891,17 @@ function useRangeSummary(draft) {
|
|
|
3793
3891
|
}
|
|
3794
3892
|
function RangeCalendar({ value, bounds, phone, testID, onApply, onCancel }) {
|
|
3795
3893
|
const { labels, today } = useDatePickerConfig();
|
|
3796
|
-
const [draft, setDraft] =
|
|
3894
|
+
const [draft, setDraft] = React40.useState(value);
|
|
3797
3895
|
const initialDay = clampToBounds(value.from !== "" ? value.from : today, bounds.min, bounds.max);
|
|
3798
|
-
const pickDraft =
|
|
3896
|
+
const pickDraft = React40.useCallback((iso) => setDraft((current) => pickRangeDay(current, iso)), []);
|
|
3799
3897
|
const focus = useGridFocus(initialDay, bounds, testID, pickDraft);
|
|
3800
3898
|
const visible = phone ? PHONE_MONTHS : DESKTOP_MONTHS;
|
|
3801
|
-
const [first, setFirst] =
|
|
3899
|
+
const [first, setFirst] = React40.useState(() => monthStart(phone ? initialDay : addMonths(initialDay, 1 - DESKTOP_MONTHS)));
|
|
3802
3900
|
const focusMonth = monthStart(focus.focusedDay);
|
|
3803
3901
|
const last = addMonths(first, visible - 1);
|
|
3804
3902
|
const motion = useMonthSlide(first);
|
|
3805
3903
|
const summary = useRangeSummary(draft);
|
|
3806
|
-
|
|
3904
|
+
React40.useEffect(() => {
|
|
3807
3905
|
if (focusMonth < first) setFirst(focusMonth);
|
|
3808
3906
|
else if (focusMonth > last) setFirst(addMonths(focusMonth, 1 - visible));
|
|
3809
3907
|
}, [focusMonth, first, last, visible]);
|
|
@@ -3852,18 +3950,18 @@ function orNone(value) {
|
|
|
3852
3950
|
function WebDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, testID, context, onTypedError }) {
|
|
3853
3951
|
const { labels } = useDatePickerConfig();
|
|
3854
3952
|
const phone = useIsPhone();
|
|
3855
|
-
const [open, setOpen] =
|
|
3856
|
-
const [fromError, setFromError] =
|
|
3857
|
-
const [toError, setToError] =
|
|
3858
|
-
const anchorRef =
|
|
3859
|
-
const fromRef =
|
|
3953
|
+
const [open, setOpen] = React40.useState(false);
|
|
3954
|
+
const [fromError, setFromError] = React40.useState(void 0);
|
|
3955
|
+
const [toError, setToError] = React40.useState(void 0);
|
|
3956
|
+
const anchorRef = React40.useRef(null);
|
|
3957
|
+
const fromRef = React40.useRef(null);
|
|
3860
3958
|
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 });
|
|
3861
3959
|
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 });
|
|
3862
3960
|
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: true });
|
|
3863
3961
|
const focus = focusBind;
|
|
3864
3962
|
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError });
|
|
3865
|
-
|
|
3866
|
-
const close =
|
|
3963
|
+
React40.useEffect(() => onTypedError(fromError ?? toError), [fromError, toError, onTypedError]);
|
|
3964
|
+
const close = React40.useCallback(() => setOpen(false), []);
|
|
3867
3965
|
useReturnFocus(open, fromRef);
|
|
3868
3966
|
const onKeyDown = (event) => {
|
|
3869
3967
|
if (event.key === "ArrowDown" && event.altKey) {
|
|
@@ -3947,7 +4045,7 @@ function DateRangeControl({
|
|
|
3947
4045
|
}) {
|
|
3948
4046
|
const hint = accessibilityHint ?? `${fromLabel} \u2013 ${toLabel}`;
|
|
3949
4047
|
const { labels } = useDatePickerConfig();
|
|
3950
|
-
const [typedError, setTypedError] =
|
|
4048
|
+
const [typedError, setTypedError] = React40.useState(void 0);
|
|
3951
4049
|
if (!IS_WEB9) {
|
|
3952
4050
|
return /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(NativeDateRange, { fromLabel, hint, style, testID, toLabel, value, onChange, onSubmit }) });
|
|
3953
4051
|
}
|
|
@@ -4115,9 +4213,9 @@ function FormStatusLine({ message, testID, style }) {
|
|
|
4115
4213
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles24.line, { color: theme.colors.text }, style], testID, children: message });
|
|
4116
4214
|
}
|
|
4117
4215
|
function useFocusFirstInvalid(refs) {
|
|
4118
|
-
const latest =
|
|
4216
|
+
const latest = React40.useRef(refs);
|
|
4119
4217
|
latest.current = refs;
|
|
4120
|
-
return
|
|
4218
|
+
return React40.useCallback((invalid) => {
|
|
4121
4219
|
const first = invalid.map((field2) => latest.current[field2].current).find((node) => node !== null);
|
|
4122
4220
|
first?.focus();
|
|
4123
4221
|
}, []);
|
|
@@ -4168,10 +4266,10 @@ function withoutField(state, field2) {
|
|
|
4168
4266
|
}
|
|
4169
4267
|
function useServerFieldErrors(options) {
|
|
4170
4268
|
const { fields, refs, formatCode } = options;
|
|
4171
|
-
const [state, setState] =
|
|
4269
|
+
const [state, setState] = React40.useState(EMPTY_STATE);
|
|
4172
4270
|
const focusFirst = useFocusFirstInvalid(refs ?? NO_REFS);
|
|
4173
4271
|
const hasRefs = refs !== void 0;
|
|
4174
|
-
const apply =
|
|
4272
|
+
const apply = React40.useCallback(
|
|
4175
4273
|
(error) => {
|
|
4176
4274
|
const assigned = assignServerErrors(apiClientBase.parseFieldErrors(error), fields, formatCode);
|
|
4177
4275
|
setState({ byField: assigned.byField, formError: assigned.formError });
|
|
@@ -4182,17 +4280,17 @@ function useServerFieldErrors(options) {
|
|
|
4182
4280
|
},
|
|
4183
4281
|
[fields, formatCode, focusFirst, hasRefs]
|
|
4184
4282
|
);
|
|
4185
|
-
const clear =
|
|
4186
|
-
const reset =
|
|
4187
|
-
const errorFor =
|
|
4283
|
+
const clear = React40.useCallback((field2) => setState((current) => withoutField(current, field2)), []);
|
|
4284
|
+
const reset = React40.useCallback(() => setState(EMPTY_STATE), []);
|
|
4285
|
+
const errorFor = React40.useCallback((field2) => state.byField[field2], [state.byField]);
|
|
4188
4286
|
return { errorFor, apply, clear, formError: state.formError, reset };
|
|
4189
4287
|
}
|
|
4190
4288
|
function isScrollable(node) {
|
|
4191
4289
|
return "scrollIntoView" in Object(node);
|
|
4192
4290
|
}
|
|
4193
4291
|
function useKeepInView(trigger) {
|
|
4194
|
-
const ref =
|
|
4195
|
-
|
|
4292
|
+
const ref = React40.useRef(null);
|
|
4293
|
+
React40.useEffect(() => {
|
|
4196
4294
|
const node = ref.current;
|
|
4197
4295
|
const hasTrigger = trigger !== void 0 && trigger !== null;
|
|
4198
4296
|
if (hasTrigger && isScrollable(node)) node.scrollIntoView({ block: "nearest" });
|
|
@@ -4282,7 +4380,7 @@ var UploadWithLinkField = ({
|
|
|
4282
4380
|
const { theme } = uiFeedback.useUi();
|
|
4283
4381
|
const ring = uiButtons.useFocusRing();
|
|
4284
4382
|
const url = value ?? "";
|
|
4285
|
-
const [pasting, setPasting] =
|
|
4383
|
+
const [pasting, setPasting] = React40.useState(url !== "");
|
|
4286
4384
|
const previewBox = { borderRadius: PREVIEW_RADIUS, height: previewSize, width: previewSize };
|
|
4287
4385
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles26.root, children: [
|
|
4288
4386
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles26.title, { color: theme.colors.text }], children: labels.title }),
|
|
@@ -4340,7 +4438,7 @@ var AddOnRequest = ({
|
|
|
4340
4438
|
disabled = false,
|
|
4341
4439
|
style
|
|
4342
4440
|
}) => {
|
|
4343
|
-
const [requested, setRequested] =
|
|
4441
|
+
const [requested, setRequested] = React40.useState(false);
|
|
4344
4442
|
const remove = () => {
|
|
4345
4443
|
setRequested(false);
|
|
4346
4444
|
onRemove();
|
|
@@ -4400,13 +4498,6 @@ var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) =>
|
|
|
4400
4498
|
)
|
|
4401
4499
|
] });
|
|
4402
4500
|
};
|
|
4403
|
-
|
|
4404
|
-
// src/SearchSelect/SelectSurface.ts
|
|
4405
|
-
var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
4406
|
-
SelectSurface2["Sheet"] = "sheet";
|
|
4407
|
-
SelectSurface2["Dropdown"] = "dropdown";
|
|
4408
|
-
return SelectSurface2;
|
|
4409
|
-
})(SelectSurface || {});
|
|
4410
4501
|
var ROW_PAD_H = 12;
|
|
4411
4502
|
var ROW_GAP4 = 8;
|
|
4412
4503
|
var OPTION_FONT2 = 14;
|
|
@@ -4466,23 +4557,23 @@ var SHEET_MAX_HEIGHT2 = 480;
|
|
|
4466
4557
|
function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
|
|
4467
4558
|
const { theme } = uiFeedback.useUi();
|
|
4468
4559
|
const { colors } = theme;
|
|
4469
|
-
const progress =
|
|
4560
|
+
const progress = React40.useRef(new reactNative.Animated.Value(0)).current;
|
|
4470
4561
|
const { durationMs } = motion;
|
|
4471
|
-
|
|
4562
|
+
React40.useEffect(() => {
|
|
4472
4563
|
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
4473
4564
|
}, [progress, durationMs]);
|
|
4474
|
-
const leaving =
|
|
4475
|
-
const leave =
|
|
4565
|
+
const leaving = React40.useRef(false);
|
|
4566
|
+
const leave = React40.useCallback((after) => {
|
|
4476
4567
|
if (leaving.current) return;
|
|
4477
4568
|
leaving.current = true;
|
|
4478
4569
|
if (durationMs === 0) return after();
|
|
4479
4570
|
reactNative.Animated.timing(progress, { toValue: 0, duration: durationMs, useNativeDriver: false }).start(() => after());
|
|
4480
4571
|
}, [progress, durationMs]);
|
|
4481
4572
|
const { close, pick: pickNow, submit: submitNow, onKey, sections, highlight } = state;
|
|
4482
|
-
const dismiss =
|
|
4483
|
-
const pick =
|
|
4484
|
-
const submit =
|
|
4485
|
-
const onKeyPress =
|
|
4573
|
+
const dismiss = React40.useCallback(() => leave(close), [leave, close]);
|
|
4574
|
+
const pick = React40.useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
|
|
4575
|
+
const submit = React40.useCallback(() => submitNow(pick), [submitNow, pick]);
|
|
4576
|
+
const onKeyPress = React40.useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
|
|
4486
4577
|
const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [motion.fromY, 0] });
|
|
4487
4578
|
const isSheet = motion.surface === "sheet" /* Sheet */;
|
|
4488
4579
|
const shared = { selectedValue, renderLeading, renderDetail, onPick: pick, optionHint: labels.optionHint, testID, highlight };
|
|
@@ -4519,8 +4610,8 @@ var styles31 = reactNative.StyleSheet.create({
|
|
|
4519
4610
|
empty: { padding: PANEL_PAD }
|
|
4520
4611
|
});
|
|
4521
4612
|
function useRefocusOnClose(open, ref) {
|
|
4522
|
-
const wasOpen =
|
|
4523
|
-
|
|
4613
|
+
const wasOpen = React40.useRef(false);
|
|
4614
|
+
React40.useEffect(() => {
|
|
4524
4615
|
if (wasOpen.current && !open) ref.current?.focus();
|
|
4525
4616
|
wasOpen.current = open;
|
|
4526
4617
|
}, [open, ref]);
|
|
@@ -4553,53 +4644,40 @@ var KEY_DOWN = "ArrowDown";
|
|
|
4553
4644
|
var KEY_UP = "ArrowUp";
|
|
4554
4645
|
var KEY_ESCAPE2 = "Escape";
|
|
4555
4646
|
function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
4556
|
-
const [open, setOpen] =
|
|
4557
|
-
const [query, setQueryState] =
|
|
4558
|
-
const [rawHighlight, setHighlight] =
|
|
4559
|
-
const sections =
|
|
4647
|
+
const [open, setOpen] = React40.useState(false);
|
|
4648
|
+
const [query, setQueryState] = React40.useState("");
|
|
4649
|
+
const [rawHighlight, setHighlight] = React40.useState(-1);
|
|
4650
|
+
const sections = React40.useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
|
|
4560
4651
|
const highlight = rawHighlight < sections.flat.length ? rawHighlight : -1;
|
|
4561
4652
|
const active = sections.flat[highlight];
|
|
4562
4653
|
const { remember } = recents;
|
|
4563
|
-
const close =
|
|
4654
|
+
const close = React40.useCallback(() => {
|
|
4564
4655
|
setOpen(false);
|
|
4565
4656
|
setQueryState("");
|
|
4566
4657
|
setHighlight(-1);
|
|
4567
4658
|
onClosed();
|
|
4568
4659
|
}, [onClosed]);
|
|
4569
|
-
const pick =
|
|
4660
|
+
const pick = React40.useCallback((option) => {
|
|
4570
4661
|
remember(option.value);
|
|
4571
4662
|
onChange(option.value);
|
|
4572
4663
|
close();
|
|
4573
4664
|
}, [remember, onChange, close]);
|
|
4574
|
-
const submit =
|
|
4665
|
+
const submit = React40.useCallback((via = pick) => {
|
|
4575
4666
|
if (active !== void 0) via(active);
|
|
4576
4667
|
}, [active, pick]);
|
|
4577
|
-
const setQuery =
|
|
4668
|
+
const setQuery = React40.useCallback((next) => {
|
|
4578
4669
|
setQueryState(next);
|
|
4579
4670
|
setHighlight(highlightAfterQuery(next));
|
|
4580
4671
|
}, []);
|
|
4581
|
-
const onKey =
|
|
4672
|
+
const onKey = React40.useCallback((key) => {
|
|
4582
4673
|
const count = sections.flat.length;
|
|
4583
4674
|
if (key === KEY_DOWN) setHighlight(moveHighlight(highlight, count, 1));
|
|
4584
4675
|
if (key === KEY_UP) setHighlight(moveHighlight(highlight, count, -1));
|
|
4585
4676
|
if (key === KEY_ESCAPE2) close();
|
|
4586
4677
|
}, [sections.flat.length, highlight, close]);
|
|
4587
|
-
const openList =
|
|
4678
|
+
const openList = React40.useCallback(() => setOpen(true), []);
|
|
4588
4679
|
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
4589
4680
|
}
|
|
4590
|
-
|
|
4591
|
-
// src/SearchSelect/utils/searchSelectMotion.ts
|
|
4592
|
-
var PHONE_MAX_WIDTH = 600;
|
|
4593
|
-
var SHEET_TRAVEL_PX = 320;
|
|
4594
|
-
var DROPDOWN_TRAVEL_PX = -8;
|
|
4595
|
-
var SHEET_MS = 240;
|
|
4596
|
-
var DROPDOWN_MS = 160;
|
|
4597
|
-
function resolveSelectMotion(width, reducedMotion) {
|
|
4598
|
-
const isPhone = width < PHONE_MAX_WIDTH;
|
|
4599
|
-
const surface = isPhone ? "sheet" /* Sheet */ : "dropdown" /* Dropdown */;
|
|
4600
|
-
if (reducedMotion) return { surface, fromY: 0, durationMs: 0 };
|
|
4601
|
-
return isPhone ? { surface, fromY: SHEET_TRAVEL_PX, durationMs: SHEET_MS } : { surface, fromY: DROPDOWN_TRAVEL_PX, durationMs: DROPDOWN_MS };
|
|
4602
|
-
}
|
|
4603
4681
|
var CHEVRON = "\u25BE";
|
|
4604
4682
|
var VALUE_GAP = 8;
|
|
4605
4683
|
var MIN_TOUCH = 44;
|
|
@@ -4608,8 +4686,8 @@ function SearchSelect(props) {
|
|
|
4608
4686
|
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger, onBlur } = props;
|
|
4609
4687
|
const { theme } = uiFeedback.useUi();
|
|
4610
4688
|
const { colors } = theme;
|
|
4611
|
-
const triggerRef =
|
|
4612
|
-
const anchorRef =
|
|
4689
|
+
const triggerRef = React40.useRef(null);
|
|
4690
|
+
const anchorRef = React40.useRef(null);
|
|
4613
4691
|
const { width } = reactNative.useWindowDimensions();
|
|
4614
4692
|
const motion = resolveSelectMotion(width, useReducedMotion());
|
|
4615
4693
|
const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
|
|
@@ -4617,9 +4695,9 @@ function SearchSelect(props) {
|
|
|
4617
4695
|
useRefocusOnClose(state.open, triggerRef);
|
|
4618
4696
|
const selected = findOption(options, value);
|
|
4619
4697
|
const onPress = state.open ? state.close : state.openList;
|
|
4620
|
-
const openRef =
|
|
4698
|
+
const openRef = React40.useRef(state.open);
|
|
4621
4699
|
openRef.current = state.open;
|
|
4622
|
-
const onTriggerBlur =
|
|
4700
|
+
const onTriggerBlur = React40.useCallback(() => {
|
|
4623
4701
|
if (!openRef.current) onBlur?.();
|
|
4624
4702
|
}, [onBlur]);
|
|
4625
4703
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles32.anchor, children: [
|
|
@@ -4669,7 +4747,7 @@ function isOutside(container, target) {
|
|
|
4669
4747
|
return !(target instanceof Node && container.contains(target));
|
|
4670
4748
|
}
|
|
4671
4749
|
function useOutsidePress(ref, onOutside) {
|
|
4672
|
-
|
|
4750
|
+
React40.useEffect(() => {
|
|
4673
4751
|
if (reactNative.Platform.OS !== "web" || typeof document === "undefined") return void 0;
|
|
4674
4752
|
const onPointerDown = (event) => {
|
|
4675
4753
|
if (isOutside(ref.current, event.target)) onOutside();
|
|
@@ -4680,7 +4758,7 @@ function useOutsidePress(ref, onOutside) {
|
|
|
4680
4758
|
}
|
|
4681
4759
|
var AFTER_SURFACE_UNMOUNT_MS = 0;
|
|
4682
4760
|
function useDeferredFocus(ref) {
|
|
4683
|
-
return
|
|
4761
|
+
return React40.useCallback(() => {
|
|
4684
4762
|
setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
|
|
4685
4763
|
}, [ref]);
|
|
4686
4764
|
}
|
|
@@ -5432,8 +5510,8 @@ var renderFlag = (option) => option.value === NO_COUNTRY2 ? null : /* @__PURE__
|
|
|
5432
5510
|
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }) {
|
|
5433
5511
|
const { theme } = uiFeedback.useUi();
|
|
5434
5512
|
const { textSecondary } = theme.colors;
|
|
5435
|
-
const options =
|
|
5436
|
-
const renderCode =
|
|
5513
|
+
const options = React40.useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
|
|
5514
|
+
const renderCode = React40.useCallback((option) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles33.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
|
|
5437
5515
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5438
5516
|
SearchSelect,
|
|
5439
5517
|
{
|
|
@@ -5455,9 +5533,9 @@ var styles33 = reactNative.StyleSheet.create({
|
|
|
5455
5533
|
code: { fontSize: CODE_FONT }
|
|
5456
5534
|
});
|
|
5457
5535
|
function useBlurVerdict(validate) {
|
|
5458
|
-
const [verdict, setVerdict] =
|
|
5459
|
-
const onEdit =
|
|
5460
|
-
const onLeave =
|
|
5536
|
+
const [verdict, setVerdict] = React40.useState(null);
|
|
5537
|
+
const onEdit = React40.useCallback(() => setVerdict(null), []);
|
|
5538
|
+
const onLeave = React40.useCallback(() => {
|
|
5461
5539
|
const next = validate();
|
|
5462
5540
|
setVerdict(next);
|
|
5463
5541
|
return next;
|
|
@@ -5611,11 +5689,11 @@ function rawCaretAfterChange(previous, previousCaret, next) {
|
|
|
5611
5689
|
|
|
5612
5690
|
// src/IbanInput/hooks/useIbanCaret.ts
|
|
5613
5691
|
function useIbanCaret(display) {
|
|
5614
|
-
const [selection2, setSelection] =
|
|
5615
|
-
const onSelectionChange =
|
|
5692
|
+
const [selection2, setSelection] = React40.useState({ start: display.length, end: display.length });
|
|
5693
|
+
const onSelectionChange = React40.useCallback((event) => {
|
|
5616
5694
|
setSelection(event.nativeEvent.selection);
|
|
5617
5695
|
}, []);
|
|
5618
|
-
const placeAfterEdit =
|
|
5696
|
+
const placeAfterEdit = React40.useCallback((text) => {
|
|
5619
5697
|
const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection2.end, text));
|
|
5620
5698
|
setSelection({ start: caret, end: caret });
|
|
5621
5699
|
}, [display, selection2.end]);
|
|
@@ -5721,19 +5799,19 @@ function rejectionMessage(rejection, none, labels) {
|
|
|
5721
5799
|
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
5722
5800
|
const { theme } = uiFeedback.useUi();
|
|
5723
5801
|
const { colors } = theme;
|
|
5724
|
-
const draft =
|
|
5725
|
-
const validate =
|
|
5802
|
+
const draft = React40.useMemo(() => draftIban(value), [value]);
|
|
5803
|
+
const validate = React40.useCallback(() => validateIban(value), [value]);
|
|
5726
5804
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5727
5805
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5728
5806
|
const counter = ibanCounter(draft);
|
|
5729
5807
|
const { selection: selection2, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
5730
|
-
const onChangeText =
|
|
5808
|
+
const onChangeText = React40.useCallback((text) => {
|
|
5731
5809
|
onEdit();
|
|
5732
5810
|
onVerdict?.(null);
|
|
5733
5811
|
placeAfterEdit(text);
|
|
5734
5812
|
onChange(draftIban(text).electronic);
|
|
5735
5813
|
}, [onEdit, onVerdict, placeAfterEdit, onChange]);
|
|
5736
|
-
const onBlur =
|
|
5814
|
+
const onBlur = React40.useCallback(() => {
|
|
5737
5815
|
const verdict2 = onLeave();
|
|
5738
5816
|
onVerdict?.(value === "" ? null : verdict2);
|
|
5739
5817
|
onLeft?.();
|
|
@@ -5808,16 +5886,16 @@ function validateBic(raw) {
|
|
|
5808
5886
|
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
5809
5887
|
const { theme } = uiFeedback.useUi();
|
|
5810
5888
|
const { colors } = theme;
|
|
5811
|
-
const draft =
|
|
5812
|
-
const validate =
|
|
5889
|
+
const draft = React40.useMemo(() => draftBic(value), [value]);
|
|
5890
|
+
const validate = React40.useCallback(() => validateBic(value), [value]);
|
|
5813
5891
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5814
5892
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5815
|
-
const onChangeText =
|
|
5893
|
+
const onChangeText = React40.useCallback((text) => {
|
|
5816
5894
|
onEdit();
|
|
5817
5895
|
onVerdict?.(null);
|
|
5818
5896
|
onChange(draftBic(text).value);
|
|
5819
5897
|
}, [onEdit, onVerdict, onChange]);
|
|
5820
|
-
const onBlur =
|
|
5898
|
+
const onBlur = React40.useCallback(() => {
|
|
5821
5899
|
const verdict2 = onLeave();
|
|
5822
5900
|
onVerdict?.(value === "" ? null : verdict2);
|
|
5823
5901
|
onLeft?.();
|
|
@@ -5973,7 +6051,7 @@ var styles38 = reactNative.StyleSheet.create({
|
|
|
5973
6051
|
function RadioList(props) {
|
|
5974
6052
|
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
5975
6053
|
const { theme } = uiFeedback.useUi();
|
|
5976
|
-
const colors =
|
|
6054
|
+
const colors = React40__default.default.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
5977
6055
|
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
5978
6056
|
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
5979
6057
|
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6128,12 +6206,12 @@ var SubmitError = ({ message, testID }) => {
|
|
|
6128
6206
|
};
|
|
6129
6207
|
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
6130
6208
|
function useDecisionPanel(outcomes, onSubmit) {
|
|
6131
|
-
const [outcome, setOutcome] =
|
|
6132
|
-
const [note, setNote] =
|
|
6133
|
-
const [reasons, setReasons] =
|
|
6134
|
-
const [checked, setChecked] =
|
|
6135
|
-
const [error, setError] =
|
|
6136
|
-
const [pending, setPending] =
|
|
6209
|
+
const [outcome, setOutcome] = React40__default.default.useState("");
|
|
6210
|
+
const [note, setNote] = React40__default.default.useState("");
|
|
6211
|
+
const [reasons, setReasons] = React40__default.default.useState([]);
|
|
6212
|
+
const [checked, setChecked] = React40__default.default.useState([]);
|
|
6213
|
+
const [error, setError] = React40__default.default.useState(null);
|
|
6214
|
+
const [pending, setPending] = React40__default.default.useState(null);
|
|
6137
6215
|
const submit = async (override) => {
|
|
6138
6216
|
const target = override ?? outcome;
|
|
6139
6217
|
const problem = validateDecision(outcomes, target, note);
|
|
@@ -6221,10 +6299,10 @@ var styles42 = reactNative.StyleSheet.create({
|
|
|
6221
6299
|
});
|
|
6222
6300
|
function RuleMark({ tone, colors }) {
|
|
6223
6301
|
const reduced = useReducedMotion();
|
|
6224
|
-
const scale =
|
|
6225
|
-
const wasMet =
|
|
6302
|
+
const scale = React40.useRef(new reactNative.Animated.Value(1)).current;
|
|
6303
|
+
const wasMet = React40.useRef(tone === "met" /* Met */);
|
|
6226
6304
|
const met = tone === "met" /* Met */;
|
|
6227
|
-
|
|
6305
|
+
React40.useEffect(() => {
|
|
6228
6306
|
const turnedMet = met && !wasMet.current;
|
|
6229
6307
|
wasMet.current = met;
|
|
6230
6308
|
if (!turnedMet || reduced) return;
|
|
@@ -6339,9 +6417,9 @@ function ruleAnnouncement(changed, labels) {
|
|
|
6339
6417
|
|
|
6340
6418
|
// src/PasswordField/usePasswordRuleAnnouncement.ts
|
|
6341
6419
|
function usePasswordRuleAnnouncement(rules, labels) {
|
|
6342
|
-
const previous =
|
|
6343
|
-
const [message, setMessage] =
|
|
6344
|
-
|
|
6420
|
+
const previous = React40.useRef(rules);
|
|
6421
|
+
const [message, setMessage] = React40.useState("");
|
|
6422
|
+
React40.useEffect(() => {
|
|
6345
6423
|
const changed = changedRules(previous.current, rules);
|
|
6346
6424
|
previous.current = rules;
|
|
6347
6425
|
if (changed.length > 0) setMessage(ruleAnnouncement(changed, labels));
|
|
@@ -6358,7 +6436,7 @@ function ruleColorsFrom(palette) {
|
|
|
6358
6436
|
}
|
|
6359
6437
|
function useRuleColors(override) {
|
|
6360
6438
|
const { theme } = uiFeedback.useUi();
|
|
6361
|
-
return
|
|
6439
|
+
return React40.useMemo(() => {
|
|
6362
6440
|
if (override !== void 0) return ruleColorsFrom(override);
|
|
6363
6441
|
return ruleColorsFrom({
|
|
6364
6442
|
success: theme.semantic.success?.["500"] ?? theme.colors.text,
|
|
@@ -6385,16 +6463,16 @@ function joinIds(...ids) {
|
|
|
6385
6463
|
return joined === "" ? void 0 : joined;
|
|
6386
6464
|
}
|
|
6387
6465
|
function useCaretKeepingToggle(inputRef, initialLength) {
|
|
6388
|
-
const [revealed, setRevealed] =
|
|
6389
|
-
const selection2 =
|
|
6390
|
-
const hadFocus =
|
|
6391
|
-
const onSelectionChange =
|
|
6466
|
+
const [revealed, setRevealed] = React40.useState(false);
|
|
6467
|
+
const selection2 = React40.useRef({ start: initialLength, end: initialLength });
|
|
6468
|
+
const hadFocus = React40.useRef(false);
|
|
6469
|
+
const onSelectionChange = React40.useCallback((event) => {
|
|
6392
6470
|
selection2.current = event.nativeEvent.selection;
|
|
6393
6471
|
}, []);
|
|
6394
|
-
const onPressIn =
|
|
6472
|
+
const onPressIn = React40.useCallback(() => {
|
|
6395
6473
|
hadFocus.current = inputRef.current?.isFocused?.() ?? false;
|
|
6396
6474
|
}, [inputRef]);
|
|
6397
|
-
const onToggle =
|
|
6475
|
+
const onToggle = React40.useCallback(() => {
|
|
6398
6476
|
setRevealed((current) => !current);
|
|
6399
6477
|
if (!hadFocus.current) return;
|
|
6400
6478
|
const node = inputRef.current;
|
|
@@ -6406,9 +6484,9 @@ function useCaretKeepingToggle(inputRef, initialLength) {
|
|
|
6406
6484
|
}, [inputRef]);
|
|
6407
6485
|
return { revealed, onPressIn, onToggle, onSelectionChange };
|
|
6408
6486
|
}
|
|
6409
|
-
var PasswordField =
|
|
6410
|
-
const inputRef =
|
|
6411
|
-
|
|
6487
|
+
var PasswordField = React40__default.default.forwardRef(function PasswordField2({ label, value, onChangeText, labels, testID, rules = NO_RULES, rulesDisplay = "meterGrid" /* MeterGrid */, flagUnmet = false, error, colors: colorOverride, inputProps }, ref) {
|
|
6488
|
+
const inputRef = React40.useRef(null);
|
|
6489
|
+
React40.useImperativeHandle(ref, () => inputRef.current);
|
|
6412
6490
|
const toggle2 = useCaretKeepingToggle(inputRef, value.length);
|
|
6413
6491
|
const colors = useRuleColors(colorOverride);
|
|
6414
6492
|
const announcement = usePasswordRuleAnnouncement(rules, labels);
|
|
@@ -6506,6 +6584,7 @@ exports.SEGMENT_BESIDE_TEXT_INPUT = SEGMENT_BESIDE_TEXT_INPUT;
|
|
|
6506
6584
|
exports.SearchSelect = SearchSelect;
|
|
6507
6585
|
exports.SelectControl = SelectControl;
|
|
6508
6586
|
exports.SelectField = SelectField;
|
|
6587
|
+
exports.SelectLookProvider = SelectLookProvider;
|
|
6509
6588
|
exports.SelectSurface = SelectSurface;
|
|
6510
6589
|
exports.StepperNav = StepperNav;
|
|
6511
6590
|
exports.StepperTabs = StepperTabs;
|
|
@@ -6557,6 +6636,7 @@ exports.rowsForText = rowsForText;
|
|
|
6557
6636
|
exports.ruleAnnouncement = ruleAnnouncement;
|
|
6558
6637
|
exports.ruleColorsFrom = ruleColorsFrom;
|
|
6559
6638
|
exports.ruleTone = ruleTone;
|
|
6639
|
+
exports.selectLookMetrics = selectLookMetrics;
|
|
6560
6640
|
exports.suggestOptions = suggestOptions;
|
|
6561
6641
|
exports.toCountryValue = toCountryValue;
|
|
6562
6642
|
exports.toggleGroupSelection = toggleGroupSelection;
|