@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
|
@@ -2565,10 +2565,21 @@ const fetchColors = async (filters) => {
|
|
|
2565
2565
|
return [];
|
|
2566
2566
|
}
|
|
2567
2567
|
};
|
|
2568
|
+
const getSampleSortForProduct = (sample, productId) => {
|
|
2569
|
+
var _a, _b;
|
|
2570
|
+
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);
|
|
2571
|
+
// put null/undefined at the end
|
|
2572
|
+
return (_b = link === null || link === void 0 ? void 0 : link.sort) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY;
|
|
2573
|
+
};
|
|
2568
2574
|
const fetchSamplesColors = async (filters) => {
|
|
2569
2575
|
try {
|
|
2576
|
+
// you already include Products.* in the query
|
|
2577
|
+
const { id: productId } = filters;
|
|
2570
2578
|
const response = await ApiService.getData(`items/Sample?${fetchColorsQuery(Object.assign({}, filters))}`);
|
|
2571
|
-
|
|
2579
|
+
const data = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
2580
|
+
// order by junction sort
|
|
2581
|
+
const ordered = [...data].sort((a, b) => getSampleSortForProduct(a, productId) - getSampleSortForProduct(b, productId));
|
|
2582
|
+
return ordered;
|
|
2572
2583
|
}
|
|
2573
2584
|
catch (error) {
|
|
2574
2585
|
console.error('Error fetching samples colors:', error);
|
|
@@ -6613,8 +6624,6 @@ const Modal = class {
|
|
|
6613
6624
|
return sortedColors;
|
|
6614
6625
|
}
|
|
6615
6626
|
getColorHueGroup(hex) {
|
|
6616
|
-
if (!hex || !chroma.valid(hex))
|
|
6617
|
-
return 'other';
|
|
6618
6627
|
const color = chroma(hex);
|
|
6619
6628
|
const hue = color.get('hsl.h');
|
|
6620
6629
|
const saturation = color.get('hsl.s');
|
|
@@ -6645,9 +6654,6 @@ const Modal = class {
|
|
|
6645
6654
|
sortColorsByHueAndSimilarity(colors) {
|
|
6646
6655
|
if ((colors === null || colors === void 0 ? void 0 : colors.length) <= 1)
|
|
6647
6656
|
return colors;
|
|
6648
|
-
// Separate valid and invalid hex colors
|
|
6649
|
-
const validColors = colors.filter(c => typeof c.hex === 'string' && c.hex && chroma.valid(c.hex));
|
|
6650
|
-
const invalidColors = colors.filter(c => !c.hex || !chroma.valid(c.hex));
|
|
6651
6657
|
// Group valid colors by their hue family
|
|
6652
6658
|
const colorGroups = {
|
|
6653
6659
|
red: [],
|
|
@@ -6661,7 +6667,7 @@ const Modal = class {
|
|
|
6661
6667
|
white: [],
|
|
6662
6668
|
other: [],
|
|
6663
6669
|
};
|
|
6664
|
-
|
|
6670
|
+
colors.forEach(color => {
|
|
6665
6671
|
const group = this.getColorHueGroup(color.hex);
|
|
6666
6672
|
colorGroups[group].push(color);
|
|
6667
6673
|
});
|
|
@@ -6674,10 +6680,10 @@ const Modal = class {
|
|
|
6674
6680
|
}
|
|
6675
6681
|
});
|
|
6676
6682
|
// Combine all sorted groups, then append invalid colors at the end
|
|
6677
|
-
return
|
|
6683
|
+
return sortedGroups.flat();
|
|
6678
6684
|
}
|
|
6679
6685
|
async fetchColorsData({ reset = false } = {}) {
|
|
6680
|
-
if (this.loading)
|
|
6686
|
+
if (this.loading && !reset)
|
|
6681
6687
|
return;
|
|
6682
6688
|
this.loading = true;
|
|
6683
6689
|
try {
|