meemup-library 1.1.78 → 1.1.79
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.
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* کلاس ColorController برای مدیریت رنگها و تولید رنگ متن بر اساس رنگ پس زمینه استفاده میشود.
|
|
3
|
+
*/
|
|
4
|
+
declare class ColorController {
|
|
5
|
+
/**
|
|
6
|
+
* متد generateContrastColorForHex برای تولید رنگ متن بر اساس رنگ پس زمینه به صورت hex استفاده میشود.
|
|
7
|
+
* @param background_color رنگ پس زمینه به صورت hex (#RRGGBB).
|
|
8
|
+
* @returns رنگ متن متناسب (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
|
|
9
|
+
*/
|
|
10
|
+
generateContrastColorForHex(background_color: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* متد generateContrastColorForRgba برای تولید رنگ متن بر اساس رنگ پس زمینه به صورت RGBA استفاده میشود.
|
|
13
|
+
* @param rgba_color رنگ پس زمینه به صورت RGBA (رنگ، سبز، آبی، شفافیت).
|
|
14
|
+
* @returns رنگ متن متناسب (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
|
|
15
|
+
*/
|
|
16
|
+
generateContrastColorForRgba(rgba_color: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* متد generateContrastColorForRgb برای تولید رنگ متن بر اساس رنگ پس زمینه به صورت RGB استفاده میشود.
|
|
19
|
+
* @param rgb_color رنگ پس زمینه به صورت RGB (رنگ، سبز، آبی).
|
|
20
|
+
* @returns رنگ متن متناسب (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
|
|
21
|
+
*/
|
|
22
|
+
generateContrastColorForRgb(rgb_color: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* متد generateContrastColorForBackground برای تولید رنگ متن بر اساس رنگ پس زمینه مورد نظر استفاده میشود.
|
|
25
|
+
* اگر رنگ پس زمینه null یا "transparent" باشد، رنگ متن #000000 (سیاه) برگردانده میشود.
|
|
26
|
+
* در غیر این صورت، از سه متد generateContrastColorForRgb و generateContrastColorForRgba و generateContrastColorForHex برای تولید رنگ متن استفاده میشود.
|
|
27
|
+
* اگر در هیچکدام از سه متد مورد نظر نگنجید، رنگ متن #000000 (سیاه) برگردانده میشود.
|
|
28
|
+
* @param background_color رنگ پس زمینه به هر فرمتی که میتواند string یا null باشد.
|
|
29
|
+
* @returns رنگ متن متناظر (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
|
|
30
|
+
*/
|
|
31
|
+
generateContrastColorForBackground(background_color: string | null, default_text_color?: string): string;
|
|
32
|
+
}
|
|
33
|
+
declare const _default: ColorController;
|
|
34
|
+
export default _default;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* کلاس ColorController برای مدیریت رنگها و تولید رنگ متن بر اساس رنگ پس زمینه استفاده میشود.
|
|
3
|
+
*/
|
|
4
|
+
class ColorController {
|
|
5
|
+
/**
|
|
6
|
+
* متد generateContrastColorForHex برای تولید رنگ متن بر اساس رنگ پس زمینه به صورت hex استفاده میشود.
|
|
7
|
+
* @param background_color رنگ پس زمینه به صورت hex (#RRGGBB).
|
|
8
|
+
* @returns رنگ متن متناسب (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
|
|
9
|
+
*/
|
|
10
|
+
generateContrastColorForHex(background_color) {
|
|
11
|
+
// تبدیل رنگ پس زمینه به عددی
|
|
12
|
+
background_color = background_color.replace("#", "");
|
|
13
|
+
const r = parseInt(background_color.substring(0, 2), 16);
|
|
14
|
+
const g = parseInt(background_color.substring(2, 4), 16);
|
|
15
|
+
const b = parseInt(background_color.substring(4, 6), 16);
|
|
16
|
+
// محاسبه میانگین مقادیر RGB
|
|
17
|
+
const avg_color = (r + g + b) / 3;
|
|
18
|
+
// انتخاب رنگ متن بر اساس میانگین رنگ پس زمینه
|
|
19
|
+
const text_color = avg_color > 127 ? "#000000" : "#FFFFFF"; // اگر میانگین بیشتر از نیمهی راه بین 0 و 255 باشد، متن رنگ سیاه خواهد بود
|
|
20
|
+
return text_color;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* متد generateContrastColorForRgba برای تولید رنگ متن بر اساس رنگ پس زمینه به صورت RGBA استفاده میشود.
|
|
24
|
+
* @param rgba_color رنگ پس زمینه به صورت RGBA (رنگ، سبز، آبی، شفافیت).
|
|
25
|
+
* @returns رنگ متن متناسب (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
|
|
26
|
+
*/
|
|
27
|
+
generateContrastColorForRgba(rgba_color) {
|
|
28
|
+
var _a;
|
|
29
|
+
// استخراج مقادیر R، G، B از RGBA
|
|
30
|
+
const rgba_values = ((_a = rgba_color.match(/\d+(\.\d+)?/g)) === null || _a === void 0 ? void 0 : _a.map(Number)) || [];
|
|
31
|
+
const r = rgba_values[0] || 0;
|
|
32
|
+
const g = rgba_values[1] || 0;
|
|
33
|
+
const b = rgba_values[2] || 0;
|
|
34
|
+
// محاسبه میانگین مقادیر RGB
|
|
35
|
+
const avg_color = (r + g + b) / 3;
|
|
36
|
+
// انتخاب رنگ متن بر اساس میانگین رنگ پس زمینه
|
|
37
|
+
const text_color = avg_color > 127 ? "#000000" : "#FFFFFF"; // اگر میانگین بیشتر از نیمهی راه بین 0 و 255 باشد، متن رنگ سیاه خواهد بود
|
|
38
|
+
return text_color;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* متد generateContrastColorForRgb برای تولید رنگ متن بر اساس رنگ پس زمینه به صورت RGB استفاده میشود.
|
|
42
|
+
* @param rgb_color رنگ پس زمینه به صورت RGB (رنگ، سبز، آبی).
|
|
43
|
+
* @returns رنگ متن متناسب (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
|
|
44
|
+
*/
|
|
45
|
+
generateContrastColorForRgb(rgb_color) {
|
|
46
|
+
var _a;
|
|
47
|
+
// استخراج مقادیر R، G، B از رشته RGB
|
|
48
|
+
const rgb_values = ((_a = rgb_color.match(/\d+(\.\d+)?/g)) === null || _a === void 0 ? void 0 : _a.map(Number)) || [];
|
|
49
|
+
const r = rgb_values[0] || 0;
|
|
50
|
+
const g = rgb_values[1] || 0;
|
|
51
|
+
const b = rgb_values[2] || 0;
|
|
52
|
+
// محاسبه میانگین مقادیر RGB
|
|
53
|
+
const avg_color = (r + g + b) / 3;
|
|
54
|
+
// انتخاب رنگ متن بر اساس میانگین رنگ پس زمینه
|
|
55
|
+
const text_color = avg_color > 127 ? "#000000" : "#FFFFFF"; // اگر میانگین بیشتر از نیمهی راه بین 0 و 255 باشد، متن رنگ سیاه خواهد بود
|
|
56
|
+
return text_color;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* متد generateContrastColorForBackground برای تولید رنگ متن بر اساس رنگ پس زمینه مورد نظر استفاده میشود.
|
|
60
|
+
* اگر رنگ پس زمینه null یا "transparent" باشد، رنگ متن #000000 (سیاه) برگردانده میشود.
|
|
61
|
+
* در غیر این صورت، از سه متد generateContrastColorForRgb و generateContrastColorForRgba و generateContrastColorForHex برای تولید رنگ متن استفاده میشود.
|
|
62
|
+
* اگر در هیچکدام از سه متد مورد نظر نگنجید، رنگ متن #000000 (سیاه) برگردانده میشود.
|
|
63
|
+
* @param background_color رنگ پس زمینه به هر فرمتی که میتواند string یا null باشد.
|
|
64
|
+
* @returns رنگ متن متناظر (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
|
|
65
|
+
*/
|
|
66
|
+
generateContrastColorForBackground(background_color, default_text_color = "#000") {
|
|
67
|
+
// اگر رنگ پس زمینه null یا "transparent" باشد، رنگ سیاه را برگردانید
|
|
68
|
+
if (background_color === null || background_color.trim().toLowerCase() === "transparent") {
|
|
69
|
+
return default_text_color;
|
|
70
|
+
}
|
|
71
|
+
// استفاده از متد generateContrastColorForHex برای رنگهای HEX
|
|
72
|
+
if (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i.test(background_color.trim())) {
|
|
73
|
+
return this.generateContrastColorForHex(background_color);
|
|
74
|
+
}
|
|
75
|
+
// استفاده از متد generateContrastColorForRgb برای رنگهای RGB
|
|
76
|
+
if (/^rgb\(/i.test(background_color)) {
|
|
77
|
+
return this.generateContrastColorForRgb(background_color);
|
|
78
|
+
}
|
|
79
|
+
// استفاده از متد generateContrastColorForRgba برای رنگهای RGBA
|
|
80
|
+
if (/^rgba\(/i.test(background_color)) {
|
|
81
|
+
return this.generateContrastColorForRgba(background_color);
|
|
82
|
+
}
|
|
83
|
+
// اگر هیچکدام از فرمتهای بالا نبود، رنگ سیاه را برگردانید
|
|
84
|
+
return default_text_color;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export default new ColorController();
|
|
@@ -37,5 +37,8 @@ export default interface IPointOfSaleSetting {
|
|
|
37
37
|
availablePaymentTypes: number[];
|
|
38
38
|
customerMandatoryType: number;
|
|
39
39
|
startingOrderNumberFrom: number;
|
|
40
|
+
additionalPickupInstructions: boolean;
|
|
41
|
+
coloredTiles: boolean;
|
|
42
|
+
displayImages: boolean;
|
|
40
43
|
}
|
|
41
44
|
export declare const initPointOfSaleSetting: IPointOfSaleSetting;
|