@ahrowe/ui 0.47.3 → 0.48.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.
@@ -25,6 +25,11 @@ export interface MenuAction {
25
25
  disabled?: boolean;
26
26
  /** Renders in the destructive colour. For deleting, discarding, revoking. */
27
27
  danger?: boolean;
28
+ /**
29
+ * Followed after `onClick` and `onAction`. In `Menu` a real `<a>`, so Ctrl/⌘-click opens a new tab.
30
+ * Loads the whole page: with a client-side router, navigate in `onClick` instead.
31
+ */
32
+ href?: string;
28
33
  onClick?: () => void;
29
34
  }
30
35
  /** A line between groups of actions. */
@@ -14,7 +14,7 @@ import { MenuEntry } from './menu.types.js';
14
14
  * useHotkeys(menuHotkeys(items, run), { enabled: isOpen }); // only while the menu is open
15
15
  * ```
16
16
  *
17
- * Runs each entry the way clicking it does: its own `onClick`, then `onAction`. A `disabled`
18
- * entry, and an entry with no `shortcut`, is left out.
17
+ * Runs each entry the way clicking it does: its own `onClick`, then `onAction`, then its `href`.
18
+ * A `disabled` entry, and an entry with no `shortcut`, is left out.
19
19
  */
20
20
  export declare function menuHotkeys(items: MenuEntry[], onAction?: (id: string) => void): HotkeyMap;
@@ -0,0 +1,10 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { MenuAction, MenuEntry } from './menu.types.js';
3
+ export declare function hasAnyIcon(items: MenuEntry[]): boolean;
4
+ /** The action's icon, or an empty cell as wide when another action has one, so the labels line up. */
5
+ export declare function renderItemIcon(icon: MenuAction['icon'], reserveCell: boolean, props: {
6
+ className: string;
7
+ style?: CSSProperties;
8
+ }): ReactNode;
9
+ /** Runs an action the way clicking it does: its own `onClick`, then `onAction`, then its `href`. */
10
+ export declare function runMenuAction(action: MenuAction, onAction?: (id: string) => void): void;
@@ -73,7 +73,7 @@ On a small touch screen it can present as a bottom sheet like every `Modal`: pas
73
73
  | `isLoading` | `boolean` | Shows the `loading` label instead of `empty` while nothing matches |
74
74
  | `presentation` | `Presentation` | Centred dialog (default), bottom sheet, or a sheet only on a small touch screen |
75
75
 
76
- A command is a `MenuAction`: `id`, `label`, `icon`, `shortcut`, `keywords`, `disabled`, `danger` and `onClick`. See [Menu.md](Menu.md).
76
+ A command is a `MenuAction`: `id`, `label`, `icon`, `shortcut`, `keywords`, `disabled`, `danger`, `href` and `onClick`. A command with an `href` goes there after running. See [Menu.md](Menu.md).
77
77
 
78
78
  **Global defaults:** adopts `ConfigProvider`, e.g. `defaultProps={{ CommandPalette: { presentation: Presentation.Auto } }}`. See [ConfigProvider.md](ConfigProvider.md).
79
79
 
@@ -23,4 +23,4 @@ import { InteractableDiv } from '@ahrowe/ui';
23
23
  </InteractableDiv>
24
24
  ```
25
25
 
26
- **Note:** Check [package/common/interactableDiv/](https://github.com/AndreasWeinzierl/ahrowe-ui/tree/master/package/common/interactableDiv) for full prop details.
26
+ **Note:** Check [package/common/interactableDiv/](https://github.com/ahrowe-dev/ahrowe-ui/tree/master/package/common/interactableDiv) for full prop details.
package/docs/Menu.md CHANGED
@@ -27,9 +27,9 @@ const items: MenuEntry[] = [
27
27
  **Entries** are one of three shapes, and the list is read in the order you give it:
28
28
 
29
29
  ```ts
30
- { id: 'edit', label: 'Edit', icon, shortcut, keywords, disabled, danger, onClick } // an action
31
- { separator: true } // a line
32
- { heading: 'This document' } // a label over what follows
30
+ { id: 'edit', label: 'Edit', icon, shortcut, keywords, disabled, danger, href, onClick } // an action, or a link with `href`
31
+ { separator: true } // a line
32
+ { heading: 'This document' } // a label over what follows
33
33
  ```
34
34
 
35
35
  `keywords` are extra search terms for [CommandPalette](CommandPalette.md), which takes the same entries. The menu ignores them.
@@ -54,7 +54,7 @@ useHotkeys(menuHotkeys(items, run));
54
54
  useHotkeys(menuHotkeys(items, run), { enabled: isOpen });
55
55
  ```
56
56
 
57
- It runs each entry the way clicking it does, its own `onClick` then `onAction`, and leaves out a `disabled` entry and any entry with no `shortcut`. Bind them yourself instead if the actions already live in a keymap of your own; the menu does not mind either way.
57
+ It runs each entry the way clicking it does, its own `onClick` then `onAction` then its `href`, and leaves out a `disabled` entry and any entry with no `shortcut`. Bind them yourself instead if the actions already live in a keymap of your own; the menu does not mind either way.
58
58
 
59
59
  An action runs its own `onClick` first, then `onAction` on the menu, then the menu closes. Use whichever of the two fits: a handler per entry when they are unrelated, `onAction` when they funnel into one place.
60
60
 
@@ -116,10 +116,11 @@ Separators and headings are never focused. The trigger is given `aria-haspopup`,
116
116
  |-------|------|-------------|
117
117
  | `id` | `string` | Stable id, also what `onAction` reports |
118
118
  | `label` | `ReactNode` | What the entry says |
119
- | `icon` | `IconContent` | Leading icon |
119
+ | `icon` | `IconContent` | Leading icon. Entries without one keep its space while any other has one, so the labels line up. Same in `CommandPalette` |
120
120
  | `shortcut` | `string` | A combo in `useHotkeys` spelling, e.g. `'mod+k'`. Shown on the trailing edge, written for the platform. Binding it is yours, see `menuHotkeys` |
121
121
  | `disabled` | `boolean` | Not clickable, and skipped by the arrow keys |
122
122
  | `danger` | `boolean` | Renders in the destructive colour |
123
+ | `href` | `string` | Makes the entry a real `<a>`, so Ctrl/⌘-click and a middle click open it in a new tab. A click runs `onClick` and `onAction` first, a middle click neither. The browser loads the page, so with a client-side router navigate in `onClick` instead. A `disabled` entry stays a button |
123
124
  | `onClick` | `() => void` | Runs before `onAction` |
124
125
 
125
126
  **Slots:** `root` `trigger` `menu` `item` `itemIcon` `itemLabel` `itemShortcut` `separator` `heading`
@@ -49,7 +49,7 @@ when unset. A label on a coloured segment is black or white, whichever reads on
49
49
 
50
50
  | Variable | Falls back to |
51
51
  |----------|---------------|
52
- | `--progress-bar-track-color` | `var(--background-accent)` |
52
+ | `--progress-bar-track-color` | `var(--background-accent-light)` |
53
53
 
54
54
  ```tsx
55
55
  // Theme-wide, via ThemeProvider
@@ -79,6 +79,6 @@ interface RadioOption {
79
79
 
80
80
  ## Sizing
81
81
 
82
- The group is sized by its font, so the radios, the spacing between options and the gap to each label all scale with the text. `--radio-size` and `--radio-gap` override the circle and the label spacing; they fall back to `1.125em` and `0.625em`, i.e. 18px and 10px at a 16px base. The dot is always half the circle.
82
+ The group is sized by its font, so the radios, the spacing between options and the gap to each label all scale with the text. `--radio-size` and `--radio-gap` override the circle and the label spacing; they fall back to `1.125em` and `0.625em`, i.e. 18px and 10px at a 16px base. The dot is about half the circle.
83
83
 
84
84
  The `size` prop still wins where it is given, for a radio that must match a fixed layout rather than the text around it.
@@ -92,7 +92,7 @@ interface Theme {
92
92
  }
93
93
  ```
94
94
 
95
- **Key CSS variables** (see `package/common/themeProvider/theme.types.ts` for the full list):
95
+ **Key CSS variables** (`ThemeVariables` is the full list, in `node_modules/@ahrowe/ui/dist/types/common/themeProvider/theme.types.d.ts`):
96
96
 
97
97
  | Variable | Purpose |
98
98
  |----------|---------|
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahrowe/ui",
3
- "version": "0.47.3",
3
+ "version": "0.48.0",
4
4
  "description": "A React UI component library with theming, CSS Modules, and TypeScript support",
5
5
  "keywords": [
6
6
  "agent",
@@ -18,13 +18,13 @@
18
18
  ],
19
19
  "homepage": "https://ahrowe.com/packages/ui/demo/",
20
20
  "bugs": {
21
- "url": "https://github.com/AndreasWeinzierl/ahrowe-ui/issues"
21
+ "url": "https://github.com/ahrowe-dev/ahrowe-ui/issues"
22
22
  },
23
23
  "license": "MIT",
24
24
  "author": "ahrowe <dev@ahrowe.com>",
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "git+https://github.com/AndreasWeinzierl/ahrowe-ui.git"
27
+ "url": "git+https://github.com/ahrowe-dev/ahrowe-ui.git"
28
28
  },
29
29
  "style": "./dist/style.css",
30
30
  "bin": {
@@ -77,7 +77,7 @@
77
77
  "scripts": {
78
78
  "dev": "vite",
79
79
  "build": "vite build",
80
- "build:demo": "vite build --base=/packages/ui/demo/ --outDir dist-demo",
80
+ "build:demo": "vite build --base=./ --outDir dist-demo",
81
81
  "build:lib": "vite build --config vite.lib.config.ts",
82
82
  "build:mcp": "vite build --config vite.mcp.config.ts",
83
83
  "preview": "vite preview",