@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.d.cts
CHANGED
|
@@ -1501,7 +1501,7 @@ declare const selectTypography: {
|
|
|
1501
1501
|
readonly letterSpacing: 0.36;
|
|
1502
1502
|
};
|
|
1503
1503
|
};
|
|
1504
|
-
/** Avatar name / email / menu-item typography —
|
|
1504
|
+
/** Avatar name / email / menu-item typography — compact line heights, 0 letter-spacing. */
|
|
1505
1505
|
declare const avatarTypography: {
|
|
1506
1506
|
readonly name: {
|
|
1507
1507
|
readonly fontFamily: "Noto Sans Armenian";
|
|
@@ -1521,7 +1521,7 @@ declare const avatarTypography: {
|
|
|
1521
1521
|
readonly fontFamily: "Noto Sans Armenian";
|
|
1522
1522
|
readonly fontSize: 12;
|
|
1523
1523
|
readonly fontWeight: "600";
|
|
1524
|
-
readonly lineHeight:
|
|
1524
|
+
readonly lineHeight: 20;
|
|
1525
1525
|
readonly letterSpacing: 0;
|
|
1526
1526
|
};
|
|
1527
1527
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1501,7 +1501,7 @@ declare const selectTypography: {
|
|
|
1501
1501
|
readonly letterSpacing: 0.36;
|
|
1502
1502
|
};
|
|
1503
1503
|
};
|
|
1504
|
-
/** Avatar name / email / menu-item typography —
|
|
1504
|
+
/** Avatar name / email / menu-item typography — compact line heights, 0 letter-spacing. */
|
|
1505
1505
|
declare const avatarTypography: {
|
|
1506
1506
|
readonly name: {
|
|
1507
1507
|
readonly fontFamily: "Noto Sans Armenian";
|
|
@@ -1521,7 +1521,7 @@ declare const avatarTypography: {
|
|
|
1521
1521
|
readonly fontFamily: "Noto Sans Armenian";
|
|
1522
1522
|
readonly fontSize: 12;
|
|
1523
1523
|
readonly fontWeight: "600";
|
|
1524
|
-
readonly lineHeight:
|
|
1524
|
+
readonly lineHeight: 20;
|
|
1525
1525
|
readonly letterSpacing: 0;
|
|
1526
1526
|
};
|
|
1527
1527
|
};
|
package/dist/index.js
CHANGED
|
@@ -28727,7 +28727,7 @@ var avatarTypography = {
|
|
|
28727
28727
|
fontFamily: fonts.sans,
|
|
28728
28728
|
fontSize: 12,
|
|
28729
28729
|
fontWeight: "600",
|
|
28730
|
-
lineHeight:
|
|
28730
|
+
lineHeight: 20,
|
|
28731
28731
|
letterSpacing: 0
|
|
28732
28732
|
}
|
|
28733
28733
|
};
|
|
@@ -32855,7 +32855,6 @@ var ANIMATION_DURATION2 = 200;
|
|
|
32855
32855
|
var OPTION_HORIZONTAL_PADDING = 16;
|
|
32856
32856
|
var OPTION_CONTENT_GAP = 12;
|
|
32857
32857
|
var OPTION_MIN_WIDTH = 97;
|
|
32858
|
-
var OPTION_MEASUREMENT_TOLERANCE = 0.5;
|
|
32859
32858
|
var TRACK_PADDING = 4;
|
|
32860
32859
|
var OPTION_GAP = 4;
|
|
32861
32860
|
function buildIndicatorOutputRange(optionWidths) {
|
|
@@ -32894,18 +32893,15 @@ var SegmentedToggle = forwardRef(
|
|
|
32894
32893
|
const setContainerRef = useMemo(() => mergeRefs(containerRef, forwardedRef), [forwardedRef]);
|
|
32895
32894
|
const progress = useRef(new Animated.Value(selectedIndex)).current;
|
|
32896
32895
|
const hasMounted = useRef(false);
|
|
32897
|
-
const [
|
|
32896
|
+
const [measuredOptionWidths, setMeasuredOptionWidths] = useState(
|
|
32898
32897
|
() => Array.from({ length: optionCount }, () => 0)
|
|
32899
32898
|
);
|
|
32900
32899
|
const [containerWidth, setContainerWidth] = useState(0);
|
|
32901
32900
|
const trackChrome = TRACK_PADDING * 2 + OPTION_GAP * (optionCount - 1);
|
|
32902
32901
|
const availableOptionWidth = Math.max(0, (containerWidth - trackChrome) / optionCount);
|
|
32903
|
-
const
|
|
32904
|
-
|
|
32905
|
-
|
|
32906
|
-
) : 0;
|
|
32907
|
-
const optionWidths = fullWidth ? Array.from({ length: optionCount }, () => availableOptionWidth) : contentWidths.map((width) => resolveContentOptionWidth(width));
|
|
32908
|
-
const selectedOptionWidth = optionWidths[selectedIndex] ?? 0;
|
|
32902
|
+
const optionWidths = fullWidth ? Array.from({ length: optionCount }, () => availableOptionWidth) : measuredOptionWidths;
|
|
32903
|
+
const measurementsReady = optionWidths.every((width) => width > 0);
|
|
32904
|
+
const selectedOptionWidth = measurementsReady ? optionWidths[selectedIndex] ?? 0 : 0;
|
|
32909
32905
|
const indicatorInputRange = options.map((_, index) => index);
|
|
32910
32906
|
const indicatorOutputRange = buildIndicatorOutputRange(optionWidths);
|
|
32911
32907
|
const indicatorTranslateX = progress.interpolate({
|
|
@@ -32914,7 +32910,7 @@ var SegmentedToggle = forwardRef(
|
|
|
32914
32910
|
});
|
|
32915
32911
|
useApplyWebClassName(containerRef, resolvedClassName);
|
|
32916
32912
|
useEffect(() => {
|
|
32917
|
-
|
|
32913
|
+
setMeasuredOptionWidths((current) => {
|
|
32918
32914
|
if (current.length === optionCount) return current;
|
|
32919
32915
|
return Array.from({ length: optionCount }, (_, index) => current[index] ?? 0);
|
|
32920
32916
|
});
|
|
@@ -32959,30 +32955,6 @@ var SegmentedToggle = forwardRef(
|
|
|
32959
32955
|
],
|
|
32960
32956
|
accessibilityRole: "radiogroup",
|
|
32961
32957
|
children: [
|
|
32962
|
-
!fullWidth ? options.map(({ value: optionValue, label, icon: Icon2, showLabel = true }, index) => /* @__PURE__ */ jsxs(
|
|
32963
|
-
View,
|
|
32964
|
-
{
|
|
32965
|
-
pointerEvents: "none",
|
|
32966
|
-
"aria-hidden": true,
|
|
32967
|
-
accessibilityElementsHidden: true,
|
|
32968
|
-
importantForAccessibility: "no-hide-descendants",
|
|
32969
|
-
onLayout: (event) => {
|
|
32970
|
-
const nextWidth = event.nativeEvent.layout.width;
|
|
32971
|
-
setContentWidths((currentWidths) => {
|
|
32972
|
-
if (currentWidths[index] === nextWidth) return currentWidths;
|
|
32973
|
-
const nextWidths = [...currentWidths];
|
|
32974
|
-
nextWidths[index] = nextWidth;
|
|
32975
|
-
return nextWidths;
|
|
32976
|
-
});
|
|
32977
|
-
},
|
|
32978
|
-
style: styles20.optionMeasurement,
|
|
32979
|
-
children: [
|
|
32980
|
-
Icon2 ? /* @__PURE__ */ jsx(Icon2, { size: ICON_SIZE8 }) : null,
|
|
32981
|
-
showLabel ? /* @__PURE__ */ jsx(Text, { style: [styles20.label, styles20.contentWidthLabel], children: label }) : null
|
|
32982
|
-
]
|
|
32983
|
-
},
|
|
32984
|
-
`${optionValue}-measurement`
|
|
32985
|
-
)) : null,
|
|
32986
32958
|
selectedOptionWidth > 0 ? /* @__PURE__ */ jsx(
|
|
32987
32959
|
Animated.View,
|
|
32988
32960
|
{
|
|
@@ -32997,37 +32969,61 @@ var SegmentedToggle = forwardRef(
|
|
|
32997
32969
|
const selected = optionValue === selectedValue;
|
|
32998
32970
|
const iconColor = selected ? colors.primary : colors.whiteAlpha20;
|
|
32999
32971
|
const labelColor = selected ? colors.white : colors.grey150;
|
|
33000
|
-
|
|
33001
|
-
return /* @__PURE__ */ jsx(
|
|
32972
|
+
return /* @__PURE__ */ jsxs(
|
|
33002
32973
|
Pressable,
|
|
33003
32974
|
{
|
|
33004
32975
|
onPress: () => selectOption(optionValue),
|
|
33005
32976
|
disabled,
|
|
33006
32977
|
hitSlop,
|
|
32978
|
+
onLayout: fullWidth ? void 0 : (event) => {
|
|
32979
|
+
const nextWidth = event.nativeEvent.layout.width;
|
|
32980
|
+
setMeasuredOptionWidths((currentWidths) => {
|
|
32981
|
+
if (currentWidths[index] === nextWidth) return currentWidths;
|
|
32982
|
+
const nextWidths = [...currentWidths];
|
|
32983
|
+
nextWidths[index] = nextWidth;
|
|
32984
|
+
return nextWidths;
|
|
32985
|
+
});
|
|
32986
|
+
},
|
|
33007
32987
|
accessibilityRole: "radio",
|
|
33008
32988
|
accessibilityLabel: label,
|
|
33009
32989
|
accessibilityState: { selected, disabled },
|
|
33010
32990
|
style: [
|
|
33011
32991
|
styles20.option,
|
|
33012
|
-
fullWidth ? styles20.optionFullWidth :
|
|
33013
|
-
selected &&
|
|
32992
|
+
fullWidth ? styles20.optionFullWidth : styles20.optionContentWidth,
|
|
32993
|
+
selected && !measurementsReady && styles20.initialSelectedOption
|
|
33014
32994
|
],
|
|
33015
|
-
children:
|
|
33016
|
-
|
|
33017
|
-
|
|
33018
|
-
Text,
|
|
32995
|
+
children: [
|
|
32996
|
+
!fullWidth ? /* @__PURE__ */ jsxs(
|
|
32997
|
+
View,
|
|
33019
32998
|
{
|
|
33020
|
-
|
|
33021
|
-
|
|
33022
|
-
|
|
33023
|
-
|
|
33024
|
-
|
|
33025
|
-
|
|
33026
|
-
|
|
33027
|
-
|
|
32999
|
+
"aria-hidden": true,
|
|
33000
|
+
accessibilityElementsHidden: true,
|
|
33001
|
+
importantForAccessibility: "no-hide-descendants",
|
|
33002
|
+
pointerEvents: "none",
|
|
33003
|
+
style: [styles20.optionContent, styles20.optionSizeProbe],
|
|
33004
|
+
children: [
|
|
33005
|
+
Icon2 ? /* @__PURE__ */ jsx(Icon2, { size: ICON_SIZE8 }) : null,
|
|
33006
|
+
showLabel ? /* @__PURE__ */ jsx(Text, { style: [styles20.label, styles20.selectedLabel, styles20.contentWidthLabel], children: label }) : null
|
|
33007
|
+
]
|
|
33028
33008
|
}
|
|
33029
|
-
) : null
|
|
33030
|
-
|
|
33009
|
+
) : null,
|
|
33010
|
+
/* @__PURE__ */ jsxs(View, { style: [styles20.optionContent, !fullWidth && styles20.contentWidthVisibleContent], children: [
|
|
33011
|
+
Icon2 ? /* @__PURE__ */ jsx(Icon2, { size: ICON_SIZE8, color: iconColor }) : null,
|
|
33012
|
+
showLabel ? /* @__PURE__ */ jsx(
|
|
33013
|
+
Text,
|
|
33014
|
+
{
|
|
33015
|
+
numberOfLines: fullWidth ? 1 : void 0,
|
|
33016
|
+
style: [
|
|
33017
|
+
styles20.label,
|
|
33018
|
+
selected ? styles20.selectedLabel : styles20.inactiveLabel,
|
|
33019
|
+
!fullWidth && styles20.contentWidthLabel,
|
|
33020
|
+
{ color: labelColor }
|
|
33021
|
+
],
|
|
33022
|
+
children: label
|
|
33023
|
+
}
|
|
33024
|
+
) : null
|
|
33025
|
+
] })
|
|
33026
|
+
]
|
|
33031
33027
|
},
|
|
33032
33028
|
optionValue
|
|
33033
33029
|
);
|
|
@@ -33071,13 +33067,17 @@ var styles20 = StyleSheet.create({
|
|
|
33071
33067
|
alignItems: "center",
|
|
33072
33068
|
gap: OPTION_CONTENT_GAP
|
|
33073
33069
|
},
|
|
33074
|
-
|
|
33075
|
-
position: "absolute",
|
|
33076
|
-
flexDirection: "row",
|
|
33077
|
-
alignItems: "center",
|
|
33078
|
-
gap: OPTION_CONTENT_GAP,
|
|
33070
|
+
optionSizeProbe: {
|
|
33079
33071
|
opacity: 0
|
|
33080
33072
|
},
|
|
33073
|
+
contentWidthVisibleContent: {
|
|
33074
|
+
position: "absolute",
|
|
33075
|
+
top: 0,
|
|
33076
|
+
left: 0,
|
|
33077
|
+
width: "100%",
|
|
33078
|
+
height: "100%",
|
|
33079
|
+
justifyContent: "center"
|
|
33080
|
+
},
|
|
33081
33081
|
optionFullWidth: {
|
|
33082
33082
|
flex: 1,
|
|
33083
33083
|
minWidth: 0
|