@enonic/ui 1.4.0 → 1.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 CHANGED
@@ -194,6 +194,50 @@ it in a `useMemo` keyed on that instead, or the labels keep their first wording.
194
194
  and check its bundle against. Texts the application supplies through props — a dialog title, an
195
195
  item name — never pass through the provider.
196
196
 
197
+ ## Dialog action shortcuts
198
+
199
+ Shortcuts are opt-in. Use `Dialog.Shortcut` inside `Dialog.Content` to register a primary action,
200
+ or set `shortcut='secondary'` for the secondary action. On macOS, Cmd+Enter activates primary and
201
+ Cmd+Shift+Enter activates secondary; on Windows and Linux, use Ctrl instead of Cmd. By default,
202
+ `Dialog.Shortcut` renders a native button. Set `asChild` to wrap `Button`, `Dialog.Close asChild`,
203
+ or `Stepper.Next/Previous asChild`; the child must forward its ref and props to a native button:
204
+
205
+ ```tsx
206
+ <Dialog.Shortcut asChild shortcut='secondary'>
207
+ <Dialog.Close asChild>
208
+ <Button label='Cancel' />
209
+ </Dialog.Close>
210
+ </Dialog.Shortcut>
211
+ <Dialog.Shortcut asChild pending={saving}>
212
+ <Button label='Save' disabled={saving} onClick={save} />
213
+ </Dialog.Shortcut>
214
+ ```
215
+
216
+ The shortcut calls the registered button's click path, preserving its click handler and close or
217
+ step behavior. `pending` blocks shortcut activation and sets `aria-busy`; it does not block an
218
+ ordinary click, so also disable the button while saving if clicks must be blocked. Disabled,
219
+ hidden, and unmounted actions do not respond to shortcuts. Only the topmost open dialog handles
220
+ shortcuts and Escape. Shortcut keys can come from its content or a registered portal. Modal dialogs
221
+ also accept keys from `<body>` or `document`, preserving shortcuts if a focused field loses
222
+ focus. Non-modal dialogs reject keys from outside their content and registered portals.
223
+ When a shortcut hides the focused step panel, focus moves to the dialog content.
224
+ If two actions use the same shortcut, the first registered action wins until it unregisters;
225
+ development builds warn.
226
+ Buttons keep their ordinary focus, Enter, and Space behavior.
227
+
228
+ Use `shortcutEnabled={false}` to unregister a mounted action without disabling its button; set
229
+ it on inactive views when they share a shortcut. A disabled `Dialog.Shortcut` can render outside
230
+ `Dialog.Content`; enabled registration requires content. For platform-specific hints,
231
+ `getDialogShortcutKeys` returns
232
+ `Meta+Enter` / `Meta+Shift+Enter` on macOS and `Control+Enter` / `Control+Shift+Enter` elsewhere.
233
+ Separately bundled copies share a dialog stack when they use the same shortcut protocol; incompatible
234
+ protocol versions cannot coordinate their topmost scopes.
235
+
236
+ For a multi-step dialog, use `Dialog.StepIndicator keyboardShortcuts`. Previous is secondary;
237
+ Next is primary until the last step, where the final action becomes primary. Its `disabled` and
238
+ `pending` props suppress the corresponding shortcuts. Add visible shortcut hints where people
239
+ need to discover them.
240
+
197
241
  ## What's exported
198
242
 
199
243
  Beyond the components, the package entry re-exports the hooks that drive them (roving tabindex, type-ahead, floating position, scroll lock, and more), the bundled icon set, context providers, shared types, and the `cn` class-merge helper.