@ws-ui/formatter 0.1.25 → 0.1.28

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/package.json CHANGED
@@ -1,19 +1,18 @@
1
1
  {
2
2
  "name": "@ws-ui/formatter",
3
- "version": "0.1.25",
3
+ "version": "0.1.28",
4
4
  "description": "A module for formatting text, dates and numbers",
5
- "main": "dist/index.js",
6
5
  "type": "module",
7
- "module": "./dist/index.js",
6
+ "module": "./dist/index.es.js",
7
+ "main": "./dist/index.cjs.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
- "dist",
11
- "out"
10
+ "dist"
12
11
  ],
13
12
  "scripts": {
14
13
  "test:watch": "jest --watch",
15
14
  "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
16
- "build": "tsc && swc ./src -d dist -s true && npm run bundle",
15
+ "build": "vite build && tsc",
17
16
  "postbuild": "yalc push --changed",
18
17
  "bundle": "node ./scripts/bundle.js",
19
18
  "test": "jest",
@@ -34,16 +33,16 @@
34
33
  "@types/node": "^20.10.3",
35
34
  "@typescript-eslint/eslint-plugin": "^6.4.0",
36
35
  "@typescript-eslint/parser": "^6.4.0",
37
- "esbuild": "^0.19.2",
38
36
  "eslint": "^8.47.0",
39
37
  "jest": "^29.6.2",
40
38
  "jest-environment-jsdom": "^29.7.0",
41
39
  "prettier": "^3.0.2",
42
40
  "typescript": "^5.1.6",
41
+ "vite": "^5.2.12",
42
+ "vite-plugin-dts": "^3.9.1",
43
43
  "yalc": "^1.0.0-pre.53"
44
44
  },
45
45
  "dependencies": {
46
- "@ws-ui/intl": "^1.2.6",
47
46
  "numfmt": "^2.5.2"
48
47
  },
