@xleddyl/443-components-vue 0.16.87 → 0.16.89
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 +2 -2
- package/README.md +2 -2
- package/dist/components/core/FormField.vue +9 -0
- package/dist/components/core/FormField.vue.d.ts +8 -6
- package/dist/components/data/Tree.vue +86 -16
- package/dist/components/data/Tree.vue.d.ts +18 -3
- package/dist/components/data/types.d.ts +1 -0
- package/dist/locale/de.mjs +2 -1
- package/dist/locale/en.mjs +2 -1
- package/dist/locale/it.mjs +2 -1
- package/dist/locale/types.d.ts +1 -0
- package/dist/styles/core/form-field.css +7 -0
- package/dist/styles/data/tree.css +23 -4
- package/dist/styles/forced-colors.css +6 -1
- package/package.json +1 -1
package/CATALOG.md
CHANGED
|
@@ -152,7 +152,7 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
|
|
|
152
152
|
| `Spinner` | Loading indicator. Use `block` for a centered loading state that fills its container. | Props: `size` (xs to lg), `label`, `decorative`, `block`. | `core/spinner.vue` |
|
|
153
153
|
| `Input` | Single line text field. Use `NumberInput` for numbers, `PasswordInput` for passwords. | Model: `v-model` (string, number or null; modifiers `.number`, `.trim`). Props: `type`, `size`, `icon`, `clearable`, `counter` (needs `maxlength`), `transform`, `numeric` (decimal keyboard, number model, tabular digits, left aligned), `invalid`, `disabled`, `readonly`, `required`, `noAutofill`. Slots: `leading`, `trailing`. Event: `clear`. | `core/input.vue` |
|
|
154
154
|
| `Textarea` | Multi line text field. | Model: `v-model`. Props: `rows`, `maxRows`, `autoresize`, `counter`, `size`, `invalid`, `disabled`, `readonly`, `required`. Slot: `trailing`. | `core/textarea.vue` |
|
|
155
|
-
| `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
|
|
155
|
+
| `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`, `help` (an info icon after the label with the text as tooltip, also linked to the control as a description). Slots: default, `label`, `label-actions`, `description`, `hint`. | `core/form-field.vue` |
|
|
156
156
|
| `FieldMessage` | One error, warning or hint line outside a `FormField`. | Props: `message`, `tone` (danger, warning, neutral), `icon`. Slot: default. | `core/field-message.vue` |
|
|
157
157
|
| `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` |
|
|
158
158
|
| `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), `guard` (`false` keeps this form out of the leave guard; default: the `guard` option of `useForm`). While mounted it registers its dirty state in the nearest leave scope (`Modal`, `Drawer`, `FormDrawer`, `FormModal`, `SettingsModal`, else the page): leaving it dirty asks `confirm.discard()` first. Not while submitting or disabled. Slot: default, `alerts`. Events: `submitted`, `invalid`, `reset`. | `core/form.vue` |
|
|
@@ -228,7 +228,7 @@ Mount `OverlayHost` once for the imperative hooks (see [Composables](#composable
|
|
|
228
228
|
| `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`): each row becomes a navigation item (padding, hover and press background like a ghost button, no separators) and its title a button, so Tab reaches every row and Enter or Space opens it (focus ring on the row, the description is the button description). Clicks on buttons, links, inputs, menu items and inside an open menu, popover or dialog of the row are ignored, and pressing them does not tint the row; `rowClickable(item)` keeps some rows static in the same list (no button, no hover). Slots: `leading`, `action` (`{ item }`), `empty`, `empty-actions` (buttons in the default empty state). | `data/record-list.vue` |
|
|
229
229
|
| `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` |
|
|
230
230
|
| `Timeline` | Vertical list of events or activity. | Props: `items` (`title`, `description`, `time`, `datetime`, `icon`, `tone`), `compact`. Slot: `item`. | `data/timeline.vue` |
|
|
231
|
-
| `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
|
|
231
|
+
| `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`, `invalid`), `selectable`, `highlighted` (id or ids tinted like hover), `invalidText`, `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`, `actions` (row end, on hover, focus and the selected row; `node`, `level`, `selected`, `expanded`, `highlighted`, `hovered`), `empty`, `empty-actions` (buttons in the default empty state). Events: `select`, `move`, `hover` (node or `null`). | `data/tree.vue` |
|
|
232
232
|
|
|
233
233
|
## Layout
|
|
234
234
|
|
package/README.md
CHANGED
|
@@ -502,12 +502,12 @@ On your own elements, `paletteClass(color)` gives the class of a palette name an
|
|
|
502
502
|
|
|
503
503
|
### Lists, trees and uploads
|
|
504
504
|
|
|
505
|
-
- `Tree` takes `size="sm"` for dense rows, `checkmark`, `descriptionVariant` (`mono`, the default for paths and slugs, or `text`; a node can override it with its own `descriptionVariant`), `emptyText`, `emptyDescription`, `emptyIcon` and `emptyVariant` (`card`, the default, or `plain`) for the `EmptyState` shown without nodes (`#empty` replaces it, `#empty-actions` adds buttons inside it, like `RecordList`) and works inside a `FormField` (labelled and described by the field). With `reorderable` rows get a drag handle and Alt with the up and down arrows moves them; `nestable` also lets rows change level (drop in the middle of a row, Alt with left and right). Each row also shows move buttons; `moveButtons: false` hides them and keeps drag and the keyboard. The `move` event carries `{ node, target, position, from: { parent, index }, to: { parent, index } }`, `to.index` being the final index, and `applyTreeMove(nodes, move)` returns the updated tree. `canDrop(move)` vetoes a move. Moves are announced to screen readers.
|
|
505
|
+
- `Tree` takes `size="sm"` for dense rows, `checkmark`, `descriptionVariant` (`mono`, the default for paths and slugs, or `text`; a node can override it with its own `descriptionVariant`), `emptyText`, `emptyDescription`, `emptyIcon` and `emptyVariant` (`card`, the default, or `plain`) for the `EmptyState` shown without nodes (`#empty` replaces it, `#empty-actions` adds buttons inside it, like `RecordList`) and works inside a `FormField` (labelled and described by the field). With `reorderable` rows get a drag handle and Alt with the up and down arrows moves them; `nestable` also lets rows change level (drop in the middle of a row, Alt with left and right). Each row also shows move buttons; `moveButtons: false` hides them and keeps drag and the keyboard. The `move` event carries `{ node, target, position, from: { parent, index }, to: { parent, index } }`, `to.index` being the final index, and `applyTreeMove(nodes, move)` returns the updated tree. `canDrop(move)` vetoes a move. Moves are announced to screen readers. The `#actions` slot (`node`, `level`, `selected`, `expanded`, `highlighted`, `hovered`) renders row actions at the end of the row, over the label, on the hovered, focused and selected rows only; Tab from the focused row reaches them, and focus returns to a row when the focused one is removed. `highlighted` (an id or an array of ids) tints rows like hover, for a link with something outside the tree (a block hovered in a preview). The `hover` event carries the node under the pointer, then `null` when the pointer leaves the tree. A node with `invalid: true` shows a danger dot and a tinted label, and its row is described by a hidden "Contains errors" (`invalidText` overrides it).
|
|
506
506
|
- `Select` takes string, number or boolean option values (`{ value: true, label: 'Yes' }`); the model gets the option value back with its type and is typed `T | null | undefined`, so `v-model` works on a narrow ref (`Ref<'a' | 'b' | null>`). An option whose value is `''` is a real option: it is selected and shown with its own label, distinct from the placeholder, which still maps to `null`.
|
|
507
507
|
- `Input` and `Textarea` take `counter`: with a `maxlength` attribute they show `length / maxlength` inside the field, describe the control with "12 of 40 characters" (`form.characterCount`) and announce "Character limit reached" when it is hit.
|
|
508
508
|
- Numbers are left aligned in every field. `Input` `numeric` sets the decimal keyboard, the number model and tabular digits; `NumberInput` takes `align="end"` to right align its value when a layout needs it (default `start`).
|
|
509
509
|
- `Input` takes `transform: (value: string) => string`, applied to the typed text before it reaches the model (the caret keeps its place; IME composition is transformed when it ends). `:transform="(value) => value.toUpperCase()"` enforces uppercase codes. Values set from outside are not transformed.
|
|
510
|
-
- `FormField` takes `optional`, a muted localized "Optional" marker in the label row (`form.optional`, `optionalText` overrides it), the counterpart of the required asterisk. It is hidden when the field is required.
|
|
510
|
+
- `FormField` takes `optional`, a muted localized "Optional" marker in the label row (`form.optional`, `optionalText` overrides it), the counterpart of the required asterisk. It is hidden when the field is required. `help` adds an info icon after the label: the text shows as a tooltip on hover and is linked to the control with `aria-describedby`, for a format or a rule that the label cannot say.
|
|
511
511
|
- `CheckboxGroup` takes `columns` (a number): the options are laid out in a grid with that many equal columns. Unset keeps the `orientation` layout. `variant="filled"` (`CheckboxGroupVariant`, `'default' | 'filled'`, default `'default'`) puts the options in a subtle filled panel, styled by `--k-checkbox-group-background` (`--k-subtle`), `--k-checkbox-group-padding` (0.75rem), `--k-checkbox-group-radius` (`--k-radius-md`) and `--k-checkbox-group-border` (none).
|
|
512
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'" />`.
|
|
513
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 }]" />`.
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
<span v-if="optional && !isRequired" class="k-form-field-optional">{{
|
|
29
29
|
optionalText ?? t("form.optional")
|
|
30
30
|
}}</span>
|
|
31
|
+
<span v-if="help" class="k-form-field-help">
|
|
32
|
+
<Icon name="information-circle" aria-hidden="true" />
|
|
33
|
+
<span :id="helpId" class="k-visually-hidden">{{ help }}</span>
|
|
34
|
+
<HintTooltip :text="help" />
|
|
35
|
+
</span>
|
|
31
36
|
</label>
|
|
32
37
|
<span v-if="hint || $slots.hint" :id="hintId" class="k-form-field-hint">
|
|
33
38
|
<slot name="hint">{{ hint }}</slot>
|
|
@@ -72,6 +77,7 @@ import { useFormDisabled } from "../../internal/forms/disabled";
|
|
|
72
77
|
import { FIELD_KEY, FIELD_ROLE_KEY } from "../../internal/keys";
|
|
73
78
|
import FieldMessage from "./FieldMessage.vue";
|
|
74
79
|
import Icon from "./Icon.vue";
|
|
80
|
+
import HintTooltip from "../../internal/overlays/HintTooltip.vue";
|
|
75
81
|
const props = defineProps({
|
|
76
82
|
label: { type: String, required: false },
|
|
77
83
|
name: { type: String, required: false },
|
|
@@ -84,6 +90,7 @@ const props = defineProps({
|
|
|
84
90
|
optionalText: { type: String, required: false },
|
|
85
91
|
disabled: { type: Boolean, required: false },
|
|
86
92
|
icon: { type: null, required: false },
|
|
93
|
+
help: { type: String, required: false },
|
|
87
94
|
id: { type: String, required: false }
|
|
88
95
|
});
|
|
89
96
|
const slots = useSlots();
|
|
@@ -95,6 +102,7 @@ const baseId = useId();
|
|
|
95
102
|
const id = computed(() => props.id ?? `${baseId}-control`);
|
|
96
103
|
const labelId = `${baseId}-label`;
|
|
97
104
|
const hintId = `${baseId}-hint`;
|
|
105
|
+
const helpId = `${baseId}-help`;
|
|
98
106
|
const descriptionId = `${baseId}-description`;
|
|
99
107
|
const messageId = `${baseId}-message`;
|
|
100
108
|
const controlErrors = shallowReactive(/* @__PURE__ */ new Map());
|
|
@@ -139,6 +147,7 @@ const hasLabelRow = computed(
|
|
|
139
147
|
);
|
|
140
148
|
const describedBy = computed(
|
|
141
149
|
() => joinIds(
|
|
150
|
+
props.help && helpId,
|
|
142
151
|
(props.hint || slots.hint) && hintId,
|
|
143
152
|
(props.description || slots.description) && descriptionId,
|
|
144
153
|
(errorMessage.value || warningMessage.value) && messageId
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { IconName } from '../../composables/useIcons';
|
|
2
|
-
declare var __VLS_6: {},
|
|
2
|
+
declare var __VLS_6: {}, __VLS_18: {}, __VLS_20: {}, __VLS_22: {
|
|
3
3
|
id: string;
|
|
4
4
|
describedBy: string | undefined;
|
|
5
5
|
invalid: boolean;
|
|
6
|
-
},
|
|
6
|
+
}, __VLS_24: {};
|
|
7
7
|
type __VLS_Slots = {} & {
|
|
8
8
|
label?: (props: typeof __VLS_6) => any;
|
|
9
9
|
} & {
|
|
10
|
-
hint?: (props: typeof
|
|
10
|
+
hint?: (props: typeof __VLS_18) => any;
|
|
11
11
|
} & {
|
|
12
|
-
'label-actions'?: (props: typeof
|
|
12
|
+
'label-actions'?: (props: typeof __VLS_20) => any;
|
|
13
13
|
} & {
|
|
14
|
-
default?: (props: typeof
|
|
14
|
+
default?: (props: typeof __VLS_22) => any;
|
|
15
15
|
} & {
|
|
16
|
-
description?: (props: typeof
|
|
16
|
+
description?: (props: typeof __VLS_24) => any;
|
|
17
17
|
};
|
|
18
18
|
declare const __VLS_base: import("vue").DefineComponent<{
|
|
19
19
|
label?: string;
|
|
@@ -27,6 +27,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
27
27
|
optionalText?: string;
|
|
28
28
|
disabled?: boolean;
|
|
29
29
|
icon?: IconName;
|
|
30
|
+
help?: string;
|
|
30
31
|
id?: string | undefined;
|
|
31
32
|
innerHTML?: string | undefined | undefined;
|
|
32
33
|
class?: import("vue").ClassValue;
|
|
@@ -231,6 +232,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
231
232
|
optionalText?: string;
|
|
232
233
|
disabled?: boolean;
|
|
233
234
|
icon?: IconName;
|
|
235
|
+
help?: string;
|
|
234
236
|
id?: string | undefined;
|
|
235
237
|
innerHTML?: string | undefined | undefined;
|
|
236
238
|
class?: import("vue").ClassValue;
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
role="tree"
|
|
15
15
|
:class="rootClass"
|
|
16
16
|
data-k-shake
|
|
17
|
+
@pointerleave="onTreeLeave"
|
|
18
|
+
@focusin="hasFocus = true"
|
|
19
|
+
@focusout="onFocusOut"
|
|
17
20
|
>
|
|
18
21
|
<li
|
|
19
22
|
v-for="(entry, index) in visible"
|
|
@@ -31,7 +34,11 @@
|
|
|
31
34
|
:aria-describedby="describedBy(entry)"
|
|
32
35
|
:aria-keyshortcuts="canReorder && !entry.node.disabled ? keyShortcuts : void 0"
|
|
33
36
|
:tabindex="entry.node.id === rovingId ? 0 : -1"
|
|
34
|
-
:class="{
|
|
37
|
+
:class="{
|
|
38
|
+
'is-moving': dragId === entry.node.id,
|
|
39
|
+
'is-highlighted': highlightedSet.has(entry.node.id),
|
|
40
|
+
'is-invalid': entry.node.invalid
|
|
41
|
+
}"
|
|
35
42
|
:data-drop="dropState?.id === entry.node.id ? dropState.position : void 0"
|
|
36
43
|
:style="{
|
|
37
44
|
'--k-tree-level': entry.level - 1,
|
|
@@ -40,6 +47,7 @@
|
|
|
40
47
|
@click="activate(entry)"
|
|
41
48
|
@keydown="onKeydown($event, entry, index)"
|
|
42
49
|
@focus="focusId = entry.node.id"
|
|
50
|
+
@pointerenter="onRowEnter(entry)"
|
|
43
51
|
@dragover="onDragOver($event, entry)"
|
|
44
52
|
@dragleave="onDragLeave($event, entry)"
|
|
45
53
|
@drop="onDrop($event, entry)"
|
|
@@ -81,6 +89,7 @@
|
|
|
81
89
|
>
|
|
82
90
|
</slot>
|
|
83
91
|
</span>
|
|
92
|
+
<span v-if="entry.node.invalid" class="k-tree-invalid" aria-hidden="true" />
|
|
84
93
|
<span
|
|
85
94
|
v-if="entry.node.meta || $slots.meta"
|
|
86
95
|
:id="metaId(entry.node.id)"
|
|
@@ -92,22 +101,36 @@
|
|
|
92
101
|
<Icon v-if="selected === entry.node.id" name="check" />
|
|
93
102
|
</span>
|
|
94
103
|
<span
|
|
95
|
-
v-if="
|
|
104
|
+
v-if="hasMoveButtons(entry) || $slots.actions"
|
|
96
105
|
class="k-tree-actions"
|
|
106
|
+
:class="{ 'has-slot': $slots.actions }"
|
|
107
|
+
:inert="actionsInert(entry) || void 0"
|
|
97
108
|
@click.stop
|
|
109
|
+
@focusin="focusId = entry.node.id"
|
|
98
110
|
>
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
<template v-if="hasMoveButtons(entry)">
|
|
112
|
+
<Button
|
|
113
|
+
v-for="action in rowActions(entry)"
|
|
114
|
+
:key="action.direction"
|
|
115
|
+
variant="ghost"
|
|
116
|
+
tone="neutral"
|
|
117
|
+
size="xs"
|
|
118
|
+
tabindex="-1"
|
|
119
|
+
:icon="action.icon"
|
|
120
|
+
:aria-label="action.label"
|
|
121
|
+
:title="action.label"
|
|
122
|
+
:disabled="!action.move"
|
|
123
|
+
@click="action.move && commit(action.move)"
|
|
124
|
+
/>
|
|
125
|
+
</template>
|
|
126
|
+
<slot
|
|
127
|
+
name="actions"
|
|
128
|
+
:node="entry.node"
|
|
129
|
+
:level="entry.level"
|
|
130
|
+
:selected="selectable && selected === entry.node.id"
|
|
131
|
+
:expanded="entry.hasChildren && isExpanded(entry.node.id)"
|
|
132
|
+
:highlighted="highlightedSet.has(entry.node.id)"
|
|
133
|
+
:hovered="hoverId === entry.node.id"
|
|
111
134
|
/>
|
|
112
135
|
</span>
|
|
113
136
|
</li>
|
|
@@ -135,6 +158,7 @@
|
|
|
135
158
|
</EmptyState>
|
|
136
159
|
</slot>
|
|
137
160
|
</div>
|
|
161
|
+
<span v-if="hasInvalid" :id="invalidId" class="k-visually-hidden">{{ invalidLabel }}</span>
|
|
138
162
|
<template v-if="canReorder">
|
|
139
163
|
<span :id="hintId" class="k-visually-hidden">{{ hintText }}</span>
|
|
140
164
|
<LiveRegion :message="live.message.value" />
|
|
@@ -142,11 +166,12 @@
|
|
|
142
166
|
</template>
|
|
143
167
|
|
|
144
168
|
<script setup>
|
|
145
|
-
import { computed, nextTick, ref, useId, useSlots, useTemplateRef } from "vue";
|
|
169
|
+
import { computed, nextTick, ref, useId, useSlots, useTemplateRef, watch } from "vue";
|
|
146
170
|
import { useFieldControl } from "../../composables/useField";
|
|
147
171
|
import { useLocale } from "../../composables/useLocale";
|
|
148
172
|
import LiveRegion from "../../internal/core/LiveRegion.vue";
|
|
149
173
|
import { useLiveMessage } from "../../internal/core/live";
|
|
174
|
+
import { hasFocusWithin, isFocusLost } from "../../internal/core/focus";
|
|
150
175
|
import { useTypeahead } from "../../internal/core/roving";
|
|
151
176
|
import { joinIds } from "../../internal/forms/control";
|
|
152
177
|
import Button from "../core/Button.vue";
|
|
@@ -171,13 +196,15 @@ const props = defineProps({
|
|
|
171
196
|
moveButtons: { type: Boolean, required: false, default: true },
|
|
172
197
|
canDrop: { type: Function, required: false },
|
|
173
198
|
reorderText: { type: String, required: false },
|
|
199
|
+
highlighted: { type: [String, Number, Array, null], required: false },
|
|
200
|
+
invalidText: { type: String, required: false },
|
|
174
201
|
invalid: { type: Boolean, required: false, default: void 0 },
|
|
175
202
|
disabled: { type: Boolean, required: false },
|
|
176
203
|
required: { type: Boolean, required: false }
|
|
177
204
|
});
|
|
178
205
|
const { t } = useLocale();
|
|
179
206
|
const slots = useSlots();
|
|
180
|
-
const emit = defineEmits(["select", "move"]);
|
|
207
|
+
const emit = defineEmits(["select", "move", "hover"]);
|
|
181
208
|
const expanded = defineModel("expanded", { type: Array, ...{ default: () => [] } });
|
|
182
209
|
const selected = defineModel("selected", { type: [String, Number, null], ...{ default: null } });
|
|
183
210
|
const control = useFieldControl({
|
|
@@ -188,12 +215,15 @@ const control = useFieldControl({
|
|
|
188
215
|
});
|
|
189
216
|
const baseId = useId();
|
|
190
217
|
const hintId = `${baseId}-hint`;
|
|
218
|
+
const invalidId = `${baseId}-invalid`;
|
|
191
219
|
const tree = useTemplateRef("tree");
|
|
192
220
|
const focusId = ref(selected.value ?? props.nodes[0]?.id ?? null);
|
|
193
221
|
const revealAnchor = ref(-1);
|
|
194
222
|
const dragId = ref(null);
|
|
195
223
|
const dropState = ref(null);
|
|
196
224
|
const live = useLiveMessage();
|
|
225
|
+
const hoverId = ref(null);
|
|
226
|
+
const hasFocus = ref(false);
|
|
197
227
|
const ariaLabel = computed(() => {
|
|
198
228
|
if (props.label) return props.label;
|
|
199
229
|
return control.labelledBy.value ? void 0 : t("tree.label");
|
|
@@ -208,6 +238,12 @@ const keyShortcuts = computed(
|
|
|
208
238
|
() => props.nestable ? "Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight" : "Alt+ArrowUp Alt+ArrowDown"
|
|
209
239
|
);
|
|
210
240
|
const expandedSet = computed(() => new Set(expanded.value));
|
|
241
|
+
const highlightedSet = computed(() => {
|
|
242
|
+
const value = props.highlighted;
|
|
243
|
+
if (value === null || value === void 0) return /* @__PURE__ */ new Set();
|
|
244
|
+
return new Set(Array.isArray(value) ? value : [value]);
|
|
245
|
+
});
|
|
246
|
+
const invalidLabel = computed(() => props.invalidText ?? t("tree.invalidNode"));
|
|
211
247
|
function rowId(id) {
|
|
212
248
|
return `${baseId}-node-${id}`;
|
|
213
249
|
}
|
|
@@ -236,6 +272,7 @@ const rootClass = computed(() => [
|
|
|
236
272
|
function describedBy(entry) {
|
|
237
273
|
const hasMeta = Boolean(entry.node.meta || slots.meta);
|
|
238
274
|
return joinIds(
|
|
275
|
+
entry.node.invalid ? invalidId : void 0,
|
|
239
276
|
!slots.label && entry.node.description ? descriptionId(entry.node.id) : void 0,
|
|
240
277
|
hasMeta ? metaId(entry.node.id) : void 0,
|
|
241
278
|
canReorder.value && !entry.node.disabled ? hintId : void 0
|
|
@@ -279,6 +316,39 @@ const rovingId = computed(() => {
|
|
|
279
316
|
if (list.some((entry) => entry.node.id === focusId.value)) return focusId.value;
|
|
280
317
|
return list.find((entry) => entry.node.id === selected.value)?.node.id ?? list[0]?.node.id;
|
|
281
318
|
});
|
|
319
|
+
const hasInvalid = computed(() => visible.value.some((entry) => entry.node.invalid));
|
|
320
|
+
function hasMoveButtons(entry) {
|
|
321
|
+
return canReorder.value && props.moveButtons && !entry.node.disabled;
|
|
322
|
+
}
|
|
323
|
+
function actionsInert(entry) {
|
|
324
|
+
const id = entry.node.id;
|
|
325
|
+
return hoverId.value !== id && !(hasFocus.value && rovingId.value === id);
|
|
326
|
+
}
|
|
327
|
+
function setHover(node) {
|
|
328
|
+
const id = node?.id ?? null;
|
|
329
|
+
if (hoverId.value === id) return;
|
|
330
|
+
hoverId.value = id;
|
|
331
|
+
emit("hover", node);
|
|
332
|
+
}
|
|
333
|
+
function onRowEnter(entry) {
|
|
334
|
+
setHover(entry.node);
|
|
335
|
+
}
|
|
336
|
+
function onTreeLeave() {
|
|
337
|
+
setHover(null);
|
|
338
|
+
}
|
|
339
|
+
function onFocusOut(event) {
|
|
340
|
+
const next = event.relatedTarget;
|
|
341
|
+
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
342
|
+
hasFocus.value = false;
|
|
343
|
+
}
|
|
344
|
+
watch(visible, (list) => {
|
|
345
|
+
if (hoverId.value !== null && !list.some((entry) => entry.node.id === hoverId.value))
|
|
346
|
+
setHover(null);
|
|
347
|
+
if (!hasFocusWithin(tree.value)) return;
|
|
348
|
+
nextTick(() => {
|
|
349
|
+
if (isFocusLost()) focusNode(rovingId.value);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
282
352
|
function setExpanded(entry, position, open) {
|
|
283
353
|
if (!entry.hasChildren || isExpanded(entry.node.id) === open) return;
|
|
284
354
|
revealAnchor.value = position;
|
|
@@ -5,15 +5,24 @@ declare var __VLS_12: {
|
|
|
5
5
|
level: number;
|
|
6
6
|
}, __VLS_14: {
|
|
7
7
|
node: TreeNode;
|
|
8
|
-
}, __VLS_29: {
|
|
8
|
+
}, __VLS_29: {
|
|
9
|
+
node: TreeNode;
|
|
10
|
+
level: number;
|
|
11
|
+
selected: boolean;
|
|
12
|
+
expanded: boolean;
|
|
13
|
+
highlighted: boolean;
|
|
14
|
+
hovered: boolean;
|
|
15
|
+
}, __VLS_31: {}, __VLS_40: {};
|
|
9
16
|
type __VLS_Slots = {} & {
|
|
10
17
|
label?: (props: typeof __VLS_12) => any;
|
|
11
18
|
} & {
|
|
12
19
|
meta?: (props: typeof __VLS_14) => any;
|
|
13
20
|
} & {
|
|
14
|
-
|
|
21
|
+
actions?: (props: typeof __VLS_29) => any;
|
|
22
|
+
} & {
|
|
23
|
+
empty?: (props: typeof __VLS_31) => any;
|
|
15
24
|
} & {
|
|
16
|
-
'empty-actions'?: (props: typeof
|
|
25
|
+
'empty-actions'?: (props: typeof __VLS_40) => any;
|
|
17
26
|
};
|
|
18
27
|
declare const __VLS_base: import("vue").DefineComponent<{
|
|
19
28
|
nodes: TreeNode[];
|
|
@@ -32,6 +41,8 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
32
41
|
moveButtons?: boolean;
|
|
33
42
|
canDrop?: (move: TreeMove) => boolean;
|
|
34
43
|
reorderText?: string;
|
|
44
|
+
highlighted?: TreeNodeId | TreeNodeId[] | null;
|
|
45
|
+
invalidText?: string;
|
|
35
46
|
invalid?: boolean;
|
|
36
47
|
disabled?: boolean;
|
|
37
48
|
required?: boolean;
|
|
@@ -232,6 +243,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
232
243
|
move: (move: TreeMove) => any;
|
|
233
244
|
select: (node: TreeNode) => any;
|
|
234
245
|
"update:selected": (value: TreeNodeId | null) => any;
|
|
246
|
+
hover: (node: TreeNode | null) => any;
|
|
235
247
|
"update:expanded": (value: TreeNodeId[]) => any;
|
|
236
248
|
}, string, import("vue").PublicProps, Readonly<{
|
|
237
249
|
nodes: TreeNode[];
|
|
@@ -250,6 +262,8 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
250
262
|
moveButtons?: boolean;
|
|
251
263
|
canDrop?: (move: TreeMove) => boolean;
|
|
252
264
|
reorderText?: string;
|
|
265
|
+
highlighted?: TreeNodeId | TreeNodeId[] | null;
|
|
266
|
+
invalidText?: string;
|
|
253
267
|
invalid?: boolean;
|
|
254
268
|
disabled?: boolean;
|
|
255
269
|
required?: boolean;
|
|
@@ -450,6 +464,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
450
464
|
onMove?: ((move: TreeMove) => any) | undefined;
|
|
451
465
|
onSelect?: ((node: TreeNode) => any) | undefined;
|
|
452
466
|
"onUpdate:selected"?: ((value: TreeNodeId | null) => any) | undefined;
|
|
467
|
+
onHover?: ((node: TreeNode | null) => any) | undefined;
|
|
453
468
|
"onUpdate:expanded"?: ((value: TreeNodeId[]) => any) | undefined;
|
|
454
469
|
}>, {
|
|
455
470
|
size: TreeSize;
|
package/dist/locale/de.mjs
CHANGED
|
@@ -436,7 +436,8 @@ export const de = {
|
|
|
436
436
|
moveUp: "{label} nach oben verschieben",
|
|
437
437
|
moveDown: "{label} nach unten verschieben",
|
|
438
438
|
indent: "{label} einr\xFCcken",
|
|
439
|
-
outdent: "{label} ausr\xFCcken"
|
|
439
|
+
outdent: "{label} ausr\xFCcken",
|
|
440
|
+
invalidNode: "Enth\xE4lt Fehler"
|
|
440
441
|
},
|
|
441
442
|
treeSelect: {
|
|
442
443
|
placeholder: "Ausw\xE4hlen",
|
package/dist/locale/en.mjs
CHANGED
|
@@ -436,7 +436,8 @@ export const en = {
|
|
|
436
436
|
moveUp: "Move {label} up",
|
|
437
437
|
moveDown: "Move {label} down",
|
|
438
438
|
indent: "Indent {label}",
|
|
439
|
-
outdent: "Outdent {label}"
|
|
439
|
+
outdent: "Outdent {label}",
|
|
440
|
+
invalidNode: "Contains errors"
|
|
440
441
|
},
|
|
441
442
|
treeSelect: {
|
|
442
443
|
placeholder: "Select",
|
package/dist/locale/it.mjs
CHANGED
|
@@ -436,7 +436,8 @@ export const it = {
|
|
|
436
436
|
moveUp: "Sposta {label} in su",
|
|
437
437
|
moveDown: "Sposta {label} in gi\xF9",
|
|
438
438
|
indent: "Aumenta il rientro di {label}",
|
|
439
|
-
outdent: "Riduci il rientro di {label}"
|
|
439
|
+
outdent: "Riduci il rientro di {label}",
|
|
440
|
+
invalidNode: "Contiene errori"
|
|
440
441
|
},
|
|
441
442
|
treeSelect: {
|
|
442
443
|
placeholder: "Seleziona",
|
package/dist/locale/types.d.ts
CHANGED
|
@@ -62,6 +62,13 @@
|
|
|
62
62
|
animation: k-shake 320ms var(--k-ease);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
.k-form-field-help {
|
|
66
|
+
--k-icon-size: 0.875rem;
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
color: var(--k-text-dimmed);
|
|
69
|
+
cursor: help;
|
|
70
|
+
}
|
|
71
|
+
|
|
65
72
|
.k-form-field.is-disabled .k-form-field-label {
|
|
66
73
|
color: var(--k-text-muted);
|
|
67
74
|
}
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
border-top: 1px solid var(--k-line);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
.k-tree-row:hover
|
|
34
|
+
.k-tree-row:hover,
|
|
35
|
+
.k-tree-row.is-highlighted {
|
|
35
36
|
background: var(--k-subtle);
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -113,6 +114,18 @@
|
|
|
113
114
|
color: var(--k-text-muted);
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
.k-tree-invalid {
|
|
118
|
+
width: 0.4375rem;
|
|
119
|
+
height: 0.4375rem;
|
|
120
|
+
flex: none;
|
|
121
|
+
border-radius: var(--k-radius-full);
|
|
122
|
+
background: var(--k-danger);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.k-tree .k-tree-row.is-invalid .k-tree-label {
|
|
126
|
+
color: var(--k-danger-text);
|
|
127
|
+
}
|
|
128
|
+
|
|
116
129
|
.k-tree-meta {
|
|
117
130
|
flex-shrink: 0;
|
|
118
131
|
font-size: 0.75rem;
|
|
@@ -238,7 +251,8 @@
|
|
|
238
251
|
border-top: 0;
|
|
239
252
|
}
|
|
240
253
|
|
|
241
|
-
.k-tree-sm .k-tree-row:hover:not([aria-disabled='true'])
|
|
254
|
+
.k-tree-sm .k-tree-row:hover:not([aria-disabled='true']),
|
|
255
|
+
.k-tree-sm .k-tree-row.is-highlighted {
|
|
242
256
|
background: var(--k-hover);
|
|
243
257
|
}
|
|
244
258
|
|
|
@@ -292,12 +306,17 @@
|
|
|
292
306
|
transition: opacity var(--k-duration) var(--k-ease);
|
|
293
307
|
}
|
|
294
308
|
|
|
295
|
-
.k-tree-
|
|
309
|
+
.k-tree-actions:empty {
|
|
310
|
+
display: none;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.k-tree-row:is(:hover, :focus-within) > .k-tree-actions,
|
|
314
|
+
.k-tree-row[aria-selected='true'] > .k-tree-actions.has-slot {
|
|
296
315
|
opacity: 1;
|
|
297
316
|
pointer-events: auto;
|
|
298
317
|
}
|
|
299
318
|
|
|
300
|
-
.k-tree.is-dragging .k-tree-actions {
|
|
319
|
+
.k-tree.is-dragging .k-tree-row > .k-tree-actions {
|
|
301
320
|
opacity: 0;
|
|
302
321
|
pointer-events: none;
|
|
303
322
|
}
|
|
@@ -217,11 +217,16 @@
|
|
|
217
217
|
background: Highlight;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
.k-tab-dot {
|
|
220
|
+
:is(.k-tab-dot, .k-tree-invalid) {
|
|
221
221
|
forced-color-adjust: none;
|
|
222
222
|
background: CanvasText;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
.k-tree-row.is-highlighted:not(:focus-visible) {
|
|
226
|
+
outline: 2px dashed Highlight;
|
|
227
|
+
outline-offset: -2px;
|
|
228
|
+
}
|
|
229
|
+
|
|
225
230
|
.k-tag-list.is-drop-target {
|
|
226
231
|
outline: 2px dashed Highlight;
|
|
227
232
|
}
|
package/package.json
CHANGED