@ppg_pl/tinting 0.0.2 → 0.0.4
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/dist/cjs/modal-header_9.cjs.entry.js +15 -9
- package/dist/cjs/modal-header_9.cjs.entry.js.map +1 -1
- package/dist/collection/components/api/services.js +12 -1
- package/dist/collection/components/api/services.js.map +1 -1
- package/dist/collection/components/modal/index.js +3 -8
- package/dist/collection/components/modal/index.js.map +1 -1
- package/dist/components/index10.js +3 -8
- package/dist/components/index10.js.map +1 -1
- package/dist/components/index2.js +12 -1
- package/dist/components/index2.js.map +1 -1
- package/dist/esm/modal-header_9.entry.js +15 -9
- package/dist/esm/modal-header_9.entry.js.map +1 -1
- package/dist/tinting/p-d9e19fea.entry.js +15 -0
- package/dist/tinting/p-d9e19fea.entry.js.map +1 -0
- package/dist/tinting/tinting.esm.js +1 -1
- package/dist/types/components/api/services.d.ts +1 -1
- package/package.json +1 -1
- package/www/build/p-d9e19fea.entry.js +15 -0
- package/www/build/p-d9e19fea.entry.js.map +1 -0
- package/www/build/tinting.esm.js +1 -1
- package/dist/tinting/p-cd431d43.entry.js +0 -15
- package/dist/tinting/p-cd431d43.entry.js.map +0 -1
- package/www/build/p-cd431d43.entry.js +0 -15
- package/www/build/p-cd431d43.entry.js.map +0 -1
|
@@ -2569,10 +2569,21 @@ const fetchColors = async (filters) => {
|
|
|
2569
2569
|
return [];
|
|
2570
2570
|
}
|
|
2571
2571
|
};
|
|
2572
|
+
const getSampleSortForProduct = (sample, productId) => {
|
|
2573
|
+
var _a, _b;
|
|
2574
|
+
const link = (_a = sample === null || sample === void 0 ? void 0 : sample.Products) === null || _a === void 0 ? void 0 : _a.find((p) => p.Product_id === productId);
|
|
2575
|
+
// put null/undefined at the end
|
|
2576
|
+
return (_b = link === null || link === void 0 ? void 0 : link.sort) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY;
|
|
2577
|
+
};
|
|
2572
2578
|
const fetchSamplesColors = async (filters) => {
|
|
2573
2579
|
try {
|
|
2580
|
+
// you already include Products.* in the query
|
|
2581
|
+
const { id: productId } = filters;
|
|
2574
2582
|
const response = await ApiService.getData(`items/Sample?${fetchColorsQuery(Object.assign({}, filters))}`);
|
|
2575
|
-
|
|
2583
|
+
const data = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
2584
|
+
// order by junction sort
|
|
2585
|
+
const ordered = [...data].sort((a, b) => getSampleSortForProduct(a, productId) - getSampleSortForProduct(b, productId));
|
|
2586
|
+
return ordered;
|
|
2576
2587
|
}
|
|
2577
2588
|
catch (error) {
|
|
2578
2589
|
console.error('Error fetching samples colors:', error);
|
|
@@ -6617,8 +6628,6 @@ const Modal = class {
|
|
|
6617
6628
|
return sortedColors;
|
|
6618
6629
|
}
|
|
6619
6630
|
getColorHueGroup(hex) {
|
|
6620
|
-
if (!hex || !chroma.valid(hex))
|
|
6621
|
-
return 'other';
|
|
6622
6631
|
const color = chroma(hex);
|
|
6623
6632
|
const hue = color.get('hsl.h');
|
|
6624
6633
|
const saturation = color.get('hsl.s');
|
|
@@ -6649,9 +6658,6 @@ const Modal = class {
|
|
|
6649
6658
|
sortColorsByHueAndSimilarity(colors) {
|
|
6650
6659
|
if ((colors === null || colors === void 0 ? void 0 : colors.length) <= 1)
|
|
6651
6660
|
return colors;
|
|
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
6661
|
// Group valid colors by their hue family
|
|
6656
6662
|
const colorGroups = {
|
|
6657
6663
|
red: [],
|
|
@@ -6665,7 +6671,7 @@ const Modal = class {
|
|
|
6665
6671
|
white: [],
|
|
6666
6672
|
other: [],
|
|
6667
6673
|
};
|
|
6668
|
-
|
|
6674
|
+
colors.forEach(color => {
|
|
6669
6675
|
const group = this.getColorHueGroup(color.hex);
|
|
6670
6676
|
colorGroups[group].push(color);
|
|
6671
6677
|
});
|
|
@@ -6678,10 +6684,10 @@ const Modal = class {
|
|
|
6678
6684
|
}
|
|
6679
6685
|
});
|
|
6680
6686
|
// Combine all sorted groups, then append invalid colors at the end
|
|
6681
|
-
return
|
|
6687
|
+
return sortedGroups.flat();
|
|
6682
6688
|
}
|
|
6683
6689
|
async fetchColorsData({ reset = false } = {}) {
|
|
6684
|
-
if (this.loading)
|
|
6690
|
+
if (this.loading && !reset)
|
|
6685
6691
|
return;
|
|
6686
6692
|
this.loading = true;
|
|
6687
6693
|
try {
|