@open-tender/utils 0.0.54 → 0.0.56

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,2 +0,0 @@
1
- export declare const wp: (designWidth: number) => number;
2
- export declare const hp: (designHeight: number) => number;
@@ -1,19 +1 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hp = exports.wp = void 0;
4
- const react_native_responsive_screen_1 = require("react-native-responsive-screen");
5
- // The dimensions of the default designs screen
6
- const DESIGN_SCREEN_WIDTH = 390;
7
- const DESIGN_SCREEN_HEIGHT = 844;
8
- // Calculate the adaptive width given the design screen width dimension.
9
- // To be used for style props like: width, marginHorizontal, fontSize, ...
10
- const wp = (designWidth) => {
11
- return (0, react_native_responsive_screen_1.widthPercentageToDP)((designWidth * 100) / DESIGN_SCREEN_WIDTH);
12
- };
13
- exports.wp = wp;
14
- // Calculate the adaptive height given the design screen height dimension.
15
- // To be used for style props like: height, marginVertical, ...
16
- const hp = (designHeight) => {
17
- return (0, react_native_responsive_screen_1.heightPercentageToDP)((designHeight * 100) / DESIGN_SCREEN_HEIGHT);
18
- };
19
- exports.hp = hp;
@@ -1,18 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hexToRgbA = exports.decorateTheme = exports.pixelsToFloat = exports.pixelsToInt = exports.objRemsToPixels = exports.remsToNumber = exports.remsToPixels = exports.makeLineHeight = void 0;
4
- const platform_1 = require("./platform");
5
4
  const makeLineHeight = (lineHeight, fontSize) => {
6
5
  var _a;
7
6
  const size = parseInt((_a = fontSize === null || fontSize === void 0 ? void 0 : fontSize.replace('px', '')) !== null && _a !== void 0 ? _a : '0');
8
- return `${(0, platform_1.wp)(parseFloat(lineHeight !== null && lineHeight !== void 0 ? lineHeight : '0') * size).toFixed(3)}px`;
7
+ return `${(parseFloat(lineHeight !== null && lineHeight !== void 0 ? lineHeight : '0') * size).toFixed(3)}px`;
9
8
  };
10
9
  exports.makeLineHeight = makeLineHeight;
11
10
  const remsToPixels = (rems, responsive = false) => {
12
11
  if (!rems)
13
12
  return '0';
14
13
  const pixels = parseFloat(rems.replace('rem', '')) * 10;
15
- const adjustedPixels = responsive ? (0, platform_1.wp)(pixels) : pixels;
14
+ const adjustedPixels = responsive ? (pixels) : pixels;
16
15
  const noZeroes = parseFloat(adjustedPixels.toFixed(2)).toString();
17
16
  return noZeroes === '0' ? '0' : `${noZeroes}px`;
18
17
  };
