@xleddyl/443-components-vue 0.16.63 → 0.16.65

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
@@ -152,7 +152,7 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
152
152
  | `FormField` | Label, description, hint, error and required marker around one control. It links ids and ARIA for the control inside. | Props: `label`, `name` (reads error and warning from the surrounding `Form`), `description`, `hint`, `error`, `warning`, `required`, `optional`, `disabled`, `icon`. Slots: default, `label`, `label-actions`, `description`, `hint`. | `core/form-field.vue` |
153
153
  | `FieldMessage` | One error, warning or hint line outside a `FormField`. | Props: `message`, `tone` (danger, warning, neutral), `icon`. Slot: default. | `core/field-message.vue` |
154
154
  | `FieldBoundary` | Cut the field context for controls inside a `FormField` that are not the main control (a search box above a `Tree`). | Prop: `auxiliary` (keeps own id, follows only `disabled`). Without it the context is fully cut. | `core/form-field.vue` |
155
- | `Form` | Connects a `useForm` result to a `<form>`. Provides errors to `FormField`, handles submit, reset, focus on first error. | Props: `form` (required), `as` (form or div; use `div` for a form nested in a modal), `focusOnError`, `alerts` (start, end, false), `disabled` (every `FormField` and control inside is disabled; nested forms inherit it). Slot: default, `alerts`. Events: `submitted`, `invalid`, `reset`. | `core/form.vue` |
155
+ | `Form` | Connects a `useForm` result to a `<form>`. Provides errors to `FormField`, handles submit, reset, focus on first error. | Props: `form` (required), `as` (form or div; use `div` for a form nested in a modal), `focusOnError`, `alerts` (start, end, false), `disabled` (every `FormField` and control inside is disabled; a nested form inherits it unless it sets its own). Slot: default, `alerts`. Events: `submitted`, `invalid`, `reset`. | `core/form.vue` |
156
156
  | `FormAlerts` | Render root errors and warnings as alerts. `Form` already does it. Use it only for a custom placement. | Props: `errors`, `warnings`. | `core/form.vue` |
157
157
  | `Kbd` | Show a keyboard key or shortcut. | Props: `value` (for example `mod+k`, shown per platform), `size`. Slot: default. | `core/kbd.vue` |
158
158
  | `VisuallyHidden` | Text for screen readers only. | Props: `as`, `focusable`. | `core/visually-hidden.vue` |
