@xleddyl/443-components-vue 0.16.70 → 0.16.72
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 +130 -127
- package/README.md +71 -16
- package/dist/components/core/Button.vue +67 -5
- package/dist/components/core/Button.vue.d.ts +9 -4
- package/dist/components/core/Form.vue +8 -2
- package/dist/components/core/Form.vue.d.ts +1 -0
- package/dist/components/core/Input.vue.d.ts +2 -2
- package/dist/components/data/RecordList.vue +29 -7
- package/dist/components/forms/ColorInput.vue.d.ts +2 -2
- package/dist/components/forms/DateInput.vue.d.ts +2 -2
- package/dist/components/forms/Fieldset.vue +16 -2
- package/dist/components/forms/Fieldset.vue.d.ts +3 -3
- package/dist/components/forms/NumberInput.vue.d.ts +2 -2
- package/dist/components/forms/PaletteSelect.vue.d.ts +4 -4
- package/dist/components/forms/PasswordInput.vue.d.ts +2 -2
- package/dist/components/forms/PinInput.vue.d.ts +2 -2
- package/dist/components/forms/Slider.vue.d.ts +2 -2
- package/dist/components/forms/TimeInput.vue.d.ts +2 -2
- package/dist/components/layout/Tabs.vue +10 -1
- package/dist/components/layout/ThemeSwitch.vue.d.ts +4 -0
- package/dist/components/overlays/CommandButton.vue +1 -0
- package/dist/components/overlays/ConfirmDialog.vue.d.ts +8 -2
- package/dist/components/overlays/ConfirmHost.vue.d.ts +8 -2
- package/dist/components/overlays/ContextMenu.vue.d.ts +2 -2
- package/dist/components/overlays/Drawer.vue +9 -1
- package/dist/components/overlays/Drawer.vue.d.ts +9 -0
- package/dist/components/overlays/Modal.vue +8 -0
- package/dist/components/overlays/Modal.vue.d.ts +9 -0
- package/dist/components/overlays/Tooltip.vue +3 -1
- package/dist/components/overlays/types.d.ts +2 -0
- package/dist/components/templates/AuthLogin.vue +4 -2
- package/dist/components/templates/FormDrawer.vue +18 -34
- package/dist/components/templates/FormDrawer.vue.d.ts +8 -1
- package/dist/components/templates/FormModal.vue +156 -0
- package/dist/components/templates/FormModal.vue.d.ts +306 -0
- package/dist/components/templates/FormPage.vue +1 -0
- package/dist/components/templates/SettingsModal.vue +61 -7
- package/dist/components/templates/SettingsModal.vue.d.ts +7 -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 +4 -2
- package/dist/composables/templates.d.ts +1 -0
- package/dist/composables/templates.mjs +1 -0
- package/dist/composables/useConfirm.mjs +11 -8
- package/dist/composables/useDirtyGuard.mjs +7 -47
- package/dist/composables/useForm.d.ts +4 -0
- package/dist/composables/useForm.mjs +9 -1
- package/dist/composables/useLeaveGuard.d.ts +19 -0
- package/dist/composables/useLeaveGuard.mjs +52 -0
- package/dist/composables/useRouteRecord.mjs +6 -5
- package/dist/grid/DataGrid.vue +170 -8
- package/dist/grid/DataGrid.vue.d.ts +8 -23
- package/dist/grid/cells/ButtonCell.vue +21 -1
- package/dist/grid/cells/ButtonCell.vue.d.ts +4 -0
- package/dist/grid/data-grid.css +7 -1
- package/dist/grid/types.d.ts +12 -0
- package/dist/internal/forms/form-overlay.d.ts +25 -0
- package/dist/internal/forms/form-overlay.mjs +31 -0
- package/dist/internal/forms/leave.d.ts +30 -0
- package/dist/internal/forms/leave.mjs +135 -0
- package/dist/internal/keys.d.ts +1 -0
- package/dist/internal/keys.mjs +1 -0
- package/dist/internal/layout/query.d.ts +4 -0
- package/dist/internal/layout/query.mjs +3 -0
- package/dist/internal/overlays/DialogFrame.vue +43 -5
- package/dist/internal/overlays/DialogFrame.vue.d.ts +11 -1
- package/dist/internal/overlays/HintTooltip.vue +65 -0
- package/dist/internal/overlays/HintTooltip.vue.d.ts +402 -0
- package/dist/internal/overlays/MenuList.vue +21 -0
- package/dist/internal/overlays/OverlayView.vue.d.ts +10 -4
- package/dist/styles/data/record-list.css +31 -1
- package/dist/styles/forms/fieldset.css +8 -0
- package/dist/styles/overlays/tooltip.css +11 -0
- package/dist/styles/templates/form-modal.css +16 -0
- package/dist/styles/templates.css +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -430,6 +430,35 @@ Several controls in one `FormField`. Only the primary control takes the field id
|
|
|
430
430
|
</KFormField>
|
|
431
431
|
```
|
|
432
432
|
|
|
433
|
+
### Unsaved changes
|
|
434
|
+
|
|
435
|
+
Every `Form` registers its dirty state in the nearest leave scope while it is mounted, so a form can not be left silently, wherever it is:
|
|
436
|
+
|
|
437
|
+
| Scope | Asks before |
|
|
438
|
+
| ------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
439
|
+
| `Modal`, `Drawer` | close (button, Escape, backdrop, `close()`), trail navigation; then `beforeClose` runs |
|
|
440
|
+
| `FormDrawer`, `FormModal` | the same, plus the cancel button (`onCancel` too); `confirmDiscard()` asks on demand |
|
|
441
|
+
| `SettingsModal` | Back, the breadcrumb, another section, `openPage()`, close, a route change of its `route` entry (browser back) |
|
|
442
|
+
| `useRouteRecord` | a navigation that closes or replaces the record, with the topmost open dialog dirty (or your `beforeLeave`) |
|
|
443
|
+
| Page (the app root scope) | a route path change (vue-router or Nuxt, through `$router`) and the tab close (`beforeunload`) |
|
|
444
|
+
|
|
445
|
+
Scopes nest: a dirty form in a drawer also blocks a route change of the page. The question is `useConfirm().discard()` (localized in `en`, `it`, `de`, the copy of the nearest scope: `guardTitle` and `guardMessage` of the overlay), shown once even when several guards ask for the same navigation or click. A form does not block while it is submitting, disabled or read only, and a successful `onSubmit` marks it clean (throw to keep it dirty; without `onSubmit` nothing changes). `form.markClean()` does it by hand (a save outside `onSubmit`), `form.reset(values)` loads new saved values.
|
|
446
|
+
|
|
447
|
+
Opt out per form with `useForm({ guard: false })` or `<KForm :guard="false">`, per overlay with `guard: false` on `Modal`, `Drawer`, `FormDrawer`, `FormModal` or `SettingsModal`, for every form with `createFormConfig({ guard: false })` (`provideFormConfig` in a subtree). Programmatic changes (`open = false`, writing `v-model:pages`) never ask.
|
|
448
|
+
|
|
449
|
+
For state that is not a `Form` (an editable grid with dirty cells, a canvas) register a flag yourself. `useLeaveGuard` joins the nearest scope, `provideLeaveScope()` makes your own component a scope (call `scope.confirmLeave()` before you replace its content). `useDirtyGuard(dirty, options?)` is the same registration with `confirmLeave()` (asks only when its own flag is dirty) and `allowNext()` (lets the next route change through, after a save that navigates).
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
const dirtyCells = ref(0)
|
|
453
|
+
const guard = useLeaveGuard(() => dirtyCells.value > 0, {
|
|
454
|
+
description: 'The edited cells will be lost.',
|
|
455
|
+
})
|
|
456
|
+
|
|
457
|
+
async function switchView() {
|
|
458
|
+
if (await guard.confirmLeave()) view.value = 'list'
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
433
462
|
## Components
|
|
434
463
|
|
|
435
464
|
| Group | Components |
|
|
@@ -445,7 +474,20 @@ Several controls in one `FormField`. Only the primary control takes the field id
|
|
|
445
474
|
| editor | RichTextEditor |
|
|
446
475
|
| chart | ChartPanel, ChartLegend, LineChart, BarChart, DoughnutChart |
|
|
447
476
|
|
|
448
|
-
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`, `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).
|
|
477
|
+
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).
|
|
478
|
+
|
|
479
|
+
### Buttons and tooltips
|
|
480
|
+
|
|
481
|
+
- An icon-only `Button` (no label: `square`, or only an `icon`) shows its `aria-label` (or `title`) in a `Tooltip` styled tooltip on hover and keyboard focus, after the usual delay. The native `title` stays only until mount, so there is never a double tooltip. Inside a `Tooltip` trigger the button shows none (the outer tooltip wins); `tooltip: false` turns it off.
|
|
482
|
+
- `tooltip="..."` adds a tooltip to any button, also with a label; when it differs from the accessible name it is also the button description.
|
|
483
|
+
- `disabledReason` explains a disabled button. With `disabled` and a reason the button uses `aria-disabled` instead of `disabled`: it stays in the Tab order and receives hover, clicks (and implicit form submission) are ignored, the reason shows as a tooltip and is linked with `aria-describedby`, and before mount the reason is the native `title`. Without a reason a disabled button behaves as before.
|
|
484
|
+
- Menu items of `DropdownMenu` and `ContextMenu` (and every `MenuItems` list: the account menu, `FilterPills` option menus) take `disabledReason` too: with `disabled` the item stays reachable with the arrow keys but cannot be selected, and the reason shows as a tooltip on hover and keyboard focus and is linked with `aria-describedby`. Use it instead of putting the reason in `description`.
|
|
485
|
+
- The same works for `CommandButton` (`CommandItem.disabledReason`, and `iconOnly` shows the label as a tooltip), `Tabs` (`TabItem.title`, also on a disabled tab), `FormDrawer` and `FormModal` (`deleteHint`) and the grid `ButtonCell` (`tooltip`, `disabled`, `disabledReason` params).
|
|
486
|
+
|
|
487
|
+
```vue
|
|
488
|
+
<KButton icon="pencil" square variant="ghost" tone="neutral" aria-label="Edit" />
|
|
489
|
+
<KButton :disabled="!canPublish" disabled-reason="Only an admin can publish">Publish</KButton>
|
|
490
|
+
```
|
|
449
491
|
|
|
450
492
|
### Colors
|
|
451
493
|
|
|
@@ -470,7 +512,8 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
470
512
|
- `Combobox` with `creatable` takes `createTransform` (`ComboboxCreateTransform`, `(input) => string | null | undefined`) and `createValidate` (`ComboboxCreateValidate`, `(input) => string | true | undefined`). The transform runs on the typed text first: the "Create" option shows its result, and an empty result (or `null`) shows no create option. The validator gets the transformed text when the user picks the create option: a returned string is the error, shown inline through the surrounding `FormField` (`useFieldControl().setControlError`, or a `FieldMessage` under the control and an announcement without a field) with `aria-invalid` on the input, and nothing is created; `true` or nothing accepts it. The error clears when the query changes. Both work with `multiple`, where created values become tags: `<KCombobox v-model="tags" multiple creatable :create-transform="(input) => input.toLowerCase()" :create-validate="(input) => input.length >= 3 || 'Too short'" />`.
|
|
471
513
|
- `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 }]" />`.
|
|
472
514
|
- `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.
|
|
473
|
-
- `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)
|
|
515
|
+
- `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.
|
|
516
|
+
- `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.
|
|
474
517
|
- `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.
|
|
475
518
|
- 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.
|
|
476
519
|
- `FilterPills` can list active filters: options with `removable: true` render as active pills with a remove button (`removeLabel`, a `'Remove {label}'` template). Clicking the pill emits `select(value)`, the button emits `remove(value)` (and drops the value from the model when it is selected); focus moves to the next pill when the removed one disappears.
|
|
@@ -483,7 +526,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
483
526
|
<KStepper v-model="step" :steps="steps" linear label="Import" />
|
|
484
527
|
```
|
|
485
528
|
|
|
486
|
-
- `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`
|
|
529
|
+
- `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`.
|
|
487
530
|
- `DropdownMenu` takes `matchTriggerWidth` (the menu is at least as wide as its trigger) and `minWidth` (a CSS length).
|
|
488
531
|
- `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).
|
|
489
532
|
- `RichTextEditor` accepts `'underline'` in `toolbar` (not in the default toolbar).
|
|
@@ -581,7 +624,7 @@ await run(() => api.save(form))
|
|
|
581
624
|
|
|
582
625
|
### Dialogs
|
|
583
626
|
|
|
584
|
-
`Modal` and `Drawer` take `beforeClose(reason)` (`'escape' | 'backdrop' | 'close-button' | 'action'`). It runs for every user close: Escape, a backdrop click, the close button and the `close` function of the slots. Return `false` (or a promise of `false`) to keep the dialog open
|
|
627
|
+
`Modal` and `Drawer` take `beforeClose(reason)` (`'escape' | 'backdrop' | 'close-button' | 'action'`). It runs for every user close: Escape, a backdrop click, the close button and the `close` function of the slots. Return `false` (or a promise of `false`) to keep the dialog open. A dirty `Form` inside already asks before any of these closes and before a trail navigation (`guard`, default `true`, copy in `guardTitle` and `guardMessage`; see [Unsaved changes](#unsaved-changes)); `beforeClose` runs after that question. Setting `v-model:open` to `false` from the parent always closes. `confirmLeave()` (exposed) asks on demand. `useModal().open()` and `useDrawer().open()` take `beforeClose` too.
|
|
585
628
|
|
|
586
629
|
```vue
|
|
587
630
|
<KDrawer v-model:open="open" title="Spring campaign" :before-close="confirmDiscard">
|
|
@@ -618,7 +661,7 @@ const confirmDiscard = () => !dirty.value || confirm({ title: 'Discard changes?'
|
|
|
618
661
|
|
|
619
662
|
### Deep links
|
|
620
663
|
|
|
621
|
-
`useRouteRecord(key, options?)` is the record version of `useRouteState`. `#family/fam_1` opens a record and `#family/new` the create form (`newId`). Options: `find(id)` (gives `current`), `loaded` (while false, `loading` is true, so the drawer opens at once with its skeleton; when true and `find` gives nothing, the entry is removed), `canCreate`, `linkedKeys` (entries removed together with the record, such as a tab or a sub record), `beforeLeave` (a function that returns `true` or `false`, or a promise of it, called before a navigation would close the open record or show another one: the entry changes or is removed, or the path changes while it is open; `false` cancels the navigation, so the back button, a link or a row of another record ask the same discard question as the drawer). It returns `param`, `id`, `isNew`, `current`, `loading`, `open` (for `v-model:open`), `openRecord(id | null, linked?)`, `close()` and `replaceId(id, linked?)` (after a create). All the entries change in one navigation. `close()`, `open = false`, `openRecord()` and `replaceId()` skip `beforeLeave` (they come after the drawer question or are on purpose). The guard is registered on mount, only in a component with a router.
|
|
664
|
+
`useRouteRecord(key, options?)` is the record version of `useRouteState`. `#family/fam_1` opens a record and `#family/new` the create form (`newId`). Options: `find(id)` (gives `current`), `loaded` (while false, `loading` is true, so the drawer opens at once with its skeleton; when true and `find` gives nothing, the entry is removed), `canCreate`, `linkedKeys` (entries removed together with the record, such as a tab or a sub record), `beforeLeave` (a function that returns `true` or `false`, or a promise of it, called before a navigation would close the open record or show another one: the entry changes or is removed, or the path changes while it is open; `false` cancels the navigation, so the back button, a link or a row of another record ask the same discard question as the drawer; without it the leave guard of the topmost open dialog asks, see [Unsaved changes](#unsaved-changes)). It returns `param`, `id`, `isNew`, `current`, `loading`, `open` (for `v-model:open`), `openRecord(id | null, linked?)`, `close()` and `replaceId(id, linked?)` (after a create). All the entries change in one navigation. `close()`, `open = false`, `openRecord()` and `replaceId()` skip `beforeLeave` (they come after the drawer question or are on purpose). The guard is registered on mount, only in a component with a router.
|
|
622
665
|
|
|
623
666
|
```ts
|
|
624
667
|
const drawer = useTemplateRef<{ confirmDiscard: () => Promise<boolean> }>('drawer')
|
|
@@ -779,18 +822,19 @@ Both take the `AuthLayout` frame props and the `brand`, `corner`, `footer` and `
|
|
|
779
822
|
|
|
780
823
|
### Page templates
|
|
781
824
|
|
|
782
|
-
| Component | What it gives you
|
|
783
|
-
| -------------------------------------------- |
|
|
784
|
-
| `DashboardPage` | PageHeader (`title`, `eyebrow`, `description`, `#actions`), a Stat grid from `stats` (or `#stats`), a content grid (`columns`, default 1 then 3 columns).
|
|
785
|
-
| `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. `cell-*` and `header-*` slots go to the Table.
|
|
786
|
-
| `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.
|
|
787
|
-
| `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`), then runs `beforeClose`. `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). |
|
|
788
|
-
| `
|
|
789
|
-
| `
|
|
790
|
-
| `
|
|
791
|
-
| `
|
|
825
|
+
| Component | What it gives you |
|
|
826
|
+
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
827
|
+
| `DashboardPage` | PageHeader (`title`, `eyebrow`, `description`, `#actions`), a Stat grid from `stats` (or `#stats`), a content grid (`columns`, default 1 then 3 columns). |
|
|
828
|
+
| `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. `cell-*` and `header-*` slots go to the Table. |
|
|
829
|
+
| `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. |
|
|
830
|
+
| `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). |
|
|
831
|
+
| `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. |
|
|
832
|
+
| `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`. |
|
|
833
|
+
| `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`. |
|
|
834
|
+
| `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`. |
|
|
835
|
+
| `EmptyPage` | First run screen: illustration, title, description, primary and secondary actions, onboarding `steps`. |
|
|
792
836
|
|
|
793
|
-
`useDirtyGuard(dirty, options?)` asks before leaving (router navigation through `ConfirmHost`, or the native confirm) and on tab close. Returns `confirmLeave()` and `allowNext()`.
|
|
837
|
+
`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).
|
|
794
838
|
|
|
795
839
|
### Nuxt: your own layout
|
|
796
840
|
|
|
@@ -939,6 +983,17 @@ Accessibility related props and defaults:
|
|
|
939
983
|
- A column without a visible header (a photo column) keeps a name for the Columns menu with `headerValueGetter: ({ location }) => (location === 'header' ? '' : 'Photo')`: the menu reads the name for the `columnToolPanel` location.
|
|
940
984
|
- `DataGrid` takes `gridOptions` for any AG Grid option it does not wrap (`rowHeight`, `onCellEditingStopped`, `onFilterChanged`, ...). A prop of `DataGrid` wins only when it is set: `getRowId`, `rowSelection` (when `selectable` is off), `autoSizeStrategy` (also `undefined` to turn it off), `tooltipShowDelay`, `overlayNoRowsTemplate` and `overlayLoadingTemplate` from `gridOptions` are used otherwise; `defaultColDef` and `localeText` are merged over the component defaults, and `context` is merged under the cell context. Handlers from both run.
|
|
941
985
|
- `DataGrid` row ids: `getRowId: (params) => string` (wins), `rowIdKey` (a field of the row), or `gridOptions.getRowId`.
|
|
986
|
+
- `DataGrid` `v-model:selected` (`string[]`) is the selected row ids, two way, for `selectable` grids (also `'single'`, at most one id). It needs row ids (`rowIdKey`, `getRowId` or `gridOptions.getRowId`); a dev warning tells you when they are missing. Leave it unbound for an uncontrolled grid. The header checkbox selects all the filtered rows (`selectAll: 'filtered'`): not the rows hidden by the search or the column filters, and not only the current page. A row hidden by the toolbar search, a column filter or an external filter leaves the selection: the grid deselects it and drops its id from the model when the filter changes, and an id set in the model for a hidden row is dropped too, so a bulk action never acts on rows the user cannot see. `keepHiddenSelected` keeps the old behavior (a hidden row stays selected). Client pagination keeps the selection across pages. A row that disappears from `rows` is dropped from the model, except while `loading` is set or the rows are empty, so a preselected model survives the first load. With `serverPagination` the ids of rows that are not in the current `rows` stay in the model: the selection survives a page change and a re-fetch, the footer counts the whole model, and the header checkbox only selects the rows of the page. The grid cannot see the other pages, so it drops an id that the server filter excludes only when it knows the whole result: once `loading` is off and `rows` holds every row of `total` (or the result is empty), the ids that are not in `rows` leave the model. Rows of the page hidden by a client column filter leave it as in client mode. To drop the ids of other pages when your own filters change, set the model yourself (for example `selected = []` when the query changes). Ids of rows that are not loaded yet stay out of the grid and are selected when the rows arrive. `selectionChange` still emits the selected rows of the grid.
|
|
987
|
+
- `DataGrid` template ref methods have a type: `DataGridMethods<Row>` (`api`, `getSelectedRows`, `getSelectedIds`, `selectRows(ids)`, `selectAllRows()` for the filtered rows, `deselectAll`, `resetColumns` and the `GridSpreadsheetMethods`; `selectAll` stays the cell range one of the spreadsheet).
|
|
988
|
+
|
|
989
|
+
```ts
|
|
990
|
+
import type { DataGridMethods } from '@xleddyl/443-components-vue/grid'
|
|
991
|
+
|
|
992
|
+
const grid = useTemplateRef<DataGridMethods<Row>>('grid')
|
|
993
|
+
grid.value?.selectAllRows()
|
|
994
|
+
const ids = grid.value?.getSelectedIds()
|
|
995
|
+
```
|
|
996
|
+
|
|
942
997
|
- `DataGrid` `fill` makes the grid, with its toolbar and footer, fill its parent (a flex or grid item with `flex: 1; min-height: 0`, or `height: 100%` in a block with a height) instead of the fixed `height`. Ignored with `autoHeight`.
|
|
943
998
|
- `DataGrid` `showEdges` and `showJump` reach the footer pager (first and last page buttons, page number input). `loading` also keeps the pager from resetting the page while a server total is unknown.
|
|
944
999
|
- `DataGrid` registers the AG Grid cell editors (text, large text, number, date, checkbox, select, custom and undo/redo) when `editable` is set or when a column or `gridOptions.defaultColDef` has `editable` at mount. `registerGridEditorModules()` from `/grid` does it by hand, before the first grid mounts, for columns that become editable later.
|
|
@@ -7,10 +7,15 @@
|
|
|
7
7
|
:target="target"
|
|
8
8
|
:external="external || void 0"
|
|
9
9
|
:class="classes"
|
|
10
|
+
:title="titleAttr"
|
|
11
|
+
:aria-describedby="describedBy"
|
|
12
|
+
@pointerenter="armHint"
|
|
13
|
+
@focusin="armHint"
|
|
10
14
|
>
|
|
11
15
|
<ButtonContent v-bind="contentProps"
|
|
12
16
|
><slot>{{ label }}</slot></ButtonContent
|
|
13
17
|
>
|
|
18
|
+
<HintTooltip v-if="showHint" :id="hintId" :text="hintText" />
|
|
14
19
|
</component>
|
|
15
20
|
<a
|
|
16
21
|
v-else-if="isLink"
|
|
@@ -22,33 +27,46 @@
|
|
|
22
27
|
:aria-disabled="inactive ? 'true' : void 0"
|
|
23
28
|
:aria-busy="busy ? 'true' : void 0"
|
|
24
29
|
:class="classes"
|
|
30
|
+
:title="titleAttr"
|
|
31
|
+
:aria-describedby="describedBy"
|
|
32
|
+
@pointerenter="armHint"
|
|
33
|
+
@focusin="armHint"
|
|
25
34
|
>
|
|
26
35
|
<ButtonContent v-bind="contentProps"
|
|
27
36
|
><slot>{{ label }}</slot></ButtonContent
|
|
28
37
|
>
|
|
38
|
+
<HintTooltip v-if="showHint" :id="hintId" :text="hintText" />
|
|
29
39
|
</a>
|
|
30
40
|
<button
|
|
31
41
|
v-else
|
|
32
42
|
v-bind="$attrs"
|
|
33
43
|
:type="type"
|
|
34
|
-
:disabled="disabled || void 0"
|
|
35
|
-
:aria-disabled="busy && !disabled ? 'true' : ariaDisabledAttr"
|
|
44
|
+
:disabled="disabled && !reasonActive || void 0"
|
|
45
|
+
:aria-disabled="reasonActive || busy && !disabled ? 'true' : ariaDisabledAttr"
|
|
36
46
|
:aria-busy="busy ? 'true' : void 0"
|
|
37
47
|
:class="classes"
|
|
48
|
+
:title="titleAttr"
|
|
49
|
+
:aria-describedby="describedBy"
|
|
38
50
|
@click.capture="onBusyClick"
|
|
51
|
+
@pointerenter="armHint"
|
|
52
|
+
@focusin="armHint"
|
|
39
53
|
>
|
|
40
54
|
<ButtonContent v-bind="contentProps"
|
|
41
55
|
><slot>{{ label }}</slot></ButtonContent
|
|
42
56
|
>
|
|
57
|
+
<HintTooltip v-if="showHint" :id="hintId" :text="hintText" />
|
|
43
58
|
</button>
|
|
44
59
|
</template>
|
|
45
60
|
|
|
46
61
|
<script setup>
|
|
47
|
-
import { computed, onMounted, useAttrs, useSlots, warn } from "vue";
|
|
62
|
+
import { computed, inject, onMounted, ref, useAttrs, useId, useSlots, warn } from "vue";
|
|
48
63
|
import { useFormContext } from "../../composables/useForm";
|
|
49
64
|
import { useLinkComponent } from "../../composables/useLink";
|
|
50
65
|
import ButtonContent from "../../internal/core/ButtonContent.vue";
|
|
51
66
|
import { linkHref } from "../../internal/core/link";
|
|
67
|
+
import { joinIds } from "../../internal/forms/control";
|
|
68
|
+
import { TOOLTIP_TRIGGER_KEY } from "../../internal/keys";
|
|
69
|
+
import HintTooltip from "../../internal/overlays/HintTooltip.vue";
|
|
52
70
|
defineOptions({ inheritAttrs: false });
|
|
53
71
|
const props = defineProps({
|
|
54
72
|
label: { type: String, required: false },
|
|
@@ -65,7 +83,9 @@ const props = defineProps({
|
|
|
65
83
|
disabled: { type: Boolean, required: false },
|
|
66
84
|
loading: { type: Boolean, required: false },
|
|
67
85
|
block: { type: Boolean, required: false },
|
|
68
|
-
square: { type: Boolean, required: false }
|
|
86
|
+
square: { type: Boolean, required: false },
|
|
87
|
+
tooltip: { type: [String, Boolean], required: false, default: void 0 },
|
|
88
|
+
disabledReason: { type: String, required: false }
|
|
69
89
|
});
|
|
70
90
|
const slots = useSlots();
|
|
71
91
|
const attrs = useAttrs();
|
|
@@ -93,8 +113,49 @@ const classes = computed(() => [
|
|
|
93
113
|
const ariaDisabledAttr = computed(
|
|
94
114
|
() => attrs["aria-disabled"]
|
|
95
115
|
);
|
|
116
|
+
const insideTooltip = inject(TOOLTIP_TRIGGER_KEY, false);
|
|
117
|
+
const hintId = `${useId()}-hint`;
|
|
118
|
+
const mounted = ref(false);
|
|
119
|
+
const hintArmed = ref(false);
|
|
120
|
+
const reasonActive = computed(() => Boolean(props.disabled && props.disabledReason));
|
|
121
|
+
function textAttr(name) {
|
|
122
|
+
const value = attrs[name];
|
|
123
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
124
|
+
}
|
|
125
|
+
const hintText = computed(() => {
|
|
126
|
+
if (reasonActive.value) return props.disabledReason;
|
|
127
|
+
if (props.tooltip === false || insideTooltip) return void 0;
|
|
128
|
+
if (props.tooltip) return props.tooltip;
|
|
129
|
+
if (hasLabel.value) return void 0;
|
|
130
|
+
return textAttr("aria-label") ?? textAttr("title");
|
|
131
|
+
});
|
|
132
|
+
const describes = computed(() => {
|
|
133
|
+
const text = hintText.value;
|
|
134
|
+
if (!text) return false;
|
|
135
|
+
if (reasonActive.value) return true;
|
|
136
|
+
const name = textAttr("aria-label") ?? (hasLabel.value ? void 0 : textAttr("title"));
|
|
137
|
+
return Boolean(props.tooltip) && text !== name;
|
|
138
|
+
});
|
|
139
|
+
const showHint = computed(
|
|
140
|
+
() => Boolean(hintText.value) && mounted.value && (hintArmed.value || describes.value)
|
|
141
|
+
);
|
|
142
|
+
const titleAttr = computed(() => {
|
|
143
|
+
const own = attrs.title;
|
|
144
|
+
if (!hintText.value) return own;
|
|
145
|
+
if (mounted.value) return void 0;
|
|
146
|
+
return reasonActive.value ? props.disabledReason : own;
|
|
147
|
+
});
|
|
148
|
+
const describedBy = computed(
|
|
149
|
+
() => joinIds(
|
|
150
|
+
attrs["aria-describedby"],
|
|
151
|
+
showHint.value && describes.value ? hintId : void 0
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
function armHint() {
|
|
155
|
+
if (hintText.value) hintArmed.value = true;
|
|
156
|
+
}
|
|
96
157
|
function onBusyClick(event) {
|
|
97
|
-
if (!busy.value) return;
|
|
158
|
+
if (!busy.value && !reasonActive.value) return;
|
|
98
159
|
event.preventDefault();
|
|
99
160
|
event.stopImmediatePropagation();
|
|
100
161
|
}
|
|
@@ -105,6 +166,7 @@ const contentProps = computed(() => ({
|
|
|
105
166
|
trailingIcon: props.trailingIcon
|
|
106
167
|
}));
|
|
107
168
|
onMounted(() => {
|
|
169
|
+
mounted.value = true;
|
|
108
170
|
const named = attrs["aria-label"] || attrs["aria-labelledby"] || attrs.title;
|
|
109
171
|
if (iconOnly.value && !hasLabel.value && !named)
|
|
110
172
|
warn(
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { IconName } from '../../composables/useIcons';
|
|
2
2
|
import type { ButtonSize, ButtonVariant, LinkTarget, Tone } from './types';
|
|
3
|
-
declare var
|
|
3
|
+
declare var __VLS_16: {}, __VLS_29: {}, __VLS_42: {};
|
|
4
4
|
type __VLS_Slots = {} & {
|
|
5
|
-
default?: (props: typeof
|
|
6
|
-
} & {
|
|
7
|
-
default?: (props: typeof __VLS_21) => any;
|
|
5
|
+
default?: (props: typeof __VLS_16) => any;
|
|
8
6
|
} & {
|
|
9
7
|
default?: (props: typeof __VLS_29) => any;
|
|
8
|
+
} & {
|
|
9
|
+
default?: (props: typeof __VLS_42) => any;
|
|
10
10
|
};
|
|
11
11
|
declare const __VLS_base: import("vue").DefineComponent<{
|
|
12
12
|
label?: string;
|
|
@@ -24,6 +24,8 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
24
24
|
loading?: boolean;
|
|
25
25
|
block?: boolean;
|
|
26
26
|
square?: boolean;
|
|
27
|
+
tooltip?: string | false;
|
|
28
|
+
disabledReason?: string;
|
|
27
29
|
download?: any;
|
|
28
30
|
hreflang?: string | undefined | undefined;
|
|
29
31
|
media?: string | undefined | undefined;
|
|
@@ -249,6 +251,8 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
249
251
|
loading?: boolean;
|
|
250
252
|
block?: boolean;
|
|
251
253
|
square?: boolean;
|
|
254
|
+
tooltip?: string | false;
|
|
255
|
+
disabledReason?: string;
|
|
252
256
|
download?: any;
|
|
253
257
|
hreflang?: string | undefined | undefined;
|
|
254
258
|
media?: string | undefined | undefined;
|
|
@@ -461,6 +465,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
461
465
|
}> & Readonly<{}>, {
|
|
462
466
|
size: ButtonSize;
|
|
463
467
|
tone: Tone;
|
|
468
|
+
tooltip: string | false;
|
|
464
469
|
type: "submit" | "button" | "reset";
|
|
465
470
|
variant: ButtonVariant;
|
|
466
471
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -62,14 +62,17 @@
|
|
|
62
62
|
<script setup>
|
|
63
63
|
import { computed, nextTick, useTemplateRef } from "vue";
|
|
64
64
|
import { provideForm } from "../../composables/useForm";
|
|
65
|
+
import { useLeaveScope } from "../../composables/useLeaveGuard";
|
|
65
66
|
import { provideFormDisabled } from "../../internal/forms/disabled";
|
|
67
|
+
import { registerLeaveEntry } from "../../internal/forms/leave";
|
|
66
68
|
import FormAlerts from "./FormAlerts.vue";
|
|
67
69
|
const props = defineProps({
|
|
68
70
|
form: { type: Object, required: true },
|
|
69
71
|
as: { type: String, required: false, default: "form" },
|
|
70
72
|
focusOnError: { type: Boolean, required: false, default: true },
|
|
71
73
|
alerts: { type: [String, Boolean], required: false, default: "start" },
|
|
72
|
-
disabled: { type: Boolean, required: false, default: void 0 }
|
|
74
|
+
disabled: { type: Boolean, required: false, default: void 0 },
|
|
75
|
+
guard: { type: Boolean, required: false, default: void 0 }
|
|
73
76
|
});
|
|
74
77
|
const emit = defineEmits(["submitted", "invalid", "reset"]);
|
|
75
78
|
const formRef = useTemplateRef("formRef");
|
|
@@ -78,7 +81,10 @@ const rootRef = computed(() => formRef.value ?? divRef.value);
|
|
|
78
81
|
const rootErrors = computed(() => props.form.rootErrors?.value ?? []);
|
|
79
82
|
const rootWarnings = computed(() => props.form.rootWarnings?.value ?? []);
|
|
80
83
|
provideForm(props.form);
|
|
81
|
-
provideFormDisabled(() => props.disabled);
|
|
84
|
+
const inactive = provideFormDisabled(() => props.disabled);
|
|
85
|
+
registerLeaveEntry(useLeaveScope(), {
|
|
86
|
+
dirty: () => (props.guard ?? props.form.guard) !== false && !inactive.value && props.form.dirty.value && !props.form.submitting.value
|
|
87
|
+
});
|
|
82
88
|
const IMPLICIT_SUBMIT_SKIP = /* @__PURE__ */ new Set([
|
|
83
89
|
"button",
|
|
84
90
|
"submit",
|
|
@@ -6,6 +6,7 @@ declare const __VLS_export: <S extends FormSchema, V extends object>(__VLS_props
|
|
|
6
6
|
focusOnError?: boolean;
|
|
7
7
|
alerts?: "start" | "end" | false;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
guard?: boolean;
|
|
9
10
|
} & {
|
|
10
11
|
onInvalid?: (() => any) | undefined;
|
|
11
12
|
onReset?: (() => any) | undefined;
|
|
@@ -226,6 +226,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
226
226
|
exportparts?: string | undefined;
|
|
227
227
|
part?: string | undefined;
|
|
228
228
|
popover?: (import("../../index.ts").PopoverMode | "" | boolean) | undefined;
|
|
229
|
+
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
229
230
|
autofocus?: (boolean | "true" | "false") | undefined;
|
|
230
231
|
formaction?: string | undefined | undefined;
|
|
231
232
|
formenctype?: string | undefined | undefined;
|
|
@@ -239,7 +240,6 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
239
240
|
multiple?: (boolean | "true" | "false") | undefined;
|
|
240
241
|
accept?: string | undefined | undefined;
|
|
241
242
|
alt?: string | undefined | undefined;
|
|
242
|
-
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
243
243
|
crossorigin?: string | undefined | undefined;
|
|
244
244
|
minlength?: (string | number) | undefined;
|
|
245
245
|
src?: string | undefined | undefined;
|
|
@@ -471,6 +471,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
471
471
|
exportparts?: string | undefined;
|
|
472
472
|
part?: string | undefined;
|
|
473
473
|
popover?: (import("../../index.ts").PopoverMode | "" | boolean) | undefined;
|
|
474
|
+
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
474
475
|
autofocus?: (boolean | "true" | "false") | undefined;
|
|
475
476
|
formaction?: string | undefined | undefined;
|
|
476
477
|
formenctype?: string | undefined | undefined;
|
|
@@ -484,7 +485,6 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
484
485
|
multiple?: (boolean | "true" | "false") | undefined;
|
|
485
486
|
accept?: string | undefined | undefined;
|
|
486
487
|
alt?: string | undefined | undefined;
|
|
487
|
-
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
488
488
|
crossorigin?: string | undefined | undefined;
|
|
489
489
|
minlength?: (string | number) | undefined;
|
|
490
490
|
src?: string | undefined | undefined;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
:aria-label="label"
|
|
9
9
|
>
|
|
10
10
|
<li
|
|
11
|
-
v-for="item in items"
|
|
11
|
+
v-for="(item, index) in items"
|
|
12
12
|
:key="item.id"
|
|
13
13
|
class="k-record-list-item"
|
|
14
14
|
:class="{ 'is-interactive': clickable(item) }"
|
|
@@ -17,7 +17,17 @@
|
|
|
17
17
|
<slot name="leading" :item="item" />
|
|
18
18
|
<div class="k-record-list-text">
|
|
19
19
|
<span class="k-record-list-title-row">
|
|
20
|
-
<
|
|
20
|
+
<button
|
|
21
|
+
v-if="clickable(item)"
|
|
22
|
+
type="button"
|
|
23
|
+
class="k-record-list-title k-record-list-trigger"
|
|
24
|
+
:title="item.title"
|
|
25
|
+
:aria-describedby="item.description ? descriptionId(index) : void 0"
|
|
26
|
+
@click="emit('rowClick', item, $event)"
|
|
27
|
+
>
|
|
28
|
+
{{ item.title }}
|
|
29
|
+
</button>
|
|
30
|
+
<span v-else class="k-record-list-title" :title="item.title">{{ item.title }}</span>
|
|
21
31
|
<Badge
|
|
22
32
|
v-if="item.badge"
|
|
23
33
|
:label="item.badge.label"
|
|
@@ -25,7 +35,11 @@
|
|
|
25
35
|
size="sm"
|
|
26
36
|
/>
|
|
27
37
|
</span>
|
|
28
|
-
<span
|
|
38
|
+
<span
|
|
39
|
+
v-if="item.description"
|
|
40
|
+
:id="descriptionId(index)"
|
|
41
|
+
class="k-record-list-description"
|
|
42
|
+
>
|
|
29
43
|
{{ item.description }}
|
|
30
44
|
</span>
|
|
31
45
|
</div>
|
|
@@ -48,7 +62,7 @@
|
|
|
48
62
|
</template>
|
|
49
63
|
|
|
50
64
|
<script setup>
|
|
51
|
-
import { computed, getCurrentInstance } from "vue";
|
|
65
|
+
import { computed, getCurrentInstance, useId } from "vue";
|
|
52
66
|
import { useLocale } from "../../composables/useLocale";
|
|
53
67
|
import EmptyState from "../feedback/EmptyState.vue";
|
|
54
68
|
import SkeletonList from "../feedback/SkeletonList.vue";
|
|
@@ -70,7 +84,12 @@ defineSlots();
|
|
|
70
84
|
const emit = defineEmits(["rowClick"]);
|
|
71
85
|
const { t } = useLocale();
|
|
72
86
|
const instance = getCurrentInstance();
|
|
73
|
-
const
|
|
87
|
+
const baseId = useId();
|
|
88
|
+
function descriptionId(index) {
|
|
89
|
+
return `${baseId}-description-${index}`;
|
|
90
|
+
}
|
|
91
|
+
const interactiveSelector = 'a, button, input, select, textarea, label, summary, [contenteditable="true"], [role="button"], [role="menuitem"], [role="option"], [role="checkbox"], [role="switch"], [role="tab"]';
|
|
92
|
+
const layerSelector = "dialog, [popover], .k-floating";
|
|
74
93
|
const hasRowClick = computed(
|
|
75
94
|
() => Boolean(instance?.vnode.props?.onRowClick || instance?.vnode.props?.["onRow-click"])
|
|
76
95
|
);
|
|
@@ -78,9 +97,12 @@ function clickable(item) {
|
|
|
78
97
|
return hasRowClick.value && (props.rowClickable?.(item) ?? true);
|
|
79
98
|
}
|
|
80
99
|
function onRowClick(item, event) {
|
|
81
|
-
if (!clickable(item)) return;
|
|
100
|
+
if (!clickable(item) || event.defaultPrevented) return;
|
|
82
101
|
const row = event.currentTarget;
|
|
83
|
-
const
|
|
102
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
103
|
+
const layer = target?.closest(layerSelector);
|
|
104
|
+
if (layer && row.contains(layer)) return;
|
|
105
|
+
const origin = target?.closest(interactiveSelector);
|
|
84
106
|
if (origin && row.contains(origin)) return;
|
|
85
107
|
if (window.getSelection()?.toString()) return;
|
|
86
108
|
emit("rowClick", item, event);
|
|
@@ -216,6 +216,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
216
216
|
exportparts?: string | undefined;
|
|
217
217
|
part?: string | undefined;
|
|
218
218
|
popover?: (import("../../index.ts").PopoverMode | "" | boolean) | undefined;
|
|
219
|
+
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
219
220
|
autofocus?: (boolean | "true" | "false") | undefined;
|
|
220
221
|
formaction?: string | undefined | undefined;
|
|
221
222
|
formenctype?: string | undefined | undefined;
|
|
@@ -229,7 +230,6 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
229
230
|
multiple?: (boolean | "true" | "false") | undefined;
|
|
230
231
|
accept?: string | undefined | undefined;
|
|
231
232
|
alt?: string | undefined | undefined;
|
|
232
|
-
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
233
233
|
crossorigin?: string | undefined | undefined;
|
|
234
234
|
minlength?: (string | number) | undefined;
|
|
235
235
|
src?: string | undefined | undefined;
|
|
@@ -455,6 +455,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
455
455
|
exportparts?: string | undefined;
|
|
456
456
|
part?: string | undefined;
|
|
457
457
|
popover?: (import("../../index.ts").PopoverMode | "" | boolean) | undefined;
|
|
458
|
+
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
458
459
|
autofocus?: (boolean | "true" | "false") | undefined;
|
|
459
460
|
formaction?: string | undefined | undefined;
|
|
460
461
|
formenctype?: string | undefined | undefined;
|
|
@@ -468,7 +469,6 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
468
469
|
multiple?: (boolean | "true" | "false") | undefined;
|
|
469
470
|
accept?: string | undefined | undefined;
|
|
470
471
|
alt?: string | undefined | undefined;
|
|
471
|
-
capture?: boolean | "user" | "environment" | undefined | undefined;
|
|
472
472
|
crossorigin?: string | undefined | undefined;
|
|
473
473
|
minlength?: (string | number) | undefined;
|
|
474
474
|
src?: string | undefined | undefined;
|
|
@@ -215,6 +215,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
215
215
|
part?: string;
|
|
216
216
|
popover?: import("../../index.ts").PopoverMode | "" | boolean;
|
|
217
217
|
numeric?: boolean;
|
|
218
|
+
capture?: boolean | "user" | "environment" | undefined;
|
|
218
219
|
autofocus?: (boolean | "true" | "false") | undefined;
|
|
219
220
|
formaction?: string | undefined;
|
|
220
221
|
formenctype?: string | undefined;
|
|
@@ -238,7 +239,6 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
238
239
|
multiple?: (boolean | "true" | "false") | undefined;
|
|
239
240
|
accept?: string | undefined;
|
|
240
241
|
alt?: string | undefined;
|
|
241
|
-
capture?: boolean | "user" | "environment" | undefined;
|
|
242
242
|
crossorigin?: string | undefined;
|
|
243
243
|
minlength?: (string | number) | undefined;
|
|
244
244
|
src?: string | undefined;
|
|
@@ -462,6 +462,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
462
462
|
part?: string;
|
|
463
463
|
popover?: import("../../index.ts").PopoverMode | "" | boolean;
|
|
464
464
|
numeric?: boolean;
|
|
465
|
+
capture?: boolean | "user" | "environment" | undefined;
|
|
465
466
|
autofocus?: (boolean | "true" | "false") | undefined;
|
|
466
467
|
formaction?: string | undefined;
|
|
467
468
|
formenctype?: string | undefined;
|
|
@@ -485,7 +486,6 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
485
486
|
multiple?: (boolean | "true" | "false") | undefined;
|
|
486
487
|
accept?: string | undefined;
|
|
487
488
|
alt?: string | undefined;
|
|
488
|
-
capture?: boolean | "user" | "environment" | undefined;
|
|
489
489
|
crossorigin?: string | undefined;
|
|
490
490
|
minlength?: (string | number) | undefined;
|
|
491
491
|
src?: string | undefined;
|