@things-factory/apptool-ui 10.1.291 → 10.1.296

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.
@@ -8,7 +8,7 @@ import { customElement, state } from 'lit/decorators.js';
8
8
  import { i18next } from '@operato/i18n';
9
9
  import { OxPopupMenu } from '@operato/popup/ox-popup-menu.js';
10
10
  import { store } from '@operato/shell';
11
- import { menuEntries, monogram, personName } from './user-menu-model';
11
+ import { menuGroups, monogram, personName } from './user-menu-model';
12
12
  /**
13
13
  * The signed-in person's avatar and their own menu - the right end of the header, as YouTube has it.
14
14
  *
@@ -97,11 +97,15 @@ let AppUserMenu = class AppUserMenu extends LitElement {
97
97
  ${email ? html `<span style="font-size: 12px; color: var(--md-sys-color-on-surface-variant);">${email}</span>` : nothing}
98
98
  </div>
99
99
  </div>
100
- ${menuEntries(this.entries).map(entry => html `
101
- <ox-popup-menuitem label=${i18next.t(entry.label || entry.name)} @select=${() => entry.action?.()}>
102
- <md-icon slot="icon">${entry.icon}</md-icon>
103
- </ox-popup-menuitem>
104
- `)}
100
+ ${menuGroups(this.entries).map(part => part.map((entry, at) => html `
101
+ <ox-popup-menuitem
102
+ label=${i18next.t(entry.label || entry.name)}
103
+ style=${at < part.length - 1 ? 'border-bottom-color: transparent;' : nothing}
104
+ @select=${() => entry.action?.()}
105
+ >
106
+ <md-icon slot="icon">${entry.icon}</md-icon>
107
+ </ox-popup-menuitem>
108
+ `))}
105
109
  `,
106
110
  top: at.bottom + 6,
107
111
  right: window.innerWidth - at.right,
@@ -5,16 +5,20 @@
5
5
  * is registered by the modules that own each entry (`ADD_USER_MENU` in apptool-base) - auth-ui's
6
6
  * profile and sign-out, setting-ui's settings - so no person's word lives in this package.
7
7
  */
8
+ import type { UserMenuGroup } from '@things-factory/apptool-base/client';
8
9
  /** An entry as the registry keeps it. `action` is never called here. */
9
10
  export type UserMenuEntry = {
10
11
  name: string;
11
12
  icon?: string;
12
13
  label?: string;
14
+ group?: UserMenuGroup;
13
15
  order?: number;
14
16
  action?: () => void;
15
17
  };
16
- /** The entries in the order the menu shows them - by `order`, then as registered. */
18
+ /** The entries in the order the menu shows them - by group, then `order`, then as registered. */
17
19
  export declare function menuEntries<T extends UserMenuEntry>(entries?: readonly T[]): T[];
20
+ /** The entries split into the parts the menu draws, in order; a part with no entry is left out. */
21
+ export declare function menuGroups<T extends UserMenuEntry>(entries?: readonly T[]): T[][];
18
22
  /** The name the menu's head shows: the person's name, or the email for one who has none. */
19
23
  export declare function personName(user?: {
20
24
  name?: string;
@@ -5,15 +5,40 @@
5
5
  * is registered by the modules that own each entry (`ADD_USER_MENU` in apptool-base) - auth-ui's
6
6
  * profile and sign-out, setting-ui's settings - so no person's word lives in this package.
7
7
  */
8
- /** An entry that names no order sits after settings and before the about page. */
8
+ /**
9
+ * The menu's parts, top to bottom: the person's own pages, then the company's rules, asking and the
10
+ * about page, then sign-out alone at the end - a line between parts, none inside one (user, 2026-11-18).
11
+ */
12
+ const GROUPS = ['self', 'help', 'session'];
13
+ /** An entry that names no group sits among `help`; one that names no order, before the about page. */
14
+ const DEFAULT_GROUP = 'help';
9
15
  const DEFAULT_ORDER = 50;
10
- /** The entries in the order the menu shows them - by `order`, then as registered. */
16
+ const rankOf = (entry) => {
17
+ const rank = GROUPS.indexOf(entry.group ?? DEFAULT_GROUP);
18
+ return rank < 0 ? GROUPS.indexOf(DEFAULT_GROUP) : rank;
19
+ };
20
+ /** The entries in the order the menu shows them - by group, then `order`, then as registered. */
11
21
  export function menuEntries(entries = []) {
12
22
  return (entries || [])
13
23
  .map((entry, index) => ({ entry, index }))
14
- .sort((a, b) => (a.entry.order ?? DEFAULT_ORDER) - (b.entry.order ?? DEFAULT_ORDER) || a.index - b.index)
24
+ .sort((a, b) => rankOf(a.entry) - rankOf(b.entry) ||
25
+ (a.entry.order ?? DEFAULT_ORDER) - (b.entry.order ?? DEFAULT_ORDER) ||
26
+ a.index - b.index)
15
27
  .map(({ entry }) => entry);
16
28
  }
29
+ /** The entries split into the parts the menu draws, in order; a part with no entry is left out. */
30
+ export function menuGroups(entries = []) {
31
+ const parts = [];
32
+ let last = -1;
33
+ for (const entry of menuEntries(entries)) {
34
+ const rank = rankOf(entry);
35
+ if (rank !== last)
36
+ parts.push([]);
37
+ parts[parts.length - 1].push(entry);
38
+ last = rank;
39
+ }
40
+ return parts;
41
+ }
17
42
  /** The name the menu's head shows: the person's name, or the email for one who has none. */
18
43
  export function personName(user) {
19
44
  return (user?.name || '').trim() || (user?.email || '').trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/apptool-ui",
3
- "version": "10.1.291",
3
+ "version": "10.1.296",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "files": [
@@ -47,8 +47,8 @@
47
47
  "@operato/shell": "^10.29.60",
48
48
  "@operato/styles": "^10.29.81",
49
49
  "@operato/utils": "^10.29.43",
50
- "@things-factory/apptool-base": "^10.1.291",
51
- "@things-factory/setting-base": "^10.1.291"
50
+ "@things-factory/apptool-base": "^10.1.296",
51
+ "@things-factory/setting-base": "^10.1.296"
52
52
  },
53
- "gitHead": "994bc91b2d71513039c204560bb0571baa92ca0b"
53
+ "gitHead": "0cd4b6207e4dfc557157f86630d82aed423b1dde"
54
54
  }