react-native-molecules 0.5.0-beta.3 → 0.5.0-beta.30
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/components/Accordion/Accordion.tsx +2 -6
- package/components/Accordion/AccordionItem.tsx +16 -12
- package/components/Accordion/AccordionItemContent.tsx +6 -1
- package/components/Accordion/AccordionItemHeader.tsx +1 -1
- package/components/Accordion/utils.ts +6 -0
- package/components/ActivityIndicator/ActivityIndicator.tsx +6 -15
- package/components/Appbar/AppbarBase.tsx +18 -13
- package/components/Button/Button.tsx +211 -264
- package/components/Button/index.tsx +9 -3
- package/components/Button/types.ts +16 -2
- package/components/Button/utils.ts +230 -208
- package/components/Card/Card.tsx +1 -1
- package/components/Checkbox/Checkbox.tsx +125 -88
- package/components/Checkbox/CheckboxBase.ios.tsx +14 -23
- package/components/Checkbox/CheckboxBase.tsx +21 -137
- package/components/Checkbox/context.tsx +14 -0
- package/components/Checkbox/index.tsx +11 -4
- package/components/Checkbox/types.ts +63 -29
- package/components/Checkbox/utils.ts +25 -108
- package/components/Chip/Chip.tsx +41 -52
- package/components/Chip/utils.ts +3 -7
- package/components/DateField/DateField.tsx +111 -0
- package/components/DateField/index.tsx +6 -0
- package/components/{DatePickerInput/inputUtils.ts → DateField/useDateFieldState.ts} +19 -51
- package/components/DatePicker/DateCalendar.tsx +83 -0
- package/components/DatePicker/DatePickerActions.tsx +73 -0
- package/components/DatePicker/DatePickerModal.tsx +246 -0
- package/components/DatePicker/DatePickerPopover.tsx +79 -0
- package/components/DatePicker/DatePickerProvider.tsx +158 -0
- package/components/DatePicker/DatePickerTrigger.tsx +23 -0
- package/components/DatePicker/context.tsx +83 -0
- package/components/DatePicker/index.tsx +45 -0
- package/components/DatePicker/utils.ts +295 -0
- package/components/DatePickerInline/DatePickerDockedHeader.tsx +117 -0
- package/components/DatePickerInline/DatePickerInline.tsx +17 -16
- package/components/DatePickerInline/DatePickerInlineBase.tsx +11 -5
- package/components/DatePickerInline/DatePickerInlineHeader.tsx +50 -20
- package/components/DatePickerInline/Day.tsx +25 -1
- package/components/DatePickerInline/DayNames.tsx +13 -10
- package/components/DatePickerInline/DayRange.tsx +2 -4
- package/components/DatePickerInline/HeaderItem.tsx +44 -29
- package/components/DatePickerInline/Month.tsx +48 -67
- package/components/DatePickerInline/MonthPicker.tsx +80 -92
- package/components/DatePickerInline/Swiper.native.tsx +21 -4
- package/components/DatePickerInline/Swiper.tsx +169 -14
- package/components/DatePickerInline/SwiperUtils.ts +1 -1
- package/components/DatePickerInline/Week.tsx +6 -1
- package/components/DatePickerInline/YearPicker.tsx +220 -78
- package/components/DatePickerInline/dateUtils.tsx +18 -13
- package/components/DatePickerInline/store.tsx +27 -0
- package/components/DatePickerInline/types.ts +6 -2
- package/components/DatePickerInline/utils.ts +66 -29
- package/components/Divider/Divider.tsx +192 -0
- package/components/Divider/index.tsx +10 -0
- package/components/Drawer/Drawer.tsx +17 -6
- package/components/Drawer/DrawerItemGroup.tsx +3 -7
- package/components/ElementGroup/ElementGroup.tsx +1 -1
- package/components/FilePicker/FilePicker.tsx +48 -78
- package/components/FilePicker/index.tsx +2 -1
- package/components/FilePicker/utils.ts +9 -0
- package/components/HelperText/HelperText.tsx +0 -35
- package/components/Icon/iconFactory.tsx +5 -4
- package/components/Icon/index.tsx +1 -1
- package/components/Icon/types.ts +17 -6
- package/components/IconButton/IconButton.tsx +84 -84
- package/components/IconButton/index.tsx +1 -0
- package/components/IconButton/types.ts +10 -0
- package/components/IconButton/utils.ts +167 -33
- package/components/List/List.tsx +276 -0
- package/components/List/context.tsx +27 -0
- package/components/List/index.ts +8 -0
- package/components/List/types.ts +117 -0
- package/components/List/utils.ts +79 -0
- package/components/LoadingIndicator/LoadingIndicator.tsx +253 -0
- package/components/LoadingIndicator/LoadingIndicator.web.tsx +136 -0
- package/components/LoadingIndicator/index.tsx +13 -0
- package/components/LoadingIndicator/utils.ts +117 -0
- package/components/Menu/Menu.tsx +162 -39
- package/components/Menu/index.tsx +10 -7
- package/components/Menu/utils.ts +21 -70
- package/components/NavigationRail/NavigationRail.tsx +15 -9
- package/components/Popover/Popover.tsx +119 -145
- package/components/Popover/PopoverRoot.tsx +60 -0
- package/components/Popover/common.ts +54 -34
- package/components/Popover/index.ts +12 -1
- package/components/Popover/usePlatformMeasure.native.ts +90 -0
- package/components/Popover/usePlatformMeasure.ts +120 -0
- package/components/Popover/utils.ts +34 -0
- package/components/Portal/Portal.tsx +1 -2
- package/components/Radio/Radio.tsx +188 -0
- package/components/Radio/RadioBase.ios.tsx +69 -0
- package/components/Radio/RadioBase.tsx +136 -0
- package/components/Radio/context.tsx +23 -0
- package/components/Radio/index.tsx +20 -0
- package/components/Radio/types.ts +101 -0
- package/components/Radio/utils.ts +115 -0
- package/components/Rating/Rating.tsx +1 -1
- package/components/Select/Select.tsx +521 -785
- package/components/Select/context.tsx +81 -0
- package/components/Select/index.ts +26 -14
- package/components/Select/types.ts +65 -58
- package/components/Select/utils.ts +126 -0
- package/components/Slot/Slot.tsx +244 -0
- package/components/Slot/compose-refs.tsx +62 -0
- package/components/Slot/index.tsx +8 -0
- package/components/Surface/Surface.android.tsx +32 -7
- package/components/Surface/Surface.ios.tsx +34 -29
- package/components/Surface/Surface.tsx +31 -4
- package/components/Surface/utils.ts +44 -6
- package/components/Switch/Switch.ios.tsx +1 -1
- package/components/Switch/Switch.tsx +10 -3
- package/components/Tabs/TabItem.tsx +35 -58
- package/components/Tabs/TabLabel.tsx +5 -9
- package/components/Tabs/Tabs.tsx +156 -150
- package/components/Tabs/utils.ts +15 -2
- package/components/Text/textFactory.tsx +17 -5
- package/components/TextInput/TextInput.tsx +663 -579
- package/components/TextInput/index.tsx +19 -3
- package/components/TextInput/types.ts +77 -28
- package/components/TextInput/utils.ts +235 -145
- package/components/TimeField/TimeField.tsx +75 -0
- package/components/TimeField/index.tsx +6 -0
- package/components/TimeField/useTimeFieldState.ts +70 -0
- package/components/{TimePickerField/sanitizeTime.ts → TimeField/utils.ts} +77 -10
- package/components/TimePicker/AnalogClock.tsx +1 -1
- package/components/TimePicker/TimeInput.tsx +87 -42
- package/components/TimePicker/TimeInputs.tsx +138 -50
- package/components/TimePicker/TimePicker.tsx +74 -11
- package/components/TimePicker/TimePickerModal.tsx +186 -0
- package/components/TimePicker/context.tsx +17 -0
- package/components/TimePicker/index.tsx +15 -3
- package/components/TimePicker/utils.ts +93 -4
- package/components/Tooltip/Tooltip.tsx +42 -67
- package/components/Tooltip/TooltipContent.tsx +32 -5
- package/components/Tooltip/TooltipTrigger.tsx +20 -20
- package/components/Tooltip/index.tsx +1 -1
- package/components/TouchableRipple/TouchableRipple.native.tsx +83 -16
- package/components/TouchableRipple/TouchableRipple.tsx +150 -102
- package/components/TouchableRipple/rippleFromForegroundColor.ts +21 -0
- package/hocs/index.tsx +1 -1
- package/hocs/withKeyboardAccessibility.tsx +2 -3
- package/hocs/withPortal.tsx +1 -1
- package/hooks/index.tsx +2 -12
- package/hooks/useActionState.tsx +19 -8
- package/hooks/useContrastColor.ts +1 -2
- package/hooks/useFilePicker.tsx +7 -17
- package/hooks/useHandleNumberFormat.tsx +2 -2
- package/hooks/useMediaQuery.tsx +1 -2
- package/package.json +95 -111
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +6 -3
- package/shortcuts-manager/ShortcutsManager/utils.tsx +1 -1
- package/shortcuts-manager/useSetScopes/useSetScopes.tsx +1 -1
- package/shortcuts-manager/useShortcut/useShortcut.tsx +1 -1
- package/styles/shadow.ts +2 -1
- package/styles/themes/LightTheme.tsx +1 -1
- package/utils/DocumentPicker/documentPicker.ts +78 -27
- package/utils/DocumentPicker/types.ts +0 -1
- package/utils/extractSubcomponents.ts +89 -0
- package/utils/extractTextStyles.ts +1 -2
- package/utils/formatNumberWithMask/formatNumberWithMask.ts +2 -1
- package/utils/index.ts +0 -3
- package/utils/normalizeToNumberString/normalizeToNumberString.ts +1 -1
- package/components/DatePickerDocked/DatePickerDocked.tsx +0 -30
- package/components/DatePickerDocked/DatePickerDockedHeader.tsx +0 -129
- package/components/DatePickerDocked/index.tsx +0 -17
- package/components/DatePickerDocked/types.ts +0 -11
- package/components/DatePickerDocked/utils.ts +0 -157
- package/components/DatePickerInline/DatePickerContext.tsx +0 -21
- package/components/DatePickerInput/DatePickerInput.tsx +0 -139
- package/components/DatePickerInput/DatePickerInputModal.tsx +0 -48
- package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +0 -77
- package/components/DatePickerInput/DateRangeInput.tsx +0 -88
- package/components/DatePickerInput/index.tsx +0 -10
- package/components/DatePickerInput/types.ts +0 -28
- package/components/DatePickerInput/utils.ts +0 -15
- package/components/DatePickerModal/AnimatedCrossView.tsx +0 -94
- package/components/DatePickerModal/CalendarEdit.tsx +0 -139
- package/components/DatePickerModal/DatePickerModal.tsx +0 -85
- package/components/DatePickerModal/DatePickerModalContent.tsx +0 -155
- package/components/DatePickerModal/DatePickerModalContentHeader.tsx +0 -213
- package/components/DatePickerModal/DatePickerModalHeader.tsx +0 -74
- package/components/DatePickerModal/DatePickerModalHeaderBackground.tsx +0 -13
- package/components/DatePickerModal/index.tsx +0 -16
- package/components/DatePickerModal/types.ts +0 -92
- package/components/DatePickerModal/utils.ts +0 -122
- package/components/DateTimePicker/DateTimePicker.tsx +0 -172
- package/components/DateTimePicker/index.tsx +0 -10
- package/components/DateTimePicker/utils.ts +0 -12
- package/components/HorizontalDivider/HorizontalDivider.tsx +0 -103
- package/components/HorizontalDivider/index.tsx +0 -9
- package/components/ListItem/ListItem.tsx +0 -136
- package/components/ListItem/ListItemDescription.tsx +0 -25
- package/components/ListItem/ListItemTitle.tsx +0 -25
- package/components/ListItem/index.tsx +0 -14
- package/components/ListItem/utils.ts +0 -115
- package/components/Menu/MenuDivider.tsx +0 -13
- package/components/Menu/MenuItem.tsx +0 -128
- package/components/Popover/Popover.native.tsx +0 -185
- package/components/RadioButton/RadioButton.tsx +0 -138
- package/components/RadioButton/RadioButtonAndroid.tsx +0 -188
- package/components/RadioButton/RadioButtonGroup.tsx +0 -98
- package/components/RadioButton/RadioButtonIOS.tsx +0 -106
- package/components/RadioButton/RadioButtonItem.tsx +0 -232
- package/components/RadioButton/index.ts +0 -22
- package/components/RadioButton/utils.ts +0 -165
- package/components/TimePickerField/TimePickerField.tsx +0 -152
- package/components/TimePickerField/index.tsx +0 -10
- package/components/TimePickerField/utils.ts +0 -94
- package/components/TimePickerModal/TimePickerModal.tsx +0 -115
- package/components/TimePickerModal/index.tsx +0 -10
- package/components/TimePickerModal/utils.ts +0 -47
- package/components/VerticalDivider/VerticalDivider.tsx +0 -100
- package/components/VerticalDivider/index.tsx +0 -9
- package/context-bridge/index.tsx +0 -87
- package/fast-context/index.tsx +0 -190
- package/hocs/typedMemo.tsx +0 -5
- package/hooks/useControlledValue.tsx +0 -68
- package/hooks/useLatest.tsx +0 -9
- package/hooks/useMergedRefs.ts +0 -14
- package/hooks/usePrevious.ts +0 -13
- package/hooks/useSearchable.tsx +0 -74
- package/hooks/useSubcomponents.tsx +0 -59
- package/hooks/useToggle.tsx +0 -24
- package/utils/color.ts +0 -22
- package/utils/compare/index.ts +0 -54
- package/utils/lodash.ts +0 -49
- package/utils/repository.ts +0 -53
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import type { TextProps, ViewProps } from 'react-native';
|
|
2
3
|
|
|
3
4
|
import type { TouchableRippleProps } from '../TouchableRipple';
|
|
4
5
|
|
|
5
6
|
export type Size = 'sm' | 'md' | 'lg';
|
|
6
7
|
export type States = 'disabled' | 'checked' | 'hovered' | 'checkedAndHovered';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Internal props for the platform control (CheckboxBase).
|
|
11
|
+
*/
|
|
12
|
+
export type CheckboxBaseProps = Omit<TouchableRippleProps, 'children'> & {
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
14
|
+
* Whether the checkbox is checked.
|
|
11
15
|
*/
|
|
12
|
-
value
|
|
16
|
+
value: boolean;
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
defaultValue?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* function execute when the value change i.e checkbox is press
|
|
18
|
+
* Called when the checkbox is pressed.
|
|
19
19
|
*/
|
|
20
20
|
onChange?: (newValue: boolean) => void;
|
|
21
21
|
/**
|
|
22
|
-
* Whether
|
|
22
|
+
* Whether the checkbox is in the indeterminate state (overrides `value`).
|
|
23
23
|
*/
|
|
24
24
|
indeterminate?: boolean;
|
|
25
25
|
/**
|
|
26
|
-
* Whether checkbox is disabled.
|
|
26
|
+
* Whether the checkbox is disabled.
|
|
27
27
|
*/
|
|
28
28
|
disabled?: boolean;
|
|
29
29
|
/**
|
|
30
|
-
* Size of the
|
|
31
|
-
* Should be a number or a Design Token
|
|
30
|
+
* Size of the checkbox.
|
|
32
31
|
*/
|
|
33
32
|
size?: Size;
|
|
34
33
|
/**
|
|
35
|
-
* Custom color for
|
|
34
|
+
* Custom color for the checked checkbox.
|
|
36
35
|
*/
|
|
37
|
-
|
|
36
|
+
color?: string;
|
|
38
37
|
/**
|
|
39
|
-
* Custom color for checkbox.
|
|
38
|
+
* Custom color for the unchecked checkbox.
|
|
40
39
|
*/
|
|
41
|
-
|
|
40
|
+
uncheckedColor?: string;
|
|
42
41
|
/**
|
|
43
|
-
* Accessibility label for the touchable.
|
|
42
|
+
* Accessibility label for the touchable.
|
|
44
43
|
*/
|
|
45
44
|
accessibilityLabel?: string;
|
|
46
45
|
/**
|
|
@@ -48,25 +47,60 @@ export type CheckBoxBaseProps = Omit<TouchableRippleProps, 'children'> & {
|
|
|
48
47
|
*/
|
|
49
48
|
testID?: string;
|
|
50
49
|
/**
|
|
51
|
-
*
|
|
50
|
+
* Props for the state layer.
|
|
51
|
+
*/
|
|
52
|
+
stateLayerProps?: PropsWithoutRef<ViewProps>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The checkbox control (the box). Use inside a CheckboxRow, or standalone with `value`/`onChange`.
|
|
57
|
+
*/
|
|
58
|
+
export type CheckboxProps = Omit<CheckboxBaseProps, 'value' | 'onChange'> & {
|
|
59
|
+
/**
|
|
60
|
+
* Whether the checkbox is checked (controlled).
|
|
61
|
+
*/
|
|
62
|
+
value?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Default checked state (uncontrolled).
|
|
65
|
+
*/
|
|
66
|
+
defaultValue?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Called when the checked state changes.
|
|
52
69
|
*/
|
|
53
|
-
|
|
70
|
+
onChange?: (newValue: boolean) => void;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type CheckboxRowProps = ViewProps & {
|
|
54
74
|
/**
|
|
55
|
-
*
|
|
75
|
+
* Whether the checkbox is checked (controlled).
|
|
56
76
|
*/
|
|
57
|
-
|
|
77
|
+
value?: boolean;
|
|
58
78
|
/**
|
|
59
|
-
*
|
|
79
|
+
* Default checked state (uncontrolled).
|
|
60
80
|
*/
|
|
61
|
-
|
|
81
|
+
defaultValue?: boolean;
|
|
62
82
|
/**
|
|
63
|
-
*
|
|
83
|
+
* Called when the checked state changes.
|
|
64
84
|
*/
|
|
65
|
-
|
|
85
|
+
onChange?: (newValue: boolean) => void;
|
|
66
86
|
/**
|
|
67
|
-
*
|
|
87
|
+
* Whether the checkbox is in the indeterminate state.
|
|
68
88
|
*/
|
|
69
|
-
|
|
89
|
+
indeterminate?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Disables the row (control + label).
|
|
92
|
+
*/
|
|
93
|
+
disabled?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Size applied to the checkbox.
|
|
96
|
+
*/
|
|
97
|
+
size?: Size;
|
|
98
|
+
/**
|
|
99
|
+
* Checkbox control and Checkbox.Label, in any order.
|
|
100
|
+
*/
|
|
101
|
+
children: ReactNode;
|
|
102
|
+
};
|
|
70
103
|
|
|
71
|
-
|
|
104
|
+
export type CheckboxLabelProps = TextProps & {
|
|
105
|
+
children: ReactNode;
|
|
72
106
|
};
|
|
@@ -21,17 +21,14 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
|
|
|
21
21
|
sm: {
|
|
22
22
|
padding: PADDING,
|
|
23
23
|
borderRadius: 16,
|
|
24
|
-
// iconSize: iconSizeMap.sm,
|
|
25
24
|
},
|
|
26
25
|
md: {
|
|
27
26
|
padding: PADDING,
|
|
28
27
|
borderRadius: 18,
|
|
29
|
-
// iconSize: iconSizeMap.md,
|
|
30
28
|
},
|
|
31
29
|
lg: {
|
|
32
30
|
padding: PADDING,
|
|
33
31
|
borderRadius: 20,
|
|
34
|
-
// iconSize: iconSizeMap.lg,
|
|
35
32
|
},
|
|
36
33
|
},
|
|
37
34
|
},
|
|
@@ -81,82 +78,6 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
|
|
|
81
78
|
},
|
|
82
79
|
},
|
|
83
80
|
},
|
|
84
|
-
itemContainer: {
|
|
85
|
-
flexDirection: 'row',
|
|
86
|
-
alignItems: 'center',
|
|
87
|
-
justifyContent: 'space-between',
|
|
88
|
-
},
|
|
89
|
-
label: {
|
|
90
|
-
flexShrink: 1,
|
|
91
|
-
flexGrow: 1,
|
|
92
|
-
variants: {
|
|
93
|
-
variant: {
|
|
94
|
-
item: {
|
|
95
|
-
color: theme.colors.onSurface,
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
isLeading: {
|
|
99
|
-
true: {
|
|
100
|
-
textAlign: 'right',
|
|
101
|
-
paddingLeft: 0,
|
|
102
|
-
paddingRight: theme.spacings['2'],
|
|
103
|
-
},
|
|
104
|
-
false: {
|
|
105
|
-
textAlign: 'left',
|
|
106
|
-
paddingLeft: theme.spacings['2'],
|
|
107
|
-
paddingRight: 0,
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
compoundVariants: [
|
|
112
|
-
{
|
|
113
|
-
variant: 'item',
|
|
114
|
-
size: 'sm',
|
|
115
|
-
styles: {
|
|
116
|
-
...theme.typescale.bodyMedium,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
variant: 'item',
|
|
121
|
-
size: 'md',
|
|
122
|
-
styles: {
|
|
123
|
-
...theme.typescale.bodyMedium,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
variant: 'item',
|
|
128
|
-
size: 'lg',
|
|
129
|
-
styles: {
|
|
130
|
-
...theme.typescale.bodyLarge,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
fillContainer: {
|
|
136
|
-
alignItems: 'center',
|
|
137
|
-
justifyContent: 'center',
|
|
138
|
-
},
|
|
139
|
-
animatedFill: {
|
|
140
|
-
width: 24 / 2 + (PADDING - 2),
|
|
141
|
-
height: 24 / 2 + (PADDING - 2),
|
|
142
|
-
|
|
143
|
-
variants: {
|
|
144
|
-
size: {
|
|
145
|
-
sm: {
|
|
146
|
-
width: iconSizeMap.sm / 2 + (PADDING - 2),
|
|
147
|
-
height: iconSizeMap.sm / 2 + (PADDING - 2),
|
|
148
|
-
},
|
|
149
|
-
md: {
|
|
150
|
-
width: iconSizeMap.md / 2 + (PADDING - 2),
|
|
151
|
-
height: iconSizeMap.md / 2 + (PADDING - 2),
|
|
152
|
-
},
|
|
153
|
-
lg: {
|
|
154
|
-
width: iconSizeMap.lg / 2 + (PADDING - 2),
|
|
155
|
-
height: iconSizeMap.lg / 2 + (PADDING - 2),
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
81
|
icon: {
|
|
161
82
|
color: theme.colors.onSurfaceVariant,
|
|
162
83
|
|
|
@@ -175,36 +96,32 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
|
|
|
175
96
|
},
|
|
176
97
|
},
|
|
177
98
|
},
|
|
178
|
-
|
|
179
|
-
// if (variant === 'android') {
|
|
180
|
-
// return {
|
|
181
|
-
// root: {
|
|
182
|
-
// ...(size === 'sm' && { width: 32, height: 32 }),
|
|
183
|
-
// ...(size === 'md' && { width: 36, height: 36 }),
|
|
184
|
-
// ...(size === 'lg' && { width: 40, height: 40 }),
|
|
185
|
-
// },
|
|
186
|
-
// stateLayer: {
|
|
187
|
-
// ...(state === 'hovered' && {
|
|
188
|
-
// backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
189
|
-
// }),
|
|
190
|
-
// ...(state === 'checkedAndHovered' && {
|
|
191
|
-
// backgroundColor: theme.colors.stateLayer.hover.primary,
|
|
192
|
-
// }),
|
|
193
|
-
// },
|
|
194
|
-
// } as any;
|
|
195
|
-
// }
|
|
99
|
+
}));
|
|
196
100
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
101
|
+
const checkboxRowStylesDefault = StyleSheet.create(theme => ({
|
|
102
|
+
row: {
|
|
103
|
+
flexDirection: 'row',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
},
|
|
106
|
+
label: {
|
|
107
|
+
flexShrink: 1,
|
|
108
|
+
flexGrow: 1,
|
|
109
|
+
color: theme.colors.onSurface,
|
|
110
|
+
...theme.typescale.bodyLarge,
|
|
111
|
+
|
|
112
|
+
variants: {
|
|
113
|
+
state: {
|
|
114
|
+
checked: {},
|
|
115
|
+
checkedAndHovered: {},
|
|
116
|
+
hovered: {},
|
|
117
|
+
disabled: { color: theme.colors.onSurfaceDisabled },
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
208
121
|
}));
|
|
209
122
|
|
|
210
123
|
export const styles = getRegisteredComponentStylesWithFallback('Checkbox', checkboxStylesDefault);
|
|
124
|
+
export const checkboxRowStyles = getRegisteredComponentStylesWithFallback(
|
|
125
|
+
'Checkbox_Row',
|
|
126
|
+
checkboxRowStylesDefault,
|
|
127
|
+
);
|
package/components/Chip/Chip.tsx
CHANGED
|
@@ -97,10 +97,6 @@ export type Props = Omit<TouchableRippleProps, 'children'> &
|
|
|
97
97
|
* Whether to show the ActivityIndicator or not
|
|
98
98
|
*/
|
|
99
99
|
loading?: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* container style
|
|
102
|
-
*/
|
|
103
|
-
containerStyle?: ViewStyle;
|
|
104
100
|
/**
|
|
105
101
|
* left element container style
|
|
106
102
|
*/
|
|
@@ -132,7 +128,6 @@ export type Props = Omit<TouchableRippleProps, 'children'> &
|
|
|
132
128
|
const Chip = (
|
|
133
129
|
{
|
|
134
130
|
style,
|
|
135
|
-
containerStyle: containerStyleProp,
|
|
136
131
|
label: _label,
|
|
137
132
|
labelCharacterLimit = 20,
|
|
138
133
|
variant = 'outlined',
|
|
@@ -158,11 +153,13 @@ const Chip = (
|
|
|
158
153
|
leftElementIconProps,
|
|
159
154
|
invertLabelColor,
|
|
160
155
|
backgroundColor,
|
|
156
|
+
onPress,
|
|
161
157
|
...rest
|
|
162
158
|
}: Props,
|
|
163
159
|
ref: any,
|
|
164
160
|
) => {
|
|
165
161
|
const { hovered, actionsRef } = useActionState({ ref, actionsToListen: ['hover'] });
|
|
162
|
+
const Wrapper = onPress ? TouchableRipple : View;
|
|
166
163
|
|
|
167
164
|
const state = resolveStateVariant({
|
|
168
165
|
disabled: !!disabled,
|
|
@@ -192,47 +189,39 @@ const Chip = (
|
|
|
192
189
|
// selectedColorProp ? { selectedColor: selectedColorProp } : {},
|
|
193
190
|
// ]);
|
|
194
191
|
|
|
195
|
-
const {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
styles.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
stateLayerProps?.style,
|
|
229
|
-
style,
|
|
230
|
-
containerStyleProp,
|
|
231
|
-
labelStyleProp,
|
|
232
|
-
state,
|
|
233
|
-
size,
|
|
234
|
-
variant,
|
|
235
|
-
]);
|
|
192
|
+
const { containerStyle, leftElementStyle, rightElementStyle, labelStyle, stateLayerStyle } =
|
|
193
|
+
useMemo(() => {
|
|
194
|
+
return {
|
|
195
|
+
containerStyle: [
|
|
196
|
+
styles.container,
|
|
197
|
+
selected && selectionBackgroundColor
|
|
198
|
+
? { backgroundColor: selectionBackgroundColor }
|
|
199
|
+
: {},
|
|
200
|
+
style,
|
|
201
|
+
],
|
|
202
|
+
leftElementStyle: [styles.leftElement, leftElementContainerStyle],
|
|
203
|
+
rightElementStyle: [styles.rightElement, rightElementContainerStyle],
|
|
204
|
+
labelStyle: [
|
|
205
|
+
styles.label,
|
|
206
|
+
selected && selectedColor ? { color: selectedColor } : {},
|
|
207
|
+
labelStyleProp,
|
|
208
|
+
],
|
|
209
|
+
stateLayerStyle: [styles.stateLayer, stateLayerProps?.style],
|
|
210
|
+
};
|
|
211
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
212
|
+
}, [
|
|
213
|
+
leftElementContainerStyle,
|
|
214
|
+
rightElementContainerStyle,
|
|
215
|
+
selected,
|
|
216
|
+
selectedColor,
|
|
217
|
+
selectionBackgroundColor,
|
|
218
|
+
stateLayerProps?.style,
|
|
219
|
+
style,
|
|
220
|
+
labelStyleProp,
|
|
221
|
+
state,
|
|
222
|
+
size,
|
|
223
|
+
variant,
|
|
224
|
+
]);
|
|
236
225
|
|
|
237
226
|
const { accessibilityState, elevation } = useMemo(
|
|
238
227
|
() => ({
|
|
@@ -251,14 +240,14 @@ const Chip = (
|
|
|
251
240
|
{...containerProps}
|
|
252
241
|
elevation={elevation}
|
|
253
242
|
style={containerStyle}
|
|
254
|
-
backgroundColor={backgroundColor}
|
|
255
|
-
|
|
243
|
+
backgroundColor={backgroundColor}
|
|
244
|
+
asChild>
|
|
245
|
+
<Wrapper
|
|
256
246
|
borderless
|
|
257
247
|
{...rest}
|
|
258
248
|
disabled={disabled}
|
|
259
|
-
|
|
249
|
+
onPress={onPress}
|
|
260
250
|
accessibilityLabel={accessibilityLabel}
|
|
261
|
-
accessibilityRole="button"
|
|
262
251
|
accessibilityState={accessibilityState}
|
|
263
252
|
ref={actionsRef}
|
|
264
253
|
testID={testID}>
|
|
@@ -297,7 +286,7 @@ const Chip = (
|
|
|
297
286
|
style={stateLayerStyle}
|
|
298
287
|
/>
|
|
299
288
|
</>
|
|
300
|
-
</
|
|
289
|
+
</Wrapper>
|
|
301
290
|
</Surface>
|
|
302
291
|
);
|
|
303
292
|
};
|
|
@@ -362,7 +351,7 @@ const RightElement = memo(
|
|
|
362
351
|
{onClose ? (
|
|
363
352
|
<IconButtonWithContrastColor
|
|
364
353
|
name="close"
|
|
365
|
-
size={
|
|
354
|
+
size={14}
|
|
366
355
|
accessibilityLabel="Close"
|
|
367
356
|
disabled={disabled}
|
|
368
357
|
onPress={onClose}
|
package/components/Chip/utils.ts
CHANGED
|
@@ -6,6 +6,9 @@ const chipStylesDefault = StyleSheet.create(theme => ({
|
|
|
6
6
|
container: {
|
|
7
7
|
borderRadius: theme.shapes.corner.small,
|
|
8
8
|
backgroundColor: theme.colors.surface,
|
|
9
|
+
paddingHorizontal: theme.spacings['2'],
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
alignItems: 'center',
|
|
9
12
|
|
|
10
13
|
variants: {
|
|
11
14
|
variant: {
|
|
@@ -47,13 +50,6 @@ const chipStylesDefault = StyleSheet.create(theme => ({
|
|
|
47
50
|
},
|
|
48
51
|
},
|
|
49
52
|
},
|
|
50
|
-
touchableRippleContainer: {
|
|
51
|
-
flex: 1,
|
|
52
|
-
paddingHorizontal: theme.spacings['2'],
|
|
53
|
-
borderRadius: theme.shapes.corner.small,
|
|
54
|
-
flexDirection: 'row',
|
|
55
|
-
alignItems: 'center',
|
|
56
|
-
},
|
|
57
53
|
label: {
|
|
58
54
|
display: 'flex',
|
|
59
55
|
color: theme.colors.onSurfaceVariant,
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { memo, useCallback, useMemo, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { DatePickerValue, RangeValue } from '../DatePicker/context';
|
|
4
|
+
import { useDatePickerContext } from '../DatePicker/context';
|
|
5
|
+
import type { TextInputProps } from '../TextInput';
|
|
6
|
+
import { TextInputWithMask } from '../TextInputWithMask';
|
|
7
|
+
import { useDateFieldState } from './useDateFieldState';
|
|
8
|
+
|
|
9
|
+
export type DateFieldInputMode = 'start' | 'end';
|
|
10
|
+
|
|
11
|
+
export type DateFieldProps = Omit<
|
|
12
|
+
TextInputProps,
|
|
13
|
+
'value' | 'defaultValue' | 'onChangeText' | 'inputMode'
|
|
14
|
+
> & {
|
|
15
|
+
inputMode?: DateFieldInputMode;
|
|
16
|
+
dateFormat?: string;
|
|
17
|
+
mask?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const DEFAULT_DATE_FORMAT = 'dd/MM/yyyy';
|
|
21
|
+
|
|
22
|
+
const isRange = (value: DatePickerValue): value is RangeValue =>
|
|
23
|
+
value !== null && typeof value === 'object' && 'start' in value && 'end' in value;
|
|
24
|
+
|
|
25
|
+
const preserveTime = (next: Date | null, prev: Date | null): Date | null => {
|
|
26
|
+
if (!next || !prev) return next;
|
|
27
|
+
|
|
28
|
+
const combined = new Date(next);
|
|
29
|
+
|
|
30
|
+
combined.setHours(
|
|
31
|
+
prev.getHours(),
|
|
32
|
+
prev.getMinutes(),
|
|
33
|
+
prev.getSeconds(),
|
|
34
|
+
prev.getMilliseconds(),
|
|
35
|
+
);
|
|
36
|
+
return combined;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function DateField({
|
|
40
|
+
ref,
|
|
41
|
+
inputMode = 'start',
|
|
42
|
+
dateFormat = DEFAULT_DATE_FORMAT,
|
|
43
|
+
disabled: disabledProp,
|
|
44
|
+
onBlur,
|
|
45
|
+
onFocus,
|
|
46
|
+
...rest
|
|
47
|
+
}: DateFieldProps) {
|
|
48
|
+
const {
|
|
49
|
+
mode,
|
|
50
|
+
value,
|
|
51
|
+
commitValue,
|
|
52
|
+
validRange,
|
|
53
|
+
disabled: providerDisabled,
|
|
54
|
+
} = useDatePickerContext();
|
|
55
|
+
const isBlurredRef = useRef(true);
|
|
56
|
+
|
|
57
|
+
const disabled = disabledProp ?? providerDisabled;
|
|
58
|
+
|
|
59
|
+
const fieldValue = useMemo<Date | null>(() => {
|
|
60
|
+
if (mode === 'range') {
|
|
61
|
+
if (!isRange(value)) return null;
|
|
62
|
+
return inputMode === 'end' ? value.end : value.start;
|
|
63
|
+
}
|
|
64
|
+
return isRange(value) ? null : value;
|
|
65
|
+
}, [value, mode, inputMode]);
|
|
66
|
+
|
|
67
|
+
const onChange = useCallback(
|
|
68
|
+
(next: Date | null) => {
|
|
69
|
+
if (mode === 'range') {
|
|
70
|
+
const current: RangeValue = isRange(value) ? value : { start: null, end: null };
|
|
71
|
+
commitValue({ ...current, [inputMode]: next });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
commitValue(preserveTime(next, isRange(value) ? null : value));
|
|
75
|
+
},
|
|
76
|
+
[mode, value, inputMode, commitValue],
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const {
|
|
80
|
+
formattedValue,
|
|
81
|
+
onChangeText,
|
|
82
|
+
onBlur: onInnerBlur,
|
|
83
|
+
onFocus: onInnerFocus,
|
|
84
|
+
} = useDateFieldState({
|
|
85
|
+
value: fieldValue,
|
|
86
|
+
validRange,
|
|
87
|
+
inputMode,
|
|
88
|
+
dateFormat,
|
|
89
|
+
onChange,
|
|
90
|
+
onBlur,
|
|
91
|
+
onFocus,
|
|
92
|
+
isBlurredRef,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<TextInputWithMask
|
|
97
|
+
placeholder={dateFormat}
|
|
98
|
+
keyboardType="number-pad"
|
|
99
|
+
mask={dateFormat}
|
|
100
|
+
{...rest}
|
|
101
|
+
ref={ref}
|
|
102
|
+
disabled={disabled}
|
|
103
|
+
value={formattedValue}
|
|
104
|
+
onChangeText={onChangeText}
|
|
105
|
+
onBlur={onInnerBlur}
|
|
106
|
+
onFocus={onInnerFocus}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export default memo(DateField);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback } from '../../core';
|
|
2
|
+
import DateFieldDefault from './DateField';
|
|
3
|
+
|
|
4
|
+
export const DateField = getRegisteredComponentWithFallback('DateField', DateFieldDefault);
|
|
5
|
+
|
|
6
|
+
export type { DateFieldInputMode, DateFieldProps } from './DateField';
|