@hero-design/rn 8.87.2 → 8.88.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 (31) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/CHANGELOG.md +12 -0
  3. package/es/index.js +109 -50
  4. package/lib/index.js +109 -50
  5. package/package.json +1 -1
  6. package/src/components/AppCue/StyledAppCue.tsx +27 -1
  7. package/src/components/AppCue/__tests__/StyledAppCue.tsx +4 -0
  8. package/src/components/AppCue/__tests__/__snapshots__/StyledAppCue.tsx.snap +194 -0
  9. package/src/components/AppCue/__tests__/__snapshots__/index.spec.tsx.snap +260 -0
  10. package/src/components/AppCue/__tests__/index.spec.tsx +4 -0
  11. package/src/components/AppCue/__tests__/utils.spec.ts +57 -4
  12. package/src/components/AppCue/index.tsx +7 -4
  13. package/src/components/AppCue/utils.ts +60 -9
  14. package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +18 -15
  15. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +6 -5
  16. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +6 -5
  17. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +12 -10
  18. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +12 -12
  19. package/src/components/Empty/index.tsx +1 -1
  20. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +8 -0
  21. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +42 -35
  22. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +36 -30
  23. package/src/components/TextInput/StyledTextInput.tsx +4 -0
  24. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +20 -0
  25. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +446 -432
  26. package/src/components/TextInput/index.tsx +13 -32
  27. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +12 -10
  28. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +12 -10
  29. package/stats/8.88.0/rn-stats.html +4844 -0
  30. package/types/components/AppCue/StyledAppCue.d.ts +1 -1
  31. package/types/components/AppCue/utils.d.ts +6 -3
@@ -1,4 +1,4 @@
1
- (node:3084) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
1
+ (node:3003) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
2
2
  (Use `node --trace-warnings ...` to show where the warning was created)
3
3
  
4
4
  src/index.ts → lib/index.js, es/index.js...
@@ -10,4 +10,4 @@
10
10
     ~~~~~~~~~~~~~~~~~~~
11
11
  
12
12
  (!) [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.or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.
13
- created lib/index.js, es/index.js in 52.1s
13
+ created lib/index.js, es/index.js in 52.4s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.88.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#3630](https://github.com/Thinkei/hero-design/pull/3630) [`b4ae9bf3fe00b4a7a27d2919eb7ef83a7d391e59`](https://github.com/Thinkei/hero-design/commit/b4ae9bf3fe00b4a7a27d2919eb7ef83a7d391e59) Thanks [@phucdph](https://github.com/phucdph)! - [AppCue] Support top-left, top-right, bottom-left, bottom-right placement
8
+
9
+ ### Patch Changes
10
+
11
+ - [#3633](https://github.com/Thinkei/hero-design/pull/3633) [`040aa3235d512304df0dc00c4aa3c26766f1fc1c`](https://github.com/Thinkei/hero-design/commit/040aa3235d512304df0dc00c4aa3c26766f1fc1c) Thanks [@luanlai2201](https://github.com/luanlai2201)! - [TextInput] Fix label when has value do not align with another TextInput
12
+
13
+ - [#3638](https://github.com/Thinkei/hero-design/pull/3638) [`4a5628d321f2c6b9dcb96c62b1ceed999a6ec7b7`](https://github.com/Thinkei/hero-design/commit/4a5628d321f2c6b9dcb96c62b1ceed999a6ec7b7) Thanks [@ttkien](https://github.com/ttkien)! - [Empty] Update descrption typeface and font size
14
+
3
15
  ## 8.87.2
4
16
 
5
17
  ### Patch Changes
package/es/index.js CHANGED
@@ -8358,7 +8358,7 @@ var StyledContainer$9 = index$a(View)(function (_ref2) {
8358
8358
  var StyledIconContainer$1 = index$a(Animated.View)(function (_ref3) {
8359
8359
  var theme = _ref3.theme,
8360
8360
  themePlacement = _ref3.themePlacement;
8361
- return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
8361
+ return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
8362
8362
  position: 'absolute',
8363
8363
  color: theme.__hd__.appCue.colors.background,
8364
8364
  display: 'flex',
@@ -8385,6 +8385,24 @@ var StyledIconContainer$1 = index$a(Animated.View)(function (_ref3) {
8385
8385
  rotate: '-90deg'
8386
8386
  }],
8387
8387
  height: '100%'
8388
+ }), themePlacement === 'top-left' && {
8389
+ bottom: -theme.__hd__.appCue.space.arrowOffset,
8390
+ right: theme.__hd__.appCue.space.arrowOffset
8391
+ }), themePlacement === 'top-right' && {
8392
+ bottom: -theme.__hd__.appCue.space.arrowOffset,
8393
+ left: theme.__hd__.appCue.space.arrowOffset
8394
+ }), themePlacement === 'bottom-left' && {
8395
+ top: -theme.__hd__.appCue.space.arrowOffset,
8396
+ right: theme.__hd__.appCue.space.arrowOffset,
8397
+ transform: [{
8398
+ rotate: '180deg'
8399
+ }]
8400
+ }), themePlacement === 'bottom-right' && {
8401
+ top: -theme.__hd__.appCue.space.arrowOffset,
8402
+ left: theme.__hd__.appCue.space.arrowOffset,
8403
+ transform: [{
8404
+ rotate: '180deg'
8405
+ }]
8388
8406
  });
8389
8407
  });
