@xleddyl/443-components-vue 0.16.92 → 0.16.93

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 CHANGED
@@ -113,7 +113,7 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
113
113
  | Dashboard layout with sidebar, search, account and settings | `DashboardLayout` (or the Nuxt layout `k-dashboard`) |
114
114
  | Actions in a settings section header ("Add user") | `#actions-<id>` on `SettingsModal`, `#settings-actions-<id>` on `DashboardLayout` (gets `page`, `openPage`, `back`) |
115
115
  | Tabs in a settings section header, like a drawer | `#tabs-<id>` on `SettingsModal`, `#settings-tabs-<id>` on `DashboardLayout`: put a `Tabs` `variant="underline"` `size="sm"` in it |
116
- | Page that fills the panel height (a full height grid) | `content="fill"` or `"centered"` on `DashboardLayout` / `AppShell`, `definePageMeta({ content: 'fill' })` |
116
+ | Page that fills the panel height (a full height grid) | `content="fill"` or `"centered"` on `DashboardLayout` / `AppShell`, `definePageMeta({ content: 'fill' })`, with `DataGrid fill` or `ListPage fill` |
117
117
  | Custom app frame with your own sidebar | `AppShell` + `Sidebar` + `SidebarNav` |
118
118
  | Login, sign up, reset password page | `AuthLogin` + `AuthLogout` (two step flow); `AuthLayout` (or `k-auth`) for other pages |
119
119
  | Settings in a modal (account, appearance, your sections) | `SettingsModal` (the `DashboardLayout` embeds it) |
