@mmb-digital/shared-libs-auto 0.0.13 → 0.0.15

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.
Files changed (102) hide show
  1. package/dist/formatters/const.d.ts +1 -1
  2. package/dist/formatters/const.js +1 -1
  3. package/dist/formatters/const.js.map +1 -1
  4. package/dist/formatters/formatBankAccount/formatBankAccount.js +2 -3
  5. package/dist/formatters/formatBankAccount/formatBankAccount.js.map +1 -1
  6. package/dist/formatters/formatBankAccount/inputFormatBankAccount.d.ts +1 -1
  7. package/dist/formatters/formatBankAccount/inputFormatBankAccount.js +7 -2
  8. package/dist/formatters/formatBankAccount/inputFormatBankAccount.js.map +1 -1
  9. package/dist/formatters/formatBankAccount/types.d.ts +1 -2
  10. package/dist/formatters/formatBankAccount/utils/innerFormatBankAccount.d.ts +5 -0
  11. package/dist/formatters/formatBankAccount/utils/innerFormatBankAccount.js +9 -0
  12. package/dist/formatters/formatBankAccount/utils/innerFormatBankAccount.js.map +1 -0
  13. package/dist/formatters/formatBytes/formatBytes.js +2 -2
  14. package/dist/formatters/formatBytes/formatBytes.js.map +1 -1
  15. package/dist/formatters/formatCZSKPhoneNumber/formatCZSKPhoneNumber.js +4 -21
  16. package/dist/formatters/formatCZSKPhoneNumber/formatCZSKPhoneNumber.js.map +1 -1
  17. package/dist/formatters/formatCZSKPhoneNumber/inputFormatCZSKPhoneNumber.d.ts +1 -1
  18. package/dist/formatters/formatCZSKPhoneNumber/inputFormatCZSKPhoneNumber.js +2 -2
  19. package/dist/formatters/formatCZSKPhoneNumber/inputFormatCZSKPhoneNumber.js.map +1 -1
  20. package/dist/formatters/formatCZSKPhoneNumber/utils/innerFormatCZSKPhoneNumber.d.ts +5 -0
  21. package/dist/formatters/formatCZSKPhoneNumber/utils/innerFormatCZSKPhoneNumber.js +30 -0
  22. package/dist/formatters/formatCZSKPhoneNumber/utils/innerFormatCZSKPhoneNumber.js.map +1 -0
  23. package/dist/formatters/formatCzZipCode/formatCzZipCode.js +2 -2
  24. package/dist/formatters/formatCzZipCode/formatCzZipCode.js.map +1 -1
  25. package/dist/formatters/formatCzZipCode/inputFormatCzZipCode.d.ts +1 -1
  26. package/dist/formatters/formatCzZipCode/inputFormatCzZipCode.js +7 -2
  27. package/dist/formatters/formatCzZipCode/inputFormatCzZipCode.js.map +1 -1
  28. package/dist/formatters/formatCzZipCode/utils/innerFormatCzZipCode.d.ts +4 -0
  29. package/dist/formatters/formatCzZipCode/utils/innerFormatCzZipCode.js +6 -0
  30. package/dist/formatters/formatCzZipCode/utils/innerFormatCzZipCode.js.map +1 -0
  31. package/dist/formatters/formatICO/formatICO.js +2 -8
  32. package/dist/formatters/formatICO/formatICO.js.map +1 -1
  33. package/dist/formatters/formatICO/inputFormatICO.d.ts +1 -1
  34. package/dist/formatters/formatICO/inputFormatICO.js +10 -2
  35. package/dist/formatters/formatICO/inputFormatICO.js.map +1 -1
  36. package/dist/formatters/formatICO/utils/innerFormatICO.d.ts +4 -0
  37. package/dist/formatters/formatICO/utils/innerFormatICO.js +12 -0
  38. package/dist/formatters/formatICO/utils/innerFormatICO.js.map +1 -0
  39. package/dist/formatters/formatNumber/formatNumber.d.ts +7 -0
  40. package/dist/formatters/formatNumber/formatNumber.js +20 -0
  41. package/dist/formatters/formatNumber/formatNumber.js.map +1 -0
  42. package/dist/formatters/formatNumber/formatPercent.d.ts +8 -0
  43. package/dist/formatters/formatNumber/formatPercent.js +26 -0
  44. package/dist/formatters/formatNumber/formatPercent.js.map +1 -0
  45. package/dist/formatters/formatNumber/inputFormatFloat.d.ts +6 -0
  46. package/dist/formatters/formatNumber/inputFormatFloat.js +20 -0
  47. package/dist/formatters/formatNumber/inputFormatFloat.js.map +1 -0
  48. package/dist/formatters/formatNumber/inputFormatNumber.d.ts +6 -0
  49. package/dist/formatters/formatNumber/inputFormatNumber.js +20 -0
  50. package/dist/formatters/formatNumber/inputFormatNumber.js.map +1 -0
  51. package/dist/formatters/formatNumber/utils/innerFormatNumber.d.ts +5 -0
  52. package/dist/formatters/formatNumber/utils/innerFormatNumber.js +7 -0
  53. package/dist/formatters/formatNumber/utils/innerFormatNumber.js.map +1 -0
  54. package/dist/formatters/formatPin/formatPin.js +4 -4
  55. package/dist/formatters/formatPin/formatPin.js.map +1 -1
  56. package/dist/formatters/formatPin/inputFormatPin.d.ts +1 -1
  57. package/dist/formatters/formatPin/inputFormatPin.js +9 -2
  58. package/dist/formatters/formatPin/inputFormatPin.js.map +1 -1
  59. package/dist/formatters/formatPin/utils/innerFormatPin.d.ts +4 -0
  60. package/dist/formatters/formatPin/utils/innerFormatPin.js +6 -0
  61. package/dist/formatters/formatPin/utils/innerFormatPin.js.map +1 -0
  62. package/dist/formatters/index.d.ts +4 -0
  63. package/dist/formatters/index.js +4 -0
  64. package/dist/formatters/index.js.map +1 -1
  65. package/dist/utils/cleanObject/cleanObject.d.ts +1 -1
  66. package/dist/utils/cleanObject/cleanObject.js +5 -1
  67. package/dist/utils/cleanObject/cleanObject.js.map +1 -1
  68. package/dist/utils/downloadFile/downloadFile.d.ts +2 -2
  69. package/dist/utils/downloadFile/downloadFile.js +12 -18
  70. package/dist/utils/downloadFile/downloadFile.js.map +1 -1
  71. package/dist/utils/downloadFile/utils/processDownload.d.ts +4 -0
  72. package/dist/utils/downloadFile/utils/processDownload.js +18 -0
  73. package/dist/utils/downloadFile/utils/processDownload.js.map +1 -0
  74. package/dist/utils/getNumber/getNumber.js +2 -2
  75. package/dist/utils/getNumber/getNumber.js.map +1 -1
  76. package/dist/utils/getNumberFloat/getNumberFloat.d.ts +8 -0
  77. package/dist/utils/getNumberFloat/getNumberFloat.js +31 -0
  78. package/dist/utils/getNumberFloat/getNumberFloat.js.map +1 -0
  79. package/dist/utils/index.d.ts +2 -0
  80. package/dist/utils/index.js +2 -0
  81. package/dist/utils/index.js.map +1 -1
  82. package/dist/utils/openFile/openFile.d.ts +4 -0
  83. package/dist/utils/openFile/openFile.js +29 -0
  84. package/dist/utils/openFile/openFile.js.map +1 -0
  85. package/dist/utils/openFile/utils/innerOpenFile.d.ts +4 -0
  86. package/dist/utils/openFile/utils/innerOpenFile.js +8 -0
  87. package/dist/utils/openFile/utils/innerOpenFile.js.map +1 -0
  88. package/dist/utils/range/isInRange.d.ts +1 -1
  89. package/dist/utils/range/isInRange.js +2 -0
  90. package/dist/utils/range/isInRange.js.map +1 -1
  91. package/dist/utils/range/unionRange.d.ts +1 -1
  92. package/dist/utils/range/unionRange.js +6 -0
  93. package/dist/utils/range/unionRange.js.map +1 -1
  94. package/dist/validators/index.d.ts +1 -0
  95. package/dist/validators/index.js +1 -0
  96. package/dist/validators/index.js.map +1 -1
  97. package/dist/validators/isArrayBuffer/isArrayBuffer.d.ts +4 -0
  98. package/dist/validators/isArrayBuffer/isArrayBuffer.js +6 -0
  99. package/dist/validators/isArrayBuffer/isArrayBuffer.js.map +1 -0
  100. package/dist/validators/isValidDate/isValidDate.js +1 -1
  101. package/dist/validators/isValidDate/isValidDate.js.map +1 -1
  102. package/package.json +2 -3