8390
8408
 
@@ -8411,42 +8429,79 @@ var calculatePosition = function calculatePosition(_ref) {
8411
8429
  var placement = _ref.placement,
8412
8430
  position = _ref.position,
8413
8431
  contentSize = _ref.contentSize,
8414
- offset = _ref.offset;
8432
+ offset = _ref.offset,
8433
+ windowWidth = _ref.windowWidth;
8415
8434
  switch (placement) {
8416
8435
  case 'top':
8417
8436
  {
8418
8437
  return {
8419
8438
  // The X coordinate is calculated by adding the half of the width of the target element to the X coordinate of the target element.
8420
- x: position.pageX + (position.width - contentSize.width) / 2,
8439
+ left: position.pageX + (position.width - contentSize.width) / 2,
8421
8440
  // The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element
8422
- y: position.pageY - contentSize.height - offset
8441
+ top: position.pageY - contentSize.height - offset
8423
8442
  };
8424
8443
  }
8425
8444
  case 'bottom':
8426
8445
  {
8427
8446
  return {
8428
8447
  // The X coordinate is calculated by adding the half of the width of the target element to the X coordinate of the target element.
8429
- x: position.pageX + (position.width - contentSize.width) / 2,
8448
+ left: position.pageX + (position.width - contentSize.width) / 2,
8430
8449
  // The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
8431
- y: position.pageY + position.height + offset
8450
+ top: position.pageY + position.height + offset
8432
8451
  };
8433
8452
  }
8434
8453
  case 'right':
8435
8454
  {
8436
8455
  return {
8437
8456
  // The X coordinate is calculated by adding the width of the target element and the offset to the X coordinate of the target element.
8438
- x: position.pageX + position.width + offset,
8457
+ left: position.pageX + position.width + offset,
8439
8458
  // The Y coordinate is calculated by adding half of the height of the target element to the Y coordinate of the target element.
8440
- y: position.pageY + (position.height - contentSize.height) / 2
8459
+ top: position.pageY + (position.height - contentSize.height) / 2
8441
8460
  };
8442
8461
  }
8443
8462
  case 'left':
8444
8463
  {
8445
8464
  return {
8446
8465
  // The X coordinate is calculated by subtracting the width of the content and the offset from the X coordinate of the target element.
8447
- x: position.pageX - contentSize.width - offset,
8466
+ left: position.pageX - contentSize.width - offset,
8448
8467
  // The Y coordinate is calculated by adding half of the height of the target element to the Y coordinate of the target element.
8449
- y: position.pageY + (position.height - contentSize.height) / 2
8468
+ top: position.pageY + (position.height - contentSize.height) / 2
8469
+ };
8470
+ }
8471
+ case 'top-left':
8472
+ {
8473
+ return {
8474
+ // The X coordinate is calculated by subtracting the width of the content from the X coordinate of the target element.
8475
+ right: windowWidth - position.pageX - position.width,
8476
+ // The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element
8477
+ top: position.pageY - contentSize.height - offset
8478
+ };
8479
+ }
8480
+ case 'top-right':
8481
+ {
8482
+ return {
8483
+ // The X coordinate is calculated by adding the width of the target element to the X coordinate of the target element.
8484
+ left: position.pageX,
8485
+ // The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element.
8486
+ top: position.pageY - contentSize.height - offset
8487
+ };
8488
+ }
8489
+ case 'bottom-left':
8490
+ {
8491
+ return {
8492
+ // The X coordinate is calculated by subtracting the width of the content from the X coordinate of the target element.
8493
+ right: windowWidth - position.pageX - position.width,
8494
+ // The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
8495
+ top: position.pageY + position.height + offset
8496
+ };
8497
+ }
8498
+ case 'bottom-right':
8499
+ {
8500
+ return {
8501
+ // The X coordinate is calculated by adding the width of the target element to the X coordinate of the target element.
8502
+ left: position.pageX,
8503
+ // The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
8504
+ top: position.pageY + position.height + offset
8450
8505
  };
8451
8506
  }
8452
8507
  }
@@ -8488,6 +8543,22 @@ var calulateContentMaxWidth = function calulateContentMaxWidth(_ref2) {
8488
8543
  {
8489
8544
  return position.pageX - offset;
8490
8545
  }
8546
+ case 'top-left':
8547
+ {
8548
+ return position.pageX + position.width;
8549
+ }
8550
+ case 'top-right':
8551
+ {
8552
+ return windowWidth - position.pageX;
8553
+ }
8554
+ case 'bottom-left':
8555
+ {
8556
+ return position.pageX + position.width;
8557
+ }
8558
+ case 'bottom-right':
8559
+ {
8560
+ return windowWidth - position.pageX;
8561
+ }
8491
8562
  }
8492
8563
  };
