@hero-design/rn 8.108.1 → 8.108.2

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.
@@ -1,4 +1,4 @@
1
- (node:3310) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
1
+ (node:3373) 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...
@@ -15,9 +15,9 @@ node_modules/d3-selection/src/selection/index.js -> node_modules/d3-selection/sr
15
15
     ~~~~~~~~~~~~~~~~~~~
16
16
  
17
17
  (!) [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.
18
- created lib/index.js, es/index.js in 1m 13.9s
18
+ created lib/index.js, es/index.js in 1m 12.7s
19
19
  
20
20
  /home/runner/work/hero-design/hero-design/packages/rn/src/locales/en_AU.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/en_CA.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/index.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/types.ts → ., ....
21
21
  (!) Generated empty chunks
22
22
  "locales/types" and "locales/types"
23
- created ., . in 20.4s
23
+ created ., . in 23.9s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.108.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4216](https://github.com/Thinkei/hero-design/pull/4216) [`498d2b6f8d3eb3090e54346cb7f54a248256f848`](https://github.com/Thinkei/hero-design/commit/498d2b6f8d3eb3090e54346cb7f54a248256f848) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [Slider] Update colors to match design
8
+
3
9
  ## 8.108.1
4
10
 
5
11
  ### Patch Changes
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as reactNative from 'react-native';
2
- import { StyleSheet as StyleSheet$1, Platform, Dimensions, Animated, View, UIManager, LayoutAnimation, TouchableOpacity, Text as Text$1, Easing, useWindowDimensions, TouchableWithoutFeedback, Modal as Modal$1, Image as Image$1, Keyboard, Pressable, SafeAreaView, KeyboardAvoidingView, TouchableHighlight, ScrollView, FlatList, TextInput as TextInput$1, PanResponder, BackHandler, InteractionManager, SectionList, RefreshControl as RefreshControl$1 } from 'react-native';
2
+ import { StyleSheet as StyleSheet$1, Platform, Dimensions, Keyboard, Animated, View, UIManager, LayoutAnimation, TouchableOpacity, Text as Text$1, Easing, useWindowDimensions, TouchableWithoutFeedback, Modal as Modal$1, Image as Image$1, Pressable, SafeAreaView, KeyboardAvoidingView, TouchableHighlight, ScrollView, FlatList, TextInput as TextInput$1, PanResponder, BackHandler, InteractionManager, SectionList, RefreshControl as RefreshControl$1 } from 'react-native';
3
3
  import * as React from 'react';
4
- import React__default, { useMemo, useEffect, useCallback, useRef, useLayoutEffect, useState, createContext, forwardRef, useContext, memo, useReducer, useImperativeHandle, isValidElement } from 'react';
4
+ import React__default, { useState, useEffect, useMemo, useCallback, useRef, useLayoutEffect, createContext, forwardRef, useContext, memo, useReducer, useImperativeHandle, isValidElement } from 'react';
5
5
  import { createIconSet } from 'react-native-vector-icons';
6
6
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
7
7
  import { MonthYearPickerViewIOS, MonthYearPickerDialogueAndroid } from '@hero-design/react-native-month-year-picker';
@@ -6681,14 +6681,174 @@ var getSkeletonTheme = function getSkeletonTheme(theme) {
6681
6681
  };
6682
6682
  };
6683
6683
 
