@ecohouse/ui 0.1.45 → 0.1.46
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.cjs +57 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +57 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SegmentedToggle/SegmentedToggle.tsx +46 -50
- package/src/theme/typography.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -28733,7 +28733,7 @@ var avatarTypography = {
|
|
|
28733
28733
|
fontFamily: fonts.sans,
|
|
28734
28734
|
fontSize: 12,
|
|
28735
28735
|
fontWeight: "600",
|
|
28736
|
-
lineHeight:
|
|
28736
|
+
lineHeight: 20,
|
|
28737
28737
|
letterSpacing: 0
|
|
28738
28738
|
}
|
|
28739
28739
|
};
|
|
@@ -32861,7 +32861,6 @@ var ANIMATION_DURATION2 = 200;
|
|
|
32861
32861
|
var OPTION_HORIZONTAL_PADDING = 16;
|
|
32862
32862
|
var OPTION_CONTENT_GAP = 12;
|
|
32863
32863
|
var OPTION_MIN_WIDTH = 97;
|
|
32864
|
-
var OPTION_MEASUREMENT_TOLERANCE = 0.5;
|
|
32865
32864
|
var TRACK_PADDING = 4;
|
|
32866
32865
|
var OPTION_GAP = 4;
|
|
32867
32866
|
function buildIndicatorOutputRange(optionWidths) {
|
|
@@ -32900,18 +32899,15 @@ var SegmentedToggle = react.forwardRef(
|
|
|
32900
32899
|
const setContainerRef = react.useMemo(() => mergeRefs(containerRef, forwardedRef), [forwardedRef]);
|
|
32901
32900
|
const progress = react.useRef(new reactNative.Animated.Value(selectedIndex)).current;
|
|
32902
32901
|
const hasMounted = react.useRef(false);
|
|
32903
|
-
const [
|
|
32902
|
+
const [measuredOptionWidths, setMeasuredOptionWidths] = react.useState(
|
|
32904
32903
|
() => Array.from({ length: optionCount }, () => 0)
|
|
32905
32904
|
);
|
|
32906
32905
|
const [containerWidth, setContainerWidth] = react.useState(0);
|
|
32907
32906
|
const trackChrome = TRACK_PADDING * 2 + OPTION_GAP * (optionCount - 1);
|
|
32908
32907
|
const availableOptionWidth = Math.max(0, (containerWidth - trackChrome) / optionCount);
|
|
32909
|
-
const
|
|
32910
|
-
|
|
32911
|
-
|
|
32912
|
-
) : 0;
|
|
32913
|
-
const optionWidths = fullWidth ? Array.from({ length: optionCount }, () => availableOptionWidth) : contentWidths.map((width) => resolveContentOptionWidth(width));
|
|
32914
|
-
const selectedOptionWidth = optionWidths[selectedIndex] ?? 0;
|
|
32908
|
+
const optionWidths = fullWidth ? Array.from({ length: optionCount }, () => availableOptionWidth) : measuredOptionWidths;
|
|
32909
|
+
const measurementsReady = optionWidths.every((width) => width > 0);
|
|
32910
|
+
const selectedOptionWidth = measurementsReady ? optionWidths[selectedIndex] ?? 0 : 0;
|
|
32915
32911
|
const indicatorInputRange = options.map((_, index) => index);
|
|
32916
32912
|
const indicatorOutputRange = buildIndicatorOutputRange(optionWidths);
|
|
32917
32913
|
const indicatorTranslateX = progress.interpolate({
|
|
@@ -32920,7 +32916,7 @@ var SegmentedToggle = react.forwardRef(
|
|
|
32920
32916
|
});
|
|
32921
32917
|
useApplyWebClassName(containerRef, resolvedClassName);
|
|
32922
32918
|
react.useEffect(() => {
|
|
32923
|
-
|
|
32919
|
+
setMeasuredOptionWidths((current) => {
|
|
32924
32920
|
if (current.length === optionCount) return current;
|
|
32925
32921
|
return Array.from({ length: optionCount }, (_, index) => current[index] ?? 0);
|
|
32926
32922
|
});
|
|
@@ -32965,30 +32961,6 @@ var SegmentedToggle = react.forwardRef(
|
|
|
32965
32961
|
],
|
|
32966
32962
|
accessibilityRole: "radiogroup",
|
|
32967
32963
|
children: [
|
|
32968
|
-
!fullWidth ? options.map(({ value: optionValue, label, icon: Icon2, showLabel = true }, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
32969
|
-
reactNative.View,
|
|
32970
|
-
{
|
|
32971
|
-
pointerEvents: "none",
|
|
32972
|
-
"aria-hidden": true,
|
|
32973
|
-
accessibilityElementsHidden: true,
|
|
32974
|
-
importantForAccessibility: "no-hide-descendants",
|
|
32975
|
-
onLayout: (event) => {
|
|
32976
|
-
const nextWidth = event.nativeEvent.layout.width;
|
|
32977
|
-
setContentWidths((currentWidths) => {
|
|
32978
|
-
if (currentWidths[index] === nextWidth) return currentWidths;
|
|
32979
|
-
const nextWidths = [...currentWidths];
|
|
32980
|
-
nextWidths[index] = nextWidth;
|
|
32981
|
-
return nextWidths;
|
|
32982
|
-
});
|
|
32983
|
-
},
|
|
32984
|
-
style: styles20.optionMeasurement,
|
|
32985
|
-
children: [
|
|
32986
|
-
Icon2 ? /* @__PURE__ */ jsxRuntime.jsx(Icon2, { size: ICON_SIZE8 }) : null,
|
|
32987
|
-
showLabel ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.label, styles20.contentWidthLabel], children: label }) : null
|
|
32988
|
-
]
|
|
32989
|
-
},
|
|
32990
|
-
`${optionValue}-measurement`
|
|
32991
|
-
)) : null,
|
|
32992
32964
|
selectedOptionWidth > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
32993
32965
|
reactNative.Animated.View,
|
|
32994
32966
|
{
|
|
@@ -33003,37 +32975,61 @@ var SegmentedToggle = react.forwardRef(
|
|
|
33003
32975
|
const selected = optionValue === selectedValue;
|
|
33004
32976
|
const iconColor = selected ? colors.primary : colors.whiteAlpha20;
|
|
33005
32977
|
const labelColor = selected ? colors.white : colors.grey150;
|
|
33006
|
-
|
|
33007
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
32978
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
33008
32979
|
reactNative.Pressable,
|
|
33009
32980
|
{
|
|
33010
32981
|
onPress: () => selectOption(optionValue),
|
|
33011
32982
|
disabled,
|
|
33012
32983
|
hitSlop,
|
|
32984
|
+
onLayout: fullWidth ? void 0 : (event) => {
|
|
32985
|
+
const nextWidth = event.nativeEvent.layout.width;
|
|
32986
|
+
setMeasuredOptionWidths((currentWidths) => {
|
|
32987
|
+
if (currentWidths[index] === nextWidth) return currentWidths;
|
|
32988
|
+
const nextWidths = [...currentWidths];
|
|
32989
|
+
nextWidths[index] = nextWidth;
|
|
32990
|
+
return nextWidths;
|
|
32991
|
+
});
|
|
32992
|
+
},
|
|
33013
32993
|
accessibilityRole: "radio",
|
|
33014
32994
|
accessibilityLabel: label,
|
|
33015
32995
|
accessibilityState: { selected, disabled },
|
|
33016
32996
|
style: [
|
|
33017
32997
|
styles20.option,
|
|
33018
|
-
fullWidth ? styles20.optionFullWidth :
|
|
33019
|
-
selected &&
|
|
32998
|
+
fullWidth ? styles20.optionFullWidth : styles20.optionContentWidth,
|
|
32999
|
+
selected && !measurementsReady && styles20.initialSelectedOption
|
|
33020
33000
|
],
|
|
33021
|
-
children:
|
|
33022
|
-
|
|
33023
|
-
|
|
33024
|
-
reactNative.Text,
|
|
33001
|
+
children: [
|
|
33002
|
+
!fullWidth ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
33003
|
+
reactNative.View,
|
|
33025
33004
|
{
|
|
33026
|
-
|
|
33027
|
-
|
|
33028
|
-
|
|
33029
|
-
|
|
33030
|
-
|
|
33031
|
-
|
|
33032
|
-
|
|
33033
|
-
|
|
33005
|
+
"aria-hidden": true,
|
|
33006
|
+
accessibilityElementsHidden: true,
|
|
33007
|
+
importantForAccessibility: "no-hide-descendants",
|
|
33008
|
+
pointerEvents: "none",
|
|
33009
|
+
style: [styles20.optionContent, styles20.optionSizeProbe],
|
|
33010
|
+
children: [
|
|
33011
|
+
Icon2 ? /* @__PURE__ */ jsxRuntime.jsx(Icon2, { size: ICON_SIZE8 }) : null,
|
|
33012
|
+
showLabel ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.label, styles20.selectedLabel, styles20.contentWidthLabel], children: label }) : null
|
|
33013
|
+
]
|
|
33034
33014
|
}
|
|
33035
|
-
) : null
|
|
33036
|
-
|
|
33015
|
+
) : null,
|
|
33016
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles20.optionContent, !fullWidth && styles20.contentWidthVisibleContent], children: [
|
|
33017
|
+
Icon2 ? /* @__PURE__ */ jsxRuntime.jsx(Icon2, { size: ICON_SIZE8, color: iconColor }) : null,
|
|
33018
|
+
showLabel ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
33019
|
+
reactNative.Text,
|
|
33020
|
+
{
|
|
33021
|
+
numberOfLines: fullWidth ? 1 : void 0,
|
|
33022
|
+
style: [
|
|
33023
|
+
styles20.label,
|
|
33024
|
+
selected ? styles20.selectedLabel : styles20.inactiveLabel,
|
|
33025
|
+
!fullWidth && styles20.contentWidthLabel,
|
|
33026
|
+
{ color: labelColor }
|
|
33027
|
+
],
|
|
33028
|
+
children: label
|
|
33029
|
+
}
|
|
33030
|
+
) : null
|
|
33031
|
+
] })
|
|
33032
|
+
]
|
|
33037
33033
|
},
|
|
33038
33034
|
optionValue
|
|
33039
33035
|
);
|
|
@@ -33077,13 +33073,17 @@ var styles20 = reactNative.StyleSheet.create({
|
|
|
33077
33073
|
alignItems: "center",
|
|
33078
33074
|
gap: OPTION_CONTENT_GAP
|
|
33079
33075
|
},
|
|
33080
|
-
|
|
33081
|
-
position: "absolute",
|
|
33082
|
-
flexDirection: "row",
|
|
33083
|
-
alignItems: "center",
|
|
33084
|
-
gap: OPTION_CONTENT_GAP,
|
|
33076
|
+
optionSizeProbe: {
|
|
33085
33077
|
opacity: 0
|
|
33086
33078
|
},
|
|
33079
|
+
contentWidthVisibleContent: {
|
|
33080
|
+
position: "absolute",
|
|
33081
|
+
top: 0,
|
|
33082
|
+
left: 0,
|
|
33083
|
+
width: "100%",
|
|
33084
|
+
height: "100%",
|
|
33085
|
+
justifyContent: "center"
|
|
33086
|
+
},
|
|
33087
33087
|
optionFullWidth: {
|
|
33088
33088
|
flex: 1,
|
|
33089
33089
|
minWidth: 0
|