@ecohouse/ui 0.1.22 → 0.1.23

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.js CHANGED
@@ -2224,6 +2224,7 @@ var styles6 = StyleSheet.create({
2224
2224
  var ICON_SIZE4 = 20;
2225
2225
  var ANIMATION_DURATION = 200;
2226
2226
  var OPTION_HORIZONTAL_PADDING = 16;
2227
+ var OPTION_MIN_WIDTH = 97;
2227
2228
  var SegmentedToggle = forwardRef(
2228
2229
  function SegmentedToggle2({
2229
2230
  options,
@@ -2249,12 +2250,9 @@ var SegmentedToggle = forwardRef(
2249
2250
  const resolvedClassName = className?.trim() || void 0;
2250
2251
  const setContainerRef = useMemo(() => mergeRefs(containerRef, forwardedRef), [forwardedRef]);
2251
2252
  const progress = useRef(new Animated.Value(selectedIndex)).current;
2252
- const [contentWidths, setContentWidths] = useState([0, 0]);
2253
2253
  const [containerWidth, setContainerWidth] = useState(0);
2254
2254
  const availableOptionWidth = Math.max(0, (containerWidth - 12) / 2);
2255
- const widestContentWidth = Math.max(...contentWidths);
2256
- const contentBasedOptionWidth = widestContentWidth > 0 ? widestContentWidth + OPTION_HORIZONTAL_PADDING * 2 : 0;
2257
- const optionWidth = fullWidth ? availableOptionWidth : contentBasedOptionWidth;
2255
+ const optionWidth = fullWidth ? availableOptionWidth : OPTION_MIN_WIDTH;
2258
2256
  const indicatorTranslateX = progress.interpolate({
2259
2257
  inputRange: [0, 1],
2260
2258
  outputRange: [0, optionWidth + 4]
@@ -2305,7 +2303,7 @@ var SegmentedToggle = forwardRef(
2305
2303
  ]
2306
2304
  }
2307
2305
  ) : null,
2308
- options.map(({ value: optionValue, label, icon: Icon2 }, index) => {
2306
+ options.map(({ value: optionValue, label, icon: Icon2 }) => {
2309
2307
  const selected = optionValue === selectedValue;
2310
2308
  const iconColor = selected ? colors.primary : colors.whiteAlpha20;
2311
2309
  const labelColor = selected ? colors.whiteAlpha86 : colors.whiteAlpha40;
@@ -2320,27 +2318,12 @@ var SegmentedToggle = forwardRef(
2320
2318
  accessibilityState: { selected, disabled },
2321
2319
  style: [
2322
2320
  styles7.option,
2323
- fullWidth ? styles7.optionFullWidth : optionWidth > 0 && { minWidth: optionWidth }
2321
+ fullWidth ? styles7.optionFullWidth : { width: OPTION_MIN_WIDTH, minWidth: OPTION_MIN_WIDTH }
2324
2322
  ],
2325
- children: /* @__PURE__ */ jsxs(
2326
- View,
2327
- {
2328
- onLayout: (event) => {
2329
- const nextWidth = event.nativeEvent.layout.width;
2330
- setContentWidths((currentWidths) => {
2331
- if (currentWidths[index] === nextWidth) return currentWidths;
2332
- const nextWidths = [currentWidths[0], currentWidths[1]];
2333
- nextWidths[index] = nextWidth;
2334
- return nextWidths;
2335
- });
2336
- },
2337
- style: styles7.optionContent,
2338
- children: [
2339
- Icon2 ? /* @__PURE__ */ jsx(Icon2, { size: ICON_SIZE4, color: iconColor }) : null,
2340
- /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles7.label, { color: labelColor }], children: label })
2341
- ]
2342
- }
2343
- )
2323
+ children: /* @__PURE__ */ jsxs(View, { style: styles7.optionContent, children: [
2324
+ Icon2 ? /* @__PURE__ */ jsx(Icon2, { size: ICON_SIZE4, color: iconColor }) : null,
2325
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles7.label, { color: labelColor }], children: label })
2326
+ ] })
2344
2327
  },
2345
2328
  optionValue
2346
2329
  );