8493
8564
 
@@ -8554,14 +8625,15 @@ var AppCue = function AppCue(_ref) {
8554
8625
  height: event.nativeEvent.layout.height
8555
8626
  });
8556
8627
  };
8628
+ var _useWindowDimensions = useWindowDimensions(),
8629
+ windowWidth = _useWindowDimensions.width;
8557
8630
  var pos = calculatePosition({
8558
8631
  position: position,
8559
8632
  contentSize: contentSize,
8560
8633
  placement: placement,
8561
- offset: offset
8634
+ offset: offset,
8635
+ windowWidth: windowWidth
8562
8636
  });
8563
- var _useWindowDimensions = useWindowDimensions(),
8564
- windowWidth = _useWindowDimensions.width;
8565
8637
  var maxWidth = calulateContentMaxWidth({
8566
8638
  position: position,
8567
8639
  offset: offset,
@@ -8601,8 +8673,10 @@ var AppCue = function AppCue(_ref) {
8601
8673
  }, /*#__PURE__*/React__default.createElement(StyledContainer$9, null, /*#__PURE__*/React__default.createElement(View, {
8602
8674
  style: StyleSheet$1.flatten([{
8603
8675
  position: 'absolute',
8604
- top: pos.y,
8605
- left: pos.x
8676
+ top: pos.top,
8677
+ left: pos.left,
8678
+ bottom: pos.bottom,
8679
+ right: pos.right
8606
8680
  }, style]),
8607
8681
  onLayout: measureContent,
8608
8682
  testID: testID
@@ -13970,7 +14044,11 @@ var StyledLabelInsideTextInput = index$a(Typography.Body)(function (_ref3) {
13970
14044
  alignContent: 'center',
13971
14045
  alignItems: 'center',
13972
14046
  color: theme.__hd__.textInput.colors.labelsInsideTextInput[themeState],
13973
- marginTop: theme.__hd__.textInput.space.labelInsideTextInputMarginTop
14047
+ marginTop: theme.__hd__.textInput.space.labelInsideTextInputMarginTop,
14048
+ position: 'absolute',
14049
+ zIndex: 1,
14050
+ left: 0,
14051
+ top: '50%'
13974
14052
  };
13975
14053
  });
13976
14054
  var StyledAsteriskLabelInsideTextInput = index$a(Typography.Body)(function (_ref4) {
@@ -14191,18 +14269,10 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref8, ref) {
14191
14269
  _React$useState2 = _slicedToArray(_React$useState, 2),
14192
14270
  inputSize = _React$useState2[0],
14193
14271
  setInputSize = _React$useState2[1];
14194
- var _React$useState3 = React__default.useState(0),
14272
+ var _React$useState3 = React__default.useState(false),
14195
14273
  _React$useState4 = _slicedToArray(_React$useState3, 2),
14196
- labelWidth = _React$useState4[0],
14197
- setLabelWidth = _React$useState4[1];
14198
- var _React$useState5 = React__default.useState(0),
14199
- _React$useState6 = _slicedToArray(_React$useState5, 2),
14200
- prefixWidth = _React$useState6[0],
14201
- setPrefixWidth = _React$useState6[1];
14202
- var _React$useState7 = React__default.useState(false),
14203
- _React$useState8 = _slicedToArray(_React$useState7, 2),
14204
- isFocused = _React$useState8[0],
14205
- setIsFocused = _React$useState8[1];
14274
+ isFocused = _React$useState4[0],
14275
+ setIsFocused = _React$useState4[1];
14206
14276
  var state = getState$3({
14207
14277
  disabled: disabled,
14208
14278
  error: error,
@@ -14232,14 +14302,6 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref8, ref) {
14232
14302
  });
14233
14303
  });
14234
14304
  }, []);
14235
- var onPrefixLayout = useCallback(function (event) {
14236
- var width = event.nativeEvent.layout.width;
14237
- setPrefixWidth(width);
14238
- }, []);
14239
- var onLabelLayout = useCallback(function (event) {
14240
- var width = event.nativeEvent.layout.width;
14241
- setLabelWidth(width);
14242
- }, []);
14243
14305
  var innerTextInput = React__default.useRef();
14244
14306
  React__default.useImperativeHandle(ref, function () {
14245
14307
  return {
@@ -14346,9 +14408,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref8, ref) {
14346
14408
  style: [{
14347
14409
  backgroundColor: backgroundColor
14348
14410
  }, borderStyle]
14349
- }), /*#__PURE__*/React__default.createElement(View, {
14350
- onLayout: onPrefixLayout
14351
- }, renderPrefix$1({
14411
+ }), /*#__PURE__*/React__default.createElement(View, null, renderPrefix$1({
14352
14412
  state: state,
14353
14413
  prefix: prefix
14354
14414
  })), /*#__PURE__*/React__default.createElement(StyledLabelContainerInsideTextInput, {
@@ -14360,12 +14420,12 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref8, ref) {
14360
14420
  transform: [{
14361
14421
  translateY: focusAnimation.interpolate({
14362
14422
  inputRange: [0, 1],
14363
- outputRange: [variant !== 'textarea' ? inputSize.height / 2 : theme.space.large, 0]
14423
+ outputRange: [variant !== 'textarea' ? inputSize.height / 2 : theme.space.large, theme.space.xsmall]
14364
14424
  })
14365
14425
  }, {
14366
14426
  translateX: focusAnimation.interpolate({
14367
14427
  inputRange: [0, 1],
14368
- outputRange: [-inputSize.width / 2 + labelWidth / 2 + prefixWidth + theme.space.large, -inputSize.width / 2 + labelWidth / 2 + theme.space.small]
14428
+ outputRange: [prefix ? theme.space.xxlarge : theme.space.medium, -theme.space.xlarge + theme.space.xsmall]
14369
14429
  })
14370
14430
  }, {
14371
14431
  scale: focusAnimation.interpolate({
@@ -14374,21 +14434,20 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref8, ref) {
14374
14434
  })
14375
14435
  }]
14376
14436
  }]
14377
- }, required && /*#__PURE__*/React__default.createElement(StyledAsteriskLabelInsideTextInput, {
14437
+ }, !!label && /*#__PURE__*/React__default.createElement(StyledLabelInsideTextInput, {
14378
14438
  style: {
14379
14439
  backgroundColor: backgroundColor
14380
14440
  },
14381
- themeState: state,
14382
- testID: "input-label-asterisk"
14383
- }, "*"), !!label && /*#__PURE__*/React__default.createElement(StyledLabelInsideTextInput, {
14441
+ nativeID: accessibilityLabelledBy,
14442
+ testID: "input-label",
14443
+ themeState: state
14444
+ }, required && /*#__PURE__*/React__default.createElement(StyledAsteriskLabelInsideTextInput, {
14384
14445
  style: {
14385
14446
  backgroundColor: backgroundColor
14386
14447
  },
14387
- nativeID: accessibilityLabelledBy,
14388
- testID: "input-label",
14389
14448
  themeState: state,
14390
- onLayout: onLabelLayout
14391
- }, label)), /*#__PURE__*/React__default.createElement(StyledTextInputAndLabelContainer, null, renderInput$1({
14449
+ testID: "input-label-asterisk"
14450
+ }, "*"), label)), /*#__PURE__*/React__default.createElement(StyledTextInputAndLabelContainer, null, renderInput$1({
14392
14451
  variant: variant,
14393
14452
  nativeInputProps: nativeInputProps,
14394
14453
  renderInputValue: renderInputValue,
@@ -15111,8 +15170,8 @@ var Empty = function Empty(_ref) {
15111
15170
  level: "h4",
15112
15171
  typeface: "playful"
15113
15172
  }, title), !!description && /*#__PURE__*/React__default.createElement(StyledDescription, {
15114
- themeVariant: variant,
15115
- typeface: "playful"
15173
+ variant: "small",
15174
+ themeVariant: variant
15116
15175
  }, description));
15117
15176
  };
15118
15177
 
package/lib/index.js CHANGED
@@ -8386,7 +8386,7 @@ var StyledContainer$9 = index$a(reactNative.View)(function (_ref2) {
8386
8386
  var StyledIconContainer$1 = index$a(reactNative.Animated.View)(function (_ref3) {
8387
8387
  var theme = _ref3.theme,
8388
8388
  themePlacement = _ref3.themePlacement;
8389
- return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
8389
+ return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
8390
8390
  position: 'absolute',
8391
8391
  color: theme.__hd__.appCue.colors.background,
8392
8392
  display: 'flex',
@@ -8413,6 +8413,24 @@ var StyledIconContainer$1 = index$a(reactNative.Animated.View)(function (_ref3)
8413
8413
  rotate: '-90deg'
8414
8414
  }],
8415
8415
  height: '100%'
8416
+ }), themePlacement === 'top-left' && {
8417
+ bottom: -theme.__hd__.appCue.space.arrowOffset,
8418
+ right: theme.__hd__.appCue.space.arrowOffset
8419
+ }), themePlacement === 'top-right' && {
8420
+ bottom: -theme.__hd__.appCue.space.arrowOffset,
8421
+ left: theme.__hd__.appCue.space.arrowOffset
8422
+ }), themePlacement === 'bottom-left' && {
8423
+ top: -theme.__hd__.appCue.space.arrowOffset,
8424
+ right: theme.__hd__.appCue.space.arrowOffset,
8425
+ transform: [{
8426
+ rotate: '180deg'
8427
+ }]
8428
+ }), themePlacement === 'bottom-right' && {
8429
+ top: -theme.__hd__.appCue.space.arrowOffset,
8430
+ left: theme.__hd__.appCue.space.arrowOffset,
8431
+ transform: [{
8432
+ rotate: '180deg'
8433
+ }]
8416
8434
  });
