vue-composable-ui 0.0.1 → 1.0.2
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/LICENSE +1 -1
- package/README.md +5 -1
- package/dist/combobox.vue_vue_type_script_setup_true_lang-BhVMcx67.js +140 -0
- package/dist/comboboxHiddenInput.vue_vue_type_script_setup_true_lang-Ba-UPd-M.js +29 -0
- package/dist/comboboxInput.vue_vue_type_script_setup_true_lang-DzRfJ5ke.js +33 -0
- package/dist/comboboxOption.vue_vue_type_script_setup_true_lang-OyJxB4Jk.js +42 -0
- package/dist/comboboxOptions.vue_vue_type_script_setup_true_lang-Doy6MfEQ.js +20 -0
- package/dist/composable-ui.js +49 -0
- package/dist/composable-ui10.js +4 -0
- package/dist/composable-ui11.js +4 -0
- package/dist/composable-ui12.js +4 -0
- package/dist/composable-ui13.js +4 -0
- package/dist/composable-ui14.js +4 -0
- package/dist/composable-ui15.js +4 -0
- package/dist/composable-ui16.js +4 -0
- package/dist/composable-ui17.js +31 -0
- package/dist/composable-ui18.js +4 -0
- package/dist/composable-ui19.js +4 -0
- package/dist/composable-ui2.js +55 -0
- package/dist/composable-ui20.js +4 -0
- package/dist/composable-ui21.js +100 -0
- package/dist/composable-ui22.js +144 -0
- package/dist/composable-ui23.js +7 -0
- package/dist/composable-ui24.js +7 -0
- package/dist/composable-ui3.js +4 -0
- package/dist/composable-ui4.js +4 -0
- package/dist/composable-ui5.js +4 -0
- package/dist/composable-ui6.js +4 -0
- package/dist/composable-ui7.js +4 -0
- package/dist/composable-ui8.js +4 -0
- package/dist/composable-ui9.js +4 -0
- package/dist/listbox.vue_vue_type_script_setup_true_lang-Bj1ZXiBX.js +69 -0
- package/dist/listboxOption.vue_vue_type_script_setup_true_lang-B_yRptJm.js +37 -0
- package/dist/menu.vue_vue_type_script_setup_true_lang-Ci7q2rOg.js +82 -0
- package/dist/menuItem.vue_vue_type_script_setup_true_lang-mXtMa4gO.js +63 -0
- package/dist/menuItems.vue_vue_type_script_setup_true_lang-p9vftREy.js +49 -0
- package/dist/popover.vue_vue_type_script_setup_true_lang-DhKF7_nY.js +50 -0
- package/dist/popoverDialog.vue_vue_type_script_setup_true_lang-CDXUO7wZ.js +33 -0
- package/dist/tab.vue_vue_type_script_setup_true_lang-Y5OFGqMB.js +29 -0
- package/dist/tabContainer.vue_vue_type_script_setup_true_lang-fPpLno2Z.js +40 -0
- package/dist/tabList.vue_vue_type_script_setup_true_lang-CZyqGCuj.js +48 -0
- package/dist/tabPanel.vue_vue_type_script_setup_true_lang-CGhP6SHR.js +31 -0
- package/dist/tooltip.vue_vue_type_script_setup_true_lang-DVKYJyfL.js +85 -0
- package/dist/types/components/combobox/combobox.vue.d.ts +45 -0
- package/dist/types/components/combobox/comboboxHiddenInput.vue.d.ts +6 -0
- package/dist/types/components/combobox/comboboxInput.vue.d.ts +9 -0
- package/dist/types/components/combobox/comboboxOption.vue.d.ts +20 -0
- package/dist/types/components/combobox/comboboxOptions.vue.d.ts +12 -0
- package/dist/types/components/injectionKeys.d.ts +43 -0
- package/dist/types/components/listbox/listbox.vue.d.ts +26 -0
- package/dist/types/components/listbox/listboxOption.vue.d.ts +20 -0
- package/dist/types/components/menu/menu.vue.d.ts +42 -0
- package/dist/types/components/menu/menuItem.vue.d.ts +24 -0
- package/dist/types/components/menu/menuItems.vue.d.ts +12 -0
- package/dist/types/components/popover/popover.vue.d.ts +40 -0
- package/dist/types/components/popover/popoverDialog.vue.d.ts +12 -0
- package/dist/types/components/tabs/tab.vue.d.ts +17 -0
- package/dist/types/components/tabs/tabContainer.vue.d.ts +19 -0
- package/dist/types/components/tabs/tabList.vue.d.ts +17 -0
- package/dist/types/components/tabs/tabPanel.vue.d.ts +15 -0
- package/dist/types/components/tooltip.vue.d.ts +34 -0
- package/dist/types/composables/formControl.d.ts +48 -0
- package/dist/types/composables/list.d.ts +107 -0
- package/dist/types/composables/listOption.d.ts +34 -0
- package/dist/types/composables/popover.d.ts +68 -0
- package/dist/types/main.d.ts +22 -0
- package/dist/types/utils/element.d.ts +3 -0
- package/package.json +28 -12
- package/.github/workflows/deploy.yml +0 -21
- package/.github/workflows/docs.yml +0 -62
- package/.vscode/extensions.json +0 -7
- package/docs/.vitepress/config.mts +0 -40
- package/docs/.vitepress/theme/index.js +0 -4
- package/docs/.vitepress/theme/style.scss +0 -155
- package/docs/components/combobox.md +0 -174
- package/docs/components/demos/combobox.vue +0 -142
- package/docs/components/demos/combobox_autocomplete.vue +0 -75
- package/docs/components/demos/combobox_tags.vue +0 -127
- package/docs/components/demos/input.vue +0 -35
- package/docs/components/demos/listbox.vue +0 -64
- package/docs/components/demos/menu.vue +0 -93
- package/docs/components/demos/popover.vue +0 -16
- package/docs/components/demos/tabs.vue +0 -59
- package/docs/components/demos/tooltip.vue +0 -27
- package/docs/components/listbox.md +0 -9
- package/docs/components/menu.md +0 -121
- package/docs/components/popover.md +0 -82
- package/docs/components/tabs.md +0 -9
- package/docs/components/tooltip.md +0 -78
- package/docs/composables/form-control.md +0 -130
- package/docs/composables/list-option.md +0 -47
- package/docs/composables/list.md +0 -192
- package/docs/composables/popover.md +0 -90
- package/docs/index.md +0 -24
- package/docs/intro.md +0 -0
- package/src/components/combobox/combobox.vue +0 -229
- package/src/components/combobox/comboboxFormInput.vue +0 -33
- package/src/components/combobox/comboboxOption.vue +0 -52
- package/src/components/combobox/comboboxOptions.vue +0 -17
- package/src/components/injectionKeys.ts +0 -50
- package/src/components/listbox/listbox.vue +0 -91
- package/src/components/listbox/listboxOption.vue +0 -37
- package/src/components/menu/menu.vue +0 -100
- package/src/components/menu/menuItem.vue +0 -86
- package/src/components/menu/menuItems.vue +0 -51
- package/src/components/popover/popover.vue +0 -68
- package/src/components/popover/popoverDialog.vue +0 -35
- package/src/components/tabs/tab.vue +0 -35
- package/src/components/tabs/tabContainer.vue +0 -50
- package/src/components/tabs/tabList.vue +0 -52
- package/src/components/tabs/tabPanel.vue +0 -36
- package/src/components/tooltip.vue +0 -115
- package/src/composables/formControl.ts +0 -144
- package/src/composables/list.ts +0 -326
- package/src/composables/listOption.ts +0 -80
- package/src/composables/popover.ts +0 -306
- package/src/main.ts +0 -65
- package/src/utils/element.ts +0 -19
- package/src/utils/id.ts +0 -5
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -27
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -28
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import ComboboxDemo from './demos/combobox.vue'
|
|
3
|
-
import ComboboxTagsDemo from './demos/combobox_tags.vue'
|
|
4
|
-
</script>
|
|
5
|
-
|
|
6
|
-
# Combobox Components
|
|
7
|
-
|
|
8
|
-
A combobox is a composite widget that combines an input field with a popup providing possible values for that input field.
|
|
9
|
-
|
|
10
|
-
Based on:
|
|
11
|
-
|
|
12
|
-
- [usePopover](/composables/popover)
|
|
13
|
-
- [useList](/composables/list)
|
|
14
|
-
- [useListOption](/composables/list-option)
|
|
15
|
-
- [useFormControl](/composables/form-control)
|
|
16
|
-
|
|
17
|
-
## Demo
|
|
18
|
-
|
|
19
|
-
<ComboboxDemo />
|
|
20
|
-
::: details Code
|
|
21
|
-
<<< ./demos/combobox.vue
|
|
22
|
-
:::
|
|
23
|
-
|
|
24
|
-
## Complex Widget Example
|
|
25
|
-
|
|
26
|
-
Autocomplete + tags
|
|
27
|
-
|
|
28
|
-
<ComboboxTagsDemo />
|
|
29
|
-
::: details Code
|
|
30
|
-
<<< ./demos/combobox_tags.vue
|
|
31
|
-
:::
|
|
32
|
-
|
|
33
|
-
## Combobox
|
|
34
|
-
|
|
35
|
-
The root component.
|
|
36
|
-
|
|
37
|
-
### Properties
|
|
38
|
-
|
|
39
|
-
| Property | Required | Description | Type | Default |
|
|
40
|
-
| ---------------- | -------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
-
| **modelValue** | true | The selected value. Set to an array to enable multiselection. | `any` \| `any[]` | `undefined` |
|
|
42
|
-
| **displayValue** | false | A function that takes the combobox value and returns a string representation that is shown in the input. | `(value: unknown \| unknown[]) => string` | Calls `.toString()` on the provided value. For multi-selectable combobox converts every value to string and joins the results with a comma. |
|
|
43
|
-
| **name** | false | The name of the field that is submitted when using inside a form. | `string` | `undefined` |
|
|
44
|
-
| **formValue** | false | A function that takes a selected item value and transforms it into a value to submit when using inside a form. | `(item: unknown) => Record<string, string> \| string` | Returns the value unchanged |
|
|
45
|
-
| **id** | false | The ID of the combobox input. | `string` | Auto-generated |
|
|
46
|
-
| **activatorId** | false | The ID of the activator element. | `string` | Equals to the `id` |
|
|
47
|
-
|
|
48
|
-
### Slots
|
|
49
|
-
|
|
50
|
-
#### input
|
|
51
|
-
|
|
52
|
-
The `input` slot is used to provide an input element and possibly an activator. The slot passes the following properties:
|
|
53
|
-
|
|
54
|
-
| Property | Description | Type |
|
|
55
|
-
| ------------- | --------------------------------------------------------- | -------------- |
|
|
56
|
-
| **attrs** | Required attributes that **must** be binded to the input. | `object` |
|
|
57
|
-
| **isOpen** | The status of the popover. | `Ref<boolean>` |
|
|
58
|
-
| **toggle** | Toggle the popover. | `() => void` |
|
|
59
|
-
| **popoverId** | The ID of the popover dialog. | `string` |
|
|
60
|
-
|
|
61
|
-
In a complex component you may need to wrap the input in a container element which must serve as an activator for the popover. You can achieve this by setting the `activatorId` property and assigning it to the wrapper element in the input slot.
|
|
62
|
-
|
|
63
|
-
```vue
|
|
64
|
-
<Combobox activatorId="activator">
|
|
65
|
-
<template #input="{ popoverId, attrs, toggle, isOpen }">
|
|
66
|
-
<div id="activator">
|
|
67
|
-
<input
|
|
68
|
-
v-bind="attrs"
|
|
69
|
-
/>
|
|
70
|
-
<button
|
|
71
|
-
@click="toggle"
|
|
72
|
-
:aria-controls="isOpen ? popoverId : undefined"
|
|
73
|
-
:aria-expanded="isOpen"
|
|
74
|
-
aria-haspopup="listbox"
|
|
75
|
-
tabindex="-1"
|
|
76
|
-
>
|
|
77
|
-
Toggle
|
|
78
|
-
</button>
|
|
79
|
-
</div>
|
|
80
|
-
</template>
|
|
81
|
-
</Combobox>
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Keyboard interactions
|
|
85
|
-
|
|
86
|
-
When closed:
|
|
87
|
-
|
|
88
|
-
- `Space` / `Enter` - Opens the listbox.
|
|
89
|
-
- `Down Arrow` / `Home` - Opens the listbox and moves focus to the first item.
|
|
90
|
-
- `Up Arrow` / `End` - Opens the listbox and moves focus to the last item.
|
|
91
|
-
|
|
92
|
-
When open:
|
|
93
|
-
|
|
94
|
-
- `Space` - Selects the currently active item and closes the combobox (if it is not multiselectable).
|
|
95
|
-
- `Enter` - Selects the currently active item and closes the combobox.
|
|
96
|
-
- `Tab` - Selects the currently active item, closes the combobox and proceeds to the default tab action.
|
|
97
|
-
- `Down Arrow` - Moves focus to the next item.
|
|
98
|
-
- `Up Arrow` - Moves focus to the previous item.
|
|
99
|
-
- `Home` - Moves focus to the first item.
|
|
100
|
-
- `End` - Moves focus to the last item.
|
|
101
|
-
- `Escape` - Closes the listbox.
|
|
102
|
-
|
|
103
|
-
## ComboboxOptions
|
|
104
|
-
|
|
105
|
-
Wraps a collection of options, has no properties.
|
|
106
|
-
|
|
107
|
-
### ARIA roles and attributes
|
|
108
|
-
|
|
109
|
-
Options container has the [listbox](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role) role.
|
|
110
|
-
|
|
111
|
-
## ComboboxOption
|
|
112
|
-
|
|
113
|
-
### Properties
|
|
114
|
-
|
|
115
|
-
| Property | Required | Description | Type | Default |
|
|
116
|
-
| ------------ | -------- | ----------------------------- | --------- | -------------- |
|
|
117
|
-
| **value** | true | Value assigned to the item. | `any` | |
|
|
118
|
-
| **disabled** | false | Whether the item is disabled. | `boolean` | `false` |
|
|
119
|
-
| **id** | false | The ID of the item. | `string` | Auto-generated |
|
|
120
|
-
|
|
121
|
-
### Slots
|
|
122
|
-
|
|
123
|
-
#### default
|
|
124
|
-
|
|
125
|
-
| Attribute | Description | Type |
|
|
126
|
-
| -------------- | ------------------------------------- | --------- |
|
|
127
|
-
| **isSelected** | Whether the item is selected. | `boolean` |
|
|
128
|
-
| **isActive** | Whether the item is active (focused). | `boolean` |
|
|
129
|
-
|
|
130
|
-
### ARIA roles and attributes
|
|
131
|
-
|
|
132
|
-
Options have the [option](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/option_role) role.
|
|
133
|
-
|
|
134
|
-
The following attributes are automatically managed:
|
|
135
|
-
|
|
136
|
-
- [aria-selected](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected)
|
|
137
|
-
- [aria-disabled](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled)
|
|
138
|
-
|
|
139
|
-
## Using in a Form
|
|
140
|
-
|
|
141
|
-
When using Combobox in a form set the `name` attribute on the root component.
|
|
142
|
-
|
|
143
|
-
If multiple items are selected, the values will be submitted as an array:
|
|
144
|
-
|
|
145
|
-
```
|
|
146
|
-
name[0]=value1&name[1]=value2...&name[n]=valueN
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
If a value is an object each of its properties will be submitted as a separate field:
|
|
150
|
-
|
|
151
|
-
```js
|
|
152
|
-
const value = {
|
|
153
|
-
login: "johny1223",
|
|
154
|
-
email: "johny@gmail.com",
|
|
155
|
-
isAdmin: false,
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// Will be submitted as
|
|
159
|
-
// name[login]=johny1223&name[email]=johny@gmail.com&name[isAdmin]=false
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
Sometimes you may want to transform a value before submitting the form. Use the `formValue` attribute to provide a transformer function, if multiple items are selected the function will be call for each value:
|
|
163
|
-
|
|
164
|
-
```js
|
|
165
|
-
const value = {
|
|
166
|
-
login: "johny1223",
|
|
167
|
-
email: "johny@gmail.com",
|
|
168
|
-
isAdmin: false,
|
|
169
|
-
};
|
|
170
|
-
const formValue = (value) => value.login;
|
|
171
|
-
|
|
172
|
-
// Will be submitted as
|
|
173
|
-
// name=johny@gmail.com
|
|
174
|
-
```
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="d-demo">
|
|
3
|
-
<div class="d-demo__column">
|
|
4
|
-
<h5>Select-Only Combobox</h5>
|
|
5
|
-
<Combobox
|
|
6
|
-
v-model="fruit"
|
|
7
|
-
readonly
|
|
8
|
-
placeholder="Choose a fruit..."
|
|
9
|
-
class="d-input d-input--select"
|
|
10
|
-
>
|
|
11
|
-
<template #input="{ attrs }">
|
|
12
|
-
<button v-bind="attrs">ad</button>
|
|
13
|
-
</template>
|
|
14
|
-
<ComboboxOptions class="d-menu">
|
|
15
|
-
<ComboboxOption
|
|
16
|
-
v-for="opt in fruits"
|
|
17
|
-
:value="opt"
|
|
18
|
-
v-slot="{ isSelected }"
|
|
19
|
-
class="d-menu-item"
|
|
20
|
-
>
|
|
21
|
-
{{ opt }}
|
|
22
|
-
<svg
|
|
23
|
-
v-if="isSelected"
|
|
24
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
-
width="1rem"
|
|
26
|
-
height="1rem"
|
|
27
|
-
viewBox="0 0 256 256"
|
|
28
|
-
>
|
|
29
|
-
<path
|
|
30
|
-
fill="currentColor"
|
|
31
|
-
d="m232.49 80.49l-128 128a12 12 0 0 1-17 0l-56-56a12 12 0 1 1 17-17L96 183L215.51 63.51a12 12 0 0 1 17 17Z"
|
|
32
|
-
/>
|
|
33
|
-
</svg>
|
|
34
|
-
</ComboboxOption>
|
|
35
|
-
</ComboboxOptions>
|
|
36
|
-
</Combobox>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<div class="d-demo__column">
|
|
40
|
-
<h5>Select-Only Combobox</h5>
|
|
41
|
-
<Combobox
|
|
42
|
-
v-model="fruit"
|
|
43
|
-
readonly
|
|
44
|
-
placeholder="Choose a fruit..."
|
|
45
|
-
class="d-input d-input--select"
|
|
46
|
-
>
|
|
47
|
-
<ComboboxOptions class="d-menu">
|
|
48
|
-
<ComboboxOption
|
|
49
|
-
v-for="opt in fruits"
|
|
50
|
-
:value="opt"
|
|
51
|
-
v-slot="{ isSelected }"
|
|
52
|
-
class="d-menu-item"
|
|
53
|
-
>
|
|
54
|
-
{{ opt }}
|
|
55
|
-
<svg
|
|
56
|
-
v-if="isSelected"
|
|
57
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
58
|
-
width="1rem"
|
|
59
|
-
height="1rem"
|
|
60
|
-
viewBox="0 0 256 256"
|
|
61
|
-
>
|
|
62
|
-
<path
|
|
63
|
-
fill="currentColor"
|
|
64
|
-
d="m232.49 80.49l-128 128a12 12 0 0 1-17 0l-56-56a12 12 0 1 1 17-17L96 183L215.51 63.51a12 12 0 0 1 17 17Z"
|
|
65
|
-
/>
|
|
66
|
-
</svg>
|
|
67
|
-
</ComboboxOption>
|
|
68
|
-
</ComboboxOptions>
|
|
69
|
-
</Combobox>
|
|
70
|
-
</div>
|
|
71
|
-
|
|
72
|
-
<div class="d-demo__column">
|
|
73
|
-
<h5>Multiselectable Combobox</h5>
|
|
74
|
-
<Combobox
|
|
75
|
-
v-model="value"
|
|
76
|
-
:displayValue="(items: any[]) => items.map((i) => i.name).join(', ')"
|
|
77
|
-
readonly
|
|
78
|
-
placeholder="Select some people..."
|
|
79
|
-
class="d-input d-input--select"
|
|
80
|
-
>
|
|
81
|
-
<ComboboxOptions class="d-menu">
|
|
82
|
-
<ComboboxOption
|
|
83
|
-
v-for="opt in options"
|
|
84
|
-
:value="opt"
|
|
85
|
-
v-slot="{ isSelected }"
|
|
86
|
-
class="d-menu-item"
|
|
87
|
-
>
|
|
88
|
-
{{ opt.name }}
|
|
89
|
-
<svg
|
|
90
|
-
v-if="isSelected"
|
|
91
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
92
|
-
width="1rem"
|
|
93
|
-
height="1rem"
|
|
94
|
-
viewBox="0 0 256 256"
|
|
95
|
-
>
|
|
96
|
-
<path
|
|
97
|
-
fill="currentColor"
|
|
98
|
-
d="m232.49 80.49l-128 128a12 12 0 0 1-17 0l-56-56a12 12 0 1 1 17-17L96 183L215.51 63.51a12 12 0 0 1 17 17Z"
|
|
99
|
-
/>
|
|
100
|
-
</svg>
|
|
101
|
-
</ComboboxOption>
|
|
102
|
-
</ComboboxOptions>
|
|
103
|
-
</Combobox>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
</template>
|
|
107
|
-
|
|
108
|
-
<script setup lang="ts">
|
|
109
|
-
import { ref } from "vue";
|
|
110
|
-
import { Combobox, ComboboxOptions, ComboboxOption } from "../../../src/main";
|
|
111
|
-
|
|
112
|
-
const fruit = ref("");
|
|
113
|
-
const fruits = ["Apple", "Banana", "Grape", "Orange"];
|
|
114
|
-
|
|
115
|
-
const value = ref([]);
|
|
116
|
-
const options = [
|
|
117
|
-
{
|
|
118
|
-
id: 0,
|
|
119
|
-
name: "John Doe",
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
id: 1,
|
|
123
|
-
name: "Cris Doe",
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
id: 2,
|
|
127
|
-
name: "Michael Doe",
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
id: 3,
|
|
131
|
-
name: "Kim Doe",
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
id: 4,
|
|
135
|
-
name: "Boris Doe",
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
id: 5,
|
|
139
|
-
name: "Angelina Doe",
|
|
140
|
-
},
|
|
141
|
-
];
|
|
142
|
-
</script>
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="d-demo">
|
|
3
|
-
<Combobox
|
|
4
|
-
v-model="value"
|
|
5
|
-
:displayName="(i) => i?.name"
|
|
6
|
-
:customValue="(i) => ({ id: -1, name: i })"
|
|
7
|
-
@input="query = $event"
|
|
8
|
-
class="d-input"
|
|
9
|
-
>
|
|
10
|
-
<ComboboxOptions class="d-popup">
|
|
11
|
-
<div v-if="!filteredPeople.length">
|
|
12
|
-
Use <span>{{ query }}</span>
|
|
13
|
-
</div>
|
|
14
|
-
<ComboboxOption
|
|
15
|
-
v-for="opt in filteredPeople"
|
|
16
|
-
:key="opt.id"
|
|
17
|
-
:value="opt"
|
|
18
|
-
v-slot="{ active, selected }"
|
|
19
|
-
><div class="d-menu-item" :class="{ 'd-menu-item--active': active }">
|
|
20
|
-
{{ opt.name }}
|
|
21
|
-
</div></ComboboxOption
|
|
22
|
-
>
|
|
23
|
-
</ComboboxOptions>
|
|
24
|
-
</Combobox>
|
|
25
|
-
|
|
26
|
-
{{ value }}
|
|
27
|
-
</div>
|
|
28
|
-
</template>
|
|
29
|
-
|
|
30
|
-
<script setup lang="ts">
|
|
31
|
-
import { ref, computed } from "vue";
|
|
32
|
-
import { Combobox, ComboboxOptions, ComboboxOption } from "../../../src/main";
|
|
33
|
-
|
|
34
|
-
const value = ref();
|
|
35
|
-
const query = ref("");
|
|
36
|
-
const options = [
|
|
37
|
-
{
|
|
38
|
-
id: 0,
|
|
39
|
-
name: "John Doe",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: 1,
|
|
43
|
-
name: "Cris Doe",
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: 2,
|
|
47
|
-
name: "Michael Doe",
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: 3,
|
|
51
|
-
name: "Kim Doe",
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: 4,
|
|
55
|
-
name: "Boris Doe",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: 5,
|
|
59
|
-
name: "Angelina Doe",
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
const filteredPeople = computed(() =>
|
|
64
|
-
query.value === ""
|
|
65
|
-
? options
|
|
66
|
-
: options.filter((person) =>
|
|
67
|
-
person.name
|
|
68
|
-
.toLowerCase()
|
|
69
|
-
.replace(/\s+/g, "")
|
|
70
|
-
.includes(query.value.toLowerCase().replace(/\s+/g, ""))
|
|
71
|
-
)
|
|
72
|
-
);
|
|
73
|
-
</script>
|
|
74
|
-
|
|
75
|
-
<style scoped></style>
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="d-demo">
|
|
3
|
-
<Combobox v-model="value" :displayValue="() => ''" activatorId="testid">
|
|
4
|
-
<template #input="{ popoverId, attrs, toggle, isOpen }">
|
|
5
|
-
<div id="testid" class="d-combobox">
|
|
6
|
-
<div class="d-combobox__tags">
|
|
7
|
-
<div v-for="item in value.slice(0, 3)" class="d-tag">
|
|
8
|
-
{{ item.name }}
|
|
9
|
-
</div>
|
|
10
|
-
<div v-if="value.length > 3">+{{ value.length - 3 }}</div>
|
|
11
|
-
</div>
|
|
12
|
-
<input
|
|
13
|
-
type="text"
|
|
14
|
-
v-bind="attrs"
|
|
15
|
-
@input="query = $event.target.value"
|
|
16
|
-
@focus="query = ''"
|
|
17
|
-
placeholder="Type to search..."
|
|
18
|
-
autocomplete="off"
|
|
19
|
-
/>
|
|
20
|
-
<button
|
|
21
|
-
@click="toggle"
|
|
22
|
-
:aria-controls="isOpen ? popoverId : undefined"
|
|
23
|
-
:aria-expanded="isOpen"
|
|
24
|
-
aria-haspopup="listbox"
|
|
25
|
-
tabindex="-1"
|
|
26
|
-
>
|
|
27
|
-
<svg
|
|
28
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
-
width="24"
|
|
30
|
-
height="24"
|
|
31
|
-
viewBox="0 0 20 20"
|
|
32
|
-
>
|
|
33
|
-
<path
|
|
34
|
-
fill="currentColor"
|
|
35
|
-
fill-rule="evenodd"
|
|
36
|
-
d="M10 3a.75.75 0 0 1 .55.24l3.25 3.5a.75.75 0 1 1-1.1 1.02L10 4.852L7.3 7.76a.75.75 0 0 1-1.1-1.02l3.25-3.5A.75.75 0 0 1 10 3Zm-3.76 9.2a.75.75 0 0 1 1.06.04l2.7 2.908l2.7-2.908a.75.75 0 1 1 1.1 1.02l-3.25 3.5a.75.75 0 0 1-1.1 0l-3.25-3.5a.75.75 0 0 1 .04-1.06Z"
|
|
37
|
-
clip-rule="evenodd"
|
|
38
|
-
/>
|
|
39
|
-
</svg>
|
|
40
|
-
</button>
|
|
41
|
-
</div>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<ComboboxOptions class="d-menu">
|
|
45
|
-
<div class="d-no-options" v-if="filteredPeople.length == 0">
|
|
46
|
-
Nothing found for <strong>"{{ query }}"</strong>
|
|
47
|
-
</div>
|
|
48
|
-
<ComboboxOption
|
|
49
|
-
v-for="opt in filteredPeople"
|
|
50
|
-
:key="opt.id"
|
|
51
|
-
:value="opt"
|
|
52
|
-
:disabled="opt.disabled"
|
|
53
|
-
v-slot="{ isSelected }"
|
|
54
|
-
class="d-menu-item"
|
|
55
|
-
>
|
|
56
|
-
{{ opt.name }}
|
|
57
|
-
<svg
|
|
58
|
-
v-if="isSelected"
|
|
59
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
-
width="1rem"
|
|
61
|
-
height="1rem"
|
|
62
|
-
viewBox="0 0 256 256"
|
|
63
|
-
>
|
|
64
|
-
<path
|
|
65
|
-
fill="currentColor"
|
|
66
|
-
d="m232.49 80.49l-128 128a12 12 0 0 1-17 0l-56-56a12 12 0 1 1 17-17L96 183L215.51 63.51a12 12 0 0 1 17 17Z"
|
|
67
|
-
/>
|
|
68
|
-
</svg>
|
|
69
|
-
</ComboboxOption>
|
|
70
|
-
</ComboboxOptions>
|
|
71
|
-
</Combobox>
|
|
72
|
-
</div>
|
|
73
|
-
</template>
|
|
74
|
-
|
|
75
|
-
<script setup lang="ts">
|
|
76
|
-
import { ref, computed, watch } from "vue";
|
|
77
|
-
import { Combobox, ComboboxOptions, ComboboxOption } from "../../../src/main";
|
|
78
|
-
|
|
79
|
-
const value = ref([]);
|
|
80
|
-
const options = [
|
|
81
|
-
{
|
|
82
|
-
id: 0,
|
|
83
|
-
name: "John Doe",
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
id: 1,
|
|
87
|
-
name: "Cris Doe",
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
id: 2,
|
|
91
|
-
name: "Michael Doe",
|
|
92
|
-
disabled: true,
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
id: 3,
|
|
96
|
-
name: "Kim Doe",
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
id: 4,
|
|
100
|
-
name: "Boris Doe",
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: 5,
|
|
104
|
-
name: "Angelina Doe",
|
|
105
|
-
},
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
const query = ref("");
|
|
109
|
-
const filteredPeople = computed(() =>
|
|
110
|
-
query.value === ""
|
|
111
|
-
? options
|
|
112
|
-
: options.filter((person) =>
|
|
113
|
-
person.name
|
|
114
|
-
.toLowerCase()
|
|
115
|
-
.replace(/\s+/g, "")
|
|
116
|
-
.includes(query.value.toLowerCase().replace(/\s+/g, ""))
|
|
117
|
-
)
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
watch(
|
|
121
|
-
value,
|
|
122
|
-
() => {
|
|
123
|
-
query.value = "";
|
|
124
|
-
},
|
|
125
|
-
{ deep: true }
|
|
126
|
-
);
|
|
127
|
-
</script>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="d-demo">
|
|
3
|
-
<Input
|
|
4
|
-
v-model="value"
|
|
5
|
-
:mask="mask"
|
|
6
|
-
v-model:unmasked="unmaskedValue"
|
|
7
|
-
v-model:isValid="isValid"
|
|
8
|
-
v-model:validationMessage="validationMessage"
|
|
9
|
-
class="d-input"
|
|
10
|
-
type="tel"
|
|
11
|
-
/>
|
|
12
|
-
<div>
|
|
13
|
-
<div>val: {{ value }}</div>
|
|
14
|
-
<div>Unmasked value: {{ unmaskedValue }}</div>
|
|
15
|
-
<div>Is valid: {{ isValid }}</div>
|
|
16
|
-
<div>Validation message: {{ validationMessage }}</div>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</template>
|
|
20
|
-
|
|
21
|
-
<script setup lang="ts">
|
|
22
|
-
import { ref } from "vue";
|
|
23
|
-
import { Input } from "../../../src/main";
|
|
24
|
-
|
|
25
|
-
const value = ref("test");
|
|
26
|
-
const mask = {
|
|
27
|
-
mask: "{+7} (000) 000-00-00",
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const unmaskedValue = ref("");
|
|
31
|
-
const isValid = ref();
|
|
32
|
-
const validationMessage = ref("");
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<style scoped></style>
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="d-demo">
|
|
3
|
-
<div>
|
|
4
|
-
<input type="checkbox" v-model="multiple" /> Multiselectable
|
|
5
|
-
<input type="checkbox" v-model="loop" /> Loop
|
|
6
|
-
<div>Value: {{ value }}</div>
|
|
7
|
-
<Listbox
|
|
8
|
-
class="list"
|
|
9
|
-
:multiselectable="multiple"
|
|
10
|
-
:loop="loop"
|
|
11
|
-
v-model="value"
|
|
12
|
-
>
|
|
13
|
-
<ListboxOption value="1" class="list-item"> Item 1 </ListboxOption>
|
|
14
|
-
<ListboxOption value="2" class="list-item"> Item 2 </ListboxOption>
|
|
15
|
-
<ListboxOption value="3" class="list-item"> Item 3 </ListboxOption>
|
|
16
|
-
</Listbox>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</template>
|
|
20
|
-
|
|
21
|
-
<script setup lang="ts">
|
|
22
|
-
import { ref, watch } from "vue";
|
|
23
|
-
import { Listbox, ListboxOption } from "../../../src/main";
|
|
24
|
-
|
|
25
|
-
const value = ref();
|
|
26
|
-
const multiple = ref(false);
|
|
27
|
-
const loop = ref(false);
|
|
28
|
-
|
|
29
|
-
watch(multiple, (val) => {
|
|
30
|
-
if (val) {
|
|
31
|
-
value.value = [value.value];
|
|
32
|
-
} else {
|
|
33
|
-
value.value = value.value.length ? value.value[0] : undefined;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
<style>
|
|
39
|
-
.list {
|
|
40
|
-
padding: 0.5rem;
|
|
41
|
-
border: 2px blue solid;
|
|
42
|
-
border-radius: 0.5rem;
|
|
43
|
-
display: flex;
|
|
44
|
-
flex-direction: column;
|
|
45
|
-
gap: 0.25rem;
|
|
46
|
-
}
|
|
47
|
-
.list-item {
|
|
48
|
-
padding: 0.25rem 0.5rem;
|
|
49
|
-
border-radius: 0.25rem;
|
|
50
|
-
background-color: Lavender;
|
|
51
|
-
outline: none;
|
|
52
|
-
}
|
|
53
|
-
.list-item[aria-selected="true"] {
|
|
54
|
-
background-color: blue;
|
|
55
|
-
color: white;
|
|
56
|
-
}
|
|
57
|
-
.list-item[aria-selected="false"]:hover {
|
|
58
|
-
background-color: LightSkyBlue;
|
|
59
|
-
}
|
|
60
|
-
.list[aria-multiselectable="true"] .list-item[data-active="true"] {
|
|
61
|
-
outline: 3px solid DeepPink;
|
|
62
|
-
outline-offset: 2px;
|
|
63
|
-
}
|
|
64
|
-
</style>
|