6684
+ var DISABLED_UNSELECTED_TRACK_OPACITY = 0.1;
6685
+ var DISABLED_SELECTED_TRACK_OPACITY = 1;
6686
+ var UNSELECTED_TRACK_OPACITY = 0.1;
6687
+
6688
+ var isIOS = Platform.OS === 'ios';
6689
+ var isAndroid = Platform.OS === 'android';
6690
+ function pick(keys, obj) {
6691
+ return keys.filter(function (key) {
6692
+ return key in obj;
6693
+ }).reduce(function (result, cur) {
6694
+ return _objectSpread2(_objectSpread2({}, result), {}, _defineProperty({}, cur, obj[cur]));
6695
+ }, {});
6696
+ }
6697
+ function omit(keys, obj) {
6698
+ var result = obj;
6699
+ keys.forEach(function (key) {
6700
+ delete result[key];
6701
+ });
6702
+ return result;
6703
+ }
6704
+ function hexToRgba(hex, a) {
6705
+ // Validate inputs
6706
+ if (typeof hex !== 'string' || typeof a !== 'number') {
6707
+ throw new Error('hexToRgba: hex must be a string and alpha must be a number');
6708
+ }
6709
+ if (a < 0 || a > 1) {
6710
+ throw new Error('hexToRgba: alpha must be between 0 and 1');
6711
+ }
6712
+ // Remove # if present and validate hex format
6713
+ var cleanHex = hex.replace(/^#/, '');
6714
+ if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(cleanHex)) {
6715
+ throw new Error('hexToRgba: hex must be a valid 3 or 6 character hex color');
6716
+ }
6717
+ // Handle 3-character hex codes (e.g., #fff -> #ffffff)
6718
+ var normalizedHex = cleanHex.length === 3 ? cleanHex.split('').map(function (_char) {
6719
+ return _char + _char;
6720
+ }).join('') : cleanHex;
6721
+ // Parse hex values
6722
+ var r = parseInt(normalizedHex.substring(0, 2), 16);
6723
+ var g = parseInt(normalizedHex.substring(2, 4), 16);
6724
+ var b = parseInt(normalizedHex.substring(4, 6), 16);
6725
+ return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(a, ")");
6726
+ }
6727
+ /**
6728
+ * Dim a hex color by blending it with a surface color
6729
+ * @param hex - The hex color to dim (3 or 6 characters, with or without #)
6730
+ * @param surface - The surface color to blend with.
6731
+ * @param amount - The amount of dimming (0 = original color, 1 = fully surface color)
6732
+ * @returns The dimmed hex color
6733
+ */
6734
+ var DEFAULT_DIM_AMOUNT = 0.6;
6735
+ function dimHex(hex, surface) {
6736
+ var amount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_DIM_AMOUNT;
6737
+ // Validate inputs
6738
+ if (typeof hex !== 'string' || typeof surface !== 'string' || typeof amount !== 'number') {
6739
+ throw new Error('dimHex: hex and surface must be strings and amount must be a number');
6740
+ }
6741
+ if (amount < 0 || amount > 1) {
6742
+ throw new Error('dimHex: amount must be between 0 and 1');
6743
+ }
6744
+ // Remove # if present and validate hex format
6745
+ var cleanHex = hex.replace(/^#/, '');
6746
+ var cleanSurface = surface.replace(/^#/, '');
6747
+ if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(cleanHex)) {
6748
+ throw new Error('dimHex: hex must be a valid 3 or 6 character hex color');
6749
+ }
6750
+ if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(cleanSurface)) {
6751
+ throw new Error('dimHex: surface must be a valid 3 or 6 character hex color');
6752
+ }
6753
+ // Handle 3-character hex codes (e.g., #fff -> #ffffff)
6754
+ var normalizedHex = cleanHex.length === 3 ? cleanHex.split('').map(function (_char2) {
6755
+ return _char2 + _char2;
6756
+ }).join('') : cleanHex;
6757
+ var normalizedSurface = cleanSurface.length === 3 ? cleanSurface.split('').map(function (_char3) {
6758
+ return _char3 + _char3;
6759
+ }).join('') : cleanSurface;
6760
+ // Parse hex values
6761
+ var r = parseInt(normalizedHex.substring(0, 2), 16);
6762
+ var g = parseInt(normalizedHex.substring(2, 4), 16);
6763
+ var b = parseInt(normalizedHex.substring(4, 6), 16);
6764
+ var sr = parseInt(normalizedSurface.substring(0, 2), 16);
6765
+ var sg = parseInt(normalizedSurface.substring(2, 4), 16);
6766
+ var sb = parseInt(normalizedSurface.substring(4, 6), 16);
6767
+ // Linear interpolation between colors
6768
+ var lerp = function lerp(c, s) {
6769
+ return Math.round(c * (1 - amount) + s * amount);
6770
+ };
6771
+ var rr = lerp(r, sr).toString(16).padStart(2, '0');
6772
+ var gg = lerp(g, sg).toString(16).padStart(2, '0');
6773
+ var bb = lerp(b, sb).toString(16).padStart(2, '0');
6774
+ return "#".concat(rr).concat(gg).concat(bb);
6775
+ }
6776
+ var _deepCompareValue = function deepCompareValue(a, b) {
6777
+ // Handle strict equality first (handles primitives, null, undefined)
6778
+ if (a === b) return true;
6779
+ // Special handling for NaN (NaN !== NaN in JS)
6780
+ if (typeof a === 'number' && typeof b === 'number' && Number.isNaN(a) && Number.isNaN(b)) {
6781
+ return false;
6782
+ }
6783
+ // If either is null or undefined (but they are not strictly equal), return false
6784
+ if (a == null || b == null) return false;
6785
+ // If types don't match, they can't be equal
6786
+ if (_typeof$1(a) !== _typeof$1(b)) return false;
6787
+ // Handle array comparison
6788
+ if (Array.isArray(a) && Array.isArray(b)) {
6789
+ if (a.length !== b.length) return false;
6790
+ return a.every(function (val, index) {
6791
+ return _deepCompareValue(val, b[index]);
6792
+ });
6793
+ }
6794
+ // If one is array and the other isn't, return false
6795
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
6796
+ // Handle object comparison
6797
+ if (_typeof$1(a) === 'object' && _typeof$1(b) === 'object') {
6798
+ var keysA = Object.keys(a);
6799
+ var keysB = Object.keys(b);
6800
+ if (keysA.length !== keysB.length) return false;
6801
+ return keysA.every(function (key) {
6802
+ return keysB.includes(key) && _deepCompareValue(a[key], b[key]);
6803
+ });
6804
+ }
6805
+ // If none of the above conditions matched, they're not equal
6806
+ return false;
6807
+ };
6808
+ var useKeyboard = function useKeyboard() {
6809
+ var _useState = useState(false),
6810
+ _useState2 = _slicedToArray(_useState, 2),
6811
+ isKeyboardVisible = _useState2[0],
6812
+ setKeyboardVisible = _useState2[1];
6813
+ var _useState3 = useState(0),
6814
+ _useState4 = _slicedToArray(_useState3, 2),
6815
+ keyboardHeight = _useState4[0],
6816
+ setKeyboardHeight = _useState4[1];
6817
+ useEffect(function () {
6818
+ var keyboardWillShowListener = Keyboard.addListener('keyboardWillShow', function (e) {
6819
+ setKeyboardVisible(true);
6820
+ setKeyboardHeight(e.endCoordinates.height);
6821
+ });
6822
+ var keyboardWillHideListener = Keyboard.addListener('keyboardWillHide', function () {
6823
+ setKeyboardVisible(false);
6824
+ });
6825
+ return function () {
6826
+ keyboardWillShowListener.remove();
6827
+ keyboardWillHideListener.remove();
6828
+ };
6829
+ }, []);
6830
+ return {
6831
+ isKeyboardVisible: isKeyboardVisible,
6832
+ keyboardHeight: keyboardHeight
6833
+ };
6834
+ };
6835
+ var transformKebabCaseToCamelCase = function transformKebabCaseToCamelCase(string) {
6836
+ return string.replace(/-([a-z0-9])/g, function (_, _char4) {
6837
+ return /[a-z]/.test(_char4) ? _char4.toUpperCase() : _char4;
6838
+ });
6839
+ };
6840
+
6684
6841
  var getSliderTheme = function getSliderTheme(theme) {
6685
6842
  var colors = {
6686
- minimumTrackTint: theme.colors.primary,
6687
- thumbTint: theme.colors.primary,
6688
- maximumTrackTint: theme.colors.highlightedSurface,
6689
- trackBackground: theme.colors.highlightedSurface,
6690
- disabledThumbTint: theme.colors.disabledOnDefaultGlobalSurface,
6691
- disabledTrackBackground: theme.colors.neutralGlobalSurface
6843
+ // Unselected track colors
6844
+ unselectedTrack: hexToRgba(theme.colors.overlayGlobalSurface, UNSELECTED_TRACK_OPACITY),
6845
+ disabledUnselectedTrack: dimHex(theme.colors.overlayGlobalSurface, theme.colors.defaultGlobalSurface),
6846
+ // Selected track colors
6847
+ selectedTrack: theme.colors.primary,
6848
+ disabledSelectedTrack: dimHex(theme.colors.primary, theme.colors.defaultGlobalSurface),
6849
+ // Thumb/marker colors
6850
+ thumb: theme.colors.primary,
6851
+ disabledThumb: dimHex(theme.colors.primary, theme.colors.defaultGlobalSurface)
6692
6852
  };
6693
6853
  var shadows = {
6694
6854
  marker: theme.shadows["default"]
@@ -9413,110 +9573,6 @@ var Avatar = function Avatar(_ref) {
9413
9573
  }));
