@rcarls/rc-adaptive-menu 0.5.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.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # `@rcarls/rc-adaptive-menu`
2
+
3
+ Priority-aware action toolbar that preserves authored controls while moving
4
+ lower-priority actions into an overflow menu. The same light-DOM nodes remain
5
+ connected, so framework handlers, form behavior, dialog invokers, and element
6
+ references keep working when an action moves.
7
+
8
+ Docs: [https://richardcarls.github.io/rc-webcomponents/components/rc-adaptive-menu](https://richardcarls.github.io/rc-webcomponents/components/rc-adaptive-menu).
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @rcarls/rc-adaptive-menu
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```html
19
+ <rc-adaptive-menu label="Document actions" max-shown="3">
20
+ <button type="button" data-priority="30">
21
+ <span data-rc-menu-leading aria-hidden="true">★</span>
22
+ <span data-rc-menu-label>Favorite</span>
23
+ </button>
24
+ <button type="button" data-priority="20">
25
+ <span data-rc-menu-leading aria-hidden="true">✎</span>
26
+ <span data-rc-menu-label>Edit</span>
27
+ </button>
28
+ <button type="button" slot="overflow">
29
+ <span data-rc-menu-label>Delete</span>
30
+ </button>
31
+ </rc-adaptive-menu>
32
+
33
+ <script type="module">
34
+ import '@rcarls/rc-adaptive-menu/define';
35
+ </script>
36
+ ```
37
+
38
+ Larger numeric `data-priority` values are promoted first, with DOM order as the
39
+ tie breaker, up to `max-shown` authored actions. Author `slot="overflow"` to
40
+ keep an action in the overflow menu regardless of `max-shown`. A negative
41
+ `data-priority` has the same effect: the action always overflows. The overflow
42
+ menu renders in authored DOM order (native slot distribution isn't
43
+ JS-ordered), so author negative-priority actions after normal-priority ones to
44
+ have them appear last. `max-shown` is a static declarative cap, re-evaluated
45
+ whenever it or an authored action's `data-priority` changes: the component
46
+ does not measure its own or its children's rendered size, so promoted actions
47
+ are not guaranteed to visually fit any particular container. A consumer that
48
+ needs the promoted count to react to available space (a breakpoint, a
49
+ container query, a window size class) owns that decision and writes the
50
+ resulting `max-shown` value down. When the authored set changes, the
51
+ component changes the actions' slot, `role`, and `tabindex`, then restores
52
+ the authored values when they return or disconnect. Demoted `rc-menu-button`
53
+ actions also receive vertical menu-row orientation while overflowed, with
54
+ their authored orientation restored when promoted or disconnected.
55
+
56
+ In horizontal mode the toolbar is a plain shrink-to-fit flex row:
57
+ `max-inline-size: 100%` keeps it constrained by its allocated space, but its
58
+ own preferred width is ordinary CSS, sized to only the actions actually
59
+ promoted. No JS-computed intrinsic-size hint is involved.
60
+
61
+ Use `data-rc-menu-leading`, `data-rc-menu-label`,
62
+ `data-rc-menu-trailing`, and `data-rc-menu-shortcut` to expose menu content
63
+ regions to themes shared with `rc-menu`.
64
+
65
+ The visible overflow button and its activation area can be sized independently
66
+ with `--rc-adaptive-menu-trigger-*` and
67
+ `--rc-adaptive-menu-touch-target-*`. The default activation-area floor is
68
+ `3rem` in both axes.
69
+
70
+ Use `default-open` for initial uncontrolled state, or write `open` and handle
71
+ `rc-adaptive-menu-toggle` for controlled state. The event reports the state
72
+ requested by user interaction; property writes and `openMenu()`, `closeMenu()`,
73
+ and `toggleMenu()` calls are silent. The `$actions`, `$promotedActions`, and
74
+ `$overflowedActions` getters expose the original nodes in current DOM order.