@hanzo/ui 8.0.8 → 8.0.11

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.
@@ -969,6 +969,44 @@ function AppHeader({
969
969
  ] })
970
970
  ] });
971
971
  }
972
+ function monogram(name) {
973
+ const words = name.trim().split(/[\s._/-]+/).filter(Boolean);
974
+ const letters = words.slice(0, 2).map((w) => w[0] ?? "").join("");
975
+ return (letters || name.trim().slice(0, 2)).toUpperCase();
976
+ }
977
+ function OrgMark({ org, size = 22, maxW }) {
978
+ if (org.logo) {
979
+ return /* @__PURE__ */ jsxRuntime.jsx(
980
+ "img",
981
+ {
982
+ src: org.logo,
983
+ alt: "",
984
+ style: {
985
+ height: size,
986
+ width: maxW ? "auto" : size,
987
+ maxWidth: maxW ?? size,
988
+ objectFit: "contain",
989
+ display: "block",
990
+ borderRadius: 6,
991
+ flexShrink: 0
992
+ }
993
+ }
994
+ );
995
+ }
996
+ return /* @__PURE__ */ jsxRuntime.jsx(
997
+ gui.YStack,
998
+ {
999
+ width: size,
1000
+ height: size,
1001
+ rounded: "$3",
1002
+ bg: "$color4",
1003
+ items: "center",
1004
+ justify: "center",
1005
+ style: { flexShrink: 0 },
1006
+ children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: Math.round(size * 0.4), fontWeight: "800", color: "$color12", children: monogram(org.displayName || org.name) })
1007
+ }
1008
+ );
1009
+ }
972
1010
 
973
1011
  // src/product/scope.ts
974
1012
  function browserStorage() {
@@ -1038,14 +1076,7 @@ function filterOrgs(orgs, query) {
1038
1076
  );
1039
1077
  }
1040
1078
  var titleCase = (s) => s ? s[0].toUpperCase() + s.slice(1) : s;