@@ -1,2 +1,2 @@
1
1
  export declare const EMPTY_VALUE_PLACEHOLDER = "-";
2
- export declare const EMPTY_INPUT_PLACEHOLDER = "";
2
+ export declare const EMPTY_INPUT_PLACEHOLDER: null;
@@ -1,3 +1,3 @@
1
1
  export const EMPTY_VALUE_PLACEHOLDER = '-';
2
- export const EMPTY_INPUT_PLACEHOLDER = '';
2
+ export const EMPTY_INPUT_PLACEHOLDER = null;
3
3
  //# sourceMappingURL=const.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/formatters/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAC1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAA"}
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/formatters/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAC1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { isEmpty } from '../../validators/isEmpty/isEmpty.js';
2
2
  import { EMPTY_VALUE_PLACEHOLDER } from '../const.js';
3
+ import { innerFormatBankAccount } from './utils/innerFormatBankAccount.js';
3
4
  /**
4
5
  * Formats a bank account input into a standardized string representation.
5
6
  * @example "1234567890/0800" or "123-1234567890/0800"
@@ -7,8 +8,6 @@ import { EMPTY_VALUE_PLACEHOLDER } from '../const.js';
7
8
  export const formatBankAccount = (value, fallback = EMPTY_VALUE_PLACEHOLDER) => {
8
9
  if (isEmpty(value))
9
10
  return fallback;
10
- const { prefix, number, bankCode } = value;
11
- const accountNumber = [String(number).trim(), bankCode.trim()].join('/');
12
- return [prefix, accountNumber].filter(Boolean).join('-');
11
+ return innerFormatBankAccount(value);
13
12
  };
14
13
  //# sourceMappingURL=formatBankAccount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatBankAccount.js","sourceRoot":"","sources":["../../../src/formatters/formatBankAccount/formatBankAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAGrD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAuB,EAAE,QAAQ,GAAG,uBAAuB,EAAE,EAAE;IAC/F,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC1C,MAAM,aAAa,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxE,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1D,CAAC,CAAA"}
1
+ {"version":3,"file":"formatBankAccount.js","sourceRoot":"","sources":["../../../src/formatters/formatBankAccount/formatBankAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAAuB,EACvB,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnC,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAA;AACtC,CAAC,CAAA"}
@@ -4,4 +4,4 @@ import type { BankAccountInput } from './types.js';
4
4
  * Used for input fields where empty string is preferred over placeholder.
5
5
  * @example "1234567890/0800" or "123-1234567890/0800"
6
6
  */
