@fluentui/react-avatar 9.11.8 → 9.11.9

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/CHANGELOG.md CHANGED
@@ -1,12 +1,29 @@
1
1
  # Change Log - @fluentui/react-avatar
2
2
 
3
- <!-- This log was last generated on Wed, 23 Sep 2026 09:03:16 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Mon, 19 Oct 2026 14:49:10 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.11.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-avatar_v9.11.9)
8
+
9
+ Mon, 19 Oct 2026 14:49:10 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-avatar_v9.11.8..@fluentui/react-avatar_v9.11.9)
11
+
12
+ ### Patches
13
+
14
+ - fix: avoid repeated scanning of unmatched name enclosures when generating initials ([PR #36738](https://github.com/microsoft/fluentui/pull/36738) by 223556219+Copilot@users.noreply.github.com)
15
+ - fix: improve phone number initials handling ([PR #36711](https://github.com/microsoft/fluentui/pull/36711) by paulmardling@microsoft.com)
16
+ - Bump @fluentui/react-badge to v9.5.7 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
+ - Bump @fluentui/react-context-selector to v9.2.21 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
18
+ - Bump @fluentui/react-jsx-runtime to v9.4.7 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
19
+ - Bump @fluentui/react-popover to v9.14.10 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
20
+ - Bump @fluentui/react-tabster to v9.26.19 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
21
+ - Bump @fluentui/react-tooltip to v9.10.8 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
22
+ - Bump @fluentui/react-utilities to v9.27.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
23
+
7
24
  ## [9.11.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-avatar_v9.11.8)
8
25
 
9
- Wed, 23 Sep 2026 09:03:16 GMT
26
+ Wed, 23 Sep 2026 09:04:33 GMT
10
27
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-avatar_v9.11.7..@fluentui/react-avatar_v9.11.8)
11
28
 
12
29
  ### Patches
package/dist/index.d.cts CHANGED
@@ -323,9 +323,6 @@ export declare type AvatarState = ComponentState<AvatarSlots> & Required<Pick<Av
323
323
  activeAriaLabelElement?: JSXElement;
324
324
  };
325
325
 
326
- /**
327
- * Regular expressions matching characters to ignore when calculating the initials.
328
- */
329
326
  /**
330
327
  * Get (up to 2 characters) initials based on display name of the persona.
331
328
  *
package/dist/index.d.ts CHANGED
@@ -323,9 +323,6 @@ export declare type AvatarState = ComponentState<AvatarSlots> & Required<Pick<Av
323
323
  activeAriaLabelElement?: JSXElement;
324
324
  };
325
325
 
326
- /**
327
- * Regular expressions matching characters to ignore when calculating the initials.
328
- */
329
326
  /**
330
327
  * Get (up to 2 characters) initials based on display name of the persona.
331
328
  *
@@ -1,9 +1,6 @@
1
1
  /**
2
- * Regular expressions matching characters to ignore when calculating the initials.
3
- */ /**
4
- * Regular expression matching characters within various types of enclosures, including the enclosures themselves
5
- * so for example, (xyz) [xyz] {xyz} all would be ignored
6
- */ const UNWANTED_ENCLOSURES_REGEX = /[\(\[\{][^\)\]\}]*[\)\]\}]/g;
2
+ * Regular expression matching complete enclosures or an unmatched enclosure tail.
3
+ */ const UNWANTED_ENCLOSURES_REGEX = /[\(\[\{][^\)\]\}]*([\)\]\}]|$)/g;
7
4
  /**
8
5
  * Regular expression matching special ASCII characters except space, plus some unicode special characters.
9
6
  * Applies after unwanted enclosures have been removed.
@@ -13,7 +10,7 @@
13
10
  /**
14
11
  * Regular expression matching phone numbers. Applied after chars matching UNWANTED_CHARS_REGEX have been removed
15
12
  * and number has been trimmed for whitespaces
16
- */ const PHONENUMBER_REGEX = /^\d+[\d\s]*(:?ext|x|)\s*\d+$/i;
13
+ */ const PHONENUMBER_REGEX = /^(?:\d[\d\s]*\d|\d[\d\s]*(?:ext|x)\s*\d+)$/i;
17
14
  /** Regular expression matching one or more spaces. */ const MULTIPLE_WHITESPACES_REGEX = /\s+/g;
