@xleddyl/443-components-vue 0.16.94 → 0.16.96
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 +175 -170
- package/README.md +51 -7
- package/dist/components/data/RecordList.vue +44 -6
- package/dist/components/data/RecordList.vue.d.ts +4 -1
- package/dist/components/data/SortableList.vue +120 -0
- package/dist/components/data/SortableList.vue.d.ts +48 -0
- package/dist/components/data/Table.vue +43 -3
- package/dist/components/data/Table.vue.d.ts +8 -2
- package/dist/components/data/TileGrid.vue +274 -0
- package/dist/components/data/TileGrid.vue.d.ts +51 -0
- package/dist/components/data/Tree.vue +84 -24
- package/dist/components/data/Tree.vue.d.ts +9 -9
- package/dist/components/data/index.d.ts +2 -0
- package/dist/components/data/index.mjs +2 -0
- package/dist/components/data/types.d.ts +40 -1
- package/dist/components/layout/Accordion.vue +6 -2
- package/dist/components/layout/Accordion.vue.d.ts +3 -0
- package/dist/components/overlays/Popover.vue +4 -2
- package/dist/components/overlays/Popover.vue.d.ts +2 -0
- package/dist/composables/useSortable.d.ts +1 -0
- package/dist/composables/useSortable.mjs +53 -11
- package/dist/icons/builtin.d.ts +1 -0
- package/dist/icons/builtin.mjs +1 -0
- package/dist/internal/data/sortable.d.ts +6 -1
- package/dist/internal/data/sortable.mjs +51 -0
- package/dist/locale/de.mjs +12 -0
- package/dist/locale/en.mjs +12 -0
- package/dist/locale/it.mjs +12 -0
- package/dist/locale/types.d.ts +12 -0
- package/dist/styles/data/record-list.css +54 -0
- package/dist/styles/data/sortable-list.css +185 -0
- package/dist/styles/data/table.css +12 -0
- package/dist/styles/data/tile-grid.css +144 -0
- package/dist/styles/data/tree.css +57 -4
- package/dist/styles/data.css +2 -0
- package/dist/styles/forced-colors.css +34 -0
- package/dist/styles/layout/accordion.css +4 -5
- package/dist/styles/layout/card.css +2 -0
- package/dist/styles/overlays/popover.css +6 -0
- package/dist/styles/shared.css +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -473,7 +473,7 @@ async function switchView() {
|
|
|
473
473
|
| core | Root, Icon, Button, Spinner, Input, Textarea, FormField, FieldMessage, FieldBoundary, Form, FormAlerts, Kbd, VisuallyHidden |
|
|
474
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
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, Stat, Table, Tag, TagList, Thumbnail, Timeline, Tree
|
|
476
|
+
| data | Avatar, AvatarGroup, Badge, DescriptionList, FilterPill, FilterPills, Pagination, RecordList, SelectionBar, SortableList, Stat, Table, Tag, TagList, Thumbnail, TileGrid, Timeline, Tree |
|
|
477
477
|
| layout | Accordion, AppShell, Breadcrumbs, Card, CopyButton, Grid, NavLink, PageHeader, Separator, Sidebar, SidebarNav, SidebarSection, Stack, Stepper, Tabs, ThemeSwitch, Toolbar |
|
|
478
478
|
| templates | DashboardLayout, AuthLayout, AuthLogin, AuthLogout, DashboardPage, ListPage, DetailPage, FormPage, SettingsPage, SettingsSection, SettingsModal, SettingsGroup, AppearanceSettings, SaveBar, ErrorPage, NotFoundPage, EmptyPage, Brand, AccountMenu, FormDrawer |
|
|
479
479
|
| feedback | Alert, EmptyState, LoadingOverlay, Meter, Progress, ProgressRing, Skeleton, SkeletonForm, SkeletonList |
|
|
@@ -510,7 +510,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
510
510
|
|
|
511
511
|
### Lists, trees and uploads
|
|
512
512
|
|
|
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.
|
|
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. 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
514
|
- `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
515
|
- `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
516
|
- 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 +521,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
521
521
|
- `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
522
|
- `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
523
|
- `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.
|
|
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. 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
525
|
- `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
526
|
- `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
527
|
- 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.
|
|
@@ -570,7 +570,17 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
570
570
|
/>
|
|
571
571
|
```
|
|
572
572
|
|
|
573
|
-
- `
|
|
573
|
+
- `SortableList` is a vertical list of rows to reorder: `v-model` (`SortableListItem[]`: `value`, `label`, `description`, `icon`, `disabled`) in a labelled list (`label`, default "Items"). Each row has a drag handle, the icon, the label with the description under it (both on one line with an ellipsis) and the `#trailing` slot (`{ item, index }`) for switches or actions. A drag starts from the handle or the label (not from the trailing controls), the row follows the pointer and its slot stays as a dashed placeholder, Escape cancels. The handle is a button ("Move Title", `handleLabel` is a `'Move {label}'` template): the up and down arrow keys, Home and End move the row, Alt with an arrow key works from anywhere in the row, and every move is announced. A disabled item cannot be picked up or moved by its handle (the handle is disabled), `disabled` locks the whole list (the trailing controls stay usable). `move({ item, from, to })` fires after each move. `size` is `'md'` (default) or `'sm'` (`SortableListSize`); `#item` replaces the icon, label and description; `emptyText` or `#empty` shows when the list is empty.
|
|
574
|
+
|
|
575
|
+
```vue
|
|
576
|
+
<KSortableList v-model="columns" label="Visible columns">
|
|
577
|
+
<template #trailing="{ item }">
|
|
578
|
+
<KSwitch :model-value="true" :aria-label="`Hide ${item.label}`" @update:model-value="hide(item)" />
|
|
579
|
+
</template>
|
|
580
|
+
</KSortableList>
|
|
581
|
+
```
|
|
582
|
+
|
|
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 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.
|
|
574
584
|
|
|
575
585
|
- `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.
|
|
576
586
|
|
|
@@ -582,8 +592,42 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
582
592
|
</KThumbnail>
|
|
583
593
|
```
|
|
584
594
|
|
|
595
|
+
- `TileGrid` lays out `items` as a responsive grid of tiles: `minItemWidth` (default `10rem`, the narrowest tile), `columns` (the most columns, unset fills the row) and `gap` (`LayoutGap`, default `md`). The `#tile` slot (`{ item, index, selected, dragging }`) renders each tile (a `Card`, a `Thumbnail`) and stretches it to the cell; `#add` is a last cell after the tiles (a `Card variant="dashed" as="button"`). `itemKey` (a field name, default `id`, or `(item, index) => key`) keys the tiles and the selection, `itemLabel(item)` names each tile and its announcements, `label` names the grid (default "Items"). The tiles are one tab stop: the arrow keys move between them across wrapped rows (Up and Down go to the nearest tile of the row above or below), Home and End go to the ends, and the controls inside a tile keep their own tab stops. `selectable` with `v-model:selected` (the keys) makes it a multi select `listbox` (otherwise a `list`): a round check shows on hover, focus and on every tile while something is selected (always on touch screens), a click on it toggles the tile, Shift adds the range from the last toggled tile, Space and Shift with Space do the same from the keyboard and Ctrl or Cmd with A selects all. A click on the tile itself toggles it while something is selected or with Shift, Ctrl or Cmd held, and calls `@activate(item, index, event)` otherwise (Enter too; without an `activate` listener it toggles). `sortable` reorders by pointer drag (the tile follows the pointer and its cell stays as a dashed placeholder, Escape cancels; `handle`, a selector, limits where a drag starts and keeps touch scrolling on the rest of the tile) and by Alt with an arrow key on a focused tile, with an announcement; bind `v-model:items` (or write `items` back from `move({ item, from, to, items })`). `dragData(item, items)` makes tiles native drag sources for drop targets outside the grid (folders): it returns `{ [mimeType]: string }` for the `DataTransfer` (or `null` to refuse the drag), `items` is the whole selection when the dragged tile is selected, `dragEffect` sets `effectAllowed` (default `move`), the dragged tiles fade and `itemDragStart` and `itemDragEnd` (`{ item, items, event }`) fire. `dragData` is ignored when `sortable` is set. `--k-tile-grid-radius` (default `--k-radius-lg`) is the radius of the tiles, the selected ring and the placeholder.
|
|
596
|
+
|
|
597
|
+
```vue
|
|
598
|
+
<KTileGrid
|
|
599
|
+
v-model:selected="selected"
|
|
600
|
+
:items="files"
|
|
601
|
+
:item-label="(file) => file.name"
|
|
602
|
+
label="Files"
|
|
603
|
+
min-item-width="9rem"
|
|
604
|
+
selectable
|
|
605
|
+
:drag-data="(file, files) => ({ 'application/x-media': files.map((f) => f.id).join(',') })"
|
|
606
|
+
@activate="open"
|
|
607
|
+
>
|
|
608
|
+
<template #tile="{ item }">
|
|
609
|
+
<KThumbnail :src="item.url" aspect="1/1" :caption="item.name" />
|
|
610
|
+
</template>
|
|
611
|
+
</KTileGrid>
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
- `Table` takes `rowAttrs(row, index)` (`TableRowAttrs`): attributes and listeners bound on each `<tr>` (`data-*`, `title`, `onDragover` to make rows drop targets); classes and listeners merge with the table's own. `rowDraggable` (`true` or `(row, index) => boolean`) with `dragData(row, rows)` makes rows native drag sources for drop targets outside the table (folders): `dragData` returns `{ [mimeType]: string }` for the `DataTransfer` (or `null` to refuse the drag), `rows` is the whole selection when the dragged row is selected, `dragEffect` sets `effectAllowed` (default `move`), the dragged rows fade and `rowDragStart` and `rowDragEnd` (`{ row, rows, event }`) fire. Selection, `rowClick`, row links and the keyboard keep working; links in draggable rows are not dragged on their own.
|
|
615
|
+
|
|
616
|
+
```vue
|
|
617
|
+
<KTable
|
|
618
|
+
v-model:selected="selected"
|
|
619
|
+
:rows="files"
|
|
620
|
+
:columns="columns"
|
|
621
|
+
row-key="name"
|
|
622
|
+
selectable
|
|
623
|
+
row-draggable
|
|
624
|
+
:drag-data="(file, rows) => ({ 'application/x-media': rows.map((r) => r.name).join(',') })"
|
|
625
|
+
@row-click="open"
|
|
626
|
+
/>
|
|
627
|
+
```
|
|
628
|
+
|
|
585
629
|
- `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.
|
|
586
|
-
- `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
|
|
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 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.
|
|
587
631
|
- `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']`.
|
|
588
632
|
|
|
589
633
|
### Grid defaults
|
|
@@ -740,7 +784,7 @@ const archived = useRouteState('archived', {
|
|
|
740
784
|
- Pages that set `definePageMeta({ key: (route) => route.fullPath })` remount on every query change; keep the default page key for pages with deep links.
|
|
741
785
|
- 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.
|
|
742
786
|
|
|
743
|
-
`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`.
|
|
787
|
+
`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`.
|
|
744
788
|
|
|
745
789
|
```vue
|
|
746
790
|
<script setup lang="ts">
|
|
@@ -772,7 +816,7 @@ function openAt(event: MouseEvent) {
|
|
|
772
816
|
```
|
|
773
817
|
|
|
774
818
|
- `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.
|
|
775
|
-
- `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.
|
|
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. 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.
|
|
776
820
|
- `Spinner`: `block` renders a centered loading state that fills its container, with `label` shown under the spinner: `<KSpinner block size="lg" label="Loading entries" />`.
|
|
777
821
|
|
|
778
822
|
## Layouts and page templates
|
|
@@ -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;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="k-sortable-list"
|
|
4
|
+
:class="[
|
|
5
|
+
`k-sortable-list-${size}`,
|
|
6
|
+
{
|
|
7
|
+
'is-sortable': canSort,
|
|
8
|
+
'is-dragging': sorter.dragging.value !== null,
|
|
9
|
+
'is-disabled': disabled
|
|
10
|
+
}
|
|
11
|
+
]"
|
|
12
|
+
>
|
|
13
|
+
<ul
|
|
14
|
+
v-if="items.length"
|
|
15
|
+
ref="list"
|
|
16
|
+
class="k-sortable-list-items"
|
|
17
|
+
:aria-label="labelText"
|
|
18
|
+
:aria-describedby="hintId"
|
|
19
|
+
>
|
|
20
|
+
<li
|
|
21
|
+
v-for="(item, index) in items"
|
|
22
|
+
:key="item.value"
|
|
23
|
+
class="k-sortable-list-item"
|
|
24
|
+
:class="{
|
|
25
|
+
'is-moving': sorter.dragging.value === index,
|
|
26
|
+
'is-locked': !sorter.canMove(index)
|
|
27
|
+
}"
|
|
28
|
+
v-bind="sorter.itemProps(index)"
|
|
29
|
+
>
|
|
30
|
+
<div class="k-sortable-list-row">
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
class="k-sortable-list-handle"
|
|
34
|
+
:aria-label="handleText(item)"
|
|
35
|
+
:aria-describedby="hintId"
|
|
36
|
+
:disabled="!sorter.canMove(index)"
|
|
37
|
+
@keydown="onHandleKeydown($event, index)"
|
|
38
|
+
>
|
|
39
|
+
<Icon name="bars-2" />
|
|
40
|
+
</button>
|
|
41
|
+
<span class="k-sortable-list-content">
|
|
42
|
+
<slot name="item" :item="item" :index="index">
|
|
43
|
+
<Icon v-if="item.icon" :name="item.icon" class="k-sortable-list-icon" />
|
|
44
|
+
<span class="k-sortable-list-text">
|
|
45
|
+
<span class="k-sortable-list-label">{{ item.label }}</span>
|
|
46
|
+
<span v-if="item.description" class="k-sortable-list-description">{{
|
|
47
|
+
item.description
|
|
48
|
+
}}</span>
|
|
49
|
+
</span>
|
|
50
|
+
</slot>
|
|
51
|
+
</span>
|
|
52
|
+
<span v-if="$slots.trailing" class="k-sortable-list-trailing">
|
|
53
|
+
<slot name="trailing" :item="item" :index="index" />
|
|
54
|
+
</span>
|
|
55
|
+
</div>
|
|
56
|
+
</li>
|
|
57
|
+
</ul>
|
|
58
|
+
<p v-else class="k-sortable-list-empty">
|
|
59
|
+
<slot name="empty">{{ emptyLabel }}</slot>
|
|
60
|
+
</p>
|
|
61
|
+
<span :id="hintId" class="k-visually-hidden">{{ t("sortableList.hint") }}</span>
|
|
62
|
+
<LiveRegion :message="sorter.announcement.value" />
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<script setup>
|
|
67
|
+
import { computed, useId, useTemplateRef } from "vue";
|
|
68
|
+
import { useLocale } from "../../composables/useLocale";
|
|
69
|
+
import { useSortable } from "../../composables/useSortable";
|
|
70
|
+
import LiveRegion from "../../internal/core/LiveRegion.vue";
|
|
71
|
+
import { translateOr } from "../../locale";
|
|
72
|
+
import Icon from "../core/Icon.vue";
|
|
73
|
+
const props = defineProps({
|
|
74
|
+
label: { type: String, required: false },
|
|
75
|
+
size: { type: String, required: false, default: "md" },
|
|
76
|
+
disabled: { type: Boolean, required: false },
|
|
77
|
+
emptyText: { type: String, required: false },
|
|
78
|
+
handleLabel: { type: String, required: false }
|
|
79
|
+
});
|
|
80
|
+
const model = defineModel({ type: Array, ...{ default: () => [] } });
|
|
81
|
+
const emit = defineEmits(["move"]);
|
|
82
|
+
defineSlots();
|
|
83
|
+
const { t, locale } = useLocale();
|
|
84
|
+
const hintId = `${useId()}-hint`;
|
|
85
|
+
const list = useTemplateRef("list");
|
|
86
|
+
const items = computed(() => model.value);
|
|
87
|
+
const canSort = computed(() => !props.disabled && items.value.length > 1);
|
|
88
|
+
const labelText = computed(() => props.label ?? t("sortableList.label"));
|
|
89
|
+
const emptyLabel = computed(() => props.emptyText ?? t("sortableList.empty"));
|
|
90
|
+
function handleText(item) {
|
|
91
|
+
return translateOr(locale.value, props.handleLabel, "sortableList.handle", { label: item.label });
|
|
92
|
+
}
|
|
93
|
+
const sorter = useSortable(list, {
|
|
94
|
+
items,
|
|
95
|
+
orientation: "vertical",
|
|
96
|
+
handle: ".k-sortable-list-handle, .k-sortable-list-content",
|
|
97
|
+
preview: ".k-sortable-list-row",
|
|
98
|
+
disabled: () => props.disabled,
|
|
99
|
+
canMove: (item) => !item.disabled,
|
|
100
|
+
label: (item) => item.label,
|
|
101
|
+
onMove: (next, move) => {
|
|
102
|
+
model.value = next;
|
|
103
|
+
emit("move", { item: move.item, from: move.from, to: move.to });
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const HANDLE_KEYS = {
|
|
107
|
+
ArrowUp: (index) => index - 1,
|
|
108
|
+
ArrowDown: (index) => index + 1,
|
|
109
|
+
Home: () => 0,
|
|
110
|
+
End: (_, count) => count - 1
|
|
111
|
+
};
|
|
112
|
+
function onHandleKeydown(event, index) {
|
|
113
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
114
|
+
const target = HANDLE_KEYS[event.key];
|
|
115
|
+
if (!target) return;
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
sorter.move(index, target(index, items.value.length), { announce: true, source: "keyboard" });
|
|
119
|
+
}
|
|
120
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SortableListItem, SortableListSize } from './types';
|
|
2
|
+
declare const __VLS_export: <T extends SortableListItem>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
4
|
+
label?: string;
|
|
5
|
+
size?: SortableListSize;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
emptyText?: string;
|
|
8
|
+
handleLabel?: string;
|
|
9
|
+
} & {
|
|
10
|
+
modelValue?: T[];
|
|
11
|
+
}) & {
|
|
12
|
+
onMove?: ((move: {
|
|
13
|
+
item: T;
|
|
14
|
+
from: number;
|
|
15
|
+
to: number;
|
|
16
|
+
}) => any) | undefined;
|
|
17
|
+
"onUpdate:modelValue"?: ((value: T[]) => any) | undefined;
|
|
18
|
+
} & Partial<import("vue").HTMLAttributes & import("vue").ReservedProps>> & (typeof globalThis extends {
|
|
19
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
20
|
+
} ? P : {});
|
|
21
|
+
expose: (exposed: {}) => void;
|
|
22
|
+
attrs: any;
|
|
23
|
+
slots: {
|
|
24
|
+
item?: (props: {
|
|
25
|
+
item: T;
|
|
26
|
+
index: number;
|
|
27
|
+
}) => unknown;
|
|
28
|
+
trailing?: (props: {
|
|
29
|
+
item: T;
|
|
30
|
+
index: number;
|
|
31
|
+
}) => unknown;
|
|
32
|
+
empty?: () => unknown;
|
|
33
|
+
};
|
|
34
|
+
emit: ((evt: "move", move: {
|
|
35
|
+
item: T;
|
|
36
|
+
from: number;
|
|
37
|
+
to: number;
|
|
38
|
+
}) => void) & ((event: "update:modelValue", value: T[]) => void);
|
|
39
|
+
}>) => import("vue").VNode & {
|
|
40
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
41
|
+
};
|
|
42
|
+
declare const _default: typeof __VLS_export;
|
|
43
|
+
export default _default;
|
|
44
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
45
|
+
[K in keyof T]: T[K];
|
|
46
|
+
} : {
|
|
47
|
+
[K in keyof T as K]: T[K];
|
|
48
|
+
}) & {};
|
|
@@ -111,10 +111,17 @@
|
|
|
111
111
|
<tr
|
|
112
112
|
v-for="(row, index) in rows"
|
|
113
113
|
:key="keyOf(row, index)"
|
|
114
|
+
:draggable="isDraggable(row, index) ? 'true' : void 0"
|
|
115
|
+
v-bind="rowAttrs?.(row, index)"
|
|
114
116
|
class="k-table-row"
|
|
115
|
-
:class="{
|
|
117
|
+
:class="{
|
|
118
|
+
'is-selected': isSelected(row, index),
|
|
119
|
+
'is-dragging': draggedKeys.has(keyOf(row, index))
|
|
120
|
+
}"
|
|
116
121
|
:style="{ '--k-row-delay': rowDelay(index, stagger ? void 0 : 0) }"
|
|
117
122
|
@click="onRowClick(row, index, $event)"
|
|
123
|
+
@dragstart="onRowDragStart(row, index, $event)"
|
|
124
|
+
@dragend="onRowDragEnd(row, $event)"
|
|
118
125
|
>
|
|
119
126
|
<td v-if="selectable" class="k-table-check-cell" @click.stop>
|
|
120
127
|
<label class="k-table-check-hit">
|
|
@@ -148,6 +155,7 @@
|
|
|
148
155
|
v-else-if="column.key === linkColumnKey && rowLinks.has(row)"
|
|
149
156
|
v-bind="rowLinks.get(row).attrs"
|
|
150
157
|
class="k-table-link"
|
|
158
|
+
:draggable="isDraggable(row, index) ? 'false' : void 0"
|
|
151
159
|
@click.stop
|
|
152
160
|
>
|
|
153
161
|
<slot
|
|
@@ -216,9 +224,13 @@ const props = defineProps({
|
|
|
216
224
|
stickyHeader: { type: Boolean, required: false, default: true },
|
|
217
225
|
maxHeight: { type: String, required: false },
|
|
218
226
|
bordered: { type: Boolean, required: false, default: true },
|
|
219
|
-
stagger: { type: Boolean, required: false, default: true }
|
|
227
|
+
stagger: { type: Boolean, required: false, default: true },
|
|
228
|
+
rowAttrs: { type: Function, required: false },
|
|
229
|
+
rowDraggable: { type: [Boolean, Function], required: false },
|
|
230
|
+
dragData: { type: Function, required: false },
|
|
231
|
+
dragEffect: { type: null, required: false, default: "move" }
|
|
220
232
|
});
|
|
221
|
-
const emit = defineEmits(["rowClick"]);
|
|
233
|
+
const emit = defineEmits(["rowClick", "rowDragStart", "rowDragEnd"]);
|
|
222
234
|
defineSlots();
|
|
223
235
|
const sort = defineModel("sort", { type: [Object, null], ...{ default: null } });
|
|
224
236
|
const selected = defineModel("selected", { type: Array, ...{ default: () => [] } });
|
|
@@ -372,6 +384,34 @@ function onRowClick(row, index, event) {
|
|
|
372
384
|
})
|
|
373
385
|
);
|
|
374
386
|
}
|
|
387
|
+
function isDraggable(row, index) {
|
|
388
|
+
const draggable = props.rowDraggable;
|
|
389
|
+
if (!draggable || !props.dragData) return false;
|
|
390
|
+
return draggable === true || draggable(row, index);
|
|
391
|
+
}
|
|
392
|
+
const draggedKeys = ref(/* @__PURE__ */ new Set());
|
|
393
|
+
let draggedRows = [];
|
|
394
|
+
function onRowDragStart(row, index, event) {
|
|
395
|
+
if (!isDraggable(row, index) || !event.dataTransfer || !props.dragData) return;
|
|
396
|
+
const rows = props.selectable && isSelected(row, index) ? props.rows.filter((entry, position) => isSelected(entry, position)) : [row];
|
|
397
|
+
const data = props.dragData(row, rows);
|
|
398
|
+
if (!data) {
|
|
399
|
+
event.preventDefault();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
for (const [type, value] of Object.entries(data)) event.dataTransfer.setData(type, value);
|
|
403
|
+
event.dataTransfer.effectAllowed = props.dragEffect;
|
|
404
|
+
draggedRows = rows;
|
|
405
|
+
draggedKeys.value = new Set(rows.map((entry) => keyOf(entry, props.rows.indexOf(entry))));
|
|
406
|
+
emit("rowDragStart", { row, rows, event });
|
|
407
|
+
}
|
|
408
|
+
function onRowDragEnd(row, event) {
|
|
409
|
+
if (!draggedKeys.value.size) return;
|
|
410
|
+
const rows = draggedRows;
|
|
411
|
+
draggedRows = [];
|
|
412
|
+
draggedKeys.value = /* @__PURE__ */ new Set();
|
|
413
|
+
emit("rowDragEnd", { row, rows, event });
|
|
414
|
+
}
|
|
375
415
|
const skeletonWidths = [72, 48, 60, 36, 54, 66, 42];
|
|
376
416
|
function skeletonWidth(rowIndex, columnIndex) {
|
|
377
417
|
return `${skeletonWidths[(rowIndex + columnIndex * 3) % skeletonWidths.length]}%`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LinkTarget } from '../core/types';
|
|
2
|
-
import type { RowKey, TableColumn, TableDensity, TableSort } from './types';
|
|
2
|
+
import type { RowKey, TableColumn, TableDensity, TableDragData, TableRowAttrs, TableRowDrag, TableSort } from './types';
|
|
3
3
|
declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
4
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
5
5
|
rows: T[];
|
|
@@ -22,11 +22,17 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
22
22
|
maxHeight?: string;
|
|
23
23
|
bordered?: boolean;
|
|
24
24
|
stagger?: boolean;
|
|
25
|
+
rowAttrs?: (row: T, index: number) => TableRowAttrs;
|
|
26
|
+
rowDraggable?: boolean | ((row: T, index: number) => boolean);
|
|
27
|
+
dragData?: (row: T, rows: T[]) => TableDragData | null | undefined;
|
|
28
|
+
dragEffect?: DataTransfer["effectAllowed"];
|
|
25
29
|
} & {
|
|
26
30
|
sort?: TableSort | null;
|
|
27
31
|
selected?: RowKey[];
|
|
28
32
|
}) & {
|
|
29
33
|
onRowClick?: ((row: T, index: number, event: MouseEvent) => any) | undefined;
|
|
34
|
+
onRowDragStart?: ((drag: TableRowDrag<T>) => any) | undefined;
|
|
35
|
+
onRowDragEnd?: ((drag: TableRowDrag<T>) => any) | undefined;
|
|
30
36
|
"onUpdate:sort"?: ((value: TableSort | null) => any) | undefined;
|
|
31
37
|
"onUpdate:selected"?: ((value: RowKey[]) => any) | undefined;
|
|
32
38
|
} & Partial<import("vue").HTMLAttributes & import("vue").ReservedProps>> & (typeof globalThis extends {
|
|
@@ -48,7 +54,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
48
54
|
} & {
|
|
49
55
|
empty?: () => unknown;
|
|
50
56
|
};
|
|
51
|
-
emit: ((evt: "rowClick", row: T, index: number, event: MouseEvent) => void) & (((event: "update:sort", value: TableSort | null) => void) & ((event: "update:selected", value: RowKey[]) => void));
|
|
57
|
+
emit: (((evt: "rowClick", row: T, index: number, event: MouseEvent) => void) & ((evt: "rowDragStart", drag: TableRowDrag<T>) => void) & ((evt: "rowDragEnd", drag: TableRowDrag<T>) => void)) & (((event: "update:sort", value: TableSort | null) => void) & ((event: "update:selected", value: RowKey[]) => void));
|
|
52
58
|
}>) => import("vue").VNode & {
|
|
53
59
|
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
54
60
|
};
|