@codeleap/web 3.4.0 → 3.5.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 (59) hide show
  1. package/package.json +3 -1
  2. package/src/components/ActionIcon/index.tsx +49 -30
  3. package/src/components/ActionIcon/styles.ts +8 -5
  4. package/src/components/ActivityIndicator/index.tsx +6 -5
  5. package/src/components/Badge/index.tsx +135 -0
  6. package/src/components/Badge/styles.ts +15 -0
  7. package/src/components/Button/index.tsx +79 -69
  8. package/src/components/Button/styles.ts +10 -14
  9. package/src/components/Checkbox/index.tsx +9 -3
  10. package/src/components/Collapse/index.tsx +6 -3
  11. package/src/components/Drawer/index.tsx +72 -44
  12. package/src/components/Drawer/styles.ts +11 -3
  13. package/src/components/EmptyPlaceholder/index.tsx +135 -0
  14. package/src/components/EmptyPlaceholder/styles.ts +16 -0
  15. package/src/components/Grid/index.tsx +169 -0
  16. package/src/components/Grid/styles.ts +10 -0
  17. package/src/components/Grid/types.ts +24 -0
  18. package/src/components/Icon/index.tsx +7 -4
  19. package/src/components/InputBase/styles.ts +8 -56
  20. package/src/components/InputBase/utils.ts +63 -0
  21. package/src/components/List/ListLayout.tsx +98 -0
  22. package/src/components/List/PaginationIndicator.tsx +102 -0
  23. package/src/components/List/index.tsx +104 -91
  24. package/src/components/List/styles.ts +17 -5
  25. package/src/components/List/types.ts +51 -0
  26. package/src/components/List/useInfiniteScroll.ts +113 -0
  27. package/src/components/LoadingOverlay/index.tsx +5 -3
  28. package/src/components/Modal/index.tsx +30 -29
  29. package/src/components/NumberIncrement/index.tsx +3 -2
  30. package/src/components/Overlay/index.tsx +12 -2
  31. package/src/components/Pager/index.tsx +5 -1
  32. package/src/components/RadioInput/index.tsx +4 -3
  33. package/src/components/SearchInput/index.tsx +93 -0
  34. package/src/components/SegmentedControl/SegmentedControlOption.tsx +15 -9
  35. package/src/components/SegmentedControl/index.tsx +12 -5
  36. package/src/components/Select/index.tsx +18 -14
  37. package/src/components/Select/styles.ts +4 -3
  38. package/src/components/Select/types.ts +4 -3
  39. package/src/components/Slider/index.tsx +3 -2
  40. package/src/components/Switch/index.tsx +4 -2
  41. package/src/components/Text/index.tsx +98 -25
  42. package/src/components/Text/styles.ts +4 -4
  43. package/src/components/TextInput/index.tsx +6 -15
  44. package/src/components/Tooltip/index.tsx +163 -131
  45. package/src/components/Tooltip/styles.ts +13 -9
  46. package/src/components/Touchable/index.tsx +88 -26
  47. package/src/components/Touchable/styles.ts +4 -6
  48. package/src/components/View/index.tsx +1 -1
  49. package/src/components/components.ts +5 -1
  50. package/src/components/defaultStyles.ts +10 -3
  51. package/src/index.ts +2 -0
  52. package/src/lib/hooks.ts +27 -13
  53. package/src/lib/index.ts +4 -1
  54. package/src/lib/useBreakpointMatch.ts +33 -0
  55. package/src/lib/usePopState.ts +30 -0
  56. package/src/lib/useSearchParams.ts +54 -0
  57. package/src/lib/utils/stopPropagation.ts +3 -3
  58. package/src/types/index.ts +1 -1
  59. package/src/types/utility.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/web",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "main": "src/index.ts",