7
- export declare const inputFormatBankAccount: (value: BankAccountInput) => string;
7
+ export declare const inputFormatBankAccount: (value: BankAccountInput) => string | null;
@@ -1,9 +1,14 @@
1
+ import { isEmpty } from '../../validators/isEmpty/isEmpty.js';
1
2
  import { EMPTY_INPUT_PLACEHOLDER } from '../const.js';
2
- import { formatBankAccount } from './formatBankAccount.js';
3
+ import { innerFormatBankAccount } from './utils/innerFormatBankAccount.js';
3
4
  /**
4
5
  * Formats a bank account input into a standardized string representation.
5
6
  * Used for input fields where empty string is preferred over placeholder.
6
7
  * @example "1234567890/0800" or "123-1234567890/0800"
7
8
  */
8
- export const inputFormatBankAccount = (value) => formatBankAccount(value, EMPTY_INPUT_PLACEHOLDER);
9
+ export const inputFormatBankAccount = (value) => {
10
+ if (isEmpty(value))
11
+ return EMPTY_INPUT_PLACEHOLDER;
12
+ return innerFormatBankAccount(value);
13
+ };
9
14
  //# sourceMappingURL=inputFormatBankAccount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inputFormatBankAccount.js","sourceRoot":"","sources":["../../../src/formatters/formatBankAccount/inputFormatBankAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAuB,EAAE,EAAE,CAChE,iBAAiB,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAA"}
