@codeleap/mobile 2.2.10 → 2.3.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.
Files changed (118) hide show
  1. package/dist/utils/ModalManager/components.js +0 -7
  2. package/dist/utils/ModalManager/components.js.map +1 -1
  3. package/package.json +2 -1
  4. package/src/components/ActionIcon/index.tsx +0 -32
  5. package/src/components/ActionIcon/styles.ts +0 -97
  6. package/src/components/ActivityIndicator/index.tsx +0 -50
  7. package/src/components/ActivityIndicator/styles.ts +0 -68
  8. package/src/components/Animated.tsx +0 -34
  9. package/src/components/AutoComplete/index.tsx +0 -163
  10. package/src/components/AutoComplete/styles.ts +0 -44
  11. package/src/components/Backdrop/index.tsx +0 -48
  12. package/src/components/Backdrop/styles.ts +0 -33
  13. package/src/components/Button/index.tsx +0 -167
  14. package/src/components/Button/styles.ts +0 -129
  15. package/src/components/Calendar/index.tsx +0 -65
  16. package/src/components/Calendar/style.ts +0 -35
  17. package/src/components/Calendar/types.ts +0 -102
  18. package/src/components/Checkbox/index.tsx +0 -91
  19. package/src/components/Checkbox/styles.ts +0 -81
  20. package/src/components/ContentView/index.tsx +0 -63
  21. package/src/components/ContentView/styles.ts +0 -24
  22. package/src/components/Drawer/index.tsx +0 -33
  23. package/src/components/Drawer/styles.ts +0 -43
  24. package/src/components/EmptyPlaceholder/index.tsx +0 -88
  25. package/src/components/EmptyPlaceholder/styles.ts +0 -58
  26. package/src/components/FileInput/index.tsx +0 -181
  27. package/src/components/FileInput/styles.ts +0 -15
  28. package/src/components/Grid/index.tsx +0 -117
  29. package/src/components/Grid/styles.ts +0 -11
  30. package/src/components/Icon/index.tsx +0 -69
  31. package/src/components/Icon/styles.ts +0 -57
  32. package/src/components/Image/index.tsx +0 -91
  33. package/src/components/Image/styles.ts +0 -20
  34. package/src/components/ImageView/Spotlight.tsx +0 -157
  35. package/src/components/ImageView/component.tsx +0 -38
  36. package/src/components/ImageView/index.ts +0 -2
  37. package/src/components/InputLabel/index.tsx +0 -38
  38. package/src/components/InputLabel/styles.ts +0 -19
  39. package/src/components/List/PaginationIndicator.tsx +0 -71
  40. package/src/components/List/index.tsx +0 -114
  41. package/src/components/List/styles.ts +0 -19
  42. package/src/components/Modal/index.tsx +0 -218
  43. package/src/components/Modal/styles.ts +0 -153
  44. package/src/components/MultiSelect/index.tsx +0 -138
  45. package/src/components/MultiSelect/styles.ts +0 -18
  46. package/src/components/MultiSelect/types.ts +0 -42
  47. package/src/components/Navigation/Navigation.tsx +0 -54
  48. package/src/components/Navigation/constants.ts +0 -8
  49. package/src/components/Navigation/index.tsx +0 -3
  50. package/src/components/Navigation/types.ts +0 -35
  51. package/src/components/Navigation/utils.tsx +0 -57
  52. package/src/components/Pager/index.tsx +0 -121
  53. package/src/components/Pager/styles.ts +0 -81
  54. package/src/components/RadioInput/index.tsx +0 -106
  55. package/src/components/RadioInput/styles.ts +0 -67
  56. package/src/components/Scroll/index.tsx +0 -124
  57. package/src/components/Scroll/styles.ts +0 -18
  58. package/src/components/Sections/index.tsx +0 -91
  59. package/src/components/SegmentedControl/index.tsx +0 -204
  60. package/src/components/SegmentedControl/styles.ts +0 -89
  61. package/src/components/Select/index.tsx +0 -167
  62. package/src/components/Select/styles.ts +0 -62
  63. package/src/components/Select/types.ts +0 -43
  64. package/src/components/Slider/Mark.tsx +0 -46
  65. package/src/components/Slider/Thumb.tsx +0 -29
  66. package/src/components/Slider/index.tsx +0 -130
  67. package/src/components/Slider/styles.ts +0 -76
  68. package/src/components/Slider/types.ts +0 -30
  69. package/src/components/Switch/index.tsx +0 -91
  70. package/src/components/Switch/styles.ts +0 -38
  71. package/src/components/Text/index.tsx +0 -97
  72. package/src/components/Text/styles.ts +0 -50
  73. package/src/components/TextInput/index.tsx +0 -319
  74. package/src/components/TextInput/styles.ts +0 -127
  75. package/src/components/Touchable/index.tsx +0 -172
  76. package/src/components/Touchable/styles.ts +0 -28
  77. package/src/components/View/index.tsx +0 -103
  78. package/src/components/View/styles.ts +0 -24
  79. package/src/components/components.ts +0 -42
  80. package/src/components/defaultStyles.ts +0 -62
  81. package/src/components/legacy/Modal/index.tsx +0 -163
  82. package/src/components/legacy/Modal/styles.ts +0 -125
  83. package/src/components/legacy/Pager/index.tsx +0 -242
  84. package/src/components/legacy/Pager/styles.ts +0 -51
  85. package/src/components/legacy/index.ts +0 -2
  86. package/src/modules/documentPicker.ts +0 -7
  87. package/src/modules/fastImage.ts +0 -2
  88. package/src/modules/imageCropPicker.d.ts +0 -497
  89. package/src/modules/index.d.ts +0 -682
  90. package/src/modules/reactNavigation.ts +0 -15
  91. package/src/modules/textInputMask.ts +0 -11
  92. package/src/modules/types/documentPicker.d.ts +0 -215
  93. package/src/modules/types/fileTypes.ts +0 -138
  94. package/src/modules/types/textInputMask.ts +0 -9
  95. package/src/types/index.ts +0 -1
  96. package/src/types/utility.ts +0 -9
  97. package/src/utils/KeyboardAware/context.tsx +0 -75
  98. package/src/utils/KeyboardAware/index.ts +0 -17
  99. package/src/utils/KeyboardAware/keyboardHooks.ts +0 -124
  100. package/src/utils/KeyboardAware/lib/KeyboardAwareFlatList.ts +0 -4
  101. package/src/utils/KeyboardAware/lib/KeyboardAwareHOC.tsx +0 -618
  102. package/src/utils/KeyboardAware/lib/KeyboardAwareInterface.ts +0 -13
  103. package/src/utils/KeyboardAware/lib/KeyboardAwareScrollView.ts +0 -6
  104. package/src/utils/KeyboardAware/lib/KeyboardAwareSectionList.ts +0 -6
  105. package/src/utils/KeyboardAware/types.ts +0 -159
  106. package/src/utils/ModalManager/components.tsx +0 -119
  107. package/src/utils/ModalManager/context.tsx +0 -260
  108. package/src/utils/ModalManager/index.ts +0 -16
  109. package/src/utils/OSAlert.ts +0 -180
  110. package/src/utils/PermissionManager/context.tsx +0 -302
  111. package/src/utils/PermissionManager/index.ts +0 -20
  112. package/src/utils/PermissionManager/types.ts +0 -24
  113. package/src/utils/hooks.ts +0 -163
  114. package/src/utils/index.ts +0 -11
  115. package/src/utils/input.ts +0 -51
  116. package/src/utils/misc.ts +0 -83
  117. package/src/utils/notifications.ts +0 -206
  118. package/src/utils/theme.ts +0 -55