5
5
  "repository": {
6
6
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -21,6 +21,8 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@radix-ui/react-slider": "1.1.1",
24
+ "@radix-ui/react-tooltip": "^1.0.6",
25
+ "@tanstack/react-virtual": "^3.0.0-beta.54",
24
26
  "framer-motion": "^10.10.0",
25
27
  "js-cookie": "^3.0.1",
26
28
  "rc-slider": "^9.7.5",
@@ -1,27 +1,48 @@
1
- /** @jsx jsx */
2
- import { jsx, CSSObject } from '@emotion/react'
3
-
4
- import { ComponentVariants, PropsOf, TypeGuards, useDefaultComponentStyle } from '@codeleap/common'
5
- import { StylesOf } from '../../types'
1
+ import { ComponentVariants, TypeGuards, useDefaultComponentStyle } from '@codeleap/common'
2
+ import { ComponentCommonProps, StylesOf } from '../../types'
6
3
  import { Icon, IconProps } from '../Icon'
7
- import { Touchable } from '../Touchable'
4
+ import { Touchable, TouchableProps } from '../Touchable'
8
5
  import { View } from '../View'
9
- import { ActionIconComposition, ActionIconPresets } from './styles'
6
+ import { ActionIconComposition, ActionIconParts, ActionIconPresets } from './styles'
10
7
 
11
- export type ActionIconProps = {
12
- iconProps?: Partial<IconProps>
13
- icon?: IconProps['name']
14
- name?: IconProps['name']
15
- action?: () => void
16
- styles?: StylesOf<ActionIconComposition>
17
- } & Omit<PropsOf<typeof Touchable>, 'styles' | 'variants'> & ComponentVariants<typeof ActionIconPresets>
8
+ export * from './styles'
18
9
 
19
- export const ActionIcon = (props:ActionIconProps) => {
20
- const { icon, name, iconProps, onPress, variants, styles, children, disabled, ...touchableProps } = props
10
+ export type ActionIconProps = Omit<TouchableProps, 'styles' | 'variants'> & ComponentCommonProps & {
11
+ iconProps?: Partial<IconProps>
12
+ icon?: IconProps['name']
13
+ name?: IconProps['name']
14
+ styles?: StylesOf<ActionIconComposition>
15
+ } & ComponentVariants<typeof ActionIconPresets>
21
16
 
17
+ const defaultProps: Partial<ActionIconProps> = {
18
+ disabled: false,
19
+ }
20
+
21
+ export const ActionIcon = (props: ActionIconProps) => {
22
+ const allProps = {
23
+ ...ActionIcon.defaultProps,
24
+ ...props,
25
+ }
26
+
27
+ const {
28
+ icon,
29
+ name,
30
+ iconProps,
31
+ onPress,
32
+ responsiveVariants = {},
33
+ variants = [],
34
+ styles = {},
35
+ children,
36
+ disabled,
37
+ debugName,
38
+ ...touchableProps
39
+ } = allProps
40
+
22
41
  const variantStyles = useDefaultComponentStyle<'u:ActionIcon', typeof ActionIconPresets>('u:ActionIcon', {
23
- variants,
42
+ responsiveVariants,
43
+ variants,
24
44
  styles,
45
+ rootElement: 'touchableWrapper'
25
46
  })
26
47
 
27
48
  const isPressable = TypeGuards.isFunction(onPress) && !disabled
@@ -34,16 +55,17 @@ export const ActionIcon = (props:ActionIconProps) => {
34
55
  if (onPress) onPress?.()
35
56
  }
36
57
 
58
+ const getStyles = (key: ActionIconParts) => ({
59
+ ...variantStyles[key],
60
+ ...(disabled ? variantStyles[`${key}:disabled`] : {}),
61
+ ...(isPressable ? variantStyles[`${key}:pressable`] : {})
62
+ })
63
+
37
64
  return (
38
- // @ts-ignore
39
65
  <WrapperComponent
40
- onPress={handlePress}
41
- css={[
42
- variantStyles.wrapper,
43
- disabled && variantStyles['wrapper:disabled'],
44
- isPressable && variantStyles['wrapper:cursor'],
45
- ]}
66
+ css={getStyles('touchableWrapper')}
46
67
  disabled={disabled}
68
+ debugName={debugName}
47
69
  {
48
70
  ...(isPressable && {
49
71
  onPress: handlePress,
@@ -52,17 +74,14 @@ export const ActionIcon = (props:ActionIconProps) => {
52
74
  {...touchableProps}
53
75
  >
54
76
  <Icon
77
+ debugName={debugName}
55
78
  name={icon ?? name}
79
+ style={getStyles('icon')}
56
80
  {...iconProps}
57
- // @ts-ignore
58
- css={[
59
- variantStyles.icon,
60
- disabled && variantStyles['icon:disabled'],
61
- ]}
62
81
  />
63
82
  {children}
64
83
  </WrapperComponent>
65
84
  )
66
85
  }
67
86
 
68
- export * from './styles'
87
+ ActionIcon.defaultProps = defaultProps
@@ -1,9 +1,12 @@
1
1
  import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
- import { TouchableComposition } from '../Touchable'
2
+ import { IconComposition } from '../Icon'
3
+ import { TouchableComposition } from '../Touchable/styles'
4
+
5
+ export type ActionIconParts = IconComposition | `touchable${Capitalize<TouchableComposition>}`
6
+ export type ActionIconStates = 'disabled' | 'pressable'
7
+
8
+ export type ActionIconComposition = ActionIconParts | `${ActionIconParts}:${ActionIconStates}`
3
9
 
4
- export type ActionIconParts = 'icon' | TouchableComposition
5
- export type ActionIconStates = ':disabled' | ':cursor' | ''
6
- export type ActionIconComposition = `${ActionIconParts}${ActionIconStates}`
7
10
  const createActionIconStyle = createDefaultVariantFactory<ActionIconComposition>()
8
11
 
9
- export const ActionIconPresets = includePresets((style) => createActionIconStyle(() => ({ wrapper: style })))
12
+ export const ActionIconPresets = includePresets((style) => createActionIconStyle(() => ({ touchableWrapper: style })))
@@ -10,11 +10,11 @@ import {
10
10
  } from '@codeleap/common'
11
11
  import { ActivityIndicatorPresets } from './styles'
12
12
  import { CSSInterpolation } from '@emotion/css'
13
- import { ComponentWithDefaultProps } from '../../types'
13
+ import { ComponentCommonProps, ComponentWithDefaultProps } from '../../types'
14
14
 
15
15
  export * from './styles'
16
16
 
17
- export type ActivityIndicatorProps = {
17
+ export type ActivityIndicatorProps = ComponentCommonProps & {
18
18
  style?: React.CSSProperties
19
19
  styles?: StylesOf<ActivityIndicatorComposition>
20
20
  css?: CSSInterpolation | CSSInterpolation[]
@@ -41,9 +41,10 @@ export const ActivityIndicator = React.forwardRef<typeof View, ActivityIndicator
41
41
  const variantStyles = useDefaultComponentStyle<'u:ActivityIndicator', typeof ActivityIndicatorPresets>(
42
42
  'u:ActivityIndicator',
43
43
  {
44
+ responsiveVariants,
44
45
  variants,
45
46
  styles,
46
- responsiveVariants,
47
+ rootElement: 'wrapper',
47
48
  },
48
49
  )
49
50
 
@@ -55,10 +56,10 @@ export const ActivityIndicator = React.forwardRef<typeof View, ActivityIndicator
55
56
  }, [size])
56
57
 
57
58
  return (
58
- <View css={[variantStyles.wrapper, style, _size]}>
59
+ <View css={[variantStyles.wrapper, _size, style]}>
59
60
  <Component
60
61
  ref={ref}
61
- css={[variantStyles.wrapper, _size]}
62
+ css={[variantStyles.wrapper, _size, style]}
62
63
  {...props}
63
64
  />
64
65
  </View>
@@ -0,0 +1,135 @@
1
+ import React from 'react'
2
+ import { ComponentVariants, PropsOf, StylesOf, TypeGuards, useDefaultComponentStyle } from '@codeleap/common'
3
+ import { Text } from '../Text'
4
+ import { View, ViewProps } from '../View'
5
+ import { BadgeComposition, BadgePresets } from './styles'
6
+ import { ComponentCommonProps } from '../../types'
7
+
8
+ export * from './styles'
9
+
10
+ export type BadgeProps = ComponentVariants<typeof BadgePresets>
11
+ & ViewProps<'div'>
12
+ & ComponentCommonProps
13
+ & {
14
+ styles?: StylesOf<BadgeComposition>
15
+ maxCount?: number
16
+ minCount?: number
17
+ debugName?: string
18
+ innerWrapperProps?: Partial<PropsOf<typeof View>>
19
+ textProps?: Partial<PropsOf<typeof Text>>
20
+ getBadgeContent?: (props: BadgeContent) => string
21
+ renderBadgeContent?: (props: BadgeContent & { content: string }) => JSX.Element
22
+ disabled?: boolean
23
+ badge?: number | boolean
24
+ }
25
+
26
+ type BadgeContent = BadgeProps & { count: number }
27
+
28
+ export type BadgeComponentProps = {
29
+ badge?: BadgeProps['badge']
30
+ badgeProps?: Partial<BadgeProps>
31
+ }
32
+
33
+ const defaultGetBadgeContent = ({ count, maxCount }: BadgeContent) => {
34
+ if (Number(count) > maxCount) {
35
+ return `${maxCount}+`
36
+ } else {
37
+ return String(count)
38
+ }
39
+ }
40
+
41
+ const defaultProps: Partial<BadgeProps> = {
42
+ maxCount: 9,
43
+ minCount: 1,
44
+ getBadgeContent: defaultGetBadgeContent,
45
+ renderBadgeContent: null,
46
+ disabled: false,
47
+ badge: true,
48
+ }
49
+
50
+ export const Badge = (props: BadgeProps) => {
51
+ const allProps = {
52
+ ...Badge.defaultProps,
53
+ ...props,
54
+ }
55
+
56
+ const {
57
+ debugName,
58
+ innerWrapperProps = {},
59
+ textProps = {},
60
+ maxCount,
61
+ minCount,
62
+ getBadgeContent,
63
+ renderBadgeContent,
64
+ styles = {},
65
+ variants = [],
66
+ responsiveVariants = {},
67
+ disabled,
68
+ style = {},
69
+ css,
70
+ badge,
71
+ ...rest
72
+ } = allProps
73
+
74
+ const visible = (TypeGuards.isBoolean(badge) && badge === true) || TypeGuards.isNumber(badge)
75
+
76
+ if (!visible) return null
77
+
78
+ const variantStyles = useDefaultComponentStyle<'u:Badge', typeof BadgePresets>('u:Badge', {
79
+ responsiveVariants,
80
+ variants,
81
+ styles,
82
+ rootElement: 'wrapper',
83
+ })
84
+
85
+ const wrapperStyles = [
86
+ variantStyles?.wrapper,
87
+ (disabled && variantStyles?.['wrapper:disabled']),
88
+ css,
89
+ style,
90
+ ]
91
+
92
+ const innerWrapperStyles = [
93
+ variantStyles?.innerWrapper,
94
+ (disabled && variantStyles?.['innerWrapper:disabled']),
95
+ innerWrapperProps?.style,
96
+ ]
97
+
98
+ const countStyles = [
99
+ variantStyles?.count,
100
+ (disabled && variantStyles?.['count:disabled']),
101
+ textProps?.style,
102
+ ]
103
+
104
+ const count = TypeGuards.isNumber(badge) ? badge : null
105
+
106
+ const content = getBadgeContent({ ...props, maxCount, minCount, count })
107
+
108
+ const showContent = TypeGuards.isNumber(count) && count >= minCount
109
+
110
+ let BadgeContent = renderBadgeContent
111
+
112
+ if (TypeGuards.isNil(renderBadgeContent)) {
113
+ BadgeContent = () => <Text text={content} {...textProps} css={countStyles} />
114
+ }
115
+
116
+ return (
117
+ <View {...rest} css={wrapperStyles}>
118
+ <View {...innerWrapperProps} css={innerWrapperStyles}>
119
+ {showContent
120
+ ? <BadgeContent
121
+ {...props}
122
+ maxCount={maxCount}
123
+ minCount={minCount}
124
+ count={count}
125
+ getBadgeContent={getBadgeContent}
126
+ content={content}
127
+ />
128
+ : null
129
+ }
130
+ </View>
131
+ </View>
132
+ )
133
+ }
134
+
135
+ Badge.defaultProps = defaultProps
@@ -0,0 +1,15 @@
1
+ import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
+
3
+ type BadgeParts = 'wrapper' | 'innerWrapper' | 'count'
4
+
5
+ type BadgeStates = 'disabled'
6
+
7
+ export type BadgeComposition =
8
+ `${BadgeParts}:${BadgeStates}`
9
+ | BadgeParts
10
+
11
+ const createBadgeStyle = createDefaultVariantFactory<BadgeComposition>()
12
+
13
+ export const BadgePresets = includePresets((styles) => createBadgeStyle(() => ({
14
+ wrapper: styles
15
+ })))
@@ -1,121 +1,131 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react'
3
-
1
+ import React from 'react'
4
2
  import {
5
3
  useDefaultComponentStyle,
6
- ButtonStyles,
7
4
  ComponentVariants,
8
- ButtonComposition,
9
- ButtonParts,
10
- optionalObject,
11
5
  AnyFunction,
12
- EnhancedTheme,
13
- ComponentStyleMap,
14
- CommonVariantObject,
15
- AppTheme,
6
+ TypeGuards,
7
+ IconPlaceholder,
8
+ StylesOf,
16
9
  } from '@codeleap/common'
17
- import React from 'react'
18
- import { StylesOf } from '../../types/utility'
19
10
  import { Text } from '../Text'
20
11
  import { Touchable, TouchableProps } from '../Touchable'
21
12
  import { Icon } from '../Icon'
22
- import { IconPlaceholder, useNestedStylesByKey } from '@codeleap/common'
23
- import { LoadingOverlay } from '../LoadingOverlay'
24
- import { ActivityIndicator } from '../ActivityIndicator'
25
-
26
- export type ButtonProps =
27
- ComponentVariants<typeof ButtonStyles> & {
13
+ import { ActivityIndicator, ActivityIndicatorProps } from '../ActivityIndicator'
14
+ import { ButtonComposition, ButtonPresets, ButtonParts } from './styles'
15
+ import { ComponentCommonProps } from '../../types'
16
+
17
+ export type ButtonProps =
18
+ ComponentVariants<typeof ButtonPresets> &
19
+ Partial<Omit<TouchableProps<'button'>, 'variants' | 'styles'>> &
20
+ ComponentCommonProps & {
28
21
  text?: string
29
22
  rightIcon?: IconPlaceholder
30
23
  icon?: IconPlaceholder
31
24
  onPress?: AnyFunction
32
25
  styles?: StylesOf<ButtonComposition>
26
+ style?: React.CSSProperties
33
27
  loading?: boolean
28
+ loadingShowText?: boolean
34
29
  debugName: string
35
30
  debounce?: number
36
- } & Partial<TouchableProps<'button'>>
31
+ selected?: boolean
32
+ children?: React.ReactNode | ((props: Partial<Omit<ButtonProps, 'children'>>) => JSX.Element)
33
+ loaderProps?: Partial<ActivityIndicatorProps>
34
+ }
35
+
36
+ const defaultProps: Partial<ButtonProps> = {
37
+ debounce: 600,
38
+ loadingShowText: false,
39
+ }
40
+
41
+ export const Button = (buttonProps: ButtonProps) => {
42
+ const allProps = {
43
+ ...Button.defaultProps,
44
+ ...buttonProps
45
+ }
37
46
 
38
- export const Button = (buttonProps:ButtonProps) => {
39
47
  const {
40
48
  variants = [],
41
49
  responsiveVariants = {},
50
+ styles = {},
42
51
  children,
43
52
  icon,
44
53
  text,
45
54
  loading,
46
- styles,
55
+ loadingShowText,
47
56
  onPress,
48
57
  disabled,
49
58
  rightIcon,
50
- debounce = 600,
59
+ selected,
60
+ loaderProps = {},
61
+ debugName,
51
62
  ...props
52
- } = buttonProps
63
+ } = allProps
53
64
 
54
- const [pressed, setPressed] = React.useState(false)
55
- const variantStyles = useDefaultComponentStyle('Button', {
65
+ const variantStyles = useDefaultComponentStyle<'u:Button', typeof ButtonPresets>('u:Button', {
56
66
  responsiveVariants,
57
67
  variants,
58
68
  styles,
69
+ rootElement: 'wrapper',
59
70
  })
60
71
 
61
- function handlePress(e?: Parameters<ButtonProps['onPress']>[0]) {
62
- if (!pressed) {
63
- props?.onClick?.(e)
64
-
65
- setPressed(true)
66
-
67
- setTimeout(() => setPressed(false), debounce)
72
+ const getStyles = (key: ButtonParts) => ({
73
+ ...variantStyles?.[key],
74
+ ...(disabled ? variantStyles?.[key + ':disabled'] : {}),
75
+ ...(selected ? variantStyles?.[key + ':selected'] : {})
76
+ })
68
77
 
69
- onPress && onPress()
70
- }
78
+ const iconStyles = getStyles('icon')
79
+
80
+ const _styles: StylesOf<ButtonParts> = {
81
+ wrapper: getStyles('wrapper'),
82
+ text: getStyles('text'),
83
+ loaderWrapper: getStyles('loaderWrapper'),
84
+ leftIcon: {
85
+ ...iconStyles,
86
+ ...getStyles('leftIcon'),
87
+ },
88
+ rightIcon: {
89
+ ...iconStyles,
90
+ ...getStyles('rightIcon')
91
+ },
71
92
  }
72
93
 
73
- function getStyles(key:ButtonParts) {
94
+ const childrenContent = TypeGuards.isFunction(children)
95
+ // @ts-ignore
96
+ ? children(allProps)
97
+ : children
74
98
 
75
- return {
76
- ...variantStyles[key],
77
- ...optionalObject(disabled, variantStyles[key + ':disabled'], {}),
78
- }
79
- }
80
- const iconStyle = getStyles('icon')
99
+ // TODO - This is a hack to hide the icon with display: none
100
+ const isLeftIconHide = _styles?.leftIcon?.display === 'none'
101
+
102
+ const shouldRenderLeftIcon = !loading && !isLeftIconHide
81
103
 
82
- const loaderStyle = useNestedStylesByKey('loading', variantStyles)
104
+ const _hideTextOnLoading = !loadingShowText && loading
83
105
 
84
106
  return (
85
107
  <Touchable
86
- css={getStyles('wrapper')}
108
+ css={_styles.wrapper}
87
109
  component='button'
88
110
  debugComponent='Button'
111
+ disabled={disabled}
112
+ onPress={onPress}
113
+ debugName={debugName}
89
114
  {...props}
90
- onPress={null}
91
- onClick={handlePress}
92
115
  >
93
- <LoadingOverlay
94
- visible={loading}
95
- styles={loaderStyle}
96
- />
97
- {!loading && (
98
- <Icon
99
- name={icon}
100
- style={{ ...iconStyle, ...getStyles('leftIcon') }}
101
-
102
- />
116
+ {shouldRenderLeftIcon && <Icon debugName={debugName} name={icon} style={_styles.leftIcon} />}
117
+ {TypeGuards.isString(text) && !_hideTextOnLoading ? <Text debugName={debugName} text={text} css={[_styles.text]} /> : null }
118
+
119
+ {childrenContent}
120
+
121
+ <Icon debugName={debugName} name={rightIcon} style={_styles.rightIcon}/>
122
+ {loading && (
123
+ <ActivityIndicator debugName={debugName} style={_styles.loaderWrapper} {...loaderProps} />
103
124
  )}
104
- {children || (
105
- <Text
106
- text={text}
107
- css={getStyles('text')}
108
- />
109
- )}
110
-
111
- <Icon
112
- name={rightIcon}
113
- style={{ ...iconStyle, ...getStyles('rightIcon') }}
114
-
115
- />
116
- {loading && <ActivityIndicator css={{ display: 'none' }} />}
117
125
  </Touchable>
118
126
  )
119
127
  }
120
128
 
129
+ Button.defaultProps = defaultProps
130
+
121
131
  export * from './styles'
@@ -1,22 +1,18 @@
1
- import { createDefaultVariantFactory, includePresets, StylesOf } from '@codeleap/common'
2
- import { LoadingOverlayComposition } from '../LoadingOverlay'
1
+ import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
+ import { ActivityIndicatorComposition } from '../ActivityIndicator'
3
+
4
+ export type ButtonStates = 'disabled' | 'selected'
3
5
 
4
- export type ButtonStates = 'disabled'
5
6
  export type ButtonParts =
6
- | 'text'
7
- | 'inner'
8
- | 'wrapper'
9
- | 'icon'
10
- | 'leftIcon'
11
- | 'rightIcon'
12
- | `loading${Capitalize<LoadingOverlayComposition>}`
13
- | 'badgeText'
14
- | 'badgeWrapper'
7
+ | 'wrapper'
8
+ | 'text'
9
+ | 'icon'
10
+ | 'leftIcon'
11
+ | 'rightIcon'
12
+ | `loader${Capitalize<ActivityIndicatorComposition>}`
15
13
 
16
14
  export type ButtonComposition = `${ButtonParts}:${ButtonStates}` | ButtonParts
17
15
 
18
-
19
-
20
16
  const createButtonStyle = createDefaultVariantFactory<ButtonComposition>()
21
17
 
22
18
  export const ButtonPresets = includePresets((styles) => createButtonStyle(() => ({ wrapper: styles })))
@@ -12,20 +12,20 @@ import { InputBase, InputBaseDefaultOrder, InputBaseProps, selectInputBaseProps
12
12
  import { useAnimatedVariantStyles } from '../..'
13
13
  import { Icon } from '../Icon'
14
14
  import { motion } from 'framer-motion'
15
+ import { ComponentCommonProps } from '../../types/utility'
15
16
 
16
17
  export * from './styles'
17
18
 
18
19
  export type CheckboxProps = Pick<
19
20
  InputBaseProps,
20
21
  'debugName' | 'disabled' | 'label'
21
- > & {
22
- variants?: ComponentVariants<typeof CheckboxPresets>['variants']
22
+ > & ComponentCommonProps & {
23
23
  styles?: StylesOf<CheckboxComposition>
24
24
  value: boolean
25
25
  onValueChange: (value: boolean) => void
26
26
  style?: PropsOf<typeof View>['style']
27
27
  checkboxOnLeft?: boolean
28
- }
28
+ } & ComponentVariants<typeof CheckboxPresets>
29
29
 
30
30
  const reversedOrder = [...InputBaseDefaultOrder].reverse()
31
31
 
@@ -36,6 +36,7 @@ export const Checkbox = (props: CheckboxProps) => {
36
36
  } = selectInputBaseProps(props)
37
37
 
38
38
  const {
39
+ responsiveVariants = {},
39
40
  variants = [],
40
41
  style = {},
41
42
  styles = {},
@@ -47,6 +48,7 @@ export const Checkbox = (props: CheckboxProps) => {
47
48
  } = others
48
49
 
49
50
  const variantStyles = useDefaultComponentStyle<'u:Checkbox', typeof CheckboxPresets>('u:Checkbox', {
51
+ responsiveVariants,
50
52
  variants,
51
53
  styles,
52
54
  rootElement: 'wrapper',
@@ -115,6 +117,9 @@ export const Checkbox = (props: CheckboxProps) => {
115
117
  }}
116
118
  order={_checkboxOnLeft ? reversedOrder : InputBaseDefaultOrder}
117
119
  style={style}
120
+ wrapperProps={{
121
+ onClick: handleChange
122
+ }}
118
123
  >
119
124
  <motion.div
120
125
  css={[
@@ -136,6 +141,7 @@ export const Checkbox = (props: CheckboxProps) => {
136
141
  transition={variantStyles['checkmarkWrapper:transition']}
137
142
  >
138
143
  <Icon
144
+ debugName={debugName}
139
145
  name={'checkbox-checkmark' as any}
140
146
  css={[variantStyles.checkmark, disabled && variantStyles['checkmark:disabled']]}
141
147
  />
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react'
3
3
 
4
- import { capitalize, TypeGuards } from '@codeleap/common'
4
+ import { capitalize, StylesOf, TypeGuards } from '@codeleap/common'
5
5
  import { Scroll } from '../Scroll'
6
6
  import { View, ViewProps } from '../View'
7
7
  import { ElementType } from 'react'
@@ -58,6 +58,7 @@ export type CollapseProps<T extends NativeHTMLElement = 'div'> = ViewProps<T> &
58
58
  size?: string | number
59
59
  direction?: CollapseAxis
60
60
  animation?: string
61
+ styles: StylesOf<CollapseComposition>
61
62
  }
62
63
 
63
64
  export const Collapse = ({
@@ -67,19 +68,21 @@ export const Collapse = ({
67
68
  children,
68
69
  direction,
69
70
  animation,
71
+ styles,
70
72
  ...props
71
73
  }:CollapseProps) => {
72
74
 
73
75
  const Component = scroll ? Scroll : View
74
- const styles = getCollapseStyles({
76
+ const _styles = getCollapseStyles({
75
77
  value: size,
76
78
  direction,
77
79
  animation,
78
80
  })
79
81
  // @ts-ignore
80
82
  return <Component css={[
83
+ _styles.wrapper,
84
+ open ? _styles['wrapper:open'] : _styles['wrapper:closed'],
81
85
  styles.wrapper,
82
- open ? styles['wrapper:open'] : styles['wrapper:closed'],
83
86
  ]} {...props}>
84
87
  {children}
85
88
  </Component>