meemup-library 1.1.82 → 1.1.84

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.
@@ -1,5 +1,5 @@
1
- import IProduct from "..//interfaces/IProduct";
2
1
  import IPointOfSaleSetting from "../interfaces/IPointOfSaleSetting";
2
+ import IDProduct from "../interfaces/database/IDProduct";
3
3
  /**
4
4
  * کلاس ColorController برای مدیریت رنگ‌ها و تولید رنگ متن بر اساس رنگ پس زمینه استفاده می‌شود.
5
5
  */
@@ -31,7 +31,11 @@ declare class ColorController {
31
31
  * @returns رنگ متن متناظر (به صورت hex) که برای نمایش بر روی رنگ پس زمینه انتخاب شده است.
32
32
  */
33
33
  generateContrastColorForBackground(background_color: string | null, default_text_color?: string): string;
34
- generateColorForPosProductOrCategory(product: IProduct, setting: IPointOfSaleSetting, defaultBackgroundColor: any, defaultTextColor: any): {
34
+ generateColorForPosProduct(product: IDProduct, setting: IPointOfSaleSetting, defaultBackgroundColor: any, defaultTextColor: any): {
35
+ backgroundColor: any;
36
+ textColor: any;
37
+ };
38
+ generateColorForPosCategory(color: string | null, setting: IPointOfSaleSetting, defaultBackgroundColor: any, defaultTextColor: any): {
35
39
  backgroundColor: any;
36
40
  textColor: any;
37
41
  };
@@ -83,7 +83,7 @@ class ColorController {
83
83
  // اگر هیچکدام از فرمت‌های بالا نبود، رنگ سیاه را برگردانید
84
84
  return default_text_color;
85
85
  }
86
- generateColorForPosProductOrCategory(product, setting, defaultBackgroundColor, defaultTextColor) {
86
+ generateColorForPosProduct(product, setting, defaultBackgroundColor, defaultTextColor) {
87
87
  let textColor = defaultTextColor;
88
88
  let backgroundColor = defaultBackgroundColor;
89
89
  if (setting.coloredTiles) {
@@ -92,6 +92,15 @@ class ColorController {
92
92
  }
93
93
  return { backgroundColor, textColor };
94
94
  }
95
+ generateColorForPosCategory(color, setting, defaultBackgroundColor, defaultTextColor) {
96
+ let textColor = defaultTextColor;
97
+ let backgroundColor = defaultBackgroundColor;
98
+ if (setting.coloredTiles) {
99
+ textColor = this.generateContrastColorForBackground(color, defaultTextColor);
100
+ backgroundColor = textColor === defaultTextColor ? defaultBackgroundColor : color;
101
+ }
102
+ return { backgroundColor, textColor };
103
+ }
95
104
  rgbaToHexWithAlpha(rgba, defaultColor = '#00000000') {
96
105
  // از regex برای جدا کردن مقادیر RGBA استفاده می‌کنیم
97
106
  const match = rgba.match(/(\d+(\.\d+)?)/g);
@@ -133,7 +142,7 @@ class ColorController {
133
142
  }
134
143
  else {
135
144
  // اگر رشته HEX غیر معتبر باشد
136
- throw new Error('Invalid HEX color format');
145
+ throw defaultColor;
137
146
  }
138
147
  // ایجاد رشته RGBA
139
148
  const rgba = `rgba(${r}, ${g}, ${b}, ${a})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meemup-library",
3
- "version": "1.1.82",
3
+ "version": "1.1.84",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",