@ornikar/kitt-universal 1.0.0 → 1.0.1
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/package.json +4 -4
- package/CHANGELOG.md +0 -8
- package/src/.eslintrc.json +0 -19
- package/src/Avatar/Avatar.stories.tsx +0 -45
- package/src/Avatar/Avatar.tsx +0 -60
- package/src/Avatar/__snapshots__/Avatar.stories.tsx.snap +0 -1229
- package/src/Button/Button.stories.tsx +0 -301
- package/src/Button/Button.tsx +0 -60
- package/src/Button/ButtonContainer.tsx +0 -32
- package/src/Button/ButtonContent.tsx +0 -133
- package/src/Button/__snapshots__/Button.stories.tsx.snap +0 -7483
- package/src/Button/useButton.ts +0 -14
- package/src/Card/Card.stories.tsx +0 -31
- package/src/Card/Card.tsx +0 -25
- package/src/Card/__snapshots__/Card.stories.tsx.snap +0 -306
- package/src/FullScreenModal/Body.tsx +0 -25
- package/src/FullScreenModal/FullScreenModal.stories.tsx +0 -63
- package/src/FullScreenModal/FullScreenModal.tsx +0 -21
- package/src/FullScreenModal/Header.tsx +0 -129
- package/src/FullScreenModal/__snapshots__/FullScreenModal.stories.tsx.snap +0 -771
- package/src/Icon/Icon.stories.tsx +0 -59
- package/src/Icon/Icon.tsx +0 -37
- package/src/Icon/SpinningIcon.tsx +0 -38
- package/src/Icon/SpinningIcon.web.module.css +0 -13
- package/src/Icon/SpinningIcon.web.module.css.d.ts +0 -6
- package/src/Icon/SpinningIcon.web.tsx +0 -11
- package/src/Icon/__snapshots__/Icon.stories.tsx.snap +0 -5648
- package/src/KittBreakpoints.ts +0 -44
- package/src/ListItem/ListItem.stories.tsx +0 -122
- package/src/ListItem/ListItem.tsx +0 -61
- package/src/ListItem/ListItemContent.tsx +0 -17
- package/src/ListItem/ListItemSideContent.tsx +0 -41
- package/src/ListItem/__snapshots__/ListItem.stories.tsx.snap +0 -1514
- package/src/Loader/LargeLoader.tsx +0 -12
- package/src/Loader/LargeLoader.web.module.css +0 -103
- package/src/Loader/LargeLoader.web.module.css.d.ts +0 -11
- package/src/Loader/LargeLoader.web.test.tsx +0 -10
- package/src/Loader/LargeLoader.web.tsx +0 -18
- package/src/Loader/Loader.stories.tsx +0 -47
- package/src/Loader/Loader.tsx +0 -21
- package/src/Loader/Loader.web.test.tsx +0 -20
- package/src/Loader/Loader.web.tsx +0 -14
- package/src/Loader/__snapshots__/LargeLoader.web.test.tsx.snap +0 -33
- package/src/Loader/__snapshots__/Loader.stories.tsx.snap +0 -607
- package/src/Loader/__snapshots__/Loader.web.test.tsx.snap +0 -103
- package/src/Message/Message.stories.tsx +0 -102
- package/src/Message/Message.tsx +0 -114
- package/src/Message/__snapshots__/Message.stories.tsx.snap +0 -2776
- package/src/Modal/Body.tsx +0 -20
- package/src/Modal/Footer.tsx +0 -18
- package/src/Modal/Header.tsx +0 -66
- package/src/Modal/Modal.stories.tsx +0 -181
- package/src/Modal/Modal.tsx +0 -66
- package/src/Modal/OnCloseContext.ts +0 -3
- package/src/Modal/__snapshots__/Modal.stories.tsx.snap +0 -2960
- package/src/Notification/Notification.stories.tsx +0 -102
- package/src/Notification/Notification.tsx +0 -21
- package/src/Notification/__snapshots__/Notification.stories.tsx.snap +0 -2861
- package/src/Overlay/Overlay.tsx +0 -22
- package/src/Tag/Tag.stories.tsx +0 -18
- package/src/Tag/Tag.tsx +0 -31
- package/src/Tag/__snapshots__/Tag.stories.tsx.snap +0 -303
- package/src/Tooltip/Tooltip.tsx +0 -17
- package/src/__mocks__/react-native-safe-area-context.tsx +0 -26
- package/src/forms/InputFeedback/InputFeedback.stories.tsx +0 -17
- package/src/forms/InputFeedback/InputFeedback.tsx +0 -28
- package/src/forms/InputFeedback/__snapshots__/InputFeedback.stories.tsx.snap +0 -252
- package/src/forms/InputField/InputField.stories.tsx +0 -19
- package/src/forms/InputField/InputField.tsx +0 -45
- package/src/forms/InputField/__snapshots__/InputField.stories.tsx.snap +0 -240
- package/src/forms/InputFormState.ts +0 -1
- package/src/forms/InputText/InputText.stories.tsx +0 -85
- package/src/forms/InputText/InputText.tsx +0 -172
- package/src/forms/InputText/__snapshots__/InputText.stories.tsx.snap +0 -4274
- package/src/forms/InputText/useInputText.ts +0 -19
- package/src/forms/Label/Label.stories.tsx +0 -14
- package/src/forms/Label/Label.tsx +0 -17
- package/src/forms/Label/__snapshots__/Label.stories.tsx.snap +0 -174
- package/src/forms/Radio/Radio.stories.tsx +0 -48
- package/src/forms/Radio/Radio.tsx +0 -81
- package/src/forms/Radio/__snapshots__/Radio.stories.tsx.snap +0 -967
- package/src/forms/TextArea/TextArea.stories.tsx +0 -72
- package/src/forms/TextArea/TextArea.tsx +0 -12
- package/src/forms/TextArea/__snapshots__/TextArea.stories.tsx.snap +0 -2091
- package/src/index.ts +0 -61
- package/src/stories/Block.tsx +0 -24
- package/src/stories/Flex.tsx +0 -16
- package/src/stories/color-tokens.stories.tsx +0 -143
- package/src/stories-list.ts +0 -22
- package/src/story-components/Section.tsx +0 -56
- package/src/story-components/Story.tsx +0 -24
- package/src/story-components/StoryDecorator.tsx +0 -8
- package/src/story-components/StoryGrid.tsx +0 -80
- package/src/story-components/StoryTitle.stories.tsx +0 -12
- package/src/story-components/StoryTitle.tsx +0 -69
- package/src/story-components/__snapshots__/StoryTitle.stories.tsx.snap +0 -155
- package/src/story-components/index.ts +0 -5
- package/src/themes/default.ts +0 -34
- package/src/themes/late-ocean/avatarLateOceanTheme.ts +0 -12
- package/src/themes/late-ocean/buttonLateOceanTheme.ts +0 -37
- package/src/themes/late-ocean/cardLateOceanTheme.ts +0 -19
- package/src/themes/late-ocean/colorsLateOceanTheme.ts +0 -19
- package/src/themes/late-ocean/feedbackMessageLateOceanTheme.ts +0 -10
- package/src/themes/late-ocean/formLateOceanTheme.ts +0 -9
- package/src/themes/late-ocean/fullScreenModalLateOceanTheme.ts +0 -9
- package/src/themes/late-ocean/inputFieldLateOceanTheme.ts +0 -4
- package/src/themes/late-ocean/inputLateOceanTheme.ts +0 -55
- package/src/themes/late-ocean/listItemLateOceanTheme.ts +0 -8
- package/src/themes/late-ocean/radioLateOceanTheme.ts +0 -19
- package/src/themes/late-ocean/shadowsLateOceanTheme.ts +0 -3
- package/src/themes/late-ocean/tagLateOceanTheme.ts +0 -17
- package/src/themes/late-ocean/typographyLateOceanTheme.ts +0 -94
- package/src/themes/palettes/lateOceanColorPalette.ts +0 -24
- package/src/typings/babel-config.d.ts +0 -6
- package/src/typings/metro.d.ts +0 -6
- package/src/typography/Typography.stories.tsx +0 -113
- package/src/typography/Typography.tsx +0 -165
- package/src/typography/TypographyIcon.stories.tsx +0 -31
- package/src/typography/TypographyIcon.tsx +0 -35
- package/src/typography/TypographyLink.stories.tsx +0 -88
- package/src/typography/TypographyLink.tsx +0 -48
- package/src/typography/__snapshots__/Typography.stories.tsx.snap +0 -6118
- package/src/typography/__snapshots__/TypographyIcon.stories.tsx.snap +0 -334
- package/src/typography/__snapshots__/TypographyLink.stories.tsx.snap +0 -10945
- package/src/useKittTheme.tsx +0 -12
- package/src/utils/storybook/decorators/KittThemeDecorator.tsx +0 -27
- package/src/utils/storybook/decorators/SafeAreaProviderDecorator.tsx +0 -11
- package/src/utils/storybook/setup-global-decorators.ts +0 -6
- package/src/utils/tests/renderWithProvidersUtils.tsx +0 -17
- package/src/utils/typeUtils.ts +0 -6
- package/src/utils/windowSize/MatchWindowSize.tsx +0 -14
- package/src/utils/windowSize/__snapshots__/windowSize.stories.tsx.snap +0 -1485
- package/src/utils/windowSize/createWindowSizeHelper.test.ts +0 -11
- package/src/utils/windowSize/createWindowSizeHelper.ts +0 -65
- package/src/utils/windowSize/useMatchWindowSize.ts +0 -14
- package/src/utils/windowSize/useWindowSize.ts +0 -1
- package/src/utils/windowSize/windowSize.stories.tsx +0 -115
- package/tsconfig.build.json +0 -33
- package/tsconfig.json +0 -13
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { EyeIcon, EyeOffIcon } from '@ornikar/kitt-icons';
|
|
2
|
-
import type { ReactElement } from 'react';
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
4
|
-
import type { KeyboardTypeOptions, TextInput as RNTextInput, TextInputProps as RNTextInputProps } from 'react-native';
|
|
5
|
-
import { Platform } from 'react-native';
|
|
6
|
-
import styled, { css, useTheme } from 'styled-components/native';
|
|
7
|
-
import { TypographyIcon } from '../../typography/TypographyIcon';
|
|
8
|
-
import type { InputFormState } from '../InputFormState';
|
|
9
|
-
import { useInputText } from './useInputText';
|
|
10
|
-
|
|
11
|
-
type InputTextType = 'text' | 'email' | 'password' | 'username';
|
|
12
|
-
export type InputTextState = 'default' | 'invalid' | 'disabled' | 'hover' | 'focus';
|
|
13
|
-
|
|
14
|
-
export interface InputTextProps extends Exclude<RNTextInputProps, 'nativeID'> {
|
|
15
|
-
id?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
type: InputTextType;
|
|
19
|
-
minHeight?: number;
|
|
20
|
-
state?: InputFormState;
|
|
21
|
-
/** @internal */
|
|
22
|
-
internalForceState?: InputTextState;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface TextInputMixinProps {
|
|
26
|
-
state: InputTextState;
|
|
27
|
-
}
|
|
28
|
-
interface InputProps extends TextInputMixinProps {
|
|
29
|
-
minHeight: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const styledTextInputMixin = css<TextInputMixinProps>`
|
|
33
|
-
/* stylelint-disable declaration-property-value-allowed-list */
|
|
34
|
-
background-color: ${({ theme, state }) =>
|
|
35
|
-
state === 'disabled'
|
|
36
|
-
? theme.kitt.forms.input.states.disabled.backgroundColor
|
|
37
|
-
: theme.kitt.forms.input.states.default.backgroundColor};
|
|
38
|
-
border-width: ${({ theme }) => theme.kitt.forms.input.borderWidth};
|
|
39
|
-
border-radius: ${({ theme }) => theme.kitt.forms.input.borderRadius};
|
|
40
|
-
border-color: ${({ theme, state }) => theme.kitt.forms.input.states[state].borderColor};
|
|
41
|
-
font-size: ${({ theme }) => theme.kitt.typography.types.bodies.configs.body.baseAndSmall.fontSize};
|
|
42
|
-
color: ${({ theme, state }) => theme.kitt.typography.colors[theme.kitt.forms.input.states[state].color]};
|
|
43
|
-
font-family: ${({ theme }) => theme.kitt.typography.types.bodies.fontFamily.regular};
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
const Input = styled.TextInput<InputProps>`
|
|
47
|
-
/* stylelint-disable declaration-bang-space-before */
|
|
48
|
-
/* stylelint-disable comment-word-disallowed-list */
|
|
49
|
-
|
|
50
|
-
/* FIXME: text input is not vertically centered on iOS because of bigger line-height */
|
|
51
|
-
${styledTextInputMixin}
|
|
52
|
-
padding: ${({ theme, multiline }) =>
|
|
53
|
-
!multiline && Platform.OS === 'ios' ? theme.kitt.forms.input.paddingSingleLineIOS : theme.kitt.forms.input.padding};
|
|
54
|
-
line-height: ${({ theme, multiline }) =>
|
|
55
|
-
!multiline && Platform.OS === 'ios' ? 0 : theme.kitt.typography.types.bodies.configs.body.baseAndSmall.lineHeight};
|
|
56
|
-
min-height: ${({ minHeight }) => minHeight}px;
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
const Container = styled.View`
|
|
60
|
-
margin-top: ${({ theme }) => theme.kitt.forms.input.marginTop};
|
|
61
|
-
margin-bottom: ${({ theme }) => theme.kitt.forms.input.marginBottom};
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
const PasswordButtonContainer = styled.Pressable`
|
|
65
|
-
position: absolute;
|
|
66
|
-
right: 0;
|
|
67
|
-
top: 0;
|
|
68
|
-
bottom: 0;
|
|
69
|
-
justify-content: center;
|
|
70
|
-
padding: ${({ theme }) => theme.kitt.forms.input.passwordButtonIconSize / 2}px;
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
const getInputState = ({
|
|
74
|
-
isDisabled,
|
|
75
|
-
isFocused,
|
|
76
|
-
formState,
|
|
77
|
-
}: {
|
|
78
|
-
isFocused: boolean;
|
|
79
|
-
formState: InputFormState;
|
|
80
|
-
isDisabled: boolean;
|
|
81
|
-
}): InputTextState => {
|
|
82
|
-
if (isDisabled) return 'disabled';
|
|
83
|
-
if (isFocused) return 'focus';
|
|
84
|
-
if (formState === 'invalid') return 'invalid';
|
|
85
|
-
return 'default';
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const keyboardTypeByTextInputType: Record<InputTextType, KeyboardTypeOptions> = {
|
|
89
|
-
text: 'default',
|
|
90
|
-
email: 'email-address',
|
|
91
|
-
password: 'default',
|
|
92
|
-
username: 'default',
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const autoCompleteTypeByType: Record<InputTextType, 'off' | 'email' | 'password' | 'name'> = {
|
|
96
|
-
text: 'off',
|
|
97
|
-
email: 'email',
|
|
98
|
-
password: 'password',
|
|
99
|
-
username: 'name',
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const autoCorrectByType: Record<InputTextType, boolean> = {
|
|
103
|
-
text: true,
|
|
104
|
-
email: false,
|
|
105
|
-
password: false,
|
|
106
|
-
username: false,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const textContentTypeByType: Record<InputTextType, 'none' | 'emailAddress' | 'password' | 'username'> = {
|
|
110
|
-
text: 'none',
|
|
111
|
-
email: 'emailAddress',
|
|
112
|
-
password: 'password',
|
|
113
|
-
username: 'username',
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const InputText = forwardRef<RNTextInput, InputTextProps>(
|
|
117
|
-
(
|
|
118
|
-
{
|
|
119
|
-
id,
|
|
120
|
-
minHeight = 0,
|
|
121
|
-
type,
|
|
122
|
-
state: formState,
|
|
123
|
-
internalForceState,
|
|
124
|
-
disabled = false,
|
|
125
|
-
onFocus,
|
|
126
|
-
onBlur,
|
|
127
|
-
...props
|
|
128
|
-
}: InputTextProps,
|
|
129
|
-
ref,
|
|
130
|
-
): ReactElement => {
|
|
131
|
-
const { isFocused, handleInputBlur, handleInputFocus, isPasswordVisible, togglePasswordVisibility } =
|
|
132
|
-
useInputText();
|
|
133
|
-
const theme = useTheme();
|
|
134
|
-
const state = internalForceState || getInputState({ isFocused, isDisabled: disabled, formState });
|
|
135
|
-
return (
|
|
136
|
-
<Container>
|
|
137
|
-
<Input
|
|
138
|
-
ref={ref}
|
|
139
|
-
nativeID={id}
|
|
140
|
-
editable={!disabled}
|
|
141
|
-
keyboardType={keyboardTypeByTextInputType[type]}
|
|
142
|
-
autoCompleteType={autoCompleteTypeByType[type]}
|
|
143
|
-
autoCorrect={autoCorrectByType[type]}
|
|
144
|
-
minHeight={minHeight}
|
|
145
|
-
textContentType={textContentTypeByType[type]}
|
|
146
|
-
placeholderTextColor={theme.kitt.typography.colors[theme.kitt.forms.input.placeholderColor]}
|
|
147
|
-
selectionColor={theme.kitt.forms.input.selectionColor}
|
|
148
|
-
secureTextEntry={type === 'password' && !isPasswordVisible}
|
|
149
|
-
{...props}
|
|
150
|
-
state={state}
|
|
151
|
-
onFocus={(e) => {
|
|
152
|
-
handleInputFocus();
|
|
153
|
-
if (onFocus) onFocus(e);
|
|
154
|
-
}}
|
|
155
|
-
onBlur={(e) => {
|
|
156
|
-
handleInputBlur();
|
|
157
|
-
if (onBlur) onBlur(e);
|
|
158
|
-
}}
|
|
159
|
-
/>
|
|
160
|
-
{type === 'password' && !disabled && (
|
|
161
|
-
<PasswordButtonContainer onPress={togglePasswordVisibility}>
|
|
162
|
-
<TypographyIcon
|
|
163
|
-
icon={isPasswordVisible ? <EyeIcon /> : <EyeOffIcon />}
|
|
164
|
-
size={theme.kitt.forms.input.passwordButtonIconSize}
|
|
165
|
-
color={theme.kitt.forms.input.states[state].passwordButtonIconColor}
|
|
166
|
-
/>
|
|
167
|
-
</PasswordButtonContainer>
|
|
168
|
-
)}
|
|
169
|
-
</Container>
|
|
170
|
-
);
|
|
171
|
-
},
|
|
172
|
-
);
|