jp-composter 0.1.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.
- package/dist/index.d.mts +997 -0
- package/dist/index.d.ts +997 -0
- package/dist/index.js +36837 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +36778 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
- package/src/SliceUI/IconMoon.tsx +33 -0
- package/src/SliceUI/assets/Anatomy diagram copy.svg +19 -0
- package/src/SliceUI/assets/Anatomy diagram.svg +19 -0
- package/src/SliceUI/assets/Anatomycheck.svg +15 -0
- package/src/SliceUI/assets/Anatomyinput.svg +32 -0
- package/src/SliceUI/assets/Checkbox.jpg +0 -0
- package/src/SliceUI/assets/Diagram copy.svg +15 -0
- package/src/SliceUI/assets/Diagram.jpg +0 -0
- package/src/SliceUI/assets/Diagram.svg +15 -0
- package/src/SliceUI/assets/Frame 5 copy.png +0 -0
- package/src/SliceUI/assets/Frame 5.png +0 -0
- package/src/SliceUI/assets/Frame 65.png +0 -0
- package/src/SliceUI/assets/Frame_65.png +0 -0
- package/src/SliceUI/assets/Icon copy.svg +3 -0
- package/src/SliceUI/assets/Icon.svg +3 -0
- package/src/SliceUI/assets/Icon_Bridging copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Bridging.svg +39 -0
- package/src/SliceUI/assets/Icon_Consistent copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Consistent.svg +39 -0
- package/src/SliceUI/assets/Icon_Plug copy.svg +38 -0
- package/src/SliceUI/assets/Icon_Plug.svg +38 -0
- package/src/SliceUI/assets/Icon_Reusable copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Reusable.svg +39 -0
- package/src/SliceUI/assets/Layer_1.png +0 -0
- package/src/SliceUI/assets/accessibility.png +0 -0
- package/src/SliceUI/assets/accessibility.svg +1 -0
- package/src/SliceUI/assets/addon-library.png +0 -0
- package/src/SliceUI/assets/assets.png +0 -0
- package/src/SliceUI/assets/avif-test-image.avif +0 -0
- package/src/SliceUI/assets/bridging.svg +13 -0
- package/src/SliceUI/assets/consistent.svg +11 -0
- package/src/SliceUI/assets/context.png +0 -0
- package/src/SliceUI/assets/discord.svg +1 -0
- package/src/SliceUI/assets/docs.png +0 -0
- package/src/SliceUI/assets/figma-plugin.png +0 -0
- package/src/SliceUI/assets/github.svg +1 -0
- package/src/SliceUI/assets/resources/Anatomy diagram.svg +19 -0
- package/src/SliceUI/assets/resources/Anatomycheck.svg +15 -0
- package/src/SliceUI/assets/resources/Anatomyinput.svg +32 -0
- package/src/SliceUI/assets/resources/Diagram.svg +15 -0
- package/src/SliceUI/assets/resources/Frame 5.png +0 -0
- package/src/SliceUI/assets/resources/Frame 65.png +0 -0
- package/src/SliceUI/assets/resources/Icon.svg +3 -0
- package/src/SliceUI/assets/resources/Icon_Bridging.svg +39 -0
- package/src/SliceUI/assets/resources/Icon_Consistent.svg +39 -0
- package/src/SliceUI/assets/resources/Icon_Plug.svg +38 -0
- package/src/SliceUI/assets/resources/Icon_Reusable.svg +39 -0
- package/src/SliceUI/assets/resources/fonts/FontIcon.json +150 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Black.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Bold.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Heavy.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Medium.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Regular.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato.woff2 +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.eot +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.svg +601 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.woff +0 -0
- package/src/SliceUI/assets/resources/fonts/selection.json +1 -0
- package/src/SliceUI/assets/share.png +0 -0
- package/src/SliceUI/assets/styling.png +0 -0
- package/src/SliceUI/assets/testing.png +0 -0
- package/src/SliceUI/assets/theming.png +0 -0
- package/src/SliceUI/assets/tutorials.svg +1 -0
- package/src/SliceUI/assets/youtube.svg +1 -0
- package/src/SliceUI/automation/helper.ts +29 -0
- package/src/SliceUI/avatar/Avatar.tsx +237 -0
- package/src/SliceUI/avatar/Token.ts +116 -0
- package/src/SliceUI/avatar/Type.ts +36 -0
- package/src/SliceUI/avatar/helper.ts +53 -0
- package/src/SliceUI/badge/Badge.tsx +308 -0
- package/src/SliceUI/badge/Token.ts +202 -0
- package/src/SliceUI/badge/Type.ts +46 -0
- package/src/SliceUI/badge/helper.ts +39 -0
- package/src/SliceUI/button/Button.tsx +243 -0
- package/src/SliceUI/button/Token.ts +138 -0
- package/src/SliceUI/button/Type.ts +34 -0
- package/src/SliceUI/button/helper.ts +125 -0
- package/src/SliceUI/checkbox/Checkbox.tsx +176 -0
- package/src/SliceUI/checkbox/Token.ts +128 -0
- package/src/SliceUI/checkbox/Type.ts +35 -0
- package/src/SliceUI/chip/Chip.tsx +290 -0
- package/src/SliceUI/chip/Token.ts +151 -0
- package/src/SliceUI/chip/Type.ts +43 -0
- package/src/SliceUI/chip/helper.ts +40 -0
- package/src/SliceUI/colors/Pallete.ts +151 -0
- package/src/SliceUI/colors/Token.ts +110 -0
- package/src/SliceUI/colors/Type.ts +56 -0
- package/src/SliceUI/contextProvider/context.tsx +108 -0
- package/src/SliceUI/divider/Divider.tsx +109 -0
- package/src/SliceUI/divider/Token.ts +18 -0
- package/src/SliceUI/divider/Type.ts +26 -0
- package/src/SliceUI/icon/CustomIcon.ts +4 -0
- package/src/SliceUI/icon/IcoMoonIcon.tsx +11 -0
- package/src/SliceUI/icon/Icon.tsx +38 -0
- package/src/SliceUI/icon/Token.ts +14 -0
- package/src/SliceUI/icon/Type.ts +13 -0
- package/src/SliceUI/icon/selection.json +1 -0
- package/src/SliceUI/input/Input.tsx +573 -0
- package/src/SliceUI/input/ToDo.md +99 -0
- package/src/SliceUI/input/Token.ts +372 -0
- package/src/SliceUI/input/Type.ts +109 -0
- package/src/SliceUI/input/components/InputPortal.tsx +211 -0
- package/src/SliceUI/input/components/NativeBottomSheet.tsx +296 -0
- package/src/SliceUI/input/components/SelectChip.tsx +185 -0
- package/src/SliceUI/input/components/SelectList.tsx +173 -0
- package/src/SliceUI/input/components/SelectListItem.tsx +377 -0
- package/src/SliceUI/input/components/SelectScrollbarStyle.ts +44 -0
- package/src/SliceUI/input/hooks/useCustomScrollbar.ts +17 -0
- package/src/SliceUI/input/hooks/useInputState.ts +41 -0
- package/src/SliceUI/input/hooks/useLabelAnimation.ts +132 -0
- package/src/SliceUI/input/hooks/useOutsideClick.ts +38 -0
- package/src/SliceUI/input/hooks/useSelectLogic.ts +338 -0
- package/src/SliceUI/input/utils/inputUtils.ts +120 -0
- package/src/SliceUI/input/utils/selectUtils.ts +85 -0
- package/src/SliceUI/input/utils/styleUtils.ts +50 -0
- package/src/SliceUI/input/variants/CurrencyInput/CurrencyInput.tsx +16 -0
- package/src/SliceUI/input/variants/CurrencyInput/NativeCurrencyInput.tsx +181 -0
- package/src/SliceUI/input/variants/CurrencyInput/WebCurrencyInput.tsx +163 -0
- package/src/SliceUI/input/variants/CurrencyInput/types.ts +17 -0
- package/src/SliceUI/input/variants/PhoneInput/NativePhoneInput.tsx +189 -0
- package/src/SliceUI/input/variants/PhoneInput/PhoneInput.tsx +16 -0
- package/src/SliceUI/input/variants/PhoneInput/WebPhoneInput.tsx +291 -0
- package/src/SliceUI/input/variants/PhoneInput/types.ts +22 -0
- package/src/SliceUI/input/variants/SelectInput/SelectInput.tsx +407 -0
- package/src/SliceUI/input/variants/SelectInput/types.ts +34 -0
- package/src/SliceUI/input/variants/TextInput.tsx +68 -0
- package/src/SliceUI/layout/Box.tsx +38 -0
- package/src/SliceUI/layout/Center.tsx +38 -0
- package/src/SliceUI/layout/Divider.tsx +37 -0
- package/src/SliceUI/layout/Grid.tsx +75 -0
- package/src/SliceUI/layout/PageContainer.tsx +60 -0
- package/src/SliceUI/layout/ScrollContainer.tsx +72 -0
- package/src/SliceUI/layout/Spacer.tsx +54 -0
- package/src/SliceUI/layout/Stack.tsx +97 -0
- package/src/SliceUI/layout/StickyHeader.tsx +71 -0
- package/src/SliceUI/radio/RadioButton.tsx +130 -0
- package/src/SliceUI/radio/Token.ts +197 -0
- package/src/SliceUI/radio/Type.ts +35 -0
- package/src/SliceUI/react-native.config.js +3 -0
- package/src/SliceUI/responsive/Type.ts +7 -0
- package/src/SliceUI/responsive/helper.ts +53 -0
- package/src/SliceUI/switch/Switch.tsx +119 -0
- package/src/SliceUI/switch/Token.ts +205 -0
- package/src/SliceUI/switch/Type.ts +26 -0
- package/src/SliceUI/tab/TabItem.tsx +204 -0
- package/src/SliceUI/tab/Tabs.tsx +110 -0
- package/src/SliceUI/tab/Token.ts +282 -0
- package/src/SliceUI/tab/Type.ts +66 -0
- package/src/SliceUI/tab/helper.ts +53 -0
- package/src/SliceUI/table/Table.tsx +388 -0
- package/src/SliceUI/table/TableCell.tsx +158 -0
- package/src/SliceUI/table/TableFooter.tsx +353 -0
- package/src/SliceUI/table/TableHeader.tsx +247 -0
- package/src/SliceUI/table/TableRow.tsx +218 -0
- package/src/SliceUI/table/Token.ts +252 -0
- package/src/SliceUI/table/Type.ts +213 -0
- package/src/SliceUI/table/helper.ts +376 -0
- package/src/SliceUI/table/index.ts +53 -0
- package/src/SliceUI/theme/dummyColors.tsx +7 -0
- package/src/SliceUI/theme/theme.ts +107 -0
- package/src/SliceUI/typography/BaseTypographyToken.ts +62 -0
- package/src/SliceUI/typography/FoundationToken.ts +48 -0
- package/src/SliceUI/typography/Token.ts +228 -0
- package/src/SliceUI/typography/Type.ts +20 -0
- package/src/SliceUI/typography/Typography.tsx +99 -0
- package/src/SliceUI/values/BorderRadius.ts +17 -0
- package/src/SliceUI/values/BorderWidth.ts +7 -0
- package/src/SliceUI/values/Dimension.ts +35 -0
- package/src/SliceUI/values/IconSizes.ts +13 -0
- package/src/SliceUI/values/Spacing.ts +22 -0
- package/src/declarations.d.ts +8 -0
- package/src/index.tsx +119 -0
- package/src/stories/Colors.mdx +1418 -0
- package/src/stories/Dimensions.mdx +60 -0
- package/src/stories/GetStarted.mdx +90 -0
- package/src/stories/Introduction.mdx +136 -0
- package/src/stories/Shape.mdx +126 -0
- package/src/stories/Spacing.mdx +104 -0
- package/src/stories/Typography.mdx +454 -0
- package/src/stories/Utils.mdx +277 -0
- package/src/stories/story-components/AddIcon.js +13 -0
- package/src/stories/story-components/RectangleWithBox.jsx +51 -0
- package/src/stories/story-components/RoundedRectangle.jsx +18 -0
- package/src/stories/story-components/RoundedWithWhiteInside.jsx +33 -0
- package/src/stories/story-components/WhiteRoundedRectangle.jsx +107 -0
- package/src/stories/story-components/svgPaths.js +126 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {dimensions} from '../values/Dimension';
|
|
2
|
+
import type {CheckboxThemeSize} from './Type';
|
|
3
|
+
|
|
4
|
+
export const CHECKBOX_THEME: CheckboxThemeSize = {
|
|
5
|
+
small: {
|
|
6
|
+
default: {
|
|
7
|
+
container: {
|
|
8
|
+
flexDirection: 'row',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
minHeight: dimensions.dimension17,
|
|
11
|
+
},
|
|
12
|
+
box: {
|
|
13
|
+
width: dimensions.dimension07,
|
|
14
|
+
height: dimensions.dimension07,
|
|
15
|
+
borderRadius: 4,
|
|
16
|
+
borderWidth: 2,
|
|
17
|
+
borderColor: '#888',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
marginRight: dimensions.dimension04,
|
|
21
|
+
},
|
|
22
|
+
check: {
|
|
23
|
+
width: dimensions.dimension05,
|
|
24
|
+
height: dimensions.dimension05,
|
|
25
|
+
backgroundColor: '#888',
|
|
26
|
+
borderRadius: 2,
|
|
27
|
+
},
|
|
28
|
+
label: {fontSize: dimensions.dimension06, color: '#222'},
|
|
29
|
+
description: {fontSize: dimensions.dimension05, color: '#666'},
|
|
30
|
+
},
|
|
31
|
+
error: {
|
|
32
|
+
container: {},
|
|
33
|
+
box: {borderColor: '#E53935'},
|
|
34
|
+
check: {backgroundColor: '#E53935'},
|
|
35
|
+
label: {color: '#E53935'},
|
|
36
|
+
description: {color: '#E53935'},
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
container: {},
|
|
40
|
+
box: {borderColor: '#CCC', backgroundColor: '#F5F5F5'},
|
|
41
|
+
check: {backgroundColor: '#CCC'},
|
|
42
|
+
label: {color: '#CCC'},
|
|
43
|
+
description: {color: '#CCC'},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
medium: {
|
|
47
|
+
default: {
|
|
48
|
+
container: {
|
|
49
|
+
flexDirection: 'row',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
minHeight: dimensions.dimension18,
|
|
52
|
+
},
|
|
53
|
+
box: {
|
|
54
|
+
width: dimensions.dimension08,
|
|
55
|
+
height: dimensions.dimension08,
|
|
56
|
+
borderRadius: 4,
|
|
57
|
+
borderWidth: 2,
|
|
58
|
+
borderColor: '#888',
|
|
59
|
+
justifyContent: 'center',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
marginRight: dimensions.dimension05,
|
|
62
|
+
},
|
|
63
|
+
check: {
|
|
64
|
+
width: dimensions.dimension06,
|
|
65
|
+
height: dimensions.dimension06,
|
|
66
|
+
backgroundColor: '#888',
|
|
67
|
+
borderRadius: 2,
|
|
68
|
+
},
|
|
69
|
+
label: {fontSize: dimensions.dimension07, color: '#222'},
|
|
70
|
+
description: {fontSize: dimensions.dimension06, color: '#666'},
|
|
71
|
+
},
|
|
72
|
+
error: {
|
|
73
|
+
container: {},
|
|
74
|
+
box: {borderColor: '#E53935'},
|
|
75
|
+
check: {backgroundColor: '#E53935'},
|
|
76
|
+
label: {color: '#E53935'},
|
|
77
|
+
description: {color: '#E53935'},
|
|
78
|
+
},
|
|
79
|
+
disabled: {
|
|
80
|
+
container: {},
|
|
81
|
+
box: {borderColor: '#CCC', backgroundColor: '#F5F5F5'},
|
|
82
|
+
check: {backgroundColor: '#CCC'},
|
|
83
|
+
label: {color: '#CCC'},
|
|
84
|
+
description: {color: '#CCC'},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
large: {
|
|
88
|
+
default: {
|
|
89
|
+
container: {
|
|
90
|
+
flexDirection: 'row',
|
|
91
|
+
alignItems: 'center',
|
|
92
|
+
minHeight: dimensions.dimension19,
|
|
93
|
+
},
|
|
94
|
+
box: {
|
|
95
|
+
width: dimensions.dimension09,
|
|
96
|
+
height: dimensions.dimension09,
|
|
97
|
+
borderRadius: 4,
|
|
98
|
+
borderWidth: 2,
|
|
99
|
+
borderColor: '#888',
|
|
100
|
+
justifyContent: 'center',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
marginRight: dimensions.dimension06,
|
|
103
|
+
},
|
|
104
|
+
check: {
|
|
105
|
+
width: dimensions.dimension07,
|
|
106
|
+
height: dimensions.dimension07,
|
|
107
|
+
backgroundColor: '#888',
|
|
108
|
+
borderRadius: 2,
|
|
109
|
+
},
|
|
110
|
+
label: {fontSize: dimensions.dimension08, color: '#222'},
|
|
111
|
+
description: {fontSize: dimensions.dimension07, color: '#666'},
|
|
112
|
+
},
|
|
113
|
+
error: {
|
|
114
|
+
container: {},
|
|
115
|
+
box: {borderColor: '#E53935'},
|
|
116
|
+
check: {backgroundColor: '#E53935'},
|
|
117
|
+
label: {color: '#E53935'},
|
|
118
|
+
description: {color: '#E53935'},
|
|
119
|
+
},
|
|
120
|
+
disabled: {
|
|
121
|
+
container: {},
|
|
122
|
+
box: {borderColor: '#CCC', backgroundColor: '#F5F5F5'},
|
|
123
|
+
check: {backgroundColor: '#CCC'},
|
|
124
|
+
label: {color: '#CCC'},
|
|
125
|
+
description: {color: '#CCC'},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {ViewStyle, TextStyle} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type CheckboxSize = 'small' | 'medium' | 'large';
|
|
4
|
+
export type CheckboxVariant = 'default' | 'error' | 'disabled';
|
|
5
|
+
|
|
6
|
+
export interface CheckboxProps {
|
|
7
|
+
checked: boolean;
|
|
8
|
+
onPress: () => void;
|
|
9
|
+
label: string;
|
|
10
|
+
size?: CheckboxSize;
|
|
11
|
+
variant?: CheckboxVariant;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
style?: ViewStyle;
|
|
14
|
+
labelStyle?: TextStyle;
|
|
15
|
+
description?: string;
|
|
16
|
+
descriptionStyle?: TextStyle;
|
|
17
|
+
prefixIcon?: React.ReactNode;
|
|
18
|
+
suffixIcon?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CheckboxTheme {
|
|
22
|
+
container: ViewStyle;
|
|
23
|
+
box: ViewStyle;
|
|
24
|
+
check: ViewStyle;
|
|
25
|
+
label: TextStyle;
|
|
26
|
+
description: TextStyle;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type CheckboxThemeVariant = {
|
|
30
|
+
[key in CheckboxVariant]: CheckboxTheme;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type CheckboxThemeSize = {
|
|
34
|
+
[key in CheckboxSize]: CheckboxThemeVariant;
|
|
35
|
+
};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import React, {useState, useMemo, useCallback, type ReactNode} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Text,
|
|
4
|
+
Pressable,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
Platform,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
type TextStyle,
|
|
9
|
+
View,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import {useSliceTheme} from '../contextProvider/context';
|
|
12
|
+
// import {useGetColors} from '../theme/dummyColors';
|
|
13
|
+
import {getBackgroundColor, getBorderColor, getTextColor} from './helper';
|
|
14
|
+
import {resolveVariant, scaleFont} from '../responsive/helper';
|
|
15
|
+
import type {SizeType, VariantsType} from './Type';
|
|
16
|
+
import type {CHIP_COLOR_TOKENS} from './Token';
|
|
17
|
+
import {setTestId} from '../automation/helper';
|
|
18
|
+
import type {ExtendedTheme} from '../colors/Type';
|
|
19
|
+
import Typography from '../typography/Typography';
|
|
20
|
+
import {dimensions} from '../values/Dimension';
|
|
21
|
+
import {spacing} from '../values/Spacing';
|
|
22
|
+
import IconMoon from '../IconMoon';
|
|
23
|
+
|
|
24
|
+
interface ChipProps {
|
|
25
|
+
screenName?: string;
|
|
26
|
+
id?: number | string;
|
|
27
|
+
text: string | string[];
|
|
28
|
+
onPress?: () => void;
|
|
29
|
+
overridedTheme?: any;
|
|
30
|
+
variant?: ChipVariantType;
|
|
31
|
+
size?: string;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
rounded?: boolean;
|
|
34
|
+
chipStyle?: ViewStyle;
|
|
35
|
+
textStyle?: TextStyle;
|
|
36
|
+
showSuffixIcon?: boolean;
|
|
37
|
+
iconName?: string;
|
|
38
|
+
chipSelected?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const CHIP_VARIANTS = {
|
|
42
|
+
PRIMARY: 'primary',
|
|
43
|
+
PRIMARY_OUTLINE: 'primaryOutline',
|
|
44
|
+
} as const;
|
|
45
|
+
|
|
46
|
+
export type ChipVariantType =
|
|
47
|
+
(typeof CHIP_VARIANTS)[keyof typeof CHIP_VARIANTS];
|
|
48
|
+
|
|
49
|
+
const isWeb = Platform.OS === 'web';
|
|
50
|
+
|
|
51
|
+
const Chip: React.FC<ChipProps> = ({
|
|
52
|
+
screenName = 'default',
|
|
53
|
+
id = 'default',
|
|
54
|
+
text,
|
|
55
|
+
onPress,
|
|
56
|
+
variant = CHIP_VARIANTS.PRIMARY,
|
|
57
|
+
size = 'medium',
|
|
58
|
+
disabled = false,
|
|
59
|
+
rounded = false,
|
|
60
|
+
showSuffixIcon = false,
|
|
61
|
+
iconName,
|
|
62
|
+
chipStyle,
|
|
63
|
+
chipSelected,
|
|
64
|
+
textStyle,
|
|
65
|
+
}) => {
|
|
66
|
+
const {theme, deviceBreakpoint} = useSliceTheme();
|
|
67
|
+
const {isDebugBuildType, automationBaseid} = theme;
|
|
68
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
69
|
+
const [isSelected, setIsSelected] = useState(chipSelected);
|
|
70
|
+
|
|
71
|
+
const onPressChip = () => {
|
|
72
|
+
setIsSelected(!isSelected);
|
|
73
|
+
onPress?.();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const responsiveSize = useMemo(
|
|
77
|
+
() => resolveVariant(size, deviceBreakpoint),
|
|
78
|
+
[size, deviceBreakpoint],
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const chipTheme = useMemo(() => {
|
|
82
|
+
const chipType = 'outline';
|
|
83
|
+
const styleKey = rounded ? `${chipType}Rounded` : chipType;
|
|
84
|
+
|
|
85
|
+
return theme.chipStyles[responsiveSize as SizeType][
|
|
86
|
+
styleKey as VariantsType
|
|
87
|
+
];
|
|
88
|
+
}, [responsiveSize, rounded, theme]);
|
|
89
|
+
|
|
90
|
+
const textTheme = useMemo(
|
|
91
|
+
() => theme.chipTextStyles[responsiveSize as SizeType],
|
|
92
|
+
[responsiveSize, theme.chipTextStyles],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const defaultBgColor = useMemo(
|
|
96
|
+
() =>
|
|
97
|
+
getBackgroundColor(
|
|
98
|
+
variant as keyof typeof CHIP_COLOR_TOKENS,
|
|
99
|
+
'default',
|
|
100
|
+
theme as ExtendedTheme,
|
|
101
|
+
),
|
|
102
|
+
[variant, theme],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const hoverBgColor = useMemo(
|
|
106
|
+
() =>
|
|
107
|
+
getBackgroundColor(
|
|
108
|
+
variant as keyof typeof CHIP_COLOR_TOKENS,
|
|
109
|
+
'hover',
|
|
110
|
+
theme as ExtendedTheme,
|
|
111
|
+
),
|
|
112
|
+
[variant, theme],
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const disabledBgColor = useMemo(
|
|
116
|
+
() =>
|
|
117
|
+
getBackgroundColor(
|
|
118
|
+
variant as keyof typeof CHIP_COLOR_TOKENS,
|
|
119
|
+
'disabled',
|
|
120
|
+
theme as ExtendedTheme,
|
|
121
|
+
),
|
|
122
|
+
[variant, theme],
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const pressedBgColor = useMemo(
|
|
126
|
+
() =>
|
|
127
|
+
getBackgroundColor(
|
|
128
|
+
variant as keyof typeof CHIP_COLOR_TOKENS,
|
|
129
|
+
'pressed',
|
|
130
|
+
theme as ExtendedTheme,
|
|
131
|
+
),
|
|
132
|
+
[variant, theme],
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const selectedBgColor = useMemo(
|
|
136
|
+
() =>
|
|
137
|
+
getBackgroundColor(
|
|
138
|
+
variant as keyof typeof CHIP_COLOR_TOKENS,
|
|
139
|
+
'selected',
|
|
140
|
+
theme as ExtendedTheme,
|
|
141
|
+
),
|
|
142
|
+
[variant, theme],
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const borderColor = useMemo(
|
|
146
|
+
() =>
|
|
147
|
+
getBorderColor(
|
|
148
|
+
variant as keyof typeof CHIP_COLOR_TOKENS,
|
|
149
|
+
isSelected ? 'selected' : 'default',
|
|
150
|
+
theme as ExtendedTheme,
|
|
151
|
+
),
|
|
152
|
+
[variant, isSelected, theme],
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const textColor = useMemo(
|
|
156
|
+
() =>
|
|
157
|
+
getTextColor(
|
|
158
|
+
variant as keyof typeof CHIP_COLOR_TOKENS,
|
|
159
|
+
isSelected ? 'selected' : 'default',
|
|
160
|
+
theme as ExtendedTheme,
|
|
161
|
+
),
|
|
162
|
+
[variant, isSelected, theme],
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const opacity = useMemo(() => (disabled ? 0.3 : 1), [disabled]);
|
|
166
|
+
|
|
167
|
+
const iconStyleMemo = useMemo(() => {
|
|
168
|
+
const iconSize = scaleFont(
|
|
169
|
+
theme?.chipIconStyles?.[responsiveSize as SizeType]?.size,
|
|
170
|
+
);
|
|
171
|
+
return {
|
|
172
|
+
size: iconSize,
|
|
173
|
+
color: textColor,
|
|
174
|
+
paddingRight: spacing.space500 + spacing.space500,
|
|
175
|
+
paddingLeft: spacing.space500 + spacing.space500,
|
|
176
|
+
};
|
|
177
|
+
}, [responsiveSize, textColor, theme.chipIconStyles]);
|
|
178
|
+
|
|
179
|
+
const applyIconStyle = useCallback(
|
|
180
|
+
(icon: ReactNode) =>
|
|
181
|
+
icon
|
|
182
|
+
? React.cloneElement(icon as React.ReactElement, iconStyleMemo)
|
|
183
|
+
: null,
|
|
184
|
+
[iconStyleMemo],
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const combinedButtonStyle = useMemo(
|
|
188
|
+
() =>
|
|
189
|
+
StyleSheet.flatten([
|
|
190
|
+
styles.baseChip,
|
|
191
|
+
chipTheme,
|
|
192
|
+
{
|
|
193
|
+
backgroundColor: disabled
|
|
194
|
+
? disabledBgColor
|
|
195
|
+
: isHovered
|
|
196
|
+
? hoverBgColor
|
|
197
|
+
: defaultBgColor,
|
|
198
|
+
borderColor,
|
|
199
|
+
opacity,
|
|
200
|
+
},
|
|
201
|
+
chipStyle,
|
|
202
|
+
]),
|
|
203
|
+
[
|
|
204
|
+
disabled,
|
|
205
|
+
disabledBgColor,
|
|
206
|
+
chipTheme,
|
|
207
|
+
isHovered,
|
|
208
|
+
hoverBgColor,
|
|
209
|
+
defaultBgColor,
|
|
210
|
+
borderColor,
|
|
211
|
+
opacity,
|
|
212
|
+
chipStyle,
|
|
213
|
+
],
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
const pressedChipStyle = useMemo(
|
|
217
|
+
() =>
|
|
218
|
+
StyleSheet.flatten([
|
|
219
|
+
combinedButtonStyle,
|
|
220
|
+
{backgroundColor: pressedBgColor},
|
|
221
|
+
]),
|
|
222
|
+
[combinedButtonStyle, pressedBgColor],
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const selectedChipStyle = useMemo(
|
|
226
|
+
() =>
|
|
227
|
+
StyleSheet.flatten([
|
|
228
|
+
combinedButtonStyle,
|
|
229
|
+
{backgroundColor: selectedBgColor},
|
|
230
|
+
]),
|
|
231
|
+
[combinedButtonStyle, selectedBgColor],
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const combinedTextStyle = useMemo(
|
|
235
|
+
() =>
|
|
236
|
+
StyleSheet.flatten([
|
|
237
|
+
styles.baseText,
|
|
238
|
+
|
|
239
|
+
{color: textColor, fontSize: scaleFont(textTheme.fontSize)},
|
|
240
|
+
textStyle,
|
|
241
|
+
]) as TextStyle,
|
|
242
|
+
[textTheme, textColor, textStyle],
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
return (
|
|
246
|
+
<Pressable
|
|
247
|
+
onPress={onPressChip}
|
|
248
|
+
disabled={disabled}
|
|
249
|
+
style={({pressed}) =>
|
|
250
|
+
isSelected
|
|
251
|
+
? selectedChipStyle
|
|
252
|
+
: pressed
|
|
253
|
+
? pressedChipStyle
|
|
254
|
+
: combinedButtonStyle
|
|
255
|
+
}
|
|
256
|
+
{...(isWeb && {
|
|
257
|
+
onMouseEnter: () => setIsHovered(true),
|
|
258
|
+
onMouseLeave: () => setIsHovered(false),
|
|
259
|
+
})}
|
|
260
|
+
{...(isDebugBuildType && automationBaseid
|
|
261
|
+
? setTestId(automationBaseid, screenName, id)
|
|
262
|
+
: {})}>
|
|
263
|
+
<Typography style={combinedTextStyle} variant="body1">
|
|
264
|
+
{text}
|
|
265
|
+
</Typography>
|
|
266
|
+
{isSelected && showSuffixIcon && iconName && (
|
|
267
|
+
<View style={{paddingLeft: spacing.space100}}>
|
|
268
|
+
<IconMoon
|
|
269
|
+
icon={iconName}
|
|
270
|
+
color={textColor}
|
|
271
|
+
size={iconStyleMemo.size}
|
|
272
|
+
/>
|
|
273
|
+
</View>
|
|
274
|
+
)}
|
|
275
|
+
</Pressable>
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const styles = StyleSheet.create({
|
|
280
|
+
baseChip: {
|
|
281
|
+
alignItems: 'center',
|
|
282
|
+
justifyContent: 'center',
|
|
283
|
+
flexDirection: 'row',
|
|
284
|
+
},
|
|
285
|
+
baseText: {
|
|
286
|
+
textAlign: 'center',
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
export default Chip;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { spacing } from '../values/Spacing';
|
|
2
|
+
import { borderRadius } from '../values/BorderRadius';
|
|
3
|
+
import type {
|
|
4
|
+
ChipIconSizeType,
|
|
5
|
+
ChipSizeType,
|
|
6
|
+
ChipTextSizeType,
|
|
7
|
+
SizePadding,
|
|
8
|
+
} from './Type';
|
|
9
|
+
import { TYPOGRAPHY_STYLES } from '../typography/Token';
|
|
10
|
+
import type { TextStyle } from 'react-native';
|
|
11
|
+
import { ICON_SIZES } from '../icon/Token';
|
|
12
|
+
import type { ExtendedTheme } from '../colors/Type';
|
|
13
|
+
|
|
14
|
+
// Variant styles (shared across sizes)
|
|
15
|
+
const variantStyles = {
|
|
16
|
+
solid: { borderRadius: borderRadius.borderRadius40 },
|
|
17
|
+
solidRounded: { borderRadius: borderRadius.borderRadiusFull },
|
|
18
|
+
outline: { borderRadius: borderRadius.borderRadius40, borderWidth: 1 },
|
|
19
|
+
outlineRounded: {
|
|
20
|
+
borderRadius: borderRadius.borderRadiusFull,
|
|
21
|
+
borderWidth: 1,
|
|
22
|
+
},
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
// Size-specific padding
|
|
26
|
+
const sizePaddings = {
|
|
27
|
+
small: { paddingVertical: spacing.space150, paddingHorizontal: spacing.space300 },
|
|
28
|
+
medium: { paddingVertical: spacing.space150, paddingHorizontal: spacing.space300 },
|
|
29
|
+
large: { paddingVertical: spacing.space400, paddingHorizontal: spacing.space450 },
|
|
30
|
+
xLarge: { paddingVertical: spacing.space400, paddingHorizontal: spacing.space450 },
|
|
31
|
+
xxLarge: { paddingVertical: spacing.space400, paddingHorizontal: spacing.space450 }
|
|
32
|
+
} as const;
|
|
33
|
+
|
|
34
|
+
// Helper function to create styles for a given size
|
|
35
|
+
const createStylesForSize = (sizePadding: SizePadding) => ({
|
|
36
|
+
solid: { ...variantStyles.solid, ...sizePadding },
|
|
37
|
+
solidRounded: {
|
|
38
|
+
...variantStyles.solidRounded,
|
|
39
|
+
...sizePadding,
|
|
40
|
+
},
|
|
41
|
+
outline: {
|
|
42
|
+
...variantStyles.outline,
|
|
43
|
+
...sizePadding,
|
|
44
|
+
},
|
|
45
|
+
outlineRounded: {
|
|
46
|
+
...variantStyles.outlineRounded,
|
|
47
|
+
...sizePadding,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Export the button styles
|
|
52
|
+
export const CHIP_STYLE: ChipSizeType = {
|
|
53
|
+
small: createStylesForSize(sizePaddings.small),
|
|
54
|
+
medium: createStylesForSize(sizePaddings.medium),
|
|
55
|
+
large: createStylesForSize(sizePaddings.large),
|
|
56
|
+
xLarge: createStylesForSize(sizePaddings.xLarge),
|
|
57
|
+
xxLarge: createStylesForSize(sizePaddings.xxLarge),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function textViewWrapperStyle(
|
|
61
|
+
textStyle: TextStyle,
|
|
62
|
+
marginRight?: TextStyle['marginHorizontal']
|
|
63
|
+
): TextStyle {
|
|
64
|
+
return { ...textStyle, lineHeight: undefined, marginRight };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const CHIP_TXT_STYLE: ChipTextSizeType = {
|
|
68
|
+
small: textViewWrapperStyle(
|
|
69
|
+
TYPOGRAPHY_STYLES.body2Bold as TextStyle,
|
|
70
|
+
spacing.space100
|
|
71
|
+
),
|
|
72
|
+
medium: textViewWrapperStyle(
|
|
73
|
+
TYPOGRAPHY_STYLES.body1Bold as TextStyle,
|
|
74
|
+
spacing.space100
|
|
75
|
+
),
|
|
76
|
+
large: textViewWrapperStyle(
|
|
77
|
+
TYPOGRAPHY_STYLES.heading5Bold as TextStyle,
|
|
78
|
+
spacing.space100
|
|
79
|
+
),
|
|
80
|
+
xLarge: textViewWrapperStyle(
|
|
81
|
+
TYPOGRAPHY_STYLES.heading3Bold as TextStyle,
|
|
82
|
+
spacing.space100
|
|
83
|
+
),
|
|
84
|
+
xxLarge: textViewWrapperStyle(
|
|
85
|
+
TYPOGRAPHY_STYLES.heading3Bold as TextStyle,
|
|
86
|
+
spacing.space100
|
|
87
|
+
),
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const CHIP_ICON_STYLE: ChipIconSizeType = {
|
|
91
|
+
xxLarge: ICON_SIZES.xxLarge,
|
|
92
|
+
xLarge: ICON_SIZES.xLarge,
|
|
93
|
+
large: ICON_SIZES.large,
|
|
94
|
+
medium: ICON_SIZES.small,
|
|
95
|
+
small: ICON_SIZES.xSmall,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const CHIP_ROUNDED_BORDER_RADIUS = borderRadius.borderRadiusFull;
|
|
99
|
+
|
|
100
|
+
export const CHIP_COLOR_TOKENS = {
|
|
101
|
+
primary: {
|
|
102
|
+
background: {
|
|
103
|
+
default: () => 'transparent',
|
|
104
|
+
pressed: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryPressed,
|
|
105
|
+
hover: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryHover,
|
|
106
|
+
selected: (theme: ExtendedTheme) => theme.colors.colorForegroundAccent,
|
|
107
|
+
disabled: (theme: ExtendedTheme) => theme.colors.colorBackgroundSecondary,
|
|
108
|
+
},
|
|
109
|
+
border: {
|
|
110
|
+
default: (theme: ExtendedTheme) => theme.colors.colorBorderSubtle,
|
|
111
|
+
selected: (theme: ExtendedTheme) => theme.colors.colorBorderSubtle,
|
|
112
|
+
},
|
|
113
|
+
text: {
|
|
114
|
+
default: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
|
|
115
|
+
selected: (theme: ExtendedTheme) => theme.colors.colorBackgroundLighter,
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
primaryOutline: {
|
|
119
|
+
background: {
|
|
120
|
+
default: () => 'transparent',
|
|
121
|
+
pressed: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryPressed,
|
|
122
|
+
hover: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryHover,
|
|
123
|
+
selected: (theme: ExtendedTheme) => theme.colors.colorBackgroundAccentAlpha,
|
|
124
|
+
disabled: (theme: ExtendedTheme) => theme.colors.colorBackgroundSecondary,
|
|
125
|
+
},
|
|
126
|
+
border: {
|
|
127
|
+
default: (theme: ExtendedTheme) => theme.colors.colorBorderSubtle,
|
|
128
|
+
selected: (theme: ExtendedTheme) => theme.colors.colorBorderAccent,
|
|
129
|
+
},
|
|
130
|
+
text: {
|
|
131
|
+
default: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
|
|
132
|
+
selected: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
outlined: {
|
|
136
|
+
background: {
|
|
137
|
+
default: () => 'transparent',
|
|
138
|
+
pressed: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryPressed,
|
|
139
|
+
hover: (theme: ExtendedTheme) => theme.colors.colorStatePrimaryHover,
|
|
140
|
+
disabled: (theme: ExtendedTheme) => theme.colors.colorBackgroundSecondary,
|
|
141
|
+
},
|
|
142
|
+
border: {
|
|
143
|
+
default: (theme: ExtendedTheme) => theme.colors.colorBorderSubtle,
|
|
144
|
+
selected: (theme: ExtendedTheme) => theme.colors.colorBorderSubtle,
|
|
145
|
+
},
|
|
146
|
+
text: {
|
|
147
|
+
default: (theme: ExtendedTheme) => theme.colors.colorForegroundSecondary,
|
|
148
|
+
selected: (theme: ExtendedTheme) => theme.colors.colorBackgroundLighter,
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
} as const;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import type { TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export type SizeType = 'small' | 'medium' | 'large' | 'xLarge' | 'xxLarge';
|
|
6
|
+
|
|
7
|
+
export type VariantsType =
|
|
8
|
+
| 'solid'
|
|
9
|
+
| 'outline'
|
|
10
|
+
| 'solidRounded'
|
|
11
|
+
| 'outlineRounded';
|
|
12
|
+
|
|
13
|
+
export type ChipSizeType = {
|
|
14
|
+
[key in SizeType]: ChipVariantType;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ChipVariantType = {
|
|
18
|
+
[key in VariantsType]: ViewStyle;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export type ChipVariants = {
|
|
23
|
+
[key in SizeType]: TextStyle;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ChipTextSizeType = {
|
|
27
|
+
[key in SizeType]: TextStyle;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ChipIconSizeType = {
|
|
31
|
+
[key in SizeType]: any;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ChipState = 'default' | 'pressed' | 'hover' | 'disabled' | 'selected';
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export type ChipVariant = 'primary' | 'primaryOutline' | 'outlined';
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
export type SizePadding = {
|
|
41
|
+
paddingVertical: ViewStyle['paddingVertical'],
|
|
42
|
+
paddingHorizontal: ViewStyle['paddingHorizontal']
|
|
43
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ExtendedTheme } from '../colors/Type';
|
|
2
|
+
import { CHIP_COLOR_TOKENS } from './Token';
|
|
3
|
+
import type { ChipState } from './Type';
|
|
4
|
+
|
|
5
|
+
export const getBackgroundColor = (
|
|
6
|
+
chipType: keyof typeof CHIP_COLOR_TOKENS,
|
|
7
|
+
state: ChipState,
|
|
8
|
+
theme: ExtendedTheme
|
|
9
|
+
) => {
|
|
10
|
+
const variant =
|
|
11
|
+
CHIP_COLOR_TOKENS[chipType] || CHIP_COLOR_TOKENS.primary;
|
|
12
|
+
const bg =
|
|
13
|
+
variant.background[state as keyof typeof variant.background] ||
|
|
14
|
+
variant.background.default;
|
|
15
|
+
return bg(theme);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const getBorderColor = (
|
|
19
|
+
chipType: keyof typeof CHIP_COLOR_TOKENS,
|
|
20
|
+
state: ChipState,
|
|
21
|
+
theme: ExtendedTheme
|
|
22
|
+
) => {
|
|
23
|
+
const variant =
|
|
24
|
+
CHIP_COLOR_TOKENS[chipType] || CHIP_COLOR_TOKENS.primary;
|
|
25
|
+
const border = variant.border[state as keyof typeof variant.border] || variant.border.default;
|
|
26
|
+
return border(theme);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const getTextColor = (
|
|
30
|
+
chipType: keyof typeof CHIP_COLOR_TOKENS,
|
|
31
|
+
state: ChipState,
|
|
32
|
+
theme: ExtendedTheme
|
|
33
|
+
) => {
|
|
34
|
+
const variant =
|
|
35
|
+
CHIP_COLOR_TOKENS[chipType] || CHIP_COLOR_TOKENS.primary;
|
|
36
|
+
const text =
|
|
37
|
+
variant.text[state as keyof typeof variant.text] ||
|
|
38
|
+
variant.text.default;
|
|
39
|
+
return text(theme);
|
|
40
|
+
};
|