@hero-design/rn 8.97.0 → 8.98.0-alpha.1

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 (38) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/es/index.js +48 -15
  3. package/lib/index.js +48 -15
  4. package/locales/en_AU.d.ts +3 -0
  5. package/locales/en_CA.d.ts +3 -0
  6. package/locales/index.d.ts +5 -0
  7. package/locales/types.d.ts +10 -0
  8. package/package.json +1 -1
  9. package/src/components/Button/Button.tsx +16 -6
  10. package/src/components/Button/StyledButton.tsx +78 -29
  11. package/src/components/Button/__tests__/Button.spec.tsx +51 -36
  12. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +1873 -0
  13. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +2 -0
  14. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
  15. package/src/components/Tabs/StyledScrollableTabs.tsx +10 -2
  16. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +1 -0
  17. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +4 -1
  18. package/src/theme/components/button.ts +4 -1
  19. package/stats/8.98.0/rn-stats.html +4842 -0
  20. package/types/components/Button/Button.d.ts +2 -2
  21. package/types/components/Button/StyledButton.d.ts +1 -0
  22. package/types/components/DatePicker/DatePickerDialog/AndroidDatePickerDialog.d.ts +4 -0
  23. package/types/components/DatePicker/DatePickerDialog/IOSDatePickerDialog.d.ts +4 -0
  24. package/types/components/DatePicker/DatePickerDialog/type.d.ts +50 -0
  25. package/types/components/DatePicker/useCalculateDate.d.ts +4 -0
  26. package/types/components/DatePicker/useFormatDate.d.ts +12 -0
  27. package/types/components/Empty/StyledEmpty.d.ts +21 -0
  28. package/types/components/Empty/index.d.ts +31 -0
  29. package/types/components/Error/StyledError.d.ts +53 -0
  30. package/types/components/Error/index.d.ts +56 -0
  31. package/types/components/Success/StyledSuccess.d.ts +49 -0
  32. package/types/components/Success/index.d.ts +50 -0
  33. package/types/theme/components/button.d.ts +4 -1
  34. package/types/theme/global/shadows/shadows.d.ts +9 -0
  35. package/types/theme/global/shadows/swagLight.d.ts +3 -0
  36. package/types/theme/global/shadows/swagLightJobs.d.ts +3 -0
  37. package/types/theme/global/shadows.d.ts +16 -0
  38. package/.turbo/turbo-build.log +0 -18
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.98.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#3788](https://github.com/Thinkei/hero-design/pull/3788) [`1c42238a8c0b3651f621b04994bd812e14a30c8c`](https://github.com/Thinkei/hero-design/commit/1c42238a8c0b3651f621b04994bd812e14a30c8c) Thanks [@ttkien](https://github.com/ttkien)! - [Button] add compact text and compact inline text
8
+
3
9
  ## 8.97.0
4
10
 
5
11
  ### Minor Changes
package/es/index.js CHANGED
@@ -2794,7 +2794,10 @@ var getButtonTheme = function getButtonTheme(theme) {
2794
2794
  }
2795
2795
  };
2796
2796
  var lineHeights = {
2797
- titleOfTextVariant: theme.lineHeights.medium,
2797
+ titleOfTextVariant: {
2798
+ "default": theme.lineHeights.medium,
2799
+ compact: theme.lineHeights.small
2800
+ },
2798
2801
  buttonText: Platform.select({
2799
2802
  android: theme.lineHeights.medium + theme.space.xxsmall
2800
2803
  }),
@@ -9052,7 +9055,7 @@ var Avatar = function Avatar(_ref) {
9052
9055
  }));
9053
9056
  };
9054
9057
 
9055
- var isIOS = Platform.OS === 'ios';
9058
+ var isIOS$1 = Platform.OS === 'ios';
9056
9059
  var isAndroid = Platform.OS === 'android';
9057
9060
  function pick(keys, obj) {
9058
9061
  return keys.filter(function (key) {
@@ -9786,7 +9789,7 @@ var BottomNavigation = function BottomNavigation(_ref) {
9786
9789
  removeClippedSubviews:
9787
9790
  // On iOS, set removeClippedSubviews to true only when not focused
9788
9791
  // This is an workaround for a bug where the clipped view never re-appears.
9789
- isIOS ? selectedTabKey !== key : true,
9792
+ isIOS$1 ? selectedTabKey !== key : true,
9790
9793
  themeVisibility: active
9791
9794
  }, component);
9792
9795
  })), /*#__PURE__*/React__default.createElement(BottomBarWrapper, {
@@ -10117,6 +10120,24 @@ var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent
10117
10120
  backgroundColor: 'transparent'
10118
10121
  }, borderColorStyling());
10119
10122
  };
