@dloizides/ui-forms 1.53.0 → 1.55.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 +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +333 -254
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -65
- 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 };
|
|
@@ -2027,9 +2027,8 @@ var FormSwitch = ({
|
|
|
2027
2027
|
disabled = false,
|
|
2028
2028
|
...props
|
|
2029
2029
|
}) => variant === "box" ? /* @__PURE__ */ jsx(FormSwitchBox, { ...props, disabled, stateLabel, testID }) : /* @__PURE__ */ jsx(FormSwitchRow, { ...props, disabled, testID });
|
|
2030
|
-
|
|
2031
|
-
// src/FormCheckbox/checkboxColors.ts
|
|
2032
2030
|
var checkboxBoxColors = (colors, brand, checked) => checked ? { backgroundColor: brand, borderColor: brand } : { backgroundColor: "transparent", borderColor: colors.textSecondary };
|
|
2031
|
+
var checkboxTickColor = (brand) => resolveOnBrand(brand);
|
|
2033
2032
|
var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
|
|
2034
2033
|
var HINT_FONT_SIZE2 = 12;
|
|
2035
2034
|
var BOX_SIZE = 20;
|
|
@@ -2056,6 +2055,11 @@ var styles17 = StyleSheet.create({
|
|
|
2056
2055
|
centered: {
|
|
2057
2056
|
alignItems: "center"
|
|
2058
2057
|
},
|
|
2058
|
+
boxOnly: {
|
|
2059
|
+
minWidth: MIN_TOUCH_TARGET_PX,
|
|
2060
|
+
justifyContent: "center",
|
|
2061
|
+
marginBottom: 0
|
|
2062
|
+
},
|
|
2059
2063
|
box: {
|
|
2060
2064
|
width: BOX_SIZE,
|
|
2061
2065
|
height: BOX_SIZE,
|
|
@@ -2105,7 +2109,8 @@ var FormCheckbox = ({
|
|
|
2105
2109
|
containerStyle,
|
|
2106
2110
|
testID = "form-checkbox",
|
|
2107
2111
|
accessibilityLabel,
|
|
2108
|
-
accessibilityHint
|
|
2112
|
+
accessibilityHint,
|
|
2113
|
+
labelHidden = false
|
|
2109
2114
|
}) => {
|
|
2110
2115
|
const { theme } = useUi();
|
|
2111
2116
|
const { colors, palette } = theme;
|
|
@@ -2113,14 +2118,15 @@ var FormCheckbox = ({
|
|
|
2113
2118
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
2114
2119
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
2115
2120
|
const { hintId } = useFieldIds();
|
|
2116
|
-
const [focused, setFocused] =
|
|
2117
|
-
const themeStyles =
|
|
2121
|
+
const [focused, setFocused] = React40.useState(false);
|
|
2122
|
+
const themeStyles = React40.useMemo(() => {
|
|
2118
2123
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
2119
2124
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
2120
2125
|
const ring = { borderColor: brand };
|
|
2126
|
+
const tick = { borderColor: checkboxTickColor(brand) };
|
|
2121
2127
|
const labelStyle = { color: colors.text };
|
|
2122
2128
|
const hintStyle = { color: colors.textSecondary };
|
|
2123
|
-
return { boxOn, boxOff, ring, label: labelStyle, hint: hintStyle };
|
|
2129
|
+
return { boxOn, boxOff, ring, tick, label: labelStyle, hint: hintStyle };
|
|
2124
2130
|
}, [brand, colors]);
|
|
2125
2131
|
const toggle2 = () => {
|
|
2126
2132
|
const next = !value;
|
|
@@ -2152,6 +2158,7 @@ var FormCheckbox = ({
|
|
|
2152
2158
|
style: [
|
|
2153
2159
|
styles17.container,
|
|
2154
2160
|
hasHint ? null : styles17.centered,
|
|
2161
|
+
labelHidden ? styles17.boxOnly : null,
|
|
2155
2162
|
containerStyle,
|
|
2156
2163
|
disabled ? { opacity: DISABLED_OPACITY } : null,
|
|
2157
2164
|
Platform.OS === "web" ? WEB_NO_DEFAULT_OUTLINE : null
|
|
@@ -2161,9 +2168,9 @@ var FormCheckbox = ({
|
|
|
2161
2168
|
children: [
|
|
2162
2169
|
/* @__PURE__ */ jsxs(View, { style: [styles17.box, value ? themeStyles.boxOn : themeStyles.boxOff], testID: `${testID}-box`, children: [
|
|
2163
2170
|
focused ? /* @__PURE__ */ jsx(View, { pointerEvents: "none", style: [styles17.focusRing, themeStyles.ring], testID: `${testID}-focus-ring` }) : null,
|
|
2164
|
-
value ? /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, pointerEvents: "none", style: [styles17.tick,
|
|
2171
|
+
value ? /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, pointerEvents: "none", style: [styles17.tick, themeStyles.tick], testID: `${testID}-tick` }) : null
|
|
2165
2172
|
] }),
|
|
2166
|
-
/* @__PURE__ */ jsxs(View, { style: styles17.textColumn, children: [
|
|
2173
|
+
labelHidden ? null : /* @__PURE__ */ jsxs(View, { style: styles17.textColumn, children: [
|
|
2167
2174
|
/* @__PURE__ */ jsx(Text, { style: [styles17.label, themeStyles.label], children: label }),
|
|
2168
2175
|
hasHint ? /* @__PURE__ */ jsx(Text, { nativeID: hintId, style: [styles17.hint, themeStyles.hint], children: hintText }) : null
|
|
2169
2176
|
] })
|
|
@@ -2171,6 +2178,63 @@ var FormCheckbox = ({
|
|
|
2171
2178
|
}
|
|
2172
2179
|
);
|
|
2173
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 = createContext(DEFAULT_CONFIG);
|
|
2210
|
+
function SelectLookProvider({ look, borderColor, children }) {
|
|
2211
|
+
const value = useMemo(() => ({ look, borderColor }), [look, borderColor]);
|
|
2212
|
+
return /* @__PURE__ */ 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 = useContext(SelectLookContext);
|
|
2231
|
+
const { width } = 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
|
+
}
|
|
2174
2238
|
var NATIVE_SELECT_BOX = {
|
|
2175
2239
|
borderStyle: "solid",
|
|
2176
2240
|
boxSizing: "border-box",
|
|
@@ -2178,12 +2242,36 @@ var NATIVE_SELECT_BOX = {
|
|
|
2178
2242
|
width: "100%"
|
|
2179
2243
|
};
|
|
2180
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;
|
|
2181
2247
|
var fitStyles = StyleSheet.create({
|
|
2182
|
-
anchor: { alignSelf: "flex-start", flexShrink: 0 }
|
|
2248
|
+
anchor: { alignSelf: "flex-start", flexShrink: 0 },
|
|
2249
|
+
oneLine: { maxWidth: "100%", minWidth: 0, flexShrink: 1 }
|
|
2183
2250
|
});
|
|
2184
2251
|
function nativeSelectBox(fit) {
|
|
2185
2252
|
return fit ? { ...NATIVE_SELECT_BOX, ...FIT_SELECT_BOX } : NATIVE_SELECT_BOX;
|
|
2186
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
|
+
}
|
|
2187
2275
|
function nativeSelectStyle(fit, borderColor, backgroundColor, color) {
|
|
2188
2276
|
const trigger = StyleSheet.flatten(controlStyles.selectTrigger);
|
|
2189
2277
|
const text = StyleSheet.flatten(controlStyles.selectTriggerText);
|
|
@@ -2217,14 +2305,16 @@ function NativeSelect({
|
|
|
2217
2305
|
const hasMatch = options.some((o) => o.value === value);
|
|
2218
2306
|
const textColor = hasMatch ? colors.text : colors.textSecondary;
|
|
2219
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 });
|
|
2220
2310
|
const handleChange = (event) => onChange(event.target.value);
|
|
2221
|
-
return /* @__PURE__ */ jsx(View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, style], children: /* @__PURE__ */ jsxs(
|
|
2311
|
+
return /* @__PURE__ */ jsx(View, { style: [controlStyles.anchor, fit ? fitStyles.anchor : void 0, metrics === void 0 ? void 0 : fitStyles.oneLine, style], children: /* @__PURE__ */ jsxs(
|
|
2222
2312
|
"select",
|
|
2223
2313
|
{
|
|
2224
2314
|
"aria-label": accessibilityLabel,
|
|
2225
2315
|
"aria-labelledby": labelledById,
|
|
2226
2316
|
"data-testid": testID,
|
|
2227
|
-
style:
|
|
2317
|
+
style: selectStyle,
|
|
2228
2318
|
title: accessibilityHint,
|
|
2229
2319
|
value,
|
|
2230
2320
|
onChange: handleChange,
|
|
@@ -2235,6 +2325,9 @@ function NativeSelect({
|
|
|
2235
2325
|
}
|
|
2236
2326
|
) });
|
|
2237
2327
|
}
|
|
2328
|
+
function SelectChevron({ color, open }) {
|
|
2329
|
+
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" }) });
|
|
2330
|
+
}
|
|
2238
2331
|
|
|
2239
2332
|
// src/controls/nextHighlight.ts
|
|
2240
2333
|
var NO_HIGHLIGHT = -1;
|
|
@@ -2270,6 +2363,9 @@ function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
|
|
|
2270
2363
|
var IS_WEB7 = Platform.OS === "web";
|
|
2271
2364
|
var CHEVRON_DOWN = "\u25BE";
|
|
2272
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
|
+
}
|
|
2273
2369
|
function listboxTriggerAria(testID, hasList, highlighted) {
|
|
2274
2370
|
return {
|
|
2275
2371
|
role: "combobox",
|
|
@@ -2317,6 +2413,7 @@ function MenuSelectControl({
|
|
|
2317
2413
|
},
|
|
2318
2414
|
[onChange]
|
|
2319
2415
|
);
|
|
2416
|
+
const metrics = useSelectLookMetrics();
|
|
2320
2417
|
const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
|
|
2321
2418
|
const isListbox = menuAnchor !== void 0;
|
|
2322
2419
|
const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
|
|
@@ -2335,11 +2432,11 @@ function MenuSelectControl({
|
|
|
2335
2432
|
"aria-labelledby": labelledById,
|
|
2336
2433
|
onBlur: isListbox ? close : void 0,
|
|
2337
2434
|
onPress: toggle2,
|
|
2338
|
-
style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2435
|
+
style: [controlStyles.selectTrigger, lookTriggerBox(metrics), { borderColor: metrics?.borderColor ?? colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2339
2436
|
testID: `${testID}-trigger`,
|
|
2340
2437
|
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 })
|
|
2438
|
+
/* @__PURE__ */ jsx(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__ */ 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
2440
|
]
|
|
2344
2441
|
}
|
|
2345
2442
|
),
|
|
@@ -4401,13 +4498,6 @@ var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) =>
|
|
|
4401
4498
|
)
|
|
4402
4499
|
] });
|
|
4403
4500
|
};
|
|
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
4501
|
var ROW_PAD_H = 12;
|
|
4412
4502
|
var ROW_GAP4 = 8;
|
|
4413
4503
|
var OPTION_FONT2 = 14;
|
|
@@ -4588,19 +4678,6 @@ function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
|
4588
4678
|
const openList = useCallback(() => setOpen(true), []);
|
|
4589
4679
|
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
4590
4680
|
}
|
|
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
4681
|
var CHEVRON = "\u25BE";
|
|
4605
4682
|
var VALUE_GAP = 8;
|
|
4606
4683
|
var MIN_TOUCH = 44;
|
|
@@ -5974,7 +6051,7 @@ var styles38 = StyleSheet.create({
|
|
|
5974
6051
|
function RadioList(props) {
|
|
5975
6052
|
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
5976
6053
|
const { theme } = useUi();
|
|
5977
|
-
const colors =
|
|
6054
|
+
const colors = React40.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
5978
6055
|
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
5979
6056
|
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
5980
6057
|
return /* @__PURE__ */ jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsx(
|
|
@@ -6129,12 +6206,12 @@ var SubmitError = ({ message, testID }) => {
|
|
|
6129
6206
|
};
|
|
6130
6207
|
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
6131
6208
|
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] =
|
|
6209
|
+
const [outcome, setOutcome] = React40.useState("");
|
|
6210
|
+
const [note, setNote] = React40.useState("");
|
|
6211
|
+
const [reasons, setReasons] = React40.useState([]);
|
|
6212
|
+
const [checked, setChecked] = React40.useState([]);
|
|
6213
|
+
const [error, setError] = React40.useState(null);
|
|
6214
|
+
const [pending, setPending] = React40.useState(null);
|
|
6138
6215
|
const submit = async (override) => {
|
|
6139
6216
|
const target = override ?? outcome;
|
|
6140
6217
|
const problem = validateDecision(outcomes, target, note);
|
|
@@ -6407,7 +6484,7 @@ function useCaretKeepingToggle(inputRef, initialLength) {
|
|
|
6407
6484
|
}, [inputRef]);
|
|
6408
6485
|
return { revealed, onPressIn, onToggle, onSelectionChange };
|
|
6409
6486
|
}
|
|
6410
|
-
var PasswordField =
|
|
6487
|
+
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
6488
|
const inputRef = useRef(null);
|
|
6412
6489
|
useImperativeHandle(ref, () => inputRef.current);
|
|
6413
6490
|
const toggle2 = useCaretKeepingToggle(inputRef, value.length);
|
|
@@ -6444,6 +6521,6 @@ var PasswordField = React39.forwardRef(function PasswordField2({ label, value, o
|
|
|
6444
6521
|
] }) });
|
|
6445
6522
|
});
|
|
6446
6523
|
|
|
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 };
|
|
6524
|
+
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
6525
|
//# sourceMappingURL=index.mjs.map
|
|
6449
6526
|
//# sourceMappingURL=index.mjs.map
|