@vueland/ui 0.0.2 → 0.0.3
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/README.md +55 -45
- package/dist/components/CApp/CApp.js +2 -2
- package/dist/components/CAutocomplete/CAutocomplete.js +23 -6
- package/dist/components/CCheckbox/CCheckbox.js +1 -1
- package/dist/components/CDateInput/CDateInput.js +0 -1
- package/dist/components/CDatePicker/index4.js +1 -1
- package/dist/components/CDatePicker/index6.js +1 -1
- package/dist/components/CDialog/index.js +1 -1
- package/dist/components/CDialog/index2.js +1 -1
- package/dist/components/CInput/CInput.js +23 -14
- package/dist/components/CList/CList.js +36 -17
- package/dist/components/CList/CListItem.js +15 -10
- package/dist/components/CMenu/CMenu.js +29 -31
- package/dist/components/CSelect/CSelect.js +26 -6
- package/dist/components/CTextField/CTextField.js +1 -1
- package/dist/components/CTooltip/CTooltip.js +12 -8
- package/dist/components/CTooltip/index.js +2 -2
- package/dist/components/CTooltip/index2.js +5 -0
- package/dist/components/index.d.ts +174 -188
- package/dist/components/index.js +1 -1
- package/dist/composables/index.d.ts +124 -590
- package/dist/composables/index.js +11 -6
- package/dist/composables/use-activator.js +1 -13
- package/dist/composables/{use-app-scroll.js → use-application-scroll.js} +2 -2
- package/dist/composables/use-aria-activator.js +15 -0
- package/dist/composables/use-aria-dialog.js +16 -0
- package/dist/composables/use-aria-field.js +18 -0
- package/dist/composables/use-aria-listbox.js +14 -0
- package/dist/composables/use-aria-toggle.js +15 -0
- package/dist/composables/use-auto-position.js +51 -51
- package/dist/composables/use-breakpoints.js +8 -0
- package/dist/composables/use-delay-actions.js +9 -8
- package/dist/composables/use-display.js +4 -4
- package/dist/composables/use-presets.js +1 -3
- package/dist/constants/aria.js +32 -0
- package/dist/constants/index.d.ts +78 -37
- package/dist/constants/index.js +1 -0
- package/dist/css/lib.css +1 -0
- package/dist/css/utils/_grid.css +1 -0
- package/dist/css/utils/_grid.js +3 -0
- package/dist/css/utils/_radius.css +1 -1
- package/dist/css/utils/_typography.css +1 -1
- package/dist/library.js +5 -5
- package/dist/scss/lib.scss +26 -0
- package/dist/scss/styles.scss +1 -0
- package/dist/scss/utils/_grid.scss +173 -0
- package/dist/scss/utils/_radius.scss +4 -4
- package/dist/scss/utils/_typography.scss +13 -0
- package/dist/styles.css +1 -1
- package/dist/temp-types/src/components/CAutocomplete/CAutocomplete.vue.d.ts +1 -1
- package/dist/temp-types/src/components/CAutocomplete/CAutocomplete.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CCheckbox/CCheckbox.vue.d.ts +1 -1
- package/dist/temp-types/src/components/CCheckbox/CheckboxElement.vue.d.ts +1 -1
- package/dist/temp-types/src/components/CDateInput/CDateInput.vue.d.ts +2 -2
- package/dist/temp-types/src/components/CDateInput/CDateInput.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CGrid/CRow.d.ts +1 -1
- package/dist/temp-types/src/components/CInput/CInput.vue.d.ts +2 -2
- package/dist/temp-types/src/components/CInput/CInput.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CInput/types.d.ts +2 -2
- package/dist/temp-types/src/components/CInput/types.d.ts.map +1 -1
- package/dist/temp-types/src/components/CList/CList.vue.d.ts +5 -1
- package/dist/temp-types/src/components/CList/CList.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CList/CListItem.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CList/types.d.ts +3 -1
- package/dist/temp-types/src/components/CList/types.d.ts.map +1 -1
- package/dist/temp-types/src/components/CMenu/CMenu.vue.d.ts +4 -4
- package/dist/temp-types/src/components/CMenu/CMenu.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CMenu/types.d.ts +2 -2
- package/dist/temp-types/src/components/CMenu/types.d.ts.map +1 -1
- package/dist/temp-types/src/components/CRadio/CRadio.vue.d.ts +1 -1
- package/dist/temp-types/src/components/CSelect/CSelect.vue.d.ts +1 -1
- package/dist/temp-types/src/components/CSelect/CSelect.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CSelectControl/CSelectControl.vue.d.ts +1 -1
- package/dist/temp-types/src/components/CTextField/CTextField.vue.d.ts +1 -1
- package/dist/temp-types/src/components/CTextField/CTextField.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CTextField/types.d.ts +1 -1
- package/dist/temp-types/src/components/CTooltip/CTooltip.vue.d.ts +3 -1
- package/dist/temp-types/src/components/CTooltip/CTooltip.vue.d.ts.map +1 -1
- package/dist/temp-types/src/components/CTooltip/index.d.ts +7 -1
- package/dist/temp-types/src/components/CTooltip/index.d.ts.map +1 -1
- package/dist/temp-types/src/composables/index.d.ts +7 -2
- package/dist/temp-types/src/composables/index.d.ts.map +1 -1
- package/dist/temp-types/src/composables/use-activator.d.ts +0 -153
- package/dist/temp-types/src/composables/use-activator.d.ts.map +1 -1
- package/dist/temp-types/src/composables/{use-app-scroll.d.ts → use-application-scroll.d.ts} +2 -2
- package/dist/temp-types/src/composables/use-application-scroll.d.ts.map +1 -0
- package/dist/temp-types/src/composables/use-aria-activator.d.ts +8 -0
- package/dist/temp-types/src/composables/use-aria-activator.d.ts.map +1 -0
- package/dist/temp-types/src/composables/use-aria-dialog.d.ts +9 -0
- package/dist/temp-types/src/composables/use-aria-dialog.d.ts.map +1 -0
- package/dist/temp-types/src/composables/use-aria-field.d.ts +13 -0
- package/dist/temp-types/src/composables/use-aria-field.d.ts.map +1 -0
- package/dist/temp-types/src/composables/use-aria-listbox.d.ts +8 -0
- package/dist/temp-types/src/composables/use-aria-listbox.d.ts.map +1 -0
- package/dist/temp-types/src/composables/use-aria-toggle.d.ts +11 -0
- package/dist/temp-types/src/composables/use-aria-toggle.d.ts.map +1 -0
- package/dist/temp-types/src/composables/use-auto-position.d.ts +4 -284
- package/dist/temp-types/src/composables/use-auto-position.d.ts.map +1 -1
- package/dist/temp-types/src/composables/use-breakpoints.d.ts +1 -0
- package/dist/temp-types/src/composables/use-breakpoints.d.ts.map +1 -1
- package/dist/temp-types/src/composables/use-delay-actions.d.ts +0 -26
- package/dist/temp-types/src/composables/use-delay-actions.d.ts.map +1 -1
- package/dist/temp-types/src/composables/use-display.d.ts +22 -49
- package/dist/temp-types/src/composables/use-display.d.ts.map +1 -1
- package/dist/temp-types/src/composables/use-presets.d.ts +0 -14
- package/dist/temp-types/src/composables/use-presets.d.ts.map +1 -1
- package/dist/temp-types/src/constants/aria.d.ts +35 -0
- package/dist/temp-types/src/constants/aria.d.ts.map +1 -0
- package/dist/temp-types/src/constants/index.d.ts +1 -0
- package/dist/temp-types/src/constants/index.d.ts.map +1 -1
- package/dist/temp-types/src/constants/provide-keys.d.ts +3 -5
- package/dist/temp-types/src/constants/provide-keys.d.ts.map +1 -1
- package/dist/temp-types/src/utils/aria.d.ts +36 -0
- package/dist/temp-types/src/utils/aria.d.ts.map +1 -0
- package/dist/temp-types/src/utils/index.d.ts +1 -1
- package/dist/temp-types/src/utils/index.d.ts.map +1 -1
- package/dist/temp-types/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/aria.js +95 -0
- package/dist/utils/index.d.ts +40 -38
- package/dist/utils/index.js +1 -1
- package/package.json +5 -5
- package/dist/composables/use-menu-presets.js +0 -17
- package/dist/css/themes/default-theme.css +0 -1
- package/dist/scss/themes/default-theme.scss +0 -25
- package/dist/temp-types/src/composables/use-app-scroll.d.ts.map +0 -1
- package/dist/temp-types/src/composables/use-menu-presets.d.ts +0 -7
- package/dist/temp-types/src/composables/use-menu-presets.d.ts.map +0 -1
- package/dist/temp-types/src/utils/props-factory.d.ts +0 -37
- package/dist/temp-types/src/utils/props-factory.d.ts.map +0 -1
- package/dist/utils/props-factory.js +0 -25
- /package/dist/css/{themes/default-theme.js → lib.js} +0 -0
package/README.md
CHANGED
|
@@ -2,32 +2,43 @@
|
|
|
2
2
|
<img src="https://raw.githubusercontent.com/vueland/vueland/master/logo.png" style="max-width: 100%;">
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<div align="center">
|
|
6
|
+
<h1>@vueland/ui</h1>
|
|
7
|
+
<p>UI layer of the <a href="https://github.com/vueland/vueland">Vueland platform</a></p>
|
|
8
|
+
<p>
|
|
9
|
+
<a href="https://vueland.github.io/vueland/en/components/">Documentation</a> ·
|
|
10
|
+
<a href="https://www.npmjs.com/package/@vueland/ui">npm</a>
|
|
11
|
+
</p>
|
|
12
|
+
<p>
|
|
13
|
+
<a href="https://github.com/vueland/vueland">
|
|
14
|
+
<img src="https://img.shields.io/github/stars/vueland/vueland?style=flat&logo=github&label=Star%20us%20on%20GitHub" alt="GitHub Stars">
|
|
15
|
+
</a>
|
|
16
|
+
</p>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
---
|
|
6
20
|
|
|
7
21
|
> **⚠️ Active development — not production ready**
|
|
8
|
-
>
|
|
22
|
+
> APIs may change between releases without notice. Production-ready components are marked **Stable** in the docs.
|
|
9
23
|
|
|
10
|
-
|
|
24
|
+
`@vueland/ui` is the UI layer of the Vueland platform. It provides components built for real-world frontend needs: a 12-column grid, form controls with validation and presets, overlays, composables, and a slot-first architecture that lets you replace visual sections of complex components without losing their behavior.
|
|
11
25
|
|
|
12
26
|
## Documentation
|
|
13
27
|
|
|
14
|
-
Full documentation, examples, and
|
|
28
|
+
Full documentation, examples, and component API references:
|
|
15
29
|
|
|
16
30
|
https://vueland.github.io/vueland/en/guide/getting-started
|
|
17
31
|
|
|
18
32
|
## Installation
|
|
19
33
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
```bash [pnpm]
|
|
34
|
+
```bash
|
|
35
|
+
# pnpm
|
|
23
36
|
pnpm add @vueland/ui
|
|
24
|
-
```
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
# npm
|
|
27
39
|
npm install @vueland/ui
|
|
28
|
-
```
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
# yarn
|
|
31
42
|
yarn add @vueland/ui
|
|
32
43
|
```
|
|
33
44
|
|
|
@@ -41,8 +52,8 @@ import { createApp } from 'vue'
|
|
|
41
52
|
import { createVuelandUI } from '@vueland/ui'
|
|
42
53
|
import * as components from '@vueland/ui/components'
|
|
43
54
|
|
|
44
|
-
import '@vueland/ui/
|
|
45
|
-
import '@vueland/ui/
|
|
55
|
+
import '@vueland/ui/styles/styles.scss'
|
|
56
|
+
import '@vueland/ui/styles/lib.scss'
|
|
46
57
|
|
|
47
58
|
import App from './App.vue'
|
|
48
59
|
|
|
@@ -51,7 +62,7 @@ app.use(createVuelandUI({ components }))
|
|
|
51
62
|
app.mount('#app')
|
|
52
63
|
```
|
|
53
64
|
|
|
54
|
-
> **Import SCSS source, not pre-compiled CSS.**
|
|
65
|
+
> **Import SCSS source, not pre-compiled CSS.** Styles are compiled by Vite at build time. If you import `dist/styles.css`, breakpoints configured via `@vueland/utils-jit` will not be applied.
|
|
55
66
|
|
|
56
67
|
### 2. Use components
|
|
57
68
|
|
|
@@ -59,17 +70,17 @@ Components are registered globally after `app.use(vueland)`:
|
|
|
59
70
|
|
|
60
71
|
```vue
|
|
61
72
|
<template>
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
65
|
-
</
|
|
66
|
-
</
|
|
73
|
+
<CRow>
|
|
74
|
+
<CCol cols="12" sm="6" md="4">
|
|
75
|
+
<CCard class="pa-4 elevation-2">Hello Vueland</CCard>
|
|
76
|
+
</CCol>
|
|
77
|
+
</CRow>
|
|
67
78
|
</template>
|
|
68
79
|
```
|
|
69
80
|
|
|
70
81
|
## Breakpoints
|
|
71
82
|
|
|
72
|
-
|
|
83
|
+
Material Design breakpoint scale, shared across the grid, utility classes, and `useDisplay`:
|
|
73
84
|
|
|
74
85
|
| Name | min-width |
|
|
75
86
|
|------|-----------|
|
|
@@ -80,29 +91,20 @@ The default breakpoint scale follows Material Design:
|
|
|
80
91
|
| xl | 1920px |
|
|
81
92
|
| xxl | 2560px |
|
|
82
93
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
To customize them, use [`@vueland/utils-jit`](https://www.npmjs.com/package/@vueland/utils-jit) — one config in `vite.config.ts` syncs all layers automatically. See the [Breakpoints guide](https://vueland.github.io/vueland/en/guide/breakpoints) for the full step-by-step setup.
|
|
94
|
+
To customize breakpoints, use [`@vueland/utils-jit`](https://www.npmjs.com/package/@vueland/utils-jit) — one config in `vite.config.ts` syncs all layers. See the [Breakpoints guide](https://vueland.github.io/vueland/en/guide/breakpoints).
|
|
86
95
|
|
|
87
96
|
## Grid system
|
|
88
97
|
|
|
89
|
-
12-column flexbox grid built on `CRow`, `CCol`, and `CSpacer`:
|
|
90
|
-
|
|
91
98
|
```vue
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</c-row>
|
|
99
|
+
<CRow align="center" justify="space-between">
|
|
100
|
+
<CCol cols="12" sm="6" md="4">
|
|
101
|
+
<CCard class="pa-4">Card</CCard>
|
|
102
|
+
</CCol>
|
|
103
|
+
</CRow>
|
|
98
104
|
```
|
|
99
105
|
|
|
100
|
-
Responsive column props, offset, order, and row-level alignment all follow the same breakpoint scale.
|
|
101
|
-
|
|
102
106
|
## Utility classes
|
|
103
107
|
|
|
104
|
-
Predefined utility classes cover spacing, colors, typography, flex, display, sizing, elevation, borders, and more. All support responsive prefixes:
|
|
105
|
-
|
|
106
108
|
```html
|
|
107
109
|
<div class="pa-2 md:pa-6 lg:pa-10">responsive padding</div>
|
|
108
110
|
<div class="d-none md:d-flex">hidden on mobile</div>
|
|
@@ -111,26 +113,34 @@ Predefined utility classes cover spacing, colors, typography, flex, display, siz
|
|
|
111
113
|
|
|
112
114
|
## `useDisplay` composable
|
|
113
115
|
|
|
114
|
-
Reactive screen state in JS/Vue, synced to the same breakpoints:
|
|
115
|
-
|
|
116
116
|
```vue
|
|
117
117
|
<script setup lang="ts">
|
|
118
|
-
import {
|
|
119
|
-
import { $BREAKPOINTS_KEY } from '@vueland/ui/constants'
|
|
118
|
+
import { useBreakpoints } from '@vueland/ui/composables'
|
|
120
119
|
|
|
121
|
-
const
|
|
120
|
+
const { mdAndUp } = useBreakpoints()
|
|
122
121
|
</script>
|
|
123
122
|
|
|
124
123
|
<template>
|
|
125
|
-
<
|
|
126
|
-
Adaptive column
|
|
127
|
-
</
|
|
124
|
+
<CRow>
|
|
125
|
+
<CCol :cols="mdAndUp ? 6 : 12">Adaptive column</CCol>
|
|
126
|
+
</CRow>
|
|
128
127
|
</template>
|
|
129
128
|
```
|
|
130
129
|
|
|
131
|
-
##
|
|
130
|
+
## Part of the Vueland platform
|
|
131
|
+
|
|
132
|
+
`@vueland/ui` is one part of the Vueland platform. The platform also includes:
|
|
133
|
+
|
|
134
|
+
- [`@vueland/utils-jit`](https://www.npmjs.com/package/@vueland/utils-jit) — JIT utility class generation for Vite
|
|
135
|
+
- More plugins and adapters coming over time
|
|
136
|
+
|
|
137
|
+
See the [platform overview](https://github.com/vueland/vueland) for the full picture.
|
|
138
|
+
|
|
139
|
+
## ⭐ Support the project
|
|
140
|
+
|
|
141
|
+
If this package is useful to you, a star on GitHub goes a long way.
|
|
132
142
|
|
|
133
|
-
https://
|
|
143
|
+
**[Star on GitHub →](https://github.com/vueland/vueland)**
|
|
134
144
|
|
|
135
145
|
## License
|
|
136
146
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, provide, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, renderSlot } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { useApplicationScroll } from '../../composables/use-application-scroll.js';
|
|
3
3
|
import { $APP_API_KEY } from '../../constants/provide-keys.js';
|
|
4
4
|
|
|
5
5
|
const _hoisted_1 = { class: "c-app__wrapper" };
|
|
@@ -14,7 +14,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
14
14
|
getScrollLeft,
|
|
15
15
|
blockScroll,
|
|
16
16
|
unblockScroll
|
|
17
|
-
} =
|
|
17
|
+
} = useApplicationScroll();
|
|
18
18
|
provide($APP_API_KEY, {
|
|
19
19
|
getScrollTop,
|
|
20
20
|
getScrollLeft,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, useModel, shallowRef,
|
|
1
|
+
import { defineComponent, useModel, shallowRef, computed, unref, watch, resolveComponent, openBlock, createBlock, mergeProps, withCtx, renderSlot, createElementBlock, toDisplayString, createVNode, Fragment, renderList, createTextVNode, createElementVNode, normalizeProps, guardReactiveProps, isRef, toHandlers, mergeModels } from 'vue';
|
|
2
2
|
import { useAutocomplete } from '../../composables/use-autocomplete.js';
|
|
3
3
|
import _sfc_main$1 from '../CInput/CInput.js';
|
|
4
4
|
import _sfc_main$2 from '../CMenu/CMenu.js';
|
|
@@ -40,6 +40,14 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
40
40
|
const fieldRef = shallowRef();
|
|
41
41
|
const menuRef = shallowRef();
|
|
42
42
|
const menuListRef = shallowRef();
|
|
43
|
+
const ariaControls = computed(() => {
|
|
44
|
+
var _a;
|
|
45
|
+
return (_a = unref(menuListRef)) == null ? void 0 : _a.listId;
|
|
46
|
+
});
|
|
47
|
+
const ariaActiveDescendant = computed(() => {
|
|
48
|
+
var _a;
|
|
49
|
+
return (_a = unref(menuListRef)) == null ? void 0 : _a.activeDescendant;
|
|
50
|
+
});
|
|
43
51
|
const { onKeydown } = useKeyboard({
|
|
44
52
|
Backspace: () => {
|
|
45
53
|
if (!unref(inputValue)) {
|
|
@@ -56,9 +64,14 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
56
64
|
unref(fieldRef).$el.blur();
|
|
57
65
|
},
|
|
58
66
|
ArrowDown: () => {
|
|
59
|
-
|
|
67
|
+
var _a;
|
|
68
|
+
return (_a = unref(menuListRef)) == null ? void 0 : _a.navigateDown();
|
|
69
|
+
},
|
|
70
|
+
ArrowUp: () => {
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = unref(menuListRef)) == null ? void 0 : _a.navigateUp();
|
|
60
73
|
}
|
|
61
|
-
});
|
|
74
|
+
}, { prevent: ["ArrowDown", "ArrowUp"] });
|
|
62
75
|
function clear() {
|
|
63
76
|
model.value = props.multiple ? [] : void 0;
|
|
64
77
|
inputValue.value = "";
|
|
@@ -81,7 +94,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
81
94
|
ref_key: "inputRef",
|
|
82
95
|
ref: inputRef,
|
|
83
96
|
"model-value": model.value
|
|
84
|
-
}, _ctx.$attrs, {
|
|
97
|
+
}, _ctx.$attrs, {
|
|
98
|
+
role: "combobox",
|
|
99
|
+
"aria-controls": ariaControls.value,
|
|
100
|
+
"aria-activedescendant": ariaActiveDescendant.value
|
|
101
|
+
}), {
|
|
85
102
|
field: withCtx((field) => {
|
|
86
103
|
var _a;
|
|
87
104
|
return [
|
|
@@ -89,7 +106,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
89
106
|
id: `${field.uid}-menu`,
|
|
90
107
|
ref_key: "menuRef",
|
|
91
108
|
ref: menuRef,
|
|
92
|
-
|
|
109
|
+
align: "bottom",
|
|
93
110
|
"open-on-focus": "",
|
|
94
111
|
"close-on-click-outside": "",
|
|
95
112
|
"close-on-content-click": !__props.multiple,
|
|
@@ -247,7 +264,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
247
264
|
]),
|
|
248
265
|
_: 3
|
|
249
266
|
/* FORWARDED */
|
|
250
|
-
}, 16, ["model-value"]);
|
|
267
|
+
}, 16, ["model-value", "aria-controls", "aria-activedescendant"]);
|
|
251
268
|
};
|
|
252
269
|
}
|
|
253
270
|
});
|
|
@@ -26,7 +26,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
26
26
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event)
|
|
27
27
|
}, _ctx.$attrs), {
|
|
28
28
|
default: withCtx(({ checked, toggle }) => [
|
|
29
|
-
createVNode(_component_c_input, mergeProps({ "model-value": model.value }, _ctx.$attrs, {
|
|
29
|
+
createVNode(_component_c_input, mergeProps({ "model-value": model.value }, _ctx.$attrs, { role: "checkbox" }), {
|
|
30
30
|
field: withCtx(({ uid, label, attrs, hasError, readonly, disabled }) => [
|
|
31
31
|
createVNode(_sfc_main$2, mergeProps({
|
|
32
32
|
id: uid,
|
|
@@ -3,6 +3,8 @@ import { useValidate } from '../../composables/use-validate.js';
|
|
|
3
3
|
import { useForm } from '../../composables/use-form.js';
|
|
4
4
|
import { useInputPresets } from '../../composables/use-input-presets.js';
|
|
5
5
|
import { FIELD_ATTRS } from '../../constants/attrs.js';
|
|
6
|
+
import { useAriaField } from '../../composables/use-aria-field.js';
|
|
7
|
+
import { useAriaActivator } from '../../composables/use-aria-activator.js';
|
|
6
8
|
import { useId } from '../../composables/use-id.js';
|
|
7
9
|
|
|
8
10
|
const _hoisted_1 = { class: "c-input__field" };
|
|
@@ -26,7 +28,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
26
28
|
disabled: { type: Boolean },
|
|
27
29
|
focused: { type: Boolean },
|
|
28
30
|
readonly: { type: Boolean },
|
|
29
|
-
|
|
31
|
+
role: {}
|
|
30
32
|
}, {
|
|
31
33
|
"focused": { type: Boolean, ...{ default: false } },
|
|
32
34
|
"focusedModifiers": {}
|
|
@@ -58,10 +60,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
58
60
|
state,
|
|
59
61
|
errors
|
|
60
62
|
});
|
|
61
|
-
const fieldId = useId(props.id, { prefix: props.
|
|
62
|
-
const
|
|
63
|
-
const isCheckBox = props.
|
|
64
|
-
const isRadio = props.
|
|
63
|
+
const fieldId = useId(props.id, { prefix: props.role });
|
|
64
|
+
const isCombobox = props.role === "combobox";
|
|
65
|
+
const isCheckBox = props.role === "checkbox";
|
|
66
|
+
const isRadio = props.role === "radio";
|
|
65
67
|
const hasDetails = computed(
|
|
66
68
|
() => !props.noDetails && (!!props.details || !!(slots == null ? void 0 : slots.details) || errors.hasError)
|
|
67
69
|
);
|
|
@@ -71,16 +73,23 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
71
73
|
}
|
|
72
74
|
return acc;
|
|
73
75
|
}, {}));
|
|
76
|
+
const ariaField = useAriaField(() => ({
|
|
77
|
+
fieldId,
|
|
78
|
+
label: props.label || isCheckBox || isRadio,
|
|
79
|
+
hasDetails: unref(hasDetails),
|
|
80
|
+
hasError: errors.hasError,
|
|
81
|
+
errorMessage: errors.errorMessage,
|
|
82
|
+
readonly: props.readonly,
|
|
83
|
+
disabled: props.disabled
|
|
84
|
+
}));
|
|
85
|
+
const ariaActivator = useAriaActivator(() => ({
|
|
86
|
+
expanded: state.focused,
|
|
87
|
+
haspopup: "listbox",
|
|
88
|
+
controls: `${fieldId}-menu`
|
|
89
|
+
}));
|
|
74
90
|
const fieldAttrs = computed(() => ({
|
|
75
|
-
...
|
|
76
|
-
...
|
|
77
|
-
...errors.hasError ? { "aria-invalid": "true" } : {},
|
|
78
|
-
...errors.errorMessage && unref(hasDetails) ? { "aria-errormessage": `${fieldId}-details` } : {},
|
|
79
|
-
...props.readonly ? { "aria-readonly": "true" } : {},
|
|
80
|
-
...props.disabled ? { "aria-disabled": "true" } : {},
|
|
81
|
-
...isLisBox ? { "aria-haspopup": "listbox" } : {},
|
|
82
|
-
...isLisBox ? { "aria-controls": `${fieldId}-menu` } : {},
|
|
83
|
-
...isLisBox ? { "aria-expanded": `${state.focused}` } : {},
|
|
91
|
+
...unref(ariaField),
|
|
92
|
+
...isCombobox ? { role: "combobox", ...unref(ariaActivator) } : {},
|
|
84
93
|
...unref(normalizedAttrsMap)
|
|
85
94
|
}));
|
|
86
95
|
const classes = computed(() => [
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { defineComponent, useModel, useAttrs, shallowRef, computed, unref, provide, openBlock, createElementBlock, normalizeClass, renderSlot, mergeModels, toRaw, nextTick } from 'vue';
|
|
2
2
|
import { $LIST_API_KEY } from '../../constants/provide-keys.js';
|
|
3
|
+
import { useId } from '../../composables/use-id.js';
|
|
3
4
|
import { useKeyboard } from '../../composables/use-keyboard.js';
|
|
4
5
|
|
|
5
|
-
const _hoisted_1 = ["role", "tabindex", "aria-multiselectable"];
|
|
6
|
+
const _hoisted_1 = ["role", "tabindex", "aria-multiselectable", "aria-activedescendant"];
|
|
6
7
|
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
8
|
...{
|
|
8
9
|
name: "CList",
|
|
@@ -27,8 +28,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
27
28
|
const attrs = useAttrs();
|
|
28
29
|
const focused = shallowRef(false);
|
|
29
30
|
const listEl = shallowRef();
|
|
31
|
+
const activeDescendant = shallowRef();
|
|
32
|
+
const listId = useId(void 0, { prefix: "c-list" });
|
|
30
33
|
let handlers = [];
|
|
31
|
-
let
|
|
34
|
+
let currentIndex = -1;
|
|
32
35
|
const classes = computed(() => ({
|
|
33
36
|
"c-list--readonly": props.readonly,
|
|
34
37
|
[attrs.class]: !!attrs.class
|
|
@@ -58,7 +61,9 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
58
61
|
if (props.readonly) return;
|
|
59
62
|
if (props.multiple) {
|
|
60
63
|
const current = unref(model);
|
|
61
|
-
if (props.mandatory && (current == null ? void 0 : current.length) <= 1)
|
|
64
|
+
if (props.mandatory && (current == null ? void 0 : current.length) <= 1) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
62
67
|
model.value = current == null ? void 0 : current.filter((item) => toRaw(item) !== toRaw(listItem));
|
|
63
68
|
} else {
|
|
64
69
|
if (props.mandatory) return;
|
|
@@ -74,38 +79,51 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
function register(itemControls) {
|
|
82
|
+
const idx = handlers.length;
|
|
77
83
|
handlers.push(itemControls);
|
|
84
|
+
return idx;
|
|
78
85
|
}
|
|
79
86
|
function unregister(itemControls) {
|
|
80
87
|
handlers = handlers.filter((it) => it !== itemControls);
|
|
81
88
|
}
|
|
89
|
+
function setDescendant(id) {
|
|
90
|
+
activeDescendant.value = id;
|
|
91
|
+
}
|
|
82
92
|
async function focus() {
|
|
83
93
|
focused.value = true;
|
|
84
94
|
await nextTick();
|
|
85
95
|
unref(listEl).focus();
|
|
86
96
|
}
|
|
97
|
+
function navigateDown() {
|
|
98
|
+
var _a;
|
|
99
|
+
if (!handlers.length) return;
|
|
100
|
+
const next = Math.min(handlers.length - 1, currentIndex + 1);
|
|
101
|
+
(_a = handlers[currentIndex]) == null ? void 0 : _a.blur();
|
|
102
|
+
handlers[next].focus();
|
|
103
|
+
currentIndex = next;
|
|
104
|
+
}
|
|
105
|
+
function navigateUp() {
|
|
106
|
+
var _a;
|
|
107
|
+
if (!handlers.length || currentIndex <= 0) return;
|
|
108
|
+
const prev = currentIndex - 1;
|
|
109
|
+
(_a = handlers[currentIndex]) == null ? void 0 : _a.blur();
|
|
110
|
+
handlers[prev].focus();
|
|
111
|
+
currentIndex = prev;
|
|
112
|
+
}
|
|
87
113
|
const { onKeydown } = useKeyboard({
|
|
88
|
-
ArrowDown:
|
|
89
|
-
|
|
90
|
-
handlers[index].focus();
|
|
91
|
-
(_a = handlers[index - 1]) == null ? void 0 : _a.blur();
|
|
92
|
-
index = Math.min(handlers.length - 1, index + 1);
|
|
93
|
-
},
|
|
94
|
-
ArrowUp: () => {
|
|
95
|
-
var _a;
|
|
96
|
-
(_a = handlers[index]) == null ? void 0 : _a.blur();
|
|
97
|
-
index = Math.min(handlers.length - 1, Math.max(0, index - 1));
|
|
98
|
-
handlers[index].focus();
|
|
99
|
-
}
|
|
114
|
+
ArrowDown: navigateDown,
|
|
115
|
+
ArrowUp: navigateUp
|
|
100
116
|
});
|
|
101
|
-
__expose({ focus });
|
|
117
|
+
__expose({ focus, listId, activeDescendant, navigateDown, navigateUp });
|
|
102
118
|
provide($LIST_API_KEY, {
|
|
103
119
|
role,
|
|
120
|
+
listId,
|
|
104
121
|
register,
|
|
105
122
|
unregister,
|
|
106
123
|
select,
|
|
107
124
|
unselect,
|
|
108
|
-
isActive
|
|
125
|
+
isActive,
|
|
126
|
+
setDescendant
|
|
109
127
|
});
|
|
110
128
|
return (_ctx, _cache) => {
|
|
111
129
|
return openBlock(), createElementBlock("ul", {
|
|
@@ -115,6 +133,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
115
133
|
role: role.value,
|
|
116
134
|
tabindex: tabindex.value,
|
|
117
135
|
"aria-multiselectable": __props.multiple,
|
|
136
|
+
"aria-activedescendant": activeDescendant.value,
|
|
118
137
|
onKeydown: _cache[0] || (_cache[0] = //@ts-ignore
|
|
119
138
|
(...args) => unref(onKeydown) && unref(onKeydown)(...args))
|
|
120
139
|
}, [
|
|
@@ -11,8 +11,12 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11
11
|
setup(__props) {
|
|
12
12
|
const props = __props;
|
|
13
13
|
const list = useList();
|
|
14
|
-
const
|
|
14
|
+
const myIndex = shallowRef(-1);
|
|
15
|
+
const focused = shallowRef(false);
|
|
15
16
|
const isInActiveList = computed(() => unref(list == null ? void 0 : list.role) === "listbox" || unref(list == null ? void 0 : list.role) === "menu");
|
|
17
|
+
const myId = computed(
|
|
18
|
+
() => isInActiveList.value && (list == null ? void 0 : list.listId) && myIndex.value >= 0 ? `${list.listId}-option-${myIndex.value}` : void 0
|
|
19
|
+
);
|
|
16
20
|
const isSelected = computed(
|
|
17
21
|
() => {
|
|
18
22
|
var _a;
|
|
@@ -21,10 +25,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
21
25
|
);
|
|
22
26
|
const classes = computed(() => ({
|
|
23
27
|
"c-list-item--active": unref(isSelected),
|
|
24
|
-
"c-list-item--focused": unref(
|
|
28
|
+
"c-list-item--focused": unref(focused)
|
|
25
29
|
}));
|
|
26
30
|
const attrs = computed(() => ({
|
|
27
|
-
...unref(
|
|
31
|
+
...unref(myId) ? { id: unref(myId) } : {},
|
|
28
32
|
...isInActiveList.value ? { role: "option" } : {},
|
|
29
33
|
"aria-selected": unref(isSelected)
|
|
30
34
|
}));
|
|
@@ -33,18 +37,19 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
33
37
|
handler == null ? void 0 : handler(props.value);
|
|
34
38
|
}
|
|
35
39
|
function focus() {
|
|
36
|
-
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = list == null ? void 0 : list.setDescendant) == null ? void 0 : _a.call(list, unref(myId));
|
|
42
|
+
focused.value = true;
|
|
37
43
|
}
|
|
38
44
|
function blur() {
|
|
39
|
-
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = list == null ? void 0 : list.setDescendant) == null ? void 0 : _a.call(list, void 0);
|
|
47
|
+
focused.value = false;
|
|
40
48
|
}
|
|
41
|
-
const handlers = {
|
|
42
|
-
focus,
|
|
43
|
-
blur
|
|
44
|
-
};
|
|
49
|
+
const handlers = { focus, blur };
|
|
45
50
|
onMounted(() => {
|
|
46
51
|
if (unref(isInActiveList)) {
|
|
47
|
-
list.register(handlers);
|
|
52
|
+
myIndex.value = list.register(handlers);
|
|
48
53
|
}
|
|
49
54
|
});
|
|
50
55
|
onBeforeUnmount(() => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { defineComponent, useModel, shallowRef, computed, unref, provide, watch, onMounted, onBeforeUnmount, openBlock, createElementBlock, Fragment, renderSlot, createVNode, withCtx, Transition, withDirectives, mergeProps, createElementVNode, vShow, createCommentVNode, mergeModels } from 'vue';
|
|
1
|
+
import { defineComponent, useModel, useAttrs, shallowRef, computed, unref, provide, watch, onMounted, onBeforeUnmount, openBlock, createElementBlock, Fragment, renderSlot, createVNode, withCtx, Transition, withDirectives, mergeProps, createElementVNode, vShow, createCommentVNode, mergeModels } from 'vue';
|
|
2
2
|
import { isDef } from '../../helpers/index.js';
|
|
3
3
|
import { useActivator } from '../../composables/use-activator.js';
|
|
4
4
|
import { useAutoPosition } from '../../composables/use-auto-position.js';
|
|
5
|
-
import { useMenuPresets } from '../../composables/use-menu-presets.js';
|
|
6
5
|
import _sfc_main$1 from '../COverlay/COverlay.js';
|
|
7
6
|
import { vClickOutside } from '../../directives/v-click-outside.js';
|
|
8
7
|
import { useKeyboard } from '../../composables/use-keyboard.js';
|
|
@@ -11,8 +10,10 @@ import { useDelayedActions } from '../../composables/use-delay-actions.js';
|
|
|
11
10
|
import { convertToUnit } from '../../utils/convert-to-unit.js';
|
|
12
11
|
import { $MENU_API_KEY } from '../../constants/provide-keys.js';
|
|
13
12
|
import { IN_BROWSER } from '../../utils/globals.js';
|
|
13
|
+
import { useId } from '../../composables/use-id.js';
|
|
14
14
|
|
|
15
|
-
const _hoisted_1 =
|
|
15
|
+
const _hoisted_1 = ["id"];
|
|
16
|
+
const _hoisted_2 = { class: "c-menu__content" };
|
|
16
17
|
const THROTTLE_DELAY = 50;
|
|
17
18
|
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
18
19
|
...{
|
|
@@ -38,13 +39,9 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
38
39
|
positionY: {},
|
|
39
40
|
offsetX: {},
|
|
40
41
|
offsetY: {},
|
|
41
|
-
|
|
42
|
-
right: { type: Boolean },
|
|
43
|
-
top: { type: Boolean },
|
|
44
|
-
bottom: { type: Boolean },
|
|
42
|
+
align: {},
|
|
45
43
|
openDelay: {},
|
|
46
44
|
closeDelay: {},
|
|
47
|
-
preset: {},
|
|
48
45
|
modelValue: { type: Boolean },
|
|
49
46
|
to: {},
|
|
50
47
|
closeOnClickOutside: { type: Boolean },
|
|
@@ -61,6 +58,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
61
58
|
const emit = __emit;
|
|
62
59
|
const model = useModel(__props, "modelValue");
|
|
63
60
|
const { transition = "fade" } = props;
|
|
61
|
+
const attrs = useAttrs();
|
|
64
62
|
const {
|
|
65
63
|
element,
|
|
66
64
|
activatorProps,
|
|
@@ -72,9 +70,13 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
72
70
|
contentRef,
|
|
73
71
|
update
|
|
74
72
|
} = useAutoPosition(props, element);
|
|
75
|
-
const presets = useMenuPresets({ props });
|
|
76
73
|
const { openDelay, closeDelay } = useDelayedActions(props);
|
|
77
74
|
const mounted = shallowRef(props.ssr || props.modelValue);
|
|
75
|
+
const _generatedId = useId(void 0, { prefix: "c-menu" });
|
|
76
|
+
const menuId = computed(() => {
|
|
77
|
+
var _a;
|
|
78
|
+
return (_a = attrs.id) != null ? _a : _generatedId;
|
|
79
|
+
});
|
|
78
80
|
const detached = computed(() => isDef(props.positionX) || isDef(props.positionY));
|
|
79
81
|
const sizesStyles = computed(() => {
|
|
80
82
|
var _a, _b;
|
|
@@ -92,16 +94,14 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
92
94
|
left: convertToUnit(unref(content).left),
|
|
93
95
|
...unref(sizesStyles)
|
|
94
96
|
}));
|
|
95
|
-
const classes = computed(() =>
|
|
96
|
-
{ "c-menu--visible": unref(model) },
|
|
97
|
-
...unref(presets).root
|
|
98
|
-
]);
|
|
97
|
+
const classes = computed(() => ({ "c-menu--visible": unref(model) }));
|
|
99
98
|
const open = () => {
|
|
100
99
|
mounted.value = true;
|
|
101
100
|
openDelay(() => {
|
|
102
101
|
if (!unref(detached)) {
|
|
103
102
|
model.value = true;
|
|
104
103
|
}
|
|
104
|
+
update();
|
|
105
105
|
emit("open");
|
|
106
106
|
});
|
|
107
107
|
};
|
|
@@ -129,7 +129,9 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
129
129
|
emit("click");
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
|
-
const { onKeydown } = useKeyboard({
|
|
132
|
+
const { onKeydown } = useKeyboard({
|
|
133
|
+
Escape: () => close()
|
|
134
|
+
});
|
|
133
135
|
const listeners = genListeners({
|
|
134
136
|
open,
|
|
135
137
|
close,
|
|
@@ -188,23 +190,19 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
188
190
|
default: withCtx(({ zIndex }) => [
|
|
189
191
|
createVNode(Transition, { name: unref(transition) }, {
|
|
190
192
|
default: withCtx(() => [
|
|
191
|
-
mounted.value ? withDirectives((openBlock(), createElementBlock(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
[
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
],
|
|
205
|
-
16
|
|
206
|
-
/* FULL_PROPS */
|
|
207
|
-
)), [
|
|
193
|
+
mounted.value ? withDirectives((openBlock(), createElementBlock("div", mergeProps({ key: 0 }, _ctx.$attrs, {
|
|
194
|
+
id: menuId.value,
|
|
195
|
+
ref_key: "contentRef",
|
|
196
|
+
ref: contentRef,
|
|
197
|
+
class: ["c-menu", classes.value],
|
|
198
|
+
style: { ...styles.value, zIndex },
|
|
199
|
+
tabindex: "-1",
|
|
200
|
+
onClick: onContentClick
|
|
201
|
+
}), [
|
|
202
|
+
createElementVNode("div", _hoisted_2, [
|
|
203
|
+
renderSlot(_ctx.$slots, "default")
|
|
204
|
+
])
|
|
205
|
+
], 16, _hoisted_1)), [
|
|
208
206
|
[vShow, model.value],
|
|
209
207
|
[unref(vClickOutside), onClickOutside]
|
|
210
208
|
]) : createCommentVNode("v-if", true)
|