jp-composter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +997 -0
- package/dist/index.d.ts +997 -0
- package/dist/index.js +36837 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +36778 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
- package/src/SliceUI/IconMoon.tsx +33 -0
- package/src/SliceUI/assets/Anatomy diagram copy.svg +19 -0
- package/src/SliceUI/assets/Anatomy diagram.svg +19 -0
- package/src/SliceUI/assets/Anatomycheck.svg +15 -0
- package/src/SliceUI/assets/Anatomyinput.svg +32 -0
- package/src/SliceUI/assets/Checkbox.jpg +0 -0
- package/src/SliceUI/assets/Diagram copy.svg +15 -0
- package/src/SliceUI/assets/Diagram.jpg +0 -0
- package/src/SliceUI/assets/Diagram.svg +15 -0
- package/src/SliceUI/assets/Frame 5 copy.png +0 -0
- package/src/SliceUI/assets/Frame 5.png +0 -0
- package/src/SliceUI/assets/Frame 65.png +0 -0
- package/src/SliceUI/assets/Frame_65.png +0 -0
- package/src/SliceUI/assets/Icon copy.svg +3 -0
- package/src/SliceUI/assets/Icon.svg +3 -0
- package/src/SliceUI/assets/Icon_Bridging copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Bridging.svg +39 -0
- package/src/SliceUI/assets/Icon_Consistent copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Consistent.svg +39 -0
- package/src/SliceUI/assets/Icon_Plug copy.svg +38 -0
- package/src/SliceUI/assets/Icon_Plug.svg +38 -0
- package/src/SliceUI/assets/Icon_Reusable copy.svg +39 -0
- package/src/SliceUI/assets/Icon_Reusable.svg +39 -0
- package/src/SliceUI/assets/Layer_1.png +0 -0
- package/src/SliceUI/assets/accessibility.png +0 -0
- package/src/SliceUI/assets/accessibility.svg +1 -0
- package/src/SliceUI/assets/addon-library.png +0 -0
- package/src/SliceUI/assets/assets.png +0 -0
- package/src/SliceUI/assets/avif-test-image.avif +0 -0
- package/src/SliceUI/assets/bridging.svg +13 -0
- package/src/SliceUI/assets/consistent.svg +11 -0
- package/src/SliceUI/assets/context.png +0 -0
- package/src/SliceUI/assets/discord.svg +1 -0
- package/src/SliceUI/assets/docs.png +0 -0
- package/src/SliceUI/assets/figma-plugin.png +0 -0
- package/src/SliceUI/assets/github.svg +1 -0
- package/src/SliceUI/assets/resources/Anatomy diagram.svg +19 -0
- package/src/SliceUI/assets/resources/Anatomycheck.svg +15 -0
- package/src/SliceUI/assets/resources/Anatomyinput.svg +32 -0
- package/src/SliceUI/assets/resources/Diagram.svg +15 -0
- package/src/SliceUI/assets/resources/Frame 5.png +0 -0
- package/src/SliceUI/assets/resources/Frame 65.png +0 -0
- package/src/SliceUI/assets/resources/Icon.svg +3 -0
- package/src/SliceUI/assets/resources/Icon_Bridging.svg +39 -0
- package/src/SliceUI/assets/resources/Icon_Consistent.svg +39 -0
- package/src/SliceUI/assets/resources/Icon_Plug.svg +38 -0
- package/src/SliceUI/assets/resources/Icon_Reusable.svg +39 -0
- package/src/SliceUI/assets/resources/fonts/FontIcon.json +150 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Black.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Bold.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Heavy.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Medium.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato-Regular.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/Lato.woff2 +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.eot +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.svg +601 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.ttf +0 -0
- package/src/SliceUI/assets/resources/fonts/icomoon.woff +0 -0
- package/src/SliceUI/assets/resources/fonts/selection.json +1 -0
- package/src/SliceUI/assets/share.png +0 -0
- package/src/SliceUI/assets/styling.png +0 -0
- package/src/SliceUI/assets/testing.png +0 -0
- package/src/SliceUI/assets/theming.png +0 -0
- package/src/SliceUI/assets/tutorials.svg +1 -0
- package/src/SliceUI/assets/youtube.svg +1 -0
- package/src/SliceUI/automation/helper.ts +29 -0
- package/src/SliceUI/avatar/Avatar.tsx +237 -0
- package/src/SliceUI/avatar/Token.ts +116 -0
- package/src/SliceUI/avatar/Type.ts +36 -0
- package/src/SliceUI/avatar/helper.ts +53 -0
- package/src/SliceUI/badge/Badge.tsx +308 -0
- package/src/SliceUI/badge/Token.ts +202 -0
- package/src/SliceUI/badge/Type.ts +46 -0
- package/src/SliceUI/badge/helper.ts +39 -0
- package/src/SliceUI/button/Button.tsx +243 -0
- package/src/SliceUI/button/Token.ts +138 -0
- package/src/SliceUI/button/Type.ts +34 -0
- package/src/SliceUI/button/helper.ts +125 -0
- package/src/SliceUI/checkbox/Checkbox.tsx +176 -0
- package/src/SliceUI/checkbox/Token.ts +128 -0
- package/src/SliceUI/checkbox/Type.ts +35 -0
- package/src/SliceUI/chip/Chip.tsx +290 -0
- package/src/SliceUI/chip/Token.ts +151 -0
- package/src/SliceUI/chip/Type.ts +43 -0
- package/src/SliceUI/chip/helper.ts +40 -0
- package/src/SliceUI/colors/Pallete.ts +151 -0
- package/src/SliceUI/colors/Token.ts +110 -0
- package/src/SliceUI/colors/Type.ts +56 -0
- package/src/SliceUI/contextProvider/context.tsx +108 -0
- package/src/SliceUI/divider/Divider.tsx +109 -0
- package/src/SliceUI/divider/Token.ts +18 -0
- package/src/SliceUI/divider/Type.ts +26 -0
- package/src/SliceUI/icon/CustomIcon.ts +4 -0
- package/src/SliceUI/icon/IcoMoonIcon.tsx +11 -0
- package/src/SliceUI/icon/Icon.tsx +38 -0
- package/src/SliceUI/icon/Token.ts +14 -0
- package/src/SliceUI/icon/Type.ts +13 -0
- package/src/SliceUI/icon/selection.json +1 -0
- package/src/SliceUI/input/Input.tsx +573 -0
- package/src/SliceUI/input/ToDo.md +99 -0
- package/src/SliceUI/input/Token.ts +372 -0
- package/src/SliceUI/input/Type.ts +109 -0
- package/src/SliceUI/input/components/InputPortal.tsx +211 -0
- package/src/SliceUI/input/components/NativeBottomSheet.tsx +296 -0
- package/src/SliceUI/input/components/SelectChip.tsx +185 -0
- package/src/SliceUI/input/components/SelectList.tsx +173 -0
- package/src/SliceUI/input/components/SelectListItem.tsx +377 -0
- package/src/SliceUI/input/components/SelectScrollbarStyle.ts +44 -0
- package/src/SliceUI/input/hooks/useCustomScrollbar.ts +17 -0
- package/src/SliceUI/input/hooks/useInputState.ts +41 -0
- package/src/SliceUI/input/hooks/useLabelAnimation.ts +132 -0
- package/src/SliceUI/input/hooks/useOutsideClick.ts +38 -0
- package/src/SliceUI/input/hooks/useSelectLogic.ts +338 -0
- package/src/SliceUI/input/utils/inputUtils.ts +120 -0
- package/src/SliceUI/input/utils/selectUtils.ts +85 -0
- package/src/SliceUI/input/utils/styleUtils.ts +50 -0
- package/src/SliceUI/input/variants/CurrencyInput/CurrencyInput.tsx +16 -0
- package/src/SliceUI/input/variants/CurrencyInput/NativeCurrencyInput.tsx +181 -0
- package/src/SliceUI/input/variants/CurrencyInput/WebCurrencyInput.tsx +163 -0
- package/src/SliceUI/input/variants/CurrencyInput/types.ts +17 -0
- package/src/SliceUI/input/variants/PhoneInput/NativePhoneInput.tsx +189 -0
- package/src/SliceUI/input/variants/PhoneInput/PhoneInput.tsx +16 -0
- package/src/SliceUI/input/variants/PhoneInput/WebPhoneInput.tsx +291 -0
- package/src/SliceUI/input/variants/PhoneInput/types.ts +22 -0
- package/src/SliceUI/input/variants/SelectInput/SelectInput.tsx +407 -0
- package/src/SliceUI/input/variants/SelectInput/types.ts +34 -0
- package/src/SliceUI/input/variants/TextInput.tsx +68 -0
- package/src/SliceUI/layout/Box.tsx +38 -0
- package/src/SliceUI/layout/Center.tsx +38 -0
- package/src/SliceUI/layout/Divider.tsx +37 -0
- package/src/SliceUI/layout/Grid.tsx +75 -0
- package/src/SliceUI/layout/PageContainer.tsx +60 -0
- package/src/SliceUI/layout/ScrollContainer.tsx +72 -0
- package/src/SliceUI/layout/Spacer.tsx +54 -0
- package/src/SliceUI/layout/Stack.tsx +97 -0
- package/src/SliceUI/layout/StickyHeader.tsx +71 -0
- package/src/SliceUI/radio/RadioButton.tsx +130 -0
- package/src/SliceUI/radio/Token.ts +197 -0
- package/src/SliceUI/radio/Type.ts +35 -0
- package/src/SliceUI/react-native.config.js +3 -0
- package/src/SliceUI/responsive/Type.ts +7 -0
- package/src/SliceUI/responsive/helper.ts +53 -0
- package/src/SliceUI/switch/Switch.tsx +119 -0
- package/src/SliceUI/switch/Token.ts +205 -0
- package/src/SliceUI/switch/Type.ts +26 -0
- package/src/SliceUI/tab/TabItem.tsx +204 -0
- package/src/SliceUI/tab/Tabs.tsx +110 -0
- package/src/SliceUI/tab/Token.ts +282 -0
- package/src/SliceUI/tab/Type.ts +66 -0
- package/src/SliceUI/tab/helper.ts +53 -0
- package/src/SliceUI/table/Table.tsx +388 -0
- package/src/SliceUI/table/TableCell.tsx +158 -0
- package/src/SliceUI/table/TableFooter.tsx +353 -0
- package/src/SliceUI/table/TableHeader.tsx +247 -0
- package/src/SliceUI/table/TableRow.tsx +218 -0
- package/src/SliceUI/table/Token.ts +252 -0
- package/src/SliceUI/table/Type.ts +213 -0
- package/src/SliceUI/table/helper.ts +376 -0
- package/src/SliceUI/table/index.ts +53 -0
- package/src/SliceUI/theme/dummyColors.tsx +7 -0
- package/src/SliceUI/theme/theme.ts +107 -0
- package/src/SliceUI/typography/BaseTypographyToken.ts +62 -0
- package/src/SliceUI/typography/FoundationToken.ts +48 -0
- package/src/SliceUI/typography/Token.ts +228 -0
- package/src/SliceUI/typography/Type.ts +20 -0
- package/src/SliceUI/typography/Typography.tsx +99 -0
- package/src/SliceUI/values/BorderRadius.ts +17 -0
- package/src/SliceUI/values/BorderWidth.ts +7 -0
- package/src/SliceUI/values/Dimension.ts +35 -0
- package/src/SliceUI/values/IconSizes.ts +13 -0
- package/src/SliceUI/values/Spacing.ts +22 -0
- package/src/declarations.d.ts +8 -0
- package/src/index.tsx +119 -0
- package/src/stories/Colors.mdx +1418 -0
- package/src/stories/Dimensions.mdx +60 -0
- package/src/stories/GetStarted.mdx +90 -0
- package/src/stories/Introduction.mdx +136 -0
- package/src/stories/Shape.mdx +126 -0
- package/src/stories/Spacing.mdx +104 -0
- package/src/stories/Typography.mdx +454 -0
- package/src/stories/Utils.mdx +277 -0
- package/src/stories/story-components/AddIcon.js +13 -0
- package/src/stories/story-components/RectangleWithBox.jsx +51 -0
- package/src/stories/story-components/RoundedRectangle.jsx +18 -0
- package/src/stories/story-components/RoundedWithWhiteInside.jsx +33 -0
- package/src/stories/story-components/WhiteRoundedRectangle.jsx +107 -0
- package/src/stories/story-components/svgPaths.js +126 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SelectInput/types.ts
|
|
2
|
+
import type { SelectOption } from '../../Type';
|
|
3
|
+
|
|
4
|
+
export type ChipSize = 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';
|
|
5
|
+
|
|
6
|
+
export interface SelectInputProps {
|
|
7
|
+
value?: string | string[];
|
|
8
|
+
displayValue: string;
|
|
9
|
+
searchable?: boolean;
|
|
10
|
+
normalizedMultiple?: boolean;
|
|
11
|
+
normalizedListType?: 'default' | 'checkbox';
|
|
12
|
+
selectDropdownOpen: boolean;
|
|
13
|
+
filteredOptions: SelectOption[];
|
|
14
|
+
options: SelectOption[];
|
|
15
|
+
searchValue: string;
|
|
16
|
+
setSearchValue: (v: string) => void;
|
|
17
|
+
onOpen: () => void;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
onKeyDown: (e: any) => void;
|
|
20
|
+
onOptionSelect: (value: string) => void;
|
|
21
|
+
onCheckboxToggle: (value: string, checked: boolean) => void;
|
|
22
|
+
colorTheme: any;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
noItemText?: string;
|
|
25
|
+
maxAllowed?: number;
|
|
26
|
+
maxVisibleItems?: number;
|
|
27
|
+
selectedIcon?: React.ReactNode;
|
|
28
|
+
selectedValues: string[];
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
registerOptionRef: (index: number, el: HTMLElement | null) => void;
|
|
31
|
+
inputRef?: React.RefObject<any> | React.MutableRefObject<any>;
|
|
32
|
+
size?: ChipSize;
|
|
33
|
+
expandChips?: boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput as RNTextInput, Platform} from 'react-native';
|
|
3
|
+
|
|
4
|
+
interface TextInputVariantProps {
|
|
5
|
+
inputRef: React.Ref<any>;
|
|
6
|
+
value?: string | string[];
|
|
7
|
+
onChangeText?: (value: string | string[]) => void;
|
|
8
|
+
onFocus?: (e: any) => void;
|
|
9
|
+
onBlur?: (e: any) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
style?: any;
|
|
13
|
+
placeholderTextColor?: string;
|
|
14
|
+
restProps?: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const TextInput = ({
|
|
18
|
+
inputRef,
|
|
19
|
+
value,
|
|
20
|
+
onChangeText,
|
|
21
|
+
onFocus,
|
|
22
|
+
onBlur,
|
|
23
|
+
placeholder,
|
|
24
|
+
disabled,
|
|
25
|
+
style,
|
|
26
|
+
placeholderTextColor,
|
|
27
|
+
restProps = {},
|
|
28
|
+
}: TextInputVariantProps) => {
|
|
29
|
+
const handleChangeText = (text: string) => {
|
|
30
|
+
onChangeText?.(text);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const inputStyle =
|
|
34
|
+
Platform.OS === 'web'
|
|
35
|
+
? [
|
|
36
|
+
style,
|
|
37
|
+
{
|
|
38
|
+
outline: 'none',
|
|
39
|
+
outlineWidth: 0,
|
|
40
|
+
outlineStyle: 'none',
|
|
41
|
+
boxShadow: 'none',
|
|
42
|
+
} as any,
|
|
43
|
+
]
|
|
44
|
+
: [
|
|
45
|
+
style,
|
|
46
|
+
{
|
|
47
|
+
paddingVertical: 0,
|
|
48
|
+
textAlignVertical: 'center',
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<RNTextInput
|
|
54
|
+
{...restProps}
|
|
55
|
+
ref={inputRef}
|
|
56
|
+
value={typeof value === 'string' ? value : ''}
|
|
57
|
+
onChangeText={handleChangeText}
|
|
58
|
+
onFocus={onFocus}
|
|
59
|
+
onBlur={onBlur}
|
|
60
|
+
style={inputStyle}
|
|
61
|
+
placeholder={placeholder}
|
|
62
|
+
placeholderTextColor={placeholderTextColor}
|
|
63
|
+
editable={!disabled}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default TextInput;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// Example Usage:
|
|
5
|
+
// <Box padding={10} bg="lightblue" margin={5}>
|
|
6
|
+
// <Text>Content inside a styled box</Text> {/* Box with padding, margin, and background */}
|
|
7
|
+
// </Box>
|
|
8
|
+
// <VStack>
|
|
9
|
+
// <Box flex={1} bg="gray">
|
|
10
|
+
// <Text>Fills available space</Text>
|
|
11
|
+
// </Box>
|
|
12
|
+
// </VStack>
|
|
13
|
+
|
|
14
|
+
interface BoxProps {
|
|
15
|
+
padding?: number; // Padding inside the box
|
|
16
|
+
margin?: number; // Margin outside the box
|
|
17
|
+
bg?: string; // Background color
|
|
18
|
+
flex?: number; // Flex value
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Box: React.FC<BoxProps> = ({
|
|
23
|
+
padding = 0,
|
|
24
|
+
margin = 0,
|
|
25
|
+
bg,
|
|
26
|
+
flex,
|
|
27
|
+
children,
|
|
28
|
+
}) => {
|
|
29
|
+
const style: ViewStyle = {
|
|
30
|
+
padding,
|
|
31
|
+
margin,
|
|
32
|
+
backgroundColor: bg,
|
|
33
|
+
flex,
|
|
34
|
+
};
|
|
35
|
+
return <View style={style}>{children}</View>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default React.memo(Box);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// Example Usage:
|
|
5
|
+
// <Box bg="lightgray" padding={20}>
|
|
6
|
+
// <Center> {/* Centers text both horizontally and vertically */}
|
|
7
|
+
// <Text>Centered Text</Text>
|
|
8
|
+
// </Center>
|
|
9
|
+
// </Box>
|
|
10
|
+
// <HStack>
|
|
11
|
+
// <Text>Left</Text>
|
|
12
|
+
// <Center horizontal={true} vertical={false}> {/* Centers horizontally only */}
|
|
13
|
+
// <Text>Middle</Text>
|
|
14
|
+
// </Center>
|
|
15
|
+
// <Text>Right</Text>
|
|
16
|
+
// </HStack>
|
|
17
|
+
|
|
18
|
+
interface CenterProps {
|
|
19
|
+
horizontal?: boolean; // Center horizontally
|
|
20
|
+
vertical?: boolean; // Center vertically
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Center: React.FC<CenterProps> = ({
|
|
25
|
+
horizontal = true,
|
|
26
|
+
vertical = true,
|
|
27
|
+
children,
|
|
28
|
+
}) => {
|
|
29
|
+
const style: ViewStyle = {
|
|
30
|
+
...(horizontal ? { alignItems: 'center' } : {}),
|
|
31
|
+
...(vertical ? { justifyContent: 'center' } : {}),
|
|
32
|
+
flex: 1, // Ensures it takes available space
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return <View style={style}>{children}</View>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default React.memo(Center);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// Example Usage:
|
|
5
|
+
// <VStack>
|
|
6
|
+
// <Text>Item 1</Text>
|
|
7
|
+
// <Divider color="gray" thickness={1} /> {/* Horizontal line between items */}
|
|
8
|
+
// <Text>Item 2</Text>
|
|
9
|
+
// </VStack>
|
|
10
|
+
// <HStack>
|
|
11
|
+
// <Text>Left</Text>
|
|
12
|
+
// <Divider orientation="vertical" color="black" thickness={2} /> {/* Vertical separator */}
|
|
13
|
+
// <Text>Right</Text>
|
|
14
|
+
// </HStack>
|
|
15
|
+
|
|
16
|
+
interface DividerProps {
|
|
17
|
+
orientation?: 'horizontal' | 'vertical'; // Direction of the line
|
|
18
|
+
color?: string; // Line color
|
|
19
|
+
thickness?: number; // Line thickness
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Divider: React.FC<DividerProps> = ({
|
|
23
|
+
orientation = 'horizontal',
|
|
24
|
+
color = 'gray',
|
|
25
|
+
thickness = 1,
|
|
26
|
+
}) => {
|
|
27
|
+
const style: ViewStyle = {
|
|
28
|
+
backgroundColor: color,
|
|
29
|
+
...(orientation === 'horizontal'
|
|
30
|
+
? { height: thickness, width: '100%' }
|
|
31
|
+
: { width: thickness, height: '100%' }),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return <View style={style} />;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default React.memo(Divider);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
ViewStyle,
|
|
5
|
+
StyleProp,
|
|
6
|
+
ViewProps,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
interface GridProps extends ViewProps {
|
|
11
|
+
columns?: number; // Number of columns
|
|
12
|
+
gap?: number; // Spacing between items
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
style?: StyleProp<ViewStyle>; // Container styles
|
|
15
|
+
itemStyle?: StyleProp<ViewStyle>; // Item styles
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Grid is a flexible layout component for creating multi-column grids.
|
|
20
|
+
* It supports adjustable columns, spacing (gap), and custom styles.
|
|
21
|
+
*
|
|
22
|
+
* Example usage:
|
|
23
|
+
*
|
|
24
|
+
* // 3-column grid with spacing
|
|
25
|
+
* <Grid columns={3} gap={10}>
|
|
26
|
+
* <Box bg="lightblue" padding={10}><Text>Box 1</Text></Box>
|
|
27
|
+
* <Box bg="lightblue" padding={10}><Text>Box 2</Text></Box>
|
|
28
|
+
* <Box bg="lightblue" padding={10}><Text>Box 3</Text></Box>
|
|
29
|
+
* <Box bg="lightblue" padding={10}><Text>Box 4</Text></Box>
|
|
30
|
+
* </Grid>
|
|
31
|
+
*
|
|
32
|
+
* // 2-column grid with smaller gap
|
|
33
|
+
* <Grid columns={2} gap={5}>
|
|
34
|
+
* <Text>Item 1</Text>
|
|
35
|
+
* <Text>Item 2</Text>
|
|
36
|
+
* <Text>Item 3</Text>
|
|
37
|
+
* </Grid>
|
|
38
|
+
*
|
|
39
|
+
* // Grid with custom container and item styles
|
|
40
|
+
* <Grid columns={2} gap={8} style={{ padding: 10 }} itemStyle={{ backgroundColor: '#eee' }}>
|
|
41
|
+
* <Text>Styled 1</Text>
|
|
42
|
+
* <Text>Styled 2</Text>
|
|
43
|
+
* </Grid>
|
|
44
|
+
*/
|
|
45
|
+
const Grid: React.FC<GridProps> = ({
|
|
46
|
+
columns = 2,
|
|
47
|
+
gap = 0,
|
|
48
|
+
children,
|
|
49
|
+
style,
|
|
50
|
+
itemStyle,
|
|
51
|
+
...rest
|
|
52
|
+
}) => {
|
|
53
|
+
const gridStyle: ViewStyle = {
|
|
54
|
+
flexDirection: 'row',
|
|
55
|
+
flexWrap: 'wrap',
|
|
56
|
+
gap,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const calculatedItemStyle: ViewStyle = {
|
|
60
|
+
width: `${100 / columns - (gap * (columns - 1)) / columns}%`,
|
|
61
|
+
marginBottom: gap,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<View style={[gridStyle, style]} {...rest}>
|
|
66
|
+
{React.Children.map(children, (child, index) => (
|
|
67
|
+
<View key={`grid-item-${index}`} style={[calculatedItemStyle, itemStyle]}>
|
|
68
|
+
{child}
|
|
69
|
+
</View>
|
|
70
|
+
))}
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default React.memo(Grid);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
ViewStyle,
|
|
5
|
+
StyleProp,
|
|
6
|
+
ViewProps,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
interface PageContainerProps extends ViewProps {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
maxWidth?: number;
|
|
13
|
+
|
|
14
|
+
// Padding options
|
|
15
|
+
padding?: number;
|
|
16
|
+
paddingTop?: number;
|
|
17
|
+
paddingBottom?: number;
|
|
18
|
+
paddingHorizontal?: number;
|
|
19
|
+
paddingVertical?: number;
|
|
20
|
+
paddingLeft?: number;
|
|
21
|
+
paddingRight?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const PageContainer: React.FC<PageContainerProps> = ({
|
|
25
|
+
children,
|
|
26
|
+
style,
|
|
27
|
+
maxWidth = 1024,
|
|
28
|
+
padding,
|
|
29
|
+
paddingTop,
|
|
30
|
+
paddingBottom,
|
|
31
|
+
paddingHorizontal,
|
|
32
|
+
paddingVertical,
|
|
33
|
+
paddingLeft,
|
|
34
|
+
paddingRight,
|
|
35
|
+
...rest
|
|
36
|
+
}) => {
|
|
37
|
+
const containerStyle: ViewStyle = {
|
|
38
|
+
flex: 1,
|
|
39
|
+
width: '100%',
|
|
40
|
+
alignSelf: 'center',
|
|
41
|
+
maxWidth,
|
|
42
|
+
|
|
43
|
+
// Apply padding props if provided
|
|
44
|
+
...(padding !== undefined && { padding }),
|
|
45
|
+
...(paddingTop !== undefined && { paddingTop }),
|
|
46
|
+
...(paddingBottom !== undefined && { paddingBottom }),
|
|
47
|
+
...(paddingHorizontal !== undefined && { paddingHorizontal }),
|
|
48
|
+
...(paddingVertical !== undefined && { paddingVertical }),
|
|
49
|
+
...(paddingLeft !== undefined && { paddingLeft }),
|
|
50
|
+
...(paddingRight !== undefined && { paddingRight }),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View style={[containerStyle, style]} {...rest}>
|
|
55
|
+
{children}
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default React.memo(PageContainer);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
DimensionValue,
|
|
4
|
+
ScrollView,
|
|
5
|
+
ScrollViewProps,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
StyleProp,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
|
|
11
|
+
interface ScrollContainerProps extends ScrollViewProps {
|
|
12
|
+
direction?: 'horizontal' | 'vertical'; // Scroll direction
|
|
13
|
+
showsIndicators?: boolean; // Toggle scroll indicators
|
|
14
|
+
maxHeight?: DimensionValue; // Max height for vertical scroll
|
|
15
|
+
style?: StyleProp<ViewStyle>; // Additional styles
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* ScrollContainer provides a customizable scrollable wrapper.
|
|
20
|
+
* Supports both vertical and horizontal scrolling, with optional indicators and max height.
|
|
21
|
+
*
|
|
22
|
+
* Example usage:
|
|
23
|
+
*
|
|
24
|
+
* // Vertical scrollable list with max height
|
|
25
|
+
* <ScrollContainer direction="vertical" maxHeight={200} showsIndicators={false}>
|
|
26
|
+
* <VStack gap={10}>
|
|
27
|
+
* <Text>Item 1</Text>
|
|
28
|
+
* <Text>Item 2</Text>
|
|
29
|
+
* <Text>Item 3</Text>
|
|
30
|
+
* <Text>Item 4</Text>
|
|
31
|
+
* </VStack>
|
|
32
|
+
* </ScrollContainer>
|
|
33
|
+
*
|
|
34
|
+
* // Horizontal scrollable row
|
|
35
|
+
* <ScrollContainer direction="horizontal">
|
|
36
|
+
* <HStack gap={10}>
|
|
37
|
+
* <Box bg="lightblue" padding={10}><Text>Box 1</Text></Box>
|
|
38
|
+
* <Box bg="lightblue" padding={10}><Text>Box 2</Text></Box>
|
|
39
|
+
* <Box bg="lightblue" padding={10}><Text>Box 3</Text></Box>
|
|
40
|
+
* </HStack>
|
|
41
|
+
* </ScrollContainer>
|
|
42
|
+
*/
|
|
43
|
+
const ScrollContainer: React.FC<ScrollContainerProps> = ({
|
|
44
|
+
direction = 'vertical',
|
|
45
|
+
showsIndicators = true,
|
|
46
|
+
maxHeight,
|
|
47
|
+
style,
|
|
48
|
+
children,
|
|
49
|
+
...scrollViewProps
|
|
50
|
+
}) => {
|
|
51
|
+
const isHorizontal = direction === 'horizontal';
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<ScrollView
|
|
55
|
+
horizontal={isHorizontal}
|
|
56
|
+
showsHorizontalScrollIndicator={isHorizontal ? showsIndicators : false}
|
|
57
|
+
showsVerticalScrollIndicator={!isHorizontal ? showsIndicators : false}
|
|
58
|
+
style={[styles.scroll, maxHeight ? { maxHeight } : {}, style]}
|
|
59
|
+
{...scrollViewProps}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
</ScrollView>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
scroll: {
|
|
68
|
+
flexGrow: 0, // Prevents scroll from expanding unnecessarily
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export default React.memo(ScrollContainer);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
DimensionValue,
|
|
4
|
+
View,
|
|
5
|
+
ViewStyle,
|
|
6
|
+
ViewProps,
|
|
7
|
+
StyleProp,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
interface SpacerProps extends ViewProps {
|
|
11
|
+
width?: DimensionValue; // Fixed width or percentage
|
|
12
|
+
height?: DimensionValue; // Fixed height or percentage
|
|
13
|
+
flex?: number; // Flex grow to fill space
|
|
14
|
+
style?: StyleProp<ViewStyle>; // Additional styles
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Spacer is a utility component for adding space between elements.
|
|
19
|
+
* You can control its size with `width`, `height`, or `flex`.
|
|
20
|
+
*
|
|
21
|
+
* Example usage:
|
|
22
|
+
*
|
|
23
|
+
* // Horizontal space between two items
|
|
24
|
+
* <HStack>
|
|
25
|
+
* <Text>Left</Text>
|
|
26
|
+
* <Spacer width={20} />
|
|
27
|
+
* <Text>Right</Text>
|
|
28
|
+
* </HStack>
|
|
29
|
+
*
|
|
30
|
+
* // Push content to the end using flex
|
|
31
|
+
* <HStack>
|
|
32
|
+
* <Text>Left</Text>
|
|
33
|
+
* <Spacer flex={1} />
|
|
34
|
+
* <Text>Right</Text>
|
|
35
|
+
* </HStack>
|
|
36
|
+
*
|
|
37
|
+
* // Vertical spacing
|
|
38
|
+
* <VStack>
|
|
39
|
+
* <Text>Top</Text>
|
|
40
|
+
* <Spacer height={30} />
|
|
41
|
+
* <Text>Bottom</Text>
|
|
42
|
+
* </VStack>
|
|
43
|
+
*/
|
|
44
|
+
const Spacer: React.FC<SpacerProps> = ({ width, height, flex, style, ...rest }) => {
|
|
45
|
+
const spacerStyle: ViewStyle = {
|
|
46
|
+
width,
|
|
47
|
+
height,
|
|
48
|
+
flex,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return <View style={[spacerStyle, style]} {...rest} />;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default React.memo(Spacer);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
ViewStyle,
|
|
5
|
+
ViewProps,
|
|
6
|
+
StyleProp,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
interface StackProps extends ViewProps {
|
|
10
|
+
gap?: number; // Spacing between children
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
style?: StyleProp<ViewStyle>; // Additional container styles
|
|
13
|
+
alignItems?: ViewStyle['alignItems']; // Alignment along cross axis
|
|
14
|
+
justifyContent?: ViewStyle['justifyContent']; // Alignment along main axis
|
|
15
|
+
flexWrap?: ViewStyle['flexWrap']; // Wrap children if needed
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* HStack arranges children in a horizontal row with optional spacing and alignment.
|
|
20
|
+
*
|
|
21
|
+
* Example usage:
|
|
22
|
+
*
|
|
23
|
+
* <HStack gap={10}>
|
|
24
|
+
* <Text>Left</Text>
|
|
25
|
+
* <Text>Right</Text>
|
|
26
|
+
* </HStack>
|
|
27
|
+
*
|
|
28
|
+
* <HStack gap={12} alignItems="center" justifyContent="space-between" style={{ padding: 10 }}>
|
|
29
|
+
* <Text>Left</Text>
|
|
30
|
+
* <Text>Right</Text>
|
|
31
|
+
* </HStack>
|
|
32
|
+
*/
|
|
33
|
+
const HStackComponent: React.FC<StackProps> = ({
|
|
34
|
+
gap = 0,
|
|
35
|
+
children,
|
|
36
|
+
style,
|
|
37
|
+
alignItems,
|
|
38
|
+
justifyContent,
|
|
39
|
+
flexWrap,
|
|
40
|
+
...rest
|
|
41
|
+
}) => {
|
|
42
|
+
const combinedStyle: ViewStyle = {
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
gap,
|
|
45
|
+
alignItems,
|
|
46
|
+
justifyContent,
|
|
47
|
+
flexWrap,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<View style={[combinedStyle, style]} {...rest}>
|
|
52
|
+
{children}
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* VStack arranges children in a vertical column with optional spacing and alignment.
|
|
59
|
+
*
|
|
60
|
+
* Example usage:
|
|
61
|
+
*
|
|
62
|
+
* <VStack gap={15}>
|
|
63
|
+
* <Text>Top</Text>
|
|
64
|
+
* <Text>Bottom</Text>
|
|
65
|
+
* </VStack>
|
|
66
|
+
*
|
|
67
|
+
* <VStack gap={20} style={{ backgroundColor: '#f0f0f0' }} alignItems="center">
|
|
68
|
+
* <Text>Centered 1</Text>
|
|
69
|
+
* <Text>Centered 2</Text>
|
|
70
|
+
* </VStack>
|
|
71
|
+
*/
|
|
72
|
+
const VStackComponent: React.FC<StackProps> = ({
|
|
73
|
+
gap = 0,
|
|
74
|
+
children,
|
|
75
|
+
style,
|
|
76
|
+
alignItems,
|
|
77
|
+
justifyContent,
|
|
78
|
+
flexWrap,
|
|
79
|
+
...rest
|
|
80
|
+
}) => {
|
|
81
|
+
const combinedStyle: ViewStyle = {
|
|
82
|
+
flexDirection: 'column',
|
|
83
|
+
gap,
|
|
84
|
+
alignItems,
|
|
85
|
+
justifyContent,
|
|
86
|
+
flexWrap,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<View style={[combinedStyle, style]} {...rest}>
|
|
91
|
+
{children}
|
|
92
|
+
</View>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const HStack = React.memo(HStackComponent);
|
|
97
|
+
export const VStack = React.memo(VStackComponent);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ViewStyle, StyleProp } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// Example Usage:
|
|
5
|
+
// <StickyHeader
|
|
6
|
+
// bg="#f0f0f0"
|
|
7
|
+
// position="top" {/* Default top positioning */}
|
|
8
|
+
// offset={10} {/* Adds 10 units from the top */}
|
|
9
|
+
// shadow={true} {/* Adds a subtle shadow */}
|
|
10
|
+
// opacity={0.9} {/* Slightly transparent */}
|
|
11
|
+
// style={{ borderBottomWidth: 1, borderColor: 'gray' }} {/* Custom styles */}
|
|
12
|
+
// >
|
|
13
|
+
// <HStack gap={10} style={{ padding: 10 }}>
|
|
14
|
+
// <Text style={{ fontSize: 20 }}>John Doe</Text>
|
|
15
|
+
// <Spacer flex={1} />
|
|
16
|
+
// <Text>Settings</Text>
|
|
17
|
+
// </HStack>
|
|
18
|
+
// </StickyHeader>
|
|
19
|
+
// <StickyHeader
|
|
20
|
+
// bg="white"
|
|
21
|
+
// position="bottom" {/* Sticks to bottom */}
|
|
22
|
+
// shadow={false}
|
|
23
|
+
// zIndex={5}
|
|
24
|
+
// >
|
|
25
|
+
// <HStack gap={5} style={{ padding: 5 }}>
|
|
26
|
+
// <Text>Footer Item</Text>
|
|
27
|
+
// </HStack>
|
|
28
|
+
// </StickyHeader>
|
|
29
|
+
|
|
30
|
+
interface StickyHeaderProps {
|
|
31
|
+
bg?: string; // Background color of the header
|
|
32
|
+
position?: 'top' | 'bottom'; // Where the header sticks (top or bottom)
|
|
33
|
+
offset?: number; // Distance from the edge (top or bottom)
|
|
34
|
+
shadow?: boolean; // Toggle shadow effect
|
|
35
|
+
opacity?: number; // Transparency level (0 to 1)
|
|
36
|
+
zIndex?: number; // Stacking order
|
|
37
|
+
style?: StyleProp<ViewStyle>; // Additional custom styles
|
|
38
|
+
children: React.ReactNode; // Content inside the header
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const StickyHeader: React.FC<StickyHeaderProps> = ({
|
|
42
|
+
bg = '#f0f0f0',
|
|
43
|
+
position = 'top',
|
|
44
|
+
offset = 0,
|
|
45
|
+
shadow = false,
|
|
46
|
+
opacity = 1,
|
|
47
|
+
zIndex = 10,
|
|
48
|
+
style,
|
|
49
|
+
children,
|
|
50
|
+
}) => {
|
|
51
|
+
const baseStyle: ViewStyle = {
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
[position]: offset, // Dynamically set top or bottom based on position prop
|
|
54
|
+
left: 0,
|
|
55
|
+
right: 0,
|
|
56
|
+
backgroundColor: bg,
|
|
57
|
+
opacity,
|
|
58
|
+
zIndex,
|
|
59
|
+
...(shadow && {
|
|
60
|
+
shadowColor: '#000',
|
|
61
|
+
shadowOffset: { width: 0, height: 2 },
|
|
62
|
+
shadowOpacity: 0.2,
|
|
63
|
+
shadowRadius: 4,
|
|
64
|
+
elevation: 5, // For Android shadow
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return <View style={[baseStyle, style]}>{children}</View>;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default React.memo(StickyHeader);
|