@adecore/ui 0.54.12 → 0.54.13

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.
@@ -19,7 +19,7 @@ type ItemLook = {
19
19
  unstyled?: boolean;
20
20
  };
21
21
  type MenuItemProps = ComponentProps<typeof BaseMenu.Item> & ItemLook;
22
- export declare function MenuItem({ unstyled, className, ...props }: MenuItemProps): import("react").JSX.Element;
22
+ export declare function MenuItem({ unstyled, className, children, ...props }: MenuItemProps): import("react").JSX.Element;
23
23
  export interface MenuCheckProps {
24
24
  kind: 'radio' | 'checkbox';
25
25
  checked?: boolean;
@@ -159,8 +159,33 @@ export function MenuPopup(t0) {
159
159
  }
160
160
  return t8;
161
161
  }
162
+ /*
163
+ * Typing in an open menu moves to the first row whose text starts with the letters, read from the
164
+ * row's `label` or else its rendered text. The space JSX keeps between an icon and the name
165
+ * (`<Icon /> {name}`) draws nothing in a row laid out with a gap, but it would start that text and
166
+ * keep the row from ever matching. A row whose text starts with something other than its name,
167
+ * such as initials before it, sets `label`.
168
+ */
169
+ function withoutLeadingSpace(children) {
170
+ if (typeof children === 'string') {
171
+ return children.trimStart();
172
+ }
173
+ if (!Array.isArray(children)) {
174
+ return children;
175
+ }
176
+ let reached = false;
177
+ return children.map(child => {
178
+ if (reached || typeof child !== 'string') {
179
+ return child;
180
+ }
181
+ const trimmed = child.trimStart();
182
+ reached = trimmed !== '';
183
+ return trimmed;
184
+ });
185
+ }
162
186
  export function MenuItem(t0) {
163
- const $ = _c(10);
187
+ const $ = _c(15);
188
+ let children;
164
189
  let className;
165
190
  let props;
166
191
  let t1;
@@ -168,40 +193,54 @@ export function MenuItem(t0) {
168
193
  ({
169
194
  unstyled: t1,
170
195
  className,
196
+ children,
171
197
  ...props
172
198
  } = t0);
173
199
  $[0] = t0;
174
- $[1] = className;
175
- $[2] = props;
176
- $[3] = t1;
200
+ $[1] = children;
201
+ $[2] = className;
202
+ $[3] = props;
203
+ $[4] = t1;
177
204
  } else {
178
- className = $[1];
179
- props = $[2];
180
- t1 = $[3];
205
+ children = $[1];
206
+ className = $[2];
207
+ props = $[3];
208
+ t1 = $[4];
181
209
  }
182
210
  const unstyled = t1 === undefined ? false : t1;
183
211
  let t2;
184
- if ($[4] !== className || $[5] !== unstyled) {
212
+ if ($[5] !== className || $[6] !== unstyled) {
185
213
  t2 = unstyled ? className : withClass("menu-item", className);
186
- $[4] = className;
187
- $[5] = unstyled;
188
- $[6] = t2;
214
+ $[5] = className;
215
+ $[6] = unstyled;
216
+ $[7] = t2;
189
217
  } else {
190
- t2 = $[6];
218
+ t2 = $[7];
191
219
  }
192
220
  let t3;
193
- if ($[7] !== props || $[8] !== t2) {
194
- t3 = /*#__PURE__*/_jsx(BaseMenu.Item, {
221
+ if ($[8] !== children || $[9] !== unstyled) {
222
+ t3 = unstyled ? children : withoutLeadingSpace(children);
223
+ $[8] = children;
224
+ $[9] = unstyled;
225
+ $[10] = t3;
226
+ } else {
227
+ t3 = $[10];
228
+ }
229
+ let t4;
230
+ if ($[11] !== props || $[12] !== t2 || $[13] !== t3) {
231
+ t4 = /*#__PURE__*/_jsx(BaseMenu.Item, {
195
232
  className: t2,
196
- ...props
233
+ ...props,
234
+ children: t3
197
235
  });
198
- $[7] = props;
199
- $[8] = t2;
200
- $[9] = t3;
236
+ $[11] = props;
237
+ $[12] = t2;
238
+ $[13] = t3;
239
+ $[14] = t4;
201
240
  } else {
202
- t3 = $[9];
241
+ t4 = $[14];
203
242
  }
204
- return t3;
243
+ return t4;
205
244
  }
206
245
  /* One line of the row tall, so a row with a second line keeps the tick beside its first. */
207
246
  export function MenuCheck(t0) {
@@ -281,7 +320,7 @@ export function MenuCheck(t0) {
281
320
  const checkRow = (kind, unstyled, indicator, children) => unstyled ? children : /*#__PURE__*/_jsxs(_Fragment, {
282
321
  children: [indicator === 'start' && /*#__PURE__*/_jsx(MenuCheck, {
283
322
  kind: kind
284
- }), children, indicator === 'end' && /*#__PURE__*/_jsx(MenuCheck, {
323
+ }), withoutLeadingSpace(children), indicator === 'end' && /*#__PURE__*/_jsx(MenuCheck, {
285
324
  kind: kind,
286
325
  className: "ml-auto"
287
326
  })]
@@ -418,7 +457,7 @@ export function MenuRadioItem(t0) {
418
457
  return t5;
419
458
  }
420
459
  export function MenuSubmenuTrigger(t0) {
421
- const $ = _c(14);
460
+ const $ = _c(16);
422
461
  let children;
423
462
  let className;
424
463
  let props;
@@ -451,33 +490,41 @@ export function MenuSubmenuTrigger(t0) {
451
490
  t2 = $[6];
452
491
  }
453
492
  let t3;
454
- if ($[7] !== chevron) {
455
- t3 = chevron && /*#__PURE__*/_jsx(Icon, {
493
+ if ($[7] !== children) {
494
+ t3 = withoutLeadingSpace(children);
495
+ $[7] = children;
496
+ $[8] = t3;
497
+ } else {
498
+ t3 = $[8];
499
+ }
500
+ let t4;
501
+ if ($[9] !== chevron) {
502
+ t4 = chevron && /*#__PURE__*/_jsx(Icon, {
456
503
  icon: ChevronRight,
457
504
  size: 14,
458
505
  className: "ml-auto text-text-faint"
459
506
  });
460
- $[7] = chevron;
461
- $[8] = t3;
507
+ $[9] = chevron;
508
+ $[10] = t4;
462
509
  } else {
463
- t3 = $[8];
510
+ t4 = $[10];
464
511
  }
465
- let t4;
466
- if ($[9] !== children || $[10] !== props || $[11] !== t2 || $[12] !== t3) {
467
- t4 = /*#__PURE__*/_jsxs(BaseMenu.SubmenuTrigger, {
512
+ let t5;
513
+ if ($[11] !== props || $[12] !== t2 || $[13] !== t3 || $[14] !== t4) {
514
+ t5 = /*#__PURE__*/_jsxs(BaseMenu.SubmenuTrigger, {
468
515
  className: t2,
469
516
  ...props,
470
- children: [children, t3]
517
+ children: [t3, t4]
471
518
  });
472
- $[9] = children;
473
- $[10] = props;
474
- $[11] = t2;
475
- $[12] = t3;
476
- $[13] = t4;
519
+ $[11] = props;
520
+ $[12] = t2;
521
+ $[13] = t3;
522
+ $[14] = t4;
523
+ $[15] = t5;
477
524
  } else {
478
- t4 = $[13];
525
+ t5 = $[15];
479
526
  }
480
- return t4;
527
+ return t5;
481
528
  }
482
529
  /* Its first item is the row, every `RowAction` and `RowSubmenuTrigger` after it an item of its own, so the arrow keys reach each. */
483
530
  export function MenuRow(t0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/ui",
3
- "version": "0.54.12",
3
+ "version": "0.54.13",
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",
@@ -97,10 +97,44 @@ type ItemLook = {
97
97
  unstyled?: boolean;
98
98
  };
99
99
 
100
+ /*
101
+ * Typing in an open menu moves to the first row whose text starts with the letters, read from the
102
+ * row's `label` or else its rendered text. The space JSX keeps between an icon and the name
103
+ * (`<Icon /> {name}`) draws nothing in a row laid out with a gap, but it would start that text and
104
+ * keep the row from ever matching. A row whose text starts with something other than its name,
105
+ * such as initials before it, sets `label`.
106
+ */
107
+ function withoutLeadingSpace(children: ReactNode): ReactNode {
108
+ if (typeof children === 'string') {
109
+ return children.trimStart();
110
+ }
111
+
112
+ if (!Array.isArray(children)) {
113
+ return children;
114
+ }
115
+
116
+ let reached = false;
117
+
118
+ return children.map((child: ReactNode) => {
119
+ if (reached || typeof child !== 'string') {
120
+ return child;
121
+ }
122
+
123
+ const trimmed = child.trimStart();
124
+ reached = trimmed !== '';
125
+
126
+ return trimmed;
127
+ });
128
+ }
129
+
100
130
  type MenuItemProps = ComponentProps<typeof BaseMenu.Item> & ItemLook;
101
131
 
102
- export function MenuItem({ unstyled = false, className, ...props }: MenuItemProps) {
103
- return <BaseMenu.Item className={unstyled ? className : withClass('menu-item', className)} {...props} />;
132
+ export function MenuItem({ unstyled = false, className, children, ...props }: MenuItemProps) {
133
+ return (
134
+ <BaseMenu.Item className={unstyled ? className : withClass('menu-item', className)} {...props}>
135
+ {unstyled ? children : withoutLeadingSpace(children)}
136
+ </BaseMenu.Item>
137
+ );
104
138
  }
105
139
 
106
140
  export interface MenuCheckProps {
@@ -147,7 +181,7 @@ const checkRow = (kind: MenuCheckProps['kind'], unstyled: boolean, indicator: In
147
181
  ) : (
148
182
  <>
149
183
  {indicator === 'start' && <MenuCheck kind={kind} />}
150
- {children}
184
+ {withoutLeadingSpace(children)}
151
185
  {indicator === 'end' && <MenuCheck kind={kind} className="ml-auto" />}
152
186
  </>
153
187
  );
@@ -182,7 +216,7 @@ type SubmenuTriggerProps = ComponentProps<typeof BaseMenu.SubmenuTrigger> & {
182
216
  export function MenuSubmenuTrigger({ className, children, chevron = true, ...props }: SubmenuTriggerProps) {
183
217
  return (
184
218
  <BaseMenu.SubmenuTrigger className={withClass('menu-item', className)} {...props}>
185
- {children}
219
+ {withoutLeadingSpace(children)}
186
220
  {chevron && <Icon icon={ChevronRight} size={14} className="ml-auto text-text-faint" />}
187
221
  </BaseMenu.SubmenuTrigger>
188
222
  );