@@ -218,7 +218,7 @@ Mount `OverlayHost` once for the imperative hooks (see [Composables](#composable
218
218
  | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
219
219
  | `Table` | Small to medium table with sort, selection, links and loading rows. For thousands of rows or editing use `DataGrid`. | Models: `v-model:sort` (`{ key, direction }`), `v-model:selected` (row keys). Props: `rows`, `columns` (`key`, `label`, `align`, `width`, `numeric`, `sortable`, `value`, `format`), `rowKey`, `selectable`, `rowTo`, `loading`, `emptyText`, `density`, `stickyHeader`, `maxHeight`, `bordered`, `caption`. Slots: `cell-<key>`, `header-<key>`, `empty`. Event: `rowClick`. | `data/table.vue` |
220
220
  | `Pagination` | Page buttons, page size select and summary. Client or server paging. | Models: `v-model:page`, `v-model:pageSize`. Props: `total`, `pageSizes` (numbers, `'all'` for every row), `allLabel`, `showEdges`, `showJump`, `compact`, `loading`, `showSummary`. Slot: `summary`. | `data/pagination.vue` |
221
- | `SelectionBar` | Shows the selected count and bulk actions for a list or table. | Props: `count`, `total`, `placement` (inline, sticky, floating), `onSelectAll`, `onClear`. Slots: `actions`, `count`. With `count` 0 it renders nothing visible. | `data/selection-bar.vue` |
221
+ | `SelectionBar` | Shows the selected count and bulk actions for a list or table. | Props: `count`, `total`, `placement` (inline, sticky, floating), `onSelectAll` (may return a promise: spinner), `onClear`. With everything selected, select all becomes "Clear selection". Slots: `actions`, `count`. With `count` 0 it renders nothing visible. | `data/selection-bar.vue` |
222
222
  | `FilterPills` | Quick filters as pills: single, multiple, menu or panel pills, removable active filters. | Model: value, array (`multiple`) or null. Props: `options` (`value`, `label`, `valueLabel`, `count`, `icon`, `color`, `menu`, `panel`, `removable`), `multiple`, `required`, `clearable`, `size`. Slots: `pill`, `panel-<value>`. Events: `select`, `remove`. | `data/filter-pills.vue` |
223
223
  | `FilterPill` | One pill button. Use it alone for a custom filter trigger. `FilterPills` uses it. | Props: `label`, `valueLabel`, `icon`, `count`, `active`, `pressed`, `caret`, `size`, `disabled`. Slot: default. | `data/filter-pills.vue` |
224
224
  | `Tag` | Chip or label, optionally removable. Use `Badge` for a status. | Props: `label`, `tone`, `color` (palette name or hex), `size`, `icon`, `removable`, `removeLabel`, `removeTabindex`, `disabled`. Slot: default. Event: `remove`. | `data/tag.vue` |
@@ -278,7 +278,7 @@ Templates combine core parts into whole pages and layouts. Start from them for n
278
278
  | `AuthLayout` | Frame of sign in, sign up and reset password pages: left column with brand, title (or a large breadcrumb), form and footer; aside panel on the right from 960px. | Props: `title`, `description`, `breadcrumbs`, `footer`, `brandName`, `brandIcon`, `brandLogo`, `aside`, `asideTitle`, `asideDescription`, `themeSwitch`. Slots: default, `links`, `footer`, `brand`, `aside`, `corner`. | `templates/auth-layout.vue` |
279
279
  | `AuthLogin` | Complete sign in page in two steps (email, then password with a breadcrumb back). Offers to sign in again after `AuthLogout`. | Props: `submit` (`{ email, password }`), `submitError`, `title`, `description`, `emailLabel`, `emailPlaceholder`, `passwordLabel`, `submitLabel`, `stepKey`, `reasonKey`, frame props of `AuthLayout`. Slots: `links` (`{ email, step }`), `footer`, `brand`, `aside`, `corner`. | `templates/auth-login.vue` |
280
280
  | `AuthLogout` | Sign out page: runs `logout()`, remembers the account, reloads the sign in page. Retry on error. | Props: `logout`, `account` (`{ email, name }`), `loginTo`, `reasonKey`, frame props of `AuthLayout`. Slots: `footer`, `brand`, `aside`, `corner`. Helpers: `rememberSignedOutAccount`, `takeSignedOutAccount`, `SIGNED_OUT_REASON`. | `templates/auth-login.vue` |
281
- | `ListPage` | Whole list page: header, search, filters, table, pagination, bulk actions, loading, empty, no results and error states. Client or server mode (`total`). | Models: `page`, `pageSize`, `search`, `filter`, `sort`, `selected`. Props: `title`, `rows`, `columns`, `rowKey`, `rowTo`, `selectable`, `loading`, `error`, `total`, `paginate`, `searchable`, `searchKeys`, `filters`, `filterKey`, `filterMultiple`, `filtered` (filters of your own in `#toolbar` are active: no rows show no results with the toolbar and a clear button that emits `clear`, not the first run empty state), `emptyTitle`. Slots: `actions`, `toolbar`, `toolbar-end`, `bulk`, `empty`, `empty-actions`, `no-results`, `error`, `cell-<key>`, `table`. Events: `retry`, `clear`, `rowClick`. | `templates/list-page.vue` |
281
+ | `ListPage` | Whole list page: header, search, filters, table, pagination, bulk actions, loading, empty, no results and error states. Client or server mode (`total`). | Models: `page`, `pageSize`, `search`, `filter`, `sort`, `selected`. Props: `title`, `rows`, `columns`, `rowKey`, `rowTo`, `selectable`, `loading`, `error`, `total`, `paginate`, `searchable`, `searchKeys`, `filters`, `filterKey`, `filterMultiple`, `filtered` (filters of your own in `#toolbar` are active: no rows show no results with the toolbar and a clear button that emits `clear`, not the first run empty state), `fill` (the card fills the page height, for `content: 'fill'` pages: rows scroll under a sticky header, footer pinned, states centered), `count` (a badge next to the title: `true` for `total` or the row count, or a number), `allIds` (server mode "Select all N" in the selection bar; client mode selects every filtered row without it), `selectedText`, `emptyTitle`. Slots: `actions`, `badge`, `toolbar`, `toolbar-end`, `bulk`, `empty`, `empty-actions`, `no-results`, `error`, `cell-<key>`, `table`. Events: `retry`, `clear`, `rowClick`. | `templates/list-page.vue` |
282
282
  | `DetailPage` | Record page: back link, title, status, actions, tabs, main column and aside with description lists. | Model: `v-model:tab`. Props: `title`, `backTo`, `backLabel`, `status` (`label`, `tone`, `dot`), `tabs`, `sections` (`title`, `items`), `loading`, `error`. Slots: default, `actions`, `badge`, `meta`, `aside`, `aside-before`, `panel-<value>`. | `templates/detail-page.vue` |
283
283
  | `FormDrawer` | Drawer with a form: `Form` around the body, footer with delete (left), cancel and submit, a discard confirmation on close when the form is dirty, `SkeletonForm` while `loading`. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `side`, `size`, `fill` (full height body), `tabs` (`FormDrawerTab`: `fields` gives the error dot and opens the tab on a failed submit, `fill: true` makes the drawer `fill` while the tab is active), `tabRoute` (keeps the tab in the hash under this key), `trail`, `backLabel`, `form`, `loading`, `readonly` (also disables every field of the body, your own `Form` in the slot too), `creating` (submit says Create, no dirty needed), `requireDirty`, `deletable`, `deleteDisabled`, `deleteHint`, `submitLabel`, `cancelLabel`, `deleteLabel`, `submitIcon` (icon of the submit button), `deleteIcon` (default `trash`), `guard`, `guardTitle`, `guardMessage` (the leave guard of the drawer: close, cancel, trail navigation), `beforeClose`, `onCancel`. `deleteHint` is a tooltip of the delete button, and the reason when `deleteDisabled`. Slots: default (`{ tab }`), `actions`, `title-trailing`, `skeleton`, `footer`. Events: `delete`, `submitted`, `navigate`, `afterLeave`. Exposes `confirmDiscard()`, `close()`. | `templates/form-drawer.vue` |
284
284
  | `FormModal` | Modal with a form, like `FormDrawer`: `Form` around the body, footer with delete (left), cancel and submit, the leave guard on close, `SkeletonForm` while `loading`, `readonly`. | Model: `v-model:open`. Props: `title`, `description`, `label`, `size`, `sheet`, `width`, `fill`, `dismissible`, `form`, `nested` (the form is a `div`: a modal opened from a field of another form), `loading`, `readonly`, `creating`, `requireDirty`, `deletable`, `deleteDisabled`, `deleteHint`, `submitLabel`, `cancelLabel`, `deleteLabel`, `submitIcon` (icon of the submit button), `deleteIcon` (default `trash`), `guard`, `guardTitle`, `guardMessage`, `beforeClose`, `onCancel`. Slots: default, `actions`, `title-trailing`, `skeleton`, `footer` (`{ submit, cancel }`). Events: `delete`, `submitted`, `open`, `close`, `afterLeave`. Exposes `submit()`, `confirmDiscard()`, `close()`. | `templates/form-modal.vue` |
package/README.md CHANGED
@@ -541,7 +541,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
541
541
  - `RichTextEditor` accepts `'underline'` in `toolbar` (not in the default toolbar).
542
542
  - `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.
543
543
  - `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`.
544
- - `SelectionBar` shows a plural aware selected count (announced in a live region), select all (`total` plus `@select-all`) and clear (`@clear`) actions, an `#actions` slot and `placement` `inline`, `sticky` or `floating`. With `count` 0 it renders no box (only its live region), so it can sit in a flex toolbar without adding a gap; the first count after mount is announced too. `ListPage` renders it for `#bulk`.
544
+ - `SelectionBar` shows a plural aware selected count (announced in a live region), select all (`total` plus `@select-all`; a listener that returns a promise shows a spinner until it settles) and clear (`@clear`) actions (with `@select-all` and `count` at `total`, the select all action becomes a "Clear selection" button in place of the clear icon), an `#actions` slot and `placement` `inline`, `sticky` or `floating`. With `count` 0 it renders no box (only its live region), so it can sit in a flex toolbar without adding a gap; the first count after mount is announced too. `ListPage` renders it in its toolbar when `selectable`.
545
545
  - `FilterPills` is generic: the value type comes from the options, `multiple` makes the model an array and `required` drops `null` from it (like `SegmentedControl`). Options take `menu` items (a dropdown trigger showing `valueLabel`) or `panel: true`, which opens a popover with the `#panel-<value>` slot (`{ option, active, toggle, close }`, `panelLabel` names it). The `#pill` slot renders any trigger and its scope has `defaultPill`, a component that renders the built-in pill for that option, so one custom pill does not mean rewriting the others: `<component :is="defaultPill" v-else />`. `FilterPill` is exported so custom triggers match the other pills.
546
546
  - `SegmentedControl` with `required` narrows `v-model` to a non null value. Options take `title` (tooltip and description) and `muted`, and the `#option` slot replaces the content of each option.
547
547
  - `FileInput` takes `directory` (folder picker; dropped folders are walked, every file keeps its relative path) or `directory="drop"` (the click opens a file picker, dropped folders are still walked), `directoryAction` (an "Upload a folder" button under the dropzone, `directoryActionLabel` renames it) or the `#actions` slot (`{ browse, browseDirectory, disabled }`), `skipHidden` (ignores dot files and dot folders), `list: false` (no file list: picks and drops only emit `add`), `fill` (the dropzone fills the height of its flex column parent, with the icon and the text centered: an import screen), `loading` and the `#hint` slot. `add` receives `(files, { entries: [{ file, path }], directories, source, event, dataTransfer })`; `directories` lists every folder path of a folder pick or drop, empty folders included, and `add` also fires for a drop of empty folders. `invalid` fires per file and `reject` once with every rejected file (`(events, detail)`). `acceptMode="hint"` only passes `accept` to the picker and leaves filtering to the host. The component exposes `browse()`, `browseDirectory()`, `addFiles()` and `focus()`.
@@ -860,17 +860,17 @@ Both take the `AuthLayout` frame props and the `brand`, `corner`, `footer` and `
860
860
 
861
861
  ### Page templates
862
862
 
863
- | Component | What it gives you |
864
- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
865
- | `DashboardPage` | PageHeader (`title`, `eyebrow`, `description`, `#actions`), a Stat grid from `stats` (or `#stats`), a content grid (`columns`, default 1 then 3 columns). |
866
- | `ListPage` | Header, toolbar (search with `searchable`, FilterPills from `filters`, `#toolbar`, `#bulk` when rows are selected), Table from `columns`/`rows`, Pagination. Client mode filters (`searchKeys`, `filterKey`), sorts and paginates; pass `total` for server mode. States: `loading` skeleton rows, first run `#empty`, no results with a clear button, `error` with retry. Filters of your own in `#toolbar` (a Select, a date range) set `filtered` while they are active: no rows then show the no results state with the toolbar still visible instead of the first run `#empty`, and the clear button (or `clear` of `#no-results`) emits `clear`, where you reset them. `cell-*` and `header-*` slots go to the Table. |
867
- | `DetailPage` | Back link (`backTo`), title, `status` badge, `#actions`, optional `tabs` (`#panel-<value>`), main column plus an aside with DescriptionList cards from `sections` (or `#aside`). `loading` and `error` states. |
868
- | `FormDrawer` | A `Drawer` with a `Form` (`form` from `useForm`) around the body and a footer: delete on the left (`deletable`, `@delete`, `deleteDisabled`, `deleteHint`), cancel and submit on the right. `creating` changes the submit text to Create and enables it without changes; otherwise it needs a dirty form (`requireDirty`). `readonly` keeps only a Close button and disables every field of the body (see [Forms](#forms)). Every close asks before discarding a dirty form (`guard`, the leave guard of its `Drawer`), then runs `beforeClose`. `deleteHint` is the tooltip of the delete button, and its reason when `deleteDisabled`. `submitIcon` adds an icon to the submit button (`check`, `plus`, `printer`), `deleteIcon` changes the delete icon (default `trash`). `onCancel` replaces the close of the cancel button (back to a parent view), after the same question. `loading` shows a `SkeletonForm` (or `#skeleton`) and keeps the header, the tabs and the footer in place. Pass another `form` to switch the body to a subpage (with `trail`). A tab with `fill: true` (`FormDrawerTab`) makes the drawer `fill` while it is active (a tab with a long table). |
869
- | `FormModal` | The modal version of `FormDrawer`: a `Modal` with a `Form` around the body, footer with delete (`deletable`, `deleteDisabled`, `deleteHint`, `deleteIcon`), cancel (ghost) and submit (`creating`, `requireDirty`, `submitting` state, `submitIcon`), the leave guard on close and cancel, `loading` skeleton, `readonly`. `nested` renders the form as a `div`, for a modal opened from a field of another form (its footer submit then calls `submit()`). `@submitted` fires after a successful submit. |
870
- | `FormPage` | Header, your cards inside `Form` (`form` from `useForm`, or a plain `form` emitting `submit`), sticky footer with cancel and submit, unsaved state, dirty guard (`guard`, on by default) through `useDirtyGuard`. |
871
- | `SettingsPage`, `SettingsSection`, `SaveBar` | Section nav (sticky on the left, a scrolling row on narrow screens; items with `to` become route links), `#section-<value>` panels, section cards with a save footer, and a floating save bar while `dirty`. |
872
- | `ErrorPage`, `NotFoundPage` | Status code, title, message (defaults per status code, reads a Nuxt `error`), home, retry (`@retry`) and back actions. `@home` replaces the home link, handy for `clearError`. |
873
- | `EmptyPage` | First run screen: illustration, title, description, primary and secondary actions, onboarding `steps`. |
863
+ | Component | What it gives you |
864
+ | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
865
+ | `DashboardPage` | PageHeader (`title`, `eyebrow`, `description`, `#actions`), a Stat grid from `stats` (or `#stats`), a content grid (`columns`, default 1 then 3 columns). |
866
+ | `ListPage` | Header, toolbar (search with `searchable`, FilterPills from `filters`, `#toolbar`, `#bulk` when rows are selected), Table from `columns`/`rows`, Pagination. Client mode filters (`searchKeys`, `filterKey`), sorts and paginates; pass `total` for server mode. States: `loading` skeleton rows, first run `#empty`, no results with a clear button, `error` with retry. Filters of your own in `#toolbar` (a Select, a date range) set `filtered` while they are active: no rows then show the no results state with the toolbar still visible instead of the first run `#empty`, and the clear button (or `clear` of `#no-results`) emits `clear`, where you reset them. `cell-*` and `header-*` slots go to the Table. `fill` makes the card take the rest of the height of its parent (a page with `content: 'fill'`, or any flex parent with a height): the rows scroll inside the card under the sticky header row, the footer (summary and pagination) stays at the bottom even with few rows, the first run, error and no results states are centered in the same height, and a custom `#table` scrolls in the same area. It stays on at every width (like `content="fill"` and `DataGrid` `fill`); the card keeps a 20rem minimum height, so on a short screen the panel scrolls instead of squeezing the rows. An `EmptyPage` in `#empty` fills by itself. `count` shows the number of rows in a `Badge` next to the title (`true`: `total` in server mode, `rows.length` in client mode, hidden while the first load, the first run empty state or an error shows; a number: that number); `#badge` (scope `{ total }`, the result count) replaces it. With `selectable` the selection bar counts against the result total (`3 of 42 selected`) and, like the `DataGrid` footer link, offers "Select all N" once every row of the page is selected and more rows match: in client mode it selects every filtered row (across pages), in server mode it needs `allIds` (`() => Promise<readonly RowKey[]> | readonly RowKey[]`), awaits it with a spinner and sets `v-model:selected` to the returned ids (a rejected promise keeps the selection and logs an error). With every row selected the action becomes "Clear selection". |
867
+ | `DetailPage` | Back link (`backTo`), title, `status` badge, `#actions`, optional `tabs` (`#panel-<value>`), main column plus an aside with DescriptionList cards from `sections` (or `#aside`). `loading` and `error` states. |
868
+ | `FormDrawer` | A `Drawer` with a `Form` (`form` from `useForm`) around the body and a footer: delete on the left (`deletable`, `@delete`, `deleteDisabled`, `deleteHint`), cancel and submit on the right. `creating` changes the submit text to Create and enables it without changes; otherwise it needs a dirty form (`requireDirty`). `readonly` keeps only a Close button and disables every field of the body (see [Forms](#forms)). Every close asks before discarding a dirty form (`guard`, the leave guard of its `Drawer`), then runs `beforeClose`. `deleteHint` is the tooltip of the delete button, and its reason when `deleteDisabled`. `submitIcon` adds an icon to the submit button (`check`, `plus`, `printer`), `deleteIcon` changes the delete icon (default `trash`). `onCancel` replaces the close of the cancel button (back to a parent view), after the same question. `loading` shows a `SkeletonForm` (or `#skeleton`) and keeps the header, the tabs and the footer in place. Pass another `form` to switch the body to a subpage (with `trail`). A tab with `fill: true` (`FormDrawerTab`) makes the drawer `fill` while it is active (a tab with a long table). |
869
+ | `FormModal` | The modal version of `FormDrawer`: a `Modal` with a `Form` around the body, footer with delete (`deletable`, `deleteDisabled`, `deleteHint`, `deleteIcon`), cancel (ghost) and submit (`creating`, `requireDirty`, `submitting` state, `submitIcon`), the leave guard on close and cancel, `loading` skeleton, `readonly`. `nested` renders the form as a `div`, for a modal opened from a field of another form (its footer submit then calls `submit()`). `@submitted` fires after a successful submit. |
870
+ | `FormPage` | Header, your cards inside `Form` (`form` from `useForm`, or a plain `form` emitting `submit`), sticky footer with cancel and submit, unsaved state, dirty guard (`guard`, on by default) through `useDirtyGuard`. |
871
+ | `SettingsPage`, `SettingsSection`, `SaveBar` | Section nav (sticky on the left, a scrolling row on narrow screens; items with `to` become route links), `#section-<value>` panels, section cards with a save footer, and a floating save bar while `dirty`. |
872
+ | `ErrorPage`, `NotFoundPage` | Status code, title, message (defaults per status code, reads a Nuxt `error`), home, retry (`@retry`) and back actions. `@home` replaces the home link, handy for `clearError`. |
873
+ | `EmptyPage` | First run screen: illustration, title, description, primary and secondary actions, onboarding `steps`. |
874
874
 
875
875
  `useDirtyGuard(dirty, options?)` asks before leaving (router navigation through `ConfirmHost`, or the native confirm) and on tab close. Returns `confirmLeave()` and `allowNext()`. It is built on the leave guard, see [Unsaved changes](#unsaved-changes).
876
876
 
@@ -19,19 +19,20 @@
19
19
  <slot name="count" :count="count" :total="total">{{ countText }}</slot>
20
20
  </span>
21
21
  <Button
22
- v-if="onSelectAll && total !== void 0 && count < total"
22
+ v-if="allAction"
23
23
  class="k-selection-bar-all"
24
24
  variant="ghost"
25
25
  tone="neutral"
26
26
  size="xs"
27
- :label="selectAllText"
28
- @click="onSelectAll"
27
+ :label="allAction === 'clear' ? clearText : selectAllText"
28
+ :loading="selectingAll"
29
+ @click="runAllAction"
29
30
  />
30
31
  <div v-if="$slots.actions" class="k-selection-bar-actions">
31
32
  <slot name="actions" :count="count" />
32
33
  </div>
33
34
  <Button
34
- v-if="onClear"
35
+ v-if="onClear && allAction !== 'clear'"
35
36
  class="k-selection-bar-clear"
36
37
  variant="ghost"
37
38
  tone="neutral"
@@ -76,6 +77,25 @@ const countText = computed(() => {
76
77
  return t("selectionBar.selectedOf", { count: props.count, total: props.total });
77
78
  return t("common.selected", { count: props.count });
78
79
  });
80
+ const allAction = computed(() => {
81
+ if (!props.onSelectAll || props.total === void 0) return void 0;
82
+ if (props.count < props.total) return "select";
83
+ return props.onClear ? "clear" : void 0;
84
+ });
85
+ const selectingAll = ref(false);
86
+ async function runAllAction() {
87
+ if (allAction.value === "clear") {
88
+ props.onClear?.();
89
+ return;
90
+ }
91
+ if (selectingAll.value) return;
92
+ selectingAll.value = true;
93
+ try {
94
+ await props.onSelectAll?.();
95
+ } finally {
96
+ selectingAll.value = false;
97
+ }
98
+ }
79
99
  const announcement = ref("");
80
100
  const mounted = ref(false);
81
101
  watch(
@@ -17,7 +17,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
17
17
  selectAllLabel?: string;
18
18
  clearLabel?: string;
19
19
  clearedText?: string;
20
- onSelectAll?: () => void;
20
+ onSelectAll?: () => unknown;
21
21
  onClear?: () => void;
22
22
  innerHTML?: string | undefined | undefined;
23
23
  class?: import("vue").ClassValue;
@@ -220,7 +220,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
220
220
  selectAllLabel?: string;
221
221
  clearLabel?: string;
222
222
  clearedText?: string;
223
- onSelectAll?: () => void;
223
+ onSelectAll?: () => unknown;
224
224
  onClear?: () => void;
225
225
  innerHTML?: string | undefined | undefined;
226
226
  class?: import("vue").ClassValue;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="k-page k-list-page">
2
+ <div class="k-page k-list-page" :class="{ 'is-fill': fill }">
3
3
  <PageHeader
4
4
  :title="title"
5
5
  :description="description"
@@ -7,6 +7,11 @@
7
7
  :breadcrumbs="breadcrumbs"
8
8
  :level="level"
9
9
  >
10
+ <template v-if="$slots.badge || countValue !== void 0" #badge>
11
+ <slot name="badge" :total="resultTotal">
12
+ <Badge v-if="countValue !== void 0">{{ countText }}</Badge>
13
+ </slot>
14
+ </template>
10
15
  <template v-if="$slots.actions" #actions><slot name="actions" /></template>
11
16
  </PageHeader>
12
17
 
@@ -20,6 +25,7 @@
20
25
  :title="errorText"
21
26
  :description="typeof error === 'string' ? error : void 0"
22
27
  :level="childLevel"
28
+ :fill="fill"
23
29
  >
24
30
  <template #actions>
25
31
  <Button
@@ -42,6 +48,7 @@
42
48
  :title="emptyTitleText"
43
49
  :description="emptyDescription"
44
50
  :level="childLevel"
51
+ :fill="fill"
45
52
  >
46
53
  <template v-if="$slots['empty-actions']" #actions>
47
54
  <slot name="empty-actions" />
@@ -80,7 +87,9 @@
80
87
  v-if="selectable"
81
88
  class="k-list-selection"
82
89
  :count="selected.length"
83
- :selected-text="selectedLabel"
90
+ :total="resultTotal"
91
+ :selected-text="selectedText"
92
+ :on-select-all="canSelectAll ? selectAll : void 0"
84
93
  :on-clear="clearSelection"
85
94
  >
86
95
  <template v-if="$slots.bulk" #actions>
@@ -91,7 +100,10 @@
91
100
  </div>
92
101
  </div>
93
102
 
94
- <slot name="table" :rows="visibleRows" :loading="loading">
103
+ <div v-if="fill && $slots.table" class="k-list-scroll">
104
+ <slot name="table" :rows="visibleRows" :loading="loading" />
105
+ </div>
106
+ <slot v-else name="table" :rows="visibleRows" :loading="loading">
95
107
  <Table
96
108
  v-model:sort="sort"
97
109
  v-model:selected="selected"
@@ -165,7 +177,9 @@ import { useLocale } from "../../composables/useLocale";
165
177
  import Button from "../core/Button.vue";
166
178
  import { createCollator, readCell, sortRows } from "../../internal/data/rows";
167
179
  import { normalizeSearch } from "../../internal/core/text";
180
+ import { numberFormat } from "../../internal/core/intl";
168
181
  import Input from "../core/Input.vue";
182
+ import Badge from "../data/Badge.vue";
169
183
  import FilterPills from "../data/FilterPills.vue";
170
184
  import Pagination from "../data/Pagination.vue";
171
185
  import SelectionBar from "../data/SelectionBar.vue";
@@ -180,6 +194,7 @@ const props = defineProps({
180
194
  icon: { type: null, required: false },
181
195
  breadcrumbs: { type: Array, required: false },
182
196
  level: { type: Number, required: false, default: 1 },
197
+ count: { type: [Number, Boolean], required: false },
183
198
  rows: { type: Array, required: false, default: () => [] },
184
199
  columns: { type: Array, required: false },
185
200
  rowKey: { type: [String, Function], required: false, default: "id" },
@@ -189,6 +204,7 @@ const props = defineProps({
189
204
  selectable: { type: Boolean, required: false },
190
205
  density: { type: String, required: false, default: "normal" },
191
206
  stickyHeader: { type: Boolean, required: false, default: true },
207
+ fill: { type: Boolean, required: false },
192
208
  loading: { type: Boolean, required: false },
193
209
  error: { type: [String, Boolean], required: false },
194
210
  total: { type: Number, required: false },
@@ -212,6 +228,7 @@ const props = defineProps({
212
228
  clearLabel: { type: String, required: false },
213
229
  errorTitle: { type: String, required: false },
214
230
  retryLabel: { type: String, required: false },
231
+ allIds: { type: Function, required: false },
215
232
  selectedText: { type: Function, required: false },
216
233
  resultsText: { type: Function, required: false }
217
234
  });
@@ -228,9 +245,6 @@ const clearText = computed(() => props.clearLabel ?? t("listPage.clearFilters"))
228
245
  const errorText = computed(() => props.errorTitle ?? t("common.somethingWentWrong"));
229
246
  const retryText = computed(() => props.retryLabel ?? t("common.retry"));
230
247
  const childLevel = computed(() => Math.min(props.level + 1, 6));
231
- function selectedLabel(count) {
232
- return props.selectedText ? props.selectedText(count) : t("common.selected", { count });
233
- }
234
248
  const emit = defineEmits(["retry", "clear", "rowClick"]);
235
249
  defineSlots();
236
250
  const page = defineModel("page", { type: Number, ...{ default: 1 } });
@@ -298,6 +312,31 @@ const visibleRows = computed(() => {
298
312
  const start = (page.value - 1) * pageSize.value;
299
313
  return sorted.value.slice(start, start + pageSize.value);
300
314
  });
315
+ function keyOf(row, index) {
316
+ if (typeof props.rowKey === "function") return props.rowKey(row, index);
317
+ const value = row[props.rowKey];
318
+ return typeof value === "string" || typeof value === "number" ? value : index;
319
+ }
320
+ const pageFullySelected = computed(() => {
321
+ if (!visibleRows.value.length) return false;
322
+ const keys = new Set(selected.value);
323
+ return visibleRows.value.every((row, index) => keys.has(keyOf(row, index)));
324
+ });
325
+ const canSelectAll = computed(
326
+ () => !props.loading && (!serverMode.value || Boolean(props.allIds)) && resultTotal.value > visibleRows.value.length && pageFullySelected.value
327
+ );
328
+ async function selectAll() {
329
+ if (!serverMode.value) {
330
+ selected.value = sorted.value.map((row, index) => keyOf(row, index));
331
+ return;
332
+ }
333
+ if (!props.allIds) return;
334
+ try {
335
+ selected.value = [...await props.allIds()];
336
+ } catch (reason) {
337
+ console.error("[@xleddyl/443-components-vue] ListPage allIds failed", reason);
338
+ }
339
+ }
301
340
  const isFirstRun = computed(
302
341
  () => !props.loading && !isFiltered.value && props.rows.length === 0 && (!serverMode.value || props.total === 0)
303
342
  );
@@ -306,6 +345,15 @@ function clearFilters() {
306
345
  filter.value = Array.isArray(filter.value) ? [] : null;
307
346
  emit("clear");
308
347
  }
348
+ const countValue = computed(() => {
349
+ if (typeof props.count === "number") return props.count;
350
+ if (!props.count || props.error || isFirstRun.value) return void 0;
351
+ if (props.loading && !props.rows.length) return void 0;
352
+ return serverMode.value ? props.total ?? 0 : props.rows.length;
353
+ });
354
+ const countText = computed(
355
+ () => countValue.value === void 0 ? "" : numberFormat(locale.value.code).format(countValue.value)
356
+ );
309
357
  const interacted = ref(false);
310
358
  watch([search, filterValues, () => props.filtered], () => {
311
359
  interacted.value = true;
@@ -9,6 +9,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
9
9
  icon?: IconName;
10
10
  breadcrumbs?: BreadcrumbItem[];
11
11
  level?: HeadingLevel;
12
+ count?: number | boolean;
12
13
  rows?: T[];
13
14
  columns?: TableColumn<T>[];
14
15
  rowKey?: string | ((row: T, index: number) => RowKey);
@@ -18,6 +19,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
18
19
  selectable?: boolean;
19
20
  density?: TableDensity;
20
21
  stickyHeader?: boolean;
22
+ fill?: boolean;
21
23
  loading?: boolean;
22
24
  error?: string | boolean;
23
25
  total?: number;
@@ -41,7 +43,8 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
41
43
  clearLabel?: string;
42
44
  errorTitle?: string;
43
45
  retryLabel?: string;
44
- selectedText?: (count: number) => string;
46
+ allIds?: () => Promise<readonly RowKey[]> | readonly RowKey[];
47
+ selectedText?: (count: number, total?: number) => string;
45
48
  resultsText?: (count: number) => string;
46
49
  } & {
47
50
  page?: number;
@@ -79,6 +82,9 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
79
82
  } & {
80
83
  default?: () => unknown;
81
84
  actions?: () => unknown;
85
+ badge?: (props: {
86
+ total: number;
87
+ }) => unknown;
82
88
  before?: () => unknown;
83
89
  toolbar?: () => unknown;
84
90
  'toolbar-end'?: () => unknown;
@@ -45,3 +45,41 @@
45
45
  .k-list-empty {
46
46
  padding-block: 3.5rem;
47
47
  }
48
+
49
+ .k-page.k-list-page.is-fill {
50
+ flex: 1 0 auto;
51
+ }
52
+
53
+ .k-list-page.is-fill > :is(.k-list-card, .k-list-state) {
54
+ flex: 1 1 0;
55
+ min-height: 20rem;
56
+ }
57
+
58
+ .k-list-page.is-fill > :is(.k-list-card, .k-list-state) > .k-card-body {
59
+ display: flex;
60
+ flex-direction: column;
61
+ min-height: 0;
62
+ }
63
+
64
+ .k-list-page.is-fill > .k-list-card > .k-card-body > :is(.k-table, .k-list-scroll) {
65
+ flex: 1 1 0;
66
+ min-height: 0;
67
+ }
68
+
69
+ .k-list-scroll {
70
+ overflow: auto;
71
+ overscroll-behavior: contain;
72
+ }
73
+
74
+ .k-list-page.is-fill .k-table-scroll {
75
+ display: flex;
76
+ flex-direction: column;
77
+ }
78
+
79
+ .k-list-page.is-fill .k-table-el {
80
+ flex: none;
81
+ }
82
+
83
+ .k-list-page.is-fill .k-table-el:has(> .k-table-body > .k-table-empty-row) {
84
+ flex: 1 0 auto;
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xleddyl/443-components-vue",
3
- "version": "0.16.92",
3
+ "version": "0.16.93",
4
4
  "description": "Compact, scoped dashboard components for Vue and Nuxt",
5
5
  "license": "MIT",
6
6
  "author": "Edoardo Alberti (https://github.com/xleddyl)",