1
+ {"version":3,"file":"inputFormatBankAccount.js","sourceRoot":"","sources":["../../../src/formatters/formatBankAccount/inputFormatBankAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAuB,EAAiB,EAAE;IAC/E,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,uBAAuB,CAAA;IAElD,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAA;AACtC,CAAC,CAAA"}
@@ -1,7 +1,6 @@
1
- interface BankAccount {
1
+ export interface BankAccount {
2
2
  number: string;
3
3
  bankCode: string;
4
4
  prefix?: string | null;
5
5
  }
6
6
  export type BankAccountInput = BankAccount | null | undefined;
7
- export {};
@@ -0,0 +1,5 @@
1
+ import type { BankAccount } from '../types.js';
2
+ /**
3
+ * Internal utility to format a bank account input into a standardized string representation.
4
+ */
5
+ export declare const innerFormatBankAccount: (value: BankAccount) => string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Internal utility to format a bank account input into a standardized string representation.
3
+ */
4
+ export const innerFormatBankAccount = (value) => {
5
+ const { prefix, number, bankCode } = value;
6
+ const accountNumber = [String(number).trim(), bankCode.trim()].join('/');
7
+ return [prefix, accountNumber].filter(Boolean).join('-');
8
+ };
9
+ //# sourceMappingURL=innerFormatBankAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"innerFormatBankAccount.js","sourceRoot":"","sources":["../../../../src/formatters/formatBankAccount/utils/innerFormatBankAccount.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAkB,EAAU,EAAE;IACnE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC1C,MAAM,aAAa,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACxE,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1D,CAAC,CAAA"}
@@ -10,9 +10,9 @@ export const formatBytes = (bytes, decimals = 2, fallback = EMPTY_VALUE_PLACEHOL
10
10
  if (bytes === 0)
11
11
  return '0 Bytes';
12
12
  const k = 1024;
13
- const dm = decimals < 0 ? 0 : decimals;
13
+ const dm = Math.max(0, decimals);
14
14
  const sizes = ['Bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
15
15
  const i = Math.floor(Math.log(bytes) / Math.log(k));
16
- return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
16
+ return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
17
17
  };
18
18
  //# sourceMappingURL=formatBytes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatBytes.js","sourceRoot":"","sources":["../../../src/formatters/formatBytes/formatBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAgC,EAChC,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,uBAAuB,EAClC,EAAE;IACF,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC7C,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAEjC,MAAM,CAAC,GAAG,IAAI,CAAA;IACd,MAAM,EAAE,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;IACtC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACvE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACnD,OAAO,GAAG,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAClE,CAAC,CAAA"}
1
+ {"version":3,"file":"formatBytes.js","sourceRoot":"","sources":["../../../src/formatters/formatBytes/formatBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAgC,EAChC,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC7C,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAEjC,MAAM,CAAC,GAAG,IAAI,CAAA;IACd,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;IAChC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACvE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACnD,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AACzE,CAAC,CAAA"}
@@ -1,31 +1,14 @@
1
1
  import { isEmpty } from '../../validators/isEmpty/isEmpty.js';
2
2
  import { EMPTY_VALUE_PLACEHOLDER } from '../const.js';
3
- const CZECH_PHONE_CODE = '+420';
4
- const SLOVAK_PHONE_CODE = '+421';
5
- const CZ_SK_PHONE_MASK = /^(\+42[01])\d{9}$/;
3
+ import { innerFormatCZSKPhoneNumber } from './utils/innerFormatCZSKPhoneNumber.js';
6
4
  /**
7
5
  * Formats a Czech or Slovak phone number.
8
6
  * @example "+420 123 456 789" or "+421 123 456 789"
9
7
  */
10
8
  export const formatCZSKPhoneNumber = (value, fallback = EMPTY_VALUE_PLACEHOLDER) => {
11
- if (isEmpty(value))
9
+ const formattedPhoneNumber = innerFormatCZSKPhoneNumber(value, fallback);
10
+ if (isEmpty(formattedPhoneNumber))
12
11
  return fallback;
13
- if (!CZ_SK_PHONE_MASK.test(value)) {
14
- return value ?? fallback;
15
- }
16
- const testedCode = value.includes(CZECH_PHONE_CODE) ? CZECH_PHONE_CODE : SLOVAK_PHONE_CODE;
17
- const phonePart = value.split(testedCode)[1];
18
- if (!phonePart) {
19
- return value ?? '';
20
- }
21
- const buffer = [];
22
- for (let i = 0; i < phonePart.length; i++) {
23
- if (i !== 0 && i % 3 === 0) {
24
- buffer.push(' ');
25
- }
26
- buffer.push(phonePart[i]);
27
- }
28
- const formattedPhonePart = buffer.join('');
29
- return `${testedCode} ${formattedPhonePart}`;
12
+ return formattedPhoneNumber;
30
13
  };
31
14
  //# sourceMappingURL=formatCZSKPhoneNumber.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatCZSKPhoneNumber.js","sourceRoot":"","sources":["../../../src/formatters/formatCZSKPhoneNumber/formatCZSKPhoneNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAC/B,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAChC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAAgC,EAChC,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,IAAI,QAAQ,CAAA;IAC1B,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,iBAAiB,CAAA;IAC1F,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAE5C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,IAAI,EAAE,CAAA;IACpB,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,CAAA;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3B,CAAC;IACD,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC1C,OAAO,GAAG,UAAU,IAAI,kBAAkB,EAAE,CAAA;AAC9C,CAAC,CAAA"}
1
+ {"version":3,"file":"formatCZSKPhoneNumber.js","sourceRoot":"","sources":["../../../src/formatters/formatCZSKPhoneNumber/formatCZSKPhoneNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAAgC,EAChC,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,MAAM,oBAAoB,GAAG,0BAA0B,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAExE,IAAI,OAAO,CAAC,oBAAoB,CAAC;QAAE,OAAO,QAAQ,CAAA;IAClD,OAAO,oBAAoB,CAAA;AAC7B,CAAC,CAAA"}
@@ -3,4 +3,4 @@
3
3
  * Used for input fields where empty string is preferred over placeholder.
4
4
  * @example "+420 123 456 789" or "+421 123 456 789"
5
5
  */
6
- export declare const inputFormatCZSKPhoneNumber: (value: string | undefined | null) => string;
6
+ export declare const inputFormatCZSKPhoneNumber: (value: string | undefined | null) => string | null;
@@ -1,9 +1,9 @@
1
1
  import { EMPTY_INPUT_PLACEHOLDER } from '../const.js';
2
- import { formatCZSKPhoneNumber } from './formatCZSKPhoneNumber.js';
2
+ import { innerFormatCZSKPhoneNumber } from './utils/innerFormatCZSKPhoneNumber.js';
3
3
  /**
4
4
  * Formats a Czech or Slovak phone number.
5
5
  * Used for input fields where empty string is preferred over placeholder.
6
6
  * @example "+420 123 456 789" or "+421 123 456 789"
7
7
  */
8
- export const inputFormatCZSKPhoneNumber = (value) => formatCZSKPhoneNumber(value, EMPTY_INPUT_PLACEHOLDER);
8
+ export const inputFormatCZSKPhoneNumber = (value) => innerFormatCZSKPhoneNumber(value, EMPTY_INPUT_PLACEHOLDER);
9
9
  //# sourceMappingURL=inputFormatCZSKPhoneNumber.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inputFormatCZSKPhoneNumber.js","sourceRoot":"","sources":["../../../src/formatters/formatCZSKPhoneNumber/inputFormatCZSKPhoneNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAgC,EAAE,EAAE,CAC7E,qBAAqB,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAA"}
1
+ {"version":3,"file":"inputFormatCZSKPhoneNumber.js","sourceRoot":"","sources":["../../../src/formatters/formatCZSKPhoneNumber/inputFormatCZSKPhoneNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAA;AAElF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,KAAgC,EAAiB,EAAE,CAC5F,0BAA0B,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Internal utility to format a Czech or Slovak phone number into a standardized string representation.
3
+ * Returns null or fallback if the input is empty
4
+ */
5
+ export declare const innerFormatCZSKPhoneNumber: (value: string | undefined | null, fallback: string | null) => string | null;
@@ -0,0 +1,30 @@
1
+ import { isEmpty } from '../../../validators/isEmpty/isEmpty.js';
2
+ const CZECH_PHONE_CODE = '+420';
3
+ const SLOVAK_PHONE_CODE = '+421';
4
+ const CZ_SK_PHONE_MASK = /^(\+42[01])\d{9}$/;
5
+ /**
6
+ * Internal utility to format a Czech or Slovak phone number into a standardized string representation.
7
+ * Returns null or fallback if the input is empty
8
+ */
9
+ export const innerFormatCZSKPhoneNumber = (value, fallback) => {
10
+ if (isEmpty(value))
11
+ return fallback;
12
+ if (!CZ_SK_PHONE_MASK.test(value)) {
13
+ return value ?? fallback;
14
+ }
15
+ const testedCode = value.includes(CZECH_PHONE_CODE) ? CZECH_PHONE_CODE : SLOVAK_PHONE_CODE;
16
+ const phonePart = value.split(testedCode)[1];
17
+ if (!phonePart) {
18
+ return value ?? '';
19
+ }
20
+ const buffer = [];
21
+ for (let i = 0; i < phonePart.length; i++) {
22
+ if (i !== 0 && i % 3 === 0) {
23
+ buffer.push(' ');
24
+ }
25
+ buffer.push(phonePart[i]);
26
+ }
27
+ const formattedPhonePart = buffer.join('');
28
+ return `${testedCode} ${formattedPhonePart}`;
29
+ };
30
+ //# sourceMappingURL=innerFormatCZSKPhoneNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"innerFormatCZSKPhoneNumber.js","sourceRoot":"","sources":["../../../../src/formatters/formatCZSKPhoneNumber/utils/innerFormatCZSKPhoneNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAA;AAEhE,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAC/B,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAChC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,KAAgC,EAChC,QAAuB,EACR,EAAE;IACjB,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,IAAI,QAAQ,CAAA;IAC1B,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,iBAAiB,CAAA;IAC1F,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAE5C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,IAAI,EAAE,CAAA;IACpB,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,CAAA;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3B,CAAC;IACD,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC1C,OAAO,GAAG,UAAU,IAAI,kBAAkB,EAAE,CAAA;AAC9C,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { isEmpty } from '../../validators/isEmpty/isEmpty.js';
2
2
  import { EMPTY_VALUE_PLACEHOLDER } from '../const.js';
3
- const ZIP_CODE_REGEX = /(\d{3})(\d{2})/;
3
+ import { innerFormatCzZipCode } from './utils/innerFormatCzZipCode.js';
4
4
  /**
5
5
  * Formats a Czech zip code by adding a space between the third and fourth digits.
6
6
  * @example "123 45"
@@ -8,6 +8,6 @@ const ZIP_CODE_REGEX = /(\d{3})(\d{2})/;
8
8
  export const formatCzZipCode = (value, fallback = EMPTY_VALUE_PLACEHOLDER) => {
9
9
  if (isEmpty(value))
10
10
  return fallback;
11
- return value.toString().replace(ZIP_CODE_REGEX, `$1 $2`);
11
+ return innerFormatCzZipCode(value);
12
12
  };
13
13
  //# sourceMappingURL=formatCzZipCode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatCzZipCode.js","sourceRoot":"","sources":["../../../src/formatters/formatCzZipCode/formatCzZipCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAEvC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAyC,EACzC,QAAQ,GAAG,uBAAuB,EAClC,EAAE;IACF,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AAC1D,CAAC,CAAA"}
1
+ {"version":3,"file":"formatCzZipCode.js","sourceRoot":"","sources":["../../../src/formatters/formatCzZipCode/formatCzZipCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAEtE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAyC,EACzC,WAAmB,uBAAuB,EAClC,EAAE;IACV,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnC,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC,CAAA"}
@@ -3,4 +3,4 @@
3
3
  * Used for input fields where empty string is preferred over placeholder.
4
4
  * @example "123 45"
5
5
  */
6
- export declare const inputFormatCzZipCode: (value: number | string | null | undefined) => string;
6
+ export declare const inputFormatCzZipCode: (value: number | string | null | undefined) => string | null;
@@ -1,9 +1,14 @@
1
+ import { isEmpty } from '../../validators/isEmpty/isEmpty.js';
1
2
  import { EMPTY_INPUT_PLACEHOLDER } from '../const.js';
2
- import { formatCzZipCode } from './formatCzZipCode.js';
3
+ import { innerFormatCzZipCode } from './utils/innerFormatCzZipCode.js';
3
4
  /**
4
5
  * Formats a Czech zip code by adding a space between the third and fourth digits.
5
6
  * Used for input fields where empty string is preferred over placeholder.
6
7
  * @example "123 45"
7
8
  */
8
- export const inputFormatCzZipCode = (value) => formatCzZipCode(value, EMPTY_INPUT_PLACEHOLDER);
9
+ export const inputFormatCzZipCode = (value) => {
10
+ if (isEmpty(value))
11
+ return EMPTY_INPUT_PLACEHOLDER;
12
+ return innerFormatCzZipCode(value);
13
+ };
9
14
  //# sourceMappingURL=inputFormatCzZipCode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inputFormatCzZipCode.js","sourceRoot":"","sources":["../../../src/formatters/formatCzZipCode/inputFormatCzZipCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAyC,EAAE,EAAE,CAChF,eAAe,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAA"}
1
+ {"version":3,"file":"inputFormatCzZipCode.js","sourceRoot":"","sources":["../../../src/formatters/formatCzZipCode/inputFormatCzZipCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAEtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAyC,EAAiB,EAAE;IAC/F,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,uBAAuB,CAAA;IAElD,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Internal utility to format a Czech zip code into a standardized string representation.
3
+ */
4
+ export declare const innerFormatCzZipCode: (value: number | string) => string;
@@ -0,0 +1,6 @@
1
+ const ZIP_CODE_REGEX = /(\d{3})(\d{2})/;
2
+ /**
3
+ * Internal utility to format a Czech zip code into a standardized string representation.
4
+ */
5
+ export const innerFormatCzZipCode = (value) => value.toString().replace(ZIP_CODE_REGEX, `$1 $2`);
6
+ //# sourceMappingURL=innerFormatCzZipCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"innerFormatCzZipCode.js","sourceRoot":"","sources":["../../../../src/formatters/formatCzZipCode/utils/innerFormatCzZipCode.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAsB,EAAE,EAAE,CAC7D,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA"}
@@ -1,13 +1,7 @@
1
- import { removeWhitespaces } from '../../utils/removeWhitespaces/removeWhitespaces.js';
2
1
  import { isEmpty } from '../../validators/isEmpty/isEmpty.js';
3
2
  import { isNaturalNumericStringWithWhitespaces } from '../../validators/isNaturalNumericStringWithWhitespaces/isNaturalNumericStringWithWhitespaces.js';
4
3
  import { EMPTY_VALUE_PLACEHOLDER } from '../const.js';
5
- /**
6
- * Délka Identifikační čísla osoby (IČO) je 8 znaků.
7
- *
8
- * https://cs.wikipedia.org/wiki/Identifika%C4%8Dn%C3%AD_%C4%8D%C3%ADslo_osoby
9
- */
10
- const ICO_NUMBER_LENGTH = 8;
4
+ import { innerFormatICO } from './utils/innerFormatICO.js';
11
5
  /**
12
6
  * Formats the given ICO (Identifikační číslo organizace) by padding it with leading zeros to ensure it is 8 characters long.
13
7
  * @example "00012345"
@@ -17,6 +11,6 @@ export const formatICO = (value, fallback = EMPTY_VALUE_PLACEHOLDER) => {
17
11
  return fallback;
18
12
  if (!isNaturalNumericStringWithWhitespaces(value))
19
13
  return fallback;
20
- return removeWhitespaces(value.toString()).padStart(ICO_NUMBER_LENGTH, '0');
14
+ return innerFormatICO(value);
21
15
  };
22
16
  //# sourceMappingURL=formatICO.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatICO.js","sourceRoot":"","sources":["../../../src/formatters/formatICO/formatICO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAA;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,qCAAqC,EAAE,MAAM,iGAAiG,CAAA;AACvJ,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAE3B;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAyC,EACzC,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IACnC,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAElE,OAAO,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;AAC7E,CAAC,CAAA"}
1
+ {"version":3,"file":"formatICO.js","sourceRoot":"","sources":["../../../src/formatters/formatICO/formatICO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,qCAAqC,EAAE,MAAM,iGAAiG,CAAA;AACvJ,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAyC,EACzC,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IACnC,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAElE,OAAO,cAAc,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC,CAAA"}
@@ -3,4 +3,4 @@
3
3
  * Used for input fields where empty string is preferred over placeholder.
4
4
  * @example "00012345"
5
5
  */
6
- export declare const inputFormatICO: (value: string | number | null | undefined) => string;
6
+ export declare const inputFormatICO: (value: string | number | null | undefined) => string | null;
@@ -1,9 +1,17 @@
1
+ import { isEmpty } from '../../validators/isEmpty/isEmpty.js';
2
+ import { isNaturalNumericStringWithWhitespaces } from '../../validators/isNaturalNumericStringWithWhitespaces/isNaturalNumericStringWithWhitespaces.js';
1
3
  import { EMPTY_INPUT_PLACEHOLDER } from '../const.js';
2
- import { formatICO } from './formatICO.js';
4
+ import { innerFormatICO } from './utils/innerFormatICO.js';
3
5
  /**
4
6
  * Formats an ICO (Identifikační číslo organizace).
5
7
  * Used for input fields where empty string is preferred over placeholder.
6
8
  * @example "00012345"
7
9
  */
8
- export const inputFormatICO = (value) => formatICO(value, EMPTY_INPUT_PLACEHOLDER);
10
+ export const inputFormatICO = (value) => {
11
+ if (isEmpty(value))
12
+ return EMPTY_INPUT_PLACEHOLDER;
13
+ if (!isNaturalNumericStringWithWhitespaces(value))
14
+ return EMPTY_INPUT_PLACEHOLDER;
15
+ return innerFormatICO(value);
16
+ };
9
17
  //# sourceMappingURL=inputFormatICO.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inputFormatICO.js","sourceRoot":"","sources":["../../../src/formatters/formatICO/inputFormatICO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAyC,EAAE,EAAE,CAC1E,SAAS,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAA"}
1
+ {"version":3,"file":"inputFormatICO.js","sourceRoot":"","sources":["../../../src/formatters/formatICO/inputFormatICO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,qCAAqC,EAAE,MAAM,iGAAiG,CAAA;AACvJ,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAyC,EAAiB,EAAE;IACzF,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,uBAAuB,CAAA;IAClD,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC;QAAE,OAAO,uBAAuB,CAAA;IAEjF,OAAO,cAAc,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Internal function to format ICO by padding it with leading zeros.
3
+ */
4
+ export declare const innerFormatICO: (value: string | number) => string;
@@ -0,0 +1,12 @@
1
+ import { removeWhitespaces } from '../../../utils/removeWhitespaces/removeWhitespaces.js';
2
+ /**
3
+ * Délka Identifikační čísla osoby (IČO) je 8 znaků.
4
+ *
5
+ * https://cs.wikipedia.org/wiki/Identifika%C4%8Dn%C3%AD_%C4%8D%C3%ADslo_osoby
6
+ */
7
+ const ICO_NUMBER_LENGTH = 8;
8
+ /**
9
+ * Internal function to format ICO by padding it with leading zeros.
10
+ */
11
+ export const innerFormatICO = (value) => removeWhitespaces(value.toString()).padStart(ICO_NUMBER_LENGTH, '0');
12
+ //# sourceMappingURL=innerFormatICO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"innerFormatICO.js","sourceRoot":"","sources":["../../../../src/formatters/formatICO/utils/innerFormatICO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAA;AAEzF;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAE3B;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAU,EAAE,CAC/D,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Formats a number or a numeric string into a string representation
3
+ * @example "123 456 789"
4
+ *
5
+ * decimals - number of decimal places to include in the formatted output (default is 0)
6
+ */
7
+ export declare const formatNumber: (value: number | string | null | undefined, decimals?: number, fallback?: string) => string;
@@ -0,0 +1,20 @@
1
+ import { getNumberFloat } from '../../utils/getNumberFloat/getNumberFloat.js';
2
+ import { isNullOrUndefined } from '../../validators/isNullOrUndefined/isNullOrUndefined.js';
3
+ import { isNumber } from '../../validators/isNumber/isNumber.js';
4
+ import { EMPTY_VALUE_PLACEHOLDER } from '../const.js';
5
+ import { innerFormatNumber } from './utils/innerFormatNumber.js';
6
+ /**
7
+ * Formats a number or a numeric string into a string representation
8
+ * @example "123 456 789"
9
+ *
10
+ * decimals - number of decimal places to include in the formatted output (default is 0)
11
+ */
12
+ export const formatNumber = (value, decimals = 0, fallback = EMPTY_VALUE_PLACEHOLDER) => {
13
+ if (isNullOrUndefined(value))
14
+ return fallback;
15
+ const valueNumber = isNumber(value) ? value : getNumberFloat(value);
16
+ if (isNullOrUndefined(valueNumber))
17
+ return fallback;
18
+ return innerFormatNumber(valueNumber, decimals);
19
+ };
20
+ //# sourceMappingURL=formatNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatNumber.js","sourceRoot":"","sources":["../../../src/formatters/formatNumber/formatNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAyC,EACzC,WAAmB,CAAC,EACpB,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAE7C,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IACnE,IAAI,iBAAiB,CAAC,WAAW,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnD,OAAO,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;AACjD,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Formats a number or a numeric string into a percentage string representation
3
+ * @example "12,34 %"
4
+ *
5
+ * isDecimalValue - indicates whether the input value is in decimal form (e.g., 0.1234 for 12.34 %) or already in percentage form (e.g., 12.34 for 12.34 %)
6
+ * Default is true (decimal form)
7
+ */
8
+ export declare const formatPercent: (value: number | string | null | undefined, isDecimalValue?: boolean, fallback?: string) => string;
@@ -0,0 +1,26 @@
1
+ import { getNumberFloat } from '../../utils/getNumberFloat/getNumberFloat.js';
2
+ import { isNullOrUndefined } from '../../validators/isNullOrUndefined/isNullOrUndefined.js';
3
+ import { isNumber } from '../../validators/isNumber/isNumber.js';
4
+ import { EMPTY_VALUE_PLACEHOLDER } from '../const.js';
5
+ import { innerFormatNumber } from './utils/innerFormatNumber.js';
6
+ const IRREGULAR_WHITESPACE = '\u00A0'; // Non-breaking space character
7
+ const PERCENT_DECIMALS = 2;
8
+ const PERCENT_MULTIPLIER = 100;
9
+ /**
10
+ * Formats a number or a numeric string into a percentage string representation
11
+ * @example "12,34 %"
12
+ *
13
+ * isDecimalValue - indicates whether the input value is in decimal form (e.g., 0.1234 for 12.34 %) or already in percentage form (e.g., 12.34 for 12.34 %)
14
+ * Default is true (decimal form)
15
+ */
16
+ export const formatPercent = (value, isDecimalValue = true, fallback = EMPTY_VALUE_PLACEHOLDER) => {
17
+ if (isNullOrUndefined(value))
18
+ return fallback;
19
+ const valueNumber = isNumber(value) ? value : getNumberFloat(value);
20
+ if (isNullOrUndefined(valueNumber))
21
+ return fallback;
22
+ const adjustedValue = isDecimalValue ? valueNumber * PERCENT_MULTIPLIER : valueNumber;
23
+ const formattedValue = innerFormatNumber(adjustedValue, PERCENT_DECIMALS);
24
+ return `${formattedValue}${IRREGULAR_WHITESPACE}%`;
25
+ };
26
+ //# sourceMappingURL=formatPercent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatPercent.js","sourceRoot":"","sources":["../../../src/formatters/formatNumber/formatPercent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAEhE,MAAM,oBAAoB,GAAG,QAAiB,CAAA,CAAC,+BAA+B;AAC9E,MAAM,gBAAgB,GAAG,CAAU,CAAA;AACnC,MAAM,kBAAkB,GAAG,GAAY,CAAA;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAyC,EACzC,cAAc,GAAG,IAAI,EACrB,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAE7C,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IACnE,IAAI,iBAAiB,CAAC,WAAW,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnD,MAAM,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,WAAW,GAAG,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAA;IACrF,MAAM,cAAc,GAAG,iBAAiB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAA;IAEzE,OAAO,GAAG,cAAc,GAAG,oBAAoB,GAAG,CAAA;AACpD,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Formats a number or a numeric string into a string representation with two decimal places.
3
+ * Used for input fields where empty string is preferred over placeholder.
4
+ * @example "123 456 789,00"
5
+ */
6
+ export declare const inputFormatFloat: (value: number | string | null | undefined) => string | null;
@@ -0,0 +1,20 @@
1
+ import { getNumberFloat } from '../../utils/getNumberFloat/getNumberFloat.js';
2
+ import { isNullOrUndefined } from '../../validators/isNullOrUndefined/isNullOrUndefined.js';
3
+ import { isNumber } from '../../validators/isNumber/isNumber.js';
4
+ import { EMPTY_INPUT_PLACEHOLDER } from '../const.js';
5
+ import { innerFormatNumber } from './utils/innerFormatNumber.js';
6
+ const DECIMALS = 2;
7
+ /**
8
+ * Formats a number or a numeric string into a string representation with two decimal places.
9
+ * Used for input fields where empty string is preferred over placeholder.
10
+ * @example "123 456 789,00"
11
+ */
12
+ export const inputFormatFloat = (value) => {
13
+ if (isNullOrUndefined(value))
14
+ return EMPTY_INPUT_PLACEHOLDER;
15
+ const valueNumber = isNumber(value) ? value : getNumberFloat(value);
16
+ if (isNullOrUndefined(valueNumber))
17
+ return EMPTY_INPUT_PLACEHOLDER;
18
+ return innerFormatNumber(valueNumber, DECIMALS);
19
+ };
20
+ //# sourceMappingURL=inputFormatFloat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputFormatFloat.js","sourceRoot":"","sources":["../../../src/formatters/formatNumber/inputFormatFloat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAEhE,MAAM,QAAQ,GAAG,CAAU,CAAA;AAE3B;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAyC,EAAiB,EAAE;IAC3F,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,uBAAuB,CAAA;IAE5D,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IACnE,IAAI,iBAAiB,CAAC,WAAW,CAAC;QAAE,OAAO,uBAAuB,CAAA;IAElE,OAAO,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;AACjD,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Formats a number or a numeric string into a string representation.
3
+ * Used for input fields where empty string is preferred over placeholder.
4
+ * @example "123 456 789"
5
+ */
6
+ export declare const inputFormatNumber: (value: number | string | null | undefined) => string | null;
@@ -0,0 +1,20 @@
1
+ import { getNumberFloat } from '../../utils/getNumberFloat/getNumberFloat.js';
2
+ import { isNullOrUndefined } from '../../validators/isNullOrUndefined/isNullOrUndefined.js';
3
+ import { isNumber } from '../../validators/isNumber/isNumber.js';
4
+ import { EMPTY_INPUT_PLACEHOLDER } from '../const.js';
5
+ import { innerFormatNumber } from './utils/innerFormatNumber.js';
6
+ const DECIMALS = 0;
7
+ /**
8
+ * Formats a number or a numeric string into a string representation.
9
+ * Used for input fields where empty string is preferred over placeholder.
10
+ * @example "123 456 789"
11
+ */
12
+ export const inputFormatNumber = (value) => {
13
+ if (isNullOrUndefined(value))
14
+ return EMPTY_INPUT_PLACEHOLDER;
15
+ const valueNumber = isNumber(value) ? value : getNumberFloat(value);
16
+ if (isNullOrUndefined(valueNumber))
17
+ return EMPTY_INPUT_PLACEHOLDER;
18
+ return innerFormatNumber(valueNumber, DECIMALS);
19
+ };
20
+ //# sourceMappingURL=inputFormatNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputFormatNumber.js","sourceRoot":"","sources":["../../../src/formatters/formatNumber/inputFormatNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAEhE,MAAM,QAAQ,GAAG,CAAU,CAAA;AAE3B;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAyC,EAAiB,EAAE;IAC5F,IAAI,iBAAiB,CAAC,KAAK,CAAC;QAAE,OAAO,uBAAuB,CAAA;IAE5D,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IACnE,IAAI,iBAAiB,CAAC,WAAW,CAAC;QAAE,OAAO,uBAAuB,CAAA;IAElE,OAAO,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;AACjD,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Internal utility to format a number with specified decimal places,
3
+ * using comma as decimal separator and space as thousand separator.
4
+ */
5
+ export declare const innerFormatNumber: (valueNumber: number, decimals: number) => string;
@@ -0,0 +1,7 @@
1
+ const THOUSAND_SEPARATOR_REG = /\B(?=(\d{3})+(?!\d))/g;
2
+ /**
3
+ * Internal utility to format a number with specified decimal places,
4
+ * using comma as decimal separator and space as thousand separator.
5
+ */
6
+ export const innerFormatNumber = (valueNumber, decimals) => valueNumber.toFixed(decimals).replace('.', ',').replaceAll(THOUSAND_SEPARATOR_REG, ' ');
7
+ //# sourceMappingURL=innerFormatNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"innerFormatNumber.js","sourceRoot":"","sources":["../../../../src/formatters/formatNumber/utils/innerFormatNumber.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAG,uBAAuB,CAAA;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAE,QAAgB,EAAU,EAAE,CACjF,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA"}
@@ -1,15 +1,15 @@
1
1
  import { isEmpty } from '../../validators/isEmpty/isEmpty.js';
2
2
  import { EMPTY_VALUE_PLACEHOLDER } from '../const.js';
3
- const PIN_CODE_REGEX = /(\d{6})(\d{1,4})/g;
3
+ import { innerFormatPin } from './utils/innerFormatPin.js';
4
4
  /**
5
5
  * Format a PIN code.
6
6
  * @example "123456/7890"
7
7
  */
8
8
  export const formatPin = (value, fallback = EMPTY_VALUE_PLACEHOLDER) => {
9
- if (Number.isNaN(value))
10
- return fallback;
11
9
  if (isEmpty(value))
12
10
  return fallback;
13
- return value.toString().replace(PIN_CODE_REGEX, `$1/$2`);
11
+ if (Number.isNaN(value))
12
+ return fallback;
13
+ return innerFormatPin(value);
14
14
  };
15
15
  //# sourceMappingURL=formatPin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatPin.js","sourceRoot":"","sources":["../../../src/formatters/formatPin/formatPin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,cAAc,GAAG,mBAAmB,CAAA;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAyC,EACzC,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IACxC,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEnC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AAC1D,CAAC,CAAA"}
1
+ {"version":3,"file":"formatPin.js","sourceRoot":"","sources":["../../../src/formatters/formatPin/formatPin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAyC,EACzC,QAAQ,GAAG,uBAAuB,EAC1B,EAAE;IACV,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IACnC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IAExC,OAAO,cAAc,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC,CAAA"}