@himakarinv/nativex 1.0.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/LICENSE +21 -0
- package/README.md +105 -0
- package/images.d.ts +14 -0
- package/index.js +8 -0
- package/nativewind-preset.js +18 -0
- package/package.json +120 -0
- package/src/assets/branding/logo.jpg +0 -0
- package/src/assets/branding/softech-logo.png +0 -0
- package/src/assets/icons/2-layers.svg +3 -0
- package/src/assets/icons/Forbidden.svg +211 -0
- package/src/assets/icons/Internal-server-error.svg +119 -0
- package/src/assets/icons/Log-out-nav.svg +4 -0
- package/src/assets/icons/Not-Found.svg +282 -0
- package/src/assets/icons/Unauthorized.svg +314 -0
- package/src/assets/icons/User-Frame.svg +5 -0
- package/src/assets/icons/alert.svg +4 -0
- package/src/assets/icons/arrow-right.svg +3 -0
- package/src/assets/icons/avatar-female.svg +10 -0
- package/src/assets/icons/avatar-male.svg +10 -0
- package/src/assets/icons/bell.svg +3 -0
- package/src/assets/icons/calendar-event.svg +11 -0
- package/src/assets/icons/calendar.svg +6 -0
- package/src/assets/icons/card.svg +4 -0
- package/src/assets/icons/caret-right.svg +3 -0
- package/src/assets/icons/chat.svg +11 -0
- package/src/assets/icons/check.svg +3 -0
- package/src/assets/icons/checkbox-minus.svg +3 -0
- package/src/assets/icons/checkmark.svg +3 -0
- package/src/assets/icons/chevron-down.svg +3 -0
- package/src/assets/icons/chevron-left.svg +9 -0
- package/src/assets/icons/chevron-right.svg +9 -0
- package/src/assets/icons/circle-radio-active.svg +10 -0
- package/src/assets/icons/circle-radio.svg +10 -0
- package/src/assets/icons/clock.svg +3 -0
- package/src/assets/icons/close.svg +3 -0
- package/src/assets/icons/code.svg +3 -0
- package/src/assets/icons/country.svg +20 -0
- package/src/assets/icons/dot.svg +3 -0
- package/src/assets/icons/download.svg +1 -0
- package/src/assets/icons/dropdown-arrow.svg +3 -0
- package/src/assets/icons/dropdown-avatar.svg +3 -0
- package/src/assets/icons/email.svg +3 -0
- package/src/assets/icons/error.svg +3 -0
- package/src/assets/icons/eye-off.svg +1 -0
- package/src/assets/icons/eye.svg +1 -0
- package/src/assets/icons/hashtag-icon.svg +3 -0
- package/src/assets/icons/help-circle.svg +10 -0
- package/src/assets/icons/help.svg +4 -0
- package/src/assets/icons/hide-checkbox.svg +3 -0
- package/src/assets/icons/home-smile.svg +3 -0
- package/src/assets/icons/home.svg +3 -0
- package/src/assets/icons/info.svg +5 -0
- package/src/assets/icons/left-arrow.svg +3 -0
- package/src/assets/icons/log-out.svg +3 -0
- package/src/assets/icons/notification-box.svg +4 -0
- package/src/assets/icons/pencil.svg +1 -0
- package/src/assets/icons/plus.svg +3 -0
- package/src/assets/icons/radio-dot.svg +3 -0
- package/src/assets/icons/right-arrow.svg +3 -0
- package/src/assets/icons/search.svg +3 -0
- package/src/assets/icons/settings.svg +11 -0
- package/src/assets/icons/slack.svg +17 -0
- package/src/assets/icons/slash.svg +3 -0
- package/src/assets/icons/success.svg +3 -0
- package/src/assets/icons/successicon.svg +5 -0
- package/src/assets/icons/three-dot-vertical.svg +5 -0
- package/src/assets/icons/trash.svg +1 -0
- package/src/assets/icons/trend-down-01.svg +3 -0
- package/src/assets/icons/trend-up-01.svg +3 -0
- package/src/assets/icons/up-arrow.svg +3 -0
- package/src/assets/icons/user-plus.svg +10 -0
- package/src/assets/icons/user.svg +3 -0
- package/src/assets/icons/users.svg +3 -0
- package/src/assets/icons/vertical-dots-true-icon.svg +5 -0
- package/src/assets/icons/vertical-line.svg +3 -0
- package/src/assets/icons/vertical-three-dots-icon.svg +5 -0
- package/src/assets/icons/warning.svg +3 -0
- package/src/assets/icons/zap.svg +3 -0
- package/src/components/ActionsMenu/ActionsMenu.tsx +314 -0
- package/src/components/ActionsMenu/index.ts +2 -0
- package/src/components/Alert/Alert.tsx +291 -0
- package/src/components/Alert/index.ts +2 -0
- package/src/components/Badge/Badge.tsx +230 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +364 -0
- package/src/components/Breadcrumb/index.ts +7 -0
- package/src/components/Button/Button.tsx +584 -0
- package/src/components/Button/index.ts +9 -0
- package/src/components/Checkbox/Checkbox.tsx +336 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/CreatePassword/CreatePassword.tsx +161 -0
- package/src/components/CreatePassword/index.ts +2 -0
- package/src/components/DataTable/DataTable.tsx +822 -0
- package/src/components/DataTable/index.ts +10 -0
- package/src/components/Datepicker/Datepicker.tsx +797 -0
- package/src/components/Datepicker/index.ts +2 -0
- package/src/components/Dropdown/Dropdown.tsx +277 -0
- package/src/components/Dropdown/index.ts +7 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +471 -0
- package/src/components/DropdownMenu/index.ts +11 -0
- package/src/components/DynamicForm/DynamicForm.tsx +741 -0
- package/src/components/DynamicForm/index.ts +13 -0
- package/src/components/ErrorPages/ErrorPages.tsx +135 -0
- package/src/components/ErrorPages/index.ts +2 -0
- package/src/components/ForgotPassword/ForgotPassword.tsx +121 -0
- package/src/components/ForgotPassword/index.ts +2 -0
- package/src/components/HintError/HintError.tsx +37 -0
- package/src/components/HintError/index.ts +2 -0
- package/src/components/Icon/Icon.tsx +43 -0
- package/src/components/Icon/icon-registry.ts +227 -0
- package/src/components/Icon/index.ts +3 -0
- package/src/components/InputDropdown/InputDropdown.tsx +662 -0
- package/src/components/InputDropdown/index.ts +9 -0
- package/src/components/InputField/InputField.tsx +527 -0
- package/src/components/InputField/index.ts +2 -0
- package/src/components/Label/Label.tsx +88 -0
- package/src/components/Label/index.ts +2 -0
- package/src/components/LoginForm/LoginForm.tsx +158 -0
- package/src/components/LoginForm/index.ts +2 -0
- package/src/components/LoginShell/LoginShell.tsx +97 -0
- package/src/components/LoginShell/RoleCard.tsx +24 -0
- package/src/components/LoginShell/SoftechLogo.tsx +24 -0
- package/src/components/LoginShell/branding-assets.ts +2 -0
- package/src/components/LoginShell/index.ts +20 -0
- package/src/components/LoginShell/login-copy.ts +45 -0
- package/src/components/LoginShell/loginPageStyles.ts +210 -0
- package/src/components/Modals/Modals.tsx +313 -0
- package/src/components/Modals/index.ts +2 -0
- package/src/components/Offcanvas/Offcanvas.tsx +404 -0
- package/src/components/Offcanvas/index.ts +13 -0
- package/src/components/PageHeader/PageHeader.tsx +128 -0
- package/src/components/PageHeader/index.ts +2 -0
- package/src/components/Pagination/Pagination.tsx +540 -0
- package/src/components/Pagination/index.ts +8 -0
- package/src/components/ResetPassword/ResetPassword.tsx +172 -0
- package/src/components/ResetPassword/index.ts +2 -0
- package/src/components/RoleSelection/RoleSelection.tsx +111 -0
- package/src/components/RoleSelection/index.ts +2 -0
- package/src/components/SendOtp/SendOtp.tsx +149 -0
- package/src/components/SendOtp/index.ts +2 -0
- package/src/components/Sidenavbar/Sidenavbar.tsx +358 -0
- package/src/components/Sidenavbar/index.ts +2 -0
- package/src/components/StatCard/StatCard.tsx +393 -0
- package/src/components/StatCard/index.ts +6 -0
- package/src/components/Tabs/Tabs.tsx +239 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Textarea/Textarea.tsx +217 -0
- package/src/components/Textarea/index.ts +2 -0
- package/src/components/Timepicker/Timepicker.tsx +384 -0
- package/src/components/Timepicker/index.ts +2 -0
- package/src/components/Toast/Toast.tsx +278 -0
- package/src/components/Toast/index.ts +2 -0
- package/src/components/Toggle/Toggle.tsx +296 -0
- package/src/components/Toggle/index.ts +2 -0
- package/src/components/Typeahead/Typeahead.tsx +521 -0
- package/src/components/Typeahead/index.ts +2 -0
- package/src/components/Verification/Verification.tsx +374 -0
- package/src/components/Verification/index.ts +2 -0
- package/src/index.ts +39 -0
- package/src/theme/borders.ts +19 -0
- package/src/theme/button.ts +41 -0
- package/src/theme/colors.ts +273 -0
- package/src/theme/index.ts +14 -0
- package/src/theme/nativewind-theme.js +182 -0
- package/src/theme/radius.ts +12 -0
- package/src/theme/shadows.ts +40 -0
- package/src/theme/spacing.ts +18 -0
- package/src/theme/typography.ts +35 -0
- package/src/utils/a11y.ts +21 -0
- package/svg.d.ts +7 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export {
|
|
2
|
+
DynamicForm,
|
|
3
|
+
DynamicFormFieldType,
|
|
4
|
+
DynamicFormLayout,
|
|
5
|
+
} from './DynamicForm';
|
|
6
|
+
export type {
|
|
7
|
+
DynamicFormFieldConfig,
|
|
8
|
+
DynamicFormFieldValidation,
|
|
9
|
+
DynamicFormProps,
|
|
10
|
+
DynamicFormSelectOption,
|
|
11
|
+
DynamicFormTypeaheadConfig,
|
|
12
|
+
DynamicFormValue,
|
|
13
|
+
} from './DynamicForm';
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Pressable, StyleSheet, Text, useWindowDimensions, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { colors, spacing, typography } from '../../theme';
|
|
4
|
+
import { Button, ButtonSize, ButtonVariant, dismissButtonFocus } from '../Button';
|
|
5
|
+
import { IconName } from '../Icon';
|
|
6
|
+
import { getIconComponent } from '../Icon/icon-registry';
|
|
7
|
+
|
|
8
|
+
export const ErrorPageVariant = {
|
|
9
|
+
NotFound: 'not-found',
|
|
10
|
+
Unauthorized: 'unauthorized',
|
|
11
|
+
Forbidden: 'forbidden',
|
|
12
|
+
InternalServerError: 'internal-server-error',
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export type ErrorPageVariant = (typeof ErrorPageVariant)[keyof typeof ErrorPageVariant];
|
|
16
|
+
|
|
17
|
+
export type ErrorPagesProps = {
|
|
18
|
+
variant?: ErrorPageVariant;
|
|
19
|
+
onBackToSafety?: () => void;
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const COPY: Record<
|
|
24
|
+
ErrorPageVariant,
|
|
25
|
+
{ icon: string; alt: string; message: string; landscape: boolean }
|
|
26
|
+
> = {
|
|
27
|
+
[ErrorPageVariant.NotFound]: {
|
|
28
|
+
icon: IconName.NotFound,
|
|
29
|
+
alt: 'Error 404 illustration',
|
|
30
|
+
message: "Oops! The page you're looking for doesn't exist.",
|
|
31
|
+
landscape: true,
|
|
32
|
+
},
|
|
33
|
+
[ErrorPageVariant.Unauthorized]: {
|
|
34
|
+
icon: IconName.Unauthorized,
|
|
35
|
+
alt: 'Error 401 Unauthorized illustration',
|
|
36
|
+
message: 'UNAUTHORIZED - Authentication failed',
|
|
37
|
+
landscape: false,
|
|
38
|
+
},
|
|
39
|
+
[ErrorPageVariant.Forbidden]: {
|
|
40
|
+
icon: IconName.Forbidden,
|
|
41
|
+
alt: 'Error 403 Forbidden illustration',
|
|
42
|
+
message: 'FORBIDDEN - Access denied',
|
|
43
|
+
landscape: false,
|
|
44
|
+
},
|
|
45
|
+
[ErrorPageVariant.InternalServerError]: {
|
|
46
|
+
icon: IconName.InternalServerError,
|
|
47
|
+
alt: 'Error 500 Internal Server Error illustration',
|
|
48
|
+
message: '500 - INTERNAL SERVER ERROR',
|
|
49
|
+
landscape: false,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function ErrorPages({
|
|
54
|
+
variant = ErrorPageVariant.NotFound,
|
|
55
|
+
onBackToSafety,
|
|
56
|
+
style,
|
|
57
|
+
}: ErrorPagesProps) {
|
|
58
|
+
const { width } = useWindowDimensions();
|
|
59
|
+
const copy = COPY[variant];
|
|
60
|
+
const Illustration = getIconComponent(copy.icon);
|
|
61
|
+
const illustrationWidth = Math.min(width - spacing.xl * 2, spacing['6xl'] * 7);
|
|
62
|
+
const illustrationHeight = copy.landscape
|
|
63
|
+
? Math.round(illustrationWidth * (435 / 628))
|
|
64
|
+
: illustrationWidth;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Pressable
|
|
68
|
+
accessible={false}
|
|
69
|
+
focusable={false}
|
|
70
|
+
onPress={dismissButtonFocus}
|
|
71
|
+
style={[styles.host, style]}>
|
|
72
|
+
<View style={styles.centerStage}>
|
|
73
|
+
<View style={styles.content}>
|
|
74
|
+
<View
|
|
75
|
+
accessible
|
|
76
|
+
accessibilityRole="image"
|
|
77
|
+
accessibilityLabel={copy.alt}
|
|
78
|
+
style={[styles.illustration, { width: illustrationWidth, height: illustrationHeight }]}>
|
|
79
|
+
{Illustration ? (
|
|
80
|
+
<Illustration width={illustrationWidth} height={illustrationHeight} />
|
|
81
|
+
) : null}
|
|
82
|
+
</View>
|
|
83
|
+
<Text style={styles.message}>{copy.message}</Text>
|
|
84
|
+
<View style={styles.cta}>
|
|
85
|
+
<Button
|
|
86
|
+
variant={ButtonVariant.Primary}
|
|
87
|
+
size={ButtonSize.Medium}
|
|
88
|
+
label="Back To Safety"
|
|
89
|
+
onPress={onBackToSafety}
|
|
90
|
+
/>
|
|
91
|
+
</View>
|
|
92
|
+
</View>
|
|
93
|
+
</View>
|
|
94
|
+
</Pressable>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const styles = StyleSheet.create({
|
|
99
|
+
host: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
width: '100%',
|
|
102
|
+
minHeight: '100%',
|
|
103
|
+
backgroundColor: colors.white,
|
|
104
|
+
},
|
|
105
|
+
centerStage: {
|
|
106
|
+
flex: 1,
|
|
107
|
+
width: '100%',
|
|
108
|
+
alignItems: 'center',
|
|
109
|
+
justifyContent: 'center',
|
|
110
|
+
paddingHorizontal: spacing.xl,
|
|
111
|
+
paddingBottom: spacing['4xl'],
|
|
112
|
+
},
|
|
113
|
+
content: {
|
|
114
|
+
width: '100%',
|
|
115
|
+
maxWidth: spacing['6xl'] * 8,
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
gap: spacing.xl,
|
|
118
|
+
},
|
|
119
|
+
illustration: {
|
|
120
|
+
overflow: 'hidden',
|
|
121
|
+
},
|
|
122
|
+
message: {
|
|
123
|
+
width: '100%',
|
|
124
|
+
fontFamily: typography.fontFamily.base,
|
|
125
|
+
fontSize: typography.fontSize.lg,
|
|
126
|
+
fontWeight: typography.fontWeight.medium,
|
|
127
|
+
textAlign: 'center',
|
|
128
|
+
color: colors.text.strong,
|
|
129
|
+
},
|
|
130
|
+
cta: {
|
|
131
|
+
width: '100%',
|
|
132
|
+
flexDirection: 'row',
|
|
133
|
+
justifyContent: 'center',
|
|
134
|
+
},
|
|
135
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Text, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Button, ButtonSize, ButtonVariant, IconPosition } from '../Button';
|
|
5
|
+
import { IconName } from '../Icon';
|
|
6
|
+
import { InputField, InputState, InputVariant } from '../InputField';
|
|
7
|
+
import { LoginShell } from '../LoginShell/LoginShell';
|
|
8
|
+
import { RoleCard } from '../LoginShell/RoleCard';
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_BACK_AND_SELECT_ROLE,
|
|
11
|
+
DEFAULT_ROLE_DESCRIPTION,
|
|
12
|
+
DEFAULT_ROLE_TITLE,
|
|
13
|
+
isValidEmail,
|
|
14
|
+
} from '../LoginShell/login-copy';
|
|
15
|
+
import { loginPageStyles as styles } from '../LoginShell/loginPageStyles';
|
|
16
|
+
|
|
17
|
+
export type ForgotPasswordProps = {
|
|
18
|
+
brandingAsideAriaLabel?: string;
|
|
19
|
+
logoSrc?: string;
|
|
20
|
+
logoAlt?: string;
|
|
21
|
+
quoteText?: string;
|
|
22
|
+
quoteAttribution?: string;
|
|
23
|
+
backButtonLabel?: string;
|
|
24
|
+
roleTitle?: string;
|
|
25
|
+
roleDescription?: string;
|
|
26
|
+
pageTitle?: string;
|
|
27
|
+
emailLabel?: string;
|
|
28
|
+
emailPlaceholder?: string;
|
|
29
|
+
emailInitialValue?: string;
|
|
30
|
+
submitButtonLabel?: string;
|
|
31
|
+
onBack?: () => void;
|
|
32
|
+
onSubmit?: (email: string) => void;
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function ForgotPassword({
|
|
37
|
+
brandingAsideAriaLabel,
|
|
38
|
+
logoSrc,
|
|
39
|
+
logoAlt,
|
|
40
|
+
quoteText,
|
|
41
|
+
quoteAttribution,
|
|
42
|
+
backButtonLabel = DEFAULT_BACK_AND_SELECT_ROLE,
|
|
43
|
+
roleTitle = DEFAULT_ROLE_TITLE,
|
|
44
|
+
roleDescription = DEFAULT_ROLE_DESCRIPTION,
|
|
45
|
+
pageTitle = 'Verify your Email',
|
|
46
|
+
emailLabel = 'What is your e-mail?',
|
|
47
|
+
emailPlaceholder = 'Alex.johnson@gmail.com',
|
|
48
|
+
emailInitialValue = '',
|
|
49
|
+
submitButtonLabel = 'Reset Password',
|
|
50
|
+
onBack,
|
|
51
|
+
onSubmit,
|
|
52
|
+
style,
|
|
53
|
+
}: ForgotPasswordProps) {
|
|
54
|
+
const [email, setEmail] = useState(emailInitialValue);
|
|
55
|
+
const [submitted, setSubmitted] = useState(false);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
setEmail(emailInitialValue);
|
|
59
|
+
}, [emailInitialValue]);
|
|
60
|
+
|
|
61
|
+
const emailError = submitted && !isValidEmail(email) ? 'Enter a valid email address.' : '';
|
|
62
|
+
|
|
63
|
+
function submit() {
|
|
64
|
+
setSubmitted(true);
|
|
65
|
+
if (!isValidEmail(email)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
onSubmit?.(email.trim());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<LoginShell
|
|
73
|
+
brandingAsideAriaLabel={brandingAsideAriaLabel}
|
|
74
|
+
logoSrc={logoSrc}
|
|
75
|
+
logoAlt={logoAlt}
|
|
76
|
+
quoteText={quoteText}
|
|
77
|
+
quoteAttribution={quoteAttribution}
|
|
78
|
+
style={style}>
|
|
79
|
+
<View style={styles.form}>
|
|
80
|
+
<View style={styles.backWrap}>
|
|
81
|
+
<Button
|
|
82
|
+
variant={ButtonVariant.LinkGray}
|
|
83
|
+
size={ButtonSize.Small}
|
|
84
|
+
iconPosition={IconPosition.Before}
|
|
85
|
+
iconName={IconName.ChevronLeft}
|
|
86
|
+
iconDecorative
|
|
87
|
+
label={backButtonLabel}
|
|
88
|
+
onPress={onBack}
|
|
89
|
+
/>
|
|
90
|
+
</View>
|
|
91
|
+
<RoleCard title={roleTitle} description={roleDescription} />
|
|
92
|
+
<Text accessibilityRole="header" style={[styles.pageTitle, styles.pageTitleVerify]}>
|
|
93
|
+
{pageTitle}
|
|
94
|
+
</Text>
|
|
95
|
+
<View style={styles.fields}>
|
|
96
|
+
<InputField
|
|
97
|
+
fullWidth
|
|
98
|
+
variant={InputVariant.Email}
|
|
99
|
+
label={emailLabel}
|
|
100
|
+
placeholder={emailPlaceholder}
|
|
101
|
+
value={email}
|
|
102
|
+
error={emailError}
|
|
103
|
+
state={emailError ? InputState.Error : InputState.Default}
|
|
104
|
+
onValueChange={setEmail}
|
|
105
|
+
autoComplete="email"
|
|
106
|
+
inputType="email"
|
|
107
|
+
/>
|
|
108
|
+
<View style={styles.submit}>
|
|
109
|
+
<Button
|
|
110
|
+
fullWidth
|
|
111
|
+
variant={ButtonVariant.Secondary}
|
|
112
|
+
size={ButtonSize.Large}
|
|
113
|
+
label={submitButtonLabel}
|
|
114
|
+
onPress={submit}
|
|
115
|
+
/>
|
|
116
|
+
</View>
|
|
117
|
+
</View>
|
|
118
|
+
</View>
|
|
119
|
+
</LoginShell>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StyleSheet, Text } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { colors, typography } from '../../theme';
|
|
4
|
+
|
|
5
|
+
export type HintErrorProps = {
|
|
6
|
+
hint?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function HintError({ hint, error }: HintErrorProps) {
|
|
11
|
+
if (error) {
|
|
12
|
+
return <Text style={styles.error}>{error}</Text>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (hint) {
|
|
16
|
+
return <Text style={styles.hint}>{hint}</Text>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const styles = StyleSheet.create({
|
|
23
|
+
hint: {
|
|
24
|
+
color: colors.input.label,
|
|
25
|
+
fontSize: typography.fontSize.sm,
|
|
26
|
+
lineHeight: typography.fontSize.sm * typography.lineHeight.tight,
|
|
27
|
+
marginTop: 6,
|
|
28
|
+
fontFamily: typography.fontFamily.base,
|
|
29
|
+
},
|
|
30
|
+
error: {
|
|
31
|
+
color: colors.danger.strong,
|
|
32
|
+
fontSize: typography.fontSize.sm,
|
|
33
|
+
lineHeight: typography.fontSize.sm * typography.lineHeight.tight,
|
|
34
|
+
marginTop: 6,
|
|
35
|
+
fontFamily: typography.fontFamily.base,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Platform, View } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { a11yHiddenProps } from '../../utils/a11y';
|
|
4
|
+
import { getIconComponent, isIconName } from './icon-registry';
|
|
5
|
+
|
|
6
|
+
export type IconProps = {
|
|
7
|
+
name: string;
|
|
8
|
+
size?: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
decorative?: boolean;
|
|
11
|
+
accessibilityLabel?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function Icon({
|
|
15
|
+
name,
|
|
16
|
+
size = 16,
|
|
17
|
+
color,
|
|
18
|
+
decorative = false,
|
|
19
|
+
accessibilityLabel,
|
|
20
|
+
}: IconProps) {
|
|
21
|
+
if (!isIconName(name)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const SvgIcon = getIconComponent(name);
|
|
26
|
+
if (!SvgIcon) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View
|
|
32
|
+
accessible={!decorative}
|
|
33
|
+
accessibilityRole={decorative ? undefined : 'image'}
|
|
34
|
+
accessibilityLabel={decorative ? undefined : accessibilityLabel ?? name}
|
|
35
|
+
{...(decorative
|
|
36
|
+
? a11yHiddenProps(true)
|
|
37
|
+
: Platform.OS === 'web'
|
|
38
|
+
? {}
|
|
39
|
+
: { importantForAccessibility: 'yes' as const })}>
|
|
40
|
+
<SvgIcon width={size} height={size} color={color} />
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { SvgProps } from 'react-native-svg';
|
|
3
|
+
|
|
4
|
+
import Alert from '../../assets/icons/alert.svg';
|
|
5
|
+
import Calendar from '../../assets/icons/calendar.svg';
|
|
6
|
+
import ArrowRight from '../../assets/icons/arrow-right.svg';
|
|
7
|
+
import LeftArrow from '../../assets/icons/left-arrow.svg';
|
|
8
|
+
import RightArrow from '../../assets/icons/right-arrow.svg';
|
|
9
|
+
import Card from '../../assets/icons/card.svg';
|
|
10
|
+
import Chat from '../../assets/icons/chat.svg';
|
|
11
|
+
import CalendarEvent from '../../assets/icons/calendar-event.svg';
|
|
12
|
+
import ErrorIcon from '../../assets/icons/error.svg';
|
|
13
|
+
import DropdownArrow from '../../assets/icons/dropdown-arrow.svg';
|
|
14
|
+
import DropdownAvatar from '../../assets/icons/dropdown-avatar.svg';
|
|
15
|
+
import AvatarMale from '../../assets/icons/avatar-male.svg';
|
|
16
|
+
import AvatarFemale from '../../assets/icons/avatar-female.svg';
|
|
17
|
+
import Email from '../../assets/icons/email.svg';
|
|
18
|
+
import Eye from '../../assets/icons/eye.svg';
|
|
19
|
+
import Info from '../../assets/icons/info.svg';
|
|
20
|
+
import EyeOff from '../../assets/icons/eye-off.svg';
|
|
21
|
+
import Help from '../../assets/icons/help.svg';
|
|
22
|
+
import VerticalLine from '../../assets/icons/vertical-line.svg';
|
|
23
|
+
import User from '../../assets/icons/user.svg';
|
|
24
|
+
import UserFrame from '../../assets/icons/User-Frame.svg';
|
|
25
|
+
import Dot from '../../assets/icons/dot.svg';
|
|
26
|
+
import Search from '../../assets/icons/search.svg';
|
|
27
|
+
import ChevronDown from '../../assets/icons/chevron-down.svg';
|
|
28
|
+
import ChevronLeft from '../../assets/icons/chevron-left.svg';
|
|
29
|
+
import ChevronRight from '../../assets/icons/chevron-right.svg';
|
|
30
|
+
import CaretRight from '../../assets/icons/caret-right.svg';
|
|
31
|
+
import Slash from '../../assets/icons/slash.svg';
|
|
32
|
+
import CircleRadio from '../../assets/icons/circle-radio.svg';
|
|
33
|
+
import CircleRadioActive from '../../assets/icons/circle-radio-active.svg';
|
|
34
|
+
import Check from '../../assets/icons/check.svg';
|
|
35
|
+
import Checkmark from '../../assets/icons/checkmark.svg';
|
|
36
|
+
import CheckboxMinus from '../../assets/icons/checkbox-minus.svg';
|
|
37
|
+
import RadioDot from '../../assets/icons/radio-dot.svg';
|
|
38
|
+
import Layers from '../../assets/icons/2-layers.svg';
|
|
39
|
+
import Code from '../../assets/icons/code.svg';
|
|
40
|
+
import Country from '../../assets/icons/country.svg';
|
|
41
|
+
import Close from '../../assets/icons/close.svg';
|
|
42
|
+
import HelpCircle from '../../assets/icons/help-circle.svg';
|
|
43
|
+
import HashtagIcon from '../../assets/icons/hashtag-icon.svg';
|
|
44
|
+
import Home from '../../assets/icons/home.svg';
|
|
45
|
+
import HomeSmile from '../../assets/icons/home-smile.svg';
|
|
46
|
+
import LogOut from '../../assets/icons/log-out.svg';
|
|
47
|
+
import LogOutNav from '../../assets/icons/Log-out-nav.svg';
|
|
48
|
+
import Pencil from '../../assets/icons/pencil.svg';
|
|
49
|
+
import Plus from '../../assets/icons/plus.svg';
|
|
50
|
+
import Settings from '../../assets/icons/settings.svg';
|
|
51
|
+
import Slack from '../../assets/icons/slack.svg';
|
|
52
|
+
import Success from '../../assets/icons/success.svg';
|
|
53
|
+
import Trash from '../../assets/icons/trash.svg';
|
|
54
|
+
import Download from '../../assets/icons/download.svg';
|
|
55
|
+
import UserPlus from '../../assets/icons/user-plus.svg';
|
|
56
|
+
import Users from '../../assets/icons/users.svg';
|
|
57
|
+
import Warning from '../../assets/icons/warning.svg';
|
|
58
|
+
import Zap from '../../assets/icons/zap.svg';
|
|
59
|
+
import VerticalThreeDots from '../../assets/icons/vertical-three-dots-icon.svg';
|
|
60
|
+
import VerticalDotsActive from '../../assets/icons/vertical-dots-true-icon.svg';
|
|
61
|
+
import NotFound from '../../assets/icons/Not-Found.svg';
|
|
62
|
+
import Unauthorized from '../../assets/icons/Unauthorized.svg';
|
|
63
|
+
import Forbidden from '../../assets/icons/Forbidden.svg';
|
|
64
|
+
import InternalServerError from '../../assets/icons/Internal-server-error.svg';
|
|
65
|
+
import Bell from '../../assets/icons/bell.svg';
|
|
66
|
+
import NotificationBox from '../../assets/icons/notification-box.svg';
|
|
67
|
+
import Clock from '../../assets/icons/clock.svg';
|
|
68
|
+
import TrendUp from '../../assets/icons/trend-up-01.svg';
|
|
69
|
+
import TrendDown from '../../assets/icons/trend-down-01.svg';
|
|
70
|
+
|
|
71
|
+
export enum IconName {
|
|
72
|
+
Alert = 'alert',
|
|
73
|
+
Calendar = 'calendar',
|
|
74
|
+
ArrowRight = 'arrow-right',
|
|
75
|
+
LeftArrow = 'left-arrow',
|
|
76
|
+
RightArrow = 'right-arrow',
|
|
77
|
+
Card = 'card',
|
|
78
|
+
Chat = 'chat',
|
|
79
|
+
CalendarEvent = 'calendar-event',
|
|
80
|
+
Error = 'error',
|
|
81
|
+
DropdownArrow = 'dropdown-arrow',
|
|
82
|
+
DropdownAvatar = 'dropdown-avatar',
|
|
83
|
+
AvatarMale = 'avatar-male',
|
|
84
|
+
AvatarFemale = 'avatar-female',
|
|
85
|
+
Email = 'email',
|
|
86
|
+
Eye = 'eye',
|
|
87
|
+
Info = 'info',
|
|
88
|
+
EyeOff = 'eye-off',
|
|
89
|
+
Help = 'help',
|
|
90
|
+
VerticalLine = 'vertical-line',
|
|
91
|
+
User = 'user',
|
|
92
|
+
UserFrame = 'User-Frame',
|
|
93
|
+
Dot = 'dot',
|
|
94
|
+
Search = 'search',
|
|
95
|
+
ChevronDown = 'chevron-down',
|
|
96
|
+
ChevronLeft = 'chevron-left',
|
|
97
|
+
ChevronRight = 'chevron-right',
|
|
98
|
+
CaretRight = 'caret-right',
|
|
99
|
+
Slash = 'slash',
|
|
100
|
+
CircleRadio = 'circle-radio',
|
|
101
|
+
CircleRadioActive = 'circle-radio-active',
|
|
102
|
+
Check = 'check',
|
|
103
|
+
Checkmark = 'checkmark',
|
|
104
|
+
CheckboxMinus = 'checkbox-minus',
|
|
105
|
+
RadioDot = 'radio-dot',
|
|
106
|
+
Layers = '2-layers',
|
|
107
|
+
Code = 'code',
|
|
108
|
+
Country = 'country',
|
|
109
|
+
Close = 'close',
|
|
110
|
+
HelpCircle = 'help-circle',
|
|
111
|
+
HashtagIcon = 'hashtag-icon',
|
|
112
|
+
Home = 'home',
|
|
113
|
+
HomeSmile = 'home-smile',
|
|
114
|
+
LogOut = 'log-out',
|
|
115
|
+
LogOutNav = 'Log-out-nav',
|
|
116
|
+
Pencil = 'pencil',
|
|
117
|
+
Plus = 'plus',
|
|
118
|
+
Settings = 'settings',
|
|
119
|
+
Slack = 'slack',
|
|
120
|
+
Success = 'success',
|
|
121
|
+
Trash = 'trash',
|
|
122
|
+
Download = 'download',
|
|
123
|
+
UserPlus = 'user-plus',
|
|
124
|
+
Users = 'users',
|
|
125
|
+
Warning = 'warning',
|
|
126
|
+
Zap = 'zap',
|
|
127
|
+
VerticalThreeDots = 'vertical-three-dots-icon',
|
|
128
|
+
VerticalDotsActive = 'vertical-dots-true-icon',
|
|
129
|
+
NotFound = 'Not-Found',
|
|
130
|
+
Unauthorized = 'Unauthorized',
|
|
131
|
+
Forbidden = 'Forbidden',
|
|
132
|
+
InternalServerError = 'Internal-server-error',
|
|
133
|
+
Bell = 'bell',
|
|
134
|
+
NotificationBox = 'notification-box',
|
|
135
|
+
Clock = 'clock',
|
|
136
|
+
TrendUp = 'trend-up-01',
|
|
137
|
+
TrendDown = 'trend-down-01',
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const ICON_NAMES = Object.values(IconName);
|
|
141
|
+
|
|
142
|
+
export function isIconName(name: string): name is IconName {
|
|
143
|
+
return (ICON_NAMES as string[]).includes(name);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Same contract as Angular `getIconPath`: name → `assets/icons/{name}.svg`. */
|
|
147
|
+
export function getIconPath(name: string): string {
|
|
148
|
+
return isIconName(name) ? `assets/icons/${name}.svg` : '';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type IconSvg = ComponentType<SvgProps>;
|
|
152
|
+
|
|
153
|
+
const ICON_MODULES: Record<IconName, IconSvg> = {
|
|
154
|
+
[IconName.Alert]: Alert,
|
|
155
|
+
[IconName.Calendar]: Calendar,
|
|
156
|
+
[IconName.ArrowRight]: ArrowRight,
|
|
157
|
+
[IconName.LeftArrow]: LeftArrow,
|
|
158
|
+
[IconName.RightArrow]: RightArrow,
|
|
159
|
+
[IconName.Card]: Card,
|
|
160
|
+
[IconName.Chat]: Chat,
|
|
161
|
+
[IconName.CalendarEvent]: CalendarEvent,
|
|
162
|
+
[IconName.Error]: ErrorIcon,
|
|
163
|
+
[IconName.DropdownArrow]: DropdownArrow,
|
|
164
|
+
[IconName.DropdownAvatar]: DropdownAvatar,
|
|
165
|
+
[IconName.AvatarMale]: AvatarMale,
|
|
166
|
+
[IconName.AvatarFemale]: AvatarFemale,
|
|
167
|
+
[IconName.Email]: Email,
|
|
168
|
+
[IconName.Eye]: Eye,
|
|
169
|
+
[IconName.Info]: Info,
|
|
170
|
+
[IconName.EyeOff]: EyeOff,
|
|
171
|
+
[IconName.Help]: Help,
|
|
172
|
+
[IconName.VerticalLine]: VerticalLine,
|
|
173
|
+
[IconName.User]: User,
|
|
174
|
+
[IconName.UserFrame]: UserFrame,
|
|
175
|
+
[IconName.Dot]: Dot,
|
|
176
|
+
[IconName.Search]: Search,
|
|
177
|
+
[IconName.ChevronDown]: ChevronDown,
|
|
178
|
+
[IconName.ChevronLeft]: ChevronLeft,
|
|
179
|
+
[IconName.ChevronRight]: ChevronRight,
|
|
180
|
+
[IconName.CaretRight]: CaretRight,
|
|
181
|
+
[IconName.Slash]: Slash,
|
|
182
|
+
[IconName.CircleRadio]: CircleRadio,
|
|
183
|
+
[IconName.CircleRadioActive]: CircleRadioActive,
|
|
184
|
+
[IconName.Check]: Check,
|
|
185
|
+
[IconName.Checkmark]: Checkmark,
|
|
186
|
+
[IconName.CheckboxMinus]: CheckboxMinus,
|
|
187
|
+
[IconName.RadioDot]: RadioDot,
|
|
188
|
+
[IconName.Layers]: Layers,
|
|
189
|
+
[IconName.Code]: Code,
|
|
190
|
+
[IconName.Country]: Country,
|
|
191
|
+
[IconName.Close]: Close,
|
|
192
|
+
[IconName.HelpCircle]: HelpCircle,
|
|
193
|
+
[IconName.HashtagIcon]: HashtagIcon,
|
|
194
|
+
[IconName.Home]: Home,
|
|
195
|
+
[IconName.HomeSmile]: HomeSmile,
|
|
196
|
+
[IconName.LogOut]: LogOut,
|
|
197
|
+
[IconName.LogOutNav]: LogOutNav,
|
|
198
|
+
[IconName.Pencil]: Pencil,
|
|
199
|
+
[IconName.Plus]: Plus,
|
|
200
|
+
[IconName.Settings]: Settings,
|
|
201
|
+
[IconName.Slack]: Slack,
|
|
202
|
+
[IconName.Success]: Success,
|
|
203
|
+
[IconName.Trash]: Trash,
|
|
204
|
+
[IconName.Download]: Download,
|
|
205
|
+
[IconName.UserPlus]: UserPlus,
|
|
206
|
+
[IconName.Users]: Users,
|
|
207
|
+
[IconName.Warning]: Warning,
|
|
208
|
+
[IconName.Zap]: Zap,
|
|
209
|
+
[IconName.VerticalThreeDots]: VerticalThreeDots,
|
|
210
|
+
[IconName.VerticalDotsActive]: VerticalDotsActive,
|
|
211
|
+
[IconName.NotFound]: NotFound,
|
|
212
|
+
[IconName.Unauthorized]: Unauthorized,
|
|
213
|
+
[IconName.Forbidden]: Forbidden,
|
|
214
|
+
[IconName.InternalServerError]: InternalServerError,
|
|
215
|
+
[IconName.Bell]: Bell,
|
|
216
|
+
[IconName.NotificationBox]: NotificationBox,
|
|
217
|
+
[IconName.Clock]: Clock,
|
|
218
|
+
[IconName.TrendUp]: TrendUp,
|
|
219
|
+
[IconName.TrendDown]: TrendDown,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export function getIconComponent(name: string): IconSvg | undefined {
|
|
223
|
+
if (!isIconName(name)) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
return ICON_MODULES[name];
|
|
227
|
+
}
|