@webority-technologies/mobile 0.0.15 → 0.0.21
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/lib/commonjs/components/Accordion/Accordion.js +60 -19
- package/lib/commonjs/components/AppBar/AppBar.js +29 -20
- package/lib/commonjs/components/Avatar/Avatar.js +38 -8
- package/lib/commonjs/components/Badge/Badge.js +66 -4
- package/lib/commonjs/components/Banner/Banner.js +146 -66
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +37 -15
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +78 -53
- package/lib/commonjs/components/Button/Button.js +12 -5
- package/lib/commonjs/components/Card/Card.js +106 -16
- package/lib/commonjs/components/Carousel/Carousel.js +66 -12
- package/lib/commonjs/components/Checkbox/Checkbox.js +11 -7
- package/lib/commonjs/components/Chip/Chip.js +44 -12
- package/lib/commonjs/components/DatePicker/DatePicker.js +185 -76
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +133 -59
- package/lib/commonjs/components/Dialog/Dialog.js +16 -10
- package/lib/commonjs/components/Drawer/Drawer.js +13 -10
- package/lib/commonjs/components/FieldBase/FieldBase.js +494 -0
- package/lib/commonjs/components/FieldBase/index.js +32 -0
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +69 -44
- package/lib/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
- package/lib/commonjs/components/FormField/FormField.js +3 -2
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +132 -44
- package/lib/commonjs/components/Input/Input.js +144 -181
- package/lib/commonjs/components/ListItem/ListItem.js +90 -11
- package/lib/commonjs/components/Modal/Modal.js +55 -27
- package/lib/commonjs/components/NumberInput/NumberInput.js +60 -106
- package/lib/commonjs/components/OTPInput/OTPInput.js +65 -58
- package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +185 -0
- package/lib/commonjs/components/{AppIcon → PickerTrigger}/index.js +4 -4
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +19 -11
- package/lib/commonjs/components/Radio/Radio.js +11 -6
- package/lib/commonjs/components/Rating/Rating.js +85 -19
- package/lib/commonjs/components/SearchBar/SearchBar.js +90 -107
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +22 -11
- package/lib/commonjs/components/Select/Select.js +62 -91
- package/lib/commonjs/components/Skeleton/Skeleton.js +131 -174
- package/lib/commonjs/components/Skeleton/SkeletonClock.js +117 -0
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +164 -81
- package/lib/commonjs/components/Skeleton/SkeletonProvider.js +72 -10
- package/lib/commonjs/components/Skeleton/index.js +17 -16
- package/lib/commonjs/components/Slider/Slider.js +44 -25
- package/lib/commonjs/components/Stepper/Stepper.js +199 -29
- package/lib/commonjs/components/Swipeable/Swipeable.js +36 -19
- package/lib/commonjs/components/Switch/Switch.js +9 -2
- package/lib/commonjs/components/Tabs/Tabs.js +84 -21
- package/lib/commonjs/components/TimePicker/TimePicker.js +123 -45
- package/lib/commonjs/components/Toast/Toast.js +27 -16
- package/lib/commonjs/components/Tooltip/Tooltip.js +56 -32
- package/lib/commonjs/components/index.js +37 -37
- package/lib/commonjs/theme/tokens.js +55 -7
- package/lib/module/components/Accordion/Accordion.js +61 -20
- package/lib/module/components/AppBar/AppBar.js +29 -20
- package/lib/module/components/Avatar/Avatar.js +39 -9
- package/lib/module/components/Badge/Badge.js +67 -5
- package/lib/module/components/Banner/Banner.js +147 -67
- package/lib/module/components/BottomNavigation/BottomNavigation.js +37 -15
- package/lib/module/components/BottomSheet/BottomSheet.js +80 -55
- package/lib/module/components/Button/Button.js +12 -5
- package/lib/module/components/Card/Card.js +107 -17
- package/lib/module/components/Carousel/Carousel.js +67 -13
- package/lib/module/components/Checkbox/Checkbox.js +11 -7
- package/lib/module/components/Chip/Chip.js +45 -13
- package/lib/module/components/DatePicker/DatePicker.js +185 -76
- package/lib/module/components/DateRangePicker/DateRangePicker.js +134 -60
- package/lib/module/components/Dialog/Dialog.js +16 -10
- package/lib/module/components/Drawer/Drawer.js +13 -10
- package/lib/module/components/FieldBase/FieldBase.js +485 -0
- package/lib/module/components/FieldBase/index.js +4 -0
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +69 -44
- package/lib/module/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
- package/lib/module/components/FormField/FormField.js +3 -2
- package/lib/module/components/ImageGallery/ImageGallery.js +128 -40
- package/lib/module/components/Input/Input.js +144 -179
- package/lib/module/components/ListItem/ListItem.js +91 -12
- package/lib/module/components/Modal/Modal.js +55 -27
- package/lib/module/components/NumberInput/NumberInput.js +60 -106
- package/lib/module/components/OTPInput/OTPInput.js +65 -58
- package/lib/module/components/PickerTrigger/PickerTrigger.js +181 -0
- package/lib/module/components/PickerTrigger/index.js +4 -0
- package/lib/module/components/ProgressBar/ProgressBar.js +19 -11
- package/lib/module/components/Radio/Radio.js +11 -6
- package/lib/module/components/Rating/Rating.js +86 -20
- package/lib/module/components/SearchBar/SearchBar.js +90 -107
- package/lib/module/components/SegmentedControl/SegmentedControl.js +22 -11
- package/lib/module/components/Select/Select.js +62 -91
- package/lib/module/components/Skeleton/Skeleton.js +135 -175
- package/lib/module/components/Skeleton/SkeletonClock.js +110 -0
- package/lib/module/components/Skeleton/SkeletonContent.js +167 -84
- package/lib/module/components/Skeleton/SkeletonProvider.js +71 -10
- package/lib/module/components/Skeleton/index.js +3 -2
- package/lib/module/components/Slider/Slider.js +44 -25
- package/lib/module/components/Stepper/Stepper.js +201 -31
- package/lib/module/components/Swipeable/Swipeable.js +36 -19
- package/lib/module/components/Switch/Switch.js +9 -2
- package/lib/module/components/Tabs/Tabs.js +84 -21
- package/lib/module/components/TimePicker/TimePicker.js +123 -45
- package/lib/module/components/Toast/Toast.js +27 -16
- package/lib/module/components/Tooltip/Tooltip.js +56 -32
- package/lib/module/components/index.js +2 -2
- package/lib/module/theme/tokens.js +55 -7
- package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +10 -5
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +8 -0
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +12 -6
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +7 -6
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +17 -6
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/lib/typescript/commonjs/components/Card/Card.d.ts +17 -6
- package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +7 -6
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +9 -1
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +13 -6
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +38 -3
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +36 -3
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +172 -0
- package/lib/typescript/commonjs/components/FieldBase/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
- package/lib/typescript/commonjs/components/FloatingActionButton/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +7 -0
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +6 -4
- package/lib/typescript/commonjs/components/Input/Input.d.ts +7 -1
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +13 -6
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -0
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +57 -0
- package/lib/typescript/commonjs/components/PickerTrigger/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -0
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +9 -6
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +49 -20
- package/lib/typescript/commonjs/components/Skeleton/SkeletonClock.d.ts +60 -0
- package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +80 -19
- package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +39 -5
- package/lib/typescript/commonjs/components/Skeleton/index.d.ts +6 -4
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +12 -1
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +18 -6
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +2 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +1 -0
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +26 -2
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +36 -3
- package/lib/typescript/commonjs/components/Toast/Toast.d.ts +8 -0
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +7 -1
- package/lib/typescript/commonjs/components/index.d.ts +5 -5
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/types.d.ts +578 -12
- package/lib/typescript/module/components/Accordion/Accordion.d.ts +10 -5
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +8 -0
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +12 -6
- package/lib/typescript/module/components/Badge/Badge.d.ts +7 -6
- package/lib/typescript/module/components/Banner/Banner.d.ts +17 -6
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/lib/typescript/module/components/Card/Card.d.ts +17 -6
- package/lib/typescript/module/components/Carousel/Carousel.d.ts +7 -6
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +9 -1
- package/lib/typescript/module/components/Chip/Chip.d.ts +13 -6
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +38 -3
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +36 -3
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +172 -0
- package/lib/typescript/module/components/FieldBase/index.d.ts +3 -0
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
- package/lib/typescript/module/components/FloatingActionButton/index.d.ts +1 -1
- package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
- package/lib/typescript/module/components/FormField/FormField.d.ts +7 -0
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +6 -4
- package/lib/typescript/module/components/Input/Input.d.ts +7 -1
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +13 -6
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -0
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +57 -0
- package/lib/typescript/module/components/PickerTrigger/index.d.ts +3 -0
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/module/components/Radio/Radio.d.ts +3 -0
- package/lib/typescript/module/components/Rating/Rating.d.ts +9 -6
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +49 -20
- package/lib/typescript/module/components/Skeleton/SkeletonClock.d.ts +60 -0
- package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +80 -19
- package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +39 -5
- package/lib/typescript/module/components/Skeleton/index.d.ts +6 -4
- package/lib/typescript/module/components/Slider/Slider.d.ts +12 -1
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +18 -6
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +2 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +1 -0
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +26 -2
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +36 -3
- package/lib/typescript/module/components/Toast/Toast.d.ts +8 -0
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +7 -1
- package/lib/typescript/module/components/index.d.ts +5 -5
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/theme/index.d.ts +1 -1
- package/lib/typescript/module/theme/types.d.ts +578 -12
- package/package.json +2 -6
- package/lib/commonjs/components/AppIcon/AppIcon.js +0 -120
- package/lib/commonjs/types/vector-icons.d.js +0 -2
- package/lib/module/components/AppIcon/AppIcon.js +0 -111
- package/lib/module/components/AppIcon/index.js +0 -4
- package/lib/module/types/vector-icons.d.js +0 -2
- package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +0 -20
- package/lib/typescript/commonjs/components/AppIcon/index.d.ts +0 -3
- package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +0 -20
- package/lib/typescript/module/components/AppIcon/index.d.ts +0 -3
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PickerTrigger — the tappable input field that opens a modal picker.
|
|
5
|
+
*
|
|
6
|
+
* Standalone read-only field built on FieldBase, used by DatePicker,
|
|
7
|
+
* TimePicker and DateRangePicker (and any consumer-built picker) to render
|
|
8
|
+
* the closed-state row that matches Input / Select pixel-for-pixel.
|
|
9
|
+
*
|
|
10
|
+
* The component is purely visual + interactive — it does not own picker
|
|
11
|
+
* state. Consumers either:
|
|
12
|
+
* - Use the built-in trigger mode on a picker, which composes this
|
|
13
|
+
* internally and manages its own open/close.
|
|
14
|
+
* - Render PickerTrigger themselves alongside a controlled picker.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
18
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
19
|
+
import { fontFor, useTheme } from "../../theme/index.js";
|
|
20
|
+
import { FieldBase, resolveFieldSize, resolveFieldTextStyle } from "../FieldBase/index.js";
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
const PickerTrigger = /*#__PURE__*/forwardRef((props, _ref) => {
|
|
23
|
+
const {
|
|
24
|
+
value,
|
|
25
|
+
placeholder,
|
|
26
|
+
label,
|
|
27
|
+
helperText,
|
|
28
|
+
error,
|
|
29
|
+
required = false,
|
|
30
|
+
onPress,
|
|
31
|
+
clearable = false,
|
|
32
|
+
onClear,
|
|
33
|
+
leadingIcon,
|
|
34
|
+
trailing,
|
|
35
|
+
disabled = false,
|
|
36
|
+
size = 'md',
|
|
37
|
+
variant,
|
|
38
|
+
style,
|
|
39
|
+
triggerStyle,
|
|
40
|
+
valueStyle,
|
|
41
|
+
labelStyle,
|
|
42
|
+
messageStyle,
|
|
43
|
+
accessibilityLabel,
|
|
44
|
+
testID
|
|
45
|
+
} = props;
|
|
46
|
+
const theme = useTheme();
|
|
47
|
+
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
48
|
+
const sizeTokens = resolveFieldSize(theme, size);
|
|
49
|
+
const fieldText = resolveFieldTextStyle(theme, {
|
|
50
|
+
disabled
|
|
51
|
+
});
|
|
52
|
+
const hasValue = typeof value === 'string' && value.length > 0;
|
|
53
|
+
const hasError = typeof error === 'string' && error.length > 0;
|
|
54
|
+
const displayText = hasValue ? value : placeholder ?? 'Select…';
|
|
55
|
+
const valueColor = hasValue ? fieldText.color : fieldText.placeholderColor;
|
|
56
|
+
const a11ySummary = hasValue ? `${label ?? 'Selection'}: ${value}` : placeholder ?? 'No selection';
|
|
57
|
+
const a11yLabel = accessibilityLabel ?? a11ySummary;
|
|
58
|
+
const a11yState = {
|
|
59
|
+
disabled
|
|
60
|
+
};
|
|
61
|
+
const handleClear = () => {
|
|
62
|
+
if (disabled) return;
|
|
63
|
+
onClear?.();
|
|
64
|
+
};
|
|
65
|
+
const showChevron = trailing === undefined;
|
|
66
|
+
const showClear = clearable && hasValue && !disabled;
|
|
67
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
68
|
+
style: [styles.root, style],
|
|
69
|
+
testID: testID,
|
|
70
|
+
children: [label ? /*#__PURE__*/_jsxs(Text, {
|
|
71
|
+
style: [styles.label, {
|
|
72
|
+
color: hasError ? theme.colors.error : theme.colors.text.secondary,
|
|
73
|
+
fontSize: theme.typography.fontSize.sm,
|
|
74
|
+
...fontFor(theme, 'medium'),
|
|
75
|
+
marginBottom: theme.spacing.xxs
|
|
76
|
+
}, labelStyle],
|
|
77
|
+
children: [label, required ? /*#__PURE__*/_jsx(Text, {
|
|
78
|
+
style: {
|
|
79
|
+
color: theme.colors.error
|
|
80
|
+
},
|
|
81
|
+
children: " *"
|
|
82
|
+
}) : null]
|
|
83
|
+
}) : null, /*#__PURE__*/_jsx(FieldBase, {
|
|
84
|
+
size: size,
|
|
85
|
+
variant: variant,
|
|
86
|
+
disabled: disabled,
|
|
87
|
+
error: hasError,
|
|
88
|
+
filled: hasValue,
|
|
89
|
+
onPress: onPress,
|
|
90
|
+
leading: leadingIcon,
|
|
91
|
+
trailing: showClear || showChevron || trailing !== null ? /*#__PURE__*/_jsxs(View, {
|
|
92
|
+
style: styles.trailingRow,
|
|
93
|
+
children: [showClear ? /*#__PURE__*/_jsx(Text, {
|
|
94
|
+
onPress: handleClear,
|
|
95
|
+
accessibilityRole: "button",
|
|
96
|
+
accessibilityLabel: "Clear",
|
|
97
|
+
style: {
|
|
98
|
+
fontSize: sizeTokens.iconSize,
|
|
99
|
+
color: theme.colors.text.secondary,
|
|
100
|
+
paddingHorizontal: 4
|
|
101
|
+
},
|
|
102
|
+
children: "\xD7"
|
|
103
|
+
}) : null, trailing !== undefined ? trailing : showChevron ? /*#__PURE__*/_jsx(Chevron, {
|
|
104
|
+
size: sizeTokens.iconSize,
|
|
105
|
+
color: disabled ? theme.colors.text.disabled : theme.colors.text.tertiary
|
|
106
|
+
}) : null]
|
|
107
|
+
}) : null,
|
|
108
|
+
accessibilityLabel: a11yLabel,
|
|
109
|
+
accessibilityState: a11yState,
|
|
110
|
+
accessibilityRole: "button",
|
|
111
|
+
style: triggerStyle,
|
|
112
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
113
|
+
numberOfLines: 1,
|
|
114
|
+
style: [styles.valueText, {
|
|
115
|
+
color: valueColor,
|
|
116
|
+
fontSize: sizeTokens.fontSize,
|
|
117
|
+
...fieldText.weightStyle
|
|
118
|
+
}, valueStyle],
|
|
119
|
+
children: displayText
|
|
120
|
+
})
|
|
121
|
+
}), hasError || helperText ? /*#__PURE__*/_jsx(Text, {
|
|
122
|
+
style: [styles.message, {
|
|
123
|
+
color: hasError ? theme.colors.error : theme.colors.text.secondary,
|
|
124
|
+
fontSize: theme.typography.fontSize.xs,
|
|
125
|
+
marginTop: theme.spacing.xxs
|
|
126
|
+
}, messageStyle],
|
|
127
|
+
accessibilityLiveRegion: hasError ? 'polite' : 'none',
|
|
128
|
+
children: hasError ? error : helperText
|
|
129
|
+
}) : null]
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
PickerTrigger.displayName = 'PickerTrigger';
|
|
133
|
+
const Chevron = ({
|
|
134
|
+
size,
|
|
135
|
+
color
|
|
136
|
+
}) => {
|
|
137
|
+
// Simple down-pointing triangle drawn with borders — no icon dependency.
|
|
138
|
+
const half = size / 2;
|
|
139
|
+
return /*#__PURE__*/_jsx(View, {
|
|
140
|
+
style: {
|
|
141
|
+
width: size,
|
|
142
|
+
height: size,
|
|
143
|
+
alignItems: 'center',
|
|
144
|
+
justifyContent: 'center'
|
|
145
|
+
},
|
|
146
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
147
|
+
style: {
|
|
148
|
+
width: 0,
|
|
149
|
+
height: 0,
|
|
150
|
+
borderLeftWidth: half * 0.7,
|
|
151
|
+
borderRightWidth: half * 0.7,
|
|
152
|
+
borderTopWidth: half * 0.7,
|
|
153
|
+
borderLeftColor: 'transparent',
|
|
154
|
+
borderRightColor: 'transparent',
|
|
155
|
+
borderTopColor: color
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
const buildStyles = _theme => StyleSheet.create({
|
|
161
|
+
root: {
|
|
162
|
+
width: '100%'
|
|
163
|
+
},
|
|
164
|
+
label: {
|
|
165
|
+
includeFontPadding: false
|
|
166
|
+
},
|
|
167
|
+
valueText: {
|
|
168
|
+
flex: 1,
|
|
169
|
+
includeFontPadding: false
|
|
170
|
+
},
|
|
171
|
+
message: {
|
|
172
|
+
includeFontPadding: false
|
|
173
|
+
},
|
|
174
|
+
trailingRow: {
|
|
175
|
+
flexDirection: 'row',
|
|
176
|
+
alignItems: 'center'
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
export { PickerTrigger };
|
|
180
|
+
export default PickerTrigger;
|
|
181
|
+
//# sourceMappingURL=PickerTrigger.js.map
|
|
@@ -35,6 +35,8 @@ const ProgressBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
35
35
|
barColor,
|
|
36
36
|
animated = true,
|
|
37
37
|
style,
|
|
38
|
+
containerStyle,
|
|
39
|
+
barStyle,
|
|
38
40
|
accessibilityLabel,
|
|
39
41
|
testID
|
|
40
42
|
} = props;
|
|
@@ -42,7 +44,11 @@ const ProgressBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
42
44
|
const clamped = clampProgress(progress);
|
|
43
45
|
const fillAnim = useRef(createAnimatedValue(clamped)).current;
|
|
44
46
|
const loopAnim = useRef(createAnimatedValue(0)).current;
|
|
47
|
+
const widthAnim = useRef(createAnimatedValue(0)).current;
|
|
45
48
|
const widthRef = useRef(0);
|
|
49
|
+
const determinateDuration = theme.components.progressBar?.determinateAnimationDuration ?? 400;
|
|
50
|
+
const indeterminateDuration = theme.components.progressBar?.indeterminateLoopDuration ?? 1500;
|
|
51
|
+
const indeterminateWidth = theme.components.progressBar?.indeterminateWidth ?? '30%';
|
|
46
52
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
47
53
|
const resolvedRadius = radius ?? theme.radius.full;
|
|
48
54
|
const resolvedTrack = trackColor ?? theme.colors.surface.disabled;
|
|
@@ -55,17 +61,17 @@ const ProgressBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
55
61
|
}
|
|
56
62
|
Animated.timing(fillAnim, {
|
|
57
63
|
toValue: clamped,
|
|
58
|
-
duration:
|
|
64
|
+
duration: determinateDuration,
|
|
59
65
|
easing: Easing.bezier(...theme.motion.easing.standard),
|
|
60
66
|
useNativeDriver: false
|
|
61
67
|
}).start();
|
|
62
|
-
}, [animated, clamped, fillAnim, isIndeterminate, theme]);
|
|
68
|
+
}, [animated, clamped, determinateDuration, fillAnim, isIndeterminate, theme]);
|
|
63
69
|
useEffect(() => {
|
|
64
70
|
if (!isIndeterminate) return;
|
|
65
71
|
setNativeValue(loopAnim, 0);
|
|
66
72
|
const animation = Animated.loop(Animated.timing(loopAnim, {
|
|
67
73
|
toValue: 1,
|
|
68
|
-
duration:
|
|
74
|
+
duration: indeterminateDuration,
|
|
69
75
|
easing: Easing.inOut(Easing.ease),
|
|
70
76
|
useNativeDriver: true
|
|
71
77
|
}));
|
|
@@ -73,7 +79,7 @@ const ProgressBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
73
79
|
return () => {
|
|
74
80
|
animation.stop();
|
|
75
81
|
};
|
|
76
|
-
}, [isIndeterminate, loopAnim]);
|
|
82
|
+
}, [isIndeterminate, loopAnim, indeterminateDuration]);
|
|
77
83
|
const determinateWidth = fillAnim.interpolate({
|
|
78
84
|
inputRange: [0, 1],
|
|
79
85
|
outputRange: ['0%', '100%']
|
|
@@ -83,7 +89,9 @@ const ProgressBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
83
89
|
outputRange: [-1, 1]
|
|
84
90
|
});
|
|
85
91
|
const onLayout = event => {
|
|
86
|
-
|
|
92
|
+
const w = event.nativeEvent.layout.width;
|
|
93
|
+
widthRef.current = w;
|
|
94
|
+
setNativeValue(widthAnim, w);
|
|
87
95
|
};
|
|
88
96
|
return /*#__PURE__*/_jsx(View, {
|
|
89
97
|
ref: ref,
|
|
@@ -102,23 +110,24 @@ const ProgressBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
102
110
|
height,
|
|
103
111
|
borderRadius: resolvedRadius,
|
|
104
112
|
backgroundColor: resolvedTrack
|
|
105
|
-
}, style],
|
|
113
|
+
}, style, containerStyle],
|
|
106
114
|
children: isIndeterminate ? /*#__PURE__*/_jsx(Animated.View, {
|
|
107
115
|
style: [styles.indeterminateBar, {
|
|
108
116
|
height,
|
|
109
117
|
borderRadius: resolvedRadius,
|
|
110
118
|
backgroundColor: resolvedBar,
|
|
119
|
+
width: indeterminateWidth,
|
|
111
120
|
transform: [{
|
|
112
|
-
translateX: Animated.multiply(indeterminateTranslate,
|
|
121
|
+
translateX: Animated.multiply(indeterminateTranslate, widthAnim)
|
|
113
122
|
}]
|
|
114
|
-
}]
|
|
123
|
+
}, barStyle]
|
|
115
124
|
}) : /*#__PURE__*/_jsx(Animated.View, {
|
|
116
125
|
style: [styles.determinateBar, {
|
|
117
126
|
height,
|
|
118
127
|
borderRadius: resolvedRadius,
|
|
119
128
|
backgroundColor: resolvedBar,
|
|
120
129
|
width: determinateWidth
|
|
121
|
-
}]
|
|
130
|
+
}, barStyle]
|
|
122
131
|
})
|
|
123
132
|
});
|
|
124
133
|
});
|
|
@@ -136,8 +145,7 @@ const buildStyles = _theme => StyleSheet.create({
|
|
|
136
145
|
indeterminateBar: {
|
|
137
146
|
position: 'absolute',
|
|
138
147
|
left: 0,
|
|
139
|
-
top: 0
|
|
140
|
-
width: '30%'
|
|
148
|
+
top: 0
|
|
141
149
|
}
|
|
142
150
|
});
|
|
143
151
|
export { ProgressBar };
|
|
@@ -44,9 +44,12 @@ const Radio = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
44
44
|
size = 'md',
|
|
45
45
|
tone = 'primary',
|
|
46
46
|
accessibilityLabel,
|
|
47
|
-
haptic
|
|
47
|
+
haptic,
|
|
48
48
|
style,
|
|
49
|
+
containerStyle,
|
|
49
50
|
circleStyle,
|
|
51
|
+
dotStyle,
|
|
52
|
+
labelStyle,
|
|
50
53
|
testID,
|
|
51
54
|
...rest
|
|
52
55
|
} = props;
|
|
@@ -59,8 +62,10 @@ const Radio = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
59
62
|
const sizeOverrides = theme.components.radio?.[size];
|
|
60
63
|
const outer = sizeOverrides?.outer ?? sizeMap[size].outer;
|
|
61
64
|
const inner = sizeOverrides?.inner ?? sizeMap[size].inner;
|
|
62
|
-
const radioBorderWidth = theme.
|
|
65
|
+
const radioBorderWidth = theme.colors.border.width;
|
|
63
66
|
const radioLabelGap = theme.components.radio?.labelGap ?? 10;
|
|
67
|
+
const pressHapticEnabled = theme.components.radio?.pressHaptic ?? false;
|
|
68
|
+
const resolvedHaptic = haptic === undefined ? pressHapticEnabled ? 'selection' : false : haptic;
|
|
64
69
|
const progress = useRef(createAnimatedValue(selected ? 1 : 0)).current;
|
|
65
70
|
useEffect(() => {
|
|
66
71
|
Animated.spring(progress, {
|
|
@@ -77,7 +82,7 @@ const Radio = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
77
82
|
});
|
|
78
83
|
const handlePress = event => {
|
|
79
84
|
if (disabled) return;
|
|
80
|
-
if (
|
|
85
|
+
if (resolvedHaptic !== false) triggerHaptic(resolvedHaptic);
|
|
81
86
|
if (ctx) {
|
|
82
87
|
ctx.onSelect(value);
|
|
83
88
|
} else {
|
|
@@ -104,7 +109,7 @@ const Radio = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
104
109
|
pressed
|
|
105
110
|
}) => [styles.row, {
|
|
106
111
|
opacity: disabled ? 0.55 : pressed ? 0.85 : 1
|
|
107
|
-
}, style],
|
|
112
|
+
}, style, containerStyle],
|
|
108
113
|
children: [/*#__PURE__*/_jsx(View, {
|
|
109
114
|
style: [styles.outer, {
|
|
110
115
|
width: outer,
|
|
@@ -123,14 +128,14 @@ const Radio = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
123
128
|
transform: [{
|
|
124
129
|
scale
|
|
125
130
|
}]
|
|
126
|
-
}]
|
|
131
|
+
}, dotStyle]
|
|
127
132
|
})
|
|
128
133
|
}), label ? /*#__PURE__*/_jsx(Text, {
|
|
129
134
|
style: [styles.label, {
|
|
130
135
|
marginLeft: radioLabelGap,
|
|
131
136
|
color: disabled ? theme.colors.text.disabled : theme.colors.text.primary,
|
|
132
137
|
fontSize: theme.typography.fontSize.base
|
|
133
|
-
}],
|
|
138
|
+
}, labelStyle],
|
|
134
139
|
numberOfLines: 2,
|
|
135
140
|
children: label
|
|
136
141
|
}) : null]
|
|
@@ -4,7 +4,7 @@ import React, { forwardRef, useCallback, useMemo, useRef } from 'react';
|
|
|
4
4
|
import { Animated, Easing, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { useTheme } from "../../theme/index.js";
|
|
6
6
|
import { triggerHaptic } from "../../utils/hapticUtils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { Skeleton } from "../Skeleton/index.js";
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
const sizePxMap = {
|
|
10
10
|
sm: 16,
|
|
@@ -82,6 +82,8 @@ const Rating = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
82
82
|
loading = false,
|
|
83
83
|
accessibilityLabel,
|
|
84
84
|
style,
|
|
85
|
+
containerStyle,
|
|
86
|
+
starContainerStyle,
|
|
85
87
|
testID
|
|
86
88
|
} = props;
|
|
87
89
|
const theme = useTheme();
|
|
@@ -95,17 +97,31 @@ const Rating = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
95
97
|
const handleStarLayout = useCallback(e => {
|
|
96
98
|
starWidthRef.current = e.nativeEvent.layout.width;
|
|
97
99
|
}, []);
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
const scaleMapRef = useRef(new Map());
|
|
101
|
+
const scaleRefs = useMemo(() => {
|
|
102
|
+
const map = scaleMapRef.current;
|
|
103
|
+
const out = [];
|
|
104
|
+
for (let i = 0; i < max; i += 1) {
|
|
105
|
+
let v = map.get(i);
|
|
106
|
+
if (!v) {
|
|
107
|
+
v = new Animated.Value(1);
|
|
108
|
+
map.set(i, v);
|
|
109
|
+
}
|
|
110
|
+
out.push(v);
|
|
111
|
+
}
|
|
112
|
+
for (const key of Array.from(map.keys())) {
|
|
113
|
+
if (key >= max) map.delete(key);
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}, [max]);
|
|
117
|
+
const pulseOnPress = theme.components.rating?.pulseOnPress ?? false;
|
|
118
|
+
const pulseScale = theme.components.rating?.pulseScale ?? 1.2;
|
|
119
|
+
const pressHapticEnabled = theme.components.rating?.pressHaptic ?? false;
|
|
104
120
|
const pulse = useCallback(idx => {
|
|
105
|
-
const v = scaleRefs
|
|
121
|
+
const v = scaleRefs[idx];
|
|
106
122
|
if (!v) return;
|
|
107
123
|
Animated.sequence([Animated.timing(v, {
|
|
108
|
-
toValue:
|
|
124
|
+
toValue: pulseScale,
|
|
109
125
|
duration: theme.motion.duration.fast,
|
|
110
126
|
easing: Easing.bezier(...theme.motion.easing.standard),
|
|
111
127
|
useNativeDriver: true
|
|
@@ -116,14 +132,14 @@ const Rating = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
116
132
|
mass: theme.motion.spring.bouncy.mass,
|
|
117
133
|
useNativeDriver: true
|
|
118
134
|
})]).start();
|
|
119
|
-
}, [theme.motion]);
|
|
135
|
+
}, [theme.motion, pulseScale, scaleRefs]);
|
|
120
136
|
const commit = useCallback((next, animatedIndex) => {
|
|
121
137
|
if (!interactive || !onChange) return;
|
|
122
138
|
const cleaned = clampToStep(next, max, step);
|
|
123
|
-
triggerHaptic('selection');
|
|
124
|
-
if (typeof animatedIndex === 'number') pulse(animatedIndex);
|
|
139
|
+
if (pressHapticEnabled) triggerHaptic('selection');
|
|
140
|
+
if (pulseOnPress && typeof animatedIndex === 'number') pulse(animatedIndex);
|
|
125
141
|
onChange(cleaned);
|
|
126
|
-
}, [interactive, onChange, max, step, pulse]);
|
|
142
|
+
}, [interactive, onChange, max, step, pulse, pressHapticEnabled, pulseOnPress]);
|
|
127
143
|
const handleStarPress = useCallback(index => e => {
|
|
128
144
|
if (!interactive) return;
|
|
129
145
|
const w = starWidthRef.current || starSize;
|
|
@@ -144,13 +160,15 @@ const Rating = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
144
160
|
const a11yLabel = accessibilityLabel ?? label ?? valueText;
|
|
145
161
|
const stars = [];
|
|
146
162
|
for (let i = 0; i < max; i += 1) {
|
|
163
|
+
const scaleVal = scaleRefs[i];
|
|
164
|
+
if (!scaleVal) continue;
|
|
147
165
|
const star = /*#__PURE__*/_jsx(Star, {
|
|
148
166
|
index: i,
|
|
149
167
|
filled: value,
|
|
150
168
|
size: starSize,
|
|
151
169
|
filledColor: filledColor,
|
|
152
170
|
emptyColor: emptyColor,
|
|
153
|
-
scale:
|
|
171
|
+
scale: scaleVal
|
|
154
172
|
}, i);
|
|
155
173
|
stars.push(interactive ? /*#__PURE__*/_jsx(Pressable, {
|
|
156
174
|
onPress: handleStarPress(i),
|
|
@@ -166,7 +184,7 @@ const Rating = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
166
184
|
}, i));
|
|
167
185
|
}
|
|
168
186
|
const rendered = /*#__PURE__*/_jsxs(View, {
|
|
169
|
-
style: [styles.wrapper, style],
|
|
187
|
+
style: [styles.wrapper, style, containerStyle],
|
|
170
188
|
ref: ref,
|
|
171
189
|
testID: testID,
|
|
172
190
|
children: [label ? /*#__PURE__*/_jsx(Text, {
|
|
@@ -176,7 +194,7 @@ const Rating = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
176
194
|
}],
|
|
177
195
|
children: label
|
|
178
196
|
}) : null, /*#__PURE__*/_jsx(View, {
|
|
179
|
-
style: styles.row,
|
|
197
|
+
style: [styles.row, starContainerStyle],
|
|
180
198
|
accessible: true,
|
|
181
199
|
accessibilityRole: interactive ? 'adjustable' : 'text',
|
|
182
200
|
accessibilityLabel: a11yLabel,
|
|
@@ -196,15 +214,63 @@ const Rating = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
196
214
|
})]
|
|
197
215
|
});
|
|
198
216
|
if (loading) {
|
|
199
|
-
return /*#__PURE__*/_jsx(
|
|
200
|
-
|
|
201
|
-
mode: "auto",
|
|
202
|
-
children: rendered
|
|
217
|
+
return /*#__PURE__*/_jsx(RatingSkeleton, {
|
|
218
|
+
...props
|
|
203
219
|
});
|
|
204
220
|
}
|
|
205
221
|
return rendered;
|
|
206
222
|
});
|
|
207
223
|
Rating.displayName = 'Rating';
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Placeholder shape for `<Rating>`. Row of N star-shaped skeletons sized
|
|
227
|
+
* exactly like the live stars, plus an optional label line above. The
|
|
228
|
+
* footprint stays identical between loading and loaded states.
|
|
229
|
+
*/
|
|
230
|
+
const RatingSkeleton = ({
|
|
231
|
+
max = 5,
|
|
232
|
+
size = 'md',
|
|
233
|
+
label,
|
|
234
|
+
containerStyle,
|
|
235
|
+
starContainerStyle,
|
|
236
|
+
style
|
|
237
|
+
}) => {
|
|
238
|
+
const starSize = resolveSize(size);
|
|
239
|
+
const stars = Math.max(1, max);
|
|
240
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
241
|
+
style: [{
|
|
242
|
+
alignItems: 'flex-start'
|
|
243
|
+
}, containerStyle, style],
|
|
244
|
+
accessibilityRole: "progressbar",
|
|
245
|
+
accessibilityState: {
|
|
246
|
+
busy: true
|
|
247
|
+
},
|
|
248
|
+
children: [label !== undefined ? /*#__PURE__*/_jsx(Skeleton, {
|
|
249
|
+
shape: "text",
|
|
250
|
+
width: 80,
|
|
251
|
+
height: 14,
|
|
252
|
+
style: {
|
|
253
|
+
marginBottom: 6
|
|
254
|
+
}
|
|
255
|
+
}) : null, /*#__PURE__*/_jsx(View, {
|
|
256
|
+
style: [{
|
|
257
|
+
flexDirection: 'row'
|
|
258
|
+
}, starContainerStyle],
|
|
259
|
+
children: Array.from({
|
|
260
|
+
length: stars
|
|
261
|
+
}).map((_, i) => /*#__PURE__*/_jsx(Skeleton, {
|
|
262
|
+
width: starSize,
|
|
263
|
+
height: starSize,
|
|
264
|
+
radius: Math.round(starSize * 0.25),
|
|
265
|
+
style: i < stars - 1 ? {
|
|
266
|
+
marginRight: 4
|
|
267
|
+
} : undefined
|
|
268
|
+
}, `sk-star-${i}`))
|
|
269
|
+
})]
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
RatingSkeleton.displayName = 'RatingSkeleton';
|
|
273
|
+
Rating.Skeleton = RatingSkeleton;
|
|
208
274
|
const starStyles = StyleSheet.create({
|
|
209
275
|
starWrap: {
|
|
210
276
|
position: 'relative',
|