18
15
  /**
19
16
  * Regular expression matching languages for which we currently don't support initials.
@@ -57,7 +54,7 @@ function getInitialsLatin(displayName, isRtl, firstInitialOnly) {
57
54
  return initials;
58
55
  }
59
56
  function cleanupDisplayName(displayName) {
60
- displayName = displayName.replace(UNWANTED_ENCLOSURES_REGEX, '');
57
+ displayName = displayName.replace(UNWANTED_ENCLOSURES_REGEX, (match, closing)=>closing ? '' : match);
61
58
  displayName = displayName.replace(UNWANTED_CHARS_REGEX, '');
62
59
  displayName = displayName.replace(MULTIPLE_WHITESPACES_REGEX, ' ');
63
60
  displayName = displayName.trim();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/getInitials.ts"],"sourcesContent":["/**\n * Regular expressions matching characters to ignore when calculating the initials.\n */\n\n/**\n * Regular expression matching characters within various types of enclosures, including the enclosures themselves\n * so for example, (xyz) [xyz] {xyz} all would be ignored\n */\nconst UNWANTED_ENCLOSURES_REGEX: RegExp = /[\\(\\[\\{][^\\)\\]\\}]*[\\)\\]\\}]/g;\n\n/**\n * Regular expression matching special ASCII characters except space, plus some unicode special characters.\n * Applies after unwanted enclosures have been removed.\n * Note: the range starts at \\uE000 (not \\uD800) to avoid matching surrogate code units, which would break\n * supplementary Unicode characters (encoded as surrogate pairs in UTF-16) such as GB18030-2022 extension characters.\n */\nconst UNWANTED_CHARS_REGEX: RegExp = /[\\0-\\u001F\\!-/:-@\\[-`\\{-\\u00BF\\u0250-\\u036F\\uE000-\\uFFFF]/g;\n\n/**\n * Regular expression matching phone numbers. Applied after chars matching UNWANTED_CHARS_REGEX have been removed\n * and number has been trimmed for whitespaces\n */\nconst PHONENUMBER_REGEX: RegExp = /^\\d+[\\d\\s]*(:?ext|x|)\\s*\\d+$/i;\n\n/** Regular expression matching one or more spaces. */\nconst MULTIPLE_WHITESPACES_REGEX: RegExp = /\\s+/g;\n\n/**\n * Regular expression matching languages for which we currently don't support initials.\n * Arabic: Arabic, Arabic Supplement, Arabic Extended-A.\n * Korean: Hangul Jamo, Hangul Compatibility Jamo, Hangul Jamo Extended-A, Hangul Syllables, Hangul Jamo Extended-B.\n * Japanese: Hiragana, Katakana.\n * CJK: CJK Unified Ideographs Extension A, CJK Unified Ideographs, CJK Compatibility Ideographs.\n * Note: Supplementary CJK characters (GB18030-2022 extension characters in Ext B-I) are intentionally not listed\n * here so they can be rendered as initials.\n */\nconst UNSUPPORTED_TEXT_REGEX: RegExp =\n /[\\u0600-\\u06FF\\u0750-\\u077F\\u08A0-\\u08FF\\u1100-\\u11FF\\u3130-\\u318F\\uA960-\\uA97F\\uAC00-\\uD7AF\\uD7B0-\\uD7FF\\u3040-\\u309F\\u30A0-\\u30FF\\u3400-\\u4DBF\\u4E00-\\u9FFF\\uF900-\\uFAFF]/;\n\nfunction getFirstCodePoint(value: string): string {\n if (!value) {\n return '';\n }\n\n const codePoint = value.codePointAt(0);\n return codePoint === undefined ? '' : String.fromCodePoint(codePoint);\n}\n\nfunction getInitialsLatin(displayName: string, isRtl: boolean, firstInitialOnly?: boolean): string {\n let initials = '';\n\n const splits: string[] = displayName.split(' ');\n if (splits.length !== 0) {\n // Use code point-aware helper to correctly handle supplementary characters (e.g. GB18030-2022 extension chars)\n // that are encoded as surrogate pairs; charAt(0) would only return half of such a character.\n initials += getFirstCodePoint(splits[0]).toUpperCase();\n }\n\n if (!firstInitialOnly) {\n if (splits.length === 2) {\n initials += getFirstCodePoint(splits[1]).toUpperCase();\n } else if (splits.length === 3) {\n initials += getFirstCodePoint(splits[2]).toUpperCase();\n }\n }\n\n if (isRtl && [...initials].length > 1) {\n const chars = [...initials];\n return chars[1] + chars[0];\n }\n\n return initials;\n}\n\nfunction cleanupDisplayName(displayName: string): string {\n displayName = displayName.replace(UNWANTED_ENCLOSURES_REGEX, '');\n displayName = displayName.replace(UNWANTED_CHARS_REGEX, '');\n displayName = displayName.replace(MULTIPLE_WHITESPACES_REGEX, ' ');\n displayName = displayName.trim();\n\n return displayName;\n}\n\n/**\n * Get (up to 2 characters) initials based on display name of the persona.\n *\n * @param displayName - The full name of the person or entity\n * @param isRtl - Whether the display is in RTL\n * @param options - Extra options to control the behavior of getInitials\n *\n * @returns The 1 or 2 character initials based on the name. Or an empty string if no initials\n * could be derived from the name.\n *\n * @internal\n */\nexport function getInitials(\n displayName: string | undefined | null,\n isRtl: boolean,\n options?: {\n /** Should initials be generated from phone numbers (default false) */\n allowPhoneInitials?: boolean;\n\n /** Returns only the first initial */\n firstInitialOnly?: boolean;\n },\n): string {\n if (!displayName) {\n return '';\n }\n\n displayName = cleanupDisplayName(displayName);\n\n // Check only the first code point against UNSUPPORTED_TEXT_REGEX so that names starting with a supported\n // character (e.g. GB18030-2022 extension characters) produce an initial even when the rest of the string\n // contains BMP CJK characters that would otherwise trigger the regex.\n const firstCodePoint = getFirstCodePoint(displayName);\n if (\n UNSUPPORTED_TEXT_REGEX.test(firstCodePoint) ||\n (!options?.allowPhoneInitials && PHONENUMBER_REGEX.test(displayName))\n ) {\n return '';\n }\n\n return getInitialsLatin(displayName, isRtl, options?.firstInitialOnly);\n}\n"],"names":["UNWANTED_ENCLOSURES_REGEX","UNWANTED_CHARS_REGEX","PHONENUMBER_REGEX","MULTIPLE_WHITESPACES_REGEX","UNSUPPORTED_TEXT_REGEX","getFirstCodePoint","value","codePoint","codePointAt","undefined","String","fromCodePoint","getInitialsLatin","displayName","isRtl","firstInitialOnly","initials","splits","split","length","toUpperCase","chars","cleanupDisplayName","replace","trim","getInitials","options","firstCodePoint","test","allowPhoneInitials"],"mappings":"AAAA;;CAEC,GAED;;;CAGC,GACD,MAAMA,4BAAoC;AAE1C;;;;;CAKC,GACD,MAAMC,uBAA+B;AAErC;;;CAGC,GACD,MAAMC,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IACT;IAEAA,cAAcS,mBAAmBT;IAEjC,yGAAyG;IACzG,yGAAyG;IACzG,sEAAsE;IACtE,MAAMc,iBAAiBtB,kBAAkBQ;IACzC,IACET,uBAAuBwB,IAAI,CAACD,mBAC3B,EAACD,oBAAAA,8BAAAA,QAASG,kBAAkB,KAAI3B,kBAAkB0B,IAAI,CAACf,cACxD;QACA,OAAO;IACT;IAEA,OAAOD,iBAAiBC,aAAaC,OAAOY,oBAAAA,8BAAAA,QAASX,gBAAgB;AACvE"}
1
+ {"version":3,"sources":["../src/utils/getInitials.ts"],"sourcesContent":["/**\n * Regular expression matching complete enclosures or an unmatched enclosure tail.\n */\nconst UNWANTED_ENCLOSURES_REGEX: RegExp = /[\\(\\[\\{][^\\)\\]\\}]*([\\)\\]\\}]|$)/g;\n\n/**\n * Regular expression matching special ASCII characters except space, plus some unicode special characters.\n * Applies after unwanted enclosures have been removed.\n * Note: the range starts at \\uE000 (not \\uD800) to avoid matching surrogate code units, which would break\n * supplementary Unicode characters (encoded as surrogate pairs in UTF-16) such as GB18030-2022 extension characters.\n */\nconst UNWANTED_CHARS_REGEX: RegExp = /[\\0-\\u001F\\!-/:-@\\[-`\\{-\\u00BF\\u0250-\\u036F\\uE000-\\uFFFF]/g;\n\n/**\n * Regular expression matching phone numbers. Applied after chars matching UNWANTED_CHARS_REGEX have been removed\n * and number has been trimmed for whitespaces\n */\nconst PHONENUMBER_REGEX: RegExp = /^(?:\\d[\\d\\s]*\\d|\\d[\\d\\s]*(?:ext|x)\\s*\\d+)$/i;\n\n/** Regular expression matching one or more spaces. */\nconst MULTIPLE_WHITESPACES_REGEX: RegExp = /\\s+/g;\n\n/**\n * Regular expression matching languages for which we currently don't support initials.\n * Arabic: Arabic, Arabic Supplement, Arabic Extended-A.\n * Korean: Hangul Jamo, Hangul Compatibility Jamo, Hangul Jamo Extended-A, Hangul Syllables, Hangul Jamo Extended-B.\n * Japanese: Hiragana, Katakana.\n * CJK: CJK Unified Ideographs Extension A, CJK Unified Ideographs, CJK Compatibility Ideographs.\n * Note: Supplementary CJK characters (GB18030-2022 extension characters in Ext B-I) are intentionally not listed\n * here so they can be rendered as initials.\n */\nconst UNSUPPORTED_TEXT_REGEX: RegExp =\n /[\\u0600-\\u06FF\\u0750-\\u077F\\u08A0-\\u08FF\\u1100-\\u11FF\\u3130-\\u318F\\uA960-\\uA97F\\uAC00-\\uD7AF\\uD7B0-\\uD7FF\\u3040-\\u309F\\u30A0-\\u30FF\\u3400-\\u4DBF\\u4E00-\\u9FFF\\uF900-\\uFAFF]/;\n\nfunction getFirstCodePoint(value: string): string {\n if (!value) {\n return '';\n }\n\n const codePoint = value.codePointAt(0);\n return codePoint === undefined ? '' : String.fromCodePoint(codePoint);\n}\n\nfunction getInitialsLatin(displayName: string, isRtl: boolean, firstInitialOnly?: boolean): string {\n let initials = '';\n\n const splits: string[] = displayName.split(' ');\n if (splits.length !== 0) {\n // Use code point-aware helper to correctly handle supplementary characters (e.g. GB18030-2022 extension chars)\n // that are encoded as surrogate pairs; charAt(0) would only return half of such a character.\n initials += getFirstCodePoint(splits[0]).toUpperCase();\n }\n\n if (!firstInitialOnly) {\n if (splits.length === 2) {\n initials += getFirstCodePoint(splits[1]).toUpperCase();\n } else if (splits.length === 3) {\n initials += getFirstCodePoint(splits[2]).toUpperCase();\n }\n }\n\n if (isRtl && [...initials].length > 1) {\n const chars = [...initials];\n return chars[1] + chars[0];\n }\n\n return initials;\n}\n\nfunction cleanupDisplayName(displayName: string): string {\n displayName = displayName.replace(UNWANTED_ENCLOSURES_REGEX, (match, closing: string) => (closing ? '' : match));\n displayName = displayName.replace(UNWANTED_CHARS_REGEX, '');\n displayName = displayName.replace(MULTIPLE_WHITESPACES_REGEX, ' ');\n displayName = displayName.trim();\n\n return displayName;\n}\n\n/**\n * Get (up to 2 characters) initials based on display name of the persona.\n *\n * @param displayName - The full name of the person or entity\n * @param isRtl - Whether the display is in RTL\n * @param options - Extra options to control the behavior of getInitials\n *\n * @returns The 1 or 2 character initials based on the name. Or an empty string if no initials\n * could be derived from the name.\n *\n * @internal\n */\nexport function getInitials(\n displayName: string | undefined | null,\n isRtl: boolean,\n options?: {\n /** Should initials be generated from phone numbers (default false) */\n allowPhoneInitials?: boolean;\n\n /** Returns only the first initial */\n firstInitialOnly?: boolean;\n },\n): string {\n if (!displayName) {\n return '';\n }\n\n displayName = cleanupDisplayName(displayName);\n\n // Check only the first code point against UNSUPPORTED_TEXT_REGEX so that names starting with a supported\n // character (e.g. GB18030-2022 extension characters) produce an initial even when the rest of the string\n // contains BMP CJK characters that would otherwise trigger the regex.\n const firstCodePoint = getFirstCodePoint(displayName);\n if (\n UNSUPPORTED_TEXT_REGEX.test(firstCodePoint) ||\n (!options?.allowPhoneInitials && PHONENUMBER_REGEX.test(displayName))\n ) {\n return '';\n }\n\n return getInitialsLatin(displayName, isRtl, options?.firstInitialOnly);\n}\n"],"names":["UNWANTED_ENCLOSURES_REGEX","UNWANTED_CHARS_REGEX","PHONENUMBER_REGEX","MULTIPLE_WHITESPACES_REGEX","UNSUPPORTED_TEXT_REGEX","getFirstCodePoint","value","codePoint","codePointAt","undefined","String","fromCodePoint","getInitialsLatin","displayName","isRtl","firstInitialOnly","initials","splits","split","length","toUpperCase","chars","cleanupDisplayName","replace","match","closing","trim","getInitials","options","firstCodePoint","test","allowPhoneInitials"],"mappings":"AAAA;;CAEC,GACD,MAAMA,4BAAoC;AAE1C;;;;;CAKC,GACD,MAAMC,uBAA+B;AAErC;;;CAGC,GACD,MAAMC,oBAA4B;AAElC,oDAAoD,GACpD,MAAMC,6BAAqC;AAE3C;;;;;;;;CAQC,GACD,MAAMC,yBACJ;AAEF,SAASC,kBAAkBC,KAAa;IACtC,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IAEA,MAAMC,YAAYD,MAAME,WAAW,CAAC;IACpC,OAAOD,cAAcE,YAAY,KAAKC,OAAOC,aAAa,CAACJ;AAC7D;AAEA,SAASK,iBAAiBC,WAAmB,EAAEC,KAAc,EAAE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aAAaC,OAAOc,oBAAAA,8BAAAA,QAASb,gBAAgB;AACvE"}
@@ -1,8 +1,5 @@
1
1
  /**
2
- * Regular expressions matching characters to ignore when calculating the initials.
3
- */ /**
4
- * Regular expression matching characters within various types of enclosures, including the enclosures themselves
5
- * so for example, (xyz) [xyz] {xyz} all would be ignored
2
+ * Regular expression matching complete enclosures or an unmatched enclosure tail.
6
3
  */ "use strict";
7
4
  Object.defineProperty(exports, "__esModule", {
8
5
  value: true
@@ -13,7 +10,7 @@ Object.defineProperty(exports, "getInitials", {
13
10
  return getInitials;
14
11
  }
15
12
  });
16
- const UNWANTED_ENCLOSURES_REGEX = /[\(\[\{][^\)\]\}]*[\)\]\}]/g;
13
+ const UNWANTED_ENCLOSURES_REGEX = /[\(\[\{][^\)\]\}]*([\)\]\}]|$)/g;
17
14
  /**
18
15
  * Regular expression matching special ASCII characters except space, plus some unicode special characters.
19
16
  * Applies after unwanted enclosures have been removed.
@@ -23,7 +20,7 @@ const UNWANTED_ENCLOSURES_REGEX = /[\(\[\{][^\)\]\}]*[\)\]\}]/g;
23
20
  /**
24
21
  * Regular expression matching phone numbers. Applied after chars matching UNWANTED_CHARS_REGEX have been removed
25
22
  * and number has been trimmed for whitespaces
26
- */ const PHONENUMBER_REGEX = /^\d+[\d\s]*(:?ext|x|)\s*\d+$/i;
23
+ */ const PHONENUMBER_REGEX = /^(?:\d[\d\s]*\d|\d[\d\s]*(?:ext|x)\s*\d+)$/i;
27
24
  /** Regular expression matching one or more spaces. */ const MULTIPLE_WHITESPACES_REGEX = /\s+/g;
