@primevue/mcp 4.5.5 → 5.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +45 -21
- package/README.md +48 -250
- package/data/components.json +47269 -0
- package/data/llms/components/accordion.md +629 -0
- package/data/llms/components/animateonscroll.md +165 -0
- package/data/llms/components/autocomplete.md +995 -0
- package/data/llms/components/avatar.md +264 -0
- package/data/llms/components/badge.md +200 -0
- package/data/llms/components/blockui.md +99 -0
- package/data/llms/components/breadcrumb.md +269 -0
- package/data/llms/components/button.md +902 -0
- package/data/llms/components/card.md +209 -0
- package/data/llms/components/carousel.md +506 -0
- package/data/llms/components/cascadeselect.md +1207 -0
- package/data/llms/components/chart.md +1022 -0
- package/data/llms/components/checkbox.md +401 -0
- package/data/llms/components/chip.md +206 -0
- package/data/llms/components/colorpicker.md +213 -0
- package/data/llms/components/commandmenu.md +660 -0
- package/data/llms/components/compare.md +407 -0
- package/data/llms/components/confirmdialog.md +343 -0
- package/data/llms/components/confirmpopup.md +252 -0
- package/data/llms/components/contextmenu.md +522 -0
- package/data/llms/components/datatable.md +5266 -0
- package/data/llms/components/dataview.md +569 -0
- package/data/llms/components/datepicker.md +964 -0
- package/data/llms/components/deferredcontent.md +96 -0
- package/data/llms/components/dialog.md +702 -0
- package/data/llms/components/divider.md +152 -0
- package/data/llms/components/dock.md +488 -0
- package/data/llms/components/drawer.md +469 -0
- package/data/llms/components/dynamicdialog.md +214 -0
- package/data/llms/components/editor.md +205 -0
- package/data/llms/components/fieldset.md +253 -0
- package/data/llms/components/fileupload.md +459 -0
- package/data/llms/components/floatlabel.md +144 -0
- package/data/llms/components/fluid.md +104 -0
- package/data/llms/components/focustrap.md +59 -0
- package/data/llms/components/forms.md +344 -0
- package/data/llms/components/galleria.md +1119 -0
- package/data/llms/components/gallery.md +1003 -0
- package/data/llms/components/iconfield.md +283 -0
- package/data/llms/components/iftalabel.md +96 -0
- package/data/llms/components/image.md +179 -0
- package/data/llms/components/imagecompare.md +108 -0
- package/data/llms/components/inplace.md +183 -0
- package/data/llms/components/inputcolor.md +869 -0
- package/data/llms/components/inputgroup.md +419 -0
- package/data/llms/components/inputmask.md +345 -0
- package/data/llms/components/inputnumber.md +551 -0
- package/data/llms/components/inputotp.md +345 -0
- package/data/llms/components/inputpassword.md +738 -0
- package/data/llms/components/inputtags.md +432 -0
- package/data/llms/components/inputtext.md +569 -0
- package/data/llms/components/installation.md +1 -0
- package/data/llms/components/keyfilter.md +116 -0
- package/data/llms/components/knob.md +318 -0
- package/data/llms/components/label.md +151 -0
- package/data/llms/components/laravel.md +53 -0
- package/data/llms/components/listbox.md +636 -0
- package/data/llms/components/mask.md +203 -0
- package/data/llms/components/mcp.md +39 -0
- package/data/llms/components/megamenu.md +563 -0
- package/data/llms/components/menu.md +651 -0
- package/data/llms/components/menubar.md +446 -0
- package/data/llms/components/message.md +497 -0
- package/data/llms/components/metergroup.md +281 -0
- package/data/llms/components/multiselect.md +752 -0
- package/data/llms/components/orderlist.md +224 -0
- package/data/llms/components/organizationchart.md +418 -0
- package/data/llms/components/paginator.md +221 -0
- package/data/llms/components/panel.md +321 -0
- package/data/llms/components/panelmenu.md +703 -0
- package/data/llms/components/password.md +657 -0
- package/data/llms/components/picklist.md +286 -0
- package/data/llms/components/popover.md +145 -0
- package/data/llms/components/progressbar.md +242 -0
- package/data/llms/components/progressspinner.md +104 -0
- package/data/llms/components/radiobutton.md +427 -0
- package/data/llms/components/rating.md +312 -0
- package/data/llms/components/ripple.md +91 -0
- package/data/llms/components/scrollarea.md +700 -0
- package/data/llms/components/scrollpanel.md +131 -0
- package/data/llms/components/scrolltop.md +87 -0
- package/data/llms/components/select.md +1251 -0
- package/data/llms/components/selectbutton.md +268 -0
- package/data/llms/components/sidebar.md +2232 -0
- package/data/llms/components/skeleton.md +302 -0
- package/data/llms/components/slider.md +416 -0
- package/data/llms/components/speeddial.md +402 -0
- package/data/llms/components/splitbutton.md +840 -0
- package/data/llms/components/splitter.md +447 -0
- package/data/llms/components/stepper.md +551 -0
- package/data/llms/components/styleclass.md +226 -0
- package/data/llms/components/tabs.md +609 -0
- package/data/llms/components/tag.md +178 -0
- package/data/llms/components/terminal.md +123 -0
- package/data/llms/components/textarea.md +519 -0
- package/data/llms/components/tieredmenu.md +578 -0
- package/data/llms/components/timeline.md +494 -0
- package/data/llms/components/toast.md +472 -0
- package/data/llms/components/togglebutton.md +276 -0
- package/data/llms/components/toggleswitch.md +271 -0
- package/data/llms/components/toolbar.md +140 -0
- package/data/llms/components/tooltip.md +160 -0
- package/data/llms/components/tree.md +1076 -0
- package/data/llms/components/treeselect.md +660 -0
- package/data/llms/components/treetable.md +2493 -0
- package/data/llms/components/virtualscroller.md +265 -0
- package/data/llms/guides/autoimport.md +28 -0
- package/data/llms/guides/cdn.md +72 -0
- package/data/llms/guides/configuration.md +158 -0
- package/data/llms/guides/customicons.md +67 -0
- package/data/llms/guides/guides/accessibility.md +27 -0
- package/data/llms/guides/guides/animations.md +119 -0
- package/data/llms/guides/guides/rtl.md +7 -0
- package/data/llms/guides/icons.md +136 -0
- package/data/llms/guides/installation.md +3 -0
- package/data/llms/guides/laravel.md +66 -0
- package/data/llms/guides/llms.md +15 -0
- package/data/llms/guides/mcp.md +104 -0
- package/data/llms/guides/migration/v4.md +15 -0
- package/data/llms/guides/migration/v5.md +15 -0
- package/data/llms/guides/nuxt.md +141 -0
- package/data/llms/guides/passthrough.md +137 -0
- package/data/llms/guides/primeclt.md +43 -0
- package/data/llms/guides/tailwind.md +151 -0
- package/data/llms/guides/theming/styled.md +497 -0
- package/data/llms/guides/theming/unstyled.md +57 -0
- package/data/llms/guides/uikit.md +3 -0
- package/data/llms/guides/vite.md +90 -0
- package/data/llms/llms-full.txt +54465 -0
- package/data/llms/llms.txt +132 -0
- package/data/llms/pages/accessibility.md +27 -0
- package/data/llms/pages/animations.md +119 -0
- package/data/llms/pages/autoimport.md +28 -0
- package/data/llms/pages/cdn.md +72 -0
- package/data/llms/pages/configuration.md +158 -0
- package/data/llms/pages/contribution.md +31 -0
- package/data/llms/pages/customicons.md +67 -0
- package/data/llms/pages/designer.md +79 -0
- package/data/llms/pages/dynamicimports.md +7 -0
- package/data/llms/pages/forms.md +63 -0
- package/data/llms/pages/guides/accessibility.md +27 -0
- package/data/llms/pages/guides/animations.md +119 -0
- package/data/llms/pages/guides/rtl.md +7 -0
- package/data/llms/pages/icons.md +136 -0
- package/data/llms/pages/installation.md +3 -0
- package/data/llms/pages/introduction.md +23 -0
- package/data/llms/pages/laravel.md +66 -0
- package/data/llms/pages/llms.md +15 -0
- package/data/llms/pages/mcp.md +104 -0
- package/data/llms/pages/migration/v4.md +15 -0
- package/data/llms/pages/migration/v5.md +15 -0
- package/data/llms/pages/nuxt.md +141 -0
- package/data/llms/pages/passthrough.md +137 -0
- package/data/llms/pages/primeclt.md +43 -0
- package/data/llms/pages/rtl.md +7 -0
- package/data/llms/pages/setup.md +3 -0
- package/data/llms/pages/styled.md +497 -0
- package/data/llms/pages/tailwind.md +151 -0
- package/data/llms/pages/theming/styled.md +497 -0
- package/data/llms/pages/theming/unstyled.md +57 -0
- package/data/llms/pages/uikit.md +3 -0
- package/data/llms/pages/unstyled.md +57 -0
- package/data/llms/pages/v4.md +15 -0
- package/data/llms/pages/v5.md +15 -0
- package/data/llms/pages/vite.md +90 -0
- package/data/manifest.json +11117 -0
- package/data/mcp-data.json +55940 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.js +66066 -72541
- package/package.json +10 -12
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
# DataView
|
|
2
|
+
|
|
3
|
+
DataView displays data in grid or list layout with pagination and sorting features.
|
|
4
|
+
|
|
5
|
+
## Basic
|
|
6
|
+
|
|
7
|
+
DataView requires a value to display along with a list slot for item content.
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<template>
|
|
11
|
+
<div>
|
|
12
|
+
<DataView :value="products">
|
|
13
|
+
<template #list="slotProps">
|
|
14
|
+
<div class="flex flex-col">
|
|
15
|
+
<div v-for="(item, index) in slotProps.items" :key="index">
|
|
16
|
+
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
|
|
17
|
+
<div class="md:w-40 relative">
|
|
18
|
+
<img class="block xl:block mx-auto rounded-border w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
|
|
19
|
+
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute dark:bg-surface-900!" style="left: 4px; top: 4px" />
|
|
20
|
+
</div>
|
|
21
|
+
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
|
|
22
|
+
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
|
|
23
|
+
<div>
|
|
24
|
+
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
|
25
|
+
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="bg-surface-100 p-1" style="border-radius: 30px">
|
|
28
|
+
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
29
|
+
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
|
30
|
+
<span class="flex text-yellow-500"><StarFill :size="14" /></span>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="flex flex-col md:items-end gap-8">
|
|
35
|
+
<span class="text-xl font-semibold">\${{ item.price }}</span>
|
|
36
|
+
<div class="flex flex-row-reverse md:flex-row gap-2">
|
|
37
|
+
<Button variant="outlined"><Heart /></Button>
|
|
38
|
+
<Button :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial whitespace-nowrap"><ShoppingCart /> Buy Now</Button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
</DataView>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script setup>
|
|
51
|
+
import { ref, onMounted } from "vue";
|
|
52
|
+
import { ProductService } from '@/service/ProductService';
|
|
53
|
+
import Heart from '@primeicons/vue/heart';
|
|
54
|
+
import ShoppingCart from '@primeicons/vue/shopping-cart';
|
|
55
|
+
import StarFill from '@primeicons/vue/star-fill';
|
|
56
|
+
|
|
57
|
+
onMounted(() => {
|
|
58
|
+
ProductService.getProductsSmall().then((data) => (products.value = data.slice(0, 5)));
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const products = ref();
|
|
62
|
+
const getSeverity = (product) => {
|
|
63
|
+
switch (product.inventoryStatus) {
|
|
64
|
+
case 'INSTOCK':
|
|
65
|
+
return 'success';
|
|
66
|
+
|
|
67
|
+
case 'LOWSTOCK':
|
|
68
|
+
return 'warn';
|
|
69
|
+
|
|
70
|
+
case 'OUTOFSTOCK':
|
|
71
|
+
return 'danger';
|
|
72
|
+
|
|
73
|
+
default:
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
<\/script>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Pagination
|
|
81
|
+
|
|
82
|
+
Pagination is enabled with the paginator and rows properties. Refer to the Paginator for more information about customizing the paginator.
|
|
83
|
+
|
|
84
|
+
```vue
|
|
85
|
+
<template>
|
|
86
|
+
<div>
|
|
87
|
+
<DataView :value="products" paginator :rows="5">
|
|
88
|
+
<template #list="slotProps">
|
|
89
|
+
<div class="flex flex-col">
|
|
90
|
+
<div v-for="(item, index) in slotProps.items" :key="index">
|
|
91
|
+
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
|
|
92
|
+
<div class="md:w-40 relative">
|
|
93
|
+
<img class="block xl:block mx-auto rounded-border w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
|
|
94
|
+
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute dark:bg-surface-900!" style="left: 4px; top: 4px" />
|
|
95
|
+
</div>
|
|
96
|
+
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
|
|
97
|
+
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
|
|
98
|
+
<div>
|
|
99
|
+
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
|
100
|
+
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="bg-surface-100 p-1" style="border-radius: 30px">
|
|
103
|
+
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
104
|
+
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
|
105
|
+
<span class="flex text-yellow-500"><StarFill :size="14" /></span>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<div class="flex flex-col md:items-end gap-8">
|
|
110
|
+
<span class="text-xl font-semibold">\${{ item.price }}</span>
|
|
111
|
+
<div class="flex flex-row-reverse md:flex-row gap-2">
|
|
112
|
+
<Button variant="outlined"><Heart /></Button>
|
|
113
|
+
<Button :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial whitespace-nowrap"><ShoppingCart /> Buy Now</Button>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
</template>
|
|
121
|
+
</DataView>
|
|
122
|
+
</div>
|
|
123
|
+
</template>
|
|
124
|
+
|
|
125
|
+
<script setup>
|
|
126
|
+
import { ref, onMounted } from "vue";
|
|
127
|
+
import { ProductService } from '@/service/ProductService';
|
|
128
|
+
import Heart from '@primeicons/vue/heart';
|
|
129
|
+
import ShoppingCart from '@primeicons/vue/shopping-cart';
|
|
130
|
+
import StarFill from '@primeicons/vue/star-fill';
|
|
131
|
+
|
|
132
|
+
onMounted(() => {
|
|
133
|
+
ProductService.getProducts().then((data) => (products.value = data));
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const products = ref();
|
|
137
|
+
const getSeverity = (product) => {
|
|
138
|
+
switch (product.inventoryStatus) {
|
|
139
|
+
case 'INSTOCK':
|
|
140
|
+
return 'success';
|
|
141
|
+
|
|
142
|
+
case 'LOWSTOCK':
|
|
143
|
+
return 'warn';
|
|
144
|
+
|
|
145
|
+
case 'OUTOFSTOCK':
|
|
146
|
+
return 'danger';
|
|
147
|
+
|
|
148
|
+
default:
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
<\/script>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Sorting
|
|
156
|
+
|
|
157
|
+
Built-in sorting is controlled by bindings sortField and sortOrder properties from a custom UI.
|
|
158
|
+
|
|
159
|
+
```vue
|
|
160
|
+
<template>
|
|
161
|
+
<div>
|
|
162
|
+
<DataView :value="products" :sortOrder="sortOrder" :sortField="sortField">
|
|
163
|
+
<template #header>
|
|
164
|
+
<div class="flex justify-center pb-4">
|
|
165
|
+
<SelectButton v-model="sortKey" :options="sortOptions" optionLabel="label" optionValue="value" @change="onSortChange($event)" />
|
|
166
|
+
</div>
|
|
167
|
+
</template>
|
|
168
|
+
<template #list="slotProps">
|
|
169
|
+
<div class="flex flex-col">
|
|
170
|
+
<div v-for="(item, index) in slotProps.items" :key="index">
|
|
171
|
+
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
|
|
172
|
+
<div class="md:w-40 relative">
|
|
173
|
+
<img class="block xl:block mx-auto rounded-border w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
|
|
174
|
+
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute dark:bg-surface-900!" style="left: 4px; top: 4px" />
|
|
175
|
+
</div>
|
|
176
|
+
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
|
|
177
|
+
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
|
|
178
|
+
<div>
|
|
179
|
+
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
|
180
|
+
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
|
|
181
|
+
</div>
|
|
182
|
+
<div class="bg-surface-100 p-1" style="border-radius: 30px">
|
|
183
|
+
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
184
|
+
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
|
185
|
+
<span class="flex text-yellow-500"><StarFill :size="14" /></span>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
<div class="flex flex-col md:items-end gap-8">
|
|
190
|
+
<span class="text-xl font-semibold">\${{ item.price }}</span>
|
|
191
|
+
<div class="flex flex-row-reverse md:flex-row gap-2">
|
|
192
|
+
<Button variant="outlined"><Heart /></Button>
|
|
193
|
+
<Button :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial whitespace-nowrap"><ShoppingCart /> Buy Now</Button>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
</template>
|
|
201
|
+
</DataView>
|
|
202
|
+
</div>
|
|
203
|
+
</template>
|
|
204
|
+
|
|
205
|
+
<script setup>
|
|
206
|
+
import { ref, onMounted } from "vue";
|
|
207
|
+
import { ProductService } from '@/service/ProductService';
|
|
208
|
+
import Heart from '@primeicons/vue/heart';
|
|
209
|
+
import ShoppingCart from '@primeicons/vue/shopping-cart';
|
|
210
|
+
import StarFill from '@primeicons/vue/star-fill';
|
|
211
|
+
|
|
212
|
+
onMounted(() => {
|
|
213
|
+
ProductService.getProductsSmall().then((data) => (products.value = data.slice(0, 5)));
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const products = ref();
|
|
217
|
+
const sortKey = ref();
|
|
218
|
+
const sortOrder = ref();
|
|
219
|
+
const sortField = ref();
|
|
220
|
+
const sortOptions = ref([
|
|
221
|
+
{ label: 'Price High to Low', value: 'hightolow' },
|
|
222
|
+
{ label: 'Price Low to High', value: 'lowtohigh' }
|
|
223
|
+
]);
|
|
224
|
+
const onSortChange = (event) => {
|
|
225
|
+
const value = event.value;
|
|
226
|
+
|
|
227
|
+
if (value === 'hightolow') {
|
|
228
|
+
sortOrder.value = -1;
|
|
229
|
+
sortField.value = 'price';
|
|
230
|
+
}
|
|
231
|
+
else if (value === 'lowtohigh') {
|
|
232
|
+
sortOrder.value = 1;
|
|
233
|
+
sortField.value = 'price';
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const getSeverity = (product) => {
|
|
237
|
+
switch (product.inventoryStatus) {
|
|
238
|
+
case 'INSTOCK':
|
|
239
|
+
return 'success';
|
|
240
|
+
|
|
241
|
+
case 'LOWSTOCK':
|
|
242
|
+
return 'warn';
|
|
243
|
+
|
|
244
|
+
case 'OUTOFSTOCK':
|
|
245
|
+
return 'danger';
|
|
246
|
+
|
|
247
|
+
default:
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
<\/script>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Layout
|
|
255
|
+
|
|
256
|
+
DataView supports list and grid display modes defined with the layout property. The grid mode is not built-in for flexibility purposes and requires a library with CSS grid features like Tailwind.
|
|
257
|
+
|
|
258
|
+
```vue
|
|
259
|
+
<template>
|
|
260
|
+
<div>
|
|
261
|
+
<DataView :value="products" :layout="layout">
|
|
262
|
+
<template #header>
|
|
263
|
+
<div class="flex justify-end">
|
|
264
|
+
<SelectButton v-model="layout" :options="options" :allowEmpty="false">
|
|
265
|
+
<template #option="{ option }">
|
|
266
|
+
<Bars v-if="option === 'list'" />
|
|
267
|
+
<Table v-else />
|
|
268
|
+
</template>
|
|
269
|
+
</SelectButton>
|
|
270
|
+
</div>
|
|
271
|
+
</template>
|
|
272
|
+
|
|
273
|
+
<template #list="slotProps">
|
|
274
|
+
<div class="flex flex-col">
|
|
275
|
+
<div v-for="(item, index) in slotProps.items" :key="index">
|
|
276
|
+
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" :class="{ 'border-t border-surface-200 dark:border-surface-700': index !== 0 }">
|
|
277
|
+
<div class="md:w-40 relative">
|
|
278
|
+
<img class="block xl:block mx-auto rounded-border w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
|
|
279
|
+
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute dark:bg-surface-900!" style="left: 4px; top: 4px" />
|
|
280
|
+
</div>
|
|
281
|
+
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
|
|
282
|
+
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
|
|
283
|
+
<div>
|
|
284
|
+
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
|
285
|
+
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
|
|
286
|
+
</div>
|
|
287
|
+
<div class="bg-surface-100 p-1" style="border-radius: 30px">
|
|
288
|
+
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
289
|
+
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
|
290
|
+
<span class="flex text-yellow-500"><StarFill :size="14" /></span>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
<div class="flex flex-col md:items-end gap-8">
|
|
295
|
+
<span class="text-xl font-semibold">\${{ item.price }}</span>
|
|
296
|
+
<div class="flex flex-row-reverse md:flex-row gap-2">
|
|
297
|
+
<Button variant="outlined"><Heart /></Button>
|
|
298
|
+
<Button :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial whitespace-nowrap"><ShoppingCart /> Buy Now</Button>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
304
|
+
</div>
|
|
305
|
+
</template>
|
|
306
|
+
|
|
307
|
+
<template #grid="slotProps">
|
|
308
|
+
<div class="grid grid-cols-12 gap-4">
|
|
309
|
+
<div v-for="(item, index) in slotProps.items" :key="index" class="col-span-12 sm:col-span-6 md:col-span-4 xl:col-span-6 p-2">
|
|
310
|
+
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded flex flex-col">
|
|
311
|
+
<div class="bg-surface-50 flex justify-center rounded p-4">
|
|
312
|
+
<div class="relative mx-auto">
|
|
313
|
+
<img class="rounded w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" style="max-width: 300px"/>
|
|
314
|
+
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute dark:bg-surface-900!" style="left: 4px; top: 4px" />
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
<div class="pt-6">
|
|
318
|
+
<div class="flex flex-row justify-between items-start gap-2">
|
|
319
|
+
<div>
|
|
320
|
+
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
|
321
|
+
<div class="text-lg font-medium mt-1">{{ item.name }}</div>
|
|
322
|
+
</div>
|
|
323
|
+
<div class="bg-surface-100 p-1" style="border-radius: 30px">
|
|
324
|
+
<div class="bg-surface-0 flex items-center gap-2 justify-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
325
|
+
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
|
326
|
+
<span class="flex text-yellow-500"><StarFill :size="14" /></span>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
<div class="flex flex-col gap-6 mt-6">
|
|
331
|
+
<span class="text-2xl font-semibold">\${{ item.price }}</span>
|
|
332
|
+
<div class="flex gap-2">
|
|
333
|
+
<Button :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto whitespace-nowrap"><ShoppingCart /> Buy Now</Button>
|
|
334
|
+
<Button variant="outlined"><Heart /></Button>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
</template>
|
|
342
|
+
</DataView>
|
|
343
|
+
</div>
|
|
344
|
+
</template>
|
|
345
|
+
|
|
346
|
+
<script setup>
|
|
347
|
+
import { ref, onMounted } from "vue";
|
|
348
|
+
import { ProductService } from '@/service/ProductService';
|
|
349
|
+
import Bars from '@primeicons/vue/bars';
|
|
350
|
+
import Heart from '@primeicons/vue/heart';
|
|
351
|
+
import ShoppingCart from '@primeicons/vue/shopping-cart';
|
|
352
|
+
import StarFill from '@primeicons/vue/star-fill';
|
|
353
|
+
import Table from '@primeicons/vue/table';
|
|
354
|
+
|
|
355
|
+
onMounted(() => {
|
|
356
|
+
ProductService.getProducts().then((data) => (products.value = data.slice(0, 12)));
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
const products = ref();
|
|
360
|
+
const layout = ref('grid');
|
|
361
|
+
const options = ref(['list', 'grid']);
|
|
362
|
+
|
|
363
|
+
const getSeverity = (product) => {
|
|
364
|
+
switch (product.inventoryStatus) {
|
|
365
|
+
case 'INSTOCK':
|
|
366
|
+
return 'success';
|
|
367
|
+
|
|
368
|
+
case 'LOWSTOCK':
|
|
369
|
+
return 'warn';
|
|
370
|
+
|
|
371
|
+
case 'OUTOFSTOCK':
|
|
372
|
+
return 'danger';
|
|
373
|
+
|
|
374
|
+
default:
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
<\/script>
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Loading
|
|
383
|
+
|
|
384
|
+
While data is being loaded, Skeleton component may be used to indicate the busy state.
|
|
385
|
+
|
|
386
|
+
```vue
|
|
387
|
+
<template>
|
|
388
|
+
<div>
|
|
389
|
+
<DataView :value="products" :layout="layout">
|
|
390
|
+
<template #header>
|
|
391
|
+
<div class="flex justify-end">
|
|
392
|
+
<SelectButton v-model="layout" :options="options" :allowEmpty="false">
|
|
393
|
+
<template #option="{ option }">
|
|
394
|
+
<Bars v-if="option === 'list'" />
|
|
395
|
+
<Table v-else />
|
|
396
|
+
</template>
|
|
397
|
+
</SelectButton>
|
|
398
|
+
</div>
|
|
399
|
+
</template>
|
|
400
|
+
|
|
401
|
+
<template #list>
|
|
402
|
+
<div class="flex flex-col">
|
|
403
|
+
<div v-for="i in 6" :key="i">
|
|
404
|
+
<div class="flex flex-col xl:flex-row xl:items-start p-6 gap-6" :class="{ 'border-t border-surface-200 dark:border-surface-700': i !== 1 }">
|
|
405
|
+
<Skeleton class="w-9/12! sm:w-64! xl:w-40! h-24! mx-auto" />
|
|
406
|
+
<div class="flex flex-col sm:flex-row justify-between items-center xl:items-start flex-1 gap-6">
|
|
407
|
+
<div class="flex flex-col items-center sm:items-start gap-4">
|
|
408
|
+
<Skeleton width="8rem" height="2rem" />
|
|
409
|
+
<Skeleton width="6rem" height="1rem" />
|
|
410
|
+
|
|
411
|
+
<div class="flex items-center gap-4">
|
|
412
|
+
<Skeleton width="6rem" height="1rem" />
|
|
413
|
+
<Skeleton width="3rem" height="1rem" />
|
|
414
|
+
</div>
|
|
415
|
+
</div>
|
|
416
|
+
<div class="flex sm:flex-col items-center sm:items-end gap-4 sm:gap-2">
|
|
417
|
+
<Skeleton width="4rem" height="2rem" />
|
|
418
|
+
<Skeleton size="3rem" shape="circle" />
|
|
419
|
+
</div>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
</div>
|
|
423
|
+
</div>
|
|
424
|
+
</template>
|
|
425
|
+
|
|
426
|
+
<template #grid>
|
|
427
|
+
<div class="grid grid-cols-12 gap-4">
|
|
428
|
+
<div v-for="i in 6" :key="i" class="col-span-12 sm:col-span-6 xl:col-span-4 p-2">
|
|
429
|
+
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded">
|
|
430
|
+
<div class="flex flex-wrap items-center justify-between gap-2">
|
|
431
|
+
<Skeleton width="6rem" height="2rem" />
|
|
432
|
+
<Skeleton width="3rem" height="1rem" />
|
|
433
|
+
</div>
|
|
434
|
+
<div class="flex flex-col items-center gap-4 py-8">
|
|
435
|
+
<Skeleton width="75%" height="10rem" />
|
|
436
|
+
<Skeleton width="8rem" height="2rem" />
|
|
437
|
+
<Skeleton width="6rem" height="1rem" />
|
|
438
|
+
</div>
|
|
439
|
+
<div class="flex items-center justify-between">
|
|
440
|
+
<Skeleton width="4rem" height="2rem" />
|
|
441
|
+
<Skeleton width="6rem" height="1rem" shape="circle" size="3rem" />
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
</template>
|
|
447
|
+
</DataView>
|
|
448
|
+
</div>
|
|
449
|
+
</template>
|
|
450
|
+
|
|
451
|
+
<script setup>
|
|
452
|
+
import { ref, onMounted } from "vue";
|
|
453
|
+
import { ProductService } from '@/service/ProductService';
|
|
454
|
+
import Bars from '@primeicons/vue/bars';
|
|
455
|
+
import Table from '@primeicons/vue/table';
|
|
456
|
+
|
|
457
|
+
onMounted(() => {
|
|
458
|
+
ProductService.getProductsSmall().then((data) => (products.value = data.slice(0, 6)));
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
const products = ref();
|
|
462
|
+
const layout = ref('grid');
|
|
463
|
+
const options = ref(['list', 'grid']);
|
|
464
|
+
|
|
465
|
+
const getSeverity = (product) => {
|
|
466
|
+
switch (product.inventoryStatus) {
|
|
467
|
+
case 'INSTOCK':
|
|
468
|
+
return 'success';
|
|
469
|
+
|
|
470
|
+
case 'LOWSTOCK':
|
|
471
|
+
return 'warn';
|
|
472
|
+
|
|
473
|
+
case 'OUTOFSTOCK':
|
|
474
|
+
return 'danger';
|
|
475
|
+
|
|
476
|
+
default:
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
<\/script>
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
## Accessibility
|
|
485
|
+
|
|
486
|
+
Screen Reader The container element that wraps the layout options buttons has a group role whereas each button element uses button role and aria-pressed is updated depending on selection state. Values to describe the buttons are derived from the aria.listView and aria.gridView properties of the locale API respectively. Refer to paginator accessibility documentation for the paginator of the component. Keyboard Support Key Function tab Moves focus to the buttons. space Toggles the checked state of a button.
|
|
487
|
+
|
|
488
|
+
## Data View API
|
|
489
|
+
|
|
490
|
+
### Props
|
|
491
|
+
|
|
492
|
+
| Name |Type |Default |Description |
|
|
493
|
+
| --- | --- | --- | --- |
|
|
494
|
+
| value | null \| T[] | - | An array of objects to display. |
|
|
495
|
+
| layout | HintedString<"list" \| "grid"> | list | Layout of the items, valid values are 'list' and 'grid'. |
|
|
496
|
+
| rows | number | 0 | Number of rows to display per page. |
|
|
497
|
+
| first | number | 0 | Index of the first record to render. |
|
|
498
|
+
| totalRecords | number | - | Number of total records, defaults to length of value when not defined. |
|
|
499
|
+
| paginator | boolean | false | When specified as true, enables the pagination. |
|
|
500
|
+
| paginatorPosition | HintedString<"top" \| "bottom" \| "both"> | bottom | Position of the paginator, options are 'top','bottom' or 'both'. |
|
|
501
|
+
| alwaysShowPaginator | boolean | true | Whether to show it even there is only one page. |
|
|
502
|
+
| paginatorTemplate | string | FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown | Template of the paginator. It can be customized using the template property using the predefined keys, - FirstPageLink - PrevPageLink - PageLinks - NextPageLink - LastPageLink - RowsPerPageDropdown - JumpToPageDropdown - JumpToPageInput - CurrentPageReport |
|
|
503
|
+
| pageLinkSize | number | 5 | Number of page links to display. |
|
|
504
|
+
| rowsPerPageOptions | number[] | - | Array of integer values to display inside rows per page dropdown. |
|
|
505
|
+
| currentPageReportTemplate | string | '({currentPage} of {totalPages})' | Template of the current page report element. It displays information about the pagination state. - {currentPage} - {totalPages} - {rows} - {first} - {last} - {totalRecords} |
|
|
506
|
+
| sortField | null \| string \| Function | - | Property name or a getter function of data to use in sorting by default. |
|
|
507
|
+
| sortOrder | null \| number | - | Order to sort the data by default. |
|
|
508
|
+
| lazy | boolean | false | Defines if data is loaded and interacted with in lazy manner. |
|
|
509
|
+
| dataKey | string | - | Name of the data that uniquely identifies the a record in the data. |
|
|
510
|
+
| dt | any | - | It generates scoped CSS variables using design tokens for the component. |
|
|
511
|
+
| pt | PassThrough<DataViewPassThroughOptions> | - | Used to pass attributes to DOM elements inside the component. |
|
|
512
|
+
| ptOptions | any | - | Used to configure passthrough(pt) options of the component. |
|
|
513
|
+
| unstyled | boolean | false | When enabled, it removes component related styles in the core. |
|
|
514
|
+
|
|
515
|
+
### Pass Through Options
|
|
516
|
+
|
|
517
|
+
| Name |Type |Description |
|
|
518
|
+
| --- | --- | --- |
|
|
519
|
+
| root | DataViewPassThroughOptionType | Used to pass attributes to the root's DOM element. |
|
|
520
|
+
| header | DataViewPassThroughOptionType | Used to pass attributes to the header's DOM element. |
|
|
521
|
+
| pcPaginator | any | Used to pass attributes to the Paginator component. |
|
|
522
|
+
| content | DataViewPassThroughOptionType | Used to pass attributes to the content's DOM element. |
|
|
523
|
+
| emptyMessage | DataViewPassThroughOptionType | Used to pass attributes to the empty message's DOM element. |
|
|
524
|
+
| footer | DataViewPassThroughOptionType | Used to pass attributes to the footer's DOM element. |
|
|
525
|
+
| hooks | any | Used to manage all lifecycle hooks. |
|
|
526
|
+
|
|
527
|
+
### Theming
|
|
528
|
+
|
|
529
|
+
### CSS Classes
|
|
530
|
+
|
|
531
|
+
| Class |Description |
|
|
532
|
+
| --- | --- |
|
|
533
|
+
| p-dataview | Class name of the root element |
|
|
534
|
+
| p-dataview-header | Class name of the header element |
|
|
535
|
+
| p-dataview-paginator-[position] | Class name of the paginator element |
|
|
536
|
+
| p-dataview-content | Class name of the content element |
|
|
537
|
+
| p-dataview-empty-message | Class name of the empty message element |
|
|
538
|
+
| p-dataview-footer | Class name of the footer element |
|
|
539
|
+
|
|
540
|
+
### Design Tokens
|
|
541
|
+
|
|
542
|
+
| Token |CSS Variable |Description |
|
|
543
|
+
| --- | --- | --- |
|
|
544
|
+
| dataview.border.color | --p-dataview-border-color | Border color of root |
|
|
545
|
+
| dataview.border.width | --p-dataview-border-width | Border width of root |
|
|
546
|
+
| dataview.border.radius | --p-dataview-border-radius | Border radius of root |
|
|
547
|
+
| dataview.padding | --p-dataview-padding | Padding of root |
|
|
548
|
+
| dataview.header.background | --p-dataview-header-background | Background of header |
|
|
549
|
+
| dataview.header.color | --p-dataview-header-color | Color of header |
|
|
550
|
+
| dataview.header.border.color | --p-dataview-header-border-color | Border color of header |
|
|
551
|
+
| dataview.header.border.width | --p-dataview-header-border-width | Border width of header |
|
|
552
|
+
| dataview.header.padding | --p-dataview-header-padding | Padding of header |
|
|
553
|
+
| dataview.header.border.radius | --p-dataview-header-border-radius | Border radius of header |
|
|
554
|
+
| dataview.content.background | --p-dataview-content-background | Background of content |
|
|
555
|
+
| dataview.content.color | --p-dataview-content-color | Color of content |
|
|
556
|
+
| dataview.content.border.color | --p-dataview-content-border-color | Border color of content |
|
|
557
|
+
| dataview.content.border.width | --p-dataview-content-border-width | Border width of content |
|
|
558
|
+
| dataview.content.padding | --p-dataview-content-padding | Padding of content |
|
|
559
|
+
| dataview.content.border.radius | --p-dataview-content-border-radius | Border radius of content |
|
|
560
|
+
| dataview.footer.background | --p-dataview-footer-background | Background of footer |
|
|
561
|
+
| dataview.footer.color | --p-dataview-footer-color | Color of footer |
|
|
562
|
+
| dataview.footer.border.color | --p-dataview-footer-border-color | Border color of footer |
|
|
563
|
+
| dataview.footer.border.width | --p-dataview-footer-border-width | Border width of footer |
|
|
564
|
+
| dataview.footer.padding | --p-dataview-footer-padding | Padding of footer |
|
|
565
|
+
| dataview.footer.border.radius | --p-dataview-footer-border-radius | Border radius of footer |
|
|
566
|
+
| dataview.paginator.top.border.color | --p-dataview-paginator-top-border-color | Border color of paginator top |
|
|
567
|
+
| dataview.paginator.top.border.width | --p-dataview-paginator-top-border-width | Border width of paginator top |
|
|
568
|
+
| dataview.paginator.bottom.border.color | --p-dataview-paginator-bottom-border-color | Border color of paginator bottom |
|
|
569
|
+
| dataview.paginator.bottom.border.width | --p-dataview-paginator-bottom-border-width | Border width of paginator bottom |
|