react-native-molecules 0.5.0-beta.20 → 0.5.0-beta.22

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.
Files changed (59) hide show
  1. package/components/Card/Card.tsx +1 -1
  2. package/components/Checkbox/CheckboxBase.ios.tsx +9 -16
  3. package/components/Checkbox/CheckboxBase.tsx +11 -18
  4. package/components/DateField/DateField.tsx +4 -3
  5. package/components/DatePicker/DateCalendar.tsx +4 -4
  6. package/components/DatePicker/DatePickerModal.tsx +35 -23
  7. package/components/DatePicker/DatePickerProvider.tsx +8 -2
  8. package/components/DatePicker/context.tsx +2 -1
  9. package/components/DatePicker/index.tsx +1 -0
  10. package/components/DatePickerInline/DatePickerDockedHeader.tsx +11 -7
  11. package/components/DatePickerInline/DatePickerInline.tsx +1 -1
  12. package/components/DatePickerInline/DatePickerInlineBase.tsx +3 -3
  13. package/components/DatePickerInline/DatePickerInlineHeader.tsx +50 -20
  14. package/components/DatePickerInline/DayNames.tsx +13 -10
  15. package/components/DatePickerInline/HeaderItem.tsx +2 -2
  16. package/components/DatePickerInline/Month.tsx +4 -3
  17. package/components/DatePickerInline/MonthPicker.tsx +74 -54
  18. package/components/DatePickerInline/Swiper.native.tsx +2 -2
  19. package/components/DatePickerInline/Swiper.tsx +3 -3
  20. package/components/DatePickerInline/YearPicker.tsx +136 -112
  21. package/components/DatePickerInline/{DatePickerContext.tsx → store.tsx} +7 -3
  22. package/components/DatePickerInline/types.ts +4 -3
  23. package/components/Divider/Divider.tsx +192 -0
  24. package/components/Divider/index.tsx +11 -0
  25. package/components/Drawer/DrawerItemGroup.tsx +3 -7
  26. package/components/IconButton/IconButton.tsx +2 -12
  27. package/components/List/List.tsx +507 -0
  28. package/components/List/context.tsx +28 -0
  29. package/components/List/index.ts +9 -0
  30. package/components/List/types.ts +149 -0
  31. package/components/{ListItem → List}/utils.ts +47 -50
  32. package/components/Menu/Menu.tsx +156 -12
  33. package/components/Menu/index.tsx +11 -7
  34. package/components/Menu/utils.ts +21 -70
  35. package/components/RadioButton/RadioButtonAndroid.tsx +38 -54
  36. package/components/RadioButton/RadioButtonIOS.tsx +2 -16
  37. package/components/Select/Select.tsx +139 -497
  38. package/components/Select/context.tsx +14 -32
  39. package/components/Select/types.ts +44 -53
  40. package/components/Select/utils.ts +15 -47
  41. package/components/Text/textFactory.tsx +17 -5
  42. package/components/TimeField/TimeField.tsx +1 -1
  43. package/components/TimePicker/TimeInput.tsx +2 -7
  44. package/components/TimePicker/TimePickerModal.tsx +15 -15
  45. package/components/TimePicker/utils.ts +0 -4
  46. package/components/TouchableRipple/TouchableRipple.native.tsx +36 -5
  47. package/components/TouchableRipple/TouchableRipple.tsx +53 -19
  48. package/components/TouchableRipple/rippleFromForegroundColor.ts +21 -0
  49. package/package.json +4 -2
  50. package/components/HorizontalDivider/HorizontalDivider.tsx +0 -103
  51. package/components/HorizontalDivider/index.tsx +0 -9
  52. package/components/ListItem/ListItem.tsx +0 -138
  53. package/components/ListItem/ListItemDescription.tsx +0 -25
  54. package/components/ListItem/ListItemTitle.tsx +0 -25
  55. package/components/ListItem/index.tsx +0 -14
  56. package/components/Menu/MenuDivider.tsx +0 -13
  57. package/components/Menu/MenuItem.tsx +0 -128
  58. package/components/VerticalDivider/VerticalDivider.tsx +0 -100
  59. package/components/VerticalDivider/index.tsx +0 -9
@@ -1,11 +1,12 @@
1
1
  import type { MemoExoticComponent } from 'react';
2
2
  import type { ViewStyle } from 'react-native';
3
3
 
4
+ import type { DatePickerLocale } from '../DatePicker/context';
4
5
  import type { CalendarHeaderProps } from './DatePickerInlineHeader';
5
6
  import type { DisableWeekDaysType } from './dateUtils';
6
7
 
