22 <v-col cols =" 12" >
33 <v-card elevation =" 5" >
44 <v-data-table
5+ :key =" tableOptions.tableKey"
56 density =" default"
67 :headers =" headers"
78 :items =" posts"
1718 :cancel-icon =" componentOptions.cancelIcon"
1819 :cancel-icon-color =" componentOptions.cancelIconColor"
1920 :cancel-icon-text =" componentOptions.cancelIconText"
20- :card-field =" componentOptions.cardField "
21+ :card-field =" cardFieldState "
2122 :card-offset-x =" componentOptions.cardOffsetX"
2223 :card-offset-y =" componentOptions.cardOffsetY"
2324 :card-props =" componentOptions.cardProps"
5152 :cancel-button-title =" componentOptions.cancelButtonTitle"
5253 :cancel-button-variant =" componentOptions.cancelButtonVariant"
5354 :cancel-icon-color =" componentOptions.cancelIconColor"
54- :card-field =" componentOptions.cardField "
55+ :card-field =" cardFieldState "
5556 :card-offset-x =" componentOptions.cardOffsetX"
5657 :card-offset-y =" componentOptions.cardOffsetY"
5758 :card-props =" componentOptions.cardProps"
9697 <template #[` item.title ` ]=" { item } " >
9798 <VInlineTextField
9899 v-model =" item.raw.title"
99- :append-icon =" componentOptions.appendIcon"
100- :append-inner-icon =" componentOptions.appendIcon"
101100 :cancel-button-color =" componentOptions.cancelButtonColor"
102101 :cancel-button-title =" componentOptions.cancelButtonTitle"
103102 :cancel-button-variant =" componentOptions.cancelButtonVariant"
104103 :cancel-icon-color =" componentOptions.cancelIconColor"
105- :card-field =" componentOptions.cardField "
104+ :card-field =" cardFieldState "
106105 :card-offset-x =" componentOptions.cardOffsetX"
107106 :card-offset-y =" componentOptions.cardOffsetY"
108107 :card-props =" componentOptions.cardProps"
111110 :color =" componentOptions.color"
112111 :density =" componentOptions.density"
113112 :disabled =" componentOptions.disabled"
114- :display-append-icon =" componentOptions.displayAppendIcon"
115- :display-append-icon-color =" componentOptions.displayAppendIconColor"
116- :display-append-inner-icon =" componentOptions.displayAppendInnerIcon"
117- :display-append-inner-icon-color =" componentOptions.displayAppendInnerIconColor"
118- :display-prepend-icon =" componentOptions.displayPrependIcon"
119- :display-prepend-iconColor =" componentOptions.displayPrependIconColor"
120- :display-prepend-inner-icon =" componentOptions.displayPrependInnerIcon"
121- :display-prepend-inner-icon-color =" componentOptions.displayPrependInnerIconColor"
122113 :field-only =" componentOptions.fieldOnly"
123114 :hide-details =" componentOptions.hideDetails"
124115 :item =" item"
125116 :label =" componentOptions.label"
126117 :loading =" item.raw.loading"
127118 :loading-wait =" componentOptions.loadingWait"
128119 name =" title"
129- :prepend-icon =" componentOptions.appendIcon"
130- :prepend-inner-icon =" componentOptions.appendIcon"
131120 required
132121 :rules =" [componentOptions.rules.required, componentOptions.rules.minLength]"
133122 :save-button-color =" componentOptions.saveButtonColor"
144133 @error =" showError = $event"
145134 @update =" updatedValue(item.raw, 'title')"
146135 >
147- <template #[` display-append-icon ` ]>foo</template >
148136 </VInlineTextField >
149137 </template >
150138
155143 :cancel-button-title =" componentOptions.cancelButtonTitle"
156144 :cancel-button-variant =" componentOptions.cancelButtonVariant"
157145 :cancel-icon-color =" componentOptions.cancelIconColor"
158- :card-field =" componentOptions.cardField "
146+ :card-field =" cardFieldState "
159147 :card-offset-x =" componentOptions.cardOffsetX"
160148 :card-offset-y =" componentOptions.cardOffsetY"
161149 :card-props =" componentOptions.cardProps"
187175 :variant =" componentOptions.variant"
188176 @error =" showError = $event"
189177 @update =" updatedValue(item.raw, 'body')"
190- />
178+ >
179+ </VInlineTextarea >
191180 </template >
192181
193182 <template #[` item.range ` ]=" { item } " >
194183 <VInlineCustomField
195184 v-model =" item.raw.range"
196- :card-field =" componentOptions.cardField "
185+ :card-field =" cardFieldState "
197186 :card-offset-x =" componentOptions.cardOffsetX"
198187 :card-offset-y =" componentOptions.cardOffsetY"
199188 :card-props =" componentOptions.cardProps"
218207 :cancel-button-title =" componentOptions.cancelButtonTitle"
219208 :cancel-button-variant =" componentOptions.cancelButtonVariant"
220209 :cancel-icon-color =" componentOptions.cancelIconColor"
221- :card-field =" componentOptions.cardField "
210+ :card-field =" cardFieldState "
222211 :card-offset-x =" componentOptions.cardOffsetX"
223212 :card-offset-y =" componentOptions.cardOffsetY"
224213 :card-props =" componentOptions.cardProps"
245234 </v-data-table >
246235 </v-card >
247236 </v-col >
237+
238+ <v-col
239+ class =" mb-4"
240+ cols =" 12"
241+ >
242+ <v-switch
243+ v-model =" isCardField"
244+ class =" ms-2 align-center d-flex"
245+ color =" primary"
246+ density =" compact"
247+ >
248+ <template #label >
249+ <div class =" switch-label" >
250+ <div
251+ class =" d-inline"
252+ :class =" !isCardField ? 'text-primary' : ''"
253+ >Inline</div >
254+ /
255+ <div
256+ class =" d-inline"
257+ :class =" isCardField ? 'text-primary' : ''"
258+ >Card</div > Field
259+ </div >
260+ </template >
261+ </v-switch >
262+ </v-col >
248263</template >
249264
250265
251266<script setup>
252267// ? Components are already loaded via the configs/playground.ts file //
253-
254268onMounted (() => {
255269 getPosts ();
256270});
@@ -262,24 +276,29 @@ onBeforeMount(() => {
262276const tableOptions = reactive ({
263277 itemsPerPage: 10 ,
264278 sortBy: [{ key: ' title' , order: ' asc' }],
279+ tableKey: new Date ().getUTCMilliseconds (),
265280});
266281
282+
283+ // ? Changes the type of field the table uses //
284+ const isCardField = ref (false );
285+ const cardFieldState = computed (() => isCardField .value );
286+
287+ watch (() => isCardField .value , () => {
288+ tableOptions .tableKey = new Date ().getUTCMilliseconds ();
289+ });
290+
291+
292+ // ? Use these options to play around with the component props //
267293const componentOptions = reactive ({
268- // appendIcon: 'mdi:mdi-cog',
269294 cancelButtonColor: ' default' ,
270295 cancelButtonTitle: ' Cancel' ,
271296 cancelButtonVariant: ' text' ,
272297 cancelIcon: undefined ,
273298 cancelIconColor: ' default' ,
274- cardField: false ,
275299 cardOffsetX: 0 ,
276300 cardOffsetY: 0 ,
277- cardProps: {
278- // color: 'primary',
279- // elevation: 5,
280- // variant: 'flat',
281- width: undefined ,
282- },
301+ cardProps: {},
283302 clearable: false ,
284303 closeSiblings: true ,
285304 color: ' primary' ,
@@ -371,6 +390,23 @@ const headers = [
371390 },
372391];
373392
393+
394+ /**
395+ * ? This is where you would save the item in the database.
396+ * @param {object} item The item being updated.
397+ * @param {string} field The field being updated.
398+ */
399+ function updatedValue (item ) {
400+ item .loading = true ;
401+
402+ // ? Simulate a delay while item is saving.
403+ setTimeout (() => {
404+ item .loading = false ;
405+ }, 1500 );
406+ }
407+
408+
409+ // ? Data loading section. You can ignore this part. //
374410let posts = ref ();
375411const users = ref (null );
376412const showError = ref (false );
@@ -398,26 +434,14 @@ function getUsers() {
398434 }));
399435 });
400436};
401-
402-
403- /**
404- * ? This is where you would save the item in the database.
405- * @param {object} item The item being updated.
406- * @param {string} field The field being updated.
407- */
408- function updatedValue (item , field ) {
409- console .log (' PlaygroundPage.vue: updatedValue' , field, item);
410- item .loading = true ;
411-
412- // ? Simulate a delay while item is saving.
413- setTimeout (() => {
414- item .loading = false ;
415- }, 1500 );
416- }
417437< / script>
418438
419439< style lang= " scss" scoped>
420440: deep (.v - data - table__td ) {
421441 align- items: center;
422442}
443+
444+ : deep (.v - label ) {
445+ opacity: 1 ;
446+ }
423447< / style>
0 commit comments