@gouvfr-lasuite/ui-kit 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.
package/dist/index.d.ts CHANGED
@@ -448,6 +448,16 @@ export declare function getLocales(): {
448
448
  "fr-FR": any;
449
449
  };
450
450
 
451
+ /**
452
+ * Get a consistent avatar's color according to a hash of the name
453
+ */
454
+ export declare const getUserColor: (name: string) => string;
455
+
456
+ /**
457
+ * Split the name into parts and return the first two initials
458
+ */
459
+ export declare const getUserInitials: (name: string) => string;
460
+
451
461
  export declare const Header: ({ leftIcon, rightIcon, languages, onTogglePanel, isPanelOpen, }: HeaderProps) => JSX.Element;
452
462
 
453
463
  export declare const headerHeight = 52;
package/dist/index.js CHANGED
@@ -18970,10 +18970,14 @@ const c8 = (t) => {
18970
18970
  "div",
18971
18971
  {
18972
18972
  onClick: (E) => {
18973
- E.target.closest(".c__tree-view--node") || E.stopPropagation(), e == null || e();
18973
+ if (!E.target.closest(".c__tree-view--node")) {
18974
+ E.stopPropagation();
18975
+ return;
18976
+ }
18977
+ e == null || e();
18974
18978
  },
18975
18979
  onKeyDown: (E) => {
18976
- E.stopPropagation();
18980
+ E.target.closest(".c__tree-view--node") || E.stopPropagation();
18977
18981
  },
18978
18982
  ref: r,
18979
18983
  style: i,
@@ -19102,10 +19106,12 @@ const c8 = (t) => {
19102
19106
  "gold",
19103
19107
  "olive",
19104
19108
  "rose"
19105
- ], h8 = (t) => {
19106
- const e = t.split(" ");
19107
- return e.length > 2 ? e.slice(0, 2).map((n) => n[0]).join("") : e.map((n) => n[0]).join("");
19108
- }, p8 = (t) => fc[t.charCodeAt(0) % fc.length], g8 = ({
19109
+ ], h8 = (t) => t.split(/[\s-_]+/).slice(0, 2).map((e) => e[0]).join("").toUpperCase(), p8 = (t) => {
19110
+ let e = 0;
19111
+ for (let n = 0; n < t.length; n++)
19112
+ e += t.charCodeAt(n);
19113
+ return fc[e % fc.length];
19114
+ }, g8 = ({
19109
19115
  fullName: t,
19110
19116
  size: e = "medium",
19111
19117
  forceColor: n
@@ -19165,16 +19171,15 @@ const c8 = (t) => {
19165
19171
  canUpdate: i = !0,
19166
19172
  roleTopMessage: o
19167
19173
  }) => {
19168
- const { t: l } = ft(), a = dr(), s = dr(), u = [
19169
- {
19174
+ const { t: l } = ft(), a = dr(), s = dr(), u = Y(() => {
19175
+ const d = [];
19176
+ return r && d.push({
19170
19177
  label: l("components.share.access.delete"),
19171
19178
  icon: /* @__PURE__ */ y.jsx("span", { className: "material-icons", children: "back_hand" }),
19172
19179
  isDisabled: !i,
19173
- callback: () => {
19174
- r == null || r(t);
19175
- }
19176
- }
19177
- ], c = () => {
19180
+ callback: () => r(t)
19181
+ }), d;
19182
+ }, [r, t, i, l]), c = () => {
19178
19183
  const d = s.isOpen;
19179
19184
  s.setIsOpen(!d);
19180
19185
  };
@@ -19203,7 +19208,7 @@ const c8 = (t) => {
19203
19208
  roleTopMessage: o
19204
19209
  }
19205
19210
  ),
19206
- i && /* @__PURE__ */ y.jsx(
19211
+ u.length > 0 && i && /* @__PURE__ */ y.jsx(
19207
19212
  Ri,
19208
19213
  {
19209
19214
  options: u,
@@ -19538,6 +19543,8 @@ export {
19538
19543
  I8 as WithLabel,
19539
19544
  Rs as cunninghamConfig,
19540
19545
  wh as getLocales,
19546
+ p8 as getUserColor,
19547
+ h8 as getUserInitials,
19541
19548
  _8 as headerHeight,
19542
19549
  zr as isNode,
19543
19550
  xl as isSeparator,