@xsolla/xui-b2b-sidebar 0.194.0 → 0.195.1

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/native/index.js CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.tsx
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ DEFAULT_SIDEBAR_LABELS: () => DEFAULT_SIDEBAR_LABELS,
33
34
  Sidebar: () => Sidebar,
34
35
  SidebarChatButton: () => SidebarChatButton,
35
36
  SidebarCollapsed: () => SidebarCollapsed,
@@ -44,6 +45,7 @@ __export(index_exports, {
44
45
  SidebarProvider: () => SidebarProvider,
45
46
  SidebarTrigger: () => SidebarTrigger,
46
47
  getPinnedCollapsedItem: () => getPinnedCollapsedItem,
48
+ resolveSidebarLabels: () => resolveSidebarLabels,
47
49
  useSidebar: () => useSidebar
48
50
  });
49
51
  module.exports = __toCommonJS(index_exports);
@@ -54,6 +56,24 @@ var import_xui_core2 = require("@xsolla/xui-core");
54
56
 
55
57
  // src/SidebarContext.tsx
56
58
  var import_react = require("react");
59
+
60
+ // src/labels.ts
61
+ var DEFAULT_SIDEBAR_LABELS = {
62
+ navigation: "Sidebar navigation",
63
+ expandSidebar: "Expand sidebar",
64
+ collapseSidebar: "Collapse sidebar",
65
+ chat: "Chat",
66
+ openChat: "Open chat",
67
+ pin: "Pin",
68
+ unpin: "Unpin",
69
+ pinItem: "Pin item",
70
+ unpinItem: "Unpin item",
71
+ beta: "Beta",
72
+ pinned: "Pinned"
73
+ };
74
+ var resolveSidebarLabels = (overrides) => overrides ? { ...DEFAULT_SIDEBAR_LABELS, ...overrides } : DEFAULT_SIDEBAR_LABELS;
75
+
76
+ // src/SidebarContext.tsx
57
77
  var import_jsx_runtime = require("react/jsx-runtime");
