@xleddyl/443-components-vue 0.16.109 → 0.16.110
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/CATALOG.md +16 -16
- package/README.md +1 -1
- package/dist/internal/overlays/DialogFrame.vue +51 -2
- package/dist/styles/overlays/drawer.css +7 -0
- package/package.json +1 -1
package/CATALOG.md
CHANGED
|
@@ -208,22 +208,22 @@ All field components work inside `FormField` and take `invalid`, `disabled`, `re
|
|
|
208
208
|
|
|
209
209
|
Mount `OverlayHost` once for the imperative hooks (see [Composables](#composables)).
|
|
210
210
|
|
|
211
|
-
| Component | Purpose and when to use it | Main props, models, slots, events
|
|
212
|
-
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
213
|
-
| `Modal` | Centered dialog for forms and content. Use `Drawer` for a side panel, `useConfirm` for a yes or no question. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `size` (sm to xl, full, fit, fullscreen), `width`, `minHeight`, `height` (fixed, capped at the viewport), `dismissible`, `hideClose`, `sheet`, `flush`, `fill`, `loading`, `beforeClose(reason)`, `tabs` (tabs in the header), `trail` (breadcrumb title and back button; a long trail stays on one line, the middle crumbs collapse into a "..." menu and the current title truncates), `backLabel`, `guard` (default `true`: closing, or a trail navigation, with a dirty `Form` inside asks to discard first; `beforeClose` runs after), `guardTitle`, `guardMessage`. Slots: default (`{ tab }`), `header`, `actions` (header, before the close button), `toolbar` (a full width row of controls under the title and the description, such as filters), `footer`, `title-trailing`. Events: `open`, `close`, `afterLeave`, `navigate(index)`. Exposes `close()`, `confirmLeave()`, `dirty`.
|
|
214
|
-
| `Drawer` | Panel from the side or bottom for details and edit forms. Use `Modal` for short focused dialogs. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `side` (left, right, bottom), `size` (sm to xl, full), `dismissible`, `hideClose`, `flush`, `fill` (the body content takes the full height, for a table or a grid), `loading`, `beforeClose(reason)`, `tabs`, `trail`, `backLabel`, `guard`, `guardTitle`, `guardMessage` (as `Modal`), `docked` (a right drawer stays in the dock of `AppShell` beside the page, not modal, from 1280px of shell width; the dock shows an empty state while it is closed; a header button detaches or docks the whole dock, saved in the preferences, `detachLabel`, `attachLabel`; in the dock
|
|
215
|
-
| `ConfirmDialog` | Declarative confirm dialog. Prefer `useConfirm()`. Use this one only when the dialog state lives in the template. | Model: `v-model:open`. Props: `title`, `description`, `confirmLabel`, `cancelLabel`, `tone`, `icon`, `hideCancel`, `onConfirm`. Events: `resolve(confirmed)`, `cancel`, `afterLeave`.
|
|
216
|
-
| `ConfirmHost` | Renders the dialogs of `useConfirm`, `useAlert`, `usePrompt`. `OverlayHost` includes it. Do not mount it alone. | None.
|
|
217
|
-
| `OverlayHost` | One mount point for toasts, confirm dialogs, programmatic modals and loading indicators. | Props: `toaster` (true or options), `confirm`, `modals`, `loading` (true or `{ bar, delay, label }`).
|
|
218
|
-
| `Toaster` | Renders toasts. `OverlayHost` includes it. Use it directly only for custom options. The stack moves out of the way of an open side Drawer (beside it, or above its footer). | Props: `position`, `max`, `duration`, `gap`, `expand`, `progress`, `hotkey`.
|
|
219
|
-
| `DropdownMenu` | Menu opened by its trigger. Items can have icons, shortcuts, checkboxes, radios, sub menus and links. | Model: `v-model:open`. Props: `items` (`label`, `icon`, `color` (palette name or hex dot, or `muted` for a grey dot of an empty state), `to`, `href`, `tone: danger`, `shortcut`, `disabled`, `disabledReason` (with `disabled`: a tooltip on hover and keyboard focus, linked with `aria-describedby`; the item stays reachable but not selectable), `children`, `onSelect`; also `type`: checkbox, radio, label, separator), `placement`, `offset`, `matchTriggerWidth`, `minWidth`. Slot: default (the trigger). Event: `select`.
|
|
220
|
-
| `ContextMenu` | Menu on right click of the wrapped area. | Model: `v-model:open`. Props: `items` (same as `DropdownMenu`), `disabled`. Slot: default (the area). Event: `select`.
|
|
221
|
-
| `Popover` | Floating panel with any content (a form, filters) opened by its trigger, or next to any element or point with `anchor`. Use `DropdownMenu` for a list of actions. | Model: `v-model:open`. Props: `placement`, `offset`, `arrow`, `label`, `initialFocus`, `width` (any CSS length, capped at the viewport), `anchor` (an element, also inside a same origin iframe, or a virtual `{ getBoundingClientRect() }`; positions against it instead of the trigger, the trigger slot becomes optional). `sheet` (a bottom sheet `Modal` with the same content when the viewport is 640px wide or less). Slots: default (the trigger), `content`. Exposed: `show`, `hide`, `toggle`.
|
|
222
|
-
| `HoverCard` | Rich preview on hover or focus (user card, link preview). Use `Tooltip` for plain text. | Model: `v-model:open`. Props: `placement`, `openDelay`, `closeDelay`, `arrow`, `disabled`. Slots: default (trigger), `content`.
|
|
223
|
-
| `Tooltip` | Short text on hover or focus. Optional shortcut. `Button` already shows one for icon-only buttons, `tooltip` and `disabledReason`. | Props: `text`, `placement`, `openDelay`, `closeDelay`, `arrow`, `shortcut`, `disabled`. Slots: default (trigger), `content`.
|
|
224
|
-
| `CommandPalette` | Search and command dialog (Cmd+K) with groups, recent items, async search and typed item data. Groups take `icon` (default item icon) and `more` (a last "show all" item). Matching (`matchesSearch`, exported) finds every word in any order, without case or accents. | Models: `v-model:open`, `v-model:query`. Props: `groups` (items with `id`, `label`, `description`, `meta` (inline secondary label), `highlight` (`{ label, description }` ranges `[start, end]` marked with `k-mark`), `icon`, `badge`, `shortcut`, `keywords`, `to`, `data`, `disabled`, `disabledReason` (with `disabled`: reachable with the arrow keys but not selectable, a tooltip on hover and keyboard focus, linked with `aria-describedby`), `onSelect`), `search(query, signal)`, `pinned` (items or `(query) => items` shown first, never filtered or saved as recent), `shortcut`, `trigger`, `recentKey`, `emptyText`, `notice`. Slots: `item`, `empty`, `group-label`, `after-results`. Events: `select`, `open`, `close`.
|
|
225
|
-
| `CommandList` | The search field and grouped list of `CommandPalette` without the dialog: place it inline in a panel or in a `Popover` (with `anchor` for a picker opened next to any element). Arrow keys, Enter and the same matching. | Model: `v-model:query`. Props: the `CommandPalette` list props (`groups`, `search`, `pinned`, `filter`, `loading`, `placeholder`, `label`, `recentKey`, `emptyText`, `notice` and the copy props), `autofocus` (default `true`), `footer` (the key hints, default `false`). Slots: `item`, `empty`, `group-label`, `after-results`. Events: `select`, `close` (Escape). Exposed: `focus`, `refresh`.
|
|
226
|
-
| `CommandButton` | A `Button` made from a `CommandItem`: label, icon, `to`, `href`, `disabled`, `disabledReason` (tooltip on the disabled button) and `onSelect` come from the command. | Props: `command`, `label`, `icon`, `iconOnly` (a square button with the icon only, the label as `aria-label` and tooltip), and every `Button` prop (size, variant, tone).
|
|
211
|
+
| Component | Purpose and when to use it | Main props, models, slots, events | Playground |
|
|
212
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
|
|
213
|
+
| `Modal` | Centered dialog for forms and content. Use `Drawer` for a side panel, `useConfirm` for a yes or no question. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `size` (sm to xl, full, fit, fullscreen), `width`, `minHeight`, `height` (fixed, capped at the viewport), `dismissible`, `hideClose`, `sheet`, `flush`, `fill`, `loading`, `beforeClose(reason)`, `tabs` (tabs in the header), `trail` (breadcrumb title and back button; a long trail stays on one line, the middle crumbs collapse into a "..." menu and the current title truncates), `backLabel`, `guard` (default `true`: closing, or a trail navigation, with a dirty `Form` inside asks to discard first; `beforeClose` runs after), `guardTitle`, `guardMessage`. Slots: default (`{ tab }`), `header`, `actions` (header, before the close button), `toolbar` (a full width row of controls under the title and the description, such as filters), `footer`, `title-trailing`. Events: `open`, `close`, `afterLeave`, `navigate(index)`. The `#actions` slot moves into an "Actions" menu when it does not fit next to the title. Exposes `close()`, `confirmLeave()`, `dirty`. | `overlays/modal.vue` |
|
|
214
|
+
| `Drawer` | Panel from the side or bottom for details and edit forms. Use `Modal` for short focused dialogs. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `side` (left, right, bottom), `size` (sm to xl, full), `dismissible`, `hideClose`, `flush`, `fill` (the body content takes the full height, for a table or a grid), `loading`, `beforeClose(reason)`, `tabs`, `trail`, `backLabel`, `guard`, `guardTitle`, `guardMessage` (as `Modal`), `docked` (a right drawer stays in the dock of `AppShell` beside the page, not modal, from 1280px of shell width; the dock shows an empty state while it is closed; a header button detaches or docks the whole dock, saved in the preferences, `detachLabel`, `attachLabel`; in the dock there is no close button; the overlay is at most 48rem wide). The body is a size container (`k-drawer`): use container queries inside. Slots like `Modal`. Events: `open`, `close`, `afterLeave`, `navigate(index)`. Exposes `close()`, `confirmLeave()`, `dirty`. | `overlays/drawer.vue` |
|
|
215
|
+
| `ConfirmDialog` | Declarative confirm dialog. Prefer `useConfirm()`. Use this one only when the dialog state lives in the template. | Model: `v-model:open`. Props: `title`, `description`, `confirmLabel`, `cancelLabel`, `tone`, `icon`, `hideCancel`, `onConfirm`. Events: `resolve(confirmed)`, `cancel`, `afterLeave`. | `overlays/confirm-dialog.vue` |
|
|
216
|
+
| `ConfirmHost` | Renders the dialogs of `useConfirm`, `useAlert`, `usePrompt`. `OverlayHost` includes it. Do not mount it alone. | None. | - |
|
|
217
|
+
| `OverlayHost` | One mount point for toasts, confirm dialogs, programmatic modals and loading indicators. | Props: `toaster` (true or options), `confirm`, `modals`, `loading` (true or `{ bar, delay, label }`). | `overlays/hooks.vue` |
|
|
218
|
+
| `Toaster` | Renders toasts. `OverlayHost` includes it. Use it directly only for custom options. The stack moves out of the way of an open side Drawer (beside it, or above its footer). | Props: `position`, `max`, `duration`, `gap`, `expand`, `progress`, `hotkey`. | `overlays/toast.vue` |
|
|
219
|
+
| `DropdownMenu` | Menu opened by its trigger. Items can have icons, shortcuts, checkboxes, radios, sub menus and links. | Model: `v-model:open`. Props: `items` (`label`, `icon`, `color` (palette name or hex dot, or `muted` for a grey dot of an empty state), `to`, `href`, `tone: danger`, `shortcut`, `disabled`, `disabledReason` (with `disabled`: a tooltip on hover and keyboard focus, linked with `aria-describedby`; the item stays reachable but not selectable), `children`, `onSelect`; also `type`: checkbox, radio, label, separator), `placement`, `offset`, `matchTriggerWidth`, `minWidth`. Slot: default (the trigger). Event: `select`. | `overlays/dropdown-menu.vue` |
|
|
220
|
+
| `ContextMenu` | Menu on right click of the wrapped area. | Model: `v-model:open`. Props: `items` (same as `DropdownMenu`), `disabled`. Slot: default (the area). Event: `select`. | `overlays/context-menu.vue` |
|
|
221
|
+
| `Popover` | Floating panel with any content (a form, filters) opened by its trigger, or next to any element or point with `anchor`. Use `DropdownMenu` for a list of actions. | Model: `v-model:open`. Props: `placement`, `offset`, `arrow`, `label`, `initialFocus`, `width` (any CSS length, capped at the viewport), `anchor` (an element, also inside a same origin iframe, or a virtual `{ getBoundingClientRect() }`; positions against it instead of the trigger, the trigger slot becomes optional). `sheet` (a bottom sheet `Modal` with the same content when the viewport is 640px wide or less). Slots: default (the trigger), `content`. Exposed: `show`, `hide`, `toggle`. | `overlays/popover.vue` |
|
|
222
|
+
| `HoverCard` | Rich preview on hover or focus (user card, link preview). Use `Tooltip` for plain text. | Model: `v-model:open`. Props: `placement`, `openDelay`, `closeDelay`, `arrow`, `disabled`. Slots: default (trigger), `content`. | `overlays/hover-card.vue` |
|
|
223
|
+
| `Tooltip` | Short text on hover or focus. Optional shortcut. `Button` already shows one for icon-only buttons, `tooltip` and `disabledReason`. | Props: `text`, `placement`, `openDelay`, `closeDelay`, `arrow`, `shortcut`, `disabled`. Slots: default (trigger), `content`. | `overlays/tooltip.vue` |
|
|
224
|
+
| `CommandPalette` | Search and command dialog (Cmd+K) with groups, recent items, async search and typed item data. Groups take `icon` (default item icon) and `more` (a last "show all" item). Matching (`matchesSearch`, exported) finds every word in any order, without case or accents. | Models: `v-model:open`, `v-model:query`. Props: `groups` (items with `id`, `label`, `description`, `meta` (inline secondary label), `highlight` (`{ label, description }` ranges `[start, end]` marked with `k-mark`), `icon`, `badge`, `shortcut`, `keywords`, `to`, `data`, `disabled`, `disabledReason` (with `disabled`: reachable with the arrow keys but not selectable, a tooltip on hover and keyboard focus, linked with `aria-describedby`), `onSelect`), `search(query, signal)`, `pinned` (items or `(query) => items` shown first, never filtered or saved as recent), `shortcut`, `trigger`, `recentKey`, `emptyText`, `notice`. Slots: `item`, `empty`, `group-label`, `after-results`. Events: `select`, `open`, `close`. | `overlays/command-palette.vue` |
|
|
225
|
+
| `CommandList` | The search field and grouped list of `CommandPalette` without the dialog: place it inline in a panel or in a `Popover` (with `anchor` for a picker opened next to any element). Arrow keys, Enter and the same matching. | Model: `v-model:query`. Props: the `CommandPalette` list props (`groups`, `search`, `pinned`, `filter`, `loading`, `placeholder`, `label`, `recentKey`, `emptyText`, `notice` and the copy props), `autofocus` (default `true`), `footer` (the key hints, default `false`). Slots: `item`, `empty`, `group-label`, `after-results`. Events: `select`, `close` (Escape). Exposed: `focus`, `refresh`. | `overlays/command-palette.vue` |
|
|
226
|
+
| `CommandButton` | A `Button` made from a `CommandItem`: label, icon, `to`, `href`, `disabled`, `disabledReason` (tooltip on the disabled button) and `onSelect` come from the command. | Props: `command`, `label`, `icon`, `iconOnly` (a square button with the icon only, the label as `aria-label` and tooltip), and every `Button` prop (size, variant, tone). | `overlays/command-palette.vue` |
|
|
227
227
|
|
|
228
228
|
## Data
|
|
229
229
|
|
package/README.md
CHANGED
|
@@ -779,7 +779,7 @@ const confirmDiscard = () => !dirty.value || confirm({ title: 'Discard changes?'
|
|
|
779
779
|
- The shell shows a dock on the right of the page as long as a docked drawer is mounted, also while it is closed: a page with a docked drawer shows the empty state of the dock ("Nothing selected", `dockEmptyTitle` and `dockEmptyDescription` of the layout), and a page without one shows no dock. The open drawer fills the dock.
|
|
780
780
|
- The dock has a resize handle on its left edge (min 22rem, max 48rem and at most 45% of the shell, double click resets to 30rem). The width goes to the preferences store under `dock:<dockStorageKey>` (default `k-dock`, `false` keeps it only in memory).
|
|
781
781
|
- `size` gives the width of the overlay mode only. The dock can be detached: every docked drawer of the app then opens as a normal overlay and no page shows the dock. The header of a docked drawer has the detach button (icon `dock-detach`, a pop out); the header of the overlay and the end of the actions of `PageHeader` (only while detached, on a page with a docked drawer in a wide shell, `dockToggle: false` hides it) have the dock button (icon `dock-attach`, a frame with a small filled panel on the right). Labels `detachLabel` and `attachLabel`. The choice is saved with the width (`dock:<dockStorageKey>`, `{ width, detached }`).
|
|
782
|
-
- In the dock the header has no close button (Escape, the cancel button of the footer or a click on another row change it)
|
|
782
|
+
- In the dock the header has no close button (Escape, the cancel button of the footer or a click on another row change it). In every Modal and Drawer, when the `#actions` slot does not fit next to a title of 12rem, it moves into an "Actions" menu (a soft button with a popover; the buttons of the slot show as menu rows, and a click on one closes the menu unless it opens a menu of its own), and it comes back inline when there is space again. The overlay of a docked drawer is at most 48rem wide (the maximum width of the dock), also with `size="xl"` or `"full"`.
|
|
783
783
|
- A docked drawer is not modal: no backdrop, no scroll lock, focus stays where it was when it opens, and Escape closes it only when the focus is inside it (and no menu or nested dialog is open). The leave guard is the same: closing it, its trail and a navigation ask before they drop a dirty form.
|
|
784
784
|
- `useRouteRecord().openRecord(id)` asks the discard question when it replaces another open record (the user clicked another row with a dirty form). The default `beforeLeave` reads the topmost modal dialog, else the docked drawer. A discard accepted by a scope also answers the next question of the same scope in the same task, so a drawer that asks and then calls `openRecord()` asks once.
|
|
785
785
|
- Toasts move to the left of the dock.
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
<div v-if="present" ref="panelRef" :class="`${prefix}-panel`" tabindex="-1">
|
|
18
18
|
<header
|
|
19
19
|
v-if="hasHeader"
|
|
20
|
+
ref="headerRef"
|
|
20
21
|
:class="[
|
|
21
22
|
`${prefix}-header`,
|
|
22
23
|
{ 'has-tabs': hasTabs, 'has-toolbar': !!slots.toolbar }
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
</template>
|
|
53
54
|
<div
|
|
54
55
|
v-if="$slots.actions || showClose || hasTrail || showDockToggle"
|
|
56
|
+
ref="actionsRef"
|
|
55
57
|
:class="`${prefix}-actions`"
|
|
56
58
|
>
|
|
57
59
|
<Button
|
|
@@ -66,7 +68,8 @@
|
|
|
66
68
|
{{ backText }}
|
|
67
69
|
</Button>
|
|
68
70
|
<Popover
|
|
69
|
-
v-if="
|
|
71
|
+
v-if="actionsCollapsed && slots.actions"
|
|
72
|
+
ref="actionsMenuRef"
|
|
70
73
|
placement="bottom-end"
|
|
71
74
|
:label="actionsText"
|
|
72
75
|
class="k-dialog-actions-menu"
|
|
@@ -89,7 +92,13 @@
|
|
|
89
92
|
</div>
|
|
90
93
|
</template>
|
|
91
94
|
</Popover>
|
|
92
|
-
<
|
|
95
|
+
<div
|
|
96
|
+
v-else-if="slots.actions"
|
|
97
|
+
ref="inlineActionsRef"
|
|
98
|
+
class="k-dialog-actions-inline"
|
|
99
|
+
>
|
|
100
|
+
<slot name="actions" :close="close" />
|
|
101
|
+
</div>
|
|
93
102
|
<Button
|
|
94
103
|
v-if="showDockToggle"
|
|
95
104
|
:icon="docked ? 'dock-detach' : 'dock-attach'"
|
|
@@ -288,6 +297,46 @@ const { present, requestClose, onCancel, onClose, onPointerDown, onClick } = use
|
|
|
288
297
|
onClose: () => emit("close"),
|
|
289
298
|
onAfterLeave: () => emit("afterLeave")
|
|
290
299
|
});
|
|
300
|
+
const headerRef = useTemplateRef("headerRef");
|
|
301
|
+
const actionsRef = useTemplateRef("actionsRef");
|
|
302
|
+
const inlineActionsRef = useTemplateRef("inlineActionsRef");
|
|
303
|
+
const actionsMenuRef = useTemplateRef("actionsMenuRef");
|
|
304
|
+
const actionsCollapsed = ref(false);
|
|
305
|
+
const HEADING_MIN_REM = 12;
|
|
306
|
+
let inlineActionsWidth = 0;
|
|
307
|
+
let actionsObserver;
|
|
308
|
+
function remPixels() {
|
|
309
|
+
return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
|
|
310
|
+
}
|
|
311
|
+
function measureActions() {
|
|
312
|
+
const header = headerRef.value;
|
|
313
|
+
const actions = actionsRef.value;
|
|
314
|
+
if (!header || !actions) return;
|
|
315
|
+
const style = getComputedStyle(header);
|
|
316
|
+
const width = header.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
|
|
317
|
+
if (width <= 0) return;
|
|
318
|
+
const inline = inlineActionsRef.value;
|
|
319
|
+
const menu = actions.querySelector(":scope > .k-overlay-trigger");
|
|
320
|
+
if (inline) inlineActionsWidth = inline.scrollWidth;
|
|
321
|
+
const current = inline?.offsetWidth ?? menu?.offsetWidth ?? 0;
|
|
322
|
+
const others = actions.offsetWidth - current;
|
|
323
|
+
const gap = parseFloat(style.columnGap) || 0;
|
|
324
|
+
const needed = HEADING_MIN_REM * remPixels() + gap + others + inlineActionsWidth;
|
|
325
|
+
const collapse = needed > width;
|
|
326
|
+
if (collapse !== actionsCollapsed.value) actionsCollapsed.value = collapse;
|
|
327
|
+
}
|
|
328
|
+
watch(
|
|
329
|
+
() => [headerRef.value, inlineActionsRef.value, actionsMenuRef.value],
|
|
330
|
+
([header, inline]) => {
|
|
331
|
+
actionsObserver?.disconnect();
|
|
332
|
+
if (!header || typeof ResizeObserver === "undefined") return;
|
|
333
|
+
actionsObserver ??= new ResizeObserver(() => measureActions());
|
|
334
|
+
actionsObserver.observe(header);
|
|
335
|
+
if (inline) actionsObserver.observe(inline);
|
|
336
|
+
},
|
|
337
|
+
{ flush: "post" }
|
|
338
|
+
);
|
|
339
|
+
onBeforeUnmount(() => actionsObserver?.disconnect());
|
|
291
340
|
function onActionsClick(event, closeActions) {
|
|
292
341
|
const target = event.target instanceof Element ? event.target.closest("button, a") : null;
|
|
293
342
|
if (!target || target.matches('[aria-haspopup]:not([aria-haspopup="false"])')) return;
|
package/package.json
CHANGED