mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
feat: implement person name utility functions and update related components for name handling
This commit is contained in:
@@ -23,3 +23,4 @@ export * from "./lib/feedback/use-error-handler";
|
||||
export * from "./lib/data/useServerTable";
|
||||
export * from "./lib/landing/LandingPage";
|
||||
export * from "./lib/landing/landing-copy";
|
||||
export * from "./lib/utils/person-name";
|
||||
|
||||
19
libs/ui/src/lib/utils/person-name.ts
Normal file
19
libs/ui/src/lib/utils/person-name.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Splits and joins a person's name between the account's single `name.en`
|
||||
* string and the profile's separate `firstName`/`middleName`/`lastName`
|
||||
* fields.
|
||||
*
|
||||
* The account has no first/middle/last columns of its own (that model lives
|
||||
* only on the profile), so this is the one place that heuristic lives —
|
||||
* reused everywhere a name crosses that boundary: the signup form joins into
|
||||
* it, the Identity Details wizard step and the Profile page's Personal tab
|
||||
* both split out of it.
|
||||
*/
|
||||
export function splitPersonName(fullName: string) {
|
||||
const [firstName = '', middleName = '', ...rest] = fullName.trim().split(/\s+/);
|
||||
return { firstName, middleName, lastName: rest.join(' ') };
|
||||
}
|
||||
|
||||
export function joinPersonName(parts: { firstName: string; middleName?: string; lastName: string }) {
|
||||
return [parts.firstName, parts.middleName, parts.lastName].filter(Boolean).join(' ');
|
||||
}
|
||||
Reference in New Issue
Block a user