58
78
  var DefaultLink = ({
59
79
  to,
@@ -87,13 +107,15 @@ var SidebarContext = (0, import_react.createContext)({
87
107
  LinkComponent: DefaultLink,
88
108
  expandedId: null,
89
109
  onExpandedIdChange: () => {
90
- }
110
+ },
111
+ labels: DEFAULT_SIDEBAR_LABELS
91
112
  });
92
113
  var SidebarProvider = ({
93
114
  collapsed: collapsedProp,
94
115
  onCollapsedChange,
95
116
  pathname = "",
96
117
  linkComponent,
118
+ labels: labelsProp,
97
119
  children
98
120
  }) => {
99
121
  const [internalCollapsed, setInternalCollapsed] = (0, import_react.useState)(false);
@@ -109,6 +131,12 @@ var SidebarProvider = ({
109
131
  const onExpandedIdChange = (0, import_react.useCallback)((id) => {
110
132
  setExpandedId(id);
111
133
  }, []);
134
+ const labelsKey = labelsProp ? JSON.stringify(labelsProp) : "";
135
+ const labels = (0, import_react.useMemo)(
136
+ () => resolveSidebarLabels(labelsProp),
137
+ // eslint-disable-next-line react-hooks/exhaustive-deps
138
+ [labelsKey]
139
+ );
112
140
  const value = (0, import_react.useMemo)(
113
141
  () => ({
114
142
  collapsed,
@@ -116,7 +144,8 @@ var SidebarProvider = ({
116
144
  pathname,
117
145
  LinkComponent: linkComponent || DefaultLink,
118
146
  expandedId,
119
- onExpandedIdChange
147
+ onExpandedIdChange,
148
+ labels
120
149
  }),
121
150
  [
122
151
  collapsed,
@@ -124,7 +153,8 @@ var SidebarProvider = ({
124
153
  pathname,
125
154
  linkComponent,
126
155
  expandedId,
127
- onExpandedIdChange
156
+ onExpandedIdChange,
157
+ labels
128
158
  ]
129
159
  );
130
160
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SidebarContext.Provider, { value, children });
@@ -740,9 +770,11 @@ var SidebarCollapsed = ({
740
770
  onToggleCollapse,
741
771
  onChatClick,
742
772
  showChat = true,
743
- chatBadge = false
773
+ chatBadge = false,
774
+ chatAriaLabel,
775
+ expandLabel
744
776
  }) => {
745
- const { pathname } = useSidebar();
777
+ const { pathname, labels } = useSidebar();
746
778
  const { theme } = (0, import_xui_core.useResolvedTheme)();
747
779
  const sizing = theme.sizing.sidebar();
748
780
  const colors = theme.colors;
@@ -829,7 +861,7 @@ var SidebarCollapsed = ({
829
861
  {
830
862
  onClick: onChatClick,
831
863
  type: "button",
832
- "aria-label": "Open chat",
864
+ "aria-label": chatAriaLabel ?? labels.openChat,
833
865
  $size: sizing.itemHeight,
834
866
  $radius: sizing.radius,
835
867
  $bg: colors.control.brand.primary.bg,
@@ -854,7 +886,7 @@ var SidebarCollapsed = ({
854
886
  {
855
887
  onClick: onToggleCollapse,
856
888
  type: "button",
857
- "aria-label": "Expand sidebar",
889
+ "aria-label": expandLabel ?? labels.expandSidebar,
858
890
  "aria-pressed": true,
859
891
  $size: sizing.itemHeight,
860
892
  $radius: sizing.radius,
@@ -940,16 +972,17 @@ var Sidebar = ({
940
972
  showChat = true,
941
973
  onChatClick,
942
974
  chatBadge = false,
975
+ navigationLabel,
943
976
  children
944
977
  }) => {
945
- const { collapsed, onCollapsedChange } = useSidebar();
978
+ const { collapsed, onCollapsedChange, labels } = useSidebar();
946
979
  const { theme } = (0, import_xui_core2.useResolvedTheme)();
947
980
  const sizing = theme.sizing.sidebar();
948
981
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
949
982
  Outer2,
950
983
  {
951
984
  role: "navigation",
952
- "aria-label": "Sidebar navigation",
985
+ "aria-label": navigationLabel ?? labels.navigation,
953
986
  $expanded: sizing.widthExpanded,
954
987
  $collapsed: sizing.widthCollapsed,
955
988
  $width: collapsed ? sizing.widthCollapsed : sizing.widthExpanded,
@@ -1268,8 +1301,11 @@ var ToggleButton = import_styled_components4.default.button`
1268
1301
  height: ${(p) => p.$iconSize}px;
1269
1302
  }
1270
1303
  `;
1271
- var SidebarTrigger = () => {
1272
- const { collapsed, onCollapsedChange } = useSidebar();
1304
+ var SidebarTrigger = ({
1305
+ expandLabel,
1306
+ collapseLabel
1307
+ }) => {
1308
+ const { collapsed, onCollapsedChange, labels } = useSidebar();
1273
1309
  const { theme } = (0, import_xui_core5.useResolvedTheme)();
1274
1310
  const sizing = theme.sizing.sidebar();
1275
1311
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -1277,7 +1313,7 @@ var SidebarTrigger = () => {
1277
1313
  {
1278
1314
  type: "button",
1279
1315
  onClick: () => onCollapsedChange(!collapsed),
1280
- "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
1316
+ "aria-label": collapsed ? expandLabel ?? labels.expandSidebar : collapseLabel ?? labels.collapseSidebar,
1281
1317
  "aria-pressed": collapsed,
1282
1318
  $size: sizing.itemHeight,
1283
1319
  $radius: sizing.radius,
@@ -1532,13 +1568,20 @@ var SidebarMenuItem = ({
1532
1568
  beta,
1533
1569
  multiLine,
1534
1570
  extra,
1535
- isNested = false
1571
+ isNested = false,
1572
+ pinLabel,
1573
+ unpinLabel,
1574
+ pinAriaLabel,
1575
+ unpinAriaLabel,
1576
+ betaLabel
1536
1577
  }) => {
1537
- const { LinkComponent } = useSidebar();
1578
+ const { LinkComponent, labels } = useSidebar();
1538
1579
  const { theme } = (0, import_xui_core7.useResolvedTheme)();
1539
1580
  const sizing = theme.sizing.sidebar();
1540
1581
  const shouldTruncate = Boolean(hasTooltip) && typeof label === "string" && label.length > TOOLTIP_TRUNCATE_LENGTH;
1541
1582
  const displayLabel = shouldTruncate ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_xui_tooltip.Tooltip, { content: label, placement: "right", size: "md", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: `${label.slice(0, TOOLTIP_TRUNCATE_LENGTH)}\u2026` }) }) : label;
1583
+ const pinTooltip = isPinned ? unpinLabel ?? labels.unpin : pinLabel ?? labels.pin;
1584
+ const pinAria = isPinned ? unpinAriaLabel ?? labels.unpinItem : pinAriaLabel ?? labels.pinItem;
1542
1585
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1543
1586
  ItemWrapper,
1544
1587
  {
@@ -1590,40 +1633,32 @@ var SidebarMenuItem = ({
1590
1633
  }
1591
1634
  )
1592
1635
  ] }),
1593
- onPinToggle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1594
- import_xui_tooltip.Tooltip,
1636
+ onPinToggle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_xui_tooltip.Tooltip, { content: pinTooltip, placement: "top", size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1637
+ PinButton,
1595
1638
  {
1596
- content: isPinned ? "Unpin" : "Pin",
1597
- placement: "top",
1598
- size: "sm",
1599
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1600
- PinButton,
1601
- {
1602
- type: "button",
1603
- "aria-label": isPinned ? "Unpin item" : "Pin item",
1604
- "aria-pressed": Boolean(isPinned),
1605
- $size: sizing.iconSize,
1606
- $color: theme.colors.content.tertiary,
1607
- $hoverColor: theme.colors.content.primary,
1608
- $activeColor: theme.colors.content.primary,
1609
- $isPinned: Boolean(isPinned),
1610
- onClick: (e) => {
1611
- e.preventDefault();
1612
- e.stopPropagation();
1613
- onPinToggle(e);
1614
- },
1615
- children: isPinned ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_xui_icons_base2.Remove, { size: 12, variant: "line" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_xui_icons_base2.Pin, { size: 12, variant: "solid" })
1616
- }
1617
- )
1639
+ type: "button",
1640
+ "aria-label": pinAria,
1641
+ "aria-pressed": Boolean(isPinned),
1642
+ $size: sizing.iconSize,
1643
+ $color: theme.colors.content.tertiary,
1644
+ $hoverColor: theme.colors.content.primary,
1645
+ $activeColor: theme.colors.content.primary,
1646
+ $isPinned: Boolean(isPinned),
1647
+ onClick: (e) => {
1648
+ e.preventDefault();
1649
+ e.stopPropagation();
1650
+ onPinToggle(e);
1651
+ },
1652
+ children: isPinned ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_xui_icons_base2.Remove, { size: 12, variant: "line" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_xui_icons_base2.Pin, { size: 12, variant: "solid" })
1618
1653
  }
1619
- ),
1654
+ ) }),
1620
1655
  beta && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1621
1656
  BetaTag,
1622
1657
  {
1623
1658
  $bg: theme.colors.overlay.mono,
1624
1659
  $color: theme.colors.content.tertiary,
1625
1660
  $radius: sizing.radius,
1626
- children: "Beta"
1661
+ children: betaLabel ?? labels.beta
1627
1662
  }
1628
1663
  ),
1629
1664
  external && hasExternalIcon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
@@ -1899,9 +1934,11 @@ var Badge = import_styled_components7.default.span`
1899
1934
  `;
1900
1935
  var SidebarChatButton = ({
1901
1936
  onClick,
1902
- badge
1937
+ badge,
1938
+ label
1903
1939
  }) => {
1904
1940
  const { theme } = (0, import_xui_core9.useResolvedTheme)();
1941
+ const { labels } = useSidebar();
1905
1942
  const sizing = theme.sizing.sidebar();
1906
1943
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1907
1944
  ChatButton,
@@ -1918,7 +1955,7 @@ var SidebarChatButton = ({
1918
1955
  $focusOutlineWidth: sizing.focusOutlineWidth,
1919
1956
  children: [
1920
1957
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_xui_icons_base4.ChatTwoMessages, { size: 16, variant: "line" }),
1921
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_xui_typography5.Typography, { variant: "bodySmAccent", color: "inherit", children: "Chat" }),
1958
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_xui_typography5.Typography, { variant: "bodySmAccent", color: "inherit", children: label ?? labels.chat }),
1922
1959
  badge && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1923
1960
  Badge,
1924
1961
  {
@@ -2006,7 +2043,7 @@ var SidebarPinnedList = ({
2006
2043
  var getPinnedCollapsedItem = (items, options = {}) => {
2007
2044
  if (items.length === 0) return null;
2008
2045
  return {
2009
- label: options.label ?? "Pinned",
2046
+ label: options.label ?? DEFAULT_SIDEBAR_LABELS.pinned,
2010
2047
  icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_xui_icons_base5.Pin, { size: 18, variant: "solid" }),
2011
2048
  dataId: options.dataId ?? "sidebar-collapsed-pinned",
2012
2049
  children: items.map((i) => ({
@@ -2018,6 +2055,7 @@ var getPinnedCollapsedItem = (items, options = {}) => {
2018
2055
  };
2019
2056
  // Annotate the CommonJS export names for ESM import in node:
2020
2057
  0 && (module.exports = {
2058
+ DEFAULT_SIDEBAR_LABELS,
2021
2059
  Sidebar,
2022
2060
  SidebarChatButton,
2023
2061
  SidebarCollapsed,
@@ -2032,6 +2070,7 @@ var getPinnedCollapsedItem = (items, options = {}) => {
2032
2070
  SidebarProvider,
2033
2071
  SidebarTrigger,
2034
2072
  getPinnedCollapsedItem,
2073
+ resolveSidebarLabels,
2035
2074
  useSidebar
2036
2075
  });
2037
2076
  //# sourceMappingURL=index.js.map