49
48
  "peerDependencies": {
package/dist/date.js DELETED
@@ -1,43 +0,0 @@
1
- import formatFn from 'date-fns/format';
2
- import Intl from '@ws-ui/intl';
3
- import * as locales from 'date-fns/locale';
4
- import { sanitizeLocale } from './duration';
5
- import(`@ws-ui/intl/locale-data/jsonp/${typeof navigator !== 'undefined' ? navigator.language : 'en'}`);
6
- function getDateFormat(options) {
7
- return new Intl.DateTimeFormat(undefined, options).resolvedOptions().resolvedFormat;
8
- }
9
- export const INVALID_DATE = new Date('').toString();
10
- export function parseDateFormat(format) {
11
- switch(format){
12
- case 'Date short':
13
- return getDateFormat();
14
- case 'Date long':
15
- return getDateFormat({
16
- weekday: 'long',
17
- year: 'numeric',
18
- month: 'long',
19
- day: 'numeric'
20
- });
21
- case 'Date abbreviated':
22
- return getDateFormat({
23
- weekday: 'short',
24
- year: 'numeric',
25
- month: 'short',
26
- day: 'numeric'
27
- });
28
- default:
29
- return format;
30
- }
31
- }
32
- export function isValidDate(value) {
33
- return value instanceof Date && value.toString() !== INVALID_DATE;
34
- }
35
- export function formatDate(value, format) {
36
- if (!isValidDate(value)) return INVALID_DATE;
37
- const parsedFormat = parseDateFormat(format);
38
- return formatFn(value, parsedFormat, {
39
- locale: locales[sanitizeLocale(navigator.language)]
40
- });
41
- }
42
-
43
- //# sourceMappingURL=date.js.map
package/dist/date.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/date.ts"],"sourcesContent":["import formatFn from 'date-fns/format';\nimport Intl from '@ws-ui/intl';\nimport * as locales from 'date-fns/locale';\nimport { sanitizeLocale } from './duration';\nimport(\n `@ws-ui/intl/locale-data/jsonp/${typeof navigator !== 'undefined' ? navigator.language : 'en'}`\n);\n\ntype ResolvedDateTimeFormatOptions = Intl.ResolvedDateTimeFormatOptions & {\n pattern?: string;\n resolvedFormat: string;\n};\n\nfunction getDateFormat(options?: Intl.DateTimeFormatOptions) {\n return (\n new Intl.DateTimeFormat(undefined, options).resolvedOptions() as ResolvedDateTimeFormatOptions\n ).resolvedFormat;\n}\n\nexport const INVALID_DATE = new Date('').toString();\n\nexport function parseDateFormat(format: string) {\n switch (format) {\n case 'Date short':\n return getDateFormat();\n case 'Date long':\n return getDateFormat({\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n });\n case 'Date abbreviated':\n return getDateFormat({\n weekday: 'short',\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n default:\n return format;\n }\n}\n\nexport function isValidDate(value: Date | number) {\n return value instanceof Date && value.toString() !== INVALID_DATE;\n}\n\nexport function formatDate(value: Date | number, format: string) {\n if (!isValidDate(value)) return INVALID_DATE;\n const parsedFormat = parseDateFormat(format);\n return formatFn(value, parsedFormat, { locale: locales[sanitizeLocale(navigator.language)] });\n}\n"],"names":["formatFn","Intl","locales","sanitizeLocale","navigator","language","getDateFormat","options","DateTimeFormat","undefined","resolvedOptions","resolvedFormat","INVALID_DATE","Date","toString","parseDateFormat","format","weekday","year","month","day","isValidDate","value","formatDate","parsedFormat","locale"],"mappings":"AAAA,OAAOA,cAAc,kBAAkB;AACvC,OAAOC,UAAU,cAAc;AAC/B,YAAYC,aAAa,kBAAkB;AAC3C,SAASC,cAAc,QAAQ,aAAa;AAC5C,MAAM,CACJ,CAAC,8BAA8B,EAAE,OAAOC,cAAc,cAAcA,UAAUC,QAAQ,GAAG,KAAK,CAAC;AAQjG,SAASC,cAAcC,OAAoC;IACzD,OAAO,AACL,IAAIN,KAAKO,cAAc,CAACC,WAAWF,SAASG,eAAe,GAC3DC,cAAc;AAClB;AAEA,OAAO,MAAMC,eAAe,IAAIC,KAAK,IAAIC,QAAQ,GAAG;AAEpD,OAAO,SAASC,gBAAgBC,MAAc;IAC5C,OAAQA;QACN,KAAK;YACH,OAAOV;QACT,KAAK;YACH,OAAOA,cAAc;gBACnBW,SAAS;gBACTC,MAAM;gBACNC,OAAO;gBACPC,KAAK;YACP;QACF,KAAK;YACH,OAAOd,cAAc;gBACnBW,SAAS;gBACTC,MAAM;gBACNC,OAAO;gBACPC,KAAK;YACP;QACF;YACE,OAAOJ;IACX;AACF;AAEA,OAAO,SAASK,YAAYC,KAAoB;IAC9C,OAAOA,iBAAiBT,QAAQS,MAAMR,QAAQ,OAAOF;AACvD;AAEA,OAAO,SAASW,WAAWD,KAAoB,EAAEN,MAAc;IAC7D,IAAI,CAACK,YAAYC,QAAQ,OAAOV;IAChC,MAAMY,eAAeT,gBAAgBC;IACrC,OAAOhB,SAASsB,OAAOE,cAAc;QAAEC,QAAQvB,OAAO,CAACC,eAAeC,UAAUC,QAAQ,EAAE;IAAC;AAC7F"}
package/dist/duration.js DELETED
@@ -1,70 +0,0 @@
1
- import { formatDistance, formatDistanceStrict } from 'date-fns';
2
- import * as locales from 'date-fns/locale';
3
- const SECONDS = 1000;
4
- const MINUTES = SECONDS * 60;
5
- const HOURS = MINUTES * 60;
6
- function padNumber(value, digits = 2) {
7
- return `${String(value).padStart(digits, '0')}`;
8
- }
9
- export function sanitizeLocale(locale) {
10
- const [language, region = ''] = locale.split('-');
11
- const lang = language.toLowerCase();
12
- const key = lang + region.toUpperCase();
13
- if (locales[key]) {
14
- return key;
15
- } else {
16
- return lang;
17
- }
18
- }
19
- export function formatDuration(value, format = 'Simple') {
20
- if ([
21
- 'Simple',
22
- 'Without seconds'
23
- ].includes(format)) {
24
- let v = +value;
25
- let isNegative = false;
26
- if (v < 0) {
27
- v = -v;
28
- isNegative = true;
29
- }
30
- const hours = Math.floor(v / HOURS);
31
- const minutes = Math.floor(v % HOURS / MINUTES);
32
- const seconds = Math.floor(v % MINUTES / SECONDS);
33
- switch(format){
34
- case 'Simple':
35
- return `${isNegative ? '-' : ''}${padNumber(hours)}:${padNumber(minutes)}:${padNumber(seconds)}`;
36
- case 'Without seconds':
37
- return `${isNegative ? '-' : ''}${padNumber(hours)}:${padNumber(minutes)}`;
38
- }
39
- }
40
- const d1 = new Date();
41
- const d2 = value instanceof Date ? value : new Date(d1.getTime() + +value);
42
- const l = typeof navigator !== 'undefined' && locales[sanitizeLocale(navigator.language)] ? locales[sanitizeLocale(navigator.language)] : locales.enUS;
43
- switch(format){
44
- case 'Distance':
45
- return formatDistance(d2, d1, {
46
- locale: l
47
- });
48
- case 'Distance With Suffix':
49
- return formatDistance(d2, d1, {
50
- addSuffix: true,
51
- locale: l
52
- });
53
- case 'Strict Distance':
54
- return formatDistanceStrict(d2, d1, {
55
- locale: l
56
- });
57
- case 'Strict Distance With Suffix':
58
- return formatDistanceStrict(d2, d1, {
59
- addSuffix: true,
60
- locale: l
61
- });
62
- }
63
- }
64
- export function parseDuration(value) {
65
- const [hours = 0, minutes = 0, seconds = 0] = value.split(':').map(Number);
66
- const duration = Math.abs(hours) * HOURS + minutes * MINUTES + seconds * SECONDS;
67
- return hours < 0 ? -duration : duration;
68
- }
69
-
70
- //# sourceMappingURL=duration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/duration.ts"],"sourcesContent":["import { formatDistance, formatDistanceStrict } from 'date-fns';\nimport * as locales from 'date-fns/locale';\n\nexport type Format =\n | 'Simple'\n | 'Distance'\n | 'Without seconds'\n | 'Distance With Suffix'\n | 'Strict Distance'\n | 'Strict Distance With Suffix';\n\nconst SECONDS = 1000;\nconst MINUTES = SECONDS * 60;\nconst HOURS = MINUTES * 60;\n\nfunction padNumber(value: number, digits: number = 2) {\n return `${String(value).padStart(digits, '0')}`;\n}\n\nexport function sanitizeLocale(locale: string) {\n const [language, region = ''] = locale.split('-');\n const lang = language.toLowerCase();\n const key = lang + region.toUpperCase();\n if (locales[key]) {\n return key;\n } else {\n return lang;\n }\n}\n\nexport function formatDuration(value: string | number | Date, format: Format = 'Simple') {\n if (['Simple', 'Without seconds'].includes(format)) {\n let v = +value;\n let isNegative = false;\n\n if (v < 0) {\n v = -v;\n isNegative = true;\n }\n\n const hours = Math.floor(v / HOURS);\n const minutes = Math.floor((v % HOURS) / MINUTES);\n const seconds = Math.floor((v % MINUTES) / SECONDS);\n\n switch (format) {\n case 'Simple':\n return `${isNegative ? '-' : ''}${padNumber(hours)}:${padNumber(minutes)}:${padNumber(\n seconds,\n )}`;\n case 'Without seconds':\n return `${isNegative ? '-' : ''}${padNumber(hours)}:${padNumber(minutes)}`;\n }\n }\n\n const d1 = new Date();\n const d2 = value instanceof Date ? value : new Date(d1.getTime() + +value);\n const l =\n typeof navigator !== 'undefined' && locales[sanitizeLocale(navigator.language)]\n ? locales[sanitizeLocale(navigator.language)]\n : locales.enUS;\n\n switch (format) {\n case 'Distance':\n return formatDistance(d2, d1, {\n locale: l,\n });\n case 'Distance With Suffix':\n return formatDistance(d2, d1, {\n addSuffix: true,\n locale: l,\n });\n case 'Strict Distance':\n return formatDistanceStrict(d2, d1, {\n locale: l,\n });\n case 'Strict Distance With Suffix':\n return formatDistanceStrict(d2, d1, {\n addSuffix: true,\n locale: l,\n });\n }\n}\n\nexport function parseDuration(value: string) {\n const [hours = 0, minutes = 0, seconds = 0] = value.split(':').map(Number);\n\n const duration = Math.abs(hours) * HOURS + minutes * MINUTES + seconds * SECONDS;\n\n return hours < 0 ? -duration : duration;\n}\n"],"names":["formatDistance","formatDistanceStrict","locales","SECONDS","MINUTES","HOURS","padNumber","value","digits","String","padStart","sanitizeLocale","locale","language","region","split","lang","toLowerCase","key","toUpperCase","formatDuration","format","includes","v","isNegative","hours","Math","floor","minutes","seconds","d1","Date","d2","getTime","l","navigator","enUS","addSuffix","parseDuration","map","Number","duration","abs"],"mappings":"AAAA,SAASA,cAAc,EAAEC,oBAAoB,QAAQ,WAAW;AAChE,YAAYC,aAAa,kBAAkB;AAU3C,MAAMC,UAAU;AAChB,MAAMC,UAAUD,UAAU;AAC1B,MAAME,QAAQD,UAAU;AAExB,SAASE,UAAUC,KAAa,EAAEC,SAAiB,CAAC;IAClD,OAAO,CAAC,EAAEC,OAAOF,OAAOG,QAAQ,CAACF,QAAQ,KAAK,CAAC;AACjD;AAEA,OAAO,SAASG,eAAeC,MAAc;IAC3C,MAAM,CAACC,UAAUC,SAAS,EAAE,CAAC,GAAGF,OAAOG,KAAK,CAAC;IAC7C,MAAMC,OAAOH,SAASI,WAAW;IACjC,MAAMC,MAAMF,OAAOF,OAAOK,WAAW;IACrC,IAAIjB,OAAO,CAACgB,IAAI,EAAE;QAChB,OAAOA;IACT,OAAO;QACL,OAAOF;IACT;AACF;AAEA,OAAO,SAASI,eAAeb,KAA6B,EAAEc,SAAiB,QAAQ;IACrF,IAAI;QAAC;QAAU;KAAkB,CAACC,QAAQ,CAACD,SAAS;QAClD,IAAIE,IAAI,CAAChB;QACT,IAAIiB,aAAa;QAEjB,IAAID,IAAI,GAAG;YACTA,IAAI,CAACA;YACLC,aAAa;QACf;QAEA,MAAMC,QAAQC,KAAKC,KAAK,CAACJ,IAAIlB;QAC7B,MAAMuB,UAAUF,KAAKC,KAAK,CAAC,AAACJ,IAAIlB,QAASD;QACzC,MAAMyB,UAAUH,KAAKC,KAAK,CAAC,AAACJ,IAAInB,UAAWD;QAE3C,OAAQkB;YACN,KAAK;gBACH,OAAO,CAAC,EAAEG,aAAa,MAAM,GAAG,EAAElB,UAAUmB,OAAO,CAAC,EAAEnB,UAAUsB,SAAS,CAAC,EAAEtB,UAC1EuB,SACA,CAAC;YACL,KAAK;gBACH,OAAO,CAAC,EAAEL,aAAa,MAAM,GAAG,EAAElB,UAAUmB,OAAO,CAAC,EAAEnB,UAAUsB,SAAS,CAAC;QAC9E;IACF;IAEA,MAAME,KAAK,IAAIC;IACf,MAAMC,KAAKzB,iBAAiBwB,OAAOxB,QAAQ,IAAIwB,KAAKD,GAAGG,OAAO,KAAK,CAAC1B;IACpE,MAAM2B,IACJ,OAAOC,cAAc,eAAejC,OAAO,CAACS,eAAewB,UAAUtB,QAAQ,EAAE,GAC3EX,OAAO,CAACS,eAAewB,UAAUtB,QAAQ,EAAE,GAC3CX,QAAQkC,IAAI;IAElB,OAAQf;QACN,KAAK;YACH,OAAOrB,eAAegC,IAAIF,IAAI;gBAC5BlB,QAAQsB;YACV;QACF,KAAK;YACH,OAAOlC,eAAegC,IAAIF,IAAI;gBAC5BO,WAAW;gBACXzB,QAAQsB;YACV;QACF,KAAK;YACH,OAAOjC,qBAAqB+B,IAAIF,IAAI;gBAClClB,QAAQsB;YACV;QACF,KAAK;YACH,OAAOjC,qBAAqB+B,IAAIF,IAAI;gBAClCO,WAAW;gBACXzB,QAAQsB;YACV;IACJ;AACF;AAEA,OAAO,SAASI,cAAc/B,KAAa;IACzC,MAAM,CAACkB,QAAQ,CAAC,EAAEG,UAAU,CAAC,EAAEC,UAAU,CAAC,CAAC,GAAGtB,MAAMQ,KAAK,CAAC,KAAKwB,GAAG,CAACC;IAEnE,MAAMC,WAAWf,KAAKgB,GAAG,CAACjB,SAASpB,QAAQuB,UAAUxB,UAAUyB,UAAU1B;IAEzE,OAAOsB,QAAQ,IAAI,CAACgB,WAAWA;AACjC"}
package/dist/index.js DELETED
@@ -1,39 +0,0 @@
1
- import numfmt from 'numfmt';
2
- import { formatString } from './string';
3
- import { formatDate, parseDateFormat, isValidDate, INVALID_DATE } from './date';
4
- import { formatDuration, parseDuration } from './duration';
5
- function format(rawValue, dataType, format) {
6
- switch(dataType){
7
- // string formatting
8
- case 'string':
9
- return formatString(rawValue, format);
10
- // date formatting
11
- case 'date':
12
- return formatDate(rawValue instanceof Date ? rawValue : new Date(rawValue), format);
13
- // number formatting
14
- case 'number':
15
- return numfmt(format)(isNaN(rawValue) ? rawValue : +rawValue);
16
- // duration formatting
17
- case 'duration':
18
- return formatDuration(rawValue, format);
19
- default:
20
- return rawValue;
21
- }
22
- }
23
- function getStyle(dataType, format, value) {
24
- switch(dataType){
25
- case 'number':
26
- {
27
- const color = numfmt(format).color(isNaN(value) ? value : +value);
28
- if (color === 'black' && !format.toLowerCase().includes('[black]')) return {};
29
- return {
30
- color
31
- };
32
- }
33
- default:
34
- return {};
35
- }
36
- }
37
- export { format, parseDateFormat, parseDuration, isValidDate, INVALID_DATE, getStyle };
38
-
39
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import numfmt from 'numfmt';\nimport { Format, formatString } from './string';\nimport { formatDate, parseDateFormat, isValidDate, INVALID_DATE } from './date';\nimport { formatDuration, Format as DurationFormat, parseDuration } from './duration';\n\nexport type DataType = 'string' | 'date' | 'number' | 'duration';\n\nfunction format(rawValue: unknown, dataType: DataType, format?: string | Format): string {\n switch (dataType) {\n // string formatting\n case 'string':\n return formatString(rawValue as string, format as Format) as string;\n // date formatting\n case 'date':\n return formatDate(rawValue instanceof Date ? rawValue : new Date(rawValue as string), format);\n // number formatting\n case 'number':\n return numfmt(format)(isNaN(rawValue as number) ? rawValue : +rawValue);\n // duration formatting\n case 'duration':\n return formatDuration(rawValue as string | number | Date, format as DurationFormat);\n default:\n return rawValue as string;\n }\n}\n\nfunction getStyle(dataType: DataType, format: string | Format, value: unknown) {\n switch (dataType) {\n case 'number': {\n const color = numfmt(format).color(isNaN(value as number) ? value : +value);\n if (color === 'black' && !format.toLowerCase().includes('[black]')) return {};\n return { color };\n }\n default:\n return {};\n }\n}\n\nexport { format, parseDateFormat, parseDuration, isValidDate, INVALID_DATE, getStyle };\n"],"names":["numfmt","formatString","formatDate","parseDateFormat","isValidDate","INVALID_DATE","formatDuration","parseDuration","format","rawValue","dataType","Date","isNaN","getStyle","value","color","toLowerCase","includes"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,SAAiBC,YAAY,QAAQ,WAAW;AAChD,SAASC,UAAU,EAAEC,eAAe,EAAEC,WAAW,EAAEC,YAAY,QAAQ,SAAS;AAChF,SAASC,cAAc,EAA4BC,aAAa,QAAQ,aAAa;AAIrF,SAASC,OAAOC,QAAiB,EAAEC,QAAkB,EAAEF,MAAwB;IAC7E,OAAQE;QACN,oBAAoB;QACpB,KAAK;YACH,OAAOT,aAAaQ,UAAoBD;QAC1C,kBAAkB;QAClB,KAAK;YACH,OAAON,WAAWO,oBAAoBE,OAAOF,WAAW,IAAIE,KAAKF,WAAqBD;QACxF,oBAAoB;QACpB,KAAK;YACH,OAAOR,OAAOQ,QAAQI,MAAMH,YAAsBA,WAAW,CAACA;QAChE,sBAAsB;QACtB,KAAK;YACH,OAAOH,eAAeG,UAAoCD;QAC5D;YACE,OAAOC;IACX;AACF;AAEA,SAASI,SAASH,QAAkB,EAAEF,MAAuB,EAAEM,KAAc;IAC3E,OAAQJ;QACN,KAAK;YAAU;gBACb,MAAMK,QAAQf,OAAOQ,QAAQO,KAAK,CAACH,MAAME,SAAmBA,QAAQ,CAACA;gBACrE,IAAIC,UAAU,WAAW,CAACP,OAAOQ,WAAW,GAAGC,QAAQ,CAAC,YAAY,OAAO,CAAC;gBAC5E,OAAO;oBAAEF;gBAAM;YACjB;QACA;YACE,OAAO,CAAC;IACZ;AACF;AAEA,SAASP,MAAM,EAAEL,eAAe,EAAEI,aAAa,EAAEH,WAAW,EAAEC,YAAY,EAAEQ,QAAQ,GAAG"}
package/dist/string.js DELETED
@@ -1,29 +0,0 @@
1
- function _capitalizeEachWord(value) {
2
- return value.split(' ').map(_toLower).map(_capitalize).join(' ');
3
- }
4
- function _upperCase(value) {
5
- return value.toUpperCase();
6
- }
7
- function _toLower(value) {
8
- return value.toLowerCase();
9
- }
10
- function _capitalize(value) {
11
- return value ? value.charAt(0).toUpperCase() + value.slice(1).toLowerCase() : '';
12
- }
13
- export function formatString(value, format) {
14
- const v = value ? value.toString() : '';
15
- switch(format){
16
- case 'U':
17
- return _upperCase(_toLower(v));
18
- case 'l':
19
- return _toLower(v);
20
- case 'C':
21
- return _capitalize(_toLower(v));
22
- case 'c':
23
- return _capitalizeEachWord(v);
24
- default:
25
- return value;
26
- }
27
- }
28
-
29
- //# sourceMappingURL=string.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/string.ts"],"sourcesContent":["function _capitalizeEachWord(value: string) {\n return value.split(' ').map(_toLower).map(_capitalize).join(' ');\n}\n\nfunction _upperCase(value: string) {\n return value.toUpperCase();\n}\n\nfunction _toLower(value: string) {\n return value.toLowerCase();\n}\n\nfunction _capitalize(value: string) {\n return value ? value.charAt(0).toUpperCase() + value.slice(1).toLowerCase() : '';\n}\n\nexport type Format = 'U' | 'l' | 'C' | 'c';\n\nexport function formatString(value: string | null | Date | number, format: Format) {\n const v = value ? value.toString() : '';\n switch (format) {\n case 'U':\n return _upperCase(_toLower(v));\n case 'l':\n return _toLower(v);\n case 'C':\n return _capitalize(_toLower(v));\n case 'c':\n return _capitalizeEachWord(v);\n default:\n return value;\n }\n}\n"],"names":["_capitalizeEachWord","value","split","map","_toLower","_capitalize","join","_upperCase","toUpperCase","toLowerCase","charAt","slice","formatString","format","v","toString"],"mappings":"AAAA,SAASA,oBAAoBC,KAAa;IACxC,OAAOA,MAAMC,KAAK,CAAC,KAAKC,GAAG,CAACC,UAAUD,GAAG,CAACE,aAAaC,IAAI,CAAC;AAC9D;AAEA,SAASC,WAAWN,KAAa;IAC/B,OAAOA,MAAMO,WAAW;AAC1B;AAEA,SAASJ,SAASH,KAAa;IAC7B,OAAOA,MAAMQ,WAAW;AAC1B;AAEA,SAASJ,YAAYJ,KAAa;IAChC,OAAOA,QAAQA,MAAMS,MAAM,CAAC,GAAGF,WAAW,KAAKP,MAAMU,KAAK,CAAC,GAAGF,WAAW,KAAK;AAChF;AAIA,OAAO,SAASG,aAAaX,KAAoC,EAAEY,MAAc;IAC/E,MAAMC,IAAIb,QAAQA,MAAMc,QAAQ,KAAK;IACrC,OAAQF;QACN,KAAK;YACH,OAAON,WAAWH,SAASU;QAC7B,KAAK;YACH,OAAOV,SAASU;QAClB,KAAK;YACH,OAAOT,YAAYD,SAASU;QAC9B,KAAK;YACH,OAAOd,oBAAoBc;QAC7B;YACE,OAAOb;IACX;AACF"}