@yahoo/uds-mobile 2.21.2 → 2.23.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/README.md +2 -0
- package/dist/bin/automated-config/dist/generated/generatedConfigs.mjs +3127 -452
- package/dist/bin/uds-mobile.mjs +7 -7
- package/dist/components/IconButton.cjs +24 -21
- package/dist/components/IconButton.js +25 -22
- package/dist/components/IconButton.js.map +1 -1
- package/dist/components/Select/Select.cjs +194 -0
- package/dist/components/Select/Select.d.cts +47 -0
- package/dist/components/Select/Select.d.cts.map +1 -0
- package/dist/components/Select/Select.d.ts +47 -0
- package/dist/components/Select/Select.d.ts.map +1 -0
- package/dist/components/Select/Select.js +194 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/Select/SelectContent.cjs +148 -0
- package/dist/components/Select/SelectContent.d.cts +31 -0
- package/dist/components/Select/SelectContent.d.cts.map +1 -0
- package/dist/components/Select/SelectContent.d.ts +31 -0
- package/dist/components/Select/SelectContent.d.ts.map +1 -0
- package/dist/components/Select/SelectContent.js +147 -0
- package/dist/components/Select/SelectContent.js.map +1 -0
- package/dist/components/Select/SelectItem.cjs +138 -0
- package/dist/components/Select/SelectItem.d.cts +24 -0
- package/dist/components/Select/SelectItem.d.cts.map +1 -0
- package/dist/components/Select/SelectItem.d.ts +24 -0
- package/dist/components/Select/SelectItem.d.ts.map +1 -0
- package/dist/components/Select/SelectItem.js +137 -0
- package/dist/components/Select/SelectItem.js.map +1 -0
- package/dist/components/Select/SelectTrigger.cjs +140 -0
- package/dist/components/Select/SelectTrigger.d.cts +13 -0
- package/dist/components/Select/SelectTrigger.d.cts.map +1 -0
- package/dist/components/Select/SelectTrigger.d.ts +13 -0
- package/dist/components/Select/SelectTrigger.d.ts.map +1 -0
- package/dist/components/Select/SelectTrigger.js +139 -0
- package/dist/components/Select/SelectTrigger.js.map +1 -0
- package/dist/components/Select/index.cjs +8 -0
- package/dist/components/Select/index.d.cts +5 -0
- package/dist/components/Select/index.d.ts +5 -0
- package/dist/components/Select/index.js +5 -0
- package/dist/components/Select/selectContext.cjs +22 -0
- package/dist/components/Select/selectContext.d.cts +12 -0
- package/dist/components/Select/selectContext.d.cts.map +1 -0
- package/dist/components/Select/selectContext.d.ts +12 -0
- package/dist/components/Select/selectContext.d.ts.map +1 -0
- package/dist/components/Select/selectContext.js +19 -0
- package/dist/components/Select/selectContext.js.map +1 -0
- package/dist/components/Select/selectItemTheme.cjs +39 -0
- package/dist/components/Select/selectItemTheme.d.cts +19 -0
- package/dist/components/Select/selectItemTheme.d.cts.map +1 -0
- package/dist/components/Select/selectItemTheme.d.ts +19 -0
- package/dist/components/Select/selectItemTheme.d.ts.map +1 -0
- package/dist/components/Select/selectItemTheme.js +39 -0
- package/dist/components/Select/selectItemTheme.js.map +1 -0
- package/dist/components/Select/types.cjs +1 -0
- package/dist/components/Select/types.d.cts +43 -0
- package/dist/components/Select/types.d.cts.map +1 -0
- package/dist/components/Select/types.d.ts +43 -0
- package/dist/components/Select/types.d.ts.map +1 -0
- package/dist/components/Select/types.js +1 -0
- package/dist/components/Switch.cjs +34 -12
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +36 -14
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/UDSGestureProvider.cjs +4 -0
- package/dist/components/UDSGestureProvider.d.cts +3 -0
- package/dist/components/UDSGestureProvider.d.ts +3 -0
- package/dist/components/UDSGestureProvider.js +3 -0
- package/dist/components/UDSProvider.cjs +10 -5
- package/dist/components/UDSProvider.d.cts +15 -7
- package/dist/components/UDSProvider.d.cts.map +1 -1
- package/dist/components/UDSProvider.d.ts +15 -7
- package/dist/components/UDSProvider.d.ts.map +1 -1
- package/dist/components/UDSProvider.js +10 -6
- package/dist/components/UDSProvider.js.map +1 -1
- package/dist/components/internal/Overlay/OverlayPortal.js.map +1 -1
- package/dist/components/internal/Overlay/index.cjs +2 -0
- package/dist/components/internal/Overlay/index.d.cts +2 -1
- package/dist/components/internal/Overlay/index.d.ts +2 -1
- package/dist/components/internal/Overlay/index.js +2 -1
- package/dist/components/internal/Overlay/measureTrigger.cjs +35 -0
- package/dist/components/internal/Overlay/measureTrigger.d.cts +9 -0
- package/dist/components/internal/Overlay/measureTrigger.d.cts.map +1 -0
- package/dist/components/internal/Overlay/measureTrigger.d.ts +9 -0
- package/dist/components/internal/Overlay/measureTrigger.d.ts.map +1 -0
- package/dist/components/internal/Overlay/measureTrigger.js +36 -0
- package/dist/components/internal/Overlay/measureTrigger.js.map +1 -0
- package/dist/jest/mocks/styles.cjs +68 -10
- package/dist/jest/mocks/styles.d.cts +5 -2
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts +5 -2
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +66 -11
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/jest/mocks/unistyles.cjs +16 -1
- package/dist/jest/mocks/unistyles.d.cts +56 -2
- package/dist/jest/mocks/unistyles.d.cts.map +1 -1
- package/dist/jest/mocks/unistyles.d.ts +56 -2
- package/dist/jest/mocks/unistyles.d.ts.map +1 -1
- package/dist/jest/mocks/unistyles.js +16 -1
- package/dist/jest/mocks/unistyles.js.map +1 -1
- package/dist/portal.cjs +1 -1
- package/dist/portal.js +1 -1
- package/dist/portal.js.map +1 -1
- package/dist/types/dist/index.d.cts +28 -1
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts +28 -1
- package/dist/types/dist/index.d.ts.map +1 -1
- package/generated/styles.cjs +125 -0
- package/generated/styles.d.ts +39 -0
- package/generated/styles.mjs +125 -0
- package/generated/unistyles.d.ts +108 -8
- package/package.json +21 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
const require_components_HStack = require("../HStack.cjs");
|
|
5
|
+
const require_components_IconSlot = require("../IconSlot.cjs");
|
|
6
|
+
const require_components_Select_selectContext = require("./selectContext.cjs");
|
|
7
|
+
const require_components_Select_selectItemTheme = require("./selectItemTheme.cjs");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let react_native = require("react-native");
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
let react_native_unistyles = require("react-native-unistyles");
|
|
12
|
+
let react_native_reanimated = require("react-native-reanimated");
|
|
13
|
+
react_native_reanimated = require_runtime.__toESM(react_native_reanimated);
|
|
14
|
+
//#region src/components/Select/SelectItem.tsx
|
|
15
|
+
/**
|
|
16
|
+
* **▾ Select item**
|
|
17
|
+
*
|
|
18
|
+
* A single selectable option inside {@link SelectContent}.
|
|
19
|
+
*/
|
|
20
|
+
const SelectItem = (0, react.memo)(function SelectItem({ value, disabled, children, style, testID }) {
|
|
21
|
+
const { value: selectedValue, setValue, setOpen, open, registerItem, unregisterItem, highlightedValue, setHighlightedValue, reduceMotion } = require_components_Select_selectContext.useSelectContext();
|
|
22
|
+
const { theme } = (0, react_native_unistyles.useUnistyles)();
|
|
23
|
+
const [isPressed, setIsPressed] = (0, react.useState)(false);
|
|
24
|
+
const label = (0, react.useMemo)(() => {
|
|
25
|
+
if (typeof children === "string" || typeof children === "number") return String(children);
|
|
26
|
+
return value;
|
|
27
|
+
}, [children, value]);
|
|
28
|
+
(0, react.useEffect)(() => {
|
|
29
|
+
registerItem(value, label);
|
|
30
|
+
return () => unregisterItem(value);
|
|
31
|
+
}, [
|
|
32
|
+
label,
|
|
33
|
+
registerItem,
|
|
34
|
+
unregisterItem,
|
|
35
|
+
value
|
|
36
|
+
]);
|
|
37
|
+
const isSelected = selectedValue === value;
|
|
38
|
+
const interaction = require_components_Select_selectItemTheme.resolveSelectItemInteractionState({
|
|
39
|
+
isPressed,
|
|
40
|
+
isHighlighted: highlightedValue === value
|
|
41
|
+
});
|
|
42
|
+
const rootStyle = (0, react.useMemo)(() => [
|
|
43
|
+
require_components_Select_selectItemTheme.getMergedSelectItemLayerStyle(theme, "root", interaction, isSelected),
|
|
44
|
+
{
|
|
45
|
+
flexDirection: "row",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
justifyContent: "space-between",
|
|
48
|
+
width: "100%",
|
|
49
|
+
opacity: disabled ? .5 : 1
|
|
50
|
+
},
|
|
51
|
+
style
|
|
52
|
+
], [
|
|
53
|
+
disabled,
|
|
54
|
+
interaction,
|
|
55
|
+
isSelected,
|
|
56
|
+
style,
|
|
57
|
+
theme
|
|
58
|
+
]);
|
|
59
|
+
const textStyle = (0, react.useMemo)(() => require_components_Select_selectItemTheme.getMergedSelectItemLayerStyle(theme, "text", interaction, isSelected), [
|
|
60
|
+
interaction,
|
|
61
|
+
isSelected,
|
|
62
|
+
theme
|
|
63
|
+
]);
|
|
64
|
+
const endIconStyle = (0, react.useMemo)(() => require_components_Select_selectItemTheme.getMergedSelectItemLayerStyle(theme, "endIcon", interaction, isSelected), [
|
|
65
|
+
interaction,
|
|
66
|
+
isSelected,
|
|
67
|
+
theme
|
|
68
|
+
]);
|
|
69
|
+
const checkScale = (0, react_native_reanimated.useDerivedValue)(() => (0, react_native_reanimated.withTiming)(isSelected ? 1 : 0, {
|
|
70
|
+
duration: reduceMotion ? 0 : 120,
|
|
71
|
+
easing: react_native_reanimated.Easing.out(react_native_reanimated.Easing.ease)
|
|
72
|
+
}), [isSelected, reduceMotion]);
|
|
73
|
+
const checkAnimatedStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
74
|
+
opacity: checkScale.value,
|
|
75
|
+
transform: [{ scale: .7 + checkScale.value * .3 }]
|
|
76
|
+
}));
|
|
77
|
+
const handlePress = (0, react.useCallback)(() => {
|
|
78
|
+
if (disabled) return;
|
|
79
|
+
setValue(value);
|
|
80
|
+
setOpen(false);
|
|
81
|
+
setHighlightedValue(null);
|
|
82
|
+
}, [
|
|
83
|
+
disabled,
|
|
84
|
+
setHighlightedValue,
|
|
85
|
+
setOpen,
|
|
86
|
+
setValue,
|
|
87
|
+
value
|
|
88
|
+
]);
|
|
89
|
+
const handlePressIn = (0, react.useCallback)(() => {
|
|
90
|
+
if (disabled) return;
|
|
91
|
+
setIsPressed(true);
|
|
92
|
+
setHighlightedValue(value);
|
|
93
|
+
}, [
|
|
94
|
+
disabled,
|
|
95
|
+
setHighlightedValue,
|
|
96
|
+
value
|
|
97
|
+
]);
|
|
98
|
+
const handlePressOut = (0, react.useCallback)(() => {
|
|
99
|
+
setIsPressed(false);
|
|
100
|
+
}, []);
|
|
101
|
+
if (!open) return null;
|
|
102
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.Pressable, {
|
|
103
|
+
testID,
|
|
104
|
+
disabled,
|
|
105
|
+
onPress: handlePress,
|
|
106
|
+
onPressIn: handlePressIn,
|
|
107
|
+
onPressOut: handlePressOut,
|
|
108
|
+
style: rootStyle,
|
|
109
|
+
accessibilityRole: "menuitem",
|
|
110
|
+
accessibilityState: {
|
|
111
|
+
disabled: !!disabled,
|
|
112
|
+
selected: isSelected
|
|
113
|
+
},
|
|
114
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_HStack.HStack, {
|
|
115
|
+
columnGap: "2",
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
justifyContent: "flex-start",
|
|
118
|
+
style: { flex: 1 },
|
|
119
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
120
|
+
style: textStyle,
|
|
121
|
+
numberOfLines: 1,
|
|
122
|
+
children
|
|
123
|
+
})
|
|
124
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
125
|
+
style: checkAnimatedStyle,
|
|
126
|
+
pointerEvents: "none",
|
|
127
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
128
|
+
icon: "Check",
|
|
129
|
+
size: "sm",
|
|
130
|
+
variant: "fill",
|
|
131
|
+
style: endIconStyle
|
|
132
|
+
})
|
|
133
|
+
})]
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
SelectItem.displayName = "SelectItem";
|
|
137
|
+
//#endregion
|
|
138
|
+
exports.SelectItem = SelectItem;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _$react from "react";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Select/SelectItem.d.ts
|
|
7
|
+
interface SelectItemProps {
|
|
8
|
+
/** Value submitted when this option is selected. */
|
|
9
|
+
value: string;
|
|
10
|
+
/** Whether this option is disabled. */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
testID?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* **▾ Select item**
|
|
18
|
+
*
|
|
19
|
+
* A single selectable option inside {@link SelectContent}.
|
|
20
|
+
*/
|
|
21
|
+
declare const SelectItem: _$react.NamedExoticComponent<SelectItemProps>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SelectItem, type SelectItemProps };
|
|
24
|
+
//# sourceMappingURL=SelectItem.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectItem.d.cts","names":[],"sources":["../../../src/components/Select/SelectItem.tsx"],"mappings":";;;;;;UAqBU,eAAA;;EAER,KAAA;EAFQ;EAIR,QAAA;EACA,QAAA,GAAW,SAAA;EACX,KAAA,GAAQ,SAAA,CAAU,SAAA;EAClB,MAAA;AAAA;;;;;;cAQI,UAAA,EAAU,OAAA,CAAA,oBAAA,CAAA,eAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _$react from "react";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Select/SelectItem.d.ts
|
|
7
|
+
interface SelectItemProps {
|
|
8
|
+
/** Value submitted when this option is selected. */
|
|
9
|
+
value: string;
|
|
10
|
+
/** Whether this option is disabled. */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
testID?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* **▾ Select item**
|
|
18
|
+
*
|
|
19
|
+
* A single selectable option inside {@link SelectContent}.
|
|
20
|
+
*/
|
|
21
|
+
declare const SelectItem: _$react.NamedExoticComponent<SelectItemProps>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SelectItem, type SelectItemProps };
|
|
24
|
+
//# sourceMappingURL=SelectItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectItem.d.ts","names":[],"sources":["../../../src/components/Select/SelectItem.tsx"],"mappings":";;;;;;UAqBU,eAAA;;EAER,KAAA;EAFQ;EAIR,QAAA;EACA,QAAA,GAAW,SAAA;EACX,KAAA,GAAQ,SAAA,CAAU,SAAA;EAClB,MAAA;AAAA;;;;;;cAQI,UAAA,EAAU,OAAA,CAAA,oBAAA,CAAA,eAAA"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { HStack } from "../HStack.js";
|
|
3
|
+
import { IconSlot } from "../IconSlot.js";
|
|
4
|
+
import { useSelectContext } from "./selectContext.js";
|
|
5
|
+
import { getMergedSelectItemLayerStyle, resolveSelectItemInteractionState } from "./selectItemTheme.js";
|
|
6
|
+
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
7
|
+
import { Pressable, Text } from "react-native";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useUnistyles } from "react-native-unistyles";
|
|
10
|
+
import Animated, { Easing, useAnimatedStyle, useDerivedValue, withTiming } from "react-native-reanimated";
|
|
11
|
+
//#region src/components/Select/SelectItem.tsx
|
|
12
|
+
/**
|
|
13
|
+
* **▾ Select item**
|
|
14
|
+
*
|
|
15
|
+
* A single selectable option inside {@link SelectContent}.
|
|
16
|
+
*/
|
|
17
|
+
const SelectItem = memo(function SelectItem({ value, disabled, children, style, testID }) {
|
|
18
|
+
const { value: selectedValue, setValue, setOpen, open, registerItem, unregisterItem, highlightedValue, setHighlightedValue, reduceMotion } = useSelectContext();
|
|
19
|
+
const { theme } = useUnistyles();
|
|
20
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
21
|
+
const label = useMemo(() => {
|
|
22
|
+
if (typeof children === "string" || typeof children === "number") return String(children);
|
|
23
|
+
return value;
|
|
24
|
+
}, [children, value]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
registerItem(value, label);
|
|
27
|
+
return () => unregisterItem(value);
|
|
28
|
+
}, [
|
|
29
|
+
label,
|
|
30
|
+
registerItem,
|
|
31
|
+
unregisterItem,
|
|
32
|
+
value
|
|
33
|
+
]);
|
|
34
|
+
const isSelected = selectedValue === value;
|
|
35
|
+
const interaction = resolveSelectItemInteractionState({
|
|
36
|
+
isPressed,
|
|
37
|
+
isHighlighted: highlightedValue === value
|
|
38
|
+
});
|
|
39
|
+
const rootStyle = useMemo(() => [
|
|
40
|
+
getMergedSelectItemLayerStyle(theme, "root", interaction, isSelected),
|
|
41
|
+
{
|
|
42
|
+
flexDirection: "row",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
justifyContent: "space-between",
|
|
45
|
+
width: "100%",
|
|
46
|
+
opacity: disabled ? .5 : 1
|
|
47
|
+
},
|
|
48
|
+
style
|
|
49
|
+
], [
|
|
50
|
+
disabled,
|
|
51
|
+
interaction,
|
|
52
|
+
isSelected,
|
|
53
|
+
style,
|
|
54
|
+
theme
|
|
55
|
+
]);
|
|
56
|
+
const textStyle = useMemo(() => getMergedSelectItemLayerStyle(theme, "text", interaction, isSelected), [
|
|
57
|
+
interaction,
|
|
58
|
+
isSelected,
|
|
59
|
+
theme
|
|
60
|
+
]);
|
|
61
|
+
const endIconStyle = useMemo(() => getMergedSelectItemLayerStyle(theme, "endIcon", interaction, isSelected), [
|
|
62
|
+
interaction,
|
|
63
|
+
isSelected,
|
|
64
|
+
theme
|
|
65
|
+
]);
|
|
66
|
+
const checkScale = useDerivedValue(() => withTiming(isSelected ? 1 : 0, {
|
|
67
|
+
duration: reduceMotion ? 0 : 120,
|
|
68
|
+
easing: Easing.out(Easing.ease)
|
|
69
|
+
}), [isSelected, reduceMotion]);
|
|
70
|
+
const checkAnimatedStyle = useAnimatedStyle(() => ({
|
|
71
|
+
opacity: checkScale.value,
|
|
72
|
+
transform: [{ scale: .7 + checkScale.value * .3 }]
|
|
73
|
+
}));
|
|
74
|
+
const handlePress = useCallback(() => {
|
|
75
|
+
if (disabled) return;
|
|
76
|
+
setValue(value);
|
|
77
|
+
setOpen(false);
|
|
78
|
+
setHighlightedValue(null);
|
|
79
|
+
}, [
|
|
80
|
+
disabled,
|
|
81
|
+
setHighlightedValue,
|
|
82
|
+
setOpen,
|
|
83
|
+
setValue,
|
|
84
|
+
value
|
|
85
|
+
]);
|
|
86
|
+
const handlePressIn = useCallback(() => {
|
|
87
|
+
if (disabled) return;
|
|
88
|
+
setIsPressed(true);
|
|
89
|
+
setHighlightedValue(value);
|
|
90
|
+
}, [
|
|
91
|
+
disabled,
|
|
92
|
+
setHighlightedValue,
|
|
93
|
+
value
|
|
94
|
+
]);
|
|
95
|
+
const handlePressOut = useCallback(() => {
|
|
96
|
+
setIsPressed(false);
|
|
97
|
+
}, []);
|
|
98
|
+
if (!open) return null;
|
|
99
|
+
return /* @__PURE__ */ jsxs(Pressable, {
|
|
100
|
+
testID,
|
|
101
|
+
disabled,
|
|
102
|
+
onPress: handlePress,
|
|
103
|
+
onPressIn: handlePressIn,
|
|
104
|
+
onPressOut: handlePressOut,
|
|
105
|
+
style: rootStyle,
|
|
106
|
+
accessibilityRole: "menuitem",
|
|
107
|
+
accessibilityState: {
|
|
108
|
+
disabled: !!disabled,
|
|
109
|
+
selected: isSelected
|
|
110
|
+
},
|
|
111
|
+
children: [/* @__PURE__ */ jsx(HStack, {
|
|
112
|
+
columnGap: "2",
|
|
113
|
+
alignItems: "center",
|
|
114
|
+
justifyContent: "flex-start",
|
|
115
|
+
style: { flex: 1 },
|
|
116
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
117
|
+
style: textStyle,
|
|
118
|
+
numberOfLines: 1,
|
|
119
|
+
children
|
|
120
|
+
})
|
|
121
|
+
}), /* @__PURE__ */ jsx(Animated.View, {
|
|
122
|
+
style: checkAnimatedStyle,
|
|
123
|
+
pointerEvents: "none",
|
|
124
|
+
children: /* @__PURE__ */ jsx(IconSlot, {
|
|
125
|
+
icon: "Check",
|
|
126
|
+
size: "sm",
|
|
127
|
+
variant: "fill",
|
|
128
|
+
style: endIconStyle
|
|
129
|
+
})
|
|
130
|
+
})]
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
SelectItem.displayName = "SelectItem";
|
|
134
|
+
//#endregion
|
|
135
|
+
export { SelectItem };
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=SelectItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectItem.js","names":["RNPressable","RNText"],"sources":["../../../src/components/Select/SelectItem.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport { Pressable as RNPressable, Text as RNText } from 'react-native';\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useDerivedValue,\n withTiming,\n} from 'react-native-reanimated';\n// eslint-disable-next-line uds/no-use-unistyles -- selectItem selected state uses theme paths\nimport { useUnistyles } from 'react-native-unistyles';\n\nimport { HStack } from '../HStack';\nimport { IconSlot } from '../IconSlot';\nimport { useSelectContext } from './selectContext';\nimport {\n getMergedSelectItemLayerStyle,\n resolveSelectItemInteractionState,\n} from './selectItemTheme';\n\ninterface SelectItemProps {\n /** Value submitted when this option is selected. */\n value: string;\n /** Whether this option is disabled. */\n disabled?: boolean;\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n}\n\n/**\n * **▾ Select item**\n *\n * A single selectable option inside {@link SelectContent}.\n */\nconst SelectItem = memo(function SelectItem({\n value,\n disabled,\n children,\n style,\n testID,\n}: SelectItemProps) {\n const {\n value: selectedValue,\n setValue,\n setOpen,\n open,\n registerItem,\n unregisterItem,\n highlightedValue,\n setHighlightedValue,\n reduceMotion,\n } = useSelectContext();\n const { theme } = useUnistyles();\n const [isPressed, setIsPressed] = useState(false);\n\n const label = useMemo(() => {\n if (typeof children === 'string' || typeof children === 'number') {\n return String(children);\n }\n\n return value;\n }, [children, value]);\n\n useEffect(() => {\n registerItem(value, label);\n return () => unregisterItem(value);\n }, [label, registerItem, unregisterItem, value]);\n\n const isSelected = selectedValue === value;\n const isHighlighted = highlightedValue === value;\n const interaction = resolveSelectItemInteractionState({\n isPressed,\n isHighlighted,\n });\n\n const rootStyle = useMemo(\n () =>\n [\n getMergedSelectItemLayerStyle(theme, 'root', interaction, isSelected),\n {\n flexDirection: 'row' as const,\n alignItems: 'center' as const,\n justifyContent: 'space-between' as const,\n width: '100%' as const,\n opacity: disabled ? 0.5 : 1,\n },\n style,\n ] as StyleProp<ViewStyle>,\n [disabled, interaction, isSelected, style, theme],\n );\n\n const textStyle = useMemo(\n () => getMergedSelectItemLayerStyle(theme, 'text', interaction, isSelected),\n [interaction, isSelected, theme],\n );\n\n const endIconStyle = useMemo(\n () => getMergedSelectItemLayerStyle(theme, 'endIcon', interaction, isSelected),\n [interaction, isSelected, theme],\n );\n\n const checkScale = useDerivedValue(\n () =>\n withTiming(isSelected ? 1 : 0, {\n duration: reduceMotion ? 0 : 120,\n easing: Easing.out(Easing.ease),\n }),\n [isSelected, reduceMotion],\n );\n\n const checkAnimatedStyle = useAnimatedStyle(() => ({\n opacity: checkScale.value,\n transform: [{ scale: 0.7 + checkScale.value * 0.3 }],\n }));\n\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n setValue(value);\n setOpen(false);\n setHighlightedValue(null);\n }, [disabled, setHighlightedValue, setOpen, setValue, value]);\n\n const handlePressIn = useCallback(() => {\n if (disabled) {\n return;\n }\n\n setIsPressed(true);\n setHighlightedValue(value);\n }, [disabled, setHighlightedValue, value]);\n\n const handlePressOut = useCallback(() => {\n setIsPressed(false);\n }, []);\n\n if (!open) {\n return null;\n }\n\n return (\n <RNPressable\n testID={testID}\n disabled={disabled}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n style={rootStyle}\n accessibilityRole=\"menuitem\"\n accessibilityState={{ disabled: !!disabled, selected: isSelected }}\n >\n <HStack columnGap=\"2\" alignItems=\"center\" justifyContent=\"flex-start\" style={{ flex: 1 }}>\n <RNText style={textStyle} numberOfLines={1}>\n {children}\n </RNText>\n </HStack>\n\n <Animated.View style={checkAnimatedStyle} pointerEvents=\"none\">\n <IconSlot icon=\"Check\" size=\"sm\" variant=\"fill\" style={endIconStyle} />\n </Animated.View>\n </RNPressable>\n );\n});\n\nSelectItem.displayName = 'SelectItem';\n\nexport { SelectItem, type SelectItemProps };\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,MAAM,aAAa,KAAK,SAAS,WAAW,EAC1C,OACA,UACA,UACA,OACA,UACkB;CAClB,MAAM,EACJ,OAAO,eACP,UACA,SACA,MACA,cACA,gBACA,kBACA,qBACA,iBACE,kBAAkB;CACtB,MAAM,EAAE,UAAU,cAAc;CAChC,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CAEjD,MAAM,QAAQ,cAAc;EAC1B,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,UACtD,OAAO,OAAO,SAAS;EAGzB,OAAO;IACN,CAAC,UAAU,MAAM,CAAC;CAErB,gBAAgB;EACd,aAAa,OAAO,MAAM;EAC1B,aAAa,eAAe,MAAM;IACjC;EAAC;EAAO;EAAc;EAAgB;EAAM,CAAC;CAEhD,MAAM,aAAa,kBAAkB;CAErC,MAAM,cAAc,kCAAkC;EACpD;EACA,eAHoB,qBAAqB;EAI1C,CAAC;CAEF,MAAM,YAAY,cAEd;EACE,8BAA8B,OAAO,QAAQ,aAAa,WAAW;EACrE;GACE,eAAe;GACf,YAAY;GACZ,gBAAgB;GAChB,OAAO;GACP,SAAS,WAAW,KAAM;GAC3B;EACD;EACD,EACH;EAAC;EAAU;EAAa;EAAY;EAAO;EAAM,CAClD;CAED,MAAM,YAAY,cACV,8BAA8B,OAAO,QAAQ,aAAa,WAAW,EAC3E;EAAC;EAAa;EAAY;EAAM,CACjC;CAED,MAAM,eAAe,cACb,8BAA8B,OAAO,WAAW,aAAa,WAAW,EAC9E;EAAC;EAAa;EAAY;EAAM,CACjC;CAED,MAAM,aAAa,sBAEf,WAAW,aAAa,IAAI,GAAG;EAC7B,UAAU,eAAe,IAAI;EAC7B,QAAQ,OAAO,IAAI,OAAO,KAAK;EAChC,CAAC,EACJ,CAAC,YAAY,aAAa,CAC3B;CAED,MAAM,qBAAqB,wBAAwB;EACjD,SAAS,WAAW;EACpB,WAAW,CAAC,EAAE,OAAO,KAAM,WAAW,QAAQ,IAAK,CAAC;EACrD,EAAE;CAEH,MAAM,cAAc,kBAAkB;EACpC,IAAI,UACF;EAGF,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,oBAAoB,KAAK;IACxB;EAAC;EAAU;EAAqB;EAAS;EAAU;EAAM,CAAC;CAE7D,MAAM,gBAAgB,kBAAkB;EACtC,IAAI,UACF;EAGF,aAAa,KAAK;EAClB,oBAAoB,MAAM;IACzB;EAAC;EAAU;EAAqB;EAAM,CAAC;CAE1C,MAAM,iBAAiB,kBAAkB;EACvC,aAAa,MAAM;IAClB,EAAE,CAAC;CAEN,IAAI,CAAC,MACH,OAAO;CAGT,OACE,qBAACA,WAAD;EACU;EACE;EACV,SAAS;EACT,WAAW;EACX,YAAY;EACZ,OAAO;EACP,mBAAkB;EAClB,oBAAoB;GAAE,UAAU,CAAC,CAAC;GAAU,UAAU;GAAY;YARpE,CAUE,oBAAC,QAAD;GAAQ,WAAU;GAAI,YAAW;GAAS,gBAAe;GAAa,OAAO,EAAE,MAAM,GAAG;aACtF,oBAACC,MAAD;IAAQ,OAAO;IAAW,eAAe;IACtC;IACM,CAAA;GACF,CAAA,EAET,oBAAC,SAAS,MAAV;GAAe,OAAO;GAAoB,eAAc;aACtD,oBAAC,UAAD;IAAU,MAAK;IAAQ,MAAK;IAAK,SAAQ;IAAO,OAAO;IAAgB,CAAA;GACzD,CAAA,CACJ;;EAEhB;AAEF,WAAW,cAAc"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
const require_components_IconSlot = require("../IconSlot.cjs");
|
|
5
|
+
const require_components_internal_Overlay_measureTrigger = require("../internal/Overlay/measureTrigger.cjs");
|
|
6
|
+
const require_components_Select_selectContext = require("./selectContext.cjs");
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let react_native = require("react-native");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
let generated_styles = require("../../../generated/styles");
|
|
11
|
+
let react_native_reanimated = require("react-native-reanimated");
|
|
12
|
+
react_native_reanimated = require_runtime.__toESM(react_native_reanimated);
|
|
13
|
+
//#region src/components/Select/SelectTrigger.tsx
|
|
14
|
+
const SelectTrigger = (0, react.memo)(function SelectTrigger({ startIcon, endIcon }) {
|
|
15
|
+
const { value, open, setOpen, triggerRef, triggerRect, setTriggerRect, getItemLabel, setHighlightedValue, reduceMotion } = require_components_Select_selectContext.useSelectContext();
|
|
16
|
+
const { size, disabled, readOnly, hasError, placeholder, uid, width } = require_components_Select_selectContext.useSelectFieldContext();
|
|
17
|
+
const hasValue = value.length > 0;
|
|
18
|
+
const valueState = hasValue ? "filled" : "empty";
|
|
19
|
+
const isInteractive = !readOnly && !disabled;
|
|
20
|
+
const useAnimatedChevron = endIcon === void 0;
|
|
21
|
+
const displayText = hasValue ? getItemLabel(value) ?? value : placeholder ?? "";
|
|
22
|
+
generated_styles.inputStyles.useVariants({
|
|
23
|
+
size,
|
|
24
|
+
value: valueState,
|
|
25
|
+
pressed: open,
|
|
26
|
+
readonly: readOnly,
|
|
27
|
+
invalid: hasError
|
|
28
|
+
});
|
|
29
|
+
const inputWrapperStyle = (0, react.useMemo)(() => [
|
|
30
|
+
generated_styles.inputStyles.inputWrapper,
|
|
31
|
+
generated_styles.inputStyles.inputWrapperStatic,
|
|
32
|
+
generated_styles.inputStyles.inputWrapperDynamic,
|
|
33
|
+
{
|
|
34
|
+
flexDirection: "row",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
width,
|
|
37
|
+
alignSelf: "stretch"
|
|
38
|
+
}
|
|
39
|
+
], [
|
|
40
|
+
generated_styles.inputStyles.inputWrapper,
|
|
41
|
+
generated_styles.inputStyles.inputWrapperDynamic,
|
|
42
|
+
generated_styles.inputStyles.inputWrapperStatic,
|
|
43
|
+
width
|
|
44
|
+
]);
|
|
45
|
+
const textContainerStyle = (0, react.useMemo)(() => [{
|
|
46
|
+
flex: 1,
|
|
47
|
+
justifyContent: "center"
|
|
48
|
+
}, typeof generated_styles.inputStyles.input.height === "number" ? { minHeight: generated_styles.inputStyles.input.height } : null], [generated_styles.inputStyles.input]);
|
|
49
|
+
const textInputStyle = (0, react.useMemo)(() => [
|
|
50
|
+
{
|
|
51
|
+
fontFamily: generated_styles.inputStyles.inputWrapperStatic.fontFamily,
|
|
52
|
+
fontSize: generated_styles.inputStyles.inputWrapperStatic.fontSize,
|
|
53
|
+
letterSpacing: generated_styles.inputStyles.inputWrapperStatic.letterSpacing,
|
|
54
|
+
lineHeight: generated_styles.inputStyles.inputWrapperStatic.fontSize,
|
|
55
|
+
paddingVertical: 0
|
|
56
|
+
},
|
|
57
|
+
generated_styles.inputStyles.input,
|
|
58
|
+
{ height: void 0 },
|
|
59
|
+
!hasValue ? generated_styles.inputStyles.inputPlaceholder : null
|
|
60
|
+
], [
|
|
61
|
+
hasValue,
|
|
62
|
+
generated_styles.inputStyles.input,
|
|
63
|
+
generated_styles.inputStyles.inputPlaceholder,
|
|
64
|
+
generated_styles.inputStyles.inputWrapperStatic
|
|
65
|
+
]);
|
|
66
|
+
const chevronProgress = (0, react_native_reanimated.useDerivedValue)(() => (0, react_native_reanimated.withTiming)(open ? 1 : 0, {
|
|
67
|
+
duration: reduceMotion ? 0 : 200,
|
|
68
|
+
easing: react_native_reanimated.Easing.out(react_native_reanimated.Easing.ease)
|
|
69
|
+
}), [open, reduceMotion]);
|
|
70
|
+
const chevronAnimatedStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ transform: [{ rotate: `${chevronProgress.value * 180}deg` }] }));
|
|
71
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
72
|
+
ref: (0, react.useCallback)((node) => {
|
|
73
|
+
triggerRef.current = node;
|
|
74
|
+
}, [triggerRef]),
|
|
75
|
+
testID: "select-trigger",
|
|
76
|
+
onPress: (0, react.useCallback)(() => {
|
|
77
|
+
if (!isInteractive) return;
|
|
78
|
+
if (open) {
|
|
79
|
+
setOpen(false);
|
|
80
|
+
setHighlightedValue(null);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
require_components_internal_Overlay_measureTrigger.measureTrigger(triggerRef.current, triggerRect, setTriggerRect);
|
|
84
|
+
setHighlightedValue(null);
|
|
85
|
+
setOpen(true);
|
|
86
|
+
}, [
|
|
87
|
+
isInteractive,
|
|
88
|
+
open,
|
|
89
|
+
setHighlightedValue,
|
|
90
|
+
setOpen,
|
|
91
|
+
setTriggerRect,
|
|
92
|
+
triggerRect,
|
|
93
|
+
triggerRef
|
|
94
|
+
]),
|
|
95
|
+
disabled: !isInteractive,
|
|
96
|
+
style: {
|
|
97
|
+
width,
|
|
98
|
+
alignSelf: "stretch"
|
|
99
|
+
},
|
|
100
|
+
accessibilityRole: "button",
|
|
101
|
+
accessibilityLabel: displayText || uid,
|
|
102
|
+
accessibilityState: {
|
|
103
|
+
disabled: !isInteractive,
|
|
104
|
+
expanded: open,
|
|
105
|
+
selected: hasValue
|
|
106
|
+
},
|
|
107
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
108
|
+
style: inputWrapperStyle,
|
|
109
|
+
pointerEvents: "none",
|
|
110
|
+
children: [
|
|
111
|
+
startIcon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
112
|
+
icon: startIcon,
|
|
113
|
+
variant: "outline",
|
|
114
|
+
style: generated_styles.inputStyles.startIcon
|
|
115
|
+
}) : null,
|
|
116
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
117
|
+
style: textContainerStyle,
|
|
118
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
119
|
+
numberOfLines: 1,
|
|
120
|
+
style: textInputStyle,
|
|
121
|
+
children: displayText
|
|
122
|
+
})
|
|
123
|
+
}),
|
|
124
|
+
useAnimatedChevron || endIcon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
125
|
+
style: useAnimatedChevron ? chevronAnimatedStyle : void 0,
|
|
126
|
+
testID: "select-chevron",
|
|
127
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
128
|
+
icon: useAnimatedChevron ? "ChevronDown" : endIcon,
|
|
129
|
+
size: "sm",
|
|
130
|
+
variant: "outline",
|
|
131
|
+
style: generated_styles.inputStyles.endIcon
|
|
132
|
+
})
|
|
133
|
+
}) : null
|
|
134
|
+
]
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
SelectTrigger.displayName = "SelectTrigger";
|
|
139
|
+
//#endregion
|
|
140
|
+
exports.SelectTrigger = SelectTrigger;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import { IconSlotType } from "../IconSlot.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Select/SelectTrigger.d.ts
|
|
6
|
+
interface SelectTriggerProps {
|
|
7
|
+
startIcon?: IconSlotType;
|
|
8
|
+
endIcon?: IconSlotType;
|
|
9
|
+
}
|
|
10
|
+
declare const SelectTrigger: _$react.NamedExoticComponent<SelectTriggerProps>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { SelectTrigger, type SelectTriggerProps };
|
|
13
|
+
//# sourceMappingURL=SelectTrigger.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectTrigger.d.cts","names":[],"sources":["../../../src/components/Select/SelectTrigger.tsx"],"mappings":";;;;;UAgBU,kBAAA;EACR,SAAA,GAAY,YAAA;EACZ,OAAA,GAAU,YAAA;AAAA;AAAA,cAGN,aAAA,EAAa,OAAA,CAAA,oBAAA,CAAA,kBAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import { IconSlotType } from "../IconSlot.js";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Select/SelectTrigger.d.ts
|
|
6
|
+
interface SelectTriggerProps {
|
|
7
|
+
startIcon?: IconSlotType;
|
|
8
|
+
endIcon?: IconSlotType;
|
|
9
|
+
}
|
|
10
|
+
declare const SelectTrigger: _$react.NamedExoticComponent<SelectTriggerProps>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { SelectTrigger, type SelectTriggerProps };
|
|
13
|
+
//# sourceMappingURL=SelectTrigger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectTrigger.d.ts","names":[],"sources":["../../../src/components/Select/SelectTrigger.tsx"],"mappings":";;;;;UAgBU,kBAAA;EACR,SAAA,GAAY,YAAA;EACZ,OAAA,GAAU,YAAA;AAAA;AAAA,cAGN,aAAA,EAAa,OAAA,CAAA,oBAAA,CAAA,kBAAA"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { IconSlot } from "../IconSlot.js";
|
|
3
|
+
import { measureTrigger } from "../internal/Overlay/measureTrigger.js";
|
|
4
|
+
import { useSelectContext, useSelectFieldContext } from "./selectContext.js";
|
|
5
|
+
import { memo, useCallback, useMemo } from "react";
|
|
6
|
+
import { Pressable, Text, View } from "react-native";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { inputStyles } from "../../../generated/styles";
|
|
9
|
+
import Animated, { Easing, useAnimatedStyle, useDerivedValue, withTiming } from "react-native-reanimated";
|
|
10
|
+
//#region src/components/Select/SelectTrigger.tsx
|
|
11
|
+
const SelectTrigger = memo(function SelectTrigger({ startIcon, endIcon }) {
|
|
12
|
+
const { value, open, setOpen, triggerRef, triggerRect, setTriggerRect, getItemLabel, setHighlightedValue, reduceMotion } = useSelectContext();
|
|
13
|
+
const { size, disabled, readOnly, hasError, placeholder, uid, width } = useSelectFieldContext();
|
|
14
|
+
const hasValue = value.length > 0;
|
|
15
|
+
const valueState = hasValue ? "filled" : "empty";
|
|
16
|
+
const isInteractive = !readOnly && !disabled;
|
|
17
|
+
const useAnimatedChevron = endIcon === void 0;
|
|
18
|
+
const displayText = hasValue ? getItemLabel(value) ?? value : placeholder ?? "";
|
|
19
|
+
inputStyles.useVariants({
|
|
20
|
+
size,
|
|
21
|
+
value: valueState,
|
|
22
|
+
pressed: open,
|
|
23
|
+
readonly: readOnly,
|
|
24
|
+
invalid: hasError
|
|
25
|
+
});
|
|
26
|
+
const inputWrapperStyle = useMemo(() => [
|
|
27
|
+
inputStyles.inputWrapper,
|
|
28
|
+
inputStyles.inputWrapperStatic,
|
|
29
|
+
inputStyles.inputWrapperDynamic,
|
|
30
|
+
{
|
|
31
|
+
flexDirection: "row",
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
width,
|
|
34
|
+
alignSelf: "stretch"
|
|
35
|
+
}
|
|
36
|
+
], [
|
|
37
|
+
inputStyles.inputWrapper,
|
|
38
|
+
inputStyles.inputWrapperDynamic,
|
|
39
|
+
inputStyles.inputWrapperStatic,
|
|
40
|
+
width
|
|
41
|
+
]);
|
|
42
|
+
const textContainerStyle = useMemo(() => [{
|
|
43
|
+
flex: 1,
|
|
44
|
+
justifyContent: "center"
|
|
45
|
+
}, typeof inputStyles.input.height === "number" ? { minHeight: inputStyles.input.height } : null], [inputStyles.input]);
|
|
46
|
+
const textInputStyle = useMemo(() => [
|
|
47
|
+
{
|
|
48
|
+
fontFamily: inputStyles.inputWrapperStatic.fontFamily,
|
|
49
|
+
fontSize: inputStyles.inputWrapperStatic.fontSize,
|
|
50
|
+
letterSpacing: inputStyles.inputWrapperStatic.letterSpacing,
|
|
51
|
+
lineHeight: inputStyles.inputWrapperStatic.fontSize,
|
|
52
|
+
paddingVertical: 0
|
|
53
|
+
},
|
|
54
|
+
inputStyles.input,
|
|
55
|
+
{ height: void 0 },
|
|
56
|
+
!hasValue ? inputStyles.inputPlaceholder : null
|
|
57
|
+
], [
|
|
58
|
+
hasValue,
|
|
59
|
+
inputStyles.input,
|
|
60
|
+
inputStyles.inputPlaceholder,
|
|
61
|
+
inputStyles.inputWrapperStatic
|
|
62
|
+
]);
|
|
63
|
+
const chevronProgress = useDerivedValue(() => withTiming(open ? 1 : 0, {
|
|
64
|
+
duration: reduceMotion ? 0 : 200,
|
|
65
|
+
easing: Easing.out(Easing.ease)
|
|
66
|
+
}), [open, reduceMotion]);
|
|
67
|
+
const chevronAnimatedStyle = useAnimatedStyle(() => ({ transform: [{ rotate: `${chevronProgress.value * 180}deg` }] }));
|
|
68
|
+
return /* @__PURE__ */ jsx(Pressable, {
|
|
69
|
+
ref: useCallback((node) => {
|
|
70
|
+
triggerRef.current = node;
|
|
71
|
+
}, [triggerRef]),
|
|
72
|
+
testID: "select-trigger",
|
|
73
|
+
onPress: useCallback(() => {
|
|
74
|
+
if (!isInteractive) return;
|
|
75
|
+
if (open) {
|
|
76
|
+
setOpen(false);
|
|
77
|
+
setHighlightedValue(null);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
measureTrigger(triggerRef.current, triggerRect, setTriggerRect);
|
|
81
|
+
setHighlightedValue(null);
|
|
82
|
+
setOpen(true);
|
|
83
|
+
}, [
|
|
84
|
+
isInteractive,
|
|
85
|
+
open,
|
|
86
|
+
setHighlightedValue,
|
|
87
|
+
setOpen,
|
|
88
|
+
setTriggerRect,
|
|
89
|
+
triggerRect,
|
|
90
|
+
triggerRef
|
|
91
|
+
]),
|
|
92
|
+
disabled: !isInteractive,
|
|
93
|
+
style: {
|
|
94
|
+
width,
|
|
95
|
+
alignSelf: "stretch"
|
|
96
|
+
},
|
|
97
|
+
accessibilityRole: "button",
|
|
98
|
+
accessibilityLabel: displayText || uid,
|
|
99
|
+
accessibilityState: {
|
|
100
|
+
disabled: !isInteractive,
|
|
101
|
+
expanded: open,
|
|
102
|
+
selected: hasValue
|
|
103
|
+
},
|
|
104
|
+
children: /* @__PURE__ */ jsxs(View, {
|
|
105
|
+
style: inputWrapperStyle,
|
|
106
|
+
pointerEvents: "none",
|
|
107
|
+
children: [
|
|
108
|
+
startIcon ? /* @__PURE__ */ jsx(IconSlot, {
|
|
109
|
+
icon: startIcon,
|
|
110
|
+
variant: "outline",
|
|
111
|
+
style: inputStyles.startIcon
|
|
112
|
+
}) : null,
|
|
113
|
+
/* @__PURE__ */ jsx(View, {
|
|
114
|
+
style: textContainerStyle,
|
|
115
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
116
|
+
numberOfLines: 1,
|
|
117
|
+
style: textInputStyle,
|
|
118
|
+
children: displayText
|
|
119
|
+
})
|
|
120
|
+
}),
|
|
121
|
+
useAnimatedChevron || endIcon ? /* @__PURE__ */ jsx(Animated.View, {
|
|
122
|
+
style: useAnimatedChevron ? chevronAnimatedStyle : void 0,
|
|
123
|
+
testID: "select-chevron",
|
|
124
|
+
children: /* @__PURE__ */ jsx(IconSlot, {
|
|
125
|
+
icon: useAnimatedChevron ? "ChevronDown" : endIcon,
|
|
126
|
+
size: "sm",
|
|
127
|
+
variant: "outline",
|
|
128
|
+
style: inputStyles.endIcon
|
|
129
|
+
})
|
|
130
|
+
}) : null
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
SelectTrigger.displayName = "SelectTrigger";
|
|
136
|
+
//#endregion
|
|
137
|
+
export { SelectTrigger };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=SelectTrigger.js.map
|