@asteby/metacore-ui 0.6.0 → 0.7.0

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.
@@ -0,0 +1,19 @@
1
+ export interface GetInitialsOptions {
2
+ /** Maximum number of initials to take. Defaults to 2. */
3
+ max?: number;
4
+ /** Fallback when the input is empty / nullish. Defaults to '?'. */
5
+ fallback?: string;
6
+ }
7
+ /**
8
+ * Returns the uppercase initials of a name. Splits on whitespace, takes the
9
+ * first character of each token, caps at `max` (default 2). Trims the input
10
+ * and returns `fallback` when the result would be empty.
11
+ *
12
+ * getInitials('Alice Johnson') // 'AJ'
13
+ * getInitials(' alice johnson ') // 'AJ'
14
+ * getInitials('Maria del Carmen', { max: 3 }) // 'MDC'
15
+ * getInitials('') // '?'
16
+ * getInitials(undefined) // '?'
17
+ */
18
+ export declare function getInitials(name: string | null | undefined, options?: GetInitialsOptions): string;
19
+ //# sourceMappingURL=get-initials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-initials.d.ts","sourceRoot":"","sources":["../../src/lib/get-initials.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IAC/B,yDAAyD;IACzD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACvB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,GAAE,kBAAuB,GACjC,MAAM,CAaR"}
@@ -0,0 +1,31 @@
1
+ // Tiny helper used by every avatar in the platform — chat headers, profile
2
+ // dropdowns, dynamic-table avatar cells, sidebar nav, etc. Lived inline in
3
+ // each app for too long. Centralised here so a single fix propagates.
4
+ /**
5
+ * Returns the uppercase initials of a name. Splits on whitespace, takes the
6
+ * first character of each token, caps at `max` (default 2). Trims the input
7
+ * and returns `fallback` when the result would be empty.
8
+ *
9
+ * getInitials('Alice Johnson') // 'AJ'
10
+ * getInitials(' alice johnson ') // 'AJ'
11
+ * getInitials('Maria del Carmen', { max: 3 }) // 'MDC'
12
+ * getInitials('') // '?'
13
+ * getInitials(undefined) // '?'
14
+ */
15
+ export function getInitials(name, options = {}) {
16
+ const { max = 2, fallback = '?' } = options;
17
+ if (!name)
18
+ return fallback;
19
+ const trimmed = name.trim();
20
+ if (!trimmed)
21
+ return fallback;
22
+ const initials = trimmed
23
+ .split(/\s+/)
24
+ .map((part) => part[0] ?? '')
25
+ .filter(Boolean)
26
+ .slice(0, max)
27
+ .join('')
28
+ .toUpperCase();
29
+ return initials || fallback;
30
+ }
31
+ //# sourceMappingURL=get-initials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-initials.js","sourceRoot":"","sources":["../../src/lib/get-initials.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,sEAAsE;AAStE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACvB,IAA+B,EAC/B,UAA8B,EAAE;IAEhC,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,QAAQ,GAAG,GAAG,EAAE,GAAG,OAAO,CAAA;IAC3C,IAAI,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAA;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IAC3B,IAAI,CAAC,OAAO;QAAE,OAAO,QAAQ,CAAA;IAC7B,MAAM,QAAQ,GAAG,OAAO;SACnB,KAAK,CAAC,KAAK,CAAC;SACZ,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAC5B,MAAM,CAAC,OAAO,CAAC;SACf,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;SACb,IAAI,CAAC,EAAE,CAAC;SACR,WAAW,EAAE,CAAA;IAClB,OAAO,QAAQ,IAAI,QAAQ,CAAA;AAC/B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { cn, getPageNumbers, sleep } from './utils';
2
2
  export { getCookie, setCookie, removeCookie } from './cookies';
3
3
  export { resolveColorHex, resolveColorCss, generateBadgeStyles, } from './option-colors';
4
+ export { getInitials, type GetInitialsOptions } from './get-initials';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAA"}
package/dist/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { cn, getPageNumbers, sleep } from './utils';
2
2
  export { getCookie, setCookie, removeCookie } from './cookies';
3
3
  export { resolveColorHex, resolveColorCss, generateBadgeStyles, } from './option-colors';
4
+ export { getInitials } from './get-initials';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,WAAW,EAA2B,MAAM,gBAAgB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/metacore-ui",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Metacore UI kit — data-table, layout shell, command-menu, hooks y primitives shadcn reutilizables",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {