@bigbinary/neeto-commons-frontend 2.1.25 → 2.1.27

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.
package/README.md CHANGED
@@ -163,6 +163,7 @@ Web utility functions [↗](./docs/utils/README.md)
163
163
  - [createSubscription](./docs/utils/createSubscription.md)
164
164
  - [getFromLocalStorage](./docs/utils/getFromLocalStorage.md)
165
165
  - [setToLocalStorage](./docs/utils/setToLocalStorage.md)
166
+ - [currencyFormat](./docs/utils/currencyFormat.md)
166
167
 
167
168
  </td>
168
169
 
package/constants.cjs.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var BASE_API_V1_URL = "/api/v1";
6
+ var DEFAULT_PAGE_SIZE = 30;
6
7
  var DEFAULT_PAGE_INDEX = 1;
7
8
  var DEFAULT_STALE_TIME = 3600000; // 1 hour
8
9
 
@@ -16,6 +17,7 @@ var PLURAL = {
16
17
 
17
18
  exports.BASE_API_V1_URL = BASE_API_V1_URL;
18
19
  exports.DEFAULT_PAGE_INDEX = DEFAULT_PAGE_INDEX;
20
+ exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
19
21
  exports.DEFAULT_STALE_TIME = DEFAULT_STALE_TIME;
20
22
  exports.PLURAL = PLURAL;
21
23
  exports.SINGULAR = SINGULAR;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs.js","sources":["src/constants/index.js"],"sourcesContent":["export const BASE_API_V1_URL = \"/api/v1\";\n\nexport const DEFAULT_PAGE_INDEX = 1;\nexport const DEFAULT_STALE_TIME = 3_600_000; // 1 hour\n\n// Constants for translation\nexport const SINGULAR = { count: 1 };\nexport const PLURAL = { count: 2 };\n"],"names":["BASE_API_V1_URL","DEFAULT_PAGE_INDEX","DEFAULT_STALE_TIME","SINGULAR","count","PLURAL"],"mappings":";;;;AAAO,IAAMA,eAAe,GAAG,UAAS;AAEjC,IAAMC,kBAAkB,GAAG,EAAC;AACtBC,IAAAA,kBAAkB,GAAG,QAAU;;AAE5C;AACO,IAAMC,QAAQ,GAAG;AAAEC,EAAAA,KAAK,EAAE,CAAA;AAAE,EAAC;AAC7B,IAAMC,MAAM,GAAG;AAAED,EAAAA,KAAK,EAAE,CAAA;AAAE;;;;;;;;"}
1
+ {"version":3,"file":"constants.cjs.js","sources":["src/constants/index.js"],"sourcesContent":["export const BASE_API_V1_URL = \"/api/v1\";\n\nexport const DEFAULT_PAGE_SIZE = 30;\nexport const DEFAULT_PAGE_INDEX = 1;\nexport const DEFAULT_STALE_TIME = 3_600_000; // 1 hour\n\n// Constants for translation\nexport const SINGULAR = { count: 1 };\nexport const PLURAL = { count: 2 };\n"],"names":["BASE_API_V1_URL","DEFAULT_PAGE_SIZE","DEFAULT_PAGE_INDEX","DEFAULT_STALE_TIME","SINGULAR","count","PLURAL"],"mappings":";;;;AAAO,IAAMA,eAAe,GAAG,UAAS;AAEjC,IAAMC,iBAAiB,GAAG,GAAE;AAC5B,IAAMC,kBAAkB,GAAG,EAAC;AACtBC,IAAAA,kBAAkB,GAAG,QAAU;;AAE5C;AACO,IAAMC,QAAQ,GAAG;AAAEC,EAAAA,KAAK,EAAE,CAAA;AAAE,EAAC;AAC7B,IAAMC,MAAM,GAAG;AAAED,EAAAA,KAAK,EAAE,CAAA;AAAE;;;;;;;;;"}
package/constants.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export const BASE_API_V1_URL: string;
2
2
  export const DEFAULT_PAGE_INDEX: number;
3
+ export const DEFAULT_PAGE_SIZE: number;
3
4
  export const DEFAULT_STALE_TIME: number;
4
5
  export const SINGULAR: { count: number };
5
6
  export const PLURAL: { count: number };
package/constants.js CHANGED
@@ -1,4 +1,5 @@
1
1
  var BASE_API_V1_URL = "/api/v1";
2
+ var DEFAULT_PAGE_SIZE = 30;
2
3
  var DEFAULT_PAGE_INDEX = 1;
3
4
  var DEFAULT_STALE_TIME = 3600000; // 1 hour
4
5
 
@@ -10,5 +11,5 @@ var PLURAL = {
10
11
  count: 2
11
12
  };
12
13
 
