@dryanovski/react-native-components 1.0.7 → 1.0.9
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/lib/module/components/Accordion/Accordion.js +58 -0
- package/lib/module/components/Accordion/Accordion.js.map +1 -0
- package/lib/module/components/Accordion/AccordionContext.js +12 -0
- package/lib/module/components/Accordion/AccordionContext.js.map +1 -0
- package/lib/module/components/Accordion/AccordionItem.js +50 -0
- package/lib/module/components/Accordion/AccordionItem.js.map +1 -0
- package/lib/module/components/Accordion/style.js +11 -0
- package/lib/module/components/Accordion/style.js.map +1 -0
- package/lib/module/components/Accordion/type.js +4 -0
- package/lib/module/components/Accordion/type.js.map +1 -0
- package/lib/module/components/Button/Button.js.map +1 -1
- package/lib/module/components/Button/DangerButton.js.map +1 -1
- package/lib/module/components/Button/GhostButton.js.map +1 -1
- package/lib/module/components/Button/PrimaryButton.js.map +1 -1
- package/lib/module/components/Button/SecondaryButton.js.map +1 -1
- package/lib/module/components/Collapse/Collapse.js +114 -0
- package/lib/module/components/Collapse/Collapse.js.map +1 -0
- package/lib/module/components/Collapse/index.js +5 -0
- package/lib/module/components/Collapse/index.js.map +1 -0
- package/lib/module/components/Collapse/types.js +4 -0
- package/lib/module/components/Collapse/types.js.map +1 -0
- package/lib/module/components/Divider/Divider.js +33 -0
- package/lib/module/components/Divider/Divider.js.map +1 -0
- package/lib/module/components/Divider/styles.js +2 -0
- package/lib/module/components/Divider/styles.js.map +1 -0
- package/lib/module/components/Divider/types.js +4 -0
- package/lib/module/components/Divider/types.js.map +1 -0
- package/lib/module/components/Layout/HStack.js +24 -0
- package/lib/module/components/Layout/HStack.js.map +1 -0
- package/lib/module/components/Layout/VStack.js +24 -0
- package/lib/module/components/Layout/VStack.js.map +1 -0
- package/lib/module/components/Layout/layout.types.js +4 -0
- package/lib/module/components/Layout/layout.types.js.map +1 -0
- package/lib/module/index.js +22 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/Accordion/Accordion.d.ts +4 -0
- package/lib/typescript/src/components/Accordion/Accordion.d.ts.map +1 -0
- package/lib/typescript/src/components/Accordion/AccordionContext.d.ts +12 -0
- package/lib/typescript/src/components/Accordion/AccordionContext.d.ts.map +1 -0
- package/lib/typescript/src/components/Accordion/AccordionItem.d.ts +5 -0
- package/lib/typescript/src/components/Accordion/AccordionItem.d.ts.map +1 -0
- package/lib/typescript/src/components/Accordion/style.d.ts +8 -0
- package/lib/typescript/src/components/Accordion/style.d.ts.map +1 -0
- package/lib/typescript/src/components/Accordion/type.d.ts +56 -0
- package/lib/typescript/src/components/Accordion/type.d.ts.map +1 -0
- package/lib/typescript/src/components/Button/Button.d.ts +0 -2
- package/lib/typescript/src/components/Button/Button.d.ts.map +1 -1
- package/lib/typescript/src/components/Button/DangerButton.d.ts.map +1 -1
- package/lib/typescript/src/components/Button/GhostButton.d.ts.map +1 -1
- package/lib/typescript/src/components/Button/PrimaryButton.d.ts.map +1 -1
- package/lib/typescript/src/components/Button/SecondaryButton.d.ts.map +1 -1
- package/lib/typescript/src/components/Button/types.d.ts +11 -0
- package/lib/typescript/src/components/Button/types.d.ts.map +1 -1
- package/lib/typescript/src/components/Collapse/Collapse.d.ts +14 -0
- package/lib/typescript/src/components/Collapse/Collapse.d.ts.map +1 -0
- package/lib/typescript/src/components/Collapse/index.d.ts +3 -0
- package/lib/typescript/src/components/Collapse/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Collapse/types.d.ts +51 -0
- package/lib/typescript/src/components/Collapse/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Divider/Divider.d.ts +5 -0
- package/lib/typescript/src/components/Divider/Divider.d.ts.map +1 -0
- package/lib/typescript/src/components/Divider/styles.d.ts +1 -0
- package/lib/typescript/src/components/Divider/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Divider/types.d.ts +31 -0
- package/lib/typescript/src/components/Divider/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Layout/HStack.d.ts +4 -0
- package/lib/typescript/src/components/Layout/HStack.d.ts.map +1 -0
- package/lib/typescript/src/components/Layout/VStack.d.ts +4 -0
- package/lib/typescript/src/components/Layout/VStack.d.ts.map +1 -0
- package/lib/typescript/src/components/Layout/layout.types.d.ts +8 -0
- package/lib/typescript/src/components/Layout/layout.types.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +20 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Accordion/Accordion.tsx +75 -0
- package/src/components/Accordion/AccordionContext.tsx +22 -0
- package/src/components/Accordion/AccordionItem.tsx +60 -0
- package/src/components/Accordion/style.ts +10 -0
- package/src/components/Accordion/type.ts +65 -0
- package/src/components/Button/Button.tsx +1 -3
- package/src/components/Button/DangerButton.tsx +2 -2
- package/src/components/Button/GhostButton.tsx +2 -2
- package/src/components/Button/PrimaryButton.tsx +2 -2
- package/src/components/Button/SecondaryButton.tsx +2 -2
- package/src/components/Button/types.ts +12 -0
- package/src/components/Collapse/Collapse.tsx +126 -0
- package/src/components/Collapse/index.ts +3 -0
- package/src/components/Collapse/types.ts +62 -0
- package/src/components/Divider/Divider.tsx +28 -0
- package/src/components/Divider/styles.ts +0 -0
- package/src/components/Divider/types.ts +36 -0
- package/src/components/Layout/HStack.tsx +19 -0
- package/src/components/Layout/VStack.tsx +19 -0
- package/src/components/Layout/layout.types.ts +9 -0
- package/src/index.tsx +22 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,eAAO,MAAM,MAAM,yHAoCjB,CAAC;AAIH,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DangerButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/DangerButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"DangerButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/DangerButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,YAAY,yHAIxB,CAAC;AAIF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GhostButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/GhostButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"GhostButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/GhostButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,WAAW,yHAIvB,CAAC;AAIF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimaryButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/PrimaryButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"PrimaryButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/PrimaryButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,aAAa,yHAIzB,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecondaryButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/SecondaryButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"SecondaryButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/SecondaryButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,eAAe,yHAI3B,CAAC;AAIF,eAAe,eAAe,CAAC"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import type { ComponentRef } from 'react';
|
|
2
2
|
import type { StyleProp, TextStyle, TouchableOpacity, TouchableOpacityProps, ViewStyle } from 'react-native';
|
|
3
|
+
import type Button from './Button';
|
|
3
4
|
/**
|
|
4
5
|
* Ref type for the Button component
|
|
5
6
|
*/
|
|
6
7
|
export type ButtonRef = ComponentRef<typeof TouchableOpacity>;
|
|
8
|
+
/**
|
|
9
|
+
* The root ref type for the Button component
|
|
10
|
+
*/
|
|
11
|
+
export type ButtonBaseRef = ComponentRef<typeof Button>;
|
|
12
|
+
/**
|
|
13
|
+
* The variant types for the Button component
|
|
14
|
+
*/
|
|
7
15
|
export type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';
|
|
16
|
+
/**
|
|
17
|
+
* Button size types
|
|
18
|
+
*/
|
|
8
19
|
export type ButtonSize = 'small' | 'medium' | 'large';
|
|
9
20
|
export interface ButtonBaseProps extends Omit<TouchableOpacityProps, 'style'> {
|
|
10
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACV,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC;IAC3E;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import type { CollapseProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Collapse - A reusable component for smooth expand/collapse animations
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <Collapse isExpanded={isOpen}>
|
|
9
|
+
* <Text>Your content here</Text>
|
|
10
|
+
* </Collapse>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const Collapse: FC<CollapseProps>;
|
|
14
|
+
//# sourceMappingURL=Collapse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collapse.d.ts","sourceRoot":"","sources":["../../../../../src/components/Collapse/Collapse.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAQlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAoGtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Collapse/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import type { WithSpringConfig, WithTimingConfig } from 'react-native-reanimated';
|
|
3
|
+
export type AnimationType = 'timing' | 'spring';
|
|
4
|
+
export type AnimationConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* Type of animation to use.
|
|
7
|
+
* @default 'timing'
|
|
8
|
+
*/
|
|
9
|
+
type?: AnimationType;
|
|
10
|
+
/**
|
|
11
|
+
* Duration of the animation in milliseconds (for timing animation).
|
|
12
|
+
* @default 100
|
|
13
|
+
*/
|
|
14
|
+
duration?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Timing animation configuration.
|
|
17
|
+
*/
|
|
18
|
+
timingConfig?: WithTimingConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Spring animation configuration.
|
|
21
|
+
*/
|
|
22
|
+
springConfig?: WithSpringConfig;
|
|
23
|
+
};
|
|
24
|
+
export type CollapseProps = {
|
|
25
|
+
/**
|
|
26
|
+
* Whether the content is expanded or collapsed.
|
|
27
|
+
*/
|
|
28
|
+
isExpanded: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Content to animate.
|
|
31
|
+
*/
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Animation configuration.
|
|
35
|
+
* @default { type: 'timing', duration: 100 }
|
|
36
|
+
*/
|
|
37
|
+
animationConfig?: AnimationConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Style for the animated container.
|
|
40
|
+
*/
|
|
41
|
+
style?: StyleProp<ViewStyle>;
|
|
42
|
+
/**
|
|
43
|
+
* Style for the content wrapper.
|
|
44
|
+
*/
|
|
45
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
46
|
+
/**
|
|
47
|
+
* Callback when measurement is complete.
|
|
48
|
+
*/
|
|
49
|
+
onMeasured?: (height: number) => void;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Collapse/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAElF,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE7B;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAEpC;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import type { DividerProps } from './types';
|
|
3
|
+
export declare const Divider: import("react").ForwardRefExoticComponent<DividerProps & import("react").RefAttributes<View>>;
|
|
4
|
+
export default Divider;
|
|
5
|
+
//# sourceMappingURL=Divider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.d.ts","sourceRoot":"","sources":["../../../../../src/components/Divider/Divider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,OAAO,+FAkBlB,CAAC;AAIH,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/components/Divider/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
2
|
+
export type DividerThickness = 1 | 5 | 10;
|
|
3
|
+
export type DividerOrientation = 'horizontal' | 'vertical';
|
|
4
|
+
export interface DividerProps extends ViewProps {
|
|
5
|
+
/**
|
|
6
|
+
* Style for the divider component.
|
|
7
|
+
* Optional.
|
|
8
|
+
*/
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
/**
|
|
11
|
+
* The thickness of the divider.
|
|
12
|
+
* @default 1
|
|
13
|
+
*/
|
|
14
|
+
thickness?: DividerThickness;
|
|
15
|
+
/**
|
|
16
|
+
* The color of the divider.
|
|
17
|
+
* @default '#000'
|
|
18
|
+
*/
|
|
19
|
+
color?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The orientation of the divider.
|
|
22
|
+
* @default 'horizontal'
|
|
23
|
+
*/
|
|
24
|
+
orientation?: DividerOrientation;
|
|
25
|
+
/**
|
|
26
|
+
* The length of the divider.
|
|
27
|
+
* @default '100%'
|
|
28
|
+
*/
|
|
29
|
+
length?: number | string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Divider/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE3D,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAE7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAEjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HStack.d.ts","sourceRoot":"","sources":["../../../../../src/components/Layout/HStack.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,MAAM,8FAIjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VStack.d.ts","sourceRoot":"","sources":["../../../../../src/components/Layout/VStack.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,MAAM,8FAIjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Layout/layout.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
export * from './components/Accordion/Accordion';
|
|
2
|
+
export * from './components/Accordion/AccordionItem';
|
|
3
|
+
export * from './components/Collapse';
|
|
4
|
+
export * from './components/Button/Button';
|
|
5
|
+
export * from './components/Button/DangerButton';
|
|
6
|
+
export * from './components/Button/GhostButton';
|
|
7
|
+
export * from './components/Button/PrimaryButton';
|
|
8
|
+
export * from './components/Button/SecondaryButton';
|
|
1
9
|
export * from './components/Card/Card';
|
|
10
|
+
export * from './components/Divider/Divider';
|
|
11
|
+
export * from './components/Layout/HStack';
|
|
12
|
+
export * from './components/Layout/VStack';
|
|
13
|
+
export * from './components/Surface/Surface';
|
|
14
|
+
export * from './components/Accordion/type';
|
|
15
|
+
export * from './components/Collapse/types';
|
|
16
|
+
export * from './components/Button/types';
|
|
17
|
+
export * from './components/Card/types';
|
|
18
|
+
export * from './components/Divider/types';
|
|
19
|
+
export * from './components/Layout/layout.types';
|
|
20
|
+
export * from './components/Surface/types';
|
|
21
|
+
export * from './types/general.types';
|
|
2
22
|
export * from './providers/ThemeProvider';
|
|
3
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAG7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AAGtC,cAAc,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dryanovski/react-native-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Collection of reusable React Native components for building mobile applications.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { forwardRef, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import type { ViewRef } from '../../types/general.types';
|
|
4
|
+
import { AccordionCtx, type AccordionContextValue } from './AccordionContext';
|
|
5
|
+
import type { AccordionProps } from './type';
|
|
6
|
+
|
|
7
|
+
export const Accordion = forwardRef<ViewRef, AccordionProps>((props, ref) => {
|
|
8
|
+
const {
|
|
9
|
+
children,
|
|
10
|
+
style,
|
|
11
|
+
singleExpand = true,
|
|
12
|
+
defaultExpandedIndices = [],
|
|
13
|
+
animation,
|
|
14
|
+
} = props;
|
|
15
|
+
|
|
16
|
+
const [expandedIndices, setExpandedIndices] = useState<Set<number>>(
|
|
17
|
+
new Set(defaultExpandedIndices)
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const toggleItem = useCallback(
|
|
21
|
+
(index: number) => {
|
|
22
|
+
setExpandedIndices((prev) => {
|
|
23
|
+
const newSet = new Set(prev);
|
|
24
|
+
|
|
25
|
+
if (singleExpand) {
|
|
26
|
+
// Single expand mode: only one item can be open at a time
|
|
27
|
+
if (newSet.has(index)) {
|
|
28
|
+
// If clicking the currently open item, close it
|
|
29
|
+
newSet.delete(index);
|
|
30
|
+
} else {
|
|
31
|
+
// Close all others and open this one
|
|
32
|
+
newSet.clear();
|
|
33
|
+
newSet.add(index);
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
// Multiple expand mode: toggle the clicked item
|
|
37
|
+
if (newSet.has(index)) {
|
|
38
|
+
newSet.delete(index);
|
|
39
|
+
} else {
|
|
40
|
+
newSet.add(index);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return newSet;
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
[singleExpand]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const isItemExpanded = useCallback(
|
|
51
|
+
(index: number) => expandedIndices.has(index),
|
|
52
|
+
[expandedIndices]
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const contextValue = useMemo<AccordionContextValue>(
|
|
56
|
+
() => ({
|
|
57
|
+
expandedIndices,
|
|
58
|
+
toggleItem,
|
|
59
|
+
isItemExpanded,
|
|
60
|
+
singleExpand,
|
|
61
|
+
animationConfig: animation,
|
|
62
|
+
}),
|
|
63
|
+
[expandedIndices, toggleItem, isItemExpanded, singleExpand, animation]
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<AccordionCtx.Provider value={contextValue}>
|
|
68
|
+
<View ref={ref} style={style}>
|
|
69
|
+
{children}
|
|
70
|
+
</View>
|
|
71
|
+
</AccordionCtx.Provider>
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
Accordion.displayName = 'Accordion';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AnimationConfig } from '../Collapse/types';
|
|
3
|
+
|
|
4
|
+
export type AccordionContextValue = {
|
|
5
|
+
expandedIndices: Set<number>;
|
|
6
|
+
toggleItem: (index: number) => void;
|
|
7
|
+
isItemExpanded: (index: number) => boolean;
|
|
8
|
+
singleExpand: boolean;
|
|
9
|
+
animationConfig?: AnimationConfig;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const AccordionCtx = React.createContext<
|
|
13
|
+
AccordionContextValue | undefined
|
|
14
|
+
>(undefined);
|
|
15
|
+
|
|
16
|
+
export const useAccordionContext = () => {
|
|
17
|
+
const context = React.useContext(AccordionCtx);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error('AccordionItem must be used within an Accordion component');
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { forwardRef, useCallback, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Text,
|
|
4
|
+
TouchableOpacity,
|
|
5
|
+
View,
|
|
6
|
+
type GestureResponderEvent,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import type { ViewRef } from '../../types/general.types';
|
|
9
|
+
import { Collapse } from '../Collapse';
|
|
10
|
+
import { useAccordionContext } from './AccordionContext';
|
|
11
|
+
import type { AccordionItemProps } from './type';
|
|
12
|
+
|
|
13
|
+
export let itemIndexCounter = 0;
|
|
14
|
+
|
|
15
|
+
export const AccordionItem = forwardRef<ViewRef, AccordionItemProps>(
|
|
16
|
+
(props, ref) => {
|
|
17
|
+
const {
|
|
18
|
+
children,
|
|
19
|
+
title,
|
|
20
|
+
onPress,
|
|
21
|
+
isExpanded: externalIsExpanded,
|
|
22
|
+
style,
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
const { toggleItem, isItemExpanded, animationConfig } =
|
|
26
|
+
useAccordionContext();
|
|
27
|
+
|
|
28
|
+
// Assign a unique index to this item
|
|
29
|
+
const itemIndex = useMemo(() => itemIndexCounter++, []);
|
|
30
|
+
|
|
31
|
+
// Use external isExpanded if provided, otherwise use context state
|
|
32
|
+
const isExpanded =
|
|
33
|
+
externalIsExpanded !== undefined
|
|
34
|
+
? externalIsExpanded
|
|
35
|
+
: isItemExpanded(itemIndex);
|
|
36
|
+
|
|
37
|
+
const handlePress = useCallback(
|
|
38
|
+
(event: GestureResponderEvent) => {
|
|
39
|
+
if (onPress) {
|
|
40
|
+
onPress(event);
|
|
41
|
+
}
|
|
42
|
+
toggleItem(itemIndex);
|
|
43
|
+
},
|
|
44
|
+
[onPress, toggleItem, itemIndex]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<View ref={ref} style={style}>
|
|
49
|
+
<TouchableOpacity onPress={handlePress}>
|
|
50
|
+
<Text>{title}</Text>
|
|
51
|
+
</TouchableOpacity>
|
|
52
|
+
<Collapse isExpanded={isExpanded} animationConfig={animationConfig}>
|
|
53
|
+
{children}
|
|
54
|
+
</Collapse>
|
|
55
|
+
</View>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
AccordionItem.displayName = 'AccordionItem';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { StyleProp, TouchableOpacityProps, ViewStyle } from 'react-native';
|
|
2
|
+
import type { AnimationConfig } from '../Collapse/types';
|
|
3
|
+
|
|
4
|
+
export type AccordionProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Style for the accordion component.
|
|
7
|
+
* Optional.
|
|
8
|
+
*/
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Content of the accordion (AccordionItems).
|
|
13
|
+
*/
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Whether only one item can be expanded at a time.
|
|
18
|
+
* If true, expanding one item will collapse all others.
|
|
19
|
+
* If false, multiple items can be expanded simultaneously.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
singleExpand?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Initially expanded item indices.
|
|
26
|
+
* Optional.
|
|
27
|
+
*/
|
|
28
|
+
defaultExpandedIndices?: number[];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Animation configuration for expanding/collapsing items.
|
|
32
|
+
* @default { type: 'timing', duration: 100 }
|
|
33
|
+
*/
|
|
34
|
+
animation?: AnimationConfig;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type AccordionItemProps = {
|
|
38
|
+
/**
|
|
39
|
+
* Style for the accordion item component.
|
|
40
|
+
* Optional.
|
|
41
|
+
*/
|
|
42
|
+
style?: StyleProp<ViewStyle>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Content of the accordion item.
|
|
46
|
+
*/
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Title of the accordion item.
|
|
51
|
+
*/
|
|
52
|
+
title: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Function to be called when the accordion item is pressed.
|
|
56
|
+
*/
|
|
57
|
+
onPress?: TouchableOpacityProps['onPress'];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether the accordion item is expanded.
|
|
61
|
+
* This is controlled internally by the Accordion context.
|
|
62
|
+
* Optional - for external control.
|
|
63
|
+
*/
|
|
64
|
+
isExpanded?: boolean;
|
|
65
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
2
|
import { Text, TouchableOpacity } from 'react-native';
|
|
3
3
|
import Styles from './style';
|
|
4
4
|
import type {
|
|
@@ -8,8 +8,6 @@ import type {
|
|
|
8
8
|
ButtonVariant,
|
|
9
9
|
} from './types';
|
|
10
10
|
|
|
11
|
-
export type ButtonBaseRef = ComponentRef<typeof Button>;
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* A customizable button component that supports different variants and sizes.
|
|
15
13
|
* @return A TouchableOpacity button with text.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import { Button
|
|
3
|
-
import type { ButtonBaseProps } from './types';
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
import type { ButtonBaseProps, ButtonBaseRef } from './types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A button component styled for dangerous actions, such as deletions.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import { Button
|
|
3
|
-
import type { ButtonBaseProps } from './types';
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
import type { ButtonBaseProps, ButtonBaseRef } from './types';
|
|
4
4
|
|
|
5
5
|
export const GhostButton = forwardRef<ButtonBaseRef, ButtonBaseProps>(
|
|
6
6
|
(props, ref) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import { Button
|
|
3
|
-
import type { ButtonBaseProps } from './types';
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
import type { ButtonBaseProps, ButtonBaseRef } from './types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A button component styled for primary actions.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import { Button
|
|
3
|
-
import type { ButtonBaseProps } from './types';
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
import type { ButtonBaseProps, ButtonBaseRef } from './types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A button component styled for secondary actions.
|
|
@@ -6,14 +6,26 @@ import type {
|
|
|
6
6
|
TouchableOpacityProps,
|
|
7
7
|
ViewStyle,
|
|
8
8
|
} from 'react-native';
|
|
9
|
+
import type Button from './Button';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Ref type for the Button component
|
|
12
13
|
*/
|
|
13
14
|
export type ButtonRef = ComponentRef<typeof TouchableOpacity>;
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The root ref type for the Button component
|
|
18
|
+
*/
|
|
19
|
+
export type ButtonBaseRef = ComponentRef<typeof Button>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The variant types for the Button component
|
|
23
|
+
*/
|
|
15
24
|
export type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';
|
|
16
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Button size types
|
|
28
|
+
*/
|
|
17
29
|
export type ButtonSize = 'small' | 'medium' | 'large';
|
|
18
30
|
|
|
19
31
|
export interface ButtonBaseProps extends Omit<TouchableOpacityProps, 'style'> {
|