@@ -221,7 +221,7 @@ Mount `OverlayHost` once for the imperative hooks (see [Composables](#composable
221
221
  | `Avatar` | User picture with initials fallback and status dot. | Props: `src`, `name`, `alt`, `size` (xs to xl), `shape` (circle, square), `status` (online, away, busy, offline), `decorative`. Slot: `fallback`. | `data/avatar.vue` |
222
222
  | `AvatarGroup` | Overlapping stack of avatars with "+N". | Props: `items` (`src`, `name`, `alt`), `max`, `size`, `shape`, `moreLabel`. | `data/avatar.vue` |
223
223
  | `Stat` | Key figure (KPI) with unit, delta, trend, hint and optional sparkline. Can be a link. | Props: `label`, `value`, `unit`, `delta`, `trend` (up, down, flat), `invert` (down is good), `hint`, `icon`, `loading`, `to`, `href`, `plain`. Slots: `label`, `value`, `icon`, `sparkline`, `footer`. | `data/stat.vue` |
224
- | `RecordList` | Short list of records (settings, users, tokens): title, badge, description, leading and action slots, `SkeletonList` while `loading`, empty state. | Props: `items` (`RecordListItem`: `id`, `title` (truncated, full text on hover), `description`, `badge` `{ label, tone }`), `loading`, `avatar`, `action`, `label`, `skeletonRows`, `emptyText`, `emptyDescription`, `emptyIcon`, `emptyVariant` (card, the default, or plain). Slots: `leading`, `action` (`{ item }`), `empty`, `empty-actions` (buttons in the default empty state). | `data/record-list.vue` |
224
+ | `RecordList` | Short list of records (settings, users, tokens): title, badge, description, leading and action slots, `SkeletonList` while `loading`, empty state. | Props: `items` (`RecordListItem`: `id`, `title` (truncated, full text on hover), `description`, `badge` `{ label, tone }`), `loading`, `avatar`, `action`, `label`, `skeletonRows`, `emptyText`, `emptyDescription`, `emptyIcon`, `emptyVariant` (card, the default, or plain). Event: `row-click` (`item`, `event`): the whole row is clickable, clicks on buttons, links and inputs inside the row are ignored. Slots: `leading`, `action` (`{ item }`), `empty`, `empty-actions` (buttons in the default empty state). | `data/record-list.vue` |
225
225
  | `DescriptionList` | Label and value pairs for a record. Use it on detail views. | Props: `items` (`key`, `label`, `value`, `hint`), `layout` (stacked, inline, grid), `columns`, `divided`, `emptyText`. Slots: `term`, `value`, `value-<key>`. | `data/description-list.vue` |
226
226
  | `Timeline` | Vertical list of events or activity. | Props: `items` (`title`, `description`, `time`, `datetime`, `icon`, `tone`), `compact`. Slot: `item`. | `data/timeline.vue` |
227
227
  | `Tree` | Expandable hierarchy with selection, drag to reorder and nesting. | Models: `v-model:expanded`, `v-model:selected`. Props: `nodes` (`id`, `label`, `description`, `meta`, `icon`, `children`, `disabled`), `selectable`, `reorderable`, `nestable`, `moveButtons` (default `true`; `false` hides the row arrows, drag and Alt+arrow keys still work), `canDrop`, `size`, `checkmark`, `emptyText`, `emptyDescription`, `emptyIcon`, `emptyVariant` (card, the default, or plain). Slots: `label`, `meta`, `empty`, `empty-actions` (buttons in the default empty state). Events: `select`, `move`. | `data/tree.vue` |
package/README.md CHANGED
@@ -411,7 +411,7 @@ Nested forms. Overlays stay in the DOM, so a `Form` inside a Modal opened from a
411
411
  </KForm>
412
412
  ```
413
413
 
414
- Read only forms. `<KForm :form="form" disabled>` disables every `FormField` and every control inside (also the controls built on `useFieldControl` and the ones outside a `FormField`), as if each had `disabled`. A field is disabled when its own `disabled` is set or the form is disabled, and a nested `Form` inherits the state. `FormDrawer` with `readonly` does the same for its body, also for a `Form` you render yourself in the default slot.
414
+ Read only forms. `<KForm :form="form" disabled>` disables every `FormField` and every control inside (also the controls built on `useFieldControl` and the ones outside a `FormField`), as if each had `disabled`. A field is disabled when its own `disabled` is set or the form is disabled. A nested `Form` without `disabled` inherits the state; `:disabled="false"` or `true` on it overrides the parent, for example a modal form that opens from a read only drawer but follows its own permission. `FormDrawer` with `readonly` does the same for its body, also for a `Form` you render yourself in the default slot.
415
415
 
416
416
  ```vue
417
417
  <KForm :form="form" :disabled="!canWrite">
@@ -470,7 +470,7 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
470
470
  - `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
471
  - `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
472
  - `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.
473
+ - `RecordList` keeps each title on one line with an ellipsis; the full title is in its `title` attribute. With a `row-click` listener the whole row is clickable (pointer cursor); a click on a button, link or input inside the row does not emit it, so keep a button in `#action` for the keyboard.
474
474
  - `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
475
  - 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
476
  - `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.
@@ -69,7 +69,7 @@ const props = defineProps({
69
69
  as: { type: String, required: false, default: "form" },
70
70
  focusOnError: { type: Boolean, required: false, default: true },
71
71
  alerts: { type: [String, Boolean], required: false, default: "start" },
72
- disabled: { type: Boolean, required: false }
72
+ disabled: { type: Boolean, required: false, default: void 0 }
73
73
  });
74
74
  const emit = defineEmits(["submitted", "invalid", "reset"]);
75
75
  const formRef = useTemplateRef("formRef");
@@ -1,8 +1,18 @@
1
1
  <template>
2
2
  <SkeletonList v-if="loading" :rows="skeletonRows" :lines="2" :avatar="avatar" :action="action" />
3
3
 
4
- <ul v-else-if="items.length" class="k-record-list" :aria-label="label">
5
- <li v-for="item in items" :key="item.id" class="k-record-list-item">
4
+ <ul
5
+ v-else-if="items.length"
6
+ class="k-record-list"
7
+ :class="{ 'is-interactive': hasRowClick }"
8
+ :aria-label="label"
9
+ >
10
+ <li
11
+ v-for="item in items"
12
+ :key="item.id"
13
+ class="k-record-list-item"
14
+ @click="onRowClick(item, $event)"
15
+ >
6
16
  <slot name="leading" :item="item" />
7
17
  <div class="k-record-list-text">
8
18
  <span class="k-record-list-title-row">
@@ -37,6 +47,7 @@
37
47
  </template>
38
48
 
39
49
  <script setup>
50
+ import { computed, getCurrentInstance } from "vue";
40
51
  import { useLocale } from "../../composables/useLocale";
41
52
  import EmptyState from "../feedback/EmptyState.vue";
42
53
  import SkeletonList from "../feedback/SkeletonList.vue";
@@ -54,5 +65,19 @@ defineProps({
54
65
  emptyVariant: { type: String, required: false, default: "card" }
55
66
  });
56
67
  defineSlots();
68
+ const emit = defineEmits(["rowClick"]);
57
69
  const { t } = useLocale();
70
+ const instance = getCurrentInstance();
71
+ const interactiveSelector = 'a, button, input, select, textarea, label, summary, [role="button"]';
72
+ const hasRowClick = computed(
73
+ () => Boolean(instance?.vnode.props?.onRowClick || instance?.vnode.props?.["onRow-click"])
74
+ );
75
+ function onRowClick(item, event) {
76
+ if (!hasRowClick.value) return;
77
+ const row = event.currentTarget;
78
+ const origin = event.target?.closest(interactiveSelector);
79
+ if (origin && row.contains(origin)) return;
80
+ if (window.getSelection()?.toString()) return;
81
+ emit("rowClick", item, event);
82
+ }
58
83
  </script>
@@ -12,6 +12,8 @@ declare const __VLS_export: <Item extends RecordListItem>(__VLS_props: NonNullab
12
12
  emptyDescription?: string;
13
13
  emptyIcon?: IconName;
14
14
  emptyVariant?: "card" | "plain";
15
+ } & {
16
+ onRowClick?: ((item: Item, event: MouseEvent) => any) | undefined;
15
17
  } & Partial<{
16
18
  readonly rows?: number | undefined;
17
19
  readonly lines?: 1 | 2 | undefined;
@@ -226,7 +228,7 @@ declare const __VLS_export: <Item extends RecordListItem>(__VLS_props: NonNullab
226
228
  empty?(): unknown;
227
229
  'empty-actions'?(): unknown;
228
230
  };
229
- emit: {};
231
+ emit: (evt: "rowClick", item: Item, event: MouseEvent) => void;
230
232
  }>) => import("vue").VNode & {
231
233
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
232
234
  };
@@ -5,7 +5,7 @@ export function useFormDisabled() {
5
5
  }
6
6
  export function provideFormDisabled(disabled) {
7
7
  const parent = useFormDisabled();
8
- const value = computed(() => Boolean(toValue(disabled)) || Boolean(parent?.value));
8
+ const value = computed(() => toValue(disabled) ?? Boolean(parent?.value));
9
9
  provide(FORM_DISABLED_KEY, value);
10
10
  return value;
11
11
  }
@@ -13,6 +13,10 @@
13
13
  padding-block: 0.75rem;
14
14
  }
15
15
 
16
+ .k-record-list.is-interactive .k-record-list-item {
17
+ cursor: pointer;
18
+ }
19
+
16
20
  .k-record-list-item + .k-record-list-item {
17
21
  border-top: 1px solid var(--k-line);
18
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xleddyl/443-components-vue",
3
- "version": "0.16.63",
3
+ "version": "0.16.65",
4
4
  "description": "Compact, scoped dashboard components for Vue and Nuxt",
5
5
  "license": "MIT",
6
6
  "author": "Edoardo Alberti (https://github.com/xleddyl)",