@dloizides/ui-forms 1.53.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/dist/index.d.mts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +320 -248
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React40, { createContext, forwardRef, useRef, useImperativeHandle, useState, useCallback, useMemo, useEffect, useLayoutEffect, useContext } from 'react';
|
|
2
2
|
import { Platform, StyleSheet, TextInput, View, Text, Pressable, useWindowDimensions, ScrollView, Animated, Easing, AccessibilityInfo, Image, TouchableOpacity, Switch, Modal } from 'react-native';
|
|
3
3
|
import { useUi } from '@dloizides/ui-feedback';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -7,12 +7,12 @@ import { themeFocusRingColor, Button, useFocusRing, IconButton } from '@dloizide
|
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
import { MIN_TOUCH_TARGET_PX } from '@dloizides/a11y';
|
|
9
9
|
import { SvgIcon } from '@dloizides/ui-icons';
|
|
10
|
+
import Svg, { Rect, Path, Circle, Polygon } from 'react-native-svg';
|
|
10
11
|
import { parseFieldErrors } from '@dloizides/api-client-base';
|
|
11
|
-
import Svg, { Rect, Circle, Polygon } from 'react-native-svg';
|
|
12
12
|
|
|
13
13
|
// src/Field/Field.tsx
|
|
14
14
|
function attachControlId(child, candidateId, describedById) {
|
|
15
|
-
if (!
|
|
15
|
+
if (!React40.isValidElement(child) || child.type === React40.Fragment) {
|
|
16
16
|
return { node: child };
|
|
17
17
|
}
|
|
18
18
|
const props = child.props;
|
|
@@ -23,7 +23,7 @@ function attachControlId(child, candidateId, describedById) {
|
|
|
23
23
|
if (describedById !== void 0 && props.describedById === void 0) {
|
|
24
24
|
injected.describedById = describedById;
|
|
25
25
|
}
|
|
26
|
-
return { node:
|
|
26
|
+
return { node: React40.cloneElement(element, injected), controlId };
|
|
27
27
|
}
|
|
28
28
|
var IS_WEB = Platform.OS === "web";
|
|
29
29
|
function isAttributeHost(node) {
|
|
@@ -141,15 +141,15 @@ var labelVariantStyles = StyleSheet.create({
|
|
|
141
141
|
function resolveLabelVariantStyle(variant) {
|
|
142
142
|
return labelVariantStyles[variant ?? "field"] ?? labelVariantStyles.field;
|
|
143
143
|
}
|
|
144
|
-
var FormGridContext =
|
|
145
|
-
var GapOwnedContext =
|
|
144
|
+
var FormGridContext = React40.createContext(null);
|
|
145
|
+
var GapOwnedContext = React40.createContext(false);
|
|
146
146
|
var FormGridProvider = FormGridContext.Provider;
|
|
147
147
|
var GapOwnedProvider = GapOwnedContext.Provider;
|
|
148
148
|
function useFormGridMetrics() {
|
|
149
|
-
return
|
|
149
|
+
return React40.useContext(FormGridContext);
|
|
150
150
|
}
|
|
151
151
|
function useIsGapOwned() {
|
|
152
|
-
return
|
|
152
|
+
return React40.useContext(GapOwnedContext);
|
|
153
153
|
}
|
|
154
154
|
var ERROR_LIGHT_STEPS = ["500", "600", "700"];
|
|
155
155
|
var ERROR_DARK_STEPS = ["300", "200", "400", "100", "500"];
|
|
@@ -172,7 +172,7 @@ var styles = StyleSheet.create({
|
|
|
172
172
|
});
|
|
173
173
|
var fieldSeq = 0;
|
|
174
174
|
function useFieldIds() {
|
|
175
|
-
const [ids] =
|
|
175
|
+
const [ids] = React40.useState(() => {
|
|
176
176
|
fieldSeq += 1;
|
|
177
177
|
const seq = String(fieldSeq);
|
|
178
178
|
return {
|
|
@@ -219,7 +219,7 @@ var Field = ({
|
|
|
219
219
|
const hasLabel = labelText !== "";
|
|
220
220
|
const marker = resolveFieldMarker(required, optional);
|
|
221
221
|
const { hintId, errorId, controlId, labelId } = useFieldIds();
|
|
222
|
-
const themeStyles =
|
|
222
|
+
const themeStyles = React40.useMemo(
|
|
223
223
|
() => ({
|
|
224
224
|
label: { color: colors.textSecondary },
|
|
225
225
|
requiredMark: { color: errorColor },
|
|
@@ -271,7 +271,7 @@ var FormGrid = ({
|
|
|
271
271
|
style,
|
|
272
272
|
testID
|
|
273
273
|
}) => {
|
|
274
|
-
const metrics =
|
|
274
|
+
const metrics = React40.useMemo(() => ({ minWidth, basis }), [minWidth, basis]);
|
|
275
275
|
return /* @__PURE__ */ jsx(FormGridProvider, { value: metrics, children: /* @__PURE__ */ jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsx(View, { style: [styles2.grid, { gap }, style], testID, children }) }) });
|
|
276
276
|
};
|
|
277
277
|
var LABEL_LINE_PLACEHOLDER = "\xA0";
|
|
@@ -538,7 +538,7 @@ var styles9 = StyleSheet.create({
|
|
|
538
538
|
});
|
|
539
539
|
var sectionSeq = 0;
|
|
540
540
|
function useSectionLegendId() {
|
|
541
|
-
const [id] =
|
|
541
|
+
const [id] = React40.useState(() => {
|
|
542
542
|
sectionSeq += 1;
|
|
543
543
|
return `form-section-legend-${String(sectionSeq)}`;
|
|
544
544
|
});
|
|
@@ -932,7 +932,7 @@ function AnchoredMenu({
|
|
|
932
932
|
listbox,
|
|
933
933
|
placement
|
|
934
934
|
}) {
|
|
935
|
-
const menuRef =
|
|
935
|
+
const menuRef = React40.useRef(null);
|
|
936
936
|
useDismiss(anchorRef, menuRef, onDismiss);
|
|
937
937
|
useKeepHighlightInView(testID, listbox?.highlightedValue);
|
|
938
938
|
const rect2 = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
|
|
@@ -1092,7 +1092,7 @@ var boxStyles = StyleSheet.create({
|
|
|
1092
1092
|
textAlignVertical: "top"
|
|
1093
1093
|
}
|
|
1094
1094
|
});
|
|
1095
|
-
var ThemedTextInput =
|
|
1095
|
+
var ThemedTextInput = React40.forwardRef(function ThemedTextInput2({
|
|
1096
1096
|
hasError = false,
|
|
1097
1097
|
describedById,
|
|
1098
1098
|
requiredField = false,
|
|
@@ -1554,7 +1554,7 @@ function ChipContent(props) {
|
|
|
1554
1554
|
}
|
|
1555
1555
|
function OutlineChip(props) {
|
|
1556
1556
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1557
|
-
const [hovered, setHovered] =
|
|
1557
|
+
const [hovered, setHovered] = React40.useState(false);
|
|
1558
1558
|
const active = selected || hovered;
|
|
1559
1559
|
const borderColor = active ? colors.primary : restBorderColor(colors, props.outlineTone);
|
|
1560
1560
|
const fill = chipFill({
|
|
@@ -1670,8 +1670,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
|
|
|
1670
1670
|
var NO_GROUP_PROPS = {};
|
|
1671
1671
|
function useRadioKeyboard(config) {
|
|
1672
1672
|
const { enabled, disabled, values, selectedIndex, onChange } = config;
|
|
1673
|
-
const nodes =
|
|
1674
|
-
const chipRef =
|
|
1673
|
+
const nodes = React40.useRef([]);
|
|
1674
|
+
const chipRef = React40.useCallback((index) => (node) => {
|
|
1675
1675
|
nodes.current[index] = node;
|
|
1676
1676
|
}, []);
|
|
1677
1677
|
const onKeyDown = (event) => {
|
|
@@ -1790,7 +1790,7 @@ var ChipSelector = ({
|
|
|
1790
1790
|
const isRadioGroup = !multiple && singleSelectRole === "radio";
|
|
1791
1791
|
const { theme } = useUi();
|
|
1792
1792
|
const { colors, palette } = theme;
|
|
1793
|
-
const chipColors =
|
|
1793
|
+
const chipColors = React40.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
|
|
1794
1794
|
function isSelected(optionValue) {
|
|
1795
1795
|
if (multiple && Array.isArray(value))
|
|
1796
1796
|
return value.includes(optionValue);
|
|
@@ -1915,10 +1915,10 @@ var FormSwitchBox = ({
|
|
|
1915
1915
|
}) => {
|
|
1916
1916
|
const { colors } = useUi().theme;
|
|
1917
1917
|
const { disabled, onValueChange, value } = slot;
|
|
1918
|
-
const toggle2 =
|
|
1918
|
+
const toggle2 = React40.useCallback(() => {
|
|
1919
1919
|
if (!disabled) onValueChange(!value);
|
|
1920
1920
|
}, [disabled, onValueChange, value]);
|
|
1921
|
-
const boxColors =
|
|
1921
|
+
const boxColors = React40.useMemo(
|
|
1922
1922
|
() => ({ borderColor: colors.border, backgroundColor: colors.surface }),
|
|
1923
1923
|
[colors.border, colors.surface]
|
|
1924
1924
|
);
|
|
@@ -1972,12 +1972,12 @@ var FormSwitchRow = ({
|
|
|
1972
1972
|
activeTrackColor
|
|
1973
1973
|
}) => {
|
|
1974
1974
|
const { theme } = useUi();
|
|
1975
|
-
const toggle2 =
|
|
1975
|
+
const toggle2 = React40.useCallback(() => {
|
|
1976
1976
|
if (!disabled) onValueChange(!value);
|
|
1977
1977
|
}, [disabled, onValueChange, value]);
|
|
1978
1978
|
const { colors } = theme;
|
|
1979
1979
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1980
|
-
const themeStyles =
|
|
1980
|
+
const themeStyles = React40.useMemo(() => {
|
|
1981
1981
|
const labelStyle = { color: colors.text };
|
|
1982
1982
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1983
1983
|
return { label: labelStyle, description: descriptionStyle };
|
|
@@ -2113,8 +2113,8 @@ var FormCheckbox = ({
|
|
|
2113
2113
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
2114
2114
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
2115
2115
|
const { hintId } = useFieldIds();
|
|
2116
|
-
const [focused, setFocused] =
|
|
2117
|
-
const themeStyles =
|
|
2116
|
+
const [focused, setFocused] = React40.useState(false);
|
|
2117
|
+
const themeStyles = React40.useMemo(() => {
|
|
2118
2118
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
2119
2119
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
2120
2120
|
const ring = { borderColor: brand };
|
|
@@ -2171,6 +2171,63 @@ var FormCheckbox = ({
|
|
|
2171
2171
|
}
|
|
2172
2172
|
);
|
|
2173
2173
|
};
|
|
2174
|
+
|
|
2175
|
+
// src/SearchSelect/SelectSurface.ts
|
|
2176
|
+
var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
2177
|
+
SelectSurface2["Sheet"] = "sheet";
|
|
2178
|
+
SelectSurface2["Dropdown"] = "dropdown";
|
|
2179
|
+
return SelectSurface2;
|
|
2180
|
+
})(SelectSurface || {});
|
|
2181
|
+
|
|
2182
|
+
// src/SearchSelect/utils/searchSelectMotion.ts
|
|
2183
|
+
var PHONE_MAX_WIDTH = 600;
|
|
2184
|
+
var SHEET_TRAVEL_PX = 320;
|
|
2185
|
+
var DROPDOWN_TRAVEL_PX = -8;
|
|
2186
|
+
var SHEET_MS = 240;
|
|
2187
|
+
var DROPDOWN_MS = 160;
|
|
2188
|
+
function resolveSelectMotion(width, reducedMotion) {
|
|
2189
|
+
const isPhone = width < PHONE_MAX_WIDTH;
|
|
2190
|
+
const surface = isPhone ? "sheet" /* Sheet */ : "dropdown" /* Dropdown */;
|
|
2191
|
+
if (reducedMotion) return { surface, fromY: 0, durationMs: 0 };
|
|
2192
|
+
return isPhone ? { surface, fromY: SHEET_TRAVEL_PX, durationMs: SHEET_MS } : { surface, fromY: DROPDOWN_TRAVEL_PX, durationMs: DROPDOWN_MS };
|
|
2193
|
+
}
|
|
2194
|
+
var FIELD_DESKTOP_HEIGHT = 38;
|
|
2195
|
+
var FIELD_PHONE_HEIGHT = 44;
|
|
2196
|
+
var FIELD_PAD_H = 10;
|
|
2197
|
+
var FIELD_FONT = 13;
|
|
2198
|
+
var FIELD_RADIUS = 8;
|
|
2199
|
+
var FIELD_CHEVRON_ROOM = 30;
|
|
2200
|
+
var CHEVRON_BOX = 16;
|
|
2201
|
+
var DEFAULT_CONFIG = { look: "default" };
|
|
2202
|
+
var SelectLookContext = createContext(DEFAULT_CONFIG);
|
|
2203
|
+
function SelectLookProvider({ look, borderColor, children }) {
|
|
2204
|
+
const value = useMemo(() => ({ look, borderColor }), [look, borderColor]);
|
|
2205
|
+
return /* @__PURE__ */ jsx(SelectLookContext.Provider, { value, children });
|
|
2206
|
+
}
|
|
2207
|
+
function selectLookMetrics({ look, borderColor }, windowWidth) {
|
|
2208
|
+
if (look === "default") {
|
|
2209
|
+
return void 0;
|
|
2210
|
+
}
|
|
2211
|
+
const isPhone = windowWidth < PHONE_MAX_WIDTH;
|
|
2212
|
+
return {
|
|
2213
|
+
height: isPhone ? FIELD_PHONE_HEIGHT : FIELD_DESKTOP_HEIGHT,
|
|
2214
|
+
paddingHorizontal: FIELD_PAD_H,
|
|
2215
|
+
paddingVertical: 0,
|
|
2216
|
+
fontSize: FIELD_FONT,
|
|
2217
|
+
borderRadius: FIELD_RADIUS,
|
|
2218
|
+
chevronRoom: FIELD_CHEVRON_ROOM,
|
|
2219
|
+
borderColor
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
function useSelectLookMetrics() {
|
|
2223
|
+
const config = useContext(SelectLookContext);
|
|
2224
|
+
const { width } = useWindowDimensions();
|
|
2225
|
+
return selectLookMetrics(config, width);
|
|
2226
|
+
}
|
|
2227
|
+
function chevronDataUri(color) {
|
|
2228
|
+
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>`;
|
|
2229
|
+
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
2230
|
+
}
|
|
2174
2231
|
var NATIVE_SELECT_BOX = {
|
|
2175
2232
|
borderStyle: "solid",
|
|
2176
2233
|
boxSizing: "border-box",
|
|
@@ -2178,12 +2235,36 @@ var NATIVE_SELECT_BOX = {
|
|
|
2178
2235
|
width: "100%"
|
|
2179
2236
|
};
|
|
2180
2237
|
var FIT_SELECT_BOX = { width: "auto", maxWidth: "none" };
|
|
2238
|
+
var ONE_LINE_BOX = { maxWidth: "100%", minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" };
|
|
2239
|
+
var CHEVRON_INSET = 10;
|
|
2181
2240
|
var fitStyles = StyleSheet.create({
|
|
2182
|
-
anchor: { alignSelf: "flex-start", flexShrink: 0 }
|
|
2241
|
+
anchor: { alignSelf: "flex-start", flexShrink: 0 },
|
|
2242
|
+
oneLine: { maxWidth: "100%", minWidth: 0, flexShrink: 1 }
|
|
2183
2243
|
});
|
|
2184
2244
|
function nativeSelectBox(fit) {
|
|
2185
2245
|
return fit ? { ...NATIVE_SELECT_BOX, ...FIT_SELECT_BOX } : NATIVE_SELECT_BOX;
|
|
2186
2246
|
}
|
|
2247
|
+
function lookSelectStyle(fit, m, colors) {
|
|
2248
|
+
return {
|
|
2249
|
+
...nativeSelectBox(fit),
|
|
2250
|
+
...ONE_LINE_BOX,
|
|
2251
|
+
height: m.height,
|
|
2252
|
+
borderWidth: 1,
|
|
2253
|
+
borderRadius: m.borderRadius,
|
|
2254
|
+
fontSize: m.fontSize,
|
|
2255
|
+
paddingBlock: m.paddingVertical,
|
|
2256
|
+
paddingInlineStart: m.paddingHorizontal,
|
|
2257
|
+
paddingInlineEnd: m.chevronRoom,
|
|
2258
|
+
borderColor: m.borderColor ?? colors.border,
|
|
2259
|
+
backgroundColor: colors.background,
|
|
2260
|
+
color: colors.text,
|
|
2261
|
+
appearance: "none",
|
|
2262
|
+
backgroundImage: chevronDataUri(colors.chevron),
|
|
2263
|
+
backgroundRepeat: "no-repeat",
|
|
2264
|
+
backgroundPosition: `right ${String(CHEVRON_INSET)}px center`,
|
|
2265
|
+
backgroundSize: "16px 16px"
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2187
2268
|
function nativeSelectStyle(fit, borderColor, backgroundColor, color) {
|
|
2188
2269
|
const trigger = StyleSheet.flatten(controlStyles.selectTrigger);
|
|
2189
2270
|
const text = StyleSheet.flatten(controlStyles.selectTriggerText);
|
|
@@ -2217,14 +2298,16 @@ function NativeSelect({
|
|
|
2217
2298
|
const hasMatch = options.some((o) => o.value === value);
|
|
2218
2299
|
const textColor = hasMatch ? colors.text : colors.textSecondary;
|
|
2219
2300
|
const fit = native === "fit";
|
|
2301
|
+
const metrics = useSelectLookMetrics();
|
|
2302
|
+
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 });
|
|
2220
2303
|
const handleChange = (event) => onChange(event.target.value);
|
|
2221
|
-
return /* @__PURE__ */ jsx(View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, style], children: /* @__PURE__ */ jsxs(
|
|
2304
|
+
return /* @__PURE__ */ jsx(View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, metrics === void 0 ? void 0 : fitStyles.oneLine, style], children: /* @__PURE__ */ jsxs(
|
|
2222
2305
|
"select",
|
|
2223
2306
|
{
|
|
2224
2307
|
"aria-label": accessibilityLabel,
|
|
2225
2308
|
"aria-labelledby": labelledById,
|
|
2226
2309
|
"data-testid": testID,
|
|
2227
|
-
style:
|
|
2310
|
+
style: selectStyle,
|
|
2228
2311
|
title: accessibilityHint,
|
|
2229
2312
|
value,
|
|
2230
2313
|
onChange: handleChange,
|
|
@@ -2235,6 +2318,9 @@ function NativeSelect({
|
|
|
2235
2318
|
}
|
|
2236
2319
|
) });
|
|
2237
2320
|
}
|
|
2321
|
+
function SelectChevron({ color, open }) {
|
|
2322
|
+
return /* @__PURE__ */ jsx(Svg, { "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__ */ jsx(Path, { d: open ? "M4 10l4-4 4 4" : "M4 6l4 4 4-4" }) });
|
|
2323
|
+
}
|
|
2238
2324
|
|
|
2239
2325
|
// src/controls/nextHighlight.ts
|
|
2240
2326
|
var NO_HIGHLIGHT = -1;
|
|
@@ -2270,6 +2356,9 @@ function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
|
2270
2356
|
var IS_WEB7 = Platform.OS === "web";
|
|
2271
2357
|
var CHEVRON_DOWN = "\u25BE";
|
|
2272
2358
|
var CHEVRON_UP = "\u25B4";
|
|
2359
|
+
function lookTriggerBox(m) {
|
|
2360
|
+
return m === void 0 ? void 0 : { minHeight: m.height, height: m.height, paddingHorizontal: m.paddingHorizontal, paddingVertical: m.paddingVertical, borderRadius: m.borderRadius };
|
|
2361
|
+
}
|
|
2273
2362
|
function listboxTriggerAria(testID, hasList, highlighted) {
|
|
2274
2363
|
return {
|
|
2275
2364
|
role: "combobox",
|
|
@@ -2317,6 +2406,7 @@ function MenuSelectControl({
|
|
|
2317
2406
|
},
|
|
2318
2407
|
[onChange]
|
|
2319
2408
|
);
|
|
2409
|
+
const metrics = useSelectLookMetrics();
|
|
2320
2410
|
const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
|
|
2321
2411
|
const isListbox = menuAnchor !== void 0;
|
|
2322
2412
|
const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
|
|
@@ -2335,11 +2425,11 @@ function MenuSelectControl({
|
|
|
2335
2425
|
"aria-labelledby": labelledById,
|
|
2336
2426
|
onBlur: isListbox ? close : void 0,
|
|
2337
2427
|
onPress: toggle2,
|
|
2338
|
-
style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2428
|
+
style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: metrics?.borderColor ?? colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2339
2429
|
testID: `${testID}-trigger`,
|
|
2340
2430
|
children: [
|
|
2341
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: value === "" ? colors.textSecondary : colors.text }], children: selectedLabel }),
|
|
2342
|
-
/* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: isOpen ? CHEVRON_UP : CHEVRON_DOWN })
|
|
2431
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, metrics === void 0 ? void 0 : { fontSize: metrics.fontSize }, { color: value === "" ? colors.textSecondary : colors.text }], children: selectedLabel }),
|
|
2432
|
+
metrics === void 0 ? /* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: isOpen ? CHEVRON_UP : CHEVRON_DOWN }) : /* @__PURE__ */ jsx(SelectChevron, { color: colors.textSecondary, open: isOpen })
|
|
2343
2433
|
]
|
|
2344
2434
|
}
|
|
2345
2435
|
),
|
|
@@ -4401,13 +4491,6 @@ var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) =>
|
|
|
4401
4491
|
)
|
|
4402
4492
|
] });
|
|
4403
4493
|
};
|
|
4404
|
-
|
|
4405
|
-
// src/SearchSelect/SelectSurface.ts
|
|
4406
|
-
var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
4407
|
-
SelectSurface2["Sheet"] = "sheet";
|
|
4408
|
-
SelectSurface2["Dropdown"] = "dropdown";
|
|
4409
|
-
return SelectSurface2;
|
|
4410
|
-
})(SelectSurface || {});
|
|
4411
4494
|
var ROW_PAD_H = 12;
|
|
4412
4495
|
var ROW_GAP4 = 8;
|
|
4413
4496
|
var OPTION_FONT2 = 14;
|
|
@@ -4588,19 +4671,6 @@ function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
|
4588
4671
|
const openList = useCallback(() => setOpen(true), []);
|
|
4589
4672
|
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
4590
4673
|
}
|
|
4591
|
-
|
|
4592
|
-
// src/SearchSelect/utils/searchSelectMotion.ts
|
|
4593
|
-
var PHONE_MAX_WIDTH = 600;
|
|
4594
|
-
var SHEET_TRAVEL_PX = 320;
|
|
4595
|
-
var DROPDOWN_TRAVEL_PX = -8;
|
|
4596
|
-
var SHEET_MS = 240;
|
|
4597
|
-
var DROPDOWN_MS = 160;
|
|
4598
|
-
function resolveSelectMotion(width, reducedMotion) {
|
|
4599
|
-
const isPhone = width < PHONE_MAX_WIDTH;
|
|
4600
|
-
const surface = isPhone ? "sheet" /* Sheet */ : "dropdown" /* Dropdown */;
|
|
4601
|
-
if (reducedMotion) return { surface, fromY: 0, durationMs: 0 };
|
|
4602
|
-
return isPhone ? { surface, fromY: SHEET_TRAVEL_PX, durationMs: SHEET_MS } : { surface, fromY: DROPDOWN_TRAVEL_PX, durationMs: DROPDOWN_MS };
|
|
4603
|
-
}
|
|
4604
4674
|
var CHEVRON = "\u25BE";
|
|
4605
4675
|
var VALUE_GAP = 8;
|
|
4606
4676
|
var MIN_TOUCH = 44;
|
|
@@ -5974,7 +6044,7 @@ var styles38 = StyleSheet.create({
|
|
|
5974
6044
|
function RadioList(props) {
|
|
5975
6045
|
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
5976
6046
|
const { theme } = useUi();
|
|
5977
|
-
const colors =
|
|
6047
|
+
const colors = React40.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
5978
6048
|
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
5979
6049
|
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
5980
6050
|
return /* @__PURE__ */ jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsx(
|
|
@@ -6129,12 +6199,12 @@ var SubmitError = ({ message, testID }) => {
|
|
|
6129
6199
|
};
|
|
6130
6200
|
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
6131
6201
|
function useDecisionPanel(outcomes, onSubmit) {
|
|
6132
|
-
const [outcome, setOutcome] =
|
|
6133
|
-
const [note, setNote] =
|
|
6134
|
-
const [reasons, setReasons] =
|
|
6135
|
-
const [checked, setChecked] =
|
|
6136
|
-
const [error, setError] =
|
|
6137
|
-
const [pending, setPending] =
|
|
6202
|
+
const [outcome, setOutcome] = React40.useState("");
|
|
6203
|
+
const [note, setNote] = React40.useState("");
|
|
6204
|
+
const [reasons, setReasons] = React40.useState([]);
|
|
6205
|
+
const [checked, setChecked] = React40.useState([]);
|
|
6206
|
+
const [error, setError] = React40.useState(null);
|
|
6207
|
+
const [pending, setPending] = React40.useState(null);
|
|
6138
6208
|
const submit = async (override) => {
|
|
6139
6209
|
const target = override ?? outcome;
|
|
6140
6210
|
const problem = validateDecision(outcomes, target, note);
|
|
@@ -6407,7 +6477,7 @@ function useCaretKeepingToggle(inputRef, initialLength) {
|
|
|
6407
6477
|
}, [inputRef]);
|
|
6408
6478
|
return { revealed, onPressIn, onToggle, onSelectionChange };
|
|
6409
6479
|
}
|
|
6410
|
-
var PasswordField =
|
|
6480
|
+
var PasswordField = React40.forwardRef(function PasswordField2({ label, value, onChangeText, labels, testID, rules = NO_RULES, rulesDisplay = "meterGrid" /* MeterGrid */, flagUnmet = false, error, colors: colorOverride, inputProps }, ref) {
|
|
6411
6481
|
const inputRef = useRef(null);
|
|
6412
6482
|
useImperativeHandle(ref, () => inputRef.current);
|
|
6413
6483
|
const toggle2 = useCaretKeepingToggle(inputRef, value.length);
|
|
@@ -6444,6 +6514,6 @@ var PasswordField = React39.forwardRef(function PasswordField2({ label, value, o
|
|
|
6444
6514
|
] }) });
|
|
6445
6515
|
});
|
|
6446
6516
|
|
|
6447
|
-
export { ActionBar, AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, ChipLabelWrap, ChipSelector, CountryField, CountryFlag, DEFAULT_DATE_PICKER_LABELS, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateDisplay, DateField, DateInput, DatePickerProvider, DateRangeControl, DateTimeField, DecisionPanel, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, FileInput, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, GatedChecklist, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, LINE_ITEMS_WIDE_MIN_WIDTH, LineItems, MultiSelectField, PHONE_MAX_WIDTH, PasswordField, PasswordRules, PasswordRulesDisplay, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, RadioList, ResponsiveFormLayout, RevealToggle, RuleTone, SEGMENT_BESIDE_FIELD, SEGMENT_BESIDE_TEXT_INPUT, SearchSelect, SelectControl, SelectField, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, actionBarPosition, assignServerErrors, buildSearchSelectSections, canRemoveLine, changedRules, controlStyles, countryFieldOptions, countryFlag, countryOptions, defaultDecisionVariant, draftBic, draftIban, dropdownFrame, findOption, fitDropdownWidth, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isChecklistComplete, isFallbackFlag, isFixBarVisible, isLineItemsWide, isOutside, isUnmatched, isWideFormLayout, leadFirst, lineItemColumnFlex, lineNumberOf, moveHighlight, nextHighlight, placeDropdown, radioRowIdentity, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, rowsForText, ruleAnnouncement, ruleColorsFrom, ruleTone, suggestOptions, toCountryValue, toggleGroupSelection, useAutoGrowRows, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useServerFieldErrors, useThemedInput, validateBic, validateDecision, validateIban };
|
|
6517
|
+
export { ActionBar, AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, ChipLabelWrap, ChipSelector, CountryField, CountryFlag, DEFAULT_DATE_PICKER_LABELS, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateDisplay, DateField, DateInput, DatePickerProvider, DateRangeControl, DateTimeField, DecisionPanel, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, FileInput, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, GatedChecklist, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, LINE_ITEMS_WIDE_MIN_WIDTH, LineItems, MultiSelectField, PHONE_MAX_WIDTH, PasswordField, PasswordRules, PasswordRulesDisplay, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, RadioList, ResponsiveFormLayout, RevealToggle, RuleTone, SEGMENT_BESIDE_FIELD, SEGMENT_BESIDE_TEXT_INPUT, SearchSelect, SelectControl, SelectField, SelectLookProvider, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, actionBarPosition, assignServerErrors, buildSearchSelectSections, canRemoveLine, changedRules, controlStyles, countryFieldOptions, countryFlag, countryOptions, defaultDecisionVariant, draftBic, draftIban, dropdownFrame, findOption, fitDropdownWidth, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isChecklistComplete, isFallbackFlag, isFixBarVisible, isLineItemsWide, isOutside, isUnmatched, isWideFormLayout, leadFirst, lineItemColumnFlex, lineNumberOf, moveHighlight, nextHighlight, placeDropdown, radioRowIdentity, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, rowsForText, ruleAnnouncement, ruleColorsFrom, ruleTone, selectLookMetrics, suggestOptions, toCountryValue, toggleGroupSelection, useAutoGrowRows, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useServerFieldErrors, useThemedInput, validateBic, validateDecision, validateIban };
|
|
6448
6518
|
//# sourceMappingURL=index.mjs.map
|
|
6449
6519
|
//# sourceMappingURL=index.mjs.map
|