@open-tender/utils 0.3.6 → 0.3.7

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,4 +1,4 @@
1
- import { Address, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
1
+ import { Address, GoogleMapsStyles, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
2
2
  export declare const getDistance: (pointA: LatLng, pointB: LatLng, inMiles?: boolean) => number;
3
3
  export declare const inZone: (latLng: LatLng, polygon: number[][]) => boolean;
4
4
  export declare const addDistance: (revenueCenters: RevenueCenters, latLng: LatLng) => RevenueCenters;
@@ -213,3 +213,14 @@ export declare const LOCATIONS_MESSAGES: {
213
213
  };
214
214
  };
215
215
  export declare const renameLocation: (str: string, names: string[]) => string;
216
+ export declare const makeMapStyles: ({ labelColor, roadColor, featureColor, waterColor, backgroundColor }: GoogleMapsStyles) => {
217
+ featureType: string;
218
+ elementType: string;
219
+ stylers: ({
220
+ visibility: string;
221
+ color?: undefined;
222
+ } | {
223
+ color: string;
224
+ visibility?: undefined;
225
+ })[];
226
+ }[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameLocation = exports.LOCATIONS_MESSAGES = exports.makeDisplayedRevenueCenters = exports.makeDeliveryMesssaging = exports.makeWalkinMessaging = exports.makePickupMesssaging = exports.makeDeliveryRevenueCenters = exports.makeWalkinRevenueCenters = exports.makePickupRevenueCenters = exports.checkServiceType = exports.calcMinDistance = exports.sortRevenueCenters = exports.addDistance = exports.inZone = exports.getDistance = void 0;
3
+ exports.makeMapStyles = exports.renameLocation = exports.LOCATIONS_MESSAGES = exports.makeDisplayedRevenueCenters = exports.makeDeliveryMesssaging = exports.makeWalkinMessaging = exports.makePickupMesssaging = exports.makeDeliveryRevenueCenters = exports.makeWalkinRevenueCenters = exports.makePickupRevenueCenters = exports.checkServiceType = exports.calcMinDistance = exports.sortRevenueCenters = exports.addDistance = exports.inZone = exports.getDistance = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const RADIUS_MILES = 3959; // radius of the earth in miles
6
6
  const RADIUS_KM = 6371; // radius of the earth in kilometers
@@ -254,3 +254,81 @@ const renameLocation = (str, names) => {
254
254
  .replace(' a u', ' an u');
255
255
  };
256
256
  exports.renameLocation = renameLocation;
257
+ const makeMapStyles = ({ labelColor, roadColor, featureColor, waterColor, backgroundColor }) => [
258
+ {
259
+ featureType: 'transit',
260
+ elementType: 'all',
261
+ stylers: [{ visibility: 'off' }]
262
+ },
263
+ {
264
+ featureType: 'administrative',
265
+ elementType: 'labels.text.fill',
266
+ stylers: [{ visibility: 'off' }]
267
+ },
268
+ {
269
+ featureType: 'administrative',
270
+ elementType: 'labels.text.stroke',
271
+ stylers: [{ visibility: 'off' }]
272
+ },
273
+ {
274
+ featureType: 'road',
275
+ elementType: 'labels.icon',
276
+ stylers: [{ visibility: 'off' }]
277
+ },
278
+ {
279
+ featureType: 'road',
280
+ elementType: 'geometry',
281
+ stylers: [{ visibility: 'simplified' }, { color: roadColor }]
282
+ },
283
+ {
284
+ featureType: 'road',
285
+ elementType: 'labels.text.fill',
286
+ stylers: [{ color: labelColor }]
287
+ },
288
+ {
289
+ featureType: 'road',
290
+ elementType: 'labels.text.stroke',
291
+ stylers: [{ visibility: 'off' }]
292
+ },
293
+ {
294
+ featureType: 'road.highway',
295
+ elementType: 'geometry',
296
+ stylers: [{ color: featureColor }]
297
+ },
298
+ {
299
+ featureType: 'road.highway',
300
+ elementType: 'labels',
301
+ stylers: [{ visibility: 'off' }]
302
+ },
303
+ {
304
+ featureType: 'water',
305
+ elementType: 'geometry',
306
+ stylers: [{ color: waterColor }]
307
+ },
308
+ {
309
+ featureType: 'water',
310
+ elementType: 'labels',
311
+ stylers: [{ visibility: 'off' }]
312
+ },
313
+ {
314
+ featureType: 'poi',
315
+ elementType: 'geometry',
316
+ stylers: [{ color: backgroundColor }]
317
+ },
318
+ {
319
+ featureType: 'poi',
320
+ elementType: 'labels',
321
+ stylers: [{ visibility: 'off' }]
322
+ },
323
+ {
324
+ featureType: 'landscape',
325
+ elementType: 'geometry',
326
+ stylers: [{ color: backgroundColor }]
327
+ },
328
+ {
329
+ featureType: 'landscape',
330
+ elementType: 'labels',
331
+ stylers: [{ visibility: 'off' }]
332
+ }
333
+ ];
334
+ exports.makeMapStyles = makeMapStyles;
@@ -1,4 +1,4 @@
1
- import { formatPercentage, formatQuantity } from "../../utils";
1
+ import { formatPercentage, formatQuantity } from '../../utils';
2
2
  describe('formatPercentage', () => {
3
3
  it('formats percentage when decimal is undefined', () => {
4
4
  expect(formatPercentage('0')).toBe('0');
@@ -1,4 +1,4 @@
1
- import { Address, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
1
+ import { Address, GoogleMapsStyles, LatLng, RevenueCenter, RevenueCenters, ServiceType } from '@open-tender/types';
2
2
  export declare const getDistance: (pointA: LatLng, pointB: LatLng, inMiles?: boolean) => number;
3
3
  export declare const inZone: (latLng: LatLng, polygon: number[][]) => boolean;
4
4
  export declare const addDistance: (revenueCenters: RevenueCenters, latLng: LatLng) => RevenueCenters;
@@ -213,3 +213,14 @@ export declare const LOCATIONS_MESSAGES: {
213
213
  };
214
214
  };
215
215
  export declare const renameLocation: (str: string, names: string[]) => string;
216
+ export declare const makeMapStyles: ({ labelColor, roadColor, featureColor, waterColor, backgroundColor }: GoogleMapsStyles) => {
217
+ featureType: string;
218
+ elementType: string;
219
+ stylers: ({
220
+ visibility: string;
221
+ color?: undefined;
222
+ } | {
223
+ color: string;
224
+ visibility?: undefined;
225
+ })[];
226
+ }[];
@@ -237,3 +237,80 @@ export const renameLocation = (str, names) => {
237
237
  .replace(' a o', ' an o')
238
238
  .replace(' a u', ' an u');
239
239
  };
240
+ export const makeMapStyles = ({ labelColor, roadColor, featureColor, waterColor, backgroundColor }) => [
241
+ {
242
+ featureType: 'transit',
243
+ elementType: 'all',
244
+ stylers: [{ visibility: 'off' }]
245
+ },
246
+ {
247
+ featureType: 'administrative',
248
+ elementType: 'labels.text.fill',
249
+ stylers: [{ visibility: 'off' }]
250
+ },
251
+ {
252
+ featureType: 'administrative',
253
+ elementType: 'labels.text.stroke',
254
+ stylers: [{ visibility: 'off' }]
255
+ },
256
+ {
257
+ featureType: 'road',
258
+ elementType: 'labels.icon',
259
+ stylers: [{ visibility: 'off' }]
260
+ },
261
+ {
262
+ featureType: 'road',
263
+ elementType: 'geometry',
264
+ stylers: [{ visibility: 'simplified' }, { color: roadColor }]
265
+ },
266
+ {
267
+ featureType: 'road',
268
+ elementType: 'labels.text.fill',
269
+ stylers: [{ color: labelColor }]
270
+ },
271
+ {
272
+ featureType: 'road',
273
+ elementType: 'labels.text.stroke',
274
+ stylers: [{ visibility: 'off' }]
275
+ },
276
+ {
277
+ featureType: 'road.highway',
278
+ elementType: 'geometry',
279
+ stylers: [{ color: featureColor }]
280
+ },
281
+ {
282
+ featureType: 'road.highway',
283
+ elementType: 'labels',
284
+ stylers: [{ visibility: 'off' }]
285
+ },
286
+ {
287
+ featureType: 'water',
288
+ elementType: 'geometry',
289
+ stylers: [{ color: waterColor }]
290
+ },
291
+ {
292
+ featureType: 'water',
293
+ elementType: 'labels',
294
+ stylers: [{ visibility: 'off' }]
295
+ },
296
+ {
297
+ featureType: 'poi',
298
+ elementType: 'geometry',
299
+ stylers: [{ color: backgroundColor }]
300
+ },
301
+ {
302
+ featureType: 'poi',
303
+ elementType: 'labels',
304
+ stylers: [{ visibility: 'off' }]
305
+ },
306
+ {
307
+ featureType: 'landscape',
308
+ elementType: 'geometry',
309
+ stylers: [{ color: backgroundColor }]
310
+ },
311
+ {
312
+ featureType: 'landscape',
313
+ elementType: 'labels',
314
+ stylers: [{ visibility: 'off' }]
315
+ }
316
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
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",