7
8
  export interface BaseMonthProps {
8
- locale: undefined | string;
9
+ locale: DatePickerLocale | undefined;
9
10
  scrollMode: 'horizontal' | 'vertical';
10
11
  disableWeekDays?: DisableWeekDaysType;
11
12
  mode: ModeType;
@@ -47,13 +48,13 @@ export type ValidRangeType = {
47
48
  };
48
49
 
49
50
  export type BaseDatePickerProps = {
50
- locale?: string;
51
+ locale?: DatePickerLocale;
51
52
  disableWeekDays?: DisableWeekDaysType;
52
53
  validRange?: ValidRangeType;
53
54
  startYear?: number;
54
55
  endYear?: number;
55
56
  HeaderComponent?: MemoExoticComponent<CalendarHeaderProps | any>;
56
- headerLayout?: 'inline' | 'docked';
57
+ headerLayout?: 'default' | 'docked';
57
58
  monthStyle?: Record<string, any>;
58
59
  showOutsideDays?: boolean;
59
60
 
@@ -0,0 +1,192 @@
1
+ import { memo } from 'react';
2
+ import { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';
3
+ import { StyleSheet } from 'react-native-unistyles';
4
+
5
+ import { getRegisteredComponentStylesWithFallback } from '../../core';
6
+
7
+ export type DividerProps = Omit<ViewProps, 'children'> & {
8
+ /**
9
+ * Line orientation. Defaults to horizontal.
10
+ */
11
+ mode?: 'horizontal' | 'vertical';
12
+ /**
13
+ * Left inset when `mode` is `"horizontal"`.
14
+ */
15
+ leftInset?: number;
16
+ /**
17
+ * Right inset when `mode` is `"horizontal"`.
18
+ */
19
+ rightInset?: number;
20
+ /**
21
+ * Top inset when `mode` is `"vertical"`.
22
+ */
23
+ topInset?: number;
24
+ /**
25
+ * Bottom inset when `mode` is `"vertical"`.
26
+ */
27
+ bottomInset?: number;
28
+ /**
29
+ * Whether the divider stroke should use the bold thickness.
30
+ */
31
+ bold?: boolean;
32
+ /**
33
+ * Margin added perpendicular to the divider line (`marginVertical` for horizontal,
34
+ * `marginHorizontal` for vertical).
35
+ */
36
+ spacing?: number;
37
+ style?: StyleProp<ViewStyle>;
38
+ };
39
+
40
+ export type Props = DividerProps;
41
+
42
+ const DividerHorizontalImpl = memo(function DividerHorizontalImpl({
43
+ leftInset = 0,
44
+ rightInset = 0,
45
+ style,
46
+ bold = false,
47
+ spacing = 8,
48
+ ...rest
49
+ }: Omit<DividerProps, 'mode' | 'topInset' | 'bottomInset'>) {
50
+ horizontalDividerStyles.useVariants({
51
+ isBold: bold,
52
+ });
53
+
54
+ return (
55
+ <View
56
+ {...rest}
57
+ style={
58
+ [
59
+ horizontalDividerStyles.root,
60
+ leftInset ? { marginLeft: leftInset } : undefined,
61
+ rightInset ? { marginRight: rightInset } : undefined,
62
+ spacing ? { marginVertical: spacing } : undefined,
63
+ style,
64
+ ] as StyleProp<ViewStyle>
65
+ }
66
+ />
67
+ );
68
+ });
69
+
70
+ const DividerVerticalImpl = memo(function DividerVerticalImpl({
71
+ topInset = 0,
72
+ bottomInset = 0,
73
+ spacing = 0,
74
+ style,
75
+ bold = false,
76
+ ...rest
77
+ }: Omit<DividerProps, 'mode' | 'leftInset' | 'rightInset'>) {
78
+ verticalDividerStyles.useVariants({
79
+ isBold: bold,
80
+ });
81
+
82
+ return (
83
+ <View
84
+ {...rest}
85
+ style={
86
+ [
87
+ verticalDividerStyles.root,
88
+ style,
89
+ topInset ? { marginTop: topInset } : undefined,
90
+ bottomInset ? { marginBottom: bottomInset } : undefined,
91
+ spacing ? { marginHorizontal: spacing } : undefined,
92
+ ] as StyleProp<ViewStyle>
93
+ }
94
+ />
95
+ );
96
+ });
97
+
98
+ function DividerRoot(props: DividerProps) {
99
+ const mode = props.mode ?? 'horizontal';
100
+
101
+ if (mode === 'vertical') {
102
+ const {
103
+ mode: _m,
104
+ leftInset: _l,
105
+ rightInset: _r,
106
+ topInset,
107
+ bottomInset,
108
+ bold,
109
+ spacing,
110
+ style,
111
+ ...viewRest
112
+ } = props;
113
+
114
+ return (
115
+ <DividerVerticalImpl
116
+ {...viewRest}
117
+ topInset={topInset}
118
+ bottomInset={bottomInset}
119
+ bold={bold}
120
+ spacing={spacing}
121
+ style={style}
122
+ />
123
+ );
124
+ }
125
+
126
+ const {
127
+ mode: _m,
128
+ topInset: _t,
129
+ bottomInset: _b,
130
+ leftInset,
131
+ rightInset,
132
+ bold,
133
+ spacing,
134
+ style,
135
+ ...viewRest
136
+ } = props;
137
+
138
+ return (
139
+ <DividerHorizontalImpl
140
+ {...viewRest}
141
+ leftInset={leftInset}
142
+ rightInset={rightInset}
143
+ bold={bold}
144
+ spacing={spacing}
145
+ style={style}
146
+ />
147
+ );
148
+ }
149
+
150
+ export const Divider = memo(DividerRoot);
151
+
152
+ export const horizontalDividerStylesDefault = StyleSheet.create(theme => ({
153
+ root: {
154
+ height: StyleSheet.hairlineWidth,
155
+ background: theme.colors.outlineVariant,
156
+
157
+ variants: {
158
+ isBold: {
159
+ true: {
160
+ height: 1,
161
+ },
162
+ },
163
+ },
164
+ },
165
+ }));
166
+
167
+ export const verticalDividerStylesDefault = StyleSheet.create(theme => ({
168
+ root: {
169
+ width: StyleSheet.hairlineWidth,
170
+ background: theme.colors.outlineVariant,
171
+
172
+ variants: {
173
+ isBold: {
174
+ true: {
175
+ width: 1,
176
+ },
177
+ },
178
+ },
179
+ },
180
+ }));
181
+
182
+ export const horizontalDividerStyles = getRegisteredComponentStylesWithFallback(
183
+ 'HorizontalDivider',
184
+ horizontalDividerStylesDefault,
185
+ );
186
+
187
+ export const verticalDividerStyles = getRegisteredComponentStylesWithFallback(
188
+ 'VerticalDivider',
189
+ verticalDividerStylesDefault,
190
+ );
191
+
192
+ export default Divider;
@@ -0,0 +1,11 @@
1
+ export {
2
+ Divider,
3
+ horizontalDividerStyles,
4
+ horizontalDividerStylesDefault,
5
+ verticalDividerStyles,
6
+ verticalDividerStylesDefault,
7
+ type DividerProps,
8
+ type Props,
9
+ } from './Divider';
10
+
11
+ export { default } from './Divider';
@@ -3,13 +3,13 @@ import { type TextProps, View, type ViewProps } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
5
5
  import { getRegisteredComponentStylesWithFallback } from '../../core';
6
- import { HorizontalDivider, type HorizontalDividerProps } from '../HorizontalDivider';
6
+ import { Divider, type DividerProps } from '../Divider';
7
7
  import { Text } from '../Text';
8
8
 
9
9
  export type Props = ViewProps & {
10
10
  title?: ReactNode;
11
11
  showDivider?: boolean;
12
- dividerProps?: HorizontalDividerProps;
12
+ dividerProps?: Omit<DividerProps, 'mode'>;
13
13
  titleProps?: TextProps;
14
14
  };
15
15
 
@@ -45,11 +45,7 @@ const DrawerItemGroup = memo(
45
45
  )}
46
46
  </>
47
47
  {children}
48
- <>
49
- {showDivider && (
50
- <HorizontalDivider style={dividerStyle} {...dividerRestProps} />
51
- )}
52
- </>
48
+ <>{showDivider && <Divider style={dividerStyle} {...dividerRestProps} />}</>
53
49
  </View>
54
50
  );
55
51
  },
