@hero-design/rn 8.60.0 → 8.61.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.
@@ -2,4 +2,4 @@
2
2
  src/index.ts → lib/index.js, es/index.js...
3
3
  (!) 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`.
4
4
  (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
5
- created lib/index.js, es/index.js in 57.4s
5
+ created lib/index.js, es/index.js in 1m 0.6s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.61.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2786](https://github.com/Thinkei/hero-design/pull/2786) [`f5f4d1d55`](https://github.com/Thinkei/hero-design/commit/f5f4d1d55601f9ae3e37438f0928e9a6173ae260) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [Radio.Group] Update indicator color and add inactiveIntent prop
8
+
3
9
  ## 8.60.0
4
10
 
5
11
  ### Minor Changes
package/es/index.js CHANGED
@@ -2934,11 +2934,17 @@ var getProgressTheme = function getProgressTheme(theme) {
2934
2934
 
2935
2935
  var getRadioTheme = function getRadioTheme(theme) {
2936
2936
  var colors = {
2937
- circle: theme.colors.onDefaultGlobalSurface
2937
+ circle: theme.colors.primary,
2938
+ checked: theme.colors.highlightedSurface,
2939
+ intents: {
2940
+ light: theme.colors.defaultGlobalSurface,
2941
+ dark: theme.colors.neutralGlobalSurface
2942
+ }
2938
2943
  };
2939
2944
  var space = {
2940
2945
  circleLeftMargin: theme.space.small,
2941
- groupTopMargin: theme.space.xsmall
2946
+ groupTopMarginSmall: theme.space.xsmall,
2947
+ groupTopMarginMedium: theme.space.medium
2942
2948
  };
2943
2949
  var boundingBoxSize = theme.sizes.large;
2944
2950
  var innerPadding = theme.space.xsmall;
@@ -16145,9 +16151,18 @@ var InnerCircle = index$9(View)(function (_ref2) {
16145
16151
  };
16146
16152
  });
16147
16153
  var Spacer = index$9(View)(function (_ref3) {
16148
- var theme = _ref3.theme;
16154
+ var theme = _ref3.theme,
16155
+ themeIntent = _ref3.themeIntent;
16156
+ return {
16157
+ marginTop: themeIntent === 'light' ? theme.__hd__.radio.space.groupTopMarginSmall : theme.__hd__.radio.space.groupTopMarginMedium
16158
+ };
16159
+ });
16160
+ var StyledRadio = index$9(List.Item)(function (_ref4) {
16161
+ var theme = _ref4.theme,
16162
+ themeIntent = _ref4.themeIntent,
16163
+ themeChecked = _ref4.themeChecked;
16149
16164
  return {
16150
- marginTop: theme.__hd__.radio.space.groupTopMargin
16165
+ backgroundColor: themeChecked ? theme.__hd__.radio.colors.checked : theme.__hd__.radio.colors.intents[themeIntent]
16151
16166
  };
16152
16167
  });
16153
16168
 
@@ -16164,17 +16179,23 @@ var Radio = function Radio(_ref2) {
16164
16179
  checked = _ref2$checked === void 0 ? false : _ref2$checked,
16165
16180
  onPress = _ref2.onPress,
16166
16181
  style = _ref2.style,
16167
- testID = _ref2.testID;
16168
- return /*#__PURE__*/React.createElement(List.BasicItem, {
16182
+ subText = _ref2.subText,
16183
+ testID = _ref2.testID,
16184
+ _ref2$inactiveIntent = _ref2.inactiveIntent,
16185
+ inactiveIntent = _ref2$inactiveIntent === void 0 ? 'light' : _ref2$inactiveIntent;
16186
+ return /*#__PURE__*/React.createElement(StyledRadio, {
16169
16187
  onPress: onPress,
16170
16188
  selected: checked,
16171
16189
  title: text,
16190
+ subtitle: subText,
16172
16191
  suffix: /*#__PURE__*/React.createElement(RadioCircle, {
16173
16192
  checked: checked,
16174
16193
  text: text
16175
16194
  }),
16176
16195
  style: style,
16177
- testID: testID
16196
+ testID: testID,
16197
+ themeIntent: inactiveIntent,
16198
+ themeChecked: checked
16178
16199
  });
16179
16200
  };
16180
16201
 
@@ -16195,19 +16216,25 @@ var RadioGroup = function RadioGroup(_ref) {
16195
16216
  options = _ref.options,
16196
16217
  keyExtractor = _ref.keyExtractor,
16197
16218
  style = _ref.style,
16198
- testID = _ref.testID;
16219
+ testID = _ref.testID,
16220
+ _ref$inactiveIntent = _ref.inactiveIntent,
16221
+ inactiveIntent = _ref$inactiveIntent === void 0 ? 'light' : _ref$inactiveIntent;
16199
16222
  return /*#__PURE__*/React.createElement(View, {
16200
16223
  style: style,
16201
16224
  testID: testID
16202
16225
  }, options.map(function (option, index) {
16203
16226
  return /*#__PURE__*/React.createElement(React.Fragment, {
16204
16227
  key: getKey(option, index, keyExtractor)
16205
- }, index !== 0 && /*#__PURE__*/React.createElement(Spacer, null), /*#__PURE__*/React.createElement(Radio, {
16228
+ }, index !== 0 && /*#__PURE__*/React.createElement(Spacer, {
16229
+ themeIntent: inactiveIntent
16230
+ }), /*#__PURE__*/React.createElement(Radio, {
16206
16231
  text: option.text,
16232
+ subText: option.subText,
16207
16233
  checked: option.value === value,
16208
16234
  onPress: function onPress() {
16209
16235
  return _onPress(option.value);
16210
- }
16236
+ },
16237
+ inactiveIntent: inactiveIntent
16211
16238
  }));
16212
16239
  }));
16213
16240
  };
package/lib/index.js CHANGED
@@ -2964,11 +2964,17 @@ var getProgressTheme = function getProgressTheme(theme) {
2964
2964
 
2965
2965
  var getRadioTheme = function getRadioTheme(theme) {
2966
2966
  var colors = {
2967
- circle: theme.colors.onDefaultGlobalSurface
2967
+ circle: theme.colors.primary,
2968
+ checked: theme.colors.highlightedSurface,
2969
+ intents: {
2970
+ light: theme.colors.defaultGlobalSurface,
2971
+ dark: theme.colors.neutralGlobalSurface
2972
+ }
2968
2973
  };
2969
2974
  var space = {
2970
2975
  circleLeftMargin: theme.space.small,
2971
- groupTopMargin: theme.space.xsmall
2976
+ groupTopMarginSmall: theme.space.xsmall,
2977
+ groupTopMarginMedium: theme.space.medium
2972
2978
  };
2973
2979
  var boundingBoxSize = theme.sizes.large;
2974
2980
  var innerPadding = theme.space.xsmall;
@@ -16175,9 +16181,18 @@ var InnerCircle = index$9(reactNative.View)(function (_ref2) {
16175
16181
  };
16176
16182
  });
16177
16183
  var Spacer = index$9(reactNative.View)(function (_ref3) {
16178
- var theme = _ref3.theme;
16184
+ var theme = _ref3.theme,
16185
+ themeIntent = _ref3.themeIntent;
16186
+ return {
16187
+ marginTop: themeIntent === 'light' ? theme.__hd__.radio.space.groupTopMarginSmall : theme.__hd__.radio.space.groupTopMarginMedium
16188
+ };
16189
+ });
16190
+ var StyledRadio = index$9(List.Item)(function (_ref4) {
16191
+ var theme = _ref4.theme,
16192
+ themeIntent = _ref4.themeIntent,
16193
+ themeChecked = _ref4.themeChecked;
16179
16194
  return {
16180
- marginTop: theme.__hd__.radio.space.groupTopMargin
16195
+ backgroundColor: themeChecked ? theme.__hd__.radio.colors.checked : theme.__hd__.radio.colors.intents[themeIntent]
16181
16196
  };
16182
16197
  });
16183
16198
 
@@ -16194,17 +16209,23 @@ var Radio = function Radio(_ref2) {
16194
16209
  checked = _ref2$checked === void 0 ? false : _ref2$checked,
16195
16210
  onPress = _ref2.onPress,
16196
16211
  style = _ref2.style,
16197
- testID = _ref2.testID;
16198
- return /*#__PURE__*/React__default["default"].createElement(List.BasicItem, {
16212
+ subText = _ref2.subText,
16213
+ testID = _ref2.testID,
16214
+ _ref2$inactiveIntent = _ref2.inactiveIntent,
16215
+ inactiveIntent = _ref2$inactiveIntent === void 0 ? 'light' : _ref2$inactiveIntent;
16216
+ return /*#__PURE__*/React__default["default"].createElement(StyledRadio, {
16199
16217
  onPress: onPress,
16200
16218
  selected: checked,
16201
16219
  title: text,
16220
+ subtitle: subText,
16202
16221
  suffix: /*#__PURE__*/React__default["default"].createElement(RadioCircle, {
16203
16222
  checked: checked,
16204
16223
  text: text
16205
16224
  }),
16206
16225
  style: style,
16207
- testID: testID
16226
+ testID: testID,
16227
+ themeIntent: inactiveIntent,
16228
+ themeChecked: checked
16208
16229
  });
16209
16230
  };
16210
16231
 
@@ -16225,19 +16246,25 @@ var RadioGroup = function RadioGroup(_ref) {
16225
16246
  options = _ref.options,
16226
16247
  keyExtractor = _ref.keyExtractor,
16227
16248
  style = _ref.style,
16228
- testID = _ref.testID;
16249
+ testID = _ref.testID,
16250
+ _ref$inactiveIntent = _ref.inactiveIntent,
16251
+ inactiveIntent = _ref$inactiveIntent === void 0 ? 'light' : _ref$inactiveIntent;
16229
16252
  return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
16230
16253
  style: style,
16231
16254
  testID: testID
16232
16255
  }, options.map(function (option, index) {
16233
16256
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
16234
16257
  key: getKey(option, index, keyExtractor)
16235
- }, index !== 0 && /*#__PURE__*/React__default["default"].createElement(Spacer, null), /*#__PURE__*/React__default["default"].createElement(Radio, {
16258
+ }, index !== 0 && /*#__PURE__*/React__default["default"].createElement(Spacer, {
16259
+ themeIntent: inactiveIntent
16260
+ }), /*#__PURE__*/React__default["default"].createElement(Radio, {
16236
16261
  text: option.text,
16262
+ subText: option.subText,
16237
16263
  checked: option.value === value,
16238
16264
  onPress: function onPress() {
16239
16265
  return _onPress(option.value);
16240
- }
16266
+ },
16267
+ inactiveIntent: inactiveIntent
16241
16268
  }));
16242
16269
  }));
16243
16270
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.60.0",
3
+ "version": "8.61.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,9 +1,8 @@
1
- import React from 'react';
2
1
  import type { ReactElement } from 'react';
2
+ import React from 'react';
3
3
  import type { StyleProp, ViewStyle } from 'react-native';
4
4
 
5
- import List from '../List';
6
- import { Circle, InnerCircle } from './StyledRadio';
5
+ import { Circle, InnerCircle, StyledRadio } from './StyledRadio';
7
6
 
8
7
  export interface RadioProps {
9
8
  /**
@@ -22,10 +21,18 @@ export interface RadioProps {
22
21
  * Additional style.
23
22
  */
24
23
  style?: StyleProp<ViewStyle>;
24
+ /**
25
+ * Radio subtext.
26
+ */
27
+ subText?: string;
25
28
  /**
26
29
  * Testing id of the component.
27
30
  */
28
31
  testID?: string;
32
+ /**
33
+ * Idle background color of the Radio.
34
+ */
35
+ inactiveIntent?: 'light' | 'dark';
29
36
  }
30
37
 
31
38
  const RadioCircle = ({
@@ -42,15 +49,20 @@ const Radio = ({
42
49
  checked = false,
43
50
  onPress,
44
51
  style,
52
+ subText,
45
53
  testID,
54
+ inactiveIntent = 'light',
46
55
  }: RadioProps): ReactElement => (
47
- <List.BasicItem
56
+ <StyledRadio
48
57
  onPress={onPress}
49
58
  selected={checked}
50
59
  title={text}
60
+ subtitle={subText}
51
61
  suffix={<RadioCircle checked={checked} text={text} />}
52
62
  style={style}
53
63
  testID={testID}
64
+ themeIntent={inactiveIntent}
65
+ themeChecked={checked}
54
66
  />
55
67
  );
56
68
 
@@ -1,7 +1,7 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
3
1
  import type { ReactElement } from 'react';
2
+ import React from 'react';
4
3
  import type { StyleProp, ViewStyle } from 'react-native';
4
+ import { View } from 'react-native';
5
5
  import Radio from './Radio';
6
6
  import { Spacer } from './StyledRadio';
7
7
  import type { OptionType } from './types';
@@ -32,6 +32,10 @@ export interface RadioGroupProps<T> {
32
32
  * Testing id of the component.
33
33
  */
34
34
  testID?: string;
35
+ /**
36
+ * Idle background color of the Radio.
37
+ */
38
+ inactiveIntent?: 'light' | 'dark';
35
39
  }
36
40
 
37
41
  function getKey<T>(
@@ -58,15 +62,18 @@ const RadioGroup = <T,>({
58
62
  keyExtractor,
59
63
  style,
60
64
  testID,
65
+ inactiveIntent = 'light',
61
66
  }: RadioGroupProps<T>): ReactElement => (
62
67
  <View style={style} testID={testID}>
63
68
  {options.map((option, index) => (
64
69
  <React.Fragment key={getKey(option, index, keyExtractor)}>
65
- {index !== 0 && <Spacer />}
70
+ {index !== 0 && <Spacer themeIntent={inactiveIntent} />}
66
71
  <Radio
67
72
  text={option.text}
73
+ subText={option.subText}
68
74
  checked={option.value === value}
69
75
  onPress={() => onPress(option.value)}
76
+ inactiveIntent={inactiveIntent}
70
77
  />
71
78
  </React.Fragment>
72
79
  ))}
@@ -1,5 +1,8 @@
1
1
  import { View } from 'react-native';
2
2
  import styled from '@emotion/native';
3
+ import List from '../List';
4
+
5
+ type RadioIntent = 'light' | 'dark';
3
6
 
4
7
  const Circle = styled(View)(({ theme }) => ({
5
8
  height: theme.__hd__.radio.sizes.circle,
@@ -18,8 +21,22 @@ const InnerCircle = styled(View)(({ theme }) => ({
18
21
  backgroundColor: theme.__hd__.radio.colors.circle,
19
22
  }));
20
23
 
21
- const Spacer = styled(View)(({ theme }) => ({
22
- marginTop: theme.__hd__.radio.space.groupTopMargin,
24
+ const Spacer = styled(View)<{ themeIntent: RadioIntent }>(
25
+ ({ theme, themeIntent }) => ({
26
+ marginTop:
27
+ themeIntent === 'light'
28
+ ? theme.__hd__.radio.space.groupTopMarginSmall
29
+ : theme.__hd__.radio.space.groupTopMarginMedium,
30
+ })
31
+ );
32
+
33
+ const StyledRadio = styled(List.Item)<{
34
+ themeIntent: RadioIntent;
35
+ themeChecked: boolean;
36
+ }>(({ theme, themeIntent, themeChecked }) => ({
37
+ backgroundColor: themeChecked
38
+ ? theme.__hd__.radio.colors.checked
39
+ : theme.__hd__.radio.colors.intents[themeIntent],
23
40
  }));
24
41
 
25
- export { Circle, InnerCircle, Spacer };
42
+ export { Circle, InnerCircle, Spacer, StyledRadio };
@@ -4,24 +4,57 @@ import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
4
  import Radio from '../Radio';
5
5
 
6
6
  describe('rendering', () => {
7
- it('renders correctly when checked', () => {
8
- const { getByText, queryAllByTestId, toJSON } = renderWithTheme(
9
- <Radio text="Option A" onPress={jest.fn} checked />
10
- );
7
+ it.each`
8
+ inactiveIntent
9
+ ${'light'}
10
+ ${'dark'}
11
+ `(
12
+ 'renders correctly when checked with inactiveIntent=$inactiveIntent',
13
+ ({ inactiveIntent }) => {
14
+ const { getByText, queryAllByTestId, toJSON } = renderWithTheme(
15
+ <Radio
16
+ inactiveIntent={inactiveIntent}
17
+ text="Option A"
18
+ onPress={jest.fn}
19
+ checked
20
+ />
21
+ );
11
22
 
12
- expect(getByText('Option A')).toBeDefined();
13
- expect(queryAllByTestId('Option A-selected-circle')).toHaveLength(1);
14
- expect(toJSON()).toMatchSnapshot();
15
- });
23
+ expect(getByText('Option A')).toBeDefined();
24
+ expect(queryAllByTestId('Option A-selected-circle')).toHaveLength(1);
25
+ expect(toJSON()).toMatchSnapshot();
26
+ }
27
+ );
16
28
 
17
- it('renders correctly when not checked', () => {
18
- const { getByText, toJSON, queryAllByTestId } = renderWithTheme(
19
- <Radio text="Option A" onPress={jest.fn} checked={false} />
29
+ it.each`
30
+ inactiveIntent
31
+ ${'light'}
32
+ ${'dark'}
33
+ `(
34
+ 'renders correctly when not checked with inactiveIntent=$inactiveIntent',
35
+ ({ inactiveIntent }) => {
36
+ const { getByText, toJSON, queryAllByTestId } = renderWithTheme(
37
+ <Radio
38
+ inactiveIntent={inactiveIntent}
39
+ text="Option A"
40
+ onPress={jest.fn}
41
+ checked={false}
42
+ />
43
+ );
44
+
45
+ expect(getByText('Option A')).toBeDefined();
46
+ expect(queryAllByTestId('Option A-selected-circle')).toHaveLength(0);
47
+ expect(toJSON()).toMatchSnapshot();
48
+ }
49
+ );
50
+
51
+ it('allows rendering of subtext', () => {
52
+ const { getByText } = renderWithTheme(
53
+ <Radio text="Option A" subText="Option label" onPress={jest.fn} checked />
20
54
  );
21
55
 
22
56
  expect(getByText('Option A')).toBeDefined();
23
- expect(queryAllByTestId('Option A-selected-circle')).toHaveLength(0);
24
- expect(toJSON()).toMatchSnapshot();
57
+ expect(getByText('Option label')).toBeDefined();
25
58
  });
26
59
  });
27
60
 
@@ -9,17 +9,50 @@ const options = [
9
9
  { text: 'Nothing', value: 'nothing' },
10
10
  ];
11
11
 
12
+ const optionsWithSubtext = [
13
+ { text: 'On Demand', subText: 'InstaPay Now', value: 'on_demand' },
14
+ { text: 'Daily', subText: 'InstaPay Daily', value: 'daily' },
15
+ ];
16
+
12
17
  describe('rendering', () => {
13
- it('renders correctly', () => {
14
- const { getByText, toJSON, queryAllByTestId } = renderWithTheme(
15
- <RadioGroup options={options} value="nothing" onPress={jest.fn()} />
18
+ it.each`
19
+ inactiveIntent
20
+ ${'light'}
21
+ ${'dark'}
22
+ `(
23
+ 'renders correctly with inactiveIntent=$inactiveIntent',
24
+ ({ inactiveIntent }) => {
25
+ const { getByText, toJSON, queryAllByTestId } = renderWithTheme(
26
+ <RadioGroup
27
+ inactiveIntent={inactiveIntent}
28
+ options={options}
29
+ value="nothing"
30
+ onPress={jest.fn()}
31
+ />
32
+ );
33
+
34
+ expect(getByText('Everything')).toBeDefined();
35
+ expect(getByText('Direct mentions only')).toBeDefined();
36
+ expect(getByText('Nothing')).toBeDefined();
37
+ expect(queryAllByTestId('Nothing-selected-circle')).toHaveLength(1);
38
+ expect(toJSON()).toMatchSnapshot();
39
+ }
40
+ );
41
+
42
+ it('renders correctly with subtext', () => {
43
+ const { getByText, toJSON } = renderWithTheme(
44
+ <RadioGroup
45
+ options={optionsWithSubtext}
46
+ value="nothing"
47
+ onPress={jest.fn()}
48
+ />
16
49
  );
17
50
 
18
- expect(getByText('Everything')).toBeDefined();
19
- expect(getByText('Direct mentions only')).toBeDefined();
20
- expect(getByText('Nothing')).toBeDefined();
21
- expect(queryAllByTestId('Nothing-selected-circle')).toHaveLength(1);
22
51
  expect(toJSON()).toMatchSnapshot();
52
+ expect(getByText('On Demand')).toBeDefined();
53
+ expect(getByText('InstaPay Now')).toBeDefined();
54
+ expect(getByText('Daily')).toBeDefined();
55
+ expect(getByText('InstaPay Daily')).toBeDefined();
23
56
  });
24
57
  });
25
58