cpk-ui 0.4.0 → 0.4.2
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/components/modals/AlertDialog/AlertDialog.d.ts +6 -4
- package/components/modals/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/components/modals/AlertDialog/AlertDialog.js +76 -20
- package/components/modals/Snackbar/Snackbar.d.ts +2 -0
- package/components/modals/Snackbar/Snackbar.d.ts.map +1 -1
- package/components/modals/Snackbar/Snackbar.js +41 -7
- package/components/uis/Accordion/Accordion.d.ts +7 -5
- package/components/uis/Accordion/Accordion.d.ts.map +1 -1
- package/components/uis/Accordion/Accordion.js +2 -2
- package/components/uis/Accordion/AccordionItem.d.ts +2 -2
- package/components/uis/Accordion/AccordionItem.d.ts.map +1 -1
- package/components/uis/Accordion/AccordionItem.js +70 -7
- package/components/uis/Button/Button.d.ts +7 -7
- package/components/uis/Button/Button.d.ts.map +1 -1
- package/components/uis/Button/Button.js +9 -7
- package/components/uis/Checkbox/Checkbox.d.ts +8 -5
- package/components/uis/Checkbox/Checkbox.d.ts.map +1 -1
- package/components/uis/Checkbox/Checkbox.js +42 -9
- package/components/uis/CustomPressable/CustomPressable.d.ts +2 -2
- package/components/uis/CustomPressable/CustomPressable.d.ts.map +1 -1
- package/components/uis/EditText/EditText.d.ts +7 -5
- package/components/uis/EditText/EditText.d.ts.map +1 -1
- package/components/uis/EditText/EditText.js +64 -14
- package/components/uis/Fab/Fab.d.ts +2 -2
- package/components/uis/Fab/Fab.d.ts.map +1 -1
- package/components/uis/Icon/Icon.d.ts +4 -3
- package/components/uis/Icon/Icon.d.ts.map +1 -1
- package/components/uis/Icon/Icon.js +13 -1
- package/components/uis/IconButton/IconButton.d.ts +4 -4
- package/components/uis/IconButton/IconButton.d.ts.map +1 -1
- package/components/uis/LoadingIndicator/LoadingIndicator.d.ts +5 -5
- package/components/uis/LoadingIndicator/LoadingIndicator.d.ts.map +1 -1
- package/components/uis/LoadingIndicator/LoadingIndicator.js +31 -11
- package/components/uis/RadioGroup/RadioButton.d.ts +6 -4
- package/components/uis/RadioGroup/RadioButton.d.ts.map +1 -1
- package/components/uis/RadioGroup/RadioButton.js +7 -7
- package/components/uis/RadioGroup/RadioGroup.d.ts +6 -4
- package/components/uis/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/components/uis/RadioGroup/RadioGroup.js +5 -5
- package/components/uis/Rating/Rating.d.ts +4 -3
- package/components/uis/Rating/Rating.d.ts.map +1 -1
- package/components/uis/Rating/Rating.js +13 -6
- package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts +2 -2
- package/components/uis/StatusbarBrightness/StatusBarBrightness.d.ts.map +1 -1
- package/components/uis/Styled/StyledComponents.d.ts +2 -0
- package/components/uis/Styled/StyledComponents.d.ts.map +1 -1
- package/components/uis/Styled/StyledComponents.js +20 -3
- package/components/uis/SwitchToggle/SwitchToggle.d.ts +4 -3
- package/components/uis/SwitchToggle/SwitchToggle.d.ts.map +1 -1
- package/components/uis/SwitchToggle/SwitchToggle.js +14 -0
- package/components/uis/Typography/Typography.d.ts.map +1 -1
- package/package.json +6 -2
- package/providers/ThemeProvider.d.ts +3 -2
- package/providers/ThemeProvider.d.ts.map +1 -1
- package/providers/ThemeProvider.js +17 -13
- package/providers/index.d.ts +3 -2
- package/providers/index.d.ts.map +1 -1
- package/src/components/modals/AlertDialog/AlertDialog.stories.tsx +149 -14
- package/src/components/modals/AlertDialog/AlertDialog.test.tsx +251 -0
- package/src/components/modals/AlertDialog/AlertDialog.tsx +94 -36
- package/src/components/modals/Snackbar/Snackbar.stories.tsx +97 -14
- package/src/components/modals/Snackbar/Snackbar.test.tsx +319 -0
- package/src/components/modals/Snackbar/Snackbar.tsx +52 -11
- package/src/components/uis/Accordion/Accordion.stories.tsx +70 -0
- package/src/components/uis/Accordion/Accordion.test.tsx +64 -2
- package/src/components/uis/Accordion/Accordion.tsx +12 -7
- package/src/components/uis/Accordion/AccordionItem.tsx +79 -16
- package/src/components/uis/Button/Button.stories.tsx +79 -2
- package/src/components/uis/Button/Button.test.tsx +76 -3
- package/src/components/uis/Button/Button.tsx +19 -17
- package/src/components/uis/Card/Card.test.tsx +2 -2
- package/src/components/uis/Checkbox/Checkbox.stories.tsx +171 -1
- package/src/components/uis/Checkbox/Checkbox.test.tsx +52 -2
- package/src/components/uis/Checkbox/Checkbox.tsx +70 -17
- package/src/components/uis/CustomPressable/CustomPressable.tsx +2 -2
- package/src/components/uis/EditText/EditText.stories.tsx +90 -12
- package/src/components/uis/EditText/EditText.test.tsx +70 -4
- package/src/components/uis/EditText/EditText.tsx +81 -23
- package/src/components/uis/Fab/Fab.stories.tsx +114 -19
- package/src/components/uis/Fab/Fab.test.tsx +64 -2
- package/src/components/uis/Fab/Fab.tsx +2 -2
- package/src/components/uis/Hr/Hr.test.tsx +2 -2
- package/src/components/uis/Icon/Icon.stories.tsx +53 -0
- package/src/components/uis/Icon/Icon.test.tsx +32 -2
- package/src/components/uis/Icon/Icon.tsx +17 -2
- package/src/components/uis/IconButton/IconButton.test.tsx +2 -2
- package/src/components/uis/IconButton/IconButton.tsx +4 -4
- package/src/components/uis/LoadingIndicator/LoadingIndicator.tsx +37 -16
- package/src/components/uis/LoadingIndicator/LodingIndicator.stories.tsx +58 -3
- package/src/components/uis/RadioGroup/RadioButton.tsx +16 -9
- package/src/components/uis/RadioGroup/RadioGroup.stories.tsx +150 -2
- package/src/components/uis/RadioGroup/RadioGroup.test.tsx +68 -1
- package/src/components/uis/RadioGroup/RadioGroup.tsx +16 -10
- package/src/components/uis/Rating/Rating.test.tsx +28 -2
- package/src/components/uis/Rating/Rating.tsx +21 -12
- package/src/components/uis/StatusbarBrightness/StatusBarBrightness.test.tsx +2 -2
- package/src/components/uis/StatusbarBrightness/StatusBarBrightness.tsx +2 -2
- package/src/components/uis/Styled/StyledComponents.tsx +18 -3
- package/src/components/uis/SwitchToggle/SwitchToggle.stories.tsx +55 -1
- package/src/components/uis/SwitchToggle/SwitchToggle.test.tsx +38 -3
- package/src/components/uis/SwitchToggle/SwitchToggle.tsx +20 -3
- package/src/components/uis/Typography/Typography.stories.tsx +99 -8
- package/src/components/uis/Typography/Typography.test.tsx +2 -2
- package/src/providers/ThemeProvider.tsx +20 -16
- package/src/providers/index.tsx +5 -6
- package/src/test/testUtils.tsx +3 -3
- package/src/utils/guards.ts +7 -7
- package/test/testUtils.d.ts +2 -2
- package/test/testUtils.d.ts.map +1 -1
- package/utils/guards.d.ts +4 -4
- package/utils/guards.d.ts.map +1 -1
- package/utils/guards.js +1 -1
- package/utils/theme.d.ts.map +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { type ReactElement } from 'react';
|
|
2
2
|
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
export type AlertDialogSizeType = 'small' | 'medium' | 'large' | number;
|
|
3
4
|
export type AlertDialogProps = {
|
|
4
5
|
style?: StyleProp<ViewStyle>;
|
|
5
6
|
};
|
|
@@ -13,12 +14,13 @@ export type AlertDialogStyles = {
|
|
|
13
14
|
};
|
|
14
15
|
export type AlertDialogOptions = {
|
|
15
16
|
styles?: AlertDialogStyles;
|
|
16
|
-
title?: string |
|
|
17
|
-
body?: string |
|
|
17
|
+
title?: string | ReactElement;
|
|
18
|
+
body?: string | ReactElement;
|
|
18
19
|
backdropOpacity?: number;
|
|
19
20
|
closeOnTouchOutside?: boolean;
|
|
20
|
-
actions?:
|
|
21
|
+
actions?: ReactElement[];
|
|
21
22
|
showCloseButton?: boolean;
|
|
23
|
+
size?: AlertDialogSizeType;
|
|
22
24
|
};
|
|
23
25
|
export type AlertDialogContext = {
|
|
24
26
|
open(alertDialogOptions?: AlertDialogOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/modals/AlertDialog/AlertDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AlertDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/modals/AlertDialog/AlertDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAQZ,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AA6DlE,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAExE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,eAAe,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;;AA+PF,wBAAyF"}
|
|
@@ -16,7 +16,26 @@ const Container = styled.View `
|
|
|
16
16
|
const AlertDialogContainer = styled.View `
|
|
17
17
|
flex: 0.87;
|
|
18
18
|
background-color: ${({ theme }) => theme.bg.basic};
|
|
19
|
-
padding:
|
|
19
|
+
padding-top: ${({ $size = 'medium' }) => {
|
|
20
|
+
if (typeof $size === 'number')
|
|
21
|
+
return $size * 1.25;
|
|
22
|
+
return $size === 'small' ? 16 : $size === 'large' ? 24 : 20;
|
|
23
|
+
}};
|
|
24
|
+
padding-right: ${({ $size = 'medium' }) => {
|
|
25
|
+
if (typeof $size === 'number')
|
|
26
|
+
return $size * 1.25;
|
|
27
|
+
return $size === 'small' ? 16 : $size === 'large' ? 24 : 20;
|
|
28
|
+
}};
|
|
29
|
+
padding-bottom: ${({ $size = 'medium' }) => {
|
|
30
|
+
if (typeof $size === 'number')
|
|
31
|
+
return $size * 1.75;
|
|
32
|
+
return $size === 'small' ? 22 : $size === 'large' ? 32 : 28;
|
|
33
|
+
}};
|
|
34
|
+
padding-left: ${({ $size = 'medium' }) => {
|
|
35
|
+
if (typeof $size === 'number')
|
|
36
|
+
return $size * 1.5;
|
|
37
|
+
return $size === 'small' ? 18 : $size === 'large' ? 28 : 24;
|
|
38
|
+
}};
|
|
20
39
|
border-radius: 8px;
|
|
21
40
|
`;
|
|
22
41
|
const TitleRow = styled.View `
|
|
@@ -25,11 +44,11 @@ const TitleRow = styled.View `
|
|
|
25
44
|
align-items: center;
|
|
26
45
|
`;
|
|
27
46
|
const BodyRow = styled.View `
|
|
28
|
-
margin-top:
|
|
29
|
-
margin-bottom:
|
|
47
|
+
margin-top: ${({ $marginTop }) => $marginTop};
|
|
48
|
+
margin-bottom: ${({ $marginBottom }) => $marginBottom};
|
|
30
49
|
`;
|
|
31
50
|
const ActionRow = styled.View `
|
|
32
|
-
margin-top:
|
|
51
|
+
margin-top: ${({ $marginTop }) => $marginTop};
|
|
33
52
|
padding-right: 4px;
|
|
34
53
|
flex-direction: row;
|
|
35
54
|
`;
|
|
@@ -64,7 +83,49 @@ function AlertDialog({ style }, ref) {
|
|
|
64
83
|
open: handleOpen,
|
|
65
84
|
close: handleClose,
|
|
66
85
|
}), [handleOpen, handleClose]);
|
|
67
|
-
const { backdropOpacity = 0.2, title, body, styles, actions, closeOnTouchOutside = true, showCloseButton = true, } = options ?? {};
|
|
86
|
+
const { backdropOpacity = 0.2, title, body, styles, actions, closeOnTouchOutside = true, showCloseButton = true, size = 'medium', } = options ?? {};
|
|
87
|
+
// Calculate sizes based on size prop
|
|
88
|
+
const sizeConfig = useMemo(() => {
|
|
89
|
+
if (typeof size === 'number') {
|
|
90
|
+
return {
|
|
91
|
+
titleFontSize: size,
|
|
92
|
+
bodyFontSize: size * 0.875,
|
|
93
|
+
iconSize: size * 1.125,
|
|
94
|
+
actionMarginTop: size * 1.25,
|
|
95
|
+
bodyMarginTop: size * 0.75,
|
|
96
|
+
bodyMarginBottom: size * 0.5,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
switch (size) {
|
|
100
|
+
case 'small':
|
|
101
|
+
return {
|
|
102
|
+
titleFontSize: 14,
|
|
103
|
+
bodyFontSize: 12,
|
|
104
|
+
iconSize: 16,
|
|
105
|
+
actionMarginTop: 16,
|
|
106
|
+
bodyMarginTop: 10,
|
|
107
|
+
bodyMarginBottom: 6,
|
|
108
|
+
};
|
|
109
|
+
case 'large':
|
|
110
|
+
return {
|
|
111
|
+
titleFontSize: 18,
|
|
112
|
+
bodyFontSize: 16,
|
|
113
|
+
iconSize: 20,
|
|
114
|
+
actionMarginTop: 24,
|
|
115
|
+
bodyMarginTop: 14,
|
|
116
|
+
bodyMarginBottom: 10,
|
|
117
|
+
};
|
|
118
|
+
default: // 'medium'
|
|
119
|
+
return {
|
|
120
|
+
titleFontSize: 16,
|
|
121
|
+
bodyFontSize: 14,
|
|
122
|
+
iconSize: 18,
|
|
123
|
+
actionMarginTop: 20,
|
|
124
|
+
bodyMarginTop: 12,
|
|
125
|
+
bodyMarginBottom: 8,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}, [size]);
|
|
68
129
|
// Memoize backdrop color calculation
|
|
69
130
|
const backdropColor = useMemo(() => themeType === 'light'
|
|
70
131
|
? `rgba(0,0,0,${backdropOpacity})`
|
|
@@ -76,14 +137,6 @@ function AlertDialog({ style }, ref) {
|
|
|
76
137
|
} : {}, [theme.text.basic]);
|
|
77
138
|
// Memoize container styles
|
|
78
139
|
const containerStyles = useMemo(() => StyleSheet.flatten([shadowStyles, styles?.container]), [shadowStyles, styles?.container]);
|
|
79
|
-
// Memoize modal styles
|
|
80
|
-
const modalStyles = useMemo(() => [
|
|
81
|
-
css `
|
|
82
|
-
flex: 1;
|
|
83
|
-
align-self: stretch;
|
|
84
|
-
`,
|
|
85
|
-
style,
|
|
86
|
-
], [style]);
|
|
87
140
|
// Memoize backdrop press handler
|
|
88
141
|
const handleBackdropPress = useCallback(() => {
|
|
89
142
|
if (closeOnTouchOutside) {
|
|
@@ -93,29 +146,32 @@ function AlertDialog({ style }, ref) {
|
|
|
93
146
|
// Memoize close button press handler
|
|
94
147
|
const handleCloseButtonPress = useCallback(() => setVisible(false), []);
|
|
95
148
|
// Memoize title content
|
|
96
|
-
const titleContent = useMemo(() => typeof title === 'string' ? (_jsx(Typography.Heading3, { style: styles?.title, children: title })) : (title), [title, styles?.title]);
|
|
149
|
+
const titleContent = useMemo(() => typeof title === 'string' ? (_jsx(Typography.Heading3, { style: [{ fontSize: sizeConfig.titleFontSize }, styles?.title], children: title })) : (title), [title, sizeConfig.titleFontSize, styles?.title]);
|
|
97
150
|
// Memoize body content
|
|
98
|
-
const bodyContent = useMemo(() => typeof body === 'string' ? (_jsx(Typography.Body3, { style: styles?.body, children: body })) : (body), [body, styles?.body]);
|
|
151
|
+
const bodyContent = useMemo(() => typeof body === 'string' ? (_jsx(Typography.Body3, { style: [{ fontSize: sizeConfig.bodyFontSize }, styles?.body], children: body })) : (body), [body, sizeConfig.bodyFontSize, styles?.body]);
|
|
99
152
|
// Memoize actions content
|
|
100
|
-
const actionsContent = useMemo(() => actions ? (_jsx(ActionRow, { style: styles?.actionContainer, children: actions.map((action, index) => cloneElement(action, {
|
|
153
|
+
const actionsContent = useMemo(() => actions ? (_jsx(ActionRow, { "$marginTop": sizeConfig.actionMarginTop, style: styles?.actionContainer, children: actions.map((action, index) => cloneElement(action, {
|
|
101
154
|
key: `action-${index}`,
|
|
102
155
|
style: {
|
|
103
156
|
flex: 1,
|
|
104
157
|
marginLeft: index !== 0 ? 12 : 0,
|
|
105
158
|
},
|
|
106
|
-
})) })) : null, [actions, styles?.actionContainer]);
|
|
159
|
+
})) })) : null, [actions, sizeConfig.actionMarginTop, styles?.actionContainer]);
|
|
107
160
|
// Memoize close button content
|
|
108
|
-
const closeButtonContent = useMemo(() => showCloseButton ? (_jsx(Button, { onPress: handleCloseButtonPress, borderRadius: 24, text: _jsx(Icon, { color: theme.text.basic, name: "X", size:
|
|
161
|
+
const closeButtonContent = useMemo(() => showCloseButton ? (_jsx(Button, { onPress: handleCloseButtonPress, borderRadius: 24, text: _jsx(Icon, { color: theme.text.basic, name: "X", size: sizeConfig.iconSize }), type: "text" })) : null, [showCloseButton, handleCloseButtonPress, sizeConfig.iconSize, theme.text.basic]);
|
|
109
162
|
const AlertDialogContent = useMemo(() => (_jsxs(Container, { style: css `
|
|
110
163
|
background-color: ${backdropColor};
|
|
111
|
-
`, children: [_jsx(TouchableWithoutFeedback, { onPress: closeOnTouchOutside ? handleCloseButtonPress : undefined, children: _jsx(View, { style: StyleSheet.absoluteFill }) }), _jsxs(AlertDialogContainer, { accessibilityRole: "alert", accessibilityLabel: typeof title === 'string' ? title : 'Alert dialog', style: containerStyles, children: [_jsxs(TitleRow, { style: styles?.titleContainer, children: [titleContent, closeButtonContent] }), _jsx(BodyRow, { style: styles?.bodyContainer, children: bodyContent }), actionsContent] })] })), [
|
|
164
|
+
`, children: [_jsx(TouchableWithoutFeedback, { onPress: closeOnTouchOutside ? handleCloseButtonPress : undefined, children: _jsx(View, { style: StyleSheet.absoluteFill }) }), _jsxs(AlertDialogContainer, { "$size": size, accessibilityRole: "alert", accessibilityLabel: typeof title === 'string' ? title : 'Alert dialog', style: containerStyles, children: [_jsxs(TitleRow, { style: styles?.titleContainer, children: [titleContent, closeButtonContent] }), _jsx(BodyRow, { "$marginTop": sizeConfig.bodyMarginTop, "$marginBottom": sizeConfig.bodyMarginBottom, style: styles?.bodyContainer, children: bodyContent }), actionsContent] })] })), [
|
|
112
165
|
backdropColor,
|
|
113
166
|
closeOnTouchOutside,
|
|
114
167
|
handleCloseButtonPress,
|
|
115
168
|
title,
|
|
169
|
+
size,
|
|
116
170
|
containerStyles,
|
|
117
171
|
styles?.titleContainer,
|
|
118
172
|
styles?.bodyContainer,
|
|
173
|
+
sizeConfig.bodyMarginTop,
|
|
174
|
+
sizeConfig.bodyMarginBottom,
|
|
119
175
|
titleContent,
|
|
120
176
|
closeButtonContent,
|
|
121
177
|
bodyContent,
|
|
@@ -123,7 +179,7 @@ function AlertDialog({ style }, ref) {
|
|
|
123
179
|
]);
|
|
124
180
|
return (
|
|
125
181
|
// https://github.com/facebook/react-native/issues/48526#issuecomment-2579478884
|
|
126
|
-
_jsx(View, { children: _jsx(Modal, { animationType: "fade",
|
|
182
|
+
_jsx(View, { style: style, children: _jsx(Modal, { animationType: "fade", transparent: true, visible: visible, children: closeOnTouchOutside ? (_jsx(TouchableWithoutFeedback, { onPress: handleBackdropPress, style: css `
|
|
127
183
|
flex: 1;
|
|
128
184
|
`, children: AlertDialogContent })) : (AlertDialogContent) }) }));
|
|
129
185
|
}
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
3
|
import { SnackbarTimer } from './const';
|
|
4
4
|
import { ButtonColorType } from '../../uis/Button/Button';
|
|
5
|
+
export type SnackbarSizeType = 'small' | 'medium' | 'large' | number;
|
|
5
6
|
export type SnackbarProps = {
|
|
6
7
|
style?: StyleProp<ViewStyle>;
|
|
7
8
|
};
|
|
@@ -17,6 +18,7 @@ export type SnackbarOptions = {
|
|
|
17
18
|
text?: string;
|
|
18
19
|
actionText?: string;
|
|
19
20
|
timer?: SnackbarTimer | number;
|
|
21
|
+
size?: SnackbarSizeType;
|
|
20
22
|
};
|
|
21
23
|
export type SnackbarContext = {
|
|
22
24
|
open(snackbarOptions?: SnackbarOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snackbar.d.ts","sourceRoot":"","sources":["../../../../src/components/modals/Snackbar/Snackbar.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Snackbar.d.ts","sourceRoot":"","sources":["../../../../src/components/modals/Snackbar/Snackbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2F,MAAM,OAAO,CAAC;AAChH,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAIlE,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AACtC,OAAO,EAAS,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAKhE,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAqCrE,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,eAAe,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IAC/B,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,eAAe,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9C,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;;AA4LF,wBAAgF"}
|
|
@@ -7,6 +7,11 @@ import { Button } from '../../uis/Button/Button';
|
|
|
7
7
|
import { useTheme } from '../../../providers/ThemeProvider';
|
|
8
8
|
import { Icon } from '../../uis/Icon/Icon';
|
|
9
9
|
import { Typography } from '../../uis/Typography/Typography';
|
|
10
|
+
const calculateSpacing = (size = 'medium') => {
|
|
11
|
+
if (typeof size === 'number')
|
|
12
|
+
return size * 0.75;
|
|
13
|
+
return size === 'small' ? 10 : size === 'large' ? 14 : 12;
|
|
14
|
+
};
|
|
10
15
|
const Container = styled(View) `
|
|
11
16
|
flex: 1;
|
|
12
17
|
align-self: stretch;
|
|
@@ -18,8 +23,8 @@ const SnackbarContainer = styled(SafeAreaView) `
|
|
|
18
23
|
background-color: ${({ theme, $color }) => theme.button[$color].bg};
|
|
19
24
|
border-radius: 8px;
|
|
20
25
|
margin-bottom: 52px;
|
|
21
|
-
margin-left:
|
|
22
|
-
margin-right:
|
|
26
|
+
margin-left: ${({ $size }) => calculateSpacing($size)};
|
|
27
|
+
margin-right: ${({ $size }) => calculateSpacing($size)};
|
|
23
28
|
align-self: flex-end;
|
|
24
29
|
|
|
25
30
|
flex-direction: row;
|
|
@@ -31,7 +36,7 @@ const ActionContainer = styled(View) `
|
|
|
31
36
|
const SnackbarText = styled(Typography.Body2) `
|
|
32
37
|
color: ${({ theme, $color }) => theme.button[$color].text};
|
|
33
38
|
flex: 1;
|
|
34
|
-
padding:
|
|
39
|
+
padding: ${({ $size }) => calculateSpacing($size)};
|
|
35
40
|
`;
|
|
36
41
|
let timer = null;
|
|
37
42
|
function clearTimer() {
|
|
@@ -65,7 +70,33 @@ function Snackbar({ style }, ref) {
|
|
|
65
70
|
open: handleOpen,
|
|
66
71
|
close: handleClose,
|
|
67
72
|
}), [handleOpen, handleClose]);
|
|
68
|
-
const { text, styles, actionText, color = 'primary' } = options ?? {};
|
|
73
|
+
const { text, styles, actionText, color = 'primary', size = 'medium' } = options ?? {};
|
|
74
|
+
// Calculate sizes based on size prop
|
|
75
|
+
const sizeConfig = useMemo(() => {
|
|
76
|
+
if (typeof size === 'number') {
|
|
77
|
+
return {
|
|
78
|
+
fontSize: size,
|
|
79
|
+
iconSize: size,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
switch (size) {
|
|
83
|
+
case 'small':
|
|
84
|
+
return {
|
|
85
|
+
fontSize: 12,
|
|
86
|
+
iconSize: 14,
|
|
87
|
+
};
|
|
88
|
+
case 'large':
|
|
89
|
+
return {
|
|
90
|
+
fontSize: 16,
|
|
91
|
+
iconSize: 18,
|
|
92
|
+
};
|
|
93
|
+
default: // 'medium'
|
|
94
|
+
return {
|
|
95
|
+
fontSize: 14,
|
|
96
|
+
iconSize: 16,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}, [size]);
|
|
69
100
|
// Memoize shadow styles
|
|
70
101
|
const shadowStyles = useMemo(() => Platform.OS !== 'web' ? {
|
|
71
102
|
shadowOffset: { width: 0, height: 4 },
|
|
@@ -77,9 +108,10 @@ function Snackbar({ style }, ref) {
|
|
|
77
108
|
const textStyles = useMemo(() => StyleSheet.flatten([
|
|
78
109
|
css `
|
|
79
110
|
color: ${theme.button[color].text};
|
|
111
|
+
font-size: ${sizeConfig.fontSize}px;
|
|
80
112
|
`,
|
|
81
113
|
styles?.text,
|
|
82
|
-
]), [theme.button, color, styles?.text]);
|
|
114
|
+
]), [theme.button, color, sizeConfig.fontSize, styles?.text]);
|
|
83
115
|
// Memoize action text styles
|
|
84
116
|
const actionTextStyles = useMemo(() => StyleSheet.flatten([
|
|
85
117
|
css `
|
|
@@ -97,10 +129,11 @@ function Snackbar({ style }, ref) {
|
|
|
97
129
|
`,
|
|
98
130
|
style,
|
|
99
131
|
], [style]);
|
|
100
|
-
const SnackbarContent = useMemo(() => (_jsx(Container, { children: _jsxs(SnackbarContainer, { "$color": color, style: containerStyles, children: [_jsx(SnackbarText, { "$color": color, style: textStyles, children: text }), _jsx(ActionContainer, { style: styles?.actionContainer, children: actionText ? (_jsx(Button, { onPress: handleActionPress, styles: {
|
|
132
|
+
const SnackbarContent = useMemo(() => (_jsx(Container, { children: _jsxs(SnackbarContainer, { "$color": color, "$size": size, style: containerStyles, children: [_jsx(SnackbarText, { "$color": color, "$size": size, style: textStyles, children: text }), _jsx(ActionContainer, { style: styles?.actionContainer, children: actionText ? (_jsx(Button, { onPress: handleActionPress, styles: {
|
|
101
133
|
text: actionTextStyles,
|
|
102
|
-
}, text: actionText, type: "text" })) : (_jsx(Button, { onPress: handleActionPress, text: _jsx(Icon, { color: theme.button[color].text, name: "X" }), type: "text" })) })] }) })), [
|
|
134
|
+
}, text: actionText, type: "text" })) : (_jsx(Button, { onPress: handleActionPress, text: _jsx(Icon, { color: theme.button[color].text, name: "X", size: sizeConfig.iconSize }), type: "text" })) })] }) })), [
|
|
103
135
|
color,
|
|
136
|
+
size,
|
|
104
137
|
containerStyles,
|
|
105
138
|
textStyles,
|
|
106
139
|
text,
|
|
@@ -108,6 +141,7 @@ function Snackbar({ style }, ref) {
|
|
|
108
141
|
actionText,
|
|
109
142
|
actionTextStyles,
|
|
110
143
|
handleActionPress,
|
|
144
|
+
sizeConfig.iconSize,
|
|
111
145
|
theme.button,
|
|
112
146
|
]);
|
|
113
147
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
2
|
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
3
|
import type { AccordionItemDataType } from './AccordionItem';
|
|
4
4
|
type Styles = {
|
|
@@ -9,22 +9,24 @@ type Styles = {
|
|
|
9
9
|
itemText?: StyleProp<TextStyle>;
|
|
10
10
|
toggleElement?: StyleProp<ViewStyle>;
|
|
11
11
|
};
|
|
12
|
+
export type AccordionSizeType = 'small' | 'medium' | 'large' | number;
|
|
12
13
|
export type AccordionBaseProps<T = string, K = string> = {
|
|
13
14
|
data: AccordionItemDataType<T, K>[];
|
|
14
15
|
style?: StyleProp<ViewStyle>;
|
|
15
16
|
styles?: Styles;
|
|
17
|
+
size?: AccordionSizeType;
|
|
16
18
|
shouldAnimate?: boolean;
|
|
17
19
|
collapseOnStart?: boolean;
|
|
18
20
|
animDuration?: number;
|
|
19
21
|
activeOpacity?: number;
|
|
20
22
|
toggleElementPosition?: 'left' | 'right';
|
|
21
|
-
toggleElement?:
|
|
22
|
-
renderTitle?: (title: T) =>
|
|
23
|
-
renderItem?: (body: K) =>
|
|
23
|
+
toggleElement?: ReactElement | null;
|
|
24
|
+
renderTitle?: (title: T) => ReactElement;
|
|
25
|
+
renderItem?: (body: K) => ReactElement;
|
|
24
26
|
onPressItem?: (title: T | string, body: K | string) => void;
|
|
25
27
|
};
|
|
26
28
|
export type AccordionProps<T = string, K = string> = AccordionBaseProps<T, K>;
|
|
27
|
-
declare function Accordion<T, K>({ style, toggleElementPosition, data, ...rest }: AccordionProps<T, K>):
|
|
29
|
+
declare function Accordion<T, K>({ style, toggleElementPosition, size, data, ...rest }: AccordionProps<T, K>): ReactElement;
|
|
28
30
|
declare const _default: typeof Accordion;
|
|
29
31
|
export default _default;
|
|
30
32
|
export { Accordion };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Accordion/Accordion.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Accordion/Accordion.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAU,KAAK,YAAY,EAAC,MAAM,OAAO,CAAC;AACxD,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAIlE,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AAO3D,KAAK,MAAM,GAAG;IACZ,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtE,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,MAAM,IAAI;IACvD,IAAI,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzC,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAAC;IACzC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,YAAY,CAAC;IACvC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,MAAM,IAAI,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E,iBAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,EACvB,KAAK,EACL,qBAA+B,EAC/B,IAAe,EACf,IAAI,EACJ,GAAG,IAAI,EACR,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAqBrC;wBAGuC,OAAO,SAAS;AAAxD,wBAAyD;AACzD,OAAO,EAAC,SAAS,EAAC,CAAC"}
|
|
@@ -6,9 +6,9 @@ import { AccordionItem } from './AccordionItem';
|
|
|
6
6
|
const Container = styled(View) `
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
`;
|
|
9
|
-
function Accordion({ style, toggleElementPosition = 'right', data, ...rest }) {
|
|
9
|
+
function Accordion({ style, toggleElementPosition = 'right', size = 'medium', data, ...rest }) {
|
|
10
10
|
// Memoize accordion items rendering
|
|
11
|
-
const accordionItems = useMemo(() => data.map((datum, titleKey) => (_jsx(AccordionItem, { data: datum, testID: `${titleKey}`, toggleElementPosition: toggleElementPosition, ...rest }, titleKey))), [data, toggleElementPosition, rest]);
|
|
11
|
+
const accordionItems = useMemo(() => data.map((datum, titleKey) => (_jsx(AccordionItem, { data: datum, testID: `${titleKey}`, toggleElementPosition: toggleElementPosition, size: size, ...rest }, titleKey))), [data, toggleElementPosition, size, rest]);
|
|
12
12
|
return (_jsx(Container, { style: style, children: accordionItems }));
|
|
13
13
|
}
|
|
14
14
|
// Export memoized component for better performance
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
2
|
import type { AccordionBaseProps } from './Accordion';
|
|
3
3
|
export type AccordionItemDataType<T, K> = {
|
|
4
4
|
title: T;
|
|
@@ -8,7 +8,7 @@ type Props<T, K> = Omit<AccordionBaseProps<T, K>, 'data' | 'style'> & {
|
|
|
8
8
|
testID: string;
|
|
9
9
|
data: AccordionItemDataType<string, string> | AccordionItemDataType<T, K>;
|
|
10
10
|
};
|
|
11
|
-
export declare function AccordionItem<T, K>({ testID, data: data, shouldAnimate, collapseOnStart, animDuration, activeOpacity, toggleElement, toggleElementPosition, onPressItem, renderTitle, renderItem, styles, }: Props<T, K>):
|
|
11
|
+
export declare function AccordionItem<T, K>({ testID, data: data, size, shouldAnimate, collapseOnStart, animDuration, activeOpacity, toggleElement, toggleElementPosition, onPressItem, renderTitle, renderItem, styles, }: Props<T, K>): ReactElement;
|
|
12
12
|
declare const _default: typeof AccordionItem;
|
|
13
13
|
export default _default;
|
|
14
14
|
//# sourceMappingURL=AccordionItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Accordion/AccordionItem.tsx"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Accordion/AccordionItem.tsx"],"names":[],"mappings":"AACA,OAAc,EAAoD,KAAK,YAAY,EAAC,MAAM,OAAO,CAAC;AAQlG,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AA+DpD,MAAM,MAAM,qBAAqB,CAAC,CAAC,EAAE,CAAC,IAAI;IACxC,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,EAAE,CAAC;CACZ,CAAC;AAEF,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAC3E,CAAC;AAEF,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,EAClC,MAAM,EACN,IAAI,EAAE,IAAI,EACV,IAAe,EACf,aAAoB,EACpB,eAAsB,EACtB,YAAkB,EAClB,aAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,UAAU,EACV,MAAM,GACP,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CA8M5B;wBAG2C,OAAO,aAAa;AAAhE,wBAAiE"}
|
|
@@ -6,25 +6,77 @@ import { styled, css } from 'kstyled';
|
|
|
6
6
|
import { Icon } from '../Icon/Icon';
|
|
7
7
|
import { Typography } from '../Typography/Typography';
|
|
8
8
|
const TitleTouch = styled(TouchableOpacity) `
|
|
9
|
-
height:
|
|
9
|
+
height: ${({ $size = 'medium' }) => {
|
|
10
|
+
if (typeof $size === 'number')
|
|
11
|
+
return $size * 2.4;
|
|
12
|
+
return $size === 'small' ? 40 : $size === 'large' ? 56 : 48;
|
|
13
|
+
}};
|
|
10
14
|
background-color: ${({ theme }) => theme.bg.basic};
|
|
11
15
|
|
|
12
16
|
flex-direction: row;
|
|
13
17
|
align-items: center;
|
|
14
|
-
padding:
|
|
18
|
+
padding-top: ${({ $size = 'medium' }) => {
|
|
19
|
+
if (typeof $size === 'number')
|
|
20
|
+
return $size * 0.4;
|
|
21
|
+
return $size === 'small' ? 6 : $size === 'large' ? 10 : 8;
|
|
22
|
+
}};
|
|
23
|
+
padding-bottom: ${({ $size = 'medium' }) => {
|
|
24
|
+
if (typeof $size === 'number')
|
|
25
|
+
return $size * 0.4;
|
|
26
|
+
return $size === 'small' ? 6 : $size === 'large' ? 10 : 8;
|
|
27
|
+
}};
|
|
28
|
+
padding-left: ${({ $size = 'medium' }) => {
|
|
29
|
+
if (typeof $size === 'number')
|
|
30
|
+
return $size * 0.6;
|
|
31
|
+
return $size === 'small' ? 10 : $size === 'large' ? 14 : 12;
|
|
32
|
+
}};
|
|
33
|
+
padding-right: ${({ $size = 'medium' }) => {
|
|
34
|
+
if (typeof $size === 'number')
|
|
35
|
+
return $size * 0.6;
|
|
36
|
+
return $size === 'small' ? 10 : $size === 'large' ? 14 : 12;
|
|
37
|
+
}};
|
|
15
38
|
`;
|
|
16
39
|
const StyledIcon = styled(Icon) `
|
|
17
40
|
color: ${({ theme }) => theme.text.basic};
|
|
18
41
|
font-weight: bold;
|
|
42
|
+
font-size: ${({ $size = 'medium' }) => {
|
|
43
|
+
if (typeof $size === 'number')
|
|
44
|
+
return $size * 0.7;
|
|
45
|
+
return $size === 'small' ? 12 : $size === 'large' ? 16 : 14;
|
|
46
|
+
}};
|
|
19
47
|
`;
|
|
20
48
|
const ItemTouch = styled(TouchableOpacity) `
|
|
21
49
|
background-color: ${({ theme }) => theme.bg.paper};
|
|
22
|
-
padding:
|
|
50
|
+
padding-top: ${({ $size = 'medium' }) => {
|
|
51
|
+
if (typeof $size === 'number')
|
|
52
|
+
return $size * 0.4;
|
|
53
|
+
return $size === 'small' ? 6 : $size === 'large' ? 10 : 8;
|
|
54
|
+
}};
|
|
55
|
+
padding-bottom: ${({ $size = 'medium' }) => {
|
|
56
|
+
if (typeof $size === 'number')
|
|
57
|
+
return $size * 0.4;
|
|
58
|
+
return $size === 'small' ? 6 : $size === 'large' ? 10 : 8;
|
|
59
|
+
}};
|
|
60
|
+
padding-left: ${({ $size = 'medium' }) => {
|
|
61
|
+
if (typeof $size === 'number')
|
|
62
|
+
return $size * 0.6;
|
|
63
|
+
return $size === 'small' ? 10 : $size === 'large' ? 14 : 12;
|
|
64
|
+
}};
|
|
65
|
+
padding-right: ${({ $size = 'medium' }) => {
|
|
66
|
+
if (typeof $size === 'number')
|
|
67
|
+
return $size * 0.6;
|
|
68
|
+
return $size === 'small' ? 10 : $size === 'large' ? 14 : 12;
|
|
69
|
+
}};
|
|
23
70
|
|
|
24
71
|
flex-direction: row;
|
|
25
72
|
align-items: center;
|
|
26
73
|
`;
|
|
27
|
-
export function AccordionItem({ testID, data: data, shouldAnimate = true, collapseOnStart = true, animDuration = 200, activeOpacity = 1, toggleElement
|
|
74
|
+
export function AccordionItem({ testID, data: data, size = 'medium', shouldAnimate = true, collapseOnStart = true, animDuration = 200, activeOpacity = 1, toggleElement, toggleElementPosition, onPressItem, renderTitle, renderItem, styles, }) {
|
|
75
|
+
// Calculate icon size based on accordion size
|
|
76
|
+
const iconSize = typeof size === 'number'
|
|
77
|
+
? size * 0.7
|
|
78
|
+
: size === 'small' ? 12 : size === 'large' ? 16 : 14;
|
|
79
|
+
const defaultToggleElement = _jsx(StyledIcon, { name: "CaretDown", "$size": size, size: iconSize });
|
|
28
80
|
const dropDownAnimValueRef = useRef(new Animated.Value(0));
|
|
29
81
|
const rotateAnimValueRef = useRef(new Animated.Value(0));
|
|
30
82
|
const fadeItemAnim = useRef(new Animated.Value(0)).current;
|
|
@@ -69,10 +121,14 @@ export function AccordionItem({ testID, data: data, shouldAnimate = true, collap
|
|
|
69
121
|
const handleLayout = useCallback((e) => {
|
|
70
122
|
setItemHeight(e.nativeEvent.layout.height);
|
|
71
123
|
}, []);
|
|
124
|
+
// Calculate margin based on size
|
|
125
|
+
const toggleMargin = typeof size === 'number'
|
|
126
|
+
? size * 0.6
|
|
127
|
+
: size === 'small' ? 10 : size === 'large' ? 14 : 12;
|
|
72
128
|
// Memoize toggle element container
|
|
73
129
|
const toggleElContainer = useMemo(() => (_jsx(Animated.View, { style: [
|
|
74
130
|
css `
|
|
75
|
-
margin-right: ${toggleElementPosition === 'left' ?
|
|
131
|
+
margin-right: ${toggleElementPosition === 'left' ? toggleMargin : 0}px;
|
|
76
132
|
`,
|
|
77
133
|
{
|
|
78
134
|
transform: [
|
|
@@ -85,7 +141,7 @@ export function AccordionItem({ testID, data: data, shouldAnimate = true, collap
|
|
|
85
141
|
],
|
|
86
142
|
},
|
|
87
143
|
styles?.toggleElement,
|
|
88
|
-
], children: toggleElement })), [toggleElement, toggleElementPosition, styles?.toggleElement]);
|
|
144
|
+
], children: toggleElement || defaultToggleElement })), [toggleElement, defaultToggleElement, toggleElementPosition, toggleMargin, styles?.toggleElement]);
|
|
89
145
|
// Memoize container styles
|
|
90
146
|
const containerStyles = useMemo(() => [
|
|
91
147
|
css `
|
|
@@ -113,10 +169,17 @@ export function AccordionItem({ testID, data: data, shouldAnimate = true, collap
|
|
|
113
169
|
}),
|
|
114
170
|
},
|
|
115
171
|
], [fadeItemAnim, itemHeight]);
|
|
172
|
+
// Calculate font sizes based on size prop
|
|
173
|
+
const titleFontSize = typeof size === 'number'
|
|
174
|
+
? size
|
|
175
|
+
: size === 'small' ? 14 : size === 'large' ? 18 : 16;
|
|
176
|
+
const itemFontSize = typeof size === 'number'
|
|
177
|
+
? size * 0.875
|
|
178
|
+
: size === 'small' ? 12 : size === 'large' ? 16 : 14;
|
|
116
179
|
return (_jsxs(Animated.View, { style: containerStyles, children: [_jsx(View, { onLayout: handleLayout, style: css `
|
|
117
180
|
position: absolute;
|
|
118
181
|
opacity: 0;
|
|
119
|
-
`, children: data.items.map((body, index) => (_jsx(ItemTouch, { activeOpacity: activeOpacity, onPress: () => handleItemPress(body), children: typeof body === 'string' && !renderItem ? (_jsx(Typography.Body3, { style: styles?.itemText, children: body })) : (renderItem?.(body)) }, `body-${index}`))) }), _jsx(Animated.View, { accessibilityState: { expanded: !collapsed }, style: animatedItemStyles, testID: `body-${testID}`, children: data.items.map((body, index) => (_jsx(ItemTouch, { activeOpacity: activeOpacity, onPress: () => handleItemPress(body), style: styles?.itemContainer, children: typeof body === 'string' && !renderItem ? (_jsx(Typography.Body3, { style: styles?.itemText, children: body })) : (renderItem?.(body)) }, `body-${index}`))) }), _jsxs(TitleTouch, { activeOpacity: activeOpacity, onPress: handleToggle, accessibilityRole: "button", accessibilityLabel: typeof data.title === 'string' ? data.title : 'Accordion section', accessibilityState: { expanded: !collapsed }, accessibilityHint: collapsed ? 'Double tap to expand' : 'Double tap to collapse', style: titleContainerStyles, testID: `title-${testID}`, children: [toggleElementPosition === 'left' ? toggleElContainer : null, typeof data.title === 'string' && !renderTitle ? (_jsx(Typography.Heading4, { style: styles?.titleText, children: data.title })) : (renderTitle?.(data.title)), toggleElementPosition === 'right' ? toggleElContainer : null] })] }));
|
|
182
|
+
`, children: data.items.map((body, index) => (_jsx(ItemTouch, { activeOpacity: activeOpacity, onPress: () => handleItemPress(body), "$size": size, children: typeof body === 'string' && !renderItem ? (_jsx(Typography.Body3, { style: [{ fontSize: itemFontSize }, styles?.itemText], children: body })) : (renderItem?.(body)) }, `body-${index}`))) }), _jsx(Animated.View, { accessibilityState: { expanded: !collapsed }, style: animatedItemStyles, testID: `body-${testID}`, children: data.items.map((body, index) => (_jsx(ItemTouch, { activeOpacity: activeOpacity, onPress: () => handleItemPress(body), style: styles?.itemContainer, "$size": size, children: typeof body === 'string' && !renderItem ? (_jsx(Typography.Body3, { style: [{ fontSize: itemFontSize }, styles?.itemText], children: body })) : (renderItem?.(body)) }, `body-${index}`))) }), _jsxs(TitleTouch, { activeOpacity: activeOpacity, onPress: handleToggle, accessibilityRole: "button", accessibilityLabel: typeof data.title === 'string' ? data.title : 'Accordion section', accessibilityState: { expanded: !collapsed }, accessibilityHint: collapsed ? 'Double tap to expand' : 'Double tap to collapse', style: titleContainerStyles, testID: `title-${testID}`, "$size": size, children: [toggleElementPosition === 'left' ? toggleElContainer : null, typeof data.title === 'string' && !renderTitle ? (_jsx(Typography.Heading4, { style: [{ fontSize: titleFontSize }, styles?.titleText], children: data.title })) : (renderTitle?.(data.title)), toggleElementPosition === 'right' ? toggleElContainer : null] })] }));
|
|
120
183
|
}
|
|
121
184
|
// Export memoized component for better performance
|
|
122
185
|
export default React.memo(AccordionItem);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
2
|
import type { Insets, StyleProp, TextStyle, TouchableHighlightProps, ViewStyle } from 'react-native';
|
|
3
3
|
import * as Haptics from 'expo-haptics';
|
|
4
4
|
export type ButtonType = 'text' | 'solid' | 'outlined';
|
|
5
5
|
export type ButtonColorType = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light';
|
|
6
|
-
export type ButtonSizeType = 'small' | 'medium' | 'large';
|
|
6
|
+
export type ButtonSizeType = 'small' | 'medium' | 'large' | number;
|
|
7
7
|
export type Props = {
|
|
8
8
|
testID?: string;
|
|
9
9
|
type?: ButtonType;
|
|
@@ -12,11 +12,11 @@ export type Props = {
|
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
loading?: boolean;
|
|
14
14
|
loadingColor?: string;
|
|
15
|
-
loadingElement?:
|
|
16
|
-
text?: string |
|
|
15
|
+
loadingElement?: ReactElement;
|
|
16
|
+
text?: string | ReactElement;
|
|
17
17
|
borderRadius?: number;
|
|
18
|
-
startElement?:
|
|
19
|
-
endElement?:
|
|
18
|
+
startElement?: ReactElement;
|
|
19
|
+
endElement?: ReactElement;
|
|
20
20
|
style?: StyleProp<Omit<ViewStyle, 'borderRadius' | 'padding'>>;
|
|
21
21
|
styles?: Styles;
|
|
22
22
|
onPress?: TouchableHighlightProps['onPress'];
|
|
@@ -34,7 +34,7 @@ type Styles = {
|
|
|
34
34
|
disabledText?: StyleProp<TextStyle>;
|
|
35
35
|
hovered?: StyleProp<ViewStyle>;
|
|
36
36
|
};
|
|
37
|
-
export declare function Button({ testID, type, color, size, disabled, loading, loadingElement, text, startElement, endElement, style, styles, onPress, activeOpacity, touchableHighlightProps, borderRadius, loadingColor, hitSlop, hapticFeedback, }: Props):
|
|
37
|
+
export declare function Button({ testID, type, color, size, disabled, loading, loadingElement, text, startElement, endElement, style, styles, onPress, activeOpacity, touchableHighlightProps, borderRadius, loadingColor, hitSlop, hapticFeedback, }: Props): ReactElement;
|
|
38
38
|
declare const _default: typeof Button;
|
|
39
39
|
export default _default;
|
|
40
40
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Button/Button.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAc,EAA+B,KAAK,YAAY,EAAC,MAAM,OAAO,CAAC;AAC7E,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,SAAS,EACT,uBAAuB,EACvB,SAAS,EACV,MAAM,cAAc,CAAC;AAUtB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AACvD,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,WAAW,GACX,SAAS,GACT,QAAQ,GACR,SAAS,GACT,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnE,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAC7C,aAAa,CAAC,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC;IACzD,uBAAuB,CAAC,EAAE,IAAI,CAC5B,uBAAuB,EACvB,SAAS,GAAG,eAAe,GAAG,OAAO,CACtC,CAAC;IACF,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC7C,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC;CAC9C,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAChC,CAAC;AAgKF,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,IAAc,EACd,KAAiB,EACjB,IAAe,EACf,QAAQ,EACR,OAAe,EACf,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,KAAK,EACL,MAAM,EACN,OAAO,EACP,aAAmB,EACnB,uBAAuB,EACvB,YAAgB,EAChB,YAAY,EACZ,OAAgD,EAChD,cAAc,GACf,EAAE,KAAK,GAAG,YAAY,CA6LtB;wBAGoC,OAAO,MAAM;AAAlD,wBAAmD"}
|
|
@@ -19,13 +19,15 @@ const calculateStyles = ({ theme, type, color, size, loading, disabled, borderRa
|
|
|
19
19
|
const isDisabled = disabled || loading;
|
|
20
20
|
const padding = type === 'text'
|
|
21
21
|
? '8px'
|
|
22
|
-
: size === '
|
|
23
|
-
?
|
|
24
|
-
: size === '
|
|
25
|
-
? '
|
|
26
|
-
: size === '
|
|
27
|
-
? '
|
|
28
|
-
:
|
|
22
|
+
: typeof size === 'number'
|
|
23
|
+
? `${size * 0.6}px ${size * 1.2}px`
|
|
24
|
+
: size === 'large'
|
|
25
|
+
? '16px 24px'
|
|
26
|
+
: size === 'medium'
|
|
27
|
+
? '12px 24px'
|
|
28
|
+
: size === 'small'
|
|
29
|
+
? '8px 16px'
|
|
30
|
+
: '12px 24px';
|
|
29
31
|
const borderWidth = type === 'outlined' ? 1 : 0;
|
|
30
32
|
const backgroundColor = type === 'solid'
|
|
31
33
|
? isDisabled
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
3
|
type Styles = {
|
|
4
4
|
container?: StyleProp<ViewStyle>;
|
|
5
5
|
checkbox?: StyleProp<ViewStyle>;
|
|
6
6
|
check?: ViewStyle;
|
|
7
|
+
text?: StyleProp<TextStyle>;
|
|
7
8
|
};
|
|
8
9
|
export type CheckboxColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
|
|
10
|
+
export type CheckboxSizeType = 'small' | 'medium' | 'large' | number;
|
|
9
11
|
export interface CheckboxProps {
|
|
10
12
|
onPress?: () => void;
|
|
11
13
|
style?: StyleProp<ViewStyle>;
|
|
12
14
|
styles?: Styles;
|
|
13
15
|
color?: CheckboxColor;
|
|
16
|
+
size?: CheckboxSizeType;
|
|
14
17
|
disabled?: boolean;
|
|
15
18
|
checked?: boolean;
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
text?: string | ReactElement;
|
|
20
|
+
direction?: 'left' | 'right';
|
|
18
21
|
}
|
|
19
|
-
export declare function Checkbox({ style, styles,
|
|
22
|
+
export declare function Checkbox({ style, styles, text, direction, color, size, disabled, checked, onPress, }: CheckboxProps): ReactElement;
|
|
20
23
|
declare const _default: typeof Checkbox;
|
|
21
24
|
export default _default;
|
|
22
25
|
//# sourceMappingURL=Checkbox.d.ts.map
|