1041
- var initialsOf = (o) => (o.displayName || o.name).split(/\s+/).map((w) => w[0]).join("").slice(0, 2).toUpperCase();
1042
- function OrgAvatar({ org, size = 22 }) {
1043
- if (org.logo) {
1044
- return /* @__PURE__ */ jsxRuntime.jsx("img", { src: org.logo, alt: "", style: { height: size, width: size, objectFit: "contain", display: "block", borderRadius: 6 } });
1045
- }
1046
- return /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { width: size, height: size, rounded: "$3", bg: "$color4", items: "center", justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$1", fontWeight: "800", color: "$color12", children: initialsOf(org) }) });
1047
- }
1048
- function OrgSwitcher({ scope, orgs, pageSize = 20, create, picker = false }) {
1079
+ function OrgSwitcher({ scope, orgs, pageSize = 20, current: given, create, picker = false }) {
1049
1080
  const currentId = scope.currentOrg();
1050
1081
  const [open, setOpen] = react.useState(false);
1051
1082
  const [query, setQuery] = react.useState("");
@@ -1105,10 +1136,11 @@ function OrgSwitcher({ scope, orgs, pageSize = 20, create, picker = false }) {
1105
1136
  if (orgs) return filterOrgs(rows, query);
1106
1137
  return [{ name: currentId, displayName: titleCase(currentId) }];
1107
1138
  }, [orgs, rows, query, currentId]);
1108
- const current = react.useMemo(
1109
- () => rows.find((o) => o.name === currentId) ?? { name: currentId, displayName: titleCase(currentId) },
1110
- [rows, currentId]
1111
- );
1139
+ const current = react.useMemo(() => {
1140
+ if (given && given.name === currentId) return given;
1141
+ return rows.find((o) => o.name === currentId) ?? { name: currentId, displayName: titleCase(currentId) };
1142
+ }, [given, rows, currentId]);
1143
+ const currentLabel = current.displayName || titleCase(current.name);
1112
1144
  const select = react.useCallback(
1113
1145
  (org) => {
1114
1146
  setOpen(false);
@@ -1130,7 +1162,11 @@ function OrgSwitcher({ scope, orgs, pageSize = 20, create, picker = false }) {
1130
1162
  }
1131
1163
  };
1132
1164
  return /* @__PURE__ */ jsxRuntime.jsxs(gui.Popover, { open, onOpenChange: setOpen, placement: "bottom-start", children: [
1133
- /* @__PURE__ */ jsxRuntime.jsx(gui.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsxRuntime.jsx(OrgAvatar, { org: current, size: 18 }), iconAfter: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.ChevronsUpDown, { size: 13 }), children: current.displayName || titleCase(current.name) }) }),
1165
+ /* @__PURE__ */ jsxRuntime.jsx(gui.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { chromeless: true, height: 44, px: "$2", justify: "flex-start", "aria-label": `${currentLabel} \xB7 switch organization`, children: /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", gap: "$2.5", flex: 1, minW: 0, children: [
1166
+ /* @__PURE__ */ jsxRuntime.jsx(OrgMark, { org: current, size: 30 }),
1167
+ /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { flex: 1, minW: 0, fontSize: "$4", fontWeight: "800", color: "$color12", numberOfLines: 1, children: currentLabel }),
1168
+ /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.ChevronsUpDown, { size: 15, color: "$color9" })
1169
+ ] }) }) }),
1134
1170
  /* @__PURE__ */ jsxRuntime.jsx(gui.Popover.Content, { bordered: true, elevate: true, p: "$2", width: 300, bg: "$color2", borderColor: "$borderColor", children: creating ? /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$2", children: [
1135
1171
  /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$color12", fontWeight: "700", children: "Create organization" }),
1136
1172
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1201,7 +1237,7 @@ function OrgSwitcher({ scope, orgs, pageSize = 20, create, picker = false }) {
1201
1237
  bg: org.name === currentId ? "$color4" : "transparent",
1202
1238
  hoverStyle: { bg: "$color5" },
1203
1239
  children: [
1204
- /* @__PURE__ */ jsxRuntime.jsx(OrgAvatar, { org }),
1240
+ /* @__PURE__ */ jsxRuntime.jsx(OrgMark, { org }),
1205
1241
  /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { flex: 1, fontSize: "$2", color: "$color12", numberOfLines: 1, children: org.displayName || org.name }),
1206
1242
  org.name === currentId ? /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Check, { size: 15 }) : null
1207
1243
  ]
@@ -2032,6 +2068,7 @@ exports.MenuPanel = MenuPanel;
2032
2068
  exports.MenuSeparatorView = MenuSeparatorView;
2033
2069
  exports.MetricCard = MetricCard;
2034
2070
  exports.MiniBars = MiniBars;
2071
+ exports.OrgMark = OrgMark;
2035
2072
  exports.OrgSwitcher = OrgSwitcher;
2036
2073
  exports.PageHeader = PageHeader;
2037
2074
  exports.Panel = Panel;
@@ -2054,6 +2091,7 @@ exports.colorForIndex = colorForIndex;
2054
2091
  exports.filterOptions = filterOptions;
2055
2092
  exports.filterOrgs = filterOrgs;
2056
2093
  exports.isKnownOption = isKnownOption;
2094
+ exports.monogram = monogram;
2057
2095
  exports.orgScope = orgScope;
2058
2096
  exports.otherSurfaces = otherSurfaces;
2059
2097
  exports.providerInitials = providerInitials;
@@ -2062,5 +2100,5 @@ exports.rowShift = rowShift;
2062
2100
  exports.targetIndex = targetIndex;
2063
2101
  exports.useToast = useToast;
2064
2102
  exports.utilColor = utilColor;
2065
- //# sourceMappingURL=chunk-HSPMQQVJ.cjs.map
2066
- //# sourceMappingURL=chunk-HSPMQQVJ.cjs.map
2103
+ //# sourceMappingURL=chunk-M2ILMK44.cjs.map
2104
+ //# sourceMappingURL=chunk-M2ILMK44.cjs.map