8417
8435
  });
8418
8436
 
@@ -8439,42 +8457,79 @@ var calculatePosition = function calculatePosition(_ref) {
8439
8457
  var placement = _ref.placement,
8440
8458
  position = _ref.position,
8441
8459
  contentSize = _ref.contentSize,
8442
- offset = _ref.offset;
8460
+ offset = _ref.offset,
8461
+ windowWidth = _ref.windowWidth;
8443
8462
  switch (placement) {
8444
8463
  case 'top':
8445
8464
  {
8446
8465
  return {
8447
8466
  // The X coordinate is calculated by adding the half of the width of the target element to the X coordinate of the target element.
8448
- x: position.pageX + (position.width - contentSize.width) / 2,
8467
+ left: position.pageX + (position.width - contentSize.width) / 2,
8449
8468
  // The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element
8450
- y: position.pageY - contentSize.height - offset
8469
+ top: position.pageY - contentSize.height - offset
8451
8470
  };
8452
8471
  }
8453
8472
  case 'bottom':
8454
8473
  {
8455
8474
  return {
8456
8475
  // The X coordinate is calculated by adding the half of the width of the target element to the X coordinate of the target element.
8457
- x: position.pageX + (position.width - contentSize.width) / 2,
8476
+ left: position.pageX + (position.width - contentSize.width) / 2,
8458
8477
  // The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
8459
- y: position.pageY + position.height + offset
8478
+ top: position.pageY + position.height + offset
8460
8479
  };
8461
8480
  }
8462
8481
  case 'right':
8463
8482
  {
8464
8483
  return {
8465
8484
  // The X coordinate is calculated by adding the width of the target element and the offset to the X coordinate of the target element.
8466
- x: position.pageX + position.width + offset,
8485
+ left: position.pageX + position.width + offset,
8467
8486
  // The Y coordinate is calculated by adding half of the height of the target element to the Y coordinate of the target element.
8468
- y: position.pageY + (position.height - contentSize.height) / 2
8487
+ top: position.pageY + (position.height - contentSize.height) / 2
8469
8488
  };
8470
8489
  }
8471
8490
  case 'left':
8472
8491
  {
8473
8492
  return {
8474
8493
  // The X coordinate is calculated by subtracting the width of the content and the offset from the X coordinate of the target element.
8475
- x: position.pageX - contentSize.width - offset,
8494
+ left: position.pageX - contentSize.width - offset,
8476
8495
  // The Y coordinate is calculated by adding half of the height of the target element to the Y coordinate of the target element.
8477
- y: position.pageY + (position.height - contentSize.height) / 2
8496
+ top: position.pageY + (position.height - contentSize.height) / 2
8497
+ };
8498
+ }
8499
+ case 'top-left':
8500
+ {
8501
+ return {
8502
+ // The X coordinate is calculated by subtracting the width of the content from the X coordinate of the target element.
8503
+ right: windowWidth - position.pageX - position.width,
8504
+ // The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element
8505
+ top: position.pageY - contentSize.height - offset
8506
+ };
8507
+ }
8508
+ case 'top-right':
8509
+ {
8510
+ return {
8511
+ // The X coordinate is calculated by adding the width of the target element to the X coordinate of the target element.
8512
+ left: position.pageX,
8513
+ // The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element.
8514
+ top: position.pageY - contentSize.height - offset
8515
+ };
8516
+ }
8517
+ case 'bottom-left':
8518
+ {
8519
+ return {
8520
+ // The X coordinate is calculated by subtracting the width of the content from the X coordinate of the target element.
8521
+ right: windowWidth - position.pageX - position.width,
8522
+ // The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
8523
+ top: position.pageY + position.height + offset
8524
+ };
8525
+ }
8526
+ case 'bottom-right':
8527
+ {
8528
+ return {
8529
+ // The X coordinate is calculated by adding the width of the target element to the X coordinate of the target element.
8530
+ left: position.pageX,
8531
+ // The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
8532
+ top: position.pageY + position.height + offset
8478
8533
  };
8479
8534
  }
8480
8535
  }
@@ -8516,6 +8571,22 @@ var calulateContentMaxWidth = function calulateContentMaxWidth(_ref2) {
8516
8571
  {
8517
8572
  return position.pageX - offset;
8518
8573
  }
8574
+ case 'top-left':
8575
+ {
8576
+ return position.pageX + position.width;
8577
+ }
8578
+ case 'top-right':
8579
+ {
8580
+ return windowWidth - position.pageX;
8581
+ }
8582
+ case 'bottom-left':
8583
+ {
8584
+ return position.pageX + position.width;
8585
+ }
8586
+ case 'bottom-right':
8587
+ {
8588
+ return windowWidth - position.pageX;
8589
+ }
8519
8590
  }
8520
8591
  };