10123
+ var getTextButtonPaddingVertical = function getTextButtonPaddingVertical(theme, themeInlineText, themeIsCompact) {
10124
+ if (themeInlineText) {
10125
+ return 0;
10126
+ }
10127
+ if (themeIsCompact) {
10128
+ return theme.__hd__.button.space.compact.buttonPaddingVertical;
10129
+ }
10130
+ return theme.__hd__.button.space["default"].textButtonPadding;
10131
+ };
10132
+ var getTextButtonPaddingHorizontal = function getTextButtonPaddingHorizontal(theme, themeInlineText, themeIsCompact) {
10133
+ if (themeInlineText) {
10134
+ return 0;
10135
+ }
10136
+ if (themeIsCompact) {
10137
+ return theme.__hd__.button.space.compact.buttonPaddingHorizontal;
10138
+ }
10139
+ return theme.__hd__.button.space["default"].textButtonPadding;
10140
+ };
10120
10141
  var genTextStyles = function genTextStyles(theme, intent, disabled, isPressed) {
10121
10142
  if (disabled) {
10122
10143
  return {
@@ -10164,16 +10185,22 @@ var StyledButtonContainer = index$b(TouchableHighlight)(function (_ref) {
10164
10185
  case 'text-secondary':
10165
10186
  case 'text-danger':
10166
10187
  case 'text-white':
10167
- return {
10188
+ return _objectSpread2(_objectSpread2({
10168
10189
  height: themeInlineText ? undefined : getButtonHeight(themeIsCompact),
10169
10190
  borderRadius: theme.__hd__.button.radii.text,
10170
10191
  flexDirection: 'row',
10171
10192
  justifyContent: 'center',
10172
- alignItems: 'center',
10173
- padding: themeInlineText ? 0 : theme.__hd__.button.space["default"].textButtonPadding,
10193
+ alignItems: 'center'
10194
+ }, themeIsCompact ? {
10195
+ alignSelf: 'flex-start',
10196
+ paddingVertical: getTextButtonPaddingVertical(theme, themeInlineText, themeIsCompact),
10197
+ paddingHorizontal: getTextButtonPaddingHorizontal(theme, themeInlineText, themeIsCompact)
10198
+ } : {
10199
+ padding: themeInlineText ? 0 : theme.__hd__.button.space["default"].textButtonPadding
10200
+ }), {}, {
10174
10201
  borderWidth: 0,
10175
10202
  backgroundColor: loading && !themeInlineText && themeButtonVariant !== 'text-white' ? theme.__hd__.button.colors.textLoadingBackground : 'transparent'
10176
- };
10203
+ });
10177
10204
  }
10178
10205
  });
10179
10206
  var genWhiteTextStyles = function genWhiteTextStyles(_ref2) {
@@ -10264,7 +10291,8 @@ var StyledButtonTitleOfVariantText = index$b(Typography.Body)(function (_ref5) {
10264
10291
  var disabled = _ref5.disabled,
10265
10292
  themeButtonVariant = _ref5.themeButtonVariant,
10266
10293
  themeIsPressed = _ref5.themeIsPressed,
10267
- theme = _ref5.theme;
10294
+ theme = _ref5.theme,
10295
+ themeIsCompact = _ref5.themeIsCompact;
10268
10296
  var themeStyling = function themeStyling() {
10269
10297
  switch (themeButtonVariant) {
10270
10298
  case 'text-primary':
@@ -10283,7 +10311,7 @@ var StyledButtonTitleOfVariantText = index$b(Typography.Body)(function (_ref5) {
10283
10311
  };
10284
10312
  return _objectSpread2({
10285
10313
  flexShrink: 1,
10286
- lineHeight: theme.__hd__.button.lineHeights.titleOfTextVariant,
10314
+ lineHeight: theme.__hd__.button.lineHeights.titleOfTextVariant[themeIsCompact ? 'compact' : 'default'],
10287
10315
  textAlign: 'center',
10288
10316
  textAlignVertical: 'center'
10289
10317
  }, themeStyling());
@@ -10374,6 +10402,7 @@ var getThemeVariant = function getThemeVariant(variant, intent) {
10374
10402
  case 'outlined-compact':
10375
10403
  return OUTLINED_VARIANTS[intent];
10376
10404
  case 'text':
10405
+ case 'text-compact':
10377
10406
  return TEXT_VARIANTS[intent];
10378
10407
  }
10379
10408
  };
@@ -10426,7 +10455,7 @@ var Button = function Button(_ref) {
10426
10455
  text = _ref.text,
10427
10456
  _ref$variant = _ref.variant,
10428
10457
  variant = _ref$variant === void 0 ? 'filled' : _ref$variant;
10429
- var isInlineText = variant === 'inline-text';
10458
+ var isInlineText = variant === 'inline-text' || variant === 'inline-text-compact';
10430
10459
  var themeVariant = getThemeVariant(isInlineText ? 'text' : variant, intent);
10431
10460
  var theme = useTheme();
10432
10461
  var underlayColor = useMemo(function () {
@@ -10437,7 +10466,7 @@ var Button = function Button(_ref) {
10437
10466
  isPressed = _useState2[0],
10438
10467
  setIsPressed = _useState2[1];
10439
10468
  useDeprecation("Button variant ".concat(deprecatedVariants.join(', '), " are deprecated."), deprecatedVariants.includes(themeVariant));
10440
- var isCompactVariant = ['filled-compact', 'outlined-compact'].includes(variant);
10469
+ var isCompactVariant = ['filled-compact', 'outlined-compact', 'text-compact', 'inline-text-compact'].includes(variant);
10441
10470
  var isRenderTextVariant = isTextVariant(themeVariant);
10442
10471
  var renderTextVariantTitle = function renderTextVariantTitle() {
10443
10472
  if (!isRenderTextVariant) return null;
@@ -10447,7 +10476,8 @@ var Button = function Button(_ref) {
10447
10476
  numberOfLines: 1,
10448
10477
  disabled: disabled,
10449
10478
  themeButtonVariant: themeVariant,
10450
- themeIsPressed: isPressed
10479
+ themeIsPressed: isPressed,
10480
+ themeIsCompact: isCompactVariant
10451
10481
  }, text);
10452
10482
  };
10453
10483
  var renderTitle = function renderTitle() {
@@ -20887,6 +20917,8 @@ var ActiveTabIndicator = function ActiveTabIndicator(_ref) {
20887
20917
  });
20888
20918
  };
20889
20919
 
20920
+ var isAndroid8 = Platform.OS === 'android' && (Platform.Version === 26 || Platform.Version === 27);
20921
+ var isIOS = Platform.OS === 'ios';
20890
20922
  var TabScreen = index$b(View)({
20891
20923
  flex: 1
20892
20924
  });
@@ -20926,13 +20958,14 @@ var HeaderTabItemOutline = index$b(Animated.View)(function (_ref4) {
20926
20958
  });
20927
20959
  var HeaderTabItemWrapper = index$b(View)(function (_ref5) {
20928
20960
  var theme = _ref5.theme;
20929
- return {
20961
+ return _objectSpread2({
20930
20962
  paddingHorizontal: theme.__hd__.tabs.space.outlineHorizontalPadding,
20931
20963
  paddingVertical: theme.__hd__.tabs.space.outlineVerticalPadding,
20932
20964
  position: 'relative',
20933
- justifyContent: 'center',
20965
+ justifyContent: 'center'
20966
+ }, (!isAndroid8 || isIOS) && {
20934
20967
  alignItems: 'center'
20935
- };
20968
+ });
20936
20969
  });
20937
20970
  var HeaderTabItemIndicator = index$b(Animated.View)(function (_ref6) {
20938
20971
  var theme = _ref6.theme;
package/lib/index.js CHANGED
@@ -2823,7 +2823,10 @@ var getButtonTheme = function getButtonTheme(theme) {
2823
2823
  }
2824
2824
  };
2825
2825
  var lineHeights = {
2826
- titleOfTextVariant: theme.lineHeights.medium,
2826
+ titleOfTextVariant: {
2827
+ "default": theme.lineHeights.medium,
2828
+ compact: theme.lineHeights.small
2829
+ },
2827
2830
  buttonText: reactNative.Platform.select({
2828
2831
  android: theme.lineHeights.medium + theme.space.xxsmall
2829
2832
  }),
@@ -9081,7 +9084,7 @@ var Avatar = function Avatar(_ref) {
9081
9084
  }));
9082
9085
  };
9083
9086
 
9084
- var isIOS = reactNative.Platform.OS === 'ios';
9087
+ var isIOS$1 = reactNative.Platform.OS === 'ios';
9085
9088
  var isAndroid = reactNative.Platform.OS === 'android';
9086
9089
  function pick(keys, obj) {
9087
9090
  return keys.filter(function (key) {
@@ -9815,7 +9818,7 @@ var BottomNavigation = function BottomNavigation(_ref) {
9815
9818
  removeClippedSubviews:
9816
9819
  // On iOS, set removeClippedSubviews to true only when not focused
9817
9820
  // This is an workaround for a bug where the clipped view never re-appears.
9818
- isIOS ? selectedTabKey !== key : true,
9821
+ isIOS$1 ? selectedTabKey !== key : true,
9819
9822
  themeVisibility: active
9820
9823
  }, component);
9821
9824
  })), /*#__PURE__*/React__namespace.default.createElement(BottomBarWrapper, {
@@ -10146,6 +10149,24 @@ var genOutlineContainerStyles = function genOutlineContainerStyles(theme, intent
10146
10149
  backgroundColor: 'transparent'
10147
10150
  }, borderColorStyling());
10148
10151
  };
10152
+ var getTextButtonPaddingVertical = function getTextButtonPaddingVertical(theme, themeInlineText, themeIsCompact) {
10153
+ if (themeInlineText) {
10154
+ return 0;
10155
+ }
10156
+ if (themeIsCompact) {
10157
+ return theme.__hd__.button.space.compact.buttonPaddingVertical;
10158
+ }
10159
+ return theme.__hd__.button.space["default"].textButtonPadding;
10160
+ };
10161
+ var getTextButtonPaddingHorizontal = function getTextButtonPaddingHorizontal(theme, themeInlineText, themeIsCompact) {
10162
+ if (themeInlineText) {
10163
+ return 0;
10164
+ }
10165
+ if (themeIsCompact) {
10166
+ return theme.__hd__.button.space.compact.buttonPaddingHorizontal;
10167
+ }
10168
+ return theme.__hd__.button.space["default"].textButtonPadding;
10169
+ };
10149
10170
  var genTextStyles = function genTextStyles(theme, intent, disabled, isPressed) {
10150
10171
  if (disabled) {
10151
10172
  return {
@@ -10193,16 +10214,22 @@ var StyledButtonContainer = index$b(reactNative.TouchableHighlight)(function (_r
10193
10214
  case 'text-secondary':
10194
10215
  case 'text-danger':
10195
10216
  case 'text-white':
10196
- return {
10217
+ return _objectSpread2(_objectSpread2({
10197
10218
  height: themeInlineText ? undefined : getButtonHeight(themeIsCompact),
10198
10219
  borderRadius: theme.__hd__.button.radii.text,
10199
10220
  flexDirection: 'row',
10200
10221
  justifyContent: 'center',
10201
- alignItems: 'center',
10202
- padding: themeInlineText ? 0 : theme.__hd__.button.space["default"].textButtonPadding,
10222
+ alignItems: 'center'
10223
+ }, themeIsCompact ? {
10224
+ alignSelf: 'flex-start',
10225
+ paddingVertical: getTextButtonPaddingVertical(theme, themeInlineText, themeIsCompact),
10226
+ paddingHorizontal: getTextButtonPaddingHorizontal(theme, themeInlineText, themeIsCompact)
10227
+ } : {
10228
+ padding: themeInlineText ? 0 : theme.__hd__.button.space["default"].textButtonPadding
10229
+ }), {}, {
10203
10230
  borderWidth: 0,
10204
10231
  backgroundColor: loading && !themeInlineText && themeButtonVariant !== 'text-white' ? theme.__hd__.button.colors.textLoadingBackground : 'transparent'
10205
- };
10232
+ });
10206
10233
  }
10207
10234
  });
10208
10235
  var genWhiteTextStyles = function genWhiteTextStyles(_ref2) {
@@ -10293,7 +10320,8 @@ var StyledButtonTitleOfVariantText = index$b(Typography.Body)(function (_ref5) {
10293
10320
  var disabled = _ref5.disabled,
10294
10321
  themeButtonVariant = _ref5.themeButtonVariant,
10295
10322
  themeIsPressed = _ref5.themeIsPressed,
10296
- theme = _ref5.theme;
10323
+ theme = _ref5.theme,
10324
+ themeIsCompact = _ref5.themeIsCompact;
10297
10325
  var themeStyling = function themeStyling() {
10298
10326
  switch (themeButtonVariant) {
10299
10327
  case 'text-primary':
@@ -10312,7 +10340,7 @@ var StyledButtonTitleOfVariantText = index$b(Typography.Body)(function (_ref5) {
10312
10340
  };
10313
10341
  return _objectSpread2({
10314
10342
  flexShrink: 1,
10315
- lineHeight: theme.__hd__.button.lineHeights.titleOfTextVariant,
10343
+ lineHeight: theme.__hd__.button.lineHeights.titleOfTextVariant[themeIsCompact ? 'compact' : 'default'],
10316
10344
  textAlign: 'center',
10317
10345
  textAlignVertical: 'center'
10318
10346
  }, themeStyling());
@@ -10403,6 +10431,7 @@ var getThemeVariant = function getThemeVariant(variant, intent) {
10403
10431
  case 'outlined-compact':
10404
10432
  return OUTLINED_VARIANTS[intent];
10405
10433
  case 'text':
10434
+ case 'text-compact':
10406
10435
  return TEXT_VARIANTS[intent];
10407
10436
  }
10408
10437
  };
@@ -10455,7 +10484,7 @@ var Button = function Button(_ref) {
10455
10484
  text = _ref.text,
10456
10485
  _ref$variant = _ref.variant,
10457
10486
  variant = _ref$variant === void 0 ? 'filled' : _ref$variant;
10458
- var isInlineText = variant === 'inline-text';
10487
+ var isInlineText = variant === 'inline-text' || variant === 'inline-text-compact';
10459
10488
  var themeVariant = getThemeVariant(isInlineText ? 'text' : variant, intent);
10460
10489
  var theme = useTheme();
10461
10490
  var underlayColor = React.useMemo(function () {
@@ -10466,7 +10495,7 @@ var Button = function Button(_ref) {
10466
10495
  isPressed = _useState2[0],
10467
10496
  setIsPressed = _useState2[1];
10468
10497
  useDeprecation("Button variant ".concat(deprecatedVariants.join(', '), " are deprecated."), deprecatedVariants.includes(themeVariant));
10469
- var isCompactVariant = ['filled-compact', 'outlined-compact'].includes(variant);
10498
+ var isCompactVariant = ['filled-compact', 'outlined-compact', 'text-compact', 'inline-text-compact'].includes(variant);
10470
10499
  var isRenderTextVariant = isTextVariant(themeVariant);
10471
10500
  var renderTextVariantTitle = function renderTextVariantTitle() {
10472
10501
  if (!isRenderTextVariant) return null;
@@ -10476,7 +10505,8 @@ var Button = function Button(_ref) {
10476
10505
  numberOfLines: 1,
10477
10506
  disabled: disabled,
10478
10507
  themeButtonVariant: themeVariant,
10479
- themeIsPressed: isPressed
10508
+ themeIsPressed: isPressed,
10509
+ themeIsCompact: isCompactVariant
10480
10510
  }, text);
10481
10511
  };
10482
10512
  var renderTitle = function renderTitle() {
@@ -20916,6 +20946,8 @@ var ActiveTabIndicator = function ActiveTabIndicator(_ref) {
20916
20946
  });
20917
20947
  };
20918
20948
 
20949
+ var isAndroid8 = reactNative.Platform.OS === 'android' && (reactNative.Platform.Version === 26 || reactNative.Platform.Version === 27);
20950
+ var isIOS = reactNative.Platform.OS === 'ios';
20919
20951
  var TabScreen = index$b(reactNative.View)({
20920
20952
  flex: 1
20921
20953
  });
@@ -20955,13 +20987,14 @@ var HeaderTabItemOutline = index$b(reactNative.Animated.View)(function (_ref4) {
20955
20987
  });
20956
20988
  var HeaderTabItemWrapper = index$b(reactNative.View)(function (_ref5) {
20957
20989
  var theme = _ref5.theme;
20958
- return {
20990
+ return _objectSpread2({
20959
20991
  paddingHorizontal: theme.__hd__.tabs.space.outlineHorizontalPadding,
20960
20992
  paddingVertical: theme.__hd__.tabs.space.outlineVerticalPadding,
20961
20993
  position: 'relative',
20962
- justifyContent: 'center',
20994
+ justifyContent: 'center'
20995
+ }, (!isAndroid8 || isIOS) && {
20963
20996
  alignItems: 'center'
20964
- };
20997
+ });
20965
20998
  });
20966
20999
  var HeaderTabItemIndicator = index$b(reactNative.Animated.View)(function (_ref6) {
20967
21000
  var theme = _ref6.theme;
@@ -0,0 +1,3 @@
1
+ import { LocaleValues } from './types';
2
+ declare const locale: LocaleValues;
3
+ export default locale;
@@ -0,0 +1,3 @@
1
+ import { LocaleValues } from './types';
2
+ declare const locale: LocaleValues;
3
+ export default locale;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ 'en-AU': import("./types").LocaleValues;
3
+ 'en-CA': import("./types").LocaleValues;
4
+ };
5
+ export default _default;
@@ -0,0 +1,10 @@
1
+ declare const LOCALES: readonly ["en-AU", "en-CA"];
2
+ export type LocaleCode = typeof LOCALES[number];
3
+ export type DateTimeFormats = {
4
+ fullDate: string;
5
+ };
6
+ export type LocaleValues = {
7
+ lang: LocaleCode;
8
+ dateTimeFormats: DateTimeFormats;
9
+ };
10
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.97.0",
3
+ "version": "8.98.0-alpha.1",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -68,7 +68,9 @@ export interface ButtonProps {
68
68
  | 'text'
69
69
  | 'inline-text'
70
70
  | 'filled-compact'
71
- | 'outlined-compact';
71
+ | 'outlined-compact'
72
+ | 'text-compact'
73
+ | 'inline-text-compact';
72
74
  }
73
75
 
74
76
  const isIconName = (icon: IconName | ReactNode): icon is IconName => {
@@ -102,7 +104,8 @@ export const getThemeVariant = (
102
104
  | 'outlined'
103
105
  | 'text'
104
106
  | 'filled-compact'
105
- | 'outlined-compact',
107
+ | 'outlined-compact'
108
+ | 'text-compact',
106
109
  intent: Intent
107
110
  ): ThemeVariant => {
108
111
  switch (variant) {
@@ -113,6 +116,7 @@ export const getThemeVariant = (
113
116
  case 'outlined-compact':
114
117
  return OUTLINED_VARIANTS[intent];
115
118
  case 'text':
119
+ case 'text-compact':
116
120
  return TEXT_VARIANTS[intent];
117
121
  }
118
122
  };
@@ -181,7 +185,9 @@ const Button = ({
181
185
  text,
182
186
  variant = 'filled',
183
187
  }: ButtonProps): JSX.Element => {
184
- const isInlineText = variant === 'inline-text';
188
+ const isInlineText =
189
+ variant === 'inline-text' || variant === 'inline-text-compact';
190
+
185
191
  const themeVariant = getThemeVariant(isInlineText ? 'text' : variant, intent);
186
192
  const theme = useTheme();
187
193
  const underlayColor = useMemo(() => {
@@ -194,9 +200,12 @@ const Button = ({
194
200
  deprecatedVariants.includes(themeVariant)
195
201
  );
196
202
 
197
- const isCompactVariant = ['filled-compact', 'outlined-compact'].includes(
198
- variant
199
- );
203
+ const isCompactVariant = [
204
+ 'filled-compact',
205
+ 'outlined-compact',
206
+ 'text-compact',
207
+ 'inline-text-compact',
208
+ ].includes(variant);
200
209
 
201
210
  const isRenderTextVariant = isTextVariant(themeVariant);
202
211
 
@@ -210,6 +219,7 @@ const Button = ({
210
219
  disabled={disabled}
211
220
  themeButtonVariant={themeVariant}
212
221
  themeIsPressed={isPressed}
222
+ themeIsCompact={isCompactVariant}
213
223
  >
214
224
  {text}
215
225
  </StyledButtonTitleOfVariantText>
@@ -114,6 +114,34 @@ const genOutlineContainerStyles = (
114
114
  };
115
115
  };
116
116
 
117
+ const getTextButtonPaddingVertical = (
118
+ theme: Theme,
119
+ themeInlineText: boolean,
120
+ themeIsCompact: boolean
121
+ ) => {
122
+ if (themeInlineText) {
123
+ return 0;
124
+ }
125
+ if (themeIsCompact) {
126
+ return theme.__hd__.button.space.compact.buttonPaddingVertical;
127
+ }
128
+ return theme.__hd__.button.space.default.textButtonPadding;
129
+ };
130
+
131
+ const getTextButtonPaddingHorizontal = (
132
+ theme: Theme,
133
+ themeInlineText: boolean,
134
+ themeIsCompact: boolean
135
+ ) => {
136
+ if (themeInlineText) {
137
+ return 0;
138
+ }
139
+ if (themeIsCompact) {
140
+ return theme.__hd__.button.space.compact.buttonPaddingHorizontal;
141
+ }
142
+ return theme.__hd__.button.space.default.textButtonPadding;
143
+ };
144
+
117
145
  const genTextStyles = (
118
146
  theme: Theme,
119
147
  intent: Intent,
@@ -225,10 +253,25 @@ const StyledButtonContainer = styled(TouchableHighlight)<{
225
253
  flexDirection: 'row',
226
254
  justifyContent: 'center',
227
255
  alignItems: 'center',
228
-
229
- padding: themeInlineText
230
- ? 0
231
- : theme.__hd__.button.space.default.textButtonPadding,
256
+ ...(themeIsCompact
257
+ ? {
258
+ alignSelf: 'flex-start',
259
+ paddingVertical: getTextButtonPaddingVertical(
260
+ theme,
261
+ themeInlineText,
262
+ themeIsCompact
263
+ ),
264
+ paddingHorizontal: getTextButtonPaddingHorizontal(
265
+ theme,
266
+ themeInlineText,
267
+ themeIsCompact
268
+ ),
269
+ }
270
+ : {
271
+ padding: themeInlineText
272
+ ? 0
273
+ : theme.__hd__.button.space.default.textButtonPadding,
274
+ }),
232
275
 
233
276
  borderWidth: 0,
234
277
  backgroundColor:
@@ -339,31 +382,37 @@ const StyledButtonTitleOfVariantText = styled(Typography.Body)<{
339
382
  | 'text-danger'
340
383
  | 'text-white';
341
384
  themeIsPressed?: boolean;
342
- }>(({ disabled, themeButtonVariant, themeIsPressed, theme }) => {
343
- const themeStyling = () => {
344
- switch (themeButtonVariant) {
345
- case 'text-primary':
346
- return genTextStyles(theme, 'primary', disabled, themeIsPressed);
347
- case 'text-secondary':
348
- return genTextStyles(theme, 'secondary', disabled, themeIsPressed);
349
- case 'text-danger':
350
- return genTextStyles(theme, 'danger', disabled, themeIsPressed);
351
- case 'text-white':
352
- return genWhiteTextStyles({
353
- variant: 'text-white',
354
- disabled,
355
- theme,
356
- });
357
- }
358
- };
359
- return {
360
- flexShrink: 1,
361
- lineHeight: theme.__hd__.button.lineHeights.titleOfTextVariant,
362
- textAlign: 'center',
363
- textAlignVertical: 'center',
364
- ...themeStyling(),
365
- };
366
- });
385
+ themeIsCompact: boolean;
386
+ }>(
387
+ ({ disabled, themeButtonVariant, themeIsPressed, theme, themeIsCompact }) => {
388
+ const themeStyling = () => {
389
+ switch (themeButtonVariant) {
390
+ case 'text-primary':
391
+ return genTextStyles(theme, 'primary', disabled, themeIsPressed);
392
+ case 'text-secondary':
393
+ return genTextStyles(theme, 'secondary', disabled, themeIsPressed);
394
+ case 'text-danger':
395
+ return genTextStyles(theme, 'danger', disabled, themeIsPressed);
396
+ case 'text-white':
397
+ return genWhiteTextStyles({
398
+ variant: 'text-white',
399
+ disabled,
400
+ theme,
401
+ });
402
+ }
403
+ };
404
+ return {
405
+ flexShrink: 1,
406
+ lineHeight:
407
+ theme.__hd__.button.lineHeights.titleOfTextVariant[
408
+ themeIsCompact ? 'compact' : 'default'
409
+ ],
410
+ textAlign: 'center',
411
+ textAlignVertical: 'center',
412
+ ...themeStyling(),
413
+ };
414
+ }
415
+ );
367
416
 
368
417
  const StyledButtonIconWrapper = styled(View)<{
369
418
  themePosition: 'left' | 'right';
@@ -108,42 +108,56 @@ describe('Button', () => {
108
108
  });
109
109
 
110
110
  it.each`
111
- variant | intent | loading | disabled
112
- ${'filled'} | ${'primary'} | ${false} | ${false}
113
- ${'filled'} | ${'primary'} | ${true} | ${false}
114
- ${'filled'} | ${'primary'} | ${false} | ${true}
115
- ${'filled'} | ${'white'} | ${false} | ${false}
116
- ${'filled'} | ${'white'} | ${true} | ${false}
117
- ${'filled'} | ${'white'} | ${false} | ${true}
118
- ${'outlined'} | ${'primary'} | ${false} | ${false}
119
- ${'outlined'} | ${'primary'} | ${true} | ${false}
120
- ${'outlined'} | ${'primary'} | ${false} | ${true}
121
- ${'outlined'} | ${'white'} | ${false} | ${false}
122
- ${'outlined'} | ${'white'} | ${true} | ${false}
123
- ${'outlined'} | ${'white'} | ${false} | ${true}
124
- ${'text'} | ${'primary'} | ${false} | ${false}
125
- ${'text'} | ${'primary'} | ${true} | ${false}
126
- ${'text'} | ${'primary'} | ${false} | ${true}
127
- ${'text'} | ${'secondary'} | ${false} | ${false}
128
- ${'text'} | ${'secondary'} | ${true} | ${false}
129
- ${'text'} | ${'secondary'} | ${false} | ${true}
130
- ${'text'} | ${'danger'} | ${false} | ${false}
131
- ${'text'} | ${'danger'} | ${true} | ${false}
132
- ${'text'} | ${'danger'} | ${false} | ${true}
133
- ${'text'} | ${'white'} | ${false} | ${false}
134
- ${'text'} | ${'white'} | ${true} | ${false}
135
- ${'text'} | ${'white'} | ${false} | ${true}
136
- ${'inline-text'} | ${'primary'} | ${false} | ${false}
137
- ${'inline-text'} | ${'secondary'} | ${true} | ${false}
138
- ${'inline-text'} | ${'danger'} | ${false} | ${false}
139
- ${'inline-text'} | ${'primary'} | ${true} | ${false}
140
- ${'inline-text'} | ${'primary'} | ${false} | ${true}
141
- ${'filled-compact'} | ${'primary'} | ${false} | ${false}
142
- ${'filled-compact'} | ${'primary'} | ${true} | ${false}
143
- ${'filled-compact'} | ${'primary'} | ${false} | ${true}
144
- ${'outlined-compact'} | ${'primary'} | ${false} | ${false}
145
- ${'outlined-compact'} | ${'primary'} | ${true} | ${false}
146
- ${'outlined-compact'} | ${'primary'} | ${false} | ${true}
111
+ variant | intent | loading | disabled
112
+ ${'filled'} | ${'primary'} | ${false} | ${false}
113
+ ${'filled'} | ${'primary'} | ${true} | ${false}
114
+ ${'filled'} | ${'primary'} | ${false} | ${true}
115
+ ${'filled'} | ${'white'} | ${false} | ${false}
116
+ ${'filled'} | ${'white'} | ${true} | ${false}
117
+ ${'filled'} | ${'white'} | ${false} | ${true}
118
+ ${'outlined'} | ${'primary'} | ${false} | ${false}
119
+ ${'outlined'} | ${'primary'} | ${true} | ${false}
120
+ ${'outlined'} | ${'primary'} | ${false} | ${true}
121
+ ${'outlined'} | ${'white'} | ${false} | ${false}
122
+ ${'outlined'} | ${'white'} | ${true} | ${false}
123
+ ${'outlined'} | ${'white'} | ${false} | ${true}
124
+ ${'text'} | ${'primary'} | ${false} | ${false}
125
+ ${'text'} | ${'primary'} | ${true} | ${false}
126
+ ${'text'} | ${'primary'} | ${false} | ${true}
127
+ ${'text'} | ${'secondary'} | ${false} | ${false}
128
+ ${'text'} | ${'secondary'} | ${true} | ${false}
129
+ ${'text'} | ${'secondary'} | ${false} | ${true}
130
+ ${'text'} | ${'danger'} | ${false} | ${false}
131
+ ${'text'} | ${'danger'} | ${true} | ${false}
132
+ ${'text'} | ${'danger'} | ${false} | ${true}
133
+ ${'text'} | ${'white'} | ${false} | ${false}
134
+ ${'text'} | ${'white'} | ${true} | ${false}
135
+ ${'text'} | ${'white'} | ${false} | ${true}
136
+ ${'inline-text'} | ${'primary'} | ${false} | ${false}
137
+ ${'inline-text'} | ${'secondary'} | ${true} | ${false}
138
+ ${'inline-text'} | ${'danger'} | ${false} | ${false}
139
+ ${'inline-text'} | ${'primary'} | ${true} | ${false}
140
+ ${'inline-text'} | ${'primary'} | ${false} | ${true}
141
+ ${'filled-compact'} | ${'primary'} | ${false} | ${false}
142
+ ${'filled-compact'} | ${'primary'} | ${true} | ${false}
143
+ ${'filled-compact'} | ${'primary'} | ${false} | ${true}
144
+ ${'outlined-compact'} | ${'primary'} | ${false} | ${false}
145
+ ${'outlined-compact'} | ${'primary'} | ${true} | ${false}
146
+ ${'outlined-compact'} | ${'primary'} | ${false} | ${true}
147
+ ${'text-compact'} | ${'primary'} | ${false} | ${false}
148
+ ${'text-compact'} | ${'primary'} | ${true} | ${false}
149
+ ${'text-compact'} | ${'primary'} | ${false} | ${true}
150
+ ${'text-compact'} | ${'secondary'} | ${false} | ${false}
151
+ ${'text-compact'} | ${'secondary'} | ${true} | ${false}
152
+ ${'text-compact'} | ${'secondary'} | ${false} | ${true}
153
+ ${'text-compact'} | ${'danger'} | ${false} | ${false}
154
+ ${'text-compact'} | ${'danger'} | ${true} | ${false}
155
+ ${'text-compact'} | ${'danger'} | ${false} | ${true}
156
+ ${'inline-text-compact'} | ${'primary'} | ${false} | ${false}
157
+ ${'inline-text-compact'} | ${'secondary'} | ${true} | ${false}
158
+ ${'inline-text-compact'} | ${'danger'} | ${false} | ${false}
159
+ ${'inline-text-compact'} | ${'primary'} | ${true} | ${false}
160
+ ${'inline-text-compact'} | ${'primary'} | ${false} | ${true}
147
161
  `('renders correctly', ({ variant, intent, loading, disabled }) => {
148
162
  const { toJSON } = renderWithTheme(
149
163
  <Button
@@ -177,6 +191,7 @@ describe('getThemeVariant', () => {
177
191
  ${'text'} | ${'secondary'} | ${'text-secondary'}
178
192
  ${'text'} | ${'danger'} | ${'text-danger'}
179
193
  ${'text'} | ${'white'} | ${'text-white'}
194
+ ${'text-compact'} | ${'danger'} | ${'text-danger'}
180
195
  `('returns $themeVariant', ({ variant, intent, themeVariant }) => {
181
196
  expect(getThemeVariant(variant, intent)).toBe(themeVariant);
182
197
  });