@open-tender/store 0.3.50 → 0.3.52

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.
@@ -21,6 +21,9 @@ export interface PrepStation {
21
21
  expo_reset: boolean;
22
22
  expo_complete: boolean;
23
23
  expo_complete_all: boolean;
24
+ show_modifiers: boolean;
25
+ show_groups: boolean;
26
+ show_counts: boolean;
24
27
  }
25
28
  export declare type PrepStations = PrepStation[];
26
29
  export interface KdsTerminal {
@@ -27,3 +27,5 @@ export declare const handleRespError: (err: RequestErrorAPI | string) => {
27
27
  };
28
28
  err: RequestErrorAPI;
29
29
  };
30
+ export declare const hexToRgb: (hex: string) => number[];
31
+ export declare const makeContrastColor: (textColors: Record<string, string>, backgroundColor: string | null) => string | null;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleRespError = exports.pixelsToInt = exports.remsToInt = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.capitalize = exports.serialize = exports.convertStringToArray = exports.getHeight = exports.getWidth = exports.makeRandomNumberString = exports.contains = exports.isEmpty = void 0;
3
+ exports.makeContrastColor = exports.hexToRgb = exports.handleRespError = exports.pixelsToInt = exports.remsToInt = exports.formatDollars = exports.formatQuantity = exports.addCommas = exports.capitalize = exports.serialize = exports.convertStringToArray = exports.getHeight = exports.getWidth = exports.makeRandomNumberString = exports.contains = exports.isEmpty = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var isEmpty = function (obj) {
6
6
  return (!obj || (obj.constructor === Object && Object.entries(obj).length === 0));
@@ -107,3 +107,26 @@ var handleRespError = function (err) {
107
107
  return { title: title, detail: detail, messages: messages, errors: errors, err: err };
108
108
  };
109
109
  exports.handleRespError = handleRespError;
110
+ var hexToRgb = function (hex) {
111
+ var clean = hex.replace('#', '');
112
+ var r = parseInt(clean.slice(0, 2), 16);
113
+ var g = parseInt(clean.slice(2, 4), 16);
114
+ var b = parseInt(clean.slice(4), 16);
115
+ return [r, g, b];
116
+ };
117
+ exports.hexToRgb = hexToRgb;
118
+ var setForegroundColor = function (rgb) {
119
+ var sum = Math.round((parseInt(rgb[0].toString()) * 299 +
120
+ parseInt(rgb[1].toString()) * 587 +
121
+ parseInt(rgb[2].toString()) * 114) /
122
+ 1000);
123
+ return sum > 128 ? 'black' : 'white';
124
+ };
125
+ var makeContrastColor = function (textColors, backgroundColor) {
126
+ if (!backgroundColor)
127
+ return null;
128
+ var rgb = (0, exports.hexToRgb)(backgroundColor);
129
+ var foregroundColor = setForegroundColor(rgb);
130
+ return textColors[foregroundColor];
131
+ };
132
+ exports.makeContrastColor = makeContrastColor;
@@ -21,6 +21,9 @@ export interface PrepStation {
21
21
  expo_reset: boolean;
22
22
  expo_complete: boolean;
23
23
  expo_complete_all: boolean;
24
+ show_modifiers: boolean;
25
+ show_groups: boolean;
26
+ show_counts: boolean;
24
27
  }
25
28
  export declare type PrepStations = PrepStation[];
26
29
  export interface KdsTerminal {
@@ -27,3 +27,5 @@ export declare const handleRespError: (err: RequestErrorAPI | string) => {
27
27
  };
28
28
  err: RequestErrorAPI;
29
29
  };
30
+ export declare const hexToRgb: (hex: string) => number[];
31
+ export declare const makeContrastColor: (textColors: Record<string, string>, backgroundColor: string | null) => string | null;
@@ -90,3 +90,24 @@ export var handleRespError = function (err) {
90
90
  }
91
91
  return { title: title, detail: detail, messages: messages, errors: errors, err: err };
92
92
  };
93
+ export var hexToRgb = function (hex) {
94
+ var clean = hex.replace('#', '');
95
+ var r = parseInt(clean.slice(0, 2), 16);
96
+ var g = parseInt(clean.slice(2, 4), 16);
97
+ var b = parseInt(clean.slice(4), 16);
98
+ return [r, g, b];
99
+ };
100
+ var setForegroundColor = function (rgb) {
101
+ var sum = Math.round((parseInt(rgb[0].toString()) * 299 +
102
+ parseInt(rgb[1].toString()) * 587 +
103
+ parseInt(rgb[2].toString()) * 114) /
104
+ 1000);
105
+ return sum > 128 ? 'black' : 'white';
106
+ };
107
+ export var makeContrastColor = function (textColors, backgroundColor) {
108
+ if (!backgroundColor)
109
+ return null;
110
+ var rgb = hexToRgb(backgroundColor);
111
+ var foregroundColor = setForegroundColor(rgb);
112
+ return textColors[foregroundColor];
113
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "0.3.50",
3
+ "version": "0.3.52",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",