8521
8592
 
@@ -8582,14 +8653,15 @@ var AppCue = function AppCue(_ref) {
8582
8653
  height: event.nativeEvent.layout.height
8583
8654
  });
8584
8655
  };
8656
+ var _useWindowDimensions = reactNative.useWindowDimensions(),
8657
+ windowWidth = _useWindowDimensions.width;
8585
8658
  var pos = calculatePosition({
8586
8659
  position: position,
8587
8660
  contentSize: contentSize,
8588
8661
  placement: placement,
8589
- offset: offset
8662
+ offset: offset,
8663
+ windowWidth: windowWidth
8590
8664
  });
8591
- var _useWindowDimensions = reactNative.useWindowDimensions(),
8592
- windowWidth = _useWindowDimensions.width;
8593
8665
  var maxWidth = calulateContentMaxWidth({
8594
8666
  position: position,
8595
8667
  offset: offset,
@@ -8629,8 +8701,10 @@ var AppCue = function AppCue(_ref) {
8629
8701
  }, /*#__PURE__*/React__namespace.default.createElement(StyledContainer$9, null, /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
8630
8702
  style: reactNative.StyleSheet.flatten([{
8631
8703
  position: 'absolute',
8632
- top: pos.y,
8633
- left: pos.x
8704
+ top: pos.top,
8705
+ left: pos.left,
8706
+ bottom: pos.bottom,
8707
+ right: pos.right
8634
8708
  }, style]),
8635
8709
  onLayout: measureContent,
8636
8710
  testID: testID
@@ -13998,7 +14072,11 @@ var StyledLabelInsideTextInput = index$a(Typography.Body)(function (_ref3) {
13998
14072
  alignContent: 'center',
13999
14073
  alignItems: 'center',
14000
14074
  color: theme.__hd__.textInput.colors.labelsInsideTextInput[themeState],
14001
- marginTop: theme.__hd__.textInput.space.labelInsideTextInputMarginTop
14075
+ marginTop: theme.__hd__.textInput.space.labelInsideTextInputMarginTop,
14076
+ position: 'absolute',
14077
+ zIndex: 1,
14078
+ left: 0,
14079
+ top: '50%'
14002
14080
  };
14003
14081
  });
14004
14082
  var StyledAsteriskLabelInsideTextInput = index$a(Typography.Body)(function (_ref4) {
@@ -14219,18 +14297,10 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
14219
14297
  _React$useState2 = _slicedToArray(_React$useState, 2),
14220
14298
  inputSize = _React$useState2[0],
14221
14299
  setInputSize = _React$useState2[1];
14222
- var _React$useState3 = React__namespace.default.useState(0),
14300
+ var _React$useState3 = React__namespace.default.useState(false),
14223
14301
  _React$useState4 = _slicedToArray(_React$useState3, 2),
14224
- labelWidth = _React$useState4[0],
14225
- setLabelWidth = _React$useState4[1];
14226
- var _React$useState5 = React__namespace.default.useState(0),
14227
- _React$useState6 = _slicedToArray(_React$useState5, 2),
14228
- prefixWidth = _React$useState6[0],
14229
- setPrefixWidth = _React$useState6[1];
14230
- var _React$useState7 = React__namespace.default.useState(false),
14231
- _React$useState8 = _slicedToArray(_React$useState7, 2),
14232
- isFocused = _React$useState8[0],
14233
- setIsFocused = _React$useState8[1];
14302
+ isFocused = _React$useState4[0],
14303
+ setIsFocused = _React$useState4[1];
14234
14304
  var state = getState$3({
14235
14305
  disabled: disabled,
14236
14306
  error: error,
@@ -14260,14 +14330,6 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
14260
14330
  });
14261
14331
  });
14262
14332
  }, []);