@@ -1,167 +0,0 @@
1
- import * as React from 'react'
2
- import {
3
- useDefaultComponentStyle,
4
- ComponentVariants,
5
-
6
- IconPlaceholder,
7
- GetRefType,
8
- SmartOmit,
9
- TypeGuards,
10
- deepMerge,
11
- PropsOf,
12
- } from '@codeleap/common'
13
-
14
- import {
15
- ButtonStyles,
16
- ButtonComposition,
17
- ButtonParts,
18
- } from './styles'
19
- import { forwardRef } from 'react'
20
- import { StylesOf } from '../../types/utility'
21
- import { Text } from '../Text'
22
- import { Touchable, TouchableProps } from '../Touchable'
23
- import { Icon } from '../Icon'
24
- import { View, ViewProps } from '../View'
25
- import { ActivityIndicator } from '../ActivityIndicator'
26
- import { StyleSheet } from 'react-native'
27
- export * from './styles'
28
-
29
- type ChildProps = {
30
- styles: StylesOf<ButtonParts>
31
- pressed: boolean
32
- props: Omit<ButtonProps, 'children'>
33
- }
34
-
35
- type BadgeProps = Partial<ViewProps> & {
36
- text?: string
37
- children?: React.ReactElement | ((props: Partial<SmartOmit<BadgeProps, 'children'>>) => React.ReactElement)
38
- styles?: StylesOf<'text'|'wrapper'>
39
- position?: [number, number]
40
- textProps?: Partial<PropsOf<typeof Text>>
41
- }
42
-
43
- export type ButtonProps = Omit<TouchableProps, 'variants'> &
44
- ComponentVariants<typeof ButtonStyles> & {
45
- text?: string
46
- rightIcon?: IconPlaceholder
47
- icon?: IconPlaceholder
48
- styles?: StylesOf<ButtonComposition>
49
- loading?: boolean
50
- debounce?: number
51
- debugName: string
52
- badge?: React.ReactElement | BadgeProps
53
- children?: React.ReactNode | ((props: ChildProps) => React.ReactNode)
54
- }
55
-
56
- export const Badge = forwardRef<GetRefType<ViewProps['ref']>, BadgeProps>((props, ref) => {
57
- const {
58
- children = null,
59
- styles,
60
- text,
61
- textProps = {},
62
- ...viewProps
63
- } = props
64
-
65
- return <View style={[styles.wrapper]} {...viewProps} ref={ref}>
66
- {text && <Text text={text} style={styles.text} {...textProps}/>}
67
- {(TypeGuards.isFunction(children) ? children({ ...viewProps, styles, text }) : children)}
68
- </View>
69
- })
70
-
71
- export const Button = forwardRef<GetRefType<TouchableProps['ref']>, ButtonProps>((buttonProps, ref) => {
72
- const {
73
- variants = [],
74
- children,
75
- icon,
76
- text,
77
- loading,
78
- styles = {},
79
- onPress,
80
- disabled,
81
- badge = null,
82
- rightIcon,
83
- debounce = 600,
84
- style,
85
- ...props
86
- } = buttonProps
87
- const [pressed, setPressed] = React.useState(false)
88
-
89
- const variantStyles = useDefaultComponentStyle('u:Button', {
90
- variants,
91
- transform: StyleSheet.flatten,
92
- styles,
93
- })
94
-
95
- function handlePress() {
96
- if (!pressed) {
97
- setPressed(true)
98
-
99
- setTimeout(() => setPressed(false), debounce)
100
-
101
- onPress && onPress()
102
- }
103
- }
104
-
105
- function getStyles(key: ButtonParts) {
106
- return [
107
- variantStyles[key],
108
- key === 'wrapper' && style,
109
- disabled && variantStyles[key + ':disabled'],
110
- styles[key],
111
- disabled && styles[key + ':disabled'],
112
- ]
113
- }
114
-
115
- const iconStyle = getStyles('icon')
116
-
117
- const leftIconStyle = StyleSheet.flatten([iconStyle, getStyles('leftIcon')])
118
- const rightIconStyle = StyleSheet.flatten([iconStyle, getStyles('rightIcon')])
119
-
120
- const hasText = !!(text || children)
121
-
122
- const _styles = {
123
- wrapper: getStyles('wrapper'),
124
- loader: getStyles('loader'),
125
- leftIcon: leftIconStyle,
126
- rightIcon: rightIconStyle,
127
- text: getStyles('text'),
128
- icon: getStyles('icon'),
129
-
130
- }
131
-
132
- const childrenContent = typeof children === 'function' ?
133
- children({ styles: _styles, props: buttonProps, pressed })
134
- : children
135
-
136
- let _badge = null
137
-
138
- if (badge) {
139
- _badge = React.isValidElement(badge) ? badge : <Badge {...badge} styles={deepMerge({
140
- text: variantStyles.badgeText,
141
- wrapper: variantStyles.badgeWrapper,
142
- }, badge?.styles || {})}/>
143
-
144
- }
145
-
146
- return (
147
- <Touchable
148
- style={_styles.wrapper}
149
- onPress={handlePress}
150
- ref={ref}
151
- disabled={disabled}
152
- styles={{
153
- feedback: variantStyles.feedback,
154
- }}
155
- debugComponent={'Button'}
156
- noFeedback={!onPress}
157
- {...props}
158
- >
159
- {_badge}
160
- {loading && <ActivityIndicator style={_styles.loader} />}
161
- {!loading && <Icon name={icon} style={_styles.leftIcon} renderEmptySpace={hasText && !!rightIcon}/>}
162
- {text ? <Text text={text} style={_styles.text} /> : null}
163
- {childrenContent}
164
- <Icon name={rightIcon} style={_styles.rightIcon} renderEmptySpace={(hasText && !!icon) || loading} />
165
- </Touchable>
166
- )
167
- })
@@ -1,129 +0,0 @@
1
- import { createDefaultVariantFactory, includePresets, StylesOf } from '@codeleap/common'
2
- import { ActivityIndicatorComposition } from '../ActivityIndicator'
3
- import { TouchableStylesGen } from '../Touchable'
4
-
5
- export type ButtonStates = 'disabled'
6
- export type ButtonParts =
7
- | 'text'
8
- | 'inner'
9
- | 'wrapper'
10
- | 'icon'
11
- | 'leftIcon'
12
- | 'rightIcon'
13
- | 'loader'
14
- | `loader${Capitalize<ActivityIndicatorComposition>}`
15
- | 'badgeText'
16
- | 'badgeWrapper'
17
-
18
- export type ButtonComposition = `${ButtonParts}:${ButtonStates}` | ButtonParts
19
-
20
- export type ButtonStylesGen<TCSS = any> = StylesOf<ButtonComposition, TCSS> & {
21
- feedback?: TouchableStylesGen['feedback']
22
- }
23
-
24
- const createButtonStyle = createDefaultVariantFactory<ButtonComposition, ButtonStylesGen >()
25
-
26
- const presets = includePresets((styles) => createButtonStyle(() => ({ wrapper: styles })))
27
-
28
- export const ButtonStyles = {
29
- ...presets,
30
- default: createButtonStyle((theme) => ({
31
- wrapper: {
32
-
33
- flexDirection: 'row',
34
- backgroundColor: theme.colors.primary,
35
- ...theme.presets.justifyCenter,
36
- ...theme.presets.alignCenter,
37
- ...theme.spacing.paddingHorizontal(2.5),
38
- },
39
- text: {
40
- textAlign: 'center',
41
- // ...theme.spacing.marginHorizontal(2.5),
42
- },
43
- loader: {
44
- height: 20,
45
- width: 20,
46
- },
47
-
48
- loaderFrontCircle: {
49
- borderTopColor: theme.colors.white,
50
- },
51
- 'wrapper:disabled': {
52
- backgroundColor: theme.colors.disabled,
53
- opacity: 0.9,
54
- cursor: 'auto',
55
-
56
- },
57
- badgeWrapper: {
58
- backgroundColor: theme.colors.negative,
59
- position: 'absolute',
60
- ...theme.spacing.padding(2.5),
61
- },
62
- badgeText: {
63
- color: theme.colors.white,
64
- },
65
-
66
- leftIcon: {
67
- ...theme.sized(4),
68
- ...theme.spacing.marginRight('auto'),
69
- // ...theme.spacing.marginLeft(2.5),
70
- },
71
- rightIcon: {
72
- ...theme.spacing.marginLeft('auto'),
73
- // ...theme.spacing.marginRight(2.5),
74
- ...theme.sized(4),
75
- },
76
-
77
- })),
78
- negative: createButtonStyle((theme) => ({
79
- wrapper: {
80
- backgroundColor: theme.colors.negative,
81
-
82
- },
83
-
84
- })),
85
-
86
- circle: createButtonStyle((theme) => ({
87
- wrapper: {
88
- borderRadius: 100,
89
- ...theme.spacing.padding(1),
90
- },
91
- })),
92
- pill: createButtonStyle((theme) => ({
93
- wrapper: {
94
- borderRadius: theme.borderRadius.medium,
95
- ...theme.spacing.paddingHorizontal(1),
96
- ...theme.spacing.paddingVertical(0.5),
97
- },
98
- })),
99
- icon: createButtonStyle((theme) => ({
100
- wrapper: {
101
- backgroundColor: 'transparent',
102
- aspectRatio: 1,
103
- display: 'flex',
104
- ...theme.presets.center,
105
- ...theme.spacing.padding(0),
106
-
107
- },
108
- text: {
109
- flex: 1,
110
- textAlign: 'center',
111
- },
112
- loader: {
113
- ...theme.spacing.margin(0),
114
- },
115
- icon: {
116
- ...theme.spacing.margin(0),
117
- ...theme.presets.center,
118
- height: null,
119
- width: null,
120
- color: theme.colors.icon,
121
- },
122
- leftIcon: {
123
- ...theme.spacing.marginRight(0),
124
- },
125
- rightIcon: {
126
- ...theme.spacing.marginRight(0),
127
- },
128
- })),
129
- }
@@ -1,65 +0,0 @@
1
- import React from 'react'
2
- import { ComponentVariants, PropsOf, TypeGuards, useDefaultComponentStyle } from '@codeleap/common'
3
- import { StyleSheet } from 'react-native'
4
- import { format, formatISO } from 'date-fns'
5
- // @ts-ignore
6
- import { Calendar as RNCalendar, CalendarProps as RNCalendarProps, DateData } from 'react-native-calendars'
7
-
8
- import { View } from '../View'
9
- import { CalendarStyles } from './style'
10
- import { TCalendarStyles } from './types'
11
- export type CalendarProps = PropsOf<typeof View> & {
12
- styles?: TCalendarStyles
13
- onValueChange?: (date: Date|string) => any
14
- value?: Date|string
15
- calendarProps?: RNCalendarProps
16
- } & ComponentVariants<typeof CalendarStyles>
17
- export * from './style'
18
- export * from './types'
19
-
20
- export const Calendar = (props:CalendarProps) => {
21
- const {
22
- variants = [],
23
- style,
24
- styles = {},
25
- calendarProps,
26
- value,
27
- onValueChange,
28
- ...viewProps
29
- } = props
30
- const variantStyles = useDefaultComponentStyle<'u:Calendar', typeof CalendarStyles>('u:Calendar', {
31
- variants,
32
- styles,
33
- transform: StyleSheet.flatten,
34
- rootElement: 'wrapper',
35
- })
36
- const isDateObject = TypeGuards.isInstance(value, Date)
37
- const stringValue:string = isDateObject ? format(value, 'yyyy/MM/dd') : value
38
-
39
- function handleChange(date:DateData) {
40
- if (!onValueChange) return
41
- if (isDateObject) {
42
- onValueChange(new Date(date.timestamp))
43
- } else {
44
- onValueChange(date.dateString)
45
- }
46
- }
47
-
48
- return <View style={[variantStyles.wrapper, style]} {...viewProps}>
49
- <RNCalendar
50
- onDayPress={handleChange}
51
- current={new Date(value).toISOString()}
52
- monthFormat={'MMMM yyyy'}
53
- markedDates={{
54
- [stringValue]: { selected: true },
55
- }}
56
- theme={{
57
- ...variantStyles.theme,
58
- stylesheet: {
59
- ...variantStyles,
60
- },
61
- }}
62
- {...calendarProps}
63
- />
64
- </View>
65
- }
@@ -1,35 +0,0 @@
1
- import { createDefaultVariantFactory } from '@codeleap/common'
2
- import { TCalendarStyles, CalendarComposition } from './types'
3
-
4
- const createCalendarStyle = createDefaultVariantFactory<CalendarComposition, TCalendarStyles>()
5
-
6
- export const CalendarStyles = {
7
- default: createCalendarStyle((theme) => ({
8
- theme: {
9
- backgroundColor: '#0000',
10
- calendarBackground: '#0000',
11
- textSectionTitleColor: theme.colors.textH,
12
- textSectionTitleDisabledColor: theme.colors.disabled,
13
- selectedDayBackgroundColor: theme.colors.primary,
14
- selectedDayTextColor: theme.colors.white,
15
- todayTextColor: theme.colors.textH,
16
- dayTextColor: theme.colors.textP,
17
- textDisabledColor: theme.colors.disabled,
18
- dotColor: theme.colors.primary,
19
- selectedDotColor: theme.colors.primary,
20
- arrowColor: theme.colors.primary,
21
- disabledArrowColor: theme.colors.disabled,
22
- monthTextColor: theme.colors.textH,
23
- indicatorColor: theme.colors.backgroundSecondary,
24
- textDayFontFamily: theme.typography.fontFamily,
25
- textMonthFontFamily: theme.typography.fontFamily,
26
- textDayHeaderFontFamily: theme.typography.fontFamily,
27
- textDayFontWeight: '400',
28
- textMonthFontWeight: 'bold',
29
- textDayHeaderFontWeight: '400',
30
- textDayFontSize: 16,
31
- textMonthFontSize: 22,
32
- textDayHeaderFontSize: 15,
33
- },
34
- })),
35
- }
@@ -1,102 +0,0 @@
1
- import { FilterKeys } from '@codeleap/common'
2
- import { Paths } from '@codeleap/common/dist/types/pathMapping'
3
- import { TextStyle, ViewStyle } from 'react-native';
4
-
5
- type CalendarTheme = {
6
- timelineContainer?: object;
7
- contentStyle?: ViewStyle;
8
- event?: object;
9
- eventTitle?: object;
10
- eventSummary?: object;
11
- eventTimes?: object;
12
- line?: object;
13
- verticalLine?: object;
14
- nowIndicatorLine?: object;
15
- nowIndicatorKnob?: object;
16
- timeLabel?: object;
17
- todayTextColor?: string;
18
- calendarBackground?: string;
19
- indicatorColor?: string;
20
- textSectionTitleColor?: string;
21
- textSectionTitleDisabledColor?: string;
22
- dayTextColor?: string;
23
- selectedDayTextColor?: string;
24
- monthTextColor?: string;
25
- selectedDayBackgroundColor?: string;
26
- arrowColor?: string;
27
- textDisabledColor?: string;
28
- textInactiveColor?: string;
29
- backgroundColor?: string; //TODO: remove in V2
30
- dotColor?: string;
31
- selectedDotColor?: string;
32
- disabledArrowColor?: string;
33
- textDayFontFamily?: TextStyle['fontFamily'];
34
- textMonthFontFamily?: TextStyle['fontFamily'];
35
- textDayHeaderFontFamily?: TextStyle['fontFamily'];
36
- textDayFontWeight?: TextStyle['fontWeight'];
37
- textMonthFontWeight?: TextStyle['fontWeight'];
38
- textDayHeaderFontWeight?: TextStyle['fontWeight'];
39
- textDayFontSize?: number;
40
- textMonthFontSize?: number;
41
- textDayHeaderFontSize?: number;
42
- agendaDayTextColor?: string;
43
- agendaDayNumColor?: string;
44
- agendaTodayColor?: string;
45
- agendaKnobColor?: string;
46
- todayButtonFontFamily?: TextStyle['fontFamily'];
47
- todayButtonFontWeight?: TextStyle['fontWeight'];
48
- todayButtonFontSize?: number;
49
- textDayStyle?: TextStyle;
50
- dotStyle?: object;
51
- arrowStyle?: ViewStyle;
52
- todayBackgroundColor?: string;
53
- disabledDotColor?: string;
54
- inactiveDotColor?: string;
55
- todayDotColor?: string;
56
- todayButtonTextColor?: string;
57
- todayButtonPosition?: string;
58
- arrowHeight?: number;
59
- arrowWidth?: number;
60
- weekVerticalMargin?: number;
61
- stylesheet?: {
62
- calendar?: {
63
- main?: object;
64
- header?: object;
65
- };
66
- day?: {
67
- basic?: object;
68
- period?: object;
69
- };
70
- dot?: object;
71
- marking?: object;
72
- 'calendar-list'?: {
73
- main?: object;
74
- };
75
- agenda?: {
76
- main?: object;
77
- list?: object;
78
- };
79
- expandable?: {
80
- main?: object;
81
- };
82
- };
83
- }
84
-
85
- type FlatStyleKeys = 'dot' | 'marking'
86
-
87
- type StyleSheetKeys = Exclude<keyof CalendarTheme['stylesheet'], FlatStyleKeys>
88
-
89
- type ThemeObjPrimitiveKeys = FilterKeys<CalendarTheme, string|number>
90
-
91
- type ThemeObjCompositionKeys = Exclude<keyof CalendarTheme, ThemeObjPrimitiveKeys | 'stylesheet'>
92
-
93
- type StyleSheetObjKeys = Exclude<Paths<CalendarTheme['stylesheet']>, StyleSheetKeys>
94
-
95
- export type CalendarStyleGen<TCSS = any> = {
96
- theme?: Partial<{
97
- [P in ThemeObjPrimitiveKeys]: CalendarTheme[P]
98
- }>
99
- } & Partial<Record<StyleSheetObjKeys | 'wrapper' | ThemeObjCompositionKeys, TCSS>>
100
-
101
- export type CalendarComposition = keyof CalendarStyleGen
102
- export type TCalendarStyles = CalendarStyleGen<any>
@@ -1,91 +0,0 @@
1
- import * as React from 'react'
2
- import {
3
- ComponentVariants,
4
- useDefaultComponentStyle,
5
- StylesOf,
6
- Form,
7
- useValidate,
8
- GetRefType,
9
- PropsOf,
10
- } from '@codeleap/common'
11
- import { ComponentPropsWithRef, forwardRef, ReactNode } from 'react'
12
- import { StyleSheet, Switch as NativeCheckbox } from 'react-native'
13
- import { FormError } from '../TextInput'
14
- import { View } from '../View'
15
- import { Touchable } from '../Touchable'
16
- import {
17
- CheckboxStyles,
18
- CheckboxComposition,
19
- } from './styles'
20
- import { InputLabel } from '../InputLabel'
21
- export * from './styles'
22
-
23
- type NativeCheckboxProps = Omit<
24
- ComponentPropsWithRef<typeof NativeCheckbox>,
25
- 'thumbColor' | 'trackColor'
26
- >
27
- type CheckboxProps = NativeCheckboxProps & {
28
- variants?: ComponentVariants<typeof CheckboxStyles>['variants']
29
- label?: ReactNode
30
- styles?: StylesOf<CheckboxComposition>
31
- validate?: Form.ValidatorFunctionWithoutForm | string
32
- required?: boolean
33
- }
34
-
35
- export const Checkbox = forwardRef<GetRefType<PropsOf<typeof View>['ref']>, CheckboxProps>(
36
- (checkboxProps, ref) => {
37
- const {
38
- variants = [],
39
- style = {},
40
- styles = {},
41
- label,
42
- value,
43
- onValueChange,
44
- validate,
45
- required,
46
- ...props
47
- } = checkboxProps
48
-
49
- const variantStyles = useDefaultComponentStyle<'u:Checkbox', typeof CheckboxStyles>('u:Checkbox', {
50
- variants,
51
- styles,
52
- transform: StyleSheet.flatten,
53
- })
54
-
55
- const { error, showError } = useValidate(value, validate)
56
-
57
- function getStyles(key: CheckboxComposition, styleObj = variantStyles) {
58
- return [
59
- styleObj[key],
60
- value ? styleObj[key + ':checked'] : {},
61
- showError ? styleObj[key + ':error'] : {},
62
- checkboxProps.disabled ? styleObj[key + ':disabled'] : {},
63
- ]
64
- }
65
-
66
- return (
67
- <View style={[getStyles('wrapper'), style]} ref={ref} {...props}>
68
- <Touchable
69
- debugName={`Set checkbox value to ${!value}`}
70
- style={getStyles('input')}
71
- onPress={() => onValueChange(!value)}
72
- styles={{
73
- feedback: getStyles('inputFeedback'),
74
- }}
75
- >
76
- <View style={getStyles('checkmarkWrapper')}>
77
- <View style={getStyles('checkmark')} />
78
- </View>
79
-
80
- <InputLabel label={label} styles={{
81
- asterisk: getStyles('labelAsterisk'),
82
- wrapper: getStyles('labelWrapper'),
83
- text: getStyles('labelText'),
84
- }} required={required}/>
85
-
86
- </Touchable>
87
- <FormError text={error.message} style={getStyles('error')} />
88
- </View>
89
- )
90
- },
91
- )
@@ -1,81 +0,0 @@
1
- import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
- import { InputLabelComposition } from '../InputLabel'
3
-
4
- type CheckboxParts =
5
- | 'wrapper'
6
- | 'input'
7
- | 'inputFeedback'
8
- | 'checkmark'
9
- | 'checkmarkWrapper'
10
- | 'error'
11
- | `label${Capitalize<InputLabelComposition>}`
12
-
13
- export type CheckboxComposition =
14
- | CheckboxParts
15
- | `${CheckboxParts}:checked`
16
- | `${CheckboxParts}:disabled`
17
- | `${CheckboxParts}:error`
18
- const createCheckboxStyle =
19
- createDefaultVariantFactory<CheckboxComposition>()
20
-
21
- const presets = includePresets((styles) => createCheckboxStyle(() => ({ wrapper: styles })),
22
- )
23
-
24
- export const CheckboxStyles = {
25
- ...presets,
26
- default: createCheckboxStyle((theme) => {
27
- const size = theme.typography.baseFontSize * 1.2
28
-
29
- const markHeight = size * 0.5
30
- const markWidth = size * 0.25
31
-
32
- const translateX = -(markWidth / 2)
33
- const translateY = -(markHeight / 2)
34
- return {
35
- wrapper: {},
36
- input: {
37
- flexDirection: 'row',
38
- ...theme.presets.alignCenter,
39
-
40
- },
41
- labelWrapper: {
42
- // flex: 1,
43
- ...theme.spacing.marginLeft(1),
44
-
45
- },
46
- inputFeedback: {
47
- type: 'opacity',
48
- value: 0.5,
49
- },
50
-
51
- checkmark: {
52
- position: 'absolute',
53
- top: '40%',
54
- left: '50%',
55
-
56
- height: markHeight,
57
- width: markWidth,
58
- transform: [{ translateX }, { translateY }, { rotate: '45deg' }],
59
- },
60
- 'checkmark:checked': {
61
- ...theme.border.white({
62
- width: 2,
63
- directions: ['right', 'bottom'],
64
- }),
65
- },
66
- checkmarkWrapper: {
67
- position: 'relative',
68
- width: size,
69
- borderRadius: theme.borderRadius.small,
70
- height: size,
71
- ...theme.border.neutral(1),
72
- },
73
- 'checkmarkWrapper:checked': {
74
- backgroundColor: theme.colors.primary,
75
- },
76
- error: {
77
- color: theme.colors.negative,
78
- },
79
- }
80
- }),
81
- }