9414
9574
  };
9415
9575
 
9416
- var isIOS = Platform.OS === 'ios';
9417
- var isAndroid = Platform.OS === 'android';
9418
- function pick(keys, obj) {
9419
- return keys.filter(function (key) {
9420
- return key in obj;
9421
- }).reduce(function (result, cur) {
9422
- return _objectSpread2(_objectSpread2({}, result), {}, _defineProperty({}, cur, obj[cur]));
9423
- }, {});
9424
- }
9425
- function omit(keys, obj) {
9426
- var result = obj;
9427
- keys.forEach(function (key) {
9428
- delete result[key];
9429
- });
9430
- return result;
9431
- }
9432
- function hexToRgba(hex, a) {
9433
- // Validate inputs
9434
- if (typeof hex !== 'string' || typeof a !== 'number') {
9435
- throw new Error('hexToRgba: hex must be a string and alpha must be a number');
9436
- }
9437
- if (a < 0 || a > 1) {
9438
- throw new Error('hexToRgba: alpha must be between 0 and 1');
9439
- }
9440
- // Remove # if present and validate hex format
9441
- var cleanHex = hex.replace(/^#/, '');
9442
- if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(cleanHex)) {
9443
- throw new Error('hexToRgba: hex must be a valid 3 or 6 character hex color');
9444
- }
9445
- // Handle 3-character hex codes (e.g., #fff -> #ffffff)
9446
- var normalizedHex = cleanHex.length === 3 ? cleanHex.split('').map(function (_char) {
9447
- return _char + _char;
9448
- }).join('') : cleanHex;
9449
- // Parse hex values
9450
- var r = parseInt(normalizedHex.substring(0, 2), 16);
9451
- var g = parseInt(normalizedHex.substring(2, 4), 16);
9452
- var b = parseInt(normalizedHex.substring(4, 6), 16);
9453
- return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(a, ")");
9454
- }
9455
- var _deepCompareValue = function deepCompareValue(a, b) {
9456
- // Handle strict equality first (handles primitives, null, undefined)
9457
- if (a === b) return true;
9458
- // Special handling for NaN (NaN !== NaN in JS)
9459
- if (typeof a === 'number' && typeof b === 'number' && Number.isNaN(a) && Number.isNaN(b)) {
9460
- return false;
9461
- }
9462
- // If either is null or undefined (but they are not strictly equal), return false
9463
- if (a == null || b == null) return false;
9464
- // If types don't match, they can't be equal
9465
- if (_typeof$1(a) !== _typeof$1(b)) return false;
9466
- // Handle array comparison
9467
- if (Array.isArray(a) && Array.isArray(b)) {
9468
- if (a.length !== b.length) return false;
9469
- return a.every(function (val, index) {
9470
- return _deepCompareValue(val, b[index]);
9471
- });
9472
- }
9473
- // If one is array and the other isn't, return false
9474
- if (Array.isArray(a) !== Array.isArray(b)) return false;
9475
- // Handle object comparison
9476
- if (_typeof$1(a) === 'object' && _typeof$1(b) === 'object') {
9477
- var keysA = Object.keys(a);
9478
- var keysB = Object.keys(b);
9479
- if (keysA.length !== keysB.length) return false;
9480
- return keysA.every(function (key) {
9481
- return keysB.includes(key) && _deepCompareValue(a[key], b[key]);
9482
- });
9483
- }
9484
- // If none of the above conditions matched, they're not equal
9485
- return false;
9486
- };
9487
- var useKeyboard = function useKeyboard() {
9488
- var _useState = useState(false),
9489
- _useState2 = _slicedToArray(_useState, 2),
9490
- isKeyboardVisible = _useState2[0],
9491
- setKeyboardVisible = _useState2[1];
9492
- var _useState3 = useState(0),
9493
- _useState4 = _slicedToArray(_useState3, 2),
9494
- keyboardHeight = _useState4[0],
9495
- setKeyboardHeight = _useState4[1];
9496
- useEffect(function () {
9497
- var keyboardWillShowListener = Keyboard.addListener('keyboardWillShow', function (e) {
9498
- setKeyboardVisible(true);
9499
- setKeyboardHeight(e.endCoordinates.height);
9500
- });
9501
- var keyboardWillHideListener = Keyboard.addListener('keyboardWillHide', function () {
9502
- setKeyboardVisible(false);
9503
- });
9504
- return function () {
9505
- keyboardWillShowListener.remove();
9506
- keyboardWillHideListener.remove();
9507
- };
9508
- }, []);
9509
- return {
9510
- isKeyboardVisible: isKeyboardVisible,
9511
- keyboardHeight: keyboardHeight
9512
- };
9513
- };
9514
- var transformKebabCaseToCamelCase = function transformKebabCaseToCamelCase(string) {
9515
- return string.replace(/-([a-z0-9])/g, function (_, _char2) {
9516
- return /[a-z]/.test(_char2) ? _char2.toUpperCase() : _char2;
9517
- });
9518
- };
9519
-
9520
9576
  var colors = {
9521
9577
  backgroundColor: {
9522
9578
  property: 'backgroundColor',
@@ -25288,6 +25344,10 @@ var Slider$2 = function Slider(_ref) {
25288
25344
  style = _ref.style,
25289
25345
  testID = _ref.testID;
25290
25346
  var theme = useTheme();
25347
+ var _theme$__hd__$slider$ = theme.__hd__.slider.colors,
25348
+ selectedTrack = _theme$__hd__$slider$.selectedTrack,
25349
+ thumb = _theme$__hd__$slider$.thumb,
25350
+ unselectedTrack = _theme$__hd__$slider$.unselectedTrack;
25291
25351
  return /*#__PURE__*/React__default.createElement(RnSlider, {
25292
25352
  minimumValue: minimumValue,
25293
25353
  maximumValue: maximumValue,
@@ -25297,9 +25357,9 @@ var Slider$2 = function Slider(_ref) {
25297
25357
  onSlidingStart: onSlidingStart,
25298
25358
  onSlidingComplete: onSlidingComplete,
25299
25359
  disabled: disabled,
25300
- minimumTrackTintColor: theme.__hd__.slider.colors.minimumTrackTint,
25301
- thumbTintColor: theme.__hd__.slider.colors.thumbTint,
25302
- maximumTrackTintColor: theme.__hd__.slider.colors.maximumTrackTint,
25360
+ minimumTrackTintColor: selectedTrack,
25361
+ thumbTintColor: thumb,
25362
+ maximumTrackTintColor: unselectedTrack,
25303
25363
  style: style,
25304
25364
  testID: testID
25305
25365
  });
@@ -25312,7 +25372,7 @@ var StyledMarker = index$c(View)(function (_ref) {
25312
25372
  height: theme.__hd__.slider.sizes.markerHeight,
25313
25373
  width: theme.__hd__.slider.sizes.markerWidth,
25314
25374
  borderRadius: theme.__hd__.slider.radii.marker,
25315
- backgroundColor: themeDisabled ? theme.__hd__.slider.colors.disabledThumbTint : theme.__hd__.slider.colors.thumbTint
25375
+ backgroundColor: themeDisabled ? theme.__hd__.slider.colors.disabledThumb : theme.__hd__.slider.colors.thumb
25316
25376
  }, theme.__hd__.slider.shadows.marker);
25317
25377
  });
25318
25378
 
@@ -25352,28 +25412,30 @@ var Slider$1 = function Slider(_ref) {
25352
25412
  return [(_value$start = value === null || value === void 0 ? void 0 : value.start) !== null && _value$start !== void 0 ? _value$start : minimumValue, (_value$end = value === null || value === void 0 ? void 0 : value.end) !== null && _value$end !== void 0 ? _value$end : maximumValue];
25353
25413
  }, [value === null || value === void 0 ? void 0 : value.start, value === null || value === void 0 ? void 0 : value.end, minimumValue, maximumValue]);
25354
25414
  var _theme$__hd__$slider$ = theme.__hd__.slider.colors,
25355
- trackBackground = _theme$__hd__$slider$.trackBackground,
25356
- disabledTrackBackground = _theme$__hd__$slider$.disabledTrackBackground,
25357
- thumbTint = _theme$__hd__$slider$.thumbTint,
25358
- disabledThumbTint = _theme$__hd__$slider$.disabledThumbTint;
25415
+ unselectedTrack = _theme$__hd__$slider$.unselectedTrack,
25416
+ disabledUnselectedTrack = _theme$__hd__$slider$.disabledUnselectedTrack,
25417
+ selectedTrack = _theme$__hd__$slider$.selectedTrack,
25418
+ disabledSelectedTrack = _theme$__hd__$slider$.disabledSelectedTrack;
25359
25419
  var trackHeight = theme.__hd__.slider.sizes.trackHeight;
25360
25420
  // Define styles for disabled and enabled states
25361
25421
  var disabledStyles = {
25362
25422
  track: {
25363
- backgroundColor: disabledTrackBackground,
25423
+ opacity: DISABLED_UNSELECTED_TRACK_OPACITY,
25424
+ backgroundColor: disabledUnselectedTrack,
25364
25425
  height: trackHeight
25365
25426
  },
25366
25427
  selected: {
25367
- backgroundColor: disabledThumbTint
25428
+ opacity: DISABLED_SELECTED_TRACK_OPACITY,
25429
+ backgroundColor: disabledSelectedTrack
25368
25430
  }
25369
25431
  };
25370
25432
  var enabledStyles = {
25371
25433
  track: {
25372
- backgroundColor: trackBackground,
25434
+ backgroundColor: unselectedTrack,
25373
25435
  height: trackHeight
25374
25436
  },
25375
25437
  selected: {
25376
- backgroundColor: thumbTint
25438
+ backgroundColor: selectedTrack
25377
25439
  }
25378
25440
  };
25379
25441
  // Use styles based on the `disabled` state