13
- export { BASE_API_V1_URL, DEFAULT_PAGE_INDEX, DEFAULT_STALE_TIME, PLURAL, SINGULAR };
14
+ export { BASE_API_V1_URL, DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE, DEFAULT_STALE_TIME, PLURAL, SINGULAR };
14
15
  //# sourceMappingURL=constants.js.map
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["src/constants/index.js"],"sourcesContent":["export const BASE_API_V1_URL = \"/api/v1\";\n\nexport const DEFAULT_PAGE_INDEX = 1;\nexport const DEFAULT_STALE_TIME = 3_600_000; // 1 hour\n\n// Constants for translation\nexport const SINGULAR = { count: 1 };\nexport const PLURAL = { count: 2 };\n"],"names":["BASE_API_V1_URL","DEFAULT_PAGE_INDEX","DEFAULT_STALE_TIME","SINGULAR","count","PLURAL"],"mappings":"AAAO,IAAMA,eAAe,GAAG,UAAS;AAEjC,IAAMC,kBAAkB,GAAG,EAAC;AACtBC,IAAAA,kBAAkB,GAAG,QAAU;;AAE5C;AACO,IAAMC,QAAQ,GAAG;AAAEC,EAAAA,KAAK,EAAE,CAAA;AAAE,EAAC;AAC7B,IAAMC,MAAM,GAAG;AAAED,EAAAA,KAAK,EAAE,CAAA;AAAE;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["src/constants/index.js"],"sourcesContent":["export const BASE_API_V1_URL = \"/api/v1\";\n\nexport const DEFAULT_PAGE_SIZE = 30;\nexport const DEFAULT_PAGE_INDEX = 1;\nexport const DEFAULT_STALE_TIME = 3_600_000; // 1 hour\n\n// Constants for translation\nexport const SINGULAR = { count: 1 };\nexport const PLURAL = { count: 2 };\n"],"names":["BASE_API_V1_URL","DEFAULT_PAGE_SIZE","DEFAULT_PAGE_INDEX","DEFAULT_STALE_TIME","SINGULAR","count","PLURAL"],"mappings":"AAAO,IAAMA,eAAe,GAAG,UAAS;AAEjC,IAAMC,iBAAiB,GAAG,GAAE;AAC5B,IAAMC,kBAAkB,GAAG,EAAC;AACtBC,IAAAA,kBAAkB,GAAG,QAAU;;AAE5C;AACO,IAAMC,QAAQ,GAAG;AAAEC,EAAAA,KAAK,EAAE,CAAA;AAAE,EAAC;AAC7B,IAAMC,MAAM,GAAG;AAAED,EAAAA,KAAK,EAAE,CAAA;AAAE;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "2.1.25",
3
+ "version": "2.1.27",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
package/utils.cjs.js CHANGED
@@ -2532,8 +2532,8 @@ var lib = {
2532
2532
  };
2533
2533
 
2534
2534
  var _this = undefined;
2535
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2536
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2535
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2536
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2537
2537
  var withEventTargetValue = /*#__PURE__*/ramda.curry(function (func, event) {
2538
2538
  return func(event.target.value);
2539
2539
  });
@@ -2551,7 +2551,7 @@ var simulateApiCall = function simulateApiCall(result, error) {
2551
2551
  success: false,
2552
2552
  notice: i18next__default["default"].t("neetoCommons.notice.errorOccurred")
2553
2553
  };
2554
- Math.random() < errorProbability ? reject(_objectSpread(_objectSpread({}, defaultErrorObj), error)) : resolve(result);
2554
+ Math.random() < errorProbability ? reject(_objectSpread$1(_objectSpread$1({}, defaultErrorObj), error)) : resolve(result);
2555
2555
  }, delay);
2556
2556
  });
2557
2557
  };
@@ -2628,7 +2628,7 @@ var toLocale = function toLocale(number) {
2628
2628
  };
2629
2629
  var getQueryParams = function getQueryParams() {
2630
2630
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2631
- return lib.parse(location.search, _objectSpread({
2631
+ return lib.parse(location.search, _objectSpread$1({
2632
2632
  ignoreQueryPrefix: true
2633
2633
  }, options));
2634
2634
  };
@@ -3238,9 +3238,50 @@ var createSubscription = function createSubscription(channelName, callbacks) {
3238
3238
  return subscription;
3239
3239
  };
3240
3240
 
3241
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3242
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3243
+ var getAmountWithSymbol = function getAmountWithSymbol(amount, options) {
3244
+ var formatter = new Intl.NumberFormat(dayjs__default["default"].locale(), _objectSpread({}, options));
3245
+ return formatter.format(Number(amount));
3246
+ };
3247
+ var currencyFormat = {
3248
+ withAmount: function withAmount(amount) {
3249
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
3250
+ minimumFractionDigits: 2
3251
+ };
3252
+ return getAmountWithSymbol(amount, _objectSpread({
3253
+ style: undefined
3254
+ }, options));
3255
+ },
3256
+ // 1000, { maximumFractionDigits: 1 } => 1,000.0
3257
+ withSymbol: function withSymbol(amount, currency, options) {
3258
+ return getAmountWithSymbol(amount, _objectSpread(_objectSpread({}, options), {}, {
3259
+ style: "currency",
3260
+ currency: currency
3261
+ }));
3262
+ },
3263
+ // 1000, "INR", { maximumFractionDigits: 0 } => ₹1,000
3264
+ withCode: function withCode(amount, currency) {
3265
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
3266
+ minimumFractionDigits: 2
3267
+ };
3268
+ return "".concat(getAmountWithSymbol(amount, _objectSpread(_objectSpread({}, options), {}, {
3269
+ style: undefined
3270
+ })), " ").concat(currency);
3271
+ },
3272
+ // 1000, "USD" => 1,000.00 USD
3273
+ withSymbolAndCode: function withSymbolAndCode(amount, currency, options) {
3274
+ return "".concat(getAmountWithSymbol(amount, _objectSpread(_objectSpread({}, options), {}, {
3275
+ style: "currency",
3276
+ currency: currency
3277
+ })), " ").concat(currency);
3278
+ } // 1000, "INR", { maximumFractionDigits: 0 } => ₹1,000 INR
3279
+ };
3280
+
3241
3281
  exports.buildUrl = buildUrl;
3242
3282
  exports.copyToClipboard = copyToClipboard;
3243
3283
  exports.createSubscription = createSubscription;
3284
+ exports.currencyFormat = currencyFormat;
3244
3285
  exports.dateFormat = dateFormat;
3245
3286
  exports.debounce = debounce;
3246
3287
  exports.getFromLocalStorage = getFromLocalStorage;