@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.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,
|
|
@@ -1501,6 +1501,13 @@ function chipBoxFill(size, backgroundColor) {
|
|
|
1501
1501
|
function restBorderColor(colors, tone) {
|
|
1502
1502
|
return tone === "strong" ? colors.borderStrong : colors.border;
|
|
1503
1503
|
}
|
|
1504
|
+
function outlineRest(colors, look) {
|
|
1505
|
+
if (look.selected) return { backgroundColor: colors.tint, textColor: colors.primary };
|
|
1506
|
+
const surface = look.tone === "surface";
|
|
1507
|
+
const backgroundColor = surface ? colors.surface : colors.muted;
|
|
1508
|
+
if (look.active) return { backgroundColor, textColor: colors.primary };
|
|
1509
|
+
return { backgroundColor, textColor: surface ? colors.textStrong : colors.textMuted };
|
|
1510
|
+
}
|
|
1504
1511
|
var SOLID_RADIUS = 20;
|
|
1505
1512
|
var OUTLINE_RADIUS = 999;
|
|
1506
1513
|
var OUTLINE_PAD_H = 12;
|
|
@@ -1547,7 +1554,7 @@ function ChipContent(props) {
|
|
|
1547
1554
|
}
|
|
1548
1555
|
function OutlineChip(props) {
|
|
1549
1556
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1550
|
-
const [hovered, setHovered] =
|
|
1557
|
+
const [hovered, setHovered] = React40.useState(false);
|
|
1551
1558
|
const active = selected || hovered;
|
|
1552
1559
|
const borderColor = active ? colors.primary : restBorderColor(colors, props.outlineTone);
|
|
1553
1560
|
const fill = chipFill({
|
|
@@ -1555,7 +1562,7 @@ function OutlineChip(props) {
|
|
|
1555
1562
|
selectedFill: props.selectedFill,
|
|
1556
1563
|
ink: colors.textStrong,
|
|
1557
1564
|
onDarkInk: colors.onPrimary,
|
|
1558
|
-
rest: {
|
|
1565
|
+
rest: outlineRest(colors, { tone: props.outlineTone, selected, active })
|
|
1559
1566
|
});
|
|
1560
1567
|
const sized = chipSizeLook(props.size);
|
|
1561
1568
|
const layout = chipLabelLayout(option.labelWrap);
|
|
@@ -1663,8 +1670,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
|
|
|
1663
1670
|
var NO_GROUP_PROPS = {};
|
|
1664
1671
|
function useRadioKeyboard(config) {
|
|
1665
1672
|
const { enabled, disabled, values, selectedIndex, onChange } = config;
|
|
1666
|
-
const nodes =
|
|
1667
|
-
const chipRef =
|
|
1673
|
+
const nodes = React40.useRef([]);
|
|
1674
|
+
const chipRef = React40.useCallback((index) => (node) => {
|
|
1668
1675
|
nodes.current[index] = node;
|
|
1669
1676
|
}, []);
|
|
1670
1677
|
const onKeyDown = (event) => {
|
|
@@ -1723,6 +1730,7 @@ function buildChipColors(colors, palette) {
|
|
|
1723
1730
|
primary,
|
|
1724
1731
|
onPrimary: onBrandInk(palette),
|
|
1725
1732
|
muted: colors.background,
|
|
1733
|
+
surface: colors.surface ?? colors.background,
|
|
1726
1734
|
tint: withAlpha2(primary, OUTLINE_TINT_ALPHA)
|
|
1727
1735
|
};
|
|
1728
1736
|
}
|
|
@@ -1782,7 +1790,7 @@ var ChipSelector = ({
|
|
|
1782
1790
|
const isRadioGroup = !multiple && singleSelectRole === "radio";
|
|
1783
1791
|
const { theme } = useUi();
|
|
1784
1792
|
const { colors, palette } = theme;
|
|
1785
|
-
const chipColors =
|
|
1793
|
+
const chipColors = React40.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
|
|
1786
1794
|
function isSelected(optionValue) {
|
|
1787
1795
|
if (multiple && Array.isArray(value))
|
|
1788
1796
|
return value.includes(optionValue);
|
|
@@ -1907,10 +1915,10 @@ var FormSwitchBox = ({
|
|
|
1907
1915
|
}) => {
|
|
1908
1916
|
const { colors } = useUi().theme;
|
|
1909
1917
|
const { disabled, onValueChange, value } = slot;
|
|
1910
|
-
const toggle2 =
|
|
1918
|
+
const toggle2 = React40.useCallback(() => {
|
|
1911
1919
|
if (!disabled) onValueChange(!value);
|
|
1912
1920
|
}, [disabled, onValueChange, value]);
|
|
1913
|
-
const boxColors =
|
|
1921
|
+
const boxColors = React40.useMemo(
|
|
1914
1922
|
() => ({ borderColor: colors.border, backgroundColor: colors.surface }),
|
|
1915
1923
|
[colors.border, colors.surface]
|
|
1916
1924
|
);
|
|
@@ -1964,12 +1972,12 @@ var FormSwitchRow = ({
|
|
|
1964
1972
|
activeTrackColor
|
|
1965
1973
|
}) => {
|
|
1966
1974
|
const { theme } = useUi();
|
|
1967
|
-
const toggle2 =
|
|
1975
|
+
const toggle2 = React40.useCallback(() => {
|
|
1968
1976
|
if (!disabled) onValueChange(!value);
|
|
1969
1977
|
}, [disabled, onValueChange, value]);
|
|
1970
1978
|
const { colors } = theme;
|
|
1971
1979
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1972
|
-
const themeStyles =
|
|
1980
|
+
const themeStyles = React40.useMemo(() => {
|
|
1973
1981
|
const labelStyle = { color: colors.text };
|
|
1974
1982
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1975
1983
|
return { label: labelStyle, description: descriptionStyle };
|
|
@@ -2105,8 +2113,8 @@ var FormCheckbox = ({
|
|
|
2105
2113
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
2106
2114
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
2107
2115
|
const { hintId } = useFieldIds();
|
|
2108
|
-
const [focused, setFocused] =
|
|
2109
|
-
const themeStyles =
|
|
2116
|
+
const [focused, setFocused] = React40.useState(false);
|
|
2117
|
+
const themeStyles = React40.useMemo(() => {
|
|
2110
2118
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
2111
2119
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
2112
2120
|
const ring = { borderColor: brand };
|
|
@@ -2163,6 +2171,63 @@ var FormCheckbox = ({
|
|
|
2163
2171
|
}
|
|
2164
2172
|
);
|
|
2165
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
|
+
}
|
|
2166
2231
|
var NATIVE_SELECT_BOX = {
|
|
2167
2232
|
borderStyle: "solid",
|
|
2168
2233
|
boxSizing: "border-box",
|
|
@@ -2170,12 +2235,36 @@ var NATIVE_SELECT_BOX = {
|
|
|
2170
2235
|
width: "100%"
|
|
2171
2236
|
};
|
|
2172
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;
|
|
2173
2240
|
var fitStyles = StyleSheet.create({
|
|
2174
|
-
anchor: { alignSelf: "flex-start", flexShrink: 0 }
|
|
2241
|
+
anchor: { alignSelf: "flex-start", flexShrink: 0 },
|
|
2242
|
+
oneLine: { maxWidth: "100%", minWidth: 0, flexShrink: 1 }
|
|
2175
2243
|
});
|
|
2176
2244
|
function nativeSelectBox(fit) {
|
|
2177
2245
|
return fit ? { ...NATIVE_SELECT_BOX, ...FIT_SELECT_BOX } : NATIVE_SELECT_BOX;
|
|
2178
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
|
+
}
|
|
2179
2268
|
function nativeSelectStyle(fit, borderColor, backgroundColor, color) {
|
|
2180
2269
|
const trigger = StyleSheet.flatten(controlStyles.selectTrigger);
|
|
2181
2270
|
const text = StyleSheet.flatten(controlStyles.selectTriggerText);
|
|
@@ -2209,14 +2298,16 @@ function NativeSelect({
|
|
|
2209
2298
|
const hasMatch = options.some((o) => o.value === value);
|
|
2210
2299
|
const textColor = hasMatch ? colors.text : colors.textSecondary;
|
|
2211
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 });
|
|
2212
2303
|
const handleChange = (event) => onChange(event.target.value);
|
|
2213
|
-
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(
|
|
2214
2305
|
"select",
|
|
2215
2306
|
{
|
|
2216
2307
|
"aria-label": accessibilityLabel,
|
|
2217
2308
|
"aria-labelledby": labelledById,
|
|
2218
2309
|
"data-testid": testID,
|
|
2219
|
-
style:
|
|
2310
|
+
style: selectStyle,
|
|
2220
2311
|
title: accessibilityHint,
|
|
2221
2312
|
value,
|
|
2222
2313
|
onChange: handleChange,
|
|
@@ -2227,6 +2318,9 @@ function NativeSelect({
|
|
|
2227
2318
|
}
|
|
2228
2319
|
) });
|
|
2229
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
|
+
}
|
|
2230
2324
|
|
|
2231
2325
|
// src/controls/nextHighlight.ts
|
|
2232
2326
|
var NO_HIGHLIGHT = -1;
|
|
@@ -2262,6 +2356,9 @@ function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
|
2262
2356
|
var IS_WEB7 = Platform.OS === "web";
|
|
2263
2357
|
var CHEVRON_DOWN = "\u25BE";
|
|
2264
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
|
+
}
|
|
2265
2362
|
function listboxTriggerAria(testID, hasList, highlighted) {
|
|
2266
2363
|
return {
|
|
2267
2364
|
role: "combobox",
|
|
@@ -2309,6 +2406,7 @@ function MenuSelectControl({
|
|
|
2309
2406
|
},
|
|
2310
2407
|
[onChange]
|
|
2311
2408
|
);
|
|
2409
|
+
const metrics = useSelectLookMetrics();
|
|
2312
2410
|
const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
|
|
2313
2411
|
const isListbox = menuAnchor !== void 0;
|
|
2314
2412
|
const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
|
|
@@ -2327,11 +2425,11 @@ function MenuSelectControl({
|
|
|
2327
2425
|
"aria-labelledby": labelledById,
|
|
2328
2426
|
onBlur: isListbox ? close : void 0,
|
|
2329
2427
|
onPress: toggle2,
|
|
2330
|
-
style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2428
|
+
style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: metrics?.borderColor ?? colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2331
2429
|
testID: `${testID}-trigger`,
|
|
2332
2430
|
children: [
|
|
2333
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: value === "" ? colors.textSecondary : colors.text }], children: selectedLabel }),
|
|
2334
|
-
/* @__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 })
|
|
2335
2433
|
]
|
|
2336
2434
|
}
|
|
2337
2435
|
),
|
|
@@ -4393,13 +4491,6 @@ var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) =>
|
|
|
4393
4491
|
)
|
|
4394
4492
|
] });
|
|
4395
4493
|
};
|
|
4396
|
-
|
|
4397
|
-
// src/SearchSelect/SelectSurface.ts
|
|
4398
|
-
var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
4399
|
-
SelectSurface2["Sheet"] = "sheet";
|
|
4400
|
-
SelectSurface2["Dropdown"] = "dropdown";
|
|
4401
|
-
return SelectSurface2;
|
|
4402
|
-
})(SelectSurface || {});
|
|
4403
4494
|
var ROW_PAD_H = 12;
|
|
4404
4495
|
var ROW_GAP4 = 8;
|
|
4405
4496
|
var OPTION_FONT2 = 14;
|
|
@@ -4580,19 +4671,6 @@ function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
|
4580
4671
|
const openList = useCallback(() => setOpen(true), []);
|
|
4581
4672
|
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
4582
4673
|
}
|
|
4583
|
-
|
|
4584
|
-
// src/SearchSelect/utils/searchSelectMotion.ts
|
|
4585
|
-
var PHONE_MAX_WIDTH = 600;
|
|
4586
|
-
var SHEET_TRAVEL_PX = 320;
|
|
4587
|
-
var DROPDOWN_TRAVEL_PX = -8;
|
|
4588
|
-
var SHEET_MS = 240;
|
|
4589
|
-
var DROPDOWN_MS = 160;
|
|
4590
|
-
function resolveSelectMotion(width, reducedMotion) {
|
|
4591
|
-
const isPhone = width < PHONE_MAX_WIDTH;
|
|
4592
|
-
const surface = isPhone ? "sheet" /* Sheet */ : "dropdown" /* Dropdown */;
|
|
4593
|
-
if (reducedMotion) return { surface, fromY: 0, durationMs: 0 };
|
|
4594
|
-
return isPhone ? { surface, fromY: SHEET_TRAVEL_PX, durationMs: SHEET_MS } : { surface, fromY: DROPDOWN_TRAVEL_PX, durationMs: DROPDOWN_MS };
|
|
4595
|
-
}
|
|
4596
4674
|
var CHEVRON = "\u25BE";
|
|
4597
4675
|
var VALUE_GAP = 8;
|
|
4598
4676
|
var MIN_TOUCH = 44;
|
|
@@ -5966,7 +6044,7 @@ var styles38 = StyleSheet.create({
|
|
|
5966
6044
|
function RadioList(props) {
|
|
5967
6045
|
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
5968
6046
|
const { theme } = useUi();
|
|
5969
|
-
const colors =
|
|
6047
|
+
const colors = React40.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
5970
6048
|
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
5971
6049
|
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
5972
6050
|
return /* @__PURE__ */ jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsx(
|
|
@@ -6121,12 +6199,12 @@ var SubmitError = ({ message, testID }) => {
|
|
|
6121
6199
|
};
|
|
6122
6200
|
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
6123
6201
|
function useDecisionPanel(outcomes, onSubmit) {
|
|
6124
|
-
const [outcome, setOutcome] =
|
|
6125
|
-
const [note, setNote] =
|
|
6126
|
-
const [reasons, setReasons] =
|
|
6127
|
-
const [checked, setChecked] =
|
|
6128
|
-
const [error, setError] =
|
|
6129
|
-
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);
|
|
6130
6208
|
const submit = async (override) => {
|
|
6131
6209
|
const target = override ?? outcome;
|
|
6132
6210
|
const problem = validateDecision(outcomes, target, note);
|
|
@@ -6399,7 +6477,7 @@ function useCaretKeepingToggle(inputRef, initialLength) {
|
|
|
6399
6477
|
}, [inputRef]);
|
|
6400
6478
|
return { revealed, onPressIn, onToggle, onSelectionChange };
|
|
6401
6479
|
}
|
|
6402
|
-
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) {
|
|
6403
6481
|
const inputRef = useRef(null);
|
|
6404
6482
|
useImperativeHandle(ref, () => inputRef.current);
|
|
6405
6483
|
const toggle2 = useCaretKeepingToggle(inputRef, value.length);
|
|
@@ -6436,6 +6514,6 @@ var PasswordField = React39.forwardRef(function PasswordField2({ label, value, o
|
|
|
6436
6514
|
] }) });
|
|
6437
6515
|
});
|
|
6438
6516
|
|
|
6439
|
-
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 };
|
|
6440
6518
|
//# sourceMappingURL=index.mjs.map
|
|
6441
6519
|
//# sourceMappingURL=index.mjs.map
|