@adecore/ui 0.44.4 → 0.45.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.
@@ -20,11 +20,12 @@ export interface ProjectSwitcherProps<Item extends ProjectSwitcherItem = Project
20
20
  children?: ReactNode;
21
21
  label?: string;
22
22
  disabled?: boolean;
23
+ tabIndex?: number;
23
24
  open?: boolean;
24
25
  defaultOpen?: boolean;
25
26
  onOpenChange?: ComponentProps<typeof Menu.Root>['onOpenChange'];
26
27
  className?: string;
27
28
  ref?: Ref<HTMLButtonElement>;
28
29
  }
29
- export declare function ProjectSwitcher<Item extends ProjectSwitcherItem>({ current, projects, recentProjects, onSelect, leading, before, children, label, disabled, open, defaultOpen, onOpenChange, className, ref }: ProjectSwitcherProps<Item>): import("react").JSX.Element;
30
+ export declare function ProjectSwitcher<Item extends ProjectSwitcherItem>({ current, projects, recentProjects, onSelect, leading, before, children, label, disabled, tabIndex, open, defaultOpen, onOpenChange, className, ref }: ProjectSwitcherProps<Item>): import("react").JSX.Element;
30
31
  export declare function ProjectSwitcherGroups<Item extends ProjectSwitcherItem>({ projects, recentProjects, before, children, onSelect }: Pick<ProjectSwitcherProps<Item>, 'projects' | 'recentProjects' | 'before' | 'children' | 'onSelect'>): import("react").JSX.Element;
@@ -7,7 +7,7 @@ import * as Menu from './menu/index.parts.js';
7
7
  import { ProjectSwitcherRow } from "./project-switcher-row.js";
