@xleddyl/443-components-vue 0.16.27 → 0.16.29
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
|
@@ -48,6 +48,7 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
|
|
|
48
48
|
| Searchable select, async search, multi select, create option | `Combobox` |
|
|
49
49
|
| Pick one node of a hierarchy (category, folder) | `TreeSelect` (`leavesOnly` to allow only leaves) |
|
|
50
50
|
| Create new values with a format or rule (tags, codes) | `Combobox` with `creatable`, `createTransform`, `createValidate` |
|
|
51
|
+
| Several create actions for the typed text (create here, create in a form) | `Combobox` with `createActions` |
|
|
51
52
|
| Several choices as checkboxes | `CheckboxGroup` |
|
|
52
53
|
| One yes or no | `Switch` (instant setting) or `Checkbox` (part of a form) |
|
|
53
54
|
| Date, date and time, month | `DateInput` (native) or `DatePicker` (popover calendar, ranges) |
|
|
@@ -65,7 +66,7 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
|
|
|
65
66
|
| Short message after an action | `toast` |
|
|
66
67
|
| Toast for a promise (loading, success, error) | `toast.promise` |
|
|
67
68
|
| Toast after saving in an open Drawer | `toast` (the stack moves beside the drawer or above its footer) |
|
|
68
|
-
| Detail or edit panel from the side | `Drawer` (or `useDrawer().open`)
|
|
69
|
+
| Detail or edit panel from the side | `Drawer` (or `useDrawer().open`). At 640px or less, a left or right drawer is a full-width sheet from the bottom. |
|
|
69
70
|
| Dialog with a form or content | `Modal` (or `useModal().open` to get the result as a promise) |
|
|
70
71
|
| Tabs or subpages (breadcrumb and back) in a Modal or Drawer | `tabs` + `v-model:tab`; `trail` + `@navigate` on `Modal` / `Drawer` |
|
|
71
72
|
| Buttons in a Modal or Drawer header | `#actions` slot of `Modal` / `Drawer` (right side, before the close button) |
|
|
@@ -159,29 +160,29 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
|
|
|
159
160
|
|
|
160
161
|
All field components work inside `FormField` and take `invalid`, `disabled`, `readonly`, `required` and `size`. They use `v-model`.
|
|
161
162
|
|
|
162
|
-
| Component | Purpose and when to use it | Main props, models, slots, events
|
|
163
|
-
| ------------------ | ---------------------------------------------------------------------------------------------------- |
|
|
164
|
-
| `Checkbox` | One boolean, or one value in an array model. Use `Switch` for an instant setting. | Model: boolean or array. Props: `label`, `description`, `value`, `indeterminate`. Slots: default, `description`.
|
|
165
|
-
| `CheckboxGroup` | Several choices as checkboxes from `options`. | Model: `T[]`. Props: `options` (`label`, `value`, `description`, `disabled`, `icon`), `legend`, `orientation`, `columns`, `variant` (default, filled), `name`.
|
|
166
|
-
| `Radio` | One radio option, used inside `RadioGroup`. | Props: `value`, `label`, `description`, `icon`. Slots: default, `description`.
|
|
167
|
-
| `RadioGroup` | One choice from a short list. Use `Select` for long lists, `SegmentedControl` for a compact toggle. | Model: value or null. Props: `options`, `legend`, `orientation`, `variant` (default, card), `name`.
|
|
168
|
-
| `SegmentedControl` | Compact toggle between 2 to 5 options (view mode, period). | Model: value (with `required` it is never null). Props: `options` (`label`, `value`, `icon`, `title`, `muted`), `iconOnly`, `block`, `label`. Slot: `option`.
|
|
169
|
-
| `Select` | Native styled select. Use `Combobox` when search or async options are needed. | Model: `T or null`. Props: `options` (items or groups with `label`, `value`, `disabled`), `placeholder`, `icon`. Option values can be string, number or boolean.
|
|
170
|
-
| `Combobox` | Searchable select. Local filter, async `search`, `multiple` with tags, `creatable`. | Models: `v-model`, `v-model:query`. Props: `options` (`label`, `value`, `description`, `icon`, `color` (dot and tag color), `group` (divider with the group name, also the tooltip of a selected tag), `keywords`), `search(query, signal)`, `filter`, `multiple`, `hideTags`, `creatable`, `createTransform`, `createValidate` (a returned string is the inline error), `debounce`, `minQueryLength`, `maxSelected`, `clearable`, `loading`, `placeholder`, `emptyText`. Slots: `option`, `empty`, `header` (top of the panel, for example quick filter pills). Events: `create`, `open`, `close`. | `forms/combobox.vue` |
|
|
171
|
-
| `TreeSelect` | Pick one node of a hierarchy (category, folder) with a drill-down panel, one level at a time. | Model: `TreeNodeId or null`. Props: `nodes` (`TreeNode`: `id`, `label`, `description`, `icon`, `disabled`, `children`), `leavesOnly` (parents only navigate), `separator` (path in the control and in search results, default `' / '`), `clearable`, `placeholder`, `searchPlaceholder`, `emptyText`, `icon`. Search lists every match with its path. Slots: `node` (`node`, `selected`, `path`), `empty`. Events: `open`, `close`.
|
|
172
|
-
| `Switch` | On or off setting that applies at once. | Model: boolean. Props: `label`, `description`, `labelPosition`, `checkedIcon`, `uncheckedIcon`, `name`. Slots: default, `description`.
|
|
173
|
-
| `NumberInput` | Locale aware number with stepper, min, max, step. | Model: number or null. Props: `min`, `max`, `step`, `largeStep`, `locale`, `formatOptions` (currency, percent), `stepper`, `wheel`, `align`, `icon`, `placeholder`.
|
|
174
|
-
| `PasswordInput` | Password with show or hide, optional generator, copy and strength meter. | Model: string. Props: `generate` (true or a function), `copy`, `strength`, `minLength`, `autocomplete`. Event: `generate`.
|
|
175
|
-
| `PinInput` | One time code or PIN in separate cells. | Model: string. Props: `length`, `mode` (numeric, alphanumeric, alphabetic), `mask`, `uppercase`, `separatorAfter`, `autocomplete`. Event: `complete(value)`.
|
|
176
|
-
| `InputGroup` | Join an input with addons or buttons on its sides. | Props: `label`, `size`, `block`. Slot: default (inputs, `InputAddon`, `Button`).
|
|
177
|
-
| `InputAddon` | Static text or icon (currency, domain, unit) inside an `InputGroup`. | Props: `label`, `icon`, `size`. Slot: default.
|
|
178
|
-
| `DateInput` | Native date, datetime-local, month or week input. Use `DatePicker` for a calendar popover or ranges. | Model: ISO string or null. Props: `type`, `min`, `max`, `step`, `clearable`.
|
|
179
|
-
| `DatePicker` | Input with a calendar popover. Single date or `range`. | Model: ISO string, range object (`start`, `end`) or null. Props: `range`, `min`, `max`, `isDateDisabled`, `locale`, `weekStartsOn`, `format`, `closeOnSelect`, `clearable`. Slot: `footer`.
|
|
180
|
-
| `Calendar` | Inline calendar. Use it for availability views, or as a building block. | Models: `v-model` (date or range), `v-model:month`. Props: `range`, `min`, `max`, `isDateDisabled`, `locale`, `weekStartsOn`, `dayText(iso)`. Slots: `day`, `footer`. Event: `select`.
|
|
181
|
-
| `TimeInput` | Time of day (HH:MM, optional seconds). | Model: string or null. Props: `min`, `max`, `step`, `seconds`, `clearable`.
|
|
182
|
-
| `ColorInput` | Color text field with picker and swatches. | Model: hex string or null. Props: `swatches` (strings or `{ value, label }`), `placeholder`, `invalidText`.
|
|
183
|
-
| `Slider` | Number in a range with drag handle. | Model: number. Props: `min`, `max`, `step`, `bubble` (true, always), `marks`, `format(value)`, `label`. Event: `change` (on release).
|
|
184
|
-
| `FileInput` | Drop zone and file picker. Validates type, size and count. Supports folders and previews. | Model: `File`, `File[]` or null. Props: `accept`, `acceptMode`, `maxSize`, `maxFiles`, `multiple`, `directory`, `directoryAction`, `previews`, `list`, `loading`, `capture`, `title`, `dropText`, `hint`. Slots: `title`, `hint`, `actions`. Events: `add`, `remove`, `invalid`, `reject`.
|
|
163
|
+
| Component | Purpose and when to use it | Main props, models, slots, events | Playground |
|
|
164
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
|
|
165
|
+
| `Checkbox` | One boolean, or one value in an array model. Use `Switch` for an instant setting. | Model: boolean or array. Props: `label`, `description`, `value`, `indeterminate`. Slots: default, `description`. | `forms/checkbox.vue` |
|
|
166
|
+
| `CheckboxGroup` | Several choices as checkboxes from `options`. | Model: `T[]`. Props: `options` (`label`, `value`, `description`, `disabled`, `icon`), `legend`, `orientation`, `columns`, `variant` (default, filled), `name`. | `forms/checkbox-group.vue` |
|
|
167
|
+
| `Radio` | One radio option, used inside `RadioGroup`. | Props: `value`, `label`, `description`, `icon`. Slots: default, `description`. | `forms/radio-group.vue` |
|
|
168
|
+
| `RadioGroup` | One choice from a short list. Use `Select` for long lists, `SegmentedControl` for a compact toggle. | Model: value or null. Props: `options`, `legend`, `orientation`, `variant` (default, card), `name`. | `forms/radio-group.vue` |
|
|
169
|
+
| `SegmentedControl` | Compact toggle between 2 to 5 options (view mode, period). | Model: value (with `required` it is never null). Props: `options` (`label`, `value`, `icon`, `title`, `muted`), `iconOnly`, `block`, `label`. Slot: `option`. | `forms/segmented-control.vue` |
|
|
170
|
+
| `Select` | Native styled select. Use `Combobox` when search or async options are needed. | Model: `T or null`. Props: `options` (items or groups with `label`, `value`, `disabled`), `placeholder`, `icon`. Option values can be string, number or boolean. | `forms/select.vue` |
|
|
171
|
+
| `Combobox` | Searchable select. Local filter, async `search`, `multiple` with tags, `creatable`. | Models: `v-model`, `v-model:query`. Props: `options` (`label`, `value`, `description`, `icon`, `color` (dot and tag color), `group` (divider with the group name, also the tooltip of a selected tag), `keywords`), `search(query, signal)`, `filter`, `multiple`, `hideTags`, `creatable`, `createActions`, `createTransform`, `createValidate` (a returned string is the inline error), `debounce`, `minQueryLength`, `maxSelected`, `clearable`, `loading`, `placeholder`, `emptyText`. Slots: `option`, `empty`, `header` (top of the panel, for example quick filter pills). Events: `create`, `open`, `close`. | `forms/combobox.vue` |
|
|
172
|
+
| `TreeSelect` | Pick one node of a hierarchy (category, folder) with a drill-down panel, one level at a time. | Model: `TreeNodeId or null`. Props: `nodes` (`TreeNode`: `id`, `label`, `description`, `icon`, `disabled`, `children`), `leavesOnly` (parents only navigate), `separator` (path in the control and in search results, default `' / '`), `clearable`, `placeholder`, `searchPlaceholder`, `emptyText`, `icon`. Search lists every match with its path. Slots: `node` (`node`, `selected`, `path`), `empty`. Events: `open`, `close`. | `forms/tree-select.vue` |
|
|
173
|
+
| `Switch` | On or off setting that applies at once. | Model: boolean. Props: `label`, `description`, `labelPosition`, `checkedIcon`, `uncheckedIcon`, `name`. Slots: default, `description`. | `forms/switch.vue` |
|
|
174
|
+
| `NumberInput` | Locale aware number with stepper, min, max, step. | Model: number or null. Props: `min`, `max`, `step`, `largeStep`, `locale`, `formatOptions` (currency, percent), `stepper`, `wheel`, `align`, `icon`, `placeholder`. | `forms/number-input.vue` |
|
|
175
|
+
| `PasswordInput` | Password with show or hide, optional generator, copy and strength meter. | Model: string. Props: `generate` (true or a function), `copy`, `strength`, `minLength`, `autocomplete`. Event: `generate`. | `forms/password-input.vue` |
|
|
176
|
+
| `PinInput` | One time code or PIN in separate cells. | Model: string. Props: `length`, `mode` (numeric, alphanumeric, alphabetic), `mask`, `uppercase`, `separatorAfter`, `autocomplete`. Event: `complete(value)`. | `forms/pin-input.vue` |
|
|
177
|
+
| `InputGroup` | Join an input with addons or buttons on its sides. | Props: `label`, `size`, `block`. Slot: default (inputs, `InputAddon`, `Button`). | `forms/input-group.vue` |
|
|
178
|
+
| `InputAddon` | Static text or icon (currency, domain, unit) inside an `InputGroup`. | Props: `label`, `icon`, `size`. Slot: default. | `forms/input-group.vue` |
|
|
179
|
+
| `DateInput` | Native date, datetime-local, month or week input. Use `DatePicker` for a calendar popover or ranges. | Model: ISO string or null. Props: `type`, `min`, `max`, `step`, `clearable`. | `forms/date-input.vue` |
|
|
180
|
+
| `DatePicker` | Input with a calendar popover. Single date or `range`. | Model: ISO string, range object (`start`, `end`) or null. Props: `range`, `min`, `max`, `isDateDisabled`, `locale`, `weekStartsOn`, `format`, `closeOnSelect`, `clearable`. Slot: `footer`. | `forms/date-picker.vue` |
|
|
181
|
+
| `Calendar` | Inline calendar. Use it for availability views, or as a building block. | Models: `v-model` (date or range), `v-model:month`. Props: `range`, `min`, `max`, `isDateDisabled`, `locale`, `weekStartsOn`, `dayText(iso)`. Slots: `day`, `footer`. Event: `select`. | `forms/calendar.vue` |
|
|
182
|
+
| `TimeInput` | Time of day (HH:MM, optional seconds). | Model: string or null. Props: `min`, `max`, `step`, `seconds`, `clearable`. | `forms/time-input.vue` |
|
|
183
|
+
| `ColorInput` | Color text field with picker and swatches. | Model: hex string or null. Props: `swatches` (strings or `{ value, label }`), `placeholder`, `invalidText`. | `forms/color-input.vue` |
|
|
184
|
+
| `Slider` | Number in a range with drag handle. | Model: number. Props: `min`, `max`, `step`, `bubble` (true, always), `marks`, `format(value)`, `label`. Event: `change` (on release). | `forms/slider.vue` |
|
|
185
|
+
| `FileInput` | Drop zone and file picker. Validates type, size and count. Supports folders and previews. | Model: `File`, `File[]` or null. Props: `accept`, `acceptMode`, `maxSize`, `maxFiles`, `multiple`, `directory`, `directoryAction`, `previews`, `list`, `loading`, `capture`, `title`, `dropText`, `hint`. Slots: `title`, `hint`, `actions`. Events: `add`, `remove`, `invalid`, `reject`. | `forms/file-input.vue` |
|
|
185
186
|
|
|
186
187
|
## Overlays
|
|
187
188
|
|
package/README.md
CHANGED
|
@@ -447,6 +447,7 @@ Composables: `useTheme`, `usePreset`, `useForm`, `useField`, `useFieldControl`,
|
|
|
447
447
|
- `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.
|
|
448
448
|
- `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).
|
|
449
449
|
- `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'" />`.
|
|
450
|
+
- `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 }]" />`.
|
|
450
451
|
- `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.
|
|
451
452
|
- `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.
|
|
452
453
|
- 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.
|
|
@@ -125,10 +125,7 @@
|
|
|
125
125
|
:aria-multiselectable="multiple ? 'true' : void 0"
|
|
126
126
|
:aria-busy="busy ? 'true' : void 0"
|
|
127
127
|
>
|
|
128
|
-
<template
|
|
129
|
-
v-for="(item, index) in items"
|
|
130
|
-
:key="item.kind === 'create' ? '__create' : keyOf(item.option.value)"
|
|
131
|
-
>
|
|
128
|
+
<template v-for="(item, index) in items" :key="itemKey(item)">
|
|
132
129
|
<li v-if="groupStarts(index)" role="presentation" class="k-combobox-group">
|
|
133
130
|
<span
|
|
134
131
|
v-if="item.option.color"
|
|
@@ -155,7 +152,11 @@
|
|
|
155
152
|
<span v-if="multiple && item.kind === 'option'" class="k-combobox-check">
|
|
156
153
|
<Icon v-if="item.selected" name="check" />
|
|
157
154
|
</span>
|
|
158
|
-
<Icon
|
|
155
|
+
<Icon
|
|
156
|
+
v-if="item.kind === 'create'"
|
|
157
|
+
:name="item.action?.icon ?? 'plus'"
|
|
158
|
+
class="k-combobox-option-icon"
|
|
159
|
+
/>
|
|
159
160
|
<span
|
|
160
161
|
v-else-if="item.option.color && !item.option.icon && !item.option.group"
|
|
161
162
|
class="k-combobox-option-dot"
|
|
@@ -183,7 +184,7 @@
|
|
|
183
184
|
>
|
|
184
185
|
</slot>
|
|
185
186
|
<span v-else class="k-combobox-option-label">{{
|
|
186
|
-
buildCreateText(item.option.label)
|
|
187
|
+
item.action ? item.action.label : buildCreateText(item.option.label)
|
|
187
188
|
}}</span>
|
|
188
189
|
</span>
|
|
189
190
|
</li>
|
|
@@ -246,6 +247,7 @@ const props = defineProps({
|
|
|
246
247
|
multiple: { type: Boolean, required: false },
|
|
247
248
|
hideTags: { type: Boolean, required: false },
|
|
248
249
|
creatable: { type: [Boolean, Function], required: false },
|
|
250
|
+
createActions: { type: Function, required: false },
|
|
249
251
|
createValidate: { type: Function, required: false },
|
|
250
252
|
createTransform: { type: Function, required: false },
|
|
251
253
|
debounce: { type: Number, required: false, default: 250 },
|
|
@@ -384,7 +386,7 @@ const filteredOptions = computed(() => {
|
|
|
384
386
|
);
|
|
385
387
|
});
|
|
386
388
|
const createCandidate = computed(() => {
|
|
387
|
-
if (!props.creatable || busy.value) return void 0;
|
|
389
|
+
if (!(props.creatable || props.createActions) || busy.value) return void 0;
|
|
388
390
|
const raw = activeQuery.value;
|
|
389
391
|
if (!raw) return void 0;
|
|
390
392
|
const text = (props.createTransform ? props.createTransform(raw) ?? "" : raw).trim();
|
|
@@ -396,18 +398,18 @@ const createCandidate = computed(() => {
|
|
|
396
398
|
return exists ? void 0 : text;
|
|
397
399
|
});
|
|
398
400
|
const items = computed(() => {
|
|
399
|
-
const list = filteredOptions.value.map((
|
|
401
|
+
const list = filteredOptions.value.map((option2) => ({
|
|
400
402
|
kind: "option",
|
|
401
|
-
option,
|
|
402
|
-
selected: selectedKeys.value.has(keyOf(
|
|
403
|
+
option: option2,
|
|
404
|
+
selected: selectedKeys.value.has(keyOf(option2.value))
|
|
403
405
|
}));
|
|
404
406
|
const candidate = createCandidate.value;
|
|
405
|
-
if (candidate)
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
selected: false
|
|
410
|
-
|
|
407
|
+
if (!candidate) return list;
|
|
408
|
+
const option = { label: candidate, value: candidate };
|
|
409
|
+
if (props.createActions)
|
|
410
|
+
for (const action of props.createActions(candidate))
|
|
411
|
+
list.push({ kind: "create", option, selected: false, action });
|
|
412
|
+
else list.push({ kind: "create", option, selected: false });
|
|
411
413
|
return list;
|
|
412
414
|
});
|
|
413
415
|
const activeId = computed(
|
|
@@ -428,6 +430,10 @@ watch([statusText, query], ([text]) => {
|
|
|
428
430
|
function keyOf(value) {
|
|
429
431
|
return String(value);
|
|
430
432
|
}
|
|
433
|
+
function itemKey(item) {
|
|
434
|
+
if (item.kind === "option") return keyOf(item.option.value);
|
|
435
|
+
return item.action ? `__create:${item.action.id}` : "__create";
|
|
436
|
+
}
|
|
431
437
|
function optionId(index) {
|
|
432
438
|
return `${baseId}-option-${index}`;
|
|
433
439
|
}
|
|
@@ -561,7 +567,7 @@ function onKeydown(event) {
|
|
|
561
567
|
if (item) {
|
|
562
568
|
event.preventDefault();
|
|
563
569
|
void choose(item);
|
|
564
|
-
} else if (
|
|
570
|
+
} else if (items.value.length === 1 && items.value[0].kind === "create") {
|
|
565
571
|
event.preventDefault();
|
|
566
572
|
void choose(items.value[0]);
|
|
567
573
|
}
|
|
@@ -605,11 +611,17 @@ async function choose(item) {
|
|
|
605
611
|
setCreateError(void 0);
|
|
606
612
|
let created;
|
|
607
613
|
try {
|
|
608
|
-
|
|
614
|
+
if (item.action) created = await item.action.run(item.option.label);
|
|
615
|
+
else
|
|
616
|
+
created = typeof props.creatable === "function" ? await props.creatable(item.option.label) : item.option;
|
|
609
617
|
} catch (reason) {
|
|
610
618
|
console.error("[@xleddyl/443-components-vue] Combobox create failed", reason);
|
|
611
619
|
return;
|
|
612
620
|
}
|
|
621
|
+
if (!created) {
|
|
622
|
+
dismissQuery();
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
613
625
|
remember(created);
|
|
614
626
|
emit("create", created);
|
|
615
627
|
select(created);
|
|
@@ -641,6 +653,11 @@ function select(option) {
|
|
|
641
653
|
});
|
|
642
654
|
}
|
|
643
655
|
}
|
|
656
|
+
function dismissQuery() {
|
|
657
|
+
resetQuery();
|
|
658
|
+
if (!props.multiple) closeList();
|
|
659
|
+
else if (props.search) scheduleSearch(0);
|
|
660
|
+
}
|
|
644
661
|
function remove(value) {
|
|
645
662
|
const key = keyOf(value);
|
|
646
663
|
model.value = selectedValues.value.filter((entry) => keyOf(entry) !== key);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IconName } from '../../composables/useIcons';
|
|
2
2
|
import type { FieldSize } from '../core/types';
|
|
3
|
-
import type { ComboboxCreate, ComboboxCreateTransform, ComboboxCreateValidate, ComboboxOption, ComboboxSearch } from './types';
|
|
3
|
+
import type { ComboboxCreate, ComboboxCreateActions, ComboboxCreateTransform, ComboboxCreateValidate, ComboboxOption, ComboboxSearch } from './types';
|
|
4
4
|
declare const __VLS_export: <T extends string | number, M extends T | T[] | null | undefined = T | T[] | null | undefined>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
5
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
6
6
|
options?: ComboboxOption<T>[];
|
|
@@ -10,6 +10,7 @@ declare const __VLS_export: <T extends string | number, M extends T | T[] | null
|
|
|
10
10
|
multiple?: boolean;
|
|
11
11
|
hideTags?: boolean;
|
|
12
12
|
creatable?: boolean | ComboboxCreate<T>;
|
|
13
|
+
createActions?: ComboboxCreateActions<T>;
|
|
13
14
|
createValidate?: ComboboxCreateValidate;
|
|
14
15
|
createTransform?: ComboboxCreateTransform;
|
|
15
16
|
debounce?: number;
|
|
@@ -37,6 +37,13 @@ export type ComboboxSearch<T = string | number> = (query: string, signal: AbortS
|
|
|
37
37
|
export type ComboboxCreateValidate = (input: string) => string | true | null | undefined | void;
|
|
38
38
|
export type ComboboxCreateTransform = (input: string) => string | null | undefined;
|
|
39
39
|
export type ComboboxCreate<T = string | number> = (query: string) => ComboboxOption<T> | Promise<ComboboxOption<T>>;
|
|
40
|
+
export interface ComboboxCreateAction<T = string | number> {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
icon?: IconName;
|
|
44
|
+
run: (query: string) => ComboboxOption<T> | void | Promise<ComboboxOption<T> | void>;
|
|
45
|
+
}
|
|
46
|
+
export type ComboboxCreateActions<T = string | number> = (query: string) => ComboboxCreateAction<T>[];
|
|
40
47
|
export interface CalendarRange {
|
|
41
48
|
start: string | null;
|
|
42
49
|
end: string | null;
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
.k-drawer[open] {
|
|
8
8
|
display: flex;
|
|
9
|
+
transition:
|
|
10
|
+
padding var(--k-duration-lg) var(--k-ease),
|
|
11
|
+
display var(--k-duration-lg) allow-discrete,
|
|
12
|
+
overlay var(--k-duration-lg) allow-discrete;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
.k-drawer-left {
|
|
@@ -38,7 +42,10 @@
|
|
|
38
42
|
|
|
39
43
|
.k-drawer[open] > .k-drawer-panel {
|
|
40
44
|
transform: none;
|
|
41
|
-
transition:
|
|
45
|
+
transition:
|
|
46
|
+
transform var(--k-duration-xl) var(--k-ease-drawer),
|
|
47
|
+
max-width var(--k-duration-lg) var(--k-ease),
|
|
48
|
+
border-radius var(--k-duration-lg) var(--k-ease);
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
@starting-style {
|
|
@@ -127,9 +134,18 @@
|
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
@media (max-width: 640px) {
|
|
137
|
+
.k-drawer.k-drawer-left,
|
|
138
|
+
.k-drawer.k-drawer-right {
|
|
139
|
+
padding: max(0.75rem, env(safe-area-inset-top)) 0 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
130
142
|
.k-drawer-left > .k-drawer-panel,
|
|
131
143
|
.k-drawer-right > .k-drawer-panel {
|
|
132
|
-
|
|
144
|
+
--k-drawer-hidden: translateY(100%);
|
|
145
|
+
max-width: 100%;
|
|
146
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
147
|
+
border-radius: var(--k-drawer-radius, var(--k-radius-xl))
|
|
148
|
+
var(--k-drawer-radius, var(--k-radius-xl)) 0 0;
|
|
133
149
|
}
|
|
134
150
|
|
|
135
151
|
.k-drawer.k-drawer-bottom {
|
package/package.json
CHANGED