@xleddyl/443-components-vue 0.16.95 → 0.16.97
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 +46 -41
- package/README.md +78 -26
- package/dist/components/data/RecordList.vue +44 -6
- package/dist/components/data/RecordList.vue.d.ts +4 -1
- package/dist/components/data/Tree.vue +84 -24
- package/dist/components/data/Tree.vue.d.ts +9 -9
- package/dist/components/data/types.d.ts +10 -1
- package/dist/components/forms/PaletteSelect.vue.d.ts +2 -2
- package/dist/components/layout/Accordion.vue +6 -2
- package/dist/components/layout/Accordion.vue.d.ts +3 -0
- package/dist/components/layout/PageHeader.vue +5 -2
- package/dist/components/layout/PageHeader.vue.d.ts +4 -1
- package/dist/components/layout/ResizeHandle.vue +94 -0
- package/dist/components/layout/ResizeHandle.vue.d.ts +418 -0
- package/dist/components/layout/index.d.ts +1 -0
- package/dist/components/layout/index.mjs +1 -0
- package/dist/components/layout/types.d.ts +4 -1
- package/dist/components/overlays/ConfirmDialog.vue.d.ts +8 -8
- package/dist/components/overlays/ConfirmHost.vue.d.ts +8 -8
- package/dist/components/overlays/Popover.vue +67 -25
- package/dist/components/overlays/Popover.vue.d.ts +15 -4
- package/dist/components/templates/SettingsModal.vue.d.ts +2 -2
- package/dist/components/templates/WorkspaceLayout.vue +296 -0
- package/dist/components/templates/WorkspaceLayout.vue.d.ts +455 -0
- package/dist/components/templates/index.d.ts +1 -0
- package/dist/components/templates/index.mjs +1 -0
- package/dist/components/templates/types.d.ts +32 -0
- package/dist/composables/usePreferences.d.ts +1 -0
- package/dist/composables/usePreferences.mjs +2 -1
- package/dist/composables/useSortable.mjs +13 -0
- package/dist/internal/core/env.d.ts +2 -0
- package/dist/internal/core/env.mjs +20 -1
- package/dist/internal/data/sortable.d.ts +2 -0
- package/dist/internal/data/sortable.mjs +2 -0
- package/dist/internal/overlays/OverlayView.vue.d.ts +8 -8
- package/dist/locale/de.mjs +7 -0
- package/dist/locale/en.mjs +7 -0
- package/dist/locale/it.mjs +7 -0
- package/dist/locale/types.d.ts +7 -0
- package/dist/styles/data/record-list.css +54 -0
- package/dist/styles/data/tree.css +57 -4
- package/dist/styles/forced-colors.css +14 -0
- package/dist/styles/layout/accordion.css +4 -5
- package/dist/styles/layout/breadcrumbs.css +23 -0
- package/dist/styles/layout/card.css +2 -0
- package/dist/styles/layout/page-header.css +58 -0
- package/dist/styles/layout/resize-handle.css +52 -0
- package/dist/styles/layout.css +1 -0
- package/dist/styles/overlays/popover.css +6 -0
- package/dist/styles/shared.css +9 -0
- package/dist/styles/templates/workspace-layout.css +143 -0
- package/dist/styles/templates.css +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -214,14 +214,15 @@ Buttons show `icon` before the label and `trailingIcon` after it. Put action ico
|
|
|
214
214
|
|
|
215
215
|
## Preferences
|
|
216
216
|
|
|
217
|
-
UI choices are kept in one preferences store: the theme, the preset, the collapsed sidebar
|
|
217
|
+
UI choices are kept in one preferences store: the theme, the preset, the collapsed sidebar, the DataGrid columns and page size, and the WorkspaceLayout panes. By default the store is `localStorage` (keys `k-pref:<key>`, JSON, SSR safe, never throws, synced across tabs). Give the app your own store to keep the choices per user in a database, so they follow the user across devices.
|
|
218
218
|
|
|
219
|
-
| Key
|
|
220
|
-
|
|
|
221
|
-
| `theme`
|
|
222
|
-
| `preset`
|
|
223
|
-
| `shell:<storageKey>`
|
|
224
|
-
| `grid:<storageKey>`
|
|
219
|
+
| Key | Value | Written by |
|
|
220
|
+
| ------------------------ | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
221
|
+
| `theme` | `'system' \| 'light' \| 'dark'` | `useTheme().set`, `ThemeSwitch`, `AppearanceSettings` |
|
|
222
|
+
| `preset` | `ThemePreset` | `usePreset().set`, `AppearanceSettings` |
|
|
223
|
+
| `shell:<storageKey>` | `boolean` (collapsed) | `AppShell` and `DashboardLayout` (`shell:k-sidebar-collapsed`) |
|
|
224
|
+
| `grid:<storageKey>` | `GridPreference` (`{ columns?: GridColumnState[], pageSize }`) | `DataGrid` with `storageKey`: visibility, order, width, pinned, page size |
|
|
225
|
+
| `workspace:<storageKey>` | `WorkspacePreference` (`{ left?: { width, collapsed }, right?: { width, collapsed } }`) | `WorkspaceLayout` with `storageKey`: side pane widths and collapsed state |
|
|
225
226
|
|
|
226
227
|
`PREFERENCE_KEYS` builds them (`PREFERENCE_KEYS.grid('orders')`). Your own keys work too: use a namespace of your app (`app:<name>`).
|
|
227
228
|
|
|
@@ -468,18 +469,18 @@ async function switchView() {
|
|
|
468
469
|
|
|
469
470
|
## Components
|
|
470
471
|
|
|
471
|
-
| Group | Components
|
|
472
|
-
| --------- |
|
|
473
|
-
| core | Root, Icon, Button, Spinner, Input, Textarea, FormField, FieldMessage, FieldBoundary, Form, FormAlerts, Kbd, VisuallyHidden
|
|
474
|
-
| forms | Calendar, Checkbox, CheckboxGroup, ColorInput, Combobox, DateInput, DatePicker, FileInput, FocalPointInput, InputAddon, InputGroup, NumberInput, PaletteSelect, PasswordInput, PinInput, Radio, RadioGroup, SegmentedControl, Select, Slider, Switch, TimeInput, TreeSelect
|
|
475
|
-
| overlays | CommandButton, CommandList, CommandPalette, ConfirmDialog, ConfirmHost, ContextMenu, Drawer, DropdownMenu, HoverCard, Modal, OverlayHost, Popover, Toaster, Tooltip
|
|
476
|
-
| data | Avatar, AvatarGroup, Badge, DescriptionList, FilterPill, FilterPills, Pagination, RecordList, SelectionBar, SortableList, Stat, Table, Tag, TagList, Thumbnail, TileGrid, Timeline, Tree
|
|
477
|
-
| layout | Accordion, AppShell, Breadcrumbs, Card, CopyButton, Grid, NavLink, PageHeader, Separator, Sidebar, SidebarNav, SidebarSection, Stack, Stepper, Tabs, ThemeSwitch, Toolbar
|
|
478
|
-
| templates | DashboardLayout, AuthLayout, AuthLogin, AuthLogout, DashboardPage, ListPage, DetailPage, FormPage, SettingsPage, SettingsSection, SettingsModal, SettingsGroup, AppearanceSettings, SaveBar, ErrorPage, NotFoundPage, EmptyPage, Brand, AccountMenu, FormDrawer
|
|
479
|
-
| feedback | Alert, EmptyState, LoadingOverlay, Meter, Progress, ProgressRing, Skeleton, SkeletonForm, SkeletonList
|
|
480
|
-
| grid | DataGrid, GridToolbar, cell renderers (BadgeCell, BooleanCell, ButtonCell, DateCell, EmptyCell, ImageCell, LinkCell)
|
|
481
|
-
| editor | RichTextEditor, TemplateEditor, TemplateText
|
|
482
|
-
| chart | ChartPanel, ChartLegend, LineChart, BarChart, DoughnutChart
|
|
472
|
+
| Group | Components |
|
|
473
|
+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
474
|
+
| core | Root, Icon, Button, Spinner, Input, Textarea, FormField, FieldMessage, FieldBoundary, Form, FormAlerts, Kbd, VisuallyHidden |
|
|
475
|
+
| forms | Calendar, Checkbox, CheckboxGroup, ColorInput, Combobox, DateInput, DatePicker, FileInput, FocalPointInput, InputAddon, InputGroup, NumberInput, PaletteSelect, PasswordInput, PinInput, Radio, RadioGroup, SegmentedControl, Select, Slider, Switch, TimeInput, TreeSelect |
|
|
476
|
+
| overlays | CommandButton, CommandList, CommandPalette, ConfirmDialog, ConfirmHost, ContextMenu, Drawer, DropdownMenu, HoverCard, Modal, OverlayHost, Popover, Toaster, Tooltip |
|
|
477
|
+
| data | Avatar, AvatarGroup, Badge, DescriptionList, FilterPill, FilterPills, Pagination, RecordList, SelectionBar, SortableList, Stat, Table, Tag, TagList, Thumbnail, TileGrid, Timeline, Tree |
|
|
478
|
+
| layout | Accordion, AppShell, Breadcrumbs, Card, CopyButton, Grid, NavLink, PageHeader, ResizeHandle, Separator, Sidebar, SidebarNav, SidebarSection, Stack, Stepper, Tabs, ThemeSwitch, Toolbar |
|
|
479
|
+
| templates | DashboardLayout, WorkspaceLayout, AuthLayout, AuthLogin, AuthLogout, DashboardPage, ListPage, DetailPage, FormPage, SettingsPage, SettingsSection, SettingsModal, SettingsGroup, AppearanceSettings, SaveBar, ErrorPage, NotFoundPage, EmptyPage, Brand, AccountMenu, FormDrawer |
|
|
480
|
+
| feedback | Alert, EmptyState, LoadingOverlay, Meter, Progress, ProgressRing, Skeleton, SkeletonForm, SkeletonList |
|
|
481
|
+
| grid | DataGrid, GridToolbar, cell renderers (BadgeCell, BooleanCell, ButtonCell, DateCell, EmptyCell, ImageCell, LinkCell) |
|
|
482
|
+
| editor | RichTextEditor, TemplateEditor, TemplateText |
|
|
483
|
+
| chart | ChartPanel, ChartLegend, LineChart, BarChart, DoughnutChart |
|
|
483
484
|
|
|
484
485
|
Composables: `useTheme`, `usePreset`, `useForm`, `useField`, `useFieldControl`, `useToast` (and `toast`), `useConfirm`, `useAlert`, `usePrompt`, `useModal`, `useDrawer`, `useOverlay`, `useModalContext`, `useLoading` (and `withLoading`), `useLoadingState`, `useHotkey`, `useCopy`, `useFileDrop` (with `readDroppedFiles`), `useSortable`, `usePasswordStrength`, `useTableSort`, `useAppShell`, `useRouteState`, `useRouteRecord`, `usePageCommands`, `usePreference` (with `usePreferences`, `createPreferences`, `providePreferences`), `useScrollLock`, `useLeaveGuard` (with `useLeaveScope`, `provideLeaveScope`), `useDirtyGuard`, `useIcons` helpers and `useLinkComponent`, `provideFieldBoundary`, `provideAuxiliaryControls`, `provideForm`, `provideGridConfig` (with `createGridConfig`, `useGridConfig`), `useLocale`. With the Nuxt module also `useDashboard()` (runtime account, breadcrumbs and badges for the `k-dashboard` layout) and `useNavigationPending()` (`true` while a navigation to another path renders the new page), auto-imported or imported from `@xleddyl/443-components-vue/nuxt/composables`.
|
|
485
486
|
|
|
@@ -510,7 +511,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
510
511
|
|
|
511
512
|
### Lists, trees and uploads
|
|
512
513
|
|
|
513
|
-
- `Tree` takes `size="sm"` for dense rows, `checkmark`, `descriptionVariant` (`mono`, the default for paths and slugs, or `text`; a node can override it with its own `descriptionVariant`), `emptyText`, `emptyDescription`, `emptyIcon` and `emptyVariant` (`card`, the default, or `plain`) for the `EmptyState` shown without nodes (`#empty` replaces it, `#empty-actions` adds buttons inside it, like `RecordList`) and works inside a `FormField` (labelled and described by the field). With `reorderable` rows get a drag handle and Alt with the up and down arrows moves them; `nestable` also lets rows change level (drop in the middle of a row, Alt with left and right). Each row also shows move buttons; `moveButtons: false` hides them and keeps drag and the keyboard. The `move` event carries `{ node, target, position, from: { parent, index }, to: { parent, index } }`, `to.index` being the final index, and `applyTreeMove(nodes, move)` returns the updated tree. `canDrop(move)` vetoes a move. Moves are announced to screen readers. The `#actions` slot (`node`, `level`, `selected`, `expanded`, `highlighted`, `hovered`) renders row actions at the end of the row, over the label, on the hovered, focused and selected rows only; Tab from the focused row reaches them, and focus returns to a row when the focused one is removed. Actions stay visible and clickable while a menu, popover or select opened from them is open (any trigger inside with `aria-expanded="true"`), so the pointer can cross other rows to reach the menu items. On devices without hover (`hover: none`, touch) the slot actions are always visible and sit in the row after the label instead of over it, and the move buttons show on the focused (tapped) and selected rows. `highlighted` (an id or an array of ids) tints rows like hover, for a link with something outside the tree (a block hovered in a preview). The `hover` event carries the node under the pointer, then `null` when the pointer leaves the tree. A node with `invalid: true` shows a danger dot before the label (never covered by the actions) and a tinted label, and its row is described by a hidden "Contains errors" (`invalidText` overrides it). The `#label` slot receives `invalid` (with `node` and `level`), and a custom label inherits the danger text color unless it sets its own.
|
|
514
|
+
- `Tree` takes `size="sm"` for dense rows, `checkmark`, `descriptionVariant` (`mono`, the default for paths and slugs, or `text`; a node can override it with its own `descriptionVariant`), `emptyText`, `emptyDescription`, `emptyIcon` and `emptyVariant` (`card`, the default, or `plain`) for the `EmptyState` shown without nodes (`#empty` replaces it, `#empty-actions` adds buttons inside it, like `RecordList`) and works inside a `FormField` (labelled and described by the field). With `reorderable` rows get a drag handle and Alt with the up and down arrows moves them; `nestable` also lets rows change level (drop in the middle of a row, Alt with left and right). Each row also shows move buttons; `moveButtons: false` hides them and keeps drag and the keyboard. The `move` event carries `{ node, target, position, from: { parent, index }, to: { parent, index } }`, `to.index` being the final index, and `applyTreeMove(nodes, move)` returns the updated tree. `canDrop(move)` vetoes a move. Moves are announced to screen readers. The `#actions` slot (`node`, `level`, `selected`, `expanded`, `highlighted`, `hovered`) renders row actions at the end of the row, over the label, on the hovered, focused and selected rows only; Tab from the focused row reaches them, and focus returns to a row when the focused one is removed. Actions stay visible and clickable while a menu, popover or select opened from them is open (any trigger inside with `aria-expanded="true"`), so the pointer can cross other rows to reach the menu items. On devices without hover (`hover: none`, touch) the slot actions are always visible and sit in the row after the label instead of over it, and the move buttons show on the focused (tapped) and selected rows. `highlighted` (an id or an array of ids) tints rows like hover, for a link with something outside the tree (a block hovered in a preview). The `hover` event carries the node under the pointer, then `null` when the pointer leaves the tree. A node with `invalid: true` shows a danger dot before the label (never covered by the actions) and a tinted label, and its row is described by a hidden "Contains errors" (`invalidText` overrides it). The `#label` slot receives `invalid` (with `node` and `level`), and a custom label inherits the danger text color unless it sets its own. A node with `to` or `href` (and `target`) is a link row: its text (label and description, or the `#label` slot) is a real link stretched over the row, kept out of the Tab order so the tree keeps one tab stop. A click navigates and selects, Cmd, Ctrl or Shift click and the middle button open the link in a new tab or window without selecting, Enter follows the link (Cmd or Ctrl with Enter in a new tab) instead of expanding, Space selects, and the arrow keys, typeahead and reordering work as on any row; the handle, the toggle and the actions stay above the link. `muted: true` dims the label, the description and the icon of a node (a hidden block, a draft page), and a custom label inherits the muted color; the node stays interactive. Say why in `meta` or a hidden text, the color alone does not. In a narrow container the label keeps a minimum width (8rem, 6rem with `size="sm"`) and the `meta` wraps below it instead of squeezing it; `mono` descriptions stay on one line with an ellipsis and the full text in their `title`, `text` descriptions wrap between words, and labels carry their full text in `title` too.
|
|
514
515
|
- `Select` takes string, number or boolean option values (`{ value: true, label: 'Yes' }`); the model gets the option value back with its type and is typed `T | null | undefined`, so `v-model` works on a narrow ref (`Ref<'a' | 'b' | null>`). An option whose value is `''` is a real option: it is selected and shown with its own label, distinct from the placeholder, which still maps to `null`.
|
|
515
516
|
- `Input` and `Textarea` take `counter`: with a `maxlength` attribute they show `length / maxlength` inside the field, describe the control with "12 of 40 characters" (`form.characterCount`) and announce "Character limit reached" when it is hit.
|
|
516
517
|
- Numbers are left aligned in every field. `Input` `numeric` sets the decimal keyboard, the number model and tabular digits; `NumberInput` takes `align="end"` to right align its value when a layout needs it (default `start`).
|
|
@@ -521,7 +522,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
521
522
|
- `Combobox` takes `createActions` (`ComboboxCreateActions`, `(query) => ComboboxCreateAction[]`) to show several create items instead of the single "Create" item. Each action has `id` (the item key is `__create:<id>`), `label`, `icon` (default `plus`) and `run(query)`. The actions show at the end of the list under the same conditions as the create item: a non-empty query after `createTransform`, with no option whose label or value matches it exactly. The function gets that text, and an empty array shows no action. `createValidate` runs before `run`. When `run` returns an option, the combobox remembers it, emits `create` and selects it. When it returns nothing (for example it opens a form for the full record), nothing is selected: the query clears and the list closes (with `multiple`, only the query clears). Errors from `run` are logged. `createActions` replaces `creatable`: `<KCombobox v-model="category" :options="categories" :create-actions="(query) => [{ id: 'quick', label: 'Create here', run: createCategory }, { id: 'form', label: 'Create with details', icon: 'pencil-square', run: openForm }]" />`.
|
|
522
523
|
- `Combobox` with `:searchable="false"` is a plain select that keeps the option dots, icons, descriptions and groups: the control is a `<button>` with `role="combobox"` and `aria-haspopup="listbox"` that shows the selected label (with the color dot or the `icon`), or the placeholder when empty. There is no text to type and no filter. Click, Enter, Space, ArrowDown or ArrowUp open the list, the arrows, Home and End move, Enter or Space select (with `multiple` the list stays open), Escape and Tab close, and typing letters moves to the next option whose label starts with them (typeahead, like a native select). `clearable`, `disabled`, `readonly`, `invalid`, `size`, `icon`, `multiple` and `hideTags` work as usual; `creatable`, `createActions` and the async `search` are ignored. Use it for a short fixed list that needs a color dot or an icon (`PaletteSelect` uses it): `<KCombobox v-model="status" :options="statuses" :searchable="false" />`. The exposed `el` is the input, or the trigger button when not searchable.
|
|
523
524
|
- `Combobox` with `multiple` takes `hideTags`: the selected values are not rendered as tags inside the control (the host shows them elsewhere), the placeholder stays visible and Backspace no longer removes the last value. Selection is still announced through the options. A long tag label is truncated with an ellipsis and the full label (with the option group or description) is in the tag tooltip.
|
|
524
|
-
- `RecordList` keeps each title on one line with an ellipsis; the full title is in its `title` attribute. With a `row-click` listener each row is a navigation item (padding, the hover and press background of a ghost button, no separators, the list bleeds into the inline padding so the text stays aligned). The title of a clickable row is a button: Tab reaches every row, Enter or Space emits `row-click`, the focus ring is drawn around the row and the description is the button description. A click anywhere else in the row emits it too, except on a button, link, input, menu item or tab inside the row and inside an open menu, popover or dialog that the row contains; pressing those does not tint the row. Keep the actions of a row as buttons in `#action`, never as a second clickable area. `rowClickable(item)` returns `false` for the rows that open nothing: they keep the same padding, without the button, hover and pointer.
|
|
525
|
+
- `RecordList` keeps each title on one line with an ellipsis; the full title is in its `title` attribute. With a `row-click` listener each row is a navigation item (padding, the hover and press background of a ghost button, no separators, the list bleeds into the inline padding so the text stays aligned). The title of a clickable row is a button: Tab reaches every row, Enter or Space emits `row-click`, the focus ring is drawn around the row and the description is the button description. A click anywhere else in the row emits it too, except on a button, link, input, menu item or tab inside the row and inside an open menu, popover or dialog that the row contains; pressing those does not tint the row. Keep the actions of a row as buttons in `#action`, never as a second clickable area. `rowClickable(item)` returns `false` for the rows that open nothing: they keep the same padding, without the button, hover and pointer. An item with `to` or `href` (and `target`) is a link row: its title is a real link (the provided link component for `to`, `<a>` otherwise) stretched over the row, so a click anywhere opens it, Cmd or Ctrl click and the middle button open a new tab, Tab focuses it and the row gets the same hover, press and focus ring; buttons, links and inputs of the row stay above it, and `row-click` still fires on a plain click (to close the dialog around the list). `icon` adds a leading icon box (the fallback of `#leading`) and `meta` a short trailing text on one line (`#meta` slot with `{ item }`), both described on the title. Without items, `emptyVariant` picks the empty state: `card` (default), `plain` (a smaller centered title without the card) or `hint` (the `emptyText` as one muted line, for a small list in a form or a dialog, like "No active links").
|
|
525
526
|
- `Fieldset` is a native `fieldset`: `disabled` disables every control inside (also the buttons, not the links) and every `FormField` through the form disabled state. `:disabled="false"` enables a group inside a disabled `Form`. When it becomes disabled while a control inside has focus, the focus moves to the fieldset, never to the page. The legend comes from `legend` or the `#legend` slot.
|
|
526
527
|
- `Pagination` takes `showEdges` (first and last page buttons, `firstLabel`, `lastLabel`) and `showJump` (a typed page number, `jumpLabel`). Both are off by default. `page` is clamped to the page count only when `total` is known: while `total` is `0` or `loading` is set (it also sets `aria-busy`), the page is kept, so a server reload does not reset it.
|
|
527
528
|
- Page sizes are `PageSize` values (`number | 'all'`): `pageSizes: [25, 50, 100, 'all']` adds an "All" option (`pagination.all`, override with `allLabel`). With `'all'` the page size model is `'all'`, there is one page and the summary reads `1-<total> of <total>`. `Pagination`, `ListPage` and `DataGrid` take it; with `serverPagination` the grid emits `'all'` through `v-model:page-size` and your API returns every row.
|
|
@@ -538,7 +539,8 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
538
539
|
- `Tabs` items take `dot: true` for a small indicator without a number (`dotTone`, default `danger`; `dotLabel` is the hidden text, default "Needs attention"). `color` (a palette name or a hex, `ColorValue`) draws a small color dot before the label, separate from the status dot. `title` shows a tooltip on hover and keyboard focus (the native `title` only until mount) and becomes the tab description; a disabled tab keeps it (it uses `aria-disabled`, cannot be selected and is skipped by Tab and the arrow keys), so it can say why it is disabled. The same items work in the `tabs` of `Modal`, `Drawer`, `FormDrawer` and `DetailPage`.
|
|
539
540
|
- `Card` takes `variant="dashed"` (`CardVariant`) for a placeholder tile: a dashed `--k-line-strong` border on `--k-subtle`, with the icon, title and description centered in a column (the icon in a raised box, the title at 0.8125rem). As a button (`as="button"`) or a link (`to`, `href`) it gets the hover and focus of the `FileInput` dropzone (`--k-fill` and a `--k-text-dimmed` border on hover, a solid `--k-ring` border and the focus ring on focus); `disabled` dims it, and `selected` tints it with the accent, for a drop target while something is dragged over it. Use it for an "Add" tile at the end of a grid of items and for an empty area: `<KCard variant="dashed" as="button" icon="plus" title="Add block" @click="add" />`.
|
|
540
541
|
- `DropdownMenu` takes `matchTriggerWidth` (the menu is at least as wide as its trigger) and `minWidth` (a CSS length).
|
|
541
|
-
- `PageHeader` takes `align` (`'end'` by default, `'start'` or `'center'`) for the title block and the actions, and `truncate` to keep the title on one line with an ellipsis (the full title is in its `title` attribute). `trail` (`BreadcrumbItem[]`, the earlier levels as links) turns the title into a breadcrumb trail that ends with `title`, at the page title size: a `nav` (named by `trailLabel`, default "Breadcrumb") around an ordered list whose last item is the heading (`h<level>`, `aria-current="page"`, only the title, `#title` fills it). With `truncate` the trail stays on one line and the title gets the ellipsis. Use it for a record or a nested page instead of `Breadcrumbs` in `#title` (a `nav` inside a heading). `breadcrumbs` stays the small trail above the title.
|
|
542
|
+
- `PageHeader` takes `align` (`'end'` by default, `'start'` or `'center'`) for the title block and the actions, and `truncate` to keep the title on one line with an ellipsis (the full title is in its `title` attribute). `trail` (`BreadcrumbItem[]`, the earlier levels as links) turns the title into a breadcrumb trail that ends with `title`, at the page title size: a `nav` (named by `trailLabel`, default "Breadcrumb") around an ordered list whose last item is the heading (`h<level>`, `aria-current="page"`, only the title, `#title` fills it). With `truncate` the trail stays on one line and the title gets the ellipsis. Use it for a record or a nested page instead of `Breadcrumbs` in `#title` (a `nav` inside a heading). `breadcrumbs` stays the small trail above the title. `size="sm"` (`PageHeaderSize`, default `md`) is the compact header of a panel or an inspector: the title at the card title size (0.9375rem, 600), a 1.75rem icon box, tighter gaps, a 0.75rem description, `breadcrumbs` at `Breadcrumbs` size `sm` and the `trail` at the title size.
|
|
543
|
+
- `ResizeHandle` is a focusable `separator` that resizes the panel next to it: `v-model` is the size in pixels (`aria-valuenow`), `min` (default 0) and `max` clamp it (`aria-valuemin`, `aria-valuemax`), `orientation` is `vertical` (default, a vertical line that resizes a width, Left and Right arrows) or `horizontal` (a height, Up and Down arrows), and `target` says where the panel is: `before` (default, left or above, dragging right or down grows it) or `after` (an inspector on the right). The arrow keys move it by `step` (default 16), Home and End jump to `min` and `max`, a double click calls `onReset`. Dragging captures the pointer (it keeps working over iframes) and emits `resizeStart` and `resizeEnd(size)`. Name it with `label` and point `aria-controls` at the panel. The 1px line has a 11px hit area and turns `--k-ring` on hover, while dragging and on focus (with the `--k-ring-soft` halo).
|
|
542
544
|
- `RichTextEditor` accepts `'underline'` in `toolbar` (not in the default toolbar).
|
|
543
545
|
- `RichTextEditor` takes `linkTypes` (`EditorLinkType[]`, `'url' | 'email' | 'phone'`, default `['url']`). With more than one type the link form shows a type select; email links get `mailto:` and phone links `tel:` (spaces and separators removed). When no text is selected the form asks for the link text too (`editor.linkText`) and inserts it as a link, falling back to the address.
|
|
544
546
|
- `BarChart` takes `colorByPoint` (every bar of a series takes the next palette color, or one from `colors: string[]`; the legend lists and toggles the categories). The palette comes from `--k-chart-1` to `--k-chart-8`.
|
|
@@ -580,7 +582,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
580
582
|
</KSortableList>
|
|
581
583
|
```
|
|
582
584
|
|
|
583
|
-
- `useSortable(container, options)` is the reorder logic of `TagList` for any list. Options: `items` (a ref or getter), `onMove(items, move)` (`SortableMove`: `{ item, from, to, items, source }`, write `items` back to your state), `orientation` (`'vertical'` by default, `'horizontal'` for wrapping rows, `'grid'` for a CSS grid of cells: the item lands in the cell nearest to the pointer across wrapped rows, Alt with Left and Right moves it by one and Alt with Up and Down to the nearest cell of the row above or below), `disabled`, `handle` (a selector: only a pointer down on it starts a drag; without it any pointer down outside buttons, links and inputs does), `preview` (a selector inside the item: only that part follows the pointer and the item stays in its slot, so style the dragged item as the drop indicator, a dashed placeholder), `canMove(item, index)`, `label(item)` and `movedText(move)` for the announcement. Bind `itemProps(index)` on each item element (the attribute marks it, plus pointer and Alt with arrow key handlers) and render `announcement` in a polite live region. `move(from, to, { announce })` moves from your own buttons, `dragging` is the index being dragged (for
|
|
585
|
+
- `useSortable(container, options)` is the reorder logic of `TagList` for any list. Options: `items` (a ref or getter), `onMove(items, move)` (`SortableMove`: `{ item, from, to, items, source }`, write `items` back to your state), `orientation` (`'vertical'` by default, `'horizontal'` for wrapping rows, `'grid'` for a CSS grid of cells: the item lands in the cell nearest to the pointer across wrapped rows, Alt with Left and Right moves it by one and Alt with Up and Down to the nearest cell of the row above or below), `disabled`, `handle` (a selector: only a pointer down on it starts a drag; without it any pointer down outside buttons, links and inputs does), `preview` (a selector inside the item: only that part follows the pointer and the item stays in its slot, so style the dragged item as the drop indicator, a dashed placeholder), `canMove(item, index)`, `label(item)` and `movedText(move)` for the announcement. Bind `itemProps(index)` on each item element (the attribute marks it, plus pointer and Alt with arrow key handlers) and render `announcement` in a polite live region. `move(from, to, { announce })` moves from your own buttons, `dragging` is the index being dragged (for your own dragging style), `canMove(index)` reports locked items. Pointer drags reorder live and follow the pointer, Escape or a cancelled pointer puts the item back, and the click after a drag is swallowed. The dragged item is lifted by default: while a drag runs it carries `data-k-sortable-dragging` (`position: relative` and `z-index: 1`, so it stacks above the next items) and the part that follows the pointer (the item, or `preview`) carries `data-k-sortable-lifted` with the orientation; in a vertical list it gets `--k-shadow-raised` with `--k-shadow-sm`. Both rules have zero specificity, so any style of yours wins; `SortableList` uses the same lift.
|
|
584
586
|
|
|
585
587
|
- `Thumbnail` previews an image, a video or a file: `kind` (`ThumbnailKind`, `'image' | 'video' | 'file' | 'icon'`, default `'image'`), `src`, `alt` and `icon` (the fallback icon, by default `photo`, `video-camera` or `document`). A video shows its first frame (`preload="metadata"`, muted, no controls) under a play glyph. Without `size` it is fluid (the width of its parent, the height from `aspect`, a ratio string like `'4/3'` or a number, default 1); `size` (`ThumbnailSize`, `'xs' | 'sm' | 'md' | 'lg'`) gives a fixed inline box for tables and lists. `fit` is `'cover'` (default) or `'contain'`, `rounded` (`ThumbnailRounded`, `'none' | 'sm' | 'md' | 'lg' | 'full'`) overrides the radius of the size, and `focal` (`FocalPoint`, `{ x, y }` from 0 to 1, what `FocalPointInput` edits) or `objectPosition` (any CSS value, it wins) choose the part of the image that stays in view. While the media loads the box pulses; `missing`, or an image or video that fails to load, shows a hatched box with the icon and a hidden "File not available" (`thumbnail.missing`, `missingText` overrides it). The `top-start` and `top-end` slots put badges and actions in the corners, `caption` (or the `#caption` slot) sits at the bottom on a readable scrim, and `reveal` (`ThumbnailOverlay[]`, default `['caption']`) lists the overlays that only show on hover and focus, also when a link or button around the thumbnail is hovered or focused (always on touch screens). The default slot replaces the media with your own content (a text preview). Text and icons over media use the `--k-media-scrim` and `--k-media-text` tokens, the same in both themes; use them for your own overlays too.
|
|
586
588
|
|
|
@@ -627,7 +629,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
627
629
|
```
|
|
628
630
|
|
|
629
631
|
- `useFileDrop` returns `{ over, reset }` and takes `ignore(event)`. A drop handled by a nested drop zone is skipped by the outer ones, and the state resets after any drop, even when a child stops propagation. `readDroppedFiles(dataTransfer)` walks dropped folders (call it synchronously in the drop handler) and resolves to `[{ file, path }]`; `readDroppedFiles(dataTransfer, { directories: true })` resolves to `{ files, directories }` with every folder path, empty ones included, and `skipHidden: true` leaves out dot entries.
|
|
630
|
-
- `Tabs` items take `badgeTone` and `badgeLabel` (the accessible name of the badge); the `#panel="{ item }"` slot renders a single panel for the active tab. `stretch` makes the tabs fill the remaining height of a flex column and the active panel grow with it (`flex: 1; min-height: 0`), and `inset` spaces the tab list from the container edges with the panel flush below it, for inspectors and side panes. `Breadcrumbs` items take `attrs` and `onClick` (an item without a link renders a button, handy for drop targets), `#item` customizes the content, and `ancestors` links every item and ends with a separator (`breadcrumbsAncestors` on `PageHeader`). `heading` (a heading level) renders the current item as that heading, for a trail that is the title of the page. `Accordion` takes `variant` `card` (default), `outline` (the same card without a shadow), `separated` or `plain`; items take `description`, and `contentVariant="neutral"` drops the content
|
|
632
|
+
- `Tabs` items take `badgeTone` and `badgeLabel` (the accessible name of the badge); the `#panel="{ item }"` slot renders a single panel for the active tab. `stretch` makes the tabs fill the remaining height of a flex column and the active panel grow with it (`flex: 1; min-height: 0`), and `inset` spaces the tab list from the container edges with the panel flush below it, for inspectors and side panes. `Breadcrumbs` items take `attrs` and `onClick` (an item without a link renders a button, handy for drop targets), `#item` customizes the content, and `ancestors` links every item and ends with a separator (`breadcrumbsAncestors` on `PageHeader`). `heading` (a heading level) renders the current item as that heading, for a trail that is the title of the page. `size` is `sm` (0.75rem with tighter gaps, for panel headers and inspectors), `md` (default) or `lg` (a title sized trail). `Accordion` takes `variant` `card` (default), `outline` (the same card without a shadow), `separated` or `plain`; items take `description`, and `contentVariant="neutral"` drops the text styling of the content (it inherits font size and color, for forms) and keeps the padding of the item, aligned with the trigger. `:padded="false"` drops the content padding for content that brings its own spacing or reaches the edges (a list, a table, a tree), with either content variant.
|
|
631
633
|
- `RichTextEditor` labels heading buttons by their real level (`headingLabel="relative"` numbers them from 1) and `toolbar` picks and orders the buttons: `['headings', '|', 'bold', 'italic', 'link']`.
|
|
632
634
|
|
|
633
635
|
### Grid defaults
|
|
@@ -784,7 +786,9 @@ const archived = useRouteState('archived', {
|
|
|
784
786
|
- Pages that set `definePageMeta({ key: (route) => route.fullPath })` remount on every query change; keep the default page key for pages with deep links.
|
|
785
787
|
- To leave the page from inside an overlay, navigate (a link or `router.push`): the new route has no parameter, so the overlay closes. Do not set the ref to `undefined` and navigate in the same tick: the later navigation cancels the earlier one.
|
|
786
788
|
|
|
787
|
-
`Popover`: `anchor` places the panel against any element or a virtual reference (`OverlayVirtualAnchor`, an object with `getBoundingClientRect()`, for a pointer position or a text selection) instead of its trigger, and the trigger slot becomes optional: open it with `v-model:open` or the exposed `show()`. An element inside a same origin iframe works too: the panel is placed in the page against it, and a click or Escape inside the iframe closes it. The position follows scroll and resize. Focus moves into the panel on open and returns to the anchor when it can take focus, otherwise to the element focused before; a click outside and Escape close it. Without a trigger, name the panel with `label`.
|
|
789
|
+
`Popover`: `width` sets the width of the panel (any CSS length, like `18rem`) instead of the default range (12rem to 24rem), capped at the viewport width. `anchor` places the panel against any element or a virtual reference (`OverlayVirtualAnchor`, an object with `getBoundingClientRect()`, for a pointer position or a text selection) instead of its trigger, and the trigger slot becomes optional: open it with `v-model:open` or the exposed `show()`. An element inside a same origin iframe works too: the panel is placed in the page against it, and a click or Escape inside the iframe closes it. The position follows scroll and resize. Focus moves into the panel on open and returns to the anchor when it can take focus, otherwise to the element focused before; a click outside and Escape close it. Without a trigger, name the panel with `label`.
|
|
790
|
+
|
|
791
|
+
`sheet` renders the panel as a bottom sheet on phones: when the viewport is 640px wide or less (the breakpoint of the `Modal` sheet), the same `#content` opens in a `Modal` with its sheet look, `label` as the title (the trigger text names it without a `label`), the same first focus (`initialFocus`) and focus return, and `close` in the slot scope still closes it. `v-model:open`, `anchor` and the exposed `show`, `hide` and `toggle` work in both modes; crossing the breakpoint closes the open panel. Use it for pickers that need room on a phone (a block picker, a long `CommandList`).
|
|
788
792
|
|
|
789
793
|
```vue
|
|
790
794
|
<script setup lang="ts">
|
|
@@ -816,7 +820,7 @@ function openAt(event: MouseEvent) {
|
|
|
816
820
|
```
|
|
817
821
|
|
|
818
822
|
- `Brand`: `logo` takes an image URL, trusted inline SVG markup (`'<svg ...>'`) or a component; the `#logo` slot replaces the boxed mark; `show-name` keeps the name visible next to a logo.
|
|
819
|
-
- `Card`: `selected` gives a pressed look (`aria-pressed` on `as="button"`, `aria-selected` with `role="option"` and similar roles); `:animated="false"` turns off the entrance animation.
|
|
823
|
+
- `Card`: `selected` gives a pressed look (`aria-pressed` on `as="button"`, `aria-selected` with `role="option"` and similar roles); `:animated="false"` turns off the entrance animation. The `icon` stays beside the heading at any width (the title and the description wrap next to it), and the header actions move to their own line when they do not fit.
|
|
820
824
|
- `Spinner`: `block` renders a centered loading state that fills its container, with `label` shown under the spinner: `<KSpinner block size="lg" label="Loading entries" />`.
|
|
821
825
|
|
|
822
826
|
## Layouts and page templates
|
|
@@ -863,6 +867,54 @@ Ready defaults to start a dashboard project: an app frame, an auth frame and pag
|
|
|
863
867
|
|
|
864
868
|
Slots: `brand`, `search`, `sidebar-top` (under the search, for example a workspace select), `sidebar` (replaces the navigation), `sidebar-footer`, `account`, `topbar-brand`, `topbar`, `actions`, default, plus `settings-section-<id>`, `settings-actions-<id>`, `settings-tabs-<id>`, `settings-nav-footer`, `settings-account-start` and `settings-account-fields`, forwarded to the SettingsModal. The exposed `openSettings(id?)` opens it on a section. Landmarks: skip link, `aside` and `nav` with labels, `main` with an id, `aria-current="page"` on the active link. `SidebarNav` (layout group) renders the same navigation data inside your own `Sidebar`.
|
|
865
869
|
|
|
870
|
+
### WorkspaceLayout
|
|
871
|
+
|
|
872
|
+
A full height app workspace for editors (a visual page editor, a mail client, a file manager): a top bar and up to three panes, the side ones resizable, collapsible and remembered.
|
|
873
|
+
|
|
874
|
+
```vue
|
|
875
|
+
<KWorkspaceLayout
|
|
876
|
+
v-model:pane="pane"
|
|
877
|
+
storage-key="editor"
|
|
878
|
+
:left="{ label: 'Blocks', min: 220, max: 420, initial: 280, badge: blocks.length }"
|
|
879
|
+
:main="{ label: 'Preview' }"
|
|
880
|
+
:right="{
|
|
881
|
+
label: 'Fields',
|
|
882
|
+
min: 280,
|
|
883
|
+
max: 520,
|
|
884
|
+
initial: 340,
|
|
885
|
+
badge: errors,
|
|
886
|
+
badgeTone: 'danger',
|
|
887
|
+
}"
|
|
888
|
+
>
|
|
889
|
+
<template #start><KButton icon="arrow-left" aria-label="Back" to="/pages" /> About us</template>
|
|
890
|
+
<template #center><KSegmentedControl v-model="device" :options="devices" label="Preview width" /></template>
|
|
891
|
+
<template #end="{ compact, collapsed, toggle }">
|
|
892
|
+
<KButton
|
|
893
|
+
v-if="!compact"
|
|
894
|
+
icon="list-bullet"
|
|
895
|
+
aria-label="Blocks panel"
|
|
896
|
+
:aria-pressed="!collapsed.left"
|
|
897
|
+
@click="toggle('left')"
|
|
898
|
+
/>
|
|
899
|
+
<KButton label="Publish" />
|
|
900
|
+
</template>
|
|
901
|
+
<template #left-header><KPageHeader size="sm" title="Blocks" :level="2" /></template>
|
|
902
|
+
<template #left="{ reveal }"><KTree :nodes="nodes" @update:selected="reveal('right')" /></template>
|
|
903
|
+
<template #main><iframe src="/preview" title="Live preview" /></template>
|
|
904
|
+
<template #right-header><KPageHeader size="sm" :title="block.label" :level="2" /></template>
|
|
905
|
+
<template #right>...</template>
|
|
906
|
+
</KWorkspaceLayout>
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
- Top bar: a `header` with the slots `start`, `center` (centered, on its own row under 40rem of workspace width) and `end`, rendered only when one of them is set.
|
|
910
|
+
- Panes: `left` and `right` are `aside` landmarks and `main` is `main` (a `section`, named by its label, inside an `AppShell` or `DashboardLayout`, which already have the main landmark). A side pane renders when its slot is set. `left-header`, `main-header` and `right-header` add a header strip above the scrolling pane body (a `PageHeader size="sm"` fits there). The pane bodies are flex columns that scroll.
|
|
911
|
+
- Side panes: `left` and `right` take `label` (the landmark and tab name, default "Left panel" and "Right panel"), `min`, `max` and `initial` widths in pixels (default 200, 480, 280). A `ResizeHandle` sits on the inner edge: drag it, or focus it and use the arrow keys (`step`, default 16), Home and End; a double click goes back to `initial`. While dragging, the workspace gets `is-resizing` (column cursor, iframes ignore the pointer). `v-model:left-width` and `v-model:right-width` bind the widths, `v-model:left-collapsed` and `v-model:right-collapsed` hide a pane (it stays mounted, so its state survives).
|
|
912
|
+
- Persistence: with `storageKey` the widths and the collapsed state go to the preferences store under `workspace:<storageKey>` (`PREFERENCE_KEYS.workspace(key)`), restored after mount with a `localStorage` store or on the first render with a server snapshot.
|
|
913
|
+
- Compact mode: under `breakpoint` (default 1024, the width of the workspace itself, not the viewport; 0 turns it off) the panes become `Tabs` under the top bar, one panel at a time, with the active pane in `v-model:pane` (`'left' | 'main' | 'right'`, default `main`). The tab labels come from the pane `label`s, and `badge`, `badgeTone`, `badgeLabel`, `dot`, `dotTone`, `dotLabel` and `icon` on `left`, `main` and `right` show on the tabs (an error count on the fields pane). `panesLabel` names the tab list.
|
|
914
|
+
- Slot scope: every slot gets `{ compact, pane, collapsed: { left, right }, toggle(side), reveal(pane) }`. `reveal` selects the tab in compact mode and expands a collapsed pane otherwise (selecting a block reveals its fields). `toggle`, `reveal` and `compact` are also exposed on the component.
|
|
915
|
+
- Height: `100dvh` by default (`--k-workspace-height` changes it, `100%` inside a modal). Inside `DashboardLayout` or `AppShell` with `content="fill"` it fills the content panel with a border, without it with `content="bleed"`.
|
|
916
|
+
- Copy: `resizeLabel` (`'Resize {pane}'`) names the handles, `panesLabel` the tabs.
|
|
917
|
+
|
|
866
918
|
### SettingsModal
|
|
867
919
|
|
|
868
920
|
A large dialog (60rem) with a section nav on the left and the content on the right, the nuxt-cms settings look. Below 640px the nav turns into a scrolling row above the content.
|
|
@@ -4,25 +4,40 @@
|
|
|
4
4
|
<ul
|
|
5
5
|
v-else-if="items.length"
|
|
6
6
|
class="k-record-list"
|
|
7
|
-
:class="{ 'is-interactive': hasRowClick }"
|
|
7
|
+
:class="{ 'is-interactive': hasRowClick || hasLinks }"
|
|
8
8
|
:aria-label="label"
|
|
9
9
|
>
|
|
10
10
|
<li
|
|
11
11
|
v-for="(item, index) in items"
|
|
12
12
|
:key="item.id"
|
|
13
13
|
class="k-record-list-item"
|
|
14
|
-
:class="{ 'is-interactive': clickable(item) }"
|
|
14
|
+
:class="{ 'is-interactive': clickable(item) || links[index], 'is-link': links[index] }"
|
|
15
15
|
@click="onRowClick(item, $event)"
|
|
16
16
|
>
|
|
17
|
-
<slot name="leading" :item="item"
|
|
17
|
+
<slot name="leading" :item="item">
|
|
18
|
+
<span v-if="item.icon" class="k-record-list-icon" aria-hidden="true">
|
|
19
|
+
<Icon :name="item.icon" />
|
|
20
|
+
</span>
|
|
21
|
+
</slot>
|
|
18
22
|
<div class="k-record-list-text">
|
|
19
23
|
<span class="k-record-list-title-row">
|
|
24
|
+
<component
|
|
25
|
+
:is="links[index].is"
|
|
26
|
+
v-if="links[index]"
|
|
27
|
+
v-bind="links[index].attrs"
|
|
28
|
+
class="k-record-list-title k-record-list-trigger k-record-list-link"
|
|
29
|
+
:title="item.title"
|
|
30
|
+
:aria-describedby="describedBy(item, index)"
|
|
31
|
+
@click="emit('rowClick', item, $event)"
|
|
32
|
+
>
|
|
33
|
+
{{ item.title }}
|
|
34
|
+
</component>
|
|
20
35
|
<button
|
|
21
|
-
v-if="clickable(item)"
|
|
36
|
+
v-else-if="clickable(item)"
|
|
22
37
|
type="button"
|
|
23
38
|
class="k-record-list-title k-record-list-trigger"
|
|
24
39
|
:title="item.title"
|
|
25
|
-
:aria-describedby="item
|
|
40
|
+
:aria-describedby="describedBy(item, index)"
|
|
26
41
|
@click="emit('rowClick', item, $event)"
|
|
27
42
|
>
|
|
28
43
|
{{ item.title }}
|
|
@@ -43,12 +58,19 @@
|
|
|
43
58
|
{{ item.description }}
|
|
44
59
|
</span>
|
|
45
60
|
</div>
|
|
61
|
+
<span v-if="item.meta || $slots.meta" :id="metaId(index)" class="k-record-list-meta">
|
|
62
|
+
<slot name="meta" :item="item">{{ item.meta }}</slot>
|
|
63
|
+
</span>
|
|
46
64
|
<slot name="action" :item="item" />
|
|
47
65
|
</li>
|
|
48
66
|
</ul>
|
|
49
67
|
|
|
50
68
|
<slot v-else name="empty">
|
|
69
|
+
<p v-if="emptyVariant === 'hint'" class="k-record-list-hint">
|
|
70
|
+
{{ emptyText ?? t("common.empty") }}
|
|
71
|
+
</p>
|
|
51
72
|
<EmptyState
|
|
73
|
+
v-else
|
|
52
74
|
:icon="emptyIcon"
|
|
53
75
|
:title="emptyText ?? t('common.empty')"
|
|
54
76
|
:description="emptyDescription"
|
|
@@ -62,8 +84,11 @@
|
|
|
62
84
|
</template>
|
|
63
85
|
|
|
64
86
|
<script setup>
|
|
65
|
-
import { computed, getCurrentInstance, useId } from "vue";
|
|
87
|
+
import { computed, getCurrentInstance, useId, useSlots } from "vue";
|
|
66
88
|
import { useLocale } from "../../composables/useLocale";
|
|
89
|
+
import { useLinkResolver } from "../../internal/core/link";
|
|
90
|
+
import { joinIds } from "../../internal/forms/control";
|
|
91
|
+
import Icon from "../core/Icon.vue";
|
|
67
92
|
import EmptyState from "../feedback/EmptyState.vue";
|
|
68
93
|
import SkeletonList from "../feedback/SkeletonList.vue";
|
|
69
94
|
import Badge from "./Badge.vue";
|
|
@@ -84,10 +109,23 @@ defineSlots();
|
|
|
84
109
|
const emit = defineEmits(["rowClick"]);
|
|
85
110
|
const { t } = useLocale();
|
|
86
111
|
const instance = getCurrentInstance();
|
|
112
|
+
const slots = useSlots();
|
|
87
113
|
const baseId = useId();
|
|
114
|
+
const { resolveLink } = useLinkResolver();
|
|
115
|
+
const links = computed(() => props.items.map((item) => resolveLink(item)));
|
|
116
|
+
const hasLinks = computed(() => links.value.some(Boolean));
|
|
88
117
|
function descriptionId(index) {
|
|
89
118
|
return `${baseId}-description-${index}`;
|
|
90
119
|
}
|
|
120
|
+
function metaId(index) {
|
|
121
|
+
return `${baseId}-meta-${index}`;
|
|
122
|
+
}
|
|
123
|
+
function describedBy(item, index) {
|
|
124
|
+
return joinIds(
|
|
125
|
+
item.description ? descriptionId(index) : void 0,
|
|
126
|
+
item.meta || slots.meta ? metaId(index) : void 0
|
|
127
|
+
);
|
|
128
|
+
}
|
|
91
129
|
const interactiveSelector = 'a, button, input, select, textarea, label, summary, [contenteditable="true"], [role="button"], [role="menuitem"], [role="option"], [role="checkbox"], [role="switch"], [role="tab"]';
|
|
92
130
|
const layerSelector = "dialog, [popover], .k-floating";
|
|
93
131
|
const hasRowClick = computed(
|
|
@@ -11,7 +11,7 @@ declare const __VLS_export: <Item extends RecordListItem>(__VLS_props: NonNullab
|
|
|
11
11
|
emptyText?: string;
|
|
12
12
|
emptyDescription?: string;
|
|
13
13
|
emptyIcon?: IconName;
|
|
14
|
-
emptyVariant?: "card" | "plain";
|
|
14
|
+
emptyVariant?: "card" | "plain" | "hint";
|
|
15
15
|
rowClickable?: (item: Item) => boolean;
|
|
16
16
|
} & {
|
|
17
17
|
onRowClick?: ((item: Item, event: MouseEvent) => any) | undefined;
|
|
@@ -223,6 +223,9 @@ declare const __VLS_export: <Item extends RecordListItem>(__VLS_props: NonNullab
|
|
|
223
223
|
leading?(props: {
|
|
224
224
|
item: Item;
|
|
225
225
|
}): unknown;
|
|
226
|
+
meta?(props: {
|
|
227
|
+
item: Item;
|
|
228
|
+
}): unknown;
|
|
226
229
|
action?(props: {
|
|
227
230
|
item: Item;
|
|
228
231
|
}): unknown;
|
|
@@ -35,14 +35,16 @@
|
|
|
35
35
|
:class="{
|
|
36
36
|
'is-moving': dragId === entry.node.id,
|
|
37
37
|
'is-highlighted': highlightedSet.has(entry.node.id),
|
|
38
|
-
'is-invalid': entry.node.invalid
|
|
38
|
+
'is-invalid': entry.node.invalid,
|
|
39
|
+
'is-muted': entry.node.muted,
|
|
40
|
+
'is-link': links.has(entry.node.id)
|
|
39
41
|
}"
|
|
40
42
|
:data-drop="dropState?.id === entry.node.id ? dropState.position : void 0"
|
|
41
43
|
:style="{
|
|
42
44
|
'--k-tree-level': entry.level - 1,
|
|
43
45
|
'--k-row-delay': rowDelay(index - revealAnchor - 1)
|
|
44
46
|
}"
|
|
45
|
-
@click="
|
|
47
|
+
@click="onRowClick($event, entry)"
|
|
46
48
|
@keydown="onKeydown($event, entry, index)"
|
|
47
49
|
@focus="focusId = entry.node.id"
|
|
48
50
|
@pointerenter="onRowEnter(entry)"
|
|
@@ -76,29 +78,47 @@
|
|
|
76
78
|
<Icon :name="entry.node.icon" />
|
|
77
79
|
</span>
|
|
78
80
|
<span v-if="entry.node.invalid" class="k-tree-invalid" aria-hidden="true" />
|
|
79
|
-
<span
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
:
|
|
84
|
-
|
|
81
|
+
<span class="k-tree-body">
|
|
82
|
+
<component
|
|
83
|
+
:is="links.get(entry.node.id)?.is ?? 'span'"
|
|
84
|
+
v-bind="links.get(entry.node.id)?.attrs"
|
|
85
|
+
:id="textId(entry.node.id)"
|
|
86
|
+
class="k-tree-text"
|
|
87
|
+
:class="{ 'k-tree-link': links.has(entry.node.id) }"
|
|
88
|
+
:tabindex="links.has(entry.node.id) ? -1 : void 0"
|
|
89
|
+
@focus="links.has(entry.node.id) && focusNode(entry.node.id)"
|
|
85
90
|
>
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
:
|
|
90
|
-
|
|
91
|
-
:class="`k-tree-description-${entry.node.descriptionVariant ?? descriptionVariant}`"
|
|
92
|
-
>{{ entry.node.description }}</span
|
|
91
|
+
<slot
|
|
92
|
+
name="label"
|
|
93
|
+
:node="entry.node"
|
|
94
|
+
:level="entry.level"
|
|
95
|
+
:invalid="Boolean(entry.node.invalid)"
|
|
93
96
|
>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
<span
|
|
98
|
+
:id="labelId(entry.node.id)"
|
|
99
|
+
class="k-tree-label"
|
|
100
|
+
:title="entry.node.label"
|
|
101
|
+
>{{ entry.node.label }}</span
|
|
102
|
+
>
|
|
103
|
+
<span
|
|
104
|
+
v-if="entry.node.description"
|
|
105
|
+
:id="descriptionId(entry.node.id)"
|
|
106
|
+
class="k-tree-description"
|
|
107
|
+
:class="`k-tree-description-${descriptionVariantOf(entry.node)}`"
|
|
108
|
+
:title="
|
|
109
|
+
descriptionVariantOf(entry.node) === 'mono' ? entry.node.description : void 0
|
|
110
|
+
"
|
|
111
|
+
>{{ entry.node.description }}</span
|
|
112
|
+
>
|
|
113
|
+
</slot>
|
|
114
|
+
</component>
|
|
115
|
+
<span
|
|
116
|
+
v-if="entry.node.meta || $slots.meta"
|
|
117
|
+
:id="metaId(entry.node.id)"
|
|
118
|
+
class="k-tree-meta"
|
|
119
|
+
>
|
|
120
|
+
<slot name="meta" :node="entry.node">{{ entry.node.meta }}</slot>
|
|
121
|
+
</span>
|
|
102
122
|
</span>
|
|
103
123
|
<span v-if="checkmark && selectable" class="k-tree-check" aria-hidden="true">
|
|
104
124
|
<Icon v-if="selected === entry.node.id" name="check" />
|
|
@@ -175,6 +195,7 @@ import LiveRegion from "../../internal/core/LiveRegion.vue";
|
|
|
175
195
|
import { useLiveMessage } from "../../internal/core/live";
|
|
176
196
|
import { hasFocusWithin, isFocusLost } from "../../internal/core/focus";
|
|
177
197
|
import { useTypeahead } from "../../internal/core/roving";
|
|
198
|
+
import { useLinkResolver } from "../../internal/core/link";
|
|
178
199
|
import { joinIds } from "../../internal/forms/control";
|
|
179
200
|
import Button from "../core/Button.vue";
|
|
180
201
|
import Icon from "../core/Icon.vue";
|
|
@@ -279,6 +300,9 @@ function describedBy(entry) {
|
|
|
279
300
|
canReorder.value && !entry.node.disabled ? hintId : void 0
|
|
280
301
|
);
|
|
281
302
|
}
|
|
303
|
+
function descriptionVariantOf(node) {
|
|
304
|
+
return node.descriptionVariant ?? props.descriptionVariant;
|
|
305
|
+
}
|
|
282
306
|
function isExpanded(id) {
|
|
283
307
|
return expandedSet.value.has(id);
|
|
284
308
|
}
|
|
@@ -317,6 +341,17 @@ const rovingId = computed(() => {
|
|
|
317
341
|
if (list.some((entry) => entry.node.id === focusId.value)) return focusId.value;
|
|
318
342
|
return list.find((entry) => entry.node.id === selected.value)?.node.id ?? list[0]?.node.id;
|
|
319
343
|
});
|
|
344
|
+
const { resolveLink } = useLinkResolver();
|
|
345
|
+
const links = computed(() => {
|
|
346
|
+
const map = /* @__PURE__ */ new Map();
|
|
347
|
+
if (control.disabled.value) return map;
|
|
348
|
+
for (const entry of visible.value) {
|
|
349
|
+
if (entry.node.disabled) continue;
|
|
350
|
+
const link = resolveLink(entry.node);
|
|
351
|
+
if (link) map.set(entry.node.id, link);
|
|
352
|
+
}
|
|
353
|
+
return map;
|
|
354
|
+
});
|
|
320
355
|
const hasInvalid = computed(() => visible.value.some((entry) => entry.node.invalid));
|
|
321
356
|
function hasMoveButtons(entry) {
|
|
322
357
|
return canReorder.value && props.moveButtons && !entry.node.disabled;
|
|
@@ -357,6 +392,28 @@ function activate(entry) {
|
|
|
357
392
|
if (props.selectable) selected.value = entry.node.id;
|
|
358
393
|
emit("select", entry.node);
|
|
359
394
|
}
|
|
395
|
+
function onRowClick(event, entry) {
|
|
396
|
+
const modified = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
397
|
+
if (modified && links.value.has(entry.node.id)) return;
|
|
398
|
+
activate(entry);
|
|
399
|
+
}
|
|
400
|
+
function openLink(event, entry) {
|
|
401
|
+
if (!links.value.has(entry.node.id)) return false;
|
|
402
|
+
const element = tree.value?.querySelector(`#${CSS.escape(textId(entry.node.id))}`);
|
|
403
|
+
if (!element) return false;
|
|
404
|
+
element.dispatchEvent(
|
|
405
|
+
new MouseEvent("click", {
|
|
406
|
+
bubbles: true,
|
|
407
|
+
cancelable: true,
|
|
408
|
+
view: window,
|
|
409
|
+
ctrlKey: event.ctrlKey,
|
|
410
|
+
metaKey: event.metaKey,
|
|
411
|
+
shiftKey: event.shiftKey,
|
|
412
|
+
altKey: event.altKey
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
360
417
|
function focusNode(id) {
|
|
361
418
|
if (id === void 0 || id === null) return;
|
|
362
419
|
focusId.value = id;
|
|
@@ -508,9 +565,12 @@ function onKeydown(event, entry, position) {
|
|
|
508
565
|
else focusNode(entry.parentId);
|
|
509
566
|
break;
|
|
510
567
|
case "Enter":
|
|
568
|
+
if (openLink(event, entry)) break;
|
|
569
|
+
activate(entry);
|
|
570
|
+
toggle(entry, position);
|
|
571
|
+
break;
|
|
511
572
|
case " ":
|
|
512
573
|
activate(entry);
|
|
513
|
-
if (event.key === "Enter") toggle(entry, position);
|
|
514
574
|
break;
|
|
515
575
|
default:
|
|
516
576
|
return;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import type { IconName } from '../../composables/useIcons';
|
|
2
2
|
import type { TreeDescriptionVariant, TreeMove, TreeNode, TreeNodeId, TreeSize } from './types';
|
|
3
|
-
declare var
|
|
3
|
+
declare var __VLS_20: {
|
|
4
4
|
node: TreeNode;
|
|
5
5
|
level: number;
|
|
6
6
|
invalid: boolean;
|
|
7
|
-
},
|
|
7
|
+
}, __VLS_22: {
|
|
8
8
|
node: TreeNode;
|
|
9
|
-
},
|
|
9
|
+
}, __VLS_37: {
|
|
10
10
|
node: TreeNode;
|
|
11
11
|
level: number;
|
|
12
12
|
selected: boolean;
|
|
13
13
|
expanded: boolean;
|
|
14
14
|
highlighted: boolean;
|
|
15
15
|
hovered: boolean;
|
|
16
|
-
},
|
|
16
|
+
}, __VLS_39: {}, __VLS_48: {};
|
|
17
17
|
type __VLS_Slots = {} & {
|
|
18
|
-
label?: (props: typeof
|
|
18
|
+
label?: (props: typeof __VLS_20) => any;
|
|
19
19
|
} & {
|
|
20
|
-
meta?: (props: typeof
|
|
20
|
+
meta?: (props: typeof __VLS_22) => any;
|
|
21
21
|
} & {
|
|
22
|
-
actions?: (props: typeof
|
|
22
|
+
actions?: (props: typeof __VLS_37) => any;
|
|
23
23
|
} & {
|
|
24
|
-
empty?: (props: typeof
|
|
24
|
+
empty?: (props: typeof __VLS_39) => any;
|
|
25
25
|
} & {
|
|
26
|
-
'empty-actions'?: (props: typeof
|
|
26
|
+
'empty-actions'?: (props: typeof __VLS_48) => any;
|
|
27
27
|
};
|
|
28
28
|
declare const __VLS_base: import("vue").DefineComponent<{
|
|
29
29
|
nodes: TreeNode[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'vue';
|
|
2
|
-
import type { ColorValue, Tone } from '../core/types';
|
|
2
|
+
import type { ColorValue, LinkTarget, Tone } from '../core/types';
|
|
3
3
|
import type { IconName } from '../../composables/useIcons';
|
|
4
4
|
import type { MenuItems } from '../overlays/types';
|
|
5
5
|
export type BadgeVariant = 'soft' | 'solid' | 'outline';
|
|
@@ -84,6 +84,10 @@ export interface TreeNode {
|
|
|
84
84
|
icon?: string;
|
|
85
85
|
disabled?: boolean;
|
|
86
86
|
invalid?: boolean;
|
|
87
|
+
muted?: boolean;
|
|
88
|
+
to?: LinkTarget;
|
|
89
|
+
href?: string;
|
|
90
|
+
target?: string;
|
|
87
91
|
children?: TreeNode[];
|
|
88
92
|
}
|
|
89
93
|
export type TreeDescriptionVariant = 'text' | 'mono';
|
|
@@ -159,4 +163,9 @@ export interface RecordListItem {
|
|
|
159
163
|
label: string;
|
|
160
164
|
tone?: Tone;
|
|
161
165
|
};
|
|
166
|
+
icon?: IconName;
|
|
167
|
+
meta?: string;
|
|
168
|
+
to?: LinkTarget;
|
|
169
|
+
href?: string;
|
|
170
|
+
target?: string;
|
|
162
171
|
}
|
|
@@ -251,10 +251,10 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
251
251
|
onCancel?: ((payload: Event) => void) | undefined;
|
|
252
252
|
onClose?: (() => any) | undefined;
|
|
253
253
|
emptyText?: string | undefined;
|
|
254
|
+
onOpen?: (() => any) | undefined;
|
|
254
255
|
removeLabel?: string | undefined;
|
|
255
256
|
loadingText?: string | undefined;
|
|
256
257
|
onCreate?: ((option: ComboboxOption<PaletteOptionValue>) => any) | undefined;
|
|
257
|
-
onOpen?: (() => any) | undefined;
|
|
258
258
|
"onUpdate:query"?: ((value: string) => any) | undefined;
|
|
259
259
|
searchable?: boolean | undefined;
|
|
260
260
|
hideTags?: boolean | undefined;
|
|
@@ -521,10 +521,10 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
521
521
|
onCancel?: ((payload: Event) => void) | undefined;
|
|
522
522
|
onClose?: (() => any) | undefined;
|
|
523
523
|
emptyText?: string | undefined;
|
|
524
|
+
onOpen?: (() => any) | undefined;
|
|
524
525
|
removeLabel?: string | undefined;
|
|
525
526
|
loadingText?: string | undefined;
|
|
526
527
|
onCreate?: ((option: ComboboxOption<PaletteOptionValue>) => any) | undefined;
|
|
527
|
-
onOpen?: (() => any) | undefined;
|
|
528
528
|
"onUpdate:query"?: ((value: string) => any) | undefined;
|
|
529
529
|
searchable?: boolean | undefined;
|
|
530
530
|
hideTags?: boolean | undefined;
|