8
8
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
9
9
  export function ProjectSwitcher(t0) {
10
- const $ = _c(28);
10
+ const $ = _c(29);
11
11
  const {
12
12
  current,
13
13
  projects,
@@ -18,6 +18,7 @@ export function ProjectSwitcher(t0) {
18
18
  children,
19
19
  label,
20
20
  disabled,
21
+ tabIndex,
21
22
  open,
22
23
  defaultOpen,
23
24
  onOpenChange,
@@ -71,10 +72,11 @@ export function ProjectSwitcher(t0) {
71
72
  t7 = $[7];
72
73
  }
73
74
  let t8;
74
- if ($[8] !== disabled || $[9] !== leading || $[10] !== ref || $[11] !== t2 || $[12] !== t3 || $[13] !== t4 || $[14] !== t6) {
75
+ if ($[8] !== disabled || $[9] !== leading || $[10] !== ref || $[11] !== t2 || $[12] !== t3 || $[13] !== t4 || $[14] !== t6 || $[15] !== tabIndex) {
75
76
  t8 = /*#__PURE__*/_jsxs(Menu.Trigger, {
76
77
  ref: ref,
77
78
  disabled: disabled,
79
+ tabIndex: tabIndex,
78
80
  "aria-label": t2,
79
81
  className: t3,
80
82
  children: [leading, t4, t6, t7]
@@ -86,12 +88,13 @@ export function ProjectSwitcher(t0) {
86
88
  $[12] = t3;
87
89
  $[13] = t4;
88
90
  $[14] = t6;
89
- $[15] = t8;
91
+ $[15] = tabIndex;
92
+ $[16] = t8;
90
93
  } else {
91
- t8 = $[15];
94
+ t8 = $[16];
92
95
  }
93
96
  let t9;
94
- if ($[16] !== before || $[17] !== children || $[18] !== onSelect || $[19] !== projects || $[20] !== recentProjects) {
97
+ if ($[17] !== before || $[18] !== children || $[19] !== onSelect || $[20] !== projects || $[21] !== recentProjects) {
95
98
  t9 = /*#__PURE__*/_jsx(Menu.Popup, {
96
99
  className: "min-w-60",
97
100
  children: /*#__PURE__*/_jsx(ProjectSwitcherGroups, {
@@ -102,31 +105,31 @@ export function ProjectSwitcher(t0) {
102
105
  children: children
103
106
  })
104
107
  });
105
- $[16] = before;
106
- $[17] = children;
107
- $[18] = onSelect;
108
- $[19] = projects;
109
- $[20] = recentProjects;
110
- $[21] = t9;
108
+ $[17] = before;
109
+ $[18] = children;
110
+ $[19] = onSelect;
111
+ $[20] = projects;
112
+ $[21] = recentProjects;
113
+ $[22] = t9;
111
114
  } else {
112
- t9 = $[21];
115
+ t9 = $[22];
113
116
  }
114
117
  let t10;
115
- if ($[22] !== defaultOpen || $[23] !== onOpenChange || $[24] !== open || $[25] !== t8 || $[26] !== t9) {
118
+ if ($[23] !== defaultOpen || $[24] !== onOpenChange || $[25] !== open || $[26] !== t8 || $[27] !== t9) {
116
119
  t10 = /*#__PURE__*/_jsxs(Menu.Root, {
117
120
  open: open,
118
121
  defaultOpen: defaultOpen,
119
122
  onOpenChange: onOpenChange,
120
123
  children: [t8, t9]
121
124
  });
122
- $[22] = defaultOpen;
123
- $[23] = onOpenChange;
124
- $[24] = open;
125
- $[25] = t8;
126
- $[26] = t9;
127
- $[27] = t10;
125
+ $[23] = defaultOpen;
126
+ $[24] = onOpenChange;
127
+ $[25] = open;
128
+ $[26] = t8;
129
+ $[27] = t9;
130
+ $[28] = t10;
128
131
  } else {
129
- t10 = $[27];
132
+ t10 = $[28];
130
133
  }
131
134
  return t10;
132
135
  }
@@ -1,4 +1,5 @@
1
1
  import type { Ref } from 'react';
2
+ import { type IconButtonSize } from './IconButton.tsx';
2
3
  import type { Shortcut } from './shortcut.ts';
3
4
  export interface ZoomSelection {
4
5
  label: string;
@@ -24,7 +25,9 @@ export interface ZoomControlsProps {
24
25
  fitAll?: Shortcut;
25
26
  };
26
27
  selection?: ZoomSelection;
28
+ size?: Extract<IconButtonSize, 'md' | 'sm'>;
29
+ side?: 'top' | 'bottom';
27
30
  className?: string;
28
31
  ref?: Ref<HTMLDivElement>;
29
32
  }
30
- export declare function ZoomControls({ zoom, onZoomChange, onFitAll, presets, labels, shortcuts, selection, className, ref }: ZoomControlsProps): import("react").JSX.Element;
33
+ export declare function ZoomControls({ zoom, onZoomChange, onFitAll, presets, labels, shortcuts, selection, size, side, className, ref }: ZoomControlsProps): import("react").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
+ import clsx from 'clsx';
2
3
  import { Maximize, Minus, Plus, Scan } from 'lucide-react';
3
4
  import { useTranslation } from 'react-i18next';
4
5
  import { ButtonGroup } from "./ButtonGroup.js";
@@ -8,7 +9,12 @@ import { Kbd } from "./Kbd.js";
8
9
  import { MenuItem, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuRoot, MenuSeparator, MenuTrigger } from "./menu/parts.js";
9
10
  import { Tooltip } from "./Tooltip.js";
10
11
  import { activeZoomPreset, steppedZoom, ZOOM_PRESETS } from './zoom.js';
12
+ /* The percentage between the buttons, at the height and radius of the buttons beside it. */
11
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ const TRIGGER_SIZE = {
15
+ md: 'h-8 min-w-14 rounded-lg',
16
+ sm: 'h-7 min-w-12 rounded-md'
17
+ };
12
18
  function MenuIcon(t0) {
13
19
  const $ = _c(2);
14
20
  const {
@@ -31,7 +37,7 @@ function MenuIcon(t0) {
31
37
  return t1;
32
38
  }
33
39
  export function ZoomControls(t0) {
34
- const $ = _c(80);
40
+ const $ = _c(87);
35
41
  const {
36
42
  zoom,
37
43
  onZoomChange,
@@ -40,125 +46,141 @@ export function ZoomControls(t0) {
40
46
  labels: t2,
41
47
  shortcuts: t3,
42
48
  selection,
49
+ size: t4,
50
+ side: t5,
43
51
  className,
44
52
  ref
45
53
  } = t0;
46
54
  const presets = t1 === undefined ? ZOOM_PRESETS : t1;
47
- let t4;
55
+ let t6;
48
56
  if ($[0] !== t2) {
49
- t4 = t2 === undefined ? {} : t2;
57
+ t6 = t2 === undefined ? {} : t2;
50
58
  $[0] = t2;
51
- $[1] = t4;
59
+ $[1] = t6;
52
60
  } else {
53
- t4 = $[1];
61
+ t6 = $[1];
54
62
  }
55
- const labels = t4;
56
- let t5;
63
+ const labels = t6;
64
+ let t7;
57
65
  if ($[2] !== t3) {
58
- t5 = t3 === undefined ? {} : t3;
66
+ t7 = t3 === undefined ? {} : t3;
59
67
  $[2] = t3;
60
- $[3] = t5;
68
+ $[3] = t7;
61
69
  } else {
62
- t5 = $[3];
70
+ t7 = $[3];
63
71
  }
64
- const shortcuts = t5;
72
+ const shortcuts = t7;
73
+ const size = t4 === undefined ? "md" : t4;
74
+ const side = t5 === undefined ? "top" : t5;
65
75
  const {
66
76
  t
67
77
  } = useTranslation("ui");
68
- let t6;
78
+ let t8;
69
79
  if ($[4] !== presets || $[5] !== zoom) {
70
- t6 = activeZoomPreset(zoom, presets);
80
+ t8 = activeZoomPreset(zoom, presets);
71
81
  $[4] = presets;
72
82
  $[5] = zoom;
73
- $[6] = t6;
83
+ $[6] = t8;
74
84
  } else {
75
- t6 = $[6];
85
+ t8 = $[6];
76
86
  }
77
- const preset = t6;
78
- let t7;
87
+ const preset = t8;
88
+ let t9;
79
89
  if ($[7] !== labels.out || $[8] !== t) {
80
- t7 = labels.out ?? t("zoom.out");
90
+ t9 = labels.out ?? t("zoom.out");
81
91
  $[7] = labels.out;
82
92
  $[8] = t;
83
- $[9] = t7;
93
+ $[9] = t9;
84
94
  } else {
85
- t7 = $[9];
95
+ t9 = $[9];
86
96
  }
87
- let t8;
97
+ let t10;
88
98
  if ($[10] !== onZoomChange || $[11] !== zoom) {
89
- t8 = () => onZoomChange(steppedZoom(zoom, -10));
99
+ t10 = () => onZoomChange(steppedZoom(zoom, -10));
90
100
  $[10] = onZoomChange;
91
101
  $[11] = zoom;
92
- $[12] = t8;
102
+ $[12] = t10;
93
103
  } else {
94
- t8 = $[12];
104
+ t10 = $[12];
95
105
  }
96
- let t9;
97
- if ($[13] !== t7 || $[14] !== t8) {
98
- t9 = /*#__PURE__*/_jsx(IconButton, {
106
+ let t11;
107
+ if ($[13] !== size || $[14] !== t10 || $[15] !== t9) {
108
+ t11 = /*#__PURE__*/_jsx(IconButton, {
99
109
  icon: Minus,
100
- label: t7,
101
- onClick: t8
110
+ size: size,
111
+ label: t9,
112
+ onClick: t10
102
113
  });
103
- $[13] = t7;
104
- $[14] = t8;
114
+ $[13] = size;
115
+ $[14] = t10;
105
116
  $[15] = t9;
117
+ $[16] = t11;
106
118
  } else {
107
- t9 = $[15];
119
+ t11 = $[16];
108
120
  }
109
- let t10;
110
- if ($[16] !== labels.presets || $[17] !== t) {
111
- t10 = labels.presets ?? t("zoom.presets");
112
- $[16] = labels.presets;
113
- $[17] = t;
114
- $[18] = t10;
121
+ let t12;
122
+ if ($[17] !== labels.presets || $[18] !== t) {
123
+ t12 = labels.presets ?? t("zoom.presets");
124
+ $[17] = labels.presets;
125
+ $[18] = t;
126
+ $[19] = t12;
115
127
  } else {
116
- t10 = $[18];
128
+ t12 = $[19];
117
129
  }
118
- let t11;
119
- if ($[19] !== zoom) {
120
- t11 = Math.round(zoom * 100);
121
- $[19] = zoom;
122
- $[20] = t11;
130
+ const t13 = TRIGGER_SIZE[size];
131
+ let t14;
132
+ if ($[20] !== t13) {
133
+ t14 = clsx(t13, "px-1 text-xs text-text-muted tabular-nums hover:bg-surface-hover hover:text-text data-[popup-open]:bg-surface-active data-[popup-open]:text-text");
134
+ $[20] = t13;
135
+ $[21] = t14;
123
136
  } else {
124
- t11 = $[20];
137
+ t14 = $[21];
125
138
  }
126
- let t12;
127
- if ($[21] !== t11) {
128
- t12 = /*#__PURE__*/_jsxs(MenuTrigger, {
129
- className: "h-8 min-w-14 rounded-lg px-1 text-xs text-text-muted tabular-nums hover:bg-surface-hover hover:text-text data-[popup-open]:bg-surface-active data-[popup-open]:text-text",
130
- children: [t11, "%"]
139
+ let t15;
140
+ if ($[22] !== zoom) {
141
+ t15 = Math.round(zoom * 100);
142
+ $[22] = zoom;
143
+ $[23] = t15;
144
+ } else {
145
+ t15 = $[23];
146
+ }
147
+ let t16;
148
+ if ($[24] !== t14 || $[25] !== t15) {
149
+ t16 = /*#__PURE__*/_jsxs(MenuTrigger, {
150
+ className: t14,
151
+ children: [t15, "%"]
131
152
  });
132
- $[21] = t11;
133
- $[22] = t12;
153
+ $[24] = t14;
154
+ $[25] = t15;
155
+ $[26] = t16;
134
156
  } else {
135
- t12 = $[22];
157
+ t16 = $[26];
136
158
  }
137
- let t13;
138
- if ($[23] !== t10 || $[24] !== t12) {
139
- t13 = /*#__PURE__*/_jsx(Tooltip, {
140
- label: t10,
141
- children: t12
159
+ let t17;
160
+ if ($[27] !== t12 || $[28] !== t16) {
161
+ t17 = /*#__PURE__*/_jsx(Tooltip, {
162
+ label: t12,
163
+ children: t16
142
164
  });
143
- $[23] = t10;
144
- $[24] = t12;
145
- $[25] = t13;
165
+ $[27] = t12;
166
+ $[28] = t16;
167
+ $[29] = t17;
146
168
  } else {
147
- t13 = $[25];
169
+ t17 = $[29];
148
170
  }
149
- let t14;
150
- if ($[26] !== onZoomChange) {
151
- t14 = value => onZoomChange(value / 100);
152
- $[26] = onZoomChange;
153
- $[27] = t14;
171
+ let t18;
172
+ if ($[30] !== onZoomChange) {
173
+ t18 = value => onZoomChange(value / 100);
174
+ $[30] = onZoomChange;
175
+ $[31] = t18;
154
176
  } else {
155
- t14 = $[27];
177
+ t18 = $[31];
156
178
  }
157
- let t15;
158
- if ($[28] !== presets || $[29] !== shortcuts.zoomReset) {
159
- let t16;
160
- if ($[31] !== shortcuts.zoomReset) {
161
- t16 = percent => /*#__PURE__*/_jsxs(MenuRadioItem, {
179
+ let t19;
180
+ if ($[32] !== presets || $[33] !== shortcuts.zoomReset) {
181
+ let t20;
182
+ if ($[35] !== shortcuts.zoomReset) {
183
+ t20 = percent => /*#__PURE__*/_jsxs(MenuRadioItem, {
162
184
  value: percent,
163
185
  children: [/*#__PURE__*/_jsxs("span", {
164
186
  className: "tabular-nums",
@@ -167,83 +189,83 @@ export function ZoomControls(t0) {
167
189
  shortcut: shortcuts.zoomReset
168
190
  })]
169
191
  }, percent);
170
- $[31] = shortcuts.zoomReset;
171
- $[32] = t16;
192
+ $[35] = shortcuts.zoomReset;
193
+ $[36] = t20;
172
194
  } else {
173
- t16 = $[32];
195
+ t20 = $[36];
174
196
  }
175
- t15 = presets.map(t16);
176
- $[28] = presets;
177
- $[29] = shortcuts.zoomReset;
178
- $[30] = t15;
197
+ t19 = presets.map(t20);
198
+ $[32] = presets;
199
+ $[33] = shortcuts.zoomReset;
200
+ $[34] = t19;
179
201
  } else {
180
- t15 = $[30];
202
+ t19 = $[34];
181
203
  }
182
- let t16;
183
- if ($[33] !== preset || $[34] !== t14 || $[35] !== t15) {
184
- t16 = /*#__PURE__*/_jsx(MenuRadioGroup, {
204
+ let t20;
205
+ if ($[37] !== preset || $[38] !== t18 || $[39] !== t19) {
206
+ t20 = /*#__PURE__*/_jsx(MenuRadioGroup, {
185
207
  value: preset,
186
- onValueChange: t14,
187
- children: t15
208
+ onValueChange: t18,
209
+ children: t19
188
210
  });
189
- $[33] = preset;
190
- $[34] = t14;
191
- $[35] = t15;
192
- $[36] = t16;
211
+ $[37] = preset;
212
+ $[38] = t18;
213
+ $[39] = t19;
214
+ $[40] = t20;
193
215
  } else {
194
- t16 = $[36];
216
+ t20 = $[40];
195
217
  }
196
- let t17;
197
- if ($[37] === Symbol.for("react.memo_cache_sentinel")) {
198
- t17 = /*#__PURE__*/_jsx(MenuSeparator, {});
199
- $[37] = t17;
218
+ let t21;
219
+ if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
220
+ t21 = /*#__PURE__*/_jsx(MenuSeparator, {});
221
+ $[41] = t21;
200
222
  } else {
201
- t17 = $[37];
223
+ t21 = $[41];
202
224
  }
203
- let t18;
204
- if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
205
- t18 = /*#__PURE__*/_jsx(MenuIcon, {
225
+ let t22;
226
+ if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
227
+ t22 = /*#__PURE__*/_jsx(MenuIcon, {
206
228
  icon: Maximize
207
229
  });
208
- $[38] = t18;
230
+ $[42] = t22;
209
231
  } else {
210
- t18 = $[38];
232
+ t22 = $[42];
211
233
  }
212
- let t19;
213
- if ($[39] !== labels.fit || $[40] !== t) {
214
- t19 = labels.fit ?? t("zoom.fit");
215
- $[39] = labels.fit;
216
- $[40] = t;
217
- $[41] = t19;
234
+ let t23;
235
+ if ($[43] !== labels.fit || $[44] !== t) {
236
+ t23 = labels.fit ?? t("zoom.fit");
237
+ $[43] = labels.fit;
238
+ $[44] = t;
239
+ $[45] = t23;
218
240
  } else {
219
- t19 = $[41];
241
+ t23 = $[45];
220
242
  }
221
- let t20;
222
- if ($[42] !== shortcuts.fitAll) {
223
- t20 = shortcuts.fitAll && /*#__PURE__*/_jsx(Kbd, {
243
+ let t24;
244
+ if ($[46] !== shortcuts.fitAll) {
245
+ t24 = shortcuts.fitAll && /*#__PURE__*/_jsx(Kbd, {
224
246
  shortcut: shortcuts.fitAll
225
247
  });
226
- $[42] = shortcuts.fitAll;
227
- $[43] = t20;
248
+ $[46] = shortcuts.fitAll;
249
+ $[47] = t24;
228
250
  } else {
229
- t20 = $[43];
251
+ t24 = $[47];
230
252
  }
231
- let t21;
232
- if ($[44] !== onFitAll || $[45] !== t19 || $[46] !== t20) {
233
- t21 = /*#__PURE__*/_jsxs(MenuItem, {
253
+ let t25;
254
+ if ($[48] !== onFitAll || $[49] !== t23 || $[50] !== t24) {
255
+ t25 = /*#__PURE__*/_jsxs(MenuItem, {
234
256
  onClick: onFitAll,
235
- children: [t18, t19, " ", t20]
257
+ children: [t22, t23, " ", t24]
236
258
  });
237
- $[44] = onFitAll;
238
- $[45] = t19;
239
- $[46] = t20;
240
- $[47] = t21;
259
+ $[48] = onFitAll;
260
+ $[49] = t23;
261
+ $[50] = t24;
262
+ $[51] = t25;
241
263
  } else {
242
- t21 = $[47];
264
+ t25 = $[51];
243
265
  }
244
- let t22;
245
- if ($[48] !== selection) {
246
- t22 = selection && /*#__PURE__*/_jsxs(MenuItem, {
266
+ let t26;
267
+ if ($[52] !== selection) {
268
+ t26 = selection && /*#__PURE__*/_jsxs(MenuItem, {
247
269
  disabled: !selection.enabled,
248
270
  onClick: selection.onZoom,
249
271
  children: [/*#__PURE__*/_jsx(MenuIcon, {
@@ -252,109 +274,114 @@ export function ZoomControls(t0) {
252
274
  shortcut: selection.shortcut
253
275
  })]
254
276
  });
255
- $[48] = selection;
256
- $[49] = t22;
277
+ $[52] = selection;
278
+ $[53] = t26;
257
279
  } else {
258
- t22 = $[49];
280
+ t26 = $[53];
259
281
  }
260
- let t23;
261
- if ($[50] !== t16 || $[51] !== t21 || $[52] !== t22) {
262
- t23 = /*#__PURE__*/_jsxs(MenuPopup, {
263
- side: "top",
282
+ let t27;
283
+ if ($[54] !== side || $[55] !== t20 || $[56] !== t25 || $[57] !== t26) {
284
+ t27 = /*#__PURE__*/_jsxs(MenuPopup, {
285
+ side: side,
264
286
  sideOffset: 10,
265
287
  align: "center",
266
288
  className: "min-w-44",
267
- children: [t16, t17, t21, t22]
289
+ children: [t20, t21, t25, t26]
268
290
  });
269
- $[50] = t16;
270
- $[51] = t21;
271
- $[52] = t22;
272
- $[53] = t23;
291
+ $[54] = side;
292
+ $[55] = t20;
293
+ $[56] = t25;
294
+ $[57] = t26;
295
+ $[58] = t27;
273
296
  } else {
274
- t23 = $[53];
297
+ t27 = $[58];
275
298
  }
276
- let t24;
277
- if ($[54] !== t13 || $[55] !== t23) {
278
- t24 = /*#__PURE__*/_jsxs(MenuRoot, {
279
- children: [t13, t23]
299
+ let t28;
300
+ if ($[59] !== t17 || $[60] !== t27) {
301
+ t28 = /*#__PURE__*/_jsxs(MenuRoot, {
302
+ children: [t17, t27]
280
303
  });
281
- $[54] = t13;
282
- $[55] = t23;
283
- $[56] = t24;
304
+ $[59] = t17;
305
+ $[60] = t27;
306
+ $[61] = t28;
284
307
  } else {
285
- t24 = $[56];
308
+ t28 = $[61];
286
309
  }
287
- let t25;
288
- if ($[57] !== labels.in || $[58] !== t) {
289
- t25 = labels.in ?? t("zoom.in");
290
- $[57] = labels.in;
291
- $[58] = t;
292
- $[59] = t25;
310
+ let t29;
311
+ if ($[62] !== labels.in || $[63] !== t) {
312
+ t29 = labels.in ?? t("zoom.in");
313
+ $[62] = labels.in;
314
+ $[63] = t;
315
+ $[64] = t29;
293
316
  } else {
294
- t25 = $[59];
317
+ t29 = $[64];
295
318
  }
296
- let t26;
297
- if ($[60] !== onZoomChange || $[61] !== zoom) {
298
- t26 = () => onZoomChange(steppedZoom(zoom, 10));
299
- $[60] = onZoomChange;
300
- $[61] = zoom;
301
- $[62] = t26;
319
+ let t30;
320
+ if ($[65] !== onZoomChange || $[66] !== zoom) {
321
+ t30 = () => onZoomChange(steppedZoom(zoom, 10));
322
+ $[65] = onZoomChange;
323
+ $[66] = zoom;
324
+ $[67] = t30;
302
325
  } else {
303
- t26 = $[62];
326
+ t30 = $[67];
304
327
  }
305
- let t27;
306
- if ($[63] !== t25 || $[64] !== t26) {
307
- t27 = /*#__PURE__*/_jsx(IconButton, {
328
+ let t31;
329
+ if ($[68] !== size || $[69] !== t29 || $[70] !== t30) {
330
+ t31 = /*#__PURE__*/_jsx(IconButton, {
308
331
  icon: Plus,
309
- label: t25,
310
- onClick: t26
332
+ size: size,
333
+ label: t29,
334
+ onClick: t30
311
335
  });
312
- $[63] = t25;
313
- $[64] = t26;
314
- $[65] = t27;
336
+ $[68] = size;
337
+ $[69] = t29;
338
+ $[70] = t30;
339
+ $[71] = t31;
315
340
  } else {
316
- t27 = $[65];
341
+ t31 = $[71];
317
342
  }
318
- let t28;
319
- if ($[66] !== labels.fitEverything || $[67] !== t) {
320
- t28 = labels.fitEverything ?? t("zoom.fitEverything");
321
- $[66] = labels.fitEverything;
322
- $[67] = t;
323
- $[68] = t28;
343
+ let t32;
344
+ if ($[72] !== labels.fitEverything || $[73] !== t) {
345
+ t32 = labels.fitEverything ?? t("zoom.fitEverything");
346
+ $[72] = labels.fitEverything;
347
+ $[73] = t;
348
+ $[74] = t32;
324
349
  } else {
325
- t28 = $[68];
350
+ t32 = $[74];
326
351
  }
327
- let t29;
328
- if ($[69] !== onFitAll || $[70] !== shortcuts.fitAll || $[71] !== t28) {
329
- t29 = /*#__PURE__*/_jsx(IconButton, {
352
+ let t33;
353
+ if ($[75] !== onFitAll || $[76] !== shortcuts.fitAll || $[77] !== size || $[78] !== t32) {
354
+ t33 = /*#__PURE__*/_jsx(IconButton, {
330
355
  icon: Maximize,
331
- label: t28,
356
+ size: size,
357
+ label: t32,
332
358
  kbd: shortcuts.fitAll,
333
359
  onClick: onFitAll
334
360
  });
335
- $[69] = onFitAll;
336
- $[70] = shortcuts.fitAll;
337
- $[71] = t28;
338
- $[72] = t29;
361
+ $[75] = onFitAll;
362
+ $[76] = shortcuts.fitAll;
363
+ $[77] = size;
364
+ $[78] = t32;
365
+ $[79] = t33;
339
366
  } else {
340
- t29 = $[72];
367
+ t33 = $[79];
341
368
  }
342
- let t30;
343
- if ($[73] !== className || $[74] !== ref || $[75] !== t24 || $[76] !== t27 || $[77] !== t29 || $[78] !== t9) {
344
- t30 = /*#__PURE__*/_jsxs(ButtonGroup, {
369
+ let t34;
370
+ if ($[80] !== className || $[81] !== ref || $[82] !== t11 || $[83] !== t28 || $[84] !== t31 || $[85] !== t33) {
371
+ t34 = /*#__PURE__*/_jsxs(ButtonGroup, {
345
372
  ref: ref,
346
373
  className: className,
347
- children: [t9, t24, t27, t29]
374
+ children: [t11, t28, t31, t33]
348
375
  });
349
- $[73] = className;
350
- $[74] = ref;
351
- $[75] = t24;
352
- $[76] = t27;
353
- $[77] = t29;
354
- $[78] = t9;
355
- $[79] = t30;
376
+ $[80] = className;
377
+ $[81] = ref;
378
+ $[82] = t11;
379
+ $[83] = t28;
380
+ $[84] = t31;
381
+ $[85] = t33;
382
+ $[86] = t34;
356
383
  } else {
357
- t30 = $[79];
384
+ t34 = $[86];
358
385
  }
359
- return t30;
386
+ return t34;
360
387
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/ui",
3
- "version": "0.44.4",
3
+ "version": "0.45.0",
4
4
  "description": "React components, a theme, formatters and a settings dialog for desktop-grade apps on React 19, Base UI and Tailwind 4.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "author": "Bas Milius",
@@ -45,6 +45,7 @@ export interface ProjectSwitcherProps<Item extends ProjectSwitcherItem = Project
45
45
  label?: string;
46
46
 
47
47
  disabled?: boolean;
48
+ tabIndex?: number;
48
49
  open?: boolean;
49
50
  defaultOpen?: boolean;
50
51
  onOpenChange?: ComponentProps<typeof Menu.Root>['onOpenChange'];
@@ -62,6 +63,7 @@ export function ProjectSwitcher<Item extends ProjectSwitcherItem>({
62
63
  children,
63
64
  label,
64
65
  disabled,
66
+ tabIndex,
65
67
  open,
66
68
  defaultOpen,
67
69
  onOpenChange,
@@ -76,6 +78,7 @@ export function ProjectSwitcher<Item extends ProjectSwitcherItem>({
76
78
  <Menu.Trigger
77
79
  ref={ref}
78
80
  disabled={disabled}
81
+ tabIndex={tabIndex}
79
82
  aria-label={current === null ? empty : label === undefined ? current.name : `${label}: ${current.name}`}
80
83
  className={clsx('project-switcher-trigger', className)}
81
84
  >
@@ -1,9 +1,10 @@
1
1
  import type { Ref } from 'react';
2
+ import clsx from 'clsx';
2
3
  import { Maximize, Minus, Plus, Scan, type LucideIcon } from 'lucide-react';
3
4
  import { useTranslation } from 'react-i18next';
4
5
  import { ButtonGroup } from './ButtonGroup.tsx';
5
6
  import { Icon } from './Icon.tsx';
6
- import { IconButton } from './IconButton.tsx';
7
+ import { IconButton, type IconButtonSize } from './IconButton.tsx';
7
8
  import { Kbd } from './Kbd.tsx';
8
9
  import { MenuItem, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuRoot, MenuSeparator, MenuTrigger } from './menu/parts.tsx';
9
10
  import type { Shortcut } from './shortcut.ts';
@@ -42,10 +43,19 @@ export interface ZoomControlsProps {
42
43
  /* Left out by a surface with nothing to select. */
43
44
  selection?: ZoomSelection;
44
45
 
46
+ /* `md` beside the controls of a dock, `sm` beside the small buttons of a toolbar. */
47
+ size?: Extract<IconButtonSize, 'md' | 'sm'>;
48
+
49
+ /* Where the presets open: above a dock at the bottom, below a toolbar at the top. */
50
+ side?: 'top' | 'bottom';
51
+
45
52
  className?: string;
46
53
  ref?: Ref<HTMLDivElement>;
47
54
  }
48
55
 
56
+ /* The percentage between the buttons, at the height and radius of the buttons beside it. */
57
+ const TRIGGER_SIZE = { md: 'h-8 min-w-14 rounded-lg', sm: 'h-7 min-w-12 rounded-md' } as const;
58
+
49
59
  function MenuIcon({ icon }: { icon: LucideIcon }) {
50
60
  return (
51
61
  <span className="grid h-4 w-4 place-items-center">
@@ -62,6 +72,8 @@ export function ZoomControls({
62
72
  labels = {},
63
73
  shortcuts = {},
64
74
  selection,
75
+ size = 'md',
76
+ side = 'top',
65
77
  className,
66
78
  ref
67
79
  }: ZoomControlsProps) {
@@ -70,14 +82,19 @@ export function ZoomControls({
70
82
 
71
83
  return (
72
84
  <ButtonGroup ref={ref} className={className}>
73
- <IconButton icon={Minus} label={labels.out ?? t('zoom.out')} onClick={() => onZoomChange(steppedZoom(zoom, -10))} />
85
+ <IconButton icon={Minus} size={size} label={labels.out ?? t('zoom.out')} onClick={() => onZoomChange(steppedZoom(zoom, -10))} />
74
86
  <MenuRoot>
75
87
  <Tooltip label={labels.presets ?? t('zoom.presets')}>
76
- <MenuTrigger className="h-8 min-w-14 rounded-lg px-1 text-xs text-text-muted tabular-nums hover:bg-surface-hover hover:text-text data-[popup-open]:bg-surface-active data-[popup-open]:text-text">
88
+ <MenuTrigger
89
+ className={clsx(
90
+ TRIGGER_SIZE[size],
91
+ 'px-1 text-xs text-text-muted tabular-nums hover:bg-surface-hover hover:text-text data-[popup-open]:bg-surface-active data-[popup-open]:text-text'
92
+ )}
93
+ >
77
94
  {Math.round(zoom * 100)}%
78
95
  </MenuTrigger>
79
96
  </Tooltip>
80
- <MenuPopup side="top" sideOffset={10} align="center" className="min-w-44">
97
+ <MenuPopup side={side} sideOffset={10} align="center" className="min-w-44">
81
98
  <MenuRadioGroup value={preset} onValueChange={(value: number) => onZoomChange(value / 100)}>
82
99
  {presets.map((percent) => (
83
100
  <MenuRadioItem key={percent} value={percent}>
@@ -99,8 +116,8 @@ export function ZoomControls({
99
116
  )}
100
117
  </MenuPopup>
101
118
  </MenuRoot>
102
- <IconButton icon={Plus} label={labels.in ?? t('zoom.in')} onClick={() => onZoomChange(steppedZoom(zoom, 10))} />
103
- <IconButton icon={Maximize} label={labels.fitEverything ?? t('zoom.fitEverything')} kbd={shortcuts.fitAll} onClick={onFitAll} />
119
+ <IconButton icon={Plus} size={size} label={labels.in ?? t('zoom.in')} onClick={() => onZoomChange(steppedZoom(zoom, 10))} />
120
+ <IconButton icon={Maximize} size={size} label={labels.fitEverything ?? t('zoom.fitEverything')} kbd={shortcuts.fitAll} onClick={onFitAll} />
104
121
  </ButtonGroup>
105
122
  );
106
123
  }