@@ -1,4 +1,3 @@
1
- import color from 'color';
2
1
  import { forwardRef, memo, useMemo } from 'react';
3
2
  import {
4
3
  type GestureResponderEvent,
@@ -112,13 +111,13 @@ const IconButton = (
112
111
  variant: variant as any,
113
112
  // @ts-ignore // TODO - fix this
114
113
  state,
114
+ // @ts-ignore // TODO - fix this
115
115
  size: typeof size === 'string' && size ? size : undefined,
116
116
  });
117
117
 
118
118
  const {
119
119
  iconColor,
120
120
  iconSize,
121
- rippleColor,
122
121
  containerStyle,
123
122
  accessibilityState,
124
123
  // accessibilityTraits,
@@ -129,18 +128,9 @@ const IconButton = (
129
128
  iconButtonSizeToIconSizeMap[size as keyof typeof iconButtonSizeToIconSizeMap] ??
130
129
  (typeof size === 'number' && size ? (size as number) : undefined);
131
130
 
132
- let _rippleColor: string | undefined;
133
-
134
- try {
135
- _rippleColor = color(_iconColor).alpha(0.12).rgb().string();
136
- } catch (e) {
137
- _rippleColor = undefined;
138
- }
139
-
140
131
  return {
141
132
  iconColor: _iconColor,
142
133
  iconSize: iconSizeInNum,
143
- rippleColor: _rippleColor,
144
134
  containerStyle: [
145
135
  iconSizeInNum
146
136
  ? {
@@ -164,7 +154,7 @@ const IconButton = (
164
154
  borderless
165
155
  centered
166
156
  onPress={onPress}
167
- rippleColor={rippleColor}
157
+ rippleAlpha={0.12}
168
158
  accessibilityLabel={accessibilityLabel}
169
159
  style={containerStyle}
170
160
  // accessibilityTraits={accessibilityTraits}