@cleartrip/ct-design-segment 5.11.0-SNAPSHOT-native-main.3 → 5.11.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.
@@ -10,12 +10,7 @@ import { useTheme } from '@cleartrip/ct-design-theme';
10
10
  import { useStyles } from '@cleartrip/ct-design-style-manager';
11
11
  import { Container } from '@cleartrip/ct-design-container';
12
12
 
13
- import {
14
- getSegmentVariantStyles,
15
- segmentNativeThumbStyles,
16
- segmentStaticStyles,
17
- segmentThumbShadowNative,
18
- } from './style';
13
+ import { getSegmentVariantStyles, segmentStaticStyles, segmentThumbShadowNative } from './style';
19
14
  import { ISegmentProps, type SegmentStyleConfigProps } from './type';
20
15
  import { SegmentVariant } from './constants';
21
16
  import { SegmentButton } from './SegmentButton';
@@ -251,7 +246,6 @@ const Segment: React.FC<ISegmentProps> = ({
251
246
  pointerEvents='none'
252
247
  style={[
253
248
  segmentStaticStyles.animatedBlock,
254
- segmentNativeThumbStyles.root,
255
249
  animatedStyle,
256
250
  dynamicStyles.animatedBlock,
257
251
  ...(variantStyles.animatedBlock?.style ? [variantStyles.animatedBlock.style] : []),
package/src/Segment.tsx CHANGED
@@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
3
3
  import { useTheme } from '@cleartrip/ct-design-theme';
4
4
  import { useStyles, useWebMergeStyles } from '@cleartrip/ct-design-style-manager';
5
5
 
6
- import { getSegmentVariantStyles, segmentStaticStyles, segmentWebLayoutStyles, segmentWebThumbStyles } from './style';
6
+ import { getSegmentVariantStyles, segmentStaticStyles, segmentWebThumbStyles } from './style';
7
7
  import { ISegmentProps } from './type';
8
8
  import { SegmentVariant } from './constants';
9
9
  import { SegmentButton } from './SegmentButton';
@@ -197,12 +197,12 @@ const Segment: React.FC<ISegmentProps> = ({
197
197
  [segmentStaticStyles.root, dynamicStyles.root, variantStyles.root?.style, root],
198
198
  );
199
199
  const animatedContainerClassName = useWebMergeStyles(
200
- [segmentStaticStyles.animatedContainer, segmentWebLayoutStyles.animatedContainer, ...animatedContainer],
201
- [segmentStaticStyles.animatedContainer, segmentWebLayoutStyles.animatedContainer, animatedContainer],
200
+ [segmentStaticStyles.animatedContainer, ...animatedContainer],
201
+ [segmentStaticStyles.animatedContainer, ...animatedContainer],
202
202
  );
203
203
  const tabMeasureCellClassName = useWebMergeStyles(
204
- [segmentStaticStyles.tabMeasureCell, segmentWebLayoutStyles.tabMeasureCell],
205
- [segmentStaticStyles.tabMeasureCell, segmentWebLayoutStyles.tabMeasureCell],
204
+ [segmentStaticStyles.tabMeasureCell],
205
+ [segmentStaticStyles.tabMeasureCell],
206
206
  );
207
207
  const webThumbBaseClassName = useWebMergeStyles(
208
208
  [
@@ -24,14 +24,14 @@ export const SegmentButton: React.FC<ISegmentButtonProps> = ({
24
24
  const { segmentButton = {}, segmentText = {} } = styleConfig || {};
25
25
 
26
26
  const shell = useStyles(
27
- (t) => ({
27
+ () => ({
28
28
  rowCell: {
29
29
  flexGrow: 1,
30
30
  flexBasis: 0,
31
31
  flexShrink: 1,
32
32
  minWidth: 0,
33
33
  minHeight: 0,
34
- width: t.size['100P'],
34
+ width: undefined,
35
35
  alignSelf: 'stretch',
36
36
  height: '100%',
37
37
  maxHeight: '100%',
@@ -91,7 +91,7 @@ export const SegmentButton: React.FC<ISegmentButtonProps> = ({
91
91
  variant={ButtonVariant.BARE}
92
92
  color={ButtonColor.TERTIARY}
93
93
  size={ButtonSize.SMALL}
94
- isFullWidth
94
+ isFullWidth={false}
95
95
  prefixIcon={option?.icon}
96
96
  onClick={() => {
97
97
  if (disabled) return;
package/src/style.ts CHANGED
@@ -15,7 +15,6 @@ export const segmentThumbShadowNative = {
15
15
  elevation: 3,
16
16
  } as const;
17
17
 
18
- /** Shared layout — do not add web-only flex rules here; native uses this as-is. */
19
18
  export const segmentStaticStyles = makeStyles((theme) => {
20
19
  const trackHeight = theme.size[10];
21
20
  const borderWidth = theme.border.width.sm;
@@ -38,6 +37,8 @@ export const segmentStaticStyles = makeStyles((theme) => {
38
37
  height: trackHeight,
39
38
  alignItems: 'stretch',
40
39
  padding: theme.spacing[1],
40
+ borderStyle: 'solid',
41
+ boxSizing: 'border-box',
41
42
  },
42
43
  button: {
43
44
  backgroundColor: 'transparent',
@@ -52,10 +53,13 @@ export const segmentStaticStyles = makeStyles((theme) => {
52
53
  },
53
54
  animatedBlock: {
54
55
  position: 'absolute',
56
+ top: 0,
57
+ height: '100%',
55
58
  borderRadius: thumbRadius,
56
59
  backgroundColor: theme.color.background.neutral,
57
60
  },
58
61
  animatedContainer: {
62
+ display: 'flex',
59
63
  flexDirection: 'row',
60
64
  alignItems: 'stretch',
61
65
  justifyContent: 'flex-start',
@@ -68,6 +72,8 @@ export const segmentStaticStyles = makeStyles((theme) => {
68
72
  flexShrink: 1,
69
73
  flexBasis: 0,
70
74
  minWidth: 0,
75
+ display: 'flex',
76
+ alignItems: 'stretch',
71
77
  },
72
78
  animatedBlockWidth: {
73
79
  width: theme.size['100P'],
@@ -75,69 +81,23 @@ export const segmentStaticStyles = makeStyles((theme) => {
75
81
  };
76
82
  });
77
83
 
78
- /** Web-only flex layout — `<div>` needs explicit display; native Container must not use these. */
79
- export const segmentWebLayoutStyles = makeStyles(() => ({
80
- animatedContainer: {
81
- display: 'flex',
82
- },
83
- tabMeasureCell: {
84
- display: 'flex',
85
- flexDirection: 'row',
86
- justifyContent: 'center',
87
- alignItems: 'center',
88
- position: 'relative',
89
- zIndex: 1,
90
- },
91
- }));
92
-
93
- /**
94
- * Native thumb — inset within the padded track (web uses segmentWebThumbStyles instead).
95
- */
96
- export const segmentNativeThumbStyles = makeStyles((theme) => {
97
- const trackHeight = theme.size[10];
98
- const borderWidth = theme.border.width.sm;
99
- const trackPadding = theme.spacing[1];
100
- const trackInnerHeight = Math.max(trackHeight - borderWidth * 2, 0);
101
- const paddedInnerHeight = Math.max(trackInnerHeight - trackPadding * 2, 0);
102
- const thumbInset = Math.max(theme.spacing[0.25], 0);
103
- const paddedInnerRadius = Math.max(0, paddedInnerHeight / 2);
104
- const thumbRadius = Math.max(0, paddedInnerRadius - thumbInset);
105
-
106
- return {
107
- root: {
108
- position: 'absolute',
109
- top: thumbInset,
110
- bottom: thumbInset,
111
- borderRadius: thumbRadius,
112
- backgroundColor: theme.color.background.neutral,
113
- },
114
- };
115
- });
116
-
117
- /**
118
- * Web-only (Segment.tsx) — native uses segmentNativeThumbStyles instead.
119
- * Thumb fills animatedContainer via top/bottom inset, not a fixed height from trackHeight.
120
- */
121
84
  export const segmentWebThumbStyles = makeStyles((theme) => {
122
85
  const trackHeight = theme.size[10];
123
- const borderWidth = theme.border.width.sm;
124
86
  const trackPadding = theme.spacing[1];
125
- const trackInnerHeight = Math.max(trackHeight - borderWidth * 2, 0);
126
- const paddedInnerHeight = Math.max(trackInnerHeight - trackPadding * 2, 0);
87
+ const borderWidth = theme.border.width.sm;
88
+ const trackInnerHeight = Math.max(trackHeight - borderWidth * 2 - trackPadding * 2, 0);
127
89
  const thumbInset = Math.max(theme.spacing[0.25], 0);
128
- const paddedInnerRadius = Math.max(0, paddedInnerHeight / 2);
129
- const thumbRadius = Math.max(0, paddedInnerRadius - thumbInset);
90
+ const trackInnerRadius = Math.max(0, trackInnerHeight / 2);
91
+ const thumbRadius = Math.max(0, trackInnerRadius - thumbInset);
130
92
 
131
93
  return {
132
94
  root: {
133
95
  position: 'absolute',
134
- top: thumbInset,
135
- bottom: thumbInset,
96
+ top: 0,
97
+ height: '100%',
136
98
  borderRadius: thumbRadius,
137
99
  backgroundColor: theme.color.background.neutral,
138
100
  boxShadow: SEGMENT_THUMB_BOX_SHADOW,
139
- pointerEvents: 'none',
140
- zIndex: 0,
141
101
  },
142
102
  };
143
103
  });