@ppg_pl/tinting 0.0.1 → 0.0.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.
@@ -6503,7 +6503,7 @@ const Modal = class {
6503
6503
  }
6504
6504
  };
6505
6505
  this.chunks = (xs, y = []) => {
6506
- return xs.length === 0 ? y : this.chunks(xs.slice(this.chunksNum), y.concat([xs.slice(0, this.chunksNum)]));
6506
+ return (xs === null || xs === void 0 ? void 0 : xs.length) === 0 ? y : this.chunks(xs === null || xs === void 0 ? void 0 : xs.slice(this.chunksNum), y.concat([xs === null || xs === void 0 ? void 0 : xs.slice(0, this.chunksNum)]));
6507
6507
  };
6508
6508
  this.calculateBoxCount = () => {
6509
6509
  var _a;
@@ -6593,15 +6593,15 @@ const Modal = class {
6593
6593
  this.displayForMobile();
6594
6594
  }
6595
6595
  sortColorsBySimilarity(colors) {
6596
- if (colors.length <= 1)
6596
+ if ((colors === null || colors === void 0 ? void 0 : colors.length) <= 1)
6597
6597
  return colors;
6598
6598
  const sortedColors = [];
6599
6599
  const remainingColors = [...colors];
6600
6600
  // Start with the first color
6601
6601
  sortedColors.push(remainingColors.shift());
6602
- while (remainingColors.length > 0) {
6602
+ while ((remainingColors === null || remainingColors === void 0 ? void 0 : remainingColors.length) > 0) {
6603
6603
  // Find the most similar color to the last color in sortedColors
6604
- const lastColor = sortedColors[sortedColors.length - 1];
6604
+ const lastColor = sortedColors[(sortedColors === null || sortedColors === void 0 ? void 0 : sortedColors.length) - 1];
6605
6605
  let mostSimilarIndex = 0;
6606
6606
  let minDistance = Infinity;
6607
6607
  remainingColors.forEach((color, index) => {
@@ -6617,6 +6617,8 @@ const Modal = class {
6617
6617
  return sortedColors;
6618
6618
  }
6619
6619
  getColorHueGroup(hex) {
6620
+ if (!hex || !chroma.valid(hex))
6621
+ return 'other';
6620
6622
  const color = chroma(hex);
6621
6623
  const hue = color.get('hsl.h');
6622
6624
  const saturation = color.get('hsl.s');
@@ -6645,9 +6647,12 @@ const Modal = class {
6645
6647
  return 'other';
6646
6648
  }
6647
6649
  sortColorsByHueAndSimilarity(colors) {
6648
- if (colors.length <= 1)
6650
+ if ((colors === null || colors === void 0 ? void 0 : colors.length) <= 1)
6649
6651
  return colors;
6650
- // Group colors by their hue family
6652
+ // Separate valid and invalid hex colors
6653
+ const validColors = colors.filter(c => typeof c.hex === 'string' && c.hex && chroma.valid(c.hex));
6654
+ const invalidColors = colors.filter(c => !c.hex || !chroma.valid(c.hex));
6655
+ // Group valid colors by their hue family
6651
6656
  const colorGroups = {
6652
6657
  red: [],
6653
6658
  yellow: [],
@@ -6660,8 +6665,7 @@ const Modal = class {
6660
6665
  white: [],
6661
6666
  other: [],
6662
6667
  };
6663
- // Sort colors into groups
6664
- colors.forEach(color => {
6668
+ validColors.forEach(color => {
6665
6669
  const group = this.getColorHueGroup(color.hex);
6666
6670
  colorGroups[group].push(color);
6667
6671
  });
@@ -6673,11 +6677,11 @@ const Modal = class {
6673
6677
  sortedGroups.push(this.sortColorsBySimilarity(colorGroups[groupName]));
6674
6678
  }
6675
6679
  });
6676
- // Combine all sorted groups
6677
- return sortedGroups.flat();
6680
+ // Combine all sorted groups, then append invalid colors at the end
6681
+ return [...sortedGroups.flat(), ...invalidColors];
6678
6682
  }
6679
6683
  async fetchColorsData({ reset = false } = {}) {
6680
- if (this.loading && !reset)
6684
+ if (this.loading)
6681
6685
  return;
6682
6686
  this.loading = true;
6683
6687
  try {
@@ -6926,7 +6930,7 @@ const MySearch = class {
6926
6930
  };
6927
6931
  MySearch.style = indexCss$2;
6928
6932
 
6929
- const indexCss$1 = "@import url(\"https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1.sc-my-select,300..900&family=Poppins.sc-my-select:ital,wght@0.sc-my-select,100.sc-my-select;0.sc-my-select,200.sc-my-select;0.sc-my-select,300.sc-my-select;0.sc-my-select,400.sc-my-select;0.sc-my-select,500.sc-my-select;0.sc-my-select,600.sc-my-select;0.sc-my-select,700.sc-my-select;0.sc-my-select,800.sc-my-select;0.sc-my-select,900.sc-my-select;1.sc-my-select,100.sc-my-select;1.sc-my-select,200.sc-my-select;1.sc-my-select,300.sc-my-select;1.sc-my-select,400.sc-my-select;1.sc-my-select,500.sc-my-select;1.sc-my-select,600.sc-my-select;1.sc-my-select,700.sc-my-select;1.sc-my-select,800.sc-my-select;1.sc-my-select,900&display=swap\").sc-my-select; .tinting-wrapper.sc-my-select *.sc-my-select{font-family:\"Poppins\", sans-serif}.select.sc-my-select{position:relative;width:300px}@media (max-width: 768px){.select.sc-my-select{width:100%}}.select.sc-my-select .input-wrapper.sc-my-select{position:relative;display:flex;align-items:flex-start}.select.sc-my-select input.sc-my-select{font-size:16px;padding:16px;border-radius:27.35px;border:1px solid #dfdfdf;width:100%;color:#4c4c4c;box-sizing:border-box;padding-right:50px}.select.sc-my-select button.sc-my-select{position:absolute;right:10px;background:transparent;border:none;cursor:pointer;width:40px;height:100%;display:flex;align-items:center;justify-content:center}.select.sc-my-select button.sc-my-select img.sc-my-select{transition:transform 0.3s ease}.select.sc-my-select button.sc-my-select img.rotated.sc-my-select{transform:rotate(180deg)}.select.sc-my-select .dropdown.sc-my-select{position:absolute;top:100%;left:0;width:100%;background:white;border:1px solid #dfdfdf;border-radius:5px;max-height:200px;overflow-y:auto;z-index:1000;padding:0;margin:0}.select.sc-my-select .dropdown.sc-my-select li.sc-my-select{padding:0;margin:0;padding:10px;cursor:pointer;list-style:none;text-align:left}.select.sc-my-select .dropdown.sc-my-select li.sc-my-select:hover{background:#f5f5f5}.select.sc-my-select .dropdown.sc-my-select .no-results.sc-my-select{padding:10px;text-align:center;color:#999}";
6933
+ const indexCss$1 = "@import url(\"https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1.sc-my-select,300..900&family=Poppins.sc-my-select:ital,wght@0.sc-my-select,100.sc-my-select;0.sc-my-select,200.sc-my-select;0.sc-my-select,300.sc-my-select;0.sc-my-select,400.sc-my-select;0.sc-my-select,500.sc-my-select;0.sc-my-select,600.sc-my-select;0.sc-my-select,700.sc-my-select;0.sc-my-select,800.sc-my-select;0.sc-my-select,900.sc-my-select;1.sc-my-select,100.sc-my-select;1.sc-my-select,200.sc-my-select;1.sc-my-select,300.sc-my-select;1.sc-my-select,400.sc-my-select;1.sc-my-select,500.sc-my-select;1.sc-my-select,600.sc-my-select;1.sc-my-select,700.sc-my-select;1.sc-my-select,800.sc-my-select;1.sc-my-select,900&display=swap\").sc-my-select; .tinting-wrapper.sc-my-select *.sc-my-select{font-family:\"Poppins\", sans-serif}.select.sc-my-select{position:relative;width:300px}@media (max-width: 768px){.select.sc-my-select{width:100%}}.select.sc-my-select .input-wrapper.sc-my-select{position:relative;display:flex;align-items:flex-start}.select.sc-my-select input.sc-my-select{font-size:16px;padding:16px;border-radius:27.35px;border:1px solid #dfdfdf;width:100%;color:#4c4c4c;box-sizing:border-box;padding-right:50px}.select.sc-my-select button.sc-my-select{position:absolute;right:10px;background:transparent;border:none;cursor:pointer;width:40px;height:100%;display:flex;align-items:center;justify-content:center}.select.sc-my-select button.sc-my-select img.sc-my-select{transition:transform 0.3s ease}.select.sc-my-select button.sc-my-select img.rotated.sc-my-select{transform:rotate(180deg)}.select.sc-my-select .dropdown.sc-my-select{position:absolute;top:100%;left:0;width:100%;background:white;border:1px solid #dfdfdf;border-radius:5px;max-height:200px;overflow-y:auto;z-index:1000;padding:0;margin:0}.select.sc-my-select .dropdown.sc-my-select li.sc-my-select{padding:0;margin:0;padding:10px;cursor:pointer;list-style:none;text-align:left}.select.sc-my-select .dropdown.sc-my-select li.sc-my-select:hover{background:#f5f5f5}.select.sc-my-select .dropdown.sc-my-select .no-results.sc-my-select{padding:10px;text-align:center;color:#999}@media (max-width: 768px){.select.sc-my-select .dropdown.sc-my-select{position:relative}}";
6930
6934
 
6931
6935
  const MySelect = class {
6932
6936
  constructor(hostRef) {