@hero-design/rn 8.120.2 → 8.122.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 (51) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/es/index.js +283 -33
  3. package/jest.config.js +1 -1
  4. package/lib/index.js +282 -31
  5. package/package.json +5 -1
  6. package/rollup.config.mjs +2 -0
  7. package/src/components/Avatar/Avatar.tsx +3 -3
  8. package/src/components/Avatar/StyledAvatar.tsx +7 -1
  9. package/src/components/Icon/AnimatedIcon.tsx +7 -40
  10. package/src/components/Icon/GradientIcon/index.tsx +71 -0
  11. package/src/components/Icon/SpinWrapper.tsx +39 -0
  12. package/src/components/Icon/index.tsx +22 -1
  13. package/src/components/Toolbar/StyledToolbar.tsx +2 -2
  14. package/src/components/Typography/Body/StyledBody.tsx +2 -2
  15. package/src/components/Typography/Body/index.tsx +20 -2
  16. package/src/components/Typography/Caption/StyledCaption.tsx +2 -2
  17. package/src/components/Typography/Caption/index.tsx +20 -2
  18. package/src/components/Typography/GradientText/index.tsx +85 -0
  19. package/src/components/Typography/Label/StyledLabel.tsx +2 -2
  20. package/src/components/Typography/Label/index.tsx +20 -2
  21. package/src/components/Typography/Title/StyledTitle.tsx +2 -2
  22. package/src/components/Typography/Title/index.tsx +32 -13
  23. package/src/components/Typography/types.ts +3 -1
  24. package/src/components/Typography/utils.ts +31 -0
  25. package/src/theme/components/avatar.ts +2 -0
  26. package/src/theme/global/colors/gradients.ts +78 -0
  27. package/src/theme/global/colors/types.ts +22 -0
  28. package/src/theme/global/index.ts +5 -2
  29. package/testUtils/setup.tsx +34 -0
  30. package/types/components/Avatar/Avatar.d.ts +2 -2
  31. package/types/components/Avatar/StyledAvatar.d.ts +1 -1
  32. package/types/components/Icon/GradientIcon/index.d.ts +12 -0
  33. package/types/components/Icon/SpinWrapper.d.ts +9 -0
  34. package/types/components/Icon/index.d.ts +1 -1
  35. package/types/components/TextInput/StyledTextInput.d.ts +1 -1
  36. package/types/components/Toolbar/StyledToolbar.d.ts +4 -4
  37. package/types/components/Typography/Body/StyledBody.d.ts +2 -2
  38. package/types/components/Typography/Body/index.d.ts +1 -1
  39. package/types/components/Typography/Caption/StyledCaption.d.ts +2 -2
  40. package/types/components/Typography/Caption/index.d.ts +1 -1
  41. package/types/components/Typography/GradientText/index.d.ts +7 -0
  42. package/types/components/Typography/Label/StyledLabel.d.ts +2 -2
  43. package/types/components/Typography/Label/index.d.ts +1 -1
  44. package/types/components/Typography/Title/StyledTitle.d.ts +2 -2
  45. package/types/components/Typography/Title/index.d.ts +1 -1
  46. package/types/components/Typography/types.d.ts +2 -1
  47. package/types/components/Typography/utils.d.ts +2 -0
  48. package/types/theme/components/avatar.d.ts +1 -0
  49. package/types/theme/global/colors/gradients.d.ts +3 -0
  50. package/types/theme/global/colors/types.d.ts +21 -0
  51. package/types/theme/global/index.d.ts +3 -2
package/lib/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  var reactNative = require('react-native');
4
4
  var React = require('react');
5
+ var MaskedView = require('@react-native-masked-view/masked-view');
6
+ var expoLinearGradient = require('expo-linear-gradient');
5
7
  var reactNativeVectorIcons = require('react-native-vector-icons');
6
8
  var reactNativeSafeAreaContext = require('react-native-safe-area-context');
7
9
  var reactNativeMonthYearPicker = require('@hero-design/react-native-month-year-picker');
@@ -37,6 +39,7 @@ function _interopNamespaceCompat(e) {
37
39
 
38
40
  var reactNative__namespace = /*#__PURE__*/_interopNamespaceCompat(reactNative);
39
41
  var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
42
+ var MaskedView__default = /*#__PURE__*/_interopDefaultCompat(MaskedView);
40
43
  var Svg__default = /*#__PURE__*/_interopDefaultCompat(Svg);
41
44
  var DateTimePicker__default = /*#__PURE__*/_interopDefaultCompat(DateTimePicker);
42
45
  var RnSlider__default = /*#__PURE__*/_interopDefaultCompat(RnSlider);
@@ -5455,6 +5458,76 @@ var getShadows = function getShadows(palette) {
5455
5458
  }
5456
5459
  };
