vue-composable-ui 0.0.1

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.
Files changed (58) hide show
  1. package/.github/workflows/deploy.yml +21 -0
  2. package/.github/workflows/docs.yml +62 -0
  3. package/.vscode/extensions.json +7 -0
  4. package/LICENSE +21 -0
  5. package/README.md +3 -0
  6. package/docs/.vitepress/config.mts +40 -0
  7. package/docs/.vitepress/theme/index.js +4 -0
  8. package/docs/.vitepress/theme/style.scss +155 -0
  9. package/docs/components/combobox.md +174 -0
  10. package/docs/components/demos/combobox.vue +142 -0
  11. package/docs/components/demos/combobox_autocomplete.vue +75 -0
  12. package/docs/components/demos/combobox_tags.vue +127 -0
  13. package/docs/components/demos/input.vue +35 -0
  14. package/docs/components/demos/listbox.vue +64 -0
  15. package/docs/components/demos/menu.vue +93 -0
  16. package/docs/components/demos/popover.vue +16 -0
  17. package/docs/components/demos/tabs.vue +59 -0
  18. package/docs/components/demos/tooltip.vue +27 -0
  19. package/docs/components/listbox.md +9 -0
  20. package/docs/components/menu.md +121 -0
  21. package/docs/components/popover.md +82 -0
  22. package/docs/components/tabs.md +9 -0
  23. package/docs/components/tooltip.md +78 -0
  24. package/docs/composables/form-control.md +130 -0
  25. package/docs/composables/list-option.md +47 -0
  26. package/docs/composables/list.md +192 -0
  27. package/docs/composables/popover.md +90 -0
  28. package/docs/index.md +24 -0
  29. package/docs/intro.md +0 -0
  30. package/package.json +35 -0
  31. package/src/components/combobox/combobox.vue +229 -0
  32. package/src/components/combobox/comboboxFormInput.vue +33 -0
  33. package/src/components/combobox/comboboxOption.vue +52 -0
  34. package/src/components/combobox/comboboxOptions.vue +17 -0
  35. package/src/components/injectionKeys.ts +50 -0
  36. package/src/components/listbox/listbox.vue +91 -0
  37. package/src/components/listbox/listboxOption.vue +37 -0
  38. package/src/components/menu/menu.vue +100 -0
  39. package/src/components/menu/menuItem.vue +86 -0
  40. package/src/components/menu/menuItems.vue +51 -0
  41. package/src/components/popover/popover.vue +68 -0
  42. package/src/components/popover/popoverDialog.vue +35 -0
  43. package/src/components/tabs/tab.vue +35 -0
  44. package/src/components/tabs/tabContainer.vue +50 -0
  45. package/src/components/tabs/tabList.vue +52 -0
  46. package/src/components/tabs/tabPanel.vue +36 -0
  47. package/src/components/tooltip.vue +115 -0
  48. package/src/composables/formControl.ts +144 -0
  49. package/src/composables/list.ts +326 -0
  50. package/src/composables/listOption.ts +80 -0
  51. package/src/composables/popover.ts +306 -0
  52. package/src/main.ts +65 -0
  53. package/src/utils/element.ts +19 -0
  54. package/src/utils/id.ts +5 -0
  55. package/src/vite-env.d.ts +1 -0
  56. package/tsconfig.json +27 -0
  57. package/tsconfig.node.json +10 -0
  58. package/vite.config.ts +28 -0