14263
- var onPrefixLayout = React.useCallback(function (event) {
14264
- var width = event.nativeEvent.layout.width;
14265
- setPrefixWidth(width);
14266
- }, []);
14267
- var onLabelLayout = React.useCallback(function (event) {
14268
- var width = event.nativeEvent.layout.width;
14269
- setLabelWidth(width);
14270
- }, []);
14271
14333
  var innerTextInput = React__namespace.default.useRef();
14272
14334
  React__namespace.default.useImperativeHandle(ref, function () {
14273
14335
  return {
@@ -14374,9 +14436,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
14374
14436
  style: [{
14375
14437
  backgroundColor: backgroundColor
14376
14438
  }, borderStyle]
14377
- }), /*#__PURE__*/React__namespace.default.createElement(reactNative.View, {
14378
- onLayout: onPrefixLayout
14379
- }, renderPrefix$1({
14439
+ }), /*#__PURE__*/React__namespace.default.createElement(reactNative.View, null, renderPrefix$1({
14380
14440
  state: state,
14381
14441
  prefix: prefix
14382
14442
  })), /*#__PURE__*/React__namespace.default.createElement(StyledLabelContainerInsideTextInput, {
@@ -14388,12 +14448,12 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
14388
14448
  transform: [{
14389
14449
  translateY: focusAnimation.interpolate({
14390
14450
  inputRange: [0, 1],
14391
- outputRange: [variant !== 'textarea' ? inputSize.height / 2 : theme.space.large, 0]
14451
+ outputRange: [variant !== 'textarea' ? inputSize.height / 2 : theme.space.large, theme.space.xsmall]
14392
14452
  })
14393
14453
  }, {
14394
14454
  translateX: focusAnimation.interpolate({
14395
14455
  inputRange: [0, 1],
14396
- outputRange: [-inputSize.width / 2 + labelWidth / 2 + prefixWidth + theme.space.large, -inputSize.width / 2 + labelWidth / 2 + theme.space.small]
14456
+ outputRange: [prefix ? theme.space.xxlarge : theme.space.medium, -theme.space.xlarge + theme.space.xsmall]
14397
14457
  })
14398
14458
  }, {
14399
14459
  scale: focusAnimation.interpolate({
@@ -14402,21 +14462,20 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
14402
14462
  })
14403
14463
  }]
14404
14464
  }]
14405
- }, required && /*#__PURE__*/React__namespace.default.createElement(StyledAsteriskLabelInsideTextInput, {
14465
+ }, !!label && /*#__PURE__*/React__namespace.default.createElement(StyledLabelInsideTextInput, {
14406
14466
  style: {
14407
14467
  backgroundColor: backgroundColor
14408
14468
  },
14409
- themeState: state,
14410
- testID: "input-label-asterisk"
14411
- }, "*"), !!label && /*#__PURE__*/React__namespace.default.createElement(StyledLabelInsideTextInput, {
14469
+ nativeID: accessibilityLabelledBy,
14470
+ testID: "input-label",
14471
+ themeState: state
14472
+ }, required && /*#__PURE__*/React__namespace.default.createElement(StyledAsteriskLabelInsideTextInput, {
14412
14473
  style: {
14413
14474
  backgroundColor: backgroundColor
14414
14475
  },
14415
- nativeID: accessibilityLabelledBy,
14416
- testID: "input-label",
14417
14476
  themeState: state,
14418
- onLayout: onLabelLayout
14419
- }, label)), /*#__PURE__*/React__namespace.default.createElement(StyledTextInputAndLabelContainer, null, renderInput$1({
14477
+ testID: "input-label-asterisk"
14478
+ }, "*"), label)), /*#__PURE__*/React__namespace.default.createElement(StyledTextInputAndLabelContainer, null, renderInput$1({
14420
14479
  variant: variant,
14421
14480
  nativeInputProps: nativeInputProps,
14422
14481
  renderInputValue: renderInputValue,
@@ -15139,8 +15198,8 @@ var Empty = function Empty(_ref) {
15139
15198
  level: "h4",
15140
15199
  typeface: "playful"
15141
15200
  }, title), !!description && /*#__PURE__*/React__namespace.default.createElement(StyledDescription, {
15142
- themeVariant: variant,
15143
- typeface: "playful"
15201
+ variant: "small",
15202
+ themeVariant: variant
15144
15203
  }, description));
15145
15204
  };
15146
15205
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.87.2",
3
+ "version": "8.88.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,7 +1,15 @@
1
1
  import styled from '@emotion/native';
2
2
  import { View, Animated } from 'react-native';
3
3
 
4
- export type Placement = 'top' | 'bottom' | 'right' | 'left';
4
+ export type Placement =
5
+ | 'top'
6
+ | 'bottom'
7
+ | 'right'
8
+ | 'left'
9
+ | 'top-left'
10
+ | 'top-right'
11
+ | 'bottom-left'
12
+ | 'bottom-right';
5
13
 
6
14
  export const StyledContent = styled(View)(({ theme }) => ({
7
15
  padding: theme.__hd__.appCue.space.padding,
@@ -43,4 +51,22 @@ export const StyledIconContainer = styled(Animated.View)<{
43
51
  transform: [{ rotate: '-90deg' }],
44
52
  height: '100%',
45
53
  }),
54
+ ...(themePlacement === 'top-left' && {
55
+ bottom: -theme.__hd__.appCue.space.arrowOffset,
56
+ right: theme.__hd__.appCue.space.arrowOffset,
57
+ }),
58
+ ...(themePlacement === 'top-right' && {
59
+ bottom: -theme.__hd__.appCue.space.arrowOffset,
60
+ left: theme.__hd__.appCue.space.arrowOffset,
61
+ }),
62
+ ...(themePlacement === 'bottom-left' && {
63
+ top: -theme.__hd__.appCue.space.arrowOffset,
64
+ right: theme.__hd__.appCue.space.arrowOffset,
65
+ transform: [{ rotate: '180deg' }],
66
+ }),
67
+ ...(themePlacement === 'bottom-right' && {
68
+ top: -theme.__hd__.appCue.space.arrowOffset,
69
+ left: theme.__hd__.appCue.space.arrowOffset,
70
+ transform: [{ rotate: '180deg' }],
71
+ }),
46
72
  }));
@@ -9,6 +9,10 @@ describe('AppCue', () => {
9
9
  ${'bottom'}
10
10
  ${'left'}
11
11
  ${'right'}
12
+ ${'top-left'}
13
+ ${'top-right'}
14
+ ${'bottom-left'}
15
+ ${'bottom-right'}
12
16
  `('renders icon $placement correctly', ({ placement }) => {
13
17
  const { toJSON } = renderWithTheme(
14
18
  <StyledIconContainer themePlacement={placement} />