@awes-io/ui 2.142.3 → 2.144.0
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/assets/css/components/_index.css +7 -1
- package/assets/css/components/action-card.css +1 -0
- package/assets/css/components/action-icon.css +2 -2
- package/assets/css/components/alert.css +28 -22
- package/assets/css/components/animation.css +52 -32
- package/assets/css/components/badge.css +1 -0
- package/assets/css/components/banner-text.css +15 -4
- package/assets/css/components/card.css +0 -1
- package/assets/css/components/content-placeholder.css +104 -0
- package/assets/css/components/dropdown.css +20 -7
- package/assets/css/components/empty-container.css +69 -1
- package/assets/css/components/filter-chosen.css +6 -0
- package/assets/css/components/filter-date-range.css +17 -1
- package/assets/css/components/filter-month.css +23 -17
- package/assets/css/components/filter-select.css +11 -0
- package/assets/css/components/icon-menu-item.css +12 -7
- package/assets/css/components/layout.css +1 -32
- package/assets/css/components/mobile-menu-nav.css +8 -4
- package/assets/css/components/modal.css +1 -1
- package/assets/css/components/number.css +12 -0
- package/assets/css/components/page-aside.css +54 -0
- package/assets/css/components/text-field.css +4 -0
- package/assets/js/css.js +1 -1
- package/assets/js/icons/mono.js +59 -91
- package/assets/js/icons/multicolor.js +1 -31
- package/components/1_atoms/AwActionIcon.vue +11 -2
- package/components/1_atoms/AwContentPlaceholder.vue +60 -0
- package/components/1_atoms/AwFlow.vue +37 -49
- package/components/1_atoms/AwGrid.vue +11 -3
- package/components/1_atoms/AwIcon/AwIcon.vue +5 -3
- package/components/1_atoms/AwIcon/AwIconSystemMono.vue +3 -2
- package/components/1_atoms/AwInput.vue +2 -2
- package/components/1_atoms/AwLabel.vue +1 -1
- package/components/1_atoms/AwList.vue +3 -1
- package/components/1_atoms/AwRadio.vue +1 -1
- package/components/1_atoms/AwSlider.vue +15 -1
- package/components/1_atoms/AwTag.vue +6 -1
- package/components/2_molecules/AwAlert.vue +63 -42
- package/components/2_molecules/AwBadge.vue +1 -1
- package/components/2_molecules/AwBannerText.vue +8 -2
- package/components/2_molecules/AwButton.vue +1 -1
- package/components/2_molecules/AwDescriptionInput.vue +19 -1
- package/components/2_molecules/AwEmptyContainer.vue +74 -72
- package/components/2_molecules/AwNumber.vue +180 -0
- package/components/2_molecules/AwSelect.vue +11 -4
- package/components/3_organisms/AwBottomBar.vue +22 -4
- package/components/3_organisms/AwFilterChosen.vue +73 -0
- package/components/3_organisms/AwFilterDateRange.vue +177 -0
- package/components/3_organisms/AwFilterMonth.vue +37 -40
- package/components/3_organisms/AwFilterSelect.vue +368 -0
- package/components/3_organisms/AwMultiBlockBuilder.vue +1 -1
- package/components/3_organisms/AwSubnav.vue +11 -1
- package/components/3_organisms/AwTable/AwTableBuilder.vue +20 -60
- package/components/3_organisms/AwTable/_AwTableCellDropdown.vue +6 -1
- package/components/3_organisms/AwTable/_AwTableRow.vue +2 -1
- package/components/4_pages/AwPage.vue +1 -0
- package/components/4_pages/AwPageAside.vue +108 -0
- package/components/5_layouts/AwLayoutCenter.vue +3 -8
- package/components/5_layouts/_AwMenuItemIcon.vue +9 -2
- package/components/5_layouts/_AwMobileMenuItem.vue +5 -3
- package/components/5_layouts/_AwUserMenu.vue +1 -1
- package/components/_config.js +26 -1
- package/docs/_template.md +80 -0
- package/docs/components/atoms/aw-accordion-fold.md +129 -0
- package/docs/components/atoms/aw-action-card-body.md +99 -0
- package/docs/components/atoms/aw-action-card.md +130 -0
- package/docs/components/atoms/aw-action-icon.md +126 -0
- package/docs/components/atoms/aw-avatar.md +106 -0
- package/docs/components/atoms/aw-card.md +137 -0
- package/docs/components/atoms/aw-checkbox.md +288 -0
- package/docs/components/atoms/aw-content-placeholder.md +147 -0
- package/docs/components/atoms/aw-description.md +83 -0
- package/docs/components/atoms/aw-dock.md +90 -0
- package/docs/components/atoms/aw-dropdown-button.md +94 -0
- package/docs/components/atoms/aw-dropdown.md +178 -0
- package/docs/components/atoms/aw-file.md +73 -0
- package/docs/components/atoms/aw-flow.md +140 -0
- package/docs/components/atoms/aw-grid.md +109 -0
- package/docs/components/atoms/aw-headline.md +71 -0
- package/docs/components/atoms/aw-icon-system-color.md +122 -0
- package/docs/components/atoms/aw-icon-system-mono.md +206 -0
- package/docs/components/atoms/aw-icon.md +235 -0
- package/docs/components/atoms/aw-info.md +123 -0
- package/docs/components/atoms/aw-input.md +212 -0
- package/docs/components/atoms/aw-label.md +136 -0
- package/docs/components/atoms/aw-link.md +151 -0
- package/docs/components/atoms/aw-list.md +152 -0
- package/docs/components/atoms/aw-progress.md +119 -0
- package/docs/components/atoms/aw-radio.md +182 -0
- package/docs/components/atoms/aw-refresh-wrapper.md +81 -0
- package/docs/components/atoms/aw-select-native.md +234 -0
- package/docs/components/atoms/aw-slider.md +189 -0
- package/docs/components/atoms/aw-sub-headline.md +73 -0
- package/docs/components/atoms/aw-switcher.md +192 -0
- package/docs/components/atoms/aw-tag.md +144 -0
- package/docs/components/atoms/aw-title.md +70 -0
- package/docs/components/atoms/aw-toggler.md +90 -0
- package/docs/components/layouts/aw-layout-center.md +168 -0
- package/docs/components/layouts/aw-layout-error.md +153 -0
- package/docs/components/layouts/aw-layout-provider.md +238 -0
- package/docs/components/layouts/aw-layout.md +88 -0
- package/docs/components/molecules/aw-action-button.md +138 -0
- package/docs/components/molecules/aw-alert.md +191 -0
- package/docs/components/molecules/aw-badge.md +129 -0
- package/docs/components/molecules/aw-banner-text.md +156 -0
- package/docs/components/molecules/aw-button-nav.md +111 -0
- package/docs/components/molecules/aw-button.md +193 -0
- package/docs/components/molecules/aw-description-input.md +124 -0
- package/docs/components/molecules/aw-empty-container.md +235 -0
- package/docs/components/molecules/aw-island.md +506 -0
- package/docs/components/molecules/aw-number.md +138 -0
- package/docs/components/molecules/aw-select-object.md +401 -0
- package/docs/components/molecules/aw-select.md +215 -0
- package/docs/components/molecules/aw-tab-nav.md +108 -0
- package/docs/components/molecules/aw-tel.md +129 -0
- package/docs/components/molecules/aw-textarea.md +83 -0
- package/docs/components/molecules/aw-userpic.md +115 -0
- package/docs/components/organisms/aw-address-block.md +64 -0
- package/docs/components/organisms/aw-address.md +132 -0
- package/docs/components/organisms/aw-birthday-picker.md +73 -0
- package/docs/components/organisms/aw-bottom-bar.md +66 -0
- package/docs/components/organisms/aw-calendar-days.md +115 -0
- package/docs/components/organisms/aw-calendar-nav.md +98 -0
- package/docs/components/organisms/aw-calendar-view.md +98 -0
- package/docs/components/organisms/aw-calendar.md +166 -0
- package/docs/components/organisms/aw-chart.md +154 -0
- package/docs/components/organisms/aw-chip-select.md +164 -0
- package/docs/components/organisms/aw-chip.md +126 -0
- package/docs/components/organisms/aw-code-snippet.md +94 -0
- package/docs/components/organisms/aw-code.md +132 -0
- package/docs/components/organisms/aw-context-menu.md +117 -0
- package/docs/components/organisms/aw-cropper.md +151 -0
- package/docs/components/organisms/aw-date.md +161 -0
- package/docs/components/organisms/aw-display-date.md +33 -0
- package/docs/components/organisms/aw-download-link.md +46 -0
- package/docs/components/organisms/aw-fetch-data.md +161 -0
- package/docs/components/organisms/aw-filter-chosen.md +226 -0
- package/docs/components/organisms/aw-filter-date-range.md +205 -0
- package/docs/components/organisms/aw-filter-month.md +43 -0
- package/docs/components/organisms/aw-filter-select.md +239 -0
- package/docs/components/organisms/aw-form.md +174 -0
- package/docs/components/organisms/aw-gmap-marker.md +86 -0
- package/docs/components/organisms/aw-gmap.md +90 -0
- package/docs/components/organisms/aw-image-upload.md +56 -0
- package/docs/components/organisms/aw-island-avatar.md +87 -0
- package/docs/components/organisms/aw-markdown-editor.md +104 -0
- package/docs/components/organisms/aw-modal-buttons.md +57 -0
- package/docs/components/organisms/aw-modal.md +246 -0
- package/docs/components/organisms/aw-model-edit.md +74 -0
- package/docs/components/organisms/aw-money.md +53 -0
- package/docs/components/organisms/aw-multi-block-builder.md +165 -0
- package/docs/components/organisms/aw-pagination.md +121 -0
- package/docs/components/organisms/aw-password.md +103 -0
- package/docs/components/organisms/aw-preview-card.md +45 -0
- package/docs/components/organisms/aw-search.md +116 -0
- package/docs/components/organisms/aw-subnav.md +122 -0
- package/docs/components/organisms/aw-table-builder.md +165 -0
- package/docs/components/organisms/aw-table-col.md +123 -0
- package/docs/components/organisms/aw-table-head.md +92 -0
- package/docs/components/organisms/aw-table-row.md +91 -0
- package/docs/components/organisms/aw-table.md +172 -0
- package/docs/components/organisms/aw-tags.md +54 -0
- package/docs/components/organisms/aw-toggle-show-aside.md +43 -0
- package/docs/components/organisms/aw-uploader-files.md +125 -0
- package/docs/components/organisms/aw-uploader.md +163 -0
- package/docs/components/organisms/aw-user-menu.md +87 -0
- package/docs/components/pages/aw-page-aside.md +296 -0
- package/docs/components/pages/aw-page-menu-buttons.md +172 -0
- package/docs/components/pages/aw-page-modal.md +198 -0
- package/docs/components/pages/aw-page-single.md +300 -0
- package/docs/components/pages/aw-page.md +194 -0
- package/docs/configuration.md +493 -0
- package/docs/cookbook/advanced-patterns.md +1388 -0
- package/docs/cookbook/common-patterns.md +965 -0
- package/docs/cookbook/index.md +786 -0
- package/docs/getting-started.md +596 -0
- package/docs/guides/best-practices.md +1106 -0
- package/docs/guides/data-fetching.md +852 -0
- package/docs/guides/error-handling.md +1172 -0
- package/docs/guides/forms-guide.md +1329 -0
- package/docs/guides/mobile-subnavigation.md +359 -0
- package/docs/guides/page-patterns/aside-pages.md +1418 -0
- package/docs/guides/page-patterns/dashboard-pages.md +990 -0
- package/docs/guides/page-patterns/detail-pages.md +1556 -0
- package/docs/guides/page-patterns/list-pages.md +1242 -0
- package/docs/index.md +263 -1
- package/docs/integrations.md +870 -0
- package/docs/reference/colors.md +232 -0
- package/docs/reference/icons.md +163 -0
- package/docs/reference/menu.md +462 -0
- package/docs/reference/plugins.md +970 -0
- package/docs/reference/troubleshooting.md +964 -0
- package/nuxt/awes.config.js +9 -8
- package/nuxt/index.js +2 -2
- package/nuxt/pages/more.vue +1 -1
- package/package.json +5 -3
- package/readme.md +171 -1
- package/store/awesIo.js +11 -0
- package/CHANGELOG.md +0 -4520
- package/docs/aw-accordion-fold.md +0 -46
- package/docs/aw-address.md +0 -44
- package/docs/aw-avatar.md +0 -51
- package/docs/aw-badge.md +0 -32
- package/docs/aw-button-nav.md +0 -44
- package/docs/aw-button.md +0 -50
- package/docs/aw-calendar-days.md +0 -46
- package/docs/aw-calendar-nav.md +0 -25
- package/docs/aw-calendar-view.md +0 -12
- package/docs/aw-calendar.md +0 -59
- package/docs/aw-card.md +0 -48
- package/docs/aw-chart.md +0 -51
- package/docs/aw-checkbox.md +0 -56
- package/docs/aw-chip-select.md +0 -46
- package/docs/aw-chip.md +0 -53
- package/docs/aw-code-snippet.md +0 -18
- package/docs/aw-code.md +0 -56
- package/docs/aw-content-wrapper.md +0 -40
- package/docs/aw-context-menu.md +0 -31
- package/docs/aw-cropper.md +0 -60
- package/docs/aw-dashboard-card.md +0 -37
- package/docs/aw-dashboard-donut.md +0 -30
- package/docs/aw-dashboard-line.md +0 -20
- package/docs/aw-dashboard-progress.md +0 -33
- package/docs/aw-dashboard-section.md +0 -32
- package/docs/aw-dashboard-speed.md +0 -30
- package/docs/aw-date.md +0 -52
- package/docs/aw-dropdown-button.md +0 -31
- package/docs/aw-dropdown.md +0 -69
- package/docs/aw-fetch-data.md +0 -45
- package/docs/aw-form.md +0 -52
- package/docs/aw-grid.md +0 -48
- package/docs/aw-icon.md +0 -50
- package/docs/aw-info.md +0 -53
- package/docs/aw-input.md +0 -55
- package/docs/aw-layout-default.md +0 -30
- package/docs/aw-layout-frame-center.md +0 -29
- package/docs/aw-layout-simple.md +0 -49
- package/docs/aw-link.md +0 -54
- package/docs/aw-markdown-editor.md +0 -51
- package/docs/aw-modal.md +0 -63
- package/docs/aw-multi-block-builder.md +0 -66
- package/docs/aw-page.md +0 -36
- package/docs/aw-pagination.md +0 -54
- package/docs/aw-password.md +0 -48
- package/docs/aw-radio.md +0 -54
- package/docs/aw-search.md +0 -49
- package/docs/aw-select.md +0 -93
- package/docs/aw-slider.md +0 -40
- package/docs/aw-svg-image.md +0 -19
- package/docs/aw-switcher.md +0 -51
- package/docs/aw-tab-nav.md +0 -55
- package/docs/aw-table-builder.md +0 -58
- package/docs/aw-table-col.md +0 -33
- package/docs/aw-table-head.md +0 -28
- package/docs/aw-table-row.md +0 -33
- package/docs/aw-table.md +0 -59
- package/docs/aw-tel.md +0 -47
- package/docs/aw-textarea.md +0 -47
- package/docs/aw-toggler.md +0 -41
- package/docs/aw-uploader-files.md +0 -20
- package/docs/aw-uploader.md +0 -60
- package/docs/aw-user-menu.md +0 -34
- package/docs/aw-userpic.md +0 -34
- /package/components/{3_organisms → 2_molecules}/AwTel.vue +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
---
|
|
2
|
+
metaTitle: SelectObject component | AwesCode UI
|
|
3
|
+
meta:
|
|
4
|
+
- name: description
|
|
5
|
+
content: The <AwSelectObject /> component provides an advanced select dropdown for object-based options with search, AJAX, and grouping - UI Vue component for AwesCode UI.
|
|
6
|
+
title: SelectObject
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# AwSelectObject
|
|
10
|
+
|
|
11
|
+
**Category:** Molecule | **Import:** Global
|
|
12
|
+
|
|
13
|
+
The `AwSelectObject` component is an advanced select dropdown specifically designed for working with object-based options. It supports local and AJAX data sources, search functionality, infinite scrolling, grouping, and mobile-optimized interfaces.
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
`AwSelectObject` provides advanced select functionality with:
|
|
18
|
+
- Object-based options with customizable key/label extraction
|
|
19
|
+
- Local options or AJAX data fetching
|
|
20
|
+
- Search/filter with debouncing
|
|
21
|
+
- Infinite scroll pagination (AJAX)
|
|
22
|
+
- Option grouping
|
|
23
|
+
- Mobile-optimized dropdown
|
|
24
|
+
- Keyboard navigation
|
|
25
|
+
- Custom option rendering
|
|
26
|
+
- Preload strategies
|
|
27
|
+
- Not found handling
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Basic Example
|
|
32
|
+
|
|
33
|
+
```markup
|
|
34
|
+
<AwSelectObject
|
|
35
|
+
v-model="selectedUser"
|
|
36
|
+
:options="users"
|
|
37
|
+
label="Select User"
|
|
38
|
+
option-label="name"
|
|
39
|
+
track-by="id"
|
|
40
|
+
/>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### With Object Options
|
|
44
|
+
|
|
45
|
+
```markup
|
|
46
|
+
<template>
|
|
47
|
+
<AwSelectObject
|
|
48
|
+
v-model="selectedCountry"
|
|
49
|
+
:options="countries"
|
|
50
|
+
label="Country"
|
|
51
|
+
option-label="name"
|
|
52
|
+
track-by="code"
|
|
53
|
+
/>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
export default {
|
|
58
|
+
data() {
|
|
59
|
+
return {
|
|
60
|
+
selectedCountry: null,
|
|
61
|
+
countries: [
|
|
62
|
+
{ code: 'US', name: 'United States', region: 'North America' },
|
|
63
|
+
{ code: 'CA', name: 'Canada', region: 'North America' },
|
|
64
|
+
{ code: 'UK', name: 'United Kingdom', region: 'Europe' }
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### With AJAX Data Source
|
|
73
|
+
|
|
74
|
+
```markup
|
|
75
|
+
<AwSelectObject
|
|
76
|
+
v-model="selectedUser"
|
|
77
|
+
:options="fetchUsers"
|
|
78
|
+
label="Search Users"
|
|
79
|
+
option-label="full_name"
|
|
80
|
+
track-by="id"
|
|
81
|
+
searchable
|
|
82
|
+
preload="mounted"
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<script>
|
|
86
|
+
export default {
|
|
87
|
+
methods: {
|
|
88
|
+
fetchUsers(search, page) {
|
|
89
|
+
return {
|
|
90
|
+
url: '/api/users',
|
|
91
|
+
params: { search, page }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### With Function-Based Label
|
|
100
|
+
|
|
101
|
+
```markup
|
|
102
|
+
<AwSelectObject
|
|
103
|
+
v-model="selectedUser"
|
|
104
|
+
:options="users"
|
|
105
|
+
:option-label="user => `${user.first_name} ${user.last_name} (${user.email})`"
|
|
106
|
+
track-by="id"
|
|
107
|
+
label="User"
|
|
108
|
+
/>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### With Grouping
|
|
112
|
+
|
|
113
|
+
```markup
|
|
114
|
+
<AwSelectObject
|
|
115
|
+
v-model="selectedCountry"
|
|
116
|
+
:options="countries"
|
|
117
|
+
label="Country"
|
|
118
|
+
option-label="name"
|
|
119
|
+
track-by="code"
|
|
120
|
+
group-by="region"
|
|
121
|
+
/>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### With Custom Option Rendering
|
|
125
|
+
|
|
126
|
+
```markup
|
|
127
|
+
<AwSelectObject
|
|
128
|
+
v-model="selectedUser"
|
|
129
|
+
:options="users"
|
|
130
|
+
label="User"
|
|
131
|
+
option-label="name"
|
|
132
|
+
track-by="id"
|
|
133
|
+
>
|
|
134
|
+
<template #option-label="{ option, searchPhrase, highlightSearch }">
|
|
135
|
+
<div class="flex items-center gap-2">
|
|
136
|
+
<img :src="option.avatar" class="w-8 h-8 rounded-full" />
|
|
137
|
+
<div>
|
|
138
|
+
<div v-html="highlightSearch(option.name)"></div>
|
|
139
|
+
<div class="text-sm text-gray-500">{{ option.email }}</div>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</template>
|
|
143
|
+
</AwSelectObject>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### People selector pattern (users/customers with avatars)
|
|
147
|
+
|
|
148
|
+
Use the `icon` and `option-label` slots together to show avatars (or a fallback icon) for person-like entities such as users or customers.
|
|
149
|
+
|
|
150
|
+
```markup
|
|
151
|
+
<AwSelectObject
|
|
152
|
+
v-model="selectedPerson"
|
|
153
|
+
:options="searchPeople"
|
|
154
|
+
:option-label="person => `${person.first_name} ${person.last_name}`"
|
|
155
|
+
track-by="id"
|
|
156
|
+
clearable
|
|
157
|
+
>
|
|
158
|
+
<template #icon="{ option }">
|
|
159
|
+
<AwAvatar
|
|
160
|
+
v-if="option"
|
|
161
|
+
class="mx-3"
|
|
162
|
+
:src="option.avatar"
|
|
163
|
+
:name="`${option.first_name} ${option.last_name}`"
|
|
164
|
+
size="24"
|
|
165
|
+
icon="awesio/user"
|
|
166
|
+
/>
|
|
167
|
+
<AwActionIcon
|
|
168
|
+
v-else
|
|
169
|
+
class="mx-3 rounded-full"
|
|
170
|
+
icon="awesio/user"
|
|
171
|
+
size="xs"
|
|
172
|
+
/>
|
|
173
|
+
</template>
|
|
174
|
+
|
|
175
|
+
<template #option-label="{ option, highlightSearch }">
|
|
176
|
+
<div class="flex items-center gap-2">
|
|
177
|
+
<AwAvatar
|
|
178
|
+
:src="option.avatar"
|
|
179
|
+
:name="`${option.first_name} ${option.last_name}`"
|
|
180
|
+
size="24"
|
|
181
|
+
class="-ml-1"
|
|
182
|
+
icon="awesio/user"
|
|
183
|
+
/>
|
|
184
|
+
<div class="leading-tight">
|
|
185
|
+
<div v-html="highlightSearch(`${option.first_name} ${option.last_name}`)" />
|
|
186
|
+
<div v-if="option.email" class="text-sm text-mono-500">
|
|
187
|
+
{{ option.email }}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
</template>
|
|
192
|
+
</AwSelectObject>
|
|
193
|
+
|
|
194
|
+
<script>
|
|
195
|
+
export default {
|
|
196
|
+
methods: {
|
|
197
|
+
searchPeople(search, page) {
|
|
198
|
+
return {
|
|
199
|
+
url: '/api/users',
|
|
200
|
+
params: { search, page }
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
</script>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## API
|
|
209
|
+
|
|
210
|
+
### Props
|
|
211
|
+
|
|
212
|
+
| Name | Description | Type | Required | Default |
|
|
213
|
+
|------|-------------|------|----------|---------|
|
|
214
|
+
| value | Selected value (v-model) | `Any` | `false` | `null` |
|
|
215
|
+
| options | Options array or AJAX function | `Array\|Function` | `false` | `[]` |
|
|
216
|
+
| label | Input label | `String` | `false` | `''` |
|
|
217
|
+
| optionLabel | Key or function to extract label from option | `String\|Function` | `false` | `''` |
|
|
218
|
+
| trackBy | Key to use as value (required for objects) | `String` | `false` | `''` |
|
|
219
|
+
| groupBy | Key to group options | `String` | `false` | `''` |
|
|
220
|
+
| searchable | Enable search/filter | `Boolean` | `false` | `true` |
|
|
221
|
+
| clearable | Show clear button | `Boolean` | `false` | `false` |
|
|
222
|
+
| disabled | Disable select | `Boolean` | `false` | `false` |
|
|
223
|
+
| maxSearchItems | Max items to show | `Number` | `false` | `100` |
|
|
224
|
+
| debounce | Search debounce delay (ms) | `Number` | `false` | `400` |
|
|
225
|
+
| preload | Preload AJAX data ('mounted', 'focus', or both) | `String\|Object` | `false` | `'focus'` |
|
|
226
|
+
| showDropdownInput | Always show dropdown input | `Boolean` | `false` | `false` |
|
|
227
|
+
| getResponseData | Extract options from AJAX response | `Function` | `false` | `data => data.data` |
|
|
228
|
+
| getNextPage | Calculate next page from response | `Function` | `false` | See source |
|
|
229
|
+
| desktopFrom | Breakpoint for desktop mode | `String` | `false` | `'md'` |
|
|
230
|
+
| isCaret | Show caret icon | `Boolean\|Function` | `false` | `true` |
|
|
231
|
+
| isNotFound | Override not found detection | `Boolean` | `false` | `null` |
|
|
232
|
+
| optionDisabled | Function to determine if option is disabled | `Function` | `false` | `() => false` |
|
|
233
|
+
|
|
234
|
+
### Slots
|
|
235
|
+
|
|
236
|
+
| Name | Description | Props | Default Slot Content |
|
|
237
|
+
|------|-------------|-------|---------------------|
|
|
238
|
+
| default | Replace entire component | - | - |
|
|
239
|
+
| toggler | Custom input toggle | `{ option, optionLabel, isMobile, isOpened, isLoading, applySearch, open, close, clear }` | AwSelectInput |
|
|
240
|
+
| prefix | Content before input | - | - |
|
|
241
|
+
| postfix | Content after input | - | - |
|
|
242
|
+
| icon | Custom icon in input | `{ option, optionLabel, isLoading, isOpened }` | - |
|
|
243
|
+
| element | Custom input element | `{ value }` | - |
|
|
244
|
+
| caret | Custom caret icon | `{ isOpened }` | Default caret |
|
|
245
|
+
| dropdown | Replace entire dropdown | `{ optionsList, isOpened }` | Default dropdown |
|
|
246
|
+
| dropdown-input | Custom dropdown input | `{ option, optionLabel, isMobile, isOpened, isLoading }` | AwSelectInput |
|
|
247
|
+
| dropdown-before | Content before options | `{ optionsList, isLoading, hasSearch, searchPhrase, close }` | - |
|
|
248
|
+
| dropdown-after | Content after options | `{ optionsList, isLoading }` | - |
|
|
249
|
+
| option-label | Custom option label | `{ option, optionLabel, optionValue, index, active, disabled, searchPhrase, highlightSearch, close }` | Highlighted label |
|
|
250
|
+
| not-found | Custom not found message | `{ searchPhrase }` | "Nothing found" |
|
|
251
|
+
| loading | Custom loading message | - | "Loading..." |
|
|
252
|
+
|
|
253
|
+
### Events
|
|
254
|
+
|
|
255
|
+
| Name | Payload | Description |
|
|
256
|
+
|------|---------|-------------|
|
|
257
|
+
| input | `value` | Emitted when selection changes (v-model) |
|
|
258
|
+
| search | `searchPhrase` | Emitted when search text changes |
|
|
259
|
+
| open | `{ target }` | Emitted when dropdown opens |
|
|
260
|
+
| close | `{ target }` | Emitted when dropdown closes |
|
|
261
|
+
| focus | `{ target }` | Emitted when input is focused |
|
|
262
|
+
| clear | - | Emitted when clear button is clicked |
|
|
263
|
+
| not-found | `searchPhrase` | Emitted when Enter pressed on empty results |
|
|
264
|
+
|
|
265
|
+
## AJAX Data Loading
|
|
266
|
+
|
|
267
|
+
### Basic AJAX Setup
|
|
268
|
+
|
|
269
|
+
```markup
|
|
270
|
+
<AwSelectObject
|
|
271
|
+
v-model="selected"
|
|
272
|
+
:options="loadOptions"
|
|
273
|
+
label="Search"
|
|
274
|
+
option-label="name"
|
|
275
|
+
track-by="id"
|
|
276
|
+
/>
|
|
277
|
+
|
|
278
|
+
<script>
|
|
279
|
+
export default {
|
|
280
|
+
methods: {
|
|
281
|
+
loadOptions(search, page) {
|
|
282
|
+
// Return axios config object or URL string
|
|
283
|
+
return {
|
|
284
|
+
url: '/api/items',
|
|
285
|
+
params: { search, page, per_page: 20 }
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
</script>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Custom Response Parsing
|
|
294
|
+
|
|
295
|
+
```markup
|
|
296
|
+
<AwSelectObject
|
|
297
|
+
v-model="selected"
|
|
298
|
+
:options="loadOptions"
|
|
299
|
+
:get-response-data="response => response.items"
|
|
300
|
+
:get-next-page="(response, currentPage) => response.has_more ? currentPage + 1 : 0"
|
|
301
|
+
option-label="name"
|
|
302
|
+
track-by="id"
|
|
303
|
+
/>
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Preload Strategies
|
|
307
|
+
|
|
308
|
+
```markup
|
|
309
|
+
<!-- Preload on mount -->
|
|
310
|
+
<AwSelectObject
|
|
311
|
+
:options="loadOptions"
|
|
312
|
+
preload="mounted"
|
|
313
|
+
/>
|
|
314
|
+
|
|
315
|
+
<!-- Preload on focus -->
|
|
316
|
+
<AwSelectObject
|
|
317
|
+
:options="loadOptions"
|
|
318
|
+
preload="focus"
|
|
319
|
+
/>
|
|
320
|
+
|
|
321
|
+
<!-- Preload both -->
|
|
322
|
+
<AwSelectObject
|
|
323
|
+
:options="loadOptions"
|
|
324
|
+
preload="mounted focus"
|
|
325
|
+
/>
|
|
326
|
+
|
|
327
|
+
<!-- Advanced preload config -->
|
|
328
|
+
<AwSelectObject
|
|
329
|
+
:options="loadOptions"
|
|
330
|
+
:preload="{ mounted: true, focus: false }"
|
|
331
|
+
/>
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Grouping Options
|
|
335
|
+
|
|
336
|
+
```markup
|
|
337
|
+
<template>
|
|
338
|
+
<AwSelectObject
|
|
339
|
+
v-model="selectedFood"
|
|
340
|
+
:options="foods"
|
|
341
|
+
label="Food"
|
|
342
|
+
option-label="name"
|
|
343
|
+
track-by="id"
|
|
344
|
+
group-by="category"
|
|
345
|
+
/>
|
|
346
|
+
</template>
|
|
347
|
+
|
|
348
|
+
<script>
|
|
349
|
+
export default {
|
|
350
|
+
data() {
|
|
351
|
+
return {
|
|
352
|
+
foods: [
|
|
353
|
+
{ id: 1, name: 'Apple', category: 'Fruits' },
|
|
354
|
+
{ id: 2, name: 'Banana', category: 'Fruits' },
|
|
355
|
+
{ id: 3, name: 'Carrot', category: 'Vegetables' },
|
|
356
|
+
{ id: 4, name: 'Broccoli', category: 'Vegetables' }
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
</script>
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Mobile vs Desktop Behavior
|
|
365
|
+
|
|
366
|
+
### Desktop (md+)
|
|
367
|
+
- Popper-based dropdown positioned below input
|
|
368
|
+
- Search input inline
|
|
369
|
+
- Click outside to close
|
|
370
|
+
|
|
371
|
+
### Mobile (< md)
|
|
372
|
+
- Full-screen modal dropdown
|
|
373
|
+
- Body scroll locked
|
|
374
|
+
- Search input at top of modal
|
|
375
|
+
- Back button to close
|
|
376
|
+
|
|
377
|
+
## Keyboard Navigation
|
|
378
|
+
|
|
379
|
+
- **Arrow Up/Down**: Navigate options
|
|
380
|
+
- **Enter**: Select focused option
|
|
381
|
+
- **Escape**: Close dropdown
|
|
382
|
+
- **Type**: Search/filter options
|
|
383
|
+
|
|
384
|
+
## Related Components
|
|
385
|
+
|
|
386
|
+
- `AwSelect` - Simple select for string arrays
|
|
387
|
+
- `AwSelectNative` - Native HTML select
|
|
388
|
+
- `AwDropdownButton` - Used for options rendering
|
|
389
|
+
|
|
390
|
+
## Notes
|
|
391
|
+
|
|
392
|
+
- **Import Method:** Global - Available as molecule component
|
|
393
|
+
- Requires `track-by` prop when options are objects
|
|
394
|
+
- AJAX mode activated when `options` is a function
|
|
395
|
+
- Infinite scroll automatically loads next page when scrolling near bottom
|
|
396
|
+
- Search phrase highlights matched text in bold
|
|
397
|
+
- Mobile dropdown uses body-scroll-lock to prevent background scrolling
|
|
398
|
+
- Popper.js used for desktop dropdown positioning
|
|
399
|
+
- Debounced search prevents excessive API calls
|
|
400
|
+
- Supports IntersectionObserver for infinite scroll
|
|
401
|
+
- Can be used with Axios cancel tokens for request cancellation
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
---
|
|
2
|
+
metaTitle: Select component | AwesCode UI
|
|
3
|
+
meta:
|
|
4
|
+
- name: description
|
|
5
|
+
content: The <AwSelect /> component is used to render Select - UI Vue component for AwesCode UI.
|
|
6
|
+
title: Select
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# AwSelect
|
|
10
|
+
|
|
11
|
+
**Category:** Molecule | **Import:** Global
|
|
12
|
+
|
|
13
|
+
The `AwSelect` component is a powerful, feature-rich select dropdown that supports static options, AJAX loading, multiple selection, search, and custom option rendering. It's globally available and can be used with dynamic `component :is` bindings.
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
`AwSelect` provides a comprehensive select solution with:
|
|
18
|
+
- Static array options or AJAX function-based options
|
|
19
|
+
- Single and multiple selection modes
|
|
20
|
+
- Built-in search functionality with debouncing
|
|
21
|
+
- Custom option labels and value tracking
|
|
22
|
+
- Option grouping support
|
|
23
|
+
- Mobile-optimized interface
|
|
24
|
+
- Loading states and error handling
|
|
25
|
+
- Custom slot support for flexible rendering
|
|
26
|
+
- Keyboard navigation
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Basic Example
|
|
31
|
+
|
|
32
|
+
```markup
|
|
33
|
+
<AwSelect
|
|
34
|
+
:options="['Option 1', 'Option 2', 'Option 3']"
|
|
35
|
+
v-model="selected"
|
|
36
|
+
label="Select something"
|
|
37
|
+
/>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### With Objects
|
|
41
|
+
|
|
42
|
+
```markup
|
|
43
|
+
<AwSelect
|
|
44
|
+
:options="[
|
|
45
|
+
{ id: 1, name: 'Option 1' },
|
|
46
|
+
{ id: 2, name: 'Option 2' }
|
|
47
|
+
]"
|
|
48
|
+
v-model="selected"
|
|
49
|
+
option-label="name"
|
|
50
|
+
track-by="id"
|
|
51
|
+
label="Select option"
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Multiple Selection
|
|
56
|
+
|
|
57
|
+
```markup
|
|
58
|
+
<AwSelect
|
|
59
|
+
:options="options"
|
|
60
|
+
v-model="selected"
|
|
61
|
+
multiple
|
|
62
|
+
label="Select multiple"
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### AJAX Options
|
|
67
|
+
|
|
68
|
+
```markup
|
|
69
|
+
<AwSelect
|
|
70
|
+
:options="(search) => ({ url: '/api/items', params: { search } })"
|
|
71
|
+
v-model="selected"
|
|
72
|
+
track-by="id"
|
|
73
|
+
option-label="name"
|
|
74
|
+
label="Search items"
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### With Search
|
|
79
|
+
|
|
80
|
+
```markup
|
|
81
|
+
<AwSelect
|
|
82
|
+
:options="options"
|
|
83
|
+
v-model="selected"
|
|
84
|
+
:searchable="true"
|
|
85
|
+
label="Searchable select"
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Clearable
|
|
90
|
+
|
|
91
|
+
```markup
|
|
92
|
+
<AwSelect
|
|
93
|
+
:options="options"
|
|
94
|
+
v-model="selected"
|
|
95
|
+
clearable
|
|
96
|
+
label="Clearable select"
|
|
97
|
+
/>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Custom Option Label
|
|
101
|
+
|
|
102
|
+
```markup
|
|
103
|
+
<AwSelect :options="options" v-model="selected" label="Select">
|
|
104
|
+
<template #option-label="{ optionLabel, option }">
|
|
105
|
+
<span class="flex items-center">
|
|
106
|
+
<AwIcon name="awesio/user" class="mr-2" />
|
|
107
|
+
{{ optionLabel }}
|
|
108
|
+
</span>
|
|
109
|
+
</template>
|
|
110
|
+
</AwSelect>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Not Found / Create New
|
|
114
|
+
|
|
115
|
+
```markup
|
|
116
|
+
<AwSelect
|
|
117
|
+
:options="options"
|
|
118
|
+
v-model="selected"
|
|
119
|
+
@not-found="createItem"
|
|
120
|
+
@not-equal="createItem"
|
|
121
|
+
label="Select or create"
|
|
122
|
+
>
|
|
123
|
+
<template #not-found="{ searchPhrase }">
|
|
124
|
+
Create new: {{ searchPhrase }}
|
|
125
|
+
</template>
|
|
126
|
+
|
|
127
|
+
<template #not-equal="{ searchPhrase }">
|
|
128
|
+
Create: {{ searchPhrase }}
|
|
129
|
+
</template>
|
|
130
|
+
</AwSelect>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## API
|
|
134
|
+
|
|
135
|
+
### Props
|
|
136
|
+
|
|
137
|
+
| Name | Description | Type | Required | Default |
|
|
138
|
+
|------|-------------|------|----------|---------|
|
|
139
|
+
| options | Options array or AJAX function | `Array` / `Function` | `false` | `[]` |
|
|
140
|
+
| value | Selected value(s) | `Any` | `false` | `null` |
|
|
141
|
+
| label | Field label | `String` / `Function` | `false` | `''` |
|
|
142
|
+
| optionLabel | Property name or function to get option label | `String` / `Function` | `false` | `''` |
|
|
143
|
+
| trackBy | Property name to track option value | `String` | `false` | `''` |
|
|
144
|
+
| optionDisabled | Function to determine if option is disabled | `Function` | `false` | `() => false` |
|
|
145
|
+
| searchable | Enable search functionality | `Boolean` | `false` | `true` |
|
|
146
|
+
| clearable | Show clear button when value exists | `Boolean` | `false` | `false` |
|
|
147
|
+
| multiple | Allow multiple selection | `Boolean` | `false` | `false` |
|
|
148
|
+
| multipleSeparator | Separator for multiple values display | `String` | `false` | `', '` |
|
|
149
|
+
| maxSearchItems | Maximum items to show in dropdown | `Number` | `false` | `100` |
|
|
150
|
+
| searchPreload | Preload options on open (AJAX mode) | `Array` / `Object` / `Boolean` | `false` | `true` |
|
|
151
|
+
| searchMin | Minimum characters to trigger search | `Number` | `false` | `0` |
|
|
152
|
+
| debounce | Search debounce delay in ms | `Number` | `false` | `400` |
|
|
153
|
+
| placeholder | Placeholder text | `String` | `false` | `''` |
|
|
154
|
+
| createPlaceholder | Placeholder when creating new item | `String` | `false` | `''` |
|
|
155
|
+
| createConfirmText | Confirmation text for creating new item | `String` | `false` | `'Are you sure, you want to create a new item?'` |
|
|
156
|
+
|
|
157
|
+
**AJAX Function Format:**
|
|
158
|
+
```javascript
|
|
159
|
+
(search) => {
|
|
160
|
+
return {
|
|
161
|
+
url: '/api/items',
|
|
162
|
+
params: { search, page: 1 }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// or
|
|
166
|
+
(search) => '/api/items?search=' + search
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Slots
|
|
170
|
+
|
|
171
|
+
| Name | Description | Props | Default Slot Content |
|
|
172
|
+
|------|-------------|-------|---------------------|
|
|
173
|
+
| default | Custom dropdown content | - | Options list |
|
|
174
|
+
| dropdown | Custom dropdown wrapper | - | Default dropdown |
|
|
175
|
+
| option-label | Custom option label rendering | `{ option, optionLabel, optionValue, index, active, disabled }` | Option label text |
|
|
176
|
+
| not-found | Content when no options found | `{ searchPhrase }` | - |
|
|
177
|
+
| not-equal | Content when search doesn't match (create option) | `{ searchPhrase }` | - |
|
|
178
|
+
| prefix | Content before input | - | - |
|
|
179
|
+
| postfix | Content after input | - | - |
|
|
180
|
+
| element | Custom input element | `{ value }` | Default input |
|
|
181
|
+
| create-icon | Custom create button icon | - | Plus circle icon |
|
|
182
|
+
|
|
183
|
+
### Events
|
|
184
|
+
|
|
185
|
+
| Name | Payload | Description |
|
|
186
|
+
|------|---------|-------------|
|
|
187
|
+
| input | `value, option` (single) or `values, options` (multiple) | Emitted when selection changes |
|
|
188
|
+
| search | `String` | Emitted on search input (when using custom search handler) |
|
|
189
|
+
| not-found | `String` | Emitted when search returns no results |
|
|
190
|
+
| not-equal | `String` | Emitted when search doesn't match any option |
|
|
191
|
+
| preloaded | `Array` | Emitted when AJAX options are preloaded |
|
|
192
|
+
| clear | - | Emitted when clear button is clicked |
|
|
193
|
+
|
|
194
|
+
## Related Components
|
|
195
|
+
|
|
196
|
+
- `AwInput` - Base input component used internally
|
|
197
|
+
- `AwDropdown` - Dropdown component used for options list
|
|
198
|
+
- `AwButton` - Button component for clear/create actions
|
|
199
|
+
|
|
200
|
+
## Notes
|
|
201
|
+
|
|
202
|
+
- **Import Method:** Global - Component is globally registered for use with dynamic `component :is`
|
|
203
|
+
- When `options` is a function, it's treated as AJAX mode
|
|
204
|
+
- AJAX requests use `$axios` instance (must be configured)
|
|
205
|
+
- Search is debounced by default (400ms)
|
|
206
|
+
- Mobile interface uses full-screen overlay
|
|
207
|
+
- Keyboard navigation: Arrow keys to navigate, Enter to select
|
|
208
|
+
- Options are filtered client-side for static arrays
|
|
209
|
+
- For AJAX mode, search is handled server-side
|
|
210
|
+
- `trackBy` is used to match selected values with options
|
|
211
|
+
- `optionLabel` can be a property path (e.g., `'user.name'`) or function
|
|
212
|
+
- Multiple selection returns array of values
|
|
213
|
+
- Component automatically handles option highlighting and keyboard focus
|
|
214
|
+
- Uses `body-scroll-lock` for mobile dropdown
|
|
215
|
+
- Loading state shown during AJAX requests
|