@@ -101,7 +100,7 @@ const makeLabel = (label, lineHeight) => {
101
100
  const lh = parseFloat(lineHeight);
102
101
  return {
103
102
  fontSize: (0, exports.remsToPixels)(label.fontSizeMobile, true),
104
- lineHeight: `${(0, platform_1.wp)(fs * lh)}px`,
103
+ lineHeight: `${(fs * lh)}px`,
105
104
  offset: (0, exports.remsToPixels)(label.offset),
106
105
  padding: `${(0, exports.remsToPixels)(vertical)} ${(0, exports.remsToPixels)(horizontal)}`,
107
106
  top: (0, exports.remsToPixels)(label.top),
@@ -112,7 +111,7 @@ const makeInputs = (inputs) => {
112
111
  const [vertical, horizontal] = inputs.padding.split(' ');
113
112
  const fs = parseFloat(inputs.fontSizeMobile.replace('rem', '')) * 10.0;
114
113
  const lh = parseFloat(inputs.lineHeight);
115
- return Object.assign(Object.assign({}, inputs), { lineHeight: `${(0, platform_1.wp)(fs * lh)}px`, letterSpacing: (0, exports.remsToPixels)(inputs.letterSpacing), fontSize: (0, exports.remsToPixels)(inputs.fontSizeMobile, true), radius: (0, exports.remsToPixels)(inputs.radius), borderWidth: (0, exports.remsToPixels)(inputs.borderWidth), borderWidthApp: (0, exports.remsToPixels)(inputs.borderWidthApp), padding: `${(0, exports.remsToPixels)(vertical)} ${(0, exports.remsToPixels)(horizontal)}`, paddingHorizontal: (0, exports.remsToPixels)(inputs.paddingHorizontal), paddingVertical: (0, exports.remsToPixels)(inputs.paddingVertical), paddingTop: (0, exports.remsToPixels)(inputs.paddingTop), paddingTopActive: (0, exports.remsToPixels)(inputs.paddingTopActive), paddingBottom: (0, exports.remsToPixels)(inputs.paddingBottom), paddingBottomActive: (0, exports.remsToPixels)(inputs.paddingBottomActive), label: makeLabel(inputs.label, inputs.lineHeight) });
114
+ return Object.assign(Object.assign({}, inputs), { lineHeight: `${(fs * lh)}px`, letterSpacing: (0, exports.remsToPixels)(inputs.letterSpacing), fontSize: (0, exports.remsToPixels)(inputs.fontSizeMobile, true), radius: (0, exports.remsToPixels)(inputs.radius), borderWidth: (0, exports.remsToPixels)(inputs.borderWidth), borderWidthApp: (0, exports.remsToPixels)(inputs.borderWidthApp), padding: `${(0, exports.remsToPixels)(vertical)} ${(0, exports.remsToPixels)(horizontal)}`, paddingHorizontal: (0, exports.remsToPixels)(inputs.paddingHorizontal), paddingVertical: (0, exports.remsToPixels)(inputs.paddingVertical), paddingTop: (0, exports.remsToPixels)(inputs.paddingTop), paddingTopActive: (0, exports.remsToPixels)(inputs.paddingTopActive), paddingBottom: (0, exports.remsToPixels)(inputs.paddingBottom), paddingBottomActive: (0, exports.remsToPixels)(inputs.paddingBottomActive), label: makeLabel(inputs.label, inputs.lineHeight) });
116
115
  };
117
116
  const makeCounts = (counts) => {
118
117
  const { alerts, quantity } = counts;
@@ -1,2 +0,0 @@
1
- export declare const wp: (designWidth: number) => number;
2
- export declare const hp: (designHeight: number) => number;
@@ -1,14 +1 @@
1
- import { widthPercentageToDP, heightPercentageToDP, } from 'react-native-responsive-screen';
2
- // The dimensions of the default designs screen
3
- const DESIGN_SCREEN_WIDTH = 390;
4
- const DESIGN_SCREEN_HEIGHT = 844;
5
- // Calculate the adaptive width given the design screen width dimension.
6
- // To be used for style props like: width, marginHorizontal, fontSize, ...
7
- export const wp = (designWidth) => {
8
- return widthPercentageToDP((designWidth * 100) / DESIGN_SCREEN_WIDTH);
9
- };
10
- // Calculate the adaptive height given the design screen height dimension.
11
- // To be used for style props like: height, marginVertical, ...
12
- export const hp = (designHeight) => {
13
- return heightPercentageToDP((designHeight * 100) / DESIGN_SCREEN_HEIGHT);
14
- };
1
+ "use strict";
@@ -1,14 +1,13 @@
1
- import { wp } from './platform';
2
1
  export const makeLineHeight = (lineHeight, fontSize) => {
3
2
  var _a;
4
3
  const size = parseInt((_a = fontSize === null || fontSize === void 0 ? void 0 : fontSize.replace('px', '')) !== null && _a !== void 0 ? _a : '0');
5
- return `${wp(parseFloat(lineHeight !== null && lineHeight !== void 0 ? lineHeight : '0') * size).toFixed(3)}px`;
4
+ return `${(parseFloat(lineHeight !== null && lineHeight !== void 0 ? lineHeight : '0') * size).toFixed(3)}px`;
6
5
  };
7
6
  export const remsToPixels = (rems, responsive = false) => {
8
7
  if (!rems)
9
8
  return '0';
10
9
  const pixels = parseFloat(rems.replace('rem', '')) * 10;
11
- const adjustedPixels = responsive ? wp(pixels) : pixels;
10
+ const adjustedPixels = responsive ? (pixels) : pixels;
12
11
  const noZeroes = parseFloat(adjustedPixels.toFixed(2)).toString();
13
12
  return noZeroes === '0' ? '0' : `${noZeroes}px`;
14
13
  };
@@ -92,7 +91,7 @@ const makeLabel = (label, lineHeight) => {
92
91
  const lh = parseFloat(lineHeight);
93
92
  return {
94
93
  fontSize: remsToPixels(label.fontSizeMobile, true),
95
- lineHeight: `${wp(fs * lh)}px`,
94
+ lineHeight: `${(fs * lh)}px`,
96
95
  offset: remsToPixels(label.offset),
97
96
  padding: `${remsToPixels(vertical)} ${remsToPixels(horizontal)}`,
98
97
  top: remsToPixels(label.top),
@@ -103,7 +102,7 @@ const makeInputs = (inputs) => {
103
102
  const [vertical, horizontal] = inputs.padding.split(' ');
104
103
  const fs = parseFloat(inputs.fontSizeMobile.replace('rem', '')) * 10.0;
105
104
  const lh = parseFloat(inputs.lineHeight);
106
- return Object.assign(Object.assign({}, inputs), { lineHeight: `${wp(fs * lh)}px`, letterSpacing: remsToPixels(inputs.letterSpacing), fontSize: remsToPixels(inputs.fontSizeMobile, true), radius: remsToPixels(inputs.radius), borderWidth: remsToPixels(inputs.borderWidth), borderWidthApp: remsToPixels(inputs.borderWidthApp), padding: `${remsToPixels(vertical)} ${remsToPixels(horizontal)}`, paddingHorizontal: remsToPixels(inputs.paddingHorizontal), paddingVertical: remsToPixels(inputs.paddingVertical), paddingTop: remsToPixels(inputs.paddingTop), paddingTopActive: remsToPixels(inputs.paddingTopActive), paddingBottom: remsToPixels(inputs.paddingBottom), paddingBottomActive: remsToPixels(inputs.paddingBottomActive), label: makeLabel(inputs.label, inputs.lineHeight) });
105
+ return Object.assign(Object.assign({}, inputs), { lineHeight: `${(fs * lh)}px`, letterSpacing: remsToPixels(inputs.letterSpacing), fontSize: remsToPixels(inputs.fontSizeMobile, true), radius: remsToPixels(inputs.radius), borderWidth: remsToPixels(inputs.borderWidth), borderWidthApp: remsToPixels(inputs.borderWidthApp), padding: `${remsToPixels(vertical)} ${remsToPixels(horizontal)}`, paddingHorizontal: remsToPixels(inputs.paddingHorizontal), paddingVertical: remsToPixels(inputs.paddingVertical), paddingTop: remsToPixels(inputs.paddingTop), paddingTopActive: remsToPixels(inputs.paddingTopActive), paddingBottom: remsToPixels(inputs.paddingBottom), paddingBottomActive: remsToPixels(inputs.paddingBottomActive), label: makeLabel(inputs.label, inputs.lineHeight) });
107
106
  };
108
107
  const makeCounts = (counts) => {
109
108
  const { alerts, quantity } = counts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -34,9 +34,9 @@
34
34
  "license": "MIT",
35
35
  "private": false,
36
36
  "devDependencies": {
37
- "@open-tender/cloud": "^0.0.79",
38
37
  "@babel/core": "^7.19.1",
39
38
  "@emotion/react": "^11.10.4",
39
+ "@open-tender/cloud": "^0.0.79",
40
40
  "@reduxjs/toolkit": "^1.8.5",
41
41
  "@types/react": "^18.0.18",
42
42
  "@types/react-dom": "^18.0.6",
@@ -54,14 +54,13 @@
54
54
  "typescript": "^4.8.2"
55
55
  },
56
56
  "peerDependencies": {
57
+ "@open-tender/cloud": "^0.0.79",
57
58
  "@reduxjs/toolkit": "^1.8.5",
58
- "react": "^18.2.0",
59
- "@open-tender/cloud": "^0.0.79"
59
+ "react": "^18.2.0"
60
60
  },
61
61
  "dependencies": {
62
- "@open-tender/types": "^0.0.127",
62
+ "@open-tender/types": "^0.0.128",
63
63
  "date-fns": "^2.29.3",
64
- "date-fns-tz": "^1.3.7",
65
- "react-native-responsive-screen": "^1.4.2"
64
+ "date-fns-tz": "^1.3.7"
66
65
  }
67
66
  }