28
25
  /**
29
26
  * Regular expression matching languages for which we currently don't support initials.
@@ -67,7 +64,7 @@ function getInitialsLatin(displayName, isRtl, firstInitialOnly) {
67
64
  return initials;
68
65
  }
69
66
  function cleanupDisplayName(displayName) {
70
- displayName = displayName.replace(UNWANTED_ENCLOSURES_REGEX, '');
67
+ displayName = displayName.replace(UNWANTED_ENCLOSURES_REGEX, (match, closing)=>closing ? '' : match);
71
68
  displayName = displayName.replace(UNWANTED_CHARS_REGEX, '');
72
69
  displayName = displayName.replace(MULTIPLE_WHITESPACES_REGEX, ' ');
73
70
  displayName = displayName.trim();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/getInitials.ts"],"sourcesContent":["/**\n * Regular expressions matching characters to ignore when calculating the initials.\n */\n\n/**\n * Regular expression matching characters within various types of enclosures, including the enclosures themselves\n * so for example, (xyz) [xyz] {xyz} all would be ignored\n */\nconst UNWANTED_ENCLOSURES_REGEX: RegExp = /[\\(\\[\\{][^\\)\\]\\}]*[\\)\\]\\}]/g;\n\n/**\n * Regular expression matching special ASCII characters except space, plus some unicode special characters.\n * Applies after unwanted enclosures have been removed.\n * Note: the range starts at \\uE000 (not \\uD800) to avoid matching surrogate code units, which would break\n * supplementary Unicode characters (encoded as surrogate pairs in UTF-16) such as GB18030-2022 extension characters.\n */\nconst UNWANTED_CHARS_REGEX: RegExp = /[\\0-\\u001F\\!-/:-@\\[-`\\{-\\u00BF\\u0250-\\u036F\\uE000-\\uFFFF]/g;\n\n/**\n * Regular expression matching phone numbers. Applied after chars matching UNWANTED_CHARS_REGEX have been removed\n * and number has been trimmed for whitespaces\n */\nconst PHONENUMBER_REGEX: RegExp = /^\\d+[\\d\\s]*(:?ext|x|)\\s*\\d+$/i;\n\n/** Regular expression matching one or more spaces. */\nconst MULTIPLE_WHITESPACES_REGEX: RegExp = /\\s+/g;\n\n/**\n * Regular expression matching languages for which we currently don't support initials.\n * Arabic: Arabic, Arabic Supplement, Arabic Extended-A.\n * Korean: Hangul Jamo, Hangul Compatibility Jamo, Hangul Jamo Extended-A, Hangul Syllables, Hangul Jamo Extended-B.\n * Japanese: Hiragana, Katakana.\n * CJK: CJK Unified Ideographs Extension A, CJK Unified Ideographs, CJK Compatibility Ideographs.\n * Note: Supplementary CJK characters (GB18030-2022 extension characters in Ext B-I) are intentionally not listed\n * here so they can be rendered as initials.\n */\nconst UNSUPPORTED_TEXT_REGEX: RegExp =\n /[\\u0600-\\u06FF\\u0750-\\u077F\\u08A0-\\u08FF\\u1100-\\u11FF\\u3130-\\u318F\\uA960-\\uA97F\\uAC00-\\uD7AF\\uD7B0-\\uD7FF\\u3040-\\u309F\\u30A0-\\u30FF\\u3400-\\u4DBF\\u4E00-\\u9FFF\\uF900-\\uFAFF]/;\n\nfunction getFirstCodePoint(value: string): string {\n if (!value) {\n return '';\n }\n\n const codePoint = value.codePointAt(0);\n return codePoint === undefined ? '' : String.fromCodePoint(codePoint);\n}\n\nfunction getInitialsLatin(displayName: string, isRtl: boolean, firstInitialOnly?: boolean): string {\n let initials = '';\n\n const splits: string[] = displayName.split(' ');\n if (splits.length !== 0) {\n // Use code point-aware helper to correctly handle supplementary characters (e.g. GB18030-2022 extension chars)\n // that are encoded as surrogate pairs; charAt(0) would only return half of such a character.\n initials += getFirstCodePoint(splits[0]).toUpperCase();\n }\n\n if (!firstInitialOnly) {\n if (splits.length === 2) {\n initials += getFirstCodePoint(splits[1]).toUpperCase();\n } else if (splits.length === 3) {\n initials += getFirstCodePoint(splits[2]).toUpperCase();\n }\n }\n\n if (isRtl && [...initials].length > 1) {\n const chars = [...initials];\n return chars[1] + chars[0];\n }\n\n return initials;\n}\n\nfunction cleanupDisplayName(displayName: string): string {\n displayName = displayName.replace(UNWANTED_ENCLOSURES_REGEX, '');\n displayName = displayName.replace(UNWANTED_CHARS_REGEX, '');\n displayName = displayName.replace(MULTIPLE_WHITESPACES_REGEX, ' ');\n displayName = displayName.trim();\n\n return displayName;\n}\n\n/**\n * Get (up to 2 characters) initials based on display name of the persona.\n *\n * @param displayName - The full name of the person or entity\n * @param isRtl - Whether the display is in RTL\n * @param options - Extra options to control the behavior of getInitials\n *\n * @returns The 1 or 2 character initials based on the name. Or an empty string if no initials\n * could be derived from the name.\n *\n * @internal\n */\nexport function getInitials(\n displayName: string | undefined | null,\n isRtl: boolean,\n options?: {\n /** Should initials be generated from phone numbers (default false) */\n allowPhoneInitials?: boolean;\n\n /** Returns only the first initial */\n firstInitialOnly?: boolean;\n },\n): string {\n if (!displayName) {\n return '';\n }\n\n displayName = cleanupDisplayName(displayName);\n\n // Check only the first code point against UNSUPPORTED_TEXT_REGEX so that names starting with a supported\n // character (e.g. GB18030-2022 extension characters) produce an initial even when the rest of the string\n // contains BMP CJK characters that would otherwise trigger the regex.\n const firstCodePoint = getFirstCodePoint(displayName);\n if (\n UNSUPPORTED_TEXT_REGEX.test(firstCodePoint) ||\n (!options?.allowPhoneInitials && PHONENUMBER_REGEX.test(displayName))\n ) {\n return '';\n }\n\n return getInitialsLatin(displayName, isRtl, options?.firstInitialOnly);\n}\n"],"names":["UNWANTED_ENCLOSURES_REGEX","UNWANTED_CHARS_REGEX","PHONENUMBER_REGEX","MULTIPLE_WHITESPACES_REGEX","UNSUPPORTED_TEXT_REGEX","getFirstCodePoint","value","codePoint","codePointAt","undefined","String","fromCodePoint","getInitialsLatin","displayName","isRtl","firstInitialOnly","initials","splits","split","length","toUpperCase","chars","cleanupDisplayName","replace","trim","getInitials","options","firstCodePoint","test","allowPhoneInitials"],"mappings":"AAAA;;CAEC,GAED;;;CAGC;;;;;;;eAwFeyB;;;AAvFhB,MAAMzB,4BAAoC;AAE1C;;;;;CAKC,GACD,MAAMC,uBAA+B;AAErC;;;CAGC,GACD,MAAMC,oBAA4B;AAElC,oDAAoD,GACpD,MAAMC,6BAAqC;AAE3C;;;;;;;;CAQC,GACD,MAAMC,yBACJ;AAEF,SAASC,kBAAkBC,KAAa;IACtC,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IAEA,MAAMC,YAAYD,MAAME,WAAW,CAAC;IACpC,OAAOD,cAAcE,YAAY,KAAKC,OAAOC,aAAa,CAACJ;AAC7D;AAEA,SAASK,iBAAiBC,WAAmB,EAAEC,KAAc,EAAEC,gBAA0B;IACvF,IAAIC,WAAW;IAEf,MAAMC,SAAmBJ,YAAYK,KAAK,CAAC;IAC3C,IAAID,OAAOE,MAAM,KAAK,GAAG;QACvB,+GAA+G;QAC/G,6FAA6F;QAC7FH,YAAYX,kBAAkBY,MAAM,CAAC,EAAE,EAAEG,WAAW;IACtD;IAEA,IAAI,CAACL,kBAAkB;QACrB,IAAIE,OAAOE,MAAM,KAAK,GAAG;YACvBH,YAAYX,kBAAkBY,MAAM,CAAC,EAAE,EAAEG,WAAW;QACtD,OAAO,IAAIH,OAAOE,MAAM,KAAK,GAAG;YAC9BH,YAAYX,kBAAkBY,MAAM,CAAC,EAAE,EAAEG,WAAW;QACtD;IACF;IAEA,IAAIN,SAAS;WAAIE;KAAS,CAACG,MAAM,GAAG,GAAG;QACrC,MAAME,QAAQ;eAAIL;SAAS;QAC3B,OAAOK,KAAK,CAAC,EAAE,GAAGA,KAAK,CAAC,EAAE;IAC5B;IAEA,OAAOL;AACT;AAEA,SAASM,mBAAmBT,WAAmB;IAC7CA,cAAcA,YAAYU,OAAO,CAACvB,2BAA2B;IAC7Da,cAAcA,YAAYU,OAAO,CAACtB,sBAAsB;IACxDY,cAAcA,YAAYU,OAAO,CAACpB,4BAA4B;IAC9DU,cAAcA,YAAYW,IAAI;IAE9B,OAAOX;AACT;AAcO,qBACLA,WAAsC,EACtCC,KAAc,EACdY,OAMC;IAED,IAAI,CAACb,aAAa;QAChB,OAAO;IACT;IAEAA,cAAcS,mBAAmBT;IAEjC,yGAAyG;IACzG,yGAAyG;IACzG,sEAAsE;IACtE,MAAMc,iBAAiBtB,kBAAkBQ;IACzC,IACET,uBAAuBwB,IAAI,CAACD,mBAC3B,EAACD,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASG,kBAAAA,AAAkB,KAAI3B,kBAAkB0B,IAAI,CAACf,cACxD;QACA,OAAO;IACT;IAEA,OAAOD,iBAAiBC,aAAaC,OAAOY,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASX,gBAAgB;AACvE"}
1
+ {"version":3,"sources":["../src/utils/getInitials.ts"],"sourcesContent":["/**\n * Regular expression matching complete enclosures or an unmatched enclosure tail.\n */\nconst UNWANTED_ENCLOSURES_REGEX: RegExp = /[\\(\\[\\{][^\\)\\]\\}]*([\\)\\]\\}]|$)/g;\n\n/**\n * Regular expression matching special ASCII characters except space, plus some unicode special characters.\n * Applies after unwanted enclosures have been removed.\n * Note: the range starts at \\uE000 (not \\uD800) to avoid matching surrogate code units, which would break\n * supplementary Unicode characters (encoded as surrogate pairs in UTF-16) such as GB18030-2022 extension characters.\n */\nconst UNWANTED_CHARS_REGEX: RegExp = /[\\0-\\u001F\\!-/:-@\\[-`\\{-\\u00BF\\u0250-\\u036F\\uE000-\\uFFFF]/g;\n\n/**\n * Regular expression matching phone numbers. Applied after chars matching UNWANTED_CHARS_REGEX have been removed\n * and number has been trimmed for whitespaces\n */\nconst PHONENUMBER_REGEX: RegExp = /^(?:\\d[\\d\\s]*\\d|\\d[\\d\\s]*(?:ext|x)\\s*\\d+)$/i;\n\n/** Regular expression matching one or more spaces. */\nconst MULTIPLE_WHITESPACES_REGEX: RegExp = /\\s+/g;\n\n/**\n * Regular expression matching languages for which we currently don't support initials.\n * Arabic: Arabic, Arabic Supplement, Arabic Extended-A.\n * Korean: Hangul Jamo, Hangul Compatibility Jamo, Hangul Jamo Extended-A, Hangul Syllables, Hangul Jamo Extended-B.\n * Japanese: Hiragana, Katakana.\n * CJK: CJK Unified Ideographs Extension A, CJK Unified Ideographs, CJK Compatibility Ideographs.\n * Note: Supplementary CJK characters (GB18030-2022 extension characters in Ext B-I) are intentionally not listed\n * here so they can be rendered as initials.\n */\nconst UNSUPPORTED_TEXT_REGEX: RegExp =\n /[\\u0600-\\u06FF\\u0750-\\u077F\\u08A0-\\u08FF\\u1100-\\u11FF\\u3130-\\u318F\\uA960-\\uA97F\\uAC00-\\uD7AF\\uD7B0-\\uD7FF\\u3040-\\u309F\\u30A0-\\u30FF\\u3400-\\u4DBF\\u4E00-\\u9FFF\\uF900-\\uFAFF]/;\n\nfunction getFirstCodePoint(value: string): string {\n if (!value) {\n return '';\n }\n\n const codePoint = value.codePointAt(0);\n return codePoint === undefined ? '' : String.fromCodePoint(codePoint);\n}\n\nfunction getInitialsLatin(displayName: string, isRtl: boolean, firstInitialOnly?: boolean): string {\n let initials = '';\n\n const splits: string[] = displayName.split(' ');\n if (splits.length !== 0) {\n // Use code point-aware helper to correctly handle supplementary characters (e.g. GB18030-2022 extension chars)\n // that are encoded as surrogate pairs; charAt(0) would only return half of such a character.\n initials += getFirstCodePoint(splits[0]).toUpperCase();\n }\n\n if (!firstInitialOnly) {\n if (splits.length === 2) {\n initials += getFirstCodePoint(splits[1]).toUpperCase();\n } else if (splits.length === 3) {\n initials += getFirstCodePoint(splits[2]).toUpperCase();\n }\n }\n\n if (isRtl && [...initials].length > 1) {\n const chars = [...initials];\n return chars[1] + chars[0];\n }\n\n return initials;\n}\n\nfunction cleanupDisplayName(displayName: string): string {\n displayName = displayName.replace(UNWANTED_ENCLOSURES_REGEX, (match, closing: string) => (closing ? '' : match));\n displayName = displayName.replace(UNWANTED_CHARS_REGEX, '');\n displayName = displayName.replace(MULTIPLE_WHITESPACES_REGEX, ' ');\n displayName = displayName.trim();\n\n return displayName;\n}\n\n/**\n * Get (up to 2 characters) initials based on display name of the persona.\n *\n * @param displayName - The full name of the person or entity\n * @param isRtl - Whether the display is in RTL\n * @param options - Extra options to control the behavior of getInitials\n *\n * @returns The 1 or 2 character initials based on the name. Or an empty string if no initials\n * could be derived from the name.\n *\n * @internal\n */\nexport function getInitials(\n displayName: string | undefined | null,\n isRtl: boolean,\n options?: {\n /** Should initials be generated from phone numbers (default false) */\n allowPhoneInitials?: boolean;\n\n /** Returns only the first initial */\n firstInitialOnly?: boolean;\n },\n): string {\n if (!displayName) {\n return '';\n }\n\n displayName = cleanupDisplayName(displayName);\n\n // Check only the first code point against UNSUPPORTED_TEXT_REGEX so that names starting with a supported\n // character (e.g. GB18030-2022 extension characters) produce an initial even when the rest of the string\n // contains BMP CJK characters that would otherwise trigger the regex.\n const firstCodePoint = getFirstCodePoint(displayName);\n if (\n UNSUPPORTED_TEXT_REGEX.test(firstCodePoint) ||\n (!options?.allowPhoneInitials && PHONENUMBER_REGEX.test(displayName))\n ) {\n return '';\n }\n\n return getInitialsLatin(displayName, isRtl, options?.firstInitialOnly);\n}\n"],"names":["UNWANTED_ENCLOSURES_REGEX","UNWANTED_CHARS_REGEX","PHONENUMBER_REGEX","MULTIPLE_WHITESPACES_REGEX","UNSUPPORTED_TEXT_REGEX","getFirstCodePoint","value","codePoint","codePointAt","undefined","String","fromCodePoint","getInitialsLatin","displayName","isRtl","firstInitialOnly","initials","splits","split","length","toUpperCase","chars","cleanupDisplayName","replace","match","closing","trim","getInitials","options","firstCodePoint","test","allowPhoneInitials"],"mappings":"AAAA;;CAEC;;;;;;;eAwFe2B;;;AAvFhB,MAAM3B,4BAAoC;AAE1C;;;;;CAKC,GACD,MAAMC,uBAA+B;AAErC;;;CAGC,GACD,MAAMC,oBAA4B;AAElC,oDAAoD,GACpD,MAAMC,6BAAqC;AAE3C;;;;;;;;CAQC,GACD,MAAMC,yBACJ;AAEF,SAASC,kBAAkBC,KAAa;IACtC,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IAEA,MAAMC,YAAYD,MAAME,WAAW,CAAC;IACpC,OAAOD,cAAcE,YAAY,KAAKC,OAAOC,aAAa,CAACJ;AAC7D;AAEA,SAASK,iBAAiBC,WAAmB,EAAEC,KAAc,EAAEC,gBAA0B;IACvF,IAAIC,WAAW;IAEf,MAAMC,SAAmBJ,YAAYK,KAAK,CAAC;IAC3C,IAAID,OAAOE,MAAM,KAAK,GAAG;QACvB,+GAA+G;QAC/G,6FAA6F;QAC7FH,YAAYX,kBAAkBY,MAAM,CAAC,EAAE,EAAEG,WAAW;IACtD;IAEA,IAAI,CAACL,kBAAkB;QACrB,IAAIE,OAAOE,MAAM,KAAK,GAAG;YACvBH,YAAYX,kBAAkBY,MAAM,CAAC,EAAE,EAAEG,WAAW;QACtD,OAAO,IAAIH,OAAOE,MAAM,KAAK,GAAG;YAC9BH,YAAYX,kBAAkBY,MAAM,CAAC,EAAE,EAAEG,WAAW;QACtD;IACF;IAEA,IAAIN,SAAS;WAAIE;KAAS,CAACG,MAAM,GAAG,GAAG;QACrC,MAAME,QAAQ;eAAIL;SAAS;QAC3B,OAAOK,KAAK,CAAC,EAAE,GAAGA,KAAK,CAAC,EAAE;IAC5B;IAEA,OAAOL;AACT;AAEA,SAASM,mBAAmBT,WAAmB;IAC7CA,cAAcA,YAAYU,OAAO,CAACvB,2BAA2B,CAACwB,OAAOC,UAAqBA,UAAU,KAAKD;IACzGX,cAAcA,YAAYU,OAAO,CAACtB,sBAAsB;IACxDY,cAAcA,YAAYU,OAAO,CAACpB,4BAA4B;IAC9DU,cAAcA,YAAYa,IAAI;IAE9B,OAAOb;AACT;AAcO,qBACLA,WAAsC,EACtCC,KAAc,EACdc,OAMC;IAED,IAAI,CAACf,aAAa;QAChB,OAAO;IACT;IAEAA,cAAcS,mBAAmBT;IAEjC,yGAAyG;IACzG,yGAAyG;IACzG,sEAAsE;IACtE,MAAMgB,iBAAiBxB,kBAAkBQ;IACzC,IACET,uBAAuB0B,IAAI,CAACD,mBAC3B,EAACD,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASG,kBAAAA,AAAkB,KAAI7B,kBAAkB4B,IAAI,CAACjB,cACxD;QACA,OAAO;IACT;IAEA,OAAOD,iBAAiBC,aAAaC,OAAOc,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASb,gBAAgB;AACvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-avatar",
3
- "version": "9.11.8",
3
+ "version": "9.11.9",
4
4
  "description": "React components for building Microsoft web experiences.",
5
5
  "main": "lib-commonjs/index.cjs",
6
6
  "module": "lib/index.js",
@@ -15,16 +15,16 @@
15
15
  "es6-weak-map": "^2.0.2"
16
16
  },
17
17
  "dependencies": {
18
- "@fluentui/react-badge": "^9.5.6",
19
- "@fluentui/react-context-selector": "^9.2.20",
18
+ "@fluentui/react-badge": "^9.5.7",
19
+ "@fluentui/react-context-selector": "^9.2.21",
20
20
  "@fluentui/react-icons": "^2.0.245",
21
- "@fluentui/react-jsx-runtime": "^9.4.6",
22
- "@fluentui/react-popover": "^9.14.9",
21
+ "@fluentui/react-jsx-runtime": "^9.4.7",
22
+ "@fluentui/react-popover": "^9.14.10",
23
23
  "@fluentui/react-shared-contexts": "^9.26.4",
24
- "@fluentui/react-tabster": "^9.26.18",
24
+ "@fluentui/react-tabster": "^9.26.19",
25
25
  "@fluentui/react-theme": "^9.2.2",
26
- "@fluentui/react-tooltip": "^9.10.7",
27
- "@fluentui/react-utilities": "^9.26.7",
26
+ "@fluentui/react-tooltip": "^9.10.8",
27
+ "@fluentui/react-utilities": "^9.27.0",
28
28
  "@griffel/react": "^1.5.32",
29
29
  "@swc/helpers": "^0.5.1"
30
30
  },