@transferwise/components 0.0.0-experimental-76038dc → 0.0.0-experimental-5c9e189
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/build/common/initials.js +3 -0
- package/build/common/initials.js.map +1 -1
- package/build/common/initials.mjs +3 -0
- package/build/common/initials.mjs.map +1 -1
- package/build/main.css +3 -0
- package/build/styles/main.css +3 -0
- package/build/styles/upload/Upload.css +3 -0
- package/build/types/common/initials.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/common/initials.spec.tsx +42 -0
- package/src/common/initials.ts +4 -0
- package/src/main.css +3 -0
- package/src/upload/Upload.css +3 -0
- package/src/upload/Upload.less +7 -1
package/build/common/initials.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initials.js","sources":["../../src/common/initials.ts"],"sourcesContent":["export function getInitials(name: string) {\n const allInitials = name\n .split(' ')\n .map((part) => part[0])\n .join('')\n .toUpperCase();\n\n if (allInitials.length === 1) {\n return allInitials[0];\n }\n\n return allInitials[0] + allInitials.slice(-1);\n}\n"],"names":["getInitials","name","allInitials","split","map","part","join","toUpperCase","
|
|
1
|
+
{"version":3,"file":"initials.js","sources":["../../src/common/initials.ts"],"sourcesContent":["export function getInitials(name: string) {\n if (name.length === 2 && /^[A-Z]{2}$/.test(name)) {\n return name;\n }\n\n const allInitials = name\n .split(' ')\n .map((part) => part[0])\n .join('')\n .toUpperCase();\n\n if (allInitials.length === 1) {\n return allInitials[0];\n }\n\n return allInitials[0] + allInitials.slice(-1);\n}\n"],"names":["getInitials","name","length","test","allInitials","split","map","part","join","toUpperCase","slice"],"mappings":";;AAAM,SAAUA,WAAWA,CAACC,IAAY,EAAA;AACtC,EAAA,IAAIA,IAAI,CAACC,MAAM,KAAK,CAAC,IAAI,YAAY,CAACC,IAAI,CAACF,IAAI,CAAC,EAAE;AAChD,IAAA,OAAOA,IAAI;AACb;EAEA,MAAMG,WAAW,GAAGH,IAAI,CACrBI,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAAC,CAAC,CAAC,CAAC,CACtBC,IAAI,CAAC,EAAE,CAAC,CACRC,WAAW,EAAE;AAEhB,EAAA,IAAIL,WAAW,CAACF,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAOE,WAAW,CAAC,CAAC,CAAC;AACvB;EAEA,OAAOA,WAAW,CAAC,CAAC,CAAC,GAAGA,WAAW,CAACM,KAAK,CAAC,EAAE,CAAC;AAC/C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initials.mjs","sources":["../../src/common/initials.ts"],"sourcesContent":["export function getInitials(name: string) {\n const allInitials = name\n .split(' ')\n .map((part) => part[0])\n .join('')\n .toUpperCase();\n\n if (allInitials.length === 1) {\n return allInitials[0];\n }\n\n return allInitials[0] + allInitials.slice(-1);\n}\n"],"names":["getInitials","name","allInitials","split","map","part","join","toUpperCase","
|
|
1
|
+
{"version":3,"file":"initials.mjs","sources":["../../src/common/initials.ts"],"sourcesContent":["export function getInitials(name: string) {\n if (name.length === 2 && /^[A-Z]{2}$/.test(name)) {\n return name;\n }\n\n const allInitials = name\n .split(' ')\n .map((part) => part[0])\n .join('')\n .toUpperCase();\n\n if (allInitials.length === 1) {\n return allInitials[0];\n }\n\n return allInitials[0] + allInitials.slice(-1);\n}\n"],"names":["getInitials","name","length","test","allInitials","split","map","part","join","toUpperCase","slice"],"mappings":"AAAM,SAAUA,WAAWA,CAACC,IAAY,EAAA;AACtC,EAAA,IAAIA,IAAI,CAACC,MAAM,KAAK,CAAC,IAAI,YAAY,CAACC,IAAI,CAACF,IAAI,CAAC,EAAE;AAChD,IAAA,OAAOA,IAAI;AACb;EAEA,MAAMG,WAAW,GAAGH,IAAI,CACrBI,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAAC,CAAC,CAAC,CAAC,CACtBC,IAAI,CAAC,EAAE,CAAC,CACRC,WAAW,EAAE;AAEhB,EAAA,IAAIL,WAAW,CAACF,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAOE,WAAW,CAAC,CAAC,CAAC;AACvB;EAEA,OAAOA,WAAW,CAAC,CAAC,CAAC,GAAGA,WAAW,CAACM,KAAK,CAAC,EAAE,CAAC;AAC/C;;;;"}
|
package/build/main.css
CHANGED
|
@@ -5978,6 +5978,9 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5978
5978
|
.upload-error-message .alert {
|
|
5979
5979
|
min-width: 100px;
|
|
5980
5980
|
}
|
|
5981
|
+
.np-theme-personal .droppable-dropping .droppable-complete-card {
|
|
5982
|
+
display: none;
|
|
5983
|
+
}
|
|
5981
5984
|
.np-upload-input__upload-button {
|
|
5982
5985
|
position: relative;
|
|
5983
5986
|
padding: 16px;
|
package/build/styles/main.css
CHANGED
|
@@ -5978,6 +5978,9 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5978
5978
|
.upload-error-message .alert {
|
|
5979
5979
|
min-width: 100px;
|
|
5980
5980
|
}
|
|
5981
|
+
.np-theme-personal .droppable-dropping .droppable-complete-card {
|
|
5982
|
+
display: none;
|
|
5983
|
+
}
|
|
5981
5984
|
.np-upload-input__upload-button {
|
|
5982
5985
|
position: relative;
|
|
5983
5986
|
padding: 16px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initials.d.ts","sourceRoot":"","sources":["../../../src/common/initials.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"initials.d.ts","sourceRoot":"","sources":["../../../src/common/initials.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAgBvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-5c9e189",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@types/react": "^18.3.11",
|
|
81
81
|
"@types/react-dom": "^18.3.1",
|
|
82
82
|
"@types/react-transition-group": "4.4.12",
|
|
83
|
-
"@wise/art": "2.21.1
|
|
83
|
+
"@wise/art": "^2.21.1",
|
|
84
84
|
"@wise/eslint-config": "^12.3.0",
|
|
85
85
|
"babel-plugin-formatjs": "^10.5.38",
|
|
86
86
|
"enzyme": "^3.11.0",
|
|
@@ -94,16 +94,16 @@
|
|
|
94
94
|
"rollup": "^4.41.1",
|
|
95
95
|
"rollup-preserve-directives": "^1.1.3",
|
|
96
96
|
"storybook": "^8.6.14",
|
|
97
|
-
"@transferwise/less-config": "0.0.0-experimental-
|
|
97
|
+
"@transferwise/less-config": "0.0.0-experimental-5c9e189",
|
|
98
98
|
"@transferwise/neptune-css": "14.24.4",
|
|
99
|
-
"@wise/components-theming": "0.0.0-experimental-
|
|
99
|
+
"@wise/components-theming": "0.0.0-experimental-5c9e189",
|
|
100
100
|
"@wise/wds-configs": "0.0.0"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
103
|
"@transferwise/icons": "^3.22.0",
|
|
104
104
|
"@transferwise/neptune-css": "^14.24",
|
|
105
|
-
"@wise/art": "2.21
|
|
106
|
-
"@wise/components-theming": "0.0.0-experimental-
|
|
105
|
+
"@wise/art": "^2.21",
|
|
106
|
+
"@wise/components-theming": "0.0.0-experimental-5c9e189",
|
|
107
107
|
"react": ">=18",
|
|
108
108
|
"react-dom": ">=18",
|
|
109
109
|
"react-intl": "^5.10.0 || ^6"
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"@react-aria/overlays": "^3.27.1",
|
|
118
118
|
"@react-spring/web": "~10.0.1",
|
|
119
119
|
"@transferwise/formatting": "^2.13.1",
|
|
120
|
-
"@transferwise/neptune-validation": "0.0.0-experimental-
|
|
120
|
+
"@transferwise/neptune-validation": "0.0.0-experimental-5c9e189",
|
|
121
121
|
"clsx": "^2.1.1",
|
|
122
122
|
"commonmark": "^0.31.2",
|
|
123
123
|
"core-js": "^3.42.0",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getInitials } from './initials';
|
|
2
|
+
|
|
3
|
+
describe('getInitials', () => {
|
|
4
|
+
it('returns both letters if input is exactly two uppercase letters', () => {
|
|
5
|
+
expect(getInitials('ML')).toBe('ML');
|
|
6
|
+
expect(getInitials('JS')).toBe('JS');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('returns one letter if input is exactly two letters and either letter is lowercase', () => {
|
|
10
|
+
expect(getInitials('Na')).toBe('N');
|
|
11
|
+
expect(getInitials('aa')).toBe('A');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('returns first letter if only one word is given', () => {
|
|
15
|
+
expect(getInitials('Anton')).toBe('A');
|
|
16
|
+
expect(getInitials('richard')).toBe('R');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('returns first and last initials for multi-word names', () => {
|
|
20
|
+
expect(getInitials('Ness Grixti')).toBe('NG');
|
|
21
|
+
expect(getInitials('João Goão Cevada')).toBe('JC');
|
|
22
|
+
expect(getInitials('Caio Kaio Erio Orio')).toBe('CO');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('handles lowercase and mixed case names', () => {
|
|
26
|
+
expect(getInitials('ilya puchka')).toBe('IP');
|
|
27
|
+
expect(getInitials('ilYa pUchka')).toBe('IP');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('ignores extra spaces', () => {
|
|
31
|
+
expect(getInitials(' Deji Ajetomobi ')).toBe('DA');
|
|
32
|
+
expect(getInitials(' Gusso ')).toBe('G');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('returns first and last letter if name is two words with single letters', () => {
|
|
36
|
+
expect(getInitials('S L')).toBe('SL');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('handles single character', () => {
|
|
40
|
+
expect(getInitials('Q')).toBe('Q');
|
|
41
|
+
});
|
|
42
|
+
});
|
package/src/common/initials.ts
CHANGED
package/src/main.css
CHANGED
|
@@ -5978,6 +5978,9 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5978
5978
|
.upload-error-message .alert {
|
|
5979
5979
|
min-width: 100px;
|
|
5980
5980
|
}
|
|
5981
|
+
.np-theme-personal .droppable-dropping .droppable-complete-card {
|
|
5982
|
+
display: none;
|
|
5983
|
+
}
|
|
5981
5984
|
.np-upload-input__upload-button {
|
|
5982
5985
|
position: relative;
|
|
5983
5986
|
padding: 16px;
|
package/src/upload/Upload.css
CHANGED