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.esm.js CHANGED
@@ -47714,6 +47714,19 @@ function applyUnderlineToCells(currentData, selectedRange) {
47714
47714
  }
47715
47715
  return updatedData;
47716
47716
  }
47717
+ function isValidHexColor(color) {
47718
+ if (color.length !== 6) {
47719
+ return false;
47720
+ }
47721
+ const hexChars = '0123456789ABCDEFabcdef';
47722
+ for (let i = 1; i < color.length; i++) {
47723
+ console.log(typeof color[i]);
47724
+ if (!hexChars.includes(color[i])) {
47725
+ return false;
47726
+ }
47727
+ }
47728
+ return true;
47729
+ }
47717
47730
  function applyColorToCells(currentData, selectedRange, color) {
47718
47731
  if (!selectedRange) {
47719
47732
  return currentData;
@@ -47723,8 +47736,8 @@ function applyColorToCells(currentData, selectedRange, color) {
47723
47736
  end
47724
47737
  } = selectedRange;
47725
47738
  let updatedData = currentData;
47726
- const isHexColor = color => /^#[0-9A-Fa-f]{6}$/i.test(color);
47727
- const applyColor = isHexColor(color) ? `#${color}` : color;
47739
+ const isHex = isValidHexColor(color);
47740
+ const applyColor = isHex ? `#${color}` : color;
47728
47741
  for (let row = start.row; row <= end.row; row++) {
47729
47742
  for (let col = start.column; col <= end.column; col++) {
47730
47743
  const currentCell = get({
@@ -47756,6 +47769,8 @@ function applyBackgroundColorToCells(currentData, selectedRange, backgroundColor
47756
47769
  end
47757
47770
  } = selectedRange;
47758
47771
  let updatedData = currentData;
47772
+ const isHex = isValidHexColor(backgroundColor);
47773
+ const applyColor = isHex ? `#${backgroundColor}` : backgroundColor;
47759
47774
  for (let row = start.row; row <= end.row; row++) {
47760
47775
  for (let col = start.column; col <= end.column; col++) {
47761
47776
  const currentCell = get({
@@ -47765,12 +47780,11 @@ function applyBackgroundColorToCells(currentData, selectedRange, backgroundColor
47765
47780
  if (!currentCell) {
47766
47781
  continue;
47767
47782
  }
47768
- let HexCode = backgroundColor.length === 6;
47769
47783
  const updatedCell = {
47770
47784
  ...currentCell,
47771
47785
  style: {
47772
47786
  ...currentCell.style,
47773
- backgroundColor: HexCode ? `#${backgroundColor}` : backgroundColor
47787
+ backgroundColor: applyColor
47774
47788
  }
47775
47789
  };
47776
47790
  updatedData = set({
@@ -49643,7 +49657,7 @@ const ExcelToolBar = ({
49643
49657
  const getTextColor = color => {
49644
49658
  setColorPicker(prev => ({
49645
49659
  ...prev,
49646
- color
49660
+ color: color
49647
49661
  }));
49648
49662
  };
49649
49663
  const getBackgroundColor = color => {
@@ -49654,6 +49668,7 @@ const ExcelToolBar = ({
49654
49668
  };
49655
49669
  useEffect(() => {
49656
49670
  let timeGap = setTimeout(() => {
49671
+ console.log(colorContainer.color);
49657
49672
  setColor(data, colorContainer.color);
49658
49673
  }, 0);
49659
49674
  return () => {