@idealyst/components 1.0.98 → 1.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/package.json +4 -4
- package/src/Accordion/Accordion.native.tsx +15 -0
- package/src/Accordion/Accordion.styles.tsx +17 -0
- package/src/Accordion/Accordion.web.tsx +15 -0
- package/src/Accordion/types.ts +2 -1
- package/src/Button/Button.native.tsx +55 -2
- package/src/Button/Button.styles.tsx +22 -0
- package/src/Button/Button.web.tsx +6 -2
- package/src/Button/types.ts +15 -0
- package/src/Card/Card.native.tsx +18 -5
- package/src/Card/Card.styles.tsx +123 -131
- package/src/Card/Card.web.tsx +17 -4
- package/src/Card/types.ts +3 -8
- package/src/Checkbox/Checkbox.native.tsx +7 -0
- package/src/Checkbox/Checkbox.styles.tsx +11 -0
- package/src/Checkbox/Checkbox.web.tsx +7 -0
- package/src/Checkbox/types.ts +2 -1
- package/src/Input/Input.native.tsx +7 -0
- package/src/Input/Input.styles.tsx +9 -0
- package/src/Input/Input.web.tsx +7 -0
- package/src/Input/types.ts +2 -1
- package/src/List/List.native.tsx +15 -0
- package/src/List/List.styles.tsx +17 -0
- package/src/List/List.web.tsx +15 -0
- package/src/List/types.ts +2 -1
- package/src/Pressable/Pressable.native.tsx +13 -1
- package/src/Pressable/Pressable.styles.tsx +24 -0
- package/src/Pressable/Pressable.web.tsx +24 -6
- package/src/Pressable/types.ts +3 -2
- package/src/RadioButton/RadioButton.native.tsx +7 -0
- package/src/RadioButton/RadioButton.styles.tsx +9 -0
- package/src/RadioButton/RadioButton.web.tsx +7 -0
- package/src/RadioButton/types.ts +2 -1
- package/src/Screen/Screen.native.tsx +25 -12
- package/src/Screen/Screen.styles.tsx +28 -16
- package/src/Screen/Screen.web.tsx +16 -3
- package/src/Screen/types.ts +4 -8
- package/src/Select/Select.native.tsx +7 -0
- package/src/Select/Select.styles.tsx +11 -0
- package/src/Select/Select.web.tsx +7 -0
- package/src/Select/types.ts +2 -1
- package/src/Slider/Slider.native.tsx +7 -0
- package/src/Slider/Slider.styles.tsx +11 -0
- package/src/Slider/Slider.web.tsx +7 -0
- package/src/Slider/types.ts +2 -1
- package/src/Switch/Switch.native.tsx +7 -0
- package/src/Switch/Switch.styles.tsx +11 -0
- package/src/Switch/Switch.web.tsx +7 -0
- package/src/Switch/types.ts +2 -1
- package/src/TabBar/TabBar.native.tsx +19 -1
- package/src/TabBar/TabBar.styles.tsx +17 -0
- package/src/TabBar/TabBar.web.tsx +20 -1
- package/src/TabBar/types.ts +2 -1
- package/src/Table/Table.native.tsx +15 -0
- package/src/Table/Table.styles.tsx +27 -0
- package/src/Table/Table.web.tsx +15 -0
- package/src/Table/types.ts +2 -1
- package/src/Text/Text.native.tsx +14 -3
- package/src/Text/Text.styles.tsx +36 -12
- package/src/Text/Text.web.tsx +15 -4
- package/src/Text/types.ts +15 -4
- package/src/TextArea/TextArea.native.tsx +7 -0
- package/src/TextArea/TextArea.styles.tsx +11 -0
- package/src/TextArea/TextArea.web.tsx +7 -0
- package/src/TextArea/types.ts +2 -1
- package/src/View/View.native.tsx +35 -12
- package/src/View/View.styles.tsx +78 -75
- package/src/View/View.web.tsx +18 -9
- package/src/View/types.ts +8 -23
- package/src/examples/AccordionExamples.tsx +32 -32
- package/src/examples/AlertExamples.tsx +42 -42
- package/src/examples/AvatarExamples.tsx +18 -18
- package/src/examples/BadgeExamples.tsx +30 -30
- package/src/examples/BreadcrumbExamples.tsx +64 -64
- package/src/examples/ButtonExamples.tsx +128 -16
- package/src/examples/CardExamples.tsx +28 -28
- package/src/examples/CheckboxExamples.tsx +25 -25
- package/src/examples/ChipExamples.tsx +17 -17
- package/src/examples/DialogExamples.tsx +17 -17
- package/src/examples/DividerExamples.tsx +21 -21
- package/src/examples/IconExamples.tsx +113 -113
- package/src/examples/ImageExamples.tsx +34 -34
- package/src/examples/InputExamples.tsx +20 -20
- package/src/examples/LinkExamples.tsx +23 -23
- package/src/examples/ListExamples.tsx +42 -42
- package/src/examples/MenuExamples.tsx +15 -15
- package/src/examples/PopoverExamples.tsx +23 -23
- package/src/examples/ProgressExamples.tsx +41 -41
- package/src/examples/RadioButtonExamples.tsx +21 -21
- package/src/examples/SVGImageExamples.tsx +25 -25
- package/src/examples/ScreenExamples.tsx +41 -41
- package/src/examples/SelectExamples.tsx +59 -59
- package/src/examples/SkeletonExamples.tsx +30 -30
- package/src/examples/SliderExamples.tsx +54 -54
- package/src/examples/SwitchExamples.tsx +20 -20
- package/src/examples/TabBarExamples.tsx +26 -26
- package/src/examples/TableExamples.tsx +36 -36
- package/src/examples/TextAreaExamples.tsx +25 -25
- package/src/examples/TextExamples.tsx +61 -66
- package/src/examples/ThemeExtensionExamples.tsx +12 -12
- package/src/examples/TooltipExamples.tsx +21 -21
- package/src/examples/VideoExamples.tsx +28 -28
- package/src/examples/ViewExamples.tsx +59 -59
- package/src/index.ts +4 -0
- package/src/utils/buildViewStyleVariants.ts +148 -0
- package/src/utils/viewStyleProps.ts +63 -0
package/src/Card/Card.web.tsx
CHANGED
|
@@ -6,13 +6,20 @@ import useMergeRefs from '../hooks/useMergeRefs';
|
|
|
6
6
|
|
|
7
7
|
const Card = forwardRef<HTMLDivElement | HTMLButtonElement, CardProps>(({
|
|
8
8
|
children,
|
|
9
|
-
type = '
|
|
10
|
-
padding = 'md',
|
|
9
|
+
type = 'elevated',
|
|
11
10
|
radius = 'md',
|
|
12
11
|
intent,
|
|
13
12
|
clickable = false,
|
|
14
13
|
onPress,
|
|
15
14
|
disabled = false,
|
|
15
|
+
// Spacing variants from ContainerStyleProps
|
|
16
|
+
gap,
|
|
17
|
+
padding,
|
|
18
|
+
paddingVertical,
|
|
19
|
+
paddingHorizontal,
|
|
20
|
+
margin,
|
|
21
|
+
marginVertical,
|
|
22
|
+
marginHorizontal,
|
|
16
23
|
style,
|
|
17
24
|
testID,
|
|
18
25
|
accessibilityLabel,
|
|
@@ -28,9 +35,15 @@ const Card = forwardRef<HTMLDivElement | HTMLButtonElement, CardProps>(({
|
|
|
28
35
|
clickable,
|
|
29
36
|
radius,
|
|
30
37
|
type,
|
|
31
|
-
padding,
|
|
32
38
|
intent,
|
|
33
39
|
disabled,
|
|
40
|
+
gap,
|
|
41
|
+
padding,
|
|
42
|
+
paddingVertical,
|
|
43
|
+
paddingHorizontal,
|
|
44
|
+
margin,
|
|
45
|
+
marginVertical,
|
|
46
|
+
marginHorizontal,
|
|
34
47
|
});
|
|
35
48
|
|
|
36
49
|
// Generate web props
|
|
@@ -58,4 +71,4 @@ const Card = forwardRef<HTMLDivElement | HTMLButtonElement, CardProps>(({
|
|
|
58
71
|
|
|
59
72
|
Card.displayName = 'Card';
|
|
60
73
|
|
|
61
|
-
export default Card;
|
|
74
|
+
export default Card;
|
package/src/Card/types.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Intent, Size } from '@idealyst/theme';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import { ContainerStyleProps } from '../utils/viewStyleProps';
|
|
4
5
|
|
|
5
6
|
// Component-specific type aliases for future extensibility
|
|
6
7
|
export type CardIntentVariant = Intent;
|
|
7
8
|
export type CardType = 'default' | 'outlined' | 'elevated' | 'filled';
|
|
8
|
-
export type CardPaddingVariant = 'none' | Size;
|
|
9
9
|
export type CardRadiusVariant = 'none' | Size;
|
|
10
10
|
|
|
11
|
-
export interface CardProps {
|
|
11
|
+
export interface CardProps extends ContainerStyleProps {
|
|
12
12
|
/**
|
|
13
13
|
* The content to display inside the card
|
|
14
14
|
*/
|
|
@@ -19,11 +19,6 @@ export interface CardProps {
|
|
|
19
19
|
*/
|
|
20
20
|
type?: CardType;
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* The padding size inside the card
|
|
24
|
-
*/
|
|
25
|
-
padding?: CardPaddingVariant;
|
|
26
|
-
|
|
27
22
|
/**
|
|
28
23
|
* The border radius of the card
|
|
29
24
|
*/
|
|
@@ -63,4 +58,4 @@ export interface CardProps {
|
|
|
63
58
|
* Accessibility label
|
|
64
59
|
*/
|
|
65
60
|
accessibilityLabel?: string;
|
|
66
|
-
}
|
|
61
|
+
}
|
|
@@ -14,6 +14,10 @@ const Checkbox = forwardRef<View, CheckboxProps>(({
|
|
|
14
14
|
variant = 'default',
|
|
15
15
|
label,
|
|
16
16
|
children,
|
|
17
|
+
// Spacing variants from FormInputStyleProps
|
|
18
|
+
margin,
|
|
19
|
+
marginVertical,
|
|
20
|
+
marginHorizontal,
|
|
17
21
|
style,
|
|
18
22
|
testID,
|
|
19
23
|
accessibilityLabel,
|
|
@@ -43,6 +47,9 @@ const Checkbox = forwardRef<View, CheckboxProps>(({
|
|
|
43
47
|
disabled,
|
|
44
48
|
visible: internalChecked || indeterminate,
|
|
45
49
|
error: !!error,
|
|
50
|
+
margin,
|
|
51
|
+
marginVertical,
|
|
52
|
+
marginHorizontal,
|
|
46
53
|
});
|
|
47
54
|
|
|
48
55
|
const labelContent = children || label;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
2
|
import { Theme, StylesheetStyles, Intent, Size} from '@idealyst/theme';
|
|
3
|
+
import {
|
|
4
|
+
buildMarginVariants,
|
|
5
|
+
buildMarginVerticalVariants,
|
|
6
|
+
buildMarginHorizontalVariants,
|
|
7
|
+
} from '../utils/buildViewStyleVariants';
|
|
3
8
|
|
|
4
9
|
type CheckboxSize = Size;
|
|
5
10
|
type CheckboxIntent = Intent | 'info';
|
|
@@ -187,6 +192,12 @@ export const checkboxStyles = StyleSheet.create((theme: Theme) => {
|
|
|
187
192
|
wrapper: {
|
|
188
193
|
flexDirection: 'column',
|
|
189
194
|
gap: 4,
|
|
195
|
+
variants: {
|
|
196
|
+
// Spacing variants from FormInputStyleProps
|
|
197
|
+
margin: buildMarginVariants(theme),
|
|
198
|
+
marginVertical: buildMarginVerticalVariants(theme),
|
|
199
|
+
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
200
|
+
},
|
|
190
201
|
_web: {
|
|
191
202
|
display: 'flex',
|
|
192
203
|
flexDirection: 'column',
|
|
@@ -16,6 +16,10 @@ const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(({
|
|
|
16
16
|
variant = 'default',
|
|
17
17
|
label,
|
|
18
18
|
children,
|
|
19
|
+
// Spacing variants from FormInputStyleProps
|
|
20
|
+
margin,
|
|
21
|
+
marginVertical,
|
|
22
|
+
marginHorizontal,
|
|
19
23
|
style,
|
|
20
24
|
testID,
|
|
21
25
|
accessibilityLabel,
|
|
@@ -45,6 +49,9 @@ const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(({
|
|
|
45
49
|
disabled,
|
|
46
50
|
visible: internalChecked || indeterminate,
|
|
47
51
|
error: Boolean(error),
|
|
52
|
+
margin,
|
|
53
|
+
marginVertical,
|
|
54
|
+
marginHorizontal,
|
|
48
55
|
});
|
|
49
56
|
|
|
50
57
|
// Create style arrays
|
package/src/Checkbox/types.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Intent, Size } from '@idealyst/theme';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import { FormInputStyleProps } from '../utils/viewStyleProps';
|
|
4
5
|
|
|
5
6
|
// Component-specific type aliases for future extensibility
|
|
6
7
|
export type CheckboxIntentVariant = Intent;
|
|
7
8
|
export type CheckboxSizeVariant = Size;
|
|
8
9
|
export type CheckboxVariant = 'default' | 'outlined';
|
|
9
10
|
|
|
10
|
-
export interface CheckboxProps {
|
|
11
|
+
export interface CheckboxProps extends FormInputStyleProps {
|
|
11
12
|
/**
|
|
12
13
|
* Whether the checkbox is checked
|
|
13
14
|
*/
|
|
@@ -21,6 +21,10 @@ const Input = React.forwardRef<TextInput, InputProps>(({
|
|
|
21
21
|
size = 'md',
|
|
22
22
|
type = 'outlined',
|
|
23
23
|
hasError = false,
|
|
24
|
+
// Spacing variants from FormInputStyleProps
|
|
25
|
+
margin,
|
|
26
|
+
marginVertical,
|
|
27
|
+
marginHorizontal,
|
|
24
28
|
style,
|
|
25
29
|
testID,
|
|
26
30
|
}, ref) => {
|
|
@@ -75,6 +79,9 @@ const Input = React.forwardRef<TextInput, InputProps>(({
|
|
|
75
79
|
focused: isFocused,
|
|
76
80
|
hasError,
|
|
77
81
|
disabled,
|
|
82
|
+
margin,
|
|
83
|
+
marginVertical,
|
|
84
|
+
marginHorizontal,
|
|
78
85
|
});
|
|
79
86
|
|
|
80
87
|
// Helper to render left icon
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
2
|
import { Theme, Size, CompoundVariants} from '@idealyst/theme';
|
|
3
3
|
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import {
|
|
5
|
+
buildMarginVariants,
|
|
6
|
+
buildMarginVerticalVariants,
|
|
7
|
+
buildMarginHorizontalVariants,
|
|
8
|
+
} from '../utils/buildViewStyleVariants';
|
|
4
9
|
import { InputSize, InputType } from './types';
|
|
5
10
|
|
|
6
11
|
|
|
@@ -153,6 +158,10 @@ export const inputStyles = StyleSheet.create((theme: Theme) => {
|
|
|
153
158
|
},
|
|
154
159
|
},
|
|
155
160
|
},
|
|
161
|
+
// Spacing variants from FormInputStyleProps
|
|
162
|
+
margin: buildMarginVariants(theme),
|
|
163
|
+
marginVertical: buildMarginVerticalVariants(theme),
|
|
164
|
+
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
156
165
|
},
|
|
157
166
|
compoundVariants: createFocusedCompoundVariants(theme),
|
|
158
167
|
_web: {
|
package/src/Input/Input.web.tsx
CHANGED
|
@@ -23,6 +23,10 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(({
|
|
|
23
23
|
size = 'md',
|
|
24
24
|
type = 'outlined',
|
|
25
25
|
hasError = false,
|
|
26
|
+
// Spacing variants from FormInputStyleProps
|
|
27
|
+
margin,
|
|
28
|
+
marginVertical,
|
|
29
|
+
marginHorizontal,
|
|
26
30
|
style,
|
|
27
31
|
testID,
|
|
28
32
|
}, ref) => {
|
|
@@ -95,6 +99,9 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(({
|
|
|
95
99
|
focused: isFocused,
|
|
96
100
|
hasError,
|
|
97
101
|
disabled,
|
|
102
|
+
margin,
|
|
103
|
+
marginVertical,
|
|
104
|
+
marginHorizontal,
|
|
98
105
|
});
|
|
99
106
|
|
|
100
107
|
// Get web props for all styled elements
|
package/src/Input/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
2
|
import type { IconName } from '../Icon/icon-types';
|
|
3
3
|
import { Intent, Size } from '@idealyst/theme';
|
|
4
|
+
import { FormInputStyleProps } from '../utils/viewStyleProps';
|
|
4
5
|
|
|
5
6
|
// Component-specific type aliases for future extensibility
|
|
6
7
|
export type InputIntent = Intent;
|
|
@@ -8,7 +9,7 @@ export type InputSize = Size;
|
|
|
8
9
|
export type InputType = 'outlined' | 'filled' | 'bare';
|
|
9
10
|
export type InputInputType = 'text' | 'email' | 'password' | 'number';
|
|
10
11
|
|
|
11
|
-
export interface InputProps {
|
|
12
|
+
export interface InputProps extends FormInputStyleProps {
|
|
12
13
|
/**
|
|
13
14
|
* The current value of the input
|
|
14
15
|
*/
|
package/src/List/List.native.tsx
CHANGED
|
@@ -8,6 +8,14 @@ const List = forwardRef<View, ListProps>(({
|
|
|
8
8
|
children,
|
|
9
9
|
type = 'default',
|
|
10
10
|
size = 'md',
|
|
11
|
+
// Spacing variants from ContainerStyleProps
|
|
12
|
+
gap,
|
|
13
|
+
padding,
|
|
14
|
+
paddingVertical,
|
|
15
|
+
paddingHorizontal,
|
|
16
|
+
margin,
|
|
17
|
+
marginVertical,
|
|
18
|
+
marginHorizontal,
|
|
11
19
|
style,
|
|
12
20
|
testID,
|
|
13
21
|
scrollable = false,
|
|
@@ -17,6 +25,13 @@ const List = forwardRef<View, ListProps>(({
|
|
|
17
25
|
listStyles.useVariants({
|
|
18
26
|
size,
|
|
19
27
|
scrollable,
|
|
28
|
+
gap,
|
|
29
|
+
padding,
|
|
30
|
+
paddingVertical,
|
|
31
|
+
paddingHorizontal,
|
|
32
|
+
margin,
|
|
33
|
+
marginVertical,
|
|
34
|
+
marginHorizontal,
|
|
20
35
|
});
|
|
21
36
|
|
|
22
37
|
const containerStyle = [
|
package/src/List/List.styles.tsx
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
2
|
import { Theme, CompoundVariants } from '@idealyst/theme';
|
|
3
3
|
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import {
|
|
5
|
+
buildGapVariants,
|
|
6
|
+
buildPaddingVariants,
|
|
7
|
+
buildPaddingVerticalVariants,
|
|
8
|
+
buildPaddingHorizontalVariants,
|
|
9
|
+
buildMarginVariants,
|
|
10
|
+
buildMarginVerticalVariants,
|
|
11
|
+
buildMarginHorizontalVariants,
|
|
12
|
+
} from '../utils/buildViewStyleVariants';
|
|
4
13
|
import { ListSizeVariant, ListType } from './types';
|
|
5
14
|
|
|
6
15
|
type ListVariants = {
|
|
@@ -95,6 +104,14 @@ export const listStyles = StyleSheet.create((theme: Theme) => {
|
|
|
95
104
|
},
|
|
96
105
|
false: {},
|
|
97
106
|
},
|
|
107
|
+
// Spacing variants from ContainerStyleProps
|
|
108
|
+
gap: buildGapVariants(theme),
|
|
109
|
+
padding: buildPaddingVariants(theme),
|
|
110
|
+
paddingVertical: buildPaddingVerticalVariants(theme),
|
|
111
|
+
paddingHorizontal: buildPaddingHorizontalVariants(theme),
|
|
112
|
+
margin: buildMarginVariants(theme),
|
|
113
|
+
marginVertical: buildMarginVerticalVariants(theme),
|
|
114
|
+
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
98
115
|
},
|
|
99
116
|
},
|
|
100
117
|
item: {
|
package/src/List/List.web.tsx
CHANGED
|
@@ -8,6 +8,14 @@ const List: React.FC<ListProps> = ({
|
|
|
8
8
|
children,
|
|
9
9
|
type = 'default',
|
|
10
10
|
size = 'md',
|
|
11
|
+
// Spacing variants from ContainerStyleProps
|
|
12
|
+
gap,
|
|
13
|
+
padding,
|
|
14
|
+
paddingVertical,
|
|
15
|
+
paddingHorizontal,
|
|
16
|
+
margin,
|
|
17
|
+
marginVertical,
|
|
18
|
+
marginHorizontal,
|
|
11
19
|
style,
|
|
12
20
|
testID,
|
|
13
21
|
scrollable = false,
|
|
@@ -17,6 +25,13 @@ const List: React.FC<ListProps> = ({
|
|
|
17
25
|
listStyles.useVariants({
|
|
18
26
|
size,
|
|
19
27
|
scrollable,
|
|
28
|
+
gap,
|
|
29
|
+
padding,
|
|
30
|
+
paddingVertical,
|
|
31
|
+
paddingHorizontal,
|
|
32
|
+
margin,
|
|
33
|
+
marginVertical,
|
|
34
|
+
marginHorizontal,
|
|
20
35
|
});
|
|
21
36
|
|
|
22
37
|
const containerStyle = [
|
package/src/List/types.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import type { IconName } from '../Icon/icon-types';
|
|
4
4
|
import { Size } from '@idealyst/theme';
|
|
5
|
+
import { ContainerStyleProps } from '../utils/viewStyleProps';
|
|
5
6
|
|
|
6
7
|
// Component-specific type aliases for future extensibility
|
|
7
8
|
export type ListSizeVariant = Size;
|
|
@@ -23,7 +24,7 @@ export interface ListItemProps {
|
|
|
23
24
|
testID?: string;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export interface ListProps {
|
|
27
|
+
export interface ListProps extends ContainerStyleProps {
|
|
27
28
|
children: ReactNode;
|
|
28
29
|
type?: ListType;
|
|
29
30
|
size?: ListSizeVariant;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import { TouchableWithoutFeedback, View } from 'react-native';
|
|
3
3
|
import { PressableProps } from './types';
|
|
4
|
+
import { pressableStyles } from './Pressable.styles';
|
|
4
5
|
|
|
5
6
|
const Pressable = forwardRef<View, PressableProps>(({
|
|
6
7
|
children,
|
|
@@ -8,11 +9,22 @@ const Pressable = forwardRef<View, PressableProps>(({
|
|
|
8
9
|
onPressIn,
|
|
9
10
|
onPressOut,
|
|
10
11
|
disabled = false,
|
|
12
|
+
// Spacing variants from PressableSpacingStyleProps
|
|
13
|
+
padding,
|
|
14
|
+
paddingVertical,
|
|
15
|
+
paddingHorizontal,
|
|
11
16
|
style,
|
|
12
17
|
testID,
|
|
13
18
|
accessibilityLabel,
|
|
14
19
|
accessibilityRole,
|
|
15
20
|
}, ref) => {
|
|
21
|
+
// Apply spacing variants
|
|
22
|
+
pressableStyles.useVariants({
|
|
23
|
+
padding,
|
|
24
|
+
paddingVertical,
|
|
25
|
+
paddingHorizontal,
|
|
26
|
+
});
|
|
27
|
+
|
|
16
28
|
return (
|
|
17
29
|
<TouchableWithoutFeedback
|
|
18
30
|
onPress={disabled ? undefined : onPress}
|
|
@@ -22,7 +34,7 @@ const Pressable = forwardRef<View, PressableProps>(({
|
|
|
22
34
|
testID={testID}
|
|
23
35
|
accessibilityLabel={accessibilityLabel}
|
|
24
36
|
>
|
|
25
|
-
<View ref={ref} style={style}>
|
|
37
|
+
<View ref={ref} style={[pressableStyles.pressable, style]}>
|
|
26
38
|
{children}
|
|
27
39
|
</View>
|
|
28
40
|
</TouchableWithoutFeedback>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { Theme } from '@idealyst/theme';
|
|
3
|
+
import {
|
|
4
|
+
buildPaddingVariants,
|
|
5
|
+
buildPaddingVerticalVariants,
|
|
6
|
+
buildPaddingHorizontalVariants,
|
|
7
|
+
} from '../utils/buildViewStyleVariants';
|
|
8
|
+
|
|
9
|
+
const createPressableStyles = (theme: Theme) => {
|
|
10
|
+
return {
|
|
11
|
+
variants: {
|
|
12
|
+
// Spacing variants from PressableSpacingStyleProps
|
|
13
|
+
padding: buildPaddingVariants(theme),
|
|
14
|
+
paddingVertical: buildPaddingVerticalVariants(theme),
|
|
15
|
+
paddingHorizontal: buildPaddingHorizontalVariants(theme),
|
|
16
|
+
},
|
|
17
|
+
} as const;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const pressableStyles = StyleSheet.create((theme: Theme) => {
|
|
21
|
+
return {
|
|
22
|
+
pressable: createPressableStyles(theme),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { useCallback, useState, forwardRef } from 'react';
|
|
2
|
+
import { getWebProps } from 'react-native-unistyles/web';
|
|
2
3
|
import { PressableProps } from './types';
|
|
4
|
+
import { pressableStyles } from './Pressable.styles';
|
|
5
|
+
import useMergeRefs from '../hooks/useMergeRefs';
|
|
3
6
|
|
|
4
7
|
const Pressable = forwardRef<HTMLDivElement, PressableProps>(({
|
|
5
8
|
children,
|
|
@@ -7,6 +10,10 @@ const Pressable = forwardRef<HTMLDivElement, PressableProps>(({
|
|
|
7
10
|
onPressIn,
|
|
8
11
|
onPressOut,
|
|
9
12
|
disabled = false,
|
|
13
|
+
// Spacing variants from PressableSpacingStyleProps
|
|
14
|
+
padding,
|
|
15
|
+
paddingVertical,
|
|
16
|
+
paddingHorizontal,
|
|
10
17
|
style,
|
|
11
18
|
testID,
|
|
12
19
|
accessibilityLabel,
|
|
@@ -39,6 +46,15 @@ const Pressable = forwardRef<HTMLDivElement, PressableProps>(({
|
|
|
39
46
|
}
|
|
40
47
|
}, [disabled, onPress]);
|
|
41
48
|
|
|
49
|
+
// Apply spacing variants
|
|
50
|
+
pressableStyles.useVariants({
|
|
51
|
+
padding,
|
|
52
|
+
paddingVertical,
|
|
53
|
+
paddingHorizontal,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const webProps = getWebProps([pressableStyles.pressable, style as any]);
|
|
57
|
+
|
|
42
58
|
const baseStyle: React.CSSProperties = {
|
|
43
59
|
cursor: disabled ? 'default' : 'pointer',
|
|
44
60
|
outline: 'none',
|
|
@@ -48,17 +64,19 @@ const Pressable = forwardRef<HTMLDivElement, PressableProps>(({
|
|
|
48
64
|
opacity: disabled ? 0.5 : 1,
|
|
49
65
|
};
|
|
50
66
|
|
|
51
|
-
// Merge
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
// Merge ref from getWebProps with forwarded ref
|
|
68
|
+
const mergedRef = useMergeRefs<HTMLDivElement>(
|
|
69
|
+
ref,
|
|
70
|
+
webProps.ref as React.Ref<HTMLDivElement>
|
|
71
|
+
);
|
|
55
72
|
|
|
56
73
|
return (
|
|
57
74
|
<div
|
|
58
|
-
|
|
75
|
+
{...webProps}
|
|
76
|
+
ref={mergedRef}
|
|
59
77
|
role={accessibilityRole}
|
|
60
78
|
tabIndex={disabled ? -1 : 0}
|
|
61
|
-
style={
|
|
79
|
+
style={{ ...baseStyle, ...webProps.style }}
|
|
62
80
|
onMouseDown={handleMouseDown}
|
|
63
81
|
onMouseUp={handleMouseUp}
|
|
64
82
|
onMouseLeave={handleMouseUp} // Handle mouse leave as press out
|
package/src/Pressable/types.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { PressableSpacingStyleProps } from '../utils/viewStyleProps';
|
|
3
4
|
|
|
4
|
-
export interface PressableProps {
|
|
5
|
+
export interface PressableProps extends PressableSpacingStyleProps {
|
|
5
6
|
/**
|
|
6
7
|
* Content to render inside the pressable area
|
|
7
8
|
*/
|
|
@@ -46,4 +47,4 @@ export interface PressableProps {
|
|
|
46
47
|
* Accessibility role (web)
|
|
47
48
|
*/
|
|
48
49
|
accessibilityRole?: string;
|
|
49
|
-
}
|
|
50
|
+
}
|
|
@@ -13,6 +13,10 @@ const RadioButton = forwardRef<ComponentRef<typeof Pressable>, RadioButtonProps>
|
|
|
13
13
|
label,
|
|
14
14
|
size = 'md',
|
|
15
15
|
intent = 'primary',
|
|
16
|
+
// Spacing variants from FormInputStyleProps
|
|
17
|
+
margin,
|
|
18
|
+
marginVertical,
|
|
19
|
+
marginHorizontal,
|
|
16
20
|
style,
|
|
17
21
|
testID,
|
|
18
22
|
}, ref) => {
|
|
@@ -47,6 +51,9 @@ const RadioButton = forwardRef<ComponentRef<typeof Pressable>, RadioButtonProps>
|
|
|
47
51
|
size,
|
|
48
52
|
checked,
|
|
49
53
|
disabled,
|
|
54
|
+
margin,
|
|
55
|
+
marginVertical,
|
|
56
|
+
marginHorizontal,
|
|
50
57
|
});
|
|
51
58
|
|
|
52
59
|
const dotScale = animatedValue.interpolate({
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
2
|
import { Theme, StylesheetStyles, Intent, Size} from '@idealyst/theme';
|
|
3
3
|
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import {
|
|
5
|
+
buildMarginVariants,
|
|
6
|
+
buildMarginVerticalVariants,
|
|
7
|
+
buildMarginHorizontalVariants,
|
|
8
|
+
} from '../utils/buildViewStyleVariants';
|
|
4
9
|
|
|
5
10
|
type RadioButtonSize = Size;
|
|
6
11
|
type RadioButtonIntent = Intent;
|
|
@@ -124,6 +129,10 @@ export const radioButtonStyles = StyleSheet.create((theme: Theme) => {
|
|
|
124
129
|
size: buildSizeVariants(theme, 'radioButton', (size) => ({
|
|
125
130
|
gap: size.gap,
|
|
126
131
|
})),
|
|
132
|
+
// Spacing variants from FormInputStyleProps
|
|
133
|
+
margin: buildMarginVariants(theme),
|
|
134
|
+
marginVertical: buildMarginVerticalVariants(theme),
|
|
135
|
+
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
127
136
|
} as const,
|
|
128
137
|
},
|
|
129
138
|
radio: createRadioStyles(theme),
|
|
@@ -12,6 +12,10 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
12
12
|
label,
|
|
13
13
|
size = 'md',
|
|
14
14
|
intent = 'primary',
|
|
15
|
+
// Spacing variants from FormInputStyleProps
|
|
16
|
+
margin,
|
|
17
|
+
marginVertical,
|
|
18
|
+
marginHorizontal,
|
|
15
19
|
style,
|
|
16
20
|
testID,
|
|
17
21
|
}) => {
|
|
@@ -35,6 +39,9 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
35
39
|
size,
|
|
36
40
|
checked,
|
|
37
41
|
disabled,
|
|
42
|
+
margin,
|
|
43
|
+
marginVertical,
|
|
44
|
+
marginHorizontal,
|
|
38
45
|
});
|
|
39
46
|
|
|
40
47
|
const containerProps = getWebProps([radioButtonStyles.container, style]);
|
package/src/RadioButton/types.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import { Intent, Size } from '@idealyst/theme';
|
|
4
|
+
import { FormInputStyleProps } from '../utils/viewStyleProps';
|
|
4
5
|
|
|
5
6
|
// Component-specific type aliases for future extensibility
|
|
6
7
|
export type RadioButtonIntentVariant = Intent;
|
|
7
8
|
export type RadioButtonSizeVariant = Size;
|
|
8
9
|
|
|
9
|
-
export interface RadioButtonProps {
|
|
10
|
+
export interface RadioButtonProps extends FormInputStyleProps {
|
|
10
11
|
value: string;
|
|
11
12
|
checked?: boolean;
|
|
12
13
|
onPress?: () => void;
|
|
@@ -6,18 +6,31 @@ import { screenStyles } from './Screen.styles';
|
|
|
6
6
|
const Screen = forwardRef<RNView | RNScrollView, ScreenProps>(({
|
|
7
7
|
children,
|
|
8
8
|
background = 'primary',
|
|
9
|
-
padding = 'md',
|
|
10
9
|
safeArea = true,
|
|
11
10
|
scrollable = true,
|
|
12
11
|
contentInset,
|
|
12
|
+
// Spacing variants from ContainerStyleProps
|
|
13
|
+
gap,
|
|
14
|
+
padding,
|
|
15
|
+
paddingVertical,
|
|
16
|
+
paddingHorizontal,
|
|
17
|
+
margin,
|
|
18
|
+
marginVertical,
|
|
19
|
+
marginHorizontal,
|
|
13
20
|
style,
|
|
14
21
|
testID,
|
|
15
22
|
}, ref) => {
|
|
16
23
|
|
|
17
24
|
screenStyles.useVariants({
|
|
18
25
|
background,
|
|
19
|
-
padding,
|
|
20
26
|
safeArea,
|
|
27
|
+
gap,
|
|
28
|
+
padding,
|
|
29
|
+
paddingVertical,
|
|
30
|
+
paddingHorizontal,
|
|
31
|
+
margin,
|
|
32
|
+
marginVertical,
|
|
33
|
+
marginHorizontal,
|
|
21
34
|
});
|
|
22
35
|
|
|
23
36
|
if (scrollable) {
|
|
@@ -35,15 +48,15 @@ const Screen = forwardRef<RNView | RNScrollView, ScreenProps>(({
|
|
|
35
48
|
} : undefined,
|
|
36
49
|
];
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
return (
|
|
52
|
+
<RNScrollView
|
|
53
|
+
ref={ref as any}
|
|
54
|
+
style={scrollViewStyle}
|
|
55
|
+
contentContainerStyle={contentContainerStyleArray}
|
|
56
|
+
testID={testID}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</RNScrollView>
|
|
47
60
|
);
|
|
48
61
|
}
|
|
49
62
|
|
|
@@ -64,4 +77,4 @@ const Screen = forwardRef<RNView | RNScrollView, ScreenProps>(({
|
|
|
64
77
|
|
|
65
78
|
Screen.displayName = 'Screen';
|
|
66
79
|
|
|
67
|
-
export default Screen;
|
|
80
|
+
export default Screen;
|