vue-composable-ui 0.0.1 → 1.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.
- package/LICENSE +1 -1
- package/README.md +5 -1
- package/dist/composable-ui.js +1114 -0
- package/dist/composable-ui.umd.cjs +1 -0
- package/dist/types/components/combobox/comboboxHiddenInput.vue.d.ts +8 -0
- package/dist/types/components/combobox/comboboxInput.vue.d.ts +9 -0
- package/dist/types/components/combobox/comboboxOption.vue.d.ts +22 -0
- package/dist/types/components/combobox/comboboxOptions.vue.d.ts +11 -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 +22 -0
- package/dist/types/components/menu/menuItem.vue.d.ts +26 -0
- package/dist/types/components/menu/menuItems.vue.d.ts +11 -0
- package/dist/types/components/popover/popoverDialog.vue.d.ts +11 -0
- package/dist/types/components/tabs/tab.vue.d.ts +19 -0
- package/dist/types/components/tabs/tabContainer.vue.d.ts +18 -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 +36 -0
- package/dist/types/composables/formControl.d.ts +48 -0
- package/dist/types/composables/list.d.ts +103 -0
- package/dist/types/composables/listOption.d.ts +30 -0
- package/dist/types/composables/popover.d.ts +68 -0
- package/{src/main.ts → dist/types/main.d.ts} +3 -44
- package/dist/types/utils/element.d.ts +3 -0
- package/dist/types/utils/id.d.ts +1 -0
- package/package.json +19 -6
- 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/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,65 +1,24 @@
|
|
|
1
|
-
// Composables
|
|
2
|
-
|
|
3
1
|
import { usePopover } from "./composables/popover";
|
|
4
2
|
import { useList } from "./composables/list";
|
|
5
3
|
import { useListOption } from "./composables/listOption";
|
|
6
4
|
import { useFormControl } from "./composables/formControl";
|
|
7
|
-
|
|
8
|
-
// Utils
|
|
9
|
-
|
|
10
5
|
import { useHTMLElement } from "./utils/element";
|
|
11
6
|
import { useSequentialId } from "./utils/id";
|
|
12
|
-
|
|
13
|
-
// Components
|
|
14
|
-
|
|
7
|
+
export * from "./components/injectionKeys";
|
|
15
8
|
import Listbox from "./components/listbox/listbox.vue";
|
|
16
9
|
import ListboxOption from "./components/listbox/listboxOption.vue";
|
|
17
|
-
|
|
18
10
|
import TabContainer from "./components/tabs/tabContainer.vue";
|
|
19
11
|
import TabList from "./components/tabs/tabList.vue";
|
|
20
12
|
import Tab from "./components/tabs/tab.vue";
|
|
21
13
|
import TabPanel from "./components/tabs/tabPanel.vue";
|
|
22
|
-
|
|
23
14
|
import Popover from "./components/popover/popover.vue";
|
|
24
15
|
import PopoverDialog from "./components/popover/popoverDialog.vue";
|
|
25
|
-
|
|
26
16
|
import Tooltip from "./components/tooltip.vue";
|
|
27
|
-
|
|
28
17
|
import Menu from "./components/menu/menu.vue";
|
|
29
18
|
import MenuItems from "./components/menu/menuItems.vue";
|
|
30
19
|
import MenuItem from "./components/menu/menuItem.vue";
|
|
31
|
-
|
|
32
20
|
import Combobox from "./components/combobox/combobox.vue";
|
|
21
|
+
import ComboboxInput from "./components/combobox/comboboxInput.vue";
|
|
33
22
|
import ComboboxOptions from "./components/combobox/comboboxOptions.vue";
|
|
34
23
|
import ComboboxOption from "./components/combobox/comboboxOption.vue";
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
usePopover,
|
|
38
|
-
useList,
|
|
39
|
-
useListOption,
|
|
40
|
-
useFormControl,
|
|
41
|
-
//
|
|
42
|
-
useHTMLElement,
|
|
43
|
-
useSequentialId,
|
|
44
|
-
//
|
|
45
|
-
Listbox,
|
|
46
|
-
ListboxOption,
|
|
47
|
-
//
|
|
48
|
-
Popover,
|
|
49
|
-
PopoverDialog,
|
|
50
|
-
//
|
|
51
|
-
TabContainer,
|
|
52
|
-
TabList,
|
|
53
|
-
Tab,
|
|
54
|
-
TabPanel,
|
|
55
|
-
//
|
|
56
|
-
Tooltip,
|
|
57
|
-
//
|
|
58
|
-
Menu,
|
|
59
|
-
MenuItems,
|
|
60
|
-
MenuItem,
|
|
61
|
-
//
|
|
62
|
-
Combobox,
|
|
63
|
-
ComboboxOptions,
|
|
64
|
-
ComboboxOption,
|
|
65
|
-
};
|
|
24
|
+
export { usePopover, useList, useListOption, useFormControl, useHTMLElement, useSequentialId, Listbox, ListboxOption, Popover, PopoverDialog, TabContainer, TabList, Tab, TabPanel, Tooltip, Menu, MenuItems, MenuItem, Combobox, ComboboxInput, ComboboxOptions, ComboboxOption, };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
export type TemplateRefOrSelector<E extends HTMLElement = HTMLElement> = Ref<E | undefined> | E | string;
|
|
3
|
+
export declare function useHTMLElement<E extends HTMLElement = HTMLElement>(el: TemplateRefOrSelector<E>): Ref<E | undefined, E | undefined> | ([E | undefined] extends [Ref<any, any>] ? import("@vue/shared").IfAny<Ref<any, any> & E, Ref<Ref<any, any> & E, Ref<any, any> & E>, Ref<any, any> & E> : Ref<import("vue").UnwrapRef<E> | undefined, E | import("vue").UnwrapRef<E> | undefined>);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSequentialId(base?: string): string;
|
package/package.json
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-composable-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"repository":
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/dzapletin/vue-composable-ui.git"
|
|
8
|
+
},
|
|
6
9
|
"main": "./dist/composable-ui.umd.cjs",
|
|
7
10
|
"module": "./dist/composable-ui.js",
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
|
-
"import":
|
|
11
|
-
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/types/main.d.ts",
|
|
15
|
+
"default": "./dist/composable-ui.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/types/main.d.ts",
|
|
19
|
+
"default": "./dist/composable-ui.umd.cjs"
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
},
|
|
14
23
|
"types": "./dist/types/main.d.ts",
|
|
@@ -20,10 +29,14 @@
|
|
|
20
29
|
"docs:build": "vitepress build docs",
|
|
21
30
|
"docs:preview": "vitepress preview docs"
|
|
22
31
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"vue": "^3.5.12"
|
|
25
37
|
},
|
|
26
38
|
"devDependencies": {
|
|
39
|
+
"vue": "^3.5.12",
|
|
27
40
|
"@types/node": "^22.4.0",
|
|
28
41
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
29
42
|
"sass": "^1.69.5",
|
|
@@ -1,21 +0,0 @@
|
|
|
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 }}
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
package/.vscode/extensions.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,155 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -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
|
-
```
|