@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.
- package/.turbo/turbo-build.log +3 -3
- package/CHANGELOG.md +6 -0
- package/es/index.js +186 -124
- package/lib/index.js +184 -122
- package/package.json +1 -1
- package/src/components/Slider/RangeSlider.tsx +14 -8
- package/src/components/Slider/SingleSlider.tsx +6 -4
- package/src/components/Slider/StyledRangeSlider.tsx +2 -2
- package/src/components/Slider/__tests__/RangeSlider.spec.tsx +6 -4
- package/src/components/Slider/__tests__/__snapshots__/RangeSlider.spec.tsx.snap +6 -4
- package/src/components/Slider/__tests__/__snapshots__/SingleSlider.spec.tsx.snap +3 -3
- package/src/components/Slider/constants.ts +3 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +6 -6
- package/src/theme/components/slider.ts +25 -6
- package/src/utils/__tests__/helpers.spec.ts +71 -0
- package/src/utils/helpers.ts +79 -0
- package/stats/8.108.2/rn-stats.html +4842 -0
- package/types/components/Slider/constants.d.ts +3 -0
- package/types/components/TextInput/index.d.ts +1 -1
- package/types/theme/components/slider.d.ts +6 -6
- package/types/utils/helpers.d.ts +1 -0
package/lib/index.js
CHANGED
|
@@ -6710,14 +6710,174 @@ var getSkeletonTheme = function getSkeletonTheme(theme) {
|
|
|
6710
6710
|
};
|
|
6711
6711
|
};
|
|
6712
6712
|
|
|
6713
|
+
var DISABLED_UNSELECTED_TRACK_OPACITY = 0.1;
|
|
6714
|
+
var DISABLED_SELECTED_TRACK_OPACITY = 1;
|
|
6715
|
+
var UNSELECTED_TRACK_OPACITY = 0.1;
|
|
6716
|
+
|
|
6717
|
+
var isIOS = reactNative.Platform.OS === 'ios';
|
|
6718
|
+
var isAndroid = reactNative.Platform.OS === 'android';
|
|
6719
|
+
function pick(keys, obj) {
|
|
6720
|
+
return keys.filter(function (key) {
|
|
6721
|
+
return key in obj;
|
|
6722
|
+
}).reduce(function (result, cur) {
|
|
6723
|
+
return _objectSpread2(_objectSpread2({}, result), {}, _defineProperty({}, cur, obj[cur]));
|
|
6724
|
+
}, {});
|
|
6725
|
+
}
|
|
6726
|
+
function omit(keys, obj) {
|
|
6727
|
+
var result = obj;
|
|
6728
|
+
keys.forEach(function (key) {
|
|
6729
|
+
delete result[key];
|
|
6730
|
+
});
|
|
6731
|
+
return result;
|
|
6732
|
+
}
|
|
6733
|
+
function hexToRgba(hex, a) {
|
|
6734
|
+
// Validate inputs
|
|
6735
|
+
if (typeof hex !== 'string' || typeof a !== 'number') {
|
|
6736
|
+
throw new Error('hexToRgba: hex must be a string and alpha must be a number');
|
|
6737
|
+
}
|
|
6738
|
+
if (a < 0 || a > 1) {
|
|
6739
|
+
throw new Error('hexToRgba: alpha must be between 0 and 1');
|
|
6740
|
+
}
|
|
6741
|
+
// Remove # if present and validate hex format
|
|
6742
|
+
var cleanHex = hex.replace(/^#/, '');
|
|
6743
|
+
if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(cleanHex)) {
|
|
6744
|
+
throw new Error('hexToRgba: hex must be a valid 3 or 6 character hex color');
|
|
6745
|
+
}
|
|
6746
|
+
// Handle 3-character hex codes (e.g., #fff -> #ffffff)
|
|
6747
|
+
var normalizedHex = cleanHex.length === 3 ? cleanHex.split('').map(function (_char) {
|
|
6748
|
+
return _char + _char;
|
|
6749
|
+
}).join('') : cleanHex;
|
|
6750
|
+
// Parse hex values
|
|
6751
|
+
var r = parseInt(normalizedHex.substring(0, 2), 16);
|
|
6752
|
+
var g = parseInt(normalizedHex.substring(2, 4), 16);
|
|
6753
|
+
var b = parseInt(normalizedHex.substring(4, 6), 16);
|
|
6754
|
+
return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(a, ")");
|
|
6755
|
+
}
|
|
6756
|
+
/**
|
|
6757
|
+
* Dim a hex color by blending it with a surface color
|
|
6758
|
+
* @param hex - The hex color to dim (3 or 6 characters, with or without #)
|
|
6759
|
+
* @param surface - The surface color to blend with.
|
|
6760
|
+
* @param amount - The amount of dimming (0 = original color, 1 = fully surface color)
|
|
6761
|
+
* @returns The dimmed hex color
|
|
6762
|
+
*/
|
|
6763
|
+
var DEFAULT_DIM_AMOUNT = 0.6;
|
|
6764
|
+
function dimHex(hex, surface) {
|
|
6765
|
+
var amount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_DIM_AMOUNT;
|
|
6766
|
+
// Validate inputs
|
|
6767
|
+
if (typeof hex !== 'string' || typeof surface !== 'string' || typeof amount !== 'number') {
|
|
6768
|
+
throw new Error('dimHex: hex and surface must be strings and amount must be a number');
|
|
6769
|
+
}
|
|
6770
|
+
if (amount < 0 || amount > 1) {
|
|
6771
|
+
throw new Error('dimHex: amount must be between 0 and 1');
|
|
6772
|
+
}
|
|
6773
|
+
// Remove # if present and validate hex format
|
|
6774
|
+
var cleanHex = hex.replace(/^#/, '');
|
|
6775
|
+
var cleanSurface = surface.replace(/^#/, '');
|
|
6776
|
+
if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(cleanHex)) {
|
|
6777
|
+
throw new Error('dimHex: hex must be a valid 3 or 6 character hex color');
|
|
6778
|
+
}
|
|
6779
|
+
if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(cleanSurface)) {
|
|
6780
|
+
throw new Error('dimHex: surface must be a valid 3 or 6 character hex color');
|
|
6781
|
+
}
|
|
6782
|
+
// Handle 3-character hex codes (e.g., #fff -> #ffffff)
|
|
6783
|
+
var normalizedHex = cleanHex.length === 3 ? cleanHex.split('').map(function (_char2) {
|
|
6784
|
+
return _char2 + _char2;
|
|
6785
|
+
}).join('') : cleanHex;
|
|
6786
|
+
var normalizedSurface = cleanSurface.length === 3 ? cleanSurface.split('').map(function (_char3) {
|
|
6787
|
+
return _char3 + _char3;
|
|
6788
|
+
}).join('') : cleanSurface;
|
|
6789
|
+
// Parse hex values
|
|
6790
|
+
var r = parseInt(normalizedHex.substring(0, 2), 16);
|
|
6791
|
+
var g = parseInt(normalizedHex.substring(2, 4), 16);
|
|
6792
|
+
var b = parseInt(normalizedHex.substring(4, 6), 16);
|
|
6793
|
+
var sr = parseInt(normalizedSurface.substring(0, 2), 16);
|
|
6794
|
+
var sg = parseInt(normalizedSurface.substring(2, 4), 16);
|
|
6795
|
+
var sb = parseInt(normalizedSurface.substring(4, 6), 16);
|
|
6796
|
+
// Linear interpolation between colors
|
|
6797
|
+
var lerp = function lerp(c, s) {
|
|
6798
|
+
return Math.round(c * (1 - amount) + s * amount);
|
|
6799
|
+
};
|
|
6800
|
+
var rr = lerp(r, sr).toString(16).padStart(2, '0');
|
|
6801
|
+
var gg = lerp(g, sg).toString(16).padStart(2, '0');
|
|
6802
|
+
var bb = lerp(b, sb).toString(16).padStart(2, '0');
|
|
6803
|
+
return "#".concat(rr).concat(gg).concat(bb);
|
|
6804
|
+
}
|
|
6805
|
+
var _deepCompareValue = function deepCompareValue(a, b) {
|
|
6806
|
+
// Handle strict equality first (handles primitives, null, undefined)
|
|
6807
|
+
if (a === b) return true;
|
|
6808
|
+
// Special handling for NaN (NaN !== NaN in JS)
|
|
6809
|
+
if (typeof a === 'number' && typeof b === 'number' && Number.isNaN(a) && Number.isNaN(b)) {
|
|
6810
|
+
return false;
|
|
6811
|
+
}
|
|
6812
|
+
// If either is null or undefined (but they are not strictly equal), return false
|
|
6813
|
+
if (a == null || b == null) return false;
|
|
6814
|
+
// If types don't match, they can't be equal
|
|
6815
|
+
if (_typeof$1(a) !== _typeof$1(b)) return false;
|
|
6816
|
+
// Handle array comparison
|
|
6817
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
6818
|
+
if (a.length !== b.length) return false;
|
|
6819
|
+
return a.every(function (val, index) {
|
|
6820
|
+
return _deepCompareValue(val, b[index]);
|
|
6821
|
+
});
|
|
6822
|
+
}
|
|
6823
|
+
// If one is array and the other isn't, return false
|
|
6824
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
6825
|
+
// Handle object comparison
|
|
6826
|
+
if (_typeof$1(a) === 'object' && _typeof$1(b) === 'object') {
|
|
6827
|
+
var keysA = Object.keys(a);
|
|
6828
|
+
var keysB = Object.keys(b);
|
|
6829
|
+
if (keysA.length !== keysB.length) return false;
|
|
6830
|
+
return keysA.every(function (key) {
|
|
6831
|
+
return keysB.includes(key) && _deepCompareValue(a[key], b[key]);
|
|
6832
|
+
});
|
|
6833
|
+
}
|
|
6834
|
+
// If none of the above conditions matched, they're not equal
|
|
6835
|
+
return false;
|
|
6836
|
+
};
|
|
6837
|
+
var useKeyboard = function useKeyboard() {
|
|
6838
|
+
var _useState = React.useState(false),
|
|
6839
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6840
|
+
isKeyboardVisible = _useState2[0],
|
|
6841
|
+
setKeyboardVisible = _useState2[1];
|
|
6842
|
+
var _useState3 = React.useState(0),
|
|
6843
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
6844
|
+
keyboardHeight = _useState4[0],
|
|
6845
|
+
setKeyboardHeight = _useState4[1];
|
|
6846
|
+
React.useEffect(function () {
|
|
6847
|
+
var keyboardWillShowListener = reactNative.Keyboard.addListener('keyboardWillShow', function (e) {
|
|
6848
|
+
setKeyboardVisible(true);
|
|
6849
|
+
setKeyboardHeight(e.endCoordinates.height);
|
|
6850
|
+
});
|
|
6851
|
+
var keyboardWillHideListener = reactNative.Keyboard.addListener('keyboardWillHide', function () {
|
|
6852
|
+
setKeyboardVisible(false);
|
|
6853
|
+
});
|
|
6854
|
+
return function () {
|
|
6855
|
+
keyboardWillShowListener.remove();
|
|
6856
|
+
keyboardWillHideListener.remove();
|
|
6857
|
+
};
|
|
6858
|
+
}, []);
|
|
6859
|
+
return {
|
|
6860
|
+
isKeyboardVisible: isKeyboardVisible,
|
|
6861
|
+
keyboardHeight: keyboardHeight
|
|
6862
|
+
};
|
|
6863
|
+
};
|
|
6864
|
+
var transformKebabCaseToCamelCase = function transformKebabCaseToCamelCase(string) {
|
|
6865
|
+
return string.replace(/-([a-z0-9])/g, function (_, _char4) {
|
|
6866
|
+
return /[a-z]/.test(_char4) ? _char4.toUpperCase() : _char4;
|
|
6867
|
+
});
|
|
6868
|
+
};
|
|
6869
|
+
|
|
6713
6870
|
var getSliderTheme = function getSliderTheme(theme) {
|
|
6714
6871
|
var colors = {
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6872
|
+
// Unselected track colors
|
|
6873
|
+
unselectedTrack: hexToRgba(theme.colors.overlayGlobalSurface, UNSELECTED_TRACK_OPACITY),
|
|
6874
|
+
disabledUnselectedTrack: dimHex(theme.colors.overlayGlobalSurface, theme.colors.defaultGlobalSurface),
|
|
6875
|
+
// Selected track colors
|
|
6876
|
+
selectedTrack: theme.colors.primary,
|
|
6877
|
+
disabledSelectedTrack: dimHex(theme.colors.primary, theme.colors.defaultGlobalSurface),
|
|
6878
|
+
// Thumb/marker colors
|
|
6879
|
+
thumb: theme.colors.primary,
|
|
6880
|
+
disabledThumb: dimHex(theme.colors.primary, theme.colors.defaultGlobalSurface)
|
|
6721
6881
|
};
|
|
6722
6882
|
var shadows = {
|
|
6723
6883
|
marker: theme.shadows["default"]
|
|
@@ -9442,110 +9602,6 @@ var Avatar = function Avatar(_ref) {
|
|
|
9442
9602
|
}));
|
|
9443
9603
|
};
|
|
9444
9604
|
|
|
9445
|
-
var isIOS = reactNative.Platform.OS === 'ios';
|
|
9446
|
-
var isAndroid = reactNative.Platform.OS === 'android';
|
|
9447
|
-
function pick(keys, obj) {
|
|
9448
|
-
return keys.filter(function (key) {
|
|
9449
|
-
return key in obj;
|
|
9450
|
-
}).reduce(function (result, cur) {
|
|
9451
|
-
return _objectSpread2(_objectSpread2({}, result), {}, _defineProperty({}, cur, obj[cur]));
|
|
9452
|
-
}, {});
|
|
9453
|
-
}
|
|
9454
|
-
function omit(keys, obj) {
|
|
9455
|
-
var result = obj;
|
|
9456
|
-
keys.forEach(function (key) {
|
|
9457
|
-
delete result[key];
|
|
9458
|
-
});
|
|
9459
|
-
return result;
|
|
9460
|
-
}
|
|
9461
|
-
function hexToRgba(hex, a) {
|
|
9462
|
-
// Validate inputs
|
|
9463
|
-
if (typeof hex !== 'string' || typeof a !== 'number') {
|
|
9464
|
-
throw new Error('hexToRgba: hex must be a string and alpha must be a number');
|
|
9465
|
-
}
|
|
9466
|
-
if (a < 0 || a > 1) {
|
|
9467
|
-
throw new Error('hexToRgba: alpha must be between 0 and 1');
|
|
9468
|
-
}
|
|
9469
|
-
// Remove # if present and validate hex format
|
|
9470
|
-
var cleanHex = hex.replace(/^#/, '');
|
|
9471
|
-
if (!/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(cleanHex)) {
|
|
9472
|
-
throw new Error('hexToRgba: hex must be a valid 3 or 6 character hex color');
|
|
9473
|
-
}
|
|
9474
|
-
// Handle 3-character hex codes (e.g., #fff -> #ffffff)
|
|
9475
|
-
var normalizedHex = cleanHex.length === 3 ? cleanHex.split('').map(function (_char) {
|
|
9476
|
-
return _char + _char;
|
|
9477
|
-
}).join('') : cleanHex;
|
|
9478
|
-
// Parse hex values
|
|
9479
|
-
var r = parseInt(normalizedHex.substring(0, 2), 16);
|
|
9480
|
-
var g = parseInt(normalizedHex.substring(2, 4), 16);
|
|
9481
|
-
var b = parseInt(normalizedHex.substring(4, 6), 16);
|
|
9482
|
-
return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(a, ")");
|
|
9483
|
-
}
|
|
9484
|
-
var _deepCompareValue = function deepCompareValue(a, b) {
|
|
9485
|
-
// Handle strict equality first (handles primitives, null, undefined)
|
|
9486
|
-
if (a === b) return true;
|
|
9487
|
-
// Special handling for NaN (NaN !== NaN in JS)
|
|
9488
|
-
if (typeof a === 'number' && typeof b === 'number' && Number.isNaN(a) && Number.isNaN(b)) {
|
|
9489
|
-
return false;
|
|
9490
|
-
}
|
|
9491
|
-
// If either is null or undefined (but they are not strictly equal), return false
|
|
9492
|
-
if (a == null || b == null) return false;
|
|
9493
|
-
// If types don't match, they can't be equal
|
|
9494
|
-
if (_typeof$1(a) !== _typeof$1(b)) return false;
|
|
9495
|
-
// Handle array comparison
|
|
9496
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
9497
|
-
if (a.length !== b.length) return false;
|
|
9498
|
-
return a.every(function (val, index) {
|
|
9499
|
-
return _deepCompareValue(val, b[index]);
|
|
9500
|
-
});
|
|
9501
|
-
}
|
|
9502
|
-
// If one is array and the other isn't, return false
|
|
9503
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
9504
|
-
// Handle object comparison
|
|
9505
|
-
if (_typeof$1(a) === 'object' && _typeof$1(b) === 'object') {
|
|
9506
|
-
var keysA = Object.keys(a);
|
|
9507
|
-
var keysB = Object.keys(b);
|
|
9508
|
-
if (keysA.length !== keysB.length) return false;
|
|
9509
|
-
return keysA.every(function (key) {
|
|
9510
|
-
return keysB.includes(key) && _deepCompareValue(a[key], b[key]);
|
|
9511
|
-
});
|
|
9512
|
-
}
|
|
9513
|
-
// If none of the above conditions matched, they're not equal
|
|
9514
|
-
return false;
|
|
9515
|
-
};
|
|
9516
|
-
var useKeyboard = function useKeyboard() {
|
|
9517
|
-
var _useState = React.useState(false),
|
|
9518
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
9519
|
-
isKeyboardVisible = _useState2[0],
|
|
9520
|
-
setKeyboardVisible = _useState2[1];
|
|
9521
|
-
var _useState3 = React.useState(0),
|
|
9522
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
9523
|
-
keyboardHeight = _useState4[0],
|
|
9524
|
-
setKeyboardHeight = _useState4[1];
|
|
9525
|
-
React.useEffect(function () {
|
|
9526
|
-
var keyboardWillShowListener = reactNative.Keyboard.addListener('keyboardWillShow', function (e) {
|
|
9527
|
-
setKeyboardVisible(true);
|
|
9528
|
-
setKeyboardHeight(e.endCoordinates.height);
|
|
9529
|
-
});
|
|
9530
|
-
var keyboardWillHideListener = reactNative.Keyboard.addListener('keyboardWillHide', function () {
|
|
9531
|
-
setKeyboardVisible(false);
|
|
9532
|
-
});
|
|
9533
|
-
return function () {
|
|
9534
|
-
keyboardWillShowListener.remove();
|
|
9535
|
-
keyboardWillHideListener.remove();
|
|
9536
|
-
};
|
|
9537
|
-
}, []);
|
|
9538
|
-
return {
|
|
9539
|
-
isKeyboardVisible: isKeyboardVisible,
|
|
9540
|
-
keyboardHeight: keyboardHeight
|
|
9541
|
-
};
|
|
9542
|
-
};
|
|
9543
|
-
var transformKebabCaseToCamelCase = function transformKebabCaseToCamelCase(string) {
|
|
9544
|
-
return string.replace(/-([a-z0-9])/g, function (_, _char2) {
|
|
9545
|
-
return /[a-z]/.test(_char2) ? _char2.toUpperCase() : _char2;
|
|
9546
|
-
});
|
|
9547
|
-
};
|
|
9548
|
-
|
|
9549
9605
|
var colors = {
|
|
9550
9606
|
backgroundColor: {
|
|
9551
9607
|
property: 'backgroundColor',
|
|
@@ -25317,6 +25373,10 @@ var Slider$2 = function Slider(_ref) {
|
|
|
25317
25373
|
style = _ref.style,
|
|
25318
25374
|
testID = _ref.testID;
|
|
25319
25375
|
var theme = useTheme();
|
|
25376
|
+
var _theme$__hd__$slider$ = theme.__hd__.slider.colors,
|
|
25377
|
+
selectedTrack = _theme$__hd__$slider$.selectedTrack,
|
|
25378
|
+
thumb = _theme$__hd__$slider$.thumb,
|
|
25379
|
+
unselectedTrack = _theme$__hd__$slider$.unselectedTrack;
|
|
25320
25380
|
return /*#__PURE__*/React__namespace.default.createElement(RnSlider__default.default, {
|
|
25321
25381
|
minimumValue: minimumValue,
|
|
25322
25382
|
maximumValue: maximumValue,
|
|
@@ -25326,9 +25386,9 @@ var Slider$2 = function Slider(_ref) {
|
|
|
25326
25386
|
onSlidingStart: onSlidingStart,
|
|
25327
25387
|
onSlidingComplete: onSlidingComplete,
|
|
25328
25388
|
disabled: disabled,
|
|
25329
|
-
minimumTrackTintColor:
|
|
25330
|
-
thumbTintColor:
|
|
25331
|
-
maximumTrackTintColor:
|
|
25389
|
+
minimumTrackTintColor: selectedTrack,
|
|
25390
|
+
thumbTintColor: thumb,
|
|
25391
|
+
maximumTrackTintColor: unselectedTrack,
|
|
25332
25392
|
style: style,
|
|
25333
25393
|
testID: testID
|
|
25334
25394
|
});
|
|
@@ -25341,7 +25401,7 @@ var StyledMarker = index$c(reactNative.View)(function (_ref) {
|
|
|
25341
25401
|
height: theme.__hd__.slider.sizes.markerHeight,
|
|
25342
25402
|
width: theme.__hd__.slider.sizes.markerWidth,
|
|
25343
25403
|
borderRadius: theme.__hd__.slider.radii.marker,
|
|
25344
|
-
backgroundColor: themeDisabled ? theme.__hd__.slider.colors.
|
|
25404
|
+
backgroundColor: themeDisabled ? theme.__hd__.slider.colors.disabledThumb : theme.__hd__.slider.colors.thumb
|
|
25345
25405
|
}, theme.__hd__.slider.shadows.marker);
|
|
25346
25406
|
});
|
|
25347
25407
|
|
|
@@ -25381,28 +25441,30 @@ var Slider$1 = function Slider(_ref) {
|
|
|
25381
25441
|
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];
|
|
25382
25442
|
}, [value === null || value === void 0 ? void 0 : value.start, value === null || value === void 0 ? void 0 : value.end, minimumValue, maximumValue]);
|
|
25383
25443
|
var _theme$__hd__$slider$ = theme.__hd__.slider.colors,
|
|
25384
|
-
|
|
25385
|
-
|
|
25386
|
-
|
|
25387
|
-
|
|
25444
|
+
unselectedTrack = _theme$__hd__$slider$.unselectedTrack,
|
|
25445
|
+
disabledUnselectedTrack = _theme$__hd__$slider$.disabledUnselectedTrack,
|
|
25446
|
+
selectedTrack = _theme$__hd__$slider$.selectedTrack,
|
|
25447
|
+
disabledSelectedTrack = _theme$__hd__$slider$.disabledSelectedTrack;
|
|
25388
25448
|
var trackHeight = theme.__hd__.slider.sizes.trackHeight;
|
|
25389
25449
|
// Define styles for disabled and enabled states
|
|
25390
25450
|
var disabledStyles = {
|
|
25391
25451
|
track: {
|
|
25392
|
-
|
|
25452
|
+
opacity: DISABLED_UNSELECTED_TRACK_OPACITY,
|
|
25453
|
+
backgroundColor: disabledUnselectedTrack,
|
|
25393
25454
|
height: trackHeight
|
|
25394
25455
|
},
|
|
25395
25456
|
selected: {
|
|
25396
|
-
|
|
25457
|
+
opacity: DISABLED_SELECTED_TRACK_OPACITY,
|
|
25458
|
+
backgroundColor: disabledSelectedTrack
|
|
25397
25459
|
}
|
|
25398
25460
|
};
|
|
25399
25461
|
var enabledStyles = {
|
|
25400
25462
|
track: {
|
|
25401
|
-
backgroundColor:
|
|
25463
|
+
backgroundColor: unselectedTrack,
|
|
25402
25464
|
height: trackHeight
|
|
25403
25465
|
},
|
|
25404
25466
|
selected: {
|
|
25405
|
-
backgroundColor:
|
|
25467
|
+
backgroundColor: selectedTrack
|
|
25406
25468
|
}
|
|
25407
25469
|
};
|
|
25408
25470
|
// Use styles based on the `disabled` state
|
package/package.json
CHANGED
|
@@ -5,6 +5,10 @@ import type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
|
|
|
5
5
|
import { View } from 'react-native';
|
|
6
6
|
import { useTheme } from '../../theme';
|
|
7
7
|
import { StyledMarker } from './StyledRangeSlider';
|
|
8
|
+
import {
|
|
9
|
+
DISABLED_UNSELECTED_TRACK_OPACITY,
|
|
10
|
+
DISABLED_SELECTED_TRACK_OPACITY,
|
|
11
|
+
} from './constants';
|
|
8
12
|
|
|
9
13
|
export type SliderRangeValue = {
|
|
10
14
|
start: number;
|
|
@@ -92,10 +96,10 @@ const Slider = ({
|
|
|
92
96
|
}, [value?.start, value?.end, minimumValue, maximumValue]);
|
|
93
97
|
|
|
94
98
|
const {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
unselectedTrack,
|
|
100
|
+
disabledUnselectedTrack,
|
|
101
|
+
selectedTrack,
|
|
102
|
+
disabledSelectedTrack,
|
|
99
103
|
} = theme.__hd__.slider.colors;
|
|
100
104
|
|
|
101
105
|
const { trackHeight } = theme.__hd__.slider.sizes;
|
|
@@ -103,21 +107,23 @@ const Slider = ({
|
|
|
103
107
|
// Define styles for disabled and enabled states
|
|
104
108
|
const disabledStyles = {
|
|
105
109
|
track: {
|
|
106
|
-
|
|
110
|
+
opacity: DISABLED_UNSELECTED_TRACK_OPACITY,
|
|
111
|
+
backgroundColor: disabledUnselectedTrack,
|
|
107
112
|
height: trackHeight,
|
|
108
113
|
},
|
|
109
114
|
selected: {
|
|
110
|
-
|
|
115
|
+
opacity: DISABLED_SELECTED_TRACK_OPACITY,
|
|
116
|
+
backgroundColor: disabledSelectedTrack,
|
|
111
117
|
},
|
|
112
118
|
};
|
|
113
119
|
|
|
114
120
|
const enabledStyles = {
|
|
115
121
|
track: {
|
|
116
|
-
backgroundColor:
|
|
122
|
+
backgroundColor: unselectedTrack,
|
|
117
123
|
height: trackHeight,
|
|
118
124
|
},
|
|
119
125
|
selected: {
|
|
120
|
-
backgroundColor:
|
|
126
|
+
backgroundColor: selectedTrack,
|
|
121
127
|
},
|
|
122
128
|
};
|
|
123
129
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import RnSlider from '@react-native-community/slider';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
4
4
|
import { useTheme } from '../../theme';
|
|
5
5
|
|
|
@@ -67,6 +67,8 @@ const Slider = ({
|
|
|
67
67
|
}: SingleSliderProps) => {
|
|
68
68
|
const theme = useTheme();
|
|
69
69
|
|
|
70
|
+
const { selectedTrack, thumb, unselectedTrack } = theme.__hd__.slider.colors;
|
|
71
|
+
|
|
70
72
|
return (
|
|
71
73
|
<RnSlider
|
|
72
74
|
minimumValue={minimumValue}
|
|
@@ -77,9 +79,9 @@ const Slider = ({
|
|
|
77
79
|
onSlidingStart={onSlidingStart}
|
|
78
80
|
onSlidingComplete={onSlidingComplete}
|
|
79
81
|
disabled={disabled}
|
|
80
|
-
minimumTrackTintColor={
|
|
81
|
-
thumbTintColor={
|
|
82
|
-
maximumTrackTintColor={
|
|
82
|
+
minimumTrackTintColor={selectedTrack}
|
|
83
|
+
thumbTintColor={thumb}
|
|
84
|
+
maximumTrackTintColor={unselectedTrack}
|
|
83
85
|
style={style}
|
|
84
86
|
testID={testID}
|
|
85
87
|
/>
|
|
@@ -7,8 +7,8 @@ const StyledMarker = styled(View)<{ themeDisabled: boolean }>(
|
|
|
7
7
|
width: theme.__hd__.slider.sizes.markerWidth,
|
|
8
8
|
borderRadius: theme.__hd__.slider.radii.marker,
|
|
9
9
|
backgroundColor: themeDisabled
|
|
10
|
-
? theme.__hd__.slider.colors.
|
|
11
|
-
: theme.__hd__.slider.colors.
|
|
10
|
+
? theme.__hd__.slider.colors.disabledThumb
|
|
11
|
+
: theme.__hd__.slider.colors.thumb,
|
|
12
12
|
...theme.__hd__.slider.shadows.marker,
|
|
13
13
|
})
|
|
14
14
|
);
|
|
@@ -29,7 +29,9 @@ describe('Slider.Range', () => {
|
|
|
29
29
|
'#401960'
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
expect(nativeComponent.props['trackStyle'].backgroundColor).toBe(
|
|
32
|
+
expect(nativeComponent.props['trackStyle'].backgroundColor).toBe(
|
|
33
|
+
'rgba(0,0,0,0.1)'
|
|
34
|
+
);
|
|
33
35
|
|
|
34
36
|
// verify prop
|
|
35
37
|
expect(nativeComponent).toHaveProp('sliderLength', 100);
|
|
@@ -63,10 +65,10 @@ describe('Slider.Range', () => {
|
|
|
63
65
|
const nativeComponent = getByTestId('native-multi-slider');
|
|
64
66
|
|
|
65
67
|
expect(nativeComponent.props['selectedStyle'].backgroundColor).toBe(
|
|
66
|
-
'#
|
|
68
|
+
'#b3a3bf'
|
|
67
69
|
);
|
|
68
70
|
|
|
69
|
-
expect(nativeComponent.props['trackStyle'].backgroundColor).toBe('#
|
|
71
|
+
expect(nativeComponent.props['trackStyle'].backgroundColor).toBe('#999999');
|
|
70
72
|
});
|
|
71
73
|
|
|
72
74
|
it('trigger options', () => {
|
|
@@ -101,7 +103,7 @@ describe('StyledMarker', () => {
|
|
|
101
103
|
it.each`
|
|
102
104
|
themeDisabled | expectedBackgroundColor
|
|
103
105
|
${false} | ${'#401960'}
|
|
104
|
-
${true} | ${'#
|
|
106
|
+
${true} | ${'#b3a3bf'}
|
|
105
107
|
`(
|
|
106
108
|
'renders correctly when disabled is $themeDisabled',
|
|
107
109
|
({ themeDisabled, expectedBackgroundColor }) => {
|
|
@@ -36,7 +36,7 @@ exports[`Slider.Range renders correctly by default 1`] = `
|
|
|
36
36
|
testID="native-multi-slider"
|
|
37
37
|
trackStyle={
|
|
38
38
|
{
|
|
39
|
-
"backgroundColor": "
|
|
39
|
+
"backgroundColor": "rgba(0,0,0,0.1)",
|
|
40
40
|
"height": 4,
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -100,7 +100,8 @@ exports[`Slider.Range renders correctly when disabled is $disabled 1`] = `
|
|
|
100
100
|
onValuesChangeStart={[Function]}
|
|
101
101
|
selectedStyle={
|
|
102
102
|
{
|
|
103
|
-
"backgroundColor": "#
|
|
103
|
+
"backgroundColor": "#b3a3bf",
|
|
104
|
+
"opacity": 1,
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
sliderLength={0}
|
|
@@ -108,8 +109,9 @@ exports[`Slider.Range renders correctly when disabled is $disabled 1`] = `
|
|
|
108
109
|
testID="native-multi-slider"
|
|
109
110
|
trackStyle={
|
|
110
111
|
{
|
|
111
|
-
"backgroundColor": "#
|
|
112
|
+
"backgroundColor": "#999999",
|
|
112
113
|
"height": 4,
|
|
114
|
+
"opacity": 0.1,
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
values={
|
|
@@ -209,7 +211,7 @@ exports[`StyledMarker renders correctly when disabled is true 1`] = `
|
|
|
209
211
|
style={
|
|
210
212
|
[
|
|
211
213
|
{
|
|
212
|
-
"backgroundColor": "#
|
|
214
|
+
"backgroundColor": "#b3a3bf",
|
|
213
215
|
"borderRadius": 999,
|
|
214
216
|
"elevation": 6,
|
|
215
217
|
"height": 24,
|
|
@@ -10,7 +10,7 @@ exports[`Slider renders correctly by default 1`] = `
|
|
|
10
10
|
>
|
|
11
11
|
<Slider
|
|
12
12
|
disabled={false}
|
|
13
|
-
maximumTrackTintColor="
|
|
13
|
+
maximumTrackTintColor="rgba(0,0,0,0.1)"
|
|
14
14
|
maximumValue={1}
|
|
15
15
|
minimumTrackTintColor="#401960"
|
|
16
16
|
minimumValue={0}
|
|
@@ -51,7 +51,7 @@ exports[`Slider renders correctly when disabled 1`] = `
|
|
|
51
51
|
>
|
|
52
52
|
<Slider
|
|
53
53
|
disabled={true}
|
|
54
|
-
maximumTrackTintColor="
|
|
54
|
+
maximumTrackTintColor="rgba(0,0,0,0.1)"
|
|
55
55
|
maximumValue={1}
|
|
56
56
|
minimumTrackTintColor="#401960"
|
|
57
57
|
minimumValue={0}
|
|
@@ -92,7 +92,7 @@ exports[`Slider renders correctly with props 1`] = `
|
|
|
92
92
|
>
|
|
93
93
|
<Slider
|
|
94
94
|
disabled={false}
|
|
95
|
-
maximumTrackTintColor="
|
|
95
|
+
maximumTrackTintColor="rgba(0,0,0,0.1)"
|
|
96
96
|
maximumValue={2}
|
|
97
97
|
minimumTrackTintColor="#401960"
|
|
98
98
|
minimumValue={-1}
|
|
@@ -1281,12 +1281,12 @@ exports[`theme returns correct theme object 1`] = `
|
|
|
1281
1281
|
},
|
|
1282
1282
|
"slider": {
|
|
1283
1283
|
"colors": {
|
|
1284
|
-
"
|
|
1285
|
-
"
|
|
1286
|
-
"
|
|
1287
|
-
"
|
|
1288
|
-
"
|
|
1289
|
-
"
|
|
1284
|
+
"disabledSelectedTrack": "#b3a3bf",
|
|
1285
|
+
"disabledThumb": "#b3a3bf",
|
|
1286
|
+
"disabledUnselectedTrack": "#999999",
|
|
1287
|
+
"selectedTrack": "#401960",
|
|
1288
|
+
"thumb": "#401960",
|
|
1289
|
+
"unselectedTrack": "rgba(0,0,0,0.1)",
|
|
1290
1290
|
},
|
|
1291
1291
|
"radii": {
|
|
1292
1292
|
"marker": 999,
|
|
@@ -1,13 +1,32 @@
|
|
|
1
|
+
import { UNSELECTED_TRACK_OPACITY } from '../../components/Slider/constants';
|
|
2
|
+
import { dimHex, hexToRgba } from '../../utils/helpers';
|
|
1
3
|
import type { GlobalTheme } from '../global';
|
|
2
4
|
|
|
3
5
|
const getSliderTheme = (theme: GlobalTheme) => {
|
|
4
6
|
const colors = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
// Unselected track colors
|
|
8
|
+
unselectedTrack: hexToRgba(
|
|
9
|
+
theme.colors.overlayGlobalSurface,
|
|
10
|
+
UNSELECTED_TRACK_OPACITY
|
|
11
|
+
),
|
|
12
|
+
disabledUnselectedTrack: dimHex(
|
|
13
|
+
theme.colors.overlayGlobalSurface,
|
|
14
|
+
theme.colors.defaultGlobalSurface
|
|
15
|
+
),
|
|
16
|
+
|
|
17
|
+
// Selected track colors
|
|
18
|
+
selectedTrack: theme.colors.primary,
|
|
19
|
+
disabledSelectedTrack: dimHex(
|
|
20
|
+
theme.colors.primary,
|
|
21
|
+
theme.colors.defaultGlobalSurface
|
|
22
|
+
),
|
|
23
|
+
|
|
24
|
+
// Thumb/marker colors
|
|
25
|
+
thumb: theme.colors.primary,
|
|
26
|
+
disabledThumb: dimHex(
|
|
27
|
+
theme.colors.primary,
|
|
28
|
+
theme.colors.defaultGlobalSurface
|
|
29
|
+
),
|
|
11
30
|
};
|
|
12
31
|
|
|
13
32
|
const shadows = {
|