@@ -0,0 +1,21 @@
1
+ name: Publish Package to npmjs
2
+ on:
3
+ release:
4
+ types: [published]
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ # Setup .npmrc file to publish to npm
14
+ - uses: actions/setup-node@v4
15
+ with:
16
+ node-version: "20.x"
17
+ registry-url: "https://registry.npmjs.org"
18
+ - run: npm ci
19
+ - run: npm publish --provenance --access public
20
+ env:
21
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,62 @@
1
+ name: Deploy Docs to Pages
2
+
3
+ on:
4
+ # Runs on pushes targeting the `main` branch. Change this to `master` if you're
5
+ # using the `master` branch as the default branch.
6
+ push:
7
+ branches: [main]
8
+
9
+ # Allows you to run this workflow manually from the Actions tab
10
+ workflow_dispatch:
11
+
12
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13
+ permissions:
14
+ contents: read
15
+ pages: write
16
+ id-token: write
17
+
18
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19
+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20
+ concurrency:
21
+ group: pages
22
+ cancel-in-progress: false
23
+
24
+ jobs:
25
+ # Build job
26
+ build:
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ - name: Checkout
30
+ uses: actions/checkout@v4
31
+ with:
32
+ fetch-depth: 0 # Not needed if lastUpdated is not enabled
33
+ # - uses: pnpm/action-setup@v3 # Uncomment this if you're using pnpm
34
+ # - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
35
+ - name: Setup Node
36
+ uses: actions/setup-node@v4
37
+ with:
38
+ node-version: 20
39
+ cache: npm # or pnpm / yarn
40
+ - name: Setup Pages
41
+ uses: actions/configure-pages@v4
42
+ - name: Install dependencies
43
+ run: npm ci # or pnpm install / yarn install / bun install
44
+ - name: Build with VitePress
45
+ run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
46
+ - name: Upload artifact
47
+ uses: actions/upload-pages-artifact@v3
48
+ with:
49
+ path: docs/.vitepress/dist
50
+
51
+ # Deployment job
52
+ deploy:
53
+ environment:
54
+ name: github-pages
55
+ url: ${{ steps.deployment.outputs.page_url }}
56
+ needs: build
57
+ runs-on: ubuntu-latest
58
+ name: Deploy
59
+ steps:
60
+ - name: Deploy to GitHub Pages
61
+ id: deployment
62
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,7 @@
1
+ {
2
+ "recommendations": [
3
+ "Vue.volar",
4
+ "Vue.vscode-typescript-vue-plugin",
5
+ "puppet.puppet-vscode"
6
+ ]
7
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 dzapletin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Vue Composable UI (WIP)
2
+
3
+ Docs - https://dzapletin.github.io/vue-composable-ui/
@@ -0,0 +1,40 @@
1
+ import { defineConfig } from "vitepress";
2
+
3
+ // https://vitepress.dev/reference/site-config
4
+ export default defineConfig({
5
+ title: "Vue Composable UI",
6
+ description: "A truly headless UI framework",
7
+ base: "/vue-composable-ui/",
8
+ themeConfig: {
9
+ // https://vitepress.dev/reference/default-theme-config
10
+ nav: [{ text: "Home", link: "/" }],
11
+
12
+ sidebar: [
13
+ {
14
+ text: "Composables",
15
+ items: [
16
+ { text: "useList", link: "/composables/list" },
17
+ { text: "useListOption", link: "/composables/list-option" },
18
+ { text: "usePopover", link: "/composables/popover" },
19
+ { text: "useFormControl", link: "/composables/form-control" },
20
+ ],
21
+ },
22
+ {
23
+ text: "Components",
24
+ items: [
25
+ { text: "Listbox", link: "/components/listbox" },
26
+ { text: "Tabs", link: "/components/tabs" },
27
+ { text: "Popover", link: "/components/popover" },
28
+ { text: "Tooltip", link: "/components/tooltip" },
29
+ { text: "Menu", link: "/components/menu" },
30
+ { text: "Combobox", link: "/components/combobox" },
31
+ ],
32
+ },
33
+ ],
34
+
35
+ socialLinks: [
36
+ { icon: "github", link: "https://github.com/dzapletin/vue-composable-ui" },
37
+ ],
38
+ },
39
+ lastUpdated: true,
40
+ });
@@ -0,0 +1,4 @@
1
+ import DefaultTheme from "vitepress/theme";
2
+ import "./style.scss";
3
+
4
+ export default DefaultTheme;
@@ -0,0 +1,155 @@
1
+ .d-demo {
2
+ display: flex;
3
+ gap: 1rem;
4
+ flex-wrap: wrap;
5
+ justify-content: center;
6
+ justify-items: stretch;
7
+ position: relative;
8
+ border-radius: 1rem;
9
+ padding: 5rem;
10
+ background: linear-gradient(90deg, #e3ffe7 0%, #d9e7ff 100%);
11
+ overflow: hidden;
12
+
13
+ &__column {
14
+ flex-grow: 1;
15
+ }
16
+
17
+ h5 {
18
+ font-weight: 600;
19
+ line-height: 24px;
20
+ font-size: 16px;
21
+ margin-bottom: 0.5rem;
22
+ color: black;
23
+ }
24
+ }
25
+
26
+ .d-demo [tabindex]:not([tabindex="-1"]):focus {
27
+ outline: 3px solid DeepPink;
28
+ outline-offset: 2px;
29
+ }
30
+
31
+ .d-pointer {
32
+ cursor: pointer;
33
+ }
34
+
35
+ .d-btn {
36
+ padding: 0.375rem 0.75rem;
37
+ border-radius: 0.25rem;
38
+ font-size: 1rem;
39
+ line-height: 1.5;
40
+ border: 1px solid transparent;
41
+ background-color: #6267ec;
42
+ color: white;
43
+
44
+ &:hover {
45
+ background-color: #5047e0;
46
+ }
47
+ }
48
+
49
+ .d-tooltip {
50
+ background-color: rgba($color: #000, $alpha: 0.8);
51
+ color: white;
52
+ border-radius: 0.25rem;
53
+ padding: 0.25rem 0.5rem;
54
+ margin: 0.5rem 0;
55
+ }
56
+
57
+ .d-popover {
58
+ z-index: 20;
59
+ outline: none;
60
+ padding: 1rem;
61
+ background: white;
62
+ color: black;
63
+ border-radius: 0.5rem;
64
+ box-shadow: 0 14px 44px rgba(0, 0, 0, 0.12), 0 3px 9px rgba(0, 0, 0, 0.12);
65
+ margin: 0.5rem 0;
66
+
67
+ &--h {
68
+ margin: 0 0.5rem;
69
+ }
70
+ }
71
+
72
+ .d-menu {
73
+ @extend .d-popover;
74
+ padding: 0.25rem;
75
+ margin: 0.25rem 0;
76
+ }
77
+
78
+ .d-menu-item {
79
+ display: flex;
80
+ gap: 0.5rem;
81
+ align-items: center;
82
+ justify-content: space-between;
83
+ padding: 0.25rem 0.5rem;
84
+ outline: none;
85
+ border-radius: 0.25rem;
86
+ cursor: pointer;
87
+ user-select: none;
88
+ &[aria-disabled="true"] {
89
+ color: gray;
90
+ cursor: default;
91
+ }
92
+ &[data-active="true"] {
93
+ background-color: #6267ec;
94
+ color: white;
95
+ }
96
+ }
97
+
98
+ .d-input {
99
+ padding: 0.375rem 0.75rem;
100
+ border-radius: 0.25rem;
101
+ background: white;
102
+ border: 1px solid #d1d5da;
103
+ outline: none;
104
+ width: 100%;
105
+ max-width: 100%;
106
+ color: black;
107
+ &:focus {
108
+ border-color: #6267ec;
109
+ }
110
+
111
+ &--select {
112
+ cursor: pointer;
113
+ position: relative;
114
+ &::after {
115
+ content: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMS41IiBkPSJNOC4yNSAxNUwxMiAxOC43NUwxNS43NSAxNW0tNy41LTZMMTIgNS4yNUwxNS43NSA5Ii8+PC9zdmc+");
116
+ position: absolute;
117
+ right: 0;
118
+ top: 0;
119
+ }
120
+ }
121
+ }
122
+
123
+ .d-combobox {
124
+ @extend .d-input;
125
+ padding: 0.25rem;
126
+ display: flex;
127
+ gap: 0.25rem;
128
+
129
+ &__tags {
130
+ display: flex;
131
+ gap: 0.25rem;
132
+ align-items: center;
133
+ color: gray;
134
+ }
135
+
136
+ input {
137
+ flex-grow: 1;
138
+ width: 100%;
139
+ padding: 0.125rem 0.5rem;
140
+ }
141
+ }
142
+
143
+ .d-tag {
144
+ background-color: #6267ec;
145
+ color: white;
146
+ border-radius: 0.25rem;
147
+ padding: 0.125rem 0.5rem;
148
+ white-space: nowrap;
149
+ }
150
+
151
+ .d-no-options {
152
+ padding: 0.25rem 0.5rem;
153
+ text-align: center;
154
+ color: gray;
155
+ }
@@ -0,0 +1,174 @@
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
+ ```
@@ -0,0 +1,142 @@
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>