@hero-design/rn 8.35.1 → 8.36.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.
@@ -4,5 +4,5 @@ $ rollup -c
4
4
  src/index.ts → lib/index.js, es/index.js...
5
5
  (!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
6
6
  (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
7
- created lib/index.js, es/index.js in 29.6s
7
+ created lib/index.js, es/index.js in 32.5s
8
8
  $ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
package/es/index.js CHANGED
@@ -2103,8 +2103,11 @@ var getCardCarouselTheme = function getCardCarouselTheme(theme) {
2103
2103
 
2104
2104
  var getCheckboxTheme = function getCheckboxTheme(theme) {
2105
2105
  var colors = {
2106
- "default": theme.colors.primaryOutline,
2107
- disabledBorder: theme.colors.disabledOutline
2106
+ borders: {
2107
+ "default": theme.colors.primaryOutline,
2108
+ disabled: theme.colors.disabledOutline,
2109
+ readonly: theme.colors.inactiveOutline
2110
+ }
2108
2111
  };
2109
2112
  var space = {
2110
2113
  iconTop: 0,
@@ -11990,12 +11993,12 @@ var index$a = Object.assign(Carousel, {
11990
11993
  var StyledWrapper$7 = index$c(TouchableOpacity)(function (_ref) {
11991
11994
  var theme = _ref.theme,
11992
11995
  themeWithBorder = _ref.themeWithBorder,
11993
- themeDisabled = _ref.themeDisabled;
11996
+ themeState = _ref.themeState;
11994
11997
  var borderStyle = {
11995
11998
  borderRadius: theme.__hd__.checkbox.radii.wrapper,
11996
11999
  borderWidth: theme.__hd__.checkbox.borderWidths.wrapper,
11997
12000
  padding: theme.__hd__.checkbox.space.wrapperPadding,
11998
- borderColor: themeDisabled ? theme.__hd__.checkbox.colors.disabledBorder : theme.__hd__.checkbox.colors["default"]
12001
+ borderColor: theme.__hd__.checkbox.colors.borders[themeState]
11999
12002
  };
12000
12003
  return _objectSpread2({
12001
12004
  flexDirection: 'row'
@@ -12018,37 +12021,56 @@ var StyledCheckboxContainer = index$c(View)(function (_ref3) {
12018
12021
  });
12019
12022
  var StyledCheckbox = index$c(View)(function (_ref4) {
12020
12023
  var theme = _ref4.theme,
12021
- themeDisabled = _ref4.themeDisabled;
12024
+ themeState = _ref4.themeState;
12022
12025
  return {
12023
12026
  flex: 1,
12024
12027
  borderRadius: theme.__hd__.checkbox.radii.icon,
12025
12028
  borderWidth: theme.__hd__.checkbox.borderWidths.icon,
12026
- borderColor: themeDisabled ? theme.__hd__.checkbox.colors.disabledBorder : theme.__hd__.checkbox.colors["default"]
12029
+ borderColor: theme.__hd__.checkbox.colors.borders[themeState]
12027
12030
  };
12028
12031
  });
12029
12032
  var StyledCheckMark = index$c(Icon)(function (_ref5) {
12030
- var theme = _ref5.theme;
12033
+ var theme = _ref5.theme,
12034
+ themeState = _ref5.themeState;
12031
12035
  return {
12032
12036
  position: 'absolute',
12033
- top: theme.__hd__.checkbox.space.iconTop
12037
+ top: theme.__hd__.checkbox.space.iconTop,
12038
+ color: theme.__hd__.checkbox.colors.borders[themeState]
12034
12039
  };
12035
12040
  });
12036
12041
 
12037
- var Checkbox = function Checkbox(_ref) {
12038
- var checked = _ref.checked,
12039
- description = _ref.description,
12040
- _ref$withBorder = _ref.withBorder,
12041
- withBorder = _ref$withBorder === void 0 ? false : _ref$withBorder,
12042
- _ref$disabled = _ref.disabled,
12043
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
12044
- onPress = _ref.onPress,
12045
- style = _ref.style,
12046
- testID = _ref.testID;
12042
+ var getThemeState = function getThemeState(_ref) {
12043
+ var disabled = _ref.disabled,
12044
+ readonly = _ref.readonly;
12045
+ if (disabled) {
12046
+ return 'disabled';
12047
+ }
12048
+ if (readonly) {
12049
+ return 'readonly';
12050
+ }
12051
+ return 'default';
12052
+ };
12053
+ var Checkbox = function Checkbox(_ref2) {
12054
+ var checked = _ref2.checked,
12055
+ description = _ref2.description,
12056
+ _ref2$withBorder = _ref2.withBorder,
12057
+ withBorder = _ref2$withBorder === void 0 ? false : _ref2$withBorder,
12058
+ _ref2$disabled = _ref2.disabled,
12059
+ disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
12060
+ onPress = _ref2.onPress,
12061
+ style = _ref2.style,
12062
+ testID = _ref2.testID,
12063
+ _ref2$readonly = _ref2.readonly,
12064
+ readonly = _ref2$readonly === void 0 ? false : _ref2$readonly;
12065
+ var themeState = getThemeState({
12066
+ disabled: disabled,
12067
+ readonly: readonly
12068
+ });
12047
12069
  return /*#__PURE__*/React.createElement(StyledWrapper$7, {
12048
12070
  onPress: onPress,
12049
- disabled: disabled,
12050
- themeDisabled: disabled,
12071
+ disabled: disabled || readonly,
12051
12072
  themeWithBorder: withBorder,
12073
+ themeState: themeState,
12052
12074
  style: style,
12053
12075
  testID: testID
12054
12076
  }, !!description && /*#__PURE__*/React.createElement(StyledDescription$1, {
@@ -12056,10 +12078,10 @@ var Checkbox = function Checkbox(_ref) {
12056
12078
  variant: "small"
12057
12079
  }, description), /*#__PURE__*/React.createElement(StyledCheckboxContainer, null, checked && /*#__PURE__*/React.createElement(StyledCheckMark, {
12058
12080
  icon: "box-check",
12059
- intent: disabled ? 'disabled-text' : 'text',
12060
- testID: "check-mark"
12081
+ testID: "check-mark",
12082
+ themeState: themeState
12061
12083
  }), /*#__PURE__*/React.createElement(StyledCheckbox, {
12062
- themeDisabled: disabled
12084
+ themeState: themeState
12063
12085
  })));
12064
12086
  };
12065
12087
 
package/lib/index.js CHANGED
@@ -2134,8 +2134,11 @@ var getCardCarouselTheme = function getCardCarouselTheme(theme) {
2134
2134
 
2135
2135
  var getCheckboxTheme = function getCheckboxTheme(theme) {
2136
2136
  var colors = {
2137
- "default": theme.colors.primaryOutline,
2138
- disabledBorder: theme.colors.disabledOutline
2137
+ borders: {
2138
+ "default": theme.colors.primaryOutline,
2139
+ disabled: theme.colors.disabledOutline,
2140
+ readonly: theme.colors.inactiveOutline
2141
+ }
2139
2142
  };
2140
2143
  var space = {
2141
2144
  iconTop: 0,
@@ -12021,12 +12024,12 @@ var index$a = Object.assign(Carousel, {
12021
12024
  var StyledWrapper$7 = index$c(reactNative.TouchableOpacity)(function (_ref) {
12022
12025
  var theme = _ref.theme,
12023
12026
  themeWithBorder = _ref.themeWithBorder,
12024
- themeDisabled = _ref.themeDisabled;
12027
+ themeState = _ref.themeState;
12025
12028
  var borderStyle = {
12026
12029
  borderRadius: theme.__hd__.checkbox.radii.wrapper,
12027
12030
  borderWidth: theme.__hd__.checkbox.borderWidths.wrapper,
12028
12031
  padding: theme.__hd__.checkbox.space.wrapperPadding,
12029
- borderColor: themeDisabled ? theme.__hd__.checkbox.colors.disabledBorder : theme.__hd__.checkbox.colors["default"]
12032
+ borderColor: theme.__hd__.checkbox.colors.borders[themeState]
12030
12033
  };
12031
12034
  return _objectSpread2({
12032
12035
  flexDirection: 'row'
@@ -12049,37 +12052,56 @@ var StyledCheckboxContainer = index$c(reactNative.View)(function (_ref3) {
12049
12052
  });
12050
12053
  var StyledCheckbox = index$c(reactNative.View)(function (_ref4) {
12051
12054
  var theme = _ref4.theme,
12052
- themeDisabled = _ref4.themeDisabled;
12055
+ themeState = _ref4.themeState;
12053
12056
  return {
12054
12057
  flex: 1,
12055
12058
  borderRadius: theme.__hd__.checkbox.radii.icon,
12056
12059
  borderWidth: theme.__hd__.checkbox.borderWidths.icon,
12057
- borderColor: themeDisabled ? theme.__hd__.checkbox.colors.disabledBorder : theme.__hd__.checkbox.colors["default"]
12060
+ borderColor: theme.__hd__.checkbox.colors.borders[themeState]
12058
12061
  };
12059
12062
  });
12060
12063
  var StyledCheckMark = index$c(Icon)(function (_ref5) {
12061
- var theme = _ref5.theme;
12064
+ var theme = _ref5.theme,
12065
+ themeState = _ref5.themeState;
12062
12066
  return {
12063
12067
  position: 'absolute',
12064
- top: theme.__hd__.checkbox.space.iconTop
12068
+ top: theme.__hd__.checkbox.space.iconTop,
12069
+ color: theme.__hd__.checkbox.colors.borders[themeState]
12065
12070
  };
12066
12071
  });
12067
12072
 
12068
- var Checkbox = function Checkbox(_ref) {
12069
- var checked = _ref.checked,
12070
- description = _ref.description,
12071
- _ref$withBorder = _ref.withBorder,
12072
- withBorder = _ref$withBorder === void 0 ? false : _ref$withBorder,
12073
- _ref$disabled = _ref.disabled,
12074
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
12075
- onPress = _ref.onPress,
12076
- style = _ref.style,
12077
- testID = _ref.testID;
12073
+ var getThemeState = function getThemeState(_ref) {
12074
+ var disabled = _ref.disabled,
12075
+ readonly = _ref.readonly;
12076
+ if (disabled) {
12077
+ return 'disabled';
12078
+ }
12079
+ if (readonly) {
12080
+ return 'readonly';
12081
+ }
12082
+ return 'default';
12083
+ };
12084
+ var Checkbox = function Checkbox(_ref2) {
12085
+ var checked = _ref2.checked,
12086
+ description = _ref2.description,
12087
+ _ref2$withBorder = _ref2.withBorder,
12088
+ withBorder = _ref2$withBorder === void 0 ? false : _ref2$withBorder,
12089
+ _ref2$disabled = _ref2.disabled,
12090
+ disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
12091
+ onPress = _ref2.onPress,
12092
+ style = _ref2.style,
12093
+ testID = _ref2.testID,
12094
+ _ref2$readonly = _ref2.readonly,
12095
+ readonly = _ref2$readonly === void 0 ? false : _ref2$readonly;
12096
+ var themeState = getThemeState({
12097
+ disabled: disabled,
12098
+ readonly: readonly
12099
+ });
12078
12100
  return /*#__PURE__*/React__default["default"].createElement(StyledWrapper$7, {
12079
12101
  onPress: onPress,
12080
- disabled: disabled,
12081
- themeDisabled: disabled,
12102
+ disabled: disabled || readonly,
12082
12103
  themeWithBorder: withBorder,
12104
+ themeState: themeState,
12083
12105
  style: style,
12084
12106
  testID: testID
12085
12107
  }, !!description && /*#__PURE__*/React__default["default"].createElement(StyledDescription$1, {
@@ -12087,10 +12109,10 @@ var Checkbox = function Checkbox(_ref) {
12087
12109
  variant: "small"
12088
12110
  }, description), /*#__PURE__*/React__default["default"].createElement(StyledCheckboxContainer, null, checked && /*#__PURE__*/React__default["default"].createElement(StyledCheckMark, {
12089
12111
  icon: "box-check",
12090
- intent: disabled ? 'disabled-text' : 'text',
12091
- testID: "check-mark"
12112
+ testID: "check-mark",
12113
+ themeState: themeState
12092
12114
  }), /*#__PURE__*/React__default["default"].createElement(StyledCheckbox, {
12093
- themeDisabled: disabled
12115
+ themeState: themeState
12094
12116
  })));
12095
12117
  };
12096
12118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.35.1",
3
+ "version": "8.36.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -21,14 +21,14 @@
21
21
  "dependencies": {
22
22
  "@emotion/native": "^11.9.3",
23
23
  "@emotion/react": "^11.9.3",
24
- "@hero-design/colors": "8.35.1",
24
+ "@hero-design/colors": "8.36.0",
25
25
  "date-fns": "^2.16.1",
26
26
  "events": "^3.2.0",
27
27
  "hero-editor": "^1.9.21",
28
28
  "nanoid": "^4.0.2"
29
29
  },
30
30
  "peerDependencies": {
31
- "@hero-design/react-native-month-year-picker": "^8.35.1",
31
+ "@hero-design/react-native-month-year-picker": "^8.36.0",
32
32
  "@react-native-community/datetimepicker": "^3.5.2",
33
33
  "@react-native-community/slider": "4.1.12",
34
34
  "react": "18.0.0",
@@ -48,8 +48,8 @@
48
48
  "@babel/preset-typescript": "^7.17.12",
49
49
  "@babel/runtime": "^7.18.9",
50
50
  "@emotion/jest": "^11.9.3",
51
- "@hero-design/eslint-plugin": "8.35.1",
52
- "@hero-design/react-native-month-year-picker": "^8.35.1",
51
+ "@hero-design/eslint-plugin": "8.36.0",
52
+ "@hero-design/react-native-month-year-picker": "^8.36.0",
53
53
  "@react-native-community/datetimepicker": "^3.5.2",
54
54
  "@react-native-community/slider": "4.1.12",
55
55
  "@rollup/plugin-babel": "^5.3.1",
@@ -65,10 +65,10 @@
65
65
  "@types/react-native": "^0.67.7",
66
66
  "@types/react-native-vector-icons": "^6.4.10",
67
67
  "babel-plugin-inline-import": "^3.0.0",
68
- "eslint-config-hd": "8.35.1",
68
+ "eslint-config-hd": "8.36.0",
69
69
  "eslint-plugin-import": "^2.27.5",
70
70
  "jest": "^27.3.1",
71
- "prettier-config-hd": "8.35.1",
71
+ "prettier-config-hd": "8.36.0",
72
72
  "react": "18.0.0",
73
73
  "react-native": "0.69.7",
74
74
  "react-native-gesture-handler": "~2.5.0",
@@ -1,19 +1,19 @@
1
1
  import styled from '@emotion/native';
2
2
  import { TouchableOpacity, View } from 'react-native';
3
- import Icon from '../Icon';
3
+ import HeroIcon from '../Icon';
4
4
  import Typography from '../Typography';
5
5
 
6
+ type CheckboxThemeState = 'default' | 'disabled' | 'readonly';
7
+
6
8
  export const StyledWrapper = styled(TouchableOpacity)<{
7
9
  themeWithBorder: boolean;
8
- themeDisabled: boolean;
9
- }>(({ theme, themeWithBorder, themeDisabled }) => {
10
+ themeState: CheckboxThemeState;
11
+ }>(({ theme, themeWithBorder, themeState }) => {
10
12
  const borderStyle = {
11
13
  borderRadius: theme.__hd__.checkbox.radii.wrapper,
12
14
  borderWidth: theme.__hd__.checkbox.borderWidths.wrapper,
13
15
  padding: theme.__hd__.checkbox.space.wrapperPadding,
14
- borderColor: themeDisabled
15
- ? theme.__hd__.checkbox.colors.disabledBorder
16
- : theme.__hd__.checkbox.colors.default,
16
+ borderColor: theme.__hd__.checkbox.colors.borders[themeState],
17
17
  };
18
18
 
19
19
  return {
@@ -33,18 +33,19 @@ export const StyledCheckboxContainer = styled(View)(({ theme }) => ({
33
33
  overflow: 'hidden',
34
34
  }));
35
35
 
36
- export const StyledCheckbox = styled(View)<{ themeDisabled: boolean }>(
37
- ({ theme, themeDisabled }) => ({
38
- flex: 1,
39
- borderRadius: theme.__hd__.checkbox.radii.icon,
40
- borderWidth: theme.__hd__.checkbox.borderWidths.icon,
41
- borderColor: themeDisabled
42
- ? theme.__hd__.checkbox.colors.disabledBorder
43
- : theme.__hd__.checkbox.colors.default,
44
- })
45
- );
36
+ export const StyledCheckbox = styled(View)<{
37
+ themeState: CheckboxThemeState;
38
+ }>(({ theme, themeState }) => ({
39
+ flex: 1,
40
+ borderRadius: theme.__hd__.checkbox.radii.icon,
41
+ borderWidth: theme.__hd__.checkbox.borderWidths.icon,
42
+ borderColor: theme.__hd__.checkbox.colors.borders[themeState],
43
+ }));
46
44
 
47
- export const StyledCheckMark = styled(Icon)(({ theme }) => ({
45
+ export const StyledCheckMark = styled(HeroIcon)<{
46
+ themeState: CheckboxThemeState;
47
+ }>(({ theme, themeState }) => ({
48
48
  position: 'absolute',
49
49
  top: theme.__hd__.checkbox.space.iconTop,
50
+ color: theme.__hd__.checkbox.colors.borders[themeState],
50
51
  }));
@@ -1,18 +1,25 @@
1
1
  import React from 'react';
2
2
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
3
3
  import { StyledWrapper, StyledCheckbox } from '../StyledCheckbox';
4
+ import { getThemeState } from '..';
4
5
 
5
6
  describe('StyledWrapper', () => {
6
7
  it.each`
7
- withBorder | disabled
8
- ${false} | ${false}
9
- ${true} | ${false}
10
- ${true} | ${true}
8
+ withBorder | disabled | readonly
9
+ ${false} | ${false} | ${false}
10
+ ${true} | ${false} | ${false}
11
+ ${false} | ${true} | ${false}
12
+ ${true} | ${true} | ${false}
13
+ ${false} | ${false} | ${true}
14
+ ${true} | ${false} | ${true}
15
+ ${false} | ${true} | ${true}
16
+ ${true} | ${true} | ${true}
11
17
  `(
12
18
  'renders correctly when disabled is $disabled, withBorder is $withBorder',
13
- ({ disabled, withBorder }) => {
19
+ ({ disabled, withBorder, readonly }) => {
20
+ const themeState = getThemeState({ disabled, readonly });
14
21
  const { toJSON } = renderWithTheme(
15
- <StyledWrapper themeDisabled={disabled} themeWithBorder={withBorder} />
22
+ <StyledWrapper themeState={themeState} themeWithBorder={withBorder} />
16
23
  );
17
24
 
18
25
  expect(toJSON()).toMatchSnapshot();
@@ -22,14 +29,20 @@ describe('StyledWrapper', () => {
22
29
 
23
30
  describe('StyledCheckbox', () => {
24
31
  it.each`
25
- disabled
26
- ${true}
27
- ${false}
28
- `('renders correctly when disabled is $disabled', ({ disabled }) => {
29
- const { toJSON } = renderWithTheme(
30
- <StyledCheckbox themeDisabled={disabled} />
31
- );
32
+ disabled | readonly
33
+ ${true} | ${false}
34
+ ${true} | ${true}
35
+ ${false} | ${false}
36
+ ${false} | ${true}
37
+ `(
38
+ 'renders correctly when disabled is $disabled and readonly is $readonly',
39
+ ({ disabled, readonly }) => {
40
+ const themeState = getThemeState({ disabled, readonly });
41
+ const { toJSON } = renderWithTheme(
42
+ <StyledCheckbox themeState={themeState} />
43
+ );
32
44
 
33
- expect(toJSON()).toMatchSnapshot();
34
- });
45
+ expect(toJSON()).toMatchSnapshot();
46
+ }
47
+ );
35
48
  });
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`StyledCheckbox renders correctly when disabled is false 1`] = `
3
+ exports[`StyledCheckbox renders correctly when disabled is false and readonly is false 1`] = `
4
4
  <View
5
5
  style={
6
6
  Array [
@@ -13,11 +13,45 @@ exports[`StyledCheckbox renders correctly when disabled is false 1`] = `
13
13
  undefined,
14
14
  ]
15
15
  }
16
- themeDisabled={false}
16
+ themeState="default"
17
17
  />
18
18
  `;
19
19
 
20
- exports[`StyledCheckbox renders correctly when disabled is true 1`] = `
20
+ exports[`StyledCheckbox renders correctly when disabled is false and readonly is true 1`] = `
21
+ <View
22
+ style={
23
+ Array [
24
+ Object {
25
+ "borderColor": "#808f91",
26
+ "borderRadius": 4,
27
+ "borderWidth": 2,
28
+ "flex": 1,
29
+ },
30
+ undefined,
31
+ ]
32
+ }
33
+ themeState="readonly"
34
+ />
35
+ `;
36
+
37
+ exports[`StyledCheckbox renders correctly when disabled is true and readonly is false 1`] = `
38
+ <View
39
+ style={
40
+ Array [
41
+ Object {
42
+ "borderColor": "#bfc1c5",
43
+ "borderRadius": 4,
44
+ "borderWidth": 2,
45
+ "flex": 1,
46
+ },
47
+ undefined,
48
+ ]
49
+ }
50
+ themeState="disabled"
51
+ />
52
+ `;
53
+
54
+ exports[`StyledCheckbox renders correctly when disabled is true and readonly is true 1`] = `
21
55
  <View
22
56
  style={
23
57
  Array [
@@ -30,7 +64,7 @@ exports[`StyledCheckbox renders correctly when disabled is true 1`] = `
30
64
  undefined,
31
65
  ]
32
66
  }
33
- themeDisabled={true}
67
+ themeState="disabled"
34
68
  />
35
69
  `;
36
70
 
@@ -55,6 +89,27 @@ exports[`StyledWrapper renders correctly when disabled is false, withBorder is f
55
89
  />
56
90
  `;
57
91
 
92
+ exports[`StyledWrapper renders correctly when disabled is false, withBorder is false 2`] = `
93
+ <View
94
+ accessible={true}
95
+ collapsable={false}
96
+ focusable={false}
97
+ onClick={[Function]}
98
+ onResponderGrant={[Function]}
99
+ onResponderMove={[Function]}
100
+ onResponderRelease={[Function]}
101
+ onResponderTerminate={[Function]}
102
+ onResponderTerminationRequest={[Function]}
103
+ onStartShouldSetResponder={[Function]}
104
+ style={
105
+ Object {
106
+ "flexDirection": "row",
107
+ "opacity": 1,
108
+ }
109
+ }
110
+ />
111
+ `;
112
+
58
113
  exports[`StyledWrapper renders correctly when disabled is false, withBorder is true 1`] = `
59
114
  <View
60
115
  accessible={true}
@@ -80,6 +135,73 @@ exports[`StyledWrapper renders correctly when disabled is false, withBorder is t
80
135
  />
81
136
  `;
82
137
 
138
+ exports[`StyledWrapper renders correctly when disabled is false, withBorder is true 2`] = `
139
+ <View
140
+ accessible={true}
141
+ collapsable={false}
142
+ focusable={false}
143
+ onClick={[Function]}
144
+ onResponderGrant={[Function]}
145
+ onResponderMove={[Function]}
146
+ onResponderRelease={[Function]}
147
+ onResponderTerminate={[Function]}
148
+ onResponderTerminationRequest={[Function]}
149
+ onStartShouldSetResponder={[Function]}
150
+ style={
151
+ Object {
152
+ "borderColor": "#808f91",
153
+ "borderRadius": 8,
154
+ "borderWidth": 1,
155
+ "flexDirection": "row",
156
+ "opacity": 1,
157
+ "padding": 16,
158
+ }
159
+ }
160
+ />
161
+ `;
162
+
163
+ exports[`StyledWrapper renders correctly when disabled is true, withBorder is false 1`] = `
164
+ <View
165
+ accessible={true}
166
+ collapsable={false}
167
+ focusable={false}
168
+ onClick={[Function]}
169
+ onResponderGrant={[Function]}
170
+ onResponderMove={[Function]}
171
+ onResponderRelease={[Function]}
172
+ onResponderTerminate={[Function]}
173
+ onResponderTerminationRequest={[Function]}
174
+ onStartShouldSetResponder={[Function]}
175
+ style={
176
+ Object {
177
+ "flexDirection": "row",
178
+ "opacity": 1,
179
+ }
180
+ }
181
+ />
182
+ `;
183
+
184
+ exports[`StyledWrapper renders correctly when disabled is true, withBorder is false 2`] = `
185
+ <View
186
+ accessible={true}
187
+ collapsable={false}
188
+ focusable={false}
189
+ onClick={[Function]}
190
+ onResponderGrant={[Function]}
191
+ onResponderMove={[Function]}
192
+ onResponderRelease={[Function]}
193
+ onResponderTerminate={[Function]}
194
+ onResponderTerminationRequest={[Function]}
195
+ onStartShouldSetResponder={[Function]}
196
+ style={
197
+ Object {
198
+ "flexDirection": "row",
199
+ "opacity": 1,
200
+ }
201
+ }
202
+ />
203
+ `;
204
+
83
205
  exports[`StyledWrapper renders correctly when disabled is true, withBorder is true 1`] = `
84
206
  <View
85
207
  accessible={true}
@@ -104,3 +226,28 @@ exports[`StyledWrapper renders correctly when disabled is true, withBorder is tr
104
226
  }
105
227
  />
106
228
  `;
229
+
230
+ exports[`StyledWrapper renders correctly when disabled is true, withBorder is true 2`] = `
231
+ <View
232
+ accessible={true}
233
+ collapsable={false}
234
+ focusable={false}
235
+ onClick={[Function]}
236
+ onResponderGrant={[Function]}
237
+ onResponderMove={[Function]}
238
+ onResponderRelease={[Function]}
239
+ onResponderTerminate={[Function]}
240
+ onResponderTerminationRequest={[Function]}
241
+ onStartShouldSetResponder={[Function]}
242
+ style={
243
+ Object {
244
+ "borderColor": "#bfc1c5",
245
+ "borderRadius": 8,
246
+ "borderWidth": 1,
247
+ "flexDirection": "row",
248
+ "opacity": 1,
249
+ "padding": 16,
250
+ }
251
+ }
252
+ />
253
+ `;
@@ -48,7 +48,7 @@ exports[`Checkbox renders correctly when checked is false and there is no descri
48
48
  undefined,
49
49
  ]
50
50
  }
51
- themeDisabled={false}
51
+ themeState="default"
52
52
  />
53
53
  </View>
54
54
  </View>
@@ -100,6 +100,7 @@ exports[`Checkbox renders correctly when checked is true and there is no descrip
100
100
  },
101
101
  Array [
102
102
  Object {
103
+ "color": "#001f23",
103
104
  "position": "absolute",
104
105
  "top": 0,
105
106
  },
@@ -123,13 +124,13 @@ exports[`Checkbox renders correctly when checked is true and there is no descrip
123
124
  undefined,
124
125
  ]
125
126
  }
126
- themeDisabled={false}
127
+ themeState="default"
127
128
  />
128
129
  </View>
129
130
  </View>
130
131
  `;
131
132
 
132
- exports[`Checkbox renders correctly when disabled is false, withBorder is false 1`] = `
133
+ exports[`Checkbox renders correctly when disabled is false, withBorder is false and readonly is false 1`] = `
133
134
  <View
134
135
  accessibilityState={
135
136
  Object {
@@ -203,13 +204,93 @@ exports[`Checkbox renders correctly when disabled is false, withBorder is false
203
204
  undefined,
204
205
  ]
205
206
  }
206
- themeDisabled={false}
207
+ themeState="default"
207
208
  />
208
209
  </View>
209
210
  </View>
210
211
  `;
211
212
 
212
- exports[`Checkbox renders correctly when disabled is false, withBorder is true 1`] = `
213
+ exports[`Checkbox renders correctly when disabled is false, withBorder is false and readonly is true 1`] = `
214
+ <View
215
+ accessibilityState={
216
+ Object {
217
+ "disabled": true,
218
+ }
219
+ }
220
+ accessible={true}
221
+ collapsable={false}
222
+ focusable={false}
223
+ onClick={[Function]}
224
+ onResponderGrant={[Function]}
225
+ onResponderMove={[Function]}
226
+ onResponderRelease={[Function]}
227
+ onResponderTerminate={[Function]}
228
+ onResponderTerminationRequest={[Function]}
229
+ onStartShouldSetResponder={[Function]}
230
+ style={
231
+ Object {
232
+ "flexDirection": "row",
233
+ "opacity": 1,
234
+ }
235
+ }
236
+ >
237
+ <Text
238
+ allowFontScaling={false}
239
+ style={
240
+ Array [
241
+ Object {
242
+ "color": "#001f23",
243
+ "fontFamily": "BeVietnamPro-Regular",
244
+ "fontSize": 14,
245
+ "letterSpacing": 0.48,
246
+ "lineHeight": 22,
247
+ },
248
+ Array [
249
+ Object {
250
+ "flex": 1,
251
+ "paddingRight": 12,
252
+ },
253
+ undefined,
254
+ ],
255
+ ]
256
+ }
257
+ themeIntent="body"
258
+ themeTypeface="neutral"
259
+ themeVariant="small"
260
+ >
261
+ Please agree to our privacy policy
262
+ </Text>
263
+ <View
264
+ style={
265
+ Array [
266
+ Object {
267
+ "height": 24,
268
+ "overflow": "hidden",
269
+ "width": 24,
270
+ },
271
+ undefined,
272
+ ]
273
+ }
274
+ >
275
+ <View
276
+ style={
277
+ Array [
278
+ Object {
279
+ "borderColor": "#808f91",
280
+ "borderRadius": 4,
281
+ "borderWidth": 2,
282
+ "flex": 1,
283
+ },
284
+ undefined,
285
+ ]
286
+ }
287
+ themeState="readonly"
288
+ />
289
+ </View>
290
+ </View>
291
+ `;
292
+
293
+ exports[`Checkbox renders correctly when disabled is false, withBorder is true and readonly is false 1`] = `
213
294
  <View
214
295
  accessibilityState={
215
296
  Object {
@@ -287,13 +368,13 @@ exports[`Checkbox renders correctly when disabled is false, withBorder is true 1
287
368
  undefined,
288
369
  ]
289
370
  }
290
- themeDisabled={false}
371
+ themeState="default"
291
372
  />
292
373
  </View>
293
374
  </View>
294
375
  `;
295
376
 
296
- exports[`Checkbox renders correctly when disabled is true, withBorder is false 1`] = `
377
+ exports[`Checkbox renders correctly when disabled is false, withBorder is true and readonly is true 1`] = `
297
378
  <View
298
379
  accessibilityState={
299
380
  Object {
@@ -312,8 +393,256 @@ exports[`Checkbox renders correctly when disabled is true, withBorder is false 1
312
393
  onStartShouldSetResponder={[Function]}
313
394
  style={
314
395
  Object {
396
+ "borderColor": "#808f91",
397
+ "borderRadius": 8,
398
+ "borderWidth": 1,
315
399
  "flexDirection": "row",
316
400
  "opacity": 1,
401
+ "padding": 16,
402
+ }
403
+ }
404
+ >
405
+ <Text
406
+ allowFontScaling={false}
407
+ style={
408
+ Array [
409
+ Object {
410
+ "color": "#001f23",
411
+ "fontFamily": "BeVietnamPro-Regular",
412
+ "fontSize": 14,
413
+ "letterSpacing": 0.48,
414
+ "lineHeight": 22,
415
+ },
416
+ Array [
417
+ Object {
418
+ "flex": 1,
419
+ "paddingRight": 12,
420
+ },
421
+ undefined,
422
+ ],
423
+ ]
424
+ }
425
+ themeIntent="body"
426
+ themeTypeface="neutral"
427
+ themeVariant="small"
428
+ >
429
+ Please agree to our privacy policy
430
+ </Text>
431
+ <View
432
+ style={
433
+ Array [
434
+ Object {
435
+ "height": 24,
436
+ "overflow": "hidden",
437
+ "width": 24,
438
+ },
439
+ undefined,
440
+ ]
441
+ }
442
+ >
443
+ <View
444
+ style={
445
+ Array [
446
+ Object {
447
+ "borderColor": "#808f91",
448
+ "borderRadius": 4,
449
+ "borderWidth": 2,
450
+ "flex": 1,
451
+ },
452
+ undefined,
453
+ ]
454
+ }
455
+ themeState="readonly"
456
+ />
457
+ </View>
458
+ </View>
459
+ `;
460
+
461
+ exports[`Checkbox renders correctly when disabled is true, withBorder is false and readonly is false 1`] = `
462
+ <View
463
+ accessibilityState={
464
+ Object {
465
+ "disabled": true,
466
+ }
467
+ }
468
+ accessible={true}
469
+ collapsable={false}
470
+ focusable={false}
471
+ onClick={[Function]}
472
+ onResponderGrant={[Function]}
473
+ onResponderMove={[Function]}
474
+ onResponderRelease={[Function]}
475
+ onResponderTerminate={[Function]}
476
+ onResponderTerminationRequest={[Function]}
477
+ onStartShouldSetResponder={[Function]}
478
+ style={
479
+ Object {
480
+ "flexDirection": "row",
481
+ "opacity": 1,
482
+ }
483
+ }
484
+ >
485
+ <Text
486
+ allowFontScaling={false}
487
+ style={
488
+ Array [
489
+ Object {
490
+ "color": "#4d6265",
491
+ "fontFamily": "BeVietnamPro-Regular",
492
+ "fontSize": 14,
493
+ "letterSpacing": 0.48,
494
+ "lineHeight": 22,
495
+ },
496
+ Array [
497
+ Object {
498
+ "flex": 1,
499
+ "paddingRight": 12,
500
+ },
501
+ undefined,
502
+ ],
503
+ ]
504
+ }
505
+ themeIntent="subdued"
506
+ themeTypeface="neutral"
507
+ themeVariant="small"
508
+ >
509
+ Please agree to our privacy policy
510
+ </Text>
511
+ <View
512
+ style={
513
+ Array [
514
+ Object {
515
+ "height": 24,
516
+ "overflow": "hidden",
517
+ "width": 24,
518
+ },
519
+ undefined,
520
+ ]
521
+ }
522
+ >
523
+ <View
524
+ style={
525
+ Array [
526
+ Object {
527
+ "borderColor": "#bfc1c5",
528
+ "borderRadius": 4,
529
+ "borderWidth": 2,
530
+ "flex": 1,
531
+ },
532
+ undefined,
533
+ ]
534
+ }
535
+ themeState="disabled"
536
+ />
537
+ </View>
538
+ </View>
539
+ `;
540
+
541
+ exports[`Checkbox renders correctly when disabled is true, withBorder is false and readonly is true 1`] = `
542
+ <View
543
+ accessibilityState={
544
+ Object {
545
+ "disabled": true,
546
+ }
547
+ }
548
+ accessible={true}
549
+ collapsable={false}
550
+ focusable={false}
551
+ onClick={[Function]}
552
+ onResponderGrant={[Function]}
553
+ onResponderMove={[Function]}
554
+ onResponderRelease={[Function]}
555
+ onResponderTerminate={[Function]}
556
+ onResponderTerminationRequest={[Function]}
557
+ onStartShouldSetResponder={[Function]}
558
+ style={
559
+ Object {
560
+ "flexDirection": "row",
561
+ "opacity": 1,
562
+ }
563
+ }
564
+ >
565
+ <Text
566
+ allowFontScaling={false}
567
+ style={
568
+ Array [
569
+ Object {
570
+ "color": "#4d6265",
571
+ "fontFamily": "BeVietnamPro-Regular",
572
+ "fontSize": 14,
573
+ "letterSpacing": 0.48,
574
+ "lineHeight": 22,
575
+ },
576
+ Array [
577
+ Object {
578
+ "flex": 1,
579
+ "paddingRight": 12,
580
+ },
581
+ undefined,
582
+ ],
583
+ ]
584
+ }
585
+ themeIntent="subdued"
586
+ themeTypeface="neutral"
587
+ themeVariant="small"
588
+ >
589
+ Please agree to our privacy policy
590
+ </Text>
591
+ <View
592
+ style={
593
+ Array [
594
+ Object {
595
+ "height": 24,
596
+ "overflow": "hidden",
597
+ "width": 24,
598
+ },
599
+ undefined,
600
+ ]
601
+ }
602
+ >
603
+ <View
604
+ style={
605
+ Array [
606
+ Object {
607
+ "borderColor": "#bfc1c5",
608
+ "borderRadius": 4,
609
+ "borderWidth": 2,
610
+ "flex": 1,
611
+ },
612
+ undefined,
613
+ ]
614
+ }
615
+ themeState="disabled"
616
+ />
617
+ </View>
618
+ </View>
619
+ `;
620
+
621
+ exports[`Checkbox renders correctly when disabled is true, withBorder is true and readonly is false 1`] = `
622
+ <View
623
+ accessibilityState={
624
+ Object {
625
+ "disabled": true,
626
+ }
627
+ }
628
+ accessible={true}
629
+ collapsable={false}
630
+ focusable={false}
631
+ onClick={[Function]}
632
+ onResponderGrant={[Function]}
633
+ onResponderMove={[Function]}
634
+ onResponderRelease={[Function]}
635
+ onResponderTerminate={[Function]}
636
+ onResponderTerminationRequest={[Function]}
637
+ onStartShouldSetResponder={[Function]}
638
+ style={
639
+ Object {
640
+ "borderColor": "#bfc1c5",
641
+ "borderRadius": 8,
642
+ "borderWidth": 1,
643
+ "flexDirection": "row",
644
+ "opacity": 1,
645
+ "padding": 16,
317
646
  }
318
647
  }
319
648
  >
@@ -367,13 +696,13 @@ exports[`Checkbox renders correctly when disabled is true, withBorder is false 1
367
696
  undefined,
368
697
  ]
369
698
  }
370
- themeDisabled={true}
699
+ themeState="disabled"
371
700
  />
372
701
  </View>
373
702
  </View>
374
703
  `;
375
704
 
376
- exports[`Checkbox renders correctly when disabled is true, withBorder is true 1`] = `
705
+ exports[`Checkbox renders correctly when disabled is true, withBorder is true and readonly is true 1`] = `
377
706
  <View
378
707
  accessibilityState={
379
708
  Object {
@@ -451,7 +780,7 @@ exports[`Checkbox renders correctly when disabled is true, withBorder is true 1`
451
780
  undefined,
452
781
  ]
453
782
  }
454
- themeDisabled={true}
783
+ themeState="disabled"
455
784
  />
456
785
  </View>
457
786
  </View>
@@ -2,22 +2,42 @@ import React from 'react';
2
2
  import { fireEvent } from '@testing-library/react-native';
3
3
 
4
4
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
5
- import Checkbox from '..';
5
+ import Checkbox, { getThemeState } from '..';
6
+
7
+ describe('getThemeState', () => {
8
+ it.each`
9
+ disabled | readonly | expected
10
+ ${false} | ${false} | ${'default'}
11
+ ${false} | ${true} | ${'readonly'}
12
+ ${true} | ${false} | ${'disabled'}
13
+ ${true} | ${true} | ${'disabled'}
14
+ `(
15
+ `should return correctly if disabled is $disabled and readonly is $readonly`,
16
+ ({ disabled, readonly, expected }) => {
17
+ expect(getThemeState({ disabled, readonly })).toBe(expected);
18
+ }
19
+ );
20
+ });
6
21
 
7
22
  describe('Checkbox', () => {
8
23
  it.each`
9
- withBorder | disabled
10
- ${false} | ${false}
11
- ${false} | ${true}
12
- ${true} | ${false}
13
- ${true} | ${true}
24
+ withBorder | disabled | readonly
25
+ ${false} | ${false} | ${false}
26
+ ${false} | ${true} | ${false}
27
+ ${true} | ${false} | ${false}
28
+ ${true} | ${true} | ${false}
29
+ ${false} | ${false} | ${true}
30
+ ${false} | ${true} | ${true}
31
+ ${true} | ${false} | ${true}
32
+ ${true} | ${true} | ${true}
14
33
  `(
15
- 'renders correctly when disabled is $disabled, withBorder is $withBorder',
16
- ({ disabled, withBorder }) => {
34
+ 'renders correctly when disabled is $disabled, withBorder is $withBorder and readonly is $readonly',
35
+ ({ disabled, withBorder, readonly }) => {
17
36
  const wrapper = renderWithTheme(
18
37
  <Checkbox
19
38
  disabled={disabled}
20
39
  withBorder={withBorder}
40
+ readonly={readonly}
21
41
  description="Please agree to our privacy policy"
22
42
  />
23
43
  );
@@ -37,8 +37,29 @@ export interface CheckboxProps {
37
37
  * Testing id of the component.
38
38
  */
39
39
  testID?: string;
40
+ /**
41
+ * Readonly of the checkbox.
42
+ */
43
+ readonly?: boolean;
40
44
  }
41
45
 
46
+ type getStateType = {
47
+ disabled: boolean;
48
+ readonly: boolean;
49
+ };
50
+
51
+ export const getThemeState = ({ disabled, readonly }: getStateType) => {
52
+ if (disabled) {
53
+ return 'disabled';
54
+ }
55
+
56
+ if (readonly) {
57
+ return 'readonly';
58
+ }
59
+
60
+ return 'default';
61
+ };
62
+
42
63
  const Checkbox = ({
43
64
  checked,
44
65
  description,
@@ -47,31 +68,39 @@ const Checkbox = ({
47
68
  onPress,
48
69
  style,
49
70
  testID,
50
- }: CheckboxProps) => (
51
- <StyledWrapper
52
- onPress={onPress}
53
- disabled={disabled}
54
- themeDisabled={disabled}
55
- themeWithBorder={withBorder}
56
- style={style}
57
- testID={testID}
58
- >
59
- {!!description && (
60
- <StyledDescription intent={disabled ? 'subdued' : 'body'} variant="small">
61
- {description}
62
- </StyledDescription>
63
- )}
64
- <StyledCheckboxContainer>
65
- {checked && (
66
- <StyledCheckMark
67
- icon="box-check"
68
- intent={disabled ? 'disabled-text' : 'text'}
69
- testID="check-mark"
70
- />
71
+ readonly = false,
72
+ }: CheckboxProps) => {
73
+ const themeState = getThemeState({ disabled, readonly });
74
+
75
+ return (
76
+ <StyledWrapper
77
+ onPress={onPress}
78
+ disabled={disabled || readonly}
79
+ themeWithBorder={withBorder}
80
+ themeState={themeState}
81
+ style={style}
82
+ testID={testID}
83
+ >
84
+ {!!description && (
85
+ <StyledDescription
86
+ intent={disabled ? 'subdued' : 'body'}
87
+ variant="small"
88
+ >
89
+ {description}
90
+ </StyledDescription>
71
91
  )}
72
- <StyledCheckbox themeDisabled={disabled} />
73
- </StyledCheckboxContainer>
74
- </StyledWrapper>
75
- );
92
+ <StyledCheckboxContainer>
93
+ {checked && (
94
+ <StyledCheckMark
95
+ icon="box-check"
96
+ testID="check-mark"
97
+ themeState={themeState}
98
+ />
99
+ )}
100
+ <StyledCheckbox themeState={themeState} />
101
+ </StyledCheckboxContainer>
102
+ </StyledWrapper>
103
+ );
104
+ };
76
105
 
77
106
  export default Checkbox;
@@ -334,8 +334,11 @@ Object {
334
334
  "wrapper": 1,
335
335
  },
336
336
  "colors": Object {
337
- "default": "#001f23",
338
- "disabledBorder": "#bfc1c5",
337
+ "borders": Object {
338
+ "default": "#001f23",
339
+ "disabled": "#bfc1c5",
340
+ "readonly": "#808f91",
341
+ },
339
342
  },
340
343
  "radii": Object {
341
344
  "icon": 4,
@@ -2,8 +2,11 @@ import type { GlobalTheme } from '../global';
2
2
 
3
3
  const getCheckboxTheme = (theme: GlobalTheme) => {
4
4
  const colors = {
5
- default: theme.colors.primaryOutline,
6
- disabledBorder: theme.colors.disabledOutline,
5
+ borders: {
6
+ default: theme.colors.primaryOutline,
7
+ disabled: theme.colors.disabledOutline,
8
+ readonly: theme.colors.inactiveOutline,
9
+ },
7
10
  };
8
11
 
9
12
  const space = {
@@ -1,11 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { TouchableOpacity, View } from 'react-native';
3
+ type CheckboxThemeState = 'default' | 'disabled' | 'readonly';
3
4
  export declare const StyledWrapper: import("@emotion/native").StyledComponent<import("react-native").TouchableOpacityProps & {
4
5
  theme?: import("@emotion/react").Theme | undefined;
5
6
  as?: import("react").ElementType<any> | undefined;
6
7
  } & {
7
8
  themeWithBorder: boolean;
8
- themeDisabled: boolean;
9
+ themeState: CheckboxThemeState;
9
10
  }, {}, {
10
11
  ref?: import("react").Ref<TouchableOpacity> | undefined;
11
12
  }>;
@@ -23,11 +24,14 @@ export declare const StyledCheckbox: import("@emotion/native").StyledComponent<i
23
24
  theme?: import("@emotion/react").Theme | undefined;
24
25
  as?: import("react").ElementType<any> | undefined;
25
26
  } & {
26
- themeDisabled: boolean;
27
+ themeState: CheckboxThemeState;
27
28
  }, {}, {
28
29
  ref?: import("react").Ref<View> | undefined;
29
30
  }>;
30
31
  export declare const StyledCheckMark: import("@emotion/native").StyledComponent<import("../Icon").IconProps & {
31
32
  theme?: import("@emotion/react").Theme | undefined;
32
33
  as?: import("react").ElementType<any> | undefined;
34
+ } & {
35
+ themeState: CheckboxThemeState;
33
36
  }, {}, {}>;
37
+ export {};
@@ -28,6 +28,15 @@ export interface CheckboxProps {
28
28
  * Testing id of the component.
29
29
  */
30
30
  testID?: string;
31
+ /**
32
+ * Readonly of the checkbox.
33
+ */
34
+ readonly?: boolean;
31
35
  }
32
- declare const Checkbox: ({ checked, description, withBorder, disabled, onPress, style, testID, }: CheckboxProps) => JSX.Element;
36
+ type getStateType = {
37
+ disabled: boolean;
38
+ readonly: boolean;
39
+ };
40
+ export declare const getThemeState: ({ disabled, readonly }: getStateType) => "default" | "disabled" | "readonly";
41
+ declare const Checkbox: ({ checked, description, withBorder, disabled, onPress, style, testID, readonly, }: CheckboxProps) => JSX.Element;
33
42
  export default Checkbox;
@@ -1,8 +1,11 @@
1
1
  import type { GlobalTheme } from '../global';
2
2
  declare const getCheckboxTheme: (theme: GlobalTheme) => {
3
3
  colors: {
4
- default: string;
5
- disabledBorder: string;
4
+ borders: {
5
+ default: string;
6
+ disabled: string;
7
+ readonly: string;
8
+ };
6
9
  };
7
10
  space: {
8
11
  iconTop: number;