pixel-react-excel-sheet 1.0.2 → 1.0.3
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/lib/index.js
CHANGED
|
@@ -47734,6 +47734,19 @@ function applyUnderlineToCells(currentData, selectedRange) {
|
|
|
47734
47734
|
}
|
|
47735
47735
|
return updatedData;
|
|
47736
47736
|
}
|
|
47737
|
+
function isValidHexColor(color) {
|
|
47738
|
+
if (color.length !== 6) {
|
|
47739
|
+
return false;
|
|
47740
|
+
}
|
|
47741
|
+
const hexChars = '0123456789ABCDEFabcdef';
|
|
47742
|
+
for (let i = 1; i < color.length; i++) {
|
|
47743
|
+
console.log(typeof color[i]);
|
|
47744
|
+
if (!hexChars.includes(color[i])) {
|
|
47745
|
+
return false;
|
|
47746
|
+
}
|
|
47747
|
+
}
|
|
47748
|
+
return true;
|
|
47749
|
+
}
|
|
47737
47750
|
function applyColorToCells(currentData, selectedRange, color) {
|
|
47738
47751
|
if (!selectedRange) {
|
|
47739
47752
|
return currentData;
|
|
@@ -47743,8 +47756,8 @@ function applyColorToCells(currentData, selectedRange, color) {
|
|
|
47743
47756
|
end
|
|
47744
47757
|
} = selectedRange;
|
|
47745
47758
|
let updatedData = currentData;
|
|
47746
|
-
const
|
|
47747
|
-
const applyColor =
|
|
47759
|
+
const isHex = isValidHexColor(color);
|
|
47760
|
+
const applyColor = isHex ? `#${color}` : color;
|
|
47748
47761
|
for (let row = start.row; row <= end.row; row++) {
|
|
47749
47762
|
for (let col = start.column; col <= end.column; col++) {
|
|
47750
47763
|
const currentCell = get({
|
|
@@ -47776,6 +47789,8 @@ function applyBackgroundColorToCells(currentData, selectedRange, backgroundColor
|
|
|
47776
47789
|
end
|
|
47777
47790
|
} = selectedRange;
|
|
47778
47791
|
let updatedData = currentData;
|
|
47792
|
+
const isHex = isValidHexColor(backgroundColor);
|
|
47793
|
+
const applyColor = isHex ? `#${backgroundColor}` : backgroundColor;
|
|
47779
47794
|
for (let row = start.row; row <= end.row; row++) {
|
|
47780
47795
|
for (let col = start.column; col <= end.column; col++) {
|
|
47781
47796
|
const currentCell = get({
|
|
@@ -47785,12 +47800,11 @@ function applyBackgroundColorToCells(currentData, selectedRange, backgroundColor
|
|
|
47785
47800
|
if (!currentCell) {
|
|
47786
47801
|
continue;
|
|
47787
47802
|
}
|
|
47788
|
-
let HexCode = backgroundColor.length === 6;
|
|
47789
47803
|
const updatedCell = {
|
|
47790
47804
|
...currentCell,
|
|
47791
47805
|
style: {
|
|
47792
47806
|
...currentCell.style,
|
|
47793
|
-
backgroundColor:
|
|
47807
|
+
backgroundColor: applyColor
|
|
47794
47808
|
}
|
|
47795
47809
|
};
|
|
47796
47810
|
updatedData = set({
|
|
@@ -49663,7 +49677,7 @@ const ExcelToolBar = ({
|
|
|
49663
49677
|
const getTextColor = color => {
|
|
49664
49678
|
setColorPicker(prev => ({
|
|
49665
49679
|
...prev,
|
|
49666
|
-
color
|
|
49680
|
+
color: color
|
|
49667
49681
|
}));
|
|
49668
49682
|
};
|
|
49669
49683
|
const getBackgroundColor = color => {
|
|
@@ -49674,6 +49688,7 @@ const ExcelToolBar = ({
|
|
|
49674
49688
|
};
|
|
49675
49689
|
React.useEffect(() => {
|
|
49676
49690
|
let timeGap = setTimeout(() => {
|
|
49691
|
+
console.log(colorContainer.color);
|
|
49677
49692
|
setColor(data, colorContainer.color);
|
|
49678
49693
|
}, 0);
|
|
49679
49694
|
return () => {
|