5457
5460
 
5461
+ var DIAGONAL_ANGLE = 282;
5462
+ var HORIZONTAL_ANGLE = 90;
5463
+ var DIAGONAL_LOCATIONS = [0, 0.2931, 0.993];
5464
+ var HORIZONTAL_LOCATIONS = [0, 0.25, 0.75];
5465
+ // Convert CSS gradient angle (degrees) to expo-linear-gradient start/end points.
5466
+ // Follows CSS convention: 0° = bottom→top, 90° = left→right,
5467
+ // 180° = top→bottom, 270° = right→left.
5468
+ var angleToPoints = function angleToPoints(angleDeg) {
5469
+ var rad = (angleDeg - 90) * Math.PI / 180;
5470
+ var x = Math.cos(rad);
5471
+ var y = Math.sin(rad);
5472
+ // Normalize so both components are in [0, 1]
5473
+ var start = {
5474
+ x: Math.round((1 - x) / 2 * 100) / 100,
5475
+ y: Math.round((1 - y) / 2 * 100) / 100
5476
+ };
5477
+ var end = {
5478
+ x: Math.round((1 + x) / 2 * 100) / 100,
5479
+ y: Math.round((1 + y) / 2 * 100) / 100
5480
+ };
5481
+ return {
5482
+ start: start,
5483
+ end: end
5484
+ };
5485
+ };
5486
+ var getGradients = function getGradients(systemPalette) {
5487
+ var blueMedium = palette$9.blueMedium;
5488
+ var pinkMedium = palette$9.pinkMedium;
5489
+ var brandPrimary = systemPalette.primary;
5490
+ var backgroundFallback = systemPalette.defaultGlobalSurface;
5491
+ return {
5492
+ aiDiagonal: _objectSpread2(_objectSpread2({
5493
+ angle: DIAGONAL_ANGLE
5494
+ }, angleToPoints(DIAGONAL_ANGLE)), {}, {
5495
+ colors: [blueMedium, brandPrimary, pinkMedium],
5496
+ locations: DIAGONAL_LOCATIONS
5497
+ }),
5498
+ aiDiagonal8: _objectSpread2(_objectSpread2({
5499
+ angle: DIAGONAL_ANGLE
5500
+ }, angleToPoints(DIAGONAL_ANGLE)), {}, {
5501
+ colors: [blueMedium, brandPrimary, pinkMedium],
5502
+ locations: DIAGONAL_LOCATIONS,
5503
+ opacity: 0.08,
5504
+ backgroundFallback: backgroundFallback
5505
+ }),
5506
+ aiDiagonal16: _objectSpread2(_objectSpread2({
5507
+ angle: DIAGONAL_ANGLE
5508
+ }, angleToPoints(DIAGONAL_ANGLE)), {}, {
5509
+ colors: [blueMedium, brandPrimary, pinkMedium],
5510
+ locations: DIAGONAL_LOCATIONS,
5511
+ opacity: 0.16,
5512
+ backgroundFallback: backgroundFallback
5513
+ }),
5514
+ aiDiagonal24: _objectSpread2(_objectSpread2({
5515
+ angle: DIAGONAL_ANGLE
5516
+ }, angleToPoints(DIAGONAL_ANGLE)), {}, {
5517
+ colors: [blueMedium, brandPrimary, pinkMedium],
5518
+ locations: DIAGONAL_LOCATIONS,
5519
+ opacity: 0.24,
5520
+ backgroundFallback: backgroundFallback
5521
+ }),
5522
+ aiHorizontal: _objectSpread2(_objectSpread2({
5523
+ angle: HORIZONTAL_ANGLE
5524
+ }, angleToPoints(HORIZONTAL_ANGLE)), {}, {
5525
+ colors: [brandPrimary, pinkMedium, brandPrimary],
5526
+ locations: HORIZONTAL_LOCATIONS
5527
+ })
5528
+ };
5529
+ };
5530
+
5458
5531
  var getGlobalTheme = function getGlobalTheme(scale, systemPalette) {
5459
5532
  var fonts = getFonts(scale.font);
5460
5533
  var fontSizes = getFontSizes(scale.fontSize);
@@ -5464,8 +5537,11 @@ var getGlobalTheme = function getGlobalTheme(scale, systemPalette) {
5464
5537
  var sizes = getSizes(scale.size);
5465
5538
  var radii = getRadii(scale.radius);
5466
5539
  var shadows = getShadows(systemPalette);
5540
+ var gradients = getGradients(systemPalette);
5467
5541
  return {
5468
- colors: _objectSpread2({}, systemPalette),
5542
+ colors: _objectSpread2(_objectSpread2({}, systemPalette), {}, {
5543
+ gradients: gradients
5544
+ }),
5469
5545
  fonts: fonts,
5470
5546
  fontSizes: fontSizes,
5471
5547
  lineHeights: lineHeights,
@@ -5568,6 +5644,7 @@ var getAttachmentTheme = function getAttachmentTheme(theme) {
5568
5644
 
5569
5645
  var getAvatarTheme = function getAvatarTheme(theme) {
5570
5646
  var colors = {
5647
+ neutral: palette$8.maasstrichtBlueLight25,
5571
5648
  primary: theme.colors.primary,
5572
5649
  info: theme.colors.info,
5573
5650
  danger: theme.colors.error,
@@ -8095,7 +8172,7 @@ var StyledText$4 = index$c(reactNative.Text)(function (_ref) {
8095
8172
  });
8096
8173
  });
8097
8174
 
8098
- var _excluded$O = ["children", "fontSize", "fontWeight", "intent", "typeface", "allowFontScaling"];
8175
+ var _excluded$Q = ["children", "fontSize", "fontWeight", "intent", "typeface", "allowFontScaling"];
8099
8176
  /**
8100
8177
  * @deprecated Typography.Text is deprecated and will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.
8101
8178
  */
@@ -8111,7 +8188,7 @@ var Text = function Text(_ref) {
8111
8188
  typeface = _ref$typeface === void 0 ? 'neutral' : _ref$typeface,
8112
8189
  _ref$allowFontScaling = _ref.allowFontScaling,
8113
8190
  allowFontScaling = _ref$allowFontScaling === void 0 ? false : _ref$allowFontScaling,
8114
- nativeProps = _objectWithoutProperties(_ref, _excluded$O);
8191
+ nativeProps = _objectWithoutProperties(_ref, _excluded$Q);
8115
8192
  useDeprecation('Typography.Text is deprecated and will be removed in the next major release, please refer to https://design.employmenthero.com/mobile/Components/typography for the appropriate alternatives.');
8116
8193
  return /*#__PURE__*/React__namespace.default.createElement(StyledText$4, _extends$1({}, nativeProps, {
8117
8194
  themeFontSize: fontSize,
@@ -8144,7 +8221,79 @@ var StyledCaption = index$c(reactNative.Text)(function (_ref) {
8144
8221
  };
8145
8222
  });
8146
8223
 
8147
- var _excluded$N = ["children", "fontWeight", "intent", "allowFontScaling", "fontStyle"];
8224
+ var ACCESSIBILITY_KEYS = ['accessible', 'accessibilityActions', 'accessibilityLabel', 'accessibilityRole', 'accessibilityState', 'accessibilityHint', 'accessibilityValue', 'onAccessibilityAction',
8225
+ // Android
8226
+ 'accessibilityLabelledBy', 'accessibilityLiveRegion', 'importantForAccessibility',
8227
+ // iOS
8228
+ 'accessibilityElementsHidden', 'accessibilityLanguage', 'accessibilityIgnoresInvertColors', 'accessibilityViewIsModal', 'onAccessibilityEscape', 'onAccessibilityTap', 'onMagicTap', 'accessibilityIgnoresInvertColors'];
8229
+ var pickAccessibilityProps = function pickAccessibilityProps(props) {
8230
+ return ACCESSIBILITY_KEYS.filter(function (key) {
8231
+ return key in props;
8232
+ }).reduce(function (acc, key) {
8233
+ return Object.assign(acc, _defineProperty({}, key, props[key]));
8234
+ }, {});
8235
+ };
8236
+
8237
+ var _excluded$P = ["children"];
8238
+ var GradientText = function GradientText(_ref) {
8239
+ var children = _ref.children,
8240
+ accessibilityProps = _objectWithoutProperties(_ref, _excluded$P);
8241
+ var theme = useTheme();
8242
+ var gradient = theme.colors.gradients.aiDiagonal;
8243
+ var _useState = React.useState(null),
8244
+ _useState2 = _slicedToArray(_useState, 2),
8245
+ size = _useState2[0],
8246
+ setSize = _useState2[1];
8247
+ var onLayout = React.useCallback(function (event) {
8248
+ var _event$nativeEvent$la = event.nativeEvent.layout,
8249
+ width = _event$nativeEvent$la.width,
8250
+ height = _event$nativeEvent$la.height;
8251
+ setSize(function (prevSize) {
8252
+ if (prevSize && prevSize.width === width && prevSize.height === height) {
8253
+ return prevSize;
8254
+ }
8255
+ return {
8256
+ width: width,
8257
+ height: height
8258
+ };
8259
+ });
8260
+ }, []);
8261
+ return /*#__PURE__*/React__namespace.default.createElement(reactNative.View, accessibilityProps, /*#__PURE__*/React__namespace.default.createElement(MaskedView__default.default, {
8262
+ style: {
8263
+ alignSelf: 'stretch'
8264
+ },
8265
+ accessibilityElementsHidden: true,
8266
+ importantForAccessibility: "no-hide-descendants",
8267
+ maskElement: /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
8268
+ onLayout: onLayout,
8269
+ style: {
8270
+ backgroundColor: 'transparent'
8271
+ },
8272
+ testID: "gradient-text-mask"
8273
+ }, children)
8274
+ }, size ? /*#__PURE__*/React__namespace.default.createElement(expoLinearGradient.LinearGradient, {
8275
+ start: gradient.start,
8276
+ end: gradient.end,
8277
+ colors: gradient.colors,
8278
+ locations: gradient.locations,
8279
+ style: {
8280
+ width: size.width,
8281
+ height: size.height
8282
+ }
8283
+ }) :
8284
+ // Render children as fallback until layout is measured, so text
8285
+ // is visible immediately rather than blank on the first frame.
8286
+ children), /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
8287
+ style: {
8288
+ position: 'absolute',
8289
+ opacity: 0
8290
+ },
8291
+ importantForAccessibility: "yes",
8292
+ accessibilityElementsHidden: false
8293
+ }, children));
8294
+ };
8295
+
8296
+ var _excluded$O = ["children", "fontWeight", "intent", "allowFontScaling", "fontStyle", "style", "testID"];
8148
8297
  var Caption = function Caption(_ref) {
8149
8298
  var children = _ref.children,
8150
8299
  _ref$fontWeight = _ref.fontWeight,
@@ -8155,13 +8304,22 @@ var Caption = function Caption(_ref) {
8155
8304
  allowFontScaling = _ref$allowFontScaling === void 0 ? false : _ref$allowFontScaling,
8156
8305
  _ref$fontStyle = _ref.fontStyle,
8157
8306
  fontStyle = _ref$fontStyle === void 0 ? 'normal' : _ref$fontStyle,
8158
- nativeProps = _objectWithoutProperties(_ref, _excluded$N);
8159
- return /*#__PURE__*/React__namespace.default.createElement(StyledCaption, _extends$1({}, nativeProps, {
8307
+ style = _ref.style,
8308
+ testID = _ref.testID,
8309
+ nativeProps = _objectWithoutProperties(_ref, _excluded$O);
8310
+ var isAi = intent === 'ai';
8311
+ var styledText = /*#__PURE__*/React__namespace.default.createElement(StyledCaption, _extends$1({}, nativeProps, {
8160
8312
  themeFontWeight: fontWeight,
8161
- themeIntent: intent,
8313
+ themeIntent: isAi ? 'body' : intent,
8162
8314
  themeIsItalic: fontStyle === 'italic',
8163
- allowFontScaling: allowFontScaling
8315
+ allowFontScaling: allowFontScaling,
8316
+ style: style,
8317
+ testID: testID
8164
8318
  }), children);
8319
+ if (isAi) {
8320
+ return /*#__PURE__*/React__namespace.default.createElement(GradientText, pickAccessibilityProps(nativeProps), styledText);
8321
+ }
8322
+ return styledText;
8165
8323
  };
8166
8324
 
8167
8325
  var StyledLabel$1 = index$c(reactNative.Text)(function (_ref) {
@@ -8180,7 +8338,7 @@ var StyledLabel$1 = index$c(reactNative.Text)(function (_ref) {
8180
8338
  };
8181
8339
  });
8182
8340
 
8183
- var _excluded$M = ["children", "intent", "allowFontScaling", "fontStyle"];
8341
+ var _excluded$N = ["children", "intent", "allowFontScaling", "fontStyle", "style", "testID"];
8184
8342
  var Label = function Label(_ref) {
8185
8343
  var children = _ref.children,
8186
8344
  _ref$intent = _ref.intent,
@@ -8189,12 +8347,21 @@ var Label = function Label(_ref) {
8189
8347
  allowFontScaling = _ref$allowFontScaling === void 0 ? false : _ref$allowFontScaling,
8190
8348
  _ref$fontStyle = _ref.fontStyle,
8191
8349
  fontStyle = _ref$fontStyle === void 0 ? 'normal' : _ref$fontStyle,
8192
- nativeProps = _objectWithoutProperties(_ref, _excluded$M);
8193
- return /*#__PURE__*/React__namespace.default.createElement(StyledLabel$1, _extends$1({}, nativeProps, {
8194
- themeIntent: intent,
8350
+ style = _ref.style,
8351
+ testID = _ref.testID,
8352
+ nativeProps = _objectWithoutProperties(_ref, _excluded$N);
8353
+ var isAi = intent === 'ai';
8354
+ var styledText = /*#__PURE__*/React__namespace.default.createElement(StyledLabel$1, _extends$1({}, nativeProps, {
8355
+ themeIntent: isAi ? 'body' : intent,
8195
8356
  themeIsItalic: fontStyle === 'italic',
8196
- allowFontScaling: allowFontScaling
8357
+ allowFontScaling: allowFontScaling,
8358
+ style: style,
8359
+ testID: testID
8197
8360
  }), children);
8361
+ if (isAi) {
8362
+ return /*#__PURE__*/React__namespace.default.createElement(GradientText, pickAccessibilityProps(nativeProps), styledText);
8363
+ }
8364
+ return styledText;
8198
8365
  };
8199
8366
 
8200
8367
  var StyledTitle$1 = index$c(reactNative.Text)(function (_ref) {
@@ -8212,7 +8379,7 @@ var StyledTitle$1 = index$c(reactNative.Text)(function (_ref) {
8212
8379
  };
8213
8380
  });
8214
8381
 
8215
- var _excluded$L = ["children", "intent", "allowFontScaling", "level", "typeface", "fontStyle"];
8382
+ var _excluded$M = ["children", "intent", "allowFontScaling", "level", "typeface", "fontStyle", "style", "testID"];
8216
8383
  var Title = function Title(_ref) {
8217
8384
  var children = _ref.children,
8218
8385
  _ref$intent = _ref.intent,
@@ -8225,14 +8392,23 @@ var Title = function Title(_ref) {
8225
8392
  typeface = _ref$typeface === void 0 ? 'neutral' : _ref$typeface,
8226
8393
  _ref$fontStyle = _ref.fontStyle,
8227
8394
  fontStyle = _ref$fontStyle === void 0 ? 'normal' : _ref$fontStyle,
8228
- nativeProps = _objectWithoutProperties(_ref, _excluded$L);
8229
- return /*#__PURE__*/React__namespace.default.createElement(StyledTitle$1, _extends$1({}, nativeProps, {
8395
+ style = _ref.style,
8396
+ testID = _ref.testID,
8397
+ nativeProps = _objectWithoutProperties(_ref, _excluded$M);
8398
+ var isAi = intent === 'ai';
8399
+ var styledText = /*#__PURE__*/React__namespace.default.createElement(StyledTitle$1, _extends$1({}, nativeProps, {
8230
8400
  themeLevel: level,
8231
8401
  themeTypeface: typeface,
8232
- themeIntent: intent,
8402
+ themeIntent: isAi ? 'body' : intent,
8233
8403
  themeIsItalic: fontStyle === 'italic',
8234
- allowFontScaling: allowFontScaling
8404
+ allowFontScaling: allowFontScaling,
8405
+ style: style,
8406
+ testID: testID
8235
8407
  }), children);
8408
+ if (isAi) {
8409
+ return /*#__PURE__*/React__namespace.default.createElement(GradientText, pickAccessibilityProps(nativeProps), styledText);
8410
+ }
8411
+ return styledText;
8236
8412
  };
8237
8413
 
8238
8414
  var FONTWEIGHT_MAP = {
@@ -8264,7 +8440,7 @@ var StyledBody$2 = index$c(reactNative.Text)(function (_ref) {
8264
8440
  };
8265
8441
  });
8266
8442
 
8267
- var _excluded$K = ["children", "intent", "allowFontScaling", "typeface", "variant", "fontStyle"];
8443
+ var _excluded$L = ["children", "intent", "allowFontScaling", "typeface", "variant", "fontStyle", "style", "testID"];
8268
8444
  var Body = function Body(_ref) {
8269
8445
  var children = _ref.children,
8270
8446
  _ref$intent = _ref.intent,
@@ -8277,14 +8453,23 @@ var Body = function Body(_ref) {
8277
8453
  variant = _ref$variant === void 0 ? 'regular' : _ref$variant,
8278
8454
  _ref$fontStyle = _ref.fontStyle,
8279
8455
  fontStyle = _ref$fontStyle === void 0 ? 'normal' : _ref$fontStyle,
8280
- nativeProps = _objectWithoutProperties(_ref, _excluded$K);
8281
- return /*#__PURE__*/React__namespace.default.createElement(StyledBody$2, _extends$1({}, nativeProps, {
8456
+ style = _ref.style,
8457
+ testID = _ref.testID,
8458
+ nativeProps = _objectWithoutProperties(_ref, _excluded$L);
8459
+ var isAi = intent === 'ai';
8460
+ var styledText = /*#__PURE__*/React__namespace.default.createElement(StyledBody$2, _extends$1({}, nativeProps, {
8282
8461
  themeTypeface: typeface,
8283
- themeIntent: intent,
8462
+ themeIntent: isAi ? 'body' : intent,
8284
8463
  themeVariant: variant,
8285
8464
  themeIsItalic: fontStyle === 'italic',
8286
- allowFontScaling: allowFontScaling
8465
+ allowFontScaling: allowFontScaling,
8466
+ style: style,
8467
+ testID: testID
8287
8468
  }), children);
8469
+ if (isAi) {
8470
+ return /*#__PURE__*/React__namespace.default.createElement(GradientText, pickAccessibilityProps(nativeProps), styledText);
8471
+ }
8472
+ return styledText;
8288
8473
  };
8289
8474
 
8290
8475
  var Typography = {
@@ -8894,10 +9079,10 @@ var StyledHeroIcon = index$c(HeroIcon)(function (_ref) {
8894
9079
  };
8895
9080
  });
8896
9081
 
8897
- var _excluded$J = ["style"];
8898
- var AnimatedIcon = function AnimatedIcon(_ref) {
8899
- var style = _ref.style,
8900
- otherProps = _objectWithoutProperties(_ref, _excluded$J);
9082
+ var SpinWrapper = function SpinWrapper(_ref) {
9083
+ var children = _ref.children,
9084
+ style = _ref.style,
9085
+ testID = _ref.testID;
8901
9086
  var rotateAnimation = React.useRef(new reactNative.Animated.Value(0));
8902
9087
  React.useEffect(function () {
8903
9088
  var animation = reactNative.Animated.loop(reactNative.Animated.timing(rotateAnimation.current, {
@@ -8908,22 +9093,74 @@ var AnimatedIcon = function AnimatedIcon(_ref) {
8908
9093
  }));
8909
9094
  animation.start();
8910
9095
  return function () {
8911
- animation.stop();
9096
+ return animation.stop();
8912
9097
  };
8913
9098
  }, []);
8914
- var interpolatedRotateAnimation = rotateAnimation.current.interpolate({
9099
+ var rotate = rotateAnimation.current.interpolate({
8915
9100
  inputRange: [0, 1],
8916
9101
  outputRange: ['0deg', '360deg']
8917
9102
  });
8918
9103
  return /*#__PURE__*/React__namespace.default.createElement(reactNative.Animated.View, {
9104
+ testID: testID,
8919
9105
  style: [{
8920
9106
  transform: [{
8921
- rotate: interpolatedRotateAnimation
9107
+ rotate: rotate
8922
9108
  }]
8923
9109
  }, style]
9110
+ }, children);
9111
+ };
9112
+
9113
+ var _excluded$K = ["style"];
9114
+ var AnimatedIcon = function AnimatedIcon(_ref) {
9115
+ var style = _ref.style,
9116
+ otherProps = _objectWithoutProperties(_ref, _excluded$K);
9117
+ return /*#__PURE__*/React__namespace.default.createElement(SpinWrapper, {
9118
+ style: style
8924
9119
  }, /*#__PURE__*/React__namespace.default.createElement(StyledHeroIcon, otherProps));
8925
9120
  };
8926
9121
 
9122
+ var _excluded$J = ["name", "themeSize", "testID", "style"];
9123
+ var GradientIcon = function GradientIcon(_ref) {
9124
+ var name = _ref.name,
9125
+ themeSize = _ref.themeSize,
9126
+ testID = _ref.testID,
9127
+ style = _ref.style,
9128
+ accessibilityProps = _objectWithoutProperties(_ref, _excluded$J);
9129
+ var theme = useTheme();
9130
+ var gradient = theme.colors.gradients.aiDiagonal;
9131
+ var size = theme.__hd__.icon.sizes[themeSize];
9132
+ return /*#__PURE__*/React__namespace.default.createElement(MaskedView__default.default, _extends$1({
9133
+ testID: testID,
9134
+ style: [{
9135
+ width: size,
9136
+ height: size
9137
+ }, style]
9138
+ }, accessibilityProps, {
9139
+ maskElement: /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
9140
+ style: {
9141
+ backgroundColor: 'transparent',
9142
+ width: size,
9143
+ height: size,
9144
+ alignItems: 'center',
9145
+ justifyContent: 'center'
9146
+ }
9147
+ }, /*#__PURE__*/React__namespace.default.createElement(StyledHeroIcon, {
9148
+ name: name,
9149
+ themeIntent: "text",
9150
+ themeSize: themeSize
9151
+ }))
9152
+ }), /*#__PURE__*/React__namespace.default.createElement(expoLinearGradient.LinearGradient, {
9153
+ start: gradient.start,
9154
+ end: gradient.end,
9155
+ colors: gradient.colors,
9156
+ locations: gradient.locations,
9157
+ style: {
9158
+ width: size,
9159
+ height: size
9160
+ }
9161
+ }));
9162
+ };
9163
+
8927
9164
  var Icon = function Icon(_ref) {
8928
9165
  var icon = _ref.icon,
8929
9166
  style = _ref.style,
@@ -8959,6 +9196,20 @@ var Icon = function Icon(_ref) {
8959
9196
  accessibilityViewIsModal: accessibilityViewIsModal,
8960
9197
  accessibilityActions: accessibilityActions
8961
9198
  };
9199
+ if (intent === 'ai') {
9200
+ var gradientIcon = /*#__PURE__*/React__namespace.default.createElement(GradientIcon, _extends$1({
9201
+ name: icon,
9202
+ themeSize: size,
9203
+ testID: testID,
9204
+ style: spin ? undefined : style
9205
+ }, accessibilityProps));
9206
+ if (spin) {
9207
+ return /*#__PURE__*/React__namespace.default.createElement(SpinWrapper, {
9208
+ style: style
9209
+ }, gradientIcon);
9210
+ }
9211
+ return gradientIcon;
9212
+ }
8962
9213
  return spin ? /*#__PURE__*/React__namespace.default.createElement(AnimatedIcon, _extends$1({
8963
9214
  name: icon,
8964
9215
  themeIntent: intent,
@@ -9653,7 +9904,7 @@ var Avatar = function Avatar(_ref) {
9653
9904
  _ref$size = _ref.size,
9654
9905
  size = _ref$size === void 0 ? 'small' : _ref$size,
9655
9906
  _ref$intent = _ref.intent,
9656
- intent = _ref$intent === void 0 ? 'primary' : _ref$intent;
9907
+ intent = _ref$intent === void 0 ? 'neutral' : _ref$intent;
9657
9908
  var _useState = React.useState(false),
9658
9909
  _useState2 = _slicedToArray(_useState, 2),
9659
9910
  hasImageError = _useState2[0],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.120.2",
3
+ "version": "8.122.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -33,6 +33,8 @@
33
33
  "@ptomasroos/react-native-multi-slider": "^2.2.2",
34
34
  "@react-native-community/datetimepicker": "^8.4.4",
35
35
  "@react-native-community/slider": "^5.0.1",
36
+ "@react-native-masked-view/masked-view": "^0.3.2",
37
+ "expo-linear-gradient": ">=14.0.0",
36
38
  "react": "19.1.0",
37
39
  "react-native": "0.81.5",
38
40
  "react-native-gesture-handler": "~2.28.0",
@@ -61,6 +63,7 @@
61
63
  "@ptomasroos/react-native-multi-slider": "^2.2.2",
62
64
  "@react-native-community/datetimepicker": "8.4.4",
63
65
  "@react-native-community/slider": "^5.0.1",
66
+ "@react-native-masked-view/masked-view": "0.3.2",
64
67
  "@react-native/babel-preset": "0.81.5",
65
68
  "@rollup/plugin-babel": "^6.0.4",
66
69
  "@rollup/plugin-commonjs": "^28.0.1",
@@ -81,6 +84,7 @@
81
84
  "core-js": "^3.33.0",
82
85
  "eslint": "^8.56.0",
83
86
  "eslint-config-hd": "8.42.5",
87
+ "expo-linear-gradient": "55.0.9",
84
88
  "jest": "^29.2.1",
85
89
  "jest-environment-jsdom": "^29.2.1",
86
90
  "jest-junit": "^16.0.0",
package/rollup.config.mjs CHANGED
@@ -33,6 +33,8 @@ export default [
33
33
  },
34
34
  ],
35
35
  external: [
36
+ '@react-native-masked-view/masked-view',
37
+ 'expo-linear-gradient',
36
38
  'react',
37
39
  'react-native',
38
40
  'react-native-safe-area-context',
@@ -26,9 +26,9 @@ export interface AvatarProps extends ViewProps {
26
26
  */
27
27
  title?: string;
28
28
  /**
29
- * Intent of the Icon.
29
+ * Visual intent of the Avatar. Defaults to `'neutral'`.
30
30
  */
31
- intent?: 'primary' | 'info' | 'danger' | 'success' | 'warning';
31
+ intent?: 'neutral' | 'primary' | 'info' | 'danger' | 'success' | 'warning';
32
32
  /**
33
33
  * Size of the avatar.
34
34
  */
@@ -58,7 +58,7 @@ const Avatar = ({
58
58
  style,
59
59
  title,
60
60
  size = 'small',
61
- intent = 'primary',
61
+ intent = 'neutral',
62
62
  }: AvatarProps) => {
63
63
  const [hasImageError, setHasImageError] = useState(false);
64
64
 
@@ -12,7 +12,13 @@ type ThemeSize =
12
12
  | 'xxxlarge'
13
13
  | 'xxxxlarge'
14
14
  | 'xxxxxlarge';
15
- type ThemeIntent = 'primary' | 'info' | 'danger' | 'success' | 'warning';
15
+ type ThemeIntent =
16
+ | 'neutral'
17
+ | 'primary'
18
+ | 'info'
19
+ | 'danger'
20
+ | 'success'
21
+ | 'warning';
16
22
 
17
23
  const StyledWrapper = styled(TouchableOpacity)<{
18
24
  themeSize: ThemeSize;
@@ -1,47 +1,14 @@
1
- import React, { useEffect, useRef } from 'react';
2
- import { Animated, Easing } from 'react-native';
1
+ import React from 'react';
3
2
  import type { ComponentProps } from 'react';
4
3
  import StyledHeroIcon from './HeroIcon';
4
+ import SpinWrapper from './SpinWrapper';
5
5
 
6
6
  type AnimatedIconProps = ComponentProps<typeof StyledHeroIcon>;
7
7
 
8
- const AnimatedIcon = ({ style, ...otherProps }: AnimatedIconProps) => {
9
- const rotateAnimation = useRef<Animated.Value>(new Animated.Value(0));
10
-
11
- useEffect(() => {
12
- const animation = Animated.loop(
13
- Animated.timing(rotateAnimation.current, {
14
- toValue: 1,
15
- duration: 1000,
16
- easing: Easing.linear,
17
- useNativeDriver: true,
18
- })
19
- );
20
-
21
- animation.start();
22
-
23
- return () => {
24
- animation.stop();
25
- };
26
- }, []);
27
-
28
- const interpolatedRotateAnimation = rotateAnimation.current.interpolate({
29
- inputRange: [0, 1],
30
- outputRange: ['0deg', '360deg'],
31
- });
32
-
33
- return (
34
- <Animated.View
35
- style={[
36
- {
37
- transform: [{ rotate: interpolatedRotateAnimation }],
38
- },
39
- style,
40
- ]}
41
- >
42
- <StyledHeroIcon {...otherProps} />
43
- </Animated.View>
44
- );
45
- };
8
+ const AnimatedIcon = ({ style, ...otherProps }: AnimatedIconProps) => (
9
+ <SpinWrapper style={style}>
10
+ <StyledHeroIcon {...otherProps} />
11
+ </SpinWrapper>
12
+ );
46
13
 
47
14
  export default AnimatedIcon;
@@ -0,0 +1,71 @@
1
+ import MaskedView from '@react-native-masked-view/masked-view';
2
+ import { LinearGradient } from 'expo-linear-gradient';
3
+ import React from 'react';
4
+ import type { AccessibilityProps, StyleProp, ViewStyle } from 'react-native';
5
+ import { View } from 'react-native';
6
+
7
+ import { useTheme } from '../../../theme';
8
+ import StyledHeroIcon from '../HeroIcon';
9
+ import type { IconName } from '..';
10
+
11
+ type GradientIconSize =
12
+ | 'xxxsmall'
13
+ | 'xsmall'
14
+ | 'small'
15
+ | 'medium'
16
+ | 'large'
17
+ | 'xlarge';
18
+
19
+ interface GradientIconProps extends AccessibilityProps {
20
+ name: IconName;
21
+ themeSize: GradientIconSize;
22
+ testID?: string;
23
+ style?: StyleProp<ViewStyle>;
24
+ }
25
+
26
+ const GradientIcon = ({
27
+ name,
28
+ themeSize,
29
+ testID,
30
+ style,
31
+ ...accessibilityProps
32
+ }: GradientIconProps) => {
33
+ const theme = useTheme();
34
+ const gradient = theme.colors.gradients.aiDiagonal;
35
+ const size = theme.__hd__.icon.sizes[themeSize];
36
+
37
+ return (
38
+ <MaskedView
39
+ testID={testID}
40
+ style={[{ width: size, height: size }, style]}
41
+ {...accessibilityProps}
42
+ maskElement={
43
+ <View
44
+ style={{
45
+ backgroundColor: 'transparent',
46
+ width: size,
47
+ height: size,
48
+ alignItems: 'center',
49
+ justifyContent: 'center',
50
+ }}
51
+ >
52
+ <StyledHeroIcon
53
+ name={name}
54
+ themeIntent="text"
55
+ themeSize={themeSize}
56
+ />
57
+ </View>
58
+ }
59
+ >
60
+ <LinearGradient
61
+ start={gradient.start}
62
+ end={gradient.end}
63
+ colors={gradient.colors}
64
+ locations={gradient.locations}
65
+ style={{ width: size, height: size }}
66
+ />
67
+ </MaskedView>
68
+ );
69
+ };
70
+
71
+ export default GradientIcon;